xref: /openbmc/linux/drivers/net/ethernet/intel/ice/ice.h (revision 5cb1ebdbc4342b1c2ce89516e19808d64417bdbc)
1837f08fdSAnirudh Venkataramanan /* SPDX-License-Identifier: GPL-2.0 */
2837f08fdSAnirudh Venkataramanan /* Copyright (c) 2018, Intel Corporation. */
3837f08fdSAnirudh Venkataramanan 
4837f08fdSAnirudh Venkataramanan #ifndef _ICE_H_
5837f08fdSAnirudh Venkataramanan #define _ICE_H_
6837f08fdSAnirudh Venkataramanan 
7837f08fdSAnirudh Venkataramanan #include <linux/types.h>
8837f08fdSAnirudh Venkataramanan #include <linux/errno.h>
9837f08fdSAnirudh Venkataramanan #include <linux/kernel.h>
10837f08fdSAnirudh Venkataramanan #include <linux/module.h>
11462acf6aSTony Nguyen #include <linux/firmware.h>
12837f08fdSAnirudh Venkataramanan #include <linux/netdevice.h>
13837f08fdSAnirudh Venkataramanan #include <linux/compiler.h>
14dc49c772SAnirudh Venkataramanan #include <linux/etherdevice.h>
15cdedef59SAnirudh Venkataramanan #include <linux/skbuff.h>
163a858ba3SAnirudh Venkataramanan #include <linux/cpumask.h>
17fcea6f3dSAnirudh Venkataramanan #include <linux/rtnetlink.h>
183a858ba3SAnirudh Venkataramanan #include <linux/if_vlan.h>
19cdedef59SAnirudh Venkataramanan #include <linux/dma-mapping.h>
20837f08fdSAnirudh Venkataramanan #include <linux/pci.h>
21940b61afSAnirudh Venkataramanan #include <linux/workqueue.h>
22d69ea414SJacob Keller #include <linux/wait.h>
23837f08fdSAnirudh Venkataramanan #include <linux/aer.h>
24940b61afSAnirudh Venkataramanan #include <linux/interrupt.h>
25fcea6f3dSAnirudh Venkataramanan #include <linux/ethtool.h>
26940b61afSAnirudh Venkataramanan #include <linux/timer.h>
277ec59eeaSAnirudh Venkataramanan #include <linux/delay.h>
28837f08fdSAnirudh Venkataramanan #include <linux/bitmap.h>
293a858ba3SAnirudh Venkataramanan #include <linux/log2.h>
30d76a60baSAnirudh Venkataramanan #include <linux/ip.h>
31cf909e19SAnirudh Venkataramanan #include <linux/sctp.h>
32d76a60baSAnirudh Venkataramanan #include <linux/ipv6.h>
33efc2214bSMaciej Fijalkowski #include <linux/pkt_sched.h>
34940b61afSAnirudh Venkataramanan #include <linux/if_bridge.h>
35e3710a01SPaul M Stillwell Jr #include <linux/ctype.h>
36efc2214bSMaciej Fijalkowski #include <linux/bpf.h>
37195bb48fSMichal Swiatkowski #include <linux/btf.h>
38f9f5301eSDave Ertman #include <linux/auxiliary_bus.h>
39ddf30f7fSAnirudh Venkataramanan #include <linux/avf/virtchnl.h>
4028bf2672SBrett Creeley #include <linux/cpu_rmap.h>
41cdf1f1f1SJacob Keller #include <linux/dim.h>
420754d65bSKiran Patil #include <net/pkt_cls.h>
439fea7498SKiran Patil #include <net/tc_act/tc_mirred.h>
449fea7498SKiran Patil #include <net/tc_act/tc_gact.h>
459fea7498SKiran Patil #include <net/ip.h>
461adf7eadSJacob Keller #include <net/devlink.h>
47d76a60baSAnirudh Venkataramanan #include <net/ipv6.h>
482d4238f5SKrzysztof Kazimierczak #include <net/xdp_sock.h>
49c7a21904SMichal Swiatkowski #include <net/xdp_sock_drv.h>
50a4e82a81STony Nguyen #include <net/geneve.h>
51a4e82a81STony Nguyen #include <net/gre.h>
52a4e82a81STony Nguyen #include <net/udp_tunnel.h>
53a4e82a81STony Nguyen #include <net/vxlan.h>
54d41f26b5SBruce Allan #if IS_ENABLED(CONFIG_DCB)
55d41f26b5SBruce Allan #include <scsi/iscsi_proto.h>
56d41f26b5SBruce Allan #endif /* CONFIG_DCB */
57837f08fdSAnirudh Venkataramanan #include "ice_devids.h"
58837f08fdSAnirudh Venkataramanan #include "ice_type.h"
59940b61afSAnirudh Venkataramanan #include "ice_txrx.h"
6037b6f646SAnirudh Venkataramanan #include "ice_dcb.h"
619c20346bSAnirudh Venkataramanan #include "ice_switch.h"
62f31e4b6fSAnirudh Venkataramanan #include "ice_common.h"
63fbc7b27aSKiran Patil #include "ice_flow.h"
649c20346bSAnirudh Venkataramanan #include "ice_sched.h"
65348048e7SDave Ertman #include "ice_idc_int.h"
66ddf30f7fSAnirudh Venkataramanan #include "ice_virtchnl_pf.h"
67007676b4SAnirudh Venkataramanan #include "ice_sriov.h"
6806c16d89SJacob Keller #include "ice_ptp.h"
69148beb61SHenry Tieman #include "ice_fdir.h"
702d4238f5SKrzysztof Kazimierczak #include "ice_xsk.h"
7128bf2672SBrett Creeley #include "ice_arfs.h"
7237165e3fSMichal Swiatkowski #include "ice_repr.h"
730d08a441SKiran Patil #include "ice_eswitch.h"
74df006dd4SDave Ertman #include "ice_lag.h"
75837f08fdSAnirudh Venkataramanan 
76837f08fdSAnirudh Venkataramanan #define ICE_BAR0		0
773a858ba3SAnirudh Venkataramanan #define ICE_REQ_DESC_MULTIPLE	32
788be92a76SPreethi Banala #define ICE_MIN_NUM_DESC	64
793b6bf296SBruce Allan #define ICE_MAX_NUM_DESC	8160
801aec6e1bSBrett Creeley #define ICE_DFLT_MIN_RX_DESC	512
81dd47e1fdSJesse Brandeburg #define ICE_DFLT_NUM_TX_DESC	256
82dd47e1fdSJesse Brandeburg #define ICE_DFLT_NUM_RX_DESC	2048
83ad71b256SBrett Creeley 
845513b920SAnirudh Venkataramanan #define ICE_DFLT_TRAFFIC_CLASS	BIT(0)
85940b61afSAnirudh Venkataramanan #define ICE_INT_NAME_STR_LEN	(IFNAMSIZ + 16)
868f5ee3c4SJacob Keller #define ICE_AQ_LEN		192
8711836214SBrett Creeley #define ICE_MBXSQ_LEN		64
888f5ee3c4SJacob Keller #define ICE_SBQ_LEN		64
89f3fe97f6SBrett Creeley #define ICE_MIN_LAN_TXRX_MSIX	1
90f3fe97f6SBrett Creeley #define ICE_MIN_LAN_OICR_MSIX	1
91f3fe97f6SBrett Creeley #define ICE_MIN_MSIX		(ICE_MIN_LAN_TXRX_MSIX + ICE_MIN_LAN_OICR_MSIX)
92da62c5ffSQi Zhang #define ICE_FDIR_MSIX		2
93d25a0fc4SDave Ertman #define ICE_RDMA_NUM_AEQ_MSIX	4
94d25a0fc4SDave Ertman #define ICE_MIN_RDMA_MSIX	2
95f66756e0SGrzegorz Nitka #define ICE_ESWITCH_MSIX	1
963a858ba3SAnirudh Venkataramanan #define ICE_NO_VSI		0xffff
973a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_CONTIG	0
983a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_SCATTER	1
993a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_TXQS	16
1003a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_RXQS	16
101cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_RETRY_LIMIT	10
102cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_MAX_RETRY	(5 * ICE_Q_WAIT_RETRY_LIMIT)
103d76a60baSAnirudh Venkataramanan #define ICE_MAX_LG_RSS_QS	256
104940b61afSAnirudh Venkataramanan #define ICE_RES_VALID_BIT	0x8000
105940b61afSAnirudh Venkataramanan #define ICE_RES_MISC_VEC_ID	(ICE_RES_VALID_BIT - 1)
106d25a0fc4SDave Ertman #define ICE_RES_RDMA_VEC_ID	(ICE_RES_MISC_VEC_ID - 1)
107da62c5ffSQi Zhang /* All VF control VSIs share the same IRQ, so assign a unique ID for them */
108d25a0fc4SDave Ertman #define ICE_RES_VF_CTRL_VEC_ID	(ICE_RES_RDMA_VEC_ID - 1)
1093a858ba3SAnirudh Venkataramanan #define ICE_INVAL_Q_INDEX	0xffff
1100f9d5027SAnirudh Venkataramanan #define ICE_INVAL_VFID		256
111837f08fdSAnirudh Venkataramanan 
1128134d5ffSBrett Creeley #define ICE_MAX_RXQS_PER_TC		256	/* Used when setting VSI context per TC Rx queues */
1130754d65bSKiran Patil 
1140754d65bSKiran Patil #define ICE_CHNL_START_TC		1
1150754d65bSKiran Patil 
116afd9d4abSAnirudh Venkataramanan #define ICE_MAX_RESET_WAIT		20
117afd9d4abSAnirudh Venkataramanan 
118fcea6f3dSAnirudh Venkataramanan #define ICE_VSIQF_HKEY_ARRAY_SIZE	((VSIQF_HKEY_MAX_INDEX + 1) *	4)
119fcea6f3dSAnirudh Venkataramanan 
120837f08fdSAnirudh Venkataramanan #define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
121837f08fdSAnirudh Venkataramanan 
122efc2214bSMaciej Fijalkowski #define ICE_MAX_MTU	(ICE_AQ_SET_MAC_FRAME_SIZE_MAX - ICE_ETH_PKT_HDR_PAD)
1233a858ba3SAnirudh Venkataramanan 
1243a858ba3SAnirudh Venkataramanan #define ICE_UP_TABLE_TRANSLATE(val, i) \
1253a858ba3SAnirudh Venkataramanan 		(((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
1263a858ba3SAnirudh Venkataramanan 		  ICE_AQ_VSI_UP_TABLE_UP##i##_M)
1273a858ba3SAnirudh Venkataramanan 
1282b245cb2SAnirudh Venkataramanan #define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i]))
129cdedef59SAnirudh Venkataramanan #define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
130d76a60baSAnirudh Venkataramanan #define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i]))
131cac2a27cSHenry Tieman #define ICE_TX_FDIRDESC(R, i) (&(((struct ice_fltr_desc *)((R)->desc))[i]))
132cdedef59SAnirudh Venkataramanan 
133fbc7b27aSKiran Patil /* Minimum BW limit is 500 Kbps for any scheduler node */
134fbc7b27aSKiran Patil #define ICE_MIN_BW_LIMIT		500
135fbc7b27aSKiran Patil /* User can specify BW in either Kbit/Mbit/Gbit and OS converts it in bytes.
136fbc7b27aSKiran Patil  * use it to convert user specified BW limit into Kbps
137fbc7b27aSKiran Patil  */
138fbc7b27aSKiran Patil #define ICE_BW_KBPS_DIVISOR		125
139fbc7b27aSKiran Patil 
1400b28b702SAnirudh Venkataramanan /* Macro for each VSI in a PF */
1410b28b702SAnirudh Venkataramanan #define ice_for_each_vsi(pf, i) \
1420b28b702SAnirudh Venkataramanan 	for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
1430b28b702SAnirudh Venkataramanan 
1442faf63b6SMaciej Fijalkowski /* Macros for each Tx/Xdp/Rx ring in a VSI */
145cdedef59SAnirudh Venkataramanan #define ice_for_each_txq(vsi, i) \
146cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
147cdedef59SAnirudh Venkataramanan 
1482faf63b6SMaciej Fijalkowski #define ice_for_each_xdp_txq(vsi, i) \
1492faf63b6SMaciej Fijalkowski 	for ((i) = 0; (i) < (vsi)->num_xdp_txq; (i)++)
1502faf63b6SMaciej Fijalkowski 
151cdedef59SAnirudh Venkataramanan #define ice_for_each_rxq(vsi, i) \
152cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
153cdedef59SAnirudh Venkataramanan 
154d337f2afSAnirudh Venkataramanan /* Macros for each allocated Tx/Rx ring whether used or not in a VSI */
155f8ba7db8SJacob Keller #define ice_for_each_alloc_txq(vsi, i) \
156f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
157f8ba7db8SJacob Keller 
158f8ba7db8SJacob Keller #define ice_for_each_alloc_rxq(vsi, i) \
159f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
160f8ba7db8SJacob Keller 
16167fe64d7SBrett Creeley #define ice_for_each_q_vector(vsi, i) \
16267fe64d7SBrett Creeley 	for ((i) = 0; (i) < (vsi)->num_q_vectors; (i)++)
16367fe64d7SBrett Creeley 
1640754d65bSKiran Patil #define ice_for_each_chnl_tc(i)	\
1650754d65bSKiran Patil 	for ((i) = ICE_CHNL_START_TC; (i) < ICE_CHNL_MAX_TC; (i)++)
1660754d65bSKiran Patil 
1671a8c7778SBrett Creeley #define ICE_UCAST_PROMISC_BITS (ICE_PROMISC_UCAST_TX | ICE_PROMISC_UCAST_RX)
1685eda8afdSAkeem G Abodunrin 
1695eda8afdSAkeem G Abodunrin #define ICE_UCAST_VLAN_PROMISC_BITS (ICE_PROMISC_UCAST_TX | \
1705eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_UCAST_RX | \
1715eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_VLAN_TX  | \
1725eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_VLAN_RX)
1735eda8afdSAkeem G Abodunrin 
1745eda8afdSAkeem G Abodunrin #define ICE_MCAST_PROMISC_BITS (ICE_PROMISC_MCAST_TX | ICE_PROMISC_MCAST_RX)
1755eda8afdSAkeem G Abodunrin 
1765eda8afdSAkeem G Abodunrin #define ICE_MCAST_VLAN_PROMISC_BITS (ICE_PROMISC_MCAST_TX | \
1775eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_MCAST_RX | \
1785eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_VLAN_TX  | \
1795eda8afdSAkeem G Abodunrin 				     ICE_PROMISC_VLAN_RX)
1805eda8afdSAkeem G Abodunrin 
1814015d11eSBrett Creeley #define ice_pf_to_dev(pf) (&((pf)->pdev->dev))
1824015d11eSBrett Creeley 
18340b24760SAnirudh Venkataramanan enum ice_feature {
18440b24760SAnirudh Venkataramanan 	ICE_F_DSCP,
185325b2064SMaciej Machnikowski 	ICE_F_SMA_CTRL,
18640b24760SAnirudh Venkataramanan 	ICE_F_MAX
18740b24760SAnirudh Venkataramanan };
18840b24760SAnirudh Venkataramanan 
18922bf877eSMaciej Fijalkowski DECLARE_STATIC_KEY_FALSE(ice_xdp_locking_key);
19022bf877eSMaciej Fijalkowski 
1910754d65bSKiran Patil struct ice_channel {
1920754d65bSKiran Patil 	struct list_head list;
1930754d65bSKiran Patil 	u8 type;
1940754d65bSKiran Patil 	u16 sw_id;
1950754d65bSKiran Patil 	u16 base_q;
1960754d65bSKiran Patil 	u16 num_rxq;
1970754d65bSKiran Patil 	u16 num_txq;
1980754d65bSKiran Patil 	u16 vsi_num;
1990754d65bSKiran Patil 	u8 ena_tc;
2000754d65bSKiran Patil 	struct ice_aqc_vsi_props info;
2010754d65bSKiran Patil 	u64 max_tx_rate;
2020754d65bSKiran Patil 	u64 min_tx_rate;
20340319796SKiran Patil 	atomic_t num_sb_fltr;
2040754d65bSKiran Patil 	struct ice_vsi *ch_vsi;
2050754d65bSKiran Patil };
2060754d65bSKiran Patil 
207eff380aaSAnirudh Venkataramanan struct ice_txq_meta {
208eff380aaSAnirudh Venkataramanan 	u32 q_teid;	/* Tx-scheduler element identifier */
209eff380aaSAnirudh Venkataramanan 	u16 q_id;	/* Entry in VSI's txq_map bitmap */
210eff380aaSAnirudh Venkataramanan 	u16 q_handle;	/* Relative index of Tx queue within TC */
211eff380aaSAnirudh Venkataramanan 	u16 vsi_idx;	/* VSI index that Tx queue belongs to */
212eff380aaSAnirudh Venkataramanan 	u8 tc;		/* TC number that Tx queue belongs to */
213eff380aaSAnirudh Venkataramanan };
214eff380aaSAnirudh Venkataramanan 
2153a858ba3SAnirudh Venkataramanan struct ice_tc_info {
2163a858ba3SAnirudh Venkataramanan 	u16 qoffset;
217c5a2a4a3SUsha Ketineni 	u16 qcount_tx;
218c5a2a4a3SUsha Ketineni 	u16 qcount_rx;
219c5a2a4a3SUsha Ketineni 	u8 netdev_tc;
2203a858ba3SAnirudh Venkataramanan };
2213a858ba3SAnirudh Venkataramanan 
2223a858ba3SAnirudh Venkataramanan struct ice_tc_cfg {
2233a858ba3SAnirudh Venkataramanan 	u8 numtc; /* Total number of enabled TCs */
2240754d65bSKiran Patil 	u16 ena_tc; /* Tx map */
2253a858ba3SAnirudh Venkataramanan 	struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS];
2263a858ba3SAnirudh Venkataramanan };
2273a858ba3SAnirudh Venkataramanan 
228940b61afSAnirudh Venkataramanan struct ice_res_tracker {
229940b61afSAnirudh Venkataramanan 	u16 num_entries;
230cbe66bfeSBrett Creeley 	u16 end;
231e94c0df9SGustavo A. R. Silva 	u16 list[];
232940b61afSAnirudh Venkataramanan };
233940b61afSAnirudh Venkataramanan 
23403f7a986SAnirudh Venkataramanan struct ice_qs_cfg {
23594c4441bSAnirudh Venkataramanan 	struct mutex *qs_mutex;  /* will be assigned to &pf->avail_q_mutex */
23603f7a986SAnirudh Venkataramanan 	unsigned long *pf_map;
23703f7a986SAnirudh Venkataramanan 	unsigned long pf_map_size;
23803f7a986SAnirudh Venkataramanan 	unsigned int q_count;
23903f7a986SAnirudh Venkataramanan 	unsigned int scatter_count;
24003f7a986SAnirudh Venkataramanan 	u16 *vsi_map;
24103f7a986SAnirudh Venkataramanan 	u16 vsi_map_offset;
24203f7a986SAnirudh Venkataramanan 	u8 mapping_mode;
24303f7a986SAnirudh Venkataramanan };
24403f7a986SAnirudh Venkataramanan 
245940b61afSAnirudh Venkataramanan struct ice_sw {
246940b61afSAnirudh Venkataramanan 	struct ice_pf *pf;
247940b61afSAnirudh Venkataramanan 	u16 sw_id;		/* switch ID for this switch */
248940b61afSAnirudh Venkataramanan 	u16 bridge_mode;	/* VEB/VEPA/Port Virtualizer */
249fc0f39bcSBrett Creeley 	struct ice_vsi *dflt_vsi;	/* default VSI for this switch */
250fc0f39bcSBrett Creeley 	u8 dflt_vsi_ena:1;	/* true if above dflt_vsi is enabled */
251940b61afSAnirudh Venkataramanan };
252940b61afSAnirudh Venkataramanan 
253e97fb1aeSAnirudh Venkataramanan enum ice_pf_state {
2547e408e07SAnirudh Venkataramanan 	ICE_TESTING,
2557e408e07SAnirudh Venkataramanan 	ICE_DOWN,
2567e408e07SAnirudh Venkataramanan 	ICE_NEEDS_RESTART,
2577e408e07SAnirudh Venkataramanan 	ICE_PREPARED_FOR_RESET,	/* set by driver when prepared */
2587e408e07SAnirudh Venkataramanan 	ICE_RESET_OICR_RECV,		/* set by driver after rcv reset OICR */
259348048e7SDave Ertman 	ICE_PFR_REQ,		/* set by driver */
260348048e7SDave Ertman 	ICE_CORER_REQ,		/* set by driver */
261348048e7SDave Ertman 	ICE_GLOBR_REQ,		/* set by driver */
2627e408e07SAnirudh Venkataramanan 	ICE_CORER_RECV,		/* set by OICR handler */
2637e408e07SAnirudh Venkataramanan 	ICE_GLOBR_RECV,		/* set by OICR handler */
2647e408e07SAnirudh Venkataramanan 	ICE_EMPR_RECV,		/* set by OICR handler */
2657e408e07SAnirudh Venkataramanan 	ICE_SUSPENDED,		/* set on module remove path */
2667e408e07SAnirudh Venkataramanan 	ICE_RESET_FAILED,		/* set by reset/rebuild */
267ddf30f7fSAnirudh Venkataramanan 	/* When checking for the PF to be in a nominal operating state, the
268ddf30f7fSAnirudh Venkataramanan 	 * bits that are grouped at the beginning of the list need to be
2697e408e07SAnirudh Venkataramanan 	 * checked. Bits occurring before ICE_STATE_NOMINAL_CHECK_BITS will
270ddf30f7fSAnirudh Venkataramanan 	 * be checked. If you need to add a bit into consideration for nominal
271ddf30f7fSAnirudh Venkataramanan 	 * operating state, it must be added before
2727e408e07SAnirudh Venkataramanan 	 * ICE_STATE_NOMINAL_CHECK_BITS. Do not move this entry's position
273ddf30f7fSAnirudh Venkataramanan 	 * without appropriate consideration.
274ddf30f7fSAnirudh Venkataramanan 	 */
2757e408e07SAnirudh Venkataramanan 	ICE_STATE_NOMINAL_CHECK_BITS,
2767e408e07SAnirudh Venkataramanan 	ICE_ADMINQ_EVENT_PENDING,
2777e408e07SAnirudh Venkataramanan 	ICE_MAILBOXQ_EVENT_PENDING,
2788f5ee3c4SJacob Keller 	ICE_SIDEBANDQ_EVENT_PENDING,
2797e408e07SAnirudh Venkataramanan 	ICE_MDD_EVENT_PENDING,
2807e408e07SAnirudh Venkataramanan 	ICE_VFLR_EVENT_PENDING,
2817e408e07SAnirudh Venkataramanan 	ICE_FLTR_OVERFLOW_PROMISC,
2827e408e07SAnirudh Venkataramanan 	ICE_VF_DIS,
2837e408e07SAnirudh Venkataramanan 	ICE_CFG_BUSY,
2847e408e07SAnirudh Venkataramanan 	ICE_SERVICE_SCHED,
2857e408e07SAnirudh Venkataramanan 	ICE_SERVICE_DIS,
2867e408e07SAnirudh Venkataramanan 	ICE_FD_FLUSH_REQ,
2877e408e07SAnirudh Venkataramanan 	ICE_OICR_INTR_DIS,		/* Global OICR interrupt disabled */
2887e408e07SAnirudh Venkataramanan 	ICE_MDD_VF_PRINT_PENDING,	/* set when MDD event handle */
2897e408e07SAnirudh Venkataramanan 	ICE_VF_RESETS_DISABLED,	/* disable resets during ice_remove */
2907e408e07SAnirudh Venkataramanan 	ICE_LINK_DEFAULT_OVERRIDE_PENDING,
2917e408e07SAnirudh Venkataramanan 	ICE_PHY_INIT_COMPLETE,
2927e408e07SAnirudh Venkataramanan 	ICE_FD_VF_FLUSH_CTX,		/* set at FD Rx IRQ or timeout */
2937e408e07SAnirudh Venkataramanan 	ICE_STATE_NBITS		/* must be last */
294837f08fdSAnirudh Venkataramanan };
295837f08fdSAnirudh Venkataramanan 
296e97fb1aeSAnirudh Venkataramanan enum ice_vsi_state {
297e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_DOWN,
298e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_NEEDS_RESTART,
299a476d72aSAnirudh Venkataramanan 	ICE_VSI_NETDEV_ALLOCD,
300a476d72aSAnirudh Venkataramanan 	ICE_VSI_NETDEV_REGISTERED,
301e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_UMAC_FLTR_CHANGED,
302e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_MMAC_FLTR_CHANGED,
303e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_VLAN_FLTR_CHANGED,
304e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_PROMISC_CHANGED,
305e97fb1aeSAnirudh Venkataramanan 	ICE_VSI_STATE_NBITS		/* must be last */
306e94d4478SAnirudh Venkataramanan };
307e94d4478SAnirudh Venkataramanan 
308940b61afSAnirudh Venkataramanan /* struct that defines a VSI, associated with a dev */
309940b61afSAnirudh Venkataramanan struct ice_vsi {
310940b61afSAnirudh Venkataramanan 	struct net_device *netdev;
3113a858ba3SAnirudh Venkataramanan 	struct ice_sw *vsw;		 /* switch this VSI is on */
3123a858ba3SAnirudh Venkataramanan 	struct ice_pf *back;		 /* back pointer to PF */
313940b61afSAnirudh Venkataramanan 	struct ice_port_info *port_info; /* back pointer to port_info */
314e72bba21SMaciej Fijalkowski 	struct ice_rx_ring **rx_rings;	 /* Rx ring array */
315e72bba21SMaciej Fijalkowski 	struct ice_tx_ring **tx_rings;	 /* Tx ring array */
3163a858ba3SAnirudh Venkataramanan 	struct ice_q_vector **q_vectors; /* q_vector array */
317cdedef59SAnirudh Venkataramanan 
318cdedef59SAnirudh Venkataramanan 	irqreturn_t (*irq_handler)(int irq, void *data);
319cdedef59SAnirudh Venkataramanan 
320fcea6f3dSAnirudh Venkataramanan 	u64 tx_linearize;
321e97fb1aeSAnirudh Venkataramanan 	DECLARE_BITMAP(state, ICE_VSI_STATE_NBITS);
322e94d4478SAnirudh Venkataramanan 	unsigned int current_netdev_flags;
323fcea6f3dSAnirudh Venkataramanan 	u32 tx_restart;
324fcea6f3dSAnirudh Venkataramanan 	u32 tx_busy;
325fcea6f3dSAnirudh Venkataramanan 	u32 rx_buf_failed;
326fcea6f3dSAnirudh Venkataramanan 	u32 rx_page_failed;
32788865fc4SKarol Kolacinski 	u16 num_q_vectors;
32888865fc4SKarol Kolacinski 	u16 base_vector;		/* IRQ base for OS reserved vectors */
3293a858ba3SAnirudh Venkataramanan 	enum ice_vsi_type type;
330940b61afSAnirudh Venkataramanan 	u16 vsi_num;			/* HW (absolute) index of this VSI */
3313a858ba3SAnirudh Venkataramanan 	u16 idx;			/* software index in pf->vsi[] */
3323a858ba3SAnirudh Venkataramanan 
3338ede0178SAnirudh Venkataramanan 	s16 vf_id;			/* VF ID for SR-IOV VSIs */
3348ede0178SAnirudh Venkataramanan 
335d95276ceSAkeem G Abodunrin 	u16 ethtype;			/* Ethernet protocol for pause frame */
336148beb61SHenry Tieman 	u16 num_gfltr;
337148beb61SHenry Tieman 	u16 num_bfltr;
338d95276ceSAkeem G Abodunrin 
339d76a60baSAnirudh Venkataramanan 	/* RSS config */
340d76a60baSAnirudh Venkataramanan 	u16 rss_table_size;	/* HW RSS table size */
341d76a60baSAnirudh Venkataramanan 	u16 rss_size;		/* Allocated RSS queues */
342d76a60baSAnirudh Venkataramanan 	u8 *rss_hkey_user;	/* User configured hash keys */
343d76a60baSAnirudh Venkataramanan 	u8 *rss_lut_user;	/* User configured lookup table entries */
344d76a60baSAnirudh Venkataramanan 	u8 rss_lut_type;	/* used to configure Get/Set RSS LUT AQ call */
345d76a60baSAnirudh Venkataramanan 
34628bf2672SBrett Creeley 	/* aRFS members only allocated for the PF VSI */
34728bf2672SBrett Creeley #define ICE_MAX_ARFS_LIST	1024
34828bf2672SBrett Creeley #define ICE_ARFS_LST_MASK	(ICE_MAX_ARFS_LIST - 1)
34928bf2672SBrett Creeley 	struct hlist_head *arfs_fltr_list;
35028bf2672SBrett Creeley 	struct ice_arfs_active_fltr_cntrs *arfs_fltr_cntrs;
35128bf2672SBrett Creeley 	spinlock_t arfs_lock;	/* protects aRFS hash table and filter state */
35228bf2672SBrett Creeley 	atomic_t *arfs_last_fltr_id;
35328bf2672SBrett Creeley 
354cdedef59SAnirudh Venkataramanan 	u16 max_frame;
355cdedef59SAnirudh Venkataramanan 	u16 rx_buf_len;
356cdedef59SAnirudh Venkataramanan 
3573a858ba3SAnirudh Venkataramanan 	struct ice_aqc_vsi_props info;	 /* VSI properties */
3583a858ba3SAnirudh Venkataramanan 
359fcea6f3dSAnirudh Venkataramanan 	/* VSI stats */
360fcea6f3dSAnirudh Venkataramanan 	struct rtnl_link_stats64 net_stats;
361fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats;
362fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats_prev;
363fcea6f3dSAnirudh Venkataramanan 
364e94d4478SAnirudh Venkataramanan 	struct list_head tmp_sync_list;		/* MAC filters to be synced */
365e94d4478SAnirudh Venkataramanan 	struct list_head tmp_unsync_list;	/* MAC filters to be unsynced */
366e94d4478SAnirudh Venkataramanan 
3670ab54c5fSJesse Brandeburg 	u8 irqs_ready:1;
3680ab54c5fSJesse Brandeburg 	u8 current_isup:1;		 /* Sync 'link up' logging */
3690ab54c5fSJesse Brandeburg 	u8 stat_offsets_loaded:1;
370cd6d6b83SBrett Creeley 	u16 num_vlan;
371cdedef59SAnirudh Venkataramanan 
3723a858ba3SAnirudh Venkataramanan 	/* queue information */
3733a858ba3SAnirudh Venkataramanan 	u8 tx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
3743a858ba3SAnirudh Venkataramanan 	u8 rx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
37578b5713aSAnirudh Venkataramanan 	u16 *txq_map;			 /* index in pf->avail_txqs */
37678b5713aSAnirudh Venkataramanan 	u16 *rxq_map;			 /* index in pf->avail_rxqs */
3773a858ba3SAnirudh Venkataramanan 	u16 alloc_txq;			 /* Allocated Tx queues */
3783a858ba3SAnirudh Venkataramanan 	u16 num_txq;			 /* Used Tx queues */
3793a858ba3SAnirudh Venkataramanan 	u16 alloc_rxq;			 /* Allocated Rx queues */
3803a858ba3SAnirudh Venkataramanan 	u16 num_rxq;			 /* Used Rx queues */
38187324e74SHenry Tieman 	u16 req_txq;			 /* User requested Tx queues */
38287324e74SHenry Tieman 	u16 req_rxq;			 /* User requested Rx queues */
383ad71b256SBrett Creeley 	u16 num_rx_desc;
384ad71b256SBrett Creeley 	u16 num_tx_desc;
385348048e7SDave Ertman 	u16 qset_handle[ICE_MAX_TRAFFIC_CLASS];
3863a858ba3SAnirudh Venkataramanan 	struct ice_tc_cfg tc_cfg;
387efc2214bSMaciej Fijalkowski 	struct bpf_prog *xdp_prog;
388e72bba21SMaciej Fijalkowski 	struct ice_tx_ring **xdp_rings;	 /* XDP ring array */
389e102db78SMaciej Fijalkowski 	unsigned long *af_xdp_zc_qps;	 /* tracks AF_XDP ZC enabled qps */
390efc2214bSMaciej Fijalkowski 	u16 num_xdp_txq;		 /* Used XDP queues */
391efc2214bSMaciej Fijalkowski 	u8 xdp_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
392b126bd6bSKiran Patil 
3931a1c40dfSGrzegorz Nitka 	struct net_device **target_netdevs;
3941a1c40dfSGrzegorz Nitka 
3950754d65bSKiran Patil 	struct tc_mqprio_qopt_offload mqprio_qopt; /* queue parameters */
3960754d65bSKiran Patil 
3970754d65bSKiran Patil 	/* Channel Specific Fields */
3980754d65bSKiran Patil 	struct ice_vsi *tc_map_vsi[ICE_CHNL_MAX_TC];
3990754d65bSKiran Patil 	u16 cnt_q_avail;
4000754d65bSKiran Patil 	u16 next_base_q;	/* next queue to be used for channel setup */
4010754d65bSKiran Patil 	struct list_head ch_list;
4020754d65bSKiran Patil 	u16 num_chnl_rxq;
4030754d65bSKiran Patil 	u16 num_chnl_txq;
4040754d65bSKiran Patil 	u16 ch_rss_size;
4059fea7498SKiran Patil 	u16 num_chnl_fltr;
4060754d65bSKiran Patil 	/* store away rss size info before configuring ADQ channels so that,
4070754d65bSKiran Patil 	 * it can be used after tc-qdisc delete, to get back RSS setting as
4080754d65bSKiran Patil 	 * they were before
4090754d65bSKiran Patil 	 */
4100754d65bSKiran Patil 	u16 orig_rss_size;
4110754d65bSKiran Patil 	/* this keeps tracks of all enabled TC with and without DCB
4120754d65bSKiran Patil 	 * and inclusive of ADQ, vsi->mqprio_opt keeps track of queue
4130754d65bSKiran Patil 	 * information
4140754d65bSKiran Patil 	 */
4150754d65bSKiran Patil 	u8 all_numtc;
4160754d65bSKiran Patil 	u16 all_enatc;
4170754d65bSKiran Patil 
4180754d65bSKiran Patil 	/* store away TC info, to be used for rebuild logic */
4190754d65bSKiran Patil 	u8 old_numtc;
4200754d65bSKiran Patil 	u16 old_ena_tc;
4210754d65bSKiran Patil 
4220754d65bSKiran Patil 	struct ice_channel *ch;
4230754d65bSKiran Patil 
424b126bd6bSKiran Patil 	/* setup back reference, to which aggregator node this VSI
425b126bd6bSKiran Patil 	 * corresponds to
426b126bd6bSKiran Patil 	 */
427b126bd6bSKiran Patil 	struct ice_agg_node *agg_node;
4283a858ba3SAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
4293a858ba3SAnirudh Venkataramanan 
4303a858ba3SAnirudh Venkataramanan /* struct that defines an interrupt vector */
4313a858ba3SAnirudh Venkataramanan struct ice_q_vector {
4323a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
4338244dd2dSBrett Creeley 
4343a858ba3SAnirudh Venkataramanan 	u16 v_idx;			/* index in the vsi->q_vector array. */
435b07833a0SBrett Creeley 	u16 reg_idx;
436d337f2afSAnirudh Venkataramanan 	u8 num_ring_rx;			/* total number of Rx rings in vector */
4378244dd2dSBrett Creeley 	u8 num_ring_tx;			/* total number of Tx rings in vector */
438cdf1f1f1SJacob Keller 	u8 wb_on_itr:1;			/* if true, WB on ITR is enabled */
4399e4ab4c2SBrett Creeley 	/* in usecs, need to use ice_intrl_to_usecs_reg() before writing this
4409e4ab4c2SBrett Creeley 	 * value to the device
4419e4ab4c2SBrett Creeley 	 */
4429e4ab4c2SBrett Creeley 	u8 intrl;
4438244dd2dSBrett Creeley 
4448244dd2dSBrett Creeley 	struct napi_struct napi;
4458244dd2dSBrett Creeley 
4468244dd2dSBrett Creeley 	struct ice_ring_container rx;
4478244dd2dSBrett Creeley 	struct ice_ring_container tx;
4488244dd2dSBrett Creeley 
4498244dd2dSBrett Creeley 	cpumask_t affinity_mask;
4508244dd2dSBrett Creeley 	struct irq_affinity_notify affinity_notify;
4518244dd2dSBrett Creeley 
452fbc7b27aSKiran Patil 	struct ice_channel *ch;
453fbc7b27aSKiran Patil 
4548244dd2dSBrett Creeley 	char name[ICE_INT_NAME_STR_LEN];
455cdf1f1f1SJacob Keller 
456cdf1f1f1SJacob Keller 	u16 total_events;	/* net_dim(): number of interrupts processed */
457940b61afSAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
458940b61afSAnirudh Venkataramanan 
459940b61afSAnirudh Venkataramanan enum ice_pf_flags {
460940b61afSAnirudh Venkataramanan 	ICE_FLAG_FLTR_SYNC,
461d25a0fc4SDave Ertman 	ICE_FLAG_RDMA_ENA,
462940b61afSAnirudh Venkataramanan 	ICE_FLAG_RSS_ENA,
463ddf30f7fSAnirudh Venkataramanan 	ICE_FLAG_SRIOV_ENA,
46475d2b253SAnirudh Venkataramanan 	ICE_FLAG_SRIOV_CAPABLE,
46537b6f646SAnirudh Venkataramanan 	ICE_FLAG_DCB_CAPABLE,
46637b6f646SAnirudh Venkataramanan 	ICE_FLAG_DCB_ENA,
467148beb61SHenry Tieman 	ICE_FLAG_FD_ENA,
46806c16d89SJacob Keller 	ICE_FLAG_PTP_SUPPORTED,		/* PTP is supported by NVM */
46906c16d89SJacob Keller 	ICE_FLAG_PTP,			/* PTP is enabled by software */
470d25a0fc4SDave Ertman 	ICE_FLAG_AUX_ENA,
471462acf6aSTony Nguyen 	ICE_FLAG_ADV_FEATURES,
4720754d65bSKiran Patil 	ICE_FLAG_TC_MQPRIO,		/* support for Multi queue TC */
4730d08a441SKiran Patil 	ICE_FLAG_CLS_FLOWER,
474ab4ab73fSBruce Allan 	ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
475b4e813ddSBruce Allan 	ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA,
4766d599946STony Nguyen 	ICE_FLAG_NO_MEDIA,
47784a118abSDave Ertman 	ICE_FLAG_FW_LLDP_AGENT,
478c77849f5SAnirudh Venkataramanan 	ICE_FLAG_MOD_POWER_UNSUPPORTED,
47999d40752SBrett Creeley 	ICE_FLAG_PHY_FW_LOAD_FAILED,
4803a257a14SAnirudh Venkataramanan 	ICE_FLAG_ETHTOOL_CTXT,		/* set when ethtool holds RTNL lock */
4817237f5b0SMaciej Fijalkowski 	ICE_FLAG_LEGACY_RX,
48201b5e89aSBrett Creeley 	ICE_FLAG_VF_TRUE_PROMISC_ENA,
4839d5c5a52SPaul Greenwalt 	ICE_FLAG_MDD_AUTO_RESET_VF,
484ea78ce4dSPaul Greenwalt 	ICE_FLAG_LINK_LENIENT_MODE_ENA,
4855dbbbd01SDave Ertman 	ICE_FLAG_PLUG_AUX_DEV,
48697b01291SDave Ertman 	ICE_FLAG_MTU_CHANGED,
487940b61afSAnirudh Venkataramanan 	ICE_PF_FLAGS_NBITS		/* must be last */
488940b61afSAnirudh Venkataramanan };
489940b61afSAnirudh Venkataramanan 
4901a1c40dfSGrzegorz Nitka struct ice_switchdev_info {
4911a1c40dfSGrzegorz Nitka 	struct ice_vsi *control_vsi;
4921a1c40dfSGrzegorz Nitka 	struct ice_vsi *uplink_vsi;
4931a1c40dfSGrzegorz Nitka 	bool is_running;
4941a1c40dfSGrzegorz Nitka };
4951a1c40dfSGrzegorz Nitka 
496b126bd6bSKiran Patil struct ice_agg_node {
497b126bd6bSKiran Patil 	u32 agg_id;
498b126bd6bSKiran Patil #define ICE_MAX_VSIS_IN_AGG_NODE	64
499b126bd6bSKiran Patil 	u32 num_vsis;
500b126bd6bSKiran Patil 	u8 valid;
501b126bd6bSKiran Patil };
502b126bd6bSKiran Patil 
503837f08fdSAnirudh Venkataramanan struct ice_pf {
504837f08fdSAnirudh Venkataramanan 	struct pci_dev *pdev;
505eb0208ecSPreethi Banala 
506dce730f1SJacob Keller 	struct devlink_region *nvm_region;
50778ad87daSJacob Keller 	struct devlink_region *sram_region;
5088d7aab35SJacob Keller 	struct devlink_region *devcaps_region;
509dce730f1SJacob Keller 
5102ae0aa47SWojciech Drewek 	/* devlink port data */
5112ae0aa47SWojciech Drewek 	struct devlink_port devlink_port;
5122ae0aa47SWojciech Drewek 
513eb0208ecSPreethi Banala 	/* OS reserved IRQ details */
514940b61afSAnirudh Venkataramanan 	struct msix_entry *msix_entries;
515cbe66bfeSBrett Creeley 	struct ice_res_tracker *irq_tracker;
516cbe66bfeSBrett Creeley 	/* First MSIX vector used by SR-IOV VFs. Calculated by subtracting the
517cbe66bfeSBrett Creeley 	 * number of MSIX vectors needed for all SR-IOV VFs from the number of
518cbe66bfeSBrett Creeley 	 * MSIX vectors allowed on this PF.
519cbe66bfeSBrett Creeley 	 */
520cbe66bfeSBrett Creeley 	u16 sriov_base_vector;
521eb0208ecSPreethi Banala 
522148beb61SHenry Tieman 	u16 ctrl_vsi_idx;		/* control VSI index in pf->vsi array */
523148beb61SHenry Tieman 
524940b61afSAnirudh Venkataramanan 	struct ice_vsi **vsi;		/* VSIs created by the driver */
525940b61afSAnirudh Venkataramanan 	struct ice_sw *first_sw;	/* first switch created by firmware */
5263ea9bd5dSMichal Swiatkowski 	u16 eswitch_mode;		/* current mode of eswitch */
527ddf30f7fSAnirudh Venkataramanan 	/* Virtchnl/SR-IOV config info */
528ddf30f7fSAnirudh Venkataramanan 	struct ice_vf *vf;
52953bb6698SJesse Brandeburg 	u16 num_alloc_vfs;		/* actual number of VFs allocated */
53075d2b253SAnirudh Venkataramanan 	u16 num_vfs_supported;		/* num VFs supported for this PF */
53146c276ceSBrett Creeley 	u16 num_qps_per_vf;
53246c276ceSBrett Creeley 	u16 num_msix_per_vf;
5339d5c5a52SPaul Greenwalt 	/* used to ratelimit the MDD event logging */
5349d5c5a52SPaul Greenwalt 	unsigned long last_printed_mdd_jiffies;
5350891c896SVignesh Sridhar 	DECLARE_BITMAP(malvfs, ICE_MAX_VF_COUNT);
53640b24760SAnirudh Venkataramanan 	DECLARE_BITMAP(features, ICE_F_MAX);
5377e408e07SAnirudh Venkataramanan 	DECLARE_BITMAP(state, ICE_STATE_NBITS);
538940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);
53978b5713aSAnirudh Venkataramanan 	unsigned long *avail_txqs;	/* bitmap to track PF Tx queue usage */
54078b5713aSAnirudh Venkataramanan 	unsigned long *avail_rxqs;	/* bitmap to track PF Rx queue usage */
541940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_period;
542940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_prev;
543940b61afSAnirudh Venkataramanan 	struct timer_list serv_tmr;
544940b61afSAnirudh Venkataramanan 	struct work_struct serv_task;
545940b61afSAnirudh Venkataramanan 	struct mutex avail_q_mutex;	/* protects access to avail_[rx|tx]qs */
546940b61afSAnirudh Venkataramanan 	struct mutex sw_mutex;		/* lock for protecting VSI alloc flow */
547b94b013eSDave Ertman 	struct mutex tc_mutex;		/* lock to protect TC changes */
548837f08fdSAnirudh Venkataramanan 	u32 msg_enable;
54906c16d89SJacob Keller 	struct ice_ptp ptp;
550d25a0fc4SDave Ertman 	u16 num_rdma_msix;		/* Total MSIX vectors for RDMA driver */
551d25a0fc4SDave Ertman 	u16 rdma_base_vector;
552d69ea414SJacob Keller 
553d69ea414SJacob Keller 	/* spinlock to protect the AdminQ wait list */
554d69ea414SJacob Keller 	spinlock_t aq_wait_lock;
555d69ea414SJacob Keller 	struct hlist_head aq_wait_list;
556d69ea414SJacob Keller 	wait_queue_head_t aq_wait_queue;
557399e27dbSJacob Keller 	bool fw_emp_reset_disabled;
558d69ea414SJacob Keller 
5591c08052eSJacob Keller 	wait_queue_head_t reset_wait_queue;
5601c08052eSJacob Keller 
561d76a60baSAnirudh Venkataramanan 	u32 hw_csum_rx_error;
56288865fc4SKarol Kolacinski 	u16 oicr_idx;		/* Other interrupt cause MSIX vector index */
56388865fc4SKarol Kolacinski 	u16 num_avail_sw_msix;	/* remaining MSIX SW vectors left unclaimed */
56478b5713aSAnirudh Venkataramanan 	u16 max_pf_txqs;	/* Total Tx queues PF wide */
56578b5713aSAnirudh Venkataramanan 	u16 max_pf_rxqs;	/* Total Rx queues PF wide */
56688865fc4SKarol Kolacinski 	u16 num_lan_msix;	/* Total MSIX vectors for base driver */
567f9867df6SAnirudh Venkataramanan 	u16 num_lan_tx;		/* num LAN Tx queues setup */
568f9867df6SAnirudh Venkataramanan 	u16 num_lan_rx;		/* num LAN Rx queues setup */
569940b61afSAnirudh Venkataramanan 	u16 next_vsi;		/* Next free slot in pf->vsi[] - 0-based! */
570940b61afSAnirudh Venkataramanan 	u16 num_alloc_vsi;
5710b28b702SAnirudh Venkataramanan 	u16 corer_count;	/* Core reset count */
5720b28b702SAnirudh Venkataramanan 	u16 globr_count;	/* Global reset count */
5730b28b702SAnirudh Venkataramanan 	u16 empr_count;		/* EMP reset count */
5740b28b702SAnirudh Venkataramanan 	u16 pfr_count;		/* PF reset count */
5750b28b702SAnirudh Venkataramanan 
576769c500dSAkeem G Abodunrin 	u8 wol_ena : 1;		/* software state of WoL */
577769c500dSAkeem G Abodunrin 	u32 wakeup_reason;	/* last wakeup reason */
578fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats;
579fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats_prev;
580837f08fdSAnirudh Venkataramanan 	struct ice_hw hw;
5810ab54c5fSJesse Brandeburg 	u8 stat_prev_loaded:1; /* has previous stats been loaded */
582e523af4eSShiraz Saleem 	u8 rdma_mode;
5837b9ffc76SAnirudh Venkataramanan 	u16 dcbx_cap;
584b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_count;
585b3969fd7SSudheer Mogilappagari 	unsigned long tx_timeout_last_recovery;
586b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_recovery_level;
587940b61afSAnirudh Venkataramanan 	char int_name[ICE_INT_NAME_STR_LEN];
588d25a0fc4SDave Ertman 	struct auxiliary_device *adev;
589d25a0fc4SDave Ertman 	int aux_idx;
5900e674aebSAnirudh Venkataramanan 	u32 sw_int_count;
5919fea7498SKiran Patil 	/* count of tc_flower filters specific to channel (aka where filter
5929fea7498SKiran Patil 	 * action is "hw_tc <tc_num>")
5939fea7498SKiran Patil 	 */
5949fea7498SKiran Patil 	u16 num_dmac_chnl_fltrs;
5950d08a441SKiran Patil 	struct hlist_head tc_flower_fltr_list;
5960d08a441SKiran Patil 
5971a3571b5SPaul Greenwalt 	__le64 nvm_phy_type_lo; /* NVM PHY type low */
5981a3571b5SPaul Greenwalt 	__le64 nvm_phy_type_hi; /* NVM PHY type high */
599ea78ce4dSPaul Greenwalt 	struct ice_link_default_override_tlv link_dflt_override;
600df006dd4SDave Ertman 	struct ice_lag *lag; /* Link Aggregation information */
601b126bd6bSKiran Patil 
6021a1c40dfSGrzegorz Nitka 	struct ice_switchdev_info switchdev;
6031a1c40dfSGrzegorz Nitka 
604b126bd6bSKiran Patil #define ICE_INVALID_AGG_NODE_ID		0
605b126bd6bSKiran Patil #define ICE_PF_AGG_NODE_ID_START	1
606b126bd6bSKiran Patil #define ICE_MAX_PF_AGG_NODES		32
607b126bd6bSKiran Patil 	struct ice_agg_node pf_agg_node[ICE_MAX_PF_AGG_NODES];
608b126bd6bSKiran Patil #define ICE_VF_AGG_NODE_ID_START	65
609b126bd6bSKiran Patil #define ICE_MAX_VF_AGG_NODES		32
610b126bd6bSKiran Patil 	struct ice_agg_node vf_agg_node[ICE_MAX_VF_AGG_NODES];
611837f08fdSAnirudh Venkataramanan };
612940b61afSAnirudh Venkataramanan 
6133a858ba3SAnirudh Venkataramanan struct ice_netdev_priv {
6143a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
61537165e3fSMichal Swiatkowski 	struct ice_repr *repr;
616195bb48fSMichal Swiatkowski 	/* indirect block callbacks on registered higher level devices
617195bb48fSMichal Swiatkowski 	 * (e.g. tunnel devices)
618195bb48fSMichal Swiatkowski 	 *
619195bb48fSMichal Swiatkowski 	 * tc_indr_block_cb_priv_list is used to look up indirect callback
620195bb48fSMichal Swiatkowski 	 * private data
621195bb48fSMichal Swiatkowski 	 */
622195bb48fSMichal Swiatkowski 	struct list_head tc_indr_block_priv_list;
6233a858ba3SAnirudh Venkataramanan };
6243a858ba3SAnirudh Venkataramanan 
625940b61afSAnirudh Venkataramanan /**
626fbc7b27aSKiran Patil  * ice_vector_ch_enabled
627fbc7b27aSKiran Patil  * @qv: pointer to q_vector, can be NULL
628fbc7b27aSKiran Patil  *
629fbc7b27aSKiran Patil  * This function returns true if vector is channel enabled otherwise false
630fbc7b27aSKiran Patil  */
631fbc7b27aSKiran Patil static inline bool ice_vector_ch_enabled(struct ice_q_vector *qv)
632fbc7b27aSKiran Patil {
633fbc7b27aSKiran Patil 	return !!qv->ch; /* Enable it to run with TC */
634fbc7b27aSKiran Patil }
635fbc7b27aSKiran Patil 
636fbc7b27aSKiran Patil /**
637940b61afSAnirudh Venkataramanan  * ice_irq_dynamic_ena - Enable default interrupt generation settings
638f9867df6SAnirudh Venkataramanan  * @hw: pointer to HW struct
639f9867df6SAnirudh Venkataramanan  * @vsi: pointer to VSI struct, can be NULL
640cdedef59SAnirudh Venkataramanan  * @q_vector: pointer to q_vector, can be NULL
641940b61afSAnirudh Venkataramanan  */
642c8b7abddSBruce Allan static inline void
643c8b7abddSBruce Allan ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
644cdedef59SAnirudh Venkataramanan 		    struct ice_q_vector *q_vector)
645940b61afSAnirudh Venkataramanan {
646b07833a0SBrett Creeley 	u32 vector = (vsi && q_vector) ? q_vector->reg_idx :
647cbe66bfeSBrett Creeley 				((struct ice_pf *)hw->back)->oicr_idx;
648940b61afSAnirudh Venkataramanan 	int itr = ICE_ITR_NONE;
649940b61afSAnirudh Venkataramanan 	u32 val;
650940b61afSAnirudh Venkataramanan 
651940b61afSAnirudh Venkataramanan 	/* clear the PBA here, as this function is meant to clean out all
652940b61afSAnirudh Venkataramanan 	 * previous interrupts and enable the interrupt
653940b61afSAnirudh Venkataramanan 	 */
654940b61afSAnirudh Venkataramanan 	val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
655940b61afSAnirudh Venkataramanan 	      (itr << GLINT_DYN_CTL_ITR_INDX_S);
656cdedef59SAnirudh Venkataramanan 	if (vsi)
657e97fb1aeSAnirudh Venkataramanan 		if (test_bit(ICE_VSI_DOWN, vsi->state))
658cdedef59SAnirudh Venkataramanan 			return;
659940b61afSAnirudh Venkataramanan 	wr32(hw, GLINT_DYN_CTL(vector), val);
660940b61afSAnirudh Venkataramanan }
661cdedef59SAnirudh Venkataramanan 
662c2a23e00SBrett Creeley /**
663462acf6aSTony Nguyen  * ice_netdev_to_pf - Retrieve the PF struct associated with a netdev
664462acf6aSTony Nguyen  * @netdev: pointer to the netdev struct
665462acf6aSTony Nguyen  */
666462acf6aSTony Nguyen static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)
667462acf6aSTony Nguyen {
668462acf6aSTony Nguyen 	struct ice_netdev_priv *np = netdev_priv(netdev);
669462acf6aSTony Nguyen 
670462acf6aSTony Nguyen 	return np->vsi->back;
671462acf6aSTony Nguyen }
672462acf6aSTony Nguyen 
673efc2214bSMaciej Fijalkowski static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi)
674efc2214bSMaciej Fijalkowski {
675efc2214bSMaciej Fijalkowski 	return !!vsi->xdp_prog;
676efc2214bSMaciej Fijalkowski }
677efc2214bSMaciej Fijalkowski 
678e72bba21SMaciej Fijalkowski static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
679efc2214bSMaciej Fijalkowski {
680efc2214bSMaciej Fijalkowski 	ring->flags |= ICE_TX_FLAGS_RING_XDP;
681efc2214bSMaciej Fijalkowski }
682efc2214bSMaciej Fijalkowski 
683462acf6aSTony Nguyen /**
6841742b3d5SMagnus Karlsson  * ice_xsk_pool - get XSK buffer pool bound to a ring
685e72bba21SMaciej Fijalkowski  * @ring: Rx ring to use
6862d4238f5SKrzysztof Kazimierczak  *
6871742b3d5SMagnus Karlsson  * Returns a pointer to xdp_umem structure if there is a buffer pool present,
6882d4238f5SKrzysztof Kazimierczak  * NULL otherwise.
6892d4238f5SKrzysztof Kazimierczak  */
690e72bba21SMaciej Fijalkowski static inline struct xsk_buff_pool *ice_xsk_pool(struct ice_rx_ring *ring)
6912d4238f5SKrzysztof Kazimierczak {
692e102db78SMaciej Fijalkowski 	struct ice_vsi *vsi = ring->vsi;
69365bb559bSKrzysztof Kazimierczak 	u16 qid = ring->q_index;
6942d4238f5SKrzysztof Kazimierczak 
695e72bba21SMaciej Fijalkowski 	if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps))
696e72bba21SMaciej Fijalkowski 		return NULL;
697e72bba21SMaciej Fijalkowski 
698e72bba21SMaciej Fijalkowski 	return xsk_get_pool_from_qid(vsi->netdev, qid);
699e72bba21SMaciej Fijalkowski }
700e72bba21SMaciej Fijalkowski 
701e72bba21SMaciej Fijalkowski /**
702e72bba21SMaciej Fijalkowski  * ice_tx_xsk_pool - get XSK buffer pool bound to a ring
703e72bba21SMaciej Fijalkowski  * @ring: Tx ring to use
704e72bba21SMaciej Fijalkowski  *
705e72bba21SMaciej Fijalkowski  * Returns a pointer to xdp_umem structure if there is a buffer pool present,
706e72bba21SMaciej Fijalkowski  * NULL otherwise. Tx equivalent of ice_xsk_pool.
707e72bba21SMaciej Fijalkowski  */
708e72bba21SMaciej Fijalkowski static inline struct xsk_buff_pool *ice_tx_xsk_pool(struct ice_tx_ring *ring)
709e72bba21SMaciej Fijalkowski {
710e72bba21SMaciej Fijalkowski 	struct ice_vsi *vsi = ring->vsi;
711e72bba21SMaciej Fijalkowski 	u16 qid;
712e72bba21SMaciej Fijalkowski 
713e72bba21SMaciej Fijalkowski 	qid = ring->q_index - vsi->num_xdp_txq;
7142d4238f5SKrzysztof Kazimierczak 
715e102db78SMaciej Fijalkowski 	if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps))
7162d4238f5SKrzysztof Kazimierczak 		return NULL;
7172d4238f5SKrzysztof Kazimierczak 
718e102db78SMaciej Fijalkowski 	return xsk_get_pool_from_qid(vsi->netdev, qid);
7192d4238f5SKrzysztof Kazimierczak }
7202d4238f5SKrzysztof Kazimierczak 
7212d4238f5SKrzysztof Kazimierczak /**
722208ff751SAnirudh Venkataramanan  * ice_get_main_vsi - Get the PF VSI
723208ff751SAnirudh Venkataramanan  * @pf: PF instance
724208ff751SAnirudh Venkataramanan  *
725208ff751SAnirudh Venkataramanan  * returns pf->vsi[0], which by definition is the PF VSI
726c2a23e00SBrett Creeley  */
727208ff751SAnirudh Venkataramanan static inline struct ice_vsi *ice_get_main_vsi(struct ice_pf *pf)
728c2a23e00SBrett Creeley {
729208ff751SAnirudh Venkataramanan 	if (pf->vsi)
730208ff751SAnirudh Venkataramanan 		return pf->vsi[0];
731c2a23e00SBrett Creeley 
732c2a23e00SBrett Creeley 	return NULL;
733c2a23e00SBrett Creeley }
734c2a23e00SBrett Creeley 
735148beb61SHenry Tieman /**
7367aae80ceSWojciech Drewek  * ice_get_netdev_priv_vsi - return VSI associated with netdev priv.
7377aae80ceSWojciech Drewek  * @np: private netdev structure
7387aae80ceSWojciech Drewek  */
7397aae80ceSWojciech Drewek static inline struct ice_vsi *ice_get_netdev_priv_vsi(struct ice_netdev_priv *np)
7407aae80ceSWojciech Drewek {
7417aae80ceSWojciech Drewek 	/* In case of port representor return source port VSI. */
7427aae80ceSWojciech Drewek 	if (np->repr)
7437aae80ceSWojciech Drewek 		return np->repr->src_vsi;
7447aae80ceSWojciech Drewek 	else
7457aae80ceSWojciech Drewek 		return np->vsi;
7467aae80ceSWojciech Drewek }
7477aae80ceSWojciech Drewek 
7487aae80ceSWojciech Drewek /**
749148beb61SHenry Tieman  * ice_get_ctrl_vsi - Get the control VSI
750148beb61SHenry Tieman  * @pf: PF instance
751148beb61SHenry Tieman  */
752148beb61SHenry Tieman static inline struct ice_vsi *ice_get_ctrl_vsi(struct ice_pf *pf)
753148beb61SHenry Tieman {
754148beb61SHenry Tieman 	/* if pf->ctrl_vsi_idx is ICE_NO_VSI, control VSI was not set up */
755148beb61SHenry Tieman 	if (!pf->vsi || pf->ctrl_vsi_idx == ICE_NO_VSI)
756148beb61SHenry Tieman 		return NULL;
757148beb61SHenry Tieman 
758148beb61SHenry Tieman 	return pf->vsi[pf->ctrl_vsi_idx];
759148beb61SHenry Tieman }
760148beb61SHenry Tieman 
761df006dd4SDave Ertman /**
7621a1c40dfSGrzegorz Nitka  * ice_is_switchdev_running - check if switchdev is configured
7631a1c40dfSGrzegorz Nitka  * @pf: pointer to PF structure
7641a1c40dfSGrzegorz Nitka  *
7651a1c40dfSGrzegorz Nitka  * Returns true if eswitch mode is set to DEVLINK_ESWITCH_MODE_SWITCHDEV
7661a1c40dfSGrzegorz Nitka  * and switchdev is configured, false otherwise.
7671a1c40dfSGrzegorz Nitka  */
7681a1c40dfSGrzegorz Nitka static inline bool ice_is_switchdev_running(struct ice_pf *pf)
7691a1c40dfSGrzegorz Nitka {
7701a1c40dfSGrzegorz Nitka 	return pf->switchdev.is_running;
7711a1c40dfSGrzegorz Nitka }
7721a1c40dfSGrzegorz Nitka 
7731a1c40dfSGrzegorz Nitka /**
774df006dd4SDave Ertman  * ice_set_sriov_cap - enable SRIOV in PF flags
775df006dd4SDave Ertman  * @pf: PF struct
776df006dd4SDave Ertman  */
777df006dd4SDave Ertman static inline void ice_set_sriov_cap(struct ice_pf *pf)
778df006dd4SDave Ertman {
779df006dd4SDave Ertman 	if (pf->hw.func_caps.common_cap.sr_iov_1_1)
780df006dd4SDave Ertman 		set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
781df006dd4SDave Ertman }
782df006dd4SDave Ertman 
783df006dd4SDave Ertman /**
784df006dd4SDave Ertman  * ice_clear_sriov_cap - disable SRIOV in PF flags
785df006dd4SDave Ertman  * @pf: PF struct
786df006dd4SDave Ertman  */
787df006dd4SDave Ertman static inline void ice_clear_sriov_cap(struct ice_pf *pf)
788df006dd4SDave Ertman {
789df006dd4SDave Ertman 	clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags);
790df006dd4SDave Ertman }
791df006dd4SDave Ertman 
7924ab95646SHenry Tieman #define ICE_FD_STAT_CTR_BLOCK_COUNT	256
7934ab95646SHenry Tieman #define ICE_FD_STAT_PF_IDX(base_idx) \
7944ab95646SHenry Tieman 			((base_idx) * ICE_FD_STAT_CTR_BLOCK_COUNT)
7954ab95646SHenry Tieman #define ICE_FD_SB_STAT_IDX(base_idx) ICE_FD_STAT_PF_IDX(base_idx)
79640319796SKiran Patil #define ICE_FD_STAT_CH			1
79740319796SKiran Patil #define ICE_FD_CH_STAT_IDX(base_idx) \
79840319796SKiran Patil 			(ICE_FD_STAT_PF_IDX(base_idx) + ICE_FD_STAT_CH)
7994ab95646SHenry Tieman 
8000754d65bSKiran Patil /**
8010754d65bSKiran Patil  * ice_is_adq_active - any active ADQs
8020754d65bSKiran Patil  * @pf: pointer to PF
8030754d65bSKiran Patil  *
8040754d65bSKiran Patil  * This function returns true if there are any ADQs configured (which is
8050754d65bSKiran Patil  * determined by looking at VSI type (which should be VSI_PF), numtc, and
8060754d65bSKiran Patil  * TC_MQPRIO flag) otherwise return false
8070754d65bSKiran Patil  */
8080754d65bSKiran Patil static inline bool ice_is_adq_active(struct ice_pf *pf)
8090754d65bSKiran Patil {
8100754d65bSKiran Patil 	struct ice_vsi *vsi;
8110754d65bSKiran Patil 
8120754d65bSKiran Patil 	vsi = ice_get_main_vsi(pf);
8130754d65bSKiran Patil 	if (!vsi)
8140754d65bSKiran Patil 		return false;
8150754d65bSKiran Patil 
8160754d65bSKiran Patil 	/* is ADQ configured */
8170754d65bSKiran Patil 	if (vsi->tc_cfg.numtc > ICE_CHNL_START_TC &&
8180754d65bSKiran Patil 	    test_bit(ICE_FLAG_TC_MQPRIO, pf->flags))
8190754d65bSKiran Patil 		return true;
8200754d65bSKiran Patil 
8210754d65bSKiran Patil 	return false;
8220754d65bSKiran Patil }
8230754d65bSKiran Patil 
824df006dd4SDave Ertman bool netif_is_ice(struct net_device *dev);
8250e674aebSAnirudh Venkataramanan int ice_vsi_setup_tx_rings(struct ice_vsi *vsi);
8260e674aebSAnirudh Venkataramanan int ice_vsi_setup_rx_rings(struct ice_vsi *vsi);
827148beb61SHenry Tieman int ice_vsi_open_ctrl(struct ice_vsi *vsi);
8281a1c40dfSGrzegorz Nitka int ice_vsi_open(struct ice_vsi *vsi);
829fcea6f3dSAnirudh Venkataramanan void ice_set_ethtool_ops(struct net_device *netdev);
8307aae80ceSWojciech Drewek void ice_set_ethtool_repr_ops(struct net_device *netdev);
831462acf6aSTony Nguyen void ice_set_ethtool_safe_mode_ops(struct net_device *netdev);
8328c243700SAnirudh Venkataramanan u16 ice_get_avail_txq_count(struct ice_pf *pf);
8338c243700SAnirudh Venkataramanan u16 ice_get_avail_rxq_count(struct ice_pf *pf);
83487324e74SHenry Tieman int ice_vsi_recfg_qs(struct ice_vsi *vsi, int new_rx, int new_tx);
8355a4a8673SBruce Allan void ice_update_vsi_stats(struct ice_vsi *vsi);
8365a4a8673SBruce Allan void ice_update_pf_stats(struct ice_pf *pf);
837fcea6f3dSAnirudh Venkataramanan int ice_up(struct ice_vsi *vsi);
838fcea6f3dSAnirudh Venkataramanan int ice_down(struct ice_vsi *vsi);
8390e674aebSAnirudh Venkataramanan int ice_vsi_cfg(struct ice_vsi *vsi);
8400e674aebSAnirudh Venkataramanan struct ice_vsi *ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi);
84122bf877eSMaciej Fijalkowski int ice_vsi_determine_xdp_res(struct ice_vsi *vsi);
842efc2214bSMaciej Fijalkowski int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog);
843efc2214bSMaciej Fijalkowski int ice_destroy_xdp_rings(struct ice_vsi *vsi);
844efc2214bSMaciej Fijalkowski int
845efc2214bSMaciej Fijalkowski ice_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
846efc2214bSMaciej Fijalkowski 	     u32 flags);
847b66a972aSBrett Creeley int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
848b66a972aSBrett Creeley int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size);
849b66a972aSBrett Creeley int ice_set_rss_key(struct ice_vsi *vsi, u8 *seed);
850b66a972aSBrett Creeley int ice_get_rss_key(struct ice_vsi *vsi, u8 *seed);
851d76a60baSAnirudh Venkataramanan void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
85287324e74SHenry Tieman int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset);
853fcea6f3dSAnirudh Venkataramanan void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
854f9f5301eSDave Ertman int ice_plug_aux_dev(struct ice_pf *pf);
855f9f5301eSDave Ertman void ice_unplug_aux_dev(struct ice_pf *pf);
856d25a0fc4SDave Ertman int ice_init_rdma(struct ice_pf *pf);
8570fee3577SLihong Yang const char *ice_aq_str(enum ice_aq_err aq_err);
85831765519SAnirudh Venkataramanan bool ice_is_wol_supported(struct ice_hw *hw);
85940319796SKiran Patil void ice_fdir_del_all_fltrs(struct ice_vsi *vsi);
86028bf2672SBrett Creeley int
86128bf2672SBrett Creeley ice_fdir_write_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input, bool add,
86228bf2672SBrett Creeley 		    bool is_tun);
863148beb61SHenry Tieman void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena);
864cac2a27cSHenry Tieman int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd);
865cac2a27cSHenry Tieman int ice_del_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd);
8664ab95646SHenry Tieman int ice_get_ethtool_fdir_entry(struct ice_hw *hw, struct ethtool_rxnfc *cmd);
8674ab95646SHenry Tieman int
8684ab95646SHenry Tieman ice_get_fdir_fltr_ids(struct ice_hw *hw, struct ethtool_rxnfc *cmd,
8694ab95646SHenry Tieman 		      u32 *rule_locs);
87040319796SKiran Patil void ice_fdir_rem_adq_chnl(struct ice_hw *hw, u16 vsi_idx);
871148beb61SHenry Tieman void ice_fdir_release_flows(struct ice_hw *hw);
87283af0039SHenry Tieman void ice_fdir_replay_flows(struct ice_hw *hw);
87383af0039SHenry Tieman void ice_fdir_replay_fltrs(struct ice_pf *pf);
874148beb61SHenry Tieman int ice_fdir_create_dflt_rules(struct ice_pf *pf);
875d69ea414SJacob Keller int ice_aq_wait_for_event(struct ice_pf *pf, u16 opcode, unsigned long timeout,
876d69ea414SJacob Keller 			  struct ice_rq_event_info *event);
8770e674aebSAnirudh Venkataramanan int ice_open(struct net_device *netdev);
878e95fc857SKrzysztof Goreczny int ice_open_internal(struct net_device *netdev);
8790e674aebSAnirudh Venkataramanan int ice_stop(struct net_device *netdev);
88028bf2672SBrett Creeley void ice_service_task_schedule(struct ice_pf *pf);
881d76a60baSAnirudh Venkataramanan 
882d25a0fc4SDave Ertman /**
883d25a0fc4SDave Ertman  * ice_set_rdma_cap - enable RDMA support
884d25a0fc4SDave Ertman  * @pf: PF struct
885d25a0fc4SDave Ertman  */
886d25a0fc4SDave Ertman static inline void ice_set_rdma_cap(struct ice_pf *pf)
887d25a0fc4SDave Ertman {
888f9f5301eSDave Ertman 	if (pf->hw.func_caps.common_cap.rdma && pf->num_rdma_msix) {
889d25a0fc4SDave Ertman 		set_bit(ICE_FLAG_RDMA_ENA, pf->flags);
890bfe84435SDave Ertman 		set_bit(ICE_FLAG_AUX_ENA, pf->flags);
8915dbbbd01SDave Ertman 		set_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags);
892f9f5301eSDave Ertman 	}
893d25a0fc4SDave Ertman }
894d25a0fc4SDave Ertman 
895d25a0fc4SDave Ertman /**
896d25a0fc4SDave Ertman  * ice_clear_rdma_cap - disable RDMA support
897d25a0fc4SDave Ertman  * @pf: PF struct
898d25a0fc4SDave Ertman  */
899d25a0fc4SDave Ertman static inline void ice_clear_rdma_cap(struct ice_pf *pf)
900d25a0fc4SDave Ertman {
901*5cb1ebdbSIvan Vecera 	/* We can directly unplug aux device here only if the flag bit
902*5cb1ebdbSIvan Vecera 	 * ICE_FLAG_PLUG_AUX_DEV is not set because ice_unplug_aux_dev()
903*5cb1ebdbSIvan Vecera 	 * could race with ice_plug_aux_dev() called from
904*5cb1ebdbSIvan Vecera 	 * ice_service_task(). In this case we only clear that bit now and
905*5cb1ebdbSIvan Vecera 	 * aux device will be unplugged later once ice_plug_aux_device()
906*5cb1ebdbSIvan Vecera 	 * called from ice_service_task() finishes (see ice_service_task()).
907*5cb1ebdbSIvan Vecera 	 */
908*5cb1ebdbSIvan Vecera 	if (!test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags))
909f9f5301eSDave Ertman 		ice_unplug_aux_dev(pf);
910*5cb1ebdbSIvan Vecera 
911d25a0fc4SDave Ertman 	clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
912bfe84435SDave Ertman 	clear_bit(ICE_FLAG_AUX_ENA, pf->flags);
913d25a0fc4SDave Ertman }
914837f08fdSAnirudh Venkataramanan #endif /* _ICE_H_ */
915