xref: /freebsd/sys/dev/ixgbe/ixgbe.h (revision c00148556a4cbd3d8fd249c1d32968d95dcdfe29)
19ca4041bSJack F Vogel /******************************************************************************
213705f88SJack F Vogel 
3c0014855SJack F Vogel   Copyright (c) 2001-2010, Intel Corporation
413705f88SJack F Vogel   All rights reserved.
513705f88SJack F Vogel 
613705f88SJack F Vogel   Redistribution and use in source and binary forms, with or without
713705f88SJack F Vogel   modification, are permitted provided that the following conditions are met:
813705f88SJack F Vogel 
913705f88SJack F Vogel    1. Redistributions of source code must retain the above copyright notice,
1013705f88SJack F Vogel       this list of conditions and the following disclaimer.
1113705f88SJack F Vogel 
1213705f88SJack F Vogel    2. Redistributions in binary form must reproduce the above copyright
1313705f88SJack F Vogel       notice, this list of conditions and the following disclaimer in the
1413705f88SJack F Vogel       documentation and/or other materials provided with the distribution.
1513705f88SJack F Vogel 
1613705f88SJack F Vogel    3. Neither the name of the Intel Corporation nor the names of its
1713705f88SJack F Vogel       contributors may be used to endorse or promote products derived from
1813705f88SJack F Vogel       this software without specific prior written permission.
1913705f88SJack F Vogel 
2013705f88SJack F Vogel   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2113705f88SJack F Vogel   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2213705f88SJack F Vogel   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2313705f88SJack F Vogel   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2413705f88SJack F Vogel   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2513705f88SJack F Vogel   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2613705f88SJack F Vogel   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2713705f88SJack F Vogel   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2813705f88SJack F Vogel   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2913705f88SJack F Vogel   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3013705f88SJack F Vogel   POSSIBILITY OF SUCH DAMAGE.
3113705f88SJack F Vogel 
329ca4041bSJack F Vogel ******************************************************************************/
3313705f88SJack F Vogel /*$FreeBSD$*/
3413705f88SJack F Vogel 
351b6e0dbaSJack F Vogel 
3613705f88SJack F Vogel #ifndef _IXGBE_H_
3713705f88SJack F Vogel #define _IXGBE_H_
3813705f88SJack F Vogel 
3913705f88SJack F Vogel 
4013705f88SJack F Vogel #include <sys/param.h>
4113705f88SJack F Vogel #include <sys/systm.h>
42d8602bb9SJack F Vogel #if __FreeBSD_version >= 800000
43d8602bb9SJack F Vogel #include <sys/buf_ring.h>
44d8602bb9SJack F Vogel #endif
4513705f88SJack F Vogel #include <sys/mbuf.h>
4613705f88SJack F Vogel #include <sys/protosw.h>
4713705f88SJack F Vogel #include <sys/socket.h>
4813705f88SJack F Vogel #include <sys/malloc.h>
4913705f88SJack F Vogel #include <sys/kernel.h>
5013705f88SJack F Vogel #include <sys/module.h>
5113705f88SJack F Vogel #include <sys/sockio.h>
5213705f88SJack F Vogel 
5313705f88SJack F Vogel #include <net/if.h>
5413705f88SJack F Vogel #include <net/if_arp.h>
5513705f88SJack F Vogel #include <net/bpf.h>
5613705f88SJack F Vogel #include <net/ethernet.h>
5713705f88SJack F Vogel #include <net/if_dl.h>
5813705f88SJack F Vogel #include <net/if_media.h>
5913705f88SJack F Vogel 
6013705f88SJack F Vogel #include <net/bpf.h>
6113705f88SJack F Vogel #include <net/if_types.h>
6213705f88SJack F Vogel #include <net/if_vlan_var.h>
6313705f88SJack F Vogel 
6413705f88SJack F Vogel #include <netinet/in_systm.h>
6513705f88SJack F Vogel #include <netinet/in.h>
6613705f88SJack F Vogel #include <netinet/if_ether.h>
6713705f88SJack F Vogel #include <netinet/ip.h>
6813705f88SJack F Vogel #include <netinet/ip6.h>
6913705f88SJack F Vogel #include <netinet/tcp.h>
700ac6dfecSJack F Vogel #include <netinet/tcp_lro.h>
7113705f88SJack F Vogel #include <netinet/udp.h>
7213705f88SJack F Vogel 
7313705f88SJack F Vogel #include <machine/in_cksum.h>
7413705f88SJack F Vogel 
7513705f88SJack F Vogel #include <sys/bus.h>
7613705f88SJack F Vogel #include <machine/bus.h>
7713705f88SJack F Vogel #include <sys/rman.h>
7813705f88SJack F Vogel #include <machine/resource.h>
7913705f88SJack F Vogel #include <vm/vm.h>
8013705f88SJack F Vogel #include <vm/pmap.h>
8113705f88SJack F Vogel #include <machine/clock.h>
8213705f88SJack F Vogel #include <dev/pci/pcivar.h>
8313705f88SJack F Vogel #include <dev/pci/pcireg.h>
8413705f88SJack F Vogel #include <sys/proc.h>
8513705f88SJack F Vogel #include <sys/sysctl.h>
8613705f88SJack F Vogel #include <sys/endian.h>
8713705f88SJack F Vogel #include <sys/taskqueue.h>
889ca4041bSJack F Vogel #include <sys/pcpu.h>
89d8602bb9SJack F Vogel #include <sys/smp.h>
90d8602bb9SJack F Vogel #include <machine/smp.h>
9113705f88SJack F Vogel 
92d8602bb9SJack F Vogel #ifdef IXGBE_IEEE1588
93d8602bb9SJack F Vogel #include <sys/ieee1588.h>
940ac6dfecSJack F Vogel #endif
950ac6dfecSJack F Vogel 
9613705f88SJack F Vogel #include "ixgbe_api.h"
9713705f88SJack F Vogel 
9813705f88SJack F Vogel /* Tunables */
9913705f88SJack F Vogel 
10013705f88SJack F Vogel /*
1013ec35e52SJack F Vogel  * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
10213705f88SJack F Vogel  * number of transmit descriptors allocated by the driver. Increasing this
10313705f88SJack F Vogel  * value allows the driver to queue more transmits. Each descriptor is 16
1043ec35e52SJack F Vogel  * bytes. Performance tests have show the 2K value to be optimal for top
1053ec35e52SJack F Vogel  * performance.
10613705f88SJack F Vogel  */
1070ac6dfecSJack F Vogel #define DEFAULT_TXD	1024
1083ec35e52SJack F Vogel #define PERFORM_TXD	2048
10913705f88SJack F Vogel #define MAX_TXD		4096
11013705f88SJack F Vogel #define MIN_TXD		64
11113705f88SJack F Vogel 
11213705f88SJack F Vogel /*
1133ec35e52SJack F Vogel  * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
1143ec35e52SJack F Vogel  * number of receive descriptors allocated for each RX queue. Increasing this
11513705f88SJack F Vogel  * value allows the driver to buffer more incoming packets. Each descriptor
1163ec35e52SJack F Vogel  * is 16 bytes.  A receive buffer is also allocated for each descriptor.
11713705f88SJack F Vogel  *
1183ec35e52SJack F Vogel  * Note: with 8 rings and a dual port card, it is possible to bump up
1193ec35e52SJack F Vogel  *	against the system mbuf pool limit, you can tune nmbclusters
1203ec35e52SJack F Vogel  *	to adjust for this.
12113705f88SJack F Vogel  */
1220ac6dfecSJack F Vogel #define DEFAULT_RXD	1024
1233ec35e52SJack F Vogel #define PERFORM_RXD	2048
12413705f88SJack F Vogel #define MAX_RXD		4096
12513705f88SJack F Vogel #define MIN_RXD		64
12613705f88SJack F Vogel 
1273ec35e52SJack F Vogel /* Alignment for rings */
1283ec35e52SJack F Vogel #define DBA_ALIGN	128
1293ec35e52SJack F Vogel 
13013705f88SJack F Vogel /*
13113705f88SJack F Vogel  * This parameter controls the maximum no of times the driver will loop in
13213705f88SJack F Vogel  * the isr. Minimum Value = 1
13313705f88SJack F Vogel  */
1341b6e0dbaSJack F Vogel #define MAX_LOOP	10
13513705f88SJack F Vogel 
13613705f88SJack F Vogel /*
1372969bf0eSJack F Vogel  * This is the max watchdog interval, ie. the time that can
1382969bf0eSJack F Vogel  * pass between any two TX clean operations, such only happening
1392969bf0eSJack F Vogel  * when the TX hardware is functioning.
14013705f88SJack F Vogel  */
1412969bf0eSJack F Vogel #define IXGBE_WATCHDOG                   (10 * hz)
14213705f88SJack F Vogel 
14313705f88SJack F Vogel /*
14413705f88SJack F Vogel  * This parameters control when the driver calls the routine to reclaim
14513705f88SJack F Vogel  * transmit descriptors.
14613705f88SJack F Vogel  */
14713705f88SJack F Vogel #define IXGBE_TX_CLEANUP_THRESHOLD	(adapter->num_tx_desc / 8)
14813705f88SJack F Vogel #define IXGBE_TX_OP_THRESHOLD		(adapter->num_tx_desc / 32)
14913705f88SJack F Vogel 
15013705f88SJack F Vogel #define IXGBE_MAX_FRAME_SIZE	0x3F00
15113705f88SJack F Vogel 
1523ec35e52SJack F Vogel /* Flow control constants */
1532969bf0eSJack F Vogel #define IXGBE_FC_PAUSE		0xFFFF
1543ec35e52SJack F Vogel #define IXGBE_FC_HI		0x20000
1553ec35e52SJack F Vogel #define IXGBE_FC_LO		0x10000
15613705f88SJack F Vogel 
15713705f88SJack F Vogel /* Defines for printing debug information */
15813705f88SJack F Vogel #define DEBUG_INIT  0
15913705f88SJack F Vogel #define DEBUG_IOCTL 0
16013705f88SJack F Vogel #define DEBUG_HW    0
16113705f88SJack F Vogel 
16213705f88SJack F Vogel #define INIT_DEBUGOUT(S)            if (DEBUG_INIT)  printf(S "\n")
16313705f88SJack F Vogel #define INIT_DEBUGOUT1(S, A)        if (DEBUG_INIT)  printf(S "\n", A)
16413705f88SJack F Vogel #define INIT_DEBUGOUT2(S, A, B)     if (DEBUG_INIT)  printf(S "\n", A, B)
16513705f88SJack F Vogel #define IOCTL_DEBUGOUT(S)           if (DEBUG_IOCTL) printf(S "\n")
16613705f88SJack F Vogel #define IOCTL_DEBUGOUT1(S, A)       if (DEBUG_IOCTL) printf(S "\n", A)
16713705f88SJack F Vogel #define IOCTL_DEBUGOUT2(S, A, B)    if (DEBUG_IOCTL) printf(S "\n", A, B)
16813705f88SJack F Vogel #define HW_DEBUGOUT(S)              if (DEBUG_HW) printf(S "\n")
16913705f88SJack F Vogel #define HW_DEBUGOUT1(S, A)          if (DEBUG_HW) printf(S "\n", A)
17013705f88SJack F Vogel #define HW_DEBUGOUT2(S, A, B)       if (DEBUG_HW) printf(S "\n", A, B)
17113705f88SJack F Vogel 
17213705f88SJack F Vogel #define MAX_NUM_MULTICAST_ADDRESSES     128
1730ac6dfecSJack F Vogel #define IXGBE_82598_SCATTER		100
1740ac6dfecSJack F Vogel #define IXGBE_82599_SCATTER		32
1751b6e0dbaSJack F Vogel #define MSIX_82598_BAR			3
1761b6e0dbaSJack F Vogel #define MSIX_82599_BAR			4
17713705f88SJack F Vogel #define IXGBE_TSO_SIZE			65535
17813705f88SJack F Vogel #define IXGBE_TX_BUFFER_SIZE		((u32) 1514)
179c0014855SJack F Vogel #define IXGBE_RX_HDR			128
180d8602bb9SJack F Vogel #define IXGBE_VFTA_SIZE			128
181d8602bb9SJack F Vogel #define IXGBE_BR_SIZE			4096
18213705f88SJack F Vogel #define CSUM_OFFLOAD			7	/* Bits in csum flags */
18313705f88SJack F Vogel 
1843ec35e52SJack F Vogel /* For 6.X code compatibility */
1850ac6dfecSJack F Vogel #if !defined(ETHER_BPF_MTAP)
1863ec35e52SJack F Vogel #define ETHER_BPF_MTAP		BPF_MTAP
1870ac6dfecSJack F Vogel #endif
1880ac6dfecSJack F Vogel 
1890ac6dfecSJack F Vogel #if __FreeBSD_version < 700000
1903ec35e52SJack F Vogel #define CSUM_TSO		0
1913ec35e52SJack F Vogel #define IFCAP_TSO4		0
1923ec35e52SJack F Vogel #endif
1933ec35e52SJack F Vogel 
19413705f88SJack F Vogel /*
19513705f88SJack F Vogel  * Interrupt Moderation parameters
19613705f88SJack F Vogel  */
1971b6e0dbaSJack F Vogel #define IXGBE_LOW_LATENCY	128
1981b6e0dbaSJack F Vogel #define IXGBE_AVE_LATENCY	400
1991b6e0dbaSJack F Vogel #define IXGBE_BULK_LATENCY	1200
2001b6e0dbaSJack F Vogel #define IXGBE_LINK_ITR		2000
2011b6e0dbaSJack F Vogel 
2021b6e0dbaSJack F Vogel /* Header split args for get_bug */
2031b6e0dbaSJack F Vogel #define IXGBE_CLEAN_HDR		1
2041b6e0dbaSJack F Vogel #define IXGBE_CLEAN_PKT		2
2051b6e0dbaSJack F Vogel #define IXGBE_CLEAN_ALL		3
20613705f88SJack F Vogel 
20713705f88SJack F Vogel /*
2081b6e0dbaSJack F Vogel  *****************************************************************************
20913705f88SJack F Vogel  * vendor_info_array
21013705f88SJack F Vogel  *
21113705f88SJack F Vogel  * This array contains the list of Subvendor/Subdevice IDs on which the driver
21213705f88SJack F Vogel  * should load.
21313705f88SJack F Vogel  *
21413705f88SJack F Vogel  *****************************************************************************
21513705f88SJack F Vogel  */
21613705f88SJack F Vogel typedef struct _ixgbe_vendor_info_t {
21713705f88SJack F Vogel 	unsigned int    vendor_id;
21813705f88SJack F Vogel 	unsigned int    device_id;
21913705f88SJack F Vogel 	unsigned int    subvendor_id;
22013705f88SJack F Vogel 	unsigned int    subdevice_id;
22113705f88SJack F Vogel 	unsigned int    index;
22213705f88SJack F Vogel } ixgbe_vendor_info_t;
22313705f88SJack F Vogel 
22413705f88SJack F Vogel 
22513705f88SJack F Vogel struct ixgbe_tx_buf {
2260ac6dfecSJack F Vogel 	u32		eop_index;
22713705f88SJack F Vogel 	struct mbuf	*m_head;
22813705f88SJack F Vogel 	bus_dmamap_t	map;
22913705f88SJack F Vogel };
23013705f88SJack F Vogel 
23113705f88SJack F Vogel struct ixgbe_rx_buf {
23213705f88SJack F Vogel 	struct mbuf	*m_head;
2331b6e0dbaSJack F Vogel 	struct mbuf	*m_pack;
234c0014855SJack F Vogel 	struct mbuf	*fmp;
2351b6e0dbaSJack F Vogel 	bus_dmamap_t	map;
23613705f88SJack F Vogel };
23713705f88SJack F Vogel 
23813705f88SJack F Vogel /*
23913705f88SJack F Vogel  * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free.
24013705f88SJack F Vogel  */
24113705f88SJack F Vogel struct ixgbe_dma_alloc {
24213705f88SJack F Vogel 	bus_addr_t		dma_paddr;
24313705f88SJack F Vogel 	caddr_t			dma_vaddr;
24413705f88SJack F Vogel 	bus_dma_tag_t		dma_tag;
24513705f88SJack F Vogel 	bus_dmamap_t		dma_map;
24613705f88SJack F Vogel 	bus_dma_segment_t	dma_seg;
24713705f88SJack F Vogel 	bus_size_t		dma_size;
24813705f88SJack F Vogel 	int			dma_nseg;
24913705f88SJack F Vogel };
25013705f88SJack F Vogel 
25113705f88SJack F Vogel /*
252c0014855SJack F Vogel ** Driver queue struct: this is the interrupt container
253c0014855SJack F Vogel **  for the associated tx and rx ring.
254c0014855SJack F Vogel */
255c0014855SJack F Vogel struct ix_queue {
256c0014855SJack F Vogel 	struct adapter		*adapter;
257c0014855SJack F Vogel 	u32			msix;           /* This queue's MSIX vector */
258c0014855SJack F Vogel 	u32			eims;           /* This queue's EIMS bit */
259c0014855SJack F Vogel 	u32			eitr_setting;
260c0014855SJack F Vogel 	struct resource		*res;
261c0014855SJack F Vogel 	void			*tag;
262c0014855SJack F Vogel 	struct tx_ring		*txr;
263c0014855SJack F Vogel 	struct rx_ring		*rxr;
264c0014855SJack F Vogel 	struct task		que_task;
265c0014855SJack F Vogel 	struct taskqueue	*tq;
266c0014855SJack F Vogel 	u64			irqs;
267c0014855SJack F Vogel };
268c0014855SJack F Vogel 
269c0014855SJack F Vogel /*
270c0014855SJack F Vogel  * The transmit ring, one per queue
27113705f88SJack F Vogel  */
27213705f88SJack F Vogel struct tx_ring {
27313705f88SJack F Vogel         struct adapter		*adapter;
2749ca4041bSJack F Vogel 	struct mtx		tx_mtx;
27513705f88SJack F Vogel 	u32			me;
2762969bf0eSJack F Vogel 	bool			watchdog_check;
2772969bf0eSJack F Vogel 	int			watchdog_time;
27813705f88SJack F Vogel 	union ixgbe_adv_tx_desc	*tx_base;
27913705f88SJack F Vogel 	struct ixgbe_dma_alloc	txdma;
2802969bf0eSJack F Vogel 	u32			next_avail_desc;
2812969bf0eSJack F Vogel 	u32			next_to_clean;
28213705f88SJack F Vogel 	struct ixgbe_tx_buf	*tx_buffers;
2839ca4041bSJack F Vogel 	volatile u16		tx_avail;
2849ca4041bSJack F Vogel 	u32			txd_cmd;
28513705f88SJack F Vogel 	bus_dma_tag_t		txtag;
2861b6e0dbaSJack F Vogel 	char			mtx_name[16];
287d8602bb9SJack F Vogel #if __FreeBSD_version >= 800000
288d8602bb9SJack F Vogel 	struct buf_ring		*br;
289d8602bb9SJack F Vogel #endif
2902969bf0eSJack F Vogel #ifdef IXGBE_FDIR
2912969bf0eSJack F Vogel 	u16			atr_sample;
2922969bf0eSJack F Vogel 	u16			atr_count;
2932969bf0eSJack F Vogel #endif
294c0014855SJack F Vogel 	u32			bytes;  /* used for AIM */
295c0014855SJack F Vogel 	u32			packets;
2969ca4041bSJack F Vogel 	/* Soft Stats */
297c0014855SJack F Vogel 	u64			no_desc_avail;
2981b6e0dbaSJack F Vogel 	u64			total_packets;
29913705f88SJack F Vogel };
30013705f88SJack F Vogel 
30113705f88SJack F Vogel 
30213705f88SJack F Vogel /*
30313705f88SJack F Vogel  * The Receive ring, one per rx queue
30413705f88SJack F Vogel  */
30513705f88SJack F Vogel struct rx_ring {
30613705f88SJack F Vogel         struct adapter		*adapter;
3079ca4041bSJack F Vogel 	struct mtx		rx_mtx;
30813705f88SJack F Vogel 	u32			me;
30913705f88SJack F Vogel 	union ixgbe_adv_rx_desc	*rx_base;
31013705f88SJack F Vogel 	struct ixgbe_dma_alloc	rxdma;
3119ca4041bSJack F Vogel 	struct lro_ctrl		lro;
312d8602bb9SJack F Vogel 	bool			lro_enabled;
313d8602bb9SJack F Vogel 	bool			hdr_split;
3142969bf0eSJack F Vogel 	bool			hw_rsc;
315c0014855SJack F Vogel 	bool			discard;
316c0014855SJack F Vogel         u32			next_to_refresh;
317c0014855SJack F Vogel         u32 			next_to_check;
318c0014855SJack F Vogel 	char			mtx_name[16];
31913705f88SJack F Vogel 	struct ixgbe_rx_buf	*rx_buffers;
3201b6e0dbaSJack F Vogel 	bus_dma_tag_t		rxtag;
3211b6e0dbaSJack F Vogel 	bus_dmamap_t		spare_map;
3221b6e0dbaSJack F Vogel 
3231b6e0dbaSJack F Vogel 	u32			bytes; /* Used for AIM calc */
324c0014855SJack F Vogel 	u32			packets;
325d8602bb9SJack F Vogel 
32613705f88SJack F Vogel 	/* Soft stats */
3279ca4041bSJack F Vogel 	u64			rx_irq;
3281b6e0dbaSJack F Vogel 	u64			rx_split_packets;
3291b6e0dbaSJack F Vogel 	u64			rx_packets;
3301b6e0dbaSJack F Vogel 	u64 			rx_bytes;
331c0014855SJack F Vogel 	u64 			rx_discarded;
3322969bf0eSJack F Vogel 	u64 			rsc_num;
3332969bf0eSJack F Vogel #ifdef IXGBE_FDIR
3342969bf0eSJack F Vogel 	u64			flm;
3352969bf0eSJack F Vogel #endif
33613705f88SJack F Vogel };
33713705f88SJack F Vogel 
33813705f88SJack F Vogel /* Our adapter structure */
33913705f88SJack F Vogel struct adapter {
34013705f88SJack F Vogel 	struct ifnet		*ifp;
34113705f88SJack F Vogel 	struct ixgbe_hw		hw;
34213705f88SJack F Vogel 
34313705f88SJack F Vogel 	struct ixgbe_osdep	osdep;
34413705f88SJack F Vogel 	struct device		*dev;
3459ca4041bSJack F Vogel 
3469ca4041bSJack F Vogel 	struct resource		*pci_mem;
3479ca4041bSJack F Vogel 	struct resource		*msix_mem;
34813705f88SJack F Vogel 
34913705f88SJack F Vogel 	/*
350d8602bb9SJack F Vogel 	 * Interrupt resources: this set is
351d8602bb9SJack F Vogel 	 * either used for legacy, or for Link
352d8602bb9SJack F Vogel 	 * when doing MSIX
35313705f88SJack F Vogel 	 */
354d8602bb9SJack F Vogel 	void			*tag;
355d8602bb9SJack F Vogel 	struct resource 	*res;
35613705f88SJack F Vogel 
35713705f88SJack F Vogel 	struct ifmedia		media;
35813705f88SJack F Vogel 	struct callout		timer;
35913705f88SJack F Vogel 	int			msix;
36013705f88SJack F Vogel 	int			if_flags;
3619ca4041bSJack F Vogel 
3623ec35e52SJack F Vogel 	struct mtx		core_mtx;
3639ca4041bSJack F Vogel 
364d8602bb9SJack F Vogel 	eventhandler_tag 	vlan_attach;
365d8602bb9SJack F Vogel 	eventhandler_tag 	vlan_detach;
366d8602bb9SJack F Vogel 
3672969bf0eSJack F Vogel 	u16			num_vlans;
368d8602bb9SJack F Vogel 	u16			num_queues;
369d8602bb9SJack F Vogel 
37013705f88SJack F Vogel 	/* Info about the board itself */
3711b6e0dbaSJack F Vogel 	u32			optics;
3729ca4041bSJack F Vogel 	bool			link_active;
3739ca4041bSJack F Vogel 	u16			max_frame_size;
3749ca4041bSJack F Vogel 	u32			link_speed;
3750ac6dfecSJack F Vogel 	bool			link_up;
3761b6e0dbaSJack F Vogel 	u32 			linkvec;
37713705f88SJack F Vogel 
3781b6e0dbaSJack F Vogel 	/* Mbuf cluster size */
3791b6e0dbaSJack F Vogel 	u32			rx_mbuf_sz;
3801b6e0dbaSJack F Vogel 
3810ac6dfecSJack F Vogel 	/* Support for pluggable optics */
3821b6e0dbaSJack F Vogel 	bool			sfp_probe;
3830ac6dfecSJack F Vogel 	struct task     	link_task;  /* Link tasklet */
3840ac6dfecSJack F Vogel 	struct task     	mod_task;   /* SFP tasklet */
385c0014855SJack F Vogel 	struct task     	msf_task;   /* Multispeed Fiber */
3862969bf0eSJack F Vogel #ifdef IXGBE_FDIR
3872969bf0eSJack F Vogel 	int			fdir_reinit;
3882969bf0eSJack F Vogel 	struct task     	fdir_task;
3892969bf0eSJack F Vogel #endif
3900ac6dfecSJack F Vogel 	struct taskqueue	*tq;
39113705f88SJack F Vogel 
39213705f88SJack F Vogel 	/*
393c0014855SJack F Vogel 	** Queues:
394c0014855SJack F Vogel 	**   This is the irq holder, it has
395c0014855SJack F Vogel 	**   and RX/TX pair or rings associated
396c0014855SJack F Vogel 	**   with it.
397c0014855SJack F Vogel 	*/
398c0014855SJack F Vogel 	struct ix_queue		*queues;
399c0014855SJack F Vogel 
400c0014855SJack F Vogel 	/*
40113705f88SJack F Vogel 	 * Transmit rings:
40213705f88SJack F Vogel 	 *	Allocated at run time, an array of rings.
40313705f88SJack F Vogel 	 */
40413705f88SJack F Vogel 	struct tx_ring		*tx_rings;
40513705f88SJack F Vogel 	int			num_tx_desc;
40613705f88SJack F Vogel 
40713705f88SJack F Vogel 	/*
40813705f88SJack F Vogel 	 * Receive rings:
40913705f88SJack F Vogel 	 *	Allocated at run time, an array of rings.
41013705f88SJack F Vogel 	 */
41113705f88SJack F Vogel 	struct rx_ring		*rx_rings;
41213705f88SJack F Vogel 	int			num_rx_desc;
413c0014855SJack F Vogel 	u64			que_mask;
4149ca4041bSJack F Vogel 	u32			rx_process_limit;
41513705f88SJack F Vogel 
41613705f88SJack F Vogel 	/* Misc stats maintained by the driver */
41713705f88SJack F Vogel 	unsigned long   	dropped_pkts;
4181b6e0dbaSJack F Vogel 	unsigned long   	mbuf_defrag_failed;
4191b6e0dbaSJack F Vogel 	unsigned long   	mbuf_header_failed;
4201b6e0dbaSJack F Vogel 	unsigned long   	mbuf_packet_failed;
42113705f88SJack F Vogel 	unsigned long   	no_tx_map_avail;
42213705f88SJack F Vogel 	unsigned long   	no_tx_dma_setup;
42313705f88SJack F Vogel 	unsigned long   	watchdog_events;
42413705f88SJack F Vogel 	unsigned long   	tso_tx;
4259ca4041bSJack F Vogel 	unsigned long		link_irq;
42613705f88SJack F Vogel 
42713705f88SJack F Vogel 	struct ixgbe_hw_stats 	stats;
42813705f88SJack F Vogel };
42913705f88SJack F Vogel 
4300ac6dfecSJack F Vogel /* Precision Time Sync (IEEE 1588) defines */
4310ac6dfecSJack F Vogel #define ETHERTYPE_IEEE1588      0x88F7
4320ac6dfecSJack F Vogel #define PICOSECS_PER_TICK       20833
4330ac6dfecSJack F Vogel #define TSYNC_UDP_PORT          319 /* UDP port for the protocol */
4340ac6dfecSJack F Vogel #define IXGBE_ADVTXD_TSTAMP	0x00080000
4350ac6dfecSJack F Vogel 
4360ac6dfecSJack F Vogel 
4379ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
4389ca4041bSJack F Vogel         mtx_init(&(_sc)->core_mtx, _name, "IXGBE Core Lock", MTX_DEF)
4399ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_DESTROY(_sc)      mtx_destroy(&(_sc)->core_mtx)
4409ca4041bSJack F Vogel #define IXGBE_TX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->tx_mtx)
4419ca4041bSJack F Vogel #define IXGBE_RX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->rx_mtx)
4429ca4041bSJack F Vogel #define IXGBE_CORE_LOCK(_sc)              mtx_lock(&(_sc)->core_mtx)
4439ca4041bSJack F Vogel #define IXGBE_TX_LOCK(_sc)                mtx_lock(&(_sc)->tx_mtx)
4440ac6dfecSJack F Vogel #define IXGBE_TX_TRYLOCK(_sc)             mtx_trylock(&(_sc)->tx_mtx)
4459ca4041bSJack F Vogel #define IXGBE_RX_LOCK(_sc)                mtx_lock(&(_sc)->rx_mtx)
4469ca4041bSJack F Vogel #define IXGBE_CORE_UNLOCK(_sc)            mtx_unlock(&(_sc)->core_mtx)
4479ca4041bSJack F Vogel #define IXGBE_TX_UNLOCK(_sc)              mtx_unlock(&(_sc)->tx_mtx)
4489ca4041bSJack F Vogel #define IXGBE_RX_UNLOCK(_sc)              mtx_unlock(&(_sc)->rx_mtx)
4499ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_ASSERT(_sc)       mtx_assert(&(_sc)->core_mtx, MA_OWNED)
4509ca4041bSJack F Vogel #define IXGBE_TX_LOCK_ASSERT(_sc)         mtx_assert(&(_sc)->tx_mtx, MA_OWNED)
4519ca4041bSJack F Vogel 
4529ca4041bSJack F Vogel 
4530ac6dfecSJack F Vogel static inline bool
4540ac6dfecSJack F Vogel ixgbe_is_sfp(struct ixgbe_hw *hw)
4550ac6dfecSJack F Vogel {
4560ac6dfecSJack F Vogel 	switch (hw->phy.type) {
4570ac6dfecSJack F Vogel 	case ixgbe_phy_sfp_avago:
4580ac6dfecSJack F Vogel 	case ixgbe_phy_sfp_ftl:
4590ac6dfecSJack F Vogel 	case ixgbe_phy_sfp_intel:
4600ac6dfecSJack F Vogel 	case ixgbe_phy_sfp_unknown:
461c0014855SJack F Vogel 	case ixgbe_phy_sfp_passive_tyco:
462c0014855SJack F Vogel 	case ixgbe_phy_sfp_passive_unknown:
4630ac6dfecSJack F Vogel 		return TRUE;
4640ac6dfecSJack F Vogel 	default:
4650ac6dfecSJack F Vogel 		return FALSE;
4660ac6dfecSJack F Vogel 	}
4670ac6dfecSJack F Vogel }
4680ac6dfecSJack F Vogel 
46913705f88SJack F Vogel #endif /* _IXGBE_H_ */
470