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