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 182*1a4e3449SJack F Vogel #define IXGBE_QUEUE_IDLE 0 183*1a4e3449SJack F Vogel #define IXGBE_QUEUE_WORKING 1 184*1a4e3449SJack F Vogel #define IXGBE_QUEUE_HUNG 2 1859de5aff5SJack F Vogel 1869de5aff5SJack F Vogel /* Offload bits in mbuf flag */ 1879de5aff5SJack F Vogel #if __FreeBSD_version >= 800000 1889de5aff5SJack F Vogel #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP) 1899de5aff5SJack F Vogel #else 1909de5aff5SJack F Vogel #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP) 1919de5aff5SJack F Vogel #endif 19213705f88SJack F Vogel 1933ec35e52SJack F Vogel /* For 6.X code compatibility */ 1940ac6dfecSJack F Vogel #if !defined(ETHER_BPF_MTAP) 1953ec35e52SJack F Vogel #define ETHER_BPF_MTAP BPF_MTAP 1960ac6dfecSJack F Vogel #endif 1970ac6dfecSJack F Vogel 1980ac6dfecSJack F Vogel #if __FreeBSD_version < 700000 1993ec35e52SJack F Vogel #define CSUM_TSO 0 2003ec35e52SJack F Vogel #define IFCAP_TSO4 0 2013ec35e52SJack F Vogel #endif 2023ec35e52SJack F Vogel 20313705f88SJack F Vogel /* 20413705f88SJack F Vogel * Interrupt Moderation parameters 20513705f88SJack F Vogel */ 2061b6e0dbaSJack F Vogel #define IXGBE_LOW_LATENCY 128 2071b6e0dbaSJack F Vogel #define IXGBE_AVE_LATENCY 400 2081b6e0dbaSJack F Vogel #define IXGBE_BULK_LATENCY 1200 2091b6e0dbaSJack F Vogel #define IXGBE_LINK_ITR 2000 2101b6e0dbaSJack F Vogel 21113705f88SJack F Vogel /* 2121b6e0dbaSJack F Vogel ***************************************************************************** 21313705f88SJack F Vogel * vendor_info_array 21413705f88SJack F Vogel * 21513705f88SJack F Vogel * This array contains the list of Subvendor/Subdevice IDs on which the driver 21613705f88SJack F Vogel * should load. 21713705f88SJack F Vogel * 21813705f88SJack F Vogel ***************************************************************************** 21913705f88SJack F Vogel */ 22013705f88SJack F Vogel typedef struct _ixgbe_vendor_info_t { 22113705f88SJack F Vogel unsigned int vendor_id; 22213705f88SJack F Vogel unsigned int device_id; 22313705f88SJack F Vogel unsigned int subvendor_id; 22413705f88SJack F Vogel unsigned int subdevice_id; 22513705f88SJack F Vogel unsigned int index; 22613705f88SJack F Vogel } ixgbe_vendor_info_t; 22713705f88SJack F Vogel 22813705f88SJack F Vogel 22913705f88SJack F Vogel struct ixgbe_tx_buf { 2300ac6dfecSJack F Vogel u32 eop_index; 23113705f88SJack F Vogel struct mbuf *m_head; 23213705f88SJack F Vogel bus_dmamap_t map; 23313705f88SJack F Vogel }; 23413705f88SJack F Vogel 23513705f88SJack F Vogel struct ixgbe_rx_buf { 23613705f88SJack F Vogel struct mbuf *m_head; 2371b6e0dbaSJack F Vogel struct mbuf *m_pack; 238c0014855SJack F Vogel struct mbuf *fmp; 2393f13ffabSJack F Vogel bus_dmamap_t hmap; 2403f13ffabSJack F Vogel bus_dmamap_t pmap; 24113705f88SJack F Vogel }; 24213705f88SJack F Vogel 24313705f88SJack F Vogel /* 24413705f88SJack F Vogel * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free. 24513705f88SJack F Vogel */ 24613705f88SJack F Vogel struct ixgbe_dma_alloc { 24713705f88SJack F Vogel bus_addr_t dma_paddr; 24813705f88SJack F Vogel caddr_t dma_vaddr; 24913705f88SJack F Vogel bus_dma_tag_t dma_tag; 25013705f88SJack F Vogel bus_dmamap_t dma_map; 25113705f88SJack F Vogel bus_dma_segment_t dma_seg; 25213705f88SJack F Vogel bus_size_t dma_size; 25313705f88SJack F Vogel int dma_nseg; 25413705f88SJack F Vogel }; 25513705f88SJack F Vogel 25613705f88SJack F Vogel /* 257c0014855SJack F Vogel ** Driver queue struct: this is the interrupt container 258c0014855SJack F Vogel ** for the associated tx and rx ring. 259c0014855SJack F Vogel */ 260c0014855SJack F Vogel struct ix_queue { 261c0014855SJack F Vogel struct adapter *adapter; 262c0014855SJack F Vogel u32 msix; /* This queue's MSIX vector */ 263c0014855SJack F Vogel u32 eims; /* This queue's EIMS bit */ 264c0014855SJack F Vogel u32 eitr_setting; 265c0014855SJack F Vogel struct resource *res; 266c0014855SJack F Vogel void *tag; 267c0014855SJack F Vogel struct tx_ring *txr; 268c0014855SJack F Vogel struct rx_ring *rxr; 269c0014855SJack F Vogel struct task que_task; 270c0014855SJack F Vogel struct taskqueue *tq; 271c0014855SJack F Vogel u64 irqs; 272c0014855SJack F Vogel }; 273c0014855SJack F Vogel 274c0014855SJack F Vogel /* 275c0014855SJack F Vogel * The transmit ring, one per queue 27613705f88SJack F Vogel */ 27713705f88SJack F Vogel struct tx_ring { 27813705f88SJack F Vogel struct adapter *adapter; 2799ca4041bSJack F Vogel struct mtx tx_mtx; 28013705f88SJack F Vogel u32 me; 281*1a4e3449SJack F Vogel int queue_status; 2822969bf0eSJack F Vogel int watchdog_time; 28313705f88SJack F Vogel union ixgbe_adv_tx_desc *tx_base; 28413705f88SJack F Vogel struct ixgbe_dma_alloc txdma; 2852969bf0eSJack F Vogel u32 next_avail_desc; 2862969bf0eSJack F Vogel u32 next_to_clean; 28713705f88SJack F Vogel struct ixgbe_tx_buf *tx_buffers; 2889ca4041bSJack F Vogel volatile u16 tx_avail; 2899ca4041bSJack F Vogel u32 txd_cmd; 29013705f88SJack F Vogel bus_dma_tag_t txtag; 2911b6e0dbaSJack F Vogel char mtx_name[16]; 292d8602bb9SJack F Vogel #if __FreeBSD_version >= 800000 293d8602bb9SJack F Vogel struct buf_ring *br; 294d8602bb9SJack F Vogel #endif 2952969bf0eSJack F Vogel #ifdef IXGBE_FDIR 2962969bf0eSJack F Vogel u16 atr_sample; 2972969bf0eSJack F Vogel u16 atr_count; 2982969bf0eSJack F Vogel #endif 299c0014855SJack F Vogel u32 bytes; /* used for AIM */ 300c0014855SJack F Vogel u32 packets; 3019ca4041bSJack F Vogel /* Soft Stats */ 302c0014855SJack F Vogel u64 no_desc_avail; 3031b6e0dbaSJack F Vogel u64 total_packets; 30413705f88SJack F Vogel }; 30513705f88SJack F Vogel 30613705f88SJack F Vogel 30713705f88SJack F Vogel /* 30813705f88SJack F Vogel * The Receive ring, one per rx queue 30913705f88SJack F Vogel */ 31013705f88SJack F Vogel struct rx_ring { 31113705f88SJack F Vogel struct adapter *adapter; 3129ca4041bSJack F Vogel struct mtx rx_mtx; 31313705f88SJack F Vogel u32 me; 31413705f88SJack F Vogel union ixgbe_adv_rx_desc *rx_base; 31513705f88SJack F Vogel struct ixgbe_dma_alloc rxdma; 3169ca4041bSJack F Vogel struct lro_ctrl lro; 317d8602bb9SJack F Vogel bool lro_enabled; 318d8602bb9SJack F Vogel bool hdr_split; 3192969bf0eSJack F Vogel bool hw_rsc; 320c0014855SJack F Vogel bool discard; 321c0014855SJack F Vogel u32 next_to_refresh; 322c0014855SJack F Vogel u32 next_to_check; 323c0014855SJack F Vogel char mtx_name[16]; 32413705f88SJack F Vogel struct ixgbe_rx_buf *rx_buffers; 3253f13ffabSJack F Vogel bus_dma_tag_t htag; 3263f13ffabSJack F Vogel bus_dma_tag_t ptag; 3271b6e0dbaSJack F Vogel 3281b6e0dbaSJack F Vogel u32 bytes; /* Used for AIM calc */ 329c0014855SJack F Vogel u32 packets; 330d8602bb9SJack F Vogel 33113705f88SJack F Vogel /* Soft stats */ 3329ca4041bSJack F Vogel u64 rx_irq; 3331b6e0dbaSJack F Vogel u64 rx_split_packets; 3341b6e0dbaSJack F Vogel u64 rx_packets; 3351b6e0dbaSJack F Vogel u64 rx_bytes; 336c0014855SJack F Vogel u64 rx_discarded; 3372969bf0eSJack F Vogel u64 rsc_num; 3382969bf0eSJack F Vogel #ifdef IXGBE_FDIR 3392969bf0eSJack F Vogel u64 flm; 3402969bf0eSJack F Vogel #endif 34113705f88SJack F Vogel }; 34213705f88SJack F Vogel 34313705f88SJack F Vogel /* Our adapter structure */ 34413705f88SJack F Vogel struct adapter { 34513705f88SJack F Vogel struct ifnet *ifp; 34613705f88SJack F Vogel struct ixgbe_hw hw; 34713705f88SJack F Vogel 34813705f88SJack F Vogel struct ixgbe_osdep osdep; 34913705f88SJack F Vogel struct device *dev; 3509ca4041bSJack F Vogel 3519ca4041bSJack F Vogel struct resource *pci_mem; 3529ca4041bSJack F Vogel struct resource *msix_mem; 35313705f88SJack F Vogel 35413705f88SJack F Vogel /* 355d8602bb9SJack F Vogel * Interrupt resources: this set is 356d8602bb9SJack F Vogel * either used for legacy, or for Link 357d8602bb9SJack F Vogel * when doing MSIX 35813705f88SJack F Vogel */ 359d8602bb9SJack F Vogel void *tag; 360d8602bb9SJack F Vogel struct resource *res; 36113705f88SJack F Vogel 36213705f88SJack F Vogel struct ifmedia media; 36313705f88SJack F Vogel struct callout timer; 36413705f88SJack F Vogel int msix; 36513705f88SJack F Vogel int if_flags; 3669ca4041bSJack F Vogel 3673ec35e52SJack F Vogel struct mtx core_mtx; 3689ca4041bSJack F Vogel 369d8602bb9SJack F Vogel eventhandler_tag vlan_attach; 370d8602bb9SJack F Vogel eventhandler_tag vlan_detach; 371d8602bb9SJack F Vogel 3722969bf0eSJack F Vogel u16 num_vlans; 373d8602bb9SJack F Vogel u16 num_queues; 374d8602bb9SJack F Vogel 375*1a4e3449SJack F Vogel /* 376*1a4e3449SJack F Vogel ** Shadow VFTA table, this is needed because 377*1a4e3449SJack F Vogel ** the real vlan filter table gets cleared during 378*1a4e3449SJack F Vogel ** a soft reset and the driver needs to be able 379*1a4e3449SJack F Vogel ** to repopulate it. 380*1a4e3449SJack F Vogel */ 381*1a4e3449SJack F Vogel u32 shadow_vfta[IXGBE_VFTA_SIZE]; 382*1a4e3449SJack F Vogel 383*1a4e3449SJack F Vogel /* Info about the interface */ 3841b6e0dbaSJack F Vogel u32 optics; 38517d2646bSJack F Vogel int advertise; /* link speeds */ 3869ca4041bSJack F Vogel bool link_active; 3879ca4041bSJack F Vogel u16 max_frame_size; 3889ca4041bSJack F Vogel u32 link_speed; 3890ac6dfecSJack F Vogel bool link_up; 3901b6e0dbaSJack F Vogel u32 linkvec; 39113705f88SJack F Vogel 3921b6e0dbaSJack F Vogel /* Mbuf cluster size */ 3931b6e0dbaSJack F Vogel u32 rx_mbuf_sz; 3941b6e0dbaSJack F Vogel 3950ac6dfecSJack F Vogel /* Support for pluggable optics */ 3961b6e0dbaSJack F Vogel bool sfp_probe; 3970ac6dfecSJack F Vogel struct task link_task; /* Link tasklet */ 3980ac6dfecSJack F Vogel struct task mod_task; /* SFP tasklet */ 399c0014855SJack F Vogel struct task msf_task; /* Multispeed Fiber */ 4002969bf0eSJack F Vogel #ifdef IXGBE_FDIR 4012969bf0eSJack F Vogel int fdir_reinit; 4022969bf0eSJack F Vogel struct task fdir_task; 4032969bf0eSJack F Vogel #endif 4040ac6dfecSJack F Vogel struct taskqueue *tq; 40513705f88SJack F Vogel 40613705f88SJack F Vogel /* 407c0014855SJack F Vogel ** Queues: 408c0014855SJack F Vogel ** This is the irq holder, it has 409c0014855SJack F Vogel ** and RX/TX pair or rings associated 410c0014855SJack F Vogel ** with it. 411c0014855SJack F Vogel */ 412c0014855SJack F Vogel struct ix_queue *queues; 413c0014855SJack F Vogel 414c0014855SJack F Vogel /* 41513705f88SJack F Vogel * Transmit rings: 41613705f88SJack F Vogel * Allocated at run time, an array of rings. 41713705f88SJack F Vogel */ 41813705f88SJack F Vogel struct tx_ring *tx_rings; 41913705f88SJack F Vogel int num_tx_desc; 42013705f88SJack F Vogel 42113705f88SJack F Vogel /* 42213705f88SJack F Vogel * Receive rings: 42313705f88SJack F Vogel * Allocated at run time, an array of rings. 42413705f88SJack F Vogel */ 42513705f88SJack F Vogel struct rx_ring *rx_rings; 42613705f88SJack F Vogel int num_rx_desc; 427c0014855SJack F Vogel u64 que_mask; 4289ca4041bSJack F Vogel u32 rx_process_limit; 42913705f88SJack F Vogel 43013705f88SJack F Vogel /* Misc stats maintained by the driver */ 43113705f88SJack F Vogel unsigned long dropped_pkts; 4321b6e0dbaSJack F Vogel unsigned long mbuf_defrag_failed; 4331b6e0dbaSJack F Vogel unsigned long mbuf_header_failed; 4341b6e0dbaSJack F Vogel unsigned long mbuf_packet_failed; 43513705f88SJack F Vogel unsigned long no_tx_map_avail; 43613705f88SJack F Vogel unsigned long no_tx_dma_setup; 43713705f88SJack F Vogel unsigned long watchdog_events; 43813705f88SJack F Vogel unsigned long tso_tx; 4399ca4041bSJack F Vogel unsigned long link_irq; 44013705f88SJack F Vogel 44113705f88SJack F Vogel struct ixgbe_hw_stats stats; 44213705f88SJack F Vogel }; 44313705f88SJack F Vogel 4440ac6dfecSJack F Vogel /* Precision Time Sync (IEEE 1588) defines */ 4450ac6dfecSJack F Vogel #define ETHERTYPE_IEEE1588 0x88F7 4460ac6dfecSJack F Vogel #define PICOSECS_PER_TICK 20833 4470ac6dfecSJack F Vogel #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */ 4480ac6dfecSJack F Vogel #define IXGBE_ADVTXD_TSTAMP 0x00080000 4490ac6dfecSJack F Vogel 4500ac6dfecSJack F Vogel 4519ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_INIT(_sc, _name) \ 4529ca4041bSJack F Vogel mtx_init(&(_sc)->core_mtx, _name, "IXGBE Core Lock", MTX_DEF) 4539ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->core_mtx) 4549ca4041bSJack F Vogel #define IXGBE_TX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->tx_mtx) 4559ca4041bSJack F Vogel #define IXGBE_RX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->rx_mtx) 4569ca4041bSJack F Vogel #define IXGBE_CORE_LOCK(_sc) mtx_lock(&(_sc)->core_mtx) 4579ca4041bSJack F Vogel #define IXGBE_TX_LOCK(_sc) mtx_lock(&(_sc)->tx_mtx) 4580ac6dfecSJack F Vogel #define IXGBE_TX_TRYLOCK(_sc) mtx_trylock(&(_sc)->tx_mtx) 4599ca4041bSJack F Vogel #define IXGBE_RX_LOCK(_sc) mtx_lock(&(_sc)->rx_mtx) 4609ca4041bSJack F Vogel #define IXGBE_CORE_UNLOCK(_sc) mtx_unlock(&(_sc)->core_mtx) 4619ca4041bSJack F Vogel #define IXGBE_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->tx_mtx) 4629ca4041bSJack F Vogel #define IXGBE_RX_UNLOCK(_sc) mtx_unlock(&(_sc)->rx_mtx) 4639ca4041bSJack F Vogel #define IXGBE_CORE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->core_mtx, MA_OWNED) 4649ca4041bSJack F Vogel #define IXGBE_TX_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->tx_mtx, MA_OWNED) 4659ca4041bSJack F Vogel 4669ca4041bSJack F Vogel 4670ac6dfecSJack F Vogel static inline bool 4680ac6dfecSJack F Vogel ixgbe_is_sfp(struct ixgbe_hw *hw) 4690ac6dfecSJack F Vogel { 4700ac6dfecSJack F Vogel switch (hw->phy.type) { 4710ac6dfecSJack F Vogel case ixgbe_phy_sfp_avago: 4720ac6dfecSJack F Vogel case ixgbe_phy_sfp_ftl: 4730ac6dfecSJack F Vogel case ixgbe_phy_sfp_intel: 4740ac6dfecSJack F Vogel case ixgbe_phy_sfp_unknown: 475c0014855SJack F Vogel case ixgbe_phy_sfp_passive_tyco: 476c0014855SJack F Vogel case ixgbe_phy_sfp_passive_unknown: 4770ac6dfecSJack F Vogel return TRUE; 4780ac6dfecSJack F Vogel default: 4790ac6dfecSJack F Vogel return FALSE; 4800ac6dfecSJack F Vogel } 4810ac6dfecSJack F Vogel } 4820ac6dfecSJack F Vogel 4832d8f84cbSJack F Vogel /* Workaround to make 8.0 buildable */ 4842d8f84cbSJack F Vogel #if __FreeBSD_version < 800504 4852d8f84cbSJack F Vogel static __inline int 4862d8f84cbSJack F Vogel drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br) 4872d8f84cbSJack F Vogel { 4882d8f84cbSJack F Vogel #ifdef ALTQ 4892d8f84cbSJack F Vogel if (ALTQ_IS_ENABLED(&ifp->if_snd)) 4902d8f84cbSJack F Vogel return (1); 4912d8f84cbSJack F Vogel #endif 4922d8f84cbSJack F Vogel return (!buf_ring_empty(br)); 4932d8f84cbSJack F Vogel } 4942d8f84cbSJack F Vogel #endif 4952d8f84cbSJack F Vogel 49613705f88SJack F Vogel #endif /* _IXGBE_H_ */ 497