xref: /openbmc/linux/drivers/net/ethernet/intel/ice/ice.h (revision 9e4ab4c29a62d2ccbf4be42707669be2f42d391c)
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>
31d76a60baSAnirudh Venkataramanan #include <net/ipv6.h>
32837f08fdSAnirudh Venkataramanan #include "ice_devids.h"
33837f08fdSAnirudh Venkataramanan #include "ice_type.h"
34940b61afSAnirudh Venkataramanan #include "ice_txrx.h"
359c20346bSAnirudh Venkataramanan #include "ice_switch.h"
36f31e4b6fSAnirudh Venkataramanan #include "ice_common.h"
379c20346bSAnirudh Venkataramanan #include "ice_sched.h"
38837f08fdSAnirudh Venkataramanan 
39fcea6f3dSAnirudh Venkataramanan extern const char ice_drv_ver[];
40837f08fdSAnirudh Venkataramanan #define ICE_BAR0		0
413a858ba3SAnirudh Venkataramanan #define ICE_DFLT_NUM_DESC	128
423a858ba3SAnirudh Venkataramanan #define ICE_REQ_DESC_MULTIPLE	32
433b6bf296SBruce Allan #define ICE_MIN_NUM_DESC	ICE_REQ_DESC_MULTIPLE
443b6bf296SBruce Allan #define ICE_MAX_NUM_DESC	8160
455513b920SAnirudh Venkataramanan #define ICE_DFLT_TRAFFIC_CLASS	BIT(0)
46940b61afSAnirudh Venkataramanan #define ICE_INT_NAME_STR_LEN	(IFNAMSIZ + 16)
47fcea6f3dSAnirudh Venkataramanan #define ICE_ETHTOOL_FWVER_LEN	32
48f31e4b6fSAnirudh Venkataramanan #define ICE_AQ_LEN		64
49940b61afSAnirudh Venkataramanan #define ICE_MIN_MSIX		2
503a858ba3SAnirudh Venkataramanan #define ICE_NO_VSI		0xffff
51940b61afSAnirudh Venkataramanan #define ICE_MAX_VSI_ALLOC	130
52940b61afSAnirudh Venkataramanan #define ICE_MAX_TXQS		2048
53940b61afSAnirudh Venkataramanan #define ICE_MAX_RXQS		2048
543a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_CONTIG	0
553a858ba3SAnirudh Venkataramanan #define ICE_VSI_MAP_SCATTER	1
563a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_TXQS	16
573a858ba3SAnirudh Venkataramanan #define ICE_MAX_SCATTER_RXQS	16
58cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_RETRY_LIMIT	10
59cdedef59SAnirudh Venkataramanan #define ICE_Q_WAIT_MAX_RETRY	(5 * ICE_Q_WAIT_RETRY_LIMIT)
60d76a60baSAnirudh Venkataramanan #define ICE_MAX_LG_RSS_QS	256
61d76a60baSAnirudh Venkataramanan #define ICE_MAX_SMALL_RSS_QS	8
62940b61afSAnirudh Venkataramanan #define ICE_RES_VALID_BIT	0x8000
63940b61afSAnirudh Venkataramanan #define ICE_RES_MISC_VEC_ID	(ICE_RES_VALID_BIT - 1)
643a858ba3SAnirudh Venkataramanan #define ICE_INVAL_Q_INDEX	0xffff
650f9d5027SAnirudh Venkataramanan #define ICE_INVAL_VFID		256
66837f08fdSAnirudh Venkataramanan 
67fcea6f3dSAnirudh Venkataramanan #define ICE_VSIQF_HKEY_ARRAY_SIZE	((VSIQF_HKEY_MAX_INDEX + 1) *	4)
68fcea6f3dSAnirudh Venkataramanan 
69837f08fdSAnirudh Venkataramanan #define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
70837f08fdSAnirudh Venkataramanan 
713a858ba3SAnirudh Venkataramanan #define ICE_MAX_MTU	(ICE_AQ_SET_MAC_FRAME_SIZE_MAX - \
723a858ba3SAnirudh Venkataramanan 			 ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN)
733a858ba3SAnirudh Venkataramanan 
743a858ba3SAnirudh Venkataramanan #define ICE_UP_TABLE_TRANSLATE(val, i) \
753a858ba3SAnirudh Venkataramanan 		(((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
763a858ba3SAnirudh Venkataramanan 		  ICE_AQ_VSI_UP_TABLE_UP##i##_M)
773a858ba3SAnirudh Venkataramanan 
782b245cb2SAnirudh Venkataramanan #define ICE_TX_DESC(R, i) (&(((struct ice_tx_desc *)((R)->desc))[i]))
79cdedef59SAnirudh Venkataramanan #define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
80d76a60baSAnirudh Venkataramanan #define ICE_TX_CTX_DESC(R, i) (&(((struct ice_tx_ctx_desc *)((R)->desc))[i]))
81cdedef59SAnirudh Venkataramanan 
820b28b702SAnirudh Venkataramanan /* Macro for each VSI in a PF */
830b28b702SAnirudh Venkataramanan #define ice_for_each_vsi(pf, i) \
840b28b702SAnirudh Venkataramanan 	for ((i) = 0; (i) < (pf)->num_alloc_vsi; (i)++)
850b28b702SAnirudh Venkataramanan 
860b28b702SAnirudh Venkataramanan /* Macros for each tx/rx ring in a VSI */
87cdedef59SAnirudh Venkataramanan #define ice_for_each_txq(vsi, i) \
88cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
89cdedef59SAnirudh Venkataramanan 
90cdedef59SAnirudh Venkataramanan #define ice_for_each_rxq(vsi, i) \
91cdedef59SAnirudh Venkataramanan 	for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
92cdedef59SAnirudh Venkataramanan 
93f8ba7db8SJacob Keller /* Macros for each allocated tx/rx ring whether used or not in a VSI */
94f8ba7db8SJacob Keller #define ice_for_each_alloc_txq(vsi, i) \
95f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_txq; (i)++)
96f8ba7db8SJacob Keller 
97f8ba7db8SJacob Keller #define ice_for_each_alloc_rxq(vsi, i) \
98f8ba7db8SJacob Keller 	for ((i) = 0; (i) < (vsi)->alloc_rxq; (i)++)
99f8ba7db8SJacob Keller 
1003a858ba3SAnirudh Venkataramanan struct ice_tc_info {
1013a858ba3SAnirudh Venkataramanan 	u16 qoffset;
1023a858ba3SAnirudh Venkataramanan 	u16 qcount;
1033a858ba3SAnirudh Venkataramanan };
1043a858ba3SAnirudh Venkataramanan 
1053a858ba3SAnirudh Venkataramanan struct ice_tc_cfg {
1063a858ba3SAnirudh Venkataramanan 	u8 numtc; /* Total number of enabled TCs */
1073a858ba3SAnirudh Venkataramanan 	u8 ena_tc; /* TX map */
1083a858ba3SAnirudh Venkataramanan 	struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS];
1093a858ba3SAnirudh Venkataramanan };
1103a858ba3SAnirudh Venkataramanan 
111940b61afSAnirudh Venkataramanan struct ice_res_tracker {
112940b61afSAnirudh Venkataramanan 	u16 num_entries;
113940b61afSAnirudh Venkataramanan 	u16 search_hint;
114940b61afSAnirudh Venkataramanan 	u16 list[1];
115940b61afSAnirudh Venkataramanan };
116940b61afSAnirudh Venkataramanan 
117940b61afSAnirudh Venkataramanan struct ice_sw {
118940b61afSAnirudh Venkataramanan 	struct ice_pf *pf;
119940b61afSAnirudh Venkataramanan 	u16 sw_id;		/* switch ID for this switch */
120940b61afSAnirudh Venkataramanan 	u16 bridge_mode;	/* VEB/VEPA/Port Virtualizer */
121940b61afSAnirudh Venkataramanan };
122940b61afSAnirudh Venkataramanan 
123837f08fdSAnirudh Venkataramanan enum ice_state {
124837f08fdSAnirudh Venkataramanan 	__ICE_DOWN,
1250b28b702SAnirudh Venkataramanan 	__ICE_NEEDS_RESTART,
1260f9d5027SAnirudh Venkataramanan 	__ICE_PREPARED_FOR_RESET,	/* set by driver when prepared */
1275df7e45dSDave Ertman 	__ICE_RESET_OICR_RECV,		/* set by driver after rcv reset OICR */
128940b61afSAnirudh Venkataramanan 	__ICE_PFR_REQ,			/* set by driver and peers */
1290b28b702SAnirudh Venkataramanan 	__ICE_CORER_REQ,		/* set by driver and peers */
1300b28b702SAnirudh Venkataramanan 	__ICE_GLOBR_REQ,		/* set by driver and peers */
1310b28b702SAnirudh Venkataramanan 	__ICE_CORER_RECV,		/* set by OICR handler */
1320b28b702SAnirudh Venkataramanan 	__ICE_GLOBR_RECV,		/* set by OICR handler */
1330b28b702SAnirudh Venkataramanan 	__ICE_EMPR_RECV,		/* set by OICR handler */
1340b28b702SAnirudh Venkataramanan 	__ICE_SUSPENDED,		/* set on module remove path */
1350b28b702SAnirudh Venkataramanan 	__ICE_RESET_FAILED,		/* set by reset/rebuild */
136940b61afSAnirudh Venkataramanan 	__ICE_ADMINQ_EVENT_PENDING,
137b3969fd7SSudheer Mogilappagari 	__ICE_MDD_EVENT_PENDING,
138e94d4478SAnirudh Venkataramanan 	__ICE_FLTR_OVERFLOW_PROMISC,
139fcea6f3dSAnirudh Venkataramanan 	__ICE_CFG_BUSY,
140940b61afSAnirudh Venkataramanan 	__ICE_SERVICE_SCHED,
1418d81fa55SAkeem G Abodunrin 	__ICE_SERVICE_DIS,
142837f08fdSAnirudh Venkataramanan 	__ICE_STATE_NBITS		/* must be last */
143837f08fdSAnirudh Venkataramanan };
144837f08fdSAnirudh Venkataramanan 
145e94d4478SAnirudh Venkataramanan enum ice_vsi_flags {
146e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_UMAC_FLTR_CHANGED,
147e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_MMAC_FLTR_CHANGED,
148e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_VLAN_FLTR_CHANGED,
149e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_PROMISC_CHANGED,
150e94d4478SAnirudh Venkataramanan 	ICE_VSI_FLAG_NBITS		/* must be last */
151e94d4478SAnirudh Venkataramanan };
152e94d4478SAnirudh Venkataramanan 
153940b61afSAnirudh Venkataramanan /* struct that defines a VSI, associated with a dev */
154940b61afSAnirudh Venkataramanan struct ice_vsi {
155940b61afSAnirudh Venkataramanan 	struct net_device *netdev;
1563a858ba3SAnirudh Venkataramanan 	struct ice_sw *vsw;		 /* switch this VSI is on */
1573a858ba3SAnirudh Venkataramanan 	struct ice_pf *back;		 /* back pointer to PF */
158940b61afSAnirudh Venkataramanan 	struct ice_port_info *port_info; /* back pointer to port_info */
1593a858ba3SAnirudh Venkataramanan 	struct ice_ring **rx_rings;	 /* rx ring array */
1603a858ba3SAnirudh Venkataramanan 	struct ice_ring **tx_rings;	 /* tx ring array */
1613a858ba3SAnirudh Venkataramanan 	struct ice_q_vector **q_vectors; /* q_vector array */
162cdedef59SAnirudh Venkataramanan 
163cdedef59SAnirudh Venkataramanan 	irqreturn_t (*irq_handler)(int irq, void *data);
164cdedef59SAnirudh Venkataramanan 
165fcea6f3dSAnirudh Venkataramanan 	u64 tx_linearize;
1663a858ba3SAnirudh Venkataramanan 	DECLARE_BITMAP(state, __ICE_STATE_NBITS);
167e94d4478SAnirudh Venkataramanan 	DECLARE_BITMAP(flags, ICE_VSI_FLAG_NBITS);
168d76a60baSAnirudh Venkataramanan 	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
169e94d4478SAnirudh Venkataramanan 	unsigned int current_netdev_flags;
170fcea6f3dSAnirudh Venkataramanan 	u32 tx_restart;
171fcea6f3dSAnirudh Venkataramanan 	u32 tx_busy;
172fcea6f3dSAnirudh Venkataramanan 	u32 rx_buf_failed;
173fcea6f3dSAnirudh Venkataramanan 	u32 rx_page_failed;
1743a858ba3SAnirudh Venkataramanan 	int num_q_vectors;
175eb0208ecSPreethi Banala 	int sw_base_vector;		/* Irq base for OS reserved vectors */
176eb0208ecSPreethi Banala 	int hw_base_vector;		/* HW (absolute) index of a vector */
1773a858ba3SAnirudh Venkataramanan 	enum ice_vsi_type type;
178940b61afSAnirudh Venkataramanan 	u16 vsi_num;			 /* HW (absolute) index of this VSI */
1793a858ba3SAnirudh Venkataramanan 	u16 idx;			 /* software index in pf->vsi[] */
1803a858ba3SAnirudh Venkataramanan 
1813a858ba3SAnirudh Venkataramanan 	/* Interrupt thresholds */
1823a858ba3SAnirudh Venkataramanan 	u16 work_lmt;
1833a858ba3SAnirudh Venkataramanan 
184d76a60baSAnirudh Venkataramanan 	/* RSS config */
185d76a60baSAnirudh Venkataramanan 	u16 rss_table_size;	/* HW RSS table size */
186d76a60baSAnirudh Venkataramanan 	u16 rss_size;		/* Allocated RSS queues */
187d76a60baSAnirudh Venkataramanan 	u8 *rss_hkey_user;	/* User configured hash keys */
188d76a60baSAnirudh Venkataramanan 	u8 *rss_lut_user;	/* User configured lookup table entries */
189d76a60baSAnirudh Venkataramanan 	u8 rss_lut_type;	/* used to configure Get/Set RSS LUT AQ call */
190d76a60baSAnirudh Venkataramanan 
191cdedef59SAnirudh Venkataramanan 	u16 max_frame;
192cdedef59SAnirudh Venkataramanan 	u16 rx_buf_len;
193cdedef59SAnirudh Venkataramanan 
1943a858ba3SAnirudh Venkataramanan 	struct ice_aqc_vsi_props info;	 /* VSI properties */
1953a858ba3SAnirudh Venkataramanan 
196fcea6f3dSAnirudh Venkataramanan 	/* VSI stats */
197fcea6f3dSAnirudh Venkataramanan 	struct rtnl_link_stats64 net_stats;
198fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats;
199fcea6f3dSAnirudh Venkataramanan 	struct ice_eth_stats eth_stats_prev;
200fcea6f3dSAnirudh Venkataramanan 
201e94d4478SAnirudh Venkataramanan 	struct list_head tmp_sync_list;		/* MAC filters to be synced */
202e94d4478SAnirudh Venkataramanan 	struct list_head tmp_unsync_list;	/* MAC filters to be unsynced */
203e94d4478SAnirudh Venkataramanan 
20443f8b224SBruce Allan 	u8 irqs_ready;
20543f8b224SBruce Allan 	u8 current_isup;		 /* Sync 'link up' logging */
20643f8b224SBruce Allan 	u8 stat_offsets_loaded;
207cdedef59SAnirudh Venkataramanan 
2083a858ba3SAnirudh Venkataramanan 	/* queue information */
2093a858ba3SAnirudh Venkataramanan 	u8 tx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
2103a858ba3SAnirudh Venkataramanan 	u8 rx_mapping_mode;		 /* ICE_MAP_MODE_[CONTIG|SCATTER] */
2113a858ba3SAnirudh Venkataramanan 	u16 txq_map[ICE_MAX_TXQS];	 /* index in pf->avail_txqs */
2123a858ba3SAnirudh Venkataramanan 	u16 rxq_map[ICE_MAX_RXQS];	 /* index in pf->avail_rxqs */
2133a858ba3SAnirudh Venkataramanan 	u16 alloc_txq;			 /* Allocated Tx queues */
2143a858ba3SAnirudh Venkataramanan 	u16 num_txq;			 /* Used Tx queues */
2153a858ba3SAnirudh Venkataramanan 	u16 alloc_rxq;			 /* Allocated Rx queues */
2163a858ba3SAnirudh Venkataramanan 	u16 num_rxq;			 /* Used Rx queues */
2173a858ba3SAnirudh Venkataramanan 	u16 num_desc;
2183a858ba3SAnirudh Venkataramanan 	struct ice_tc_cfg tc_cfg;
2193a858ba3SAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
2203a858ba3SAnirudh Venkataramanan 
2213a858ba3SAnirudh Venkataramanan /* struct that defines an interrupt vector */
2223a858ba3SAnirudh Venkataramanan struct ice_q_vector {
2233a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
2243a858ba3SAnirudh Venkataramanan 	cpumask_t affinity_mask;
2253a858ba3SAnirudh Venkataramanan 	struct napi_struct napi;
2263a858ba3SAnirudh Venkataramanan 	struct ice_ring_container rx;
2273a858ba3SAnirudh Venkataramanan 	struct ice_ring_container tx;
228cdedef59SAnirudh Venkataramanan 	struct irq_affinity_notify affinity_notify;
2293a858ba3SAnirudh Venkataramanan 	u16 v_idx;			/* index in the vsi->q_vector array. */
2303a858ba3SAnirudh Venkataramanan 	u8 num_ring_tx;			/* total number of tx rings in vector */
2313a858ba3SAnirudh Venkataramanan 	u8 num_ring_rx;			/* total number of rx rings in vector */
232cdedef59SAnirudh Venkataramanan 	char name[ICE_INT_NAME_STR_LEN];
233*9e4ab4c2SBrett Creeley 	/* in usecs, need to use ice_intrl_to_usecs_reg() before writing this
234*9e4ab4c2SBrett Creeley 	 * value to the device
235*9e4ab4c2SBrett Creeley 	 */
236*9e4ab4c2SBrett Creeley 	u8 intrl;
237940b61afSAnirudh Venkataramanan } ____cacheline_internodealigned_in_smp;
238940b61afSAnirudh Venkataramanan 
239940b61afSAnirudh Venkataramanan enum ice_pf_flags {
240940b61afSAnirudh Venkataramanan 	ICE_FLAG_MSIX_ENA,
241940b61afSAnirudh Venkataramanan 	ICE_FLAG_FLTR_SYNC,
242940b61afSAnirudh Venkataramanan 	ICE_FLAG_RSS_ENA,
243940b61afSAnirudh Venkataramanan 	ICE_PF_FLAGS_NBITS		/* must be last */
244940b61afSAnirudh Venkataramanan };
245940b61afSAnirudh Venkataramanan 
246837f08fdSAnirudh Venkataramanan struct ice_pf {
247837f08fdSAnirudh Venkataramanan 	struct pci_dev *pdev;
248eb0208ecSPreethi Banala 
249eb0208ecSPreethi Banala 	/* OS reserved IRQ details */
250940b61afSAnirudh Venkataramanan 	struct msix_entry *msix_entries;
251eb0208ecSPreethi Banala 	struct ice_res_tracker *sw_irq_tracker;
252eb0208ecSPreethi Banala 
253eb0208ecSPreethi Banala 	/* HW reserved Interrupts for this PF */
254eb0208ecSPreethi Banala 	struct ice_res_tracker *hw_irq_tracker;
255eb0208ecSPreethi Banala 
256940b61afSAnirudh Venkataramanan 	struct ice_vsi **vsi;		/* VSIs created by the driver */
257940b61afSAnirudh Venkataramanan 	struct ice_sw *first_sw;	/* first switch created by firmware */
258837f08fdSAnirudh Venkataramanan 	DECLARE_BITMAP(state, __ICE_STATE_NBITS);
259940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(avail_txqs, ICE_MAX_TXQS);
260940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(avail_rxqs, ICE_MAX_RXQS);
261940b61afSAnirudh Venkataramanan 	DECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);
262940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_period;
263940b61afSAnirudh Venkataramanan 	unsigned long serv_tmr_prev;
264940b61afSAnirudh Venkataramanan 	struct timer_list serv_tmr;
265940b61afSAnirudh Venkataramanan 	struct work_struct serv_task;
266940b61afSAnirudh Venkataramanan 	struct mutex avail_q_mutex;	/* protects access to avail_[rx|tx]qs */
267940b61afSAnirudh Venkataramanan 	struct mutex sw_mutex;		/* lock for protecting VSI alloc flow */
268837f08fdSAnirudh Venkataramanan 	u32 msg_enable;
269d76a60baSAnirudh Venkataramanan 	u32 hw_csum_rx_error;
270eb0208ecSPreethi Banala 	u32 sw_oicr_idx;	/* Other interrupt cause SW vector index */
271eb0208ecSPreethi Banala 	u32 num_avail_sw_msix;	/* remaining MSIX SW vectors left unclaimed */
272eb0208ecSPreethi Banala 	u32 hw_oicr_idx;	/* Other interrupt cause vector HW index */
273eb0208ecSPreethi Banala 	u32 num_avail_hw_msix;	/* remaining HW MSIX vectors left unclaimed */
274940b61afSAnirudh Venkataramanan 	u32 num_lan_msix;	/* Total MSIX vectors for base driver */
275940b61afSAnirudh Venkataramanan 	u16 num_lan_tx;		/* num lan tx queues setup */
276940b61afSAnirudh Venkataramanan 	u16 num_lan_rx;		/* num lan rx queues setup */
277940b61afSAnirudh Venkataramanan 	u16 q_left_tx;		/* remaining num tx queues left unclaimed */
278940b61afSAnirudh Venkataramanan 	u16 q_left_rx;		/* remaining num rx queues left unclaimed */
279940b61afSAnirudh Venkataramanan 	u16 next_vsi;		/* Next free slot in pf->vsi[] - 0-based! */
280940b61afSAnirudh Venkataramanan 	u16 num_alloc_vsi;
2810b28b702SAnirudh Venkataramanan 	u16 corer_count;	/* Core reset count */
2820b28b702SAnirudh Venkataramanan 	u16 globr_count;	/* Global reset count */
2830b28b702SAnirudh Venkataramanan 	u16 empr_count;		/* EMP reset count */
2840b28b702SAnirudh Venkataramanan 	u16 pfr_count;		/* PF reset count */
2850b28b702SAnirudh Venkataramanan 
286fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats;
287fcea6f3dSAnirudh Venkataramanan 	struct ice_hw_port_stats stats_prev;
288837f08fdSAnirudh Venkataramanan 	struct ice_hw hw;
28943f8b224SBruce Allan 	u8 stat_prev_loaded;	/* has previous stats been loaded */
290b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_count;
291b3969fd7SSudheer Mogilappagari 	unsigned long tx_timeout_last_recovery;
292b3969fd7SSudheer Mogilappagari 	u32 tx_timeout_recovery_level;
293940b61afSAnirudh Venkataramanan 	char int_name[ICE_INT_NAME_STR_LEN];
294837f08fdSAnirudh Venkataramanan };
295940b61afSAnirudh Venkataramanan 
2963a858ba3SAnirudh Venkataramanan struct ice_netdev_priv {
2973a858ba3SAnirudh Venkataramanan 	struct ice_vsi *vsi;
2983a858ba3SAnirudh Venkataramanan };
2993a858ba3SAnirudh Venkataramanan 
300940b61afSAnirudh Venkataramanan /**
301940b61afSAnirudh Venkataramanan  * ice_irq_dynamic_ena - Enable default interrupt generation settings
302940b61afSAnirudh Venkataramanan  * @hw: pointer to hw struct
303cdedef59SAnirudh Venkataramanan  * @vsi: pointer to vsi struct, can be NULL
304cdedef59SAnirudh Venkataramanan  * @q_vector: pointer to q_vector, can be NULL
305940b61afSAnirudh Venkataramanan  */
306cdedef59SAnirudh Venkataramanan static inline void ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
307cdedef59SAnirudh Venkataramanan 				       struct ice_q_vector *q_vector)
308940b61afSAnirudh Venkataramanan {
309eb0208ecSPreethi Banala 	u32 vector = (vsi && q_vector) ? vsi->hw_base_vector + q_vector->v_idx :
310eb0208ecSPreethi Banala 				((struct ice_pf *)hw->back)->hw_oicr_idx;
311940b61afSAnirudh Venkataramanan 	int itr = ICE_ITR_NONE;
312940b61afSAnirudh Venkataramanan 	u32 val;
313940b61afSAnirudh Venkataramanan 
314940b61afSAnirudh Venkataramanan 	/* clear the PBA here, as this function is meant to clean out all
315940b61afSAnirudh Venkataramanan 	 * previous interrupts and enable the interrupt
316940b61afSAnirudh Venkataramanan 	 */
317940b61afSAnirudh Venkataramanan 	val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
318940b61afSAnirudh Venkataramanan 	      (itr << GLINT_DYN_CTL_ITR_INDX_S);
319cdedef59SAnirudh Venkataramanan 	if (vsi)
320cdedef59SAnirudh Venkataramanan 		if (test_bit(__ICE_DOWN, vsi->state))
321cdedef59SAnirudh Venkataramanan 			return;
322940b61afSAnirudh Venkataramanan 	wr32(hw, GLINT_DYN_CTL(vector), val);
323940b61afSAnirudh Venkataramanan }
324cdedef59SAnirudh Venkataramanan 
3255513b920SAnirudh Venkataramanan static inline void ice_vsi_set_tc_cfg(struct ice_vsi *vsi)
3265513b920SAnirudh Venkataramanan {
3275513b920SAnirudh Venkataramanan 	vsi->tc_cfg.ena_tc =  ICE_DFLT_TRAFFIC_CLASS;
3285513b920SAnirudh Venkataramanan 	vsi->tc_cfg.numtc = 1;
3295513b920SAnirudh Venkataramanan }
3305513b920SAnirudh Venkataramanan 
331fcea6f3dSAnirudh Venkataramanan void ice_set_ethtool_ops(struct net_device *netdev);
332fcea6f3dSAnirudh Venkataramanan int ice_up(struct ice_vsi *vsi);
333fcea6f3dSAnirudh Venkataramanan int ice_down(struct ice_vsi *vsi);
334d76a60baSAnirudh Venkataramanan int ice_set_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
335d76a60baSAnirudh Venkataramanan int ice_get_rss(struct ice_vsi *vsi, u8 *seed, u8 *lut, u16 lut_size);
336d76a60baSAnirudh Venkataramanan void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size);
337fcea6f3dSAnirudh Venkataramanan void ice_print_link_msg(struct ice_vsi *vsi, bool isup);
338d76a60baSAnirudh Venkataramanan 
339837f08fdSAnirudh Venkataramanan #endif /* _ICE_H_ */
340