blob: 89e709ce19475cb02c0131416d4f8617e098e014 [file] [log] [blame]
Jeff Kirsherae06c702018-03-22 10:08:48 -07001/* SPDX-License-Identifier: GPL-2.0 */
Jeff Kirsher51dce242018-04-26 08:08:09 -07002/* Copyright(c) 1999 - 2018 Intel Corporation. */
Auke Kok9a799d72007-09-15 14:07:45 -07003
4#ifndef _IXGBE_H_
5#define _IXGBE_H_
6
Jesse Grossf62bbb52010-10-20 13:56:10 +00007#include <linux/bitops.h>
Auke Kok9a799d72007-09-15 14:07:45 -07008#include <linux/types.h>
9#include <linux/pci.h>
10#include <linux/netdevice.h>
Peter Waskiewiczb25ebfd2010-10-05 01:27:49 +000011#include <linux/cpumask.h>
Peter P Waskiewicz Jr6fabd712008-12-10 01:13:08 -080012#include <linux/aer.h>
Jesse Grossf62bbb52010-10-20 13:56:10 +000013#include <linux/if_vlan.h>
Jacob Keller6cb562d2012-12-05 07:24:41 +000014#include <linux/jiffies.h>
Auke Kok9a799d72007-09-15 14:07:45 -070015
Richard Cochran74d23cc2014-12-21 19:46:56 +010016#include <linux/timecounter.h>
Jacob Keller3a6a4ed2012-05-01 05:24:58 +000017#include <linux/net_tstamp.h>
18#include <linux/ptp_clock_kernel.h>
Jacob Keller3a6a4ed2012-05-01 05:24:58 +000019
Auke Kok9a799d72007-09-15 14:07:45 -070020#include "ixgbe_type.h"
21#include "ixgbe_common.h"
Alexander Duyck2f90b862008-11-20 20:52:10 -080022#include "ixgbe_dcb.h"
Javier Martinez Canillasee58c112016-09-12 10:03:39 -040023#if IS_ENABLED(CONFIG_FCOE)
Yi Zoueacd73f2009-05-13 13:11:06 +000024#define IXGBE_FCOE
25#include "ixgbe_fcoe.h"
Javier Martinez Canillasee58c112016-09-12 10:03:39 -040026#endif /* IS_ENABLED(CONFIG_FCOE) */
Jeff Garzik5dd2d332008-10-16 05:09:31 -040027#ifdef CONFIG_IXGBE_DCA
Jeb Cramerbd0362d2008-03-03 15:04:02 -080028#include <linux/dca.h>
29#endif
Shannon Nelson8bbbc5e2017-12-19 15:59:54 -080030#include "ixgbe_ipsec.h"
Auke Kok9a799d72007-09-15 14:07:45 -070031
Jesper Dangaard Brouer99ffc5a2018-01-03 11:25:29 +010032#include <net/xdp.h>
Eliezer Tamir076bb0c2013-07-10 17:13:17 +030033#include <net/busy_poll.h>
Eliezer Tamir5a85e732013-06-10 11:40:20 +030034
Emil Tantilov849c4542010-06-03 16:53:41 +000035/* common prefix used by pr_<> macros */
36#undef pr_fmt
37#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Auke Kok9a799d72007-09-15 14:07:45 -070038
39/* TX/RX descriptor defines */
Jesse Brandeburg6bacb302009-12-03 11:33:07 +000040#define IXGBE_DEFAULT_TXD 512
Alexander Duyck59224552011-08-31 00:01:06 +000041#define IXGBE_DEFAULT_TX_WORK 256
Auke Kok9a799d72007-09-15 14:07:45 -070042#define IXGBE_MAX_TXD 4096
43#define IXGBE_MIN_TXD 64
44
Anton Blanchardfb445192013-10-22 18:34:01 +000045#if (PAGE_SIZE < 8192)
Jesse Brandeburg6bacb302009-12-03 11:33:07 +000046#define IXGBE_DEFAULT_RXD 512
Anton Blanchardfb445192013-10-22 18:34:01 +000047#else
48#define IXGBE_DEFAULT_RXD 128
49#endif
Auke Kok9a799d72007-09-15 14:07:45 -070050#define IXGBE_MAX_RXD 4096
51#define IXGBE_MIN_RXD 64
52
Don Skidmore5b7f0002015-01-28 07:03:38 +000053#define IXGBE_ETH_P_LLDP 0x88CC
54
Auke Kok9a799d72007-09-15 14:07:45 -070055/* flow control */
Jesse Brandeburg2b9ade92008-08-26 04:27:10 -070056#define IXGBE_MIN_FCRTL 0x40
Auke Kok9a799d72007-09-15 14:07:45 -070057#define IXGBE_MAX_FCRTL 0x7FF80
Jesse Brandeburg2b9ade92008-08-26 04:27:10 -070058#define IXGBE_MIN_FCRTH 0x600
Auke Kok9a799d72007-09-15 14:07:45 -070059#define IXGBE_MAX_FCRTH 0x7FFF0
Jesse Brandeburg2b9ade92008-08-26 04:27:10 -070060#define IXGBE_DEFAULT_FCPAUSE 0xFFFF
Auke Kok9a799d72007-09-15 14:07:45 -070061#define IXGBE_MIN_FCPAUSE 0
62#define IXGBE_MAX_FCPAUSE 0xFFFF
63
64/* Supported Rx Buffer Sizes */
Alexander Duyck252562c2012-05-24 01:59:27 +000065#define IXGBE_RXBUFFER_256 256 /* Used for skb receive header */
Alexander Duyck541ea692017-03-02 15:01:05 -080066#define IXGBE_RXBUFFER_1536 1536
Alexander Duyck09816fb2012-07-20 08:08:23 +000067#define IXGBE_RXBUFFER_2K 2048
68#define IXGBE_RXBUFFER_3K 3072
69#define IXGBE_RXBUFFER_4K 4096
Alexander Duyck919e78a2011-08-26 09:52:38 +000070#define IXGBE_MAX_RXBUFFER 16384 /* largest size for a single descriptor */
Auke Kok9a799d72007-09-15 14:07:45 -070071
Alexander Duyck541ea692017-03-02 15:01:05 -080072/* Attempt to maximize the headroom available for incoming frames. We
73 * use a 2K buffer for receives and need 1536/1534 to store the data for
74 * the frame. This leaves us with 512 bytes of room. From that we need
75 * to deduct the space needed for the shared info and the padding needed
76 * to IP align the frame.
77 *
78 * Note: For cache line sizes 256 or larger this value is going to end
79 * up negative. In these cases we should fall back to the 3K
80 * buffers.
81 */
Alexander Duyck2de6aa32017-01-17 08:36:54 -080082#if (PAGE_SIZE < 8192)
Alexander Duyck541ea692017-03-02 15:01:05 -080083#define IXGBE_MAX_2K_FRAME_BUILD_SKB (IXGBE_RXBUFFER_1536 - NET_IP_ALIGN)
84#define IXGBE_2K_TOO_SMALL_WITH_PADDING \
85((NET_SKB_PAD + IXGBE_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IXGBE_RXBUFFER_2K))
86
87static inline int ixgbe_compute_pad(int rx_buf_len)
88{
89 int page_size, pad_size;
90
91 page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
92 pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len;
93
94 return pad_size;
95}
96
97static inline int ixgbe_skb_pad(void)
98{
99 int rx_buf_len;
100
101 /* If a 2K buffer cannot handle a standard Ethernet frame then
102 * optimize padding for a 3K buffer instead of a 1.5K buffer.
103 *
104 * For a 3K buffer we need to add enough padding to allow for
105 * tailroom due to NET_IP_ALIGN possibly shifting us out of
106 * cache-line alignment.
107 */
108 if (IXGBE_2K_TOO_SMALL_WITH_PADDING)
109 rx_buf_len = IXGBE_RXBUFFER_3K + SKB_DATA_ALIGN(NET_IP_ALIGN);
110 else
111 rx_buf_len = IXGBE_RXBUFFER_1536;
112
113 /* if needed make room for NET_IP_ALIGN */
114 rx_buf_len -= NET_IP_ALIGN;
115
116 return ixgbe_compute_pad(rx_buf_len);
117}
118
119#define IXGBE_SKB_PAD ixgbe_skb_pad()
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800120#else
Alexander Duyck541ea692017-03-02 15:01:05 -0800121#define IXGBE_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800122#endif
123
Alexander Duyck13958072010-08-19 13:37:21 +0000124/*
Alexander Duyck252562c2012-05-24 01:59:27 +0000125 * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
126 * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
127 * this adds up to 448 bytes of extra data.
128 *
129 * Since netdev_alloc_skb now allocates a page fragment we can use a value
130 * of 256 and the resultant skb will have a truesize of 960 or less.
Alexander Duyck13958072010-08-19 13:37:21 +0000131 */
Alexander Duyck252562c2012-05-24 01:59:27 +0000132#define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
Auke Kok9a799d72007-09-15 14:07:45 -0700133
Auke Kok9a799d72007-09-15 14:07:45 -0700134/* How many Rx Buffers do we bundle into one write to the hardware ? */
135#define IXGBE_RX_BUFFER_WRITE 16 /* Must be power of 2 */
136
Alexander Duyckf3213d92017-01-17 08:35:54 -0800137#define IXGBE_RX_DMA_ATTR \
138 (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
139
Alexander Duyck472148c2012-11-07 02:34:28 +0000140enum ixgbe_tx_flags {
141 /* cmd_type flags */
142 IXGBE_TX_FLAGS_HW_VLAN = 0x01,
143 IXGBE_TX_FLAGS_TSO = 0x02,
144 IXGBE_TX_FLAGS_TSTAMP = 0x04,
145
146 /* olinfo flags */
147 IXGBE_TX_FLAGS_CC = 0x08,
148 IXGBE_TX_FLAGS_IPV4 = 0x10,
149 IXGBE_TX_FLAGS_CSUM = 0x20,
Shannon Nelson59259472017-12-19 16:00:00 -0800150 IXGBE_TX_FLAGS_IPSEC = 0x40,
Alexander Duyck472148c2012-11-07 02:34:28 +0000151
152 /* software defined flags */
Shannon Nelson59259472017-12-19 16:00:00 -0800153 IXGBE_TX_FLAGS_SW_VLAN = 0x80,
154 IXGBE_TX_FLAGS_FCOE = 0x100,
Alexander Duyck472148c2012-11-07 02:34:28 +0000155};
156
157/* VLAN info */
Auke Kok9a799d72007-09-15 14:07:45 -0700158#define IXGBE_TX_FLAGS_VLAN_MASK 0xffff0000
Alexander Duyck66f32a82011-06-29 05:43:22 +0000159#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000
160#define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT 29
Auke Kok9a799d72007-09-15 14:07:45 -0700161#define IXGBE_TX_FLAGS_VLAN_SHIFT 16
162
Greg Rose7f870472010-01-09 02:25:29 +0000163#define IXGBE_MAX_VF_MC_ENTRIES 30
164#define IXGBE_MAX_VF_FUNCTIONS 64
165#define IXGBE_MAX_VFTA_ENTRIES 128
166#define MAX_EMULATION_MAC_ADDRS 16
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000167#define IXGBE_MAX_PF_MACVLANS 15
Alexander Duyck1d9c0bf2012-05-05 05:32:21 +0000168#define VMDQ_P(p) ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
Greg Rose83c61fa2011-09-07 05:59:35 +0000169#define IXGBE_82599_VF_DEVICE_ID 0x10ED
170#define IXGBE_X540_VF_DEVICE_ID 0x1515
Greg Rose7f870472010-01-09 02:25:29 +0000171
172struct vf_data_storage {
Mark Rustad988d1302015-10-30 15:29:34 -0700173 struct pci_dev *vfdev;
Greg Rose7f870472010-01-09 02:25:29 +0000174 unsigned char vf_mac_addresses[ETH_ALEN];
175 u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
176 u16 num_vf_mc_hashes;
Greg Rose7f870472010-01-09 02:25:29 +0000177 bool clear_to_send;
Greg Rose7f016482010-05-04 22:12:06 +0000178 bool pf_set_mac;
Greg Rose7f016482010-05-04 22:12:06 +0000179 u16 pf_vlan; /* When set, guest VLAN config not allowed. */
180 u16 pf_qos;
Lior Levyff4ab202011-03-11 02:03:07 +0000181 u16 tx_rate;
Greg Rosede4c7f62011-09-29 05:57:33 +0000182 u8 spoofchk_enabled;
Vlad Zolotarove65ce0d2015-03-30 21:35:24 +0300183 bool rss_query_enabled;
Hiroshi Shimamoto54011e42015-08-28 06:58:33 +0000184 u8 trusted;
Hiroshi Shimamoto8443c1a42015-08-28 06:59:03 +0000185 int xcast_mode;
Alexander Duyck374c65d2012-07-20 08:09:22 +0000186 unsigned int vf_api;
Greg Rose7f870472010-01-09 02:25:29 +0000187};
188
Hiroshi Shimamoto8443c1a42015-08-28 06:59:03 +0000189enum ixgbevf_xcast_modes {
190 IXGBEVF_XCAST_MODE_NONE = 0,
191 IXGBEVF_XCAST_MODE_MULTI,
192 IXGBEVF_XCAST_MODE_ALLMULTI,
Don Skidmore07eea572016-12-15 21:18:32 -0500193 IXGBEVF_XCAST_MODE_PROMISC,
Hiroshi Shimamoto8443c1a42015-08-28 06:59:03 +0000194};
195
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000196struct vf_macvlans {
197 struct list_head l;
198 int vf;
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000199 bool free;
200 bool is_macvlan;
201 u8 vf_macvlan[ETH_ALEN];
202};
203
Alexander Duycka535c302011-05-27 05:31:52 +0000204#define IXGBE_MAX_TXD_PWR 14
Jacob Kellerb4f47a42016-04-13 16:08:22 -0700205#define IXGBE_MAX_DATA_PER_TXD (1u << IXGBE_MAX_TXD_PWR)
Alexander Duycka535c302011-05-27 05:31:52 +0000206
207/* Tx Descriptors needed, worst case */
208#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
Alexander Duyck990a3152013-01-26 02:08:14 +0000209#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
Alexander Duycka535c302011-05-27 05:31:52 +0000210
Auke Kok9a799d72007-09-15 14:07:45 -0700211/* wrapper around a pointer to a socket buffer,
212 * so a DMA handle can be stored along with the buffer */
213struct ixgbe_tx_buffer {
Alexander Duyckd3d00232011-07-15 02:31:25 +0000214 union ixgbe_adv_tx_desc *next_to_watch;
Auke Kok9a799d72007-09-15 14:07:45 -0700215 unsigned long time_stamp;
John Fastabend33fdc822017-04-24 03:30:18 -0700216 union {
217 struct sk_buff *skb;
Jesper Dangaard Brouer03993092018-04-17 16:46:32 +0200218 struct xdp_frame *xdpf;
John Fastabend33fdc822017-04-24 03:30:18 -0700219 };
Alexander Duyckfd0db0e2012-02-08 07:50:56 +0000220 unsigned int bytecount;
221 unsigned short gso_segs;
Alexander Duyck244e27a2012-02-08 07:51:11 +0000222 __be16 protocol;
Alexander Duyck729739b2012-02-08 07:51:06 +0000223 DEFINE_DMA_UNMAP_ADDR(dma);
224 DEFINE_DMA_UNMAP_LEN(len);
Alexander Duyckfd0db0e2012-02-08 07:50:56 +0000225 u32 tx_flags;
Auke Kok9a799d72007-09-15 14:07:45 -0700226};
227
228struct ixgbe_rx_buffer {
229 struct sk_buff *skb;
230 dma_addr_t dma;
231 struct page *page;
Alexander Duyck1b56cf42017-01-17 08:36:03 -0800232#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
233 __u32 page_offset;
234#else
235 __u16 page_offset;
236#endif
237 __u16 pagecnt_bias;
Auke Kok9a799d72007-09-15 14:07:45 -0700238};
239
240struct ixgbe_queue_stats {
241 u64 packets;
242 u64 bytes;
243};
244
Alexander Duyck5b7da512010-11-16 19:26:50 -0800245struct ixgbe_tx_queue_stats {
246 u64 restart_queue;
247 u64 tx_busy;
John Fastabendc84d3242010-11-16 19:27:12 -0800248 u64 tx_done_old;
Alexander Duyck5b7da512010-11-16 19:26:50 -0800249};
250
251struct ixgbe_rx_queue_stats {
252 u64 rsc_count;
253 u64 rsc_flush;
254 u64 non_eop_descs;
Jesper Dangaard Brouer86e23492017-09-04 20:40:22 +0200255 u64 alloc_rx_page;
Alexander Duyck5b7da512010-11-16 19:26:50 -0800256 u64 alloc_rx_page_failed;
257 u64 alloc_rx_buff_failed;
Alexander Duyck8a0da212012-01-31 02:59:49 +0000258 u64 csum_err;
Alexander Duyck5b7da512010-11-16 19:26:50 -0800259};
260
Mark Rustada9763f32015-10-27 09:58:07 -0700261#define IXGBE_TS_HDR_LEN 8
262
Alexander Duyckf8003262012-03-03 02:35:52 +0000263enum ixgbe_ring_state_t {
Alexander Duyck4f4542b2017-01-17 08:36:14 -0800264 __IXGBE_RX_3K_BUFFER,
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800265 __IXGBE_RX_BUILD_SKB_ENABLED,
Alexander Duyck4f4542b2017-01-17 08:36:14 -0800266 __IXGBE_RX_RSC_ENABLED,
267 __IXGBE_RX_CSUM_UDP_ZERO_ERR,
268 __IXGBE_RX_FCOE,
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800269 __IXGBE_TX_FDIR_INIT_DONE,
Alexander Duyckfd786b72013-01-12 06:33:31 +0000270 __IXGBE_TX_XPS_INIT_DONE,
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800271 __IXGBE_TX_DETECT_HANG,
John Fastabendc84d3242010-11-16 19:27:12 -0800272 __IXGBE_HANG_CHECK_ARMED,
John Fastabend33fdc822017-04-24 03:30:18 -0700273 __IXGBE_TX_XDP_RING,
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800274};
275
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800276#define ring_uses_build_skb(ring) \
277 test_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &(ring)->state)
278
John Fastabend2a47fa42013-11-06 09:54:52 -0800279struct ixgbe_fwd_adapter {
280 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
281 struct net_device *netdev;
John Fastabend2a47fa42013-11-06 09:54:52 -0800282 unsigned int tx_base_queue;
283 unsigned int rx_base_queue;
284 int pool;
285};
286
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800287#define check_for_tx_hang(ring) \
288 test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
289#define set_check_for_tx_hang(ring) \
290 set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
291#define clear_check_for_tx_hang(ring) \
292 clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
293#define ring_is_rsc_enabled(ring) \
294 test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
295#define set_ring_rsc_enabled(ring) \
296 set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
297#define clear_ring_rsc_enabled(ring) \
298 clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
John Fastabend33fdc822017-04-24 03:30:18 -0700299#define ring_is_xdp(ring) \
300 test_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
301#define set_ring_xdp(ring) \
302 set_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
303#define clear_ring_xdp(ring) \
304 clear_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
Auke Kok9a799d72007-09-15 14:07:45 -0700305struct ixgbe_ring {
Alexander Duyckefe3d3c2011-07-15 03:05:21 +0000306 struct ixgbe_ring *next; /* pointer to next ring in q_vector */
Alexander Duyckd3ee4292012-02-08 07:51:16 +0000307 struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
308 struct net_device *netdev; /* netdev ring belongs to */
John Fastabend92470802017-04-24 03:30:17 -0700309 struct bpf_prog *xdp_prog;
Alexander Duyckd3ee4292012-02-08 07:51:16 +0000310 struct device *dev; /* device for DMA mapping */
Auke Kok9a799d72007-09-15 14:07:45 -0700311 void *desc; /* descriptor ring memory */
Auke Kok9a799d72007-09-15 14:07:45 -0700312 union {
313 struct ixgbe_tx_buffer *tx_buffer_info;
314 struct ixgbe_rx_buffer *rx_buffer_info;
315 };
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800316 unsigned long state;
Alexander Duyckbd198052011-06-11 01:45:08 +0000317 u8 __iomem *tail;
Alexander Duyckd3ee4292012-02-08 07:51:16 +0000318 dma_addr_t dma; /* phys. address of descriptor ring */
319 unsigned int size; /* length in bytes */
Alexander Duyckbd198052011-06-11 01:45:08 +0000320
Jesse Brandeburgae540af2009-06-04 16:02:04 +0000321 u16 count; /* amount of descriptors */
Jesse Brandeburgae540af2009-06-04 16:02:04 +0000322
323 u8 queue_index; /* needed for multiqueue queue management */
Alexander Duyck7d637bc2010-11-16 19:26:56 -0800324 u8 reg_idx; /* holds the special value that gets
Jesse Brandeburgae540af2009-06-04 16:02:04 +0000325 * the hardware register offset
326 * associated with this ring, which is
327 * different for DCB and RSS modes
328 */
Alexander Duyckd3ee4292012-02-08 07:51:16 +0000329 u16 next_to_use;
330 u16 next_to_clean;
331
Mark Rustada9763f32015-10-27 09:58:07 -0700332 unsigned long last_rx_timestamp;
333
Alexander Duyckf8003262012-03-03 02:35:52 +0000334 union {
Alexander Duyckd3ee4292012-02-08 07:51:16 +0000335 u16 next_to_alloc;
Alexander Duyckf8003262012-03-03 02:35:52 +0000336 struct {
337 u8 atr_sample_rate;
338 u8 atr_count;
339 };
Alexander Duyckf8003262012-03-03 02:35:52 +0000340 };
Alexander Duyckbd198052011-06-11 01:45:08 +0000341
John Fastabende5b64632011-03-08 03:44:52 +0000342 u8 dcb_tc;
Auke Kok9a799d72007-09-15 14:07:45 -0700343 struct ixgbe_queue_stats stats;
Eric Dumazetde1036b2010-10-20 23:00:04 +0000344 struct u64_stats_sync syncp;
Alexander Duyck5b7da512010-11-16 19:26:50 -0800345 union {
346 struct ixgbe_tx_queue_stats tx_stats;
347 struct ixgbe_rx_queue_stats rx_stats;
348 };
Jesper Dangaard Brouer99ffc5a2018-01-03 11:25:29 +0100349 struct xdp_rxq_info xdp_rxq;
Jesse Brandeburg7ca3bc52009-12-03 11:33:29 +0000350} ____cacheline_internodealigned_in_smp;
Auke Kok9a799d72007-09-15 14:07:45 -0700351
Shannon Nelsonc7e43582009-02-24 16:36:38 -0800352enum ixgbe_ring_f_enum {
353 RING_F_NONE = 0,
Greg Rose7f870472010-01-09 02:25:29 +0000354 RING_F_VMDQ, /* SR-IOV uses the same ring feature */
Shannon Nelsonc7e43582009-02-24 16:36:38 -0800355 RING_F_RSS,
Peter P Waskiewicz Jrc4cf55e2009-06-04 16:01:43 +0000356 RING_F_FDIR,
Yi Zou0331a832009-05-17 12:33:52 +0000357#ifdef IXGBE_FCOE
358 RING_F_FCOE,
359#endif /* IXGBE_FCOE */
Shannon Nelsonc7e43582009-02-24 16:36:38 -0800360
361 RING_F_ARRAY_SIZE /* must be last in enum set */
362};
363
Don Skidmore0f9b2322014-11-18 09:35:08 +0000364#define IXGBE_MAX_RSS_INDICES 16
Emil Tantilove9ee3232015-11-20 13:02:16 -0800365#define IXGBE_MAX_RSS_INDICES_X550 63
Don Skidmore0f9b2322014-11-18 09:35:08 +0000366#define IXGBE_MAX_VMDQ_INDICES 64
367#define IXGBE_MAX_FDIR_INDICES 63 /* based on q_vector limit */
368#define IXGBE_MAX_FCOE_INDICES 8
369#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
370#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
John Fastabend33fdc822017-04-24 03:30:18 -0700371#define MAX_XDP_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)
Don Skidmore0f9b2322014-11-18 09:35:08 +0000372#define IXGBE_MAX_L2A_QUEUES 4
373#define IXGBE_BAD_L2A_QUEUE 3
Alexander Duyck4e039c12017-11-22 10:56:40 -0800374#define IXGBE_MAX_MACVLANS 63
John Fastabend2a47fa42013-11-06 09:54:52 -0800375
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800376struct ixgbe_ring_feature {
Alexander Duyckc0876632012-05-10 00:01:46 +0000377 u16 limit; /* upper limit on feature indices */
378 u16 indices; /* current value of indices */
Alexander Duycke4b317e2012-05-05 05:30:53 +0000379 u16 mask; /* Mask used for feature to ring mapping */
380 u16 offset; /* offset to start of feature */
Jesse Brandeburg7ca3bc52009-12-03 11:33:29 +0000381} ____cacheline_internodealigned_in_smp;
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800382
Alexander Duyck73079ea2012-07-14 06:48:49 +0000383#define IXGBE_82599_VMDQ_8Q_MASK 0x78
384#define IXGBE_82599_VMDQ_4Q_MASK 0x7C
385#define IXGBE_82599_VMDQ_2Q_MASK 0x7E
386
Alexander Duyckf8003262012-03-03 02:35:52 +0000387/*
388 * FCoE requires that all Rx buffers be over 2200 bytes in length. Since
389 * this is twice the size of a half page we need to double the page order
390 * for FCoE enabled Rx queues.
391 */
Alexander Duyck09816fb2012-07-20 08:08:23 +0000392static inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
393{
Alexander Duyck4f4542b2017-01-17 08:36:14 -0800394 if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
395 return IXGBE_RXBUFFER_3K;
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800396#if (PAGE_SIZE < 8192)
397 if (ring_uses_build_skb(ring))
Alexander Duyck541ea692017-03-02 15:01:05 -0800398 return IXGBE_MAX_2K_FRAME_BUILD_SKB;
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800399#endif
Alexander Duyck09816fb2012-07-20 08:08:23 +0000400 return IXGBE_RXBUFFER_2K;
401}
402
Alexander Duyckf8003262012-03-03 02:35:52 +0000403static inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
404{
Alexander Duyck4f4542b2017-01-17 08:36:14 -0800405#if (PAGE_SIZE < 8192)
406 if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
407 return 1;
Alexander Duyckf8003262012-03-03 02:35:52 +0000408#endif
Alexander Duyck09816fb2012-07-20 08:08:23 +0000409 return 0;
410}
Alexander Duyckf8003262012-03-03 02:35:52 +0000411#define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
Alexander Duyckf8003262012-03-03 02:35:52 +0000412
Alexander Duyckb4ded832017-09-25 14:55:36 -0700413#define IXGBE_ITR_ADAPTIVE_MIN_INC 2
414#define IXGBE_ITR_ADAPTIVE_MIN_USECS 10
415#define IXGBE_ITR_ADAPTIVE_MAX_USECS 126
416#define IXGBE_ITR_ADAPTIVE_LATENCY 0x80
417#define IXGBE_ITR_ADAPTIVE_BULK 0x00
418
Alexander Duyck08c88332011-06-11 01:45:03 +0000419struct ixgbe_ring_container {
Alexander Duyckefe3d3c2011-07-15 03:05:21 +0000420 struct ixgbe_ring *ring; /* pointer to linked list of rings */
Alexander Duyckb4ded832017-09-25 14:55:36 -0700421 unsigned long next_update; /* jiffies value of last update */
Alexander Duyckbd198052011-06-11 01:45:08 +0000422 unsigned int total_bytes; /* total bytes processed this int */
423 unsigned int total_packets; /* total packets processed this int */
424 u16 work_limit; /* total work allowed per interrupt */
Alexander Duyck08c88332011-06-11 01:45:03 +0000425 u8 count; /* total number of rings in vector */
426 u8 itr; /* current ITR setting for ring */
427};
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800428
Alexander Duycka5579282012-02-08 07:50:04 +0000429/* iterator for handling rings in ring container */
430#define ixgbe_for_each_ring(pos, head) \
431 for (pos = (head).ring; pos != NULL; pos = pos->next)
432
Alexander Duyck2f90b862008-11-20 20:52:10 -0800433#define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
Jacob Kellere7cf7452014-04-09 06:03:10 +0000434 ? 8 : 1)
Alexander Duyck2f90b862008-11-20 20:52:10 -0800435#define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
436
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000437/* MAX_Q_VECTORS of these are allocated,
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800438 * but we only use one per queue-specific vector.
439 */
440struct ixgbe_q_vector {
441 struct ixgbe_adapter *adapter;
Alexander Duyck33cf09c2010-11-16 19:26:55 -0800442#ifdef CONFIG_IXGBE_DCA
443 int cpu; /* CPU for DCA */
444#endif
Emil Tantilovd5bf4f62011-08-31 00:01:16 +0000445 u16 v_idx; /* index of q_vector within array, also used for
446 * finding the bit in EICR and friends that
447 * represents the vector for this ring */
448 u16 itr; /* Interrupt throttle rate written to EITR */
Alexander Duyck08c88332011-06-11 01:45:03 +0000449 struct ixgbe_ring_container rx, tx;
Emil Tantilovd5bf4f62011-08-31 00:01:16 +0000450
451 struct napi_struct napi;
Alexander Duyckde88eee2012-02-08 07:49:59 +0000452 cpumask_t affinity_mask;
453 int numa_node;
454 struct rcu_head rcu; /* to avoid race with update stats on free */
Alexander Duyckd0759eb2010-11-16 19:27:09 -0800455 char name[IFNAMSIZ + 9];
Alexander Duyckde88eee2012-02-08 07:49:59 +0000456
457 /* for dynamic allocation of rings associated with this q_vector */
458 struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp;
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800459};
Alexander Duyckadc810902014-07-26 02:42:44 +0000460
Don Skidmore3ca8bc62012-04-12 00:33:31 +0000461#ifdef CONFIG_IXGBE_HWMON
462
463#define IXGBE_HWMON_TYPE_LOC 0
464#define IXGBE_HWMON_TYPE_TEMP 1
465#define IXGBE_HWMON_TYPE_CAUTION 2
466#define IXGBE_HWMON_TYPE_MAX 3
467
468struct hwmon_attr {
469 struct device_attribute dev_attr;
470 struct ixgbe_hw *hw;
471 struct ixgbe_thermal_diode_data *sensor;
472 char name[12];
473};
474
475struct hwmon_buff {
Guenter Roeck03b77d82013-11-26 07:15:28 +0000476 struct attribute_group group;
477 const struct attribute_group *groups[2];
478 struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
479 struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
Don Skidmore3ca8bc62012-04-12 00:33:31 +0000480 unsigned int n_hwmon;
481};
482#endif /* CONFIG_IXGBE_HWMON */
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800483
Emil Tantilovd5bf4f62011-08-31 00:01:16 +0000484/*
485 * microsecond values for various ITR rates shifted by 2 to fit itr register
486 * with the first 3 bits reserved 0
Auke Kok9a799d72007-09-15 14:07:45 -0700487 */
Emil Tantilovd5bf4f62011-08-31 00:01:16 +0000488#define IXGBE_MIN_RSC_ITR 24
489#define IXGBE_100K_ITR 40
490#define IXGBE_20K_ITR 200
Alexander Duyck8ac34f12015-07-30 15:19:28 -0700491#define IXGBE_12K_ITR 336
Auke Kok9a799d72007-09-15 14:07:45 -0700492
Alexander Duyckf56e0cb2012-01-31 02:59:39 +0000493/* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
494static inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
495 const u32 stat_err_bits)
496{
497 return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
498}
499
Alexander Duyck7d4987d2011-05-27 05:31:37 +0000500static inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
501{
502 u16 ntc = ring->next_to_clean;
503 u16 ntu = ring->next_to_use;
504
505 return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
506}
Auke Kok9a799d72007-09-15 14:07:45 -0700507
Alexander Duycke4f74022012-01-31 02:59:44 +0000508#define IXGBE_RX_DESC(R, i) \
Alexander Duyck31f05a22010-08-19 13:40:31 +0000509 (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
Alexander Duycke4f74022012-01-31 02:59:44 +0000510#define IXGBE_TX_DESC(R, i) \
Alexander Duyck31f05a22010-08-19 13:40:31 +0000511 (&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
Alexander Duycke4f74022012-01-31 02:59:44 +0000512#define IXGBE_TX_CTXTDESC(R, i) \
Alexander Duyck31f05a22010-08-19 13:40:31 +0000513 (&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
Auke Kok9a799d72007-09-15 14:07:45 -0700514
Alexander Duyckc88887e2012-08-22 02:04:37 +0000515#define IXGBE_MAX_JUMBO_FRAME_SIZE 9728 /* Maximum Supported Size 9.5KB */
Yi Zou63f39bd2009-05-17 12:34:35 +0000516#ifdef IXGBE_FCOE
517/* Use 3K as the baby jumbo frame size for FCoE */
518#define IXGBE_FCOE_JUMBO_FRAME_SIZE 3072
519#endif /* IXGBE_FCOE */
Auke Kok9a799d72007-09-15 14:07:45 -0700520
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800521#define OTHER_VECTOR 1
522#define NON_Q_VECTORS (OTHER_VECTOR)
523
PJ Waskiewicze8e26352009-02-27 15:45:05 +0000524#define MAX_MSIX_VECTORS_82599 64
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000525#define MAX_Q_VECTORS_82599 64
Peter P Waskiewicz Jreb7f1392009-02-01 01:18:58 -0800526#define MAX_MSIX_VECTORS_82598 18
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000527#define MAX_Q_VECTORS_82598 16
Peter P Waskiewicz Jreb7f1392009-02-01 01:18:58 -0800528
Jacob Keller5d7daa32014-03-29 06:51:25 +0000529struct ixgbe_mac_addr {
530 u8 addr[ETH_ALEN];
Alexander Duyckc9f53e62015-10-22 16:26:30 -0700531 u16 pool;
Jacob Keller5d7daa32014-03-29 06:51:25 +0000532 u16 state; /* bitmask */
533};
Alexander Duyckc9f53e62015-10-22 16:26:30 -0700534
Jacob Keller5d7daa32014-03-29 06:51:25 +0000535#define IXGBE_MAC_STATE_DEFAULT 0x1
536#define IXGBE_MAC_STATE_MODIFIED 0x2
537#define IXGBE_MAC_STATE_IN_USE 0x4
538
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000539#define MAX_Q_VECTORS MAX_Q_VECTORS_82599
PJ Waskiewicze8e26352009-02-27 15:45:05 +0000540#define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
Peter P Waskiewicz Jreb7f1392009-02-01 01:18:58 -0800541
Alexander Duyck8f154862012-02-10 02:08:37 +0000542#define MIN_MSIX_Q_VECTORS 1
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800543#define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
544
Alexander Duyck46646e62012-02-08 07:49:28 +0000545/* default to trying for four seconds */
546#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
Mark Rustad58e7cd22015-08-08 16:18:48 -0700547#define IXGBE_SFP_POLL_JIFFIES (2 * HZ) /* SFP poll every 2 seconds */
Alexander Duyck46646e62012-02-08 07:49:28 +0000548
Auke Kok9a799d72007-09-15 14:07:45 -0700549/* board specific private data structure */
550struct ixgbe_adapter {
Alexander Duyck46646e62012-02-08 07:49:28 +0000551 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
552 /* OS defined structs */
553 struct net_device *netdev;
John Fastabend92470802017-04-24 03:30:17 -0700554 struct bpf_prog *xdp_prog;
Alexander Duyck46646e62012-02-08 07:49:28 +0000555 struct pci_dev *pdev;
556
Alexander Duycke606bfe2011-04-22 04:07:43 +0000557 unsigned long state;
558
559 /* Some features need tri-state capability,
560 * thus the additional *_CAPABLE flags.
561 */
562 u32 flags;
Jacob Kellerb4f47a42016-04-13 16:08:22 -0700563#define IXGBE_FLAG_MSI_ENABLED BIT(1)
564#define IXGBE_FLAG_MSIX_ENABLED BIT(3)
565#define IXGBE_FLAG_RX_1BUF_CAPABLE BIT(4)
566#define IXGBE_FLAG_RX_PS_CAPABLE BIT(5)
567#define IXGBE_FLAG_RX_PS_ENABLED BIT(6)
568#define IXGBE_FLAG_DCA_ENABLED BIT(8)
569#define IXGBE_FLAG_DCA_CAPABLE BIT(9)
570#define IXGBE_FLAG_IMIR_ENABLED BIT(10)
571#define IXGBE_FLAG_MQ_CAPABLE BIT(11)
572#define IXGBE_FLAG_DCB_ENABLED BIT(12)
573#define IXGBE_FLAG_VMDQ_CAPABLE BIT(13)
574#define IXGBE_FLAG_VMDQ_ENABLED BIT(14)
575#define IXGBE_FLAG_FAN_FAIL_CAPABLE BIT(15)
576#define IXGBE_FLAG_NEED_LINK_UPDATE BIT(16)
577#define IXGBE_FLAG_NEED_LINK_CONFIG BIT(17)
578#define IXGBE_FLAG_FDIR_HASH_CAPABLE BIT(18)
579#define IXGBE_FLAG_FDIR_PERFECT_CAPABLE BIT(19)
580#define IXGBE_FLAG_FCOE_CAPABLE BIT(20)
581#define IXGBE_FLAG_FCOE_ENABLED BIT(21)
582#define IXGBE_FLAG_SRIOV_CAPABLE BIT(22)
583#define IXGBE_FLAG_SRIOV_ENABLED BIT(23)
Mark Rustad67359c32015-06-15 11:33:25 -0700584#define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24)
Mark Rustada9763f32015-10-27 09:58:07 -0700585#define IXGBE_FLAG_RX_HWTSTAMP_ENABLED BIT(25)
586#define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER BIT(26)
Usha Ketineni88290092016-04-26 05:00:26 -0700587#define IXGBE_FLAG_DCB_CAPABLE BIT(27)
Emil Tantilova21d0822016-08-10 11:19:23 -0700588#define IXGBE_FLAG_GENEVE_OFFLOAD_CAPABLE BIT(28)
Alexander Duycke606bfe2011-04-22 04:07:43 +0000589
590 u32 flags2;
Jacob Kellerb4f47a42016-04-13 16:08:22 -0700591#define IXGBE_FLAG2_RSC_CAPABLE BIT(0)
592#define IXGBE_FLAG2_RSC_ENABLED BIT(1)
593#define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE BIT(2)
594#define IXGBE_FLAG2_TEMP_SENSOR_EVENT BIT(3)
595#define IXGBE_FLAG2_SEARCH_FOR_SFP BIT(4)
596#define IXGBE_FLAG2_SFP_NEEDS_RESET BIT(5)
Jacob Kellerb4f47a42016-04-13 16:08:22 -0700597#define IXGBE_FLAG2_FDIR_REQUIRES_REINIT BIT(7)
598#define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP BIT(8)
599#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP BIT(9)
600#define IXGBE_FLAG2_PTP_PPS_ENABLED BIT(10)
601#define IXGBE_FLAG2_PHY_INTERRUPT BIT(11)
Emil Tantilova21d0822016-08-10 11:19:23 -0700602#define IXGBE_FLAG2_UDP_TUN_REREG_NEEDED BIT(12)
Alexander Duyck16369562015-11-02 17:10:13 -0800603#define IXGBE_FLAG2_VLAN_PROMISC BIT(13)
Mark Rustadb3eb4e12016-12-14 11:02:16 -0800604#define IXGBE_FLAG2_EEE_CAPABLE BIT(14)
605#define IXGBE_FLAG2_EEE_ENABLED BIT(15)
Alexander Duyck2de6aa32017-01-17 08:36:54 -0800606#define IXGBE_FLAG2_RX_LEGACY BIT(16)
Shannon Nelson34c822e2017-12-19 15:59:56 -0800607#define IXGBE_FLAG2_IPSEC_ENABLED BIT(17)
Shannon Nelson9e4e30c2018-08-13 11:43:41 -0700608#define IXGBE_FLAG2_VF_IPSEC_ENABLED BIT(18)
Alexander Duyck46646e62012-02-08 07:49:28 +0000609
610 /* Tx fast path data */
611 int num_tx_queues;
612 u16 tx_itr_setting;
613 u16 tx_work_limit;
Shannon Nelsona8a43fd2017-12-19 16:00:01 -0800614 u64 tx_ipsec;
Alexander Duyck46646e62012-02-08 07:49:28 +0000615
616 /* Rx fast path data */
617 int num_rx_queues;
618 u16 rx_itr_setting;
Shannon Nelsona8a43fd2017-12-19 16:00:01 -0800619 u64 rx_ipsec;
Alexander Duyck46646e62012-02-08 07:49:28 +0000620
Alexander Duyck9f12df92016-01-25 19:36:29 -0800621 /* Port number used to identify VXLAN traffic */
622 __be16 vxlan_port;
Emil Tantilova21d0822016-08-10 11:19:23 -0700623 __be16 geneve_port;
Alexander Duyck9f12df92016-01-25 19:36:29 -0800624
John Fastabend33fdc822017-04-24 03:30:18 -0700625 /* XDP */
626 int num_xdp_queues;
627 struct ixgbe_ring *xdp_ring[MAX_XDP_QUEUES];
628
Alexander Duyck46646e62012-02-08 07:49:28 +0000629 /* TX */
630 struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
631
632 u64 restart_queue;
633 u64 lsc_int;
634 u32 tx_timeout_count;
635
636 /* RX */
637 struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
638 int num_rx_pools; /* == num_rx_queues in 82598 */
639 int num_rx_queues_per_pool; /* 1 if 82598, can be many if 82599 */
640 u64 hw_csum_rx_error;
641 u64 hw_rx_no_dma_resources;
642 u64 rsc_total_count;
643 u64 rsc_total_flush;
644 u64 non_eop_descs;
Jesper Dangaard Brouer86e23492017-09-04 20:40:22 +0200645 u32 alloc_rx_page;
Alexander Duyck46646e62012-02-08 07:49:28 +0000646 u32 alloc_rx_page_failed;
647 u32 alloc_rx_buff_failed;
648
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000649 struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
John Fastabendd033d522011-02-10 14:40:01 +0000650
651 /* DCB parameters */
652 struct ieee_pfc *ixgbe_ieee_pfc;
653 struct ieee_ets *ixgbe_ieee_ets;
Alexander Duyck2f90b862008-11-20 20:52:10 -0800654 struct ixgbe_dcb_config dcb_cfg;
655 struct ixgbe_dcb_config temp_dcb_cfg;
Alexander Duyck0efbf122017-11-22 10:57:11 -0800656 u8 hw_tcs;
Alexander Duyck2f90b862008-11-20 20:52:10 -0800657 u8 dcb_set_bitmap;
John Fastabend30323092011-03-01 05:25:35 +0000658 u8 dcbx_cap;
Peter P Waskiewicz Jr264857b2009-05-17 12:35:16 +0000659 enum ixgbe_fc_mode last_lfc_mode;
Auke Kok9a799d72007-09-15 14:07:45 -0700660
Alexander Duyck49c7ffb2012-05-05 05:30:43 +0000661 int num_q_vectors; /* current number of q_vectors for device */
662 int max_q_vectors; /* true count of q_vectors for device */
Shannon Nelsonc7e43582009-02-24 16:36:38 -0800663 struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
Auke Kok9a799d72007-09-15 14:07:45 -0700664 struct msix_entry *msix_entries;
665
Peter P Waskiewicz Jrda4dd0f2009-06-04 11:10:35 +0000666 u32 test_icr;
667 struct ixgbe_ring test_tx_ring;
668 struct ixgbe_ring test_rx_ring;
669
Auke Kok9a799d72007-09-15 14:07:45 -0700670 /* structs defined in ixgbe_hw.h */
671 struct ixgbe_hw hw;
672 u16 msg_enable;
673 struct ixgbe_hw_stats stats;
Ayyappan Veeraiyan021230d2008-03-03 15:03:45 -0800674
Auke Kok9a799d72007-09-15 14:07:45 -0700675 u64 tx_busy;
Jesse Brandeburg30efa5a2008-09-11 19:58:14 -0700676 unsigned int tx_ring_count;
John Fastabend33fdc822017-04-24 03:30:18 -0700677 unsigned int xdp_ring_count;
Jesse Brandeburg30efa5a2008-09-11 19:58:14 -0700678 unsigned int rx_ring_count;
Jesse Brandeburgcf8280e2008-09-11 19:55:32 -0700679
680 u32 link_speed;
681 bool link_up;
Mark Rustad58e7cd22015-08-08 16:18:48 -0700682 unsigned long sfp_poll_time;
Jesse Brandeburgcf8280e2008-09-11 19:55:32 -0700683 unsigned long link_check_timeout;
684
Alexander Duyck70864002011-04-27 09:13:56 +0000685 struct timer_list service_timer;
Alexander Duyck46646e62012-02-08 07:49:28 +0000686 struct work_struct service_task;
687
688 struct hlist_head fdir_filter_list;
689 unsigned long fdir_overflow; /* number of times ATR was backed off */
690 union ixgbe_atr_input fdir_mask;
691 int fdir_filter_count;
Peter P Waskiewicz Jrc4cf55e2009-06-04 16:01:43 +0000692 u32 fdir_pballoc;
693 u32 atr_sample_rate;
694 spinlock_t fdir_perfect_lock;
Alexander Duyck46646e62012-02-08 07:49:28 +0000695
Yi Zoud0ed8932009-05-13 13:11:29 +0000696#ifdef IXGBE_FCOE
697 struct ixgbe_fcoe fcoe;
698#endif /* IXGBE_FCOE */
Mark Rustad2a1a0912014-01-14 18:53:15 -0800699 u8 __iomem *io_addr; /* Mainly for iounmap use */
PJ Waskiewicze8e26352009-02-27 15:45:05 +0000700 u32 wol;
Alexander Duyck46646e62012-02-08 07:49:28 +0000701
Don Skidmoreaa2bacb2015-04-09 22:03:22 -0700702 u16 bridge_mode;
703
Paul Greenwalt73834ae2017-10-27 10:32:40 -0400704 char eeprom_id[NVM_VER_SIZE];
Emil Tantilovc23f5b62011-08-16 07:34:18 +0000705 u16 eeprom_cap;
Greg Rose7f870472010-01-09 02:25:29 +0000706
Mallikarjuna R Chilakala119fc602010-05-20 23:07:06 -0700707 u32 interrupt_event;
Alexander Duyck46646e62012-02-08 07:49:28 +0000708 u32 led_reg;
Jesse Brandeburg1a6c14a2010-02-03 14:18:50 +0000709
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000710 struct ptp_clock *ptp_clock;
711 struct ptp_clock_info ptp_caps;
Jacob Keller891dc082012-12-05 07:24:46 +0000712 struct work_struct ptp_tx_work;
713 struct sk_buff *ptp_tx_skb;
Jacob Keller93501d42014-02-28 15:48:58 -0800714 struct hwtstamp_config tstamp_config;
Jacob Keller891dc082012-12-05 07:24:46 +0000715 unsigned long ptp_tx_start;
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000716 unsigned long last_overflow_check;
Jacob Keller6cb562d2012-12-05 07:24:41 +0000717 unsigned long last_rx_ptp_check;
Jakub Kicinskieda183c2014-04-02 10:33:28 +0000718 unsigned long last_rx_timestamp;
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000719 spinlock_t tmreg_lock;
Mark Rustada9763f32015-10-27 09:58:07 -0700720 struct cyclecounter hw_cc;
721 struct timecounter hw_tc;
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000722 u32 base_incval;
Mark Rustada9763f32015-10-27 09:58:07 -0700723 u32 tx_hwtstamp_timeouts;
Jacob Keller4cc74c02017-05-03 10:29:00 -0700724 u32 tx_hwtstamp_skipped;
Mark Rustada9763f32015-10-27 09:58:07 -0700725 u32 rx_hwtstamp_cleared;
726 void (*ptp_setup_sdp)(struct ixgbe_adapter *);
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000727
Greg Rose7f870472010-01-09 02:25:29 +0000728 /* SR-IOV */
729 DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
730 unsigned int num_vfs;
731 struct vf_data_storage *vfinfo;
Lior Levyff4ab202011-03-11 02:03:07 +0000732 int vf_rate_link_speed;
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000733 struct vf_macvlans vf_mvs;
734 struct vf_macvlans *mv_list;
Alexander Duyck3e053342011-05-11 07:18:47 +0000735
Greg Rose83c61fa2011-09-07 05:59:35 +0000736 u32 timer_event_accumulator;
737 u32 vferr_refcount;
Jacob Keller5d7daa32014-03-29 06:51:25 +0000738 struct ixgbe_mac_addr *mac_table;
Don Skidmore3ca8bc62012-04-12 00:33:31 +0000739 struct kobject *info_kobj;
740#ifdef CONFIG_IXGBE_HWMON
Guenter Roeck03b77d82013-11-26 07:15:28 +0000741 struct hwmon_buff *ixgbe_hwmon_buff;
Don Skidmore3ca8bc62012-04-12 00:33:31 +0000742#endif /* CONFIG_IXGBE_HWMON */
Catherine Sullivan00949162012-08-10 01:59:10 +0000743#ifdef CONFIG_DEBUG_FS
744 struct dentry *ixgbe_dbg_adapter;
745#endif /*CONFIG_DEBUG_FS*/
Alexander Duyck107d3012012-10-02 00:17:03 +0000746
747 u8 default_up;
Alexander Duyck4e039c12017-11-22 10:56:40 -0800748 /* Bitmask indicating in use pools */
749 DECLARE_BITMAP(fwd_bitmask, IXGBE_MAX_MACVLANS + 1);
Vlad Zolotarovdfaf8912015-03-30 21:18:57 +0300750
John Fastabendb82b17d2016-02-16 21:18:53 -0800751#define IXGBE_MAX_LINK_HANDLE 10
Amritha Nambiar1cdaaf52016-04-14 19:08:53 -0400752 struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE];
John Fastabenddb956ae2016-02-16 21:19:19 -0800753 unsigned long tables;
John Fastabendb82b17d2016-02-16 21:18:53 -0800754
Vlad Zolotarovdfaf8912015-03-30 21:18:57 +0300755/* maximum number of RETA entries among all devices supported by ixgbe
756 * driver: currently it's x550 device in non-SRIOV mode
757 */
758#define IXGBE_MAX_RETA_ENTRIES 512
759 u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
760
761#define IXGBE_RSS_KEY_SIZE 40 /* size of RSS Hash Key in bytes */
Tony Nguyen3dfbfc72017-04-13 07:26:05 -0700762 u32 *rss_key;
Shannon Nelson34c822e2017-12-19 15:59:56 -0800763
Alexander Duycke433f3a2018-06-04 16:51:20 -0400764#ifdef CONFIG_XFRM_OFFLOAD
Shannon Nelson34c822e2017-12-19 15:59:56 -0800765 struct ixgbe_ipsec *ipsec;
Alexander Duycke433f3a2018-06-04 16:51:20 -0400766#endif /* CONFIG_XFRM_OFFLOAD */
Alexander Duyck3e053342011-05-11 07:18:47 +0000767};
768
Don Skidmore0f9b2322014-11-18 09:35:08 +0000769static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
770{
771 switch (adapter->hw.mac.type) {
772 case ixgbe_mac_82598EB:
773 case ixgbe_mac_82599EB:
774 case ixgbe_mac_X540:
775 return IXGBE_MAX_RSS_INDICES;
776 case ixgbe_mac_X550:
777 case ixgbe_mac_X550EM_x:
Mark Rustad49425df2016-04-01 12:18:09 -0700778 case ixgbe_mac_x550em_a:
Don Skidmore0f9b2322014-11-18 09:35:08 +0000779 return IXGBE_MAX_RSS_INDICES_X550;
780 default:
781 return 0;
782 }
783}
784
Alexander Duyck3e053342011-05-11 07:18:47 +0000785struct ixgbe_fdir_filter {
786 struct hlist_node fdir_node;
787 union ixgbe_atr_input filter;
788 u16 sw_idx;
Sridhar Samudrala2a9ed5d2016-04-01 10:34:38 -0700789 u64 action;
Auke Kok9a799d72007-09-15 14:07:45 -0700790};
791
Don Skidmore70e55762012-03-15 04:55:59 +0000792enum ixgbe_state_t {
Auke Kok9a799d72007-09-15 14:07:45 -0700793 __IXGBE_TESTING,
794 __IXGBE_RESETTING,
Donald Skidmorec4900be2008-11-20 21:11:42 -0800795 __IXGBE_DOWN,
Mark Rustad41c62842014-03-12 00:38:35 +0000796 __IXGBE_DISABLED,
Mark Rustad09f40ae2014-01-14 18:53:11 -0800797 __IXGBE_REMOVING,
Alexander Duyck70864002011-04-27 09:13:56 +0000798 __IXGBE_SERVICE_SCHED,
Mark Rustad58cf6632014-03-12 00:38:40 +0000799 __IXGBE_SERVICE_INITED,
Alexander Duyck70864002011-04-27 09:13:56 +0000800 __IXGBE_IN_SFP_INIT,
Jacob Keller8fecf672013-06-21 08:14:32 +0000801 __IXGBE_PTP_RUNNING,
Jakub Kicinski151b260c2014-03-15 14:55:21 +0000802 __IXGBE_PTP_TX_IN_PROGRESS,
Emil Tantilov57ca2a42016-07-29 14:46:31 -0700803 __IXGBE_RESET_REQUESTED,
Auke Kok9a799d72007-09-15 14:07:45 -0700804};
805
Alexander Duyck4c1975d2012-01-31 02:59:23 +0000806struct ixgbe_cb {
807 union { /* Union defining head/tail partner */
808 struct sk_buff *head;
809 struct sk_buff *tail;
810 };
Alexander Duyckaa801752010-11-16 19:27:02 -0800811 dma_addr_t dma;
Alexander Duyck4c1975d2012-01-31 02:59:23 +0000812 u16 append_cnt;
Alexander Duyckf8003262012-03-03 02:35:52 +0000813 bool page_released;
Alexander Duyckaa801752010-11-16 19:27:02 -0800814};
Alexander Duyck4c1975d2012-01-31 02:59:23 +0000815#define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
Alexander Duyckaa801752010-11-16 19:27:02 -0800816
Auke Kok9a799d72007-09-15 14:07:45 -0700817enum ixgbe_boards {
Auke Kok3957d632007-10-31 15:22:10 -0700818 board_82598,
PJ Waskiewicze8e26352009-02-27 15:45:05 +0000819 board_82599,
Don Skidmorefe15e8e12010-11-16 19:27:16 -0800820 board_X540,
Don Skidmore6a14ee02014-12-05 03:59:50 +0000821 board_X550,
822 board_X550EM_x,
Paul Greenwalt8dc963e2017-04-13 08:07:07 -0400823 board_x550em_x_fw,
Mark Rustad49425df2016-04-01 12:18:09 -0700824 board_x550em_a,
Mark Rustadb3eb4e12016-12-14 11:02:16 -0800825 board_x550em_a_fw,
Auke Kok9a799d72007-09-15 14:07:45 -0700826};
827
Mark Rustad37689012016-01-07 10:13:03 -0800828extern const struct ixgbe_info ixgbe_82598_info;
829extern const struct ixgbe_info ixgbe_82599_info;
830extern const struct ixgbe_info ixgbe_X540_info;
831extern const struct ixgbe_info ixgbe_X550_info;
832extern const struct ixgbe_info ixgbe_X550EM_x_info;
Paul Greenwalt8dc963e2017-04-13 08:07:07 -0400833extern const struct ixgbe_info ixgbe_x550em_x_fw_info;
Mark Rustad49425df2016-04-01 12:18:09 -0700834extern const struct ixgbe_info ixgbe_x550em_a_info;
Mark Rustadb3eb4e12016-12-14 11:02:16 -0800835extern const struct ixgbe_info ixgbe_x550em_a_fw_info;
Jeff Kirsher7a6b6f52008-11-25 01:02:08 -0800836#ifdef CONFIG_IXGBE_DCB
Stephen Hemminger3f40c742016-11-21 09:52:40 -0800837extern const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops;
Alexander Duyck2f90b862008-11-20 20:52:10 -0800838#endif
Auke Kok9a799d72007-09-15 14:07:45 -0700839
840extern char ixgbe_driver_name[];
Stephen Hemminger9c8eb722007-10-29 10:46:24 -0700841extern const char ixgbe_driver_version[];
Jeff Kirsher8af3c332012-02-18 07:08:14 +0000842#ifdef IXGBE_FCOE
Neerav Parikhea818752012-01-04 20:23:40 +0000843extern char ixgbe_default_device_descr[];
Jeff Kirsher8af3c332012-02-18 07:08:14 +0000844#endif /* IXGBE_FCOE */
Auke Kok9a799d72007-09-15 14:07:45 -0700845
Stefan Assmann6c211fe12016-02-03 09:20:48 +0100846int ixgbe_open(struct net_device *netdev);
847int ixgbe_close(struct net_device *netdev);
Joe Perches5ccc9212013-09-23 11:37:59 -0700848void ixgbe_up(struct ixgbe_adapter *adapter);
849void ixgbe_down(struct ixgbe_adapter *adapter);
850void ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
851void ixgbe_reset(struct ixgbe_adapter *adapter);
852void ixgbe_set_ethtool_ops(struct net_device *netdev);
John Fastabend92470802017-04-24 03:30:17 -0700853int ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
Joe Perches5ccc9212013-09-23 11:37:59 -0700854int ixgbe_setup_tx_resources(struct ixgbe_ring *);
855void ixgbe_free_rx_resources(struct ixgbe_ring *);
856void ixgbe_free_tx_resources(struct ixgbe_ring *);
857void ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
858void ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
Alexander Duyck1918e932018-07-20 18:29:34 -0400859void ixgbe_disable_rx(struct ixgbe_adapter *adapter);
860void ixgbe_disable_tx(struct ixgbe_adapter *adapter);
Joe Perches5ccc9212013-09-23 11:37:59 -0700861void ixgbe_update_stats(struct ixgbe_adapter *adapter);
862int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
Emil Tantilov740234f2016-04-21 11:37:12 -0700863bool ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
864 u16 subdevice_id);
Jacob Keller5d7daa32014-03-29 06:51:25 +0000865#ifdef CONFIG_PCI_IOV
866void ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter);
867#endif
868int ixgbe_add_mac_filter(struct ixgbe_adapter *adapter,
Alexander Duyckc9f53e62015-10-22 16:26:30 -0700869 const u8 *addr, u16 queue);
Jacob Keller5d7daa32014-03-29 06:51:25 +0000870int ixgbe_del_mac_filter(struct ixgbe_adapter *adapter,
Alexander Duyckc9f53e62015-10-22 16:26:30 -0700871 const u8 *addr, u16 queue);
Alexander Duycke1d0a2a2015-11-02 17:10:19 -0800872void ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid);
Joe Perches5ccc9212013-09-23 11:37:59 -0700873void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
874netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *,
875 struct ixgbe_ring *);
876void ixgbe_unmap_and_free_tx_resource(struct ixgbe_ring *,
877 struct ixgbe_tx_buffer *);
878void ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
879void ixgbe_write_eitr(struct ixgbe_q_vector *);
880int ixgbe_poll(struct napi_struct *napi, int budget);
881int ethtool_ioctl(struct ifreq *ifr);
882s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
883s32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
884s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
885s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
886 union ixgbe_atr_hash_dword input,
887 union ixgbe_atr_hash_dword common,
888 u8 queue);
889s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
890 union ixgbe_atr_input *input_mask);
891s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
892 union ixgbe_atr_input *input,
893 u16 soft_id, u8 queue);
894s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
895 union ixgbe_atr_input *input,
896 u16 soft_id);
897void ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
898 union ixgbe_atr_input *mask);
John Fastabendb82b17d2016-02-16 21:18:53 -0800899int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
900 struct ixgbe_fdir_filter *input,
901 u16 sw_idx);
Joe Perches5ccc9212013-09-23 11:37:59 -0700902void ixgbe_set_rx_mode(struct net_device *netdev);
Jeff Kirsher8af3c332012-02-18 07:08:14 +0000903#ifdef CONFIG_IXGBE_DCB
Joe Perches5ccc9212013-09-23 11:37:59 -0700904void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
Jeff Kirsher8af3c332012-02-18 07:08:14 +0000905#endif
Joe Perches5ccc9212013-09-23 11:37:59 -0700906int ixgbe_setup_tc(struct net_device *dev, u8 tc);
907void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
908void ixgbe_do_reset(struct net_device *netdev);
Don Skidmore12109822012-05-04 06:07:08 +0000909#ifdef CONFIG_IXGBE_HWMON
Joe Perches5ccc9212013-09-23 11:37:59 -0700910void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
911int ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
Don Skidmore12109822012-05-04 06:07:08 +0000912#endif /* CONFIG_IXGBE_HWMON */
Yi Zoueacd73f2009-05-13 13:11:06 +0000913#ifdef IXGBE_FCOE
Joe Perches5ccc9212013-09-23 11:37:59 -0700914void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
915int ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
916 u8 *hdr_len);
917int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
918 union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb);
919int ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
920 struct scatterlist *sgl, unsigned int sgc);
921int ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
922 struct scatterlist *sgl, unsigned int sgc);
923int ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
924int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
925void ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
926int ixgbe_fcoe_enable(struct net_device *netdev);
927int ixgbe_fcoe_disable(struct net_device *netdev);
Yi Zou6ee16522009-08-31 12:34:28 +0000928#ifdef CONFIG_IXGBE_DCB
Joe Perches5ccc9212013-09-23 11:37:59 -0700929u8 ixgbe_fcoe_getapp(struct ixgbe_adapter *adapter);
930u8 ixgbe_fcoe_setapp(struct ixgbe_adapter *adapter, u8 up);
Yi Zou6ee16522009-08-31 12:34:28 +0000931#endif /* CONFIG_IXGBE_DCB */
Joe Perches5ccc9212013-09-23 11:37:59 -0700932int ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
933int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
934 struct netdev_fcoe_hbainfo *info);
935u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
Yi Zoueacd73f2009-05-13 13:11:06 +0000936#endif /* IXGBE_FCOE */
Catherine Sullivan00949162012-08-10 01:59:10 +0000937#ifdef CONFIG_DEBUG_FS
Joe Perches5ccc9212013-09-23 11:37:59 -0700938void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
939void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
940void ixgbe_dbg_init(void);
941void ixgbe_dbg_exit(void);
Joe Perches33243fb2013-04-12 17:12:54 +0000942#else
943static inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}
944static inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {}
945static inline void ixgbe_dbg_init(void) {}
946static inline void ixgbe_dbg_exit(void) {}
Catherine Sullivan00949162012-08-10 01:59:10 +0000947#endif /* CONFIG_DEBUG_FS */
Alexander Duyckb2d96e02012-02-07 08:14:33 +0000948static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
949{
950 return netdev_get_tx_queue(ring->netdev, ring->queue_index);
951}
952
Joe Perches5ccc9212013-09-23 11:37:59 -0700953void ixgbe_ptp_init(struct ixgbe_adapter *adapter);
Jacob Keller9966d1e2014-05-16 05:12:28 +0000954void ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
Joe Perches5ccc9212013-09-23 11:37:59 -0700955void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
956void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
957void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
Jacob Keller622a2ef2017-05-03 10:29:04 -0700958void ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter);
Mark Rustada9763f32015-10-27 09:58:07 -0700959void ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *);
960void ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb);
961static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
962 union ixgbe_adv_rx_desc *rx_desc,
963 struct sk_buff *skb)
964{
965 if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) {
966 ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb);
967 return;
968 }
969
970 if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
971 return;
972
973 ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
974
975 /* Update the last_rx_timestamp timer in order to enable watchdog check
976 * for error case of latched timestamp on a dropped packet.
977 */
978 rx_ring->last_rx_timestamp = jiffies;
979}
980
Jacob Keller93501d42014-02-28 15:48:58 -0800981int ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
982int ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
Joe Perches5ccc9212013-09-23 11:37:59 -0700983void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
984void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
Mark Rustada9763f32015-10-27 09:58:07 -0700985void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter);
Greg Roseda36b642012-12-11 08:26:43 +0000986#ifdef CONFIG_PCI_IOV
987void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
988#endif
Jacob Keller3a6a4ed2012-05-01 05:24:58 +0000989
John Fastabend2a47fa42013-11-06 09:54:52 -0800990netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
991 struct ixgbe_adapter *adapter,
992 struct ixgbe_ring *tx_ring);
Vlad Zolotarov7f276ef2015-03-30 21:18:58 +0300993u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
Paolo Abenid3aa9c92016-12-15 15:20:34 +0100994void ixgbe_store_key(struct ixgbe_adapter *adapter);
Tom Barbette1c7cf072015-06-26 15:40:18 +0200995void ixgbe_store_reta(struct ixgbe_adapter *adapter);
Don Skidmore29165002016-09-27 14:31:12 -0400996s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
997 u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
Shannon Nelson8bbbc5e2017-12-19 15:59:54 -0800998#ifdef CONFIG_XFRM_OFFLOAD
999void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter);
Shannon Nelson63a67fe2017-12-19 15:59:57 -08001000void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter);
Shannon Nelson6d73a152017-12-19 15:59:58 -08001001void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter);
Shannon Nelson92103192017-12-19 15:59:59 -08001002void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
1003 union ixgbe_adv_rx_desc *rx_desc,
1004 struct sk_buff *skb);
Shannon Nelson59259472017-12-19 16:00:00 -08001005int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
1006 struct ixgbe_ipsec_tx_data *itd);
Shannon Nelson8bbbc5e2017-12-19 15:59:54 -08001007#else
1008static inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { };
Shannon Nelson63a67fe2017-12-19 15:59:57 -08001009static inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { };
Shannon Nelson6d73a152017-12-19 15:59:58 -08001010static inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { };
Shannon Nelson92103192017-12-19 15:59:59 -08001011static inline void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
1012 union ixgbe_adv_rx_desc *rx_desc,
1013 struct sk_buff *skb) { };
Shannon Nelson59259472017-12-19 16:00:00 -08001014static inline int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
1015 struct ixgbe_tx_buffer *first,
1016 struct ixgbe_ipsec_tx_data *itd) { return 0; };
Shannon Nelson8bbbc5e2017-12-19 15:59:54 -08001017#endif /* CONFIG_XFRM_OFFLOAD */
Auke Kok9a799d72007-09-15 14:07:45 -07001018#endif /* _IXGBE_H_ */