162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _IXGBE_H_
562306a36Sopenharmony_ci#define _IXGBE_H_
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <linux/bitops.h>
862306a36Sopenharmony_ci#include <linux/types.h>
962306a36Sopenharmony_ci#include <linux/pci.h>
1062306a36Sopenharmony_ci#include <linux/netdevice.h>
1162306a36Sopenharmony_ci#include <linux/cpumask.h>
1262306a36Sopenharmony_ci#include <linux/if_vlan.h>
1362306a36Sopenharmony_ci#include <linux/jiffies.h>
1462306a36Sopenharmony_ci#include <linux/phy.h>
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/timecounter.h>
1762306a36Sopenharmony_ci#include <linux/net_tstamp.h>
1862306a36Sopenharmony_ci#include <linux/ptp_clock_kernel.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#include "ixgbe_type.h"
2162306a36Sopenharmony_ci#include "ixgbe_common.h"
2262306a36Sopenharmony_ci#include "ixgbe_dcb.h"
2362306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_FCOE)
2462306a36Sopenharmony_ci#define IXGBE_FCOE
2562306a36Sopenharmony_ci#include "ixgbe_fcoe.h"
2662306a36Sopenharmony_ci#endif /* IS_ENABLED(CONFIG_FCOE) */
2762306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_DCA
2862306a36Sopenharmony_ci#include <linux/dca.h>
2962306a36Sopenharmony_ci#endif
3062306a36Sopenharmony_ci#include "ixgbe_ipsec.h"
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci#include <net/xdp.h>
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/* common prefix used by pr_<> macros */
3562306a36Sopenharmony_ci#undef pr_fmt
3662306a36Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* TX/RX descriptor defines */
3962306a36Sopenharmony_ci#define IXGBE_DEFAULT_TXD		    512
4062306a36Sopenharmony_ci#define IXGBE_DEFAULT_TX_WORK		    256
4162306a36Sopenharmony_ci#define IXGBE_MAX_TXD_82598		   4096
4262306a36Sopenharmony_ci#define IXGBE_MAX_TXD_82599		   8192
4362306a36Sopenharmony_ci#define IXGBE_MAX_TXD_X540		   8192
4462306a36Sopenharmony_ci#define IXGBE_MAX_TXD_X550		  32768
4562306a36Sopenharmony_ci#define IXGBE_MIN_TXD			     64
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#if (PAGE_SIZE < 8192)
4862306a36Sopenharmony_ci#define IXGBE_DEFAULT_RXD		    512
4962306a36Sopenharmony_ci#else
5062306a36Sopenharmony_ci#define IXGBE_DEFAULT_RXD		    128
5162306a36Sopenharmony_ci#endif
5262306a36Sopenharmony_ci#define IXGBE_MAX_RXD_82598		   4096
5362306a36Sopenharmony_ci#define IXGBE_MAX_RXD_82599		   8192
5462306a36Sopenharmony_ci#define IXGBE_MAX_RXD_X540		   8192
5562306a36Sopenharmony_ci#define IXGBE_MAX_RXD_X550		  32768
5662306a36Sopenharmony_ci#define IXGBE_MIN_RXD			     64
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* flow control */
5962306a36Sopenharmony_ci#define IXGBE_MIN_FCRTL			   0x40
6062306a36Sopenharmony_ci#define IXGBE_MAX_FCRTL			0x7FF80
6162306a36Sopenharmony_ci#define IXGBE_MIN_FCRTH			  0x600
6262306a36Sopenharmony_ci#define IXGBE_MAX_FCRTH			0x7FFF0
6362306a36Sopenharmony_ci#define IXGBE_DEFAULT_FCPAUSE		 0xFFFF
6462306a36Sopenharmony_ci#define IXGBE_MIN_FCPAUSE		      0
6562306a36Sopenharmony_ci#define IXGBE_MAX_FCPAUSE		 0xFFFF
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci/* Supported Rx Buffer Sizes */
6862306a36Sopenharmony_ci#define IXGBE_RXBUFFER_256    256  /* Used for skb receive header */
6962306a36Sopenharmony_ci#define IXGBE_RXBUFFER_1536  1536
7062306a36Sopenharmony_ci#define IXGBE_RXBUFFER_2K    2048
7162306a36Sopenharmony_ci#define IXGBE_RXBUFFER_3K    3072
7262306a36Sopenharmony_ci#define IXGBE_RXBUFFER_4K    4096
7362306a36Sopenharmony_ci#define IXGBE_MAX_RXBUFFER  16384  /* largest size for a single descriptor */
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci#define IXGBE_PKT_HDR_PAD   (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* Attempt to maximize the headroom available for incoming frames.  We
7862306a36Sopenharmony_ci * use a 2K buffer for receives and need 1536/1534 to store the data for
7962306a36Sopenharmony_ci * the frame.  This leaves us with 512 bytes of room.  From that we need
8062306a36Sopenharmony_ci * to deduct the space needed for the shared info and the padding needed
8162306a36Sopenharmony_ci * to IP align the frame.
8262306a36Sopenharmony_ci *
8362306a36Sopenharmony_ci * Note: For cache line sizes 256 or larger this value is going to end
8462306a36Sopenharmony_ci *	 up negative.  In these cases we should fall back to the 3K
8562306a36Sopenharmony_ci *	 buffers.
8662306a36Sopenharmony_ci */
8762306a36Sopenharmony_ci#if (PAGE_SIZE < 8192)
8862306a36Sopenharmony_ci#define IXGBE_MAX_2K_FRAME_BUILD_SKB (IXGBE_RXBUFFER_1536 - NET_IP_ALIGN)
8962306a36Sopenharmony_ci#define IXGBE_2K_TOO_SMALL_WITH_PADDING \
9062306a36Sopenharmony_ci((NET_SKB_PAD + IXGBE_RXBUFFER_1536) > SKB_WITH_OVERHEAD(IXGBE_RXBUFFER_2K))
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_cistatic inline int ixgbe_compute_pad(int rx_buf_len)
9362306a36Sopenharmony_ci{
9462306a36Sopenharmony_ci	int page_size, pad_size;
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci	page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
9762306a36Sopenharmony_ci	pad_size = SKB_WITH_OVERHEAD(page_size) - rx_buf_len;
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci	return pad_size;
10062306a36Sopenharmony_ci}
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_cistatic inline int ixgbe_skb_pad(void)
10362306a36Sopenharmony_ci{
10462306a36Sopenharmony_ci	int rx_buf_len;
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci	/* If a 2K buffer cannot handle a standard Ethernet frame then
10762306a36Sopenharmony_ci	 * optimize padding for a 3K buffer instead of a 1.5K buffer.
10862306a36Sopenharmony_ci	 *
10962306a36Sopenharmony_ci	 * For a 3K buffer we need to add enough padding to allow for
11062306a36Sopenharmony_ci	 * tailroom due to NET_IP_ALIGN possibly shifting us out of
11162306a36Sopenharmony_ci	 * cache-line alignment.
11262306a36Sopenharmony_ci	 */
11362306a36Sopenharmony_ci	if (IXGBE_2K_TOO_SMALL_WITH_PADDING)
11462306a36Sopenharmony_ci		rx_buf_len = IXGBE_RXBUFFER_3K + SKB_DATA_ALIGN(NET_IP_ALIGN);
11562306a36Sopenharmony_ci	else
11662306a36Sopenharmony_ci		rx_buf_len = IXGBE_RXBUFFER_1536;
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	/* if needed make room for NET_IP_ALIGN */
11962306a36Sopenharmony_ci	rx_buf_len -= NET_IP_ALIGN;
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci	return ixgbe_compute_pad(rx_buf_len);
12262306a36Sopenharmony_ci}
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define IXGBE_SKB_PAD	ixgbe_skb_pad()
12562306a36Sopenharmony_ci#else
12662306a36Sopenharmony_ci#define IXGBE_SKB_PAD	(NET_SKB_PAD + NET_IP_ALIGN)
12762306a36Sopenharmony_ci#endif
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci/*
13062306a36Sopenharmony_ci * NOTE: netdev_alloc_skb reserves up to 64 bytes, NET_IP_ALIGN means we
13162306a36Sopenharmony_ci * reserve 64 more, and skb_shared_info adds an additional 320 bytes more,
13262306a36Sopenharmony_ci * this adds up to 448 bytes of extra data.
13362306a36Sopenharmony_ci *
13462306a36Sopenharmony_ci * Since netdev_alloc_skb now allocates a page fragment we can use a value
13562306a36Sopenharmony_ci * of 256 and the resultant skb will have a truesize of 960 or less.
13662306a36Sopenharmony_ci */
13762306a36Sopenharmony_ci#define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci/* How many Rx Buffers do we bundle into one write to the hardware ? */
14062306a36Sopenharmony_ci#define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define IXGBE_RX_DMA_ATTR \
14362306a36Sopenharmony_ci	(DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_cienum ixgbe_tx_flags {
14662306a36Sopenharmony_ci	/* cmd_type flags */
14762306a36Sopenharmony_ci	IXGBE_TX_FLAGS_HW_VLAN	= 0x01,
14862306a36Sopenharmony_ci	IXGBE_TX_FLAGS_TSO	= 0x02,
14962306a36Sopenharmony_ci	IXGBE_TX_FLAGS_TSTAMP	= 0x04,
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	/* olinfo flags */
15262306a36Sopenharmony_ci	IXGBE_TX_FLAGS_CC	= 0x08,
15362306a36Sopenharmony_ci	IXGBE_TX_FLAGS_IPV4	= 0x10,
15462306a36Sopenharmony_ci	IXGBE_TX_FLAGS_CSUM	= 0x20,
15562306a36Sopenharmony_ci	IXGBE_TX_FLAGS_IPSEC	= 0x40,
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci	/* software defined flags */
15862306a36Sopenharmony_ci	IXGBE_TX_FLAGS_SW_VLAN	= 0x80,
15962306a36Sopenharmony_ci	IXGBE_TX_FLAGS_FCOE	= 0x100,
16062306a36Sopenharmony_ci};
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci/* VLAN info */
16362306a36Sopenharmony_ci#define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000
16462306a36Sopenharmony_ci#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000
16562306a36Sopenharmony_ci#define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT  29
16662306a36Sopenharmony_ci#define IXGBE_TX_FLAGS_VLAN_SHIFT	16
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#define IXGBE_MAX_VF_MC_ENTRIES         30
16962306a36Sopenharmony_ci#define IXGBE_MAX_VF_FUNCTIONS          64
17062306a36Sopenharmony_ci#define IXGBE_MAX_VFTA_ENTRIES          128
17162306a36Sopenharmony_ci#define MAX_EMULATION_MAC_ADDRS         16
17262306a36Sopenharmony_ci#define IXGBE_MAX_PF_MACVLANS           15
17362306a36Sopenharmony_ci#define VMDQ_P(p)   ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
17462306a36Sopenharmony_ci#define IXGBE_82599_VF_DEVICE_ID        0x10ED
17562306a36Sopenharmony_ci#define IXGBE_X540_VF_DEVICE_ID         0x1515
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci#define UPDATE_VF_COUNTER_32bit(reg, last_counter, counter)	\
17862306a36Sopenharmony_ci	{							\
17962306a36Sopenharmony_ci		u32 current_counter = IXGBE_READ_REG(hw, reg);	\
18062306a36Sopenharmony_ci		if (current_counter < last_counter)		\
18162306a36Sopenharmony_ci			counter += 0x100000000LL;		\
18262306a36Sopenharmony_ci		last_counter = current_counter;			\
18362306a36Sopenharmony_ci		counter &= 0xFFFFFFFF00000000LL;		\
18462306a36Sopenharmony_ci		counter |= current_counter;			\
18562306a36Sopenharmony_ci	}
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci#define UPDATE_VF_COUNTER_36bit(reg_lsb, reg_msb, last_counter, counter) \
18862306a36Sopenharmony_ci	{								 \
18962306a36Sopenharmony_ci		u64 current_counter_lsb = IXGBE_READ_REG(hw, reg_lsb);	 \
19062306a36Sopenharmony_ci		u64 current_counter_msb = IXGBE_READ_REG(hw, reg_msb);	 \
19162306a36Sopenharmony_ci		u64 current_counter = (current_counter_msb << 32) |	 \
19262306a36Sopenharmony_ci			current_counter_lsb;				 \
19362306a36Sopenharmony_ci		if (current_counter < last_counter)			 \
19462306a36Sopenharmony_ci			counter += 0x1000000000LL;			 \
19562306a36Sopenharmony_ci		last_counter = current_counter;				 \
19662306a36Sopenharmony_ci		counter &= 0xFFFFFFF000000000LL;			 \
19762306a36Sopenharmony_ci		counter |= current_counter;				 \
19862306a36Sopenharmony_ci	}
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_cistruct vf_stats {
20162306a36Sopenharmony_ci	u64 gprc;
20262306a36Sopenharmony_ci	u64 gorc;
20362306a36Sopenharmony_ci	u64 gptc;
20462306a36Sopenharmony_ci	u64 gotc;
20562306a36Sopenharmony_ci	u64 mprc;
20662306a36Sopenharmony_ci};
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_cistruct vf_data_storage {
20962306a36Sopenharmony_ci	struct pci_dev *vfdev;
21062306a36Sopenharmony_ci	unsigned char vf_mac_addresses[ETH_ALEN];
21162306a36Sopenharmony_ci	u16 vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
21262306a36Sopenharmony_ci	u16 num_vf_mc_hashes;
21362306a36Sopenharmony_ci	bool clear_to_send;
21462306a36Sopenharmony_ci	struct vf_stats vfstats;
21562306a36Sopenharmony_ci	struct vf_stats last_vfstats;
21662306a36Sopenharmony_ci	struct vf_stats saved_rst_vfstats;
21762306a36Sopenharmony_ci	bool pf_set_mac;
21862306a36Sopenharmony_ci	u16 pf_vlan; /* When set, guest VLAN config not allowed. */
21962306a36Sopenharmony_ci	u16 pf_qos;
22062306a36Sopenharmony_ci	u16 tx_rate;
22162306a36Sopenharmony_ci	int link_enable;
22262306a36Sopenharmony_ci	int link_state;
22362306a36Sopenharmony_ci	u8 spoofchk_enabled;
22462306a36Sopenharmony_ci	bool rss_query_enabled;
22562306a36Sopenharmony_ci	u8 trusted;
22662306a36Sopenharmony_ci	int xcast_mode;
22762306a36Sopenharmony_ci	unsigned int vf_api;
22862306a36Sopenharmony_ci	u8 primary_abort_count;
22962306a36Sopenharmony_ci};
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_cienum ixgbevf_xcast_modes {
23262306a36Sopenharmony_ci	IXGBEVF_XCAST_MODE_NONE = 0,
23362306a36Sopenharmony_ci	IXGBEVF_XCAST_MODE_MULTI,
23462306a36Sopenharmony_ci	IXGBEVF_XCAST_MODE_ALLMULTI,
23562306a36Sopenharmony_ci	IXGBEVF_XCAST_MODE_PROMISC,
23662306a36Sopenharmony_ci};
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_cistruct vf_macvlans {
23962306a36Sopenharmony_ci	struct list_head l;
24062306a36Sopenharmony_ci	int vf;
24162306a36Sopenharmony_ci	bool free;
24262306a36Sopenharmony_ci	bool is_macvlan;
24362306a36Sopenharmony_ci	u8 vf_macvlan[ETH_ALEN];
24462306a36Sopenharmony_ci};
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci#define IXGBE_MAX_TXD_PWR	14
24762306a36Sopenharmony_ci#define IXGBE_MAX_DATA_PER_TXD	(1u << IXGBE_MAX_TXD_PWR)
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci/* Tx Descriptors needed, worst case */
25062306a36Sopenharmony_ci#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD)
25162306a36Sopenharmony_ci#define DESC_NEEDED (MAX_SKB_FRAGS + 4)
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* wrapper around a pointer to a socket buffer,
25462306a36Sopenharmony_ci * so a DMA handle can be stored along with the buffer */
25562306a36Sopenharmony_cistruct ixgbe_tx_buffer {
25662306a36Sopenharmony_ci	union ixgbe_adv_tx_desc *next_to_watch;
25762306a36Sopenharmony_ci	unsigned long time_stamp;
25862306a36Sopenharmony_ci	union {
25962306a36Sopenharmony_ci		struct sk_buff *skb;
26062306a36Sopenharmony_ci		struct xdp_frame *xdpf;
26162306a36Sopenharmony_ci	};
26262306a36Sopenharmony_ci	unsigned int bytecount;
26362306a36Sopenharmony_ci	unsigned short gso_segs;
26462306a36Sopenharmony_ci	__be16 protocol;
26562306a36Sopenharmony_ci	DEFINE_DMA_UNMAP_ADDR(dma);
26662306a36Sopenharmony_ci	DEFINE_DMA_UNMAP_LEN(len);
26762306a36Sopenharmony_ci	u32 tx_flags;
26862306a36Sopenharmony_ci};
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_cistruct ixgbe_rx_buffer {
27162306a36Sopenharmony_ci	union {
27262306a36Sopenharmony_ci		struct {
27362306a36Sopenharmony_ci			struct sk_buff *skb;
27462306a36Sopenharmony_ci			dma_addr_t dma;
27562306a36Sopenharmony_ci			struct page *page;
27662306a36Sopenharmony_ci			__u32 page_offset;
27762306a36Sopenharmony_ci			__u16 pagecnt_bias;
27862306a36Sopenharmony_ci		};
27962306a36Sopenharmony_ci		struct {
28062306a36Sopenharmony_ci			bool discard;
28162306a36Sopenharmony_ci			struct xdp_buff *xdp;
28262306a36Sopenharmony_ci		};
28362306a36Sopenharmony_ci	};
28462306a36Sopenharmony_ci};
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_cistruct ixgbe_queue_stats {
28762306a36Sopenharmony_ci	u64 packets;
28862306a36Sopenharmony_ci	u64 bytes;
28962306a36Sopenharmony_ci};
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_cistruct ixgbe_tx_queue_stats {
29262306a36Sopenharmony_ci	u64 restart_queue;
29362306a36Sopenharmony_ci	u64 tx_busy;
29462306a36Sopenharmony_ci	u64 tx_done_old;
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistruct ixgbe_rx_queue_stats {
29862306a36Sopenharmony_ci	u64 rsc_count;
29962306a36Sopenharmony_ci	u64 rsc_flush;
30062306a36Sopenharmony_ci	u64 non_eop_descs;
30162306a36Sopenharmony_ci	u64 alloc_rx_page;
30262306a36Sopenharmony_ci	u64 alloc_rx_page_failed;
30362306a36Sopenharmony_ci	u64 alloc_rx_buff_failed;
30462306a36Sopenharmony_ci	u64 csum_err;
30562306a36Sopenharmony_ci};
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci#define IXGBE_TS_HDR_LEN 8
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_cienum ixgbe_ring_state_t {
31062306a36Sopenharmony_ci	__IXGBE_RX_3K_BUFFER,
31162306a36Sopenharmony_ci	__IXGBE_RX_BUILD_SKB_ENABLED,
31262306a36Sopenharmony_ci	__IXGBE_RX_RSC_ENABLED,
31362306a36Sopenharmony_ci	__IXGBE_RX_CSUM_UDP_ZERO_ERR,
31462306a36Sopenharmony_ci	__IXGBE_RX_FCOE,
31562306a36Sopenharmony_ci	__IXGBE_TX_FDIR_INIT_DONE,
31662306a36Sopenharmony_ci	__IXGBE_TX_XPS_INIT_DONE,
31762306a36Sopenharmony_ci	__IXGBE_TX_DETECT_HANG,
31862306a36Sopenharmony_ci	__IXGBE_HANG_CHECK_ARMED,
31962306a36Sopenharmony_ci	__IXGBE_TX_XDP_RING,
32062306a36Sopenharmony_ci	__IXGBE_TX_DISABLED,
32162306a36Sopenharmony_ci};
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci#define ring_uses_build_skb(ring) \
32462306a36Sopenharmony_ci	test_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &(ring)->state)
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_cistruct ixgbe_fwd_adapter {
32762306a36Sopenharmony_ci	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
32862306a36Sopenharmony_ci	struct net_device *netdev;
32962306a36Sopenharmony_ci	unsigned int tx_base_queue;
33062306a36Sopenharmony_ci	unsigned int rx_base_queue;
33162306a36Sopenharmony_ci	int pool;
33262306a36Sopenharmony_ci};
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci#define check_for_tx_hang(ring) \
33562306a36Sopenharmony_ci	test_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
33662306a36Sopenharmony_ci#define set_check_for_tx_hang(ring) \
33762306a36Sopenharmony_ci	set_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
33862306a36Sopenharmony_ci#define clear_check_for_tx_hang(ring) \
33962306a36Sopenharmony_ci	clear_bit(__IXGBE_TX_DETECT_HANG, &(ring)->state)
34062306a36Sopenharmony_ci#define ring_is_rsc_enabled(ring) \
34162306a36Sopenharmony_ci	test_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
34262306a36Sopenharmony_ci#define set_ring_rsc_enabled(ring) \
34362306a36Sopenharmony_ci	set_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
34462306a36Sopenharmony_ci#define clear_ring_rsc_enabled(ring) \
34562306a36Sopenharmony_ci	clear_bit(__IXGBE_RX_RSC_ENABLED, &(ring)->state)
34662306a36Sopenharmony_ci#define ring_is_xdp(ring) \
34762306a36Sopenharmony_ci	test_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
34862306a36Sopenharmony_ci#define set_ring_xdp(ring) \
34962306a36Sopenharmony_ci	set_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
35062306a36Sopenharmony_ci#define clear_ring_xdp(ring) \
35162306a36Sopenharmony_ci	clear_bit(__IXGBE_TX_XDP_RING, &(ring)->state)
35262306a36Sopenharmony_cistruct ixgbe_ring {
35362306a36Sopenharmony_ci	struct ixgbe_ring *next;	/* pointer to next ring in q_vector */
35462306a36Sopenharmony_ci	struct ixgbe_q_vector *q_vector; /* backpointer to host q_vector */
35562306a36Sopenharmony_ci	struct net_device *netdev;	/* netdev ring belongs to */
35662306a36Sopenharmony_ci	struct bpf_prog *xdp_prog;
35762306a36Sopenharmony_ci	struct device *dev;		/* device for DMA mapping */
35862306a36Sopenharmony_ci	void *desc;			/* descriptor ring memory */
35962306a36Sopenharmony_ci	union {
36062306a36Sopenharmony_ci		struct ixgbe_tx_buffer *tx_buffer_info;
36162306a36Sopenharmony_ci		struct ixgbe_rx_buffer *rx_buffer_info;
36262306a36Sopenharmony_ci	};
36362306a36Sopenharmony_ci	unsigned long state;
36462306a36Sopenharmony_ci	u8 __iomem *tail;
36562306a36Sopenharmony_ci	dma_addr_t dma;			/* phys. address of descriptor ring */
36662306a36Sopenharmony_ci	unsigned int size;		/* length in bytes */
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci	u16 count;			/* amount of descriptors */
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci	u8 queue_index; /* needed for multiqueue queue management */
37162306a36Sopenharmony_ci	u8 reg_idx;			/* holds the special value that gets
37262306a36Sopenharmony_ci					 * the hardware register offset
37362306a36Sopenharmony_ci					 * associated with this ring, which is
37462306a36Sopenharmony_ci					 * different for DCB and RSS modes
37562306a36Sopenharmony_ci					 */
37662306a36Sopenharmony_ci	u16 next_to_use;
37762306a36Sopenharmony_ci	u16 next_to_clean;
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci	unsigned long last_rx_timestamp;
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci	union {
38262306a36Sopenharmony_ci		u16 next_to_alloc;
38362306a36Sopenharmony_ci		struct {
38462306a36Sopenharmony_ci			u8 atr_sample_rate;
38562306a36Sopenharmony_ci			u8 atr_count;
38662306a36Sopenharmony_ci		};
38762306a36Sopenharmony_ci	};
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_ci	u8 dcb_tc;
39062306a36Sopenharmony_ci	struct ixgbe_queue_stats stats;
39162306a36Sopenharmony_ci	struct u64_stats_sync syncp;
39262306a36Sopenharmony_ci	union {
39362306a36Sopenharmony_ci		struct ixgbe_tx_queue_stats tx_stats;
39462306a36Sopenharmony_ci		struct ixgbe_rx_queue_stats rx_stats;
39562306a36Sopenharmony_ci	};
39662306a36Sopenharmony_ci	u16 rx_offset;
39762306a36Sopenharmony_ci	struct xdp_rxq_info xdp_rxq;
39862306a36Sopenharmony_ci	spinlock_t tx_lock;	/* used in XDP mode */
39962306a36Sopenharmony_ci	struct xsk_buff_pool *xsk_pool;
40062306a36Sopenharmony_ci	u16 ring_idx;		/* {rx,tx,xdp}_ring back reference idx */
40162306a36Sopenharmony_ci	u16 rx_buf_len;
40262306a36Sopenharmony_ci} ____cacheline_internodealigned_in_smp;
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_cienum ixgbe_ring_f_enum {
40562306a36Sopenharmony_ci	RING_F_NONE = 0,
40662306a36Sopenharmony_ci	RING_F_VMDQ,  /* SR-IOV uses the same ring feature */
40762306a36Sopenharmony_ci	RING_F_RSS,
40862306a36Sopenharmony_ci	RING_F_FDIR,
40962306a36Sopenharmony_ci#ifdef IXGBE_FCOE
41062306a36Sopenharmony_ci	RING_F_FCOE,
41162306a36Sopenharmony_ci#endif /* IXGBE_FCOE */
41262306a36Sopenharmony_ci
41362306a36Sopenharmony_ci	RING_F_ARRAY_SIZE      /* must be last in enum set */
41462306a36Sopenharmony_ci};
41562306a36Sopenharmony_ci
41662306a36Sopenharmony_ci#define IXGBE_MAX_RSS_INDICES		16
41762306a36Sopenharmony_ci#define IXGBE_MAX_RSS_INDICES_X550	63
41862306a36Sopenharmony_ci#define IXGBE_MAX_VMDQ_INDICES		64
41962306a36Sopenharmony_ci#define IXGBE_MAX_FDIR_INDICES		63	/* based on q_vector limit */
42062306a36Sopenharmony_ci#define IXGBE_MAX_FCOE_INDICES		8
42162306a36Sopenharmony_ci#define MAX_RX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
42262306a36Sopenharmony_ci#define MAX_TX_QUEUES			(IXGBE_MAX_FDIR_INDICES + 1)
42362306a36Sopenharmony_ci#define IXGBE_MAX_XDP_QS		(IXGBE_MAX_FDIR_INDICES + 1)
42462306a36Sopenharmony_ci#define IXGBE_MAX_L2A_QUEUES		4
42562306a36Sopenharmony_ci#define IXGBE_BAD_L2A_QUEUE		3
42662306a36Sopenharmony_ci#define IXGBE_MAX_MACVLANS		63
42762306a36Sopenharmony_ci
42862306a36Sopenharmony_ciDECLARE_STATIC_KEY_FALSE(ixgbe_xdp_locking_key);
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_cistruct ixgbe_ring_feature {
43162306a36Sopenharmony_ci	u16 limit;	/* upper limit on feature indices */
43262306a36Sopenharmony_ci	u16 indices;	/* current value of indices */
43362306a36Sopenharmony_ci	u16 mask;	/* Mask used for feature to ring mapping */
43462306a36Sopenharmony_ci	u16 offset;	/* offset to start of feature */
43562306a36Sopenharmony_ci} ____cacheline_internodealigned_in_smp;
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci#define IXGBE_82599_VMDQ_8Q_MASK 0x78
43862306a36Sopenharmony_ci#define IXGBE_82599_VMDQ_4Q_MASK 0x7C
43962306a36Sopenharmony_ci#define IXGBE_82599_VMDQ_2Q_MASK 0x7E
44062306a36Sopenharmony_ci
44162306a36Sopenharmony_ci/*
44262306a36Sopenharmony_ci * FCoE requires that all Rx buffers be over 2200 bytes in length.  Since
44362306a36Sopenharmony_ci * this is twice the size of a half page we need to double the page order
44462306a36Sopenharmony_ci * for FCoE enabled Rx queues.
44562306a36Sopenharmony_ci */
44662306a36Sopenharmony_cistatic inline unsigned int ixgbe_rx_bufsz(struct ixgbe_ring *ring)
44762306a36Sopenharmony_ci{
44862306a36Sopenharmony_ci	if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
44962306a36Sopenharmony_ci		return IXGBE_RXBUFFER_3K;
45062306a36Sopenharmony_ci#if (PAGE_SIZE < 8192)
45162306a36Sopenharmony_ci	if (ring_uses_build_skb(ring))
45262306a36Sopenharmony_ci		return IXGBE_MAX_2K_FRAME_BUILD_SKB;
45362306a36Sopenharmony_ci#endif
45462306a36Sopenharmony_ci	return IXGBE_RXBUFFER_2K;
45562306a36Sopenharmony_ci}
45662306a36Sopenharmony_ci
45762306a36Sopenharmony_cistatic inline unsigned int ixgbe_rx_pg_order(struct ixgbe_ring *ring)
45862306a36Sopenharmony_ci{
45962306a36Sopenharmony_ci#if (PAGE_SIZE < 8192)
46062306a36Sopenharmony_ci	if (test_bit(__IXGBE_RX_3K_BUFFER, &ring->state))
46162306a36Sopenharmony_ci		return 1;
46262306a36Sopenharmony_ci#endif
46362306a36Sopenharmony_ci	return 0;
46462306a36Sopenharmony_ci}
46562306a36Sopenharmony_ci#define ixgbe_rx_pg_size(_ring) (PAGE_SIZE << ixgbe_rx_pg_order(_ring))
46662306a36Sopenharmony_ci
46762306a36Sopenharmony_ci#define IXGBE_ITR_ADAPTIVE_MIN_INC	2
46862306a36Sopenharmony_ci#define IXGBE_ITR_ADAPTIVE_MIN_USECS	10
46962306a36Sopenharmony_ci#define IXGBE_ITR_ADAPTIVE_MAX_USECS	126
47062306a36Sopenharmony_ci#define IXGBE_ITR_ADAPTIVE_LATENCY	0x80
47162306a36Sopenharmony_ci#define IXGBE_ITR_ADAPTIVE_BULK		0x00
47262306a36Sopenharmony_ci
47362306a36Sopenharmony_cistruct ixgbe_ring_container {
47462306a36Sopenharmony_ci	struct ixgbe_ring *ring;	/* pointer to linked list of rings */
47562306a36Sopenharmony_ci	unsigned long next_update;	/* jiffies value of last update */
47662306a36Sopenharmony_ci	unsigned int total_bytes;	/* total bytes processed this int */
47762306a36Sopenharmony_ci	unsigned int total_packets;	/* total packets processed this int */
47862306a36Sopenharmony_ci	u16 work_limit;			/* total work allowed per interrupt */
47962306a36Sopenharmony_ci	u8 count;			/* total number of rings in vector */
48062306a36Sopenharmony_ci	u8 itr;				/* current ITR setting for ring */
48162306a36Sopenharmony_ci};
48262306a36Sopenharmony_ci
48362306a36Sopenharmony_ci/* iterator for handling rings in ring container */
48462306a36Sopenharmony_ci#define ixgbe_for_each_ring(pos, head) \
48562306a36Sopenharmony_ci	for (pos = (head).ring; pos != NULL; pos = pos->next)
48662306a36Sopenharmony_ci
48762306a36Sopenharmony_ci#define MAX_RX_PACKET_BUFFERS ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) \
48862306a36Sopenharmony_ci			      ? 8 : 1)
48962306a36Sopenharmony_ci#define MAX_TX_PACKET_BUFFERS MAX_RX_PACKET_BUFFERS
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci/* MAX_Q_VECTORS of these are allocated,
49262306a36Sopenharmony_ci * but we only use one per queue-specific vector.
49362306a36Sopenharmony_ci */
49462306a36Sopenharmony_cistruct ixgbe_q_vector {
49562306a36Sopenharmony_ci	struct ixgbe_adapter *adapter;
49662306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_DCA
49762306a36Sopenharmony_ci	int cpu;	    /* CPU for DCA */
49862306a36Sopenharmony_ci#endif
49962306a36Sopenharmony_ci	u16 v_idx;		/* index of q_vector within array, also used for
50062306a36Sopenharmony_ci				 * finding the bit in EICR and friends that
50162306a36Sopenharmony_ci				 * represents the vector for this ring */
50262306a36Sopenharmony_ci	u16 itr;		/* Interrupt throttle rate written to EITR */
50362306a36Sopenharmony_ci	struct ixgbe_ring_container rx, tx;
50462306a36Sopenharmony_ci
50562306a36Sopenharmony_ci	struct napi_struct napi;
50662306a36Sopenharmony_ci	cpumask_t affinity_mask;
50762306a36Sopenharmony_ci	int numa_node;
50862306a36Sopenharmony_ci	struct rcu_head rcu;	/* to avoid race with update stats on free */
50962306a36Sopenharmony_ci	char name[IFNAMSIZ + 9];
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci	/* for dynamic allocation of rings associated with this q_vector */
51262306a36Sopenharmony_ci	struct ixgbe_ring ring[] ____cacheline_internodealigned_in_smp;
51362306a36Sopenharmony_ci};
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_HWMON
51662306a36Sopenharmony_ci
51762306a36Sopenharmony_ci#define IXGBE_HWMON_TYPE_LOC		0
51862306a36Sopenharmony_ci#define IXGBE_HWMON_TYPE_TEMP		1
51962306a36Sopenharmony_ci#define IXGBE_HWMON_TYPE_CAUTION	2
52062306a36Sopenharmony_ci#define IXGBE_HWMON_TYPE_MAX		3
52162306a36Sopenharmony_ci
52262306a36Sopenharmony_cistruct hwmon_attr {
52362306a36Sopenharmony_ci	struct device_attribute dev_attr;
52462306a36Sopenharmony_ci	struct ixgbe_hw *hw;
52562306a36Sopenharmony_ci	struct ixgbe_thermal_diode_data *sensor;
52662306a36Sopenharmony_ci	char name[12];
52762306a36Sopenharmony_ci};
52862306a36Sopenharmony_ci
52962306a36Sopenharmony_cistruct hwmon_buff {
53062306a36Sopenharmony_ci	struct attribute_group group;
53162306a36Sopenharmony_ci	const struct attribute_group *groups[2];
53262306a36Sopenharmony_ci	struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
53362306a36Sopenharmony_ci	struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
53462306a36Sopenharmony_ci	unsigned int n_hwmon;
53562306a36Sopenharmony_ci};
53662306a36Sopenharmony_ci#endif /* CONFIG_IXGBE_HWMON */
53762306a36Sopenharmony_ci
53862306a36Sopenharmony_ci/*
53962306a36Sopenharmony_ci * microsecond values for various ITR rates shifted by 2 to fit itr register
54062306a36Sopenharmony_ci * with the first 3 bits reserved 0
54162306a36Sopenharmony_ci */
54262306a36Sopenharmony_ci#define IXGBE_MIN_RSC_ITR	24
54362306a36Sopenharmony_ci#define IXGBE_100K_ITR		40
54462306a36Sopenharmony_ci#define IXGBE_20K_ITR		200
54562306a36Sopenharmony_ci#define IXGBE_12K_ITR		336
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_ci/* ixgbe_test_staterr - tests bits in Rx descriptor status and error fields */
54862306a36Sopenharmony_cistatic inline __le32 ixgbe_test_staterr(union ixgbe_adv_rx_desc *rx_desc,
54962306a36Sopenharmony_ci					const u32 stat_err_bits)
55062306a36Sopenharmony_ci{
55162306a36Sopenharmony_ci	return rx_desc->wb.upper.status_error & cpu_to_le32(stat_err_bits);
55262306a36Sopenharmony_ci}
55362306a36Sopenharmony_ci
55462306a36Sopenharmony_cistatic inline u16 ixgbe_desc_unused(struct ixgbe_ring *ring)
55562306a36Sopenharmony_ci{
55662306a36Sopenharmony_ci	u16 ntc = ring->next_to_clean;
55762306a36Sopenharmony_ci	u16 ntu = ring->next_to_use;
55862306a36Sopenharmony_ci
55962306a36Sopenharmony_ci	return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
56062306a36Sopenharmony_ci}
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_ci#define IXGBE_RX_DESC(R, i)	    \
56362306a36Sopenharmony_ci	(&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
56462306a36Sopenharmony_ci#define IXGBE_TX_DESC(R, i)	    \
56562306a36Sopenharmony_ci	(&(((union ixgbe_adv_tx_desc *)((R)->desc))[i]))
56662306a36Sopenharmony_ci#define IXGBE_TX_CTXTDESC(R, i)	    \
56762306a36Sopenharmony_ci	(&(((struct ixgbe_adv_tx_context_desc *)((R)->desc))[i]))
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ci#define IXGBE_MAX_JUMBO_FRAME_SIZE	9728 /* Maximum Supported Size 9.5KB */
57062306a36Sopenharmony_ci#ifdef IXGBE_FCOE
57162306a36Sopenharmony_ci/* Use 3K as the baby jumbo frame size for FCoE */
57262306a36Sopenharmony_ci#define IXGBE_FCOE_JUMBO_FRAME_SIZE       3072
57362306a36Sopenharmony_ci#endif /* IXGBE_FCOE */
57462306a36Sopenharmony_ci
57562306a36Sopenharmony_ci#define OTHER_VECTOR 1
57662306a36Sopenharmony_ci#define NON_Q_VECTORS (OTHER_VECTOR)
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci#define MAX_MSIX_VECTORS_82599 64
57962306a36Sopenharmony_ci#define MAX_Q_VECTORS_82599 64
58062306a36Sopenharmony_ci#define MAX_MSIX_VECTORS_82598 18
58162306a36Sopenharmony_ci#define MAX_Q_VECTORS_82598 16
58262306a36Sopenharmony_ci
58362306a36Sopenharmony_cistruct ixgbe_mac_addr {
58462306a36Sopenharmony_ci	u8 addr[ETH_ALEN];
58562306a36Sopenharmony_ci	u16 pool;
58662306a36Sopenharmony_ci	u16 state; /* bitmask */
58762306a36Sopenharmony_ci};
58862306a36Sopenharmony_ci
58962306a36Sopenharmony_ci#define IXGBE_MAC_STATE_DEFAULT		0x1
59062306a36Sopenharmony_ci#define IXGBE_MAC_STATE_MODIFIED	0x2
59162306a36Sopenharmony_ci#define IXGBE_MAC_STATE_IN_USE		0x4
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_ci#define MAX_Q_VECTORS MAX_Q_VECTORS_82599
59462306a36Sopenharmony_ci#define MAX_MSIX_COUNT MAX_MSIX_VECTORS_82599
59562306a36Sopenharmony_ci
59662306a36Sopenharmony_ci#define MIN_MSIX_Q_VECTORS 1
59762306a36Sopenharmony_ci#define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NON_Q_VECTORS)
59862306a36Sopenharmony_ci
59962306a36Sopenharmony_ci/* default to trying for four seconds */
60062306a36Sopenharmony_ci#define IXGBE_TRY_LINK_TIMEOUT (4 * HZ)
60162306a36Sopenharmony_ci#define IXGBE_SFP_POLL_JIFFIES (2 * HZ)	/* SFP poll every 2 seconds */
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci#define IXGBE_PRIMARY_ABORT_LIMIT	5
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ci/* board specific private data structure */
60662306a36Sopenharmony_cistruct ixgbe_adapter {
60762306a36Sopenharmony_ci	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
60862306a36Sopenharmony_ci	/* OS defined structs */
60962306a36Sopenharmony_ci	struct net_device *netdev;
61062306a36Sopenharmony_ci	struct bpf_prog *xdp_prog;
61162306a36Sopenharmony_ci	struct pci_dev *pdev;
61262306a36Sopenharmony_ci	struct mii_bus *mii_bus;
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_ci	unsigned long state;
61562306a36Sopenharmony_ci
61662306a36Sopenharmony_ci	/* Some features need tri-state capability,
61762306a36Sopenharmony_ci	 * thus the additional *_CAPABLE flags.
61862306a36Sopenharmony_ci	 */
61962306a36Sopenharmony_ci	u32 flags;
62062306a36Sopenharmony_ci#define IXGBE_FLAG_MSI_ENABLED			BIT(1)
62162306a36Sopenharmony_ci#define IXGBE_FLAG_MSIX_ENABLED			BIT(3)
62262306a36Sopenharmony_ci#define IXGBE_FLAG_RX_1BUF_CAPABLE		BIT(4)
62362306a36Sopenharmony_ci#define IXGBE_FLAG_RX_PS_CAPABLE		BIT(5)
62462306a36Sopenharmony_ci#define IXGBE_FLAG_RX_PS_ENABLED		BIT(6)
62562306a36Sopenharmony_ci#define IXGBE_FLAG_DCA_ENABLED			BIT(8)
62662306a36Sopenharmony_ci#define IXGBE_FLAG_DCA_CAPABLE			BIT(9)
62762306a36Sopenharmony_ci#define IXGBE_FLAG_IMIR_ENABLED			BIT(10)
62862306a36Sopenharmony_ci#define IXGBE_FLAG_MQ_CAPABLE			BIT(11)
62962306a36Sopenharmony_ci#define IXGBE_FLAG_DCB_ENABLED			BIT(12)
63062306a36Sopenharmony_ci#define IXGBE_FLAG_VMDQ_CAPABLE			BIT(13)
63162306a36Sopenharmony_ci#define IXGBE_FLAG_VMDQ_ENABLED			BIT(14)
63262306a36Sopenharmony_ci#define IXGBE_FLAG_FAN_FAIL_CAPABLE		BIT(15)
63362306a36Sopenharmony_ci#define IXGBE_FLAG_NEED_LINK_UPDATE		BIT(16)
63462306a36Sopenharmony_ci#define IXGBE_FLAG_NEED_LINK_CONFIG		BIT(17)
63562306a36Sopenharmony_ci#define IXGBE_FLAG_FDIR_HASH_CAPABLE		BIT(18)
63662306a36Sopenharmony_ci#define IXGBE_FLAG_FDIR_PERFECT_CAPABLE		BIT(19)
63762306a36Sopenharmony_ci#define IXGBE_FLAG_FCOE_CAPABLE			BIT(20)
63862306a36Sopenharmony_ci#define IXGBE_FLAG_FCOE_ENABLED			BIT(21)
63962306a36Sopenharmony_ci#define IXGBE_FLAG_SRIOV_CAPABLE		BIT(22)
64062306a36Sopenharmony_ci#define IXGBE_FLAG_SRIOV_ENABLED		BIT(23)
64162306a36Sopenharmony_ci#define IXGBE_FLAG_RX_HWTSTAMP_ENABLED		BIT(25)
64262306a36Sopenharmony_ci#define IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER	BIT(26)
64362306a36Sopenharmony_ci#define IXGBE_FLAG_DCB_CAPABLE			BIT(27)
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_ci	u32 flags2;
64662306a36Sopenharmony_ci#define IXGBE_FLAG2_RSC_CAPABLE			BIT(0)
64762306a36Sopenharmony_ci#define IXGBE_FLAG2_RSC_ENABLED			BIT(1)
64862306a36Sopenharmony_ci#define IXGBE_FLAG2_TEMP_SENSOR_CAPABLE		BIT(2)
64962306a36Sopenharmony_ci#define IXGBE_FLAG2_TEMP_SENSOR_EVENT		BIT(3)
65062306a36Sopenharmony_ci#define IXGBE_FLAG2_SEARCH_FOR_SFP		BIT(4)
65162306a36Sopenharmony_ci#define IXGBE_FLAG2_SFP_NEEDS_RESET		BIT(5)
65262306a36Sopenharmony_ci#define IXGBE_FLAG2_FDIR_REQUIRES_REINIT	BIT(7)
65362306a36Sopenharmony_ci#define IXGBE_FLAG2_RSS_FIELD_IPV4_UDP		BIT(8)
65462306a36Sopenharmony_ci#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP		BIT(9)
65562306a36Sopenharmony_ci#define IXGBE_FLAG2_PTP_PPS_ENABLED		BIT(10)
65662306a36Sopenharmony_ci#define IXGBE_FLAG2_PHY_INTERRUPT		BIT(11)
65762306a36Sopenharmony_ci#define IXGBE_FLAG2_VLAN_PROMISC		BIT(13)
65862306a36Sopenharmony_ci#define IXGBE_FLAG2_EEE_CAPABLE			BIT(14)
65962306a36Sopenharmony_ci#define IXGBE_FLAG2_EEE_ENABLED			BIT(15)
66062306a36Sopenharmony_ci#define IXGBE_FLAG2_RX_LEGACY			BIT(16)
66162306a36Sopenharmony_ci#define IXGBE_FLAG2_IPSEC_ENABLED		BIT(17)
66262306a36Sopenharmony_ci#define IXGBE_FLAG2_VF_IPSEC_ENABLED		BIT(18)
66362306a36Sopenharmony_ci#define IXGBE_FLAG2_AUTO_DISABLE_VF		BIT(19)
66462306a36Sopenharmony_ci
66562306a36Sopenharmony_ci	/* Tx fast path data */
66662306a36Sopenharmony_ci	int num_tx_queues;
66762306a36Sopenharmony_ci	u16 tx_itr_setting;
66862306a36Sopenharmony_ci	u16 tx_work_limit;
66962306a36Sopenharmony_ci	u64 tx_ipsec;
67062306a36Sopenharmony_ci
67162306a36Sopenharmony_ci	/* Rx fast path data */
67262306a36Sopenharmony_ci	int num_rx_queues;
67362306a36Sopenharmony_ci	u16 rx_itr_setting;
67462306a36Sopenharmony_ci	u64 rx_ipsec;
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci	/* Port number used to identify VXLAN traffic */
67762306a36Sopenharmony_ci	__be16 vxlan_port;
67862306a36Sopenharmony_ci	__be16 geneve_port;
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ci	/* XDP */
68162306a36Sopenharmony_ci	int num_xdp_queues;
68262306a36Sopenharmony_ci	struct ixgbe_ring *xdp_ring[IXGBE_MAX_XDP_QS];
68362306a36Sopenharmony_ci	unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled rings */
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_ci	/* TX */
68662306a36Sopenharmony_ci	struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
68762306a36Sopenharmony_ci
68862306a36Sopenharmony_ci	u64 restart_queue;
68962306a36Sopenharmony_ci	u64 lsc_int;
69062306a36Sopenharmony_ci	u32 tx_timeout_count;
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci	/* RX */
69362306a36Sopenharmony_ci	struct ixgbe_ring *rx_ring[MAX_RX_QUEUES];
69462306a36Sopenharmony_ci	int num_rx_pools;		/* == num_rx_queues in 82598 */
69562306a36Sopenharmony_ci	int num_rx_queues_per_pool;	/* 1 if 82598, can be many if 82599 */
69662306a36Sopenharmony_ci	u64 hw_csum_rx_error;
69762306a36Sopenharmony_ci	u64 hw_rx_no_dma_resources;
69862306a36Sopenharmony_ci	u64 rsc_total_count;
69962306a36Sopenharmony_ci	u64 rsc_total_flush;
70062306a36Sopenharmony_ci	u64 non_eop_descs;
70162306a36Sopenharmony_ci	u32 alloc_rx_page;
70262306a36Sopenharmony_ci	u32 alloc_rx_page_failed;
70362306a36Sopenharmony_ci	u32 alloc_rx_buff_failed;
70462306a36Sopenharmony_ci
70562306a36Sopenharmony_ci	struct ixgbe_q_vector *q_vector[MAX_Q_VECTORS];
70662306a36Sopenharmony_ci
70762306a36Sopenharmony_ci	/* DCB parameters */
70862306a36Sopenharmony_ci	struct ieee_pfc *ixgbe_ieee_pfc;
70962306a36Sopenharmony_ci	struct ieee_ets *ixgbe_ieee_ets;
71062306a36Sopenharmony_ci	struct ixgbe_dcb_config dcb_cfg;
71162306a36Sopenharmony_ci	struct ixgbe_dcb_config temp_dcb_cfg;
71262306a36Sopenharmony_ci	u8 hw_tcs;
71362306a36Sopenharmony_ci	u8 dcb_set_bitmap;
71462306a36Sopenharmony_ci	u8 dcbx_cap;
71562306a36Sopenharmony_ci	enum ixgbe_fc_mode last_lfc_mode;
71662306a36Sopenharmony_ci
71762306a36Sopenharmony_ci	int num_q_vectors;	/* current number of q_vectors for device */
71862306a36Sopenharmony_ci	int max_q_vectors;	/* true count of q_vectors for device */
71962306a36Sopenharmony_ci	struct ixgbe_ring_feature ring_feature[RING_F_ARRAY_SIZE];
72062306a36Sopenharmony_ci	struct msix_entry *msix_entries;
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci	u32 test_icr;
72362306a36Sopenharmony_ci	struct ixgbe_ring test_tx_ring;
72462306a36Sopenharmony_ci	struct ixgbe_ring test_rx_ring;
72562306a36Sopenharmony_ci
72662306a36Sopenharmony_ci	/* structs defined in ixgbe_hw.h */
72762306a36Sopenharmony_ci	struct ixgbe_hw hw;
72862306a36Sopenharmony_ci	u16 msg_enable;
72962306a36Sopenharmony_ci	struct ixgbe_hw_stats stats;
73062306a36Sopenharmony_ci
73162306a36Sopenharmony_ci	u64 tx_busy;
73262306a36Sopenharmony_ci	unsigned int tx_ring_count;
73362306a36Sopenharmony_ci	unsigned int xdp_ring_count;
73462306a36Sopenharmony_ci	unsigned int rx_ring_count;
73562306a36Sopenharmony_ci
73662306a36Sopenharmony_ci	u32 link_speed;
73762306a36Sopenharmony_ci	bool link_up;
73862306a36Sopenharmony_ci	unsigned long sfp_poll_time;
73962306a36Sopenharmony_ci	unsigned long link_check_timeout;
74062306a36Sopenharmony_ci
74162306a36Sopenharmony_ci	struct timer_list service_timer;
74262306a36Sopenharmony_ci	struct work_struct service_task;
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_ci	struct hlist_head fdir_filter_list;
74562306a36Sopenharmony_ci	unsigned long fdir_overflow; /* number of times ATR was backed off */
74662306a36Sopenharmony_ci	union ixgbe_atr_input fdir_mask;
74762306a36Sopenharmony_ci	int fdir_filter_count;
74862306a36Sopenharmony_ci	u32 fdir_pballoc;
74962306a36Sopenharmony_ci	u32 atr_sample_rate;
75062306a36Sopenharmony_ci	spinlock_t fdir_perfect_lock;
75162306a36Sopenharmony_ci
75262306a36Sopenharmony_ci#ifdef IXGBE_FCOE
75362306a36Sopenharmony_ci	struct ixgbe_fcoe fcoe;
75462306a36Sopenharmony_ci#endif /* IXGBE_FCOE */
75562306a36Sopenharmony_ci	u8 __iomem *io_addr; /* Mainly for iounmap use */
75662306a36Sopenharmony_ci	u32 wol;
75762306a36Sopenharmony_ci
75862306a36Sopenharmony_ci	u16 bridge_mode;
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_ci	char eeprom_id[NVM_VER_SIZE];
76162306a36Sopenharmony_ci	u16 eeprom_cap;
76262306a36Sopenharmony_ci
76362306a36Sopenharmony_ci	u32 interrupt_event;
76462306a36Sopenharmony_ci	u32 led_reg;
76562306a36Sopenharmony_ci
76662306a36Sopenharmony_ci	struct ptp_clock *ptp_clock;
76762306a36Sopenharmony_ci	struct ptp_clock_info ptp_caps;
76862306a36Sopenharmony_ci	struct work_struct ptp_tx_work;
76962306a36Sopenharmony_ci	struct sk_buff *ptp_tx_skb;
77062306a36Sopenharmony_ci	struct hwtstamp_config tstamp_config;
77162306a36Sopenharmony_ci	unsigned long ptp_tx_start;
77262306a36Sopenharmony_ci	unsigned long last_overflow_check;
77362306a36Sopenharmony_ci	unsigned long last_rx_ptp_check;
77462306a36Sopenharmony_ci	unsigned long last_rx_timestamp;
77562306a36Sopenharmony_ci	spinlock_t tmreg_lock;
77662306a36Sopenharmony_ci	struct cyclecounter hw_cc;
77762306a36Sopenharmony_ci	struct timecounter hw_tc;
77862306a36Sopenharmony_ci	u32 base_incval;
77962306a36Sopenharmony_ci	u32 tx_hwtstamp_timeouts;
78062306a36Sopenharmony_ci	u32 tx_hwtstamp_skipped;
78162306a36Sopenharmony_ci	u32 rx_hwtstamp_cleared;
78262306a36Sopenharmony_ci	void (*ptp_setup_sdp)(struct ixgbe_adapter *);
78362306a36Sopenharmony_ci
78462306a36Sopenharmony_ci	/* SR-IOV */
78562306a36Sopenharmony_ci	DECLARE_BITMAP(active_vfs, IXGBE_MAX_VF_FUNCTIONS);
78662306a36Sopenharmony_ci	unsigned int num_vfs;
78762306a36Sopenharmony_ci	struct vf_data_storage *vfinfo;
78862306a36Sopenharmony_ci	int vf_rate_link_speed;
78962306a36Sopenharmony_ci	struct vf_macvlans vf_mvs;
79062306a36Sopenharmony_ci	struct vf_macvlans *mv_list;
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_ci	u32 timer_event_accumulator;
79362306a36Sopenharmony_ci	u32 vferr_refcount;
79462306a36Sopenharmony_ci	struct ixgbe_mac_addr *mac_table;
79562306a36Sopenharmony_ci	struct kobject *info_kobj;
79662306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_HWMON
79762306a36Sopenharmony_ci	struct hwmon_buff *ixgbe_hwmon_buff;
79862306a36Sopenharmony_ci#endif /* CONFIG_IXGBE_HWMON */
79962306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
80062306a36Sopenharmony_ci	struct dentry *ixgbe_dbg_adapter;
80162306a36Sopenharmony_ci#endif /*CONFIG_DEBUG_FS*/
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci	u8 default_up;
80462306a36Sopenharmony_ci	/* Bitmask indicating in use pools */
80562306a36Sopenharmony_ci	DECLARE_BITMAP(fwd_bitmask, IXGBE_MAX_MACVLANS + 1);
80662306a36Sopenharmony_ci
80762306a36Sopenharmony_ci#define IXGBE_MAX_LINK_HANDLE 10
80862306a36Sopenharmony_ci	struct ixgbe_jump_table *jump_tables[IXGBE_MAX_LINK_HANDLE];
80962306a36Sopenharmony_ci	unsigned long tables;
81062306a36Sopenharmony_ci
81162306a36Sopenharmony_ci/* maximum number of RETA entries among all devices supported by ixgbe
81262306a36Sopenharmony_ci * driver: currently it's x550 device in non-SRIOV mode
81362306a36Sopenharmony_ci */
81462306a36Sopenharmony_ci#define IXGBE_MAX_RETA_ENTRIES 512
81562306a36Sopenharmony_ci	u8 rss_indir_tbl[IXGBE_MAX_RETA_ENTRIES];
81662306a36Sopenharmony_ci
81762306a36Sopenharmony_ci#define IXGBE_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
81862306a36Sopenharmony_ci	u32 *rss_key;
81962306a36Sopenharmony_ci
82062306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_IPSEC
82162306a36Sopenharmony_ci	struct ixgbe_ipsec *ipsec;
82262306a36Sopenharmony_ci#endif /* CONFIG_IXGBE_IPSEC */
82362306a36Sopenharmony_ci	spinlock_t vfs_lock;
82462306a36Sopenharmony_ci};
82562306a36Sopenharmony_ci
82662306a36Sopenharmony_cistatic inline int ixgbe_determine_xdp_q_idx(int cpu)
82762306a36Sopenharmony_ci{
82862306a36Sopenharmony_ci	if (static_key_enabled(&ixgbe_xdp_locking_key))
82962306a36Sopenharmony_ci		return cpu % IXGBE_MAX_XDP_QS;
83062306a36Sopenharmony_ci	else
83162306a36Sopenharmony_ci		return cpu;
83262306a36Sopenharmony_ci}
83362306a36Sopenharmony_ci
83462306a36Sopenharmony_cistatic inline
83562306a36Sopenharmony_cistruct ixgbe_ring *ixgbe_determine_xdp_ring(struct ixgbe_adapter *adapter)
83662306a36Sopenharmony_ci{
83762306a36Sopenharmony_ci	int index = ixgbe_determine_xdp_q_idx(smp_processor_id());
83862306a36Sopenharmony_ci
83962306a36Sopenharmony_ci	return adapter->xdp_ring[index];
84062306a36Sopenharmony_ci}
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_cistatic inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
84362306a36Sopenharmony_ci{
84462306a36Sopenharmony_ci	switch (adapter->hw.mac.type) {
84562306a36Sopenharmony_ci	case ixgbe_mac_82598EB:
84662306a36Sopenharmony_ci	case ixgbe_mac_82599EB:
84762306a36Sopenharmony_ci	case ixgbe_mac_X540:
84862306a36Sopenharmony_ci		return IXGBE_MAX_RSS_INDICES;
84962306a36Sopenharmony_ci	case ixgbe_mac_X550:
85062306a36Sopenharmony_ci	case ixgbe_mac_X550EM_x:
85162306a36Sopenharmony_ci	case ixgbe_mac_x550em_a:
85262306a36Sopenharmony_ci		return IXGBE_MAX_RSS_INDICES_X550;
85362306a36Sopenharmony_ci	default:
85462306a36Sopenharmony_ci		return 0;
85562306a36Sopenharmony_ci	}
85662306a36Sopenharmony_ci}
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_cistruct ixgbe_fdir_filter {
85962306a36Sopenharmony_ci	struct hlist_node fdir_node;
86062306a36Sopenharmony_ci	union ixgbe_atr_input filter;
86162306a36Sopenharmony_ci	u16 sw_idx;
86262306a36Sopenharmony_ci	u64 action;
86362306a36Sopenharmony_ci};
86462306a36Sopenharmony_ci
86562306a36Sopenharmony_cienum ixgbe_state_t {
86662306a36Sopenharmony_ci	__IXGBE_TESTING,
86762306a36Sopenharmony_ci	__IXGBE_RESETTING,
86862306a36Sopenharmony_ci	__IXGBE_DOWN,
86962306a36Sopenharmony_ci	__IXGBE_DISABLED,
87062306a36Sopenharmony_ci	__IXGBE_REMOVING,
87162306a36Sopenharmony_ci	__IXGBE_SERVICE_SCHED,
87262306a36Sopenharmony_ci	__IXGBE_SERVICE_INITED,
87362306a36Sopenharmony_ci	__IXGBE_IN_SFP_INIT,
87462306a36Sopenharmony_ci	__IXGBE_PTP_RUNNING,
87562306a36Sopenharmony_ci	__IXGBE_PTP_TX_IN_PROGRESS,
87662306a36Sopenharmony_ci	__IXGBE_RESET_REQUESTED,
87762306a36Sopenharmony_ci};
87862306a36Sopenharmony_ci
87962306a36Sopenharmony_cistruct ixgbe_cb {
88062306a36Sopenharmony_ci	union {				/* Union defining head/tail partner */
88162306a36Sopenharmony_ci		struct sk_buff *head;
88262306a36Sopenharmony_ci		struct sk_buff *tail;
88362306a36Sopenharmony_ci	};
88462306a36Sopenharmony_ci	dma_addr_t dma;
88562306a36Sopenharmony_ci	u16 append_cnt;
88662306a36Sopenharmony_ci	bool page_released;
88762306a36Sopenharmony_ci};
88862306a36Sopenharmony_ci#define IXGBE_CB(skb) ((struct ixgbe_cb *)(skb)->cb)
88962306a36Sopenharmony_ci
89062306a36Sopenharmony_cienum ixgbe_boards {
89162306a36Sopenharmony_ci	board_82598,
89262306a36Sopenharmony_ci	board_82599,
89362306a36Sopenharmony_ci	board_X540,
89462306a36Sopenharmony_ci	board_X550,
89562306a36Sopenharmony_ci	board_X550EM_x,
89662306a36Sopenharmony_ci	board_x550em_x_fw,
89762306a36Sopenharmony_ci	board_x550em_a,
89862306a36Sopenharmony_ci	board_x550em_a_fw,
89962306a36Sopenharmony_ci};
90062306a36Sopenharmony_ci
90162306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_82598_info;
90262306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_82599_info;
90362306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_X540_info;
90462306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_X550_info;
90562306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_X550EM_x_info;
90662306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_x550em_x_fw_info;
90762306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_x550em_a_info;
90862306a36Sopenharmony_ciextern const struct ixgbe_info ixgbe_x550em_a_fw_info;
90962306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_DCB
91062306a36Sopenharmony_ciextern const struct dcbnl_rtnl_ops ixgbe_dcbnl_ops;
91162306a36Sopenharmony_ci#endif
91262306a36Sopenharmony_ci
91362306a36Sopenharmony_ciextern char ixgbe_driver_name[];
91462306a36Sopenharmony_ci#ifdef IXGBE_FCOE
91562306a36Sopenharmony_ciextern char ixgbe_default_device_descr[];
91662306a36Sopenharmony_ci#endif /* IXGBE_FCOE */
91762306a36Sopenharmony_ci
91862306a36Sopenharmony_ciint ixgbe_open(struct net_device *netdev);
91962306a36Sopenharmony_ciint ixgbe_close(struct net_device *netdev);
92062306a36Sopenharmony_civoid ixgbe_up(struct ixgbe_adapter *adapter);
92162306a36Sopenharmony_civoid ixgbe_down(struct ixgbe_adapter *adapter);
92262306a36Sopenharmony_civoid ixgbe_reinit_locked(struct ixgbe_adapter *adapter);
92362306a36Sopenharmony_civoid ixgbe_reset(struct ixgbe_adapter *adapter);
92462306a36Sopenharmony_civoid ixgbe_set_ethtool_ops(struct net_device *netdev);
92562306a36Sopenharmony_ciint ixgbe_setup_rx_resources(struct ixgbe_adapter *, struct ixgbe_ring *);
92662306a36Sopenharmony_ciint ixgbe_setup_tx_resources(struct ixgbe_ring *);
92762306a36Sopenharmony_civoid ixgbe_free_rx_resources(struct ixgbe_ring *);
92862306a36Sopenharmony_civoid ixgbe_free_tx_resources(struct ixgbe_ring *);
92962306a36Sopenharmony_civoid ixgbe_configure_rx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
93062306a36Sopenharmony_civoid ixgbe_configure_tx_ring(struct ixgbe_adapter *, struct ixgbe_ring *);
93162306a36Sopenharmony_civoid ixgbe_disable_rx(struct ixgbe_adapter *adapter);
93262306a36Sopenharmony_civoid ixgbe_disable_tx(struct ixgbe_adapter *adapter);
93362306a36Sopenharmony_civoid ixgbe_update_stats(struct ixgbe_adapter *adapter);
93462306a36Sopenharmony_ciint ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter);
93562306a36Sopenharmony_cibool ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id,
93662306a36Sopenharmony_ci			 u16 subdevice_id);
93762306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV
93862306a36Sopenharmony_civoid ixgbe_full_sync_mac_table(struct ixgbe_adapter *adapter);
93962306a36Sopenharmony_ci#endif
94062306a36Sopenharmony_ciint ixgbe_add_mac_filter(struct ixgbe_adapter *adapter,
94162306a36Sopenharmony_ci			 const u8 *addr, u16 queue);
94262306a36Sopenharmony_ciint ixgbe_del_mac_filter(struct ixgbe_adapter *adapter,
94362306a36Sopenharmony_ci			 const u8 *addr, u16 queue);
94462306a36Sopenharmony_civoid ixgbe_update_pf_promisc_vlvf(struct ixgbe_adapter *adapter, u32 vid);
94562306a36Sopenharmony_civoid ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter);
94662306a36Sopenharmony_cinetdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *, struct ixgbe_adapter *,
94762306a36Sopenharmony_ci				  struct ixgbe_ring *);
94862306a36Sopenharmony_civoid ixgbe_alloc_rx_buffers(struct ixgbe_ring *, u16);
94962306a36Sopenharmony_civoid ixgbe_write_eitr(struct ixgbe_q_vector *);
95062306a36Sopenharmony_ciint ixgbe_poll(struct napi_struct *napi, int budget);
95162306a36Sopenharmony_ciint ethtool_ioctl(struct ifreq *ifr);
95262306a36Sopenharmony_cis32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw);
95362306a36Sopenharmony_cis32 ixgbe_init_fdir_signature_82599(struct ixgbe_hw *hw, u32 fdirctrl);
95462306a36Sopenharmony_cis32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl);
95562306a36Sopenharmony_cis32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
95662306a36Sopenharmony_ci					  union ixgbe_atr_hash_dword input,
95762306a36Sopenharmony_ci					  union ixgbe_atr_hash_dword common,
95862306a36Sopenharmony_ci					  u8 queue);
95962306a36Sopenharmony_cis32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
96062306a36Sopenharmony_ci				    union ixgbe_atr_input *input_mask);
96162306a36Sopenharmony_cis32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
96262306a36Sopenharmony_ci					  union ixgbe_atr_input *input,
96362306a36Sopenharmony_ci					  u16 soft_id, u8 queue);
96462306a36Sopenharmony_cis32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
96562306a36Sopenharmony_ci					  union ixgbe_atr_input *input,
96662306a36Sopenharmony_ci					  u16 soft_id);
96762306a36Sopenharmony_civoid ixgbe_atr_compute_perfect_hash_82599(union ixgbe_atr_input *input,
96862306a36Sopenharmony_ci					  union ixgbe_atr_input *mask);
96962306a36Sopenharmony_ciint ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
97062306a36Sopenharmony_ci				    struct ixgbe_fdir_filter *input,
97162306a36Sopenharmony_ci				    u16 sw_idx);
97262306a36Sopenharmony_civoid ixgbe_set_rx_mode(struct net_device *netdev);
97362306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_DCB
97462306a36Sopenharmony_civoid ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter);
97562306a36Sopenharmony_ci#endif
97662306a36Sopenharmony_ciint ixgbe_setup_tc(struct net_device *dev, u8 tc);
97762306a36Sopenharmony_civoid ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);
97862306a36Sopenharmony_civoid ixgbe_do_reset(struct net_device *netdev);
97962306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_HWMON
98062306a36Sopenharmony_civoid ixgbe_sysfs_exit(struct ixgbe_adapter *adapter);
98162306a36Sopenharmony_ciint ixgbe_sysfs_init(struct ixgbe_adapter *adapter);
98262306a36Sopenharmony_ci#endif /* CONFIG_IXGBE_HWMON */
98362306a36Sopenharmony_ci#ifdef IXGBE_FCOE
98462306a36Sopenharmony_civoid ixgbe_configure_fcoe(struct ixgbe_adapter *adapter);
98562306a36Sopenharmony_ciint ixgbe_fso(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
98662306a36Sopenharmony_ci	      u8 *hdr_len);
98762306a36Sopenharmony_ciint ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
98862306a36Sopenharmony_ci		   union ixgbe_adv_rx_desc *rx_desc, struct sk_buff *skb);
98962306a36Sopenharmony_ciint ixgbe_fcoe_ddp_get(struct net_device *netdev, u16 xid,
99062306a36Sopenharmony_ci		       struct scatterlist *sgl, unsigned int sgc);
99162306a36Sopenharmony_ciint ixgbe_fcoe_ddp_target(struct net_device *netdev, u16 xid,
99262306a36Sopenharmony_ci			  struct scatterlist *sgl, unsigned int sgc);
99362306a36Sopenharmony_ciint ixgbe_fcoe_ddp_put(struct net_device *netdev, u16 xid);
99462306a36Sopenharmony_ciint ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
99562306a36Sopenharmony_civoid ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter);
99662306a36Sopenharmony_ciint ixgbe_fcoe_enable(struct net_device *netdev);
99762306a36Sopenharmony_ciint ixgbe_fcoe_disable(struct net_device *netdev);
99862306a36Sopenharmony_ciint ixgbe_fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type);
99962306a36Sopenharmony_ciint ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
100062306a36Sopenharmony_ci			   struct netdev_fcoe_hbainfo *info);
100162306a36Sopenharmony_ciu8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
100262306a36Sopenharmony_ci#endif /* IXGBE_FCOE */
100362306a36Sopenharmony_ci#ifdef CONFIG_DEBUG_FS
100462306a36Sopenharmony_civoid ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
100562306a36Sopenharmony_civoid ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
100662306a36Sopenharmony_civoid ixgbe_dbg_init(void);
100762306a36Sopenharmony_civoid ixgbe_dbg_exit(void);
100862306a36Sopenharmony_ci#else
100962306a36Sopenharmony_cistatic inline void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) {}
101062306a36Sopenharmony_cistatic inline void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter) {}
101162306a36Sopenharmony_cistatic inline void ixgbe_dbg_init(void) {}
101262306a36Sopenharmony_cistatic inline void ixgbe_dbg_exit(void) {}
101362306a36Sopenharmony_ci#endif /* CONFIG_DEBUG_FS */
101462306a36Sopenharmony_cistatic inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
101562306a36Sopenharmony_ci{
101662306a36Sopenharmony_ci	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
101762306a36Sopenharmony_ci}
101862306a36Sopenharmony_ci
101962306a36Sopenharmony_civoid ixgbe_ptp_init(struct ixgbe_adapter *adapter);
102062306a36Sopenharmony_civoid ixgbe_ptp_suspend(struct ixgbe_adapter *adapter);
102162306a36Sopenharmony_civoid ixgbe_ptp_stop(struct ixgbe_adapter *adapter);
102262306a36Sopenharmony_civoid ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter);
102362306a36Sopenharmony_civoid ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter);
102462306a36Sopenharmony_civoid ixgbe_ptp_tx_hang(struct ixgbe_adapter *adapter);
102562306a36Sopenharmony_civoid ixgbe_ptp_rx_pktstamp(struct ixgbe_q_vector *, struct sk_buff *);
102662306a36Sopenharmony_civoid ixgbe_ptp_rx_rgtstamp(struct ixgbe_q_vector *, struct sk_buff *skb);
102762306a36Sopenharmony_cistatic inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring,
102862306a36Sopenharmony_ci					 union ixgbe_adv_rx_desc *rx_desc,
102962306a36Sopenharmony_ci					 struct sk_buff *skb)
103062306a36Sopenharmony_ci{
103162306a36Sopenharmony_ci	if (unlikely(ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_TSIP))) {
103262306a36Sopenharmony_ci		ixgbe_ptp_rx_pktstamp(rx_ring->q_vector, skb);
103362306a36Sopenharmony_ci		return;
103462306a36Sopenharmony_ci	}
103562306a36Sopenharmony_ci
103662306a36Sopenharmony_ci	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS)))
103762306a36Sopenharmony_ci		return;
103862306a36Sopenharmony_ci
103962306a36Sopenharmony_ci	ixgbe_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
104062306a36Sopenharmony_ci
104162306a36Sopenharmony_ci	/* Update the last_rx_timestamp timer in order to enable watchdog check
104262306a36Sopenharmony_ci	 * for error case of latched timestamp on a dropped packet.
104362306a36Sopenharmony_ci	 */
104462306a36Sopenharmony_ci	rx_ring->last_rx_timestamp = jiffies;
104562306a36Sopenharmony_ci}
104662306a36Sopenharmony_ci
104762306a36Sopenharmony_ciint ixgbe_ptp_set_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
104862306a36Sopenharmony_ciint ixgbe_ptp_get_ts_config(struct ixgbe_adapter *adapter, struct ifreq *ifr);
104962306a36Sopenharmony_civoid ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);
105062306a36Sopenharmony_civoid ixgbe_ptp_reset(struct ixgbe_adapter *adapter);
105162306a36Sopenharmony_civoid ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter);
105262306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV
105362306a36Sopenharmony_civoid ixgbe_sriov_reinit(struct ixgbe_adapter *adapter);
105462306a36Sopenharmony_ci#endif
105562306a36Sopenharmony_ci
105662306a36Sopenharmony_cinetdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
105762306a36Sopenharmony_ci				  struct ixgbe_adapter *adapter,
105862306a36Sopenharmony_ci				  struct ixgbe_ring *tx_ring);
105962306a36Sopenharmony_ciu32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
106062306a36Sopenharmony_civoid ixgbe_store_key(struct ixgbe_adapter *adapter);
106162306a36Sopenharmony_civoid ixgbe_store_reta(struct ixgbe_adapter *adapter);
106262306a36Sopenharmony_cis32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
106362306a36Sopenharmony_ci		       u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
106462306a36Sopenharmony_ci#ifdef CONFIG_IXGBE_IPSEC
106562306a36Sopenharmony_civoid ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter);
106662306a36Sopenharmony_civoid ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter);
106762306a36Sopenharmony_civoid ixgbe_ipsec_restore(struct ixgbe_adapter *adapter);
106862306a36Sopenharmony_civoid ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
106962306a36Sopenharmony_ci		    union ixgbe_adv_rx_desc *rx_desc,
107062306a36Sopenharmony_ci		    struct sk_buff *skb);
107162306a36Sopenharmony_ciint ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring, struct ixgbe_tx_buffer *first,
107262306a36Sopenharmony_ci		   struct ixgbe_ipsec_tx_data *itd);
107362306a36Sopenharmony_civoid ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter, u32 vf);
107462306a36Sopenharmony_ciint ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
107562306a36Sopenharmony_ciint ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, u32 *mbuf, u32 vf);
107662306a36Sopenharmony_ci#else
107762306a36Sopenharmony_cistatic inline void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter) { }
107862306a36Sopenharmony_cistatic inline void ixgbe_stop_ipsec_offload(struct ixgbe_adapter *adapter) { }
107962306a36Sopenharmony_cistatic inline void ixgbe_ipsec_restore(struct ixgbe_adapter *adapter) { }
108062306a36Sopenharmony_cistatic inline void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
108162306a36Sopenharmony_ci				  union ixgbe_adv_rx_desc *rx_desc,
108262306a36Sopenharmony_ci				  struct sk_buff *skb) { }
108362306a36Sopenharmony_cistatic inline int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
108462306a36Sopenharmony_ci				 struct ixgbe_tx_buffer *first,
108562306a36Sopenharmony_ci				 struct ixgbe_ipsec_tx_data *itd) { return 0; }
108662306a36Sopenharmony_cistatic inline void ixgbe_ipsec_vf_clear(struct ixgbe_adapter *adapter,
108762306a36Sopenharmony_ci					u32 vf) { }
108862306a36Sopenharmony_cistatic inline int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter,
108962306a36Sopenharmony_ci					u32 *mbuf, u32 vf) { return -EACCES; }
109062306a36Sopenharmony_cistatic inline int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter,
109162306a36Sopenharmony_ci					u32 *mbuf, u32 vf) { return -EACCES; }
109262306a36Sopenharmony_ci#endif /* CONFIG_IXGBE_IPSEC */
109362306a36Sopenharmony_ci
109462306a36Sopenharmony_cistatic inline bool ixgbe_enabled_xdp_adapter(struct ixgbe_adapter *adapter)
109562306a36Sopenharmony_ci{
109662306a36Sopenharmony_ci	return !!adapter->xdp_prog;
109762306a36Sopenharmony_ci}
109862306a36Sopenharmony_ci
109962306a36Sopenharmony_ci#endif /* _IXGBE_H_ */
1100