xref: /openbmc/linux/drivers/net/ethernet/intel/ixgbe/ixgbe.h (revision fd786b7b4731b7aa9796cfd251238ffaab71d725)
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:
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>
386cb562d6SJacob Keller #include <linux/jiffies.h>
39dee1ad47SJeff Kirsher 
403a6a4edaSJacob Keller #include <linux/clocksource.h>
413a6a4edaSJacob Keller #include <linux/net_tstamp.h>
423a6a4edaSJacob Keller #include <linux/ptp_clock_kernel.h>
433a6a4edaSJacob Keller 
44dee1ad47SJeff Kirsher #include "ixgbe_type.h"
45dee1ad47SJeff Kirsher #include "ixgbe_common.h"
46dee1ad47SJeff Kirsher #include "ixgbe_dcb.h"
47dee1ad47SJeff Kirsher #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
48dee1ad47SJeff Kirsher #define IXGBE_FCOE
49dee1ad47SJeff Kirsher #include "ixgbe_fcoe.h"
50dee1ad47SJeff Kirsher #endif /* CONFIG_FCOE or CONFIG_FCOE_MODULE */
51dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
52dee1ad47SJeff Kirsher #include <linux/dca.h>
53dee1ad47SJeff Kirsher #endif
54dee1ad47SJeff Kirsher 
55dee1ad47SJeff Kirsher /* common prefix used by pr_<> macros */
56dee1ad47SJeff Kirsher #undef pr_fmt
57dee1ad47SJeff Kirsher #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
58dee1ad47SJeff Kirsher 
59dee1ad47SJeff Kirsher /* TX/RX descriptor defines */
60dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_TXD		    512
6159224555SAlexander Duyck #define IXGBE_DEFAULT_TX_WORK		    256
62dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD			   4096
63dee1ad47SJeff Kirsher #define IXGBE_MIN_TXD			     64
64dee1ad47SJeff Kirsher 
65dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_RXD		    512
66dee1ad47SJeff Kirsher #define IXGBE_MAX_RXD			   4096
67dee1ad47SJeff Kirsher #define IXGBE_MIN_RXD			     64
68dee1ad47SJeff Kirsher 
69dee1ad47SJeff Kirsher /* flow control */
70dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTL			   0x40
71dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTL			0x7FF80
72dee1ad47SJeff Kirsher #define IXGBE_MIN_FCRTH			  0x600
73dee1ad47SJeff Kirsher #define IXGBE_MAX_FCRTH			0x7FFF0
74dee1ad47SJeff Kirsher #define IXGBE_DEFAULT_FCPAUSE		 0xFFFF
75dee1ad47SJeff Kirsher #define IXGBE_MIN_FCPAUSE		      0
76dee1ad47SJeff Kirsher #define IXGBE_MAX_FCPAUSE		 0xFFFF
77dee1ad47SJeff Kirsher 
78dee1ad47SJeff Kirsher /* Supported Rx Buffer Sizes */
79252562c2SAlexander Duyck #define IXGBE_RXBUFFER_256    256  /* Used for skb receive header */
8009816fbeSAlexander Duyck #define IXGBE_RXBUFFER_2K    2048
8109816fbeSAlexander Duyck #define IXGBE_RXBUFFER_3K    3072
8209816fbeSAlexander Duyck #define IXGBE_RXBUFFER_4K    4096
83dee1ad47SJeff Kirsher #define IXGBE_MAX_RXBUFFER  16384  /* largest size for a single descriptor */
84dee1ad47SJeff Kirsher 
85dee1ad47SJeff Kirsher /*
86252562c2SAlexander Duyck  * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
87252562c2SAlexander Duyck  * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
88252562c2SAlexander Duyck  * this adds up to 448 bytes of extra data.
89252562c2SAlexander Duyck  *
90252562c2SAlexander Duyck  * Since netdev_alloc_skb now allocates a page fragment we can use a value
91252562c2SAlexander Duyck  * of 256 and the resultant skb will have a truesize of 960 or less.
92dee1ad47SJeff Kirsher  */
93252562c2SAlexander Duyck #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
94dee1ad47SJeff Kirsher 
95dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */
96dee1ad47SJeff Kirsher #define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */
97dee1ad47SJeff Kirsher 
98472148c3SAlexander Duyck enum ixgbe_tx_flags {
99472148c3SAlexander Duyck 	/* cmd_type flags */
100472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_HW_VLAN	= 0x01,
101472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_TSO	= 0x02,
102472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_TSTAMP	= 0x04,
103472148c3SAlexander Duyck 
104472148c3SAlexander Duyck 	/* olinfo flags */
105472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_CC	= 0x08,
106472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_IPV4	= 0x10,
107472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_CSUM	= 0x20,
108472148c3SAlexander Duyck 
109472148c3SAlexander Duyck 	/* software defined flags */
110472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_SW_VLAN	= 0x40,
111472148c3SAlexander Duyck 	IXGBE_TX_FLAGS_FCOE	= 0x80,
112472148c3SAlexander Duyck };
113472148c3SAlexander Duyck 
114472148c3SAlexander Duyck /* VLAN info */
115dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000
11666f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000
11766f32a8bSAlexander Duyck #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT  29
118dee1ad47SJeff Kirsher #define IXGBE_TX_FLAGS_VLAN_SHIFT	16
119dee1ad47SJeff Kirsher 
120dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_MC_ENTRIES         30
121dee1ad47SJeff Kirsher #define IXGBE_MAX_VF_FUNCTIONS          64
122dee1ad47SJeff Kirsher #define IXGBE_MAX_VFTA_ENTRIES          128
123dee1ad47SJeff Kirsher #define MAX_EMULATION_MAC_ADDRS         16
124dee1ad47SJeff Kirsher #define IXGBE_MAX_PF_MACVLANS           15
1251d9c0bfdSAlexander Duyck #define VMDQ_P(p)   ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
12683c61fa9SGreg Rose #define IXGBE_82599_VF_DEVICE_ID        0x10ED
12783c61fa9SGreg Rose #define IXGBE_X540_VF_DEVICE_ID         0x1515
128dee1ad47SJeff Kirsher 
129dee1ad47SJeff Kirsher struct vf_data_storage {
130dee1ad47SJeff Kirsher 	unsigned char vf_mac_addresses[ETH_ALEN];
131dee1ad47SJeff Kirsher 	u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
132dee1ad47SJeff Kirsher 	u16 num_vf_mc_hashes;
133dee1ad47SJeff Kirsher 	u16 default_vf_vlan_id;
134dee1ad47SJeff Kirsher 	u16 vlans_enabled;
135dee1ad47SJeff Kirsher 	bool clear_to_send;
136dee1ad47SJeff Kirsher 	bool pf_set_mac;
137dee1ad47SJeff Kirsher 	u16 pf_vlan; /* When set, guest VLAN config not allowed. */
138dee1ad47SJeff Kirsher 	u16 pf_qos;
139dee1ad47SJeff Kirsher 	u16 tx_rate;
140de4c7f65SGreg Rose 	u16 vlan_count;
141de4c7f65SGreg Rose 	u8 spoofchk_enabled;
142374c65d6SAlexander Duyck 	unsigned int vf_api;
143dee1ad47SJeff Kirsher };
144dee1ad47SJeff Kirsher 
145dee1ad47SJeff Kirsher struct vf_macvlans {
146dee1ad47SJeff Kirsher 	struct list_head l;
147dee1ad47SJeff Kirsher 	int vf;
148dee1ad47SJeff Kirsher 	int rar_entry;
149dee1ad47SJeff Kirsher 	bool free;
150dee1ad47SJeff Kirsher 	bool is_macvlan;
151dee1ad47SJeff Kirsher 	u8 vf_macvlan[ETH_ALEN];
152dee1ad47SJeff Kirsher };
153dee1ad47SJeff Kirsher 
154dee1ad47SJeff Kirsher #define IXGBE_MAX_TXD_PWR	14
155dee1ad47SJeff Kirsher #define IXGBE_MAX_DATA_PER_TXD	(1 << IXGBE_MAX_TXD_PWR)
156dee1ad47SJeff Kirsher 
157dee1ad47SJeff Kirsher /* Tx Descriptors needed, worst case */
158dee1ad47SJeff Kirsher #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
159dee1ad47SJeff Kirsher #define DESC_NEEDED ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4)
160dee1ad47SJeff Kirsher 
161dee1ad47SJeff Kirsher /* wrapper around a pointer to a socket buffer,
162dee1ad47SJeff Kirsher  * so a DMA handle can be stored along with the buffer */
163dee1ad47SJeff Kirsher struct ixgbe_tx_buffer {
164d3d00239SAlexander Duyck 	union ixgbe_adv_tx_desc *next_to_watch;
165dee1ad47SJeff Kirsher 	unsigned long time_stamp;
166d3d00239SAlexander Duyck 	struct sk_buff *skb;
167fd0db0edSAlexander Duyck 	unsigned int bytecount;
168fd0db0edSAlexander Duyck 	unsigned short gso_segs;
169244e27adSAlexander Duyck 	__be16 protocol;
170729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_ADDR(dma);
171729739b7SAlexander Duyck 	DEFINE_DMA_UNMAP_LEN(len);
172fd0db0edSAlexander Duyck 	u32 tx_flags;
173dee1ad47SJeff Kirsher };
174dee1ad47SJeff Kirsher 
175dee1ad47SJeff Kirsher struct ixgbe_rx_buffer {
176dee1ad47SJeff Kirsher 	struct sk_buff *skb;
177dee1ad47SJeff Kirsher 	dma_addr_t dma;
178dee1ad47SJeff Kirsher 	struct page *page;
179dee1ad47SJeff Kirsher 	unsigned int page_offset;
180dee1ad47SJeff Kirsher };
181dee1ad47SJeff Kirsher 
182dee1ad47SJeff Kirsher struct ixgbe_queue_stats {
183dee1ad47SJeff Kirsher 	u64 packets;
184dee1ad47SJeff Kirsher 	u64 bytes;
185dee1ad47SJeff Kirsher };
186dee1ad47SJeff Kirsher 
187dee1ad47SJeff Kirsher struct ixgbe_tx_queue_stats {
188dee1ad47SJeff Kirsher 	u64 restart_queue;
189dee1ad47SJeff Kirsher 	u64 tx_busy;
190dee1ad47SJeff Kirsher 	u64 tx_done_old;
191dee1ad47SJeff Kirsher };
192dee1ad47SJeff Kirsher 
193dee1ad47SJeff Kirsher struct ixgbe_rx_queue_stats {
194dee1ad47SJeff Kirsher 	u64 rsc_count;
195dee1ad47SJeff Kirsher 	u64 rsc_flush;
196dee1ad47SJeff Kirsher 	u64 non_eop_descs;
197dee1ad47SJeff Kirsher 	u64 alloc_rx_page_failed;
198dee1ad47SJeff Kirsher 	u64 alloc_rx_buff_failed;
1998a0da21bSAlexander Duyck 	u64 csum_err;
200dee1ad47SJeff Kirsher };
201dee1ad47SJeff Kirsher 
202f800326dSAlexander Duyck enum ixgbe_ring_state_t {
203dee1ad47SJeff Kirsher 	__IXGBE_TX_FDIR_INIT_DONE,
204*fd786b7bSAlexander Duyck 	__IXGBE_TX_XPS_INIT_DONE,
205dee1ad47SJeff Kirsher 	__IXGBE_TX_DETECT_HANG,
206dee1ad47SJeff Kirsher 	__IXGBE_HANG_CHECK_ARMED,
207dee1ad47SJeff Kirsher 	__IXGBE_RX_RSC_ENABLED,
2088a0da21bSAlexander Duyck 	__IXGBE_RX_CSUM_UDP_ZERO_ERR,
20957efd44cSAlexander Duyck 	__IXGBE_RX_FCOE,
210dee1ad47SJeff Kirsher };
211dee1ad47SJeff Kirsher 
212dee1ad47SJeff Kirsher #define check_for_tx_hang(ring) \
213dee1ad47SJeff Kirsher 	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
214dee1ad47SJeff Kirsher #define set_check_for_tx_hang(ring) \
215dee1ad47SJeff Kirsher 	set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
216dee1ad47SJeff Kirsher #define clear_check_for_tx_hang(ring) \
217dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
218dee1ad47SJeff Kirsher #define ring_is_rsc_enabled(ring) \
219dee1ad47SJeff Kirsher 	test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
220dee1ad47SJeff Kirsher #define set_ring_rsc_enabled(ring) \
221dee1ad47SJeff Kirsher 	set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
222dee1ad47SJeff Kirsher #define clear_ring_rsc_enabled(ring) \
223dee1ad47SJeff Kirsher 	clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
224dee1ad47SJeff Kirsher struct ixgbe_ring {
225efe3d3c8SAlexander Duyck 	struct ixgbe_ring *next;	/* pointer to next ring in q_vector */
226d3ee4294SAlexander Duyck 	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
227dee1ad47SJeff Kirsher 	struct net_device *netdev;	/* netdev ring belongs to */
228d3ee4294SAlexander Duyck 	struct device *dev;		/* device for DMA mapping */
229d3ee4294SAlexander Duyck 	void *desc;			/* descriptor ring memory */
230dee1ad47SJeff Kirsher 	union {
231dee1ad47SJeff Kirsher 		struct ixgbe_tx_buffer *tx_buffer_info;
232dee1ad47SJeff Kirsher 		struct ixgbe_rx_buffer *rx_buffer_info;
233dee1ad47SJeff Kirsher 	};
2346cb562d6SJacob Keller 	unsigned long last_rx_timestamp;
235dee1ad47SJeff Kirsher 	unsigned long state;
236dee1ad47SJeff Kirsher 	u8 __iomem *tail;
237d3ee4294SAlexander Duyck 	dma_addr_t dma;			/* phys. address of descriptor ring */
238d3ee4294SAlexander Duyck 	unsigned int size;		/* length in bytes */
239dee1ad47SJeff Kirsher 
240dee1ad47SJeff Kirsher 	u16 count;			/* amount of descriptors */
241dee1ad47SJeff Kirsher 
242dee1ad47SJeff Kirsher 	u8 queue_index; /* needed for multiqueue queue management */
243dee1ad47SJeff Kirsher 	u8 reg_idx;			/* holds the special value that gets
244dee1ad47SJeff Kirsher 					 * the hardware register offset
245dee1ad47SJeff Kirsher 					 * associated with this ring, which is
246dee1ad47SJeff Kirsher 					 * different for DCB and RSS modes
247dee1ad47SJeff Kirsher 					 */
248d3ee4294SAlexander Duyck 	u16 next_to_use;
249d3ee4294SAlexander Duyck 	u16 next_to_clean;
250d3ee4294SAlexander Duyck 
251f800326dSAlexander Duyck 	union {
252d3ee4294SAlexander Duyck 		u16 next_to_alloc;
253f800326dSAlexander Duyck 		struct {
254dee1ad47SJeff Kirsher 			u8 atr_sample_rate;
255dee1ad47SJeff Kirsher 			u8 atr_count;
256f800326dSAlexander Duyck 		};
257f800326dSAlexander Duyck 	};
258dee1ad47SJeff Kirsher 
259dee1ad47SJeff Kirsher 	u8 dcb_tc;
260dee1ad47SJeff Kirsher 	struct ixgbe_queue_stats stats;
261dee1ad47SJeff Kirsher 	struct u64_stats_sync syncp;
262dee1ad47SJeff Kirsher 	union {
263dee1ad47SJeff Kirsher 		struct ixgbe_tx_queue_stats tx_stats;
264dee1ad47SJeff Kirsher 		struct ixgbe_rx_queue_stats rx_stats;
265dee1ad47SJeff Kirsher 	};
266dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
267dee1ad47SJeff Kirsher 
268dee1ad47SJeff Kirsher enum ixgbe_ring_f_enum {
269dee1ad47SJeff Kirsher 	RING_F_NONE = 0,
270dee1ad47SJeff Kirsher 	RING_F_VMDQ,  /* SR-IOV uses the same ring feature */
271dee1ad47SJeff Kirsher 	RING_F_RSS,
272dee1ad47SJeff Kirsher 	RING_F_FDIR,
273dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
274dee1ad47SJeff Kirsher 	RING_F_FCOE,
275dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
276dee1ad47SJeff Kirsher 
277dee1ad47SJeff Kirsher 	RING_F_ARRAY_SIZE      /* must be last in enum set */
278dee1ad47SJeff Kirsher };
279dee1ad47SJeff Kirsher 
280dee1ad47SJeff Kirsher #define IXGBE_MAX_RSS_INDICES  16
281dee1ad47SJeff Kirsher #define IXGBE_MAX_VMDQ_INDICES 64
282d3cb9869SAlexander Duyck #define IXGBE_MAX_FDIR_INDICES 63	/* based on q_vector limit */
283dee1ad47SJeff Kirsher #define IXGBE_MAX_FCOE_INDICES  8
284d3cb9869SAlexander Duyck #define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
285d3cb9869SAlexander Duyck #define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
286dee1ad47SJeff Kirsher struct ixgbe_ring_feature {
287c087663eSAlexander Duyck 	u16 limit;	/* upper limit on feature indices */
288c087663eSAlexander Duyck 	u16 indices;	/* current value of indices */
289e4b317e9SAlexander Duyck 	u16 mask;	/* Mask used for feature to ring mapping */
290e4b317e9SAlexander Duyck 	u16 offset;	/* offset to start of feature */
291dee1ad47SJeff Kirsher } ____cacheline_internodealigned_in_smp;
292dee1ad47SJeff Kirsher 
29373079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_8Q_MASK 0x78
29473079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_4Q_MASK 0x7C
29573079ea0SAlexander Duyck #define IXGBE_82599_VMDQ_2Q_MASK 0x7E
29673079ea0SAlexander Duyck 
297f800326dSAlexander Duyck /*
298f800326dSAlexander Duyck  * FCoE requires that all Rx buffers be over 2200 bytes in length.  Since
299f800326dSAlexander Duyck  * this is twice the size of a half page we need to double the page order
300f800326dSAlexander Duyck  * for FCoE enabled Rx queues.
301f800326dSAlexander Duyck  */
30209816fbeSAlexander Duyck static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
30309816fbeSAlexander Duyck {
30409816fbeSAlexander Duyck #ifdef IXGBE_FCOE
30509816fbeSAlexander Duyck 	if (test_bit(__IXGBE_RX_FCOE, &ring->state))
30609816fbeSAlexander Duyck 		return (PAGE_SIZE < 8192) ? IXGBE_RXBUFFER_4K :
30709816fbeSAlexander Duyck 					    IXGBE_RXBUFFER_3K;
30809816fbeSAlexander Duyck #endif
30909816fbeSAlexander Duyck 	return IXGBE_RXBUFFER_2K;
31009816fbeSAlexander Duyck }
31109816fbeSAlexander Duyck 
312f800326dSAlexander Duyck static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
313f800326dSAlexander Duyck {
31409816fbeSAlexander Duyck #ifdef IXGBE_FCOE
31509816fbeSAlexander Duyck 	if (test_bit(__IXGBE_RX_FCOE, &ring->state))
31609816fbeSAlexander Duyck 		return (PAGE_SIZE < 8192) ? 1 : 0;
317f800326dSAlexander Duyck #endif
31809816fbeSAlexander Duyck 	return 0;
31909816fbeSAlexander Duyck }
320f800326dSAlexander Duyck #define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
321f800326dSAlexander Duyck 
322dee1ad47SJeff Kirsher struct ixgbe_ring_container {
323efe3d3c8SAlexander Duyck 	struct ixgbe_ring *ring;	/* pointer to linked list of rings */
324dee1ad47SJeff Kirsher 	unsigned int total_bytes;	/* total bytes processed this int */
325dee1ad47SJeff Kirsher 	unsigned int total_packets;	/* total packets processed this int */
326dee1ad47SJeff Kirsher 	u16 work_limit;			/* total work allowed per interrupt */
327dee1ad47SJeff Kirsher 	u8 count;			/* total number of rings in vector */
328dee1ad47SJeff Kirsher 	u8 itr;				/* current ITR setting for ring */
329dee1ad47SJeff Kirsher };
330dee1ad47SJeff Kirsher 
331a557928eSAlexander Duyck /* iterator for handling rings in ring container */
332a557928eSAlexander Duyck #define ixgbe_for_each_ring(pos, head) \
333a557928eSAlexander Duyck 	for (pos = (head).ring; pos != NULL; pos = pos->next)
334a557928eSAlexander Duyck 
335dee1ad47SJeff Kirsher #define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
336dee1ad47SJeff Kirsher                               ? 8 : 1)
337dee1ad47SJeff Kirsher #define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
338dee1ad47SJeff Kirsher 
33949c7ffbeSAlexander Duyck /* MAX_Q_VECTORS of these are allocated,
340dee1ad47SJeff Kirsher  * but we only use one per queue-specific vector.
341dee1ad47SJeff Kirsher  */
342dee1ad47SJeff Kirsher struct ixgbe_q_vector {
343dee1ad47SJeff Kirsher 	struct ixgbe_adapter *adapter;
344dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCA
345dee1ad47SJeff Kirsher 	int cpu;	    /* CPU for DCA */
346dee1ad47SJeff Kirsher #endif
347d5bf4f67SEmil Tantilov 	u16 v_idx;		/* index of q_vector within array, also used for
348d5bf4f67SEmil Tantilov 				 * finding the bit in EICR and friends that
349d5bf4f67SEmil Tantilov 				 * represents the vector for this ring */
350d5bf4f67SEmil Tantilov 	u16 itr;		/* Interrupt throttle rate written to EITR */
351dee1ad47SJeff Kirsher 	struct ixgbe_ring_container rx, tx;
352d5bf4f67SEmil Tantilov 
353d5bf4f67SEmil Tantilov 	struct napi_struct napi;
354de88eeebSAlexander Duyck 	cpumask_t affinity_mask;
355de88eeebSAlexander Duyck 	int numa_node;
356de88eeebSAlexander Duyck 	struct rcu_head rcu;	/* to avoid race with update stats on free */
357dee1ad47SJeff Kirsher 	char name[IFNAMSIZ + 9];
358de88eeebSAlexander Duyck 
359de88eeebSAlexander Duyck 	/* for dynamic allocation of rings associated with this q_vector */
360de88eeebSAlexander Duyck 	struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp;
361dee1ad47SJeff Kirsher };
3623ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
3633ca8bc6dSDon Skidmore 
3643ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_LOC		0
3653ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_TEMP		1
3663ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_CAUTION	2
3673ca8bc6dSDon Skidmore #define IXGBE_HWMON_TYPE_MAX		3
3683ca8bc6dSDon Skidmore 
3693ca8bc6dSDon Skidmore struct hwmon_attr {
3703ca8bc6dSDon Skidmore 	struct device_attribute dev_attr;
3713ca8bc6dSDon Skidmore 	struct ixgbe_hw *hw;
3723ca8bc6dSDon Skidmore 	struct ixgbe_thermal_diode_data *sensor;
3733ca8bc6dSDon Skidmore 	char name[12];
3743ca8bc6dSDon Skidmore };
3753ca8bc6dSDon Skidmore 
3763ca8bc6dSDon Skidmore struct hwmon_buff {
3773ca8bc6dSDon Skidmore 	struct device *device;
3783ca8bc6dSDon Skidmore 	struct hwmon_attr *hwmon_list;
3793ca8bc6dSDon Skidmore 	unsigned int n_hwmon;
3803ca8bc6dSDon Skidmore };
3813ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
382dee1ad47SJeff Kirsher 
383d5bf4f67SEmil Tantilov /*
384d5bf4f67SEmil Tantilov  * microsecond values for various ITR rates shifted by 2 to fit itr register
385d5bf4f67SEmil Tantilov  * with the first 3 bits reserved 0
386dee1ad47SJeff Kirsher  */
387d5bf4f67SEmil Tantilov #define IXGBE_MIN_RSC_ITR	24
388d5bf4f67SEmil Tantilov #define IXGBE_100K_ITR		40
389d5bf4f67SEmil Tantilov #define IXGBE_20K_ITR		200
390d5bf4f67SEmil Tantilov #define IXGBE_10K_ITR		400
391d5bf4f67SEmil Tantilov #define IXGBE_8K_ITR		500
392dee1ad47SJeff Kirsher 
393f56e0cb1SAlexander Duyck /* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
394f56e0cb1SAlexander Duyck static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
395f56e0cb1SAlexander Duyck 					const u32 stat_err_bits)
396f56e0cb1SAlexander Duyck {
397f56e0cb1SAlexander Duyck 	return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
398f56e0cb1SAlexander Duyck }
399f56e0cb1SAlexander Duyck 
400dee1ad47SJeff Kirsher static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
401dee1ad47SJeff Kirsher {
402dee1ad47SJeff Kirsher 	u16 ntc = ring->next_to_clean;
403dee1ad47SJeff Kirsher 	u16 ntu = ring->next_to_use;
404dee1ad47SJeff Kirsher 
405dee1ad47SJeff Kirsher 	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
406dee1ad47SJeff Kirsher }
407dee1ad47SJeff Kirsher 
408e4f74028SAlexander Duyck #define IXGBE_RX_DESC(R, i)	    \
409dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
410e4f74028SAlexander Duyck #define IXGBE_TX_DESC(R, i)	    \
411dee1ad47SJeff Kirsher 	(&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
412e4f74028SAlexander Duyck #define IXGBE_TX_CTXTDESC(R, i)	    \
413dee1ad47SJeff Kirsher 	(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
414dee1ad47SJeff Kirsher 
415c88887e0SAlexander Duyck #define IXGBE_MAX_JUMBO_FRAME_SIZE	9728 /* Maximum Supported Size 9.5KB */
416dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
417dee1ad47SJeff Kirsher /* Use 3K as the baby jumbo frame size for FCoE */
418dee1ad47SJeff Kirsher #define IXGBE_FCOE_JUMBO_FRAME_SIZE       3072
419dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
420dee1ad47SJeff Kirsher 
421dee1ad47SJeff Kirsher #define OTHER_VECTOR 1
422dee1ad47SJeff Kirsher #define NON_Q_VECTORS (OTHER_VECTOR)
423dee1ad47SJeff Kirsher 
424dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82599 64
42549c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82599 64
426dee1ad47SJeff Kirsher #define MAX_MSIX_VECTORS_82598 18
42749c7ffbeSAlexander Duyck #define MAX_Q_VECTORS_82598 16
428dee1ad47SJeff Kirsher 
42949c7ffbeSAlexander Duyck #define MAX_Q_VECTORS MAX_Q_VECTORS_82599
430dee1ad47SJeff Kirsher #define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
431dee1ad47SJeff Kirsher 
4328f15486dSAlexander Duyck #define MIN_MSIX_Q_VECTORS 1
433dee1ad47SJeff Kirsher #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
434dee1ad47SJeff Kirsher 
43546646e61SAlexander Duyck /* default to trying for four seconds */
43646646e61SAlexander Duyck #define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
43746646e61SAlexander Duyck 
438dee1ad47SJeff Kirsher /* board specific private data structure */
439dee1ad47SJeff Kirsher struct ixgbe_adapter {
44046646e61SAlexander Duyck 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
44146646e61SAlexander Duyck 	/* OS defined structs */
44246646e61SAlexander Duyck 	struct net_device *netdev;
44346646e61SAlexander Duyck 	struct pci_dev *pdev;
44446646e61SAlexander Duyck 
445dee1ad47SJeff Kirsher 	unsigned long state;
446dee1ad47SJeff Kirsher 
447dee1ad47SJeff Kirsher 	/* Some features need tri-state capability,
448dee1ad47SJeff Kirsher 	 * thus the additional *_CAPABLE flags.
449dee1ad47SJeff Kirsher 	 */
450dee1ad47SJeff Kirsher 	u32 flags;
451a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSI_CAPABLE                  (u32)(1 << 0)
452a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSI_ENABLED                  (u32)(1 << 1)
453a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSIX_CAPABLE                 (u32)(1 << 2)
454a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MSIX_ENABLED                 (u32)(1 << 3)
455a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_1BUF_CAPABLE              (u32)(1 << 4)
456a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_PS_CAPABLE                (u32)(1 << 5)
457a16a0d2fSAlexander Duyck #define IXGBE_FLAG_RX_PS_ENABLED                (u32)(1 << 6)
458a16a0d2fSAlexander Duyck #define IXGBE_FLAG_IN_NETPOLL                   (u32)(1 << 7)
459a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCA_ENABLED                  (u32)(1 << 8)
460a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCA_CAPABLE                  (u32)(1 << 9)
461a16a0d2fSAlexander Duyck #define IXGBE_FLAG_IMIR_ENABLED                 (u32)(1 << 10)
462a16a0d2fSAlexander Duyck #define IXGBE_FLAG_MQ_CAPABLE                   (u32)(1 << 11)
463a16a0d2fSAlexander Duyck #define IXGBE_FLAG_DCB_ENABLED                  (u32)(1 << 12)
464a16a0d2fSAlexander Duyck #define IXGBE_FLAG_VMDQ_CAPABLE                 (u32)(1 << 13)
465a16a0d2fSAlexander Duyck #define IXGBE_FLAG_VMDQ_ENABLED                 (u32)(1 << 14)
466a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FAN_FAIL_CAPABLE             (u32)(1 << 15)
467a16a0d2fSAlexander Duyck #define IXGBE_FLAG_NEED_LINK_UPDATE             (u32)(1 << 16)
468a16a0d2fSAlexander Duyck #define IXGBE_FLAG_NEED_LINK_CONFIG             (u32)(1 << 17)
469a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FDIR_HASH_CAPABLE            (u32)(1 << 18)
470a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FDIR_PERFECT_CAPABLE         (u32)(1 << 19)
471a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FCOE_CAPABLE                 (u32)(1 << 20)
472a16a0d2fSAlexander Duyck #define IXGBE_FLAG_FCOE_ENABLED                 (u32)(1 << 21)
473a16a0d2fSAlexander Duyck #define IXGBE_FLAG_SRIOV_CAPABLE                (u32)(1 << 22)
474a16a0d2fSAlexander Duyck #define IXGBE_FLAG_SRIOV_ENABLED                (u32)(1 << 23)
475dee1ad47SJeff Kirsher 
476dee1ad47SJeff Kirsher 	u32 flags2;
477a16a0d2fSAlexander Duyck #define IXGBE_FLAG2_RSC_CAPABLE                 (u32)(1 << 0)
478dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RSC_ENABLED                 (u32)(1 << 1)
479dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE         (u32)(1 << 2)
480dee1ad47SJeff Kirsher #define IXGBE_FLAG2_TEMP_SENSOR_EVENT           (u32)(1 << 3)
481dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SEARCH_FOR_SFP              (u32)(1 << 4)
482dee1ad47SJeff Kirsher #define IXGBE_FLAG2_SFP_NEEDS_RESET             (u32)(1 << 5)
483dee1ad47SJeff Kirsher #define IXGBE_FLAG2_RESET_REQUESTED             (u32)(1 << 6)
484dee1ad47SJeff Kirsher #define IXGBE_FLAG2_FDIR_REQUIRES_REINIT        (u32)(1 << 7)
485ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP		(u32)(1 << 8)
486ef6afc0cSAlexander Duyck #define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP		(u32)(1 << 9)
4871a71ab24SJacob Keller #define IXGBE_FLAG2_PTP_ENABLED			(u32)(1 << 10)
488681ae1adSJacob E Keller #define IXGBE_FLAG2_PTP_PPS_ENABLED		(u32)(1 << 11)
4899b735984SGreg Rose #define IXGBE_FLAG2_BRIDGE_MODE_VEB		(u32)(1 << 12)
49046646e61SAlexander Duyck 
49146646e61SAlexander Duyck 	/* Tx fast path data */
49246646e61SAlexander Duyck 	int num_tx_queues;
49346646e61SAlexander Duyck 	u16 tx_itr_setting;
49446646e61SAlexander Duyck 	u16 tx_work_limit;
49546646e61SAlexander Duyck 
49646646e61SAlexander Duyck 	/* Rx fast path data */
49746646e61SAlexander Duyck 	int num_rx_queues;
49846646e61SAlexander Duyck 	u16 rx_itr_setting;
49946646e61SAlexander Duyck 
50046646e61SAlexander Duyck 	/* TX */
50146646e61SAlexander Duyck 	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
50246646e61SAlexander Duyck 
50346646e61SAlexander Duyck 	u64 restart_queue;
50446646e61SAlexander Duyck 	u64 lsc_int;
50546646e61SAlexander Duyck 	u32 tx_timeout_count;
50646646e61SAlexander Duyck 
50746646e61SAlexander Duyck 	/* RX */
50846646e61SAlexander Duyck 	struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
50946646e61SAlexander Duyck 	int num_rx_pools;		/* == num_rx_queues in 82598 */
51046646e61SAlexander Duyck 	int num_rx_queues_per_pool;	/* 1 if 82598, can be many if 82599 */
51146646e61SAlexander Duyck 	u64 hw_csum_rx_error;
51246646e61SAlexander Duyck 	u64 hw_rx_no_dma_resources;
51346646e61SAlexander Duyck 	u64 rsc_total_count;
51446646e61SAlexander Duyck 	u64 rsc_total_flush;
51546646e61SAlexander Duyck 	u64 non_eop_descs;
51646646e61SAlexander Duyck 	u32 alloc_rx_page_failed;
51746646e61SAlexander Duyck 	u32 alloc_rx_buff_failed;
51846646e61SAlexander Duyck 
51949c7ffbeSAlexander Duyck 	struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
520dee1ad47SJeff Kirsher 
521dee1ad47SJeff Kirsher 	/* DCB parameters */
522dee1ad47SJeff Kirsher 	struct ieee_pfc *ixgbe_ieee_pfc;
523dee1ad47SJeff Kirsher 	struct ieee_ets *ixgbe_ieee_ets;
524dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config dcb_cfg;
525dee1ad47SJeff Kirsher 	struct ixgbe_dcb_config temp_dcb_cfg;
526dee1ad47SJeff Kirsher 	u8 dcb_set_bitmap;
527dee1ad47SJeff Kirsher 	u8 dcbx_cap;
528dee1ad47SJeff Kirsher 	enum ixgbe_fc_mode last_lfc_mode;
529dee1ad47SJeff Kirsher 
53049c7ffbeSAlexander Duyck 	int num_q_vectors;	/* current number of q_vectors for device */
53149c7ffbeSAlexander Duyck 	int max_q_vectors;	/* true count of q_vectors for device */
532dee1ad47SJeff Kirsher 	struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
533dee1ad47SJeff Kirsher 	struct msix_entry *msix_entries;
534dee1ad47SJeff Kirsher 
535dee1ad47SJeff Kirsher 	u32 test_icr;
536dee1ad47SJeff Kirsher 	struct ixgbe_ring test_tx_ring;
537dee1ad47SJeff Kirsher 	struct ixgbe_ring test_rx_ring;
538dee1ad47SJeff Kirsher 
539dee1ad47SJeff Kirsher 	/* structs defined in ixgbe_hw.h */
540dee1ad47SJeff Kirsher 	struct ixgbe_hw hw;
541dee1ad47SJeff Kirsher 	u16 msg_enable;
542dee1ad47SJeff Kirsher 	struct ixgbe_hw_stats stats;
543dee1ad47SJeff Kirsher 
544dee1ad47SJeff Kirsher 	u64 tx_busy;
545dee1ad47SJeff Kirsher 	unsigned int tx_ring_count;
546dee1ad47SJeff Kirsher 	unsigned int rx_ring_count;
547dee1ad47SJeff Kirsher 
548dee1ad47SJeff Kirsher 	u32 link_speed;
549dee1ad47SJeff Kirsher 	bool link_up;
550dee1ad47SJeff Kirsher 	unsigned long link_check_timeout;
551dee1ad47SJeff Kirsher 
552dee1ad47SJeff Kirsher 	struct timer_list service_timer;
55346646e61SAlexander Duyck 	struct work_struct service_task;
55446646e61SAlexander Duyck 
55546646e61SAlexander Duyck 	struct hlist_head fdir_filter_list;
55646646e61SAlexander Duyck 	unsigned long fdir_overflow; /* number of times ATR was backed off */
55746646e61SAlexander Duyck 	union ixgbe_atr_input fdir_mask;
55846646e61SAlexander Duyck 	int fdir_filter_count;
559dee1ad47SJeff Kirsher 	u32 fdir_pballoc;
560dee1ad47SJeff Kirsher 	u32 atr_sample_rate;
561dee1ad47SJeff Kirsher 	spinlock_t fdir_perfect_lock;
56246646e61SAlexander Duyck 
563dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
564dee1ad47SJeff Kirsher 	struct ixgbe_fcoe fcoe;
565dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
566dee1ad47SJeff Kirsher 	u32 wol;
56746646e61SAlexander Duyck 
56846646e61SAlexander Duyck 	u16 bd_number;
56946646e61SAlexander Duyck 
57015e5209fSEmil Tantilov 	u16 eeprom_verh;
57115e5209fSEmil Tantilov 	u16 eeprom_verl;
572c23f5b6bSEmil Tantilov 	u16 eeprom_cap;
573dee1ad47SJeff Kirsher 
574dee1ad47SJeff Kirsher 	u32 interrupt_event;
57546646e61SAlexander Duyck 	u32 led_reg;
576dee1ad47SJeff Kirsher 
5773a6a4edaSJacob Keller 	struct ptp_clock *ptp_clock;
5783a6a4edaSJacob Keller 	struct ptp_clock_info ptp_caps;
579891dc082SJacob Keller 	struct work_struct ptp_tx_work;
580891dc082SJacob Keller 	struct sk_buff *ptp_tx_skb;
581891dc082SJacob Keller 	unsigned long ptp_tx_start;
5823a6a4edaSJacob Keller 	unsigned long last_overflow_check;
5836cb562d6SJacob Keller 	unsigned long last_rx_ptp_check;
5843a6a4edaSJacob Keller 	spinlock_t tmreg_lock;
5853a6a4edaSJacob Keller 	struct cyclecounter cc;
5863a6a4edaSJacob Keller 	struct timecounter tc;
5873a6a4edaSJacob Keller 	u32 base_incval;
5883a6a4edaSJacob Keller 
589dee1ad47SJeff Kirsher 	/* SR-IOV */
590dee1ad47SJeff Kirsher 	DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
591dee1ad47SJeff Kirsher 	unsigned int num_vfs;
592dee1ad47SJeff Kirsher 	struct vf_data_storage *vfinfo;
593dee1ad47SJeff Kirsher 	int vf_rate_link_speed;
594dee1ad47SJeff Kirsher 	struct vf_macvlans vf_mvs;
595dee1ad47SJeff Kirsher 	struct vf_macvlans *mv_list;
596dee1ad47SJeff Kirsher 
59783c61fa9SGreg Rose 	u32 timer_event_accumulator;
59883c61fa9SGreg Rose 	u32 vferr_refcount;
5993ca8bc6dSDon Skidmore 	struct kobject *info_kobj;
6003ca8bc6dSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
6013ca8bc6dSDon Skidmore 	struct hwmon_buff ixgbe_hwmon_buff;
6023ca8bc6dSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
60300949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
60400949167SCatherine Sullivan 	struct dentry *ixgbe_dbg_adapter;
60500949167SCatherine Sullivan #endif /*CONFIG_DEBUG_FS*/
606107d3018SAlexander Duyck 
607107d3018SAlexander Duyck 	u8 default_up;
608dee1ad47SJeff Kirsher };
609dee1ad47SJeff Kirsher 
610dee1ad47SJeff Kirsher struct ixgbe_fdir_filter {
611dee1ad47SJeff Kirsher 	struct hlist_node fdir_node;
612dee1ad47SJeff Kirsher 	union ixgbe_atr_input filter;
613dee1ad47SJeff Kirsher 	u16 sw_idx;
614dee1ad47SJeff Kirsher 	u16 action;
615dee1ad47SJeff Kirsher };
616dee1ad47SJeff Kirsher 
61770e5576cSDon Skidmore enum ixgbe_state_t {
618dee1ad47SJeff Kirsher 	__IXGBE_TESTING,
619dee1ad47SJeff Kirsher 	__IXGBE_RESETTING,
620dee1ad47SJeff Kirsher 	__IXGBE_DOWN,
621dee1ad47SJeff Kirsher 	__IXGBE_SERVICE_SCHED,
622dee1ad47SJeff Kirsher 	__IXGBE_IN_SFP_INIT,
623dee1ad47SJeff Kirsher };
624dee1ad47SJeff Kirsher 
6254c1975d7SAlexander Duyck struct ixgbe_cb {
6264c1975d7SAlexander Duyck 	union {				/* Union defining head/tail partner */
6274c1975d7SAlexander Duyck 		struct sk_buff *head;
6284c1975d7SAlexander Duyck 		struct sk_buff *tail;
6294c1975d7SAlexander Duyck 	};
630dee1ad47SJeff Kirsher 	dma_addr_t dma;
6314c1975d7SAlexander Duyck 	u16 append_cnt;
632f800326dSAlexander Duyck 	bool page_released;
633dee1ad47SJeff Kirsher };
6344c1975d7SAlexander Duyck #define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
635dee1ad47SJeff Kirsher 
636dee1ad47SJeff Kirsher enum ixgbe_boards {
637dee1ad47SJeff Kirsher 	board_82598,
638dee1ad47SJeff Kirsher 	board_82599,
639dee1ad47SJeff Kirsher 	board_X540,
640dee1ad47SJeff Kirsher };
641dee1ad47SJeff Kirsher 
642dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82598_info;
643dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_82599_info;
644dee1ad47SJeff Kirsher extern struct ixgbe_info ixgbe_X540_info;
645dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
646dee1ad47SJeff Kirsher extern const struct dcbnl_rtnl_ops dcbnl_ops;
647dee1ad47SJeff Kirsher #endif
648dee1ad47SJeff Kirsher 
649dee1ad47SJeff Kirsher extern char ixgbe_driver_name[];
650dee1ad47SJeff Kirsher extern const char ixgbe_driver_version[];
6518af3c33fSJeff Kirsher #ifdef IXGBE_FCOE
652ea81875aSNeerav Parikh extern char ixgbe_default_device_descr[];
6538af3c33fSJeff Kirsher #endif /* IXGBE_FCOE */
654dee1ad47SJeff Kirsher 
655c7ccde0fSAlexander Duyck extern void ixgbe_up(struct ixgbe_adapter *adapter);
656dee1ad47SJeff Kirsher extern void ixgbe_down(struct ixgbe_adapter *adapter);
657dee1ad47SJeff Kirsher extern void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
658dee1ad47SJeff Kirsher extern void ixgbe_reset(struct ixgbe_adapter *adapter);
659dee1ad47SJeff Kirsher extern void ixgbe_set_ethtool_ops(struct net_device *netdev);
660dee1ad47SJeff Kirsher extern int ixgbe_setup_rx_resources(struct ixgbe_ring *);
661dee1ad47SJeff Kirsher extern int ixgbe_setup_tx_resources(struct ixgbe_ring *);
662dee1ad47SJeff Kirsher extern void ixgbe_free_rx_resources(struct ixgbe_ring *);
663dee1ad47SJeff Kirsher extern void ixgbe_free_tx_resources(struct ixgbe_ring *);
664dee1ad47SJeff Kirsher extern void ixgbe_configure_rx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
665dee1ad47SJeff Kirsher extern void ixgbe_configure_tx_ring(struct ixgbe_adapter *,struct ixgbe_ring *);
666dee1ad47SJeff Kirsher extern void ixgbe_disable_rx_queue(struct ixgbe_adapter *adapter,
667dee1ad47SJeff Kirsher 				   struct ixgbe_ring *);
668dee1ad47SJeff Kirsher extern void ixgbe_update_stats(struct ixgbe_adapter *adapter);
669dee1ad47SJeff Kirsher extern int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
6708e2813f5SJacob Keller extern int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
6718e2813f5SJacob Keller 			       u16 subdevice_id);
672dee1ad47SJeff Kirsher extern void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
673dee1ad47SJeff Kirsher extern netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *,
674dee1ad47SJeff Kirsher 					 struct ixgbe_adapter *,
675dee1ad47SJeff Kirsher 					 struct ixgbe_ring *);
676dee1ad47SJeff Kirsher extern void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *,
677dee1ad47SJeff Kirsher                                              struct ixgbe_tx_buffer *);
678dee1ad47SJeff Kirsher extern void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
679dee1ad47SJeff Kirsher extern void ixgbe_write_eitr(struct ixgbe_q_vector *);
6808af3c33fSJeff Kirsher extern int ixgbe_poll(struct napi_struct *napi, int budget);
681dee1ad47SJeff Kirsher extern int ethtool_ioctl(struct ifreq *ifr);
682dee1ad47SJeff Kirsher extern s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
683dee1ad47SJeff Kirsher extern s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
684dee1ad47SJeff Kirsher extern s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
685dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
686dee1ad47SJeff Kirsher 						 union ixgbe_atr_hash_dword input,
687dee1ad47SJeff Kirsher 						 union ixgbe_atr_hash_dword common,
688dee1ad47SJeff Kirsher                                                  u8 queue);
689dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
690dee1ad47SJeff Kirsher 					   union ixgbe_atr_input *input_mask);
691dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
692dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *input,
693dee1ad47SJeff Kirsher 						 u16 soft_id, u8 queue);
694dee1ad47SJeff Kirsher extern s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
695dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *input,
696dee1ad47SJeff Kirsher 						 u16 soft_id);
697dee1ad47SJeff Kirsher extern void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
698dee1ad47SJeff Kirsher 						 union ixgbe_atr_input *mask);
699d7bbcd32SDon Skidmore extern bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
700dee1ad47SJeff Kirsher extern void ixgbe_set_rx_mode(struct net_device *netdev);
7018af3c33fSJeff Kirsher #ifdef CONFIG_IXGBE_DCB
7023ebe8fdeSAlexander Duyck extern void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
703dee1ad47SJeff Kirsher extern int ixgbe_setup_tc(struct net_device *dev, u8 tc);
7048af3c33fSJeff Kirsher #endif
705dee1ad47SJeff Kirsher extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
706dee1ad47SJeff Kirsher extern void ixgbe_do_reset(struct net_device *netdev);
7071210982bSDon Skidmore #ifdef CONFIG_IXGBE_HWMON
7083ca8bc6dSDon Skidmore extern void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
7093ca8bc6dSDon Skidmore extern int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
7101210982bSDon Skidmore #endif /* CONFIG_IXGBE_HWMON */
711dee1ad47SJeff Kirsher #ifdef IXGBE_FCOE
712dee1ad47SJeff Kirsher extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
713fd0db0edSAlexander Duyck extern int ixgbe_fso(struct ixgbe_ring *tx_ring,
714fd0db0edSAlexander Duyck 		     struct ixgbe_tx_buffer *first,
715244e27adSAlexander Duyck 		     u8 *hdr_len);
716dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
717dee1ad47SJeff Kirsher 			  union ixgbe_adv_rx_desc *rx_desc,
718f56e0cb1SAlexander Duyck 			  struct sk_buff *skb);
719dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
720dee1ad47SJeff Kirsher                               struct scatterlist *sgl, unsigned int sgc);
721dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
722dee1ad47SJeff Kirsher 				 struct scatterlist *sgl, unsigned int sgc);
723dee1ad47SJeff Kirsher extern int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
7247c8ae65aSAlexander Duyck extern int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
7257c8ae65aSAlexander Duyck extern void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
726dee1ad47SJeff Kirsher extern int ixgbe_fcoe_enable(struct net_device *netdev);
727dee1ad47SJeff Kirsher extern int ixgbe_fcoe_disable(struct net_device *netdev);
728dee1ad47SJeff Kirsher #ifdef CONFIG_IXGBE_DCB
729dee1ad47SJeff Kirsher extern u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter);
730dee1ad47SJeff Kirsher extern u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);
731dee1ad47SJeff Kirsher #endif /* CONFIG_IXGBE_DCB */
732dee1ad47SJeff Kirsher extern int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
733ea81875aSNeerav Parikh extern int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
734ea81875aSNeerav Parikh 				  struct netdev_fcoe_hbainfo *info);
735800bd607SAlexander Duyck extern u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
736dee1ad47SJeff Kirsher #endif /* IXGBE_FCOE */
73700949167SCatherine Sullivan #ifdef CONFIG_DEBUG_FS
73800949167SCatherine Sullivan extern void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
73900949167SCatherine Sullivan extern void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
74000949167SCatherine Sullivan extern void ixgbe_dbg_init(void);
74100949167SCatherine Sullivan extern void ixgbe_dbg_exit(void);
74200949167SCatherine Sullivan #endif /* CONFIG_DEBUG_FS */
743b2d96e0aSAlexander Duyck static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
744b2d96e0aSAlexander Duyck {
745b2d96e0aSAlexander Duyck 	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
746b2d96e0aSAlexander Duyck }
747b2d96e0aSAlexander Duyck 
7483a6a4edaSJacob Keller extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
7493a6a4edaSJacob Keller extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
7503a6a4edaSJacob Keller extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
7516cb562d6SJacob Keller extern void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
75239dfb71bSAlexander Duyck extern void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,
7533a6a4edaSJacob Keller 				    struct sk_buff *skb);
75439dfb71bSAlexander Duyck static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
75539dfb71bSAlexander Duyck 					 union ixgbe_adv_rx_desc *rx_desc,
75639dfb71bSAlexander Duyck 					 struct sk_buff *skb)
75739dfb71bSAlexander Duyck {
75839dfb71bSAlexander Duyck 	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
75939dfb71bSAlexander Duyck 		return;
76039dfb71bSAlexander Duyck 
76139dfb71bSAlexander Duyck 	__ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb);
76239dfb71bSAlexander Duyck 
76339dfb71bSAlexander Duyck 	/*
76439dfb71bSAlexander Duyck 	 * Update the last_rx_timestamp timer in order to enable watchdog check
76539dfb71bSAlexander Duyck 	 * for error case of latched timestamp on a dropped packet.
76639dfb71bSAlexander Duyck 	 */
76739dfb71bSAlexander Duyck 	rx_ring->last_rx_timestamp = jiffies;
76839dfb71bSAlexander Duyck }
76939dfb71bSAlexander Duyck 
7703a6a4edaSJacob Keller extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,
7713a6a4edaSJacob Keller 				    struct ifreq *ifr, int cmd);
7723a6a4edaSJacob Keller extern void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
7731a71ab24SJacob Keller extern void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
774681ae1adSJacob E Keller extern void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr);
775da36b647SGreg Rose #ifdef CONFIG_PCI_IOV
776da36b647SGreg Rose void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
777da36b647SGreg Rose #endif
7783a6a4edaSJacob Keller 
779dee1ad47SJeff Kirsher #endif /* _IXGBE_H_ */
780