Home | History | Annotate | Line # | Download | only in ixgbe
ixgbe.h revision 1.94
      1 /* $NetBSD: ixgbe.h,v 1.94 2023/12/28 10:02:14 msaitoh 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 327031 2017-12-20 18:15:06Z 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 #include <sys/percpu.h>
     84 
     85 #include <net/if.h>
     86 #include <net/if_arp.h>
     87 #include <net/bpf.h>
     88 #include <net/if_ether.h>
     89 #include <net/if_dl.h>
     90 #include <net/if_media.h>
     91 
     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_vf.h"
    117 #include "ixgbe_features.h"
    118 
    119 /* Tunables */
    120 
    121 /*
    122  * TxDescriptors Valid Range: 64-4096 Default Value: 2048 This value is the
    123  * number of transmit descriptors allocated by the driver. Increasing this
    124  * value allows the driver to queue more transmits. Each descriptor is 16
    125  * bytes. Performance tests have show the 2K value to be optimal for top
    126  * performance.
    127  */
    128 #define DEFAULT_TXD	2048
    129 #define MAX_TXD		4096
    130 #define MIN_TXD		64
    131 
    132 /*
    133  * RxDescriptors Valid Range: 64-4096 Default Value: 2048 This value is the
    134  * number of receive descriptors allocated for each RX queue. Increasing this
    135  * value allows the driver to buffer more incoming packets. Each descriptor
    136  * is 16 bytes.  A receive buffer is also allocated for each descriptor.
    137  *
    138  * Note: with 8 rings and a dual port card, it is possible to bump up
    139  *	against the system mbuf pool limit, you can tune nmbclusters
    140  *	to adjust for this.
    141  */
    142 #define DEFAULT_RXD	2048
    143 #define MAX_RXD		4096
    144 #define MIN_RXD		64
    145 
    146 /* Alignment for rings */
    147 #define DBA_ALIGN	128
    148 
    149 /*
    150  * This is the max watchdog interval, ie. the time that can
    151  * pass between any two TX clean operations, such only happening
    152  * when the TX hardware is functioning.
    153  */
    154 #define IXGBE_WATCHDOG  (10 * hz)
    155 
    156 /*
    157  * This parameters control when the driver calls the routine to reclaim
    158  * transmit descriptors.
    159  */
    160 #define IXGBE_TX_CLEANUP_THRESHOLD(_a)  ((_a)->num_tx_desc / 8)
    161 #define IXGBE_TX_OP_THRESHOLD(_a)       ((_a)->num_tx_desc / 32)
    162 
    163 /* These defines are used in MTU calculations */
    164 #define IXGBE_MAX_FRAME_SIZE  9728
    165 #define IXGBE_MTU_HDR         (ETHER_HDR_LEN + ETHER_CRC_LEN)
    166 #define IXGBE_MTU_HDR_VLAN    (ETHER_HDR_LEN + ETHER_CRC_LEN + \
    167                                ETHER_VLAN_ENCAP_LEN)
    168 #define IXGBE_MAX_MTU         (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
    169 #define IXGBE_MAX_MTU_VLAN    (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN)
    170 
    171 /* Flow control constants */
    172 #define IXGBE_FC_PAUSE        0xFFFF
    173 
    174 /*
    175  * Used for optimizing small rx mbufs.  Effort is made to keep the copy
    176  * small and aligned for the CPU L1 cache.
    177  *
    178  * MHLEN is typically 168 bytes, giving us 8-byte alignment.  Getting
    179  * 32 byte alignment needed for the fast bcopy results in 8 bytes being
    180  * wasted.  Getting 64 byte alignment, which _should_ be ideal for
    181  * modern Intel CPUs, results in 40 bytes wasted and a significant drop
    182  * in observed efficiency of the optimization, 97.9% -> 81.8%.
    183  */
    184 #define IXGBE_RX_COPY_LEN_MAX     (MHLEN - ETHER_ALIGN)
    185 
    186 /*
    187  * Default TX WTHRESH value.
    188  * Currently, we don't use the Tx Head Pointer Write Back function.
    189  */
    190 #define IXGBE_TX_WTHRESH	5
    191 
    192 /*
    193  * The max number of descriptors that one packet can use is 40 - WTHRESH - 2.
    194  * Though 82598 does not have this limit, we don't want long TX chain.
    195  * 33 should be large enough even for 64K TSO
    196  * (32 * 2K mbuf cluster and 1 x mbuf header).
    197  *
    198  * Reference: 82599-X550 datasheet 7.2.1.1 "Transmit Storage in System Memory".
    199  */
    200 #define IXGBE_82599_SCATTER_MAX	(40 - IXGBE_TX_WTHRESH - 2)
    201 #define IXGBE_SCATTER_DEFAULT	33
    202 
    203 /* Defines for printing debug information */
    204 #define DEBUG_INIT  0
    205 #define DEBUG_IOCTL 0
    206 #define DEBUG_HW    0
    207 
    208 #define INIT_DEBUGOUT(S)            if (DEBUG_INIT)  printf(S "\n")
    209 #define INIT_DEBUGOUT1(S, A)        if (DEBUG_INIT)  printf(S "\n", A)
    210 #define INIT_DEBUGOUT2(S, A, B)     if (DEBUG_INIT)  printf(S "\n", A, B)
    211 #define IOCTL_DEBUGOUT(S)           if (DEBUG_IOCTL) printf(S "\n")
    212 #define IOCTL_DEBUGOUT1(S, A)       if (DEBUG_IOCTL) printf(S "\n", A)
    213 #define IOCTL_DEBUGOUT2(S, A, B)    if (DEBUG_IOCTL) printf(S "\n", A, B)
    214 #define HW_DEBUGOUT(S)              if (DEBUG_HW) printf(S "\n")
    215 #define HW_DEBUGOUT1(S, A)          if (DEBUG_HW) printf(S "\n", A)
    216 #define HW_DEBUGOUT2(S, A, B)       if (DEBUG_HW) printf(S "\n", A, B)
    217 
    218 #define MAX_NUM_MULTICAST_ADDRESSES     128
    219 #define MSIX_82598_BAR                  3
    220 #define MSIX_82599_BAR                  4
    221 #define IXGBE_TSO_SIZE                  262140
    222 #define IXGBE_RX_HDR                    128
    223 #define IXGBE_VFTA_SIZE                 128
    224 #define IXGBE_BR_SIZE                   2048
    225 #define IXGBE_QUEUE_MIN_FREE            32
    226 #define IXGBE_MAX_TX_BUSY               10
    227 #define IXGBE_QUEUE_HUNG                0x80000000
    228 
    229 #define IXGBE_EITR_DEFAULT		128
    230 
    231 /* IOCTL define to gather SFP+ Diagnostic data */
    232 #define SIOCGI2C	SIOCGIFGENERIC
    233 
    234 /* Offload bits in mbuf flag */
    235 #define	M_CSUM_OFFLOAD	\
    236     (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_UDPv6|M_CSUM_TCPv6)
    237 
    238 /* Backward compatibility items for very old versions */
    239 #ifndef pci_find_cap
    240 #define pci_find_cap pci_find_extcap
    241 #endif
    242 
    243 #ifndef DEVMETHOD_END
    244 #define DEVMETHOD_END { NULL, NULL }
    245 #endif
    246 
    247 /*
    248  * Interrupt Moderation parameters
    249  */
    250 #define IXGBE_LOW_LATENCY	128
    251 #define IXGBE_AVE_LATENCY	400
    252 #define IXGBE_BULK_LATENCY	1200
    253 
    254 /* Using 1FF (the max value), the interval is ~1.05ms */
    255 #define IXGBE_LINK_ITR_QUANTA  0x1FF
    256 #define IXGBE_LINK_ITR         ((IXGBE_LINK_ITR_QUANTA << 3) & \
    257                                 IXGBE_EITR_ITR_INT_MASK)
    258 
    259 
    260 /************************************************************************
    261  * vendor_info_array
    262  *
    263  *   Contains the list of Subvendor/Subdevice IDs on
    264  *   which the driver should load.
    265  ************************************************************************/
    266 typedef struct _ixgbe_vendor_info_t {
    267 	unsigned int vendor_id;
    268 	unsigned int device_id;
    269 	unsigned int subvendor_id;
    270 	unsigned int subdevice_id;
    271 	unsigned int index;
    272 } ixgbe_vendor_info_t;
    273 
    274 /* This is used to get SFP+ module data */
    275 struct ixgbe_i2c_req {
    276 	u8 dev_addr;
    277 	u8 offset;
    278 	u8 len;
    279 	u8 data[8];
    280 };
    281 
    282 struct ixgbe_bp_data {
    283 	u32 low;
    284 	u32 high;
    285 	u32 log;
    286 };
    287 
    288 struct ixgbe_tx_buf {
    289 	union ixgbe_adv_tx_desc	*eop;
    290 	struct mbuf             *m_head;
    291 	bus_dmamap_t            map;
    292 };
    293 
    294 struct ixgbe_rx_buf {
    295 	struct mbuf    *buf;
    296 	struct mbuf    *fmp;
    297 	bus_dmamap_t   pmap;
    298 	u_int          flags;
    299 #define IXGBE_RX_COPY  0x01
    300 	uint64_t       addr;
    301 };
    302 
    303 /*
    304  * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free
    305  */
    306 struct ixgbe_dma_alloc {
    307 	bus_addr_t        dma_paddr;
    308 	void              *dma_vaddr;
    309 	ixgbe_dma_tag_t   *dma_tag;
    310 	bus_dmamap_t      dma_map;
    311 	bus_dma_segment_t dma_seg;
    312 	bus_size_t        dma_size;
    313 };
    314 
    315 struct ixgbe_mc_addr {
    316 	u8  addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
    317 	u32 vmdq;
    318 };
    319 
    320 /*
    321  * Driver queue struct: this is the interrupt container
    322  *                      for the associated tx and rx ring.
    323  */
    324 struct ix_queue {
    325 	struct ixgbe_softc *sc;
    326 	u32              msix;           /* This queue's MSI-X vector */
    327 	u32              eitr_setting;
    328 	u32              me;
    329 	struct resource  *res;
    330 	int              busy;
    331 	struct tx_ring   *txr;
    332 	struct rx_ring   *rxr;
    333 	struct work      wq_cookie;
    334 	void             *que_si;
    335 	/* Per queue event conters */
    336 	struct evcnt     irqs;		/* Hardware interrupt */
    337 	struct evcnt     handleq;	/* software_interrupt */
    338 	struct evcnt     req;		/* deferred */
    339 	char             namebuf[32];	/* Name for sysctl */
    340 	char             evnamebuf[32];	/* Name for evcnt */
    341 
    342 	/* Lock for disabled_count and this queue's EIMS/EIMC bit */
    343 	kmutex_t         dc_mtx;
    344 	/*
    345 	 * disabled_count means:
    346 	 *     0   : this queue is enabled
    347 	 *     > 0 : this queue is disabled
    348 	 *           the value is ixgbe_disable_queue() called count
    349 	 */
    350 	int              disabled_count;
    351 	bool             txrx_use_workqueue;
    352 };
    353 
    354 /*
    355  * The transmit ring, one per queue
    356  */
    357 struct tx_ring {
    358 	struct ixgbe_softc	*sc;
    359 	kmutex_t		tx_mtx;
    360 	u32			me;
    361 	u32			tail;
    362 	int			busy;
    363 	union ixgbe_adv_tx_desc	*tx_base;
    364 	struct ixgbe_tx_buf	*tx_buffers;
    365 	struct ixgbe_dma_alloc	txdma;
    366 	volatile u16		tx_avail;
    367 	u16			next_avail_desc;
    368 	u16			next_to_clean;
    369 	u16			num_desc;
    370 	ixgbe_dma_tag_t		*txtag;
    371 #if 0
    372 	char			mtx_name[16]; /* NetBSD has no mutex name */
    373 #endif
    374 	pcq_t			*txr_interq;
    375 	struct work		wq_cookie;
    376 	void			*txr_si;
    377 	bool			txr_no_space; /* Like IFF_OACTIVE */
    378 
    379 #ifdef IXGBE_FDIR
    380 	/* Flow Director */
    381 	u16			atr_sample;
    382 	u16			atr_count;
    383 #endif
    384 
    385 	u64			bytes;  /* Used for AIM */
    386 	u64			packets;
    387 	/* Soft Stats */
    388 	struct evcnt		total_packets;
    389 	struct evcnt		pcq_drops;
    390 	struct evcnt		no_desc_avail;
    391 	struct evcnt		tso_tx;
    392 	/* Per queue conters.  The adapter total is in struct adapter */
    393 	u64              q_efbig_tx_dma_setup;
    394 	u64              q_mbuf_defrag_failed;
    395 	u64              q_efbig2_tx_dma_setup;
    396 	u64              q_einval_tx_dma_setup;
    397 	u64              q_other_tx_dma_setup;
    398 	u64              q_eagain_tx_dma_setup;
    399 	u64              q_enomem_tx_dma_setup;
    400 	u64              q_tso_err;
    401 };
    402 
    403 
    404 /*
    405  * The Receive ring, one per rx queue
    406  */
    407 struct rx_ring {
    408 	struct ixgbe_softc	*sc;
    409 	kmutex_t		rx_mtx;
    410 	u32			me;
    411 	u32			tail;
    412 	union ixgbe_adv_rx_desc	*rx_base;
    413 	struct ixgbe_dma_alloc	rxdma;
    414 #ifdef LRO
    415 	struct lro_ctrl		lro;
    416 #endif /* LRO */
    417 	bool			lro_enabled;
    418 	bool			hw_rsc;
    419 	bool			vtag_strip;
    420 	bool			discard_multidesc;
    421 	u16			next_to_refresh;
    422 	u16			next_to_check;
    423 	u16			num_desc;
    424 	u16			mbuf_sz;
    425 #if 0
    426 	char			mtx_name[16]; /* NetBSD has no mutex name */
    427 #endif
    428 	struct ixgbe_rx_buf	*rx_buffers;
    429 	ixgbe_dma_tag_t		*ptag;
    430 
    431 	u64			bytes; /* Used for AIM calc */
    432 	u64			packets;
    433 
    434 	/* Soft stats */
    435 	struct evcnt		rx_copies;
    436 	struct evcnt		rx_packets;
    437 	struct evcnt		rx_bytes;
    438 	struct evcnt		rx_discarded;
    439 	struct evcnt		no_mbuf;
    440 	u64			rsc_num;
    441 
    442 	/* Flow Director */
    443 	u64			flm;
    444 };
    445 
    446 struct ixgbe_vf {
    447 	u_int    pool;
    448 	u_int    rar_index;
    449 	u_int    max_frame_size;
    450 	uint32_t flags;
    451 	uint8_t  ether_addr[ETHER_ADDR_LEN];
    452 	uint16_t mc_hash[IXGBE_MAX_VF_MC];
    453 	uint16_t num_mc_hashes;
    454 	uint16_t default_vlan;
    455 	uint16_t vlan_tag;
    456 	uint16_t api_ver;
    457 };
    458 
    459 /*
    460  * NetBSD: For trafic class
    461  * Crrently, the following structure is only for statistics.
    462  */
    463 struct ixgbe_tc {
    464 	char             evnamebuf[32];
    465 };
    466 
    467 /* Our adapter structure */
    468 struct ixgbe_softc {
    469 	struct ixgbe_hw		hw;
    470 	struct ixgbe_osdep	osdep;
    471 
    472 	device_t		dev;
    473 	struct ifnet		*ifp;
    474 	struct if_percpuq	*ipq;	/* softint-based input queues */
    475 
    476 	struct resource		*pci_mem;
    477 
    478 	/* NetBSD: Interrupt resources are in osdep */
    479 
    480 	struct ifmedia		media;
    481 	callout_t		timer;
    482 	struct workqueue	*timer_wq;
    483 	struct work		timer_wc;
    484 	u_int			timer_pending;
    485 
    486 	u_short			if_flags;	/* saved ifp->if_flags */
    487 	int			ec_capenable;	/* saved ec->ec_capenable */
    488 
    489 	kmutex_t		core_mtx;
    490 
    491 	unsigned int		num_queues;
    492 
    493 	/*
    494 	 * Shadow VFTA table, this is needed because
    495 	 * the real vlan filter table gets cleared during
    496 	 * a soft reset and the driver needs to be able
    497 	 * to repopulate it.
    498 	 */
    499 	u32			shadow_vfta[IXGBE_VFTA_SIZE];
    500 
    501 	/* Info about the interface */
    502 	int			advertise;  /* link speeds */
    503 	bool			enable_aim; /* adaptive interrupt moderation */
    504 	int			max_interrupt_rate;
    505 	int			link_active; /* Use LINK_STATE_* value */
    506 	u16			max_frame_size;
    507 	u16			num_segs;
    508 	u32			link_speed;
    509 	bool			link_up;
    510 	bool                    link_enabled;
    511 	u32			vector;
    512 	u16			dmac;
    513 	u32			phy_layer;
    514 
    515 	/* Power management-related */
    516 	bool			wol_support;
    517 	u32			wufc;
    518 
    519 	/* Mbuf cluster size */
    520 	u32			rx_mbuf_sz;
    521 
    522 	bool			schedule_wqs_ok;
    523 
    524 	/* Flow Director */
    525 	int			fdir_reinit;
    526 
    527 	/* Admin task */
    528 	struct workqueue	*admin_wq; /* Link, SFP, PHY and FDIR */
    529 	struct work		admin_wc;
    530 	u_int			admin_pending;
    531 	volatile u32		task_requests;
    532 	kmutex_t		admin_mtx; /* lock for admin_pending, task_request */
    533 					   /*
    534 					    * Don't acquire this mutex while
    535 					    * holding rx_mtx or tx_mtx, and
    536 					    * vice versa.
    537 					    */
    538 
    539 	bool			txrx_use_workqueue;
    540 
    541 	/*
    542 	 * Workqueue for ixgbe_handle_que_work().
    543 	 *
    544 	 * que_wq's "enqueued flag" is not required, because twice
    545 	 * workqueue_enqueue() for ixgbe_handle_que_work() is avoided by
    546 	 * masking the queue's interrupt by EIMC. See also ixgbe_msix_que().
    547 	 */
    548 	struct workqueue	*que_wq;
    549 	/* Workqueue for ixgbe_deferred_mq_start_work() */
    550 	struct workqueue	*txr_wq;
    551 	percpu_t		*txr_wq_enqueued;
    552 
    553 	/*
    554 	 * Queues:
    555 	 *   This is the irq holder, it has
    556 	 *   and RX/TX pair or rings associated
    557 	 *   with it.
    558 	 */
    559 	struct ix_queue		*queues;
    560 
    561 	/*
    562 	 * Transmit rings
    563 	 *      Allocated at run time, an array of rings
    564 	 */
    565 	struct tx_ring		*tx_rings;
    566 	u32			num_tx_desc;
    567 	u32			tx_process_limit;
    568 
    569 	/*
    570 	 * Receive rings
    571 	 *      Allocated at run time, an array of rings
    572 	 */
    573 	struct rx_ring		*rx_rings;
    574 	u64			active_queues;
    575 	u32			num_rx_desc;
    576 	u32			rx_process_limit;
    577 	u32			rx_copy_len;
    578 
    579 	/* Multicast array memory */
    580 	struct ixgbe_mc_addr	*mta;
    581 
    582 	/* SR-IOV */
    583 	int                     iov_mode;
    584 	int			num_vfs;
    585 	int			pool;
    586 	struct ixgbe_vf		*vfs;
    587 
    588 	/* Bypass */
    589 	struct ixgbe_bp_data    bypass;
    590 
    591 	/* Netmap */
    592 	void			(*init_locked)(struct ixgbe_softc *);
    593 	void			(*stop_locked)(void *);
    594 
    595 	/* Firmware error check */
    596 	u_int                   recovery_mode;
    597 	callout_t               recovery_mode_timer;
    598 	struct workqueue        *recovery_mode_timer_wq;
    599 	struct work             recovery_mode_timer_wc;
    600 	u_int			recovery_mode_timer_pending;
    601 
    602 	/* Misc stats maintained by the driver */
    603 	struct evcnt		efbig_tx_dma_setup;
    604 	struct evcnt		mbuf_defrag_failed;
    605 	struct evcnt		efbig2_tx_dma_setup;
    606 	struct evcnt		einval_tx_dma_setup;
    607 	struct evcnt		other_tx_dma_setup;
    608 	struct evcnt		eagain_tx_dma_setup;
    609 	struct evcnt		enomem_tx_dma_setup;
    610 	struct evcnt		tso_err;
    611 	struct evcnt		watchdog_events;
    612 	struct evcnt		admin_irqev;
    613 	struct evcnt		link_workev;
    614 	struct evcnt		mod_workev;
    615 	struct evcnt		msf_workev;
    616 	struct evcnt		phy_workev;
    617 
    618 	union {
    619 		struct ixgbe_hw_stats pf;
    620 		struct ixgbevf_hw_stats	vf;
    621 	} stats;
    622 #if __FreeBSD_version >= 1100036
    623 	/* counter(9) stats */
    624 	u64			ipackets;
    625 	u64			ierrors;
    626 	u64			opackets;
    627 	u64			oerrors;
    628 	u64			ibytes;
    629 	u64			obytes;
    630 	u64			imcasts;
    631 	u64			omcasts;
    632 	u64			iqdrops;
    633 	u64			noproto;
    634 #endif
    635 	/* Feature capable/enabled flags.  See ixgbe_features.h */
    636 	u32                     feat_cap;
    637 	u32                     feat_en;
    638 
    639 	/* Traffic classes */
    640 	struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS];
    641 
    642 	struct sysctllog	*sysctllog;
    643 	const struct sysctlnode *sysctltop;
    644 	struct timeval		lasterr_time;
    645 };
    646 
    647 /* Precision Time Sync (IEEE 1588) defines */
    648 #define ETHERTYPE_IEEE1588      0x88F7
    649 #define PICOSECS_PER_TICK       20833
    650 #define TSYNC_UDP_PORT          319 /* UDP port for the protocol */
    651 #define IXGBE_ADVTXD_TSTAMP     0x00080000
    652 
    653 
    654 #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
    655 	mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET)
    656 #define IXGBE_CORE_LOCK_DESTROY(_sc)      mutex_destroy(&(_sc)->core_mtx)
    657 #define IXGBE_TX_LOCK_DESTROY(_sc)        mutex_destroy(&(_sc)->tx_mtx)
    658 #define IXGBE_RX_LOCK_DESTROY(_sc)        mutex_destroy(&(_sc)->rx_mtx)
    659 #define IXGBE_CORE_LOCK(_sc)              mutex_enter(&(_sc)->core_mtx)
    660 #define IXGBE_TX_LOCK(_sc)                mutex_enter(&(_sc)->tx_mtx)
    661 #define IXGBE_TX_TRYLOCK(_sc)             mutex_tryenter(&(_sc)->tx_mtx)
    662 #define IXGBE_RX_LOCK(_sc)                mutex_enter(&(_sc)->rx_mtx)
    663 #define IXGBE_CORE_UNLOCK(_sc)            mutex_exit(&(_sc)->core_mtx)
    664 #define IXGBE_TX_UNLOCK(_sc)              mutex_exit(&(_sc)->tx_mtx)
    665 #define IXGBE_RX_UNLOCK(_sc)              mutex_exit(&(_sc)->rx_mtx)
    666 #define IXGBE_CORE_LOCK_ASSERT(_sc)       KASSERT(mutex_owned(&(_sc)->core_mtx))
    667 #define IXGBE_TX_LOCK_ASSERT(_sc)         KASSERT(mutex_owned(&(_sc)->tx_mtx))
    668 
    669 /* External PHY register addresses */
    670 #define IXGBE_PHY_CURRENT_TEMP		0xC820
    671 #define IXGBE_PHY_OVERTEMP_STATUS	0xC830
    672 
    673 /* Sysctl help messages; displayed with sysctl -d */
    674 #define IXGBE_SYSCTL_DESC_ADV_SPEED \
    675 	"\nControl advertised link speed using these flags:\n" \
    676 	"\t0x1  - advertise 100M\n" \
    677 	"\t0x2  - advertise 1G\n" \
    678 	"\t0x4  - advertise 10G\n" \
    679 	"\t0x8  - advertise 10M\n" \
    680 	"\t0x10 - advertise 2.5G\n" \
    681 	"\t0x20 - advertise 5G\n\n" \
    682 	"\t5G, 2.5G, 100M and 10M are only supported on certain adapters."
    683 
    684 #define IXGBE_SYSCTL_DESC_SET_FC \
    685 	"\nSet flow control mode using these values:\n" \
    686 	"\t0 - off\n" \
    687 	"\t1 - rx pause\n" \
    688 	"\t2 - tx pause\n" \
    689 	"\t3 - tx and rx pause"
    690 
    691 /*
    692  * Find the number of unrefreshed RX descriptors
    693  */
    694 static __inline u16
    695 ixgbe_rx_unrefreshed(struct rx_ring *rxr)
    696 {
    697 	if (rxr->next_to_check > rxr->next_to_refresh)
    698 		return (rxr->next_to_check - rxr->next_to_refresh - 1);
    699 	else
    700 		return ((rxr->num_desc + rxr->next_to_check) -
    701 		    rxr->next_to_refresh - 1);
    702 }
    703 
    704 static __inline int
    705 ixgbe_legacy_ring_empty(struct ifnet *ifp, pcq_t *dummy)
    706 {
    707 	UNREFERENCED_1PARAMETER(dummy);
    708 
    709 	return IFQ_IS_EMPTY(&ifp->if_snd);
    710 }
    711 
    712 static __inline int
    713 ixgbe_mq_ring_empty(struct ifnet *dummy, pcq_t *interq)
    714 {
    715 	UNREFERENCED_1PARAMETER(dummy);
    716 
    717 	return (pcq_peek(interq) == NULL);
    718 }
    719 
    720 /*
    721  * This checks for a zero mac addr, something that will be likely
    722  * unless the Admin on the Host has created one.
    723  */
    724 static __inline bool
    725 ixv_check_ether_addr(u8 *addr)
    726 {
    727 	bool status = TRUE;
    728 
    729 	if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
    730 	    addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
    731 		status = FALSE;
    732 
    733 	return (status);
    734 }
    735 
    736 /*
    737  * This checks the sc->recovery_mode software flag which is
    738  * set by ixgbe_fw_recovery_mode().
    739  *
    740  */
    741 static inline bool
    742 ixgbe_fw_recovery_mode_swflag(struct ixgbe_softc *sc)
    743 {
    744 	return (sc->feat_en & IXGBE_FEATURE_RECOVERY_MODE) &&
    745 	    atomic_load_acq_uint(&sc->recovery_mode);
    746 }
    747 
    748 /* Shared Prototypes */
    749 void ixgbe_legacy_start(struct ifnet *);
    750 int  ixgbe_legacy_start_locked(struct ifnet *, struct tx_ring *);
    751 int  ixgbe_mq_start(struct ifnet *, struct mbuf *);
    752 int  ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *);
    753 void ixgbe_deferred_mq_start(void *);
    754 void ixgbe_deferred_mq_start_work(struct work *, void *);
    755 void ixgbe_drain_all(struct ixgbe_softc *);
    756 
    757 int  ixgbe_allocate_queues(struct ixgbe_softc *);
    758 void ixgbe_free_queues(struct ixgbe_softc *);
    759 int  ixgbe_setup_transmit_structures(struct ixgbe_softc *);
    760 void ixgbe_free_transmit_structures(struct ixgbe_softc *);
    761 int  ixgbe_setup_receive_structures(struct ixgbe_softc *);
    762 void ixgbe_free_receive_structures(struct ixgbe_softc *);
    763 bool ixgbe_txeof(struct tx_ring *);
    764 bool ixgbe_rxeof(struct ix_queue *);
    765 
    766 #define IXGBE_REQUEST_TASK_MOD		0x01
    767 #define IXGBE_REQUEST_TASK_MOD_WOI	0x02
    768 #define IXGBE_REQUEST_TASK_MSF		0x04
    769 #define IXGBE_REQUEST_TASK_MSF_WOI	0x08
    770 #define IXGBE_REQUEST_TASK_MBX		0x10
    771 #define IXGBE_REQUEST_TASK_FDIR		0x20
    772 #define IXGBE_REQUEST_TASK_PHY		0x40
    773 #define IXGBE_REQUEST_TASK_LSC		0x80
    774 
    775 /* For NetBSD */
    776 const struct sysctlnode *ixgbe_sysctl_instance(struct ixgbe_softc *);
    777 
    778 #include "ixgbe_bypass.h"
    779 #include "ixgbe_fdir.h"
    780 #include "ixgbe_rss.h"
    781 #include "ixgbe_netmap.h"
    782 
    783 #endif /* _IXGBE_H_ */
    784