xref: /openbmc/linux/drivers/net/ethernet/intel/ixgbe/ixgbe.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1ae06c70bSJeff Kirsher /* SPDX-License-Identifier: GPL-2.0 */
251dce24bSJeff Kirsher /* Copyright(c) 1999 - 2018 Intel Corporation. */
3dee1ad47SJeff Kirsher 
4dee1ad47SJeff Kirsher #ifndef _IXGBE_H_
5dee1ad47SJeff Kirsher #define _IXGBE_H_
6dee1ad47SJeff Kirsher 
7dee1ad47SJeff Kirsher #include <linux/bitops.h>
8dee1ad47SJeff Kirsher #include <linux/types.h>
9dee1ad47SJeff Kirsher #include <linux/pci.h>
10dee1ad47SJeff Kirsher #include <linux/netdevice.h>
11dee1ad47SJeff Kirsher #include <linux/cpumask.h>
12dee1ad47SJeff Kirsher #include <linux/if_vlan.h>
136cb562d6SJacob Keller #include <linux/jiffies.h>
148fa10ef0SSteve Douthit #include <linux/phy.h>
15dee1ad47SJeff Kirsher 
1674d23cc7SRichard Cochran #include <linux/timecounter.h>
173a6a4edaSJacob Keller #include <linux/net_tstamp.h>
183a6a4edaSJacob Keller #include <linux/ptp_clock_kernel.h>
193a6a4edaSJacob Keller 
20dee1ad47SJeff Kirsher #include "ixgbe_type.h"
21dee1ad47SJeff Kirsher #include "ixgbe_common.h"
22dee1ad47SJeff Kirsher #include "ixgbe_dcb.h"
23ee58c114SJavier Martinez Canillas #if IS_ENABLED(CONFIG_FCOE)
24dee1ad47SJeff Kirsher #define IXGBE_FCOE
25dee1ad47SJeff Kirsher #include "ixgbe_fcoe.h"
26ee58c114SJavier Martinez Canillas #endif /* IS_ENABLED(CONFIG_FCOE) */
27dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
28dee1ad47SJeff Kirsher #include <linux/dca.h>
29dee1ad47SJeff Kirsher #endif
308bbbc5e9SShannon Nelson #include "ixgbe_ipsec.h"
31dee1ad47SJeff Kirsher 
3299ffc5adSJesper Dangaard Brouer #include <net/xdp.h>
335a85e737SEliezer Tamir 
34dee1ad47SJeff Kirsher /* common prefix used by pr_<> macros */
35dee1ad47SJeff Kirsher #undef pr_fmt
36dee1ad47SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
37dee1ad47SJeff Kirsher 
38dee1ad47SJeff Kirsher /* TX/RX descriptor defines */
39dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_TXD		    512
4059224555SAlexander Duyck #define IXGBE_DEFAULT_TX_WORK		    256
41864f8888SDaniel Willenson #define IXGBE_MAX_TXD_82598		   4096
42864f8888SDaniel Willenson #define IXGBE_MAX_TXD_82599		   8192
43864f8888SDaniel Willenson #define IXGBE_MAX_TXD_X540		   8192
44864f8888SDaniel Willenson #define IXGBE_MAX_TXD_X550		  32768
45dee1ad47SJeff Kirsher #define IXGBE_MIN_TXD			     64
46dee1ad47SJeff Kirsher 
47fb44519dSAnton Blanchard #if (PAGE_SIZE < 8192)
48dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_RXD		    512
49fb44519dSAnton Blanchard #else
50fb44519dSAnton Blanchard #define IXGBE_DEFAULT_RXD		    128
51fb44519dSAnton Blanchard #endif
52864f8888SDaniel Willenson #define IXGBE_MAX_RXD_82598		   4096
53864f8888SDaniel Willenson #define IXGBE_MAX_RXD_82599		   8192
54864f8888SDaniel Willenson #define IXGBE_MAX_RXD_X540		   8192
55864f8888SDaniel Willenson #define IXGBE_MAX_RXD_X550		  32768
56dee1ad47SJeff Kirsher #define IXGBE_MIN_RXD			     64
57dee1ad47SJeff Kirsher 
58dee1ad47SJeff Kirsher /* flow control */
59dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTL			   0x40
60dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTL			0x7FF80
61dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTH			  0x600
62dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTH			0x7FFF0
63dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_FCPAUSE		 0xFFFF
64dee1ad47SJeff Kirsher #define IXGBE_MIN_FCPAUSE		      0
65dee1ad47SJeff Kirsher #define IXGBE_MAX_FCPAUSE		 0xFFFF
66dee1ad47SJeff Kirsher 
67dee1ad47SJeff Kirsher /* Supported Rx Buffer Sizes */
68252562c2SAlexander Duyck #define IXGBE_RXBUFFER_256    256  /* Used for skb receive header */
69541ea69aSAlexander Duyck #define IXGBE_RXBUFFER_1536  1536
7009816fbeSAlexander Duyck #define IXGBE_RXBUFFER_2K    2048
7109816fbeSAlexander Duyck #define IXGBE_RXBUFFER_3K    3072
7209816fbeSAlexander Duyck #define IXGBE_RXBUFFER_4K    4096
73dee1ad47SJeff Kirsher #define IXGBE_MAX_RXBUFFER  16384  /* largest size for a single descriptor */
74dee1ad47SJeff Kirsher 
75*0967bf83SJason Xing #define IXGBE_PKT_HDR_PAD   (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
76*0967bf83SJason Xing 
77541ea69aSAlexander Duyck /* Attempt to maximize the headroom available for incoming frames.  We
78541ea69aSAlexander Duyck  * use a 2K buffer for receives and need 1536/1534 to store the data for
79541ea69aSAlexander Duyck  * the frame.  This leaves us with 512 bytes of room.  From that we need
80541ea69aSAlexander Duyck  * to deduct the space needed for the shared info and the padding needed
81541ea69aSAlexander Duyck  * to IP align the frame.
82541ea69aSAlexander Duyck  *
83541ea69aSAlexander Duyck  * Note: For cache line sizes 256 or larger this value is going to end
84541ea69aSAlexander Duyck  *	 up negative.  In these cases we should fall back to the 3K
85541ea69aSAlexander Duyck  *	 buffers.
86541ea69aSAlexander Duyck  */
872de6aa3aSAlexander Duyck #if (PAGE_SIZE < 8192)
88541ea69aSAlexander Duyck #define IXGBE_MAX_2K_FRAME_BUILD_SKB (IXGBE_RXBUFFER_1536 - NET_IP_ALIGN)
89541ea69aSAlexander Duyck #define IXGBE_2K_TOO_SMALL_WITH_PADDING \
90541ea69aSAlexander Duyck ((NET_SKB_PAD + IXGBE_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IXGBE_RXBUFFER_2K))
91541ea69aSAlexander Duyck 
ixgbe_compute_pad(int rx_buf_len)92541ea69aSAlexander Duyck static inline int ixgbe_compute_pad(int rx_buf_len)
93541ea69aSAlexander Duyck {
94541ea69aSAlexander Duyck 	int page_size, pad_size;
95541ea69aSAlexander Duyck 
96541ea69aSAlexander Duyck 	page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
97541ea69aSAlexander Duyck 	pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len;
98541ea69aSAlexander Duyck 
99541ea69aSAlexander Duyck 	return pad_size;
100541ea69aSAlexander Duyck }
101541ea69aSAlexander Duyck 
ixgbe_skb_pad(void)102541ea69aSAlexander Duyck static inline int ixgbe_skb_pad(void)
103541ea69aSAlexander Duyck {
104541ea69aSAlexander Duyck 	int rx_buf_len;
105541ea69aSAlexander Duyck 
106541ea69aSAlexander Duyck 	/* If a 2K buffer cannot handle a standard Ethernet frame then
107541ea69aSAlexander Duyck 	 * optimize padding for a 3K buffer instead of a 1.5K buffer.
108541ea69aSAlexander Duyck 	 *
109541ea69aSAlexander Duyck 	 * For a 3K buffer we need to add enough padding to allow for
110541ea69aSAlexander Duyck 	 * tailroom due to NET_IP_ALIGN possibly shifting us out of
111541ea69aSAlexander Duyck 	 * cache-line alignment.
112541ea69aSAlexander Duyck 	 */
113541ea69aSAlexander Duyck 	if (IXGBE_2K_TOO_SMALL_WITH_PADDING)
114541ea69aSAlexander Duyck 		rx_buf_len = IXGBE_RXBUFFER_3K + SKB_DATA_ALIGN(NET_IP_ALIGN);
115541ea69aSAlexander Duyck 	else
116541ea69aSAlexander Duyck 		rx_buf_len = IXGBE_RXBUFFER_1536;
117541ea69aSAlexander Duyck 
118541ea69aSAlexander Duyck 	/* if needed make room for NET_IP_ALIGN */
119541ea69aSAlexander Duyck 	rx_buf_len -= NET_IP_ALIGN;
120541ea69aSAlexander Duyck 
121541ea69aSAlexander Duyck 	return ixgbe_compute_pad(rx_buf_len);
122541ea69aSAlexander Duyck }
123541ea69aSAlexander Duyck 
124541ea69aSAlexander Duyck #define IXGBE_SKB_PAD	ixgbe_skb_pad()
1252de6aa3aSAlexander Duyck #else
126541ea69aSAlexander Duyck #define IXGBE_SKB_PAD	(NET_SKB_PAD + NET_IP_ALIGN)
1272de6aa3aSAlexander Duyck #endif
1282de6aa3aSAlexander Duyck 
129dee1ad47SJeff Kirsher /*
130252562c2SAlexander Duyck  * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
131252562c2SAlexander Duyck  * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
132252562c2SAlexander Duyck  * this adds up to 448 bytes of extra data.
133252562c2SAlexander Duyck  *
134252562c2SAlexander Duyck  * Since netdev_alloc_skb now allocates a page fragment we can use a value
135252562c2SAlexander Duyck  * of 256 and the resultant skb will have a truesize of 960 or less.
136dee1ad47SJeff Kirsher  */
137252562c2SAlexander Duyck #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
138dee1ad47SJeff Kirsher 
139dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */
140dee1ad47SJeff Kirsher #define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */
141dee1ad47SJeff Kirsher 
142f3213d93SAlexander Duyck #define IXGBE_RX_DMA_ATTR \
143f3213d93SAlexander Duyck 	(DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
144f3213d93SAlexander Duyck 
145472148c3SAlexander Duyck enum ixgbe_tx_flags {
146472148c3SAlexander Duyck 	/* cmd_type flags */
147472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_HW_VLAN	= 0x01,
148472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_TSO	= 0x02,
149472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_TSTAMP	= 0x04,
150472148c3SAlexander Duyck 
151472148c3SAlexander Duyck 	/* olinfo flags */
152472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_CC	= 0x08,
153472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_IPV4	= 0x10,
154472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_CSUM	= 0x20,
15559259470SShannon Nelson 	IXGBE_TX_FLAGS_IPSEC	= 0x40,
156472148c3SAlexander Duyck 
157472148c3SAlexander Duyck 	/* software defined flags */
15859259470SShannon Nelson 	IXGBE_TX_FLAGS_SW_VLAN	= 0x80,
15959259470SShannon Nelson 	IXGBE_TX_FLAGS_FCOE	= 0x100,
160472148c3SAlexander Duyck };
161472148c3SAlexander Duyck 
162472148c3SAlexander Duyck /* VLAN info */
163dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000
16466f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000
16566f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT  29
166dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_SHIFT	16
167dee1ad47SJeff Kirsher 
168dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_MC_ENTRIES         30
169dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_FUNCTIONS          64
170dee1ad47SJeff Kirsher #define IXGBE_MAX_VFTA_ENTRIES          128
171dee1ad47SJeff Kirsher #define MAX_EMULATION_MAC_ADDRS         16
172dee1ad47SJeff Kirsher #define IXGBE_MAX_PF_MACVLANS           15
1731d9c0bfdSAlexander Duyck #define VMDQ_P(p)   ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
17483c61fa9SGreg Rose #define IXGBE_82599_VF_DEVICE_ID        0x10ED
17583c61fa9SGreg Rose #define IXGBE_X540_VF_DEVICE_ID         0x1515
176dee1ad47SJeff Kirsher 
17737530030SMaximilian Heyne #define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter)	\
17837530030SMaximilian Heyne 	{							\
17937530030SMaximilian Heyne 		u32 current_counter = IXGBE_READ_REG(hw, reg);	\
18037530030SMaximilian Heyne 		if (current_counter < last_counter)		\
18137530030SMaximilian Heyne 			counter += 0x100000000LL;		\
18237530030SMaximilian Heyne 		last_counter = current_counter;			\
18337530030SMaximilian Heyne 		counter &= 0xFFFFFFFF00000000LL;		\
18437530030SMaximilian Heyne 		counter |= current_counter;			\
18537530030SMaximilian Heyne 	}
18637530030SMaximilian Heyne 
18737530030SMaximilian Heyne #define UPDATE_VF_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
18837530030SMaximilian Heyne 	{								 \
18937530030SMaximilian Heyne 		u64 current_counter_lsb = IXGBE_READ_REG(hw, reg_lsb);	 \
19037530030SMaximilian Heyne 		u64 current_counter_msb = IXGBE_READ_REG(hw, reg_msb);	 \
19137530030SMaximilian Heyne 		u64 current_counter = (current_counter_msb << 32) |	 \
19237530030SMaximilian Heyne 			current_counter_lsb;				 \
19337530030SMaximilian Heyne 		if (current_counter < last_counter)			 \
19437530030SMaximilian Heyne 			counter += 0x1000000000LL;			 \
19537530030SMaximilian Heyne 		last_counter = current_counter;				 \
19637530030SMaximilian Heyne 		counter &= 0xFFFFFFF000000000LL;			 \
19737530030SMaximilian Heyne 		counter |= current_counter;				 \
19837530030SMaximilian Heyne 	}
19937530030SMaximilian Heyne 
20037530030SMaximilian Heyne struct vf_stats {
20137530030SMaximilian Heyne 	u64 gprc;
20237530030SMaximilian Heyne 	u64 gorc;
20337530030SMaximilian Heyne 	u64 gptc;
20437530030SMaximilian Heyne 	u64 gotc;
20537530030SMaximilian Heyne 	u64 mprc;
20637530030SMaximilian Heyne };
20737530030SMaximilian Heyne 
208dee1ad47SJeff Kirsher struct vf_data_storage {
209988d1307SMark Rustad 	struct pci_dev *vfdev;
210dee1ad47SJeff Kirsher 	unsigned char vf_mac_addresses[ETH_ALEN];
211dee1ad47SJeff Kirsher 	u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
212dee1ad47SJeff Kirsher 	u16 num_vf_mc_hashes;
213dee1ad47SJeff Kirsher 	bool clear_to_send;
21437530030SMaximilian Heyne 	struct vf_stats vfstats;
21537530030SMaximilian Heyne 	struct vf_stats last_vfstats;
21637530030SMaximilian Heyne 	struct vf_stats saved_rst_vfstats;
217dee1ad47SJeff Kirsher 	bool pf_set_mac;
218dee1ad47SJeff Kirsher 	u16 pf_vlan; /* When set, guest VLAN config not allowed. */
219dee1ad47SJeff Kirsher 	u16 pf_qos;
220dee1ad47SJeff Kirsher 	u16 tx_rate;
221366fd100SSlawomir Mrozowicz 	int link_enable;
222366fd100SSlawomir Mrozowicz 	int link_state;
223de4c7f65SGreg Rose 	u8 spoofchk_enabled;
224e65ce0d3SVlad Zolotarov 	bool rss_query_enabled;
22554011e4dSHiroshi Shimamoto 	u8 trusted;
2268443c1a4SHiroshi Shimamoto 	int xcast_mode;
227374c65d6SAlexander Duyck 	unsigned int vf_api;
228008ca35fSSlawomir Mrozowicz 	u8 primary_abort_count;
229dee1ad47SJeff Kirsher };
230dee1ad47SJeff Kirsher 
2318443c1a4SHiroshi Shimamoto enum ixgbevf_xcast_modes {
2328443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_NONE = 0,
2338443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_MULTI,
2348443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_ALLMULTI,
23507eea570SDon Skidmore 	IXGBEVF_XCAST_MODE_PROMISC,
2368443c1a4SHiroshi Shimamoto };
2378443c1a4SHiroshi Shimamoto 
238dee1ad47SJeff Kirsher struct vf_macvlans {
239dee1ad47SJeff Kirsher 	struct list_head l;
240dee1ad47SJeff Kirsher 	int vf;
241dee1ad47SJeff Kirsher 	bool free;
242dee1ad47SJeff Kirsher 	bool is_macvlan;
243dee1ad47SJeff Kirsher 	u8 vf_macvlan[ETH_ALEN];
244dee1ad47SJeff Kirsher };
245dee1ad47SJeff Kirsher 
246dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD_PWR	14
247b4f47a48SJacob Keller #define IXGBE_MAX_DATA_PER_TXD	(1u << IXGBE_MAX_TXD_PWR)
248dee1ad47SJeff Kirsher 
249dee1ad47SJeff Kirsher /* Tx Descriptors needed, worst case */
250dee1ad47SJeff Kirsher #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
251990a3158SAlexander Duyck #define DESC_NEEDED (MAX_SKB_FRAGS + 4)
252dee1ad47SJeff Kirsher 
253dee1ad47SJeff Kirsher /* wrapper around a pointer to a socket buffer,
254dee1ad47SJeff Kirsher  * so a DMA handle can be stored along with the buffer */
255dee1ad47SJeff Kirsher struct ixgbe_tx_buffer {
256d3d00239SAlexander Duyck 	union ixgbe_adv_tx_desc *next_to_watch;
257dee1ad47SJeff Kirsher 	unsigned long time_stamp;
25833fdc82fSJohn Fastabend 	union {
259d3d00239SAlexander Duyck 		struct sk_buff *skb;
26003993094SJesper Dangaard Brouer 		struct xdp_frame *xdpf;
26133fdc82fSJohn Fastabend 	};
262fd0db0edSAlexander Duyck 	unsigned int bytecount;
263fd0db0edSAlexander Duyck 	unsigned short gso_segs;
264244e27adSAlexander Duyck 	__be16 protocol;
265729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_ADDR(dma);
266729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_LEN(len);
267fd0db0edSAlexander Duyck 	u32 tx_flags;
268dee1ad47SJeff Kirsher };
269dee1ad47SJeff Kirsher 
270dee1ad47SJeff Kirsher struct ixgbe_rx_buffer {
271d0bcacd0SBjörn Töpel 	union {
272d0bcacd0SBjörn Töpel 		struct {
2737117132bSBjörn Töpel 			struct sk_buff *skb;
2747117132bSBjörn Töpel 			dma_addr_t dma;
275dee1ad47SJeff Kirsher 			struct page *page;
2761b56cf49SAlexander Duyck 			__u32 page_offset;
2771b56cf49SAlexander Duyck 			__u16 pagecnt_bias;
278dee1ad47SJeff Kirsher 		};
279d0bcacd0SBjörn Töpel 		struct {
2807117132bSBjörn Töpel 			bool discard;
2817117132bSBjörn Töpel 			struct xdp_buff *xdp;
282d0bcacd0SBjörn Töpel 		};
283d0bcacd0SBjörn Töpel 	};
284d0bcacd0SBjörn Töpel };
285dee1ad47SJeff Kirsher 
286dee1ad47SJeff Kirsher struct ixgbe_queue_stats {
287dee1ad47SJeff Kirsher 	u64 packets;
288dee1ad47SJeff Kirsher 	u64 bytes;
289dee1ad47SJeff Kirsher };
290dee1ad47SJeff Kirsher 
291dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats {
292dee1ad47SJeff Kirsher 	u64 restart_queue;
293dee1ad47SJeff Kirsher 	u64 tx_busy;
294dee1ad47SJeff Kirsher 	u64 tx_done_old;
295dee1ad47SJeff Kirsher };
296dee1ad47SJeff Kirsher 
297dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats {
298dee1ad47SJeff Kirsher 	u64 rsc_count;
299dee1ad47SJeff Kirsher 	u64 rsc_flush;
300dee1ad47SJeff Kirsher 	u64 non_eop_descs;
30186e23494SJesper Dangaard Brouer 	u64 alloc_rx_page;
302dee1ad47SJeff Kirsher 	u64 alloc_rx_page_failed;
303dee1ad47SJeff Kirsher 	u64 alloc_rx_buff_failed;
3048a0da21bSAlexander Duyck 	u64 csum_err;
305dee1ad47SJeff Kirsher };
306dee1ad47SJeff Kirsher 
307a9763f3cSMark Rustad #define IXGBE_TS_HDR_LEN 8
308a9763f3cSMark Rustad 
309f800326dSAlexander Duyck enum ixgbe_ring_state_t {
3104f4542bfSAlexander Duyck 	__IXGBE_RX_3K_BUFFER,
3112de6aa3aSAlexander Duyck 	__IXGBE_RX_BUILD_SKB_ENABLED,
3124f4542bfSAlexander Duyck 	__IXGBE_RX_RSC_ENABLED,
3134f4542bfSAlexander Duyck 	__IXGBE_RX_CSUM_UDP_ZERO_ERR,
3144f4542bfSAlexander Duyck 	__IXGBE_RX_FCOE,
315dee1ad47SJeff Kirsher 	__IXGBE_TX_FDIR_INIT_DONE,
316fd786b7bSAlexander Duyck 	__IXGBE_TX_XPS_INIT_DONE,
317dee1ad47SJeff Kirsher 	__IXGBE_TX_DETECT_HANG,
318dee1ad47SJeff Kirsher 	__IXGBE_HANG_CHECK_ARMED,
31933fdc82fSJohn Fastabend 	__IXGBE_TX_XDP_RING,
320024aa580SBjörn Töpel 	__IXGBE_TX_DISABLED,
321dee1ad47SJeff Kirsher };
322dee1ad47SJeff Kirsher 
3232de6aa3aSAlexander Duyck #define ring_uses_build_skb(ring) \
3242de6aa3aSAlexander Duyck 	test_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &(ring)->state)
3252de6aa3aSAlexander Duyck 
3262a47fa45SJohn Fastabend struct ixgbe_fwd_adapter {
3272a47fa45SJohn Fastabend 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
3282a47fa45SJohn Fastabend 	struct net_device *netdev;
3292a47fa45SJohn Fastabend 	unsigned int tx_base_queue;
3302a47fa45SJohn Fastabend 	unsigned int rx_base_queue;
3312a47fa45SJohn Fastabend 	int pool;
3322a47fa45SJohn Fastabend };
3332a47fa45SJohn Fastabend 
334dee1ad47SJeff Kirsher #define check_for_tx_hang(ring) \
335dee1ad47SJeff Kirsher 	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
336dee1ad47SJeff Kirsher #define set_check_for_tx_hang(ring) \
337dee1ad47SJeff Kirsher 	set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
338dee1ad47SJeff Kirsher #define clear_check_for_tx_hang(ring) \
339dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
340dee1ad47SJeff Kirsher #define ring_is_rsc_enabled(ring) \
341dee1ad47SJeff Kirsher 	test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
342dee1ad47SJeff Kirsher #define set_ring_rsc_enabled(ring) \
343dee1ad47SJeff Kirsher 	set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
344dee1ad47SJeff Kirsher #define clear_ring_rsc_enabled(ring) \
345dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
34633fdc82fSJohn Fastabend #define ring_is_xdp(ring) \
34733fdc82fSJohn Fastabend 	test_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
34833fdc82fSJohn Fastabend #define set_ring_xdp(ring) \
34933fdc82fSJohn Fastabend 	set_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
35033fdc82fSJohn Fastabend #define clear_ring_xdp(ring) \
35133fdc82fSJohn Fastabend 	clear_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
352dee1ad47SJeff Kirsher struct ixgbe_ring {
353efe3d3c8SAlexander Duyck 	struct ixgbe_ring *next;	/* pointer to next ring in q_vector */
354d3ee4294SAlexander Duyck 	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
355dee1ad47SJeff Kirsher 	struct net_device *netdev;	/* netdev ring belongs to */
35692470808SJohn Fastabend 	struct bpf_prog *xdp_prog;
357d3ee4294SAlexander Duyck 	struct device *dev;		/* device for DMA mapping */
358d3ee4294SAlexander Duyck 	void *desc;			/* descriptor ring memory */
359dee1ad47SJeff Kirsher 	union {
360dee1ad47SJeff Kirsher 		struct ixgbe_tx_buffer *tx_buffer_info;
361dee1ad47SJeff Kirsher 		struct ixgbe_rx_buffer *rx_buffer_info;
362dee1ad47SJeff Kirsher 	};
363dee1ad47SJeff Kirsher 	unsigned long state;
364dee1ad47SJeff Kirsher 	u8 __iomem *tail;
365d3ee4294SAlexander Duyck 	dma_addr_t dma;			/* phys. address of descriptor ring */
366d3ee4294SAlexander Duyck 	unsigned int size;		/* length in bytes */
367dee1ad47SJeff Kirsher 
368dee1ad47SJeff Kirsher 	u16 count;			/* amount of descriptors */
369dee1ad47SJeff Kirsher 
370dee1ad47SJeff Kirsher 	u8 queue_index; /* needed for multiqueue queue management */
371dee1ad47SJeff Kirsher 	u8 reg_idx;			/* holds the special value that gets
372dee1ad47SJeff Kirsher 					 * the hardware register offset
373dee1ad47SJeff Kirsher 					 * associated with this ring, which is
374dee1ad47SJeff Kirsher 					 * different for DCB and RSS modes
375dee1ad47SJeff Kirsher 					 */
376d3ee4294SAlexander Duyck 	u16 next_to_use;
377d3ee4294SAlexander Duyck 	u16 next_to_clean;
378d3ee4294SAlexander Duyck 
379a9763f3cSMark Rustad 	unsigned long last_rx_timestamp;
380a9763f3cSMark Rustad 
381f800326dSAlexander Duyck 	union {
382d3ee4294SAlexander Duyck 		u16 next_to_alloc;
383f800326dSAlexander Duyck 		struct {
384dee1ad47SJeff Kirsher 			u8 atr_sample_rate;
385dee1ad47SJeff Kirsher 			u8 atr_count;
386f800326dSAlexander Duyck 		};
387f800326dSAlexander Duyck 	};
388dee1ad47SJeff Kirsher 
389dee1ad47SJeff Kirsher 	u8 dcb_tc;
390dee1ad47SJeff Kirsher 	struct ixgbe_queue_stats stats;
391dee1ad47SJeff Kirsher 	struct u64_stats_sync syncp;
392dee1ad47SJeff Kirsher 	union {
393dee1ad47SJeff Kirsher 		struct ixgbe_tx_queue_stats tx_stats;
394dee1ad47SJeff Kirsher 		struct ixgbe_rx_queue_stats rx_stats;
395dee1ad47SJeff Kirsher 	};
396c0d4e9d2SMaciej Fijalkowski 	u16 rx_offset;
39799ffc5adSJesper Dangaard Brouer 	struct xdp_rxq_info xdp_rxq;
3984fe81585SJason Xing 	spinlock_t tx_lock;	/* used in XDP mode */
3991742b3d5SMagnus Karlsson 	struct xsk_buff_pool *xsk_pool;
400d0bcacd0SBjörn Töpel 	u16 ring_idx;		/* {rx,tx,xdp}_ring back reference idx */
401d0bcacd0SBjörn Töpel 	u16 rx_buf_len;
402dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
403dee1ad47SJeff Kirsher 
404dee1ad47SJeff Kirsher enum ixgbe_ring_f_enum {
405dee1ad47SJeff Kirsher 	RING_F_NONE = 0,
406dee1ad47SJeff Kirsher 	RING_F_VMDQ,  /* SR-IOV uses the same ring feature */
407dee1ad47SJeff Kirsher 	RING_F_RSS,
408dee1ad47SJeff Kirsher 	RING_F_FDIR,
409dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
410dee1ad47SJeff Kirsher 	RING_F_FCOE,
411dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
412dee1ad47SJeff Kirsher 
413dee1ad47SJeff Kirsher 	RING_F_ARRAY_SIZE      /* must be last in enum set */
414dee1ad47SJeff Kirsher };
415dee1ad47SJeff Kirsher 
416dee1ad47SJeff Kirsher #define IXGBE_MAX_RSS_INDICES		16
417e9ee3238SEmil Tantilov #define IXGBE_MAX_RSS_INDICES_X550	63
418dee1ad47SJeff Kirsher #define IXGBE_MAX_VMDQ_INDICES		64
419d3cb9869SAlexander Duyck #define IXGBE_MAX_FDIR_INDICES		63	/* based on q_vector limit */
420dee1ad47SJeff Kirsher #define IXGBE_MAX_FCOE_INDICES		8
421d3cb9869SAlexander Duyck #define MAX_RX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
422d3cb9869SAlexander Duyck #define MAX_TX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
4234fe81585SJason Xing #define IXGBE_MAX_XDP_QS		(IXGBE_MAX_FDIR_INDICES + 1)
4242a47fa45SJohn Fastabend #define IXGBE_MAX_L2A_QUEUES		4
4252a47fa45SJohn Fastabend #define IXGBE_BAD_L2A_QUEUE		3
4264e039c16SAlexander Duyck #define IXGBE_MAX_MACVLANS		63
4272a47fa45SJohn Fastabend 
4284fe81585SJason Xing DECLARE_STATIC_KEY_FALSE(ixgbe_xdp_locking_key);
4294fe81585SJason Xing 
430dee1ad47SJeff Kirsher struct ixgbe_ring_feature {
431c087663eSAlexander Duyck 	u16 limit;	/* upper limit on feature indices */
432c087663eSAlexander Duyck 	u16 indices;	/* current value of indices */
433e4b317e9SAlexander Duyck 	u16 mask;	/* Mask used for feature to ring mapping */
434e4b317e9SAlexander Duyck 	u16 offset;	/* offset to start of feature */
435dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
436dee1ad47SJeff Kirsher 
43773079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_8Q_MASK 0x78
43873079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_4Q_MASK 0x7C
43973079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_2Q_MASK 0x7E
44073079ea0SAlexander Duyck 
441f800326dSAlexander Duyck /*
442f800326dSAlexander Duyck  * FCoE requires that all Rx buffers be over 2200 bytes in length.  Since
443f800326dSAlexander Duyck  * this is twice the size of a half page we need to double the page order
444f800326dSAlexander Duyck  * for FCoE enabled Rx queues.
445f800326dSAlexander Duyck  */
ixgbe_rx_bufsz(struct ixgbe_ring * ring)44609816fbeSAlexander Duyck static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
44709816fbeSAlexander Duyck {
4484f4542bfSAlexander Duyck 	if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
4494f4542bfSAlexander Duyck 		return IXGBE_RXBUFFER_3K;
4502de6aa3aSAlexander Duyck #if (PAGE_SIZE < 8192)
4512de6aa3aSAlexander Duyck 	if (ring_uses_build_skb(ring))
452541ea69aSAlexander Duyck 		return IXGBE_MAX_2K_FRAME_BUILD_SKB;
4532de6aa3aSAlexander Duyck #endif
45409816fbeSAlexander Duyck 	return IXGBE_RXBUFFER_2K;
45509816fbeSAlexander Duyck }
45609816fbeSAlexander Duyck 
ixgbe_rx_pg_order(struct ixgbe_ring * ring)457f800326dSAlexander Duyck static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
458f800326dSAlexander Duyck {
4594f4542bfSAlexander Duyck #if (PAGE_SIZE < 8192)
4604f4542bfSAlexander Duyck 	if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
4614f4542bfSAlexander Duyck 		return 1;
462f800326dSAlexander Duyck #endif
46309816fbeSAlexander Duyck 	return 0;
46409816fbeSAlexander Duyck }
465f800326dSAlexander Duyck #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
466f800326dSAlexander Duyck 
467b4ded832SAlexander Duyck #define IXGBE_ITR_ADAPTIVE_MIN_INC	2
468b4ded832SAlexander Duyck #define IXGBE_ITR_ADAPTIVE_MIN_USECS	10
469b4ded832SAlexander Duyck #define IXGBE_ITR_ADAPTIVE_MAX_USECS	126
470b4ded832SAlexander Duyck #define IXGBE_ITR_ADAPTIVE_LATENCY	0x80
471b4ded832SAlexander Duyck #define IXGBE_ITR_ADAPTIVE_BULK		0x00
472b4ded832SAlexander Duyck 
473dee1ad47SJeff Kirsher struct ixgbe_ring_container {
474efe3d3c8SAlexander Duyck 	struct ixgbe_ring *ring;	/* pointer to linked list of rings */
475b4ded832SAlexander Duyck 	unsigned long next_update;	/* jiffies value of last update */
476dee1ad47SJeff Kirsher 	unsigned int total_bytes;	/* total bytes processed this int */
477dee1ad47SJeff Kirsher 	unsigned int total_packets;	/* total packets processed this int */
478dee1ad47SJeff Kirsher 	u16 work_limit;			/* total work allowed per interrupt */
479dee1ad47SJeff Kirsher 	u8 count;			/* total number of rings in vector */
480dee1ad47SJeff Kirsher 	u8 itr;				/* current ITR setting for ring */
481dee1ad47SJeff Kirsher };
482dee1ad47SJeff Kirsher 
483a557928eSAlexander Duyck /* iterator for handling rings in ring container */
484a557928eSAlexander Duyck #define ixgbe_for_each_ring(pos, head) \
485a557928eSAlexander Duyck 	for (pos = (head).ring; pos != NULL; pos = pos->next)
486a557928eSAlexander Duyck 
487dee1ad47SJeff Kirsher #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
488dee1ad47SJeff Kirsher 			      ? 8 : 1)
489dee1ad47SJeff Kirsher #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
490dee1ad47SJeff Kirsher 
49149c7ffbeSAlexander Duyck /* MAX_Q_VECTORS of these are allocated,
492dee1ad47SJeff Kirsher  * but we only use one per queue-specific vector.
493dee1ad47SJeff Kirsher  */
494dee1ad47SJeff Kirsher struct ixgbe_q_vector {
495dee1ad47SJeff Kirsher 	struct ixgbe_adapter *adapter;
496dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
497dee1ad47SJeff Kirsher 	int cpu;	    /* CPU for DCA */
498dee1ad47SJeff Kirsher #endif
499d5bf4f67SEmil Tantilov 	u16 v_idx;		/* index of q_vector within array, also used for
500d5bf4f67SEmil Tantilov 				 * finding the bit in EICR and friends that
501d5bf4f67SEmil Tantilov 				 * represents the vector for this ring */
502d5bf4f67SEmil Tantilov 	u16 itr;		/* Interrupt throttle rate written to EITR */
503dee1ad47SJeff Kirsher 	struct ixgbe_ring_container rx, tx;
504d5bf4f67SEmil Tantilov 
505d5bf4f67SEmil Tantilov 	struct napi_struct napi;
506de88eeebSAlexander Duyck 	cpumask_t affinity_mask;
507de88eeebSAlexander Duyck 	int numa_node;
508de88eeebSAlexander Duyck 	struct rcu_head rcu;	/* to avoid race with update stats on free */
509dee1ad47SJeff Kirsher 	char name[IFNAMSIZ + 9];
510de88eeebSAlexander Duyck 
511de88eeebSAlexander Duyck 	/* for dynamic allocation of rings associated with this q_vector */
512040efdb1SGustavo A. R. Silva 	struct ixgbe_ring ring[] ____cacheline_internodealigned_in_smp;
513dee1ad47SJeff Kirsher };
514adc81090SAlexander Duyck 
5153ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
5163ca8bc6dSDon Skidmore 
5173ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_LOC		0
5183ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_TEMP		1
5193ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_CAUTION	2
5203ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_MAX		3
5213ca8bc6dSDon Skidmore 
5223ca8bc6dSDon Skidmore struct hwmon_attr {
5233ca8bc6dSDon Skidmore 	struct device_attribute dev_attr;
5243ca8bc6dSDon Skidmore 	struct ixgbe_hw *hw;
5253ca8bc6dSDon Skidmore 	struct ixgbe_thermal_diode_data *sensor;
5263ca8bc6dSDon Skidmore 	char name[12];
5273ca8bc6dSDon Skidmore };
5283ca8bc6dSDon Skidmore 
5293ca8bc6dSDon Skidmore struct hwmon_buff {
53003b77d81SGuenter Roeck 	struct attribute_group group;
53103b77d81SGuenter Roeck 	const struct attribute_group *groups[2];
53203b77d81SGuenter Roeck 	struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
53303b77d81SGuenter Roeck 	struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
5343ca8bc6dSDon Skidmore 	unsigned int n_hwmon;
5353ca8bc6dSDon Skidmore };
5363ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
537dee1ad47SJeff Kirsher 
538d5bf4f67SEmil Tantilov /*
539d5bf4f67SEmil Tantilov  * microsecond values for various ITR rates shifted by 2 to fit itr register
540d5bf4f67SEmil Tantilov  * with the first 3 bits reserved 0
541dee1ad47SJeff Kirsher  */
542d5bf4f67SEmil Tantilov #define IXGBE_MIN_RSC_ITR	24
543d5bf4f67SEmil Tantilov #define IXGBE_100K_ITR		40
544d5bf4f67SEmil Tantilov #define IXGBE_20K_ITR		200
5458ac34f10SAlexander Duyck #define IXGBE_12K_ITR		336
546dee1ad47SJeff Kirsher 
547f56e0cb1SAlexander Duyck /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
ixgbe_test_staterr(union ixgbe_adv_rx_desc * rx_desc,const u32 stat_err_bits)548f56e0cb1SAlexander Duyck static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
549f56e0cb1SAlexander Duyck 					const u32 stat_err_bits)
550f56e0cb1SAlexander Duyck {
551f56e0cb1SAlexander Duyck 	return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
552f56e0cb1SAlexander Duyck }
553f56e0cb1SAlexander Duyck 
ixgbe_desc_unused(struct ixgbe_ring * ring)554dee1ad47SJeff Kirsher static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
555dee1ad47SJeff Kirsher {
556dee1ad47SJeff Kirsher 	u16 ntc = ring->next_to_clean;
557dee1ad47SJeff Kirsher 	u16 ntu = ring->next_to_use;
558dee1ad47SJeff Kirsher 
559dee1ad47SJeff Kirsher 	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
560dee1ad47SJeff Kirsher }
561dee1ad47SJeff Kirsher 
562e4f74028SAlexander Duyck #define IXGBE_RX_DESC(R, i)	    \
563dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
564e4f74028SAlexander Duyck #define IXGBE_TX_DESC(R, i)	    \
565dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
566e4f74028SAlexander Duyck #define IXGBE_TX_CTXTDESC(R, i)	    \
567dee1ad47SJeff Kirsher 	(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
568dee1ad47SJeff Kirsher 
569c88887e0SAlexander Duyck #define IXGBE_MAX_JUMBO_FRAME_SIZE	9728 /* Maximum Supported Size 9.5KB */
570dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
571dee1ad47SJeff Kirsher /* Use 3K as the baby jumbo frame size for FCoE */
572dee1ad47SJeff Kirsher #define IXGBE_FCOE_JUMBO_FRAME_SIZE       3072
573dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
574dee1ad47SJeff Kirsher 
575dee1ad47SJeff Kirsher #define OTHER_VECTOR 1
576dee1ad47SJeff Kirsher #define NON_Q_VECTORS (OTHER_VECTOR)
577dee1ad47SJeff Kirsher 
578dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82599 64
57949c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82599 64
580dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82598 18
58149c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82598 16
582dee1ad47SJeff Kirsher 
5835d7daa35SJacob Keller struct ixgbe_mac_addr {
5845d7daa35SJacob Keller 	u8 addr[ETH_ALEN];
585c9f53e63SAlexander Duyck 	u16 pool;
5865d7daa35SJacob Keller 	u16 state; /* bitmask */
5875d7daa35SJacob Keller };
588c9f53e63SAlexander Duyck 
5895d7daa35SJacob Keller #define IXGBE_MAC_STATE_DEFAULT		0x1
5905d7daa35SJacob Keller #define IXGBE_MAC_STATE_MODIFIED	0x2
5915d7daa35SJacob Keller #define IXGBE_MAC_STATE_IN_USE		0x4
5925d7daa35SJacob Keller 
59349c7ffbeSAlexander Duyck #define MAX_Q_VECTORS MAX_Q_VECTORS_82599
594dee1ad47SJeff Kirsher #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
595dee1ad47SJeff Kirsher 
5968f15486dSAlexander Duyck #define MIN_MSIX_Q_VECTORS 1
597dee1ad47SJeff Kirsher #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
598dee1ad47SJeff Kirsher 
59946646e61SAlexander Duyck /* default to trying for four seconds */
60046646e61SAlexander Duyck #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
60158e7cd24SMark Rustad #define IXGBE_SFP_POLL_JIFFIES (2 * HZ)	/* SFP poll every 2 seconds */
60246646e61SAlexander Duyck 
603008ca35fSSlawomir Mrozowicz #define IXGBE_PRIMARY_ABORT_LIMIT	5
604008ca35fSSlawomir Mrozowicz 
605dee1ad47SJeff Kirsher /* board specific private data structure */
606dee1ad47SJeff Kirsher struct ixgbe_adapter {
60746646e61SAlexander Duyck 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
60846646e61SAlexander Duyck 	/* OS defined structs */
60946646e61SAlexander Duyck 	struct net_device *netdev;
61092470808SJohn Fastabend 	struct bpf_prog *xdp_prog;
61146646e61SAlexander Duyck 	struct pci_dev *pdev;
6128fa10ef0SSteve Douthit 	struct mii_bus *mii_bus;
61346646e61SAlexander Duyck 
614dee1ad47SJeff Kirsher 	unsigned long state;
615dee1ad47SJeff Kirsher 
616dee1ad47SJeff Kirsher 	/* Some features need tri-state capability,
617dee1ad47SJeff Kirsher 	 * thus the additional *_CAPABLE flags.
618dee1ad47SJeff Kirsher 	 */
619dee1ad47SJeff Kirsher 	u32 flags;
620b4f47a48SJacob Keller #define IXGBE_FLAG_MSI_ENABLED			BIT(1)
621b4f47a48SJacob Keller #define IXGBE_FLAG_MSIX_ENABLED			BIT(3)
622b4f47a48SJacob Keller #define IXGBE_FLAG_RX_1BUF_CAPABLE		BIT(4)
623b4f47a48SJacob Keller #define IXGBE_FLAG_RX_PS_CAPABLE		BIT(5)
624b4f47a48SJacob Keller #define IXGBE_FLAG_RX_PS_ENABLED		BIT(6)
625b4f47a48SJacob Keller #define IXGBE_FLAG_DCA_ENABLED			BIT(8)
626b4f47a48SJacob Keller #define IXGBE_FLAG_DCA_CAPABLE			BIT(9)
627b4f47a48SJacob Keller #define IXGBE_FLAG_IMIR_ENABLED			BIT(10)
628b4f47a48SJacob Keller #define IXGBE_FLAG_MQ_CAPABLE			BIT(11)
629b4f47a48SJacob Keller #define IXGBE_FLAG_DCB_ENABLED			BIT(12)
630b4f47a48SJacob Keller #define IXGBE_FLAG_VMDQ_CAPABLE			BIT(13)
631b4f47a48SJacob Keller #define IXGBE_FLAG_VMDQ_ENABLED			BIT(14)
632b4f47a48SJacob Keller #define IXGBE_FLAG_FAN_FAIL_CAPABLE		BIT(15)
633b4f47a48SJacob Keller #define IXGBE_FLAG_NEED_LINK_UPDATE		BIT(16)
634b4f47a48SJacob Keller #define IXGBE_FLAG_NEED_LINK_CONFIG		BIT(17)
635b4f47a48SJacob Keller #define IXGBE_FLAG_FDIR_HASH_CAPABLE		BIT(18)
636b4f47a48SJacob Keller #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE		BIT(19)
637b4f47a48SJacob Keller #define IXGBE_FLAG_FCOE_CAPABLE			BIT(20)
638b4f47a48SJacob Keller #define IXGBE_FLAG_FCOE_ENABLED			BIT(21)
639b4f47a48SJacob Keller #define IXGBE_FLAG_SRIOV_CAPABLE		BIT(22)
640b4f47a48SJacob Keller #define IXGBE_FLAG_SRIOV_ENABLED		BIT(23)
641a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED		BIT(25)
642a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER	BIT(26)
6438829009dSUsha Ketineni #define IXGBE_FLAG_DCB_CAPABLE			BIT(27)
644dee1ad47SJeff Kirsher 
645dee1ad47SJeff Kirsher 	u32 flags2;
646b4f47a48SJacob Keller #define IXGBE_FLAG2_RSC_CAPABLE			BIT(0)
647b4f47a48SJacob Keller #define IXGBE_FLAG2_RSC_ENABLED			BIT(1)
648b4f47a48SJacob Keller #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE		BIT(2)
649b4f47a48SJacob Keller #define IXGBE_FLAG2_TEMP_SENSOR_EVENT		BIT(3)
650b4f47a48SJacob Keller #define IXGBE_FLAG2_SEARCH_FOR_SFP		BIT(4)
651b4f47a48SJacob Keller #define IXGBE_FLAG2_SFP_NEEDS_RESET		BIT(5)
652b4f47a48SJacob Keller #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT	BIT(7)
653b4f47a48SJacob Keller #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP		BIT(8)
654b4f47a48SJacob Keller #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP		BIT(9)
655b4f47a48SJacob Keller #define IXGBE_FLAG2_PTP_PPS_ENABLED		BIT(10)
656b4f47a48SJacob Keller #define IXGBE_FLAG2_PHY_INTERRUPT		BIT(11)
65716369564SAlexander Duyck #define IXGBE_FLAG2_VLAN_PROMISC		BIT(13)
658b3eb4e18SMark Rustad #define IXGBE_FLAG2_EEE_CAPABLE			BIT(14)
659b3eb4e18SMark Rustad #define IXGBE_FLAG2_EEE_ENABLED			BIT(15)
6602de6aa3aSAlexander Duyck #define IXGBE_FLAG2_RX_LEGACY			BIT(16)
66134c822e2SShannon Nelson #define IXGBE_FLAG2_IPSEC_ENABLED		BIT(17)
6629e4e30ccSShannon Nelson #define IXGBE_FLAG2_VF_IPSEC_ENABLED		BIT(18)
663008ca35fSSlawomir Mrozowicz #define IXGBE_FLAG2_AUTO_DISABLE_VF		BIT(19)
66446646e61SAlexander Duyck 
66546646e61SAlexander Duyck 	/* Tx fast path data */
66646646e61SAlexander Duyck 	int num_tx_queues;
66746646e61SAlexander Duyck 	u16 tx_itr_setting;
66846646e61SAlexander Duyck 	u16 tx_work_limit;
669a8a43fdaSShannon Nelson 	u64 tx_ipsec;
67046646e61SAlexander Duyck 
67146646e61SAlexander Duyck 	/* Rx fast path data */
67246646e61SAlexander Duyck 	int num_rx_queues;
67346646e61SAlexander Duyck 	u16 rx_itr_setting;
674a8a43fdaSShannon Nelson 	u64 rx_ipsec;
67546646e61SAlexander Duyck 
6769f12df90SAlexander Duyck 	/* Port number used to identify VXLAN traffic */
6779f12df90SAlexander Duyck 	__be16 vxlan_port;
678a21d0822SEmil Tantilov 	__be16 geneve_port;
6799f12df90SAlexander Duyck 
68033fdc82fSJohn Fastabend 	/* XDP */
68133fdc82fSJohn Fastabend 	int num_xdp_queues;
6824fe81585SJason Xing 	struct ixgbe_ring *xdp_ring[IXGBE_MAX_XDP_QS];
683d49e286dSJan Sokolowski 	unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled rings */
68433fdc82fSJohn Fastabend 
68546646e61SAlexander Duyck 	/* TX */
68646646e61SAlexander Duyck 	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
68746646e61SAlexander Duyck 
68846646e61SAlexander Duyck 	u64 restart_queue;
68946646e61SAlexander Duyck 	u64 lsc_int;
69046646e61SAlexander Duyck 	u32 tx_timeout_count;
69146646e61SAlexander Duyck 
69246646e61SAlexander Duyck 	/* RX */
69346646e61SAlexander Duyck 	struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
69446646e61SAlexander Duyck 	int num_rx_pools;		/* == num_rx_queues in 82598 */
69546646e61SAlexander Duyck 	int num_rx_queues_per_pool;	/* 1 if 82598, can be many if 82599 */
69646646e61SAlexander Duyck 	u64 hw_csum_rx_error;
69746646e61SAlexander Duyck 	u64 hw_rx_no_dma_resources;
69846646e61SAlexander Duyck 	u64 rsc_total_count;
69946646e61SAlexander Duyck 	u64 rsc_total_flush;
70046646e61SAlexander Duyck 	u64 non_eop_descs;
70186e23494SJesper Dangaard Brouer 	u32 alloc_rx_page;
70246646e61SAlexander Duyck 	u32 alloc_rx_page_failed;
70346646e61SAlexander Duyck 	u32 alloc_rx_buff_failed;
70446646e61SAlexander Duyck 
70549c7ffbeSAlexander Duyck 	struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
706dee1ad47SJeff Kirsher 
707dee1ad47SJeff Kirsher 	/* DCB parameters */
708dee1ad47SJeff Kirsher 	struct ieee_pfc *ixgbe_ieee_pfc;
709dee1ad47SJeff Kirsher 	struct ieee_ets *ixgbe_ieee_ets;
710dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config dcb_cfg;
711dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config temp_dcb_cfg;
7120efbf12bSAlexander Duyck 	u8 hw_tcs;
713dee1ad47SJeff Kirsher 	u8 dcb_set_bitmap;
714dee1ad47SJeff Kirsher 	u8 dcbx_cap;
715dee1ad47SJeff Kirsher 	enum ixgbe_fc_mode last_lfc_mode;
716dee1ad47SJeff Kirsher 
71749c7ffbeSAlexander Duyck 	int num_q_vectors;	/* current number of q_vectors for device */
71849c7ffbeSAlexander Duyck 	int max_q_vectors;	/* true count of q_vectors for device */
719dee1ad47SJeff Kirsher 	struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
720dee1ad47SJeff Kirsher 	struct msix_entry *msix_entries;
721dee1ad47SJeff Kirsher 
722dee1ad47SJeff Kirsher 	u32 test_icr;
723dee1ad47SJeff Kirsher 	struct ixgbe_ring test_tx_ring;
724dee1ad47SJeff Kirsher 	struct ixgbe_ring test_rx_ring;
725dee1ad47SJeff Kirsher 
726dee1ad47SJeff Kirsher 	/* structs defined in ixgbe_hw.h */
727dee1ad47SJeff Kirsher 	struct ixgbe_hw hw;
728dee1ad47SJeff Kirsher 	u16 msg_enable;
729dee1ad47SJeff Kirsher 	struct ixgbe_hw_stats stats;
730dee1ad47SJeff Kirsher 
731dee1ad47SJeff Kirsher 	u64 tx_busy;
732dee1ad47SJeff Kirsher 	unsigned int tx_ring_count;
73333fdc82fSJohn Fastabend 	unsigned int xdp_ring_count;
734dee1ad47SJeff Kirsher 	unsigned int rx_ring_count;
735dee1ad47SJeff Kirsher 
736dee1ad47SJeff Kirsher 	u32 link_speed;
737dee1ad47SJeff Kirsher 	bool link_up;
73858e7cd24SMark Rustad 	unsigned long sfp_poll_time;
739dee1ad47SJeff Kirsher 	unsigned long link_check_timeout;
740dee1ad47SJeff Kirsher 
741dee1ad47SJeff Kirsher 	struct timer_list service_timer;
74246646e61SAlexander Duyck 	struct work_struct service_task;
74346646e61SAlexander Duyck 
74446646e61SAlexander Duyck 	struct hlist_head fdir_filter_list;
74546646e61SAlexander Duyck 	unsigned long fdir_overflow; /* number of times ATR was backed off */
74646646e61SAlexander Duyck 	union ixgbe_atr_input fdir_mask;
74746646e61SAlexander Duyck 	int fdir_filter_count;
748dee1ad47SJeff Kirsher 	u32 fdir_pballoc;
749dee1ad47SJeff Kirsher 	u32 atr_sample_rate;
750dee1ad47SJeff Kirsher 	spinlock_t fdir_perfect_lock;
75146646e61SAlexander Duyck 
752dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
753dee1ad47SJeff Kirsher 	struct ixgbe_fcoe fcoe;
754dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
7552a1a091cSMark Rustad 	u8 __iomem *io_addr; /* Mainly for iounmap use */
756dee1ad47SJeff Kirsher 	u32 wol;
75746646e61SAlexander Duyck 
758aa2bacb6SDon Skidmore 	u16 bridge_mode;
759aa2bacb6SDon Skidmore 
76073834aecSPaul Greenwalt 	char eeprom_id[NVM_VER_SIZE];
761c23f5b6bSEmil Tantilov 	u16 eeprom_cap;
762dee1ad47SJeff Kirsher 
763dee1ad47SJeff Kirsher 	u32 interrupt_event;
76446646e61SAlexander Duyck 	u32 led_reg;
765dee1ad47SJeff Kirsher 
7663a6a4edaSJacob Keller 	struct ptp_clock *ptp_clock;
7673a6a4edaSJacob Keller 	struct ptp_clock_info ptp_caps;
768891dc082SJacob Keller 	struct work_struct ptp_tx_work;
769891dc082SJacob Keller 	struct sk_buff *ptp_tx_skb;
77093501d48SJacob Keller 	struct hwtstamp_config tstamp_config;
771891dc082SJacob Keller 	unsigned long ptp_tx_start;
7723a6a4edaSJacob Keller 	unsigned long last_overflow_check;
7736cb562d6SJacob Keller 	unsigned long last_rx_ptp_check;
774eda183c2SJakub Kicinski 	unsigned long last_rx_timestamp;
7753a6a4edaSJacob Keller 	spinlock_t tmreg_lock;
776a9763f3cSMark Rustad 	struct cyclecounter hw_cc;
777a9763f3cSMark Rustad 	struct timecounter hw_tc;
7783a6a4edaSJacob Keller 	u32 base_incval;
779a9763f3cSMark Rustad 	u32 tx_hwtstamp_timeouts;
7804cc74c01SJacob Keller 	u32 tx_hwtstamp_skipped;
781a9763f3cSMark Rustad 	u32 rx_hwtstamp_cleared;
782a9763f3cSMark Rustad 	void (*ptp_setup_sdp)(struct ixgbe_adapter *);
7833a6a4edaSJacob Keller 
784dee1ad47SJeff Kirsher 	/* SR-IOV */
785dee1ad47SJeff Kirsher 	DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
786dee1ad47SJeff Kirsher 	unsigned int num_vfs;
787dee1ad47SJeff Kirsher 	struct vf_data_storage *vfinfo;
788dee1ad47SJeff Kirsher 	int vf_rate_link_speed;
789dee1ad47SJeff Kirsher 	struct vf_macvlans vf_mvs;
790dee1ad47SJeff Kirsher 	struct vf_macvlans *mv_list;
791dee1ad47SJeff Kirsher 
79283c61fa9SGreg Rose 	u32 timer_event_accumulator;
79383c61fa9SGreg Rose 	u32 vferr_refcount;
7945d7daa35SJacob Keller 	struct ixgbe_mac_addr *mac_table;
7953ca8bc6dSDon Skidmore 	struct kobject *info_kobj;
7963ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
79703b77d81SGuenter Roeck 	struct hwmon_buff *ixgbe_hwmon_buff;
7983ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
79900949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
80000949167SCatherine Sullivan 	struct dentry *ixgbe_dbg_adapter;
80100949167SCatherine Sullivan #endif /*CONFIG_DEBUG_FS*/
802107d3018SAlexander Duyck 
803107d3018SAlexander Duyck 	u8 default_up;
8044e039c16SAlexander Duyck 	/* Bitmask indicating in use pools */
8054e039c16SAlexander Duyck 	DECLARE_BITMAP(fwd_bitmask, IXGBE_MAX_MACVLANS + 1);
806dfaf891dSVlad Zolotarov 
807b82b17d9SJohn Fastabend #define IXGBE_MAX_LINK_HANDLE 10
8081cdaaf54SAmritha Nambiar 	struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE];
809db956ae8SJohn Fastabend 	unsigned long tables;
810b82b17d9SJohn Fastabend 
811dfaf891dSVlad Zolotarov /* maximum number of RETA entries among all devices supported by ixgbe
812dfaf891dSVlad Zolotarov  * driver: currently it's x550 device in non-SRIOV mode
813dfaf891dSVlad Zolotarov  */
814dfaf891dSVlad Zolotarov #define IXGBE_MAX_RETA_ENTRIES 512
815dfaf891dSVlad Zolotarov 	u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
816dfaf891dSVlad Zolotarov 
817dfaf891dSVlad Zolotarov #define IXGBE_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
8183dfbfc7eSTony Nguyen 	u32 *rss_key;
81934c822e2SShannon Nelson 
82048e01e00SJeff Kirsher #ifdef CONFIG_IXGBE_IPSEC
82134c822e2SShannon Nelson 	struct ixgbe_ipsec *ipsec;
82248e01e00SJeff Kirsher #endif /* CONFIG_IXGBE_IPSEC */
8231e53834cSPiotr Skajewski 	spinlock_t vfs_lock;
824dee1ad47SJeff Kirsher };
825dee1ad47SJeff Kirsher 
ixgbe_determine_xdp_q_idx(int cpu)8264fe81585SJason Xing static inline int ixgbe_determine_xdp_q_idx(int cpu)
8274fe81585SJason Xing {
8284fe81585SJason Xing 	if (static_key_enabled(&ixgbe_xdp_locking_key))
8294fe81585SJason Xing 		return cpu % IXGBE_MAX_XDP_QS;
8304fe81585SJason Xing 	else
8314fe81585SJason Xing 		return cpu;
8324fe81585SJason Xing }
8334fe81585SJason Xing 
8344fe81585SJason Xing static inline
ixgbe_determine_xdp_ring(struct ixgbe_adapter * adapter)8354fe81585SJason Xing struct ixgbe_ring *ixgbe_determine_xdp_ring(struct ixgbe_adapter *adapter)
8364fe81585SJason Xing {
8374fe81585SJason Xing 	int index = ixgbe_determine_xdp_q_idx(smp_processor_id());
8384fe81585SJason Xing 
8394fe81585SJason Xing 	return adapter->xdp_ring[index];
8404fe81585SJason Xing }
8414fe81585SJason Xing 
ixgbe_max_rss_indices(struct ixgbe_adapter * adapter)8420f9b232bSDon Skidmore static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
8430f9b232bSDon Skidmore {
8440f9b232bSDon Skidmore 	switch (adapter->hw.mac.type) {
8450f9b232bSDon Skidmore 	case ixgbe_mac_82598EB:
8460f9b232bSDon Skidmore 	case ixgbe_mac_82599EB:
8470f9b232bSDon Skidmore 	case ixgbe_mac_X540:
8480f9b232bSDon Skidmore 		return IXGBE_MAX_RSS_INDICES;
8490f9b232bSDon Skidmore 	case ixgbe_mac_X550:
8500f9b232bSDon Skidmore 	case ixgbe_mac_X550EM_x:
85149425dfcSMark Rustad 	case ixgbe_mac_x550em_a:
8520f9b232bSDon Skidmore 		return IXGBE_MAX_RSS_INDICES_X550;
8530f9b232bSDon Skidmore 	default:
8540f9b232bSDon Skidmore 		return 0;
8550f9b232bSDon Skidmore 	}
8560f9b232bSDon Skidmore }
8570f9b232bSDon Skidmore 
858dee1ad47SJeff Kirsher struct ixgbe_fdir_filter {
859dee1ad47SJeff Kirsher 	struct hlist_node fdir_node;
860dee1ad47SJeff Kirsher 	union ixgbe_atr_input filter;
861dee1ad47SJeff Kirsher 	u16 sw_idx;
8622a9ed5d1SSridhar Samudrala 	u64 action;
863dee1ad47SJeff Kirsher };
864dee1ad47SJeff Kirsher 
86570e5576cSDon Skidmore enum ixgbe_state_t {
866dee1ad47SJeff Kirsher 	__IXGBE_TESTING,
867dee1ad47SJeff Kirsher 	__IXGBE_RESETTING,
868dee1ad47SJeff Kirsher 	__IXGBE_DOWN,
86941c62843SMark Rustad 	__IXGBE_DISABLED,
87009f40aedSMark Rustad 	__IXGBE_REMOVING,
871dee1ad47SJeff Kirsher 	__IXGBE_SERVICE_SCHED,
87258cf663fSMark Rustad 	__IXGBE_SERVICE_INITED,
873dee1ad47SJeff Kirsher 	__IXGBE_IN_SFP_INIT,
8748fecf67cSJacob Keller 	__IXGBE_PTP_RUNNING,
875151b260cSJakub Kicinski 	__IXGBE_PTP_TX_IN_PROGRESS,
87657ca2a4fSEmil Tantilov 	__IXGBE_RESET_REQUESTED,
877dee1ad47SJeff Kirsher };
878dee1ad47SJeff Kirsher 
8794c1975d7SAlexander Duyck struct ixgbe_cb {
8804c1975d7SAlexander Duyck 	union {				/* Union defining head/tail partner */
8814c1975d7SAlexander Duyck 		struct sk_buff *head;
8824c1975d7SAlexander Duyck 		struct sk_buff *tail;
8834c1975d7SAlexander Duyck 	};
884dee1ad47SJeff Kirsher 	dma_addr_t dma;
8854c1975d7SAlexander Duyck 	u16 append_cnt;
886f800326dSAlexander Duyck 	bool page_released;
887dee1ad47SJeff Kirsher };
8884c1975d7SAlexander Duyck #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
889dee1ad47SJeff Kirsher 
890dee1ad47SJeff Kirsher enum ixgbe_boards {
891dee1ad47SJeff Kirsher 	board_82598,
892dee1ad47SJeff Kirsher 	board_82599,
893dee1ad47SJeff Kirsher 	board_X540,
8946a14ee0cSDon Skidmore 	board_X550,
8956a14ee0cSDon Skidmore 	board_X550EM_x,
8968dc963e1SPaul Greenwalt 	board_x550em_x_fw,
89749425dfcSMark Rustad 	board_x550em_a,
898b3eb4e18SMark Rustad 	board_x550em_a_fw,
899dee1ad47SJeff Kirsher };
900dee1ad47SJeff Kirsher 
90137689010SMark Rustad extern const struct ixgbe_info ixgbe_82598_info;
90237689010SMark Rustad extern const struct ixgbe_info ixgbe_82599_info;
90337689010SMark Rustad extern const struct ixgbe_info ixgbe_X540_info;
90437689010SMark Rustad extern const struct ixgbe_info ixgbe_X550_info;
90537689010SMark Rustad extern const struct ixgbe_info ixgbe_X550EM_x_info;
9068dc963e1SPaul Greenwalt extern const struct ixgbe_info ixgbe_x550em_x_fw_info;
90749425dfcSMark Rustad extern const struct ixgbe_info ixgbe_x550em_a_info;
908b3eb4e18SMark Rustad extern const struct ixgbe_info ixgbe_x550em_a_fw_info;
909dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
9103f40c74cSStephen Hemminger extern const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops;
911dee1ad47SJeff Kirsher #endif
912dee1ad47SJeff Kirsher 
913dee1ad47SJeff Kirsher extern char ixgbe_driver_name[];
9148af3c33fSJeff Kirsher #ifdef IXGBE_FCOE
915ea81875aSNeerav Parikh extern char ixgbe_default_device_descr[];
9168af3c33fSJeff Kirsher #endif /* IXGBE_FCOE */
917dee1ad47SJeff Kirsher 
9186c211fe1SStefan Assmann int ixgbe_open(struct net_device *netdev);
9196c211fe1SStefan Assmann int ixgbe_close(struct net_device *netdev);
9205ccc921aSJoe Perches void ixgbe_up(struct ixgbe_adapter *adapter);
9215ccc921aSJoe Perches void ixgbe_down(struct ixgbe_adapter *adapter);
9225ccc921aSJoe Perches void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
9235ccc921aSJoe Perches void ixgbe_reset(struct ixgbe_adapter *adapter);
9245ccc921aSJoe Perches void ixgbe_set_ethtool_ops(struct net_device *netdev);
92592470808SJohn Fastabend int ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
9265ccc921aSJoe Perches int ixgbe_setup_tx_resources(struct ixgbe_ring *);
9275ccc921aSJoe Perches void ixgbe_free_rx_resources(struct ixgbe_ring *);
9285ccc921aSJoe Perches void ixgbe_free_tx_resources(struct ixgbe_ring *);
9295ccc921aSJoe Perches void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
9305ccc921aSJoe Perches void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
9311918e937SAlexander Duyck void ixgbe_disable_rx(struct ixgbe_adapter *adapter);
9321918e937SAlexander Duyck void ixgbe_disable_tx(struct ixgbe_adapter *adapter);
9335ccc921aSJoe Perches void ixgbe_update_stats(struct ixgbe_adapter *adapter);
9345ccc921aSJoe Perches int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
935740234f0SEmil Tantilov bool ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
9368e2813f5SJacob Keller 			 u16 subdevice_id);
9375d7daa35SJacob Keller #ifdef CONFIG_PCI_IOV
9385d7daa35SJacob Keller void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter);
9395d7daa35SJacob Keller #endif
9405d7daa35SJacob Keller int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter,
941c9f53e63SAlexander Duyck 			 const u8 *addr, u16 queue);
9425d7daa35SJacob Keller int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter,
943c9f53e63SAlexander Duyck 			 const u8 *addr, u16 queue);
944e1d0a2afSAlexander Duyck void ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid);
9455ccc921aSJoe Perches void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
9465ccc921aSJoe Perches netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *,
947dee1ad47SJeff Kirsher 				  struct ixgbe_ring *);
9485ccc921aSJoe Perches void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
9495ccc921aSJoe Perches void ixgbe_write_eitr(struct ixgbe_q_vector *);
9505ccc921aSJoe Perches int ixgbe_poll(struct napi_struct *napi, int budget);
9515ccc921aSJoe Perches int ethtool_ioctl(struct ifreq *ifr);
9525ccc921aSJoe Perches s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
9535ccc921aSJoe Perches s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
9545ccc921aSJoe Perches s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
9555ccc921aSJoe Perches s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
956dee1ad47SJeff Kirsher 					  union ixgbe_atr_hash_dword input,
957dee1ad47SJeff Kirsher 					  union ixgbe_atr_hash_dword common,
958dee1ad47SJeff Kirsher 					  u8 queue);
9595ccc921aSJoe Perches s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
960dee1ad47SJeff Kirsher 				    union ixgbe_atr_input *input_mask);
9615ccc921aSJoe Perches s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
962dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *input,
963dee1ad47SJeff Kirsher 					  u16 soft_id, u8 queue);
9645ccc921aSJoe Perches s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
965dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *input,
966dee1ad47SJeff Kirsher 					  u16 soft_id);
9675ccc921aSJoe Perches void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
968dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *mask);
969b82b17d9SJohn Fastabend int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
970b82b17d9SJohn Fastabend 				    struct ixgbe_fdir_filter *input,
971b82b17d9SJohn Fastabend 				    u16 sw_idx);
9725ccc921aSJoe Perches void ixgbe_set_rx_mode(struct net_device *netdev);
9738af3c33fSJeff Kirsher #ifdef CONFIG_IXGBE_DCB
9745ccc921aSJoe Perches void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
9758af3c33fSJeff Kirsher #endif
9765ccc921aSJoe Perches int ixgbe_setup_tc(struct net_device *dev, u8 tc);
9775ccc921aSJoe Perches void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
9785ccc921aSJoe Perches void ixgbe_do_reset(struct net_device *netdev);
9791210982bSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
9805ccc921aSJoe Perches void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
9815ccc921aSJoe Perches int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
9821210982bSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
983dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
9845ccc921aSJoe Perches void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
9855ccc921aSJoe Perches int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
986244e27adSAlexander Duyck 	      u8 *hdr_len);
9875ccc921aSJoe Perches int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
9885ccc921aSJoe Perches 		   union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb);
9895ccc921aSJoe Perches int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
990dee1ad47SJeff Kirsher 		       struct scatterlist *sgl, unsigned int sgc);
9915ccc921aSJoe Perches int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
992dee1ad47SJeff Kirsher 			  struct scatterlist *sgl, unsigned int sgc);
9935ccc921aSJoe Perches int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
9945ccc921aSJoe Perches int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
9955ccc921aSJoe Perches void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
9965ccc921aSJoe Perches int ixgbe_fcoe_enable(struct net_device *netdev);
9975ccc921aSJoe Perches int ixgbe_fcoe_disable(struct net_device *netdev);
9985ccc921aSJoe Perches int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
9995ccc921aSJoe Perches int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
1000ea81875aSNeerav Parikh 			   struct netdev_fcoe_hbainfo *info);
10015ccc921aSJoe Perches u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
1002dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
100300949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
10045ccc921aSJoe Perches void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
10055ccc921aSJoe Perches void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
10065ccc921aSJoe Perches void ixgbe_dbg_init(void);
10075ccc921aSJoe Perches void ixgbe_dbg_exit(void);
100833243fb0SJoe Perches #else
ixgbe_dbg_adapter_init(struct ixgbe_adapter * adapter)100933243fb0SJoe Perches static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}
ixgbe_dbg_adapter_exit(struct ixgbe_adapter * adapter)101033243fb0SJoe Perches static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {}
ixgbe_dbg_init(void)101133243fb0SJoe Perches static inline void ixgbe_dbg_init(void) {}
ixgbe_dbg_exit(void)101233243fb0SJoe Perches static inline void ixgbe_dbg_exit(void) {}
101300949167SCatherine Sullivan #endif /* CONFIG_DEBUG_FS */
txring_txq(const struct ixgbe_ring * ring)1014b2d96e0aSAlexander Duyck static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
1015b2d96e0aSAlexander Duyck {
1016b2d96e0aSAlexander Duyck 	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
1017b2d96e0aSAlexander Duyck }
1018b2d96e0aSAlexander Duyck 
10195ccc921aSJoe Perches void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
10209966d1eeSJacob Keller void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
10215ccc921aSJoe Perches void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
10225ccc921aSJoe Perches void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
10235ccc921aSJoe Perches void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
1024622a2ef5SJacob Keller void ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter);
1025a9763f3cSMark Rustad void ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *);
1026a9763f3cSMark Rustad void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb);
ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring * rx_ring,union ixgbe_adv_rx_desc * rx_desc,struct sk_buff * skb)1027a9763f3cSMark Rustad static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
1028a9763f3cSMark Rustad 					 union ixgbe_adv_rx_desc *rx_desc,
1029a9763f3cSMark Rustad 					 struct sk_buff *skb)
1030a9763f3cSMark Rustad {
1031a9763f3cSMark Rustad 	if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) {
1032a9763f3cSMark Rustad 		ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb);
1033a9763f3cSMark Rustad 		return;
1034a9763f3cSMark Rustad 	}
1035a9763f3cSMark Rustad 
1036a9763f3cSMark Rustad 	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
1037a9763f3cSMark Rustad 		return;
1038a9763f3cSMark Rustad 
1039a9763f3cSMark Rustad 	ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
1040a9763f3cSMark Rustad 
1041a9763f3cSMark Rustad 	/* Update the last_rx_timestamp timer in order to enable watchdog check
1042a9763f3cSMark Rustad 	 * for error case of latched timestamp on a dropped packet.
1043a9763f3cSMark Rustad 	 */
1044a9763f3cSMark Rustad 	rx_ring->last_rx_timestamp = jiffies;
1045a9763f3cSMark Rustad }
1046a9763f3cSMark Rustad 
104793501d48SJacob Keller int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
104893501d48SJacob Keller int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
10495ccc921aSJoe Perches void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
10505ccc921aSJoe Perches void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
1051a9763f3cSMark Rustad void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter);
1052da36b647SGreg Rose #ifdef CONFIG_PCI_IOV
1053da36b647SGreg Rose void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
1054da36b647SGreg Rose #endif
10553a6a4edaSJacob Keller 
10562a47fa45SJohn Fastabend netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
10572a47fa45SJohn Fastabend 				  struct ixgbe_adapter *adapter,
10582a47fa45SJohn Fastabend 				  struct ixgbe_ring *tx_ring);
10597f276efbSVlad Zolotarov u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
1060d3aa9c9fSPaolo Abeni void ixgbe_store_key(struct ixgbe_adapter *adapter);
10611c7cf078STom Barbette void ixgbe_store_reta(struct ixgbe_adapter *adapter);
10622916500dSDon Skidmore s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
10632916500dSDon Skidmore 		       u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
106448e01e00SJeff Kirsher #ifdef CONFIG_IXGBE_IPSEC
10658bbbc5e9SShannon Nelson void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter);
106663a67fe2SShannon Nelson void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter);
10676d73a154SShannon Nelson void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter);
106892103199SShannon Nelson void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
106992103199SShannon Nelson 		    union ixgbe_adv_rx_desc *rx_desc,
107092103199SShannon Nelson 		    struct sk_buff *skb);
107159259470SShannon Nelson int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
107259259470SShannon Nelson 		   struct ixgbe_ipsec_tx_data *itd);
107372698240SShannon Nelson void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, u32 vf);
107472698240SShannon Nelson int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
107572698240SShannon Nelson int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
10768bbbc5e9SShannon Nelson #else
ixgbe_init_ipsec_offload(struct ixgbe_adapter * adapter)107772698240SShannon Nelson static inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { }
ixgbe_stop_ipsec_offload(struct ixgbe_adapter * adapter)107872698240SShannon Nelson static inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { }
ixgbe_ipsec_restore(struct ixgbe_adapter * adapter)107972698240SShannon Nelson static inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { }
ixgbe_ipsec_rx(struct ixgbe_ring * rx_ring,union ixgbe_adv_rx_desc * rx_desc,struct sk_buff * skb)108092103199SShannon Nelson static inline void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
108192103199SShannon Nelson 				  union ixgbe_adv_rx_desc *rx_desc,
108272698240SShannon Nelson 				  struct sk_buff *skb) { }
ixgbe_ipsec_tx(struct ixgbe_ring * tx_ring,struct ixgbe_tx_buffer * first,struct ixgbe_ipsec_tx_data * itd)108359259470SShannon Nelson static inline int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
108459259470SShannon Nelson 				 struct ixgbe_tx_buffer *first,
108572698240SShannon Nelson 				 struct ixgbe_ipsec_tx_data *itd) { return 0; }
ixgbe_ipsec_vf_clear(struct ixgbe_adapter * adapter,u32 vf)108672698240SShannon Nelson static inline void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter,
108772698240SShannon Nelson 					u32 vf) { }
ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter * adapter,u32 * mbuf,u32 vf)108872698240SShannon Nelson static inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
108972698240SShannon Nelson 					u32 *mbuf, u32 vf) { return -EACCES; }
ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter * adapter,u32 * mbuf,u32 vf)109072698240SShannon Nelson static inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
109172698240SShannon Nelson 					u32 *mbuf, u32 vf) { return -EACCES; }
109248e01e00SJeff Kirsher #endif /* CONFIG_IXGBE_IPSEC */
10939ba095a6SJan Sokolowski 
ixgbe_enabled_xdp_adapter(struct ixgbe_adapter * adapter)10949ba095a6SJan Sokolowski static inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter)
10959ba095a6SJan Sokolowski {
10969ba095a6SJan Sokolowski 	return !!adapter->xdp_prog;
10979ba095a6SJan Sokolowski }
10989ba095a6SJan Sokolowski 
1099dee1ad47SJeff Kirsher #endif /* _IXGBE_H_ */
1100