xref: /openbmc/linux/drivers/net/ethernet/intel/ixgbe/ixgbe.h (revision 9f12df906cd807a05d71aa53a951532d1dd3b888)
1dee1ad47SJeff Kirsher /*******************************************************************************
2dee1ad47SJeff Kirsher 
3dee1ad47SJeff Kirsher   Intel 10 Gigabit PCI Express Linux driver
4434c5e39SDon Skidmore   Copyright(c) 1999 - 2013 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"
48dee1ad47SJeff Kirsher #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
49dee1ad47SJeff Kirsher #define IXGBE_FCOE
50dee1ad47SJeff Kirsher #include "ixgbe_fcoe.h"
51dee1ad47SJeff Kirsher #endif /* CONFIG_FCOE or CONFIG_FCOE_MODULE */
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 
58e0d1095aSCong Wang #ifdef CONFIG_NET_RX_BUSY_POLL
59b4640030SJacob Keller #define BP_EXTENDED_STATS
607e15b90fSEliezer Tamir #endif
61dee1ad47SJeff Kirsher /* common prefix used by pr_<> macros */
62dee1ad47SJeff Kirsher #undef pr_fmt
63dee1ad47SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
64dee1ad47SJeff Kirsher 
65dee1ad47SJeff Kirsher /* TX/RX descriptor defines */
66dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_TXD		    512
6759224555SAlexander Duyck #define IXGBE_DEFAULT_TX_WORK		    256
68dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD			   4096
69dee1ad47SJeff Kirsher #define IXGBE_MIN_TXD			     64
70dee1ad47SJeff Kirsher 
71fb44519dSAnton Blanchard #if (PAGE_SIZE < 8192)
72dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_RXD		    512
73fb44519dSAnton Blanchard #else
74fb44519dSAnton Blanchard #define IXGBE_DEFAULT_RXD		    128
75fb44519dSAnton Blanchard #endif
76dee1ad47SJeff Kirsher #define IXGBE_MAX_RXD			   4096
77dee1ad47SJeff Kirsher #define IXGBE_MIN_RXD			     64
78dee1ad47SJeff Kirsher 
795b7f000fSDon Skidmore #define IXGBE_ETH_P_LLDP		 0x88CC
805b7f000fSDon Skidmore 
81dee1ad47SJeff Kirsher /* flow control */
82dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTL			   0x40
83dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTL			0x7FF80
84dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTH			  0x600
85dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTH			0x7FFF0
86dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_FCPAUSE		 0xFFFF
87dee1ad47SJeff Kirsher #define IXGBE_MIN_FCPAUSE		      0
88dee1ad47SJeff Kirsher #define IXGBE_MAX_FCPAUSE		 0xFFFF
89dee1ad47SJeff Kirsher 
90dee1ad47SJeff Kirsher /* Supported Rx Buffer Sizes */
91252562c2SAlexander Duyck #define IXGBE_RXBUFFER_256    256  /* Used for skb receive header */
9209816fbeSAlexander Duyck #define IXGBE_RXBUFFER_2K    2048
9309816fbeSAlexander Duyck #define IXGBE_RXBUFFER_3K    3072
9409816fbeSAlexander Duyck #define IXGBE_RXBUFFER_4K    4096
95dee1ad47SJeff Kirsher #define IXGBE_MAX_RXBUFFER  16384  /* largest size for a single descriptor */
96dee1ad47SJeff Kirsher 
97dee1ad47SJeff Kirsher /*
98252562c2SAlexander Duyck  * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
99252562c2SAlexander Duyck  * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
100252562c2SAlexander Duyck  * this adds up to 448 bytes of extra data.
101252562c2SAlexander Duyck  *
102252562c2SAlexander Duyck  * Since netdev_alloc_skb now allocates a page fragment we can use a value
103252562c2SAlexander Duyck  * of 256 and the resultant skb will have a truesize of 960 or less.
104dee1ad47SJeff Kirsher  */
105252562c2SAlexander Duyck #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
106dee1ad47SJeff Kirsher 
107dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */
108dee1ad47SJeff Kirsher #define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */
109dee1ad47SJeff Kirsher 
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 	u16 default_vf_vlan_id;
147dee1ad47SJeff Kirsher 	u16 vlans_enabled;
148dee1ad47SJeff Kirsher 	bool clear_to_send;
149dee1ad47SJeff Kirsher 	bool pf_set_mac;
150dee1ad47SJeff Kirsher 	u16 pf_vlan; /* When set, guest VLAN config not allowed. */
151dee1ad47SJeff Kirsher 	u16 pf_qos;
152dee1ad47SJeff Kirsher 	u16 tx_rate;
153de4c7f65SGreg Rose 	u16 vlan_count;
154de4c7f65SGreg Rose 	u8 spoofchk_enabled;
155e65ce0d3SVlad Zolotarov 	bool rss_query_enabled;
15654011e4dSHiroshi Shimamoto 	u8 trusted;
1578443c1a4SHiroshi Shimamoto 	int xcast_mode;
158374c65d6SAlexander Duyck 	unsigned int vf_api;
159dee1ad47SJeff Kirsher };
160dee1ad47SJeff Kirsher 
1618443c1a4SHiroshi Shimamoto enum ixgbevf_xcast_modes {
1628443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_NONE = 0,
1638443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_MULTI,
1648443c1a4SHiroshi Shimamoto 	IXGBEVF_XCAST_MODE_ALLMULTI,
1658443c1a4SHiroshi Shimamoto };
1668443c1a4SHiroshi Shimamoto 
167dee1ad47SJeff Kirsher struct vf_macvlans {
168dee1ad47SJeff Kirsher 	struct list_head l;
169dee1ad47SJeff Kirsher 	int vf;
170dee1ad47SJeff Kirsher 	bool free;
171dee1ad47SJeff Kirsher 	bool is_macvlan;
172dee1ad47SJeff Kirsher 	u8 vf_macvlan[ETH_ALEN];
173dee1ad47SJeff Kirsher };
174dee1ad47SJeff Kirsher 
175dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD_PWR	14
176dee1ad47SJeff Kirsher #define IXGBE_MAX_DATA_PER_TXD	(1 << IXGBE_MAX_TXD_PWR)
177dee1ad47SJeff Kirsher 
178dee1ad47SJeff Kirsher /* Tx Descriptors needed, worst case */
179dee1ad47SJeff Kirsher #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
180990a3158SAlexander Duyck #define DESC_NEEDED (MAX_SKB_FRAGS + 4)
181dee1ad47SJeff Kirsher 
182dee1ad47SJeff Kirsher /* wrapper around a pointer to a socket buffer,
183dee1ad47SJeff Kirsher  * so a DMA handle can be stored along with the buffer */
184dee1ad47SJeff Kirsher struct ixgbe_tx_buffer {
185d3d00239SAlexander Duyck 	union ixgbe_adv_tx_desc *next_to_watch;
186dee1ad47SJeff Kirsher 	unsigned long time_stamp;
187d3d00239SAlexander Duyck 	struct sk_buff *skb;
188fd0db0edSAlexander Duyck 	unsigned int bytecount;
189fd0db0edSAlexander Duyck 	unsigned short gso_segs;
190244e27adSAlexander Duyck 	__be16 protocol;
191729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_ADDR(dma);
192729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_LEN(len);
193fd0db0edSAlexander Duyck 	u32 tx_flags;
194dee1ad47SJeff Kirsher };
195dee1ad47SJeff Kirsher 
196dee1ad47SJeff Kirsher struct ixgbe_rx_buffer {
197dee1ad47SJeff Kirsher 	struct sk_buff *skb;
198dee1ad47SJeff Kirsher 	dma_addr_t dma;
199dee1ad47SJeff Kirsher 	struct page *page;
200dee1ad47SJeff Kirsher 	unsigned int page_offset;
201dee1ad47SJeff Kirsher };
202dee1ad47SJeff Kirsher 
203dee1ad47SJeff Kirsher struct ixgbe_queue_stats {
204dee1ad47SJeff Kirsher 	u64 packets;
205dee1ad47SJeff Kirsher 	u64 bytes;
206b4640030SJacob Keller #ifdef BP_EXTENDED_STATS
2077e15b90fSEliezer Tamir 	u64 yields;
2087e15b90fSEliezer Tamir 	u64 misses;
2097e15b90fSEliezer Tamir 	u64 cleaned;
210b4640030SJacob Keller #endif  /* BP_EXTENDED_STATS */
211dee1ad47SJeff Kirsher };
212dee1ad47SJeff Kirsher 
213dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats {
214dee1ad47SJeff Kirsher 	u64 restart_queue;
215dee1ad47SJeff Kirsher 	u64 tx_busy;
216dee1ad47SJeff Kirsher 	u64 tx_done_old;
217dee1ad47SJeff Kirsher };
218dee1ad47SJeff Kirsher 
219dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats {
220dee1ad47SJeff Kirsher 	u64 rsc_count;
221dee1ad47SJeff Kirsher 	u64 rsc_flush;
222dee1ad47SJeff Kirsher 	u64 non_eop_descs;
223dee1ad47SJeff Kirsher 	u64 alloc_rx_page_failed;
224dee1ad47SJeff Kirsher 	u64 alloc_rx_buff_failed;
2258a0da21bSAlexander Duyck 	u64 csum_err;
226dee1ad47SJeff Kirsher };
227dee1ad47SJeff Kirsher 
228a9763f3cSMark Rustad #define IXGBE_TS_HDR_LEN 8
229a9763f3cSMark Rustad 
230f800326dSAlexander Duyck enum ixgbe_ring_state_t {
231dee1ad47SJeff Kirsher 	__IXGBE_TX_FDIR_INIT_DONE,
232fd786b7bSAlexander Duyck 	__IXGBE_TX_XPS_INIT_DONE,
233dee1ad47SJeff Kirsher 	__IXGBE_TX_DETECT_HANG,
234dee1ad47SJeff Kirsher 	__IXGBE_HANG_CHECK_ARMED,
235dee1ad47SJeff Kirsher 	__IXGBE_RX_RSC_ENABLED,
2368a0da21bSAlexander Duyck 	__IXGBE_RX_CSUM_UDP_ZERO_ERR,
23757efd44cSAlexander Duyck 	__IXGBE_RX_FCOE,
238dee1ad47SJeff Kirsher };
239dee1ad47SJeff Kirsher 
2402a47fa45SJohn Fastabend struct ixgbe_fwd_adapter {
2412a47fa45SJohn Fastabend 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
2422a47fa45SJohn Fastabend 	struct net_device *netdev;
2432a47fa45SJohn Fastabend 	struct ixgbe_adapter *real_adapter;
2442a47fa45SJohn Fastabend 	unsigned int tx_base_queue;
2452a47fa45SJohn Fastabend 	unsigned int rx_base_queue;
2462a47fa45SJohn Fastabend 	int pool;
2472a47fa45SJohn Fastabend };
2482a47fa45SJohn Fastabend 
249dee1ad47SJeff Kirsher #define check_for_tx_hang(ring) \
250dee1ad47SJeff Kirsher 	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
251dee1ad47SJeff Kirsher #define set_check_for_tx_hang(ring) \
252dee1ad47SJeff Kirsher 	set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
253dee1ad47SJeff Kirsher #define clear_check_for_tx_hang(ring) \
254dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
255dee1ad47SJeff Kirsher #define ring_is_rsc_enabled(ring) \
256dee1ad47SJeff Kirsher 	test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
257dee1ad47SJeff Kirsher #define set_ring_rsc_enabled(ring) \
258dee1ad47SJeff Kirsher 	set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
259dee1ad47SJeff Kirsher #define clear_ring_rsc_enabled(ring) \
260dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
261dee1ad47SJeff Kirsher struct ixgbe_ring {
262efe3d3c8SAlexander Duyck 	struct ixgbe_ring *next;	/* pointer to next ring in q_vector */
263d3ee4294SAlexander Duyck 	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
264dee1ad47SJeff Kirsher 	struct net_device *netdev;	/* netdev ring belongs to */
265d3ee4294SAlexander Duyck 	struct device *dev;		/* device for DMA mapping */
2662a47fa45SJohn Fastabend 	struct ixgbe_fwd_adapter *l2_accel_priv;
267d3ee4294SAlexander Duyck 	void *desc;			/* descriptor ring memory */
268dee1ad47SJeff Kirsher 	union {
269dee1ad47SJeff Kirsher 		struct ixgbe_tx_buffer *tx_buffer_info;
270dee1ad47SJeff Kirsher 		struct ixgbe_rx_buffer *rx_buffer_info;
271dee1ad47SJeff Kirsher 	};
272dee1ad47SJeff Kirsher 	unsigned long state;
273dee1ad47SJeff Kirsher 	u8 __iomem *tail;
274d3ee4294SAlexander Duyck 	dma_addr_t dma;			/* phys. address of descriptor ring */
275d3ee4294SAlexander Duyck 	unsigned int size;		/* length in bytes */
276dee1ad47SJeff Kirsher 
277dee1ad47SJeff Kirsher 	u16 count;			/* amount of descriptors */
278dee1ad47SJeff Kirsher 
279dee1ad47SJeff Kirsher 	u8 queue_index; /* needed for multiqueue queue management */
280dee1ad47SJeff Kirsher 	u8 reg_idx;			/* holds the special value that gets
281dee1ad47SJeff Kirsher 					 * the hardware register offset
282dee1ad47SJeff Kirsher 					 * associated with this ring, which is
283dee1ad47SJeff Kirsher 					 * different for DCB and RSS modes
284dee1ad47SJeff Kirsher 					 */
285d3ee4294SAlexander Duyck 	u16 next_to_use;
286d3ee4294SAlexander Duyck 	u16 next_to_clean;
287d3ee4294SAlexander Duyck 
288a9763f3cSMark Rustad 	unsigned long last_rx_timestamp;
289a9763f3cSMark Rustad 
290f800326dSAlexander Duyck 	union {
291d3ee4294SAlexander Duyck 		u16 next_to_alloc;
292f800326dSAlexander Duyck 		struct {
293dee1ad47SJeff Kirsher 			u8 atr_sample_rate;
294dee1ad47SJeff Kirsher 			u8 atr_count;
295f800326dSAlexander Duyck 		};
296f800326dSAlexander Duyck 	};
297dee1ad47SJeff Kirsher 
298dee1ad47SJeff Kirsher 	u8 dcb_tc;
299dee1ad47SJeff Kirsher 	struct ixgbe_queue_stats stats;
300dee1ad47SJeff Kirsher 	struct u64_stats_sync syncp;
301dee1ad47SJeff Kirsher 	union {
302dee1ad47SJeff Kirsher 		struct ixgbe_tx_queue_stats tx_stats;
303dee1ad47SJeff Kirsher 		struct ixgbe_rx_queue_stats rx_stats;
304dee1ad47SJeff Kirsher 	};
305dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
306dee1ad47SJeff Kirsher 
307dee1ad47SJeff Kirsher enum ixgbe_ring_f_enum {
308dee1ad47SJeff Kirsher 	RING_F_NONE = 0,
309dee1ad47SJeff Kirsher 	RING_F_VMDQ,  /* SR-IOV uses the same ring feature */
310dee1ad47SJeff Kirsher 	RING_F_RSS,
311dee1ad47SJeff Kirsher 	RING_F_FDIR,
312dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
313dee1ad47SJeff Kirsher 	RING_F_FCOE,
314dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
315dee1ad47SJeff Kirsher 
316dee1ad47SJeff Kirsher 	RING_F_ARRAY_SIZE      /* must be last in enum set */
317dee1ad47SJeff Kirsher };
318dee1ad47SJeff Kirsher 
319dee1ad47SJeff Kirsher #define IXGBE_MAX_RSS_INDICES		16
320e9ee3238SEmil Tantilov #define IXGBE_MAX_RSS_INDICES_X550	63
321dee1ad47SJeff Kirsher #define IXGBE_MAX_VMDQ_INDICES		64
322d3cb9869SAlexander Duyck #define IXGBE_MAX_FDIR_INDICES		63	/* based on q_vector limit */
323dee1ad47SJeff Kirsher #define IXGBE_MAX_FCOE_INDICES		8
324d3cb9869SAlexander Duyck #define MAX_RX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
325d3cb9869SAlexander Duyck #define MAX_TX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
3262a47fa45SJohn Fastabend #define IXGBE_MAX_L2A_QUEUES		4
3272a47fa45SJohn Fastabend #define IXGBE_BAD_L2A_QUEUE		3
3282a47fa45SJohn Fastabend #define IXGBE_MAX_MACVLANS		31
3292a47fa45SJohn Fastabend #define IXGBE_MAX_DCBMACVLANS		8
3302a47fa45SJohn Fastabend 
331dee1ad47SJeff Kirsher struct ixgbe_ring_feature {
332c087663eSAlexander Duyck 	u16 limit;	/* upper limit on feature indices */
333c087663eSAlexander Duyck 	u16 indices;	/* current value of indices */
334e4b317e9SAlexander Duyck 	u16 mask;	/* Mask used for feature to ring mapping */
335e4b317e9SAlexander Duyck 	u16 offset;	/* offset to start of feature */
336dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
337dee1ad47SJeff Kirsher 
33873079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_8Q_MASK 0x78
33973079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_4Q_MASK 0x7C
34073079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_2Q_MASK 0x7E
34173079ea0SAlexander Duyck 
342f800326dSAlexander Duyck /*
343f800326dSAlexander Duyck  * FCoE requires that all Rx buffers be over 2200 bytes in length.  Since
344f800326dSAlexander Duyck  * this is twice the size of a half page we need to double the page order
345f800326dSAlexander Duyck  * for FCoE enabled Rx queues.
346f800326dSAlexander Duyck  */
34709816fbeSAlexander Duyck static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
34809816fbeSAlexander Duyck {
34909816fbeSAlexander Duyck #ifdef IXGBE_FCOE
35009816fbeSAlexander Duyck 	if (test_bit(__IXGBE_RX_FCOE, &ring->state))
35109816fbeSAlexander Duyck 		return (PAGE_SIZE < 8192) ? IXGBE_RXBUFFER_4K :
35209816fbeSAlexander Duyck 					    IXGBE_RXBUFFER_3K;
35309816fbeSAlexander Duyck #endif
35409816fbeSAlexander Duyck 	return IXGBE_RXBUFFER_2K;
35509816fbeSAlexander Duyck }
35609816fbeSAlexander Duyck 
357f800326dSAlexander Duyck static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
358f800326dSAlexander Duyck {
35909816fbeSAlexander Duyck #ifdef IXGBE_FCOE
36009816fbeSAlexander Duyck 	if (test_bit(__IXGBE_RX_FCOE, &ring->state))
36109816fbeSAlexander Duyck 		return (PAGE_SIZE < 8192) ? 1 : 0;
362f800326dSAlexander Duyck #endif
36309816fbeSAlexander Duyck 	return 0;
36409816fbeSAlexander Duyck }
365f800326dSAlexander Duyck #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
366f800326dSAlexander Duyck 
367dee1ad47SJeff Kirsher struct ixgbe_ring_container {
368efe3d3c8SAlexander Duyck 	struct ixgbe_ring *ring;	/* pointer to linked list of rings */
369dee1ad47SJeff Kirsher 	unsigned int total_bytes;	/* total bytes processed this int */
370dee1ad47SJeff Kirsher 	unsigned int total_packets;	/* total packets processed this int */
371dee1ad47SJeff Kirsher 	u16 work_limit;			/* total work allowed per interrupt */
372dee1ad47SJeff Kirsher 	u8 count;			/* total number of rings in vector */
373dee1ad47SJeff Kirsher 	u8 itr;				/* current ITR setting for ring */
374dee1ad47SJeff Kirsher };
375dee1ad47SJeff Kirsher 
376a557928eSAlexander Duyck /* iterator for handling rings in ring container */
377a557928eSAlexander Duyck #define ixgbe_for_each_ring(pos, head) \
378a557928eSAlexander Duyck 	for (pos = (head).ring; pos != NULL; pos = pos->next)
379a557928eSAlexander Duyck 
380dee1ad47SJeff Kirsher #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
381dee1ad47SJeff Kirsher 			      ? 8 : 1)
382dee1ad47SJeff Kirsher #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
383dee1ad47SJeff Kirsher 
38449c7ffbeSAlexander Duyck /* MAX_Q_VECTORS of these are allocated,
385dee1ad47SJeff Kirsher  * but we only use one per queue-specific vector.
386dee1ad47SJeff Kirsher  */
387dee1ad47SJeff Kirsher struct ixgbe_q_vector {
388dee1ad47SJeff Kirsher 	struct ixgbe_adapter *adapter;
389dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
390dee1ad47SJeff Kirsher 	int cpu;	    /* CPU for DCA */
391dee1ad47SJeff Kirsher #endif
392d5bf4f67SEmil Tantilov 	u16 v_idx;		/* index of q_vector within array, also used for
393d5bf4f67SEmil Tantilov 				 * finding the bit in EICR and friends that
394d5bf4f67SEmil Tantilov 				 * represents the vector for this ring */
395d5bf4f67SEmil Tantilov 	u16 itr;		/* Interrupt throttle rate written to EITR */
396dee1ad47SJeff Kirsher 	struct ixgbe_ring_container rx, tx;
397d5bf4f67SEmil Tantilov 
398d5bf4f67SEmil Tantilov 	struct napi_struct napi;
399de88eeebSAlexander Duyck 	cpumask_t affinity_mask;
400de88eeebSAlexander Duyck 	int numa_node;
401de88eeebSAlexander Duyck 	struct rcu_head rcu;	/* to avoid race with update stats on free */
402dee1ad47SJeff Kirsher 	char name[IFNAMSIZ + 9];
403de88eeebSAlexander Duyck 
404e0d1095aSCong Wang #ifdef CONFIG_NET_RX_BUSY_POLL
405adc81090SAlexander Duyck 	atomic_t state;
406e0d1095aSCong Wang #endif  /* CONFIG_NET_RX_BUSY_POLL */
4075a85e737SEliezer Tamir 
408de88eeebSAlexander Duyck 	/* for dynamic allocation of rings associated with this q_vector */
409de88eeebSAlexander Duyck 	struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp;
410dee1ad47SJeff Kirsher };
411adc81090SAlexander Duyck 
412e0d1095aSCong Wang #ifdef CONFIG_NET_RX_BUSY_POLL
413adc81090SAlexander Duyck enum ixgbe_qv_state_t {
414adc81090SAlexander Duyck 	IXGBE_QV_STATE_IDLE = 0,
415adc81090SAlexander Duyck 	IXGBE_QV_STATE_NAPI,
416adc81090SAlexander Duyck 	IXGBE_QV_STATE_POLL,
417adc81090SAlexander Duyck 	IXGBE_QV_STATE_DISABLE
418adc81090SAlexander Duyck };
419adc81090SAlexander Duyck 
4205a85e737SEliezer Tamir static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)
4215a85e737SEliezer Tamir {
422adc81090SAlexander Duyck 	/* reset state to idle */
423adc81090SAlexander Duyck 	atomic_set(&q_vector->state, IXGBE_QV_STATE_IDLE);
4245a85e737SEliezer Tamir }
4255a85e737SEliezer Tamir 
4265a85e737SEliezer Tamir /* called from the device poll routine to get ownership of a q_vector */
4275a85e737SEliezer Tamir static inline bool ixgbe_qv_lock_napi(struct ixgbe_q_vector *q_vector)
4285a85e737SEliezer Tamir {
429adc81090SAlexander Duyck 	int rc = atomic_cmpxchg(&q_vector->state, IXGBE_QV_STATE_IDLE,
430adc81090SAlexander Duyck 				IXGBE_QV_STATE_NAPI);
431b4640030SJacob Keller #ifdef BP_EXTENDED_STATS
432adc81090SAlexander Duyck 	if (rc != IXGBE_QV_STATE_IDLE)
4337e15b90fSEliezer Tamir 		q_vector->tx.ring->stats.yields++;
4347e15b90fSEliezer Tamir #endif
435adc81090SAlexander Duyck 
436adc81090SAlexander Duyck 	return rc == IXGBE_QV_STATE_IDLE;
4375a85e737SEliezer Tamir }
4385a85e737SEliezer Tamir 
4395a85e737SEliezer Tamir /* returns true is someone tried to get the qv while napi had it */
440adc81090SAlexander Duyck static inline void ixgbe_qv_unlock_napi(struct ixgbe_q_vector *q_vector)
4415a85e737SEliezer Tamir {
442adc81090SAlexander Duyck 	WARN_ON(atomic_read(&q_vector->state) != IXGBE_QV_STATE_NAPI);
4435a85e737SEliezer Tamir 
444adc81090SAlexander Duyck 	/* flush any outstanding Rx frames */
445adc81090SAlexander Duyck 	if (q_vector->napi.gro_list)
446adc81090SAlexander Duyck 		napi_gro_flush(&q_vector->napi, false);
447adc81090SAlexander Duyck 
448adc81090SAlexander Duyck 	/* reset state to idle */
449adc81090SAlexander Duyck 	atomic_set(&q_vector->state, IXGBE_QV_STATE_IDLE);
4505a85e737SEliezer Tamir }
4515a85e737SEliezer Tamir 
4525a85e737SEliezer Tamir /* called from ixgbe_low_latency_poll() */
4535a85e737SEliezer Tamir static inline bool ixgbe_qv_lock_poll(struct ixgbe_q_vector *q_vector)
4545a85e737SEliezer Tamir {
455adc81090SAlexander Duyck 	int rc = atomic_cmpxchg(&q_vector->state, IXGBE_QV_STATE_IDLE,
456adc81090SAlexander Duyck 				IXGBE_QV_STATE_POLL);
457b4640030SJacob Keller #ifdef BP_EXTENDED_STATS
458adc81090SAlexander Duyck 	if (rc != IXGBE_QV_STATE_IDLE)
459adc81090SAlexander Duyck 		q_vector->tx.ring->stats.yields++;
4607e15b90fSEliezer Tamir #endif
461adc81090SAlexander Duyck 	return rc == IXGBE_QV_STATE_IDLE;
4625a85e737SEliezer Tamir }
4635a85e737SEliezer Tamir 
4645a85e737SEliezer Tamir /* returns true if someone tried to get the qv while it was locked */
465adc81090SAlexander Duyck static inline void ixgbe_qv_unlock_poll(struct ixgbe_q_vector *q_vector)
4665a85e737SEliezer Tamir {
467adc81090SAlexander Duyck 	WARN_ON(atomic_read(&q_vector->state) != IXGBE_QV_STATE_POLL);
4685a85e737SEliezer Tamir 
469adc81090SAlexander Duyck 	/* reset state to idle */
470adc81090SAlexander Duyck 	atomic_set(&q_vector->state, IXGBE_QV_STATE_IDLE);
4715a85e737SEliezer Tamir }
4725a85e737SEliezer Tamir 
4735a85e737SEliezer Tamir /* true if a socket is polling, even if it did not get the lock */
474b4640030SJacob Keller static inline bool ixgbe_qv_busy_polling(struct ixgbe_q_vector *q_vector)
4755a85e737SEliezer Tamir {
476adc81090SAlexander Duyck 	return atomic_read(&q_vector->state) == IXGBE_QV_STATE_POLL;
4775a85e737SEliezer Tamir }
47827d9ce4fSJacob Keller 
47927d9ce4fSJacob Keller /* false if QV is currently owned */
48027d9ce4fSJacob Keller static inline bool ixgbe_qv_disable(struct ixgbe_q_vector *q_vector)
48127d9ce4fSJacob Keller {
482adc81090SAlexander Duyck 	int rc = atomic_cmpxchg(&q_vector->state, IXGBE_QV_STATE_IDLE,
483adc81090SAlexander Duyck 				IXGBE_QV_STATE_DISABLE);
48427d9ce4fSJacob Keller 
485adc81090SAlexander Duyck 	return rc == IXGBE_QV_STATE_IDLE;
48627d9ce4fSJacob Keller }
48727d9ce4fSJacob Keller 
488e0d1095aSCong Wang #else /* CONFIG_NET_RX_BUSY_POLL */
4895a85e737SEliezer Tamir static inline void ixgbe_qv_init_lock(struct ixgbe_q_vector *q_vector)
4905a85e737SEliezer Tamir {
4915a85e737SEliezer Tamir }
4925a85e737SEliezer Tamir 
4935a85e737SEliezer Tamir static inline bool ixgbe_qv_lock_napi(struct ixgbe_q_vector *q_vector)
4945a85e737SEliezer Tamir {
4955a85e737SEliezer Tamir 	return true;
4965a85e737SEliezer Tamir }
4975a85e737SEliezer Tamir 
4985a85e737SEliezer Tamir static inline bool ixgbe_qv_unlock_napi(struct ixgbe_q_vector *q_vector)
4995a85e737SEliezer Tamir {
5005a85e737SEliezer Tamir 	return false;
5015a85e737SEliezer Tamir }
5025a85e737SEliezer Tamir 
5035a85e737SEliezer Tamir static inline bool ixgbe_qv_lock_poll(struct ixgbe_q_vector *q_vector)
5045a85e737SEliezer Tamir {
5055a85e737SEliezer Tamir 	return false;
5065a85e737SEliezer Tamir }
5075a85e737SEliezer Tamir 
5085a85e737SEliezer Tamir static inline bool ixgbe_qv_unlock_poll(struct ixgbe_q_vector *q_vector)
5095a85e737SEliezer Tamir {
5105a85e737SEliezer Tamir 	return false;
5115a85e737SEliezer Tamir }
5125a85e737SEliezer Tamir 
513b4640030SJacob Keller static inline bool ixgbe_qv_busy_polling(struct ixgbe_q_vector *q_vector)
5145a85e737SEliezer Tamir {
5155a85e737SEliezer Tamir 	return false;
5165a85e737SEliezer Tamir }
51727d9ce4fSJacob Keller 
51827d9ce4fSJacob Keller static inline bool ixgbe_qv_disable(struct ixgbe_q_vector *q_vector)
51927d9ce4fSJacob Keller {
52027d9ce4fSJacob Keller 	return true;
52127d9ce4fSJacob Keller }
52227d9ce4fSJacob Keller 
523e0d1095aSCong Wang #endif /* CONFIG_NET_RX_BUSY_POLL */
5245a85e737SEliezer Tamir 
5253ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
5263ca8bc6dSDon Skidmore 
5273ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_LOC		0
5283ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_TEMP		1
5293ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_CAUTION	2
5303ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_MAX		3
5313ca8bc6dSDon Skidmore 
5323ca8bc6dSDon Skidmore struct hwmon_attr {
5333ca8bc6dSDon Skidmore 	struct device_attribute dev_attr;
5343ca8bc6dSDon Skidmore 	struct ixgbe_hw *hw;
5353ca8bc6dSDon Skidmore 	struct ixgbe_thermal_diode_data *sensor;
5363ca8bc6dSDon Skidmore 	char name[12];
5373ca8bc6dSDon Skidmore };
5383ca8bc6dSDon Skidmore 
5393ca8bc6dSDon Skidmore struct hwmon_buff {
54003b77d81SGuenter Roeck 	struct attribute_group group;
54103b77d81SGuenter Roeck 	const struct attribute_group *groups[2];
54203b77d81SGuenter Roeck 	struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
54303b77d81SGuenter Roeck 	struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
5443ca8bc6dSDon Skidmore 	unsigned int n_hwmon;
5453ca8bc6dSDon Skidmore };
5463ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
547dee1ad47SJeff Kirsher 
548d5bf4f67SEmil Tantilov /*
549d5bf4f67SEmil Tantilov  * microsecond values for various ITR rates shifted by 2 to fit itr register
550d5bf4f67SEmil Tantilov  * with the first 3 bits reserved 0
551dee1ad47SJeff Kirsher  */
552d5bf4f67SEmil Tantilov #define IXGBE_MIN_RSC_ITR	24
553d5bf4f67SEmil Tantilov #define IXGBE_100K_ITR		40
554d5bf4f67SEmil Tantilov #define IXGBE_20K_ITR		200
5558ac34f10SAlexander Duyck #define IXGBE_12K_ITR		336
556dee1ad47SJeff Kirsher 
557f56e0cb1SAlexander Duyck /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
558f56e0cb1SAlexander Duyck static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
559f56e0cb1SAlexander Duyck 					const u32 stat_err_bits)
560f56e0cb1SAlexander Duyck {
561f56e0cb1SAlexander Duyck 	return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
562f56e0cb1SAlexander Duyck }
563f56e0cb1SAlexander Duyck 
564dee1ad47SJeff Kirsher static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
565dee1ad47SJeff Kirsher {
566dee1ad47SJeff Kirsher 	u16 ntc = ring->next_to_clean;
567dee1ad47SJeff Kirsher 	u16 ntu = ring->next_to_use;
568dee1ad47SJeff Kirsher 
569dee1ad47SJeff Kirsher 	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
570dee1ad47SJeff Kirsher }
571dee1ad47SJeff Kirsher 
572e4f74028SAlexander Duyck #define IXGBE_RX_DESC(R, i)	    \
573dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
574e4f74028SAlexander Duyck #define IXGBE_TX_DESC(R, i)	    \
575dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
576e4f74028SAlexander Duyck #define IXGBE_TX_CTXTDESC(R, i)	    \
577dee1ad47SJeff Kirsher 	(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
578dee1ad47SJeff Kirsher 
579c88887e0SAlexander Duyck #define IXGBE_MAX_JUMBO_FRAME_SIZE	9728 /* Maximum Supported Size 9.5KB */
580dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
581dee1ad47SJeff Kirsher /* Use 3K as the baby jumbo frame size for FCoE */
582dee1ad47SJeff Kirsher #define IXGBE_FCOE_JUMBO_FRAME_SIZE       3072
583dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
584dee1ad47SJeff Kirsher 
585dee1ad47SJeff Kirsher #define OTHER_VECTOR 1
586dee1ad47SJeff Kirsher #define NON_Q_VECTORS (OTHER_VECTOR)
587dee1ad47SJeff Kirsher 
588dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82599 64
58949c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82599 64
590dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82598 18
59149c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82598 16
592dee1ad47SJeff Kirsher 
5935d7daa35SJacob Keller struct ixgbe_mac_addr {
5945d7daa35SJacob Keller 	u8 addr[ETH_ALEN];
595c9f53e63SAlexander Duyck 	u16 pool;
5965d7daa35SJacob Keller 	u16 state; /* bitmask */
5975d7daa35SJacob Keller };
598c9f53e63SAlexander Duyck 
5995d7daa35SJacob Keller #define IXGBE_MAC_STATE_DEFAULT		0x1
6005d7daa35SJacob Keller #define IXGBE_MAC_STATE_MODIFIED	0x2
6015d7daa35SJacob Keller #define IXGBE_MAC_STATE_IN_USE		0x4
6025d7daa35SJacob Keller 
60349c7ffbeSAlexander Duyck #define MAX_Q_VECTORS MAX_Q_VECTORS_82599
604dee1ad47SJeff Kirsher #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
605dee1ad47SJeff Kirsher 
6068f15486dSAlexander Duyck #define MIN_MSIX_Q_VECTORS 1
607dee1ad47SJeff Kirsher #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
608dee1ad47SJeff Kirsher 
60946646e61SAlexander Duyck /* default to trying for four seconds */
61046646e61SAlexander Duyck #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
61158e7cd24SMark Rustad #define IXGBE_SFP_POLL_JIFFIES (2 * HZ)	/* SFP poll every 2 seconds */
61246646e61SAlexander Duyck 
613dee1ad47SJeff Kirsher /* board specific private data structure */
614dee1ad47SJeff Kirsher struct ixgbe_adapter {
61546646e61SAlexander Duyck 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
61646646e61SAlexander Duyck 	/* OS defined structs */
61746646e61SAlexander Duyck 	struct net_device *netdev;
61846646e61SAlexander Duyck 	struct pci_dev *pdev;
61946646e61SAlexander Duyck 
620dee1ad47SJeff Kirsher 	unsigned long state;
621dee1ad47SJeff Kirsher 
622dee1ad47SJeff Kirsher 	/* Some features need tri-state capability,
623dee1ad47SJeff Kirsher 	 * thus the additional *_CAPABLE flags.
624dee1ad47SJeff Kirsher 	 */
625dee1ad47SJeff Kirsher 	u32 flags;
626a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSI_ENABLED                  (u32)(1 << 1)
627a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSIX_ENABLED                 (u32)(1 << 3)
628a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_1BUF_CAPABLE              (u32)(1 << 4)
629a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_PS_CAPABLE                (u32)(1 << 5)
630a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_PS_ENABLED                (u32)(1 << 6)
631a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCA_ENABLED                  (u32)(1 << 8)
632a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCA_CAPABLE                  (u32)(1 << 9)
633a16a0d2fSAlexander Duyck #define IXGBE_FLAG_IMIR_ENABLED                 (u32)(1 << 10)
634a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MQ_CAPABLE                   (u32)(1 << 11)
635a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCB_ENABLED                  (u32)(1 << 12)
636a16a0d2fSAlexander Duyck #define IXGBE_FLAG_VMDQ_CAPABLE                 (u32)(1 << 13)
637a16a0d2fSAlexander Duyck #define IXGBE_FLAG_VMDQ_ENABLED                 (u32)(1 << 14)
638a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FAN_FAIL_CAPABLE             (u32)(1 << 15)
639a16a0d2fSAlexander Duyck #define IXGBE_FLAG_NEED_LINK_UPDATE             (u32)(1 << 16)
640a16a0d2fSAlexander Duyck #define IXGBE_FLAG_NEED_LINK_CONFIG             (u32)(1 << 17)
641a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FDIR_HASH_CAPABLE            (u32)(1 << 18)
642a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE         (u32)(1 << 19)
643a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FCOE_CAPABLE                 (u32)(1 << 20)
644a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FCOE_ENABLED                 (u32)(1 << 21)
645a16a0d2fSAlexander Duyck #define IXGBE_FLAG_SRIOV_CAPABLE                (u32)(1 << 22)
646a16a0d2fSAlexander Duyck #define IXGBE_FLAG_SRIOV_ENABLED                (u32)(1 << 23)
64767359c3cSMark Rustad #define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE	BIT(24)
648a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_ENABLED		BIT(25)
649a9763f3cSMark Rustad #define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER	BIT(26)
650dee1ad47SJeff Kirsher 
651dee1ad47SJeff Kirsher 	u32 flags2;
652a16a0d2fSAlexander Duyck #define IXGBE_FLAG2_RSC_CAPABLE                 (u32)(1 << 0)
653dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RSC_ENABLED                 (u32)(1 << 1)
654dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE         (u32)(1 << 2)
655dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_EVENT           (u32)(1 << 3)
656dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SEARCH_FOR_SFP              (u32)(1 << 4)
657dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SFP_NEEDS_RESET             (u32)(1 << 5)
658dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RESET_REQUESTED             (u32)(1 << 6)
659dee1ad47SJeff Kirsher #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT        (u32)(1 << 7)
660ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP		(u32)(1 << 8)
661ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP		(u32)(1 << 9)
6628fecf67cSJacob Keller #define IXGBE_FLAG2_PTP_PPS_ENABLED		(u32)(1 << 10)
663597f22d6SDon Skidmore #define IXGBE_FLAG2_PHY_INTERRUPT		(u32)(1 << 11)
66467359c3cSMark Rustad #define IXGBE_FLAG2_VXLAN_REREG_NEEDED		BIT(12)
66516369564SAlexander Duyck #define IXGBE_FLAG2_VLAN_PROMISC		BIT(13)
66646646e61SAlexander Duyck 
66746646e61SAlexander Duyck 	/* Tx fast path data */
66846646e61SAlexander Duyck 	int num_tx_queues;
66946646e61SAlexander Duyck 	u16 tx_itr_setting;
67046646e61SAlexander Duyck 	u16 tx_work_limit;
67146646e61SAlexander Duyck 
67246646e61SAlexander Duyck 	/* Rx fast path data */
67346646e61SAlexander Duyck 	int num_rx_queues;
67446646e61SAlexander Duyck 	u16 rx_itr_setting;
67546646e61SAlexander Duyck 
676*9f12df90SAlexander Duyck 	/* Port number used to identify VXLAN traffic */
677*9f12df90SAlexander Duyck 	__be16 vxlan_port;
678*9f12df90SAlexander Duyck 
67946646e61SAlexander Duyck 	/* TX */
68046646e61SAlexander Duyck 	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
68146646e61SAlexander Duyck 
68246646e61SAlexander Duyck 	u64 restart_queue;
68346646e61SAlexander Duyck 	u64 lsc_int;
68446646e61SAlexander Duyck 	u32 tx_timeout_count;
68546646e61SAlexander Duyck 
68646646e61SAlexander Duyck 	/* RX */
68746646e61SAlexander Duyck 	struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
68846646e61SAlexander Duyck 	int num_rx_pools;		/* == num_rx_queues in 82598 */
68946646e61SAlexander Duyck 	int num_rx_queues_per_pool;	/* 1 if 82598, can be many if 82599 */
69046646e61SAlexander Duyck 	u64 hw_csum_rx_error;
69146646e61SAlexander Duyck 	u64 hw_rx_no_dma_resources;
69246646e61SAlexander Duyck 	u64 rsc_total_count;
69346646e61SAlexander Duyck 	u64 rsc_total_flush;
69446646e61SAlexander Duyck 	u64 non_eop_descs;
69546646e61SAlexander Duyck 	u32 alloc_rx_page_failed;
69646646e61SAlexander Duyck 	u32 alloc_rx_buff_failed;
69746646e61SAlexander Duyck 
69849c7ffbeSAlexander Duyck 	struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
699dee1ad47SJeff Kirsher 
700dee1ad47SJeff Kirsher 	/* DCB parameters */
701dee1ad47SJeff Kirsher 	struct ieee_pfc *ixgbe_ieee_pfc;
702dee1ad47SJeff Kirsher 	struct ieee_ets *ixgbe_ieee_ets;
703dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config dcb_cfg;
704dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config temp_dcb_cfg;
705dee1ad47SJeff Kirsher 	u8 dcb_set_bitmap;
706dee1ad47SJeff Kirsher 	u8 dcbx_cap;
707dee1ad47SJeff Kirsher 	enum ixgbe_fc_mode last_lfc_mode;
708dee1ad47SJeff Kirsher 
70949c7ffbeSAlexander Duyck 	int num_q_vectors;	/* current number of q_vectors for device */
71049c7ffbeSAlexander Duyck 	int max_q_vectors;	/* true count of q_vectors for device */
711dee1ad47SJeff Kirsher 	struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
712dee1ad47SJeff Kirsher 	struct msix_entry *msix_entries;
713dee1ad47SJeff Kirsher 
714dee1ad47SJeff Kirsher 	u32 test_icr;
715dee1ad47SJeff Kirsher 	struct ixgbe_ring test_tx_ring;
716dee1ad47SJeff Kirsher 	struct ixgbe_ring test_rx_ring;
717dee1ad47SJeff Kirsher 
718dee1ad47SJeff Kirsher 	/* structs defined in ixgbe_hw.h */
719dee1ad47SJeff Kirsher 	struct ixgbe_hw hw;
720dee1ad47SJeff Kirsher 	u16 msg_enable;
721dee1ad47SJeff Kirsher 	struct ixgbe_hw_stats stats;
722dee1ad47SJeff Kirsher 
723dee1ad47SJeff Kirsher 	u64 tx_busy;
724dee1ad47SJeff Kirsher 	unsigned int tx_ring_count;
725dee1ad47SJeff Kirsher 	unsigned int rx_ring_count;
726dee1ad47SJeff Kirsher 
727dee1ad47SJeff Kirsher 	u32 link_speed;
728dee1ad47SJeff Kirsher 	bool link_up;
72958e7cd24SMark Rustad 	unsigned long sfp_poll_time;
730dee1ad47SJeff Kirsher 	unsigned long link_check_timeout;
731dee1ad47SJeff Kirsher 
732dee1ad47SJeff Kirsher 	struct timer_list service_timer;
73346646e61SAlexander Duyck 	struct work_struct service_task;
73446646e61SAlexander Duyck 
73546646e61SAlexander Duyck 	struct hlist_head fdir_filter_list;
73646646e61SAlexander Duyck 	unsigned long fdir_overflow; /* number of times ATR was backed off */
73746646e61SAlexander Duyck 	union ixgbe_atr_input fdir_mask;
73846646e61SAlexander Duyck 	int fdir_filter_count;
739dee1ad47SJeff Kirsher 	u32 fdir_pballoc;
740dee1ad47SJeff Kirsher 	u32 atr_sample_rate;
741dee1ad47SJeff Kirsher 	spinlock_t fdir_perfect_lock;
74246646e61SAlexander Duyck 
743dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
744dee1ad47SJeff Kirsher 	struct ixgbe_fcoe fcoe;
745dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
7462a1a091cSMark Rustad 	u8 __iomem *io_addr; /* Mainly for iounmap use */
747dee1ad47SJeff Kirsher 	u32 wol;
74846646e61SAlexander Duyck 
749aa2bacb6SDon Skidmore 	u16 bridge_mode;
750aa2bacb6SDon Skidmore 
75115e5209fSEmil Tantilov 	u16 eeprom_verh;
75215e5209fSEmil Tantilov 	u16 eeprom_verl;
753c23f5b6bSEmil Tantilov 	u16 eeprom_cap;
754dee1ad47SJeff Kirsher 
755dee1ad47SJeff Kirsher 	u32 interrupt_event;
75646646e61SAlexander Duyck 	u32 led_reg;
757dee1ad47SJeff Kirsher 
7583a6a4edaSJacob Keller 	struct ptp_clock *ptp_clock;
7593a6a4edaSJacob Keller 	struct ptp_clock_info ptp_caps;
760891dc082SJacob Keller 	struct work_struct ptp_tx_work;
761891dc082SJacob Keller 	struct sk_buff *ptp_tx_skb;
76293501d48SJacob Keller 	struct hwtstamp_config tstamp_config;
763891dc082SJacob Keller 	unsigned long ptp_tx_start;
7643a6a4edaSJacob Keller 	unsigned long last_overflow_check;
7656cb562d6SJacob Keller 	unsigned long last_rx_ptp_check;
766eda183c2SJakub Kicinski 	unsigned long last_rx_timestamp;
7673a6a4edaSJacob Keller 	spinlock_t tmreg_lock;
768a9763f3cSMark Rustad 	struct cyclecounter hw_cc;
769a9763f3cSMark Rustad 	struct timecounter hw_tc;
7703a6a4edaSJacob Keller 	u32 base_incval;
771a9763f3cSMark Rustad 	u32 tx_hwtstamp_timeouts;
772a9763f3cSMark Rustad 	u32 rx_hwtstamp_cleared;
773a9763f3cSMark Rustad 	void (*ptp_setup_sdp)(struct ixgbe_adapter *);
7743a6a4edaSJacob Keller 
775dee1ad47SJeff Kirsher 	/* SR-IOV */
776dee1ad47SJeff Kirsher 	DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
777dee1ad47SJeff Kirsher 	unsigned int num_vfs;
778dee1ad47SJeff Kirsher 	struct vf_data_storage *vfinfo;
779dee1ad47SJeff Kirsher 	int vf_rate_link_speed;
780dee1ad47SJeff Kirsher 	struct vf_macvlans vf_mvs;
781dee1ad47SJeff Kirsher 	struct vf_macvlans *mv_list;
782dee1ad47SJeff Kirsher 
78383c61fa9SGreg Rose 	u32 timer_event_accumulator;
78483c61fa9SGreg Rose 	u32 vferr_refcount;
7855d7daa35SJacob Keller 	struct ixgbe_mac_addr *mac_table;
7863ca8bc6dSDon Skidmore 	struct kobject *info_kobj;
7873ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
78803b77d81SGuenter Roeck 	struct hwmon_buff *ixgbe_hwmon_buff;
7893ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
79000949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
79100949167SCatherine Sullivan 	struct dentry *ixgbe_dbg_adapter;
79200949167SCatherine Sullivan #endif /*CONFIG_DEBUG_FS*/
793107d3018SAlexander Duyck 
794107d3018SAlexander Duyck 	u8 default_up;
7952a47fa45SJohn Fastabend 	unsigned long fwd_bitmask; /* Bitmask indicating in use pools */
796dfaf891dSVlad Zolotarov 
797b82b17d9SJohn Fastabend #define IXGBE_MAX_LINK_HANDLE 10
798b82b17d9SJohn Fastabend 	struct ixgbe_mat_field *jump_tables[IXGBE_MAX_LINK_HANDLE];
799db956ae8SJohn Fastabend 	unsigned long tables;
800b82b17d9SJohn Fastabend 
801dfaf891dSVlad Zolotarov /* maximum number of RETA entries among all devices supported by ixgbe
802dfaf891dSVlad Zolotarov  * driver: currently it's x550 device in non-SRIOV mode
803dfaf891dSVlad Zolotarov  */
804dfaf891dSVlad Zolotarov #define IXGBE_MAX_RETA_ENTRIES 512
805dfaf891dSVlad Zolotarov 	u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
806dfaf891dSVlad Zolotarov 
807dfaf891dSVlad Zolotarov #define IXGBE_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
808dfaf891dSVlad Zolotarov 	u32 rss_key[IXGBE_RSS_KEY_SIZE / sizeof(u32)];
809dee1ad47SJeff Kirsher };
810dee1ad47SJeff Kirsher 
8110f9b232bSDon Skidmore static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
8120f9b232bSDon Skidmore {
8130f9b232bSDon Skidmore 	switch (adapter->hw.mac.type) {
8140f9b232bSDon Skidmore 	case ixgbe_mac_82598EB:
8150f9b232bSDon Skidmore 	case ixgbe_mac_82599EB:
8160f9b232bSDon Skidmore 	case ixgbe_mac_X540:
8170f9b232bSDon Skidmore 		return IXGBE_MAX_RSS_INDICES;
8180f9b232bSDon Skidmore 	case ixgbe_mac_X550:
8190f9b232bSDon Skidmore 	case ixgbe_mac_X550EM_x:
8200f9b232bSDon Skidmore 		return IXGBE_MAX_RSS_INDICES_X550;
8210f9b232bSDon Skidmore 	default:
8220f9b232bSDon Skidmore 		return 0;
8230f9b232bSDon Skidmore 	}
8240f9b232bSDon Skidmore }
8250f9b232bSDon Skidmore 
826dee1ad47SJeff Kirsher struct ixgbe_fdir_filter {
827dee1ad47SJeff Kirsher 	struct hlist_node fdir_node;
828dee1ad47SJeff Kirsher 	union ixgbe_atr_input filter;
829dee1ad47SJeff Kirsher 	u16 sw_idx;
830dee1ad47SJeff Kirsher 	u16 action;
831dee1ad47SJeff Kirsher };
832dee1ad47SJeff Kirsher 
83370e5576cSDon Skidmore enum ixgbe_state_t {
834dee1ad47SJeff Kirsher 	__IXGBE_TESTING,
835dee1ad47SJeff Kirsher 	__IXGBE_RESETTING,
836dee1ad47SJeff Kirsher 	__IXGBE_DOWN,
83741c62843SMark Rustad 	__IXGBE_DISABLED,
83809f40aedSMark Rustad 	__IXGBE_REMOVING,
839dee1ad47SJeff Kirsher 	__IXGBE_SERVICE_SCHED,
84058cf663fSMark Rustad 	__IXGBE_SERVICE_INITED,
841dee1ad47SJeff Kirsher 	__IXGBE_IN_SFP_INIT,
8428fecf67cSJacob Keller 	__IXGBE_PTP_RUNNING,
843151b260cSJakub Kicinski 	__IXGBE_PTP_TX_IN_PROGRESS,
844dee1ad47SJeff Kirsher };
845dee1ad47SJeff Kirsher 
8464c1975d7SAlexander Duyck struct ixgbe_cb {
8474c1975d7SAlexander Duyck 	union {				/* Union defining head/tail partner */
8484c1975d7SAlexander Duyck 		struct sk_buff *head;
8494c1975d7SAlexander Duyck 		struct sk_buff *tail;
8504c1975d7SAlexander Duyck 	};
851dee1ad47SJeff Kirsher 	dma_addr_t dma;
8524c1975d7SAlexander Duyck 	u16 append_cnt;
853f800326dSAlexander Duyck 	bool page_released;
854dee1ad47SJeff Kirsher };
8554c1975d7SAlexander Duyck #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
856dee1ad47SJeff Kirsher 
857dee1ad47SJeff Kirsher enum ixgbe_boards {
858dee1ad47SJeff Kirsher 	board_82598,
859dee1ad47SJeff Kirsher 	board_82599,
860dee1ad47SJeff Kirsher 	board_X540,
8616a14ee0cSDon Skidmore 	board_X550,
8626a14ee0cSDon Skidmore 	board_X550EM_x,
863dee1ad47SJeff Kirsher };
864dee1ad47SJeff Kirsher 
865dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82598_info;
866dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82599_info;
867dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_X540_info;
8686a14ee0cSDon Skidmore extern struct ixgbe_info ixgbe_X550_info;
8696a14ee0cSDon Skidmore extern struct ixgbe_info ixgbe_X550EM_x_info;
870dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
871dee1ad47SJeff Kirsher extern const struct dcbnl_rtnl_ops dcbnl_ops;
872dee1ad47SJeff Kirsher #endif
873dee1ad47SJeff Kirsher 
874dee1ad47SJeff Kirsher extern char ixgbe_driver_name[];
875dee1ad47SJeff Kirsher extern const char ixgbe_driver_version[];
8768af3c33fSJeff Kirsher #ifdef IXGBE_FCOE
877ea81875aSNeerav Parikh extern char ixgbe_default_device_descr[];
8788af3c33fSJeff Kirsher #endif /* IXGBE_FCOE */
879dee1ad47SJeff Kirsher 
8805ccc921aSJoe Perches void ixgbe_up(struct ixgbe_adapter *adapter);
8815ccc921aSJoe Perches void ixgbe_down(struct ixgbe_adapter *adapter);
8825ccc921aSJoe Perches void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
8835ccc921aSJoe Perches void ixgbe_reset(struct ixgbe_adapter *adapter);
8845ccc921aSJoe Perches void ixgbe_set_ethtool_ops(struct net_device *netdev);
8855ccc921aSJoe Perches int ixgbe_setup_rx_resources(struct ixgbe_ring *);
8865ccc921aSJoe Perches int ixgbe_setup_tx_resources(struct ixgbe_ring *);
8875ccc921aSJoe Perches void ixgbe_free_rx_resources(struct ixgbe_ring *);
8885ccc921aSJoe Perches void ixgbe_free_tx_resources(struct ixgbe_ring *);
8895ccc921aSJoe Perches void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
8905ccc921aSJoe Perches void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
8915ccc921aSJoe Perches void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_ring *);
8925ccc921aSJoe Perches void ixgbe_update_stats(struct ixgbe_adapter *adapter);
8935ccc921aSJoe Perches int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
8945ccc921aSJoe Perches int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
8958e2813f5SJacob Keller 			       u16 subdevice_id);
8965d7daa35SJacob Keller #ifdef CONFIG_PCI_IOV
8975d7daa35SJacob Keller void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter);
8985d7daa35SJacob Keller #endif
8995d7daa35SJacob Keller int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter,
900c9f53e63SAlexander Duyck 			 const u8 *addr, u16 queue);
9015d7daa35SJacob Keller int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter,
902c9f53e63SAlexander Duyck 			 const u8 *addr, u16 queue);
903e1d0a2afSAlexander Duyck void ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid);
9045ccc921aSJoe Perches void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
9055ccc921aSJoe Perches netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *,
906dee1ad47SJeff Kirsher 				  struct ixgbe_ring *);
9075ccc921aSJoe Perches void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *,
908dee1ad47SJeff Kirsher 				      struct ixgbe_tx_buffer *);
9095ccc921aSJoe Perches void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
9105ccc921aSJoe Perches void ixgbe_write_eitr(struct ixgbe_q_vector *);
9115ccc921aSJoe Perches int ixgbe_poll(struct napi_struct *napi, int budget);
9125ccc921aSJoe Perches int ethtool_ioctl(struct ifreq *ifr);
9135ccc921aSJoe Perches s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
9145ccc921aSJoe Perches s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
9155ccc921aSJoe Perches s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
9165ccc921aSJoe Perches s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
917dee1ad47SJeff Kirsher 					  union ixgbe_atr_hash_dword input,
918dee1ad47SJeff Kirsher 					  union ixgbe_atr_hash_dword common,
919dee1ad47SJeff Kirsher 					  u8 queue);
9205ccc921aSJoe Perches s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
921dee1ad47SJeff Kirsher 				    union ixgbe_atr_input *input_mask);
9225ccc921aSJoe Perches s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
923dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *input,
924dee1ad47SJeff Kirsher 					  u16 soft_id, u8 queue);
9255ccc921aSJoe Perches s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
926dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *input,
927dee1ad47SJeff Kirsher 					  u16 soft_id);
9285ccc921aSJoe Perches void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
929dee1ad47SJeff Kirsher 					  union ixgbe_atr_input *mask);
930b82b17d9SJohn Fastabend int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
931b82b17d9SJohn Fastabend 				    struct ixgbe_fdir_filter *input,
932b82b17d9SJohn Fastabend 				    u16 sw_idx);
9335ccc921aSJoe Perches void ixgbe_set_rx_mode(struct net_device *netdev);
9348af3c33fSJeff Kirsher #ifdef CONFIG_IXGBE_DCB
9355ccc921aSJoe Perches void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
9368af3c33fSJeff Kirsher #endif
9375ccc921aSJoe Perches int ixgbe_setup_tc(struct net_device *dev, u8 tc);
9385ccc921aSJoe Perches void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
9395ccc921aSJoe Perches void ixgbe_do_reset(struct net_device *netdev);
9401210982bSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
9415ccc921aSJoe Perches void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
9425ccc921aSJoe Perches int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
9431210982bSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
944dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
9455ccc921aSJoe Perches void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
9465ccc921aSJoe Perches int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
947244e27adSAlexander Duyck 	      u8 *hdr_len);
9485ccc921aSJoe Perches int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
9495ccc921aSJoe Perches 		   union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb);
9505ccc921aSJoe Perches int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
951dee1ad47SJeff Kirsher 		       struct scatterlist *sgl, unsigned int sgc);
9525ccc921aSJoe Perches int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
953dee1ad47SJeff Kirsher 			  struct scatterlist *sgl, unsigned int sgc);
9545ccc921aSJoe Perches int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
9555ccc921aSJoe Perches int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
9565ccc921aSJoe Perches void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
9575ccc921aSJoe Perches int ixgbe_fcoe_enable(struct net_device *netdev);
9585ccc921aSJoe Perches int ixgbe_fcoe_disable(struct net_device *netdev);
959dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
9605ccc921aSJoe Perches u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter);
9615ccc921aSJoe Perches u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);
962dee1ad47SJeff Kirsher #endif /* CONFIG_IXGBE_DCB */
9635ccc921aSJoe Perches int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
9645ccc921aSJoe Perches int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
965ea81875aSNeerav Parikh 			   struct netdev_fcoe_hbainfo *info);
9665ccc921aSJoe Perches u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
967dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
96800949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
9695ccc921aSJoe Perches void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
9705ccc921aSJoe Perches void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
9715ccc921aSJoe Perches void ixgbe_dbg_init(void);
9725ccc921aSJoe Perches void ixgbe_dbg_exit(void);
97333243fb0SJoe Perches #else
97433243fb0SJoe Perches static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}
97533243fb0SJoe Perches static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {}
97633243fb0SJoe Perches static inline void ixgbe_dbg_init(void) {}
97733243fb0SJoe Perches static inline void ixgbe_dbg_exit(void) {}
97800949167SCatherine Sullivan #endif /* CONFIG_DEBUG_FS */
979b2d96e0aSAlexander Duyck static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
980b2d96e0aSAlexander Duyck {
981b2d96e0aSAlexander Duyck 	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
982b2d96e0aSAlexander Duyck }
983b2d96e0aSAlexander Duyck 
9845ccc921aSJoe Perches void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
9859966d1eeSJacob Keller void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
9865ccc921aSJoe Perches void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
9875ccc921aSJoe Perches void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
9885ccc921aSJoe Perches void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
989a9763f3cSMark Rustad void ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *);
990a9763f3cSMark Rustad void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb);
991a9763f3cSMark Rustad static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
992a9763f3cSMark Rustad 					 union ixgbe_adv_rx_desc *rx_desc,
993a9763f3cSMark Rustad 					 struct sk_buff *skb)
994a9763f3cSMark Rustad {
995a9763f3cSMark Rustad 	if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) {
996a9763f3cSMark Rustad 		ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb);
997a9763f3cSMark Rustad 		return;
998a9763f3cSMark Rustad 	}
999a9763f3cSMark Rustad 
1000a9763f3cSMark Rustad 	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
1001a9763f3cSMark Rustad 		return;
1002a9763f3cSMark Rustad 
1003a9763f3cSMark Rustad 	ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
1004a9763f3cSMark Rustad 
1005a9763f3cSMark Rustad 	/* Update the last_rx_timestamp timer in order to enable watchdog check
1006a9763f3cSMark Rustad 	 * for error case of latched timestamp on a dropped packet.
1007a9763f3cSMark Rustad 	 */
1008a9763f3cSMark Rustad 	rx_ring->last_rx_timestamp = jiffies;
1009a9763f3cSMark Rustad }
1010a9763f3cSMark Rustad 
101193501d48SJacob Keller int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
101293501d48SJacob Keller int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
10135ccc921aSJoe Perches void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
10145ccc921aSJoe Perches void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
1015a9763f3cSMark Rustad void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter);
1016da36b647SGreg Rose #ifdef CONFIG_PCI_IOV
1017da36b647SGreg Rose void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
1018da36b647SGreg Rose #endif
10193a6a4edaSJacob Keller 
10202a47fa45SJohn Fastabend netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
10212a47fa45SJohn Fastabend 				  struct ixgbe_adapter *adapter,
10222a47fa45SJohn Fastabend 				  struct ixgbe_ring *tx_ring);
10237f276efbSVlad Zolotarov u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
10241c7cf078STom Barbette void ixgbe_store_reta(struct ixgbe_adapter *adapter);
1025dee1ad47SJeff Kirsher #endif /* _IXGBE_H_ */
1026