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
3513705f88SJack F Vogel #ifndef _IXGBE_H_
3613705f88SJack F Vogel #define _IXGBE_H_
3713705f88SJack F Vogel
3813705f88SJack F Vogel #include <sys/param.h>
3913705f88SJack F Vogel #include <sys/systm.h>
40d8602bb9SJack F Vogel #include <sys/buf_ring.h>
4113705f88SJack F Vogel #include <sys/mbuf.h>
4213705f88SJack F Vogel #include <sys/protosw.h>
4313705f88SJack F Vogel #include <sys/socket.h>
4413705f88SJack F Vogel #include <sys/malloc.h>
4513705f88SJack F Vogel #include <sys/kernel.h>
4613705f88SJack F Vogel #include <sys/module.h>
4713705f88SJack F Vogel #include <sys/sockio.h>
4876039bc8SGleb Smirnoff #include <sys/eventhandler.h>
4913705f88SJack F Vogel
5013705f88SJack F Vogel #include <net/if.h>
5176039bc8SGleb Smirnoff #include <net/if_var.h>
5213705f88SJack F Vogel #include <net/if_arp.h>
5313705f88SJack F Vogel #include <net/bpf.h>
5413705f88SJack F Vogel #include <net/ethernet.h>
5513705f88SJack F Vogel #include <net/if_dl.h>
5613705f88SJack F Vogel #include <net/if_media.h>
5713705f88SJack F Vogel
5813705f88SJack F Vogel #include <net/if_types.h>
5913705f88SJack F Vogel #include <net/if_vlan_var.h>
60c19c7afeSEric Joyner #include <net/iflib.h>
6113705f88SJack F Vogel
6213705f88SJack F Vogel #include <netinet/in_systm.h>
6313705f88SJack F Vogel #include <netinet/in.h>
6413705f88SJack F Vogel #include <netinet/if_ether.h>
6513705f88SJack F Vogel
6613705f88SJack F Vogel #include <sys/bus.h>
6713705f88SJack F Vogel #include <machine/bus.h>
6813705f88SJack F Vogel #include <sys/rman.h>
6913705f88SJack F Vogel #include <machine/resource.h>
7013705f88SJack F Vogel #include <vm/vm.h>
7113705f88SJack F Vogel #include <vm/pmap.h>
7213705f88SJack F Vogel #include <machine/clock.h>
7313705f88SJack F Vogel #include <dev/pci/pcivar.h>
7413705f88SJack F Vogel #include <dev/pci/pcireg.h>
7513705f88SJack F Vogel #include <sys/proc.h>
7613705f88SJack F Vogel #include <sys/sysctl.h>
7713705f88SJack F Vogel #include <sys/endian.h>
78c19c7afeSEric Joyner #include <sys/gtaskqueue.h>
799ca4041bSJack F Vogel #include <sys/pcpu.h>
80d8602bb9SJack F Vogel #include <sys/smp.h>
81d8602bb9SJack F Vogel #include <machine/smp.h>
826f37f232SEric Joyner #include <sys/sbuf.h>
8313705f88SJack F Vogel
8413705f88SJack F Vogel #include "ixgbe_api.h"
856f37f232SEric Joyner #include "ixgbe_common.h"
866f37f232SEric Joyner #include "ixgbe_phy.h"
87758cc3dcSJack F Vogel #include "ixgbe_vf.h"
888eb6488eSEric Joyner #include "ixgbe_features.h"
8948056c88SJack F Vogel
9013705f88SJack F Vogel /* Tunables */
9113705f88SJack F Vogel
9213705f88SJack F Vogel /*
933ec35e52SJack F Vogel * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
9413705f88SJack F Vogel * number of transmit descriptors allocated by the driver. Increasing this
9513705f88SJack F Vogel * value allows the driver to queue more transmits. Each descriptor is 16
963ec35e52SJack F Vogel * bytes. Performance tests have show the 2K value to be optimal for top
973ec35e52SJack F Vogel * performance.
9813705f88SJack F Vogel */
99c19c7afeSEric Joyner #define DEFAULT_TXD 2048
1003ec35e52SJack F Vogel #define PERFORM_TXD 2048
10113705f88SJack F Vogel #define MAX_TXD 4096
10213705f88SJack F Vogel #define MIN_TXD 64
10313705f88SJack F Vogel
10413705f88SJack F Vogel /*
1053ec35e52SJack F Vogel * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
1063ec35e52SJack F Vogel * number of receive descriptors allocated for each RX queue. Increasing this
10713705f88SJack F Vogel * value allows the driver to buffer more incoming packets. Each descriptor
1083ec35e52SJack F Vogel * is 16 bytes. A receive buffer is also allocated for each descriptor.
10913705f88SJack F Vogel *
1103ec35e52SJack F Vogel * Note: with 8 rings and a dual port card, it is possible to bump up
1113ec35e52SJack F Vogel * against the system mbuf pool limit, you can tune nmbclusters
1123ec35e52SJack F Vogel * to adjust for this.
11313705f88SJack F Vogel */
114c19c7afeSEric Joyner #define DEFAULT_RXD 2048
1153ec35e52SJack F Vogel #define PERFORM_RXD 2048
11613705f88SJack F Vogel #define MAX_RXD 4096
11713705f88SJack F Vogel #define MIN_RXD 64
11813705f88SJack F Vogel
1193ec35e52SJack F Vogel /* Alignment for rings */
1203ec35e52SJack F Vogel #define DBA_ALIGN 128
1213ec35e52SJack F Vogel
12213705f88SJack F Vogel /*
1232969bf0eSJack F Vogel * This is the max watchdog interval, ie. the time that can
1242969bf0eSJack F Vogel * pass between any two TX clean operations, such only happening
1252969bf0eSJack F Vogel * when the TX hardware is functioning.
12613705f88SJack F Vogel */
1272969bf0eSJack F Vogel #define IXGBE_WATCHDOG (10 * hz)
12813705f88SJack F Vogel
12913705f88SJack F Vogel /*
13013705f88SJack F Vogel * This parameters control when the driver calls the routine to reclaim
13113705f88SJack F Vogel * transmit descriptors.
13213705f88SJack F Vogel */
1338eb6488eSEric Joyner #define IXGBE_TX_CLEANUP_THRESHOLD(_a) ((_a)->num_tx_desc / 8)
1348eb6488eSEric Joyner #define IXGBE_TX_OP_THRESHOLD(_a) ((_a)->num_tx_desc / 32)
13513705f88SJack F Vogel
1366f37f232SEric Joyner /* These defines are used in MTU calculations */
1376f37f232SEric Joyner #define IXGBE_MAX_FRAME_SIZE 9728
138a9ca1c79SSean Bruno #define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN)
139a9ca1c79SSean Bruno #define IXGBE_MTU_HDR_VLAN (ETHER_HDR_LEN + ETHER_CRC_LEN + \
1406f37f232SEric Joyner ETHER_VLAN_ENCAP_LEN)
1416f37f232SEric Joyner #define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
142a9ca1c79SSean Bruno #define IXGBE_MAX_MTU_VLAN (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN)
14313705f88SJack F Vogel
1443ec35e52SJack F Vogel /* Flow control constants */
1452969bf0eSJack F Vogel #define IXGBE_FC_PAUSE 0xFFFF
1463ec35e52SJack F Vogel #define IXGBE_FC_HI 0x20000
1473ec35e52SJack F Vogel #define IXGBE_FC_LO 0x10000
14813705f88SJack F Vogel
149cfc0969aSScott Long /*
150cfc0969aSScott Long * Used for optimizing small rx mbufs. Effort is made to keep the copy
151cfc0969aSScott Long * small and aligned for the CPU L1 cache.
152cfc0969aSScott Long *
153cfc0969aSScott Long * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting
154cfc0969aSScott Long * 32 byte alignment needed for the fast bcopy results in 8 bytes being
155cfc0969aSScott Long * wasted. Getting 64 byte alignment, which _should_ be ideal for
156cfc0969aSScott Long * modern Intel CPUs, results in 40 bytes wasted and a significant drop
157cfc0969aSScott Long * in observed efficiency of the optimization, 97.9% -> 81.8%.
158cfc0969aSScott Long */
15915d07799SKevin Bowling #define IXGBE_MPKTHSIZE (sizeof(struct m_hdr) + sizeof(struct pkthdr))
160cfc0969aSScott Long
16115d07799SKevin Bowling #define IXGBE_RX_COPY_HDR_PADDED ((((IXGBE_MPKTHSIZE - 1) / 32) + 1) * 32)
16215d07799SKevin Bowling #define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
16315d07799SKevin Bowling #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - IXGBE_MPKTHSIZE)
1640e6fa41fSJack F Vogel
16513705f88SJack F Vogel /* Defines for printing debug information */
16613705f88SJack F Vogel #define DEBUG_INIT 0
16713705f88SJack F Vogel #define DEBUG_IOCTL 0
16813705f88SJack F Vogel #define DEBUG_HW 0
16913705f88SJack F Vogel
17013705f88SJack F Vogel #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n")
17113705f88SJack F Vogel #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A)
17213705f88SJack F Vogel #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B)
17313705f88SJack F Vogel #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n")
17413705f88SJack F Vogel #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A)
17513705f88SJack F Vogel #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B)
17613705f88SJack F Vogel #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n")
17713705f88SJack F Vogel #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A)
17813705f88SJack F Vogel #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B)
17913705f88SJack F Vogel
18013705f88SJack F Vogel #define MAX_NUM_MULTICAST_ADDRESSES 128
1810ac6dfecSJack F Vogel #define IXGBE_82598_SCATTER 100
1820ac6dfecSJack F Vogel #define IXGBE_82599_SCATTER 32
18339fc714aSBjoern A. Zeeb #define IXGBE_TSO_SIZE 262140
184c0014855SJack F Vogel #define IXGBE_RX_HDR 128
185d8602bb9SJack F Vogel #define IXGBE_VFTA_SIZE 128
186d8602bb9SJack F Vogel #define IXGBE_BR_SIZE 4096
18785d0a26eSJack F Vogel #define IXGBE_QUEUE_MIN_FREE 32
188758cc3dcSJack F Vogel #define IXGBE_MAX_TX_BUSY 10
189758cc3dcSJack F Vogel #define IXGBE_QUEUE_HUNG 0x80000000
190758cc3dcSJack F Vogel
1918eb6488eSEric Joyner #define IXGBE_EITR_DEFAULT 128
1929de5aff5SJack F Vogel
193a9ca1c79SSean Bruno /* Supported offload bits in mbuf flag */
194a9ca1c79SSean Bruno #define CSUM_OFFLOAD (CSUM_IP_TSO|CSUM_IP6_TSO|CSUM_IP| \
195a9ca1c79SSean Bruno CSUM_IP_UDP|CSUM_IP_TCP|CSUM_IP_SCTP| \
196a9ca1c79SSean Bruno CSUM_IP6_UDP|CSUM_IP6_TCP|CSUM_IP6_SCTP)
19713705f88SJack F Vogel
198c19c7afeSEric Joyner #define IXGBE_CAPS (IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6 | IFCAP_TSO | \
199c19c7afeSEric Joyner IFCAP_LRO | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWTSO | \
200c19c7afeSEric Joyner IFCAP_VLAN_HWCSUM | IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU | \
2017f87c040SMarius Strobl IFCAP_VLAN_HWFILTER | IFCAP_WOL)
202c19c7afeSEric Joyner
203758cc3dcSJack F Vogel #ifndef DEVMETHOD_END
204758cc3dcSJack F Vogel #define DEVMETHOD_END { NULL, NULL }
205758cc3dcSJack F Vogel #endif
206758cc3dcSJack F Vogel
20713705f88SJack F Vogel /*
20813705f88SJack F Vogel * Interrupt Moderation parameters
20913705f88SJack F Vogel */
2101b6e0dbaSJack F Vogel #define IXGBE_LOW_LATENCY 128
2111b6e0dbaSJack F Vogel #define IXGBE_AVE_LATENCY 400
2121b6e0dbaSJack F Vogel #define IXGBE_BULK_LATENCY 1200
213a9ca1c79SSean Bruno
214a9ca1c79SSean Bruno /* Using 1FF (the max value), the interval is ~1.05ms */
215a9ca1c79SSean Bruno #define IXGBE_LINK_ITR_QUANTA 0x1FF
216a9ca1c79SSean Bruno #define IXGBE_LINK_ITR ((IXGBE_LINK_ITR_QUANTA << 3) & \
217a9ca1c79SSean Bruno IXGBE_EITR_ITR_INT_MASK)
2181b6e0dbaSJack F Vogel
21948056c88SJack F Vogel
2208eb6488eSEric Joyner /************************************************************************
22113705f88SJack F Vogel * vendor_info_array
22213705f88SJack F Vogel *
2238eb6488eSEric Joyner * Contains the list of Subvendor/Subdevice IDs on
2248eb6488eSEric Joyner * which the driver should load.
2258eb6488eSEric Joyner ************************************************************************/
22613705f88SJack F Vogel typedef struct _ixgbe_vendor_info_t {
22713705f88SJack F Vogel unsigned int vendor_id;
22813705f88SJack F Vogel unsigned int device_id;
22913705f88SJack F Vogel unsigned int subvendor_id;
23013705f88SJack F Vogel unsigned int subdevice_id;
23113705f88SJack F Vogel unsigned int index;
23213705f88SJack F Vogel } ixgbe_vendor_info_t;
23313705f88SJack F Vogel
2348eb6488eSEric Joyner struct ixgbe_bp_data {
2358eb6488eSEric Joyner u32 low;
2368eb6488eSEric Joyner u32 high;
2378eb6488eSEric Joyner u32 log;
2388eb6488eSEric Joyner };
23948056c88SJack F Vogel
24013705f88SJack F Vogel
24113705f88SJack F Vogel /*
24213705f88SJack F Vogel */
24313705f88SJack F Vogel struct ixgbe_dma_alloc {
24413705f88SJack F Vogel bus_addr_t dma_paddr;
24513705f88SJack F Vogel caddr_t dma_vaddr;
24613705f88SJack F Vogel bus_dma_tag_t dma_tag;
24713705f88SJack F Vogel bus_dmamap_t dma_map;
24813705f88SJack F Vogel bus_dma_segment_t dma_seg;
24913705f88SJack F Vogel bus_size_t dma_size;
25013705f88SJack F Vogel int dma_nseg;
25113705f88SJack F Vogel };
25213705f88SJack F Vogel
25348056c88SJack F Vogel struct ixgbe_mc_addr {
25448056c88SJack F Vogel u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
25548056c88SJack F Vogel u32 vmdq;
25648056c88SJack F Vogel };
25748056c88SJack F Vogel
25813705f88SJack F Vogel /*
259c0014855SJack F Vogel * The transmit ring, one per queue
26013705f88SJack F Vogel */
26113705f88SJack F Vogel struct tx_ring {
262b1d5caf3SKevin Bowling struct ixgbe_softc *sc;
26347dd71a8SJack F Vogel union ixgbe_adv_tx_desc *tx_base;
264c19c7afeSEric Joyner uint64_t tx_paddr;
265c19c7afeSEric Joyner u32 tail;
266c19c7afeSEric Joyner qidx_t *tx_rsq;
267c19c7afeSEric Joyner qidx_t tx_rs_cidx;
268c19c7afeSEric Joyner qidx_t tx_rs_pidx;
269c19c7afeSEric Joyner qidx_t tx_cidx_processed;
270c19c7afeSEric Joyner uint8_t me;
2718eb6488eSEric Joyner
2728eb6488eSEric Joyner /* Flow Director */
2732969bf0eSJack F Vogel u16 atr_sample;
2742969bf0eSJack F Vogel u16 atr_count;
2758eb6488eSEric Joyner
276c0014855SJack F Vogel u32 bytes; /* used for AIM */
277c0014855SJack F Vogel u32 packets;
2789ca4041bSJack F Vogel /* Soft Stats */
2798eb6488eSEric Joyner u64 tso_tx;
2801b6e0dbaSJack F Vogel u64 total_packets;
28113705f88SJack F Vogel };
28213705f88SJack F Vogel
28313705f88SJack F Vogel
28413705f88SJack F Vogel /*
28513705f88SJack F Vogel * The Receive ring, one per rx queue
28613705f88SJack F Vogel */
28713705f88SJack F Vogel struct rx_ring {
288c19c7afeSEric Joyner struct ix_rx_queue *que;
289b1d5caf3SKevin Bowling struct ixgbe_softc *sc;
29013705f88SJack F Vogel u32 me;
291758cc3dcSJack F Vogel u32 tail;
29213705f88SJack F Vogel union ixgbe_adv_rx_desc *rx_base;
2932969bf0eSJack F Vogel bool hw_rsc;
29485d0a26eSJack F Vogel bool vtag_strip;
295c19c7afeSEric Joyner uint64_t rx_paddr;
29660372f6fSLuigi Rizzo bus_dma_tag_t ptag;
2971b6e0dbaSJack F Vogel
2981b6e0dbaSJack F Vogel u32 bytes; /* Used for AIM calc */
299c0014855SJack F Vogel u32 packets;
300d8602bb9SJack F Vogel
30113705f88SJack F Vogel /* Soft stats */
3029ca4041bSJack F Vogel u64 rx_irq;
303cfc0969aSScott Long u64 rx_copies;
3041b6e0dbaSJack F Vogel u64 rx_packets;
3051b6e0dbaSJack F Vogel u64 rx_bytes;
306c0014855SJack F Vogel u64 rx_discarded;
3072969bf0eSJack F Vogel u64 rsc_num;
30813705f88SJack F Vogel
3098eb6488eSEric Joyner /* Flow Director */
3108eb6488eSEric Joyner u64 flm;
3118eb6488eSEric Joyner };
31248056c88SJack F Vogel
313c19c7afeSEric Joyner /*
314c19c7afeSEric Joyner * Driver queue struct: this is the interrupt container
315c19c7afeSEric Joyner * for the associated tx and rx ring.
316c19c7afeSEric Joyner */
317c19c7afeSEric Joyner struct ix_rx_queue {
318b1d5caf3SKevin Bowling struct ixgbe_softc *sc;
319c19c7afeSEric Joyner u32 msix; /* This queue's MSIX vector */
320c19c7afeSEric Joyner u32 eitr_setting;
321c19c7afeSEric Joyner struct resource *res;
322c19c7afeSEric Joyner void *tag;
323c19c7afeSEric Joyner int busy;
324c19c7afeSEric Joyner struct rx_ring rxr;
325c19c7afeSEric Joyner struct if_irq que_irq;
326c19c7afeSEric Joyner u64 irqs;
327c19c7afeSEric Joyner };
328c19c7afeSEric Joyner
329c19c7afeSEric Joyner struct ix_tx_queue {
330b1d5caf3SKevin Bowling struct ixgbe_softc *sc;
331c19c7afeSEric Joyner u32 msix; /* This queue's MSIX vector */
332c19c7afeSEric Joyner struct tx_ring txr;
333c19c7afeSEric Joyner };
334c19c7afeSEric Joyner
33548056c88SJack F Vogel #define IXGBE_MAX_VF_MC 30 /* Max number of multicast entries */
33648056c88SJack F Vogel
33748056c88SJack F Vogel struct ixgbe_vf {
33848056c88SJack F Vogel u_int pool;
33948056c88SJack F Vogel u_int rar_index;
340c19c7afeSEric Joyner u_int maximum_frame_size;
34148056c88SJack F Vogel uint32_t flags;
34248056c88SJack F Vogel uint8_t ether_addr[ETHER_ADDR_LEN];
34348056c88SJack F Vogel uint16_t mc_hash[IXGBE_MAX_VF_MC];
34448056c88SJack F Vogel uint16_t num_mc_hashes;
34548056c88SJack F Vogel uint16_t default_vlan;
34648056c88SJack F Vogel uint16_t vlan_tag;
34748056c88SJack F Vogel uint16_t api_ver;
34848056c88SJack F Vogel };
34948056c88SJack F Vogel
350b1d5caf3SKevin Bowling /* Our softc structure */
351b1d5caf3SKevin Bowling struct ixgbe_softc {
35213705f88SJack F Vogel struct ixgbe_hw hw;
35313705f88SJack F Vogel struct ixgbe_osdep osdep;
354c19c7afeSEric Joyner if_ctx_t ctx;
355c19c7afeSEric Joyner if_softc_ctx_t shared;
356c19c7afeSEric Joyner #define num_tx_queues shared->isc_ntxqsets
357c19c7afeSEric Joyner #define num_rx_queues shared->isc_nrxqsets
358c19c7afeSEric Joyner #define max_frame_size shared->isc_max_frame_size
359c19c7afeSEric Joyner #define intr_type shared->isc_intr
360a9ca1c79SSean Bruno
361bd937497SJean-Sébastien Pédron device_t dev;
362a9ca1c79SSean Bruno struct ifnet *ifp;
3639ca4041bSJack F Vogel
3649ca4041bSJack F Vogel struct resource *pci_mem;
36513705f88SJack F Vogel
36613705f88SJack F Vogel /*
367d8602bb9SJack F Vogel * Interrupt resources: this set is
368d8602bb9SJack F Vogel * either used for legacy, or for Link
3698eb6488eSEric Joyner * when doing MSI-X
37013705f88SJack F Vogel */
371c19c7afeSEric Joyner struct if_irq irq;
372d8602bb9SJack F Vogel void *tag;
373d8602bb9SJack F Vogel struct resource *res;
37413705f88SJack F Vogel
375c19c7afeSEric Joyner struct ifmedia *media;
37613705f88SJack F Vogel int if_flags;
377c19c7afeSEric Joyner int msix;
378d8602bb9SJack F Vogel
3792969bf0eSJack F Vogel u16 num_vlans;
380d8602bb9SJack F Vogel
3811a4e3449SJack F Vogel /*
3828eb6488eSEric Joyner * Shadow VFTA table, this is needed because
3838eb6488eSEric Joyner * the real vlan filter table gets cleared during
3848eb6488eSEric Joyner * a soft reset and the driver needs to be able
3858eb6488eSEric Joyner * to repopulate it.
3861a4e3449SJack F Vogel */
3871a4e3449SJack F Vogel u32 shadow_vfta[IXGBE_VFTA_SIZE];
3881a4e3449SJack F Vogel
3891a4e3449SJack F Vogel /* Info about the interface */
39017d2646bSJack F Vogel int advertise; /* link speeds */
39164881da4SSai Rajesh Tallamraju int enable_aim; /* adaptive interrupt moderation */
3929ca4041bSJack F Vogel bool link_active;
393182b3808SJack F Vogel u16 num_segs;
3949ca4041bSJack F Vogel u32 link_speed;
3950ac6dfecSJack F Vogel bool link_up;
396a3e719bbSPiotr Pietruszewski bool link_enabled;
397758cc3dcSJack F Vogel u32 vector;
3986f37f232SEric Joyner u16 dmac;
39948056c88SJack F Vogel u32 phy_layer;
4006f37f232SEric Joyner
4016f37f232SEric Joyner /* Power management-related */
4026f37f232SEric Joyner bool wol_support;
4036f37f232SEric Joyner u32 wufc;
40413705f88SJack F Vogel
4051b6e0dbaSJack F Vogel /* Mbuf cluster size */
4061b6e0dbaSJack F Vogel u32 rx_mbuf_sz;
4071b6e0dbaSJack F Vogel
4080ac6dfecSJack F Vogel /* Support for pluggable optics */
4091b6e0dbaSJack F Vogel bool sfp_probe;
4108eb6488eSEric Joyner
4118eb6488eSEric Joyner /* Flow Director */
4122969bf0eSJack F Vogel int fdir_reinit;
4138eb6488eSEric Joyner
414b2c1e8e6SEric Joyner u32 task_requests;
41513705f88SJack F Vogel
41613705f88SJack F Vogel /*
4178eb6488eSEric Joyner * Queues:
4188eb6488eSEric Joyner * This is the irq holder, it has
4198eb6488eSEric Joyner * and RX/TX pair or rings associated
4208eb6488eSEric Joyner * with it.
421c0014855SJack F Vogel */
422c19c7afeSEric Joyner struct ix_tx_queue *tx_queues;
423c19c7afeSEric Joyner struct ix_rx_queue *rx_queues;
42413705f88SJack F Vogel
42538104eccSJack F Vogel /* Multicast array memory */
42648056c88SJack F Vogel struct ixgbe_mc_addr *mta;
4278eb6488eSEric Joyner
4288eb6488eSEric Joyner /* SR-IOV */
4298eb6488eSEric Joyner int iov_mode;
43048056c88SJack F Vogel int num_vfs;
43148056c88SJack F Vogel int pool;
43248056c88SJack F Vogel struct ixgbe_vf *vfs;
4338eb6488eSEric Joyner
4348eb6488eSEric Joyner /* Bypass */
4358eb6488eSEric Joyner struct ixgbe_bp_data bypass;
4368eb6488eSEric Joyner
437*f72de14eSKevin Bowling /* Firmware error check */
438*f72de14eSKevin Bowling int recovery_mode;
439*f72de14eSKevin Bowling struct callout fw_mode_timer;
440*f72de14eSKevin Bowling
44113705f88SJack F Vogel /* Misc stats maintained by the driver */
44213705f88SJack F Vogel unsigned long dropped_pkts;
4431b6e0dbaSJack F Vogel unsigned long mbuf_header_failed;
4441b6e0dbaSJack F Vogel unsigned long mbuf_packet_failed;
44513705f88SJack F Vogel unsigned long watchdog_events;
4466f37f232SEric Joyner unsigned long link_irq;
447758cc3dcSJack F Vogel union {
448758cc3dcSJack F Vogel struct ixgbe_hw_stats pf;
449758cc3dcSJack F Vogel struct ixgbevf_hw_stats vf;
450758cc3dcSJack F Vogel } stats;
45115d07799SKevin Bowling
452758cc3dcSJack F Vogel /* counter(9) stats */
453758cc3dcSJack F Vogel u64 ipackets;
454758cc3dcSJack F Vogel u64 ierrors;
455758cc3dcSJack F Vogel u64 opackets;
456758cc3dcSJack F Vogel u64 oerrors;
457758cc3dcSJack F Vogel u64 ibytes;
458758cc3dcSJack F Vogel u64 obytes;
459758cc3dcSJack F Vogel u64 imcasts;
460758cc3dcSJack F Vogel u64 omcasts;
461758cc3dcSJack F Vogel u64 iqdrops;
462758cc3dcSJack F Vogel u64 noproto;
46315d07799SKevin Bowling
4648eb6488eSEric Joyner /* Feature capable/enabled flags. See ixgbe_features.h */
4658eb6488eSEric Joyner u32 feat_cap;
4668eb6488eSEric Joyner u32 feat_en;
46713705f88SJack F Vogel };
46813705f88SJack F Vogel
4690ac6dfecSJack F Vogel /* Precision Time Sync (IEEE 1588) defines */
4700ac6dfecSJack F Vogel #define ETHERTYPE_IEEE1588 0x88F7
4710ac6dfecSJack F Vogel #define PICOSECS_PER_TICK 20833
4720ac6dfecSJack F Vogel #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */
4730ac6dfecSJack F Vogel #define IXGBE_ADVTXD_TSTAMP 0x00080000
4740ac6dfecSJack F Vogel
475758cc3dcSJack F Vogel /* Stats macros */
476758cc3dcSJack F Vogel #define IXGBE_SET_IPACKETS(sc, count) (sc)->ipackets = (count)
477758cc3dcSJack F Vogel #define IXGBE_SET_IERRORS(sc, count) (sc)->ierrors = (count)
478758cc3dcSJack F Vogel #define IXGBE_SET_OPACKETS(sc, count) (sc)->opackets = (count)
479758cc3dcSJack F Vogel #define IXGBE_SET_OERRORS(sc, count) (sc)->oerrors = (count)
480758cc3dcSJack F Vogel #define IXGBE_SET_COLLISIONS(sc, count)
481758cc3dcSJack F Vogel #define IXGBE_SET_IBYTES(sc, count) (sc)->ibytes = (count)
482758cc3dcSJack F Vogel #define IXGBE_SET_OBYTES(sc, count) (sc)->obytes = (count)
483758cc3dcSJack F Vogel #define IXGBE_SET_IMCASTS(sc, count) (sc)->imcasts = (count)
484758cc3dcSJack F Vogel #define IXGBE_SET_OMCASTS(sc, count) (sc)->omcasts = (count)
485758cc3dcSJack F Vogel #define IXGBE_SET_IQDROPS(sc, count) (sc)->iqdrops = (count)
486758cc3dcSJack F Vogel
4876f37f232SEric Joyner /* External PHY register addresses */
4886f37f232SEric Joyner #define IXGBE_PHY_CURRENT_TEMP 0xC820
4896f37f232SEric Joyner #define IXGBE_PHY_OVERTEMP_STATUS 0xC830
4906f37f232SEric Joyner
491758cc3dcSJack F Vogel /* Sysctl help messages; displayed with sysctl -d */
492758cc3dcSJack F Vogel #define IXGBE_SYSCTL_DESC_ADV_SPEED \
493758cc3dcSJack F Vogel "\nControl advertised link speed using these flags:\n" \
494758cc3dcSJack F Vogel "\t0x1 - advertise 100M\n" \
495758cc3dcSJack F Vogel "\t0x2 - advertise 1G\n" \
4968eb6488eSEric Joyner "\t0x4 - advertise 10G\n" \
4978eb6488eSEric Joyner "\t0x8 - advertise 10M\n\n" \
498d381c807SPiotr Pietruszewski "\t0x10 - advertise 2.5G\n" \
499d381c807SPiotr Pietruszewski "\t0x20 - advertise 5G\n\n" \
5008eb6488eSEric Joyner "\t100M and 10M are only supported on certain adapters.\n"
501758cc3dcSJack F Vogel
502758cc3dcSJack F Vogel #define IXGBE_SYSCTL_DESC_SET_FC \
503758cc3dcSJack F Vogel "\nSet flow control mode using these values:\n" \
504758cc3dcSJack F Vogel "\t0 - off\n" \
505758cc3dcSJack F Vogel "\t1 - rx pause\n" \
506758cc3dcSJack F Vogel "\t2 - tx pause\n" \
507758cc3dcSJack F Vogel "\t3 - tx and rx pause"
508758cc3dcSJack F Vogel
509afb1aa4eSPiotr Pietruszewski #define IXGBE_SYSCTL_DESC_RX_ERRS \
510afb1aa4eSPiotr Pietruszewski "\nSum of the following RX errors counters:\n" \
511afb1aa4eSPiotr Pietruszewski " * CRC errors,\n" \
512afb1aa4eSPiotr Pietruszewski " * illegal byte error count,\n" \
513afb1aa4eSPiotr Pietruszewski " * missed packet count,\n" \
514afb1aa4eSPiotr Pietruszewski " * length error count,\n" \
515afb1aa4eSPiotr Pietruszewski " * undersized packets count,\n" \
516afb1aa4eSPiotr Pietruszewski " * fragmented packets count,\n" \
517afb1aa4eSPiotr Pietruszewski " * oversized packets count,\n" \
518afb1aa4eSPiotr Pietruszewski " * jabber count."
519afb1aa4eSPiotr Pietruszewski
520e2314c6cSJack F Vogel /*
5218eb6488eSEric Joyner * This checks for a zero mac addr, something that will be likely
5228eb6488eSEric Joyner * unless the Admin on the Host has created one.
523758cc3dcSJack F Vogel */
524758cc3dcSJack F Vogel static inline bool
ixv_check_ether_addr(u8 * addr)525758cc3dcSJack F Vogel ixv_check_ether_addr(u8 *addr)
526758cc3dcSJack F Vogel {
52779b36ec9SKevin Bowling bool status = true;
528758cc3dcSJack F Vogel
529758cc3dcSJack F Vogel if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
530758cc3dcSJack F Vogel addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
53179b36ec9SKevin Bowling status = false;
5328eb6488eSEric Joyner
533758cc3dcSJack F Vogel return (status);
534758cc3dcSJack F Vogel }
535758cc3dcSJack F Vogel
536a0302c92SPiotr Pietruszewski uint64_t ixgbe_link_speed_to_baudrate(ixgbe_link_speed speed);
537a0302c92SPiotr Pietruszewski
538758cc3dcSJack F Vogel /* Shared Prototypes */
539758cc3dcSJack F Vogel
540b1d5caf3SKevin Bowling int ixgbe_allocate_queues(struct ixgbe_softc *);
541b1d5caf3SKevin Bowling int ixgbe_setup_transmit_structures(struct ixgbe_softc *);
542b1d5caf3SKevin Bowling void ixgbe_free_transmit_structures(struct ixgbe_softc *);
543b1d5caf3SKevin Bowling int ixgbe_setup_receive_structures(struct ixgbe_softc *);
544b1d5caf3SKevin Bowling void ixgbe_free_receive_structures(struct ixgbe_softc *);
545c19c7afeSEric Joyner int ixgbe_get_regs(SYSCTL_HANDLER_ARGS);
546758cc3dcSJack F Vogel
5478eb6488eSEric Joyner #include "ixgbe_bypass.h"
5488eb6488eSEric Joyner #include "ixgbe_fdir.h"
5498eb6488eSEric Joyner #include "ixgbe_rss.h"
55048056c88SJack F Vogel
55113705f88SJack F Vogel #endif /* _IXGBE_H_ */
552