1dee1ad47SJeff Kirsher /******************************************************************************* 2dee1ad47SJeff Kirsher 3dee1ad47SJeff Kirsher Intel 10 Gigabit PCI Express Linux driver 437689010SMark Rustad Copyright(c) 1999 - 2016 Intel Corporation. 5dee1ad47SJeff Kirsher 6dee1ad47SJeff Kirsher This program is free software; you can redistribute it and/or modify it 7dee1ad47SJeff Kirsher under the terms and conditions of the GNU General Public License, 8dee1ad47SJeff Kirsher version 2, as published by the Free Software Foundation. 9dee1ad47SJeff Kirsher 10dee1ad47SJeff Kirsher This program is distributed in the hope it will be useful, but WITHOUT 11dee1ad47SJeff Kirsher ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12dee1ad47SJeff Kirsher FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13dee1ad47SJeff Kirsher more details. 14dee1ad47SJeff Kirsher 15dee1ad47SJeff Kirsher You should have received a copy of the GNU General Public License along with 16dee1ad47SJeff Kirsher this program; if not, write to the Free Software Foundation, Inc., 17dee1ad47SJeff Kirsher 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18dee1ad47SJeff Kirsher 19dee1ad47SJeff Kirsher The full GNU General Public License is included in this distribution in 20dee1ad47SJeff Kirsher the file called "COPYING". 21dee1ad47SJeff Kirsher 22dee1ad47SJeff Kirsher Contact Information: 23b89aae71SJacob Keller Linux NICS <linux.nics@intel.com> 24dee1ad47SJeff Kirsher e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 25dee1ad47SJeff Kirsher Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26dee1ad47SJeff Kirsher 27dee1ad47SJeff Kirsher *******************************************************************************/ 28dee1ad47SJeff Kirsher 29dee1ad47SJeff Kirsher #ifndef _IXGBE_H_ 30dee1ad47SJeff Kirsher #define _IXGBE_H_ 31dee1ad47SJeff Kirsher 32dee1ad47SJeff Kirsher #include <linux/bitops.h> 33dee1ad47SJeff Kirsher #include <linux/types.h> 34dee1ad47SJeff Kirsher #include <linux/pci.h> 35dee1ad47SJeff Kirsher #include <linux/netdevice.h> 36dee1ad47SJeff Kirsher #include <linux/cpumask.h> 37dee1ad47SJeff Kirsher #include <linux/aer.h> 38dee1ad47SJeff Kirsher #include <linux/if_vlan.h> 396cb562d6SJacob Keller #include <linux/jiffies.h> 40dee1ad47SJeff Kirsher 4174d23cc7SRichard Cochran #include <linux/timecounter.h> 423a6a4edaSJacob Keller #include <linux/net_tstamp.h> 433a6a4edaSJacob Keller #include <linux/ptp_clock_kernel.h> 443a6a4edaSJacob Keller 45dee1ad47SJeff Kirsher #include "ixgbe_type.h" 46dee1ad47SJeff Kirsher #include "ixgbe_common.h" 47dee1ad47SJeff Kirsher #include "ixgbe_dcb.h" 48ee58c114SJavier Martinez Canillas #if IS_ENABLED(CONFIG_FCOE) 49dee1ad47SJeff Kirsher #define IXGBE_FCOE 50dee1ad47SJeff Kirsher #include "ixgbe_fcoe.h" 51ee58c114SJavier Martinez Canillas #endif /* IS_ENABLED(CONFIG_FCOE) */ 52dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA 53dee1ad47SJeff Kirsher #include <linux/dca.h> 54dee1ad47SJeff Kirsher #endif 55dee1ad47SJeff Kirsher 56076bb0c8SEliezer Tamir #include <net/busy_poll.h> 575a85e737SEliezer Tamir 58dee1ad47SJeff Kirsher /* common prefix used by pr_<> macros */ 59dee1ad47SJeff Kirsher #undef pr_fmt 60dee1ad47SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 61dee1ad47SJeff Kirsher 62dee1ad47SJeff Kirsher /* TX/RX descriptor defines */ 63dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_TXD 512 6459224555SAlexander Duyck #define IXGBE_DEFAULT_TX_WORK 256 65dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD 4096 66dee1ad47SJeff Kirsher #define IXGBE_MIN_TXD 64 67dee1ad47SJeff Kirsher 68fb44519dSAnton Blanchard #if (PAGE_SIZE < 8192) 69dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_RXD 512 70fb44519dSAnton Blanchard #else 71fb44519dSAnton Blanchard #define IXGBE_DEFAULT_RXD 128 72fb44519dSAnton Blanchard #endif 73dee1ad47SJeff Kirsher #define IXGBE_MAX_RXD 4096 74dee1ad47SJeff Kirsher #define IXGBE_MIN_RXD 64 75dee1ad47SJeff Kirsher 765b7f000fSDon Skidmore #define IXGBE_ETH_P_LLDP 0x88CC 775b7f000fSDon Skidmore 78dee1ad47SJeff Kirsher /* flow control */ 79dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTL 0x40 80dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTL 0x7FF80 81dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTH 0x600 82dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTH 0x7FFF0 83dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_FCPAUSE 0xFFFF 84dee1ad47SJeff Kirsher #define IXGBE_MIN_FCPAUSE 0 85dee1ad47SJeff Kirsher #define IXGBE_MAX_FCPAUSE 0xFFFF 86dee1ad47SJeff Kirsher 87dee1ad47SJeff Kirsher /* Supported Rx Buffer Sizes */ 88252562c2SAlexander Duyck #define IXGBE_RXBUFFER_256 256 /* Used for skb receive header */ 8909816fbeSAlexander Duyck #define IXGBE_RXBUFFER_2K 2048 9009816fbeSAlexander Duyck #define IXGBE_RXBUFFER_3K 3072 9109816fbeSAlexander Duyck #define IXGBE_RXBUFFER_4K 4096 92dee1ad47SJeff Kirsher #define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */ 93dee1ad47SJeff Kirsher 94dee1ad47SJeff Kirsher /* 95252562c2SAlexander Duyck * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we 96252562c2SAlexander Duyck * reserve 64 more, and skb_shared_info adds an additional 320 bytes more, 97252562c2SAlexander Duyck * this adds up to 448 bytes of extra data. 98252562c2SAlexander Duyck * 99252562c2SAlexander Duyck * Since netdev_alloc_skb now allocates a page fragment we can use a value 100252562c2SAlexander Duyck * of 256 and the resultant skb will have a truesize of 960 or less. 101dee1ad47SJeff Kirsher */ 102252562c2SAlexander Duyck #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256 103dee1ad47SJeff Kirsher 104dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */ 105dee1ad47SJeff Kirsher #define IXGBE_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 106dee1ad47SJeff Kirsher 107*f3213d93SAlexander Duyck #define IXGBE_RX_DMA_ATTR \ 108*f3213d93SAlexander Duyck (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING) 109*f3213d93SAlexander Duyck 110472148c3SAlexander Duyck enum ixgbe_tx_flags { 111472148c3SAlexander Duyck /* cmd_type flags */ 112472148c3SAlexander Duyck IXGBE_TX_FLAGS_HW_VLAN = 0x01, 113472148c3SAlexander Duyck IXGBE_TX_FLAGS_TSO = 0x02, 114472148c3SAlexander Duyck IXGBE_TX_FLAGS_TSTAMP = 0x04, 115472148c3SAlexander Duyck 116472148c3SAlexander Duyck /* olinfo flags */ 117472148c3SAlexander Duyck IXGBE_TX_FLAGS_CC = 0x08, 118472148c3SAlexander Duyck IXGBE_TX_FLAGS_IPV4 = 0x10, 119472148c3SAlexander Duyck IXGBE_TX_FLAGS_CSUM = 0x20, 120472148c3SAlexander Duyck 121472148c3SAlexander Duyck /* software defined flags */ 122472148c3SAlexander Duyck IXGBE_TX_FLAGS_SW_VLAN = 0x40, 123472148c3SAlexander Duyck IXGBE_TX_FLAGS_FCOE = 0x80, 124472148c3SAlexander Duyck }; 125472148c3SAlexander Duyck 126472148c3SAlexander Duyck /* VLAN info */ 127dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000 12866f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000 12966f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT 29 130dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_SHIFT 16 131dee1ad47SJeff Kirsher 132dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_MC_ENTRIES 30 133dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_FUNCTIONS 64 134dee1ad47SJeff Kirsher #define IXGBE_MAX_VFTA_ENTRIES 128 135dee1ad47SJeff Kirsher #define MAX_EMULATION_MAC_ADDRS 16 136dee1ad47SJeff Kirsher #define IXGBE_MAX_PF_MACVLANS 15 1371d9c0bfdSAlexander Duyck #define VMDQ_P(p) ((p) + adapter->ring_feature[RING_F_VMDQ].offset) 13883c61fa9SGreg Rose #define IXGBE_82599_VF_DEVICE_ID 0x10ED 13983c61fa9SGreg Rose #define IXGBE_X540_VF_DEVICE_ID 0x1515 140dee1ad47SJeff Kirsher 141dee1ad47SJeff Kirsher struct vf_data_storage { 142988d1307SMark Rustad struct pci_dev *vfdev; 143dee1ad47SJeff Kirsher unsigned char vf_mac_addresses[ETH_ALEN]; 144dee1ad47SJeff Kirsher u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES]; 145dee1ad47SJeff Kirsher u16 num_vf_mc_hashes; 146dee1ad47SJeff Kirsher bool clear_to_send; 147dee1ad47SJeff Kirsher bool pf_set_mac; 148dee1ad47SJeff Kirsher u16 pf_vlan; /* When set, guest VLAN config not allowed. */ 149dee1ad47SJeff Kirsher u16 pf_qos; 150dee1ad47SJeff Kirsher u16 tx_rate; 151de4c7f65SGreg Rose u8 spoofchk_enabled; 152e65ce0d3SVlad Zolotarov bool rss_query_enabled; 15354011e4dSHiroshi Shimamoto u8 trusted; 1548443c1a4SHiroshi Shimamoto int xcast_mode; 155374c65d6SAlexander Duyck unsigned int vf_api; 156dee1ad47SJeff Kirsher }; 157dee1ad47SJeff Kirsher 1588443c1a4SHiroshi Shimamoto enum ixgbevf_xcast_modes { 1598443c1a4SHiroshi Shimamoto IXGBEVF_XCAST_MODE_NONE = 0, 1608443c1a4SHiroshi Shimamoto IXGBEVF_XCAST_MODE_MULTI, 1618443c1a4SHiroshi Shimamoto IXGBEVF_XCAST_MODE_ALLMULTI, 16207eea570SDon Skidmore IXGBEVF_XCAST_MODE_PROMISC, 1638443c1a4SHiroshi Shimamoto }; 1648443c1a4SHiroshi Shimamoto 165dee1ad47SJeff Kirsher struct vf_macvlans { 166dee1ad47SJeff Kirsher struct list_head l; 167dee1ad47SJeff Kirsher int vf; 168dee1ad47SJeff Kirsher bool free; 169dee1ad47SJeff Kirsher bool is_macvlan; 170dee1ad47SJeff Kirsher u8 vf_macvlan[ETH_ALEN]; 171dee1ad47SJeff Kirsher }; 172dee1ad47SJeff Kirsher 173dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD_PWR 14 174b4f47a48SJacob Keller #define IXGBE_MAX_DATA_PER_TXD (1u << IXGBE_MAX_TXD_PWR) 175dee1ad47SJeff Kirsher 176dee1ad47SJeff Kirsher /* Tx Descriptors needed, worst case */ 177dee1ad47SJeff Kirsher #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD) 178990a3158SAlexander Duyck #define DESC_NEEDED (MAX_SKB_FRAGS + 4) 179dee1ad47SJeff Kirsher 180dee1ad47SJeff Kirsher /* wrapper around a pointer to a socket buffer, 181dee1ad47SJeff Kirsher * so a DMA handle can be stored along with the buffer */ 182dee1ad47SJeff Kirsher struct ixgbe_tx_buffer { 183d3d00239SAlexander Duyck union ixgbe_adv_tx_desc *next_to_watch; 184dee1ad47SJeff Kirsher unsigned long time_stamp; 185d3d00239SAlexander Duyck struct sk_buff *skb; 186fd0db0edSAlexander Duyck unsigned int bytecount; 187fd0db0edSAlexander Duyck unsigned short gso_segs; 188244e27adSAlexander Duyck __be16 protocol; 189729739b7SAlexander Duyck DEFINE_DMA_UNMAP_ADDR(dma); 190729739b7SAlexander Duyck DEFINE_DMA_UNMAP_LEN(len); 191fd0db0edSAlexander Duyck u32 tx_flags; 192dee1ad47SJeff Kirsher }; 193dee1ad47SJeff Kirsher 194dee1ad47SJeff Kirsher struct ixgbe_rx_buffer { 195dee1ad47SJeff Kirsher struct sk_buff *skb; 196dee1ad47SJeff Kirsher dma_addr_t dma; 197dee1ad47SJeff Kirsher struct page *page; 198dee1ad47SJeff Kirsher unsigned int page_offset; 199dee1ad47SJeff Kirsher }; 200dee1ad47SJeff Kirsher 201dee1ad47SJeff Kirsher struct ixgbe_queue_stats { 202dee1ad47SJeff Kirsher u64 packets; 203dee1ad47SJeff Kirsher u64 bytes; 204dee1ad47SJeff Kirsher }; 205dee1ad47SJeff Kirsher 206dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats { 207dee1ad47SJeff Kirsher u64 restart_queue; 208dee1ad47SJeff Kirsher u64 tx_busy; 209dee1ad47SJeff Kirsher u64 tx_done_old; 210dee1ad47SJeff Kirsher }; 211dee1ad47SJeff Kirsher 212dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats { 213dee1ad47SJeff Kirsher u64 rsc_count; 214dee1ad47SJeff Kirsher u64 rsc_flush; 215dee1ad47SJeff Kirsher u64 non_eop_descs; 216dee1ad47SJeff Kirsher u64 alloc_rx_page_failed; 217dee1ad47SJeff Kirsher u64 alloc_rx_buff_failed; 2188a0da21bSAlexander Duyck u64 csum_err; 219dee1ad47SJeff Kirsher }; 220dee1ad47SJeff Kirsher 221a9763f3cSMark Rustad #define IXGBE_TS_HDR_LEN 8 222a9763f3cSMark Rustad 223f800326dSAlexander Duyck enum ixgbe_ring_state_t { 224dee1ad47SJeff Kirsher __IXGBE_TX_FDIR_INIT_DONE, 225fd786b7bSAlexander Duyck __IXGBE_TX_XPS_INIT_DONE, 226dee1ad47SJeff Kirsher __IXGBE_TX_DETECT_HANG, 227dee1ad47SJeff Kirsher __IXGBE_HANG_CHECK_ARMED, 228dee1ad47SJeff Kirsher __IXGBE_RX_RSC_ENABLED, 2298a0da21bSAlexander Duyck __IXGBE_RX_CSUM_UDP_ZERO_ERR, 23057efd44cSAlexander Duyck __IXGBE_RX_FCOE, 231dee1ad47SJeff Kirsher }; 232dee1ad47SJeff Kirsher 2332a47fa45SJohn Fastabend struct ixgbe_fwd_adapter { 2342a47fa45SJohn Fastabend unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 2352a47fa45SJohn Fastabend struct net_device *netdev; 2362a47fa45SJohn Fastabend struct ixgbe_adapter *real_adapter; 2372a47fa45SJohn Fastabend unsigned int tx_base_queue; 2382a47fa45SJohn Fastabend unsigned int rx_base_queue; 2392a47fa45SJohn Fastabend int pool; 2402a47fa45SJohn Fastabend }; 2412a47fa45SJohn Fastabend 242dee1ad47SJeff Kirsher #define check_for_tx_hang(ring) \ 243dee1ad47SJeff Kirsher test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state) 244dee1ad47SJeff Kirsher #define set_check_for_tx_hang(ring) \ 245dee1ad47SJeff Kirsher set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state) 246dee1ad47SJeff Kirsher #define clear_check_for_tx_hang(ring) \ 247dee1ad47SJeff Kirsher clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state) 248dee1ad47SJeff Kirsher #define ring_is_rsc_enabled(ring) \ 249dee1ad47SJeff Kirsher test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state) 250dee1ad47SJeff Kirsher #define set_ring_rsc_enabled(ring) \ 251dee1ad47SJeff Kirsher set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state) 252dee1ad47SJeff Kirsher #define clear_ring_rsc_enabled(ring) \ 253dee1ad47SJeff Kirsher clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state) 254dee1ad47SJeff Kirsher struct ixgbe_ring { 255efe3d3c8SAlexander Duyck struct ixgbe_ring *next; /* pointer to next ring in q_vector */ 256d3ee4294SAlexander Duyck struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */ 257dee1ad47SJeff Kirsher struct net_device *netdev; /* netdev ring belongs to */ 258d3ee4294SAlexander Duyck struct device *dev; /* device for DMA mapping */ 2592a47fa45SJohn Fastabend struct ixgbe_fwd_adapter *l2_accel_priv; 260d3ee4294SAlexander Duyck void *desc; /* descriptor ring memory */ 261dee1ad47SJeff Kirsher union { 262dee1ad47SJeff Kirsher struct ixgbe_tx_buffer *tx_buffer_info; 263dee1ad47SJeff Kirsher struct ixgbe_rx_buffer *rx_buffer_info; 264dee1ad47SJeff Kirsher }; 265dee1ad47SJeff Kirsher unsigned long state; 266dee1ad47SJeff Kirsher u8 __iomem *tail; 267d3ee4294SAlexander Duyck dma_addr_t dma; /* phys. address of descriptor ring */ 268d3ee4294SAlexander Duyck unsigned int size; /* length in bytes */ 269dee1ad47SJeff Kirsher 270dee1ad47SJeff Kirsher u16 count; /* amount of descriptors */ 271dee1ad47SJeff Kirsher 272dee1ad47SJeff Kirsher u8 queue_index; /* needed for multiqueue queue management */ 273dee1ad47SJeff Kirsher u8 reg_idx; /* holds the special value that gets 274dee1ad47SJeff Kirsher * the hardware register offset 275dee1ad47SJeff Kirsher * associated with this ring, which is 276dee1ad47SJeff Kirsher * different for DCB and RSS modes 277dee1ad47SJeff Kirsher */ 278d3ee4294SAlexander Duyck u16 next_to_use; 279d3ee4294SAlexander Duyck u16 next_to_clean; 280d3ee4294SAlexander Duyck 281a9763f3cSMark Rustad unsigned long last_rx_timestamp; 282a9763f3cSMark Rustad 283f800326dSAlexander Duyck union { 284d3ee4294SAlexander Duyck u16 next_to_alloc; 285f800326dSAlexander Duyck struct { 286dee1ad47SJeff Kirsher u8 atr_sample_rate; 287dee1ad47SJeff Kirsher u8 atr_count; 288f800326dSAlexander Duyck }; 289f800326dSAlexander Duyck }; 290dee1ad47SJeff Kirsher 291dee1ad47SJeff Kirsher u8 dcb_tc; 292dee1ad47SJeff Kirsher struct ixgbe_queue_stats stats; 293dee1ad47SJeff Kirsher struct u64_stats_sync syncp; 294dee1ad47SJeff Kirsher union { 295dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats tx_stats; 296dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats rx_stats; 297dee1ad47SJeff Kirsher }; 298dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp; 299dee1ad47SJeff Kirsher 300dee1ad47SJeff Kirsher enum ixgbe_ring_f_enum { 301dee1ad47SJeff Kirsher RING_F_NONE = 0, 302dee1ad47SJeff Kirsher RING_F_VMDQ, /* SR-IOV uses the same ring feature */ 303dee1ad47SJeff Kirsher RING_F_RSS, 304dee1ad47SJeff Kirsher RING_F_FDIR, 305dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE 306dee1ad47SJeff Kirsher RING_F_FCOE, 307dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */ 308dee1ad47SJeff Kirsher 309dee1ad47SJeff Kirsher RING_F_ARRAY_SIZE /* must be last in enum set */ 310dee1ad47SJeff Kirsher }; 311dee1ad47SJeff Kirsher 312dee1ad47SJeff Kirsher #define IXGBE_MAX_RSS_INDICES 16 313e9ee3238SEmil Tantilov #define IXGBE_MAX_RSS_INDICES_X550 63 314dee1ad47SJeff Kirsher #define IXGBE_MAX_VMDQ_INDICES 64 315d3cb9869SAlexander Duyck #define IXGBE_MAX_FDIR_INDICES 63 /* based on q_vector limit */ 316dee1ad47SJeff Kirsher #define IXGBE_MAX_FCOE_INDICES 8 317d3cb9869SAlexander Duyck #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1) 318d3cb9869SAlexander Duyck #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1) 3192a47fa45SJohn Fastabend #define IXGBE_MAX_L2A_QUEUES 4 3202a47fa45SJohn Fastabend #define IXGBE_BAD_L2A_QUEUE 3 3212a47fa45SJohn Fastabend #define IXGBE_MAX_MACVLANS 31 3222a47fa45SJohn Fastabend #define IXGBE_MAX_DCBMACVLANS 8 3232a47fa45SJohn Fastabend 324dee1ad47SJeff Kirsher struct ixgbe_ring_feature { 325c087663eSAlexander Duyck u16 limit; /* upper limit on feature indices */ 326c087663eSAlexander Duyck u16 indices; /* current value of indices */ 327e4b317e9SAlexander Duyck u16 mask; /* Mask used for feature to ring mapping */ 328e4b317e9SAlexander Duyck u16 offset; /* offset to start of feature */ 329dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp; 330dee1ad47SJeff Kirsher 33173079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_8Q_MASK 0x78 33273079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_4Q_MASK 0x7C 33373079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_2Q_MASK 0x7E 33473079ea0SAlexander Duyck 335f800326dSAlexander Duyck /* 336f800326dSAlexander Duyck * FCoE requires that all Rx buffers be over 2200 bytes in length. Since 337f800326dSAlexander Duyck * this is twice the size of a half page we need to double the page order 338f800326dSAlexander Duyck * for FCoE enabled Rx queues. 339f800326dSAlexander Duyck */ 34009816fbeSAlexander Duyck static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring) 34109816fbeSAlexander Duyck { 34209816fbeSAlexander Duyck #ifdef IXGBE_FCOE 34309816fbeSAlexander Duyck if (test_bit(__IXGBE_RX_FCOE, &ring->state)) 34409816fbeSAlexander Duyck return (PAGE_SIZE < 8192) ? IXGBE_RXBUFFER_4K : 34509816fbeSAlexander Duyck IXGBE_RXBUFFER_3K; 34609816fbeSAlexander Duyck #endif 34709816fbeSAlexander Duyck return IXGBE_RXBUFFER_2K; 34809816fbeSAlexander Duyck } 34909816fbeSAlexander Duyck 350f800326dSAlexander Duyck static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring) 351f800326dSAlexander Duyck { 35209816fbeSAlexander Duyck #ifdef IXGBE_FCOE 35309816fbeSAlexander Duyck if (test_bit(__IXGBE_RX_FCOE, &ring->state)) 35409816fbeSAlexander Duyck return (PAGE_SIZE < 8192) ? 1 : 0; 355f800326dSAlexander Duyck #endif 35609816fbeSAlexander Duyck return 0; 35709816fbeSAlexander Duyck } 358f800326dSAlexander Duyck #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring)) 359f800326dSAlexander Duyck 360dee1ad47SJeff Kirsher struct ixgbe_ring_container { 361efe3d3c8SAlexander Duyck struct ixgbe_ring *ring; /* pointer to linked list of rings */ 362dee1ad47SJeff Kirsher unsigned int total_bytes; /* total bytes processed this int */ 363dee1ad47SJeff Kirsher unsigned int total_packets; /* total packets processed this int */ 364dee1ad47SJeff Kirsher u16 work_limit; /* total work allowed per interrupt */ 365dee1ad47SJeff Kirsher u8 count; /* total number of rings in vector */ 366dee1ad47SJeff Kirsher u8 itr; /* current ITR setting for ring */ 367dee1ad47SJeff Kirsher }; 368dee1ad47SJeff Kirsher 369a557928eSAlexander Duyck /* iterator for handling rings in ring container */ 370a557928eSAlexander Duyck #define ixgbe_for_each_ring(pos, head) \ 371a557928eSAlexander Duyck for (pos = (head).ring; pos != NULL; pos = pos->next) 372a557928eSAlexander Duyck 373dee1ad47SJeff Kirsher #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \ 374dee1ad47SJeff Kirsher ? 8 : 1) 375dee1ad47SJeff Kirsher #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS 376dee1ad47SJeff Kirsher 37749c7ffbeSAlexander Duyck /* MAX_Q_VECTORS of these are allocated, 378dee1ad47SJeff Kirsher * but we only use one per queue-specific vector. 379dee1ad47SJeff Kirsher */ 380dee1ad47SJeff Kirsher struct ixgbe_q_vector { 381dee1ad47SJeff Kirsher struct ixgbe_adapter *adapter; 382dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA 383dee1ad47SJeff Kirsher int cpu; /* CPU for DCA */ 384dee1ad47SJeff Kirsher #endif 385d5bf4f67SEmil Tantilov u16 v_idx; /* index of q_vector within array, also used for 386d5bf4f67SEmil Tantilov * finding the bit in EICR and friends that 387d5bf4f67SEmil Tantilov * represents the vector for this ring */ 388d5bf4f67SEmil Tantilov u16 itr; /* Interrupt throttle rate written to EITR */ 389dee1ad47SJeff Kirsher struct ixgbe_ring_container rx, tx; 390d5bf4f67SEmil Tantilov 391d5bf4f67SEmil Tantilov struct napi_struct napi; 392de88eeebSAlexander Duyck cpumask_t affinity_mask; 393de88eeebSAlexander Duyck int numa_node; 394de88eeebSAlexander Duyck struct rcu_head rcu; /* to avoid race with update stats on free */ 395dee1ad47SJeff Kirsher char name[IFNAMSIZ + 9]; 396de88eeebSAlexander Duyck 397de88eeebSAlexander Duyck /* for dynamic allocation of rings associated with this q_vector */ 398de88eeebSAlexander Duyck struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp; 399dee1ad47SJeff Kirsher }; 400adc81090SAlexander Duyck 4013ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON 4023ca8bc6dSDon Skidmore 4033ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_LOC 0 4043ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_TEMP 1 4053ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_CAUTION 2 4063ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_MAX 3 4073ca8bc6dSDon Skidmore 4083ca8bc6dSDon Skidmore struct hwmon_attr { 4093ca8bc6dSDon Skidmore struct device_attribute dev_attr; 4103ca8bc6dSDon Skidmore struct ixgbe_hw *hw; 4113ca8bc6dSDon Skidmore struct ixgbe_thermal_diode_data *sensor; 4123ca8bc6dSDon Skidmore char name[12]; 4133ca8bc6dSDon Skidmore }; 4143ca8bc6dSDon Skidmore 4153ca8bc6dSDon Skidmore struct hwmon_buff { 41603b77d81SGuenter Roeck struct attribute_group group; 41703b77d81SGuenter Roeck const struct attribute_group *groups[2]; 41803b77d81SGuenter Roeck struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1]; 41903b77d81SGuenter Roeck struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4]; 4203ca8bc6dSDon Skidmore unsigned int n_hwmon; 4213ca8bc6dSDon Skidmore }; 4223ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */ 423dee1ad47SJeff Kirsher 424d5bf4f67SEmil Tantilov /* 425d5bf4f67SEmil Tantilov * microsecond values for various ITR rates shifted by 2 to fit itr register 426d5bf4f67SEmil Tantilov * with the first 3 bits reserved 0 427dee1ad47SJeff Kirsher */ 428d5bf4f67SEmil Tantilov #define IXGBE_MIN_RSC_ITR 24 429d5bf4f67SEmil Tantilov #define IXGBE_100K_ITR 40 430d5bf4f67SEmil Tantilov #define IXGBE_20K_ITR 200 4318ac34f10SAlexander Duyck #define IXGBE_12K_ITR 336 432dee1ad47SJeff Kirsher 433f56e0cb1SAlexander Duyck /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */ 434f56e0cb1SAlexander Duyck static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc, 435f56e0cb1SAlexander Duyck const u32 stat_err_bits) 436f56e0cb1SAlexander Duyck { 437f56e0cb1SAlexander Duyck return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits); 438f56e0cb1SAlexander Duyck } 439f56e0cb1SAlexander Duyck 440dee1ad47SJeff Kirsher static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring) 441dee1ad47SJeff Kirsher { 442dee1ad47SJeff Kirsher u16 ntc = ring->next_to_clean; 443dee1ad47SJeff Kirsher u16 ntu = ring->next_to_use; 444dee1ad47SJeff Kirsher 445dee1ad47SJeff Kirsher return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1; 446dee1ad47SJeff Kirsher } 447dee1ad47SJeff Kirsher 448e4f74028SAlexander Duyck #define IXGBE_RX_DESC(R, i) \ 449dee1ad47SJeff Kirsher (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i])) 450e4f74028SAlexander Duyck #define IXGBE_TX_DESC(R, i) \ 451dee1ad47SJeff Kirsher (&(((union ixgbe_adv_tx_desc *)((R)->desc))[i])) 452e4f74028SAlexander Duyck #define IXGBE_TX_CTXTDESC(R, i) \ 453dee1ad47SJeff Kirsher (&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i])) 454dee1ad47SJeff Kirsher 455c88887e0SAlexander Duyck #define IXGBE_MAX_JUMBO_FRAME_SIZE 9728 /* Maximum Supported Size 9.5KB */ 456dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE 457dee1ad47SJeff Kirsher /* Use 3K as the baby jumbo frame size for FCoE */ 458dee1ad47SJeff Kirsher #define IXGBE_FCOE_JUMBO_FRAME_SIZE 3072 459dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */ 460dee1ad47SJeff Kirsher 461dee1ad47SJeff Kirsher #define OTHER_VECTOR 1 462dee1ad47SJeff Kirsher #define NON_Q_VECTORS (OTHER_VECTOR) 463dee1ad47SJeff Kirsher 464dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82599 64 46549c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82599 64 466dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82598 18 46749c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82598 16 468dee1ad47SJeff Kirsher 4695d7daa35SJacob Keller struct ixgbe_mac_addr { 4705d7daa35SJacob Keller u8 addr[ETH_ALEN]; 471c9f53e63SAlexander Duyck u16 pool; 4725d7daa35SJacob Keller u16 state; /* bitmask */ 4735d7daa35SJacob Keller }; 474c9f53e63SAlexander Duyck 4755d7daa35SJacob Keller #define IXGBE_MAC_STATE_DEFAULT 0x1 4765d7daa35SJacob Keller #define IXGBE_MAC_STATE_MODIFIED 0x2 4775d7daa35SJacob Keller #define IXGBE_MAC_STATE_IN_USE 0x4 4785d7daa35SJacob Keller 47949c7ffbeSAlexander Duyck #define MAX_Q_VECTORS MAX_Q_VECTORS_82599 480dee1ad47SJeff Kirsher #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599 481dee1ad47SJeff Kirsher 4828f15486dSAlexander Duyck #define MIN_MSIX_Q_VECTORS 1 483dee1ad47SJeff Kirsher #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS) 484dee1ad47SJeff Kirsher 48546646e61SAlexander Duyck /* default to trying for four seconds */ 48646646e61SAlexander Duyck #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ) 48758e7cd24SMark Rustad #define IXGBE_SFP_POLL_JIFFIES (2 * HZ) /* SFP poll every 2 seconds */ 48846646e61SAlexander Duyck 489dee1ad47SJeff Kirsher /* board specific private data structure */ 490dee1ad47SJeff Kirsher struct ixgbe_adapter { 49146646e61SAlexander Duyck unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 49246646e61SAlexander Duyck /* OS defined structs */ 49346646e61SAlexander Duyck struct net_device *netdev; 49446646e61SAlexander Duyck struct pci_dev *pdev; 49546646e61SAlexander Duyck 496dee1ad47SJeff Kirsher unsigned long state; 497dee1ad47SJeff Kirsher 498dee1ad47SJeff Kirsher /* Some features need tri-state capability, 499dee1ad47SJeff Kirsher * thus the additional *_CAPABLE flags. 500dee1ad47SJeff Kirsher */ 501dee1ad47SJeff Kirsher u32 flags; 502b4f47a48SJacob Keller #define IXGBE_FLAG_MSI_ENABLED BIT(1) 503b4f47a48SJacob Keller #define IXGBE_FLAG_MSIX_ENABLED BIT(3) 504b4f47a48SJacob Keller #define IXGBE_FLAG_RX_1BUF_CAPABLE BIT(4) 505b4f47a48SJacob Keller #define IXGBE_FLAG_RX_PS_CAPABLE BIT(5) 506b4f47a48SJacob Keller #define IXGBE_FLAG_RX_PS_ENABLED BIT(6) 507b4f47a48SJacob Keller #define IXGBE_FLAG_DCA_ENABLED BIT(8) 508b4f47a48SJacob Keller #define IXGBE_FLAG_DCA_CAPABLE BIT(9) 509b4f47a48SJacob Keller #define IXGBE_FLAG_IMIR_ENABLED BIT(10) 510b4f47a48SJacob Keller #define IXGBE_FLAG_MQ_CAPABLE BIT(11) 511b4f47a48SJacob Keller #define IXGBE_FLAG_DCB_ENABLED BIT(12) 512b4f47a48SJacob Keller #define IXGBE_FLAG_VMDQ_CAPABLE BIT(13) 513b4f47a48SJacob Keller #define IXGBE_FLAG_VMDQ_ENABLED BIT(14) 514b4f47a48SJacob Keller #define IXGBE_FLAG_FAN_FAIL_CAPABLE BIT(15) 515b4f47a48SJacob Keller #define IXGBE_FLAG_NEED_LINK_UPDATE BIT(16) 516b4f47a48SJacob Keller #define IXGBE_FLAG_NEED_LINK_CONFIG BIT(17) 517b4f47a48SJacob Keller #define IXGBE_FLAG_FDIR_HASH_CAPABLE BIT(18) 518b4f47a48SJacob Keller #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE BIT(19) 519b4f47a48SJacob Keller #define IXGBE_FLAG_FCOE_CAPABLE BIT(20) 520b4f47a48SJacob Keller #define IXGBE_FLAG_FCOE_ENABLED BIT(21) 521b4f47a48SJacob Keller #define IXGBE_FLAG_SRIOV_CAPABLE BIT(22) 522b4f47a48SJacob Keller #define IXGBE_FLAG_SRIOV_ENABLED BIT(23) 52367359c3cSMark Rustad #define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24) 524a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25) 525a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26) 5268829009dSUsha Ketineni #define IXGBE_FLAG_DCB_CAPABLE BIT(27) 527a21d0822SEmil Tantilov #define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE BIT(28) 528dee1ad47SJeff Kirsher 529dee1ad47SJeff Kirsher u32 flags2; 530b4f47a48SJacob Keller #define IXGBE_FLAG2_RSC_CAPABLE BIT(0) 531b4f47a48SJacob Keller #define IXGBE_FLAG2_RSC_ENABLED BIT(1) 532b4f47a48SJacob Keller #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE BIT(2) 533b4f47a48SJacob Keller #define IXGBE_FLAG2_TEMP_SENSOR_EVENT BIT(3) 534b4f47a48SJacob Keller #define IXGBE_FLAG2_SEARCH_FOR_SFP BIT(4) 535b4f47a48SJacob Keller #define IXGBE_FLAG2_SFP_NEEDS_RESET BIT(5) 536b4f47a48SJacob Keller #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT BIT(7) 537b4f47a48SJacob Keller #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP BIT(8) 538b4f47a48SJacob Keller #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP BIT(9) 539b4f47a48SJacob Keller #define IXGBE_FLAG2_PTP_PPS_ENABLED BIT(10) 540b4f47a48SJacob Keller #define IXGBE_FLAG2_PHY_INTERRUPT BIT(11) 541a21d0822SEmil Tantilov #define IXGBE_FLAG2_UDP_TUN_REREG_NEEDED BIT(12) 54216369564SAlexander Duyck #define IXGBE_FLAG2_VLAN_PROMISC BIT(13) 543b3eb4e18SMark Rustad #define IXGBE_FLAG2_EEE_CAPABLE BIT(14) 544b3eb4e18SMark Rustad #define IXGBE_FLAG2_EEE_ENABLED BIT(15) 54546646e61SAlexander Duyck 54646646e61SAlexander Duyck /* Tx fast path data */ 54746646e61SAlexander Duyck int num_tx_queues; 54846646e61SAlexander Duyck u16 tx_itr_setting; 54946646e61SAlexander Duyck u16 tx_work_limit; 55046646e61SAlexander Duyck 55146646e61SAlexander Duyck /* Rx fast path data */ 55246646e61SAlexander Duyck int num_rx_queues; 55346646e61SAlexander Duyck u16 rx_itr_setting; 55446646e61SAlexander Duyck 5559f12df90SAlexander Duyck /* Port number used to identify VXLAN traffic */ 5569f12df90SAlexander Duyck __be16 vxlan_port; 557a21d0822SEmil Tantilov __be16 geneve_port; 5589f12df90SAlexander Duyck 55946646e61SAlexander Duyck /* TX */ 56046646e61SAlexander Duyck struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp; 56146646e61SAlexander Duyck 56246646e61SAlexander Duyck u64 restart_queue; 56346646e61SAlexander Duyck u64 lsc_int; 56446646e61SAlexander Duyck u32 tx_timeout_count; 56546646e61SAlexander Duyck 56646646e61SAlexander Duyck /* RX */ 56746646e61SAlexander Duyck struct ixgbe_ring *rx_ring[MAX_RX_QUEUES]; 56846646e61SAlexander Duyck int num_rx_pools; /* == num_rx_queues in 82598 */ 56946646e61SAlexander Duyck int num_rx_queues_per_pool; /* 1 if 82598, can be many if 82599 */ 57046646e61SAlexander Duyck u64 hw_csum_rx_error; 57146646e61SAlexander Duyck u64 hw_rx_no_dma_resources; 57246646e61SAlexander Duyck u64 rsc_total_count; 57346646e61SAlexander Duyck u64 rsc_total_flush; 57446646e61SAlexander Duyck u64 non_eop_descs; 57546646e61SAlexander Duyck u32 alloc_rx_page_failed; 57646646e61SAlexander Duyck u32 alloc_rx_buff_failed; 57746646e61SAlexander Duyck 57849c7ffbeSAlexander Duyck struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS]; 579dee1ad47SJeff Kirsher 580dee1ad47SJeff Kirsher /* DCB parameters */ 581dee1ad47SJeff Kirsher struct ieee_pfc *ixgbe_ieee_pfc; 582dee1ad47SJeff Kirsher struct ieee_ets *ixgbe_ieee_ets; 583dee1ad47SJeff Kirsher struct ixgbe_dcb_config dcb_cfg; 584dee1ad47SJeff Kirsher struct ixgbe_dcb_config temp_dcb_cfg; 585dee1ad47SJeff Kirsher u8 dcb_set_bitmap; 586dee1ad47SJeff Kirsher u8 dcbx_cap; 587dee1ad47SJeff Kirsher enum ixgbe_fc_mode last_lfc_mode; 588dee1ad47SJeff Kirsher 58949c7ffbeSAlexander Duyck int num_q_vectors; /* current number of q_vectors for device */ 59049c7ffbeSAlexander Duyck int max_q_vectors; /* true count of q_vectors for device */ 591dee1ad47SJeff Kirsher struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE]; 592dee1ad47SJeff Kirsher struct msix_entry *msix_entries; 593dee1ad47SJeff Kirsher 594dee1ad47SJeff Kirsher u32 test_icr; 595dee1ad47SJeff Kirsher struct ixgbe_ring test_tx_ring; 596dee1ad47SJeff Kirsher struct ixgbe_ring test_rx_ring; 597dee1ad47SJeff Kirsher 598dee1ad47SJeff Kirsher /* structs defined in ixgbe_hw.h */ 599dee1ad47SJeff Kirsher struct ixgbe_hw hw; 600dee1ad47SJeff Kirsher u16 msg_enable; 601dee1ad47SJeff Kirsher struct ixgbe_hw_stats stats; 602dee1ad47SJeff Kirsher 603dee1ad47SJeff Kirsher u64 tx_busy; 604dee1ad47SJeff Kirsher unsigned int tx_ring_count; 605dee1ad47SJeff Kirsher unsigned int rx_ring_count; 606dee1ad47SJeff Kirsher 607dee1ad47SJeff Kirsher u32 link_speed; 608dee1ad47SJeff Kirsher bool link_up; 60958e7cd24SMark Rustad unsigned long sfp_poll_time; 610dee1ad47SJeff Kirsher unsigned long link_check_timeout; 611dee1ad47SJeff Kirsher 612dee1ad47SJeff Kirsher struct timer_list service_timer; 61346646e61SAlexander Duyck struct work_struct service_task; 61446646e61SAlexander Duyck 61546646e61SAlexander Duyck struct hlist_head fdir_filter_list; 61646646e61SAlexander Duyck unsigned long fdir_overflow; /* number of times ATR was backed off */ 61746646e61SAlexander Duyck union ixgbe_atr_input fdir_mask; 61846646e61SAlexander Duyck int fdir_filter_count; 619dee1ad47SJeff Kirsher u32 fdir_pballoc; 620dee1ad47SJeff Kirsher u32 atr_sample_rate; 621dee1ad47SJeff Kirsher spinlock_t fdir_perfect_lock; 62246646e61SAlexander Duyck 623dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE 624dee1ad47SJeff Kirsher struct ixgbe_fcoe fcoe; 625dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */ 6262a1a091cSMark Rustad u8 __iomem *io_addr; /* Mainly for iounmap use */ 627dee1ad47SJeff Kirsher u32 wol; 62846646e61SAlexander Duyck 629aa2bacb6SDon Skidmore u16 bridge_mode; 630aa2bacb6SDon Skidmore 63115e5209fSEmil Tantilov u16 eeprom_verh; 63215e5209fSEmil Tantilov u16 eeprom_verl; 633c23f5b6bSEmil Tantilov u16 eeprom_cap; 634dee1ad47SJeff Kirsher 635dee1ad47SJeff Kirsher u32 interrupt_event; 63646646e61SAlexander Duyck u32 led_reg; 637dee1ad47SJeff Kirsher 6383a6a4edaSJacob Keller struct ptp_clock *ptp_clock; 6393a6a4edaSJacob Keller struct ptp_clock_info ptp_caps; 640891dc082SJacob Keller struct work_struct ptp_tx_work; 641891dc082SJacob Keller struct sk_buff *ptp_tx_skb; 64293501d48SJacob Keller struct hwtstamp_config tstamp_config; 643891dc082SJacob Keller unsigned long ptp_tx_start; 6443a6a4edaSJacob Keller unsigned long last_overflow_check; 6456cb562d6SJacob Keller unsigned long last_rx_ptp_check; 646eda183c2SJakub Kicinski unsigned long last_rx_timestamp; 6473a6a4edaSJacob Keller spinlock_t tmreg_lock; 648a9763f3cSMark Rustad struct cyclecounter hw_cc; 649a9763f3cSMark Rustad struct timecounter hw_tc; 6503a6a4edaSJacob Keller u32 base_incval; 651a9763f3cSMark Rustad u32 tx_hwtstamp_timeouts; 652a9763f3cSMark Rustad u32 rx_hwtstamp_cleared; 653a9763f3cSMark Rustad void (*ptp_setup_sdp)(struct ixgbe_adapter *); 6543a6a4edaSJacob Keller 655dee1ad47SJeff Kirsher /* SR-IOV */ 656dee1ad47SJeff Kirsher DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS); 657dee1ad47SJeff Kirsher unsigned int num_vfs; 658dee1ad47SJeff Kirsher struct vf_data_storage *vfinfo; 659dee1ad47SJeff Kirsher int vf_rate_link_speed; 660dee1ad47SJeff Kirsher struct vf_macvlans vf_mvs; 661dee1ad47SJeff Kirsher struct vf_macvlans *mv_list; 662dee1ad47SJeff Kirsher 66383c61fa9SGreg Rose u32 timer_event_accumulator; 66483c61fa9SGreg Rose u32 vferr_refcount; 6655d7daa35SJacob Keller struct ixgbe_mac_addr *mac_table; 6663ca8bc6dSDon Skidmore struct kobject *info_kobj; 6673ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON 66803b77d81SGuenter Roeck struct hwmon_buff *ixgbe_hwmon_buff; 6693ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */ 67000949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS 67100949167SCatherine Sullivan struct dentry *ixgbe_dbg_adapter; 67200949167SCatherine Sullivan #endif /*CONFIG_DEBUG_FS*/ 673107d3018SAlexander Duyck 674107d3018SAlexander Duyck u8 default_up; 6752a47fa45SJohn Fastabend unsigned long fwd_bitmask; /* Bitmask indicating in use pools */ 676dfaf891dSVlad Zolotarov 677b82b17d9SJohn Fastabend #define IXGBE_MAX_LINK_HANDLE 10 6781cdaaf54SAmritha Nambiar struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE]; 679db956ae8SJohn Fastabend unsigned long tables; 680b82b17d9SJohn Fastabend 681dfaf891dSVlad Zolotarov /* maximum number of RETA entries among all devices supported by ixgbe 682dfaf891dSVlad Zolotarov * driver: currently it's x550 device in non-SRIOV mode 683dfaf891dSVlad Zolotarov */ 684dfaf891dSVlad Zolotarov #define IXGBE_MAX_RETA_ENTRIES 512 685dfaf891dSVlad Zolotarov u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES]; 686dfaf891dSVlad Zolotarov 687dfaf891dSVlad Zolotarov #define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */ 688dfaf891dSVlad Zolotarov u32 rss_key[IXGBE_RSS_KEY_SIZE / sizeof(u32)]; 689dee1ad47SJeff Kirsher }; 690dee1ad47SJeff Kirsher 6910f9b232bSDon Skidmore static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter) 6920f9b232bSDon Skidmore { 6930f9b232bSDon Skidmore switch (adapter->hw.mac.type) { 6940f9b232bSDon Skidmore case ixgbe_mac_82598EB: 6950f9b232bSDon Skidmore case ixgbe_mac_82599EB: 6960f9b232bSDon Skidmore case ixgbe_mac_X540: 6970f9b232bSDon Skidmore return IXGBE_MAX_RSS_INDICES; 6980f9b232bSDon Skidmore case ixgbe_mac_X550: 6990f9b232bSDon Skidmore case ixgbe_mac_X550EM_x: 70049425dfcSMark Rustad case ixgbe_mac_x550em_a: 7010f9b232bSDon Skidmore return IXGBE_MAX_RSS_INDICES_X550; 7020f9b232bSDon Skidmore default: 7030f9b232bSDon Skidmore return 0; 7040f9b232bSDon Skidmore } 7050f9b232bSDon Skidmore } 7060f9b232bSDon Skidmore 707dee1ad47SJeff Kirsher struct ixgbe_fdir_filter { 708dee1ad47SJeff Kirsher struct hlist_node fdir_node; 709dee1ad47SJeff Kirsher union ixgbe_atr_input filter; 710dee1ad47SJeff Kirsher u16 sw_idx; 7112a9ed5d1SSridhar Samudrala u64 action; 712dee1ad47SJeff Kirsher }; 713dee1ad47SJeff Kirsher 71470e5576cSDon Skidmore enum ixgbe_state_t { 715dee1ad47SJeff Kirsher __IXGBE_TESTING, 716dee1ad47SJeff Kirsher __IXGBE_RESETTING, 717dee1ad47SJeff Kirsher __IXGBE_DOWN, 71841c62843SMark Rustad __IXGBE_DISABLED, 71909f40aedSMark Rustad __IXGBE_REMOVING, 720dee1ad47SJeff Kirsher __IXGBE_SERVICE_SCHED, 72158cf663fSMark Rustad __IXGBE_SERVICE_INITED, 722dee1ad47SJeff Kirsher __IXGBE_IN_SFP_INIT, 7238fecf67cSJacob Keller __IXGBE_PTP_RUNNING, 724151b260cSJakub Kicinski __IXGBE_PTP_TX_IN_PROGRESS, 72557ca2a4fSEmil Tantilov __IXGBE_RESET_REQUESTED, 726dee1ad47SJeff Kirsher }; 727dee1ad47SJeff Kirsher 7284c1975d7SAlexander Duyck struct ixgbe_cb { 7294c1975d7SAlexander Duyck union { /* Union defining head/tail partner */ 7304c1975d7SAlexander Duyck struct sk_buff *head; 7314c1975d7SAlexander Duyck struct sk_buff *tail; 7324c1975d7SAlexander Duyck }; 733dee1ad47SJeff Kirsher dma_addr_t dma; 7344c1975d7SAlexander Duyck u16 append_cnt; 735f800326dSAlexander Duyck bool page_released; 736dee1ad47SJeff Kirsher }; 7374c1975d7SAlexander Duyck #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb) 738dee1ad47SJeff Kirsher 739dee1ad47SJeff Kirsher enum ixgbe_boards { 740dee1ad47SJeff Kirsher board_82598, 741dee1ad47SJeff Kirsher board_82599, 742dee1ad47SJeff Kirsher board_X540, 7436a14ee0cSDon Skidmore board_X550, 7446a14ee0cSDon Skidmore board_X550EM_x, 74549425dfcSMark Rustad board_x550em_a, 746b3eb4e18SMark Rustad board_x550em_a_fw, 747dee1ad47SJeff Kirsher }; 748dee1ad47SJeff Kirsher 74937689010SMark Rustad extern const struct ixgbe_info ixgbe_82598_info; 75037689010SMark Rustad extern const struct ixgbe_info ixgbe_82599_info; 75137689010SMark Rustad extern const struct ixgbe_info ixgbe_X540_info; 75237689010SMark Rustad extern const struct ixgbe_info ixgbe_X550_info; 75337689010SMark Rustad extern const struct ixgbe_info ixgbe_X550EM_x_info; 75449425dfcSMark Rustad extern const struct ixgbe_info ixgbe_x550em_a_info; 755b3eb4e18SMark Rustad extern const struct ixgbe_info ixgbe_x550em_a_fw_info; 756dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB 7573f40c74cSStephen Hemminger extern const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops; 758dee1ad47SJeff Kirsher #endif 759dee1ad47SJeff Kirsher 760dee1ad47SJeff Kirsher extern char ixgbe_driver_name[]; 761dee1ad47SJeff Kirsher extern const char ixgbe_driver_version[]; 7628af3c33fSJeff Kirsher #ifdef IXGBE_FCOE 763ea81875aSNeerav Parikh extern char ixgbe_default_device_descr[]; 7648af3c33fSJeff Kirsher #endif /* IXGBE_FCOE */ 765dee1ad47SJeff Kirsher 7666c211fe1SStefan Assmann int ixgbe_open(struct net_device *netdev); 7676c211fe1SStefan Assmann int ixgbe_close(struct net_device *netdev); 7685ccc921aSJoe Perches void ixgbe_up(struct ixgbe_adapter *adapter); 7695ccc921aSJoe Perches void ixgbe_down(struct ixgbe_adapter *adapter); 7705ccc921aSJoe Perches void ixgbe_reinit_locked(struct ixgbe_adapter *adapter); 7715ccc921aSJoe Perches void ixgbe_reset(struct ixgbe_adapter *adapter); 7725ccc921aSJoe Perches void ixgbe_set_ethtool_ops(struct net_device *netdev); 7735ccc921aSJoe Perches int ixgbe_setup_rx_resources(struct ixgbe_ring *); 7745ccc921aSJoe Perches int ixgbe_setup_tx_resources(struct ixgbe_ring *); 7755ccc921aSJoe Perches void ixgbe_free_rx_resources(struct ixgbe_ring *); 7765ccc921aSJoe Perches void ixgbe_free_tx_resources(struct ixgbe_ring *); 7775ccc921aSJoe Perches void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *); 7785ccc921aSJoe Perches void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *); 7795ccc921aSJoe Perches void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_ring *); 7805ccc921aSJoe Perches void ixgbe_update_stats(struct ixgbe_adapter *adapter); 7815ccc921aSJoe Perches int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter); 782740234f0SEmil Tantilov bool ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id, 7838e2813f5SJacob Keller u16 subdevice_id); 7845d7daa35SJacob Keller #ifdef CONFIG_PCI_IOV 7855d7daa35SJacob Keller void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter); 7865d7daa35SJacob Keller #endif 7875d7daa35SJacob Keller int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter, 788c9f53e63SAlexander Duyck const u8 *addr, u16 queue); 7895d7daa35SJacob Keller int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter, 790c9f53e63SAlexander Duyck const u8 *addr, u16 queue); 791e1d0a2afSAlexander Duyck void ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid); 7925ccc921aSJoe Perches void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter); 7935ccc921aSJoe Perches netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *, 794dee1ad47SJeff Kirsher struct ixgbe_ring *); 7955ccc921aSJoe Perches void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *, 796dee1ad47SJeff Kirsher struct ixgbe_tx_buffer *); 7975ccc921aSJoe Perches void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16); 7985ccc921aSJoe Perches void ixgbe_write_eitr(struct ixgbe_q_vector *); 7995ccc921aSJoe Perches int ixgbe_poll(struct napi_struct *napi, int budget); 8005ccc921aSJoe Perches int ethtool_ioctl(struct ifreq *ifr); 8015ccc921aSJoe Perches s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw); 8025ccc921aSJoe Perches s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl); 8035ccc921aSJoe Perches s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl); 8045ccc921aSJoe Perches s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw, 805dee1ad47SJeff Kirsher union ixgbe_atr_hash_dword input, 806dee1ad47SJeff Kirsher union ixgbe_atr_hash_dword common, 807dee1ad47SJeff Kirsher u8 queue); 8085ccc921aSJoe Perches s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw, 809dee1ad47SJeff Kirsher union ixgbe_atr_input *input_mask); 8105ccc921aSJoe Perches s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw, 811dee1ad47SJeff Kirsher union ixgbe_atr_input *input, 812dee1ad47SJeff Kirsher u16 soft_id, u8 queue); 8135ccc921aSJoe Perches s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw, 814dee1ad47SJeff Kirsher union ixgbe_atr_input *input, 815dee1ad47SJeff Kirsher u16 soft_id); 8165ccc921aSJoe Perches void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input, 817dee1ad47SJeff Kirsher union ixgbe_atr_input *mask); 818b82b17d9SJohn Fastabend int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter, 819b82b17d9SJohn Fastabend struct ixgbe_fdir_filter *input, 820b82b17d9SJohn Fastabend u16 sw_idx); 8215ccc921aSJoe Perches void ixgbe_set_rx_mode(struct net_device *netdev); 8228af3c33fSJeff Kirsher #ifdef CONFIG_IXGBE_DCB 8235ccc921aSJoe Perches void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter); 8248af3c33fSJeff Kirsher #endif 8255ccc921aSJoe Perches int ixgbe_setup_tc(struct net_device *dev, u8 tc); 8265ccc921aSJoe Perches void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); 8275ccc921aSJoe Perches void ixgbe_do_reset(struct net_device *netdev); 8281210982bSDon Skidmore #ifdef CONFIG_IXGBE_HWMON 8295ccc921aSJoe Perches void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter); 8305ccc921aSJoe Perches int ixgbe_sysfs_init(struct ixgbe_adapter *adapter); 8311210982bSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */ 832dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE 8335ccc921aSJoe Perches void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); 8345ccc921aSJoe Perches int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first, 835244e27adSAlexander Duyck u8 *hdr_len); 8365ccc921aSJoe Perches int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter, 8375ccc921aSJoe Perches union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb); 8385ccc921aSJoe Perches int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid, 839dee1ad47SJeff Kirsher struct scatterlist *sgl, unsigned int sgc); 8405ccc921aSJoe Perches int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid, 841dee1ad47SJeff Kirsher struct scatterlist *sgl, unsigned int sgc); 8425ccc921aSJoe Perches int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid); 8435ccc921aSJoe Perches int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter); 8445ccc921aSJoe Perches void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter); 8455ccc921aSJoe Perches int ixgbe_fcoe_enable(struct net_device *netdev); 8465ccc921aSJoe Perches int ixgbe_fcoe_disable(struct net_device *netdev); 847dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB 8485ccc921aSJoe Perches u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter); 8495ccc921aSJoe Perches u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up); 850dee1ad47SJeff Kirsher #endif /* CONFIG_IXGBE_DCB */ 8515ccc921aSJoe Perches int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type); 8525ccc921aSJoe Perches int ixgbe_fcoe_get_hbainfo(struct net_device *netdev, 853ea81875aSNeerav Parikh struct netdev_fcoe_hbainfo *info); 8545ccc921aSJoe Perches u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter); 855dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */ 85600949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS 8575ccc921aSJoe Perches void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter); 8585ccc921aSJoe Perches void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter); 8595ccc921aSJoe Perches void ixgbe_dbg_init(void); 8605ccc921aSJoe Perches void ixgbe_dbg_exit(void); 86133243fb0SJoe Perches #else 86233243fb0SJoe Perches static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {} 86333243fb0SJoe Perches static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {} 86433243fb0SJoe Perches static inline void ixgbe_dbg_init(void) {} 86533243fb0SJoe Perches static inline void ixgbe_dbg_exit(void) {} 86600949167SCatherine Sullivan #endif /* CONFIG_DEBUG_FS */ 867b2d96e0aSAlexander Duyck static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring) 868b2d96e0aSAlexander Duyck { 869b2d96e0aSAlexander Duyck return netdev_get_tx_queue(ring->netdev, ring->queue_index); 870b2d96e0aSAlexander Duyck } 871b2d96e0aSAlexander Duyck 8725ccc921aSJoe Perches void ixgbe_ptp_init(struct ixgbe_adapter *adapter); 8739966d1eeSJacob Keller void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter); 8745ccc921aSJoe Perches void ixgbe_ptp_stop(struct ixgbe_adapter *adapter); 8755ccc921aSJoe Perches void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter); 8765ccc921aSJoe Perches void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter); 877a9763f3cSMark Rustad void ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *); 878a9763f3cSMark Rustad void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb); 879a9763f3cSMark Rustad static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring, 880a9763f3cSMark Rustad union ixgbe_adv_rx_desc *rx_desc, 881a9763f3cSMark Rustad struct sk_buff *skb) 882a9763f3cSMark Rustad { 883a9763f3cSMark Rustad if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) { 884a9763f3cSMark Rustad ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb); 885a9763f3cSMark Rustad return; 886a9763f3cSMark Rustad } 887a9763f3cSMark Rustad 888a9763f3cSMark Rustad if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))) 889a9763f3cSMark Rustad return; 890a9763f3cSMark Rustad 891a9763f3cSMark Rustad ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb); 892a9763f3cSMark Rustad 893a9763f3cSMark Rustad /* Update the last_rx_timestamp timer in order to enable watchdog check 894a9763f3cSMark Rustad * for error case of latched timestamp on a dropped packet. 895a9763f3cSMark Rustad */ 896a9763f3cSMark Rustad rx_ring->last_rx_timestamp = jiffies; 897a9763f3cSMark Rustad } 898a9763f3cSMark Rustad 89993501d48SJacob Keller int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr); 90093501d48SJacob Keller int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr); 9015ccc921aSJoe Perches void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter); 9025ccc921aSJoe Perches void ixgbe_ptp_reset(struct ixgbe_adapter *adapter); 903a9763f3cSMark Rustad void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter); 904da36b647SGreg Rose #ifdef CONFIG_PCI_IOV 905da36b647SGreg Rose void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter); 906da36b647SGreg Rose #endif 9073a6a4edaSJacob Keller 9082a47fa45SJohn Fastabend netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, 9092a47fa45SJohn Fastabend struct ixgbe_adapter *adapter, 9102a47fa45SJohn Fastabend struct ixgbe_ring *tx_ring); 9117f276efbSVlad Zolotarov u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter); 9121c7cf078STom Barbette void ixgbe_store_reta(struct ixgbe_adapter *adapter); 9132916500dSDon Skidmore s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg, 9142916500dSDon Skidmore u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm); 915dee1ad47SJeff Kirsher #endif /* _IXGBE_H_ */ 916