xref: /openbmc/linux/drivers/net/ethernet/intel/ixgbe/ixgbe.h (revision 49c7ffbe7b9eee0dbbce09d9afbfdbec98324438)
1dee1ad47SJeff Kirsher /*******************************************************************************
2dee1ad47SJeff Kirsher 
3dee1ad47SJeff Kirsher   Intel 10 Gigabit PCI Express Linux driver
494971820SDon Skidmore   Copyright(c) 1999 - 2012 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:
23dee1ad47SJeff Kirsher   e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24dee1ad47SJeff Kirsher   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25dee1ad47SJeff Kirsher 
26dee1ad47SJeff Kirsher *******************************************************************************/
27dee1ad47SJeff Kirsher 
28dee1ad47SJeff Kirsher #ifndef _IXGBE_H_
29dee1ad47SJeff Kirsher #define _IXGBE_H_
30dee1ad47SJeff Kirsher 
31dee1ad47SJeff Kirsher #include <linux/bitops.h>
32dee1ad47SJeff Kirsher #include <linux/types.h>
33dee1ad47SJeff Kirsher #include <linux/pci.h>
34dee1ad47SJeff Kirsher #include <linux/netdevice.h>
35dee1ad47SJeff Kirsher #include <linux/cpumask.h>
36dee1ad47SJeff Kirsher #include <linux/aer.h>
37dee1ad47SJeff Kirsher #include <linux/if_vlan.h>
38dee1ad47SJeff Kirsher 
393a6a4edaSJacob Keller #ifdef CONFIG_IXGBE_PTP
403a6a4edaSJacob Keller #include <linux/clocksource.h>
413a6a4edaSJacob Keller #include <linux/net_tstamp.h>
423a6a4edaSJacob Keller #include <linux/ptp_clock_kernel.h>
433a6a4edaSJacob Keller #endif /* CONFIG_IXGBE_PTP */
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 
56dee1ad47SJeff Kirsher /* common prefix used by pr_<> macros */
57dee1ad47SJeff Kirsher #undef pr_fmt
58dee1ad47SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
59dee1ad47SJeff Kirsher 
60dee1ad47SJeff Kirsher /* TX/RX descriptor defines */
61dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_TXD		    512
6259224555SAlexander Duyck #define IXGBE_DEFAULT_TX_WORK		    256
63dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD			   4096
64dee1ad47SJeff Kirsher #define IXGBE_MIN_TXD			     64
65dee1ad47SJeff Kirsher 
66dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_RXD		    512
67dee1ad47SJeff Kirsher #define IXGBE_MAX_RXD			   4096
68dee1ad47SJeff Kirsher #define IXGBE_MIN_RXD			     64
69dee1ad47SJeff Kirsher 
70dee1ad47SJeff Kirsher /* flow control */
71dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTL			   0x40
72dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTL			0x7FF80
73dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTH			  0x600
74dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTH			0x7FFF0
75dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_FCPAUSE		 0xFFFF
76dee1ad47SJeff Kirsher #define IXGBE_MIN_FCPAUSE		      0
77dee1ad47SJeff Kirsher #define IXGBE_MAX_FCPAUSE		 0xFFFF
78dee1ad47SJeff Kirsher 
79dee1ad47SJeff Kirsher /* Supported Rx Buffer Sizes */
80dee1ad47SJeff Kirsher #define IXGBE_RXBUFFER_512   512    /* Used for packet split */
81dee1ad47SJeff Kirsher #define IXGBE_MAX_RXBUFFER  16384  /* largest size for a single descriptor */
82dee1ad47SJeff Kirsher 
83dee1ad47SJeff Kirsher /*
84dee1ad47SJeff Kirsher  * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN mans we
85dee1ad47SJeff Kirsher  * reserve 2 more, and skb_shared_info adds an additional 384 bytes more,
86dee1ad47SJeff Kirsher  * this adds up to 512 bytes of extra data meaning the smallest allocation
87dee1ad47SJeff Kirsher  * we could have is 1K.
88dee1ad47SJeff Kirsher  * i.e. RXBUFFER_512 --> size-1024 slab
89dee1ad47SJeff Kirsher  */
90dee1ad47SJeff Kirsher #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_512
91dee1ad47SJeff Kirsher 
92dee1ad47SJeff Kirsher #define MAXIMUM_ETHERNET_VLAN_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN)
93dee1ad47SJeff Kirsher 
94dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */
95dee1ad47SJeff Kirsher #define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */
96dee1ad47SJeff Kirsher 
97dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_CSUM		(u32)(1)
9866f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_HW_VLAN		(u32)(1 << 1)
9966f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_SW_VLAN		(u32)(1 << 2)
10066f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_TSO		(u32)(1 << 3)
10166f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_IPV4		(u32)(1 << 4)
10266f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_FCOE		(u32)(1 << 5)
10366f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_FSO		(u32)(1 << 6)
1047f9643fdSAlexander Duyck #define IXGBE_TX_FLAGS_TXSW		(u32)(1 << 7)
1053a6a4edaSJacob Keller #define IXGBE_TX_FLAGS_TSTAMP		(u32)(1 << 8)
106dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000
10766f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000
10866f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT  29
109dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_SHIFT	16
110dee1ad47SJeff Kirsher 
111dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_MC_ENTRIES         30
112dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_FUNCTIONS          64
113dee1ad47SJeff Kirsher #define IXGBE_MAX_VFTA_ENTRIES          128
114dee1ad47SJeff Kirsher #define MAX_EMULATION_MAC_ADDRS         16
115dee1ad47SJeff Kirsher #define IXGBE_MAX_PF_MACVLANS           15
116dee1ad47SJeff Kirsher #define VMDQ_P(p)   ((p) + adapter->num_vfs)
11783c61fa9SGreg Rose #define IXGBE_82599_VF_DEVICE_ID        0x10ED
11883c61fa9SGreg Rose #define IXGBE_X540_VF_DEVICE_ID         0x1515
119dee1ad47SJeff Kirsher 
120dee1ad47SJeff Kirsher struct vf_data_storage {
121dee1ad47SJeff Kirsher 	unsigned char vf_mac_addresses[ETH_ALEN];
122dee1ad47SJeff Kirsher 	u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
123dee1ad47SJeff Kirsher 	u16 num_vf_mc_hashes;
124dee1ad47SJeff Kirsher 	u16 default_vf_vlan_id;
125dee1ad47SJeff Kirsher 	u16 vlans_enabled;
126dee1ad47SJeff Kirsher 	bool clear_to_send;
127dee1ad47SJeff Kirsher 	bool pf_set_mac;
128dee1ad47SJeff Kirsher 	u16 pf_vlan; /* When set, guest VLAN config not allowed. */
129dee1ad47SJeff Kirsher 	u16 pf_qos;
130dee1ad47SJeff Kirsher 	u16 tx_rate;
131de4c7f65SGreg Rose 	u16 vlan_count;
132de4c7f65SGreg Rose 	u8 spoofchk_enabled;
133c6bda30aSGreg Rose 	struct pci_dev *vfdev;
134dee1ad47SJeff Kirsher };
135dee1ad47SJeff Kirsher 
136dee1ad47SJeff Kirsher struct vf_macvlans {
137dee1ad47SJeff Kirsher 	struct list_head l;
138dee1ad47SJeff Kirsher 	int vf;
139dee1ad47SJeff Kirsher 	int rar_entry;
140dee1ad47SJeff Kirsher 	bool free;
141dee1ad47SJeff Kirsher 	bool is_macvlan;
142dee1ad47SJeff Kirsher 	u8 vf_macvlan[ETH_ALEN];
143dee1ad47SJeff Kirsher };
144dee1ad47SJeff Kirsher 
145dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD_PWR	14
146dee1ad47SJeff Kirsher #define IXGBE_MAX_DATA_PER_TXD	(1 << IXGBE_MAX_TXD_PWR)
147dee1ad47SJeff Kirsher 
148dee1ad47SJeff Kirsher /* Tx Descriptors needed, worst case */
149dee1ad47SJeff Kirsher #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
150dee1ad47SJeff Kirsher #define DESC_NEEDED ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4)
151dee1ad47SJeff Kirsher 
152dee1ad47SJeff Kirsher /* wrapper around a pointer to a socket buffer,
153dee1ad47SJeff Kirsher  * so a DMA handle can be stored along with the buffer */
154dee1ad47SJeff Kirsher struct ixgbe_tx_buffer {
155d3d00239SAlexander Duyck 	union ixgbe_adv_tx_desc *next_to_watch;
156dee1ad47SJeff Kirsher 	unsigned long time_stamp;
157d3d00239SAlexander Duyck 	struct sk_buff *skb;
158fd0db0edSAlexander Duyck 	unsigned int bytecount;
159fd0db0edSAlexander Duyck 	unsigned short gso_segs;
160244e27adSAlexander Duyck 	__be16 protocol;
161729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_ADDR(dma);
162729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_LEN(len);
163fd0db0edSAlexander Duyck 	u32 tx_flags;
164dee1ad47SJeff Kirsher };
165dee1ad47SJeff Kirsher 
166dee1ad47SJeff Kirsher struct ixgbe_rx_buffer {
167dee1ad47SJeff Kirsher 	struct sk_buff *skb;
168dee1ad47SJeff Kirsher 	dma_addr_t dma;
169dee1ad47SJeff Kirsher 	struct page *page;
170dee1ad47SJeff Kirsher 	unsigned int page_offset;
171dee1ad47SJeff Kirsher };
172dee1ad47SJeff Kirsher 
173dee1ad47SJeff Kirsher struct ixgbe_queue_stats {
174dee1ad47SJeff Kirsher 	u64 packets;
175dee1ad47SJeff Kirsher 	u64 bytes;
176dee1ad47SJeff Kirsher };
177dee1ad47SJeff Kirsher 
178dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats {
179dee1ad47SJeff Kirsher 	u64 restart_queue;
180dee1ad47SJeff Kirsher 	u64 tx_busy;
181dee1ad47SJeff Kirsher 	u64 tx_done_old;
182dee1ad47SJeff Kirsher };
183dee1ad47SJeff Kirsher 
184dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats {
185dee1ad47SJeff Kirsher 	u64 rsc_count;
186dee1ad47SJeff Kirsher 	u64 rsc_flush;
187dee1ad47SJeff Kirsher 	u64 non_eop_descs;
188dee1ad47SJeff Kirsher 	u64 alloc_rx_page_failed;
189dee1ad47SJeff Kirsher 	u64 alloc_rx_buff_failed;
1908a0da21bSAlexander Duyck 	u64 csum_err;
191dee1ad47SJeff Kirsher };
192dee1ad47SJeff Kirsher 
193f800326dSAlexander Duyck enum ixgbe_ring_state_t {
194dee1ad47SJeff Kirsher 	__IXGBE_TX_FDIR_INIT_DONE,
195dee1ad47SJeff Kirsher 	__IXGBE_TX_DETECT_HANG,
196dee1ad47SJeff Kirsher 	__IXGBE_HANG_CHECK_ARMED,
197dee1ad47SJeff Kirsher 	__IXGBE_RX_RSC_ENABLED,
1988a0da21bSAlexander Duyck 	__IXGBE_RX_CSUM_UDP_ZERO_ERR,
19957efd44cSAlexander Duyck 	__IXGBE_RX_FCOE,
200dee1ad47SJeff Kirsher };
201dee1ad47SJeff Kirsher 
202dee1ad47SJeff Kirsher #define check_for_tx_hang(ring) \
203dee1ad47SJeff Kirsher 	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
204dee1ad47SJeff Kirsher #define set_check_for_tx_hang(ring) \
205dee1ad47SJeff Kirsher 	set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
206dee1ad47SJeff Kirsher #define clear_check_for_tx_hang(ring) \
207dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
208dee1ad47SJeff Kirsher #define ring_is_rsc_enabled(ring) \
209dee1ad47SJeff Kirsher 	test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
210dee1ad47SJeff Kirsher #define set_ring_rsc_enabled(ring) \
211dee1ad47SJeff Kirsher 	set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
212dee1ad47SJeff Kirsher #define clear_ring_rsc_enabled(ring) \
213dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
214dee1ad47SJeff Kirsher struct ixgbe_ring {
215efe3d3c8SAlexander Duyck 	struct ixgbe_ring *next;	/* pointer to next ring in q_vector */
216d3ee4294SAlexander Duyck 	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
217dee1ad47SJeff Kirsher 	struct net_device *netdev;	/* netdev ring belongs to */
218d3ee4294SAlexander Duyck 	struct device *dev;		/* device for DMA mapping */
219d3ee4294SAlexander Duyck 	void *desc;			/* descriptor ring memory */
220dee1ad47SJeff Kirsher 	union {
221dee1ad47SJeff Kirsher 		struct ixgbe_tx_buffer *tx_buffer_info;
222dee1ad47SJeff Kirsher 		struct ixgbe_rx_buffer *rx_buffer_info;
223dee1ad47SJeff Kirsher 	};
224dee1ad47SJeff Kirsher 	unsigned long state;
225dee1ad47SJeff Kirsher 	u8 __iomem *tail;
226d3ee4294SAlexander Duyck 	dma_addr_t dma;			/* phys. address of descriptor ring */
227d3ee4294SAlexander Duyck 	unsigned int size;		/* length in bytes */
228dee1ad47SJeff Kirsher 
229dee1ad47SJeff Kirsher 	u16 count;			/* amount of descriptors */
230dee1ad47SJeff Kirsher 
231dee1ad47SJeff Kirsher 	u8 queue_index; /* needed for multiqueue queue management */
232dee1ad47SJeff Kirsher 	u8 reg_idx;			/* holds the special value that gets
233dee1ad47SJeff Kirsher 					 * the hardware register offset
234dee1ad47SJeff Kirsher 					 * associated with this ring, which is
235dee1ad47SJeff Kirsher 					 * different for DCB and RSS modes
236dee1ad47SJeff Kirsher 					 */
237d3ee4294SAlexander Duyck 	u16 next_to_use;
238d3ee4294SAlexander Duyck 	u16 next_to_clean;
239d3ee4294SAlexander Duyck 
240f800326dSAlexander Duyck 	union {
241d3ee4294SAlexander Duyck 		u16 next_to_alloc;
242f800326dSAlexander Duyck 		struct {
243dee1ad47SJeff Kirsher 			u8 atr_sample_rate;
244dee1ad47SJeff Kirsher 			u8 atr_count;
245f800326dSAlexander Duyck 		};
246f800326dSAlexander Duyck 	};
247dee1ad47SJeff Kirsher 
248dee1ad47SJeff Kirsher 	u8 dcb_tc;
249dee1ad47SJeff Kirsher 	struct ixgbe_queue_stats stats;
250dee1ad47SJeff Kirsher 	struct u64_stats_sync syncp;
251dee1ad47SJeff Kirsher 	union {
252dee1ad47SJeff Kirsher 		struct ixgbe_tx_queue_stats tx_stats;
253dee1ad47SJeff Kirsher 		struct ixgbe_rx_queue_stats rx_stats;
254dee1ad47SJeff Kirsher 	};
255dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
256dee1ad47SJeff Kirsher 
257dee1ad47SJeff Kirsher enum ixgbe_ring_f_enum {
258dee1ad47SJeff Kirsher 	RING_F_NONE = 0,
259dee1ad47SJeff Kirsher 	RING_F_VMDQ,  /* SR-IOV uses the same ring feature */
260dee1ad47SJeff Kirsher 	RING_F_RSS,
261dee1ad47SJeff Kirsher 	RING_F_FDIR,
262dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
263dee1ad47SJeff Kirsher 	RING_F_FCOE,
264dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
265dee1ad47SJeff Kirsher 
266dee1ad47SJeff Kirsher 	RING_F_ARRAY_SIZE      /* must be last in enum set */
267dee1ad47SJeff Kirsher };
268dee1ad47SJeff Kirsher 
269dee1ad47SJeff Kirsher #define IXGBE_MAX_RSS_INDICES  16
270dee1ad47SJeff Kirsher #define IXGBE_MAX_VMDQ_INDICES 64
271dee1ad47SJeff Kirsher #define IXGBE_MAX_FDIR_INDICES 64
272dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
273dee1ad47SJeff Kirsher #define IXGBE_MAX_FCOE_INDICES  8
274dee1ad47SJeff Kirsher #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
275dee1ad47SJeff Kirsher #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES)
276dee1ad47SJeff Kirsher #else
277dee1ad47SJeff Kirsher #define MAX_RX_QUEUES IXGBE_MAX_FDIR_INDICES
278dee1ad47SJeff Kirsher #define MAX_TX_QUEUES IXGBE_MAX_FDIR_INDICES
279dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
280dee1ad47SJeff Kirsher struct ixgbe_ring_feature {
281dee1ad47SJeff Kirsher 	int indices;
282dee1ad47SJeff Kirsher 	int mask;
283dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
284dee1ad47SJeff Kirsher 
285f800326dSAlexander Duyck /*
286f800326dSAlexander Duyck  * FCoE requires that all Rx buffers be over 2200 bytes in length.  Since
287f800326dSAlexander Duyck  * this is twice the size of a half page we need to double the page order
288f800326dSAlexander Duyck  * for FCoE enabled Rx queues.
289f800326dSAlexander Duyck  */
290f800326dSAlexander Duyck #if defined(IXGBE_FCOE) && (PAGE_SIZE < 8192)
291f800326dSAlexander Duyck static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
292f800326dSAlexander Duyck {
29357efd44cSAlexander Duyck 	return test_bit(__IXGBE_RX_FCOE, &ring->state) ? 1 : 0;
294f800326dSAlexander Duyck }
295f800326dSAlexander Duyck #else
296f800326dSAlexander Duyck #define ixgbe_rx_pg_order(_ring) 0
297f800326dSAlexander Duyck #endif
298f800326dSAlexander Duyck #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
299f800326dSAlexander Duyck #define ixgbe_rx_bufsz(_ring) ((PAGE_SIZE / 2) << ixgbe_rx_pg_order(_ring))
300f800326dSAlexander Duyck 
301dee1ad47SJeff Kirsher struct ixgbe_ring_container {
302efe3d3c8SAlexander Duyck 	struct ixgbe_ring *ring;	/* pointer to linked list of rings */
303dee1ad47SJeff Kirsher 	unsigned int total_bytes;	/* total bytes processed this int */
304dee1ad47SJeff Kirsher 	unsigned int total_packets;	/* total packets processed this int */
305dee1ad47SJeff Kirsher 	u16 work_limit;			/* total work allowed per interrupt */
306dee1ad47SJeff Kirsher 	u8 count;			/* total number of rings in vector */
307dee1ad47SJeff Kirsher 	u8 itr;				/* current ITR setting for ring */
308dee1ad47SJeff Kirsher };
309dee1ad47SJeff Kirsher 
310a557928eSAlexander Duyck /* iterator for handling rings in ring container */
311a557928eSAlexander Duyck #define ixgbe_for_each_ring(pos, head) \
312a557928eSAlexander Duyck 	for (pos = (head).ring; pos != NULL; pos = pos->next)
313a557928eSAlexander Duyck 
314dee1ad47SJeff Kirsher #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
315dee1ad47SJeff Kirsher                               ? 8 : 1)
316dee1ad47SJeff Kirsher #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
317dee1ad47SJeff Kirsher 
318*49c7ffbeSAlexander Duyck /* MAX_Q_VECTORS of these are allocated,
319dee1ad47SJeff Kirsher  * but we only use one per queue-specific vector.
320dee1ad47SJeff Kirsher  */
321dee1ad47SJeff Kirsher struct ixgbe_q_vector {
322dee1ad47SJeff Kirsher 	struct ixgbe_adapter *adapter;
323dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
324dee1ad47SJeff Kirsher 	int cpu;	    /* CPU for DCA */
325dee1ad47SJeff Kirsher #endif
326d5bf4f67SEmil Tantilov 	u16 v_idx;		/* index of q_vector within array, also used for
327d5bf4f67SEmil Tantilov 				 * finding the bit in EICR and friends that
328d5bf4f67SEmil Tantilov 				 * represents the vector for this ring */
329d5bf4f67SEmil Tantilov 	u16 itr;		/* Interrupt throttle rate written to EITR */
330dee1ad47SJeff Kirsher 	struct ixgbe_ring_container rx, tx;
331d5bf4f67SEmil Tantilov 
332d5bf4f67SEmil Tantilov 	struct napi_struct napi;
333de88eeebSAlexander Duyck 	cpumask_t affinity_mask;
334de88eeebSAlexander Duyck 	int numa_node;
335de88eeebSAlexander Duyck 	struct rcu_head rcu;	/* to avoid race with update stats on free */
336dee1ad47SJeff Kirsher 	char name[IFNAMSIZ + 9];
337de88eeebSAlexander Duyck 
338de88eeebSAlexander Duyck 	/* for dynamic allocation of rings associated with this q_vector */
339de88eeebSAlexander Duyck 	struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp;
340dee1ad47SJeff Kirsher };
3413ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
3423ca8bc6dSDon Skidmore 
3433ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_LOC		0
3443ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_TEMP		1
3453ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_CAUTION	2
3463ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_MAX		3
3473ca8bc6dSDon Skidmore 
3483ca8bc6dSDon Skidmore struct hwmon_attr {
3493ca8bc6dSDon Skidmore 	struct device_attribute dev_attr;
3503ca8bc6dSDon Skidmore 	struct ixgbe_hw *hw;
3513ca8bc6dSDon Skidmore 	struct ixgbe_thermal_diode_data *sensor;
3523ca8bc6dSDon Skidmore 	char name[12];
3533ca8bc6dSDon Skidmore };
3543ca8bc6dSDon Skidmore 
3553ca8bc6dSDon Skidmore struct hwmon_buff {
3563ca8bc6dSDon Skidmore 	struct device *device;
3573ca8bc6dSDon Skidmore 	struct hwmon_attr *hwmon_list;
3583ca8bc6dSDon Skidmore 	unsigned int n_hwmon;
3593ca8bc6dSDon Skidmore };
3603ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
361dee1ad47SJeff Kirsher 
362d5bf4f67SEmil Tantilov /*
363d5bf4f67SEmil Tantilov  * microsecond values for various ITR rates shifted by 2 to fit itr register
364d5bf4f67SEmil Tantilov  * with the first 3 bits reserved 0
365dee1ad47SJeff Kirsher  */
366d5bf4f67SEmil Tantilov #define IXGBE_MIN_RSC_ITR	24
367d5bf4f67SEmil Tantilov #define IXGBE_100K_ITR		40
368d5bf4f67SEmil Tantilov #define IXGBE_20K_ITR		200
369d5bf4f67SEmil Tantilov #define IXGBE_10K_ITR		400
370d5bf4f67SEmil Tantilov #define IXGBE_8K_ITR		500
371dee1ad47SJeff Kirsher 
372f56e0cb1SAlexander Duyck /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
373f56e0cb1SAlexander Duyck static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
374f56e0cb1SAlexander Duyck 					const u32 stat_err_bits)
375f56e0cb1SAlexander Duyck {
376f56e0cb1SAlexander Duyck 	return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
377f56e0cb1SAlexander Duyck }
378f56e0cb1SAlexander Duyck 
379dee1ad47SJeff Kirsher static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
380dee1ad47SJeff Kirsher {
381dee1ad47SJeff Kirsher 	u16 ntc = ring->next_to_clean;
382dee1ad47SJeff Kirsher 	u16 ntu = ring->next_to_use;
383dee1ad47SJeff Kirsher 
384dee1ad47SJeff Kirsher 	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
385dee1ad47SJeff Kirsher }
386dee1ad47SJeff Kirsher 
387e4f74028SAlexander Duyck #define IXGBE_RX_DESC(R, i)	    \
388dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
389e4f74028SAlexander Duyck #define IXGBE_TX_DESC(R, i)	    \
390dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
391e4f74028SAlexander Duyck #define IXGBE_TX_CTXTDESC(R, i)	    \
392dee1ad47SJeff Kirsher 	(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
393dee1ad47SJeff Kirsher 
394dee1ad47SJeff Kirsher #define IXGBE_MAX_JUMBO_FRAME_SIZE        16128
395dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
396dee1ad47SJeff Kirsher /* Use 3K as the baby jumbo frame size for FCoE */
397dee1ad47SJeff Kirsher #define IXGBE_FCOE_JUMBO_FRAME_SIZE       3072
398dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
399dee1ad47SJeff Kirsher 
400dee1ad47SJeff Kirsher #define OTHER_VECTOR 1
401dee1ad47SJeff Kirsher #define NON_Q_VECTORS (OTHER_VECTOR)
402dee1ad47SJeff Kirsher 
403dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82599 64
404*49c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82599 64
405dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82598 18
406*49c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82598 16
407dee1ad47SJeff Kirsher 
408*49c7ffbeSAlexander Duyck #define MAX_Q_VECTORS MAX_Q_VECTORS_82599
409dee1ad47SJeff Kirsher #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
410dee1ad47SJeff Kirsher 
4118f15486dSAlexander Duyck #define MIN_MSIX_Q_VECTORS 1
412dee1ad47SJeff Kirsher #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
413dee1ad47SJeff Kirsher 
41446646e61SAlexander Duyck /* default to trying for four seconds */
41546646e61SAlexander Duyck #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
41646646e61SAlexander Duyck 
417dee1ad47SJeff Kirsher /* board specific private data structure */
418dee1ad47SJeff Kirsher struct ixgbe_adapter {
41946646e61SAlexander Duyck 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
42046646e61SAlexander Duyck 	/* OS defined structs */
42146646e61SAlexander Duyck 	struct net_device *netdev;
42246646e61SAlexander Duyck 	struct pci_dev *pdev;
42346646e61SAlexander Duyck 
424dee1ad47SJeff Kirsher 	unsigned long state;
425dee1ad47SJeff Kirsher 
426dee1ad47SJeff Kirsher 	/* Some features need tri-state capability,
427dee1ad47SJeff Kirsher 	 * thus the additional *_CAPABLE flags.
428dee1ad47SJeff Kirsher 	 */
429dee1ad47SJeff Kirsher 	u32 flags;
430dee1ad47SJeff Kirsher #define IXGBE_FLAG_MSI_CAPABLE                  (u32)(1 << 1)
431dee1ad47SJeff Kirsher #define IXGBE_FLAG_MSI_ENABLED                  (u32)(1 << 2)
432dee1ad47SJeff Kirsher #define IXGBE_FLAG_MSIX_CAPABLE                 (u32)(1 << 3)
433dee1ad47SJeff Kirsher #define IXGBE_FLAG_MSIX_ENABLED                 (u32)(1 << 4)
434dee1ad47SJeff Kirsher #define IXGBE_FLAG_RX_1BUF_CAPABLE              (u32)(1 << 6)
435dee1ad47SJeff Kirsher #define IXGBE_FLAG_RX_PS_CAPABLE                (u32)(1 << 7)
436dee1ad47SJeff Kirsher #define IXGBE_FLAG_RX_PS_ENABLED                (u32)(1 << 8)
437dee1ad47SJeff Kirsher #define IXGBE_FLAG_IN_NETPOLL                   (u32)(1 << 9)
438dee1ad47SJeff Kirsher #define IXGBE_FLAG_DCA_ENABLED                  (u32)(1 << 10)
439dee1ad47SJeff Kirsher #define IXGBE_FLAG_DCA_CAPABLE                  (u32)(1 << 11)
440dee1ad47SJeff Kirsher #define IXGBE_FLAG_IMIR_ENABLED                 (u32)(1 << 12)
441dee1ad47SJeff Kirsher #define IXGBE_FLAG_MQ_CAPABLE                   (u32)(1 << 13)
442dee1ad47SJeff Kirsher #define IXGBE_FLAG_DCB_ENABLED                  (u32)(1 << 14)
443dee1ad47SJeff Kirsher #define IXGBE_FLAG_RSS_ENABLED                  (u32)(1 << 16)
444dee1ad47SJeff Kirsher #define IXGBE_FLAG_RSS_CAPABLE                  (u32)(1 << 17)
445dee1ad47SJeff Kirsher #define IXGBE_FLAG_VMDQ_CAPABLE                 (u32)(1 << 18)
446dee1ad47SJeff Kirsher #define IXGBE_FLAG_VMDQ_ENABLED                 (u32)(1 << 19)
447dee1ad47SJeff Kirsher #define IXGBE_FLAG_FAN_FAIL_CAPABLE             (u32)(1 << 20)
448dee1ad47SJeff Kirsher #define IXGBE_FLAG_NEED_LINK_UPDATE             (u32)(1 << 22)
449dee1ad47SJeff Kirsher #define IXGBE_FLAG_NEED_LINK_CONFIG             (u32)(1 << 23)
450dee1ad47SJeff Kirsher #define IXGBE_FLAG_FDIR_HASH_CAPABLE            (u32)(1 << 24)
451dee1ad47SJeff Kirsher #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE         (u32)(1 << 25)
452dee1ad47SJeff Kirsher #define IXGBE_FLAG_FCOE_CAPABLE                 (u32)(1 << 26)
453dee1ad47SJeff Kirsher #define IXGBE_FLAG_FCOE_ENABLED                 (u32)(1 << 27)
454dee1ad47SJeff Kirsher #define IXGBE_FLAG_SRIOV_CAPABLE                (u32)(1 << 28)
455dee1ad47SJeff Kirsher #define IXGBE_FLAG_SRIOV_ENABLED                (u32)(1 << 29)
456dee1ad47SJeff Kirsher 
457dee1ad47SJeff Kirsher 	u32 flags2;
458dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RSC_CAPABLE                 (u32)(1)
459dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RSC_ENABLED                 (u32)(1 << 1)
460dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE         (u32)(1 << 2)
461dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_EVENT           (u32)(1 << 3)
462dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SEARCH_FOR_SFP              (u32)(1 << 4)
463dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SFP_NEEDS_RESET             (u32)(1 << 5)
464dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RESET_REQUESTED             (u32)(1 << 6)
465dee1ad47SJeff Kirsher #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT        (u32)(1 << 7)
466ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP		(u32)(1 << 8)
467ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP		(u32)(1 << 9)
4683a6a4edaSJacob Keller #define IXGBE_FLAG2_OVERFLOW_CHECK_ENABLED	(u32)(1 << 10)
469681ae1adSJacob E Keller #define IXGBE_FLAG2_PTP_PPS_ENABLED		(u32)(1 << 11)
47046646e61SAlexander Duyck 
47146646e61SAlexander Duyck 	/* Tx fast path data */
47246646e61SAlexander Duyck 	int num_tx_queues;
47346646e61SAlexander Duyck 	u16 tx_itr_setting;
47446646e61SAlexander Duyck 	u16 tx_work_limit;
47546646e61SAlexander Duyck 
47646646e61SAlexander Duyck 	/* Rx fast path data */
47746646e61SAlexander Duyck 	int num_rx_queues;
47846646e61SAlexander Duyck 	u16 rx_itr_setting;
47946646e61SAlexander Duyck 
48046646e61SAlexander Duyck 	/* TX */
48146646e61SAlexander Duyck 	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
48246646e61SAlexander Duyck 
48346646e61SAlexander Duyck 	u64 restart_queue;
48446646e61SAlexander Duyck 	u64 lsc_int;
48546646e61SAlexander Duyck 	u32 tx_timeout_count;
48646646e61SAlexander Duyck 
48746646e61SAlexander Duyck 	/* RX */
48846646e61SAlexander Duyck 	struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
48946646e61SAlexander Duyck 	int num_rx_pools;		/* == num_rx_queues in 82598 */
49046646e61SAlexander Duyck 	int num_rx_queues_per_pool;	/* 1 if 82598, can be many if 82599 */
49146646e61SAlexander Duyck 	u64 hw_csum_rx_error;
49246646e61SAlexander Duyck 	u64 hw_rx_no_dma_resources;
49346646e61SAlexander Duyck 	u64 rsc_total_count;
49446646e61SAlexander Duyck 	u64 rsc_total_flush;
49546646e61SAlexander Duyck 	u64 non_eop_descs;
49646646e61SAlexander Duyck 	u32 alloc_rx_page_failed;
49746646e61SAlexander Duyck 	u32 alloc_rx_buff_failed;
49846646e61SAlexander Duyck 
499*49c7ffbeSAlexander Duyck 	struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
500dee1ad47SJeff Kirsher 
501dee1ad47SJeff Kirsher 	/* DCB parameters */
502dee1ad47SJeff Kirsher 	struct ieee_pfc *ixgbe_ieee_pfc;
503dee1ad47SJeff Kirsher 	struct ieee_ets *ixgbe_ieee_ets;
504dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config dcb_cfg;
505dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config temp_dcb_cfg;
506dee1ad47SJeff Kirsher 	u8 dcb_set_bitmap;
507dee1ad47SJeff Kirsher 	u8 dcbx_cap;
508dee1ad47SJeff Kirsher 	enum ixgbe_fc_mode last_lfc_mode;
509dee1ad47SJeff Kirsher 
510*49c7ffbeSAlexander Duyck 	int num_q_vectors;	/* current number of q_vectors for device */
511*49c7ffbeSAlexander Duyck 	int max_q_vectors;	/* true count of q_vectors for device */
512dee1ad47SJeff Kirsher 	struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
513dee1ad47SJeff Kirsher 	struct msix_entry *msix_entries;
514dee1ad47SJeff Kirsher 
515dee1ad47SJeff Kirsher 	u32 test_icr;
516dee1ad47SJeff Kirsher 	struct ixgbe_ring test_tx_ring;
517dee1ad47SJeff Kirsher 	struct ixgbe_ring test_rx_ring;
518dee1ad47SJeff Kirsher 
519dee1ad47SJeff Kirsher 	/* structs defined in ixgbe_hw.h */
520dee1ad47SJeff Kirsher 	struct ixgbe_hw hw;
521dee1ad47SJeff Kirsher 	u16 msg_enable;
522dee1ad47SJeff Kirsher 	struct ixgbe_hw_stats stats;
523dee1ad47SJeff Kirsher 
524dee1ad47SJeff Kirsher 	u64 tx_busy;
525dee1ad47SJeff Kirsher 	unsigned int tx_ring_count;
526dee1ad47SJeff Kirsher 	unsigned int rx_ring_count;
527dee1ad47SJeff Kirsher 
528dee1ad47SJeff Kirsher 	u32 link_speed;
529dee1ad47SJeff Kirsher 	bool link_up;
530dee1ad47SJeff Kirsher 	unsigned long link_check_timeout;
531dee1ad47SJeff Kirsher 
532dee1ad47SJeff Kirsher 	struct timer_list service_timer;
53346646e61SAlexander Duyck 	struct work_struct service_task;
53446646e61SAlexander Duyck 
53546646e61SAlexander Duyck 	struct hlist_head fdir_filter_list;
53646646e61SAlexander Duyck 	unsigned long fdir_overflow; /* number of times ATR was backed off */
53746646e61SAlexander Duyck 	union ixgbe_atr_input fdir_mask;
53846646e61SAlexander Duyck 	int fdir_filter_count;
539dee1ad47SJeff Kirsher 	u32 fdir_pballoc;
540dee1ad47SJeff Kirsher 	u32 atr_sample_rate;
541dee1ad47SJeff Kirsher 	spinlock_t fdir_perfect_lock;
54246646e61SAlexander Duyck 
543dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
544dee1ad47SJeff Kirsher 	struct ixgbe_fcoe fcoe;
545dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
546dee1ad47SJeff Kirsher 	u32 wol;
54746646e61SAlexander Duyck 
54846646e61SAlexander Duyck 	u16 bd_number;
54946646e61SAlexander Duyck 
55015e5209fSEmil Tantilov 	u16 eeprom_verh;
55115e5209fSEmil Tantilov 	u16 eeprom_verl;
552c23f5b6bSEmil Tantilov 	u16 eeprom_cap;
553dee1ad47SJeff Kirsher 
554dee1ad47SJeff Kirsher 	u32 interrupt_event;
55546646e61SAlexander Duyck 	u32 led_reg;
556dee1ad47SJeff Kirsher 
5573a6a4edaSJacob Keller #ifdef CONFIG_IXGBE_PTP
5583a6a4edaSJacob Keller 	struct ptp_clock *ptp_clock;
5593a6a4edaSJacob Keller 	struct ptp_clock_info ptp_caps;
5603a6a4edaSJacob Keller 	unsigned long last_overflow_check;
5613a6a4edaSJacob Keller 	spinlock_t tmreg_lock;
5623a6a4edaSJacob Keller 	struct cyclecounter cc;
5633a6a4edaSJacob Keller 	struct timecounter tc;
5641d1a79b5SJacob Keller 	int rx_hwtstamp_filter;
5653a6a4edaSJacob Keller 	u32 base_incval;
5663a6a4edaSJacob Keller 	u32 cycle_speed;
5673a6a4edaSJacob Keller #endif /* CONFIG_IXGBE_PTP */
5683a6a4edaSJacob Keller 
569dee1ad47SJeff Kirsher 	/* SR-IOV */
570dee1ad47SJeff Kirsher 	DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
571dee1ad47SJeff Kirsher 	unsigned int num_vfs;
572dee1ad47SJeff Kirsher 	struct vf_data_storage *vfinfo;
573dee1ad47SJeff Kirsher 	int vf_rate_link_speed;
574dee1ad47SJeff Kirsher 	struct vf_macvlans vf_mvs;
575dee1ad47SJeff Kirsher 	struct vf_macvlans *mv_list;
576dee1ad47SJeff Kirsher 
57783c61fa9SGreg Rose 	u32 timer_event_accumulator;
57883c61fa9SGreg Rose 	u32 vferr_refcount;
5793ca8bc6dSDon Skidmore 	struct kobject *info_kobj;
5803ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
5813ca8bc6dSDon Skidmore 	struct hwmon_buff ixgbe_hwmon_buff;
5823ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
583dee1ad47SJeff Kirsher };
584dee1ad47SJeff Kirsher 
585dee1ad47SJeff Kirsher struct ixgbe_fdir_filter {
586dee1ad47SJeff Kirsher 	struct hlist_node fdir_node;
587dee1ad47SJeff Kirsher 	union ixgbe_atr_input filter;
588dee1ad47SJeff Kirsher 	u16 sw_idx;
589dee1ad47SJeff Kirsher 	u16 action;
590dee1ad47SJeff Kirsher };
591dee1ad47SJeff Kirsher 
59270e5576cSDon Skidmore enum ixgbe_state_t {
593dee1ad47SJeff Kirsher 	__IXGBE_TESTING,
594dee1ad47SJeff Kirsher 	__IXGBE_RESETTING,
595dee1ad47SJeff Kirsher 	__IXGBE_DOWN,
596dee1ad47SJeff Kirsher 	__IXGBE_SERVICE_SCHED,
597dee1ad47SJeff Kirsher 	__IXGBE_IN_SFP_INIT,
598dee1ad47SJeff Kirsher };
599dee1ad47SJeff Kirsher 
6004c1975d7SAlexander Duyck struct ixgbe_cb {
6014c1975d7SAlexander Duyck 	union {				/* Union defining head/tail partner */
6024c1975d7SAlexander Duyck 		struct sk_buff *head;
6034c1975d7SAlexander Duyck 		struct sk_buff *tail;
6044c1975d7SAlexander Duyck 	};
605dee1ad47SJeff Kirsher 	dma_addr_t dma;
6064c1975d7SAlexander Duyck 	u16 append_cnt;
607f800326dSAlexander Duyck 	bool page_released;
608dee1ad47SJeff Kirsher };
6094c1975d7SAlexander Duyck #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
610dee1ad47SJeff Kirsher 
611dee1ad47SJeff Kirsher enum ixgbe_boards {
612dee1ad47SJeff Kirsher 	board_82598,
613dee1ad47SJeff Kirsher 	board_82599,
614dee1ad47SJeff Kirsher 	board_X540,
615dee1ad47SJeff Kirsher };
616dee1ad47SJeff Kirsher 
617dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82598_info;
618dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82599_info;
619dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_X540_info;
620dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
621dee1ad47SJeff Kirsher extern const struct dcbnl_rtnl_ops dcbnl_ops;
622dee1ad47SJeff Kirsher #endif
623dee1ad47SJeff Kirsher 
624dee1ad47SJeff Kirsher extern char ixgbe_driver_name[];
625dee1ad47SJeff Kirsher extern const char ixgbe_driver_version[];
6268af3c33fSJeff Kirsher #ifdef IXGBE_FCOE
627ea81875aSNeerav Parikh extern char ixgbe_default_device_descr[];
6288af3c33fSJeff Kirsher #endif /* IXGBE_FCOE */
629dee1ad47SJeff Kirsher 
630c7ccde0fSAlexander Duyck extern void ixgbe_up(struct ixgbe_adapter *adapter);
631dee1ad47SJeff Kirsher extern void ixgbe_down(struct ixgbe_adapter *adapter);
632dee1ad47SJeff Kirsher extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
633dee1ad47SJeff Kirsher extern void ixgbe_reset(struct ixgbe_adapter *adapter);
634dee1ad47SJeff Kirsher extern void ixgbe_set_ethtool_ops(struct net_device *netdev);
635dee1ad47SJeff Kirsher extern int ixgbe_setup_rx_resources(struct ixgbe_ring *);
636dee1ad47SJeff Kirsher extern int ixgbe_setup_tx_resources(struct ixgbe_ring *);
637dee1ad47SJeff Kirsher extern void ixgbe_free_rx_resources(struct ixgbe_ring *);
638dee1ad47SJeff Kirsher extern void ixgbe_free_tx_resources(struct ixgbe_ring *);
639dee1ad47SJeff Kirsher extern void ixgbe_configure_rx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
640dee1ad47SJeff Kirsher extern void ixgbe_configure_tx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
641dee1ad47SJeff Kirsher extern void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter,
642dee1ad47SJeff Kirsher 				   struct ixgbe_ring *);
643dee1ad47SJeff Kirsher extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);
644dee1ad47SJeff Kirsher extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
6458e2813f5SJacob Keller extern int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
6468e2813f5SJacob Keller 			       u16 subdevice_id);
647dee1ad47SJeff Kirsher extern void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
648dee1ad47SJeff Kirsher extern netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *,
649dee1ad47SJeff Kirsher 					 struct ixgbe_adapter *,
650dee1ad47SJeff Kirsher 					 struct ixgbe_ring *);
651dee1ad47SJeff Kirsher extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *,
652dee1ad47SJeff Kirsher                                              struct ixgbe_tx_buffer *);
653dee1ad47SJeff Kirsher extern void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
654dee1ad47SJeff Kirsher extern void ixgbe_write_eitr(struct ixgbe_q_vector *);
6558af3c33fSJeff Kirsher extern int ixgbe_poll(struct napi_struct *napi, int budget);
656dee1ad47SJeff Kirsher extern int ethtool_ioctl(struct ifreq *ifr);
657dee1ad47SJeff Kirsher extern s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
658dee1ad47SJeff Kirsher extern s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
659dee1ad47SJeff Kirsher extern s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
660dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
661dee1ad47SJeff Kirsher 						 union ixgbe_atr_hash_dword input,
662dee1ad47SJeff Kirsher 						 union ixgbe_atr_hash_dword common,
663dee1ad47SJeff Kirsher                                                  u8 queue);
664dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
665dee1ad47SJeff Kirsher 					   union ixgbe_atr_input *input_mask);
666dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
667dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *input,
668dee1ad47SJeff Kirsher 						 u16 soft_id, u8 queue);
669dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
670dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *input,
671dee1ad47SJeff Kirsher 						 u16 soft_id);
672dee1ad47SJeff Kirsher extern void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
673dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *mask);
674dee1ad47SJeff Kirsher extern void ixgbe_set_rx_mode(struct net_device *netdev);
6758af3c33fSJeff Kirsher #ifdef CONFIG_IXGBE_DCB
6763ebe8fdeSAlexander Duyck extern void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
677dee1ad47SJeff Kirsher extern int ixgbe_setup_tc(struct net_device *dev, u8 tc);
6788af3c33fSJeff Kirsher #endif
679dee1ad47SJeff Kirsher extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
680dee1ad47SJeff Kirsher extern void ixgbe_do_reset(struct net_device *netdev);
6811210982bSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
6823ca8bc6dSDon Skidmore extern void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
6833ca8bc6dSDon Skidmore extern int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
6841210982bSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
685dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
686dee1ad47SJeff Kirsher extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
687fd0db0edSAlexander Duyck extern int ixgbe_fso(struct ixgbe_ring *tx_ring,
688fd0db0edSAlexander Duyck 		     struct ixgbe_tx_buffer *first,
689244e27adSAlexander Duyck 		     u8 *hdr_len);
690dee1ad47SJeff Kirsher extern void ixgbe_cleanup_fcoe(struct ixgbe_adapter *adapter);
691dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
692dee1ad47SJeff Kirsher 			  union ixgbe_adv_rx_desc *rx_desc,
693f56e0cb1SAlexander Duyck 			  struct sk_buff *skb);
694dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
695dee1ad47SJeff Kirsher                               struct scatterlist *sgl, unsigned int sgc);
696dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
697dee1ad47SJeff Kirsher 				 struct scatterlist *sgl, unsigned int sgc);
698dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
699dee1ad47SJeff Kirsher extern int ixgbe_fcoe_enable(struct net_device *netdev);
700dee1ad47SJeff Kirsher extern int ixgbe_fcoe_disable(struct net_device *netdev);
701dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
702dee1ad47SJeff Kirsher extern u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter);
703dee1ad47SJeff Kirsher extern u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);
704dee1ad47SJeff Kirsher #endif /* CONFIG_IXGBE_DCB */
705dee1ad47SJeff Kirsher extern int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
706ea81875aSNeerav Parikh extern int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
707ea81875aSNeerav Parikh 				  struct netdev_fcoe_hbainfo *info);
708dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
709dee1ad47SJeff Kirsher 
710b2d96e0aSAlexander Duyck static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
711b2d96e0aSAlexander Duyck {
712b2d96e0aSAlexander Duyck 	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
713b2d96e0aSAlexander Duyck }
714b2d96e0aSAlexander Duyck 
7153a6a4edaSJacob Keller #ifdef CONFIG_IXGBE_PTP
7163a6a4edaSJacob Keller extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
7173a6a4edaSJacob Keller extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
7183a6a4edaSJacob Keller extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
7193a6a4edaSJacob Keller extern void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector,
7203a6a4edaSJacob Keller 				  struct sk_buff *skb);
7213a6a4edaSJacob Keller extern void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,
7221d1a79b5SJacob Keller 				  union ixgbe_adv_rx_desc *rx_desc,
7233a6a4edaSJacob Keller 				  struct sk_buff *skb);
7243a6a4edaSJacob Keller extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
7253a6a4edaSJacob Keller 				    struct ifreq *ifr, int cmd);
7263a6a4edaSJacob Keller extern void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
727681ae1adSJacob E Keller extern void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr);
7283a6a4edaSJacob Keller #endif /* CONFIG_IXGBE_PTP */
7293a6a4edaSJacob Keller 
730dee1ad47SJeff Kirsher #endif /* _IXGBE_H_ */
731