19ca4041bSJack F Vogel /****************************************************************************** 27282444bSPedro F. Giffuni SPDX-License-Identifier: BSD-3-Clause 313705f88SJack F Vogel 48eb6488eSEric Joyner Copyright (c) 2001-2017, Intel Corporation 513705f88SJack F Vogel All rights reserved. 613705f88SJack F Vogel 713705f88SJack F Vogel Redistribution and use in source and binary forms, with or without 813705f88SJack F Vogel modification, are permitted provided that the following conditions are met: 913705f88SJack F Vogel 1013705f88SJack F Vogel 1. Redistributions of source code must retain the above copyright notice, 1113705f88SJack F Vogel this list of conditions and the following disclaimer. 1213705f88SJack F Vogel 1313705f88SJack F Vogel 2. Redistributions in binary form must reproduce the above copyright 1413705f88SJack F Vogel notice, this list of conditions and the following disclaimer in the 1513705f88SJack F Vogel documentation and/or other materials provided with the distribution. 1613705f88SJack F Vogel 1713705f88SJack F Vogel 3. Neither the name of the Intel Corporation nor the names of its 1813705f88SJack F Vogel contributors may be used to endorse or promote products derived from 1913705f88SJack F Vogel this software without specific prior written permission. 2013705f88SJack F Vogel 2113705f88SJack F Vogel THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2213705f88SJack F Vogel AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2313705f88SJack F Vogel IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2413705f88SJack F Vogel ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2513705f88SJack F Vogel LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2613705f88SJack F Vogel CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2713705f88SJack F Vogel SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2813705f88SJack F Vogel INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2913705f88SJack F Vogel CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3013705f88SJack F Vogel ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3113705f88SJack F Vogel POSSIBILITY OF SUCH DAMAGE. 3213705f88SJack F Vogel 339ca4041bSJack F Vogel ******************************************************************************/ 3413705f88SJack F Vogel /*$FreeBSD$*/ 3513705f88SJack F Vogel 361b6e0dbaSJack F Vogel 3713705f88SJack F Vogel #ifndef _IXGBE_H_ 3813705f88SJack F Vogel #define _IXGBE_H_ 3913705f88SJack F Vogel 4013705f88SJack F Vogel 4113705f88SJack F Vogel #include <sys/param.h> 4213705f88SJack F Vogel #include <sys/systm.h> 43d8602bb9SJack F Vogel #include <sys/buf_ring.h> 4413705f88SJack F Vogel #include <sys/mbuf.h> 4513705f88SJack F Vogel #include <sys/protosw.h> 4613705f88SJack F Vogel #include <sys/socket.h> 4713705f88SJack F Vogel #include <sys/malloc.h> 4813705f88SJack F Vogel #include <sys/kernel.h> 4913705f88SJack F Vogel #include <sys/module.h> 5013705f88SJack F Vogel #include <sys/sockio.h> 5176039bc8SGleb Smirnoff #include <sys/eventhandler.h> 5213705f88SJack F Vogel 5313705f88SJack F Vogel #include <net/if.h> 5476039bc8SGleb Smirnoff #include <net/if_var.h> 5513705f88SJack F Vogel #include <net/if_arp.h> 5613705f88SJack F Vogel #include <net/bpf.h> 5713705f88SJack F Vogel #include <net/ethernet.h> 5813705f88SJack F Vogel #include <net/if_dl.h> 5913705f88SJack F Vogel #include <net/if_media.h> 6013705f88SJack F Vogel 6113705f88SJack F Vogel #include <net/if_types.h> 6213705f88SJack F Vogel #include <net/if_vlan_var.h> 63*c19c7afeSEric Joyner #include <net/iflib.h> 6413705f88SJack F Vogel 6513705f88SJack F Vogel #include <netinet/in_systm.h> 6613705f88SJack F Vogel #include <netinet/in.h> 6713705f88SJack F Vogel #include <netinet/if_ether.h> 6813705f88SJack F Vogel 6913705f88SJack F Vogel #include <sys/bus.h> 7013705f88SJack F Vogel #include <machine/bus.h> 7113705f88SJack F Vogel #include <sys/rman.h> 7213705f88SJack F Vogel #include <machine/resource.h> 7313705f88SJack F Vogel #include <vm/vm.h> 7413705f88SJack F Vogel #include <vm/pmap.h> 7513705f88SJack F Vogel #include <machine/clock.h> 7613705f88SJack F Vogel #include <dev/pci/pcivar.h> 7713705f88SJack F Vogel #include <dev/pci/pcireg.h> 7813705f88SJack F Vogel #include <sys/proc.h> 7913705f88SJack F Vogel #include <sys/sysctl.h> 8013705f88SJack F Vogel #include <sys/endian.h> 81*c19c7afeSEric Joyner #include <sys/gtaskqueue.h> 829ca4041bSJack F Vogel #include <sys/pcpu.h> 83d8602bb9SJack F Vogel #include <sys/smp.h> 84d8602bb9SJack F Vogel #include <machine/smp.h> 856f37f232SEric Joyner #include <sys/sbuf.h> 8613705f88SJack F Vogel 8713705f88SJack F Vogel #include "ixgbe_api.h" 886f37f232SEric Joyner #include "ixgbe_common.h" 896f37f232SEric Joyner #include "ixgbe_phy.h" 90758cc3dcSJack F Vogel #include "ixgbe_vf.h" 918eb6488eSEric Joyner #include "ixgbe_features.h" 9248056c88SJack F Vogel 9313705f88SJack F Vogel /* Tunables */ 9413705f88SJack F Vogel 9513705f88SJack F Vogel /* 963ec35e52SJack F Vogel * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the 9713705f88SJack F Vogel * number of transmit descriptors allocated by the driver. Increasing this 9813705f88SJack F Vogel * value allows the driver to queue more transmits. Each descriptor is 16 993ec35e52SJack F Vogel * bytes. Performance tests have show the 2K value to be optimal for top 1003ec35e52SJack F Vogel * performance. 10113705f88SJack F Vogel */ 102*c19c7afeSEric Joyner #define DEFAULT_TXD 2048 1033ec35e52SJack F Vogel #define PERFORM_TXD 2048 10413705f88SJack F Vogel #define MAX_TXD 4096 10513705f88SJack F Vogel #define MIN_TXD 64 10613705f88SJack F Vogel 10713705f88SJack F Vogel /* 1083ec35e52SJack F Vogel * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the 1093ec35e52SJack F Vogel * number of receive descriptors allocated for each RX queue. Increasing this 11013705f88SJack F Vogel * value allows the driver to buffer more incoming packets. Each descriptor 1113ec35e52SJack F Vogel * is 16 bytes. A receive buffer is also allocated for each descriptor. 11213705f88SJack F Vogel * 1133ec35e52SJack F Vogel * Note: with 8 rings and a dual port card, it is possible to bump up 1143ec35e52SJack F Vogel * against the system mbuf pool limit, you can tune nmbclusters 1153ec35e52SJack F Vogel * to adjust for this. 11613705f88SJack F Vogel */ 117*c19c7afeSEric Joyner #define DEFAULT_RXD 2048 1183ec35e52SJack F Vogel #define PERFORM_RXD 2048 11913705f88SJack F Vogel #define MAX_RXD 4096 12013705f88SJack F Vogel #define MIN_RXD 64 12113705f88SJack F Vogel 1223ec35e52SJack F Vogel /* Alignment for rings */ 1233ec35e52SJack F Vogel #define DBA_ALIGN 128 1243ec35e52SJack F Vogel 12513705f88SJack F Vogel /* 1262969bf0eSJack F Vogel * This is the max watchdog interval, ie. the time that can 1272969bf0eSJack F Vogel * pass between any two TX clean operations, such only happening 1282969bf0eSJack F Vogel * when the TX hardware is functioning. 12913705f88SJack F Vogel */ 1302969bf0eSJack F Vogel #define IXGBE_WATCHDOG (10 * hz) 13113705f88SJack F Vogel 13213705f88SJack F Vogel /* 13313705f88SJack F Vogel * This parameters control when the driver calls the routine to reclaim 13413705f88SJack F Vogel * transmit descriptors. 13513705f88SJack F Vogel */ 1368eb6488eSEric Joyner #define IXGBE_TX_CLEANUP_THRESHOLD(_a) ((_a)->num_tx_desc / 8) 1378eb6488eSEric Joyner #define IXGBE_TX_OP_THRESHOLD(_a) ((_a)->num_tx_desc / 32) 13813705f88SJack F Vogel 1396f37f232SEric Joyner /* These defines are used in MTU calculations */ 1406f37f232SEric Joyner #define IXGBE_MAX_FRAME_SIZE 9728 141a9ca1c79SSean Bruno #define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN) 142a9ca1c79SSean Bruno #define IXGBE_MTU_HDR_VLAN (ETHER_HDR_LEN + ETHER_CRC_LEN + \ 1436f37f232SEric Joyner ETHER_VLAN_ENCAP_LEN) 1446f37f232SEric Joyner #define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR) 145a9ca1c79SSean Bruno #define IXGBE_MAX_MTU_VLAN (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN) 14613705f88SJack F Vogel 1473ec35e52SJack F Vogel /* Flow control constants */ 1482969bf0eSJack F Vogel #define IXGBE_FC_PAUSE 0xFFFF 1493ec35e52SJack F Vogel #define IXGBE_FC_HI 0x20000 1503ec35e52SJack F Vogel #define IXGBE_FC_LO 0x10000 15113705f88SJack F Vogel 152cfc0969aSScott Long /* 153cfc0969aSScott Long * Used for optimizing small rx mbufs. Effort is made to keep the copy 154cfc0969aSScott Long * small and aligned for the CPU L1 cache. 155cfc0969aSScott Long * 156cfc0969aSScott Long * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting 157cfc0969aSScott Long * 32 byte alignment needed for the fast bcopy results in 8 bytes being 158cfc0969aSScott Long * wasted. Getting 64 byte alignment, which _should_ be ideal for 159cfc0969aSScott Long * modern Intel CPUs, results in 40 bytes wasted and a significant drop 160cfc0969aSScott Long * in observed efficiency of the optimization, 97.9% -> 81.8%. 161cfc0969aSScott Long */ 162a9ca1c79SSean Bruno #if __FreeBSD_version < 1002000 163a9ca1c79SSean Bruno #define MPKTHSIZE (sizeof(struct m_hdr) + sizeof(struct pkthdr)) 164a9ca1c79SSean Bruno #endif 16574c1c91cSEnji Cooper #define IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32) 16674c1c91cSEnji Cooper #define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED) 16774c1c91cSEnji Cooper #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE) 168cfc0969aSScott Long 1690e6fa41fSJack F Vogel /* Keep older OS drivers building... */ 1700e6fa41fSJack F Vogel #if !defined(SYSCTL_ADD_UQUAD) 1710e6fa41fSJack F Vogel #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD 1720e6fa41fSJack F Vogel #endif 1730e6fa41fSJack F Vogel 17413705f88SJack F Vogel /* Defines for printing debug information */ 17513705f88SJack F Vogel #define DEBUG_INIT 0 17613705f88SJack F Vogel #define DEBUG_IOCTL 0 17713705f88SJack F Vogel #define DEBUG_HW 0 17813705f88SJack F Vogel 17913705f88SJack F Vogel #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n") 18013705f88SJack F Vogel #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A) 18113705f88SJack F Vogel #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B) 18213705f88SJack F Vogel #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n") 18313705f88SJack F Vogel #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A) 18413705f88SJack F Vogel #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B) 18513705f88SJack F Vogel #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n") 18613705f88SJack F Vogel #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A) 18713705f88SJack F Vogel #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B) 18813705f88SJack F Vogel 18913705f88SJack F Vogel #define MAX_NUM_MULTICAST_ADDRESSES 128 1900ac6dfecSJack F Vogel #define IXGBE_82598_SCATTER 100 1910ac6dfecSJack F Vogel #define IXGBE_82599_SCATTER 32 1921b6e0dbaSJack F Vogel #define MSIX_82598_BAR 3 1931b6e0dbaSJack F Vogel #define MSIX_82599_BAR 4 19439fc714aSBjoern A. Zeeb #define IXGBE_TSO_SIZE 262140 195c0014855SJack F Vogel #define IXGBE_RX_HDR 128 196d8602bb9SJack F Vogel #define IXGBE_VFTA_SIZE 128 197d8602bb9SJack F Vogel #define IXGBE_BR_SIZE 4096 19885d0a26eSJack F Vogel #define IXGBE_QUEUE_MIN_FREE 32 199758cc3dcSJack F Vogel #define IXGBE_MAX_TX_BUSY 10 200758cc3dcSJack F Vogel #define IXGBE_QUEUE_HUNG 0x80000000 201758cc3dcSJack F Vogel 2028eb6488eSEric Joyner #define IXGBE_EITR_DEFAULT 128 2039de5aff5SJack F Vogel 204a9ca1c79SSean Bruno /* Supported offload bits in mbuf flag */ 205a9ca1c79SSean Bruno #if __FreeBSD_version >= 1000000 206a9ca1c79SSean Bruno #define CSUM_OFFLOAD (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \ 207a9ca1c79SSean Bruno CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \ 208a9ca1c79SSean Bruno CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP) 209a9ca1c79SSean Bruno #elif __FreeBSD_version >= 800000 2109de5aff5SJack F Vogel #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP) 2119de5aff5SJack F Vogel #else 2129de5aff5SJack F Vogel #define CSUM_OFFLOAD (CSUM_IP|CSUM_TCP|CSUM_UDP) 2139de5aff5SJack F Vogel #endif 21413705f88SJack F Vogel 215*c19c7afeSEric Joyner #define IXGBE_CAPS (IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6 | IFCAP_TSO | \ 216*c19c7afeSEric Joyner IFCAP_LRO | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO | \ 217*c19c7afeSEric Joyner IFCAP_VLAN_HWCSUM | IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU | \ 218*c19c7afeSEric Joyner IFCAP_HWSTATS | IFCAP_VLAN_HWFILTER | IFCAP_WOL) 219*c19c7afeSEric Joyner 220758cc3dcSJack F Vogel /* Backward compatibility items for very old versions */ 221758cc3dcSJack F Vogel #ifndef pci_find_cap 222758cc3dcSJack F Vogel #define pci_find_cap pci_find_extcap 223758cc3dcSJack F Vogel #endif 224758cc3dcSJack F Vogel 225758cc3dcSJack F Vogel #ifndef DEVMETHOD_END 226758cc3dcSJack F Vogel #define DEVMETHOD_END { NULL, NULL } 227758cc3dcSJack F Vogel #endif 228758cc3dcSJack F Vogel 22913705f88SJack F Vogel /* 23013705f88SJack F Vogel * Interrupt Moderation parameters 23113705f88SJack F Vogel */ 2321b6e0dbaSJack F Vogel #define IXGBE_LOW_LATENCY 128 2331b6e0dbaSJack F Vogel #define IXGBE_AVE_LATENCY 400 2341b6e0dbaSJack F Vogel #define IXGBE_BULK_LATENCY 1200 235a9ca1c79SSean Bruno 236a9ca1c79SSean Bruno /* Using 1FF (the max value), the interval is ~1.05ms */ 237a9ca1c79SSean Bruno #define IXGBE_LINK_ITR_QUANTA 0x1FF 238a9ca1c79SSean Bruno #define IXGBE_LINK_ITR ((IXGBE_LINK_ITR_QUANTA << 3) & \ 239a9ca1c79SSean Bruno IXGBE_EITR_ITR_INT_MASK) 2401b6e0dbaSJack F Vogel 24148056c88SJack F Vogel 2428eb6488eSEric Joyner /************************************************************************ 24313705f88SJack F Vogel * vendor_info_array 24413705f88SJack F Vogel * 2458eb6488eSEric Joyner * Contains the list of Subvendor/Subdevice IDs on 2468eb6488eSEric Joyner * which the driver should load. 2478eb6488eSEric Joyner ************************************************************************/ 24813705f88SJack F Vogel typedef struct _ixgbe_vendor_info_t { 24913705f88SJack F Vogel unsigned int vendor_id; 25013705f88SJack F Vogel unsigned int device_id; 25113705f88SJack F Vogel unsigned int subvendor_id; 25213705f88SJack F Vogel unsigned int subdevice_id; 25313705f88SJack F Vogel unsigned int index; 25413705f88SJack F Vogel } ixgbe_vendor_info_t; 25513705f88SJack F Vogel 2568eb6488eSEric Joyner struct ixgbe_bp_data { 2578eb6488eSEric Joyner u32 low; 2588eb6488eSEric Joyner u32 high; 2598eb6488eSEric Joyner u32 log; 2608eb6488eSEric Joyner }; 26148056c88SJack F Vogel 26213705f88SJack F Vogel 26313705f88SJack F Vogel /* 26413705f88SJack F Vogel */ 26513705f88SJack F Vogel struct ixgbe_dma_alloc { 26613705f88SJack F Vogel bus_addr_t dma_paddr; 26713705f88SJack F Vogel caddr_t dma_vaddr; 26813705f88SJack F Vogel bus_dma_tag_t dma_tag; 26913705f88SJack F Vogel bus_dmamap_t dma_map; 27013705f88SJack F Vogel bus_dma_segment_t dma_seg; 27113705f88SJack F Vogel bus_size_t dma_size; 27213705f88SJack F Vogel int dma_nseg; 27313705f88SJack F Vogel }; 27413705f88SJack F Vogel 27548056c88SJack F Vogel struct ixgbe_mc_addr { 27648056c88SJack F Vogel u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS]; 27748056c88SJack F Vogel u32 vmdq; 27848056c88SJack F Vogel }; 27948056c88SJack F Vogel 28013705f88SJack F Vogel /* 281c0014855SJack F Vogel * The transmit ring, one per queue 28213705f88SJack F Vogel */ 28313705f88SJack F Vogel struct tx_ring { 28413705f88SJack F Vogel struct adapter *adapter; 28547dd71a8SJack F Vogel union ixgbe_adv_tx_desc *tx_base; 286*c19c7afeSEric Joyner uint64_t tx_paddr; 287*c19c7afeSEric Joyner u32 tail; 288*c19c7afeSEric Joyner qidx_t *tx_rsq; 289*c19c7afeSEric Joyner qidx_t tx_rs_cidx; 290*c19c7afeSEric Joyner qidx_t tx_rs_pidx; 291*c19c7afeSEric Joyner qidx_t tx_cidx_processed; 292*c19c7afeSEric Joyner uint8_t me; 2938eb6488eSEric Joyner 2948eb6488eSEric Joyner /* Flow Director */ 2952969bf0eSJack F Vogel u16 atr_sample; 2962969bf0eSJack F Vogel u16 atr_count; 2978eb6488eSEric Joyner 298c0014855SJack F Vogel u32 bytes; /* used for AIM */ 299c0014855SJack F Vogel u32 packets; 3009ca4041bSJack F Vogel /* Soft Stats */ 3018eb6488eSEric Joyner u64 tso_tx; 3021b6e0dbaSJack F Vogel u64 total_packets; 30313705f88SJack F Vogel }; 30413705f88SJack F Vogel 30513705f88SJack F Vogel 30613705f88SJack F Vogel /* 30713705f88SJack F Vogel * The Receive ring, one per rx queue 30813705f88SJack F Vogel */ 30913705f88SJack F Vogel struct rx_ring { 310*c19c7afeSEric Joyner struct ix_rx_queue *que; 31113705f88SJack F Vogel struct adapter *adapter; 31213705f88SJack F Vogel u32 me; 313758cc3dcSJack F Vogel u32 tail; 31413705f88SJack F Vogel union ixgbe_adv_rx_desc *rx_base; 3152969bf0eSJack F Vogel bool hw_rsc; 31685d0a26eSJack F Vogel bool vtag_strip; 317*c19c7afeSEric Joyner uint64_t rx_paddr; 31860372f6fSLuigi Rizzo bus_dma_tag_t ptag; 3191b6e0dbaSJack F Vogel 3201b6e0dbaSJack F Vogel u32 bytes; /* Used for AIM calc */ 321c0014855SJack F Vogel u32 packets; 322d8602bb9SJack F Vogel 32313705f88SJack F Vogel /* Soft stats */ 3249ca4041bSJack F Vogel u64 rx_irq; 325cfc0969aSScott Long u64 rx_copies; 3261b6e0dbaSJack F Vogel u64 rx_packets; 3271b6e0dbaSJack F Vogel u64 rx_bytes; 328c0014855SJack F Vogel u64 rx_discarded; 3292969bf0eSJack F Vogel u64 rsc_num; 33013705f88SJack F Vogel 3318eb6488eSEric Joyner /* Flow Director */ 3328eb6488eSEric Joyner u64 flm; 3338eb6488eSEric Joyner }; 33448056c88SJack F Vogel 335*c19c7afeSEric Joyner /* 336*c19c7afeSEric Joyner * Driver queue struct: this is the interrupt container 337*c19c7afeSEric Joyner * for the associated tx and rx ring. 338*c19c7afeSEric Joyner */ 339*c19c7afeSEric Joyner struct ix_rx_queue { 340*c19c7afeSEric Joyner struct adapter *adapter; 341*c19c7afeSEric Joyner u32 msix; /* This queue's MSIX vector */ 342*c19c7afeSEric Joyner u32 eims; /* This queue's EIMS bit */ 343*c19c7afeSEric Joyner u32 eitr_setting; 344*c19c7afeSEric Joyner struct resource *res; 345*c19c7afeSEric Joyner void *tag; 346*c19c7afeSEric Joyner int busy; 347*c19c7afeSEric Joyner struct rx_ring rxr; 348*c19c7afeSEric Joyner struct if_irq que_irq; 349*c19c7afeSEric Joyner u64 irqs; 350*c19c7afeSEric Joyner }; 351*c19c7afeSEric Joyner 352*c19c7afeSEric Joyner struct ix_tx_queue { 353*c19c7afeSEric Joyner struct adapter *adapter; 354*c19c7afeSEric Joyner u32 msix; /* This queue's MSIX vector */ 355*c19c7afeSEric Joyner struct tx_ring txr; 356*c19c7afeSEric Joyner }; 357*c19c7afeSEric Joyner 35848056c88SJack F Vogel #define IXGBE_MAX_VF_MC 30 /* Max number of multicast entries */ 35948056c88SJack F Vogel 36048056c88SJack F Vogel struct ixgbe_vf { 36148056c88SJack F Vogel u_int pool; 36248056c88SJack F Vogel u_int rar_index; 363*c19c7afeSEric Joyner u_int maximum_frame_size; 36448056c88SJack F Vogel uint32_t flags; 36548056c88SJack F Vogel uint8_t ether_addr[ETHER_ADDR_LEN]; 36648056c88SJack F Vogel uint16_t mc_hash[IXGBE_MAX_VF_MC]; 36748056c88SJack F Vogel uint16_t num_mc_hashes; 36848056c88SJack F Vogel uint16_t default_vlan; 36948056c88SJack F Vogel uint16_t vlan_tag; 37048056c88SJack F Vogel uint16_t api_ver; 37148056c88SJack F Vogel }; 37248056c88SJack F Vogel 37313705f88SJack F Vogel /* Our adapter structure */ 37413705f88SJack F Vogel struct adapter { 37513705f88SJack F Vogel struct ixgbe_hw hw; 37613705f88SJack F Vogel struct ixgbe_osdep osdep; 377*c19c7afeSEric Joyner if_ctx_t ctx; 378*c19c7afeSEric Joyner if_softc_ctx_t shared; 379*c19c7afeSEric Joyner #define num_tx_queues shared->isc_ntxqsets 380*c19c7afeSEric Joyner #define num_rx_queues shared->isc_nrxqsets 381*c19c7afeSEric Joyner #define max_frame_size shared->isc_max_frame_size 382*c19c7afeSEric Joyner #define intr_type shared->isc_intr 383a9ca1c79SSean Bruno 384bd937497SJean-Sébastien Pédron device_t dev; 385a9ca1c79SSean Bruno struct ifnet *ifp; 3869ca4041bSJack F Vogel 3879ca4041bSJack F Vogel struct resource *pci_mem; 38813705f88SJack F Vogel 38913705f88SJack F Vogel /* 390d8602bb9SJack F Vogel * Interrupt resources: this set is 391d8602bb9SJack F Vogel * either used for legacy, or for Link 3928eb6488eSEric Joyner * when doing MSI-X 39313705f88SJack F Vogel */ 394*c19c7afeSEric Joyner struct if_irq irq; 395d8602bb9SJack F Vogel void *tag; 396d8602bb9SJack F Vogel struct resource *res; 39713705f88SJack F Vogel 398*c19c7afeSEric Joyner struct ifmedia *media; 39913705f88SJack F Vogel int if_flags; 400*c19c7afeSEric Joyner int msix; 401d8602bb9SJack F Vogel 4022969bf0eSJack F Vogel u16 num_vlans; 403d8602bb9SJack F Vogel 4041a4e3449SJack F Vogel /* 4058eb6488eSEric Joyner * Shadow VFTA table, this is needed because 4068eb6488eSEric Joyner * the real vlan filter table gets cleared during 4078eb6488eSEric Joyner * a soft reset and the driver needs to be able 4088eb6488eSEric Joyner * to repopulate it. 4091a4e3449SJack F Vogel */ 4101a4e3449SJack F Vogel u32 shadow_vfta[IXGBE_VFTA_SIZE]; 4111a4e3449SJack F Vogel 4121a4e3449SJack F Vogel /* Info about the interface */ 41317d2646bSJack F Vogel int advertise; /* link speeds */ 4149ca4041bSJack F Vogel bool link_active; 415182b3808SJack F Vogel u16 num_segs; 4169ca4041bSJack F Vogel u32 link_speed; 4170ac6dfecSJack F Vogel bool link_up; 418758cc3dcSJack F Vogel u32 vector; 4196f37f232SEric Joyner u16 dmac; 42048056c88SJack F Vogel u32 phy_layer; 4216f37f232SEric Joyner 4226f37f232SEric Joyner /* Power management-related */ 4236f37f232SEric Joyner bool wol_support; 4246f37f232SEric Joyner u32 wufc; 42513705f88SJack F Vogel 4261b6e0dbaSJack F Vogel /* Mbuf cluster size */ 4271b6e0dbaSJack F Vogel u32 rx_mbuf_sz; 4281b6e0dbaSJack F Vogel 4290ac6dfecSJack F Vogel /* Support for pluggable optics */ 4301b6e0dbaSJack F Vogel bool sfp_probe; 431*c19c7afeSEric Joyner struct grouptask mod_task; /* SFP tasklet */ 432*c19c7afeSEric Joyner struct grouptask msf_task; /* Multispeed Fiber */ 433*c19c7afeSEric Joyner struct grouptask mbx_task; /* VF -> PF mailbox interrupt */ 434*c19c7afeSEric Joyner int sfp_reinit; 4358eb6488eSEric Joyner 4368eb6488eSEric Joyner /* Flow Director */ 4372969bf0eSJack F Vogel int fdir_reinit; 438*c19c7afeSEric Joyner struct grouptask fdir_task; 4398eb6488eSEric Joyner 440*c19c7afeSEric Joyner struct grouptask phy_task; /* PHY intr tasklet */ 44113705f88SJack F Vogel 44213705f88SJack F Vogel /* 4438eb6488eSEric Joyner * Queues: 4448eb6488eSEric Joyner * This is the irq holder, it has 4458eb6488eSEric Joyner * and RX/TX pair or rings associated 4468eb6488eSEric Joyner * with it. 447c0014855SJack F Vogel */ 448*c19c7afeSEric Joyner struct ix_tx_queue *tx_queues; 449*c19c7afeSEric Joyner struct ix_rx_queue *rx_queues; 450758cc3dcSJack F Vogel u64 active_queues; 45113705f88SJack F Vogel 45238104eccSJack F Vogel /* Multicast array memory */ 45348056c88SJack F Vogel struct ixgbe_mc_addr *mta; 4548eb6488eSEric Joyner 4558eb6488eSEric Joyner /* SR-IOV */ 4568eb6488eSEric Joyner int iov_mode; 45748056c88SJack F Vogel int num_vfs; 45848056c88SJack F Vogel int pool; 45948056c88SJack F Vogel struct ixgbe_vf *vfs; 4608eb6488eSEric Joyner 4618eb6488eSEric Joyner /* Bypass */ 4628eb6488eSEric Joyner struct ixgbe_bp_data bypass; 4638eb6488eSEric Joyner 46413705f88SJack F Vogel /* Misc stats maintained by the driver */ 46513705f88SJack F Vogel unsigned long dropped_pkts; 4661b6e0dbaSJack F Vogel unsigned long mbuf_header_failed; 4671b6e0dbaSJack F Vogel unsigned long mbuf_packet_failed; 46813705f88SJack F Vogel unsigned long watchdog_events; 4696f37f232SEric Joyner unsigned long link_irq; 470758cc3dcSJack F Vogel union { 471758cc3dcSJack F Vogel struct ixgbe_hw_stats pf; 472758cc3dcSJack F Vogel struct ixgbevf_hw_stats vf; 473758cc3dcSJack F Vogel } stats; 474758cc3dcSJack F Vogel #if __FreeBSD_version >= 1100036 475758cc3dcSJack F Vogel /* counter(9) stats */ 476758cc3dcSJack F Vogel u64 ipackets; 477758cc3dcSJack F Vogel u64 ierrors; 478758cc3dcSJack F Vogel u64 opackets; 479758cc3dcSJack F Vogel u64 oerrors; 480758cc3dcSJack F Vogel u64 ibytes; 481758cc3dcSJack F Vogel u64 obytes; 482758cc3dcSJack F Vogel u64 imcasts; 483758cc3dcSJack F Vogel u64 omcasts; 484758cc3dcSJack F Vogel u64 iqdrops; 485758cc3dcSJack F Vogel u64 noproto; 486758cc3dcSJack F Vogel #endif 4878eb6488eSEric Joyner /* Feature capable/enabled flags. See ixgbe_features.h */ 4888eb6488eSEric Joyner u32 feat_cap; 4898eb6488eSEric Joyner u32 feat_en; 49013705f88SJack F Vogel }; 49113705f88SJack F Vogel 4920ac6dfecSJack F Vogel /* Precision Time Sync (IEEE 1588) defines */ 4930ac6dfecSJack F Vogel #define ETHERTYPE_IEEE1588 0x88F7 4940ac6dfecSJack F Vogel #define PICOSECS_PER_TICK 20833 4950ac6dfecSJack F Vogel #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */ 4960ac6dfecSJack F Vogel #define IXGBE_ADVTXD_TSTAMP 0x00080000 4970ac6dfecSJack F Vogel 498fd75b91dSJack F Vogel /* For backward compatibility */ 499fd75b91dSJack F Vogel #if !defined(PCIER_LINK_STA) 500fd75b91dSJack F Vogel #define PCIER_LINK_STA PCIR_EXPRESS_LINK_STA 501fd75b91dSJack F Vogel #endif 5029ca4041bSJack F Vogel 503758cc3dcSJack F Vogel /* Stats macros */ 504758cc3dcSJack F Vogel #if __FreeBSD_version >= 1100036 505758cc3dcSJack F Vogel #define IXGBE_SET_IPACKETS(sc, count) (sc)->ipackets = (count) 506758cc3dcSJack F Vogel #define IXGBE_SET_IERRORS(sc, count) (sc)->ierrors = (count) 507758cc3dcSJack F Vogel #define IXGBE_SET_OPACKETS(sc, count) (sc)->opackets = (count) 508758cc3dcSJack F Vogel #define IXGBE_SET_OERRORS(sc, count) (sc)->oerrors = (count) 509758cc3dcSJack F Vogel #define IXGBE_SET_COLLISIONS(sc, count) 510758cc3dcSJack F Vogel #define IXGBE_SET_IBYTES(sc, count) (sc)->ibytes = (count) 511758cc3dcSJack F Vogel #define IXGBE_SET_OBYTES(sc, count) (sc)->obytes = (count) 512758cc3dcSJack F Vogel #define IXGBE_SET_IMCASTS(sc, count) (sc)->imcasts = (count) 513758cc3dcSJack F Vogel #define IXGBE_SET_OMCASTS(sc, count) (sc)->omcasts = (count) 514758cc3dcSJack F Vogel #define IXGBE_SET_IQDROPS(sc, count) (sc)->iqdrops = (count) 515758cc3dcSJack F Vogel #else 516758cc3dcSJack F Vogel #define IXGBE_SET_IPACKETS(sc, count) (sc)->ifp->if_ipackets = (count) 517758cc3dcSJack F Vogel #define IXGBE_SET_IERRORS(sc, count) (sc)->ifp->if_ierrors = (count) 518758cc3dcSJack F Vogel #define IXGBE_SET_OPACKETS(sc, count) (sc)->ifp->if_opackets = (count) 519758cc3dcSJack F Vogel #define IXGBE_SET_OERRORS(sc, count) (sc)->ifp->if_oerrors = (count) 520758cc3dcSJack F Vogel #define IXGBE_SET_COLLISIONS(sc, count) (sc)->ifp->if_collisions = (count) 521758cc3dcSJack F Vogel #define IXGBE_SET_IBYTES(sc, count) (sc)->ifp->if_ibytes = (count) 522758cc3dcSJack F Vogel #define IXGBE_SET_OBYTES(sc, count) (sc)->ifp->if_obytes = (count) 523758cc3dcSJack F Vogel #define IXGBE_SET_IMCASTS(sc, count) (sc)->ifp->if_imcasts = (count) 524758cc3dcSJack F Vogel #define IXGBE_SET_OMCASTS(sc, count) (sc)->ifp->if_omcasts = (count) 525758cc3dcSJack F Vogel #define IXGBE_SET_IQDROPS(sc, count) (sc)->ifp->if_iqdrops = (count) 526758cc3dcSJack F Vogel #endif 527758cc3dcSJack F Vogel 5286f37f232SEric Joyner /* External PHY register addresses */ 5296f37f232SEric Joyner #define IXGBE_PHY_CURRENT_TEMP 0xC820 5306f37f232SEric Joyner #define IXGBE_PHY_OVERTEMP_STATUS 0xC830 5316f37f232SEric Joyner 532758cc3dcSJack F Vogel /* Sysctl help messages; displayed with sysctl -d */ 533758cc3dcSJack F Vogel #define IXGBE_SYSCTL_DESC_ADV_SPEED \ 534758cc3dcSJack F Vogel "\nControl advertised link speed using these flags:\n" \ 535758cc3dcSJack F Vogel "\t0x1 - advertise 100M\n" \ 536758cc3dcSJack F Vogel "\t0x2 - advertise 1G\n" \ 5378eb6488eSEric Joyner "\t0x4 - advertise 10G\n" \ 5388eb6488eSEric Joyner "\t0x8 - advertise 10M\n\n" \ 5398eb6488eSEric Joyner "\t100M and 10M are only supported on certain adapters.\n" 540758cc3dcSJack F Vogel 541758cc3dcSJack F Vogel #define IXGBE_SYSCTL_DESC_SET_FC \ 542758cc3dcSJack F Vogel "\nSet flow control mode using these values:\n" \ 543758cc3dcSJack F Vogel "\t0 - off\n" \ 544758cc3dcSJack F Vogel "\t1 - rx pause\n" \ 545758cc3dcSJack F Vogel "\t2 - tx pause\n" \ 546758cc3dcSJack F Vogel "\t3 - tx and rx pause" 547758cc3dcSJack F Vogel 5482d8f84cbSJack F Vogel /* Workaround to make 8.0 buildable */ 5494655a392SJack F Vogel #if __FreeBSD_version >= 800000 && __FreeBSD_version < 800504 5502d8f84cbSJack F Vogel static __inline int 5512d8f84cbSJack F Vogel drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br) 5522d8f84cbSJack F Vogel { 5532d8f84cbSJack F Vogel #ifdef ALTQ 5542d8f84cbSJack F Vogel if (ALTQ_IS_ENABLED(&ifp->if_snd)) 5552d8f84cbSJack F Vogel return (1); 5562d8f84cbSJack F Vogel #endif 5572d8f84cbSJack F Vogel return (!buf_ring_empty(br)); 5582d8f84cbSJack F Vogel } 5592d8f84cbSJack F Vogel #endif 5602d8f84cbSJack F Vogel 561e2314c6cSJack F Vogel /* 5628eb6488eSEric Joyner * This checks for a zero mac addr, something that will be likely 5638eb6488eSEric Joyner * unless the Admin on the Host has created one. 564758cc3dcSJack F Vogel */ 565758cc3dcSJack F Vogel static inline bool 566758cc3dcSJack F Vogel ixv_check_ether_addr(u8 *addr) 567758cc3dcSJack F Vogel { 568758cc3dcSJack F Vogel bool status = TRUE; 569758cc3dcSJack F Vogel 570758cc3dcSJack F Vogel if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 && 571758cc3dcSJack F Vogel addr[3] == 0 && addr[4]== 0 && addr[5] == 0)) 572758cc3dcSJack F Vogel status = FALSE; 5738eb6488eSEric Joyner 574758cc3dcSJack F Vogel return (status); 575758cc3dcSJack F Vogel } 576758cc3dcSJack F Vogel 577758cc3dcSJack F Vogel /* Shared Prototypes */ 578758cc3dcSJack F Vogel 579758cc3dcSJack F Vogel int ixgbe_allocate_queues(struct adapter *); 580758cc3dcSJack F Vogel int ixgbe_setup_transmit_structures(struct adapter *); 581758cc3dcSJack F Vogel void ixgbe_free_transmit_structures(struct adapter *); 582758cc3dcSJack F Vogel int ixgbe_setup_receive_structures(struct adapter *); 583758cc3dcSJack F Vogel void ixgbe_free_receive_structures(struct adapter *); 584*c19c7afeSEric Joyner int ixgbe_get_regs(SYSCTL_HANDLER_ARGS); 585758cc3dcSJack F Vogel 5868eb6488eSEric Joyner #include "ixgbe_bypass.h" 5878eb6488eSEric Joyner #include "ixgbe_fdir.h" 5888eb6488eSEric Joyner #include "ixgbe_rss.h" 58948056c88SJack F Vogel 59013705f88SJack F Vogel #endif /* _IXGBE_H_ */ 591