xref: /dpdk/drivers/net/intel/ice/ice_ethdev.h (revision 552979dfb1c98a939b0f8b087547386d3c32ac00)
1c1d14583SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2c1d14583SBruce Richardson  * Copyright(c) 2018 Intel Corporation
3c1d14583SBruce Richardson  */
4c1d14583SBruce Richardson 
5c1d14583SBruce Richardson #ifndef _ICE_ETHDEV_H_
6c1d14583SBruce Richardson #define _ICE_ETHDEV_H_
7c1d14583SBruce Richardson 
8c1d14583SBruce Richardson #include <rte_compat.h>
9c1d14583SBruce Richardson #include <rte_kvargs.h>
10c1d14583SBruce Richardson #include <rte_time.h>
11c1d14583SBruce Richardson 
12c1d14583SBruce Richardson #include <ethdev_driver.h>
13c1d14583SBruce Richardson #include <rte_tm_driver.h>
14c1d14583SBruce Richardson 
15c1d14583SBruce Richardson #include "base/ice_common.h"
16c1d14583SBruce Richardson #include "base/ice_adminq_cmd.h"
17c1d14583SBruce Richardson #include "base/ice_flow.h"
18c1d14583SBruce Richardson #include "base/ice_sched.h"
19c1d14583SBruce Richardson 
20c1d14583SBruce Richardson #define ICE_ADMINQ_LEN               32
21c1d14583SBruce Richardson #define ICE_SBIOQ_LEN                32
22c1d14583SBruce Richardson #define ICE_MAILBOXQ_LEN             32
23c1d14583SBruce Richardson #define ICE_SBQ_LEN                  64
24c1d14583SBruce Richardson #define ICE_ADMINQ_BUF_SZ            4096
25c1d14583SBruce Richardson #define ICE_SBIOQ_BUF_SZ             4096
26c1d14583SBruce Richardson #define ICE_MAILBOXQ_BUF_SZ          4096
27c1d14583SBruce Richardson /* Number of queues per TC should be one of 1, 2, 4, 8, 16, 32, 64, 128, 256 */
28c1d14583SBruce Richardson #define ICE_MAX_Q_PER_TC         256
29c1d14583SBruce Richardson #define ICE_NUM_DESC_DEFAULT     512
30c1d14583SBruce Richardson #define ICE_BUF_SIZE_MIN         1024
31c1d14583SBruce Richardson #define ICE_FRAME_SIZE_MAX       9728
32c1d14583SBruce Richardson #define ICE_QUEUE_BASE_ADDR_UNIT 128
33c1d14583SBruce Richardson /* number of VSIs and queue default setting */
34c1d14583SBruce Richardson #define ICE_MAX_QP_NUM_PER_VF    16
35c1d14583SBruce Richardson #define ICE_DEFAULT_QP_NUM_FDIR  1
36c1d14583SBruce Richardson #define ICE_UINT32_BIT_SIZE      (CHAR_BIT * sizeof(uint32_t))
37c1d14583SBruce Richardson #define ICE_VFTA_SIZE            (4096 / ICE_UINT32_BIT_SIZE)
38c1d14583SBruce Richardson /* Maximun number of MAC addresses */
39c1d14583SBruce Richardson #define ICE_NUM_MACADDR_MAX       64
40c1d14583SBruce Richardson /* Maximum number of VFs */
41c1d14583SBruce Richardson #define ICE_MAX_VF               128
42c1d14583SBruce Richardson #define ICE_MAX_INTR_QUEUE_NUM   256
43c1d14583SBruce Richardson 
44c1d14583SBruce Richardson #define ICE_MISC_VEC_ID          RTE_INTR_VEC_ZERO_OFFSET
45c1d14583SBruce Richardson #define ICE_RX_VEC_ID            RTE_INTR_VEC_RXTX_OFFSET
46c1d14583SBruce Richardson 
47c1d14583SBruce Richardson #define ICE_MAX_PKT_TYPE  1024
48c1d14583SBruce Richardson 
49c1d14583SBruce Richardson /* DDP package search path */
50c1d14583SBruce Richardson #define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
51c1d14583SBruce Richardson #define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
52c1d14583SBruce Richardson #define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
53c1d14583SBruce Richardson #define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
54c1d14583SBruce Richardson #define ICE_PKG_FILE_CUSTOMIZED_PATH "/sys/module/firmware_class/parameters/path"
55c1d14583SBruce Richardson #define ICE_MAX_PKG_FILENAME_SIZE   256
56c1d14583SBruce Richardson 
57c1d14583SBruce Richardson #define MAX_ACL_NORMAL_ENTRIES    256
58c1d14583SBruce Richardson 
59c1d14583SBruce Richardson /**
60c1d14583SBruce Richardson  * vlan_id is a 12 bit number.
61c1d14583SBruce Richardson  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
62c1d14583SBruce Richardson  * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
63c1d14583SBruce Richardson  * The higher 7 bit val specifies VFTA array index.
64c1d14583SBruce Richardson  */
65c1d14583SBruce Richardson #define ICE_VFTA_BIT(vlan_id)    (1 << ((vlan_id) & 0x1F))
66c1d14583SBruce Richardson #define ICE_VFTA_IDX(vlan_id)    ((vlan_id) >> 5)
67c1d14583SBruce Richardson 
68c1d14583SBruce Richardson /* Default TC traffic in case DCB is not enabled */
69c1d14583SBruce Richardson #define ICE_DEFAULT_TCMAP        0x1
70c1d14583SBruce Richardson #define ICE_FDIR_QUEUE_ID        0
71c1d14583SBruce Richardson 
72c1d14583SBruce Richardson /* Always assign pool 0 to main VSI, VMDQ will start from 1 */
73c1d14583SBruce Richardson #define ICE_VMDQ_POOL_BASE       1
74c1d14583SBruce Richardson 
75c1d14583SBruce Richardson #define ICE_DEFAULT_RX_FREE_THRESH  32
76c1d14583SBruce Richardson #define ICE_DEFAULT_RX_PTHRESH      8
77c1d14583SBruce Richardson #define ICE_DEFAULT_RX_HTHRESH      8
78c1d14583SBruce Richardson #define ICE_DEFAULT_RX_WTHRESH      0
79c1d14583SBruce Richardson 
80c1d14583SBruce Richardson #define ICE_DEFAULT_TX_FREE_THRESH  32
81c1d14583SBruce Richardson #define ICE_DEFAULT_TX_PTHRESH      32
82c1d14583SBruce Richardson #define ICE_DEFAULT_TX_HTHRESH      0
83c1d14583SBruce Richardson #define ICE_DEFAULT_TX_WTHRESH      0
84c1d14583SBruce Richardson #define ICE_DEFAULT_TX_RSBIT_THRESH 32
85c1d14583SBruce Richardson 
86c1d14583SBruce Richardson /* Bit shift and mask */
87c1d14583SBruce Richardson #define ICE_4_BIT_WIDTH  (CHAR_BIT / 2)
88c1d14583SBruce Richardson #define ICE_4_BIT_MASK   RTE_LEN2MASK(ICE_4_BIT_WIDTH, uint8_t)
89c1d14583SBruce Richardson #define ICE_8_BIT_WIDTH  CHAR_BIT
90c1d14583SBruce Richardson #define ICE_8_BIT_MASK   UINT8_MAX
91c1d14583SBruce Richardson #define ICE_16_BIT_WIDTH (CHAR_BIT * 2)
92c1d14583SBruce Richardson #define ICE_16_BIT_MASK  UINT16_MAX
93c1d14583SBruce Richardson #define ICE_32_BIT_WIDTH (CHAR_BIT * 4)
94c1d14583SBruce Richardson #define ICE_32_BIT_MASK  UINT32_MAX
95c1d14583SBruce Richardson #define ICE_40_BIT_WIDTH (CHAR_BIT * 5)
96c1d14583SBruce Richardson #define ICE_40_BIT_MASK  RTE_LEN2MASK(ICE_40_BIT_WIDTH, uint64_t)
97c1d14583SBruce Richardson #define ICE_48_BIT_WIDTH (CHAR_BIT * 6)
98c1d14583SBruce Richardson #define ICE_48_BIT_MASK  RTE_LEN2MASK(ICE_48_BIT_WIDTH, uint64_t)
99c1d14583SBruce Richardson 
100c1d14583SBruce Richardson #define ICE_FLAG_RSS                   BIT_ULL(0)
101c1d14583SBruce Richardson #define ICE_FLAG_DCB                   BIT_ULL(1)
102c1d14583SBruce Richardson #define ICE_FLAG_VMDQ                  BIT_ULL(2)
103c1d14583SBruce Richardson #define ICE_FLAG_SRIOV                 BIT_ULL(3)
104c1d14583SBruce Richardson #define ICE_FLAG_HEADER_SPLIT_DISABLED BIT_ULL(4)
105c1d14583SBruce Richardson #define ICE_FLAG_HEADER_SPLIT_ENABLED  BIT_ULL(5)
106c1d14583SBruce Richardson #define ICE_FLAG_FDIR                  BIT_ULL(6)
107c1d14583SBruce Richardson #define ICE_FLAG_VXLAN                 BIT_ULL(7)
108c1d14583SBruce Richardson #define ICE_FLAG_RSS_AQ_CAPABLE        BIT_ULL(8)
109c1d14583SBruce Richardson #define ICE_FLAG_VF_MAC_BY_PF          BIT_ULL(9)
110c1d14583SBruce Richardson #define ICE_FLAG_ALL  (ICE_FLAG_RSS | \
111c1d14583SBruce Richardson 		       ICE_FLAG_DCB | \
112c1d14583SBruce Richardson 		       ICE_FLAG_VMDQ | \
113c1d14583SBruce Richardson 		       ICE_FLAG_SRIOV | \
114c1d14583SBruce Richardson 		       ICE_FLAG_HEADER_SPLIT_DISABLED | \
115c1d14583SBruce Richardson 		       ICE_FLAG_HEADER_SPLIT_ENABLED | \
116c1d14583SBruce Richardson 		       ICE_FLAG_FDIR | \
117c1d14583SBruce Richardson 		       ICE_FLAG_VXLAN | \
118c1d14583SBruce Richardson 		       ICE_FLAG_RSS_AQ_CAPABLE | \
119c1d14583SBruce Richardson 		       ICE_FLAG_VF_MAC_BY_PF)
120c1d14583SBruce Richardson 
121c1d14583SBruce Richardson #define ICE_RSS_OFFLOAD_ALL ( \
122c1d14583SBruce Richardson 	RTE_ETH_RSS_IPV4 | \
123c1d14583SBruce Richardson 	RTE_ETH_RSS_FRAG_IPV4 | \
124c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV4_TCP | \
125c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
126c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV4_SCTP | \
127c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \
128c1d14583SBruce Richardson 	RTE_ETH_RSS_IPV6 | \
129c1d14583SBruce Richardson 	RTE_ETH_RSS_FRAG_IPV6 | \
130c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
131c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV6_UDP | \
132c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV6_SCTP | \
133c1d14583SBruce Richardson 	RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \
134c1d14583SBruce Richardson 	RTE_ETH_RSS_L2_PAYLOAD)
135c1d14583SBruce Richardson 
136c1d14583SBruce Richardson /**
137c1d14583SBruce Richardson  * The overhead from MTU to max frame size.
138c1d14583SBruce Richardson  * Considering QinQ packet, the VLAN tag needs to be counted twice.
139c1d14583SBruce Richardson  */
140c1d14583SBruce Richardson #define ICE_ETH_OVERHEAD \
141c1d14583SBruce Richardson 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2)
142c1d14583SBruce Richardson #define ICE_ETH_MAX_LEN (RTE_ETHER_MTU + ICE_ETH_OVERHEAD)
143c1d14583SBruce Richardson 
144c1d14583SBruce Richardson #define ICE_RXTX_BYTES_HIGH(bytes) ((bytes) & ~ICE_40_BIT_MASK)
145c1d14583SBruce Richardson #define ICE_RXTX_BYTES_LOW(bytes) ((bytes) & ICE_40_BIT_MASK)
146c1d14583SBruce Richardson 
147c1d14583SBruce Richardson /* Max number of flexible descriptor rxdid */
148c1d14583SBruce Richardson #define ICE_FLEX_DESC_RXDID_MAX_NUM 64
149c1d14583SBruce Richardson 
150c1d14583SBruce Richardson #define ICE_I2C_EEPROM_DEV_ADDR		0xA0
151c1d14583SBruce Richardson #define ICE_I2C_EEPROM_DEV_ADDR2	0xA2
152c1d14583SBruce Richardson #define ICE_MODULE_TYPE_SFP		0x03
153c1d14583SBruce Richardson #define ICE_MODULE_TYPE_QSFP_PLUS	0x0D
154c1d14583SBruce Richardson #define ICE_MODULE_TYPE_QSFP28		0x11
155c1d14583SBruce Richardson #define ICE_MODULE_SFF_ADDR_MODE	0x04
156c1d14583SBruce Richardson #define ICE_MODULE_SFF_DIAG_CAPAB	0x40
157c1d14583SBruce Richardson #define ICE_MODULE_REVISION_ADDR	0x01
158c1d14583SBruce Richardson #define ICE_MODULE_SFF_8472_COMP	0x5E
159c1d14583SBruce Richardson #define ICE_MODULE_SFF_8472_SWAP	0x5C
160c1d14583SBruce Richardson #define ICE_MODULE_QSFP_MAX_LEN		640
161c1d14583SBruce Richardson 
162c1d14583SBruce Richardson /* EEPROM Standards for plug in modules */
163c1d14583SBruce Richardson #define ICE_MODULE_SFF_8079		0x1
164c1d14583SBruce Richardson #define ICE_MODULE_SFF_8079_LEN		256
165c1d14583SBruce Richardson #define ICE_MODULE_SFF_8472		0x2
166c1d14583SBruce Richardson #define ICE_MODULE_SFF_8472_LEN		512
167c1d14583SBruce Richardson #define ICE_MODULE_SFF_8636		0x3
168c1d14583SBruce Richardson #define ICE_MODULE_SFF_8636_LEN		256
169c1d14583SBruce Richardson #define ICE_MODULE_SFF_8636_MAX_LEN     640
170c1d14583SBruce Richardson #define ICE_MODULE_SFF_8436		0x4
171c1d14583SBruce Richardson #define ICE_MODULE_SFF_8436_LEN		256
172c1d14583SBruce Richardson #define ICE_MODULE_SFF_8436_MAX_LEN     640
173c1d14583SBruce Richardson 
174c1d14583SBruce Richardson 
175c1d14583SBruce Richardson /* Per-channel register definitions */
176c1d14583SBruce Richardson #define GLTSYN_AUX_OUT(_chan, _idx)     (GLTSYN_AUX_OUT_0(_idx) + ((_chan) * 8))
177c1d14583SBruce Richardson #define GLTSYN_CLKO(_chan, _idx)        (GLTSYN_CLKO_0(_idx) + ((_chan) * 8))
178c1d14583SBruce Richardson #define GLTSYN_TGT_L(_chan, _idx)       (GLTSYN_TGT_L_0(_idx) + ((_chan) * 16))
179c1d14583SBruce Richardson #define GLTSYN_TGT_H(_chan, _idx)       (GLTSYN_TGT_H_0(_idx) + ((_chan) * 16))
180c1d14583SBruce Richardson 
181c1d14583SBruce Richardson /* DDP package type */
182c1d14583SBruce Richardson enum ice_pkg_type {
183c1d14583SBruce Richardson 	ICE_PKG_TYPE_UNKNOWN,
184c1d14583SBruce Richardson 	ICE_PKG_TYPE_OS_DEFAULT,
185c1d14583SBruce Richardson 	ICE_PKG_TYPE_COMMS,
186c1d14583SBruce Richardson };
187c1d14583SBruce Richardson 
188c1d14583SBruce Richardson enum pps_type {
189c1d14583SBruce Richardson 	PPS_NONE,
190c1d14583SBruce Richardson 	PPS_PIN,
191c1d14583SBruce Richardson 	PPS_MAX,
192c1d14583SBruce Richardson };
193c1d14583SBruce Richardson 
194c1d14583SBruce Richardson struct ice_adapter;
195c1d14583SBruce Richardson 
196c1d14583SBruce Richardson /**
197c1d14583SBruce Richardson  * MAC filter structure
198c1d14583SBruce Richardson  */
199c1d14583SBruce Richardson struct ice_mac_filter_info {
200c1d14583SBruce Richardson 	struct rte_ether_addr mac_addr;
201c1d14583SBruce Richardson };
202c1d14583SBruce Richardson 
203c1d14583SBruce Richardson TAILQ_HEAD(ice_mac_filter_list, ice_mac_filter);
204c1d14583SBruce Richardson 
205c1d14583SBruce Richardson /* MAC filter list structure */
206c1d14583SBruce Richardson struct ice_mac_filter {
207c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_mac_filter) next;
208c1d14583SBruce Richardson 	struct ice_mac_filter_info mac_info;
209c1d14583SBruce Richardson };
210c1d14583SBruce Richardson 
211c1d14583SBruce Richardson struct ice_vlan {
212c1d14583SBruce Richardson 	uint16_t tpid;
213c1d14583SBruce Richardson 	uint16_t vid;
214c1d14583SBruce Richardson };
215c1d14583SBruce Richardson 
216c1d14583SBruce Richardson #define ICE_VLAN(tpid, vid) \
217c1d14583SBruce Richardson 	((struct ice_vlan){ tpid, vid })
218c1d14583SBruce Richardson 
219c1d14583SBruce Richardson /**
220c1d14583SBruce Richardson  * VLAN filter structure
221c1d14583SBruce Richardson  */
222c1d14583SBruce Richardson struct ice_vlan_filter_info {
223c1d14583SBruce Richardson 	struct ice_vlan vlan;
224c1d14583SBruce Richardson };
225c1d14583SBruce Richardson 
226c1d14583SBruce Richardson TAILQ_HEAD(ice_vlan_filter_list, ice_vlan_filter);
227c1d14583SBruce Richardson 
228c1d14583SBruce Richardson /* VLAN filter list structure */
229c1d14583SBruce Richardson struct ice_vlan_filter {
230c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_vlan_filter) next;
231c1d14583SBruce Richardson 	struct ice_vlan_filter_info vlan_info;
232c1d14583SBruce Richardson };
233c1d14583SBruce Richardson 
234c1d14583SBruce Richardson struct pool_entry {
235c1d14583SBruce Richardson 	LIST_ENTRY(pool_entry) next;
236c1d14583SBruce Richardson 	uint16_t base;
237c1d14583SBruce Richardson 	uint16_t len;
238c1d14583SBruce Richardson };
239c1d14583SBruce Richardson 
240c1d14583SBruce Richardson LIST_HEAD(res_list, pool_entry);
241c1d14583SBruce Richardson 
242c1d14583SBruce Richardson struct ice_res_pool_info {
243c1d14583SBruce Richardson 	uint32_t base;              /* Resource start index */
244c1d14583SBruce Richardson 	uint32_t num_alloc;         /* Allocated resource number */
245c1d14583SBruce Richardson 	uint32_t num_free;          /* Total available resource number */
246c1d14583SBruce Richardson 	struct res_list alloc_list; /* Allocated resource list */
247c1d14583SBruce Richardson 	struct res_list free_list;  /* Available resource list */
248c1d14583SBruce Richardson };
249c1d14583SBruce Richardson 
250c1d14583SBruce Richardson TAILQ_HEAD(ice_vsi_list_head, ice_vsi_list);
251c1d14583SBruce Richardson 
252c1d14583SBruce Richardson struct ice_vsi;
253c1d14583SBruce Richardson 
254c1d14583SBruce Richardson /* VSI list structure */
255c1d14583SBruce Richardson struct ice_vsi_list {
256c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_vsi_list) list;
257c1d14583SBruce Richardson 	struct ice_vsi *vsi;
258c1d14583SBruce Richardson };
259c1d14583SBruce Richardson 
260c1d14583SBruce Richardson struct ice_rx_queue;
261c038157aSBruce Richardson struct ci_tx_queue;
262c1d14583SBruce Richardson 
263c1d14583SBruce Richardson /**
264c1d14583SBruce Richardson  * Structure that defines a VSI, associated with a adapter.
265c1d14583SBruce Richardson  */
266c1d14583SBruce Richardson struct ice_vsi {
267c1d14583SBruce Richardson 	struct ice_adapter *adapter; /* Backreference to associated adapter */
268c1d14583SBruce Richardson 	struct ice_aqc_vsi_props info; /* VSI properties */
269c1d14583SBruce Richardson 	/**
270c1d14583SBruce Richardson 	 * When drivers loaded, only a default main VSI exists. In case new VSI
271c1d14583SBruce Richardson 	 * needs to add, HW needs to know the layout that VSIs are organized.
272c1d14583SBruce Richardson 	 * Besides that, VSI isan element and can't switch packets, which needs
273c1d14583SBruce Richardson 	 * to add new component VEB to perform switching. So, a new VSI needs
274c1d14583SBruce Richardson 	 * to specify the uplink VSI (Parent VSI) before created. The
275c1d14583SBruce Richardson 	 * uplink VSI will check whether it had a VEB to switch packets. If no,
276c1d14583SBruce Richardson 	 * it will try to create one. Then, uplink VSI will move the new VSI
277c1d14583SBruce Richardson 	 * into its' sib_vsi_list to manage all the downlink VSI.
278c1d14583SBruce Richardson 	 *  sib_vsi_list: the VSI list that shared the same uplink VSI.
279c1d14583SBruce Richardson 	 *  parent_vsi  : the uplink VSI. It's NULL for main VSI.
280c1d14583SBruce Richardson 	 *  veb         : the VEB associates with the VSI.
281c1d14583SBruce Richardson 	 */
282c1d14583SBruce Richardson 	struct ice_vsi_list sib_vsi_list; /* sibling vsi list */
283c1d14583SBruce Richardson 	struct ice_vsi *parent_vsi;
284c1d14583SBruce Richardson 	enum ice_vsi_type type; /* VSI types */
285c1d14583SBruce Richardson 	uint16_t vlan_num;       /* Total VLAN number */
286c1d14583SBruce Richardson 	uint16_t mac_num;        /* Total mac number */
287c1d14583SBruce Richardson 	struct ice_mac_filter_list mac_list; /* macvlan filter list */
288c1d14583SBruce Richardson 	struct ice_vlan_filter_list vlan_list; /* vlan filter list */
289c1d14583SBruce Richardson 	uint16_t nb_qps;         /* Number of queue pairs VSI can occupy */
290c1d14583SBruce Richardson 	uint16_t nb_used_qps;    /* Number of queue pairs VSI uses */
291c1d14583SBruce Richardson 	uint16_t max_macaddrs;   /* Maximum number of MAC addresses */
292c1d14583SBruce Richardson 	uint16_t base_queue;     /* The first queue index of this VSI */
293c1d14583SBruce Richardson 	uint16_t vsi_id;         /* Hardware Id */
294c1d14583SBruce Richardson 	uint16_t idx;            /* vsi_handle: SW index in hw->vsi_ctx */
295c1d14583SBruce Richardson 	/* VF number to which the VSI connects, valid when VSI is VF type */
296c1d14583SBruce Richardson 	uint8_t vf_num;
297c1d14583SBruce Richardson 	uint16_t msix_intr; /* The MSIX interrupt binds to VSI */
298c1d14583SBruce Richardson 	uint16_t nb_msix;   /* The max number of msix vector */
299c1d14583SBruce Richardson 	uint8_t enabled_tc; /* The traffic class enabled */
300c1d14583SBruce Richardson 	uint8_t vlan_anti_spoof_on; /* The VLAN anti-spoofing enabled */
301c1d14583SBruce Richardson 	uint8_t vlan_filter_on; /* The VLAN filter enabled */
302c1d14583SBruce Richardson 	/* information about rss configuration */
303c1d14583SBruce Richardson 	u32 rss_key_size;
304c1d14583SBruce Richardson 	u32 rss_lut_size;
305c1d14583SBruce Richardson 	uint8_t *rss_lut;
306c1d14583SBruce Richardson 	uint8_t *rss_key;
307c1d14583SBruce Richardson 	struct ice_eth_stats eth_stats_offset;
308c1d14583SBruce Richardson 	struct ice_eth_stats eth_stats;
309c1d14583SBruce Richardson 	bool offset_loaded;
310c1d14583SBruce Richardson 	uint64_t old_rx_bytes;
311c1d14583SBruce Richardson 	uint64_t old_tx_bytes;
312c1d14583SBruce Richardson };
313c1d14583SBruce Richardson 
314c1d14583SBruce Richardson enum proto_xtr_type {
315c1d14583SBruce Richardson 	PROTO_XTR_NONE,
316c1d14583SBruce Richardson 	PROTO_XTR_VLAN,
317c1d14583SBruce Richardson 	PROTO_XTR_IPV4,
318c1d14583SBruce Richardson 	PROTO_XTR_IPV6,
319c1d14583SBruce Richardson 	PROTO_XTR_IPV6_FLOW,
320c1d14583SBruce Richardson 	PROTO_XTR_TCP,
321c1d14583SBruce Richardson 	PROTO_XTR_IP_OFFSET,
322c1d14583SBruce Richardson 	PROTO_XTR_MAX /* The last one */
323c1d14583SBruce Richardson };
324c1d14583SBruce Richardson 
325c1d14583SBruce Richardson enum ice_fdir_tunnel_type {
326c1d14583SBruce Richardson 	ICE_FDIR_TUNNEL_TYPE_NONE = 0,
327c1d14583SBruce Richardson 	ICE_FDIR_TUNNEL_TYPE_VXLAN,
328c1d14583SBruce Richardson 	ICE_FDIR_TUNNEL_TYPE_GTPU,
329c1d14583SBruce Richardson 	ICE_FDIR_TUNNEL_TYPE_GTPU_EH,
330c1d14583SBruce Richardson };
331c1d14583SBruce Richardson 
332c1d14583SBruce Richardson struct rte_flow;
333c1d14583SBruce Richardson TAILQ_HEAD(ice_flow_list, rte_flow);
334c1d14583SBruce Richardson 
335c1d14583SBruce Richardson struct ice_flow_parser_node;
336c1d14583SBruce Richardson TAILQ_HEAD(ice_parser_list, ice_flow_parser_node);
337c1d14583SBruce Richardson 
338c1d14583SBruce Richardson struct ice_fdir_filter_conf {
339c1d14583SBruce Richardson 	struct ice_fdir_fltr input;
340c1d14583SBruce Richardson 	enum ice_fdir_tunnel_type tunnel_type;
341c1d14583SBruce Richardson 
342c1d14583SBruce Richardson 	struct ice_fdir_counter *counter; /* flow specific counter context */
343c1d14583SBruce Richardson 	struct rte_flow_action_count act_count;
344c1d14583SBruce Richardson 
345c1d14583SBruce Richardson 	uint64_t input_set_o; /* used for non-tunnel or tunnel outer fields */
346c1d14583SBruce Richardson 	uint64_t input_set_i; /* only for tunnel inner fields */
347c1d14583SBruce Richardson 	uint32_t mark_flag;
348c1d14583SBruce Richardson 
349c1d14583SBruce Richardson 	struct ice_parser_profile *prof;
350c1d14583SBruce Richardson 	bool parser_ena;
351c1d14583SBruce Richardson 	u8 *pkt_buf;
352c1d14583SBruce Richardson 	u8 pkt_len;
353c1d14583SBruce Richardson };
354c1d14583SBruce Richardson 
355c1d14583SBruce Richardson struct ice_fdir_fltr_pattern {
356c1d14583SBruce Richardson 	enum ice_fltr_ptype flow_type;
357c1d14583SBruce Richardson 
358c1d14583SBruce Richardson 	union {
359c1d14583SBruce Richardson 		struct ice_fdir_v4 v4;
360c1d14583SBruce Richardson 		struct ice_fdir_v6 v6;
361c1d14583SBruce Richardson 	} ip, mask;
362c1d14583SBruce Richardson 
363c1d14583SBruce Richardson 	struct ice_fdir_udp_gtp gtpu_data;
364c1d14583SBruce Richardson 	struct ice_fdir_udp_gtp gtpu_mask;
365c1d14583SBruce Richardson 
366c1d14583SBruce Richardson 	struct ice_fdir_extra ext_data;
367c1d14583SBruce Richardson 	struct ice_fdir_extra ext_mask;
368c1d14583SBruce Richardson 
369c1d14583SBruce Richardson 	enum ice_fdir_tunnel_type tunnel_type;
370c1d14583SBruce Richardson };
371c1d14583SBruce Richardson 
372c1d14583SBruce Richardson #define ICE_FDIR_COUNTER_DEFAULT_POOL_SIZE	1
373c1d14583SBruce Richardson #define ICE_FDIR_COUNTER_MAX_POOL_SIZE		32
374c1d14583SBruce Richardson #define ICE_FDIR_COUNTERS_PER_BLOCK		256
375c1d14583SBruce Richardson #define ICE_FDIR_COUNTER_INDEX(base_idx) \
376c1d14583SBruce Richardson 				((base_idx) * ICE_FDIR_COUNTERS_PER_BLOCK)
377c1d14583SBruce Richardson struct ice_fdir_counter_pool;
378c1d14583SBruce Richardson 
379c1d14583SBruce Richardson struct ice_fdir_counter {
380c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_fdir_counter) next;
381c1d14583SBruce Richardson 	struct ice_fdir_counter_pool *pool;
382c1d14583SBruce Richardson 	uint8_t shared;
383c1d14583SBruce Richardson 	uint32_t ref_cnt;
384c1d14583SBruce Richardson 	uint32_t id;
385c1d14583SBruce Richardson 	uint64_t hits;
386c1d14583SBruce Richardson 	uint64_t bytes;
387c1d14583SBruce Richardson 	uint32_t hw_index;
388c1d14583SBruce Richardson };
389c1d14583SBruce Richardson 
390c1d14583SBruce Richardson TAILQ_HEAD(ice_fdir_counter_list, ice_fdir_counter);
391c1d14583SBruce Richardson 
392c1d14583SBruce Richardson struct ice_fdir_counter_pool {
393c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_fdir_counter_pool) next;
394c1d14583SBruce Richardson 	struct ice_fdir_counter_list counter_list;
395c1d14583SBruce Richardson 	struct ice_fdir_counter counters[0];
396c1d14583SBruce Richardson };
397c1d14583SBruce Richardson 
398c1d14583SBruce Richardson TAILQ_HEAD(ice_fdir_counter_pool_list, ice_fdir_counter_pool);
399c1d14583SBruce Richardson 
400c1d14583SBruce Richardson struct ice_fdir_counter_pool_container {
401c1d14583SBruce Richardson 	struct ice_fdir_counter_pool_list pool_list;
402c1d14583SBruce Richardson 	struct ice_fdir_counter_pool *pools[ICE_FDIR_COUNTER_MAX_POOL_SIZE];
403c1d14583SBruce Richardson 	uint8_t index_free;
404c1d14583SBruce Richardson };
405c1d14583SBruce Richardson 
406c1d14583SBruce Richardson /**
407c1d14583SBruce Richardson  *  A structure used to define fields of a FDIR related info.
408c1d14583SBruce Richardson  */
409c1d14583SBruce Richardson struct ice_fdir_info {
410c1d14583SBruce Richardson 	struct ice_vsi *fdir_vsi;     /* pointer to fdir VSI structure */
411c038157aSBruce Richardson 	struct ci_tx_queue *txq;
412c1d14583SBruce Richardson 	struct ice_rx_queue *rxq;
413c1d14583SBruce Richardson 	void *prg_pkt;                 /* memory for fdir program packet */
414c1d14583SBruce Richardson 	uint64_t dma_addr;             /* physic address of packet memory*/
415c1d14583SBruce Richardson 	const struct rte_memzone *mz;
416c1d14583SBruce Richardson 	struct ice_fdir_filter_conf conf;
417c1d14583SBruce Richardson 
418c1d14583SBruce Richardson 	struct ice_fdir_filter_conf **hash_map;
419c1d14583SBruce Richardson 	struct rte_hash *hash_table;
420c1d14583SBruce Richardson 
421c1d14583SBruce Richardson 	struct ice_fdir_counter_pool_container counter;
422c1d14583SBruce Richardson };
423c1d14583SBruce Richardson 
424c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_EH_IP		0
425c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_EH_IP_UDP	1
426c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_EH_IP_TCP	2
427c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_UP_IP		3
428c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_UP_IP_UDP	4
429c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_UP_IP_TCP	5
430c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_DW_IP		6
431c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_DW_IP_UDP	7
432c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_DW_IP_TCP	8
433c1d14583SBruce Richardson #define ICE_HASH_GTPU_CTX_MAX		9
434c1d14583SBruce Richardson 
435c1d14583SBruce Richardson struct ice_hash_gtpu_ctx {
436c1d14583SBruce Richardson 	struct ice_rss_hash_cfg ctx[ICE_HASH_GTPU_CTX_MAX];
437c1d14583SBruce Richardson };
438c1d14583SBruce Richardson 
439c1d14583SBruce Richardson struct ice_hash_ctx {
440c1d14583SBruce Richardson 	struct ice_hash_gtpu_ctx gtpu4;
441c1d14583SBruce Richardson 	struct ice_hash_gtpu_ctx gtpu6;
442c1d14583SBruce Richardson };
443c1d14583SBruce Richardson 
444c1d14583SBruce Richardson struct ice_acl_conf {
445c1d14583SBruce Richardson 	struct ice_fdir_fltr input;
446c1d14583SBruce Richardson 	uint64_t input_set;
447c1d14583SBruce Richardson };
448c1d14583SBruce Richardson 
449c1d14583SBruce Richardson /**
450c1d14583SBruce Richardson  * A structure used to define fields of ACL related info.
451c1d14583SBruce Richardson  */
452c1d14583SBruce Richardson struct ice_acl_info {
453c1d14583SBruce Richardson 	struct ice_acl_conf conf;
454c1d14583SBruce Richardson 	struct rte_bitmap *slots;
455c1d14583SBruce Richardson 	uint64_t hw_entry_id[MAX_ACL_NORMAL_ENTRIES];
456c1d14583SBruce Richardson };
457c1d14583SBruce Richardson 
458c1d14583SBruce Richardson TAILQ_HEAD(ice_shaper_profile_list, ice_tm_shaper_profile);
459c1d14583SBruce Richardson TAILQ_HEAD(ice_tm_node_list, ice_tm_node);
460c1d14583SBruce Richardson 
461c1d14583SBruce Richardson #define ICE_TM_MAX_LAYERS ICE_SCHED_9_LAYERS
462c1d14583SBruce Richardson 
463c1d14583SBruce Richardson struct ice_tm_shaper_profile {
464c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_tm_shaper_profile) node;
465c1d14583SBruce Richardson 	uint32_t shaper_profile_id;
466c1d14583SBruce Richardson 	uint32_t reference_count;
467c1d14583SBruce Richardson 	struct rte_tm_shaper_params profile;
468c1d14583SBruce Richardson };
469c1d14583SBruce Richardson 
470c1d14583SBruce Richardson /* Struct to store Traffic Manager node configuration. */
471c1d14583SBruce Richardson struct ice_tm_node {
472c1d14583SBruce Richardson 	TAILQ_ENTRY(ice_tm_node) node;
473c1d14583SBruce Richardson 	uint32_t id;
474c1d14583SBruce Richardson 	uint32_t priority;
475c1d14583SBruce Richardson 	uint32_t weight;
476c1d14583SBruce Richardson 	uint32_t level;
477c1d14583SBruce Richardson 	uint32_t reference_count;
478c1d14583SBruce Richardson 	struct ice_tm_node *parent;
479c1d14583SBruce Richardson 	struct ice_tm_node **children;
480c1d14583SBruce Richardson 	struct ice_tm_shaper_profile *shaper_profile;
481c1d14583SBruce Richardson 	struct rte_tm_node_params params;
482c1d14583SBruce Richardson 	struct ice_sched_node *sched_node;
483c1d14583SBruce Richardson };
484c1d14583SBruce Richardson 
485c1d14583SBruce Richardson /* Struct to store all the Traffic Manager configuration. */
486c1d14583SBruce Richardson struct ice_tm_conf {
487c1d14583SBruce Richardson 	struct ice_shaper_profile_list shaper_profile_list;
488c1d14583SBruce Richardson 	struct ice_tm_node *root; /* root node - port */
489c1d14583SBruce Richardson 	uint8_t hidden_layers;    /* the number of hierarchy layers hidden from app */
490c1d14583SBruce Richardson 	bool committed;
491c1d14583SBruce Richardson 	bool clear_on_fail;
492c1d14583SBruce Richardson };
493c1d14583SBruce Richardson 
494c1d14583SBruce Richardson struct ice_mbuf_stats {
495c1d14583SBruce Richardson 	uint64_t tx_pkt_errors;
496c1d14583SBruce Richardson };
497c1d14583SBruce Richardson 
498c1d14583SBruce Richardson struct ice_pf {
499c1d14583SBruce Richardson 	struct ice_adapter *adapter; /* The adapter this PF associate to */
500c1d14583SBruce Richardson 	struct ice_vsi *main_vsi; /* pointer to main VSI structure */
501c1d14583SBruce Richardson 	/* Used for next free software vsi idx.
502c1d14583SBruce Richardson 	 * To save the effort, we don't recycle the index.
503c1d14583SBruce Richardson 	 * Suppose the indexes are more than enough.
504c1d14583SBruce Richardson 	 */
505c1d14583SBruce Richardson 	uint16_t next_vsi_idx;
506c1d14583SBruce Richardson 	uint16_t vsis_allocated;
507c1d14583SBruce Richardson 	uint16_t vsis_unallocated;
508c1d14583SBruce Richardson 	struct ice_res_pool_info qp_pool;    /*Queue pair pool */
509c1d14583SBruce Richardson 	struct ice_res_pool_info msix_pool;  /* MSIX interrupt pool */
510c1d14583SBruce Richardson 	struct rte_eth_dev_data *dev_data; /* Pointer to the device data */
511c1d14583SBruce Richardson 	struct rte_ether_addr dev_addr; /* PF device mac address */
512c1d14583SBruce Richardson 	uint64_t flags; /* PF feature flags */
513c1d14583SBruce Richardson 	uint16_t hash_lut_size; /* The size of hash lookup table */
514c1d14583SBruce Richardson 	uint16_t lan_nb_qp_max;
515c1d14583SBruce Richardson 	uint16_t lan_nb_qps; /* The number of queue pairs of LAN */
516c1d14583SBruce Richardson 	uint16_t base_queue; /* The base queue pairs index  in the device */
517c1d14583SBruce Richardson 	uint8_t *proto_xtr; /* Protocol extraction type for all queues */
518c1d14583SBruce Richardson 	uint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */
519c1d14583SBruce Richardson 	uint16_t fdir_qp_offset;
520c1d14583SBruce Richardson 	struct ice_fdir_info fdir; /* flow director info */
521c1d14583SBruce Richardson 	struct ice_acl_info acl; /* ACL info */
522c1d14583SBruce Richardson 	struct ice_hash_ctx hash_ctx;
523c1d14583SBruce Richardson 	uint16_t hw_prof_cnt[ICE_FLTR_PTYPE_MAX][ICE_FD_HW_SEG_MAX];
524c1d14583SBruce Richardson 	uint16_t fdir_fltr_cnt[ICE_FLTR_PTYPE_MAX][ICE_FD_HW_SEG_MAX];
525c1d14583SBruce Richardson 	struct ice_hw_port_stats stats_offset;
526c1d14583SBruce Richardson 	struct ice_hw_port_stats stats;
527c1d14583SBruce Richardson 	struct ice_mbuf_stats mbuf_stats;
528c1d14583SBruce Richardson 	/* internal packet statistics, it should be excluded from the total */
529c1d14583SBruce Richardson 	struct ice_eth_stats internal_stats_offset;
530c1d14583SBruce Richardson 	struct ice_eth_stats internal_stats;
531c1d14583SBruce Richardson 	bool offset_loaded;
532c1d14583SBruce Richardson 	bool adapter_stopped;
533c1d14583SBruce Richardson 	struct ice_flow_list flow_list;
534c1d14583SBruce Richardson 	rte_spinlock_t flow_ops_lock;
535c1d14583SBruce Richardson 	bool init_link_up;
536c1d14583SBruce Richardson 	uint64_t old_rx_bytes;
537c1d14583SBruce Richardson 	uint64_t old_tx_bytes;
538c1d14583SBruce Richardson 	uint64_t supported_rxdid; /* bitmap for supported RXDID */
539c1d14583SBruce Richardson 	uint64_t rss_hf;
540c1d14583SBruce Richardson 	struct ice_tm_conf tm_conf;
541c1d14583SBruce Richardson 	uint16_t outer_ethertype;
542c1d14583SBruce Richardson 	/* lock prevent race condition between lsc interrupt handler
543c1d14583SBruce Richardson 	 * and link status update during dev_start.
544c1d14583SBruce Richardson 	 */
545c1d14583SBruce Richardson 	rte_spinlock_t link_lock;
546c1d14583SBruce Richardson };
547c1d14583SBruce Richardson 
548c1d14583SBruce Richardson #define ICE_MAX_QUEUE_NUM  2048
549c1d14583SBruce Richardson #define ICE_MAX_PIN_NUM   4
550c1d14583SBruce Richardson 
551c1d14583SBruce Richardson /**
552c1d14583SBruce Richardson  * Cache devargs parse result.
553c1d14583SBruce Richardson  */
554c1d14583SBruce Richardson struct ice_devargs {
555c1d14583SBruce Richardson 	int rx_low_latency;
556c1d14583SBruce Richardson 	int safe_mode_support;
557c1d14583SBruce Richardson 	uint8_t proto_xtr_dflt;
558c1d14583SBruce Richardson 	uint8_t default_mac_disable;
559c1d14583SBruce Richardson 	uint8_t proto_xtr[ICE_MAX_QUEUE_NUM];
560c1d14583SBruce Richardson 	uint8_t pin_idx;
561c1d14583SBruce Richardson 	uint8_t pps_out_ena;
562c1d14583SBruce Richardson 	uint8_t ddp_load_sched;
563c1d14583SBruce Richardson 	uint8_t tm_exposed_levels;
564c1d14583SBruce Richardson 	int xtr_field_offs;
565c1d14583SBruce Richardson 	uint8_t xtr_flag_offs[PROTO_XTR_MAX];
566c1d14583SBruce Richardson 	/* Name of the field. */
567c1d14583SBruce Richardson 	char xtr_field_name[RTE_MBUF_DYN_NAMESIZE];
568c1d14583SBruce Richardson 	uint64_t mbuf_check;
569c1d14583SBruce Richardson 	const char *ddp_filename;
570c1d14583SBruce Richardson };
571c1d14583SBruce Richardson 
572c1d14583SBruce Richardson /**
573c1d14583SBruce Richardson  * Structure to store fdir fv entry.
574c1d14583SBruce Richardson  */
575c1d14583SBruce Richardson struct ice_fdir_prof_info {
576c1d14583SBruce Richardson 	struct ice_parser_profile prof;
577c1d14583SBruce Richardson 	u64 fdir_actived_cnt;
578c1d14583SBruce Richardson };
579c1d14583SBruce Richardson 
580c1d14583SBruce Richardson /**
581c1d14583SBruce Richardson  * Structure to store rss fv entry.
582c1d14583SBruce Richardson  */
583c1d14583SBruce Richardson struct ice_rss_prof_info {
584c1d14583SBruce Richardson 	struct ice_parser_profile prof;
585c1d14583SBruce Richardson 	bool symm;
586c1d14583SBruce Richardson };
587c1d14583SBruce Richardson 
588c1d14583SBruce Richardson #define ICE_MBUF_CHECK_F_TX_MBUF        (1ULL << 0)
589c1d14583SBruce Richardson #define ICE_MBUF_CHECK_F_TX_SIZE        (1ULL << 1)
590c1d14583SBruce Richardson #define ICE_MBUF_CHECK_F_TX_SEGMENT     (1ULL << 2)
591c1d14583SBruce Richardson #define ICE_MBUF_CHECK_F_TX_OFFLOAD     (1ULL << 3)
592c1d14583SBruce Richardson 
593c1d14583SBruce Richardson /**
594c1d14583SBruce Richardson  * Structure to store private data for each PF/VF instance.
595c1d14583SBruce Richardson  */
596c1d14583SBruce Richardson struct ice_adapter {
597c1d14583SBruce Richardson 	/* Common for both PF and VF */
598c1d14583SBruce Richardson 	struct ice_hw hw;
599c1d14583SBruce Richardson 	struct ice_pf pf;
600c1d14583SBruce Richardson 	bool rx_bulk_alloc_allowed;
601c1d14583SBruce Richardson 	bool rx_vec_allowed;
602c1d14583SBruce Richardson 	bool tx_vec_allowed;
603c1d14583SBruce Richardson 	bool tx_simple_allowed;
604c1d14583SBruce Richardson 	/* ptype mapping table */
605c1d14583SBruce Richardson 	alignas(RTE_CACHE_LINE_MIN_SIZE) uint32_t ptype_tbl[ICE_MAX_PKT_TYPE];
606c1d14583SBruce Richardson 	bool is_safe_mode;
607c1d14583SBruce Richardson 	struct ice_devargs devargs;
608c1d14583SBruce Richardson 	enum ice_pkg_type active_pkg_type; /* loaded ddp package type */
609c1d14583SBruce Richardson 	uint16_t fdir_ref_cnt;
610c1d14583SBruce Richardson 	/* For vector PMD */
611c1d14583SBruce Richardson 	eth_rx_burst_t tx_pkt_burst;
612c1d14583SBruce Richardson 	/* For PTP */
613c1d14583SBruce Richardson 	uint8_t ptp_tx_block;
614c1d14583SBruce Richardson 	uint8_t ptp_tx_index;
615c1d14583SBruce Richardson 	bool ptp_ena;
616c1d14583SBruce Richardson 	uint64_t time_hw;
617c1d14583SBruce Richardson 	struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];
618c1d14583SBruce Richardson 	struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];
619c1d14583SBruce Richardson 	/* True if DCF state of the associated PF is on */
620c1d14583SBruce Richardson 	RTE_ATOMIC(bool) dcf_state_on;
621c1d14583SBruce Richardson 	/* Set bit if the engine is disabled */
622c1d14583SBruce Richardson 	unsigned long disabled_engine_mask;
623c1d14583SBruce Richardson 	struct ice_parser *psr;
624*552979dfSBruce Richardson 	/* used only on X86, zero on other Archs */
625c1d14583SBruce Richardson 	bool rx_use_avx2;
626c1d14583SBruce Richardson 	bool rx_use_avx512;
627c1d14583SBruce Richardson 	bool tx_use_avx2;
628c1d14583SBruce Richardson 	bool tx_use_avx512;
629c1d14583SBruce Richardson 	bool rx_vec_offload_support;
630c1d14583SBruce Richardson };
631c1d14583SBruce Richardson 
632c1d14583SBruce Richardson struct ice_vsi_vlan_pvid_info {
633c1d14583SBruce Richardson 	uint16_t on;		/* Enable or disable pvid */
634c1d14583SBruce Richardson 	union {
635c1d14583SBruce Richardson 		uint16_t pvid;	/* Valid in case 'on' is set to set pvid */
636c1d14583SBruce Richardson 		struct {
637c1d14583SBruce Richardson 			/* Valid in case 'on' is cleared. 'tagged' will reject
638c1d14583SBruce Richardson 			 * tagged packets, while 'untagged' will reject
639c1d14583SBruce Richardson 			 * untagged packets.
640c1d14583SBruce Richardson 			 */
641c1d14583SBruce Richardson 			uint8_t tagged;
642c1d14583SBruce Richardson 			uint8_t untagged;
643c1d14583SBruce Richardson 		} reject;
644c1d14583SBruce Richardson 	} config;
645c1d14583SBruce Richardson };
646c1d14583SBruce Richardson 
647c1d14583SBruce Richardson #define ICE_DEV_TO_PCI(eth_dev) \
648c1d14583SBruce Richardson 	RTE_DEV_TO_PCI((eth_dev)->device)
649c1d14583SBruce Richardson 
650c1d14583SBruce Richardson /* ICE_DEV_PRIVATE_TO */
651c1d14583SBruce Richardson #define ICE_DEV_PRIVATE_TO_PF(adapter) \
652c1d14583SBruce Richardson 	(&((struct ice_adapter *)adapter)->pf)
653c1d14583SBruce Richardson #define ICE_DEV_PRIVATE_TO_HW(adapter) \
654c1d14583SBruce Richardson 	(&((struct ice_adapter *)adapter)->hw)
655c1d14583SBruce Richardson #define ICE_DEV_PRIVATE_TO_ADAPTER(adapter) \
656c1d14583SBruce Richardson 	((struct ice_adapter *)adapter)
657c1d14583SBruce Richardson 
658c1d14583SBruce Richardson /* ICE_VSI_TO */
659c1d14583SBruce Richardson #define ICE_VSI_TO_HW(vsi) \
660c1d14583SBruce Richardson 	(&(((struct ice_vsi *)vsi)->adapter->hw))
661c1d14583SBruce Richardson #define ICE_VSI_TO_PF(vsi) \
662c1d14583SBruce Richardson 	(&(((struct ice_vsi *)vsi)->adapter->pf))
663c1d14583SBruce Richardson 
664c1d14583SBruce Richardson /* ICE_PF_TO */
665c1d14583SBruce Richardson #define ICE_PF_TO_HW(pf) \
666c1d14583SBruce Richardson 	(&((pf)->adapter->hw))
667c1d14583SBruce Richardson #define ICE_PF_TO_ADAPTER(pf) \
668c1d14583SBruce Richardson 	((struct ice_adapter *)(pf)->adapter)
669c1d14583SBruce Richardson #define ICE_PF_TO_ETH_DEV(pf) \
670c1d14583SBruce Richardson 	(((struct ice_pf *)pf)->adapter->eth_dev)
671c1d14583SBruce Richardson 
672c1d14583SBruce Richardson bool is_ice_supported(struct rte_eth_dev *dev);
673c1d14583SBruce Richardson int
674c1d14583SBruce Richardson ice_load_pkg(struct ice_adapter *adapter, bool use_dsn, uint64_t dsn);
675c1d14583SBruce Richardson struct ice_vsi *
676c1d14583SBruce Richardson ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
677c1d14583SBruce Richardson int
678c1d14583SBruce Richardson ice_release_vsi(struct ice_vsi *vsi);
679c1d14583SBruce Richardson void ice_vsi_enable_queues_intr(struct ice_vsi *vsi);
680c1d14583SBruce Richardson void ice_vsi_disable_queues_intr(struct ice_vsi *vsi);
681c1d14583SBruce Richardson void ice_vsi_queues_bind_intr(struct ice_vsi *vsi);
682c1d14583SBruce Richardson int ice_add_rss_cfg_wrap(struct ice_pf *pf, uint16_t vsi_id,
683c1d14583SBruce Richardson 			 struct ice_rss_hash_cfg *cfg);
684c1d14583SBruce Richardson int ice_rem_rss_cfg_wrap(struct ice_pf *pf, uint16_t vsi_id,
685c1d14583SBruce Richardson 			 struct ice_rss_hash_cfg *cfg);
686c1d14583SBruce Richardson void ice_tm_conf_init(struct rte_eth_dev *dev);
687c1d14583SBruce Richardson void ice_tm_conf_uninit(struct rte_eth_dev *dev);
688c1d14583SBruce Richardson extern const struct rte_tm_ops ice_tm_ops;
689c1d14583SBruce Richardson 
690c1d14583SBruce Richardson static inline int
691c1d14583SBruce Richardson ice_align_floor(int n)
692c1d14583SBruce Richardson {
693c1d14583SBruce Richardson 	if (n == 0)
694c1d14583SBruce Richardson 		return 0;
695c1d14583SBruce Richardson 	return 1 << (sizeof(n) * CHAR_BIT - 1 - rte_clz32(n));
696c1d14583SBruce Richardson }
697c1d14583SBruce Richardson 
698c1d14583SBruce Richardson #define ICE_PHY_TYPE_SUPPORT_50G(phy_type) \
699c1d14583SBruce Richardson 	(((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_CR2) || \
700c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_SR2) || \
701c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_LR2) || \
702c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_KR2) || \
703c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_LAUI2_AOC_ACC) || \
704c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_LAUI2) || \
705c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_AUI2_AOC_ACC) || \
706c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_AUI2) || \
707c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_CP) || \
708c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_SR) || \
709c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_FR) || \
710c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_LR) || \
711c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4) || \
712c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC) || \
713c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_50G_AUI1))
714c1d14583SBruce Richardson 
715c1d14583SBruce Richardson #define ICE_PHY_TYPE_SUPPORT_100G_LOW(phy_type) \
716c1d14583SBruce Richardson 	(((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_CR4) || \
717c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_SR4) || \
718c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_LR4) || \
719c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_KR4) || \
720c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC) || \
721c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100G_CAUI4) || \
722c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC) || \
723c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100G_AUI4) || \
724c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4) || \
725c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4) || \
726c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_CP2) || \
727c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_SR2) || \
728c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_LOW_100GBASE_DR))
729c1d14583SBruce Richardson 
730c1d14583SBruce Richardson #define ICE_PHY_TYPE_SUPPORT_100G_HIGH(phy_type) \
731c1d14583SBruce Richardson 	(((phy_type) & ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4) || \
732c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC) || \
733c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_100G_CAUI2) || \
734c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC) || \
735c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_100G_AUI2))
736c1d14583SBruce Richardson 
737c1d14583SBruce Richardson #define ICE_PHY_TYPE_SUPPORT_200G_HIGH(phy_type) \
738c1d14583SBruce Richardson 	(((phy_type) & ICE_PHY_TYPE_HIGH_200G_CR4_PAM4) || \
739c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_SR4) || \
740c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_FR4) || \
741c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_LR4) || \
742c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_DR4) || \
743c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_KR4_PAM4) || \
744c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_AUI4_AOC_ACC) || \
745c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_AUI4) || \
746c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_AUI8_AOC_ACC) || \
747c1d14583SBruce Richardson 	((phy_type) & ICE_PHY_TYPE_HIGH_200G_AUI8))
748c1d14583SBruce Richardson 
749c1d14583SBruce Richardson __rte_experimental
750c1d14583SBruce Richardson int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
751c1d14583SBruce Richardson 
752c1d14583SBruce Richardson __rte_experimental
753c1d14583SBruce Richardson int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size);
754c1d14583SBruce Richardson 
755c1d14583SBruce Richardson __rte_experimental
756c1d14583SBruce Richardson int rte_pmd_ice_dump_txsched(uint16_t port, bool detail, FILE *stream);
757c1d14583SBruce Richardson 
758c1d14583SBruce Richardson int
759c1d14583SBruce Richardson ice_tm_setup_txq_node(struct ice_pf *pf, struct ice_hw *hw, uint16_t qid, uint32_t node_teid);
760c1d14583SBruce Richardson 
761c1d14583SBruce Richardson #endif /* _ICE_ETHDEV_H_ */
762