xref: /freebsd/sys/dev/nfe/if_nfevar.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
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 
19 struct nfe_tx_data {
20 	bus_dmamap_t	tx_data_map;
21 	struct mbuf	*m;
22 };
23 
24 struct nfe_tx_ring {
25 	bus_dma_tag_t		tx_desc_tag;
26 	bus_dmamap_t		tx_desc_map;
27 	bus_addr_t		physaddr;
28 	struct nfe_desc32	*desc32;
29 	struct nfe_desc64	*desc64;
30 	bus_dma_tag_t		tx_data_tag;
31 	struct nfe_tx_data	data[NFE_TX_RING_COUNT];
32 	int			queued;
33 	int			cur;
34 	int			next;
35 };
36 
37 struct nfe_rx_data {
38 	bus_dmamap_t	rx_data_map;
39 	bus_addr_t	paddr;
40 	struct mbuf	*m;
41 };
42 
43 struct nfe_rx_ring {
44 	bus_dma_tag_t		rx_desc_tag;
45 	bus_dmamap_t		rx_desc_map;
46 	bus_addr_t		physaddr;
47 	struct nfe_desc32	*desc32;
48 	struct nfe_desc64	*desc64;
49 	bus_dma_tag_t		rx_data_tag;
50 	bus_dmamap_t		rx_spare_map;
51 	struct nfe_rx_data	data[NFE_RX_RING_COUNT];
52 	int			cur;
53 	int			next;
54 };
55 
56 struct nfe_jrx_ring {
57 	bus_dma_tag_t		jrx_desc_tag;
58 	bus_dmamap_t		jrx_desc_map;
59 	bus_dma_tag_t		jrx_jumbo_tag;
60 	bus_dmamap_t		jrx_jumbo_map;
61 	bus_addr_t		jphysaddr;
62 	struct nfe_desc32	*jdesc32;
63 	struct nfe_desc64	*jdesc64;
64 	bus_dma_tag_t		jrx_data_tag;
65 	bus_dmamap_t		jrx_spare_map;
66 	struct nfe_rx_data	jdata[NFE_JUMBO_RX_RING_COUNT];
67 	int			jcur;
68 	int			jnext;
69 };
70 
71 struct nfe_hw_stats {
72 	uint64_t		rx_octets;
73 	uint32_t		rx_frame_errors;
74 	uint32_t		rx_extra_bytes;
75 	uint32_t		rx_late_cols;
76 	uint32_t		rx_runts;
77 	uint32_t		rx_jumbos;
78 	uint32_t		rx_fifo_overuns;
79 	uint32_t		rx_crc_errors;
80 	uint32_t		rx_fae;
81 	uint32_t		rx_len_errors;
82 	uint32_t		rx_unicast;
83 	uint32_t		rx_multicast;
84 	uint32_t		rx_broadcast;
85 	uint32_t		rx_pause;
86 	uint32_t		rx_drops;
87 	uint64_t		tx_octets;
88 	uint32_t		tx_zero_rexmits;
89 	uint32_t		tx_one_rexmits;
90 	uint32_t		tx_multi_rexmits;
91 	uint32_t		tx_late_cols;
92 	uint32_t		tx_fifo_underuns;
93 	uint32_t		tx_carrier_losts;
94 	uint32_t		tx_excess_deferals;
95 	uint32_t		tx_retry_errors;
96 	uint32_t		tx_deferals;
97 	uint32_t		tx_frames;
98 	uint32_t		tx_pause;
99 	uint32_t		tx_unicast;
100 	uint32_t		tx_multicast;
101 	uint32_t		tx_broadcast;
102 };
103 
104 struct nfe_softc {
105 	if_t			nfe_ifp;
106 	device_t		nfe_dev;
107 	uint16_t		nfe_devid;
108 	uint16_t		nfe_revid;
109 	device_t		nfe_miibus;
110 	struct mtx		nfe_mtx;
111 	struct resource		*nfe_res[1];
112 	struct resource		*nfe_msix_res;
113 	struct resource		*nfe_msix_pba_res;
114 	struct resource		*nfe_irq[NFE_MSI_MESSAGES];
115 	void			*nfe_intrhand[NFE_MSI_MESSAGES];
116 	struct callout		nfe_stat_ch;
117 	int			nfe_watchdog_timer;
118 
119 	bus_dma_tag_t		nfe_parent_tag;
120 
121 	int			nfe_if_flags;
122 	uint32_t		nfe_flags;
123 #define	NFE_JUMBO_SUP		0x0001
124 #define	NFE_40BIT_ADDR		0x0002
125 #define	NFE_HW_CSUM		0x0004
126 #define	NFE_HW_VLAN		0x0008
127 #define	NFE_PWR_MGMT		0x0010
128 #define	NFE_CORRECT_MACADDR	0x0020
129 #define	NFE_TX_FLOW_CTRL	0x0040
130 #define	NFE_MIB_V1		0x0080
131 #define	NFE_MIB_V2		0x0100
132 #define	NFE_MIB_V3		0x0200
133 	int			nfe_jumbo_disable;
134 	uint32_t		rxtxctl;
135 	uint8_t			mii_phyaddr;
136 	uint8_t			eaddr[ETHER_ADDR_LEN];
137 	struct nfe_hw_stats	nfe_stats;
138 	struct taskqueue	*nfe_tq;
139 	struct task		nfe_int_task;
140 	int			nfe_link;
141 	int			nfe_suspended;
142 	int			nfe_framesize;
143 	int			nfe_process_limit;
144 	int			nfe_force_tx;
145 	uint32_t		nfe_irq_status;
146 	uint32_t		nfe_irq_mask;
147 	uint32_t		nfe_intrs;
148 	uint32_t		nfe_nointrs;
149 	uint32_t		nfe_msi;
150 	uint32_t		nfe_msix;
151 
152 	struct nfe_tx_ring	txq;
153 	struct nfe_rx_ring	rxq;
154 	struct nfe_jrx_ring	jrxq;
155 };
156 
157 struct nfe_type {
158 	uint16_t	vid_id;
159 	uint16_t	dev_id;
160 	char		*name;
161 };
162