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