ixgbe.h revision 1.1.12.1 1 1.1.12.1 jdolecek /* $NetBSD: ixgbe.h,v 1.1.12.1 2017/12/03 11:37:29 jdolecek Exp $ */
2 1.1.12.1 jdolecek
3 1.1 dyoung /******************************************************************************
4 1.1 dyoung
5 1.1.12.1 jdolecek Copyright (c) 2001-2017, Intel Corporation
6 1.1 dyoung All rights reserved.
7 1.1.12.1 jdolecek
8 1.1.12.1 jdolecek Redistribution and use in source and binary forms, with or without
9 1.1 dyoung modification, are permitted provided that the following conditions are met:
10 1.1.12.1 jdolecek
11 1.1.12.1 jdolecek 1. Redistributions of source code must retain the above copyright notice,
12 1.1 dyoung this list of conditions and the following disclaimer.
13 1.1.12.1 jdolecek
14 1.1.12.1 jdolecek 2. Redistributions in binary form must reproduce the above copyright
15 1.1.12.1 jdolecek notice, this list of conditions and the following disclaimer in the
16 1.1 dyoung documentation and/or other materials provided with the distribution.
17 1.1.12.1 jdolecek
18 1.1.12.1 jdolecek 3. Neither the name of the Intel Corporation nor the names of its
19 1.1.12.1 jdolecek contributors may be used to endorse or promote products derived from
20 1.1 dyoung this software without specific prior written permission.
21 1.1.12.1 jdolecek
22 1.1 dyoung THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 1.1.12.1 jdolecek AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1.12.1 jdolecek IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1.12.1 jdolecek ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 1.1.12.1 jdolecek LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 1.1.12.1 jdolecek CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 1.1.12.1 jdolecek SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 1.1.12.1 jdolecek INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 1.1.12.1 jdolecek CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 1.1 dyoung ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 dyoung POSSIBILITY OF SUCH DAMAGE.
33 1.1 dyoung
34 1.1 dyoung ******************************************************************************/
35 1.1.12.1 jdolecek /*$FreeBSD: head/sys/dev/ixgbe/ixgbe.h 320688 2017-07-05 17:27:03Z erj $*/
36 1.1.12.1 jdolecek
37 1.1 dyoung /*
38 1.1 dyoung * Copyright (c) 2011 The NetBSD Foundation, Inc.
39 1.1 dyoung * All rights reserved.
40 1.1 dyoung *
41 1.1 dyoung * This code is derived from software contributed to The NetBSD Foundation
42 1.1 dyoung * by Coyote Point Systems, Inc.
43 1.1 dyoung *
44 1.1 dyoung * Redistribution and use in source and binary forms, with or without
45 1.1 dyoung * modification, are permitted provided that the following conditions
46 1.1 dyoung * are met:
47 1.1 dyoung * 1. Redistributions of source code must retain the above copyright
48 1.1 dyoung * notice, this list of conditions and the following disclaimer.
49 1.1 dyoung * 2. Redistributions in binary form must reproduce the above copyright
50 1.1 dyoung * notice, this list of conditions and the following disclaimer in the
51 1.1 dyoung * documentation and/or other materials provided with the distribution.
52 1.1 dyoung *
53 1.1 dyoung * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
54 1.1 dyoung * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
55 1.1 dyoung * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56 1.1 dyoung * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
57 1.1 dyoung * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
58 1.1 dyoung * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
59 1.1 dyoung * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
60 1.1 dyoung * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
61 1.1 dyoung * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62 1.1 dyoung * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
63 1.1 dyoung * POSSIBILITY OF SUCH DAMAGE.
64 1.1 dyoung */
65 1.1 dyoung
66 1.1 dyoung
67 1.1 dyoung #ifndef _IXGBE_H_
68 1.1 dyoung #define _IXGBE_H_
69 1.1 dyoung
70 1.1 dyoung
71 1.1 dyoung #include <sys/param.h>
72 1.1 dyoung #include <sys/reboot.h>
73 1.1 dyoung #include <sys/systm.h>
74 1.1.12.1 jdolecek #include <sys/pcq.h>
75 1.1 dyoung #include <sys/mbuf.h>
76 1.1 dyoung #include <sys/protosw.h>
77 1.1 dyoung #include <sys/socket.h>
78 1.1 dyoung #include <sys/malloc.h>
79 1.1 dyoung #include <sys/kernel.h>
80 1.1 dyoung #include <sys/module.h>
81 1.1 dyoung #include <sys/sockio.h>
82 1.1 dyoung
83 1.1 dyoung #include <net/if.h>
84 1.1 dyoung #include <net/if_arp.h>
85 1.1 dyoung #include <net/bpf.h>
86 1.1 dyoung #include <net/if_ether.h>
87 1.1 dyoung #include <net/if_dl.h>
88 1.1 dyoung #include <net/if_media.h>
89 1.1 dyoung
90 1.1 dyoung #include <net/bpf.h>
91 1.1 dyoung #include <net/if_types.h>
92 1.1 dyoung #include <net/if_vlanvar.h>
93 1.1 dyoung
94 1.1 dyoung #include <netinet/in_systm.h>
95 1.1 dyoung #include <netinet/in.h>
96 1.1 dyoung #include <netinet/ip.h>
97 1.1 dyoung #include <netinet/ip6.h>
98 1.1 dyoung #include <netinet/tcp.h>
99 1.1 dyoung #include <netinet/udp.h>
100 1.1 dyoung
101 1.1 dyoung #include <sys/bus.h>
102 1.1 dyoung #include <dev/pci/pcivar.h>
103 1.1 dyoung #include <dev/pci/pcireg.h>
104 1.1 dyoung #include <sys/proc.h>
105 1.1 dyoung #include <sys/sysctl.h>
106 1.1 dyoung #include <sys/endian.h>
107 1.1 dyoung #include <sys/workqueue.h>
108 1.1.12.1 jdolecek #include <sys/cpu.h>
109 1.1.12.1 jdolecek #include <sys/interrupt.h>
110 1.1.12.1 jdolecek #include <sys/bitops.h>
111 1.1 dyoung
112 1.1 dyoung #include "ixgbe_netbsd.h"
113 1.1 dyoung #include "ixgbe_api.h"
114 1.1.12.1 jdolecek #include "ixgbe_common.h"
115 1.1.12.1 jdolecek #include "ixgbe_phy.h"
116 1.1.12.1 jdolecek #include "ixgbe_vf.h"
117 1.1.12.1 jdolecek #include "ixgbe_features.h"
118 1.1 dyoung
119 1.1 dyoung /* Tunables */
120 1.1 dyoung
121 1.1 dyoung /*
122 1.1 dyoung * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
123 1.1 dyoung * number of transmit descriptors allocated by the driver. Increasing this
124 1.1 dyoung * value allows the driver to queue more transmits. Each descriptor is 16
125 1.1 dyoung * bytes. Performance tests have show the 2K value to be optimal for top
126 1.1 dyoung * performance.
127 1.1 dyoung */
128 1.1 dyoung #define DEFAULT_TXD 1024
129 1.1 dyoung #define PERFORM_TXD 2048
130 1.1 dyoung #define MAX_TXD 4096
131 1.1 dyoung #define MIN_TXD 64
132 1.1 dyoung
133 1.1 dyoung /*
134 1.1 dyoung * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
135 1.1 dyoung * number of receive descriptors allocated for each RX queue. Increasing this
136 1.1 dyoung * value allows the driver to buffer more incoming packets. Each descriptor
137 1.1 dyoung * is 16 bytes. A receive buffer is also allocated for each descriptor.
138 1.1 dyoung *
139 1.1 dyoung * Note: with 8 rings and a dual port card, it is possible to bump up
140 1.1 dyoung * against the system mbuf pool limit, you can tune nmbclusters
141 1.1 dyoung * to adjust for this.
142 1.1 dyoung */
143 1.1 dyoung #define DEFAULT_RXD 1024
144 1.1 dyoung #define PERFORM_RXD 2048
145 1.1 dyoung #define MAX_RXD 4096
146 1.1 dyoung #define MIN_RXD 64
147 1.1 dyoung
148 1.1 dyoung /* Alignment for rings */
149 1.1 dyoung #define DBA_ALIGN 128
150 1.1 dyoung
151 1.1 dyoung /*
152 1.1 dyoung * This is the max watchdog interval, ie. the time that can
153 1.1 dyoung * pass between any two TX clean operations, such only happening
154 1.1 dyoung * when the TX hardware is functioning.
155 1.1 dyoung */
156 1.1.12.1 jdolecek #define IXGBE_WATCHDOG (10 * hz)
157 1.1 dyoung
158 1.1 dyoung /*
159 1.1 dyoung * This parameters control when the driver calls the routine to reclaim
160 1.1 dyoung * transmit descriptors.
161 1.1 dyoung */
162 1.1.12.1 jdolecek #define IXGBE_TX_CLEANUP_THRESHOLD(_a) ((_a)->num_tx_desc / 8)
163 1.1.12.1 jdolecek #define IXGBE_TX_OP_THRESHOLD(_a) ((_a)->num_tx_desc / 32)
164 1.1 dyoung
165 1.1.12.1 jdolecek /* These defines are used in MTU calculations */
166 1.1.12.1 jdolecek #define IXGBE_MAX_FRAME_SIZE 9728
167 1.1.12.1 jdolecek #define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN)
168 1.1.12.1 jdolecek #define IXGBE_MTU_HDR_VLAN (ETHER_HDR_LEN + ETHER_CRC_LEN + \
169 1.1.12.1 jdolecek ETHER_VLAN_ENCAP_LEN)
170 1.1.12.1 jdolecek #define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
171 1.1.12.1 jdolecek #define IXGBE_MAX_MTU_VLAN (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN)
172 1.1 dyoung
173 1.1 dyoung /* Flow control constants */
174 1.1.12.1 jdolecek #define IXGBE_FC_PAUSE 0xFFFF
175 1.1.12.1 jdolecek #define IXGBE_FC_HI 0x20000
176 1.1.12.1 jdolecek #define IXGBE_FC_LO 0x10000
177 1.1.12.1 jdolecek
178 1.1.12.1 jdolecek /*
179 1.1.12.1 jdolecek * Used for optimizing small rx mbufs. Effort is made to keep the copy
180 1.1.12.1 jdolecek * small and aligned for the CPU L1 cache.
181 1.1.12.1 jdolecek *
182 1.1.12.1 jdolecek * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting
183 1.1.12.1 jdolecek * 32 byte alignment needed for the fast bcopy results in 8 bytes being
184 1.1.12.1 jdolecek * wasted. Getting 64 byte alignment, which _should_ be ideal for
185 1.1.12.1 jdolecek * modern Intel CPUs, results in 40 bytes wasted and a significant drop
186 1.1.12.1 jdolecek * in observed efficiency of the optimization, 97.9% -> 81.8%.
187 1.1.12.1 jdolecek */
188 1.1.12.1 jdolecek #define MPKTHSIZE (offsetof(struct _mbuf_dummy, m_pktdat))
189 1.1.12.1 jdolecek #define IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32)
190 1.1.12.1 jdolecek #define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
191 1.1.12.1 jdolecek #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)
192 1.1 dyoung
193 1.1 dyoung /* Keep older OS drivers building... */
194 1.1 dyoung #if !defined(SYSCTL_ADD_UQUAD)
195 1.1 dyoung #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD
196 1.1 dyoung #endif
197 1.1 dyoung
198 1.1 dyoung /* Defines for printing debug information */
199 1.1 dyoung #define DEBUG_INIT 0
200 1.1 dyoung #define DEBUG_IOCTL 0
201 1.1 dyoung #define DEBUG_HW 0
202 1.1 dyoung
203 1.1 dyoung #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n")
204 1.1 dyoung #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A)
205 1.1 dyoung #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B)
206 1.1 dyoung #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n")
207 1.1 dyoung #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A)
208 1.1 dyoung #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B)
209 1.1 dyoung #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n")
210 1.1 dyoung #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A)
211 1.1 dyoung #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B)
212 1.1 dyoung
213 1.1 dyoung #define MAX_NUM_MULTICAST_ADDRESSES 128
214 1.1.12.1 jdolecek #define IXGBE_82598_SCATTER 100
215 1.1.12.1 jdolecek #define IXGBE_82599_SCATTER 32
216 1.1.12.1 jdolecek #define MSIX_82598_BAR 3
217 1.1.12.1 jdolecek #define MSIX_82599_BAR 4
218 1.1.12.1 jdolecek #define IXGBE_TSO_SIZE 262140
219 1.1.12.1 jdolecek #define IXGBE_RX_HDR 128
220 1.1.12.1 jdolecek #define IXGBE_VFTA_SIZE 128
221 1.1.12.1 jdolecek #define IXGBE_BR_SIZE 4096
222 1.1.12.1 jdolecek #define IXGBE_QUEUE_MIN_FREE 32
223 1.1.12.1 jdolecek #define IXGBE_MAX_TX_BUSY 10
224 1.1.12.1 jdolecek #define IXGBE_QUEUE_HUNG 0x80000000
225 1.1.12.1 jdolecek
226 1.1.12.1 jdolecek #define IXGBE_EITR_DEFAULT 128
227 1.1.12.1 jdolecek
228 1.1.12.1 jdolecek /* IOCTL define to gather SFP+ Diagnostic data */
229 1.1.12.1 jdolecek #define SIOCGI2C SIOCGIFGENERIC
230 1.1 dyoung
231 1.1 dyoung /* Offload bits in mbuf flag */
232 1.1 dyoung #define M_CSUM_OFFLOAD \
233 1.1 dyoung (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_UDPv6|M_CSUM_TCPv6)
234 1.1 dyoung
235 1.1.12.1 jdolecek /* Backward compatibility items for very old versions */
236 1.1.12.1 jdolecek #ifndef pci_find_cap
237 1.1.12.1 jdolecek #define pci_find_cap pci_find_extcap
238 1.1.12.1 jdolecek #endif
239 1.1.12.1 jdolecek
240 1.1.12.1 jdolecek #ifndef DEVMETHOD_END
241 1.1.12.1 jdolecek #define DEVMETHOD_END { NULL, NULL }
242 1.1.12.1 jdolecek #endif
243 1.1.12.1 jdolecek
244 1.1 dyoung /*
245 1.1 dyoung * Interrupt Moderation parameters
246 1.1 dyoung */
247 1.1 dyoung #define IXGBE_LOW_LATENCY 128
248 1.1 dyoung #define IXGBE_AVE_LATENCY 400
249 1.1 dyoung #define IXGBE_BULK_LATENCY 1200
250 1.1 dyoung
251 1.1.12.1 jdolecek /* Using 1FF (the max value), the interval is ~1.05ms */
252 1.1.12.1 jdolecek #define IXGBE_LINK_ITR_QUANTA 0x1FF
253 1.1.12.1 jdolecek #define IXGBE_LINK_ITR ((IXGBE_LINK_ITR_QUANTA << 3) & \
254 1.1.12.1 jdolecek IXGBE_EITR_ITR_INT_MASK)
255 1.1.12.1 jdolecek
256 1.1.12.1 jdolecek
257 1.1.12.1 jdolecek
258 1.1.12.1 jdolecek /************************************************************************
259 1.1 dyoung * vendor_info_array
260 1.1.12.1 jdolecek *
261 1.1.12.1 jdolecek * Contains the list of Subvendor/Subdevice IDs on
262 1.1.12.1 jdolecek * which the driver should load.
263 1.1.12.1 jdolecek ************************************************************************/
264 1.1 dyoung typedef struct _ixgbe_vendor_info_t {
265 1.1.12.1 jdolecek unsigned int vendor_id;
266 1.1.12.1 jdolecek unsigned int device_id;
267 1.1.12.1 jdolecek unsigned int subvendor_id;
268 1.1.12.1 jdolecek unsigned int subdevice_id;
269 1.1.12.1 jdolecek unsigned int index;
270 1.1 dyoung } ixgbe_vendor_info_t;
271 1.1 dyoung
272 1.1.12.1 jdolecek /* This is used to get SFP+ module data */
273 1.1.12.1 jdolecek struct ixgbe_i2c_req {
274 1.1.12.1 jdolecek u8 dev_addr;
275 1.1.12.1 jdolecek u8 offset;
276 1.1.12.1 jdolecek u8 len;
277 1.1.12.1 jdolecek u8 data[8];
278 1.1.12.1 jdolecek };
279 1.1.12.1 jdolecek
280 1.1.12.1 jdolecek struct ixgbe_bp_data {
281 1.1.12.1 jdolecek u32 low;
282 1.1.12.1 jdolecek u32 high;
283 1.1.12.1 jdolecek u32 log;
284 1.1.12.1 jdolecek };
285 1.1 dyoung
286 1.1 dyoung struct ixgbe_tx_buf {
287 1.1.12.1 jdolecek union ixgbe_adv_tx_desc *eop;
288 1.1.12.1 jdolecek struct mbuf *m_head;
289 1.1.12.1 jdolecek bus_dmamap_t map;
290 1.1 dyoung };
291 1.1 dyoung
292 1.1 dyoung struct ixgbe_rx_buf {
293 1.1.12.1 jdolecek struct mbuf *buf;
294 1.1.12.1 jdolecek struct mbuf *fmp;
295 1.1.12.1 jdolecek bus_dmamap_t pmap;
296 1.1.12.1 jdolecek u_int flags;
297 1.1.12.1 jdolecek #define IXGBE_RX_COPY 0x01
298 1.1.12.1 jdolecek uint64_t addr;
299 1.1 dyoung };
300 1.1 dyoung
301 1.1 dyoung /*
302 1.1.12.1 jdolecek * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free
303 1.1 dyoung */
304 1.1 dyoung struct ixgbe_dma_alloc {
305 1.1.12.1 jdolecek bus_addr_t dma_paddr;
306 1.1.12.1 jdolecek void *dma_vaddr;
307 1.1.12.1 jdolecek ixgbe_dma_tag_t *dma_tag;
308 1.1.12.1 jdolecek bus_dmamap_t dma_map;
309 1.1.12.1 jdolecek bus_dma_segment_t dma_seg;
310 1.1.12.1 jdolecek bus_size_t dma_size;
311 1.1.12.1 jdolecek };
312 1.1.12.1 jdolecek
313 1.1.12.1 jdolecek struct ixgbe_mc_addr {
314 1.1.12.1 jdolecek u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
315 1.1.12.1 jdolecek u32 vmdq;
316 1.1 dyoung };
317 1.1 dyoung
318 1.1 dyoung /*
319 1.1.12.1 jdolecek * Driver queue struct: this is the interrupt container
320 1.1.12.1 jdolecek * for the associated tx and rx ring.
321 1.1.12.1 jdolecek */
322 1.1 dyoung struct ix_queue {
323 1.1.12.1 jdolecek struct adapter *adapter;
324 1.1.12.1 jdolecek u32 msix; /* This queue's MSI-X vector */
325 1.1.12.1 jdolecek u32 eims; /* This queue's EIMS bit */
326 1.1.12.1 jdolecek u32 eitr_setting;
327 1.1.12.1 jdolecek u32 me;
328 1.1.12.1 jdolecek struct resource *res;
329 1.1.12.1 jdolecek void *tag;
330 1.1.12.1 jdolecek int busy;
331 1.1.12.1 jdolecek struct tx_ring *txr;
332 1.1.12.1 jdolecek struct rx_ring *rxr;
333 1.1.12.1 jdolecek void *que_si;
334 1.1.12.1 jdolecek struct evcnt irqs;
335 1.1.12.1 jdolecek char namebuf[32];
336 1.1.12.1 jdolecek char evnamebuf[32];
337 1.1 dyoung };
338 1.1 dyoung
339 1.1 dyoung /*
340 1.1 dyoung * The transmit ring, one per queue
341 1.1 dyoung */
342 1.1 dyoung struct tx_ring {
343 1.1 dyoung struct adapter *adapter;
344 1.1 dyoung kmutex_t tx_mtx;
345 1.1 dyoung u32 me;
346 1.1.12.1 jdolecek u32 tail;
347 1.1.12.1 jdolecek int busy;
348 1.1 dyoung union ixgbe_adv_tx_desc *tx_base;
349 1.1 dyoung struct ixgbe_tx_buf *tx_buffers;
350 1.1.12.1 jdolecek struct ixgbe_dma_alloc txdma;
351 1.1 dyoung volatile u16 tx_avail;
352 1.1.12.1 jdolecek u16 next_avail_desc;
353 1.1.12.1 jdolecek u16 next_to_clean;
354 1.1.12.1 jdolecek u16 num_desc;
355 1.1 dyoung u32 txd_cmd;
356 1.1 dyoung ixgbe_dma_tag_t *txtag;
357 1.1 dyoung char mtx_name[16];
358 1.1.12.1 jdolecek pcq_t *txr_interq;
359 1.1.12.1 jdolecek void *txr_si;
360 1.1.12.1 jdolecek
361 1.1.12.1 jdolecek /* Flow Director */
362 1.1 dyoung u16 atr_sample;
363 1.1 dyoung u16 atr_count;
364 1.1.12.1 jdolecek
365 1.1 dyoung u32 bytes; /* used for AIM */
366 1.1 dyoung u32 packets;
367 1.1 dyoung /* Soft Stats */
368 1.1.12.1 jdolecek struct evcnt tso_tx;
369 1.1 dyoung struct evcnt no_desc_avail;
370 1.1 dyoung struct evcnt total_packets;
371 1.1.12.1 jdolecek struct evcnt pcq_drops;
372 1.1 dyoung };
373 1.1 dyoung
374 1.1 dyoung
375 1.1 dyoung /*
376 1.1 dyoung * The Receive ring, one per rx queue
377 1.1 dyoung */
378 1.1 dyoung struct rx_ring {
379 1.1 dyoung struct adapter *adapter;
380 1.1 dyoung kmutex_t rx_mtx;
381 1.1 dyoung u32 me;
382 1.1.12.1 jdolecek u32 tail;
383 1.1 dyoung union ixgbe_adv_rx_desc *rx_base;
384 1.1 dyoung struct ixgbe_dma_alloc rxdma;
385 1.1 dyoung #ifdef LRO
386 1.1 dyoung struct lro_ctrl lro;
387 1.1 dyoung #endif /* LRO */
388 1.1 dyoung bool lro_enabled;
389 1.1 dyoung bool hw_rsc;
390 1.1.12.1 jdolecek bool vtag_strip;
391 1.1.12.1 jdolecek u16 next_to_refresh;
392 1.1.12.1 jdolecek u16 next_to_check;
393 1.1.12.1 jdolecek u16 num_desc;
394 1.1.12.1 jdolecek u16 mbuf_sz;
395 1.1 dyoung char mtx_name[16];
396 1.1 dyoung struct ixgbe_rx_buf *rx_buffers;
397 1.1 dyoung ixgbe_dma_tag_t *ptag;
398 1.1 dyoung
399 1.1 dyoung u32 bytes; /* Used for AIM calc */
400 1.1 dyoung u32 packets;
401 1.1 dyoung
402 1.1 dyoung /* Soft stats */
403 1.1.12.1 jdolecek struct evcnt rx_copies;
404 1.1 dyoung struct evcnt rx_packets;
405 1.1 dyoung struct evcnt rx_bytes;
406 1.1 dyoung struct evcnt rx_discarded;
407 1.1 dyoung struct evcnt no_jmbuf;
408 1.1 dyoung u64 rsc_num;
409 1.1.12.1 jdolecek
410 1.1.12.1 jdolecek /* Flow Director */
411 1.1 dyoung u64 flm;
412 1.1.12.1 jdolecek };
413 1.1.12.1 jdolecek
414 1.1.12.1 jdolecek #define IXGBE_MAX_VF_MC 30 /* Max number of multicast entries */
415 1.1.12.1 jdolecek
416 1.1.12.1 jdolecek struct ixgbe_vf {
417 1.1.12.1 jdolecek u_int pool;
418 1.1.12.1 jdolecek u_int rar_index;
419 1.1.12.1 jdolecek u_int max_frame_size;
420 1.1.12.1 jdolecek uint32_t flags;
421 1.1.12.1 jdolecek uint8_t ether_addr[ETHER_ADDR_LEN];
422 1.1.12.1 jdolecek uint16_t mc_hash[IXGBE_MAX_VF_MC];
423 1.1.12.1 jdolecek uint16_t num_mc_hashes;
424 1.1.12.1 jdolecek uint16_t default_vlan;
425 1.1.12.1 jdolecek uint16_t vlan_tag;
426 1.1.12.1 jdolecek uint16_t api_ver;
427 1.1 dyoung };
428 1.1 dyoung
429 1.1 dyoung /* Our adapter structure */
430 1.1 dyoung struct adapter {
431 1.1 dyoung struct ixgbe_hw hw;
432 1.1 dyoung struct ixgbe_osdep osdep;
433 1.1.12.1 jdolecek
434 1.1 dyoung device_t dev;
435 1.1.12.1 jdolecek struct ifnet *ifp;
436 1.1.12.1 jdolecek struct if_percpuq *ipq; /* softint-based input queues */
437 1.1 dyoung
438 1.1 dyoung struct resource *pci_mem;
439 1.1 dyoung struct resource *msix_mem;
440 1.1 dyoung
441 1.1 dyoung /*
442 1.1 dyoung * Interrupt resources: this set is
443 1.1 dyoung * either used for legacy, or for Link
444 1.1.12.1 jdolecek * when doing MSI-X
445 1.1 dyoung */
446 1.1 dyoung void *tag;
447 1.1 dyoung struct resource *res;
448 1.1 dyoung
449 1.1 dyoung struct ifmedia media;
450 1.1 dyoung callout_t timer;
451 1.1.12.1 jdolecek int link_rid;
452 1.1 dyoung int if_flags;
453 1.1 dyoung
454 1.1 dyoung kmutex_t core_mtx;
455 1.1 dyoung
456 1.1 dyoung unsigned int num_queues;
457 1.1 dyoung
458 1.1 dyoung /*
459 1.1.12.1 jdolecek * Shadow VFTA table, this is needed because
460 1.1.12.1 jdolecek * the real vlan filter table gets cleared during
461 1.1.12.1 jdolecek * a soft reset and the driver needs to be able
462 1.1.12.1 jdolecek * to repopulate it.
463 1.1.12.1 jdolecek */
464 1.1 dyoung u32 shadow_vfta[IXGBE_VFTA_SIZE];
465 1.1 dyoung
466 1.1 dyoung /* Info about the interface */
467 1.1 dyoung int advertise; /* link speeds */
468 1.1.12.1 jdolecek bool enable_aim; /* adaptive interrupt moderation */
469 1.1 dyoung bool link_active;
470 1.1 dyoung u16 max_frame_size;
471 1.1 dyoung u16 num_segs;
472 1.1 dyoung u32 link_speed;
473 1.1 dyoung bool link_up;
474 1.1.12.1 jdolecek u32 vector;
475 1.1.12.1 jdolecek u16 dmac;
476 1.1.12.1 jdolecek u32 phy_layer;
477 1.1.12.1 jdolecek
478 1.1.12.1 jdolecek /* Power management-related */
479 1.1.12.1 jdolecek bool wol_support;
480 1.1.12.1 jdolecek u32 wufc;
481 1.1 dyoung
482 1.1 dyoung /* Mbuf cluster size */
483 1.1 dyoung u32 rx_mbuf_sz;
484 1.1 dyoung
485 1.1 dyoung /* Support for pluggable optics */
486 1.1 dyoung bool sfp_probe;
487 1.1 dyoung void *link_si; /* Link tasklet */
488 1.1 dyoung void *mod_si; /* SFP tasklet */
489 1.1 dyoung void *msf_si; /* Multispeed Fiber */
490 1.1.12.1 jdolecek void *mbx_si; /* VF -> PF mailbox interrupt */
491 1.1.12.1 jdolecek
492 1.1.12.1 jdolecek /* Flow Director */
493 1.1 dyoung int fdir_reinit;
494 1.1 dyoung void *fdir_si;
495 1.1.12.1 jdolecek
496 1.1.12.1 jdolecek void *phy_si; /* PHY intr tasklet */
497 1.1 dyoung
498 1.1 dyoung /*
499 1.1.12.1 jdolecek * Queues:
500 1.1.12.1 jdolecek * This is the irq holder, it has
501 1.1.12.1 jdolecek * and RX/TX pair or rings associated
502 1.1.12.1 jdolecek * with it.
503 1.1.12.1 jdolecek */
504 1.1 dyoung struct ix_queue *queues;
505 1.1 dyoung
506 1.1 dyoung /*
507 1.1.12.1 jdolecek * Transmit rings
508 1.1.12.1 jdolecek * Allocated at run time, an array of rings
509 1.1 dyoung */
510 1.1 dyoung struct tx_ring *tx_rings;
511 1.1.12.1 jdolecek u32 num_tx_desc;
512 1.1.12.1 jdolecek u32 tx_process_limit;
513 1.1 dyoung
514 1.1 dyoung /*
515 1.1.12.1 jdolecek * Receive rings
516 1.1.12.1 jdolecek * Allocated at run time, an array of rings
517 1.1 dyoung */
518 1.1 dyoung struct rx_ring *rx_rings;
519 1.1.12.1 jdolecek u64 active_queues;
520 1.1.12.1 jdolecek u32 num_rx_desc;
521 1.1 dyoung u32 rx_process_limit;
522 1.1 dyoung
523 1.1 dyoung /* Multicast array memory */
524 1.1.12.1 jdolecek struct ixgbe_mc_addr *mta;
525 1.1.12.1 jdolecek
526 1.1.12.1 jdolecek /* SR-IOV */
527 1.1.12.1 jdolecek int iov_mode;
528 1.1.12.1 jdolecek int num_vfs;
529 1.1.12.1 jdolecek int pool;
530 1.1.12.1 jdolecek struct ixgbe_vf *vfs;
531 1.1.12.1 jdolecek
532 1.1.12.1 jdolecek /* Bypass */
533 1.1.12.1 jdolecek struct ixgbe_bp_data bypass;
534 1.1.12.1 jdolecek
535 1.1.12.1 jdolecek /* Netmap */
536 1.1.12.1 jdolecek void (*init_locked)(struct adapter *);
537 1.1.12.1 jdolecek void (*stop_locked)(void *);
538 1.1 dyoung
539 1.1 dyoung /* Misc stats maintained by the driver */
540 1.1 dyoung struct evcnt mbuf_defrag_failed;
541 1.1 dyoung struct evcnt efbig_tx_dma_setup;
542 1.1 dyoung struct evcnt efbig2_tx_dma_setup;
543 1.1 dyoung struct evcnt einval_tx_dma_setup;
544 1.1 dyoung struct evcnt other_tx_dma_setup;
545 1.1 dyoung struct evcnt eagain_tx_dma_setup;
546 1.1 dyoung struct evcnt enomem_tx_dma_setup;
547 1.1 dyoung struct evcnt tso_err;
548 1.1.12.1 jdolecek struct evcnt watchdog_events;
549 1.1 dyoung struct evcnt link_irq;
550 1.1 dyoung struct evcnt handleq;
551 1.1 dyoung struct evcnt req;
552 1.1 dyoung
553 1.1.12.1 jdolecek union {
554 1.1.12.1 jdolecek struct ixgbe_hw_stats pf;
555 1.1.12.1 jdolecek struct ixgbevf_hw_stats vf;
556 1.1.12.1 jdolecek } stats;
557 1.1.12.1 jdolecek #if __FreeBSD_version >= 1100036
558 1.1.12.1 jdolecek /* counter(9) stats */
559 1.1.12.1 jdolecek u64 ipackets;
560 1.1.12.1 jdolecek u64 ierrors;
561 1.1.12.1 jdolecek u64 opackets;
562 1.1.12.1 jdolecek u64 oerrors;
563 1.1.12.1 jdolecek u64 ibytes;
564 1.1.12.1 jdolecek u64 obytes;
565 1.1.12.1 jdolecek u64 imcasts;
566 1.1.12.1 jdolecek u64 omcasts;
567 1.1.12.1 jdolecek u64 iqdrops;
568 1.1.12.1 jdolecek u64 noproto;
569 1.1.12.1 jdolecek #endif
570 1.1.12.1 jdolecek /* Feature capable/enabled flags. See ixgbe_features.h */
571 1.1.12.1 jdolecek u32 feat_cap;
572 1.1.12.1 jdolecek u32 feat_en;
573 1.1.12.1 jdolecek
574 1.1 dyoung struct sysctllog *sysctllog;
575 1.1.12.1 jdolecek const struct sysctlnode *sysctltop;
576 1.1 dyoung ixgbe_extmem_head_t jcl_head;
577 1.1 dyoung };
578 1.1 dyoung
579 1.1.12.1 jdolecek
580 1.1 dyoung /* Precision Time Sync (IEEE 1588) defines */
581 1.1 dyoung #define ETHERTYPE_IEEE1588 0x88F7
582 1.1 dyoung #define PICOSECS_PER_TICK 20833
583 1.1 dyoung #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */
584 1.1.12.1 jdolecek #define IXGBE_ADVTXD_TSTAMP 0x00080000
585 1.1 dyoung
586 1.1 dyoung
587 1.1 dyoung #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
588 1.1.12.1 jdolecek mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET)
589 1.1 dyoung #define IXGBE_CORE_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->core_mtx)
590 1.1 dyoung #define IXGBE_TX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->tx_mtx)
591 1.1 dyoung #define IXGBE_RX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->rx_mtx)
592 1.1 dyoung #define IXGBE_CORE_LOCK(_sc) mutex_enter(&(_sc)->core_mtx)
593 1.1 dyoung #define IXGBE_TX_LOCK(_sc) mutex_enter(&(_sc)->tx_mtx)
594 1.1 dyoung #define IXGBE_TX_TRYLOCK(_sc) mutex_tryenter(&(_sc)->tx_mtx)
595 1.1 dyoung #define IXGBE_RX_LOCK(_sc) mutex_enter(&(_sc)->rx_mtx)
596 1.1 dyoung #define IXGBE_CORE_UNLOCK(_sc) mutex_exit(&(_sc)->core_mtx)
597 1.1 dyoung #define IXGBE_TX_UNLOCK(_sc) mutex_exit(&(_sc)->tx_mtx)
598 1.1 dyoung #define IXGBE_RX_UNLOCK(_sc) mutex_exit(&(_sc)->rx_mtx)
599 1.1.12.1 jdolecek #define IXGBE_CORE_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->core_mtx))
600 1.1 dyoung #define IXGBE_TX_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->tx_mtx))
601 1.1 dyoung
602 1.1.12.1 jdolecek /* Stats macros */
603 1.1.12.1 jdolecek #if __FreeBSD_version >= 1100036
604 1.1.12.1 jdolecek #define IXGBE_SET_IPACKETS(sc, count) (sc)->ipackets = (count)
605 1.1.12.1 jdolecek #define IXGBE_SET_IERRORS(sc, count) (sc)->ierrors = (count)
606 1.1.12.1 jdolecek #define IXGBE_SET_OPACKETS(sc, count) (sc)->opackets = (count)
607 1.1.12.1 jdolecek #define IXGBE_SET_OERRORS(sc, count) (sc)->oerrors = (count)
608 1.1.12.1 jdolecek #define IXGBE_SET_COLLISIONS(sc, count)
609 1.1.12.1 jdolecek #define IXGBE_SET_IBYTES(sc, count) (sc)->ibytes = (count)
610 1.1.12.1 jdolecek #define IXGBE_SET_OBYTES(sc, count) (sc)->obytes = (count)
611 1.1.12.1 jdolecek #define IXGBE_SET_IMCASTS(sc, count) (sc)->imcasts = (count)
612 1.1.12.1 jdolecek #define IXGBE_SET_OMCASTS(sc, count) (sc)->omcasts = (count)
613 1.1.12.1 jdolecek #define IXGBE_SET_IQDROPS(sc, count) (sc)->iqdrops = (count)
614 1.1.12.1 jdolecek #else
615 1.1.12.1 jdolecek #define IXGBE_SET_IPACKETS(sc, count) (sc)->ifp->if_ipackets = (count)
616 1.1.12.1 jdolecek #define IXGBE_SET_IERRORS(sc, count) (sc)->ifp->if_ierrors = (count)
617 1.1.12.1 jdolecek #define IXGBE_SET_OPACKETS(sc, count) (sc)->ifp->if_opackets = (count)
618 1.1.12.1 jdolecek #define IXGBE_SET_OERRORS(sc, count) (sc)->ifp->if_oerrors = (count)
619 1.1.12.1 jdolecek #define IXGBE_SET_COLLISIONS(sc, count) (sc)->ifp->if_collisions = (count)
620 1.1.12.1 jdolecek #define IXGBE_SET_IBYTES(sc, count) (sc)->ifp->if_ibytes = (count)
621 1.1.12.1 jdolecek #define IXGBE_SET_OBYTES(sc, count) (sc)->ifp->if_obytes = (count)
622 1.1.12.1 jdolecek #define IXGBE_SET_IMCASTS(sc, count) (sc)->ifp->if_imcasts = (count)
623 1.1.12.1 jdolecek #define IXGBE_SET_OMCASTS(sc, count) (sc)->ifp->if_omcasts = (count)
624 1.1.12.1 jdolecek #define IXGBE_SET_IQDROPS(sc, count) (sc)->ifp->if_iqdrops = (count)
625 1.1.12.1 jdolecek #endif
626 1.1 dyoung
627 1.1.12.1 jdolecek /* External PHY register addresses */
628 1.1.12.1 jdolecek #define IXGBE_PHY_CURRENT_TEMP 0xC820
629 1.1.12.1 jdolecek #define IXGBE_PHY_OVERTEMP_STATUS 0xC830
630 1.1.12.1 jdolecek
631 1.1.12.1 jdolecek /* Sysctl help messages; displayed with sysctl -d */
632 1.1.12.1 jdolecek #define IXGBE_SYSCTL_DESC_ADV_SPEED \
633 1.1.12.1 jdolecek "\nControl advertised link speed using these flags:\n" \
634 1.1.12.1 jdolecek "\t0x01 - advertise 100M\n" \
635 1.1.12.1 jdolecek "\t0x02 - advertise 1G\n" \
636 1.1.12.1 jdolecek "\t0x04 - advertise 10G\n" \
637 1.1.12.1 jdolecek "\t0x08 - advertise 10M\n" \
638 1.1.12.1 jdolecek "\t0x10 - advertise 2.5G\n" \
639 1.1.12.1 jdolecek "\t0x20 - advertise 5G\n\n" \
640 1.1.12.1 jdolecek "\t5G, 2.5G, 100M and 10M are only supported on certain adapters."
641 1.1.12.1 jdolecek
642 1.1.12.1 jdolecek #define IXGBE_SYSCTL_DESC_SET_FC \
643 1.1.12.1 jdolecek "\nSet flow control mode using these values:\n" \
644 1.1.12.1 jdolecek "\t0 - off\n" \
645 1.1.12.1 jdolecek "\t1 - rx pause\n" \
646 1.1.12.1 jdolecek "\t2 - tx pause\n" \
647 1.1.12.1 jdolecek "\t3 - tx and rx pause"
648 1.1 dyoung
649 1.1 dyoung /* Workaround to make 8.0 buildable */
650 1.1 dyoung #if __FreeBSD_version >= 800000 && __FreeBSD_version < 800504
651 1.1 dyoung static __inline int
652 1.1 dyoung drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
653 1.1 dyoung {
654 1.1 dyoung #ifdef ALTQ
655 1.1 dyoung if (ALTQ_IS_ENABLED(&ifp->if_snd))
656 1.1 dyoung return (1);
657 1.1 dyoung #endif
658 1.1 dyoung return (!buf_ring_empty(br));
659 1.1 dyoung }
660 1.1 dyoung #endif
661 1.1 dyoung
662 1.1 dyoung /*
663 1.1.12.1 jdolecek * Find the number of unrefreshed RX descriptors
664 1.1.12.1 jdolecek */
665 1.1 dyoung static inline u16
666 1.1 dyoung ixgbe_rx_unrefreshed(struct rx_ring *rxr)
667 1.1.12.1 jdolecek {
668 1.1 dyoung if (rxr->next_to_check > rxr->next_to_refresh)
669 1.1 dyoung return (rxr->next_to_check - rxr->next_to_refresh - 1);
670 1.1 dyoung else
671 1.1.12.1 jdolecek return ((rxr->num_desc + rxr->next_to_check) -
672 1.1 dyoung rxr->next_to_refresh - 1);
673 1.1.12.1 jdolecek }
674 1.1.12.1 jdolecek
675 1.1.12.1 jdolecek static inline int
676 1.1.12.1 jdolecek ixgbe_legacy_ring_empty(struct ifnet *ifp, pcq_t *dummy)
677 1.1.12.1 jdolecek {
678 1.1.12.1 jdolecek UNREFERENCED_1PARAMETER(dummy);
679 1.1.12.1 jdolecek
680 1.1.12.1 jdolecek return IFQ_IS_EMPTY(&ifp->if_snd);
681 1.1.12.1 jdolecek }
682 1.1.12.1 jdolecek
683 1.1.12.1 jdolecek static inline int
684 1.1.12.1 jdolecek ixgbe_mq_ring_empty(struct ifnet *dummy, pcq_t *interq)
685 1.1.12.1 jdolecek {
686 1.1.12.1 jdolecek UNREFERENCED_1PARAMETER(dummy);
687 1.1.12.1 jdolecek
688 1.1.12.1 jdolecek return (pcq_peek(interq) == NULL);
689 1.1.12.1 jdolecek }
690 1.1.12.1 jdolecek
691 1.1.12.1 jdolecek /*
692 1.1.12.1 jdolecek * This checks for a zero mac addr, something that will be likely
693 1.1.12.1 jdolecek * unless the Admin on the Host has created one.
694 1.1.12.1 jdolecek */
695 1.1.12.1 jdolecek static inline bool
696 1.1.12.1 jdolecek ixv_check_ether_addr(u8 *addr)
697 1.1.12.1 jdolecek {
698 1.1.12.1 jdolecek bool status = TRUE;
699 1.1.12.1 jdolecek
700 1.1.12.1 jdolecek if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
701 1.1.12.1 jdolecek addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
702 1.1.12.1 jdolecek status = FALSE;
703 1.1.12.1 jdolecek
704 1.1.12.1 jdolecek return (status);
705 1.1.12.1 jdolecek }
706 1.1.12.1 jdolecek
707 1.1.12.1 jdolecek /* Shared Prototypes */
708 1.1.12.1 jdolecek void ixgbe_legacy_start(struct ifnet *);
709 1.1.12.1 jdolecek int ixgbe_legacy_start_locked(struct ifnet *, struct tx_ring *);
710 1.1.12.1 jdolecek int ixgbe_mq_start(struct ifnet *, struct mbuf *);
711 1.1.12.1 jdolecek int ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *);
712 1.1.12.1 jdolecek void ixgbe_deferred_mq_start(void *);
713 1.1.12.1 jdolecek
714 1.1.12.1 jdolecek int ixgbe_allocate_queues(struct adapter *);
715 1.1.12.1 jdolecek int ixgbe_setup_transmit_structures(struct adapter *);
716 1.1.12.1 jdolecek void ixgbe_free_transmit_structures(struct adapter *);
717 1.1.12.1 jdolecek int ixgbe_setup_receive_structures(struct adapter *);
718 1.1.12.1 jdolecek void ixgbe_free_receive_structures(struct adapter *);
719 1.1.12.1 jdolecek void ixgbe_txeof(struct tx_ring *);
720 1.1.12.1 jdolecek bool ixgbe_rxeof(struct ix_queue *);
721 1.1.12.1 jdolecek
722 1.1.12.1 jdolecek const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
723 1.1.12.1 jdolecek
724 1.1.12.1 jdolecek #include "ixgbe_bypass.h"
725 1.1.12.1 jdolecek #include "ixgbe_sriov.h"
726 1.1.12.1 jdolecek #include "ixgbe_fdir.h"
727 1.1.12.1 jdolecek #include "ixgbe_rss.h"
728 1.1.12.1 jdolecek #include "ixgbe_netmap.h"
729 1.1 dyoung
730 1.1 dyoung #endif /* _IXGBE_H_ */
731