xref: /freebsd/sys/dev/nfe/if_nfevar.h (revision db612abe8df3355d1eb23bb3b50fdd97bc21e979)
1 /*	$OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $	*/
2 
3 /*-
4  * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * $FreeBSD$
19  */
20 
21 struct nfe_tx_data {
22 	bus_dmamap_t	tx_data_map;
23 	struct mbuf	*m;
24 };
25 
26 struct nfe_tx_ring {
27 	bus_dma_tag_t		tx_desc_tag;
28 	bus_dmamap_t		tx_desc_map;
29 	bus_addr_t		physaddr;
30 	struct nfe_desc32	*desc32;
31 	struct nfe_desc64	*desc64;
32 	bus_dma_tag_t		tx_data_tag;
33 	struct nfe_tx_data	data[NFE_TX_RING_COUNT];
34 	int			queued;
35 	int			cur;
36 	int			next;
37 };
38 
39 struct nfe_rx_data {
40 	bus_dmamap_t	rx_data_map;
41 	bus_addr_t	paddr;
42 	struct mbuf	*m;
43 };
44 
45 struct nfe_rx_ring {
46 	bus_dma_tag_t		rx_desc_tag;
47 	bus_dmamap_t		rx_desc_map;
48 	bus_addr_t		physaddr;
49 	struct nfe_desc32	*desc32;
50 	struct nfe_desc64	*desc64;
51 	bus_dma_tag_t		rx_data_tag;
52 	bus_dmamap_t		rx_spare_map;
53 	struct nfe_rx_data	data[NFE_RX_RING_COUNT];
54 	int			cur;
55 	int			next;
56 };
57 
58 struct nfe_jrx_ring {
59 	bus_dma_tag_t		jrx_desc_tag;
60 	bus_dmamap_t		jrx_desc_map;
61 	bus_dma_tag_t		jrx_jumbo_tag;
62 	bus_dmamap_t		jrx_jumbo_map;
63 	bus_addr_t		jphysaddr;
64 	struct nfe_desc32	*jdesc32;
65 	struct nfe_desc64	*jdesc64;
66 	bus_dma_tag_t		jrx_data_tag;
67 	bus_dmamap_t		jrx_spare_map;
68 	struct nfe_rx_data	jdata[NFE_JUMBO_RX_RING_COUNT];
69 	int			jcur;
70 	int			jnext;
71 };
72 
73 struct nfe_softc {
74 	struct ifnet		*nfe_ifp;
75 	device_t		nfe_dev;
76 	uint16_t		nfe_devid;
77 	uint16_t		nfe_revid;
78 	device_t		nfe_miibus;
79 	struct mtx		nfe_mtx;
80 	struct resource		*nfe_res[1];
81 	struct resource		*nfe_msix_res;
82 	struct resource		*nfe_msix_pba_res;
83 	struct resource		*nfe_irq[NFE_MSI_MESSAGES];
84 	void			*nfe_intrhand[NFE_MSI_MESSAGES];
85 	struct callout		nfe_stat_ch;
86 	int			nfe_watchdog_timer;
87 
88 	bus_dma_tag_t		nfe_parent_tag;
89 
90 	int			nfe_if_flags;
91 	uint32_t		nfe_flags;
92 #define	NFE_JUMBO_SUP		0x0001
93 #define	NFE_40BIT_ADDR		0x0002
94 #define	NFE_HW_CSUM		0x0004
95 #define	NFE_HW_VLAN		0x0008
96 #define	NFE_PWR_MGMT		0x0010
97 #define	NFE_CORRECT_MACADDR	0x0020
98 #define	NFE_TX_FLOW_CTRL	0x0040
99 	int			nfe_jumbo_disable;
100 	uint32_t		rxtxctl;
101 	uint8_t			mii_phyaddr;
102 	uint8_t			eaddr[ETHER_ADDR_LEN];
103 	struct taskqueue	*nfe_tq;
104 	struct task		nfe_int_task;
105 	struct task		nfe_tx_task;
106 	struct task		nfe_link_task;
107 	int			nfe_link;
108 	int			nfe_suspended;
109 	int			nfe_framesize;
110 	int			nfe_process_limit;
111 	int			nfe_force_tx;
112 	uint32_t		nfe_irq_status;
113 	uint32_t		nfe_irq_mask;
114 	uint32_t		nfe_intrs;
115 	uint32_t		nfe_nointrs;
116 	uint32_t		nfe_msi;
117 	uint32_t		nfe_msix;
118 
119 	struct nfe_tx_ring	txq;
120 	struct nfe_rx_ring	rxq;
121 	struct nfe_jrx_ring	jrxq;
122 };
123 
124 struct nfe_type {
125 	uint16_t	vid_id;
126 	uint16_t	dev_id;
127 	char		*name;
128 };
129