xref: /openbmc/linux/drivers/net/ethernet/intel/ice/ice.h (revision 67fe64d78c437d3f5a280a074e8467fa9b16216d)
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>
11837f08fdSAnirudh Venkataramanan #include <linux/netdevice.h>
12837f08fdSAnirudh Venkataramanan #include <linux/compiler.h>
13dc49c772SAnirudh Venkataramanan #include <linux/etherdevice.h>
14cdedef59SAnirudh Venkataramanan #include <linux/skbuff.h>
153a858ba3SAnirudh Venkataramanan #include <linux/cpumask.h>
16fcea6f3dSAnirudh Venkataramanan #include <linux/rtnetlink.h>
173a858ba3SAnirudh Venkataramanan #include <linux/if_vlan.h>
18cdedef59SAnirudh Venkataramanan #include <linux/dma-mapping.h>
19837f08fdSAnirudh Venkataramanan #include <linux/pci.h>
20940b61afSAnirudh Venkataramanan #include <linux/workqueue.h>
21837f08fdSAnirudh Venkataramanan #include <linux/aer.h>
22940b61afSAnirudh Venkataramanan #include <linux/interrupt.h>
23fcea6f3dSAnirudh Venkataramanan #include <linux/ethtool.h>
24940b61afSAnirudh Venkataramanan #include <linux/timer.h>
257ec59eeaSAnirudh Venkataramanan #include <linux/delay.h>
26837f08fdSAnirudh Venkataramanan #include <linux/bitmap.h>
273a858ba3SAnirudh Venkataramanan #include <linux/log2.h>
28d76a60baSAnirudh Venkataramanan #include <linux/ip.h>
29d76a60baSAnirudh Venkataramanan #include <linux/ipv6.h>
30940b61afSAnirudh Venkataramanan #include <linux/if_bridge.h>
31ddf30f7fSAnirudh Venkataramanan #include <linux/avf/virtchnl.h>
32d76a60baSAnirudh Venkataramanan #include <net/ipv6.h>
33837f08fdSAnirudh Venkataramanan #include "ice_devids.h"
34837f08fdSAnirudh Venkataramanan #include "ice_type.h"
35940b61afSAnirudh Venkataramanan #include "ice_txrx.h"
369c20346bSAnirudh Venkataramanan #include "ice_switch.h"
37f31e4b6fSAnirudh Venkataramanan #include "ice_common.h"
389c20346bSAnirudh Venkataramanan #include "ice_sched.h"
39ddf30f7fSAnirudh Venkataramanan #include "ice_virtchnl_pf.h"
40007676b4SAnirudh Venkataramanan #include "ice_sriov.h"
41837f08fdSAnirudh Venkataramanan 
42fcea6f3dSAnirudh Venkataramanan extern const char ice_drv_ver[];
43837f08fdSAnirudh Venkataramanan #define ICE_BAR0		0
443a858ba3SAnirudh Venkataramanan #define ICE_DFLT_NUM_DESC	128
453a858ba3SAnirudh Venkataramanan #define ICE_REQ_DESC_MULTIPLE	32
463b6bf296SBruce Allan #define ICE_MIN_NUM_DESC	ICE_REQ_DESC_MULTIPLE
473b6bf296SBruce Allan #define ICE_MAX_NUM_DESC	8160
485513b920SAnirudh Venkataramanan #define ICE_DFLT_TRAFFIC_CLASS	BIT(0)
49940b61afSAnirudh Venkataramanan #define ICE_INT_NAME_STR_LEN	(IFNAMSIZ + 16)
50fcea6f3dSAnirudh Venkataramanan #define ICE_ETHTOOL_FWVER_LEN	32
51f31e4b6fSAnirudh Venkataramanan #define ICE_AQ_LEN		64
5275d2b253SAnirudh Venkataramanan #define ICE_MBXQ_LEN		64
53940b61afSAnirudh Venkataramanan #define ICE_MIN_MSIX		2
543a858ba3SAnirudh Venkataramanan #define ICE_NO_VSI		0xffff
55940b61afSAnirudh Venkataramanan #define ICE_MAX_TXQS		2048
56940b61afSAnirudh Venkataramanan #define ICE_MAX_RXQS		2048
573a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_CONTIG	0
583a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_SCATTER	1
593a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_TXQS	16
603a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_RXQS	16
61cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_RETRY_LIMIT	10
62cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_MAX_RETRY	(5 * ICE_Q_WAIT_RETRY_LIMIT)
63d76a60baSAnirudh Venkataramanan #define ICE_MAX_LG_RSS_QS	256
64d76a60baSAnirudh Venkataramanan #define ICE_MAX_SMALL_RSS_QS	8
65940b61afSAnirudh Venkataramanan #define ICE_RES_VALID_BIT	0x8000
66940b61afSAnirudh Venkataramanan #define ICE_RES_MISC_VEC_ID	(ICE_RES_VALID_BIT - 1)
673a858ba3SAnirudh Venkataramanan #define ICE_INVAL_Q_INDEX	0xffff
680f9d5027SAnirudh Venkataramanan #define ICE_INVAL_VFID		256
6975d2b253SAnirudh Venkataramanan #define ICE_MAX_VF_COUNT	256
70ddf30f7fSAnirudh Venkataramanan #define ICE_MAX_QS_PER_VF		256
71ddf30f7fSAnirudh Venkataramanan #define ICE_MIN_QS_PER_VF		1
72ddf30f7fSAnirudh Venkataramanan #define ICE_DFLT_QS_PER_VF		4
731071a835SAnirudh Venkataramanan #define ICE_MAX_BASE_QS_PER_VF		16
74ddf30f7fSAnirudh Venkataramanan #define ICE_MAX_INTR_PER_VF		65
75ddf30f7fSAnirudh Venkataramanan #define ICE_MIN_INTR_PER_VF		(ICE_MIN_QS_PER_VF + 1)
76ddf30f7fSAnirudh Venkataramanan #define ICE_DFLT_INTR_PER_VF		(ICE_DFLT_QS_PER_VF + 1)
77837f08fdSAnirudh Venkataramanan 
78afd9d4abSAnirudh Venkataramanan #define ICE_MAX_RESET_WAIT		20
79afd9d4abSAnirudh Venkataramanan 
80fcea6f3dSAnirudh Venkataramanan #define ICE_VSIQF_HKEY_ARRAY_SIZE	((VSIQF_HKEY_MAX_INDEX + 1) *	4)
81fcea6f3dSAnirudh Venkataramanan 
82837f08fdSAnirudh Venkataramanan #define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
83837f08fdSAnirudh Venkataramanan 
843a858ba3SAnirudh Venkataramanan #define ICE_MAX_MTU	(ICE_AQ_SET_MAC_FRAME_SIZE_MAX - \
853a858ba3SAnirudh Venkataramanan 			 ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN)
863a858ba3SAnirudh Venkataramanan 
873a858ba3SAnirudh Venkataramanan #define ICE_UP_TABLE_TRANSLATE(val, i) \
883a858ba3SAnirudh Venkataramanan 		(((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
893a858ba3SAnirudh Venkataramanan 		  ICE_AQ_VSI_UP_TABLE_UP##i##_M)
903a858ba3SAnirudh Venkataramanan 
912b245cb2SAnirudh Venkataramanan #define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i]))
92cdedef59SAnirudh Venkataramanan #define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
93d76a60baSAnirudh Venkataramanan #define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i]))
94cdedef59SAnirudh Venkataramanan 
950b28b702SAnirudh Venkataramanan /* Macro for each VSI in a PF */
960b28b702SAnirudh Venkataramanan #define ice_for_each_vsi(pf, i) \
970b28b702SAnirudh Venkataramanan 	for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
980b28b702SAnirudh Venkataramanan 
99d337f2afSAnirudh Venkataramanan /* Macros for each Tx/Rx ring in a VSI */
100cdedef59SAnirudh Venkataramanan #define ice_for_each_txq(vsi, i) \
101cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
102cdedef59SAnirudh Venkataramanan 
103cdedef59SAnirudh Venkataramanan #define ice_for_each_rxq(vsi, i) \
104cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
105cdedef59SAnirudh Venkataramanan 
106d337f2afSAnirudh Venkataramanan /* Macros for each allocated Tx/Rx ring whether used or not in a VSI */
107f8ba7db8SJacob Keller #define ice_for_each_alloc_txq(vsi, i) \
108f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
109f8ba7db8SJacob Keller 
110f8ba7db8SJacob Keller #define ice_for_each_alloc_rxq(vsi, i) \
111f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
112f8ba7db8SJacob Keller 
113*67fe64d7SBrett Creeley #define ice_for_each_q_vector(vsi, i) \
114*67fe64d7SBrett Creeley 	for ((i) = 0; (i) < (vsi)->num_q_vectors; (i)++)
115*67fe64d7SBrett Creeley 
1163a858ba3SAnirudh Venkataramanan struct ice_tc_info {
1173a858ba3SAnirudh Venkataramanan 	u16 qoffset;
118c5a2a4a3SUsha Ketineni 	u16 qcount_tx;
119c5a2a4a3SUsha Ketineni 	u16 qcount_rx;
120c5a2a4a3SUsha Ketineni 	u8 netdev_tc;
1213a858ba3SAnirudh Venkataramanan };
1223a858ba3SAnirudh Venkataramanan 
1233a858ba3SAnirudh Venkataramanan struct ice_tc_cfg {
1243a858ba3SAnirudh Venkataramanan 	u8 numtc; /* Total number of enabled TCs */
1253a858ba3SAnirudh Venkataramanan 	u8 ena_tc; /* TX map */
1263a858ba3SAnirudh Venkataramanan 	struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS];
1273a858ba3SAnirudh Venkataramanan };
1283a858ba3SAnirudh Venkataramanan 
129940b61afSAnirudh Venkataramanan struct ice_res_tracker {
130940b61afSAnirudh Venkataramanan 	u16 num_entries;
131940b61afSAnirudh Venkataramanan 	u16 search_hint;
132940b61afSAnirudh Venkataramanan 	u16 list[1];
133940b61afSAnirudh Venkataramanan };
134940b61afSAnirudh Venkataramanan 
13503f7a986SAnirudh Venkataramanan struct ice_qs_cfg {
13603f7a986SAnirudh Venkataramanan 	struct mutex *qs_mutex;  /* will be assgined to &pf->avail_q_mutex */
13703f7a986SAnirudh Venkataramanan 	unsigned long *pf_map;
13803f7a986SAnirudh Venkataramanan 	unsigned long pf_map_size;
13903f7a986SAnirudh Venkataramanan 	unsigned int q_count;
14003f7a986SAnirudh Venkataramanan 	unsigned int scatter_count;
14103f7a986SAnirudh Venkataramanan 	u16 *vsi_map;
14203f7a986SAnirudh Venkataramanan 	u16 vsi_map_offset;
14303f7a986SAnirudh Venkataramanan 	u8 mapping_mode;
14403f7a986SAnirudh Venkataramanan };
14503f7a986SAnirudh Venkataramanan 
146940b61afSAnirudh Venkataramanan struct ice_sw {
147940b61afSAnirudh Venkataramanan 	struct ice_pf *pf;
148940b61afSAnirudh Venkataramanan 	u16 sw_id;		/* switch ID for this switch */
149940b61afSAnirudh Venkataramanan 	u16 bridge_mode;	/* VEB/VEPA/Port Virtualizer */
150940b61afSAnirudh Venkataramanan };
151940b61afSAnirudh Venkataramanan 
152837f08fdSAnirudh Venkataramanan enum ice_state {
153837f08fdSAnirudh Venkataramanan 	__ICE_DOWN,
1540b28b702SAnirudh Venkataramanan 	__ICE_NEEDS_RESTART,
1550f9d5027SAnirudh Venkataramanan 	__ICE_PREPARED_FOR_RESET,	/* set by driver when prepared */
1565df7e45dSDave Ertman 	__ICE_RESET_OICR_RECV,		/* set by driver after rcv reset OICR */
157940b61afSAnirudh Venkataramanan 	__ICE_PFR_REQ,			/* set by driver and peers */
1580b28b702SAnirudh Venkataramanan 	__ICE_CORER_REQ,		/* set by driver and peers */
1590b28b702SAnirudh Venkataramanan 	__ICE_GLOBR_REQ,		/* set by driver and peers */
1600b28b702SAnirudh Venkataramanan 	__ICE_CORER_RECV,		/* set by OICR handler */
1610b28b702SAnirudh Venkataramanan 	__ICE_GLOBR_RECV,		/* set by OICR handler */
1620b28b702SAnirudh Venkataramanan 	__ICE_EMPR_RECV,		/* set by OICR handler */
1630b28b702SAnirudh Venkataramanan 	__ICE_SUSPENDED,		/* set on module remove path */
1640b28b702SAnirudh Venkataramanan 	__ICE_RESET_FAILED,		/* set by reset/rebuild */
165ddf30f7fSAnirudh Venkataramanan 	/* When checking for the PF to be in a nominal operating state, the
166ddf30f7fSAnirudh Venkataramanan 	 * bits that are grouped at the beginning of the list need to be
167ddf30f7fSAnirudh Venkataramanan 	 * checked. Bits occurring before __ICE_STATE_NOMINAL_CHECK_BITS will
168ddf30f7fSAnirudh Venkataramanan 	 * be checked. If you need to add a bit into consideration for nominal
169ddf30f7fSAnirudh Venkataramanan 	 * operating state, it must be added before
170ddf30f7fSAnirudh Venkataramanan 	 * __ICE_STATE_NOMINAL_CHECK_BITS. Do not move this entry's position
171ddf30f7fSAnirudh Venkataramanan 	 * without appropriate consideration.
172ddf30f7fSAnirudh Venkataramanan 	 */
173ddf30f7fSAnirudh Venkataramanan 	__ICE_STATE_NOMINAL_CHECK_BITS,
174940b61afSAnirudh Venkataramanan 	__ICE_ADMINQ_EVENT_PENDING,
17575d2b253SAnirudh Venkataramanan 	__ICE_MAILBOXQ_EVENT_PENDING,
176b3969fd7SSudheer Mogilappagari 	__ICE_MDD_EVENT_PENDING,
177007676b4SAnirudh Venkataramanan 	__ICE_VFLR_EVENT_PENDING,
178e94d4478SAnirudh Venkataramanan 	__ICE_FLTR_OVERFLOW_PROMISC,
179ddf30f7fSAnirudh Venkataramanan 	__ICE_VF_DIS,
180fcea6f3dSAnirudh Venkataramanan 	__ICE_CFG_BUSY,
181940b61afSAnirudh Venkataramanan 	__ICE_SERVICE_SCHED,
1828d81fa55SAkeem G Abodunrin 	__ICE_SERVICE_DIS,
183837f08fdSAnirudh Venkataramanan 	__ICE_STATE_NBITS		/* must be last */
184837f08fdSAnirudh Venkataramanan };
185837f08fdSAnirudh Venkataramanan 
186e94d4478SAnirudh Venkataramanan enum ice_vsi_flags {
187e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_UMAC_FLTR_CHANGED,
188e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_MMAC_FLTR_CHANGED,
189e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_VLAN_FLTR_CHANGED,
190e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_PROMISC_CHANGED,
191e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_NBITS		/* must be last */
192e94d4478SAnirudh Venkataramanan };
193e94d4478SAnirudh Venkataramanan 
194940b61afSAnirudh Venkataramanan /* struct that defines a VSI, associated with a dev */
195940b61afSAnirudh Venkataramanan struct ice_vsi {
196940b61afSAnirudh Venkataramanan 	struct net_device *netdev;
1973a858ba3SAnirudh Venkataramanan 	struct ice_sw *vsw;		 /* switch this VSI is on */
1983a858ba3SAnirudh Venkataramanan 	struct ice_pf *back;		 /* back pointer to PF */
199940b61afSAnirudh Venkataramanan 	struct ice_port_info *port_info; /* back pointer to port_info */
200d337f2afSAnirudh Venkataramanan 	struct ice_ring **rx_rings;	 /* Rx ring array */
201d337f2afSAnirudh Venkataramanan 	struct ice_ring **tx_rings;	 /* Tx ring array */
2023a858ba3SAnirudh Venkataramanan 	struct ice_q_vector **q_vectors; /* q_vector array */
203cdedef59SAnirudh Venkataramanan 
204cdedef59SAnirudh Venkataramanan 	irqreturn_t (*irq_handler)(int irq, void *data);
205cdedef59SAnirudh Venkataramanan 
206fcea6f3dSAnirudh Venkataramanan 	u64 tx_linearize;
2073a858ba3SAnirudh Venkataramanan 	DECLARE_BITMAP(state, __ICE_STATE_NBITS);
208e94d4478SAnirudh Venkataramanan 	DECLARE_BITMAP(flags, ICE_VSI_FLAG_NBITS);
209e94d4478SAnirudh Venkataramanan 	unsigned int current_netdev_flags;
210fcea6f3dSAnirudh Venkataramanan 	u32 tx_restart;
211fcea6f3dSAnirudh Venkataramanan 	u32 tx_busy;
212fcea6f3dSAnirudh Venkataramanan 	u32 rx_buf_failed;
213fcea6f3dSAnirudh Venkataramanan 	u32 rx_page_failed;
2143a858ba3SAnirudh Venkataramanan 	int num_q_vectors;
215eb0208ecSPreethi Banala 	int sw_base_vector;		/* Irq base for OS reserved vectors */
216eb0208ecSPreethi Banala 	int hw_base_vector;		/* HW (absolute) index of a vector */
2173a858ba3SAnirudh Venkataramanan 	enum ice_vsi_type type;
218940b61afSAnirudh Venkataramanan 	u16 vsi_num;			/* HW (absolute) index of this VSI */
2193a858ba3SAnirudh Venkataramanan 	u16 idx;			/* software index in pf->vsi[] */
2203a858ba3SAnirudh Venkataramanan 
2213a858ba3SAnirudh Venkataramanan 	/* Interrupt thresholds */
2223a858ba3SAnirudh Venkataramanan 	u16 work_lmt;
2233a858ba3SAnirudh Venkataramanan 
2248ede0178SAnirudh Venkataramanan 	s16 vf_id;			/* VF ID for SR-IOV VSIs */
2258ede0178SAnirudh Venkataramanan 
226d76a60baSAnirudh Venkataramanan 	/* RSS config */
227d76a60baSAnirudh Venkataramanan 	u16 rss_table_size;	/* HW RSS table size */
228d76a60baSAnirudh Venkataramanan 	u16 rss_size;		/* Allocated RSS queues */
229d76a60baSAnirudh Venkataramanan 	u8 *rss_hkey_user;	/* User configured hash keys */
230d76a60baSAnirudh Venkataramanan 	u8 *rss_lut_user;	/* User configured lookup table entries */
231d76a60baSAnirudh Venkataramanan 	u8 rss_lut_type;	/* used to configure Get/Set RSS LUT AQ call */
232d76a60baSAnirudh Venkataramanan 
233cdedef59SAnirudh Venkataramanan 	u16 max_frame;
234cdedef59SAnirudh Venkataramanan 	u16 rx_buf_len;
235cdedef59SAnirudh Venkataramanan 
2363a858ba3SAnirudh Venkataramanan 	struct ice_aqc_vsi_props info;	 /* VSI properties */
2373a858ba3SAnirudh Venkataramanan 
238fcea6f3dSAnirudh Venkataramanan 	/* VSI stats */
239fcea6f3dSAnirudh Venkataramanan 	struct rtnl_link_stats64 net_stats;
240fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats;
241fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats_prev;
242fcea6f3dSAnirudh Venkataramanan 
243e94d4478SAnirudh Venkataramanan 	struct list_head tmp_sync_list;		/* MAC filters to be synced */
244e94d4478SAnirudh Venkataramanan 	struct list_head tmp_unsync_list;	/* MAC filters to be unsynced */
245e94d4478SAnirudh Venkataramanan 
24643f8b224SBruce Allan 	u8 irqs_ready;
24743f8b224SBruce Allan 	u8 current_isup;		 /* Sync 'link up' logging */
24843f8b224SBruce Allan 	u8 stat_offsets_loaded;
249cdedef59SAnirudh Venkataramanan 
2503a858ba3SAnirudh Venkataramanan 	/* queue information */
2513a858ba3SAnirudh Venkataramanan 	u8 tx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
2523a858ba3SAnirudh Venkataramanan 	u8 rx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
2533a858ba3SAnirudh Venkataramanan 	u16 txq_map[ICE_MAX_TXQS];	 /* index in pf->avail_txqs */
2543a858ba3SAnirudh Venkataramanan 	u16 rxq_map[ICE_MAX_RXQS];	 /* index in pf->avail_rxqs */
2553a858ba3SAnirudh Venkataramanan 	u16 alloc_txq;			 /* Allocated Tx queues */
2563a858ba3SAnirudh Venkataramanan 	u16 num_txq;			 /* Used Tx queues */
2573a858ba3SAnirudh Venkataramanan 	u16 alloc_rxq;			 /* Allocated Rx queues */
2583a858ba3SAnirudh Venkataramanan 	u16 num_rxq;			 /* Used Rx queues */
2593a858ba3SAnirudh Venkataramanan 	u16 num_desc;
2603a858ba3SAnirudh Venkataramanan 	struct ice_tc_cfg tc_cfg;
2613a858ba3SAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
2623a858ba3SAnirudh Venkataramanan 
2633a858ba3SAnirudh Venkataramanan /* struct that defines an interrupt vector */
2643a858ba3SAnirudh Venkataramanan struct ice_q_vector {
2653a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
2663a858ba3SAnirudh Venkataramanan 	cpumask_t affinity_mask;
2673a858ba3SAnirudh Venkataramanan 	struct napi_struct napi;
2683a858ba3SAnirudh Venkataramanan 	struct ice_ring_container rx;
2693a858ba3SAnirudh Venkataramanan 	struct ice_ring_container tx;
270cdedef59SAnirudh Venkataramanan 	struct irq_affinity_notify affinity_notify;
2713a858ba3SAnirudh Venkataramanan 	u16 v_idx;			/* index in the vsi->q_vector array. */
272d337f2afSAnirudh Venkataramanan 	u8 num_ring_tx;			/* total number of Tx rings in vector */
273d337f2afSAnirudh Venkataramanan 	u8 num_ring_rx;			/* total number of Rx rings in vector */
274cdedef59SAnirudh Venkataramanan 	char name[ICE_INT_NAME_STR_LEN];
2759e4ab4c2SBrett Creeley 	/* in usecs, need to use ice_intrl_to_usecs_reg() before writing this
2769e4ab4c2SBrett Creeley 	 * value to the device
2779e4ab4c2SBrett Creeley 	 */
2789e4ab4c2SBrett Creeley 	u8 intrl;
279940b61afSAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
280940b61afSAnirudh Venkataramanan 
281940b61afSAnirudh Venkataramanan enum ice_pf_flags {
282940b61afSAnirudh Venkataramanan 	ICE_FLAG_MSIX_ENA,
283940b61afSAnirudh Venkataramanan 	ICE_FLAG_FLTR_SYNC,
284940b61afSAnirudh Venkataramanan 	ICE_FLAG_RSS_ENA,
285ddf30f7fSAnirudh Venkataramanan 	ICE_FLAG_SRIOV_ENA,
28675d2b253SAnirudh Venkataramanan 	ICE_FLAG_SRIOV_CAPABLE,
287ab4ab73fSBruce Allan 	ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA,
288940b61afSAnirudh Venkataramanan 	ICE_PF_FLAGS_NBITS		/* must be last */
289940b61afSAnirudh Venkataramanan };
290940b61afSAnirudh Venkataramanan 
291837f08fdSAnirudh Venkataramanan struct ice_pf {
292837f08fdSAnirudh Venkataramanan 	struct pci_dev *pdev;
293eb0208ecSPreethi Banala 
294eb0208ecSPreethi Banala 	/* OS reserved IRQ details */
295940b61afSAnirudh Venkataramanan 	struct msix_entry *msix_entries;
296eb0208ecSPreethi Banala 	struct ice_res_tracker *sw_irq_tracker;
297eb0208ecSPreethi Banala 
298eb0208ecSPreethi Banala 	/* HW reserved Interrupts for this PF */
299eb0208ecSPreethi Banala 	struct ice_res_tracker *hw_irq_tracker;
300eb0208ecSPreethi Banala 
301940b61afSAnirudh Venkataramanan 	struct ice_vsi **vsi;		/* VSIs created by the driver */
302940b61afSAnirudh Venkataramanan 	struct ice_sw *first_sw;	/* first switch created by firmware */
303ddf30f7fSAnirudh Venkataramanan 	/* Virtchnl/SR-IOV config info */
304ddf30f7fSAnirudh Venkataramanan 	struct ice_vf *vf;
305ddf30f7fSAnirudh Venkataramanan 	int num_alloc_vfs;		/* actual number of VFs allocated */
30675d2b253SAnirudh Venkataramanan 	u16 num_vfs_supported;		/* num VFs supported for this PF */
307ddf30f7fSAnirudh Venkataramanan 	u16 num_vf_qps;			/* num queue pairs per VF */
308ddf30f7fSAnirudh Venkataramanan 	u16 num_vf_msix;		/* num vectors per VF */
309837f08fdSAnirudh Venkataramanan 	DECLARE_BITMAP(state, __ICE_STATE_NBITS);
310940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(avail_txqs, ICE_MAX_TXQS);
311940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(avail_rxqs, ICE_MAX_RXQS);
312940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);
313940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_period;
314940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_prev;
315940b61afSAnirudh Venkataramanan 	struct timer_list serv_tmr;
316940b61afSAnirudh Venkataramanan 	struct work_struct serv_task;
317940b61afSAnirudh Venkataramanan 	struct mutex avail_q_mutex;	/* protects access to avail_[rx|tx]qs */
318940b61afSAnirudh Venkataramanan 	struct mutex sw_mutex;		/* lock for protecting VSI alloc flow */
319837f08fdSAnirudh Venkataramanan 	u32 msg_enable;
320d76a60baSAnirudh Venkataramanan 	u32 hw_csum_rx_error;
321eb0208ecSPreethi Banala 	u32 sw_oicr_idx;	/* Other interrupt cause SW vector index */
322eb0208ecSPreethi Banala 	u32 num_avail_sw_msix;	/* remaining MSIX SW vectors left unclaimed */
323eb0208ecSPreethi Banala 	u32 hw_oicr_idx;	/* Other interrupt cause vector HW index */
324eb0208ecSPreethi Banala 	u32 num_avail_hw_msix;	/* remaining HW MSIX vectors left unclaimed */
325940b61afSAnirudh Venkataramanan 	u32 num_lan_msix;	/* Total MSIX vectors for base driver */
326d337f2afSAnirudh Venkataramanan 	u16 num_lan_tx;		/* num lan Tx queues setup */
327d337f2afSAnirudh Venkataramanan 	u16 num_lan_rx;		/* num lan Rx queues setup */
328d337f2afSAnirudh Venkataramanan 	u16 q_left_tx;		/* remaining num Tx queues left unclaimed */
329d337f2afSAnirudh Venkataramanan 	u16 q_left_rx;		/* remaining num Rx queues left unclaimed */
330940b61afSAnirudh Venkataramanan 	u16 next_vsi;		/* Next free slot in pf->vsi[] - 0-based! */
331940b61afSAnirudh Venkataramanan 	u16 num_alloc_vsi;
3320b28b702SAnirudh Venkataramanan 	u16 corer_count;	/* Core reset count */
3330b28b702SAnirudh Venkataramanan 	u16 globr_count;	/* Global reset count */
3340b28b702SAnirudh Venkataramanan 	u16 empr_count;		/* EMP reset count */
3350b28b702SAnirudh Venkataramanan 	u16 pfr_count;		/* PF reset count */
3360b28b702SAnirudh Venkataramanan 
337fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats;
338fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats_prev;
339837f08fdSAnirudh Venkataramanan 	struct ice_hw hw;
34043f8b224SBruce Allan 	u8 stat_prev_loaded;	/* has previous stats been loaded */
341b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_count;
342b3969fd7SSudheer Mogilappagari 	unsigned long tx_timeout_last_recovery;
343b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_recovery_level;
344940b61afSAnirudh Venkataramanan 	char int_name[ICE_INT_NAME_STR_LEN];
345837f08fdSAnirudh Venkataramanan };
346940b61afSAnirudh Venkataramanan 
3473a858ba3SAnirudh Venkataramanan struct ice_netdev_priv {
3483a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
3493a858ba3SAnirudh Venkataramanan };
3503a858ba3SAnirudh Venkataramanan 
351940b61afSAnirudh Venkataramanan /**
352940b61afSAnirudh Venkataramanan  * ice_irq_dynamic_ena - Enable default interrupt generation settings
353940b61afSAnirudh Venkataramanan  * @hw: pointer to hw struct
354cdedef59SAnirudh Venkataramanan  * @vsi: pointer to vsi struct, can be NULL
355cdedef59SAnirudh Venkataramanan  * @q_vector: pointer to q_vector, can be NULL
356940b61afSAnirudh Venkataramanan  */
357cdedef59SAnirudh Venkataramanan static inline void ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
358cdedef59SAnirudh Venkataramanan 				       struct ice_q_vector *q_vector)
359940b61afSAnirudh Venkataramanan {
360eb0208ecSPreethi Banala 	u32 vector = (vsi && q_vector) ? vsi->hw_base_vector + q_vector->v_idx :
361eb0208ecSPreethi Banala 				((struct ice_pf *)hw->back)->hw_oicr_idx;
362940b61afSAnirudh Venkataramanan 	int itr = ICE_ITR_NONE;
363940b61afSAnirudh Venkataramanan 	u32 val;
364940b61afSAnirudh Venkataramanan 
365940b61afSAnirudh Venkataramanan 	/* clear the PBA here, as this function is meant to clean out all
366940b61afSAnirudh Venkataramanan 	 * previous interrupts and enable the interrupt
367940b61afSAnirudh Venkataramanan 	 */
368940b61afSAnirudh Venkataramanan 	val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
369940b61afSAnirudh Venkataramanan 	      (itr << GLINT_DYN_CTL_ITR_INDX_S);
370cdedef59SAnirudh Venkataramanan 	if (vsi)
371cdedef59SAnirudh Venkataramanan 		if (test_bit(__ICE_DOWN, vsi->state))
372cdedef59SAnirudh Venkataramanan 			return;
373940b61afSAnirudh Venkataramanan 	wr32(hw, GLINT_DYN_CTL(vector), val);
374940b61afSAnirudh Venkataramanan }
375cdedef59SAnirudh Venkataramanan 
3765513b920SAnirudh Venkataramanan static inline void ice_vsi_set_tc_cfg(struct ice_vsi *vsi)
3775513b920SAnirudh Venkataramanan {
3785513b920SAnirudh Venkataramanan 	vsi->tc_cfg.ena_tc =  ICE_DFLT_TRAFFIC_CLASS;
3795513b920SAnirudh Venkataramanan 	vsi->tc_cfg.numtc = 1;
3805513b920SAnirudh Venkataramanan }
3815513b920SAnirudh Venkataramanan 
382fcea6f3dSAnirudh Venkataramanan void ice_set_ethtool_ops(struct net_device *netdev);
383fcea6f3dSAnirudh Venkataramanan int ice_up(struct ice_vsi *vsi);
384fcea6f3dSAnirudh Venkataramanan int ice_down(struct ice_vsi *vsi);
385d76a60baSAnirudh Venkataramanan int ice_set_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
386d76a60baSAnirudh Venkataramanan int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
387d76a60baSAnirudh Venkataramanan void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
388fcea6f3dSAnirudh Venkataramanan void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
38925525b69SDave Ertman void ice_napi_del(struct ice_vsi *vsi);
390d76a60baSAnirudh Venkataramanan 
391837f08fdSAnirudh Venkataramanan #endif /* _ICE_H_ */
392