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