xref: /dpdk/drivers/net/mlx5/mlx5.h (revision 665b49c51639a10c553433bc2bcd85c7331c631e)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2015 6WIND S.A.
3  * Copyright 2015 Mellanox Technologies, Ltd
4  */
5 
6 #ifndef RTE_PMD_MLX5_H_
7 #define RTE_PMD_MLX5_H_
8 
9 #include <stddef.h>
10 #include <stdbool.h>
11 #include <stdint.h>
12 #include <limits.h>
13 #include <sys/queue.h>
14 
15 #include <rte_pci.h>
16 #include <rte_ether.h>
17 #include <ethdev_driver.h>
18 #include <rte_rwlock.h>
19 #include <rte_interrupts.h>
20 #include <rte_errno.h>
21 #include <rte_flow.h>
22 #include <rte_mtr.h>
23 
24 #include <mlx5_glue.h>
25 #include <mlx5_devx_cmds.h>
26 #include <mlx5_prm.h>
27 #include <mlx5_common_mp.h>
28 #include <mlx5_common_mr.h>
29 #include <mlx5_common_devx.h>
30 #include <mlx5_common_defs.h>
31 
32 #include "mlx5_defs.h"
33 #include "mlx5_utils.h"
34 #include "mlx5_os.h"
35 #include "mlx5_autoconf.h"
36 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
37 #ifndef RTE_EXEC_ENV_WINDOWS
38 #define HAVE_MLX5_HWS_SUPPORT 1
39 #else
40 #define __be64 uint64_t
41 #endif
42 #include "hws/mlx5dr.h"
43 #endif
44 
45 #define MLX5_SH(dev) (((struct mlx5_priv *)(dev)->data->dev_private)->sh)
46 
47 #define MLX5_HW_INV_QUEUE UINT32_MAX
48 
49 /*
50  * Number of modification commands.
51  * The maximal actions amount in FW is some constant, and it is 16 in the
52  * latest releases. In some old releases, it will be limited to 8.
53  * Since there is no interface to query the capacity, the maximal value should
54  * be used to allow PMD to create the flow. The validation will be done in the
55  * lower driver layer or FW. A failure will be returned if exceeds the maximal
56  * supported actions number on the root table.
57  * On non-root tables, there is no limitation, but 32 is enough right now.
58  */
59 #define MLX5_MAX_MODIFY_NUM			32
60 #define MLX5_ROOT_TBL_MODIFY_NUM		16
61 
62 /* Maximal number of flex items created on the port.*/
63 #define MLX5_PORT_FLEX_ITEM_NUM			4
64 
65 /* Maximal number of field/field parts to map into sample registers .*/
66 #define MLX5_FLEX_ITEM_MAPPING_NUM		32
67 
68 enum mlx5_ipool_index {
69 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
70 	MLX5_IPOOL_DECAP_ENCAP = 0, /* Pool for encap/decap resource. */
71 	MLX5_IPOOL_PUSH_VLAN, /* Pool for push vlan resource. */
72 	MLX5_IPOOL_TAG, /* Pool for tag resource. */
73 	MLX5_IPOOL_PORT_ID, /* Pool for port id resource. */
74 	MLX5_IPOOL_JUMP, /* Pool for SWS jump resource. */
75 	/* Pool for HWS group. Jump action will be created internally. */
76 	MLX5_IPOOL_HW_GRP = MLX5_IPOOL_JUMP,
77 	MLX5_IPOOL_SAMPLE, /* Pool for sample resource. */
78 	MLX5_IPOOL_DEST_ARRAY, /* Pool for destination array resource. */
79 	MLX5_IPOOL_TUNNEL_ID, /* Pool for tunnel offload context */
80 	MLX5_IPOOL_TNL_TBL_ID, /* Pool for tunnel table ID. */
81 #endif
82 	MLX5_IPOOL_MTR, /* Pool for meter resource. */
83 	MLX5_IPOOL_MCP, /* Pool for metadata resource. */
84 	MLX5_IPOOL_HRXQ, /* Pool for hrxq resource. */
85 	MLX5_IPOOL_MLX5_FLOW, /* Pool for mlx5 flow handle. */
86 	MLX5_IPOOL_RTE_FLOW, /* Pool for rte_flow. */
87 	MLX5_IPOOL_RSS_EXPANTION_FLOW_ID, /* Pool for Queue/RSS flow ID. */
88 	MLX5_IPOOL_RSS_SHARED_ACTIONS, /* Pool for RSS shared actions. */
89 	MLX5_IPOOL_MTR_POLICY, /* Pool for meter policy resource. */
90 	MLX5_IPOOL_MAX,
91 };
92 
93 /*
94  * There are three reclaim memory mode supported.
95  * 0(none) means no memory reclaim.
96  * 1(light) means only PMD level reclaim.
97  * 2(aggressive) means both PMD and rdma-core level reclaim.
98  */
99 enum mlx5_reclaim_mem_mode {
100 	MLX5_RCM_NONE, /* Don't reclaim memory. */
101 	MLX5_RCM_LIGHT, /* Reclaim PMD level. */
102 	MLX5_RCM_AGGR, /* Reclaim PMD and rdma-core level. */
103 };
104 
105 /* The type of flow. */
106 enum mlx5_flow_type {
107 	MLX5_FLOW_TYPE_CTL, /* Control flow. */
108 	MLX5_FLOW_TYPE_GEN, /* General flow. */
109 	MLX5_FLOW_TYPE_MCP, /* MCP flow. */
110 	MLX5_FLOW_TYPE_MAXI,
111 };
112 
113 /* The mode of delay drop for Rx queues. */
114 enum mlx5_delay_drop_mode {
115 	MLX5_DELAY_DROP_NONE = 0, /* All disabled. */
116 	MLX5_DELAY_DROP_STANDARD = RTE_BIT32(0), /* Standard queues enable. */
117 	MLX5_DELAY_DROP_HAIRPIN = RTE_BIT32(1), /* Hairpin queues enable. */
118 };
119 
120 /* The HWS action type root/non-root. */
121 enum mlx5_hw_action_flag_type {
122 	MLX5_HW_ACTION_FLAG_ROOT, /* Root action. */
123 	MLX5_HW_ACTION_FLAG_NONE_ROOT, /* Non-root ation. */
124 	MLX5_HW_ACTION_FLAG_MAX, /* Maximum action flag. */
125 };
126 
127 /* Hlist and list callback context. */
128 struct mlx5_flow_cb_ctx {
129 	struct rte_eth_dev *dev;
130 	struct rte_flow_error *error;
131 	void *data;
132 	void *data2;
133 };
134 
135 /* Device capabilities structure which isn't changed in any stage. */
136 struct mlx5_dev_cap {
137 	int max_cq; /* Maximum number of supported CQs */
138 	int max_qp; /* Maximum number of supported QPs. */
139 	int max_qp_wr; /* Maximum number of outstanding WR on any WQ. */
140 	int max_sge;
141 	/* Maximum number of s/g per WR for SQ & RQ of QP for non RDMA Read
142 	 * operations.
143 	 */
144 	int mps; /* Multi-packet send supported mode. */
145 	uint32_t vf:1; /* This is a VF. */
146 	uint32_t sf:1; /* This is a SF. */
147 	uint32_t txpp_en:1; /* Tx packet pacing is supported. */
148 	uint32_t mpls_en:1; /* MPLS over GRE/UDP is supported. */
149 	uint32_t cqe_comp:1; /* CQE compression is supported. */
150 	uint32_t hw_csum:1; /* Checksum offload is supported. */
151 	uint32_t hw_padding:1; /* End alignment padding is supported. */
152 	uint32_t dest_tir:1; /* Whether advanced DR API is available. */
153 	uint32_t dv_esw_en:1; /* E-Switch DV flow is supported. */
154 	uint32_t dv_flow_en:1; /* DV flow is supported. */
155 	uint32_t swp:3; /* Tx generic tunnel checksum and TSO offload. */
156 	uint32_t hw_vlan_strip:1; /* VLAN stripping is supported. */
157 	uint32_t scatter_fcs_w_decap_disable:1;
158 	/* HW has bug working with tunnel packet decap and scatter FCS. */
159 	uint32_t hw_fcs_strip:1; /* FCS stripping is supported. */
160 	uint32_t rt_timestamp:1; /* Realtime timestamp format. */
161 	uint32_t rq_delay_drop_en:1; /* Enable RxQ delay drop. */
162 	uint32_t tunnel_en:3;
163 	/* Whether tunnel stateless offloads are supported. */
164 	uint32_t ind_table_max_size;
165 	/* Maximum receive WQ indirection table size. */
166 	uint32_t tso:1; /* Whether TSO is supported. */
167 	uint32_t tso_max_payload_sz; /* Maximum TCP payload for TSO. */
168 	struct {
169 		uint32_t enabled:1; /* Whether MPRQ is enabled. */
170 		uint32_t log_min_stride_size; /* Log min size of a stride. */
171 		uint32_t log_max_stride_size; /* Log max size of a stride. */
172 		uint32_t log_min_stride_num; /* Log min num of strides. */
173 		uint32_t log_max_stride_num; /* Log max num of strides. */
174 		uint32_t log_min_stride_wqe_size;
175 		/* Log min WQE size, (size of single stride)*(num of strides).*/
176 	} mprq; /* Capability for Multi-Packet RQ. */
177 	char fw_ver[64]; /* Firmware version of this device. */
178 };
179 
180 /** Data associated with devices to spawn. */
181 struct mlx5_dev_spawn_data {
182 	uint32_t ifindex; /**< Network interface index. */
183 	uint32_t max_port; /**< Device maximal port index. */
184 	uint32_t phys_port; /**< Device physical port index. */
185 	int pf_bond; /**< bonding device PF index. < 0 - no bonding */
186 	struct mlx5_switch_info info; /**< Switch information. */
187 	const char *phys_dev_name; /**< Name of physical device. */
188 	struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */
189 	struct rte_pci_device *pci_dev; /**< Backend PCI device. */
190 	struct mlx5_common_device *cdev; /**< Backend common device. */
191 	struct mlx5_bond_info *bond_info;
192 };
193 
194 /** Data associated with socket messages. */
195 struct mlx5_flow_dump_req  {
196 	uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
197 	uint64_t flow_id;
198 } __rte_packed;
199 
200 struct mlx5_flow_dump_ack {
201 	int rc; /**< Return code. */
202 };
203 
204 LIST_HEAD(mlx5_dev_list, mlx5_dev_ctx_shared);
205 
206 /* Shared data between primary and secondary processes. */
207 struct mlx5_shared_data {
208 	rte_spinlock_t lock;
209 	/* Global spinlock for primary and secondary processes. */
210 	int init_done; /* Whether primary has done initialization. */
211 	unsigned int secondary_cnt; /* Number of secondary processes init'd. */
212 };
213 
214 /* Per-process data structure, not visible to other processes. */
215 struct mlx5_local_data {
216 	int init_done; /* Whether a secondary has done initialization. */
217 };
218 
219 extern struct mlx5_shared_data *mlx5_shared_data;
220 
221 /* Dev ops structs */
222 extern const struct eth_dev_ops mlx5_dev_ops;
223 extern const struct eth_dev_ops mlx5_dev_sec_ops;
224 extern const struct eth_dev_ops mlx5_dev_ops_isolate;
225 
226 struct mlx5_counter_ctrl {
227 	/* Name of the counter. */
228 	char dpdk_name[RTE_ETH_XSTATS_NAME_SIZE];
229 	/* Name of the counter on the device table. */
230 	char ctr_name[RTE_ETH_XSTATS_NAME_SIZE];
231 	uint32_t dev:1; /**< Nonzero for dev counters. */
232 };
233 
234 struct mlx5_xstats_ctrl {
235 	/* Number of device stats. */
236 	uint16_t stats_n;
237 	/* Number of device stats identified by PMD. */
238 	uint16_t  mlx5_stats_n;
239 	/* Index in the device counters table. */
240 	uint16_t dev_table_idx[MLX5_MAX_XSTATS];
241 	uint64_t base[MLX5_MAX_XSTATS];
242 	uint64_t xstats[MLX5_MAX_XSTATS];
243 	uint64_t hw_stats[MLX5_MAX_XSTATS];
244 	struct mlx5_counter_ctrl info[MLX5_MAX_XSTATS];
245 };
246 
247 struct mlx5_stats_ctrl {
248 	/* Base for imissed counter. */
249 	uint64_t imissed_base;
250 	uint64_t imissed;
251 };
252 
253 /* Maximal size of coalesced segment for LRO is set in chunks of 256 Bytes. */
254 #define MLX5_LRO_SEG_CHUNK_SIZE	256u
255 
256 /* Maximal size of aggregated LRO packet. */
257 #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE)
258 
259 /* Maximal number of segments to split. */
260 #define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS)
261 
262 /*
263  * Port configuration structure.
264  * User device parameters disabled features.
265  * This structure contains all configurations coming from devargs which
266  * oriented to port. When probing again, devargs doesn't have to be compatible
267  * with primary devargs. It is updated for each port in spawn function.
268  */
269 struct mlx5_port_config {
270 	unsigned int hw_vlan_insert:1; /* VLAN insertion in WQE is supported. */
271 	unsigned int hw_padding:1; /* End alignment padding is supported. */
272 	unsigned int cqe_comp:1; /* CQE compression is enabled. */
273 	unsigned int cqe_comp_fmt:3; /* CQE compression format. */
274 	unsigned int rx_vec_en:1; /* Rx vector is enabled. */
275 	unsigned int std_delay_drop:1; /* Enable standard Rxq delay drop. */
276 	unsigned int hp_delay_drop:1; /* Enable hairpin Rxq delay drop. */
277 	struct {
278 		unsigned int enabled:1; /* Whether MPRQ is enabled. */
279 		unsigned int log_stride_num; /* Log number of strides. */
280 		unsigned int log_stride_size; /* Log size of a stride. */
281 		unsigned int max_memcpy_len;
282 		/* Maximum packet size to memcpy Rx packets. */
283 		unsigned int min_rxqs_num;
284 		/* Rx queue count threshold to enable MPRQ. */
285 	} mprq; /* Configurations for Multi-Packet RQ. */
286 	int mps; /* Multi-packet send supported mode. */
287 	unsigned int max_dump_files_num; /* Maximum dump files per queue. */
288 	unsigned int log_hp_size; /* Single hairpin queue data size in total. */
289 	unsigned int lro_timeout; /* LRO user configuration. */
290 	int txqs_inline; /* Queue number threshold for inlining. */
291 	int txq_inline_min; /* Minimal amount of data bytes to inline. */
292 	int txq_inline_max; /* Max packet size for inlining with SEND. */
293 	int txq_inline_mpw; /* Max packet size for inlining with eMPW. */
294 };
295 
296 /*
297  * Share context device configuration structure.
298  * User device parameters disabled features.
299  * This structure updated once for device in mlx5_alloc_shared_dev_ctx()
300  * function and cannot change even when probing again.
301  */
302 struct mlx5_sh_config {
303 	int tx_pp; /* Timestamp scheduling granularity in nanoseconds. */
304 	int tx_skew; /* Tx scheduling skew between WQE and data on wire. */
305 	uint32_t reclaim_mode:2; /* Memory reclaim mode. */
306 	uint32_t dv_esw_en:1; /* Enable E-Switch DV flow. */
307 	/* Enable DV flow. 1 means SW steering, 2 means HW steering. */
308 	uint32_t dv_flow_en:2; /* Enable DV flow. */
309 	uint32_t dv_xmeta_en:3; /* Enable extensive flow metadata. */
310 	uint32_t dv_miss_info:1; /* Restore packet after partial hw miss. */
311 	uint32_t l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */
312 	uint32_t vf_nl_en:1; /* Enable Netlink requests in VF mode. */
313 	uint32_t lacp_by_user:1; /* Enable user to manage LACP traffic. */
314 	uint32_t decap_en:1; /* Whether decap will be used or not. */
315 	uint32_t hw_fcs_strip:1; /* FCS stripping is supported. */
316 	uint32_t allow_duplicate_pattern:1;
317 	uint32_t lro_allowed:1; /* Whether LRO is allowed. */
318 	struct {
319 		uint16_t service_core;
320 		uint32_t cycle_time; /* query cycle time in milli-second. */
321 	} cnt_svc; /* configure for HW steering's counter's service. */
322 	/* Allow/Prevent the duplicate rules pattern. */
323 	uint32_t fdb_def_rule:1; /* Create FDB default jump rule */
324 	uint32_t repr_matching:1; /* Enable implicit vport matching in HWS FDB. */
325 };
326 
327 /* Structure for VF VLAN workaround. */
328 struct mlx5_vf_vlan {
329 	uint32_t tag:12;
330 	uint32_t created:1;
331 };
332 
333 /* Flow drop context necessary due to Verbs API. */
334 struct mlx5_drop {
335 	struct mlx5_hrxq *hrxq; /* Hash Rx queue queue. */
336 	struct mlx5_rxq_priv *rxq; /* Rx queue. */
337 };
338 
339 /* Loopback dummy queue resources required due to Verbs API. */
340 struct mlx5_lb_ctx {
341 	struct ibv_qp *qp; /* QP object. */
342 	void *ibv_cq; /* Completion queue. */
343 	uint16_t refcnt; /* Reference count for representors. */
344 };
345 
346 /* HW steering queue job descriptor type. */
347 enum {
348 	MLX5_HW_Q_JOB_TYPE_CREATE, /* Flow create job type. */
349 	MLX5_HW_Q_JOB_TYPE_DESTROY, /* Flow destroy job type. */
350 	MLX5_HW_Q_JOB_TYPE_UPDATE,
351 	MLX5_HW_Q_JOB_TYPE_QUERY,
352 };
353 
354 #define MLX5_HW_MAX_ITEMS (16)
355 
356 /* HW steering flow management job descriptor. */
357 struct mlx5_hw_q_job {
358 	uint32_t type; /* Job type. */
359 	union {
360 		struct rte_flow_hw *flow; /* Flow attached to the job. */
361 		const void *action; /* Indirect action attached to the job. */
362 	};
363 	void *user_data; /* Job user data. */
364 	uint8_t *encap_data; /* Encap data. */
365 	struct mlx5_modification_cmd *mhdr_cmd;
366 	struct rte_flow_item *items;
367 	union {
368 		struct {
369 			/* Pointer to ct query user memory. */
370 			struct rte_flow_action_conntrack *profile;
371 			/* Pointer to ct ASO query out memory. */
372 			void *out_data;
373 		} __rte_packed;
374 		struct rte_flow_item_ethdev port_spec;
375 		struct rte_flow_item_tag tag_spec;
376 	} __rte_packed;
377 };
378 
379 /* HW steering job descriptor LIFO pool. */
380 struct mlx5_hw_q {
381 	uint32_t job_idx; /* Free job index. */
382 	uint32_t size; /* LIFO size. */
383 	struct mlx5_hw_q_job **job; /* LIFO header. */
384 	struct rte_ring *indir_cq; /* Indirect action SW completion queue. */
385 	struct rte_ring *indir_iq; /* Indirect action SW in progress queue. */
386 } __rte_cache_aligned;
387 
388 
389 #define MLX5_COUNTER_POOLS_MAX_NUM (1 << 15)
390 #define MLX5_COUNTERS_PER_POOL 512
391 #define MLX5_MAX_PENDING_QUERIES 4
392 #define MLX5_CNT_MR_ALLOC_BULK 64
393 #define MLX5_CNT_SHARED_OFFSET 0x80000000
394 #define IS_BATCH_CNT(cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \
395 			   MLX5_CNT_BATCH_OFFSET)
396 #define MLX5_CNT_SIZE (sizeof(struct mlx5_flow_counter))
397 #define MLX5_AGE_SIZE (sizeof(struct mlx5_age_param))
398 
399 #define MLX5_CNT_LEN(pool) \
400 	(MLX5_CNT_SIZE + \
401 	((pool)->is_aged ? MLX5_AGE_SIZE : 0))
402 #define MLX5_POOL_GET_CNT(pool, index) \
403 	((struct mlx5_flow_counter *) \
404 	((uint8_t *)((pool) + 1) + (index) * (MLX5_CNT_LEN(pool))))
405 #define MLX5_CNT_ARRAY_IDX(pool, cnt) \
406 	((int)(((uint8_t *)(cnt) - (uint8_t *)((pool) + 1)) / \
407 	MLX5_CNT_LEN(pool)))
408 #define MLX5_TS_MASK_SECS 8ull
409 /* timestamp wrapping in seconds, must be  power of 2. */
410 
411 /*
412  * The pool index and offset of counter in the pool array makes up the
413  * counter index. In case the counter is from pool 0 and offset 0, it
414  * should plus 1 to avoid index 0, since 0 means invalid counter index
415  * currently.
416  */
417 #define MLX5_MAKE_CNT_IDX(pi, offset) \
418 	((pi) * MLX5_COUNTERS_PER_POOL + (offset) + 1)
419 #define MLX5_CNT_TO_AGE(cnt) \
420 	((struct mlx5_age_param *)((cnt) + 1))
421 /*
422  * The maximum single counter is 0x800000 as MLX5_CNT_BATCH_OFFSET
423  * defines. The pool size is 512, pool index should never reach
424  * INT16_MAX.
425  */
426 #define POOL_IDX_INVALID UINT16_MAX
427 
428 /* Age status. */
429 enum {
430 	AGE_FREE, /* Initialized state. */
431 	AGE_CANDIDATE, /* Counter assigned to flows. */
432 	AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */
433 };
434 
435 enum mlx5_counter_type {
436 	MLX5_COUNTER_TYPE_ORIGIN,
437 	MLX5_COUNTER_TYPE_AGE,
438 	MLX5_COUNTER_TYPE_MAX,
439 };
440 
441 /* Counter age parameter. */
442 struct mlx5_age_param {
443 	uint16_t state; /**< Age state (atomically accessed). */
444 	uint16_t port_id; /**< Port id of the counter. */
445 	uint32_t timeout:24; /**< Aging timeout in seconds. */
446 	uint32_t sec_since_last_hit;
447 	/**< Time in seconds since last hit (atomically accessed). */
448 	void *context; /**< Flow counter age context. */
449 };
450 
451 struct flow_counter_stats {
452 	uint64_t hits;
453 	uint64_t bytes;
454 };
455 
456 /* Shared counters information for counters. */
457 struct mlx5_flow_counter_shared {
458 	union {
459 		uint32_t refcnt; /* Only for shared action management. */
460 		uint32_t id; /* User counter ID for legacy sharing. */
461 	};
462 };
463 
464 struct mlx5_flow_counter_pool;
465 /* Generic counters information. */
466 struct mlx5_flow_counter {
467 	union {
468 		/*
469 		 * User-defined counter shared info is only used during
470 		 * counter active time. And aging counter sharing is not
471 		 * supported, so active shared counter will not be chained
472 		 * to the aging list. For shared counter, only when it is
473 		 * released, the TAILQ entry memory will be used, at that
474 		 * time, shared memory is not used anymore.
475 		 *
476 		 * Similarly to none-batch counter dcs, since it doesn't
477 		 * support aging, while counter is allocated, the entry
478 		 * memory is not used anymore. In this case, as bytes
479 		 * memory is used only when counter is allocated, and
480 		 * entry memory is used only when counter is free. The
481 		 * dcs pointer can be saved to these two different place
482 		 * at different stage. It will eliminate the individual
483 		 * counter extend struct.
484 		 */
485 		TAILQ_ENTRY(mlx5_flow_counter) next;
486 		/**< Pointer to the next flow counter structure. */
487 		struct {
488 			struct mlx5_flow_counter_shared shared_info;
489 			/**< Shared counter information. */
490 			void *dcs_when_active;
491 			/*
492 			 * For non-batch mode, the dcs will be saved
493 			 * here when the counter is free.
494 			 */
495 		};
496 	};
497 	union {
498 		uint64_t hits; /**< Reset value of hits packets. */
499 		struct mlx5_flow_counter_pool *pool; /**< Counter pool. */
500 	};
501 	union {
502 		uint64_t bytes; /**< Reset value of bytes. */
503 		void *dcs_when_free;
504 		/*
505 		 * For non-batch mode, the dcs will be saved here
506 		 * when the counter is free.
507 		 */
508 	};
509 	void *action; /**< Pointer to the dv action. */
510 };
511 
512 TAILQ_HEAD(mlx5_counters, mlx5_flow_counter);
513 
514 /* Generic counter pool structure - query is in pool resolution. */
515 struct mlx5_flow_counter_pool {
516 	TAILQ_ENTRY(mlx5_flow_counter_pool) next;
517 	struct mlx5_counters counters[2]; /* Free counter list. */
518 	struct mlx5_devx_obj *min_dcs;
519 	/* The devx object of the minimum counter ID. */
520 	uint64_t time_of_last_age_check;
521 	/* System time (from rte_rdtsc()) read in the last aging check. */
522 	uint32_t index:30; /* Pool index in container. */
523 	uint32_t is_aged:1; /* Pool with aging counter. */
524 	volatile uint32_t query_gen:1; /* Query round. */
525 	rte_spinlock_t sl; /* The pool lock. */
526 	rte_spinlock_t csl; /* The pool counter free list lock. */
527 	struct mlx5_counter_stats_raw *raw;
528 	struct mlx5_counter_stats_raw *raw_hw;
529 	/* The raw on HW working. */
530 };
531 
532 /* Memory management structure for group of counter statistics raws. */
533 struct mlx5_counter_stats_mem_mng {
534 	LIST_ENTRY(mlx5_counter_stats_mem_mng) next;
535 	struct mlx5_counter_stats_raw *raws;
536 	struct mlx5_pmd_wrapped_mr wm;
537 };
538 
539 /* Raw memory structure for the counter statistics values of a pool. */
540 struct mlx5_counter_stats_raw {
541 	LIST_ENTRY(mlx5_counter_stats_raw) next;
542 	struct mlx5_counter_stats_mem_mng *mem_mng;
543 	volatile struct flow_counter_stats *data;
544 };
545 
546 /* Mlx5 internal flex parser profile structure. */
547 struct mlx5_internal_flex_parser_profile {
548 	uint32_t num;/* Actual number of samples. */
549 	/* Sample IDs for this profile. */
550 	struct mlx5_ext_sample_id ids[MLX5_FLEX_ITEM_MAPPING_NUM];
551 	uint32_t offset[MLX5_FLEX_ITEM_MAPPING_NUM]; /* Each ID sample offset. */
552 	uint8_t anchor_id;
553 	uint32_t refcnt;
554 	void *fp; /* DevX flex parser object. */
555 };
556 
557 TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
558 
559 /* Counter global management structure. */
560 struct mlx5_flow_counter_mng {
561 	volatile uint16_t n_valid; /* Number of valid pools. */
562 	uint16_t last_pool_idx; /* Last used pool index */
563 	int min_id; /* The minimum counter ID in the pools. */
564 	int max_id; /* The maximum counter ID in the pools. */
565 	rte_spinlock_t pool_update_sl; /* The pool update lock. */
566 	rte_spinlock_t csl[MLX5_COUNTER_TYPE_MAX];
567 	/* The counter free list lock. */
568 	struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX];
569 	/* Free counter list. */
570 	struct mlx5_flow_counter_pool **pools; /* Counter pool array. */
571 	struct mlx5_counter_stats_mem_mng *mem_mng;
572 	/* Hold the memory management for the next allocated pools raws. */
573 	struct mlx5_counters flow_counters; /* Legacy flow counter list. */
574 	uint8_t pending_queries;
575 	uint16_t pool_index;
576 	uint8_t query_thread_on;
577 	bool counter_fallback; /* Use counter fallback management. */
578 	LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs;
579 	LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws;
580 };
581 
582 /* ASO structures. */
583 #define MLX5_ASO_QUEUE_LOG_DESC 10
584 
585 struct mlx5_aso_cq {
586 	uint16_t log_desc_n;
587 	uint32_t cq_ci:24;
588 	struct mlx5_devx_cq cq_obj;
589 	uint64_t errors;
590 };
591 
592 struct mlx5_aso_sq_elem {
593 	union {
594 		struct {
595 			struct mlx5_aso_age_pool *pool;
596 			uint16_t burst_size;
597 		};
598 		struct mlx5_aso_mtr *mtr;
599 		struct {
600 			struct mlx5_aso_ct_action *ct;
601 			char *query_data;
602 		};
603 		void *user_data;
604 	};
605 };
606 
607 struct mlx5_aso_sq {
608 	uint16_t log_desc_n;
609 	rte_spinlock_t sqsl;
610 	struct mlx5_aso_cq cq;
611 	struct mlx5_devx_sq sq_obj;
612 	struct mlx5_pmd_mr mr;
613 	volatile struct mlx5_aso_wqe *db;
614 	uint16_t pi;
615 	uint16_t db_pi;
616 	uint32_t head;
617 	uint32_t tail;
618 	uint32_t sqn;
619 	struct mlx5_aso_sq_elem elts[1 << MLX5_ASO_QUEUE_LOG_DESC];
620 	uint16_t next; /* Pool index of the next pool to query. */
621 };
622 
623 struct mlx5_aso_age_action {
624 	LIST_ENTRY(mlx5_aso_age_action) next;
625 	void *dr_action;
626 	uint32_t refcnt;
627 	/* Following fields relevant only when action is active. */
628 	uint16_t offset; /* Offset of ASO Flow Hit flag in DevX object. */
629 	struct mlx5_age_param age_params;
630 };
631 
632 #define MLX5_ASO_AGE_ACTIONS_PER_POOL 512
633 #define MLX5_ASO_AGE_CONTAINER_RESIZE 64
634 
635 struct mlx5_aso_age_pool {
636 	struct mlx5_devx_obj *flow_hit_aso_obj;
637 	uint16_t index; /* Pool index in pools array. */
638 	uint64_t time_of_last_age_check; /* In seconds. */
639 	struct mlx5_aso_age_action actions[MLX5_ASO_AGE_ACTIONS_PER_POOL];
640 };
641 
642 LIST_HEAD(aso_age_list, mlx5_aso_age_action);
643 
644 struct mlx5_aso_age_mng {
645 	struct mlx5_aso_age_pool **pools;
646 	uint16_t n; /* Total number of pools. */
647 	uint16_t next; /* Number of pools in use, index of next free pool. */
648 	rte_rwlock_t resize_rwl; /* Lock for resize objects. */
649 	rte_spinlock_t free_sl; /* Lock for free list access. */
650 	struct aso_age_list free; /* Free age actions list - ready to use. */
651 	struct mlx5_aso_sq aso_sq; /* ASO queue objects. */
652 };
653 
654 /* Management structure for geneve tlv option */
655 struct mlx5_geneve_tlv_option_resource {
656 	struct mlx5_devx_obj *obj; /* Pointer to the geneve tlv opt object. */
657 	rte_be16_t option_class; /* geneve tlv opt class.*/
658 	uint8_t option_type; /* geneve tlv opt type.*/
659 	uint8_t length; /* geneve tlv opt length. */
660 	uint32_t refcnt; /* geneve tlv object reference counter */
661 };
662 
663 
664 #define MLX5_AGE_EVENT_NEW		1
665 #define MLX5_AGE_TRIGGER		2
666 #define MLX5_AGE_SET(age_info, BIT) \
667 	((age_info)->flags |= (1 << (BIT)))
668 #define MLX5_AGE_UNSET(age_info, BIT) \
669 	((age_info)->flags &= ~(1 << (BIT)))
670 #define MLX5_AGE_GET(age_info, BIT) \
671 	((age_info)->flags & (1 << (BIT)))
672 #define GET_PORT_AGE_INFO(priv) \
673 	(&((priv)->sh->port[(priv)->dev_port - 1].age_info))
674 /* Current time in seconds. */
675 #define MLX5_CURR_TIME_SEC	(rte_rdtsc() / rte_get_tsc_hz())
676 
677 /*
678  * HW steering queue oriented AGE info.
679  * It contains an array of rings, one for each HWS queue.
680  */
681 struct mlx5_hws_q_age_info {
682 	uint16_t nb_rings; /* Number of aged-out ring lists. */
683 	struct rte_ring *aged_lists[]; /* Aged-out lists. */
684 };
685 
686 /*
687  * HW steering AGE info.
688  * It has a ring list containing all aged out flow rules.
689  */
690 struct mlx5_hws_age_info {
691 	struct rte_ring *aged_list; /* Aged out lists. */
692 };
693 
694 /* Aging information for per port. */
695 struct mlx5_age_info {
696 	uint8_t flags; /* Indicate if is new event or need to be triggered. */
697 	union {
698 		/* SW/FW steering AGE info. */
699 		struct {
700 			struct mlx5_counters aged_counters;
701 			/* Aged counter list. */
702 			struct aso_age_list aged_aso;
703 			/* Aged ASO actions list. */
704 			rte_spinlock_t aged_sl; /* Aged flow list lock. */
705 		};
706 		struct {
707 			struct mlx5_indexed_pool *ages_ipool;
708 			union {
709 				struct mlx5_hws_age_info hw_age;
710 				/* HW steering AGE info. */
711 				struct mlx5_hws_q_age_info *hw_q_age;
712 				/* HW steering queue oriented AGE info. */
713 			};
714 		};
715 	};
716 };
717 
718 /* Per port data of shared IB device. */
719 struct mlx5_dev_shared_port {
720 	uint32_t ih_port_id;
721 	uint32_t devx_ih_port_id;
722 	uint32_t nl_ih_port_id;
723 	/*
724 	 * Interrupt handler port_id. Used by shared interrupt
725 	 * handler to find the corresponding rte_eth device
726 	 * by IB port index. If value is equal or greater
727 	 * RTE_MAX_ETHPORTS it means there is no subhandler
728 	 * installed for specified IB port index.
729 	 */
730 	struct mlx5_age_info age_info;
731 	/* Aging information for per port. */
732 };
733 
734 /*
735  * Max number of actions per DV flow.
736  * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED
737  * in rdma-core file providers/mlx5/verbs.c.
738  */
739 #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
740 
741 /* ASO flow meter structures */
742 /* Modify this value if enum rte_mtr_color changes. */
743 #define RTE_MTR_DROPPED RTE_COLORS
744 /* Yellow is now supported. */
745 #define MLX5_MTR_RTE_COLORS (RTE_COLOR_YELLOW + 1)
746 /* table_id 22 bits in mlx5_flow_tbl_key so limit policy number. */
747 #define MLX5_MAX_SUB_POLICY_TBL_NUM 0x3FFFFF
748 #define MLX5_INVALID_POLICY_ID UINT32_MAX
749 /* Suffix table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
750 #define MLX5_MTR_TABLE_ID_SUFFIX 1
751 /* Drop table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
752 #define MLX5_MTR_TABLE_ID_DROP 2
753 /* Priority of the meter policy matcher. */
754 #define MLX5_MTR_POLICY_MATCHER_PRIO 0
755 /* Green & yellow color valid for now. */
756 #define MLX5_MTR_POLICY_MODE_ALL 0
757 /* Default policy. */
758 #define MLX5_MTR_POLICY_MODE_DEF 1
759 /* Only green color valid. */
760 #define MLX5_MTR_POLICY_MODE_OG 2
761 /* Only yellow color valid. */
762 #define MLX5_MTR_POLICY_MODE_OY 3
763 
764 enum mlx5_meter_domain {
765 	MLX5_MTR_DOMAIN_INGRESS,
766 	MLX5_MTR_DOMAIN_EGRESS,
767 	MLX5_MTR_DOMAIN_TRANSFER,
768 	MLX5_MTR_DOMAIN_MAX,
769 };
770 #define MLX5_MTR_DOMAIN_INGRESS_BIT  (1 << MLX5_MTR_DOMAIN_INGRESS)
771 #define MLX5_MTR_DOMAIN_EGRESS_BIT   (1 << MLX5_MTR_DOMAIN_EGRESS)
772 #define MLX5_MTR_DOMAIN_TRANSFER_BIT (1 << MLX5_MTR_DOMAIN_TRANSFER)
773 #define MLX5_MTR_ALL_DOMAIN_BIT      (MLX5_MTR_DOMAIN_INGRESS_BIT | \
774 					MLX5_MTR_DOMAIN_EGRESS_BIT | \
775 					MLX5_MTR_DOMAIN_TRANSFER_BIT)
776 
777 /* The color tag rule structure. */
778 struct mlx5_sub_policy_color_rule {
779 	void *rule;
780 	/* The color rule. */
781 	struct mlx5_flow_dv_matcher *matcher;
782 	/* The color matcher. */
783 	TAILQ_ENTRY(mlx5_sub_policy_color_rule) next_port;
784 	/**< Pointer to the next color rule structure. */
785 	int32_t src_port;
786 	/* On which src port this rule applied. */
787 };
788 
789 TAILQ_HEAD(mlx5_sub_policy_color_rules, mlx5_sub_policy_color_rule);
790 
791 /*
792  * Meter sub-policy structure.
793  * Each RSS TIR in meter policy need its own sub-policy resource.
794  */
795 struct mlx5_flow_meter_sub_policy {
796 	uint32_t main_policy_id:1;
797 	/* Main policy id is same as this sub_policy id. */
798 	uint32_t idx:31;
799 	/* Index to sub_policy ipool entity. */
800 	void *main_policy;
801 	/* Point to struct mlx5_flow_meter_policy. */
802 	struct mlx5_flow_tbl_resource *tbl_rsc;
803 	/* The sub-policy table resource. */
804 	uint32_t rix_hrxq[MLX5_MTR_RTE_COLORS];
805 	/* Index to TIR resource. */
806 	struct mlx5_flow_tbl_resource *jump_tbl[MLX5_MTR_RTE_COLORS];
807 	/* Meter jump/drop table. */
808 	struct mlx5_sub_policy_color_rules color_rules[RTE_COLORS];
809 	/* List for the color rules. */
810 };
811 
812 struct mlx5_meter_policy_acts {
813 	uint8_t actions_n;
814 	/* Number of actions. */
815 	void *dv_actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
816 	/* Action list. */
817 };
818 
819 struct mlx5_meter_policy_action_container {
820 	uint32_t rix_mark;
821 	/* Index to the mark action. */
822 	struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
823 	/* Pointer to modify header resource in cache. */
824 	uint8_t fate_action;
825 	/* Fate action type. */
826 	union {
827 		struct rte_flow_action *rss;
828 		/* Rss action configuration. */
829 		uint32_t rix_port_id_action;
830 		/* Index to port ID action resource. */
831 		void *dr_jump_action[MLX5_MTR_DOMAIN_MAX];
832 		/* Jump/drop action per color. */
833 		uint16_t queue;
834 		/* Queue action configuration. */
835 		struct {
836 			uint32_t next_mtr_id;
837 			/* The next meter id. */
838 			void *next_sub_policy;
839 			/* Next meter's sub-policy. */
840 		};
841 	};
842 };
843 
844 /* Flow meter policy parameter structure. */
845 struct mlx5_flow_meter_policy {
846 	uint32_t is_rss:1;
847 	/* Is RSS policy table. */
848 	uint32_t ingress:1;
849 	/* Rule applies to ingress domain. */
850 	uint32_t egress:1;
851 	/* Rule applies to egress domain. */
852 	uint32_t transfer:1;
853 	/* Rule applies to transfer domain. */
854 	uint32_t is_queue:1;
855 	/* Is queue action in policy table. */
856 	uint32_t is_hierarchy:1;
857 	/* Is meter action in policy table. */
858 	uint32_t match_port:1;
859 	/* If policy flows match src port. */
860 	uint32_t hierarchy_match_port:1;
861 	/* Is any meter in hierarchy contains policy flow that matches src port. */
862 	uint32_t skip_r:1;
863 	/* If red color policy is skipped. */
864 	uint32_t skip_y:1;
865 	/* If yellow color policy is skipped. */
866 	uint32_t skip_g:1;
867 	/* If green color policy is skipped. */
868 	uint32_t mark:1;
869 	/* If policy contains mark action. */
870 	uint32_t initialized:1;
871 	/* Initialized. */
872 	uint16_t group;
873 	/* The group. */
874 	rte_spinlock_t sl;
875 	uint32_t ref_cnt;
876 	/* Use count. */
877 	struct rte_flow_pattern_template *hws_item_templ;
878 	/* Hardware steering item templates. */
879 	struct rte_flow_actions_template *hws_act_templ[MLX5_MTR_DOMAIN_MAX];
880 	/* Hardware steering action templates. */
881 	struct rte_flow_template_table *hws_flow_table[MLX5_MTR_DOMAIN_MAX];
882 	/* Hardware steering tables. */
883 	struct rte_flow *hws_flow_rule[MLX5_MTR_DOMAIN_MAX][RTE_COLORS];
884 	/* Hardware steering rules. */
885 	struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS];
886 	/* Policy actions container. */
887 	void *dr_drop_action[MLX5_MTR_DOMAIN_MAX];
888 	/* drop action for red color. */
889 	uint16_t sub_policy_num;
890 	/* Count sub policy tables, 3 bits per domain. */
891 	struct mlx5_flow_meter_sub_policy **sub_policys[MLX5_MTR_DOMAIN_MAX];
892 	/* Sub policy table array must be the end of struct. */
893 };
894 
895 /* The maximum sub policy is relate to struct mlx5_rss_hash_fields[]. */
896 #define MLX5_MTR_RSS_MAX_SUB_POLICY 7
897 #define MLX5_MTR_SUB_POLICY_NUM_SHIFT  3
898 #define MLX5_MTR_SUB_POLICY_NUM_MASK  0x7
899 #define MLX5_MTRS_DEFAULT_RULE_PRIORITY 0xFFFF
900 #define MLX5_MTR_CHAIN_MAX_NUM 8
901 
902 /* Flow meter default policy parameter structure.
903  * Policy index 0 is reserved by default policy table.
904  * Action per color as below:
905  * green - do nothing, yellow - do nothing, red - drop
906  */
907 struct mlx5_flow_meter_def_policy {
908 	struct mlx5_flow_meter_sub_policy sub_policy;
909 	/* Policy rules jump to other tables. */
910 	void *dr_jump_action[RTE_COLORS];
911 	/* Jump action per color. */
912 };
913 
914 /* Meter parameter structure. */
915 struct mlx5_flow_meter_info {
916 	uint32_t meter_id;
917 	/**< Meter id. */
918 	uint32_t policy_id;
919 	/* Policy id, the first sub_policy idx. */
920 	struct mlx5_flow_meter_profile *profile;
921 	/**< Meter profile parameters. */
922 	rte_spinlock_t sl; /**< Meter action spinlock. */
923 	/** Set of stats counters to be enabled.
924 	 * @see enum rte_mtr_stats_type
925 	 */
926 	uint32_t bytes_dropped:1;
927 	/** Set bytes dropped stats to be enabled. */
928 	uint32_t pkts_dropped:1;
929 	/** Set packets dropped stats to be enabled. */
930 	uint32_t active_state:1;
931 	/**< Meter hw active state. */
932 	uint32_t shared:1;
933 	/**< Meter shared or not. */
934 	uint32_t is_enable:1;
935 	/**< Meter disable/enable state. */
936 	uint32_t ingress:1;
937 	/**< Rule applies to egress traffic. */
938 	uint32_t egress:1;
939 	/**
940 	 * Instead of simply matching the properties of traffic as it would
941 	 * appear on a given DPDK port ID, enabling this attribute transfers
942 	 * a flow rule to the lowest possible level of any device endpoints
943 	 * found in the pattern.
944 	 *
945 	 * When supported, this effectively enables an application to
946 	 * re-route traffic not necessarily intended for it (e.g. coming
947 	 * from or addressed to different physical ports, VFs or
948 	 * applications) at the device level.
949 	 *
950 	 * It complements the behavior of some pattern items such as
951 	 * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT and is meaningless without them.
952 	 *
953 	 * When transferring flow rules, ingress and egress attributes keep
954 	 * their original meaning, as if processing traffic emitted or
955 	 * received by the application.
956 	 */
957 	uint32_t transfer:1;
958 	uint32_t def_policy:1;
959 	uint32_t initialized:1;
960 	/* Meter points to default policy. */
961 	uint32_t color_aware:1;
962 	/* Meter is color aware mode. */
963 	void *drop_rule[MLX5_MTR_DOMAIN_MAX];
964 	/* Meter drop rule in drop table. */
965 	uint32_t drop_cnt;
966 	/**< Color counter for drop. */
967 	uint32_t ref_cnt;
968 	/**< Use count. */
969 	struct mlx5_indexed_pool *flow_ipool;
970 	/**< Index pool for flow id. */
971 	void *meter_action_g;
972 	/**< Flow meter action. */
973 	void *meter_action_y;
974 	/**< Flow meter action for yellow init_color. */
975 	uint32_t meter_offset;
976 	/**< Flow meter offset. */
977 	uint16_t group;
978 	/**< Flow meter group. */
979 };
980 
981 /* PPS(packets per second) map to BPS(Bytes per second).
982  * HW treat packet as 128bytes in PPS mode
983  */
984 #define MLX5_MTRS_PPS_MAP_BPS_SHIFT 7
985 
986 /* RFC2697 parameter structure. */
987 struct mlx5_flow_meter_srtcm_rfc2697_prm {
988 	rte_be32_t cbs_cir;
989 	/*
990 	 * bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa,
991 	 * bit 8-12: cir_exponent, bit 0-7 cir_mantissa.
992 	 */
993 	rte_be32_t ebs_eir;
994 	/*
995 	 * bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa,
996 	 * bit 8-12: eir_exponent, bit 0-7 eir_mantissa.
997 	 */
998 };
999 
1000 /* Flow meter profile structure. */
1001 struct mlx5_flow_meter_profile {
1002 	TAILQ_ENTRY(mlx5_flow_meter_profile) next;
1003 	/**< Pointer to the next flow meter structure. */
1004 	uint32_t id; /**< Profile id. */
1005 	struct rte_mtr_meter_profile profile; /**< Profile detail. */
1006 	union {
1007 		struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm_prm;
1008 		/**< srtcm_rfc2697 struct. */
1009 	};
1010 	uint32_t ref_cnt; /**< Use count. */
1011 	uint32_t g_support:1; /**< If G color will be generated. */
1012 	uint32_t y_support:1; /**< If Y color will be generated. */
1013 	uint32_t initialized:1; /**< Initialized. */
1014 };
1015 
1016 /* 2 meters in each ASO cache line */
1017 #define MLX5_MTRS_CONTAINER_RESIZE 64
1018 /*
1019  * The pool index and offset of meter in the pool array makes up the
1020  * meter index. In case the meter is from pool 0 and offset 0, it
1021  * should plus 1 to avoid index 0, since 0 means invalid meter index
1022  * currently.
1023  */
1024 #define MLX5_MAKE_MTR_IDX(pi, offset) \
1025 		((pi) * MLX5_ASO_MTRS_PER_POOL + (offset) + 1)
1026 
1027 /*aso flow meter state*/
1028 enum mlx5_aso_mtr_state {
1029 	ASO_METER_FREE, /* In free list. */
1030 	ASO_METER_WAIT, /* ACCESS_ASO WQE in progress. */
1031 	ASO_METER_WAIT_ASYNC, /* CQE will be handled by async pull. */
1032 	ASO_METER_READY, /* CQE received. */
1033 };
1034 
1035 /*aso flow meter type*/
1036 enum mlx5_aso_mtr_type {
1037 	ASO_METER_INDIRECT,
1038 	ASO_METER_DIRECT,
1039 };
1040 
1041 /* Generic aso_flow_meter information. */
1042 struct mlx5_aso_mtr {
1043 	union {
1044 		LIST_ENTRY(mlx5_aso_mtr) next;
1045 		struct mlx5_aso_mtr_pool *pool;
1046 	};
1047 	enum mlx5_aso_mtr_type type;
1048 	struct mlx5_flow_meter_info fm;
1049 	/**< Pointer to the next aso flow meter structure. */
1050 	uint8_t state; /**< ASO flow meter state. */
1051 	uint32_t offset;
1052 	enum rte_color init_color;
1053 };
1054 
1055 /* Generic aso_flow_meter pool structure. */
1056 struct mlx5_aso_mtr_pool {
1057 	struct mlx5_aso_mtr mtrs[MLX5_ASO_MTRS_PER_POOL];
1058 	/*Must be the first in pool*/
1059 	struct mlx5_devx_obj *devx_obj;
1060 	/* The devx object of the minimum aso flow meter ID. */
1061 	struct mlx5dr_action *action; /* HWS action. */
1062 	struct mlx5_indexed_pool *idx_pool; /* HWS index pool. */
1063 	uint32_t index; /* Pool index in management structure. */
1064 	uint32_t nb_sq; /* Number of ASO SQ. */
1065 	struct mlx5_aso_sq *sq; /* ASO SQs. */
1066 };
1067 
1068 LIST_HEAD(aso_meter_list, mlx5_aso_mtr);
1069 /* Pools management structure for ASO flow meter pools. */
1070 struct mlx5_aso_mtr_pools_mng {
1071 	volatile uint16_t n_valid; /* Number of valid pools. */
1072 	uint16_t n; /* Number of pools. */
1073 	rte_spinlock_t mtrsl; /* The ASO flow meter free list lock. */
1074 	rte_rwlock_t resize_mtrwl; /* Lock for resize objects. */
1075 	struct aso_meter_list meters; /* Free ASO flow meter list. */
1076 	struct mlx5_aso_sq sq; /*SQ using by ASO flow meter. */
1077 	struct mlx5_aso_mtr_pool **pools; /* ASO flow meter pool array. */
1078 };
1079 
1080 /* Bulk management structure for ASO flow meter. */
1081 struct mlx5_mtr_bulk {
1082 	uint32_t size; /* Number of ASO objects. */
1083 	struct mlx5dr_action *action; /* HWS action */
1084 	struct mlx5_devx_obj *devx_obj; /* DEVX object. */
1085 	struct mlx5_aso_mtr *aso; /* Array of ASO objects. */
1086 };
1087 
1088 /* Meter management structure for global flow meter resource. */
1089 struct mlx5_flow_mtr_mng {
1090 	struct mlx5_aso_mtr_pools_mng pools_mng;
1091 	/* Pools management structure for ASO flow meter pools. */
1092 	struct mlx5_flow_meter_def_policy *def_policy[MLX5_MTR_DOMAIN_MAX];
1093 	/* Default policy table. */
1094 	uint32_t def_policy_id;
1095 	/* Default policy id. */
1096 	uint32_t def_policy_ref_cnt;
1097 	/** def_policy meter use count. */
1098 	struct mlx5_flow_tbl_resource *drop_tbl[MLX5_MTR_DOMAIN_MAX];
1099 	/* Meter drop table. */
1100 	struct mlx5_flow_dv_matcher *
1101 			drop_matcher[MLX5_MTR_DOMAIN_MAX][MLX5_REG_BITS];
1102 	/* Matcher meter in drop table. */
1103 	struct mlx5_flow_dv_matcher *def_matcher[MLX5_MTR_DOMAIN_MAX];
1104 	/* Default matcher in drop table. */
1105 	void *def_rule[MLX5_MTR_DOMAIN_MAX];
1106 	/* Default rule in drop table. */
1107 	uint8_t max_mtr_bits;
1108 	/* Indicate how many bits are used by meter id at the most. */
1109 	uint8_t max_mtr_flow_bits;
1110 	/* Indicate how many bits are used by meter flow id at the most. */
1111 };
1112 
1113 /* Table key of the hash organization. */
1114 union mlx5_flow_tbl_key {
1115 	struct {
1116 		/* Table ID should be at the lowest address. */
1117 		uint32_t level;	/**< Level of the table. */
1118 		uint32_t id:22;	/**< ID of the table. */
1119 		uint32_t dummy:1;	/**< Dummy table for DV API. */
1120 		uint32_t is_fdb:1;	/**< 1 - FDB, 0 - NIC TX/RX. */
1121 		uint32_t is_egress:1;	/**< 1 - egress, 0 - ingress. */
1122 		uint32_t reserved:7;	/**< must be zero for comparison. */
1123 	};
1124 	uint64_t v64;			/**< full 64bits value of key */
1125 };
1126 
1127 /* Table structure. */
1128 struct mlx5_flow_tbl_resource {
1129 	void *obj; /**< Pointer to DR table object. */
1130 };
1131 
1132 #define MLX5_MAX_TABLES UINT16_MAX
1133 #define MLX5_HAIRPIN_TX_TABLE (UINT16_MAX - 1)
1134 /* Reserve the last two tables for metadata register copy. */
1135 #define MLX5_FLOW_MREG_ACT_TABLE_GROUP (MLX5_MAX_TABLES - 1)
1136 #define MLX5_FLOW_MREG_CP_TABLE_GROUP (MLX5_MAX_TABLES - 2)
1137 /* Tables for metering splits should be added here. */
1138 #define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)
1139 #define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)
1140 #define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY
1141 #define MLX5_FLOW_TABLE_HWS_POLICY (MLX5_MAX_TABLES - 10)
1142 #define MLX5_MAX_TABLES_FDB UINT16_MAX
1143 #define MLX5_FLOW_TABLE_FACTOR 10
1144 
1145 /* ID generation structure. */
1146 struct mlx5_flow_id_pool {
1147 	uint32_t *free_arr; /**< Pointer to the a array of free values. */
1148 	uint32_t base_index;
1149 	/**< The next index that can be used without any free elements. */
1150 	uint32_t *curr; /**< Pointer to the index to pop. */
1151 	uint32_t *last; /**< Pointer to the last element in the empty array. */
1152 	uint32_t max_id; /**< Maximum id can be allocated from the pool. */
1153 };
1154 
1155 /* Tx pacing queue structure - for Clock and Rearm queues. */
1156 struct mlx5_txpp_wq {
1157 	/* Completion Queue related data.*/
1158 	struct mlx5_devx_cq cq_obj;
1159 	uint32_t cq_ci:24;
1160 	uint32_t arm_sn:2;
1161 	/* Send Queue related data.*/
1162 	struct mlx5_devx_sq sq_obj;
1163 	uint16_t sq_size; /* Number of WQEs in the queue. */
1164 	uint16_t sq_ci; /* Next WQE to execute. */
1165 };
1166 
1167 /* Tx packet pacing internal timestamp. */
1168 struct mlx5_txpp_ts {
1169 	uint64_t ci_ts;
1170 	uint64_t ts;
1171 };
1172 
1173 /* Tx packet pacing structure. */
1174 struct mlx5_dev_txpp {
1175 	pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
1176 	uint32_t refcnt; /* Pacing reference counter. */
1177 	uint32_t freq; /* Timestamp frequency, Hz. */
1178 	uint32_t tick; /* Completion tick duration in nanoseconds. */
1179 	uint32_t test; /* Packet pacing test mode. */
1180 	int32_t skew; /* Scheduling skew. */
1181 	struct rte_intr_handle *intr_handle; /* Periodic interrupt. */
1182 	void *echan; /* Event Channel. */
1183 	struct mlx5_txpp_wq clock_queue; /* Clock Queue. */
1184 	struct mlx5_txpp_wq rearm_queue; /* Clock Queue. */
1185 	void *pp; /* Packet pacing context. */
1186 	uint16_t pp_id; /* Packet pacing context index. */
1187 	uint16_t ts_n; /* Number of captured timestamps. */
1188 	uint16_t ts_p; /* Pointer to statistics timestamp. */
1189 	struct mlx5_txpp_ts *tsa; /* Timestamps sliding window stats. */
1190 	struct mlx5_txpp_ts ts; /* Cached completion id/timestamp. */
1191 	uint32_t sync_lost:1; /* ci/timestamp synchronization lost. */
1192 	/* Statistics counters. */
1193 	uint64_t err_miss_int; /* Missed service interrupt. */
1194 	uint64_t err_rearm_queue; /* Rearm Queue errors. */
1195 	uint64_t err_clock_queue; /* Clock Queue errors. */
1196 	uint64_t err_ts_past; /* Timestamp in the past. */
1197 	uint64_t err_ts_future; /* Timestamp in the distant future. */
1198 };
1199 
1200 /* Sample ID information of eCPRI flex parser structure. */
1201 struct mlx5_ecpri_parser_profile {
1202 	uint32_t num;		/* Actual number of samples. */
1203 	uint32_t ids[8];	/* Sample IDs for this profile. */
1204 	uint8_t offset[8];	/* Bytes offset of each parser. */
1205 	void *obj;		/* Flex parser node object. */
1206 };
1207 
1208 /* Max member ports per bonding device. */
1209 #define MLX5_BOND_MAX_PORTS 2
1210 
1211 /* Bonding device information. */
1212 struct mlx5_bond_info {
1213 	int n_port; /* Number of bond member ports. */
1214 	uint32_t ifindex;
1215 	char ifname[MLX5_NAMESIZE + 1];
1216 	struct {
1217 		char ifname[MLX5_NAMESIZE + 1];
1218 		uint32_t ifindex;
1219 		struct rte_pci_addr pci_addr;
1220 	} ports[MLX5_BOND_MAX_PORTS];
1221 };
1222 
1223 /* Number of connection tracking objects per pool: must be a power of 2. */
1224 #define MLX5_ASO_CT_ACTIONS_PER_POOL 64
1225 
1226 /* Generate incremental and unique CT index from pool and offset. */
1227 #define MLX5_MAKE_CT_IDX(pool, offset) \
1228 	((pool) * MLX5_ASO_CT_ACTIONS_PER_POOL + (offset) + 1)
1229 
1230 /* ASO Conntrack state. */
1231 enum mlx5_aso_ct_state {
1232 	ASO_CONNTRACK_FREE, /* Inactive, in the free list. */
1233 	ASO_CONNTRACK_WAIT, /* WQE sent in the SQ. */
1234 	ASO_CONNTRACK_WAIT_ASYNC, /* CQE will be handled by async pull. */
1235 	ASO_CONNTRACK_READY, /* CQE received w/o error. */
1236 	ASO_CONNTRACK_QUERY, /* WQE for query sent. */
1237 	ASO_CONNTRACK_MAX, /* Guard. */
1238 };
1239 
1240 /* Generic ASO connection tracking structure. */
1241 struct mlx5_aso_ct_action {
1242 	union {
1243 		/* SWS mode struct. */
1244 		struct {
1245 			/* Pointer to the next ASO CT. Used only in SWS. */
1246 			LIST_ENTRY(mlx5_aso_ct_action) next;
1247 		};
1248 		/* HWS mode struct. */
1249 		struct {
1250 			/* Pointer to action pool. Used only in HWS. */
1251 			struct mlx5_aso_ct_pool *pool;
1252 		};
1253 	};
1254 	/* General action object for original dir. */
1255 	void *dr_action_orig;
1256 	/* General action object for reply dir. */
1257 	void *dr_action_rply;
1258 	uint32_t refcnt; /* Action used count in device flows. */
1259 	uint16_t offset; /* Offset of ASO CT in DevX objects bulk. */
1260 	uint16_t peer; /* The only peer port index could also use this CT. */
1261 	enum mlx5_aso_ct_state state; /* ASO CT state. */
1262 	bool is_original; /* The direction of the DR action to be used. */
1263 };
1264 
1265 /* CT action object state update. */
1266 #define MLX5_ASO_CT_UPDATE_STATE(c, s) \
1267 	__atomic_store_n(&((c)->state), (s), __ATOMIC_RELAXED)
1268 
1269 #ifdef PEDANTIC
1270 #pragma GCC diagnostic ignored "-Wpedantic"
1271 #endif
1272 
1273 /* ASO connection tracking software pool definition. */
1274 struct mlx5_aso_ct_pool {
1275 	uint16_t index; /* Pool index in pools array. */
1276 	/* Free ASO CT index in the pool. Used by HWS. */
1277 	struct mlx5_indexed_pool *cts;
1278 	struct mlx5_devx_obj *devx_obj;
1279 	union {
1280 		void *dummy_action;
1281 		/* Dummy action to increase the reference count in the driver. */
1282 		struct mlx5dr_action *dr_action;
1283 		/* HWS action. */
1284 	};
1285 	struct mlx5_aso_sq *sq; /* Async ASO SQ. */
1286 	struct mlx5_aso_sq *shared_sq; /* Shared ASO SQ. */
1287 	struct mlx5_aso_ct_action actions[0];
1288 	/* CT action structures bulk. */
1289 };
1290 
1291 LIST_HEAD(aso_ct_list, mlx5_aso_ct_action);
1292 
1293 #define MLX5_ASO_CT_SQ_NUM 16
1294 
1295 /* Pools management structure for ASO connection tracking pools. */
1296 struct mlx5_aso_ct_pools_mng {
1297 	struct mlx5_aso_ct_pool **pools;
1298 	uint16_t n; /* Total number of pools. */
1299 	uint16_t next; /* Number of pools in use, index of next free pool. */
1300 	uint32_t nb_sq; /* Number of ASO SQ. */
1301 	rte_spinlock_t ct_sl; /* The ASO CT free list lock. */
1302 	rte_rwlock_t resize_rwl; /* The ASO CT pool resize lock. */
1303 	struct aso_ct_list free_cts; /* Free ASO CT objects list. */
1304 	struct mlx5_aso_sq aso_sqs[0]; /* ASO queue objects. */
1305 };
1306 
1307 #ifdef PEDANTIC
1308 #pragma GCC diagnostic error "-Wpedantic"
1309 #endif
1310 
1311 /* LAG attr. */
1312 struct mlx5_lag {
1313 	uint8_t tx_remap_affinity[16]; /* The PF port number of affinity */
1314 	uint8_t affinity_mode; /* TIS or hash based affinity */
1315 };
1316 
1317 /* DevX flex parser context. */
1318 struct mlx5_flex_parser_devx {
1319 	struct mlx5_list_entry entry;  /* List element at the beginning. */
1320 	uint32_t num_samples;
1321 	uint8_t anchor_id;
1322 	void *devx_obj;
1323 	struct mlx5_devx_graph_node_attr devx_conf;
1324 	struct mlx5_ext_sample_id sample_ids[MLX5_GRAPH_NODE_SAMPLE_NUM];
1325 };
1326 
1327 /* Pattern field descriptor - how to translate flex pattern into samples. */
1328 __extension__
1329 struct mlx5_flex_pattern_field {
1330 	uint16_t width:6;
1331 	uint16_t shift:5;
1332 	uint16_t reg_id:5;
1333 };
1334 #define MLX5_INVALID_SAMPLE_REG_ID 0x1F
1335 
1336 /* Port flex item context. */
1337 struct mlx5_flex_item {
1338 	struct mlx5_flex_parser_devx *devx_fp; /* DevX flex parser object. */
1339 	uint32_t refcnt; /* Atomically accessed refcnt by flows. */
1340 	enum rte_flow_item_flex_tunnel_mode tunnel_mode; /* Tunnel mode. */
1341 	uint32_t mapnum; /* Number of pattern translation entries. */
1342 	struct mlx5_flex_pattern_field map[MLX5_FLEX_ITEM_MAPPING_NUM];
1343 };
1344 
1345 struct mlx5_send_to_kernel_action {
1346 	void *action;
1347 	void *tbl;
1348 };
1349 
1350 #define HWS_CNT_ASO_SQ_NUM 4
1351 
1352 struct mlx5_hws_aso_mng {
1353 	uint16_t sq_num;
1354 	struct mlx5_aso_sq sqs[HWS_CNT_ASO_SQ_NUM];
1355 };
1356 
1357 struct mlx5_hws_cnt_svc_mng {
1358 	uint32_t refcnt;
1359 	uint32_t service_core;
1360 	uint32_t query_interval;
1361 	pthread_t service_thread;
1362 	uint8_t svc_running;
1363 	struct mlx5_hws_aso_mng aso_mng __rte_cache_aligned;
1364 };
1365 
1366 /*
1367  * Shared Infiniband device context for Master/Representors
1368  * which belong to same IB device with multiple IB ports.
1369  **/
1370 struct mlx5_dev_ctx_shared {
1371 	LIST_ENTRY(mlx5_dev_ctx_shared) next;
1372 	uint32_t refcnt;
1373 	uint32_t esw_mode:1; /* Whether is E-Switch mode. */
1374 	uint32_t flow_hit_aso_en:1; /* Flow Hit ASO is supported. */
1375 	uint32_t steering_format_version:4;
1376 	/* Indicates the device steering logic format. */
1377 	uint32_t meter_aso_en:1; /* Flow Meter ASO is supported. */
1378 	uint32_t ct_aso_en:1; /* Connection Tracking ASO is supported. */
1379 	uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */
1380 	uint32_t tunnel_header_2_3:1; /* tunnel_header_2_3 is supported. */
1381 	uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */
1382 	uint32_t dr_drop_action_en:1; /* Use DR drop action. */
1383 	uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */
1384 	uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */
1385 	uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */
1386 	uint32_t hws_tags:1; /* Check if tags info for HWS initialized. */
1387 	uint32_t shared_mark_enabled:1;
1388 	/* If mark action is enabled on Rxqs (shared E-Switch domain). */
1389 	uint32_t hws_max_log_bulk_sz:5;
1390 	/* Log of minimal HWS counters created hard coded. */
1391 	uint32_t hws_max_nb_counters; /* Maximal number for HWS counters. */
1392 	uint32_t max_port; /* Maximal IB device port index. */
1393 	struct mlx5_bond_info bond; /* Bonding information. */
1394 	struct mlx5_common_device *cdev; /* Backend mlx5 device. */
1395 	uint32_t tdn; /* Transport Domain number. */
1396 	char ibdev_name[MLX5_FS_NAME_MAX]; /* SYSFS dev name. */
1397 	char ibdev_path[MLX5_FS_PATH_MAX]; /* SYSFS dev path for secondary */
1398 	struct mlx5_dev_cap dev_cap; /* Device capabilities. */
1399 	struct mlx5_sh_config config; /* Device configuration. */
1400 	int numa_node; /* Numa node of backing physical device. */
1401 	/* Packet pacing related structure. */
1402 	struct mlx5_dev_txpp txpp;
1403 	/* Shared DV/DR flow data section. */
1404 	uint32_t dv_meta_mask; /* flow META metadata supported mask. */
1405 	uint32_t dv_mark_mask; /* flow MARK metadata supported mask. */
1406 	uint32_t dv_regc0_mask; /* available bits of metadata reg_c[0]. */
1407 	void *fdb_domain; /* FDB Direct Rules name space handle. */
1408 	void *rx_domain; /* RX Direct Rules name space handle. */
1409 	void *tx_domain; /* TX Direct Rules name space handle. */
1410 #ifndef RTE_ARCH_64
1411 	rte_spinlock_t uar_lock_cq; /* CQs share a common distinct UAR. */
1412 	rte_spinlock_t uar_lock[MLX5_UAR_PAGE_NUM_MAX];
1413 	/* UAR same-page access control required in 32bit implementations. */
1414 #endif
1415 	union {
1416 		struct mlx5_hlist *flow_tbls; /* SWS flow table. */
1417 		struct mlx5_hlist *groups; /* HWS flow group. */
1418 	};
1419 	struct mlx5_flow_tunnel_hub *tunnel_hub;
1420 	/* Direct Rules tables for FDB, NIC TX+RX */
1421 	void *dr_drop_action; /* Pointer to DR drop action, any domain. */
1422 	void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
1423 	struct mlx5_send_to_kernel_action send_to_kernel_action;
1424 	struct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */
1425 	struct mlx5_hlist *modify_cmds;
1426 	struct mlx5_hlist *tag_table;
1427 	struct mlx5_list *port_id_action_list; /* Port ID action list. */
1428 	struct mlx5_list *push_vlan_action_list; /* Push VLAN actions. */
1429 	struct mlx5_list *sample_action_list; /* List of sample actions. */
1430 	struct mlx5_list *dest_array_list;
1431 	struct mlx5_list *flex_parsers_dv; /* Flex Item parsers. */
1432 	/* List of destination array actions. */
1433 	struct mlx5_flow_counter_mng sws_cmng;
1434 	/* SW steering counters management structure. */
1435 	void *default_miss_action; /* Default miss action. */
1436 	struct mlx5_indexed_pool *ipool[MLX5_IPOOL_MAX];
1437 	struct mlx5_indexed_pool *mdh_ipools[MLX5_MAX_MODIFY_NUM];
1438 	/* Shared interrupt handler section. */
1439 	struct rte_intr_handle *intr_handle; /* Interrupt handler for device. */
1440 	struct rte_intr_handle *intr_handle_devx; /* DEVX interrupt handler. */
1441 	struct rte_intr_handle *intr_handle_nl; /* Netlink interrupt handler. */
1442 	void *devx_comp; /* DEVX async comp obj. */
1443 	struct mlx5_devx_obj *tis[16]; /* TIS object. */
1444 	struct mlx5_devx_obj *td; /* Transport domain. */
1445 	struct mlx5_lag lag; /* LAG attributes */
1446 	struct mlx5_uar tx_uar; /* DevX UAR for Tx and Txpp and ASO SQs. */
1447 	struct mlx5_uar rx_uar; /* DevX UAR for Rx. */
1448 	struct mlx5_proc_priv *pppriv; /* Pointer to primary private process. */
1449 	struct mlx5_ecpri_parser_profile ecpri_parser;
1450 	struct mlx5_internal_flex_parser_profile srh_flex_parser; /* srh flex parser structure. */
1451 	/* Flex parser profiles information. */
1452 	LIST_HEAD(shared_rxqs, mlx5_rxq_ctrl) shared_rxqs; /* Shared RXQs. */
1453 	struct mlx5_aso_age_mng *aso_age_mng;
1454 	/* Management data for aging mechanism using ASO Flow Hit. */
1455 	struct mlx5_geneve_tlv_option_resource *geneve_tlv_option_resource;
1456 	/* Management structure for geneve tlv option */
1457 	rte_spinlock_t geneve_tlv_opt_sl; /* Lock for geneve tlv resource */
1458 	struct mlx5_flow_mtr_mng *mtrmng;
1459 	/* Meter management structure. */
1460 	struct mlx5_aso_ct_pools_mng *ct_mng; /* Management data for ASO CT in HWS only. */
1461 	struct mlx5_lb_ctx self_lb; /* QP to enable self loopback for Devx. */
1462 	unsigned int flow_max_priority;
1463 	enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM];
1464 	/* Availability of mreg_c's. */
1465 	void *devx_channel_lwm;
1466 	struct rte_intr_handle *intr_handle_lwm;
1467 	pthread_mutex_t lwm_config_lock;
1468 	uint32_t host_shaper_rate:8;
1469 	uint32_t lwm_triggered:1;
1470 	struct mlx5_hws_cnt_svc_mng *cnt_svc;
1471 	struct mlx5_dev_shared_port port[]; /* per device port data array. */
1472 };
1473 
1474 /*
1475  * Per-process private structure.
1476  * Caution, secondary process may rebuild the struct during port start.
1477  */
1478 struct mlx5_proc_priv {
1479 	void *hca_bar;
1480 	/* Mapped HCA PCI BAR area. */
1481 	size_t uar_table_sz;
1482 	/* Size of UAR register table. */
1483 	struct mlx5_uar_data uar_table[];
1484 	/* Table of UAR registers for each process. */
1485 };
1486 
1487 /* MTR profile list. */
1488 TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);
1489 /* MTR list. */
1490 TAILQ_HEAD(mlx5_legacy_flow_meters, mlx5_legacy_flow_meter);
1491 
1492 struct mlx5_mtr_config {
1493 	uint32_t nb_meters; /**< Number of configured meters */
1494 	uint32_t nb_meter_profiles; /**< Number of configured meter profiles */
1495 	uint32_t nb_meter_policies; /**< Number of configured meter policies */
1496 };
1497 
1498 /* RSS description. */
1499 struct mlx5_flow_rss_desc {
1500 	uint32_t level;
1501 	uint32_t queue_num; /**< Number of entries in @p queue. */
1502 	uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
1503 	uint64_t hash_fields; /* Verbs Hash fields. */
1504 	uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
1505 	uint32_t key_len; /**< RSS hash key len. */
1506 	uint32_t hws_flags; /**< HW steering action. */
1507 	uint32_t tunnel; /**< Queue in tunnel. */
1508 	uint32_t shared_rss; /**< Shared RSS index. */
1509 	struct mlx5_ind_table_obj *ind_tbl;
1510 	/**< Indirection table for shared RSS hash RX queues. */
1511 	union {
1512 		uint16_t *queue; /**< Destination queues. */
1513 		const uint16_t *const_q; /**< Const pointer convert. */
1514 	};
1515 };
1516 
1517 #define MLX5_PROC_PRIV(port_id) \
1518 	((struct mlx5_proc_priv *)rte_eth_devices[port_id].process_private)
1519 
1520 /* Verbs/DevX Rx queue elements. */
1521 struct mlx5_rxq_obj {
1522 	LIST_ENTRY(mlx5_rxq_obj) next; /* Pointer to the next element. */
1523 	struct mlx5_rxq_ctrl *rxq_ctrl; /* Back pointer to parent. */
1524 	int fd; /* File descriptor for event channel */
1525 	RTE_STD_C11
1526 	union {
1527 		struct {
1528 			void *wq; /* Work Queue. */
1529 			void *ibv_cq; /* Completion Queue. */
1530 			void *ibv_channel;
1531 		};
1532 		struct mlx5_devx_obj *rq; /* DevX RQ object for hairpin. */
1533 		struct {
1534 			struct mlx5_devx_rmp devx_rmp; /* RMP for shared RQ. */
1535 			struct mlx5_devx_cq cq_obj; /* DevX CQ object. */
1536 			void *devx_channel;
1537 		};
1538 	};
1539 };
1540 
1541 /* Indirection table. */
1542 struct mlx5_ind_table_obj {
1543 	LIST_ENTRY(mlx5_ind_table_obj) next; /* Pointer to the next element. */
1544 	uint32_t refcnt; /* Reference counter. */
1545 	RTE_STD_C11
1546 	union {
1547 		void *ind_table; /**< Indirection table. */
1548 		struct mlx5_devx_obj *rqt; /* DevX RQT object. */
1549 	};
1550 	uint32_t queues_n; /**< Number of queues in the list. */
1551 	uint16_t *queues; /**< Queue list. */
1552 };
1553 
1554 /* Hash Rx queue. */
1555 __extension__
1556 struct mlx5_hrxq {
1557 	struct mlx5_list_entry entry; /* List entry. */
1558 	uint32_t standalone:1; /* This object used in shared action. */
1559 	struct mlx5_ind_table_obj *ind_table; /* Indirection table. */
1560 	RTE_STD_C11
1561 	union {
1562 		void *qp; /* Verbs queue pair. */
1563 		struct mlx5_devx_obj *tir; /* DevX TIR object. */
1564 	};
1565 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1566 	void *action; /* DV QP action pointer. */
1567 #endif
1568 	uint32_t hws_flags; /* Hw steering flags. */
1569 	uint64_t hash_fields; /* Verbs Hash fields. */
1570 	uint32_t rss_key_len; /* Hash key length in bytes. */
1571 	uint32_t idx; /* Hash Rx queue index. */
1572 	uint8_t rss_key[]; /* Hash key. */
1573 };
1574 
1575 /* Verbs/DevX Tx queue elements. */
1576 struct mlx5_txq_obj {
1577 	LIST_ENTRY(mlx5_txq_obj) next; /* Pointer to the next element. */
1578 	struct mlx5_txq_ctrl *txq_ctrl; /* Pointer to the control queue. */
1579 	RTE_STD_C11
1580 	union {
1581 		struct {
1582 			void *cq; /* Completion Queue. */
1583 			void *qp; /* Queue Pair. */
1584 		};
1585 		struct {
1586 			struct mlx5_devx_obj *sq;
1587 			/* DevX object for Sx queue. */
1588 			struct mlx5_devx_obj *tis; /* The TIS object. */
1589 			void *umem_buf_wq_buffer;
1590 			void *umem_obj_wq_buffer;
1591 		};
1592 		struct {
1593 			struct rte_eth_dev *dev;
1594 			struct mlx5_devx_cq cq_obj;
1595 			/* DevX CQ object and its resources. */
1596 			struct mlx5_devx_sq sq_obj;
1597 			/* DevX SQ object and its resources. */
1598 		};
1599 	};
1600 };
1601 
1602 enum mlx5_rxq_modify_type {
1603 	MLX5_RXQ_MOD_ERR2RST, /* modify state from error to reset. */
1604 	MLX5_RXQ_MOD_RST2RDY, /* modify state from reset to ready. */
1605 	MLX5_RXQ_MOD_RDY2ERR, /* modify state from ready to error. */
1606 	MLX5_RXQ_MOD_RDY2RST, /* modify state from ready to reset. */
1607 	MLX5_RXQ_MOD_RDY2RDY, /* modify state from ready to ready. */
1608 };
1609 
1610 enum mlx5_txq_modify_type {
1611 	MLX5_TXQ_MOD_RST2RDY, /* modify state from reset to ready. */
1612 	MLX5_TXQ_MOD_RDY2RST, /* modify state from ready to reset. */
1613 	MLX5_TXQ_MOD_ERR2RDY, /* modify state from error to ready. */
1614 };
1615 
1616 struct mlx5_rxq_priv;
1617 struct mlx5_priv;
1618 
1619 /* HW objects operations structure. */
1620 struct mlx5_obj_ops {
1621 	int (*rxq_obj_modify_vlan_strip)(struct mlx5_rxq_priv *rxq, int on);
1622 	int (*rxq_obj_new)(struct mlx5_rxq_priv *rxq);
1623 	int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);
1624 	int (*rxq_obj_modify)(struct mlx5_rxq_priv *rxq, uint8_t type);
1625 	void (*rxq_obj_release)(struct mlx5_rxq_priv *rxq);
1626 	int (*rxq_event_get_lwm)(struct mlx5_priv *priv, int *rxq_idx, int *port_id);
1627 	int (*ind_table_new)(struct rte_eth_dev *dev, const unsigned int log_n,
1628 			     struct mlx5_ind_table_obj *ind_tbl);
1629 	int (*ind_table_modify)(struct rte_eth_dev *dev,
1630 				const unsigned int log_n,
1631 				const uint16_t *queues, const uint32_t queues_n,
1632 				struct mlx5_ind_table_obj *ind_tbl);
1633 	void (*ind_table_destroy)(struct mlx5_ind_table_obj *ind_tbl);
1634 	int (*hrxq_new)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
1635 			int tunnel __rte_unused);
1636 	int (*hrxq_modify)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
1637 			   const uint8_t *rss_key,
1638 			   uint64_t hash_fields,
1639 			   const struct mlx5_ind_table_obj *ind_tbl);
1640 	void (*hrxq_destroy)(struct mlx5_hrxq *hrxq);
1641 	int (*drop_action_create)(struct rte_eth_dev *dev);
1642 	void (*drop_action_destroy)(struct rte_eth_dev *dev);
1643 	int (*txq_obj_new)(struct rte_eth_dev *dev, uint16_t idx);
1644 	int (*txq_obj_modify)(struct mlx5_txq_obj *obj,
1645 			      enum mlx5_txq_modify_type type, uint8_t dev_port);
1646 	void (*txq_obj_release)(struct mlx5_txq_obj *txq_obj);
1647 	int (*lb_dummy_queue_create)(struct rte_eth_dev *dev);
1648 	void (*lb_dummy_queue_release)(struct rte_eth_dev *dev);
1649 };
1650 
1651 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
1652 
1653 struct mlx5_hw_ctrl_flow {
1654 	LIST_ENTRY(mlx5_hw_ctrl_flow) next;
1655 	struct rte_eth_dev *owner_dev;
1656 	struct rte_flow *flow;
1657 };
1658 
1659 struct mlx5_flow_hw_ctrl_rx;
1660 
1661 struct mlx5_priv {
1662 	struct rte_eth_dev_data *dev_data;  /* Pointer to device data. */
1663 	struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
1664 	uint32_t dev_port; /* Device port number. */
1665 	struct rte_pci_device *pci_dev; /* Backend PCI device. */
1666 	struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
1667 	BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
1668 	/* Bit-field of MAC addresses owned by the PMD. */
1669 	uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
1670 	unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
1671 	/* Device properties. */
1672 	uint16_t mtu; /* Configured MTU. */
1673 	unsigned int isolated:1; /* Whether isolated mode is enabled. */
1674 	unsigned int representor:1; /* Device is a port representor. */
1675 	unsigned int master:1; /* Device is a E-Switch master. */
1676 	unsigned int txpp_en:1; /* Tx packet pacing enabled. */
1677 	unsigned int sampler_en:1; /* Whether support sampler. */
1678 	unsigned int mtr_en:1; /* Whether support meter. */
1679 	unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */
1680 	unsigned int lb_used:1; /* Loopback queue is referred to. */
1681 	uint32_t mark_enabled:1; /* If mark action is enabled on rxqs. */
1682 	uint16_t domain_id; /* Switch domain identifier. */
1683 	uint16_t vport_id; /* Associated VF vport index (if any). */
1684 	uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
1685 	uint32_t vport_meta_mask; /* Used for vport index field match mask. */
1686 	uint16_t representor_id; /* UINT16_MAX if not a representor. */
1687 	int32_t pf_bond; /* >=0, representor owner PF index in bonding. */
1688 	unsigned int if_index; /* Associated kernel network device index. */
1689 	/* RX/TX queues. */
1690 	unsigned int rxqs_n; /* RX queues array size. */
1691 	unsigned int txqs_n; /* TX queues array size. */
1692 	struct mlx5_external_rxq *ext_rxqs; /* External RX queues array. */
1693 	struct mlx5_rxq_priv *(*rxq_privs)[]; /* RX queue non-shared data. */
1694 	struct mlx5_txq_data *(*txqs)[]; /* TX queues. */
1695 	struct rte_mempool *mprq_mp; /* Mempool for Multi-Packet RQ. */
1696 	struct rte_eth_rss_conf rss_conf; /* RSS configuration. */
1697 	unsigned int (*reta_idx)[]; /* RETA index table. */
1698 	unsigned int reta_idx_n; /* RETA index size. */
1699 	struct mlx5_drop drop_queue; /* Flow drop queues. */
1700 	void *root_drop_action; /* Pointer to root drop action. */
1701 	rte_spinlock_t hw_ctrl_lock;
1702 	LIST_HEAD(hw_ctrl_flow, mlx5_hw_ctrl_flow) hw_ctrl_flows;
1703 	struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;
1704 	struct rte_flow_template_table *hw_esw_sq_miss_tbl;
1705 	struct rte_flow_template_table *hw_esw_zero_tbl;
1706 	struct rte_flow_template_table *hw_tx_meta_cpy_tbl;
1707 	struct rte_flow_pattern_template *hw_tx_repr_tagging_pt;
1708 	struct rte_flow_actions_template *hw_tx_repr_tagging_at;
1709 	struct rte_flow_template_table *hw_tx_repr_tagging_tbl;
1710 	struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI];
1711 	/* RTE Flow rules. */
1712 	uint32_t ctrl_flows; /* Control flow rules. */
1713 	rte_spinlock_t flow_list_lock;
1714 	struct mlx5_obj_ops obj_ops; /* HW objects operations. */
1715 	LIST_HEAD(rxq, mlx5_rxq_ctrl) rxqsctrl; /* DPDK Rx queues. */
1716 	LIST_HEAD(rxqobj, mlx5_rxq_obj) rxqsobj; /* Verbs/DevX Rx queues. */
1717 	struct mlx5_list *hrxqs; /* Hash Rx queues. */
1718 	LIST_HEAD(txq, mlx5_txq_ctrl) txqsctrl; /* DPDK Tx queues. */
1719 	LIST_HEAD(txqobj, mlx5_txq_obj) txqsobj; /* Verbs/DevX Tx queues. */
1720 	/* Indirection tables. */
1721 	LIST_HEAD(ind_tables, mlx5_ind_table_obj) ind_tbls;
1722 	/* Standalone indirect tables. */
1723 	LIST_HEAD(stdl_ind_tables, mlx5_ind_table_obj) standalone_ind_tbls;
1724 	/* Pointer to next element. */
1725 	rte_rwlock_t ind_tbls_lock;
1726 	uint32_t refcnt; /**< Reference counter. */
1727 	/**< Verbs modify header action object. */
1728 	uint8_t ft_type; /**< Flow table type, Rx or Tx. */
1729 	uint32_t max_lro_msg_size;
1730 	uint32_t link_speed_capa; /* Link speed capabilities. */
1731 	struct mlx5_xstats_ctrl xstats_ctrl; /* Extended stats control. */
1732 	struct mlx5_stats_ctrl stats_ctrl; /* Stats control. */
1733 	struct mlx5_port_config config; /* Port configuration. */
1734 	/* Context for Verbs allocator. */
1735 	int nl_socket_rdma; /* Netlink socket (NETLINK_RDMA). */
1736 	int nl_socket_route; /* Netlink socket (NETLINK_ROUTE). */
1737 	struct mlx5_nl_vlan_vmwa_context *vmwa_context; /* VLAN WA context. */
1738 	struct mlx5_hlist *mreg_cp_tbl;
1739 	/* Hash table of Rx metadata register copy table. */
1740 	struct mlx5_mtr_config mtr_config; /* Meter configuration */
1741 	uint8_t mtr_sfx_reg; /* Meter prefix-suffix flow match REG_C. */
1742 	uint8_t mtr_color_reg; /* Meter color match REG_C. */
1743 	struct mlx5_legacy_flow_meters flow_meters; /* MTR list. */
1744 	struct mlx5_l3t_tbl *mtr_profile_tbl; /* Meter index lookup table. */
1745 	struct mlx5_flow_meter_profile *mtr_profile_arr; /* Profile array. */
1746 	struct mlx5_l3t_tbl *policy_idx_tbl; /* Policy index lookup table. */
1747 	struct mlx5_flow_meter_policy *mtr_policy_arr; /* Policy array. */
1748 	struct mlx5_l3t_tbl *mtr_idx_tbl; /* Meter index lookup table. */
1749 	struct mlx5_mtr_bulk mtr_bulk; /* Meter index mapping for HWS */
1750 	uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */
1751 	uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
1752 	struct mlx5_mp_id mp_id; /* ID of a multi-process process */
1753 	LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */
1754 	rte_spinlock_t shared_act_sl; /* Shared actions spinlock. */
1755 	uint32_t rss_shared_actions; /* RSS shared actions. */
1756 	struct mlx5_devx_obj *q_counters; /* DevX queue counter object. */
1757 	uint32_t counter_set_id; /* Queue counter ID to set in DevX objects. */
1758 	uint32_t lag_affinity_idx; /* LAG mode queue 0 affinity starting. */
1759 	rte_spinlock_t flex_item_sl; /* Flex item list spinlock. */
1760 	struct mlx5_flex_item flex_item[MLX5_PORT_FLEX_ITEM_NUM];
1761 	/* Flex items have been created on the port. */
1762 	uint32_t flex_item_map; /* Map of allocated flex item elements. */
1763 	uint32_t nb_queue; /* HW steering queue number. */
1764 	struct mlx5_hws_cnt_pool *hws_cpool; /* HW steering's counter pool. */
1765 	uint32_t hws_mark_refcnt; /* HWS mark action reference counter. */
1766 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1767 	/* Item template list. */
1768 	LIST_HEAD(flow_hw_itt, rte_flow_pattern_template) flow_hw_itt;
1769 	/* Action template list. */
1770 	LIST_HEAD(flow_hw_at, rte_flow_actions_template) flow_hw_at;
1771 	struct mlx5dr_context *dr_ctx; /**< HW steering DR context. */
1772 	/* HW steering queue polling mechanism job descriptor LIFO. */
1773 	uint32_t hws_strict_queue:1;
1774 	/**< Whether all operations strictly happen on the same HWS queue. */
1775 	uint32_t hws_age_req:1; /**< Whether this port has AGE indexed pool. */
1776 	struct mlx5_hw_q *hw_q;
1777 	/* HW steering rte flow table list header. */
1778 	LIST_HEAD(flow_hw_tbl, rte_flow_template_table) flow_hw_tbl;
1779 	struct mlx5dr_action *hw_push_vlan[MLX5DR_TABLE_TYPE_MAX];
1780 	struct mlx5dr_action *hw_pop_vlan[MLX5DR_TABLE_TYPE_MAX];
1781 	struct mlx5dr_action **hw_vport;
1782 	/* HW steering global drop action. */
1783 	struct mlx5dr_action *hw_drop[2];
1784 	/* HW steering global tag action. */
1785 	struct mlx5dr_action *hw_tag[2];
1786 	/* HW steering create ongoing rte flow table list header. */
1787 	LIST_HEAD(flow_hw_tbl_ongo, rte_flow_template_table) flow_hw_tbl_ongo;
1788 	struct mlx5_indexed_pool *acts_ipool; /* Action data indexed pool. */
1789 	struct mlx5_aso_ct_pools_mng *ct_mng;
1790 	/* Management data for ASO connection tracking. */
1791 	struct mlx5_aso_ct_pool *hws_ctpool; /* HW steering's CT pool. */
1792 	struct mlx5_aso_mtr_pool *hws_mpool; /* HW steering's Meter pool. */
1793 	struct mlx5_flow_hw_ctrl_rx *hw_ctrl_rx;
1794 	/**< HW steering templates used to create control flow rules. */
1795 #endif
1796 	struct rte_eth_dev *shared_host; /* Host device for HW steering. */
1797 	uint16_t shared_refcnt; /* HW steering host reference counter. */
1798 };
1799 
1800 #define PORT_ID(priv) ((priv)->dev_data->port_id)
1801 #define ETH_DEV(priv) (&rte_eth_devices[PORT_ID(priv)])
1802 #define CTRL_QUEUE_ID(priv) ((priv)->nb_queue - 1)
1803 
1804 struct rte_hairpin_peer_info {
1805 	uint32_t qp_id;
1806 	uint32_t vhca_id;
1807 	uint16_t peer_q;
1808 	uint16_t tx_explicit;
1809 	uint16_t manual_bind;
1810 };
1811 
1812 #define BUF_SIZE 1024
1813 enum dr_dump_rec_type {
1814 	DR_DUMP_REC_TYPE_PMD_PKT_REFORMAT = 4410,
1815 	DR_DUMP_REC_TYPE_PMD_MODIFY_HDR = 4420,
1816 	DR_DUMP_REC_TYPE_PMD_COUNTER = 4430,
1817 };
1818 
1819 /**
1820  * Indicates whether HW objects operations can be created by DevX.
1821  *
1822  * This function is used for both:
1823  *  Before creation - deciding whether to create HW objects operations by DevX.
1824  *  After creation - indicator if HW objects operations were created by DevX.
1825  *
1826  * @param sh
1827  *   Pointer to shared device context.
1828  *
1829  * @return
1830  *   True if HW objects were created by DevX, False otherwise.
1831  */
1832 static inline bool
1833 mlx5_devx_obj_ops_en(struct mlx5_dev_ctx_shared *sh)
1834 {
1835 	/*
1836 	 * When advanced DR API is available and DV flow is supported and
1837 	 * DevX is supported, HW objects operations are created by DevX.
1838 	 */
1839 	return (sh->cdev->config.devx && sh->config.dv_flow_en &&
1840 		sh->dev_cap.dest_tir);
1841 }
1842 
1843 /* mlx5.c */
1844 
1845 int mlx5_getenv_int(const char *);
1846 int mlx5_proc_priv_init(struct rte_eth_dev *dev);
1847 void mlx5_proc_priv_uninit(struct rte_eth_dev *dev);
1848 int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
1849 			      struct rte_eth_udp_tunnel *udp_tunnel);
1850 uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev);
1851 int mlx5_dev_close(struct rte_eth_dev *dev);
1852 int mlx5_net_remove(struct mlx5_common_device *cdev);
1853 bool mlx5_is_hpf(struct rte_eth_dev *dev);
1854 bool mlx5_is_sf_repr(struct rte_eth_dev *dev);
1855 void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh);
1856 int mlx5_lwm_setup(struct mlx5_priv *priv);
1857 void mlx5_lwm_unset(struct mlx5_dev_ctx_shared *sh);
1858 
1859 /* Macro to iterate over all valid ports for mlx5 driver. */
1860 #define MLX5_ETH_FOREACH_DEV(port_id, dev) \
1861 	for (port_id = mlx5_eth_find_next(0, dev); \
1862 	     port_id < RTE_MAX_ETHPORTS; \
1863 	     port_id = mlx5_eth_find_next(port_id + 1, dev))
1864 void mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh,
1865 			      struct mlx5_hca_attr *hca_attr);
1866 struct mlx5_dev_ctx_shared *
1867 mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
1868 			  struct mlx5_kvargs_ctrl *mkvlist);
1869 void mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh);
1870 int mlx5_dev_ctx_shared_mempool_subscribe(struct rte_eth_dev *dev);
1871 void mlx5_free_table_hash_list(struct mlx5_priv *priv);
1872 int mlx5_alloc_table_hash_list(struct mlx5_priv *priv);
1873 void mlx5_set_min_inline(struct mlx5_priv *priv);
1874 void mlx5_set_metadata_mask(struct rte_eth_dev *dev);
1875 int mlx5_probe_again_args_validate(struct mlx5_common_device *cdev,
1876 				   struct mlx5_kvargs_ctrl *mkvlist);
1877 int mlx5_port_args_config(struct mlx5_priv *priv,
1878 			  struct mlx5_kvargs_ctrl *mkvlist,
1879 			  struct mlx5_port_config *config);
1880 void mlx5_port_args_set_used(const char *name, uint16_t port_id,
1881 			     struct mlx5_kvargs_ctrl *mkvlist);
1882 bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);
1883 int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);
1884 void mlx5_flow_counter_mode_config(struct rte_eth_dev *dev);
1885 int mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh);
1886 int mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh);
1887 int mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh);
1888 
1889 /* mlx5_ethdev.c */
1890 
1891 int mlx5_dev_configure(struct rte_eth_dev *dev);
1892 int mlx5_representor_info_get(struct rte_eth_dev *dev,
1893 			      struct rte_eth_representor_info *info);
1894 #define MLX5_REPRESENTOR_ID(pf, type, repr) \
1895 		(((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
1896 #define MLX5_REPRESENTOR_REPR(repr_id) \
1897 		((repr_id) & 0xfff)
1898 #define MLX5_REPRESENTOR_TYPE(repr_id) \
1899 		(((repr_id) >> 12) & 3)
1900 uint16_t mlx5_representor_id_encode(const struct mlx5_switch_info *info,
1901 				    enum rte_eth_representor_type hpf_type);
1902 int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
1903 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
1904 const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
1905 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
1906 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
1907 			 struct rte_eth_hairpin_cap *cap);
1908 eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
1909 struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
1910 struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
1911 int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
1912 
1913 /* mlx5_ethdev_os.c */
1914 
1915 int mlx5_get_ifname(const struct rte_eth_dev *dev,
1916 			char (*ifname)[MLX5_NAMESIZE]);
1917 unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
1918 int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
1919 int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
1920 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
1921 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
1922 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
1923 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
1924 			   struct rte_eth_fc_conf *fc_conf);
1925 int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
1926 			   struct rte_eth_fc_conf *fc_conf);
1927 void mlx5_dev_interrupt_handler(void *arg);
1928 void mlx5_dev_interrupt_handler_devx(void *arg);
1929 void mlx5_dev_interrupt_handler_nl(void *arg);
1930 int mlx5_set_link_down(struct rte_eth_dev *dev);
1931 int mlx5_set_link_up(struct rte_eth_dev *dev);
1932 int mlx5_is_removed(struct rte_eth_dev *dev);
1933 int mlx5_sysfs_switch_info(unsigned int ifindex,
1934 			   struct mlx5_switch_info *info);
1935 void mlx5_translate_port_name(const char *port_name_in,
1936 			      struct mlx5_switch_info *port_info_out);
1937 int mlx5_sysfs_bond_info(unsigned int pf_ifindex, unsigned int *ifindex,
1938 			 char *ifname);
1939 int mlx5_get_module_info(struct rte_eth_dev *dev,
1940 			 struct rte_eth_dev_module_info *modinfo);
1941 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
1942 			   struct rte_dev_eeprom_info *info);
1943 int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
1944 			  const char *ctr_name, uint64_t *stat);
1945 int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
1946 int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
1947 void mlx5_os_stats_init(struct rte_eth_dev *dev);
1948 int mlx5_get_flag_dropless_rq(struct rte_eth_dev *dev);
1949 
1950 /* mlx5_mac.c */
1951 
1952 void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
1953 int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
1954 		      uint32_t index, uint32_t vmdq);
1955 int mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
1956 int mlx5_set_mc_addr_list(struct rte_eth_dev *dev,
1957 			struct rte_ether_addr *mc_addr_set,
1958 			uint32_t nb_mc_addr);
1959 
1960 /* mlx5_rss.c */
1961 
1962 int mlx5_rss_hash_update(struct rte_eth_dev *dev,
1963 			 struct rte_eth_rss_conf *rss_conf);
1964 int mlx5_rss_hash_conf_get(struct rte_eth_dev *dev,
1965 			   struct rte_eth_rss_conf *rss_conf);
1966 int mlx5_rss_reta_index_resize(struct rte_eth_dev *dev, unsigned int reta_size);
1967 int mlx5_dev_rss_reta_query(struct rte_eth_dev *dev,
1968 			    struct rte_eth_rss_reta_entry64 *reta_conf,
1969 			    uint16_t reta_size);
1970 int mlx5_dev_rss_reta_update(struct rte_eth_dev *dev,
1971 			     struct rte_eth_rss_reta_entry64 *reta_conf,
1972 			     uint16_t reta_size);
1973 
1974 /* mlx5_rxmode.c */
1975 
1976 int mlx5_promiscuous_enable(struct rte_eth_dev *dev);
1977 int mlx5_promiscuous_disable(struct rte_eth_dev *dev);
1978 int mlx5_allmulticast_enable(struct rte_eth_dev *dev);
1979 int mlx5_allmulticast_disable(struct rte_eth_dev *dev);
1980 
1981 /* mlx5_stats.c */
1982 
1983 int mlx5_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
1984 int mlx5_stats_reset(struct rte_eth_dev *dev);
1985 int mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
1986 		    unsigned int n);
1987 int mlx5_xstats_reset(struct rte_eth_dev *dev);
1988 int mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
1989 			  struct rte_eth_xstat_name *xstats_names,
1990 			  unsigned int n);
1991 
1992 /* mlx5_vlan.c */
1993 
1994 int mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
1995 void mlx5_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on);
1996 int mlx5_vlan_offload_set(struct rte_eth_dev *dev, int mask);
1997 
1998 /* mlx5_vlan_os.c */
1999 
2000 void mlx5_vlan_vmwa_exit(void *ctx);
2001 void mlx5_vlan_vmwa_release(struct rte_eth_dev *dev,
2002 			    struct mlx5_vf_vlan *vf_vlan);
2003 void mlx5_vlan_vmwa_acquire(struct rte_eth_dev *dev,
2004 			    struct mlx5_vf_vlan *vf_vlan);
2005 void *mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex);
2006 
2007 /* mlx5_trigger.c */
2008 
2009 int mlx5_dev_start(struct rte_eth_dev *dev);
2010 int mlx5_dev_stop(struct rte_eth_dev *dev);
2011 int mlx5_traffic_enable(struct rte_eth_dev *dev);
2012 void mlx5_traffic_disable(struct rte_eth_dev *dev);
2013 int mlx5_traffic_restart(struct rte_eth_dev *dev);
2014 int mlx5_hairpin_queue_peer_update(struct rte_eth_dev *dev, uint16_t peer_queue,
2015 				   struct rte_hairpin_peer_info *current_info,
2016 				   struct rte_hairpin_peer_info *peer_info,
2017 				   uint32_t direction);
2018 int mlx5_hairpin_queue_peer_bind(struct rte_eth_dev *dev, uint16_t cur_queue,
2019 				 struct rte_hairpin_peer_info *peer_info,
2020 				 uint32_t direction);
2021 int mlx5_hairpin_queue_peer_unbind(struct rte_eth_dev *dev, uint16_t cur_queue,
2022 				   uint32_t direction);
2023 int mlx5_hairpin_bind(struct rte_eth_dev *dev, uint16_t rx_port);
2024 int mlx5_hairpin_unbind(struct rte_eth_dev *dev, uint16_t rx_port);
2025 int mlx5_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,
2026 				size_t len, uint32_t direction);
2027 
2028 /* mlx5_flow.c */
2029 
2030 int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
2031 bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
2032 void mlx5_flow_print(struct rte_flow *flow);
2033 int mlx5_flow_validate(struct rte_eth_dev *dev,
2034 		       const struct rte_flow_attr *attr,
2035 		       const struct rte_flow_item items[],
2036 		       const struct rte_flow_action actions[],
2037 		       struct rte_flow_error *error);
2038 struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev,
2039 				  const struct rte_flow_attr *attr,
2040 				  const struct rte_flow_item items[],
2041 				  const struct rte_flow_action actions[],
2042 				  struct rte_flow_error *error);
2043 int mlx5_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
2044 		      struct rte_flow_error *error);
2045 void mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,
2046 			  bool active);
2047 int mlx5_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
2048 int mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
2049 		    const struct rte_flow_action *action, void *data,
2050 		    struct rte_flow_error *error);
2051 int mlx5_flow_isolate(struct rte_eth_dev *dev, int enable,
2052 		      struct rte_flow_error *error);
2053 int mlx5_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);
2054 int mlx5_flow_start_default(struct rte_eth_dev *dev);
2055 void mlx5_flow_stop_default(struct rte_eth_dev *dev);
2056 int mlx5_flow_verify(struct rte_eth_dev *dev);
2057 int mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, uint32_t sq_num);
2058 int mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
2059 			struct rte_flow_item_eth *eth_spec,
2060 			struct rte_flow_item_eth *eth_mask,
2061 			struct rte_flow_item_vlan *vlan_spec,
2062 			struct rte_flow_item_vlan *vlan_mask);
2063 int mlx5_ctrl_flow(struct rte_eth_dev *dev,
2064 		   struct rte_flow_item_eth *eth_spec,
2065 		   struct rte_flow_item_eth *eth_mask);
2066 int mlx5_flow_lacp_miss(struct rte_eth_dev *dev);
2067 struct rte_flow *mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev);
2068 uint32_t mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev,
2069 					    uint32_t sq_num);
2070 void mlx5_flow_async_pool_query_handle(struct mlx5_dev_ctx_shared *sh,
2071 				       uint64_t async_id, int status);
2072 void mlx5_set_query_alarm(struct mlx5_dev_ctx_shared *sh);
2073 void mlx5_flow_query_alarm(void *arg);
2074 uint32_t mlx5_counter_alloc(struct rte_eth_dev *dev);
2075 void mlx5_counter_free(struct rte_eth_dev *dev, uint32_t cnt);
2076 int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt,
2077 		    bool clear, uint64_t *pkts, uint64_t *bytes, void **action);
2078 int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow,
2079 			FILE *file, struct rte_flow_error *error);
2080 int save_dump_file(const unsigned char *data, uint32_t size,
2081 		uint32_t type, uint64_t id, void *arg, FILE *file);
2082 int mlx5_flow_query_counter(struct rte_eth_dev *dev, struct rte_flow *flow,
2083 	struct rte_flow_query_count *count, struct rte_flow_error *error);
2084 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
2085 int mlx5_flow_dev_dump_ipool(struct rte_eth_dev *dev, struct rte_flow *flow,
2086 		FILE *file, struct rte_flow_error *error);
2087 #endif
2088 void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
2089 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
2090 			uint32_t nb_contexts, struct rte_flow_error *error);
2091 int mlx5_validate_action_ct(struct rte_eth_dev *dev,
2092 			    const struct rte_flow_action_conntrack *conntrack,
2093 			    struct rte_flow_error *error);
2094 
2095 int mlx5_flow_get_q_aged_flows(struct rte_eth_dev *dev, uint32_t queue_id,
2096 			       void **contexts, uint32_t nb_contexts,
2097 			       struct rte_flow_error *error);
2098 
2099 /* mlx5_mp_os.c */
2100 
2101 int mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg,
2102 			      const void *peer);
2103 int mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg,
2104 				const void *peer);
2105 void mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev);
2106 void mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev);
2107 int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,
2108 				 enum mlx5_mp_req_type req_type);
2109 
2110 /* mlx5_socket.c */
2111 
2112 int mlx5_pmd_socket_init(void);
2113 void mlx5_pmd_socket_uninit(void);
2114 
2115 /* mlx5_flow_meter.c */
2116 
2117 int mlx5_flow_meter_init(struct rte_eth_dev *dev,
2118 			 uint32_t nb_meters,
2119 			 uint32_t nb_meter_profiles,
2120 			 uint32_t nb_meter_policies,
2121 			 uint32_t nb_queues);
2122 void mlx5_flow_meter_uninit(struct rte_eth_dev *dev);
2123 int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);
2124 struct mlx5_flow_meter_info *mlx5_flow_meter_find(struct mlx5_priv *priv,
2125 		uint32_t meter_id, uint32_t *mtr_idx);
2126 struct mlx5_flow_meter_info *
2127 flow_dv_meter_find_by_idx(struct mlx5_priv *priv, uint32_t idx);
2128 int mlx5_flow_meter_attach(struct mlx5_priv *priv,
2129 			   struct mlx5_flow_meter_info *fm,
2130 			   const struct rte_flow_attr *attr,
2131 			   struct rte_flow_error *error);
2132 void mlx5_flow_meter_detach(struct mlx5_priv *priv,
2133 			    struct mlx5_flow_meter_info *fm);
2134 struct mlx5_flow_meter_policy *mlx5_flow_meter_policy_find
2135 		(struct rte_eth_dev *dev,
2136 		uint32_t policy_id,
2137 		uint32_t *policy_idx);
2138 struct mlx5_flow_meter_info *
2139 mlx5_flow_meter_hierarchy_next_meter(struct mlx5_priv *priv,
2140 				     struct mlx5_flow_meter_policy *policy,
2141 				     uint32_t *mtr_idx);
2142 struct mlx5_flow_meter_policy *
2143 mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,
2144 					struct mlx5_flow_meter_policy *policy);
2145 int mlx5_flow_meter_flush(struct rte_eth_dev *dev,
2146 			  struct rte_mtr_error *error);
2147 void mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev);
2148 
2149 /* mlx5_os.c */
2150 
2151 struct rte_pci_driver;
2152 int mlx5_os_capabilities_prepare(struct mlx5_dev_ctx_shared *sh);
2153 void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
2154 int mlx5_os_net_probe(struct mlx5_common_device *cdev,
2155 		      struct mlx5_kvargs_ctrl *mkvlist);
2156 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
2157 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
2158 void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
2159 int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
2160 			 uint32_t index);
2161 int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
2162 			       struct rte_ether_addr *mac_addr,
2163 			       int vf_index);
2164 int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
2165 int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
2166 int mlx5_os_set_nonblock_channel_fd(int fd);
2167 void mlx5_os_mac_addr_flush(struct rte_eth_dev *dev);
2168 void mlx5_os_net_cleanup(void);
2169 
2170 /* mlx5_txpp.c */
2171 
2172 int mlx5_txpp_start(struct rte_eth_dev *dev);
2173 void mlx5_txpp_stop(struct rte_eth_dev *dev);
2174 int mlx5_txpp_read_clock(struct rte_eth_dev *dev, uint64_t *timestamp);
2175 int mlx5_txpp_xstats_get(struct rte_eth_dev *dev,
2176 			 struct rte_eth_xstat *stats,
2177 			 unsigned int n, unsigned int n_used);
2178 int mlx5_txpp_xstats_reset(struct rte_eth_dev *dev);
2179 int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,
2180 			       struct rte_eth_xstat_name *xstats_names,
2181 			       unsigned int n, unsigned int n_used);
2182 void mlx5_txpp_interrupt_handler(void *cb_arg);
2183 int mlx5_txpp_map_hca_bar(struct rte_eth_dev *dev);
2184 void mlx5_txpp_unmap_hca_bar(struct rte_eth_dev *dev);
2185 
2186 /* mlx5_rxtx.c */
2187 
2188 eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
2189 
2190 /* mlx5_flow_aso.c */
2191 
2192 int mlx5_aso_mtr_queue_init(struct mlx5_dev_ctx_shared *sh,
2193 			    struct mlx5_aso_mtr_pool *hws_pool,
2194 			    struct mlx5_aso_mtr_pools_mng *pool_mng,
2195 			    uint32_t nb_queues);
2196 void mlx5_aso_mtr_queue_uninit(struct mlx5_dev_ctx_shared *sh,
2197 			       struct mlx5_aso_mtr_pool *hws_pool,
2198 			       struct mlx5_aso_mtr_pools_mng *pool_mng);
2199 int mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh,
2200 			enum mlx5_access_aso_opc_mod aso_opc_mode,
2201 			uint32_t nb_queues);
2202 int mlx5_aso_flow_hit_queue_poll_start(struct mlx5_dev_ctx_shared *sh);
2203 int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);
2204 void mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh,
2205 			   enum mlx5_access_aso_opc_mod aso_opc_mod);
2206 int mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2207 		struct mlx5_aso_mtr *mtr, struct mlx5_mtr_bulk *bulk,
2208 		void *user_data, bool push);
2209 int mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2210 		struct mlx5_aso_mtr *mtr);
2211 int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2212 			      struct mlx5_aso_ct_action *ct,
2213 			      const struct rte_flow_action_conntrack *profile,
2214 			      void *user_data,
2215 			      bool push);
2216 int mlx5_aso_ct_wait_ready(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2217 			   struct mlx5_aso_ct_action *ct);
2218 int mlx5_aso_ct_query_by_wqe(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2219 			     struct mlx5_aso_ct_action *ct,
2220 			     struct rte_flow_action_conntrack *profile,
2221 			     void *user_data, bool push);
2222 int mlx5_aso_ct_available(struct mlx5_dev_ctx_shared *sh, uint32_t queue,
2223 			  struct mlx5_aso_ct_action *ct);
2224 uint32_t
2225 mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);
2226 uint32_t
2227 mlx5_get_supported_tunneling_offloads(const struct mlx5_hca_attr *attr);
2228 
2229 void mlx5_aso_ct_obj_analyze(struct rte_flow_action_conntrack *profile,
2230 			     char *wdata);
2231 void mlx5_aso_push_wqe(struct mlx5_dev_ctx_shared *sh,
2232 		       struct mlx5_aso_sq *sq);
2233 int mlx5_aso_pull_completion(struct mlx5_aso_sq *sq,
2234 			     struct rte_flow_op_result res[],
2235 			     uint16_t n_res);
2236 int mlx5_aso_cnt_queue_init(struct mlx5_dev_ctx_shared *sh);
2237 void mlx5_aso_cnt_queue_uninit(struct mlx5_dev_ctx_shared *sh);
2238 int mlx5_aso_cnt_query(struct mlx5_dev_ctx_shared *sh,
2239 		struct mlx5_hws_cnt_pool *cpool);
2240 int mlx5_aso_ct_queue_init(struct mlx5_dev_ctx_shared *sh,
2241 			   struct mlx5_aso_ct_pools_mng *ct_mng,
2242 			   uint32_t nb_queues);
2243 int mlx5_aso_ct_queue_uninit(struct mlx5_dev_ctx_shared *sh,
2244 			     struct mlx5_aso_ct_pools_mng *ct_mng);
2245 
2246 /* mlx5_flow_flex.c */
2247 
2248 struct rte_flow_item_flex_handle *
2249 flow_dv_item_create(struct rte_eth_dev *dev,
2250 		    const struct rte_flow_item_flex_conf *conf,
2251 		    struct rte_flow_error *error);
2252 int flow_dv_item_release(struct rte_eth_dev *dev,
2253 		    const struct rte_flow_item_flex_handle *flex_handle,
2254 		    struct rte_flow_error *error);
2255 int mlx5_flex_item_port_init(struct rte_eth_dev *dev);
2256 void mlx5_flex_item_port_cleanup(struct rte_eth_dev *dev);
2257 void mlx5_flex_flow_translate_item(struct rte_eth_dev *dev, void *matcher,
2258 				   void *key, const struct rte_flow_item *item,
2259 				   bool is_inner);
2260 int mlx5_flex_acquire_index(struct rte_eth_dev *dev,
2261 			    struct rte_flow_item_flex_handle *handle,
2262 			    bool acquire);
2263 int mlx5_flex_release_index(struct rte_eth_dev *dev, int index);
2264 
2265 /* Flex parser list callbacks. */
2266 struct mlx5_list_entry *mlx5_flex_parser_create_cb(void *list_ctx, void *ctx);
2267 int mlx5_flex_parser_match_cb(void *list_ctx,
2268 			      struct mlx5_list_entry *iter, void *ctx);
2269 void mlx5_flex_parser_remove_cb(void *list_ctx,	struct mlx5_list_entry *entry);
2270 struct mlx5_list_entry *mlx5_flex_parser_clone_cb(void *list_ctx,
2271 						  struct mlx5_list_entry *entry,
2272 						  void *ctx);
2273 void mlx5_flex_parser_clone_free_cb(void *tool_ctx,
2274 				    struct mlx5_list_entry *entry);
2275 
2276 int mlx5_alloc_srh_flex_parser(struct rte_eth_dev *dev);
2277 
2278 void mlx5_free_srh_flex_parser(struct rte_eth_dev *dev);
2279 #endif /* RTE_PMD_MLX5_H_ */
2280