1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2015 6WIND S.A.
3 * Copyright 2015 Mellanox Technologies, Ltd
6 #ifndef RTE_PMD_MLX5_H_
7 #define RTE_PMD_MLX5_H_
13 #include <sys/queue.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>
24 #include <mlx5_glue.h>
25 #include <mlx5_devx_cmds.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>
32 #include "mlx5_defs.h"
33 #include "mlx5_utils.h"
35 #include "mlx5_autoconf.h"
38 #define MLX5_SH(dev) (((struct mlx5_priv *)(dev)->data->dev_private)->sh)
41 * Number of modification commands.
42 * The maximal actions amount in FW is some constant, and it is 16 in the
43 * latest releases. In some old releases, it will be limited to 8.
44 * Since there is no interface to query the capacity, the maximal value should
45 * be used to allow PMD to create the flow. The validation will be done in the
46 * lower driver layer or FW. A failure will be returned if exceeds the maximal
47 * supported actions number on the root table.
48 * On non-root tables, there is no limitation, but 32 is enough right now.
50 #define MLX5_MAX_MODIFY_NUM 32
51 #define MLX5_ROOT_TBL_MODIFY_NUM 16
53 enum mlx5_ipool_index {
54 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
55 MLX5_IPOOL_DECAP_ENCAP = 0, /* Pool for encap/decap resource. */
56 MLX5_IPOOL_PUSH_VLAN, /* Pool for push vlan resource. */
57 MLX5_IPOOL_TAG, /* Pool for tag resource. */
58 MLX5_IPOOL_PORT_ID, /* Pool for port id resource. */
59 MLX5_IPOOL_JUMP, /* Pool for jump resource. */
60 MLX5_IPOOL_SAMPLE, /* Pool for sample resource. */
61 MLX5_IPOOL_DEST_ARRAY, /* Pool for destination array resource. */
62 MLX5_IPOOL_TUNNEL_ID, /* Pool for tunnel offload context */
63 MLX5_IPOOL_TNL_TBL_ID, /* Pool for tunnel table ID. */
65 MLX5_IPOOL_MTR, /* Pool for meter resource. */
66 MLX5_IPOOL_MCP, /* Pool for metadata resource. */
67 MLX5_IPOOL_HRXQ, /* Pool for hrxq resource. */
68 MLX5_IPOOL_MLX5_FLOW, /* Pool for mlx5 flow handle. */
69 MLX5_IPOOL_RTE_FLOW, /* Pool for rte_flow. */
70 MLX5_IPOOL_RSS_EXPANTION_FLOW_ID, /* Pool for Queue/RSS flow ID. */
71 MLX5_IPOOL_RSS_SHARED_ACTIONS, /* Pool for RSS shared actions. */
72 MLX5_IPOOL_MTR_POLICY, /* Pool for meter policy resource. */
77 * There are three reclaim memory mode supported.
78 * 0(none) means no memory reclaim.
79 * 1(light) means only PMD level reclaim.
80 * 2(aggressive) means both PMD and rdma-core level reclaim.
82 enum mlx5_reclaim_mem_mode {
83 MLX5_RCM_NONE, /* Don't reclaim memory. */
84 MLX5_RCM_LIGHT, /* Reclaim PMD level. */
85 MLX5_RCM_AGGR, /* Reclaim PMD and rdma-core level. */
88 /* The type of flow. */
90 MLX5_FLOW_TYPE_CTL, /* Control flow. */
91 MLX5_FLOW_TYPE_GEN, /* General flow. */
92 MLX5_FLOW_TYPE_MCP, /* MCP flow. */
96 /* Hlist and list callback context. */
97 struct mlx5_flow_cb_ctx {
98 struct rte_eth_dev *dev;
99 struct rte_flow_error *error;
104 /* Device attributes used in mlx5 PMD */
105 struct mlx5_dev_attr {
106 uint64_t device_cap_flags_ex;
116 uint32_t raw_packet_caps;
117 uint32_t max_rwq_indirection_table_size;
119 uint32_t tso_supported_qpts;
122 uint32_t sw_parsing_offloads;
123 uint32_t min_single_stride_log_num_of_bytes;
124 uint32_t max_single_stride_log_num_of_bytes;
125 uint32_t min_single_wqe_log_num_of_strides;
126 uint32_t max_single_wqe_log_num_of_strides;
127 uint32_t stride_supported_qpts;
128 uint32_t tunnel_offloads_caps;
132 /** Data associated with devices to spawn. */
133 struct mlx5_dev_spawn_data {
134 uint32_t ifindex; /**< Network interface index. */
135 uint32_t max_port; /**< Device maximal port index. */
136 uint32_t phys_port; /**< Device physical port index. */
137 int pf_bond; /**< bonding device PF index. < 0 - no bonding */
138 struct mlx5_switch_info info; /**< Switch information. */
139 const char *phys_dev_name; /**< Name of physical device. */
140 void *ctx; /**< Associated physical device context. */
141 struct rte_eth_dev *eth_dev; /**< Associated Ethernet device. */
142 struct rte_pci_device *pci_dev; /**< Backend PCI device. */
143 struct mlx5_common_device *cdev; /**< Backend common device. */
144 struct mlx5_bond_info *bond_info;
147 /** Data associated with socket messages. */
148 struct mlx5_flow_dump_req {
149 uint32_t port_id; /**< There are plans in DPDK to extend port_id. */
153 struct mlx5_flow_dump_ack {
154 int rc; /**< Return code. */
157 /** Key string for IPC. */
158 #define MLX5_MP_NAME "net_mlx5_mp"
160 /** Initialize a multi-process ID. */
162 mlx5_mp_id_init(struct mlx5_mp_id *mp_id, uint16_t port_id)
164 mp_id->port_id = port_id;
165 strlcpy(mp_id->name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
168 LIST_HEAD(mlx5_dev_list, mlx5_dev_ctx_shared);
170 /* Shared data between primary and secondary processes. */
171 struct mlx5_shared_data {
173 /* Global spinlock for primary and secondary processes. */
174 int init_done; /* Whether primary has done initialization. */
175 unsigned int secondary_cnt; /* Number of secondary processes init'd. */
176 struct mlx5_dev_list mem_event_cb_list;
177 rte_rwlock_t mem_event_rwlock;
180 /* Per-process data structure, not visible to other processes. */
181 struct mlx5_local_data {
182 int init_done; /* Whether a secondary has done initialization. */
185 extern struct mlx5_shared_data *mlx5_shared_data;
187 /* Dev ops structs */
188 extern const struct eth_dev_ops mlx5_dev_ops;
189 extern const struct eth_dev_ops mlx5_dev_sec_ops;
190 extern const struct eth_dev_ops mlx5_dev_ops_isolate;
192 struct mlx5_counter_ctrl {
193 /* Name of the counter. */
194 char dpdk_name[RTE_ETH_XSTATS_NAME_SIZE];
195 /* Name of the counter on the device table. */
196 char ctr_name[RTE_ETH_XSTATS_NAME_SIZE];
197 uint32_t dev:1; /**< Nonzero for dev counters. */
200 struct mlx5_xstats_ctrl {
201 /* Number of device stats. */
203 /* Number of device stats identified by PMD. */
204 uint16_t mlx5_stats_n;
205 /* Index in the device counters table. */
206 uint16_t dev_table_idx[MLX5_MAX_XSTATS];
207 uint64_t base[MLX5_MAX_XSTATS];
208 uint64_t xstats[MLX5_MAX_XSTATS];
209 uint64_t hw_stats[MLX5_MAX_XSTATS];
210 struct mlx5_counter_ctrl info[MLX5_MAX_XSTATS];
213 struct mlx5_stats_ctrl {
214 /* Base for imissed counter. */
215 uint64_t imissed_base;
219 #define MLX5_LRO_SUPPORTED(dev) \
220 (((struct mlx5_priv *)((dev)->data->dev_private))->config.lro.supported)
222 /* Maximal size of coalesced segment for LRO is set in chunks of 256 Bytes. */
223 #define MLX5_LRO_SEG_CHUNK_SIZE 256u
225 /* Maximal size of aggregated LRO packet. */
226 #define MLX5_MAX_LRO_SIZE (UINT8_MAX * MLX5_LRO_SEG_CHUNK_SIZE)
228 /* Maximal number of segments to split. */
229 #define MLX5_MAX_RXQ_NSEG (1u << MLX5_MAX_LOG_RQ_SEGS)
231 /* LRO configurations structure. */
232 struct mlx5_lro_config {
233 uint32_t supported:1; /* Whether LRO is supported. */
234 uint32_t timeout; /* User configuration. */
238 * Device configuration structure.
240 * Merged configuration from:
242 * - Device capabilities,
243 * - User device parameters disabled features.
245 struct mlx5_dev_config {
246 unsigned int hw_csum:1; /* Checksum offload is supported. */
247 unsigned int hw_vlan_strip:1; /* VLAN stripping is supported. */
248 unsigned int hw_vlan_insert:1; /* VLAN insertion in WQE is supported. */
249 unsigned int hw_fcs_strip:1; /* FCS stripping is supported. */
250 unsigned int hw_padding:1; /* End alignment padding is supported. */
251 unsigned int vf:1; /* This is a VF. */
252 unsigned int sf:1; /* This is a SF. */
253 unsigned int tunnel_en:3;
254 /* Whether tunnel stateless offloads are supported. */
255 unsigned int mpls_en:1; /* MPLS over GRE/UDP is enabled. */
256 unsigned int cqe_comp:1; /* CQE compression is enabled. */
257 unsigned int cqe_comp_fmt:3; /* CQE compression format. */
258 unsigned int tso:1; /* Whether TSO is supported. */
259 unsigned int rx_vec_en:1; /* Rx vector is enabled. */
260 unsigned int l3_vxlan_en:1; /* Enable L3 VXLAN flow creation. */
261 unsigned int vf_nl_en:1; /* Enable Netlink requests in VF mode. */
262 unsigned int dv_esw_en:1; /* Enable E-Switch DV flow. */
263 unsigned int dv_flow_en:1; /* Enable DV flow. */
264 unsigned int dv_xmeta_en:2; /* Enable extensive flow metadata. */
265 unsigned int lacp_by_user:1;
266 /* Enable user to manage LACP traffic. */
267 unsigned int swp:3; /* Tx generic tunnel checksum and TSO offload. */
268 unsigned int devx:1; /* Whether devx interface is available or not. */
269 unsigned int dest_tir:1; /* Whether advanced DR API is available. */
270 unsigned int reclaim_mode:2; /* Memory reclaim mode. */
271 unsigned int rt_timestamp:1; /* realtime timestamp format. */
272 unsigned int decap_en:1; /* Whether decap will be used or not. */
273 unsigned int dv_miss_info:1; /* restore packet after partial hw miss */
274 unsigned int allow_duplicate_pattern:1;
275 /* Allow/Prevent the duplicate rules pattern. */
277 unsigned int enabled:1; /* Whether MPRQ is enabled. */
278 unsigned int stride_num_n; /* Number of strides. */
279 unsigned int stride_size_n; /* Size of a stride. */
280 unsigned int min_stride_size_n; /* Min size of a stride. */
281 unsigned int max_stride_size_n; /* Max size of a stride. */
282 unsigned int max_memcpy_len;
283 /* Maximum packet size to memcpy Rx packets. */
284 unsigned int min_rxqs_num;
285 /* Rx queue count threshold to enable MPRQ. */
286 } mprq; /* Configurations for Multi-Packet RQ. */
287 int mps; /* Multi-packet send supported mode. */
288 unsigned int flow_prio; /* Number of flow priorities. */
289 enum modify_reg flow_mreg_c[MLX5_MREG_C_NUM];
290 /* Availibility of mreg_c's. */
291 unsigned int tso_max_payload_sz; /* Maximum TCP payload for TSO. */
292 unsigned int ind_table_max_size; /* Maximum indirection table size. */
293 unsigned int max_dump_files_num; /* Maximum dump files per queue. */
294 unsigned int log_hp_size; /* Single hairpin queue data size in total. */
295 int txqs_inline; /* Queue number threshold for inlining. */
296 int txq_inline_min; /* Minimal amount of data bytes to inline. */
297 int txq_inline_max; /* Max packet size for inlining with SEND. */
298 int txq_inline_mpw; /* Max packet size for inlining with eMPW. */
299 int tx_pp; /* Timestamp scheduling granularity in nanoseconds. */
300 int tx_skew; /* Tx scheduling skew between WQE and data on wire. */
301 struct mlx5_hca_attr hca_attr; /* HCA attributes. */
302 struct mlx5_lro_config lro; /* LRO configuration. */
306 /* Structure for VF VLAN workaround. */
307 struct mlx5_vf_vlan {
312 /* Flow drop context necessary due to Verbs API. */
314 struct mlx5_hrxq *hrxq; /* Hash Rx queue queue. */
315 struct mlx5_rxq_obj *rxq; /* Rx queue object. */
318 /* Loopback dummy queue resources required due to Verbs API. */
320 struct ibv_qp *qp; /* QP object. */
321 void *ibv_cq; /* Completion queue. */
322 uint16_t refcnt; /* Reference count for representors. */
325 #define MLX5_COUNTERS_PER_POOL 512
326 #define MLX5_MAX_PENDING_QUERIES 4
327 #define MLX5_CNT_CONTAINER_RESIZE 64
328 #define MLX5_CNT_SHARED_OFFSET 0x80000000
329 #define IS_BATCH_CNT(cnt) (((cnt) & (MLX5_CNT_SHARED_OFFSET - 1)) >= \
330 MLX5_CNT_BATCH_OFFSET)
331 #define MLX5_CNT_SIZE (sizeof(struct mlx5_flow_counter))
332 #define MLX5_AGE_SIZE (sizeof(struct mlx5_age_param))
334 #define MLX5_CNT_LEN(pool) \
336 ((pool)->is_aged ? MLX5_AGE_SIZE : 0))
337 #define MLX5_POOL_GET_CNT(pool, index) \
338 ((struct mlx5_flow_counter *) \
339 ((uint8_t *)((pool) + 1) + (index) * (MLX5_CNT_LEN(pool))))
340 #define MLX5_CNT_ARRAY_IDX(pool, cnt) \
341 ((int)(((uint8_t *)(cnt) - (uint8_t *)((pool) + 1)) / \
344 * The pool index and offset of counter in the pool array makes up the
345 * counter index. In case the counter is from pool 0 and offset 0, it
346 * should plus 1 to avoid index 0, since 0 means invalid counter index
349 #define MLX5_MAKE_CNT_IDX(pi, offset) \
350 ((pi) * MLX5_COUNTERS_PER_POOL + (offset) + 1)
351 #define MLX5_CNT_TO_AGE(cnt) \
352 ((struct mlx5_age_param *)((cnt) + 1))
354 * The maximum single counter is 0x800000 as MLX5_CNT_BATCH_OFFSET
355 * defines. The pool size is 512, pool index should never reach
358 #define POOL_IDX_INVALID UINT16_MAX
362 AGE_FREE, /* Initialized state. */
363 AGE_CANDIDATE, /* Counter assigned to flows. */
364 AGE_TMOUT, /* Timeout, wait for rte_flow_get_aged_flows and destroy. */
367 enum mlx5_counter_type {
368 MLX5_COUNTER_TYPE_ORIGIN,
369 MLX5_COUNTER_TYPE_AGE,
370 MLX5_COUNTER_TYPE_MAX,
373 /* Counter age parameter. */
374 struct mlx5_age_param {
375 uint16_t state; /**< Age state (atomically accessed). */
376 uint16_t port_id; /**< Port id of the counter. */
377 uint32_t timeout:24; /**< Aging timeout in seconds. */
378 uint32_t sec_since_last_hit;
379 /**< Time in seconds since last hit (atomically accessed). */
380 void *context; /**< Flow counter age context. */
383 struct flow_counter_stats {
388 /* Shared counters information for counters. */
389 struct mlx5_flow_counter_shared {
391 uint32_t refcnt; /* Only for shared action management. */
392 uint32_t id; /* User counter ID for legacy sharing. */
396 struct mlx5_flow_counter_pool;
397 /* Generic counters information. */
398 struct mlx5_flow_counter {
401 * User-defined counter shared info is only used during
402 * counter active time. And aging counter sharing is not
403 * supported, so active shared counter will not be chained
404 * to the aging list. For shared counter, only when it is
405 * released, the TAILQ entry memory will be used, at that
406 * time, shared memory is not used anymore.
408 * Similarly to none-batch counter dcs, since it doesn't
409 * support aging, while counter is allocated, the entry
410 * memory is not used anymore. In this case, as bytes
411 * memory is used only when counter is allocated, and
412 * entry memory is used only when counter is free. The
413 * dcs pointer can be saved to these two different place
414 * at different stage. It will eliminate the individual
415 * counter extend struct.
417 TAILQ_ENTRY(mlx5_flow_counter) next;
418 /**< Pointer to the next flow counter structure. */
420 struct mlx5_flow_counter_shared shared_info;
421 /**< Shared counter information. */
422 void *dcs_when_active;
424 * For non-batch mode, the dcs will be saved
425 * here when the counter is free.
430 uint64_t hits; /**< Reset value of hits packets. */
431 struct mlx5_flow_counter_pool *pool; /**< Counter pool. */
434 uint64_t bytes; /**< Reset value of bytes. */
437 * For non-batch mode, the dcs will be saved here
438 * when the counter is free.
441 void *action; /**< Pointer to the dv action. */
444 TAILQ_HEAD(mlx5_counters, mlx5_flow_counter);
446 /* Generic counter pool structure - query is in pool resolution. */
447 struct mlx5_flow_counter_pool {
448 TAILQ_ENTRY(mlx5_flow_counter_pool) next;
449 struct mlx5_counters counters[2]; /* Free counter list. */
450 struct mlx5_devx_obj *min_dcs;
451 /* The devx object of the minimum counter ID. */
452 uint64_t time_of_last_age_check;
453 /* System time (from rte_rdtsc()) read in the last aging check. */
454 uint32_t index:30; /* Pool index in container. */
455 uint32_t is_aged:1; /* Pool with aging counter. */
456 volatile uint32_t query_gen:1; /* Query round. */
457 rte_spinlock_t sl; /* The pool lock. */
458 rte_spinlock_t csl; /* The pool counter free list lock. */
459 struct mlx5_counter_stats_raw *raw;
460 struct mlx5_counter_stats_raw *raw_hw;
461 /* The raw on HW working. */
464 /* Memory management structure for group of counter statistics raws. */
465 struct mlx5_counter_stats_mem_mng {
466 LIST_ENTRY(mlx5_counter_stats_mem_mng) next;
467 struct mlx5_counter_stats_raw *raws;
468 struct mlx5_devx_obj *dm;
472 /* Raw memory structure for the counter statistics values of a pool. */
473 struct mlx5_counter_stats_raw {
474 LIST_ENTRY(mlx5_counter_stats_raw) next;
475 struct mlx5_counter_stats_mem_mng *mem_mng;
476 volatile struct flow_counter_stats *data;
479 TAILQ_HEAD(mlx5_counter_pools, mlx5_flow_counter_pool);
481 /* Counter global management structure. */
482 struct mlx5_flow_counter_mng {
483 volatile uint16_t n_valid; /* Number of valid pools. */
484 uint16_t n; /* Number of pools. */
485 uint16_t last_pool_idx; /* Last used pool index */
486 int min_id; /* The minimum counter ID in the pools. */
487 int max_id; /* The maximum counter ID in the pools. */
488 rte_spinlock_t pool_update_sl; /* The pool update lock. */
489 rte_spinlock_t csl[MLX5_COUNTER_TYPE_MAX];
490 /* The counter free list lock. */
491 struct mlx5_counters counters[MLX5_COUNTER_TYPE_MAX];
492 /* Free counter list. */
493 struct mlx5_flow_counter_pool **pools; /* Counter pool array. */
494 struct mlx5_counter_stats_mem_mng *mem_mng;
495 /* Hold the memory management for the next allocated pools raws. */
496 struct mlx5_counters flow_counters; /* Legacy flow counter list. */
497 uint8_t pending_queries;
499 uint8_t query_thread_on;
500 bool relaxed_ordering_read;
501 bool relaxed_ordering_write;
502 bool counter_fallback; /* Use counter fallback management. */
503 LIST_HEAD(mem_mngs, mlx5_counter_stats_mem_mng) mem_mngs;
504 LIST_HEAD(stat_raws, mlx5_counter_stats_raw) free_stat_raws;
507 /* ASO structures. */
508 #define MLX5_ASO_QUEUE_LOG_DESC 10
513 struct mlx5_devx_cq cq_obj;
517 struct mlx5_aso_sq_elem {
520 struct mlx5_aso_age_pool *pool;
523 struct mlx5_aso_mtr *mtr;
525 struct mlx5_aso_ct_action *ct;
534 struct mlx5_aso_cq cq;
535 struct mlx5_devx_sq sq_obj;
536 volatile uint64_t *uar_addr;
537 struct mlx5_pmd_mr mr;
542 struct mlx5_aso_sq_elem elts[1 << MLX5_ASO_QUEUE_LOG_DESC];
543 uint16_t next; /* Pool index of the next pool to query. */
546 struct mlx5_aso_age_action {
547 LIST_ENTRY(mlx5_aso_age_action) next;
550 /* Following fields relevant only when action is active. */
551 uint16_t offset; /* Offset of ASO Flow Hit flag in DevX object. */
552 struct mlx5_age_param age_params;
555 #define MLX5_ASO_AGE_ACTIONS_PER_POOL 512
557 struct mlx5_aso_age_pool {
558 struct mlx5_devx_obj *flow_hit_aso_obj;
559 uint16_t index; /* Pool index in pools array. */
560 uint64_t time_of_last_age_check; /* In seconds. */
561 struct mlx5_aso_age_action actions[MLX5_ASO_AGE_ACTIONS_PER_POOL];
564 LIST_HEAD(aso_age_list, mlx5_aso_age_action);
566 struct mlx5_aso_age_mng {
567 struct mlx5_aso_age_pool **pools;
568 uint16_t n; /* Total number of pools. */
569 uint16_t next; /* Number of pools in use, index of next free pool. */
570 rte_spinlock_t resize_sl; /* Lock for resize objects. */
571 rte_spinlock_t free_sl; /* Lock for free list access. */
572 struct aso_age_list free; /* Free age actions list - ready to use. */
573 struct mlx5_aso_sq aso_sq; /* ASO queue objects. */
576 /* Management structure for geneve tlv option */
577 struct mlx5_geneve_tlv_option_resource {
578 struct mlx5_devx_obj *obj; /* Pointer to the geneve tlv opt object. */
579 rte_be16_t option_class; /* geneve tlv opt class.*/
580 uint8_t option_type; /* geneve tlv opt type.*/
581 uint8_t length; /* geneve tlv opt length. */
582 uint32_t refcnt; /* geneve tlv object reference counter */
586 #define MLX5_AGE_EVENT_NEW 1
587 #define MLX5_AGE_TRIGGER 2
588 #define MLX5_AGE_SET(age_info, BIT) \
589 ((age_info)->flags |= (1 << (BIT)))
590 #define MLX5_AGE_UNSET(age_info, BIT) \
591 ((age_info)->flags &= ~(1 << (BIT)))
592 #define MLX5_AGE_GET(age_info, BIT) \
593 ((age_info)->flags & (1 << (BIT)))
594 #define GET_PORT_AGE_INFO(priv) \
595 (&((priv)->sh->port[(priv)->dev_port - 1].age_info))
596 /* Current time in seconds. */
597 #define MLX5_CURR_TIME_SEC (rte_rdtsc() / rte_get_tsc_hz())
599 /* Aging information for per port. */
600 struct mlx5_age_info {
601 uint8_t flags; /* Indicate if is new event or need to be triggered. */
602 struct mlx5_counters aged_counters; /* Aged counter list. */
603 struct aso_age_list aged_aso; /* Aged ASO actions list. */
604 rte_spinlock_t aged_sl; /* Aged flow list lock. */
607 /* Per port data of shared IB device. */
608 struct mlx5_dev_shared_port {
610 uint32_t devx_ih_port_id;
612 * Interrupt handler port_id. Used by shared interrupt
613 * handler to find the corresponding rte_eth device
614 * by IB port index. If value is equal or greater
615 * RTE_MAX_ETHPORTS it means there is no subhandler
616 * installed for specified IB port index.
618 struct mlx5_age_info age_info;
619 /* Aging information for per port. */
623 * Max number of actions per DV flow.
624 * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED
625 * in rdma-core file providers/mlx5/verbs.c.
627 #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
629 /* ASO flow meter structures */
630 /* Modify this value if enum rte_mtr_color changes. */
631 #define RTE_MTR_DROPPED RTE_COLORS
632 /* Yellow is now supported. */
633 #define MLX5_MTR_RTE_COLORS (RTE_COLOR_YELLOW + 1)
634 /* table_id 22 bits in mlx5_flow_tbl_key so limit policy number. */
635 #define MLX5_MAX_SUB_POLICY_TBL_NUM 0x3FFFFF
636 #define MLX5_INVALID_POLICY_ID UINT32_MAX
637 /* Suffix table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
638 #define MLX5_MTR_TABLE_ID_SUFFIX 1
639 /* Drop table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
640 #define MLX5_MTR_TABLE_ID_DROP 2
641 /* Priority of the meter policy matcher. */
642 #define MLX5_MTR_POLICY_MATCHER_PRIO 0
643 /* Default policy. */
644 #define MLX5_MTR_POLICY_MODE_DEF 1
645 /* Only green color valid. */
646 #define MLX5_MTR_POLICY_MODE_OG 2
647 /* Only yellow color valid. */
648 #define MLX5_MTR_POLICY_MODE_OY 3
650 enum mlx5_meter_domain {
651 MLX5_MTR_DOMAIN_INGRESS,
652 MLX5_MTR_DOMAIN_EGRESS,
653 MLX5_MTR_DOMAIN_TRANSFER,
656 #define MLX5_MTR_DOMAIN_INGRESS_BIT (1 << MLX5_MTR_DOMAIN_INGRESS)
657 #define MLX5_MTR_DOMAIN_EGRESS_BIT (1 << MLX5_MTR_DOMAIN_EGRESS)
658 #define MLX5_MTR_DOMAIN_TRANSFER_BIT (1 << MLX5_MTR_DOMAIN_TRANSFER)
659 #define MLX5_MTR_ALL_DOMAIN_BIT (MLX5_MTR_DOMAIN_INGRESS_BIT | \
660 MLX5_MTR_DOMAIN_EGRESS_BIT | \
661 MLX5_MTR_DOMAIN_TRANSFER_BIT)
663 /* The color tag rule structure. */
664 struct mlx5_sub_policy_color_rule {
666 /* The color rule. */
667 struct mlx5_flow_dv_matcher *matcher;
668 /* The color matcher. */
669 TAILQ_ENTRY(mlx5_sub_policy_color_rule) next_port;
670 /**< Pointer to the next color rule structure. */
672 /* On which src port this rule applied. */
675 TAILQ_HEAD(mlx5_sub_policy_color_rules, mlx5_sub_policy_color_rule);
678 * Meter sub-policy structure.
679 * Each RSS TIR in meter policy need its own sub-policy resource.
681 struct mlx5_flow_meter_sub_policy {
682 uint32_t main_policy_id:1;
683 /* Main policy id is same as this sub_policy id. */
685 /* Index to sub_policy ipool entity. */
687 /* Point to struct mlx5_flow_meter_policy. */
688 struct mlx5_flow_tbl_resource *tbl_rsc;
689 /* The sub-policy table resource. */
690 uint32_t rix_hrxq[MLX5_MTR_RTE_COLORS];
691 /* Index to TIR resource. */
692 struct mlx5_flow_tbl_resource *jump_tbl[MLX5_MTR_RTE_COLORS];
693 /* Meter jump/drop table. */
694 struct mlx5_sub_policy_color_rules color_rules[RTE_COLORS];
695 /* List for the color rules. */
698 struct mlx5_meter_policy_acts {
700 /* Number of actions. */
701 void *dv_actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
705 struct mlx5_meter_policy_action_container {
707 /* Index to the mark action. */
708 struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
709 /* Pointer to modify header resource in cache. */
711 /* Fate action type. */
713 struct rte_flow_action *rss;
714 /* Rss action configuration. */
715 uint32_t rix_port_id_action;
716 /* Index to port ID action resource. */
717 void *dr_jump_action[MLX5_MTR_DOMAIN_MAX];
718 /* Jump/drop action per color. */
720 /* Queue action configuration. */
722 uint32_t next_mtr_id;
723 /* The next meter id. */
724 void *next_sub_policy;
725 /* Next meter's sub-policy. */
730 /* Flow meter policy parameter structure. */
731 struct mlx5_flow_meter_policy {
732 struct rte_eth_dev *dev;
733 /* The port dev on which policy is created. */
735 /* Is RSS policy table. */
737 /* Rule applies to ingress domain. */
739 /* Rule applies to egress domain. */
741 /* Rule applies to transfer domain. */
743 /* Is queue action in policy table. */
744 uint32_t is_hierarchy:1;
745 /* Is meter action in policy table. */
747 /* If yellow color policy is skipped. */
749 /* If green color policy is skipped. */
753 struct mlx5_meter_policy_action_container act_cnt[MLX5_MTR_RTE_COLORS];
754 /* Policy actions container. */
755 void *dr_drop_action[MLX5_MTR_DOMAIN_MAX];
756 /* drop action for red color. */
757 uint16_t sub_policy_num;
758 /* Count sub policy tables, 3 bits per domain. */
759 struct mlx5_flow_meter_sub_policy **sub_policys[MLX5_MTR_DOMAIN_MAX];
760 /* Sub policy table array must be the end of struct. */
763 /* The maximum sub policy is relate to struct mlx5_rss_hash_fields[]. */
764 #define MLX5_MTR_RSS_MAX_SUB_POLICY 7
765 #define MLX5_MTR_SUB_POLICY_NUM_SHIFT 3
766 #define MLX5_MTR_SUB_POLICY_NUM_MASK 0x7
767 #define MLX5_MTRS_DEFAULT_RULE_PRIORITY 0xFFFF
768 #define MLX5_MTR_CHAIN_MAX_NUM 8
770 /* Flow meter default policy parameter structure.
771 * Policy index 0 is reserved by default policy table.
772 * Action per color as below:
773 * green - do nothing, yellow - do nothing, red - drop
775 struct mlx5_flow_meter_def_policy {
776 struct mlx5_flow_meter_sub_policy sub_policy;
777 /* Policy rules jump to other tables. */
778 void *dr_jump_action[RTE_COLORS];
779 /* Jump action per color. */
782 /* Meter parameter structure. */
783 struct mlx5_flow_meter_info {
787 /* Policy id, the first sub_policy idx. */
788 struct mlx5_flow_meter_profile *profile;
789 /**< Meter profile parameters. */
790 rte_spinlock_t sl; /**< Meter action spinlock. */
791 /** Set of stats counters to be enabled.
792 * @see enum rte_mtr_stats_type
794 uint32_t bytes_dropped:1;
795 /** Set bytes dropped stats to be enabled. */
796 uint32_t pkts_dropped:1;
797 /** Set packets dropped stats to be enabled. */
798 uint32_t active_state:1;
799 /**< Meter hw active state. */
801 /**< Meter shared or not. */
802 uint32_t is_enable:1;
803 /**< Meter disable/enable state. */
805 /**< Rule applies to egress traffic. */
808 * Instead of simply matching the properties of traffic as it would
809 * appear on a given DPDK port ID, enabling this attribute transfers
810 * a flow rule to the lowest possible level of any device endpoints
811 * found in the pattern.
813 * When supported, this effectively enables an application to
814 * re-route traffic not necessarily intended for it (e.g. coming
815 * from or addressed to different physical ports, VFs or
816 * applications) at the device level.
818 * It complements the behavior of some pattern items such as
819 * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
821 * When transferring flow rules, ingress and egress attributes keep
822 * their original meaning, as if processing traffic emitted or
823 * received by the application.
826 uint32_t def_policy:1;
827 /* Meter points to default policy. */
828 void *drop_rule[MLX5_MTR_DOMAIN_MAX];
829 /* Meter drop rule in drop table. */
831 /**< Color counter for drop. */
834 struct mlx5_indexed_pool *flow_ipool;
835 /**< Index pool for flow id. */
837 /**< Flow meter action. */
840 /* PPS(packets per second) map to BPS(Bytes per second).
841 * HW treat packet as 128bytes in PPS mode
843 #define MLX5_MTRS_PPS_MAP_BPS_SHIFT 7
845 /* RFC2697 parameter structure. */
846 struct mlx5_flow_meter_srtcm_rfc2697_prm {
849 * bit 24-28: cbs_exponent, bit 16-23 cbs_mantissa,
850 * bit 8-12: cir_exponent, bit 0-7 cir_mantissa.
854 * bit 24-28: ebs_exponent, bit 16-23 ebs_mantissa,
855 * bit 8-12: eir_exponent, bit 0-7 eir_mantissa.
859 /* Flow meter profile structure. */
860 struct mlx5_flow_meter_profile {
861 TAILQ_ENTRY(mlx5_flow_meter_profile) next;
862 /**< Pointer to the next flow meter structure. */
863 uint32_t id; /**< Profile id. */
864 struct rte_mtr_meter_profile profile; /**< Profile detail. */
866 struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm_prm;
867 /**< srtcm_rfc2697 struct. */
869 uint32_t ref_cnt; /**< Use count. */
870 uint32_t g_support:1; /**< If G color will be generated. */
871 uint32_t y_support:1; /**< If Y color will be generated. */
874 /* 2 meters in each ASO cache line */
875 #define MLX5_MTRS_CONTAINER_RESIZE 64
877 * The pool index and offset of meter in the pool array makes up the
878 * meter index. In case the meter is from pool 0 and offset 0, it
879 * should plus 1 to avoid index 0, since 0 means invalid meter index
882 #define MLX5_MAKE_MTR_IDX(pi, offset) \
883 ((pi) * MLX5_ASO_MTRS_PER_POOL + (offset) + 1)
885 /*aso flow meter state*/
886 enum mlx5_aso_mtr_state {
887 ASO_METER_FREE, /* In free list. */
888 ASO_METER_WAIT, /* ACCESS_ASO WQE in progress. */
889 ASO_METER_READY, /* CQE received. */
892 /* Generic aso_flow_meter information. */
893 struct mlx5_aso_mtr {
894 LIST_ENTRY(mlx5_aso_mtr) next;
895 struct mlx5_flow_meter_info fm;
896 /**< Pointer to the next aso flow meter structure. */
897 uint8_t state; /**< ASO flow meter state. */
901 /* Generic aso_flow_meter pool structure. */
902 struct mlx5_aso_mtr_pool {
903 struct mlx5_aso_mtr mtrs[MLX5_ASO_MTRS_PER_POOL];
904 /*Must be the first in pool*/
905 struct mlx5_devx_obj *devx_obj;
906 /* The devx object of the minimum aso flow meter ID. */
907 uint32_t index; /* Pool index in management structure. */
910 LIST_HEAD(aso_meter_list, mlx5_aso_mtr);
911 /* Pools management structure for ASO flow meter pools. */
912 struct mlx5_aso_mtr_pools_mng {
913 volatile uint16_t n_valid; /* Number of valid pools. */
914 uint16_t n; /* Number of pools. */
915 rte_spinlock_t mtrsl; /* The ASO flow meter free list lock. */
916 struct aso_meter_list meters; /* Free ASO flow meter list. */
917 struct mlx5_aso_sq sq; /*SQ using by ASO flow meter. */
918 struct mlx5_aso_mtr_pool **pools; /* ASO flow meter pool array. */
921 /* Meter management structure for global flow meter resource. */
922 struct mlx5_flow_mtr_mng {
923 struct mlx5_aso_mtr_pools_mng pools_mng;
924 /* Pools management structure for ASO flow meter pools. */
925 struct mlx5_flow_meter_def_policy *def_policy[MLX5_MTR_DOMAIN_MAX];
926 /* Default policy table. */
927 uint32_t def_policy_id;
928 /* Default policy id. */
929 uint32_t def_policy_ref_cnt;
930 /** def_policy meter use count. */
931 struct mlx5_flow_tbl_resource *drop_tbl[MLX5_MTR_DOMAIN_MAX];
932 /* Meter drop table. */
933 struct mlx5_flow_dv_matcher *
934 drop_matcher[MLX5_MTR_DOMAIN_MAX][MLX5_REG_BITS];
935 /* Matcher meter in drop table. */
936 struct mlx5_flow_dv_matcher *def_matcher[MLX5_MTR_DOMAIN_MAX];
937 /* Default matcher in drop table. */
938 void *def_rule[MLX5_MTR_DOMAIN_MAX];
939 /* Default rule in drop table. */
940 uint8_t max_mtr_bits;
941 /* Indicate how many bits are used by meter id at the most. */
942 uint8_t max_mtr_flow_bits;
943 /* Indicate how many bits are used by meter flow id at the most. */
946 /* Table key of the hash organization. */
947 union mlx5_flow_tbl_key {
949 /* Table ID should be at the lowest address. */
950 uint32_t level; /**< Level of the table. */
951 uint32_t id:22; /**< ID of the table. */
952 uint32_t dummy:1; /**< Dummy table for DV API. */
953 uint32_t is_fdb:1; /**< 1 - FDB, 0 - NIC TX/RX. */
954 uint32_t is_egress:1; /**< 1 - egress, 0 - ingress. */
955 uint32_t reserved:7; /**< must be zero for comparison. */
957 uint64_t v64; /**< full 64bits value of key */
960 /* Table structure. */
961 struct mlx5_flow_tbl_resource {
962 void *obj; /**< Pointer to DR table object. */
963 uint32_t refcnt; /**< Reference counter. */
966 #define MLX5_MAX_TABLES UINT16_MAX
967 #define MLX5_HAIRPIN_TX_TABLE (UINT16_MAX - 1)
968 /* Reserve the last two tables for metadata register copy. */
969 #define MLX5_FLOW_MREG_ACT_TABLE_GROUP (MLX5_MAX_TABLES - 1)
970 #define MLX5_FLOW_MREG_CP_TABLE_GROUP (MLX5_MAX_TABLES - 2)
971 /* Tables for metering splits should be added here. */
972 #define MLX5_FLOW_TABLE_LEVEL_METER (MLX5_MAX_TABLES - 3)
973 #define MLX5_FLOW_TABLE_LEVEL_POLICY (MLX5_MAX_TABLES - 4)
974 #define MLX5_MAX_TABLES_EXTERNAL MLX5_FLOW_TABLE_LEVEL_POLICY
975 #define MLX5_MAX_TABLES_FDB UINT16_MAX
976 #define MLX5_FLOW_TABLE_FACTOR 10
978 /* ID generation structure. */
979 struct mlx5_flow_id_pool {
980 uint32_t *free_arr; /**< Pointer to the a array of free values. */
982 /**< The next index that can be used without any free elements. */
983 uint32_t *curr; /**< Pointer to the index to pop. */
984 uint32_t *last; /**< Pointer to the last element in the empty arrray. */
985 uint32_t max_id; /**< Maximum id can be allocated from the pool. */
988 /* Tx pacing queue structure - for Clock and Rearm queues. */
989 struct mlx5_txpp_wq {
990 /* Completion Queue related data.*/
991 struct mlx5_devx_cq cq_obj;
994 /* Send Queue related data.*/
995 struct mlx5_devx_sq sq_obj;
996 uint16_t sq_size; /* Number of WQEs in the queue. */
997 uint16_t sq_ci; /* Next WQE to execute. */
1000 /* Tx packet pacing internal timestamp. */
1001 struct mlx5_txpp_ts {
1006 /* Tx packet pacing structure. */
1007 struct mlx5_dev_txpp {
1008 pthread_mutex_t mutex; /* Pacing create/destroy mutex. */
1009 uint32_t refcnt; /* Pacing reference counter. */
1010 uint32_t freq; /* Timestamp frequency, Hz. */
1011 uint32_t tick; /* Completion tick duration in nanoseconds. */
1012 uint32_t test; /* Packet pacing test mode. */
1013 int32_t skew; /* Scheduling skew. */
1014 struct rte_intr_handle intr_handle; /* Periodic interrupt. */
1015 void *echan; /* Event Channel. */
1016 struct mlx5_txpp_wq clock_queue; /* Clock Queue. */
1017 struct mlx5_txpp_wq rearm_queue; /* Clock Queue. */
1018 void *pp; /* Packet pacing context. */
1019 uint16_t pp_id; /* Packet pacing context index. */
1020 uint16_t ts_n; /* Number of captured timestamps. */
1021 uint16_t ts_p; /* Pointer to statisticks timestamp. */
1022 struct mlx5_txpp_ts *tsa; /* Timestamps sliding window stats. */
1023 struct mlx5_txpp_ts ts; /* Cached completion id/timestamp. */
1024 uint32_t sync_lost:1; /* ci/timestamp synchronization lost. */
1025 /* Statistics counters. */
1026 uint64_t err_miss_int; /* Missed service interrupt. */
1027 uint64_t err_rearm_queue; /* Rearm Queue errors. */
1028 uint64_t err_clock_queue; /* Clock Queue errors. */
1029 uint64_t err_ts_past; /* Timestamp in the past. */
1030 uint64_t err_ts_future; /* Timestamp in the distant future. */
1033 /* Supported flex parser profile ID. */
1034 enum mlx5_flex_parser_profile_id {
1035 MLX5_FLEX_PARSER_ECPRI_0 = 0,
1036 MLX5_FLEX_PARSER_MAX = 8,
1039 /* Sample ID information of flex parser structure. */
1040 struct mlx5_flex_parser_profiles {
1041 uint32_t num; /* Actual number of samples. */
1042 uint32_t ids[8]; /* Sample IDs for this profile. */
1043 uint8_t offset[8]; /* Bytes offset of each parser. */
1044 void *obj; /* Flex parser node object. */
1047 /* Max member ports per bonding device. */
1048 #define MLX5_BOND_MAX_PORTS 2
1050 /* Bonding device information. */
1051 struct mlx5_bond_info {
1052 int n_port; /* Number of bond member ports. */
1054 char ifname[MLX5_NAMESIZE + 1];
1056 char ifname[MLX5_NAMESIZE + 1];
1058 struct rte_pci_addr pci_addr;
1059 } ports[MLX5_BOND_MAX_PORTS];
1062 /* Number of connection tracking objects per pool: must be a power of 2. */
1063 #define MLX5_ASO_CT_ACTIONS_PER_POOL 64
1065 /* Generate incremental and unique CT index from pool and offset. */
1066 #define MLX5_MAKE_CT_IDX(pool, offset) \
1067 ((pool) * MLX5_ASO_CT_ACTIONS_PER_POOL + (offset) + 1)
1069 /* ASO Conntrack state. */
1070 enum mlx5_aso_ct_state {
1071 ASO_CONNTRACK_FREE, /* Inactive, in the free list. */
1072 ASO_CONNTRACK_WAIT, /* WQE sent in the SQ. */
1073 ASO_CONNTRACK_READY, /* CQE received w/o error. */
1074 ASO_CONNTRACK_QUERY, /* WQE for query sent. */
1075 ASO_CONNTRACK_MAX, /* Guard. */
1078 /* Generic ASO connection tracking structure. */
1079 struct mlx5_aso_ct_action {
1080 LIST_ENTRY(mlx5_aso_ct_action) next; /* Pointer to the next ASO CT. */
1081 void *dr_action_orig; /* General action object for original dir. */
1082 void *dr_action_rply; /* General action object for reply dir. */
1083 uint32_t refcnt; /* Action used count in device flows. */
1084 uint16_t offset; /* Offset of ASO CT in DevX objects bulk. */
1085 uint16_t peer; /* The only peer port index could also use this CT. */
1086 enum mlx5_aso_ct_state state; /* ASO CT state. */
1087 bool is_original; /* The direction of the DR action to be used. */
1090 /* CT action object state update. */
1091 #define MLX5_ASO_CT_UPDATE_STATE(c, s) \
1092 __atomic_store_n(&((c)->state), (s), __ATOMIC_RELAXED)
1094 /* ASO connection tracking software pool definition. */
1095 struct mlx5_aso_ct_pool {
1096 uint16_t index; /* Pool index in pools array. */
1097 struct mlx5_devx_obj *devx_obj;
1098 /* The first devx object in the bulk, used for freeing (not yet). */
1099 struct mlx5_aso_ct_action actions[MLX5_ASO_CT_ACTIONS_PER_POOL];
1100 /* CT action structures bulk. */
1103 LIST_HEAD(aso_ct_list, mlx5_aso_ct_action);
1105 /* Pools management structure for ASO connection tracking pools. */
1106 struct mlx5_aso_ct_pools_mng {
1107 struct mlx5_aso_ct_pool **pools;
1108 uint16_t n; /* Total number of pools. */
1109 uint16_t next; /* Number of pools in use, index of next free pool. */
1110 rte_spinlock_t ct_sl; /* The ASO CT free list lock. */
1111 rte_rwlock_t resize_rwl; /* The ASO CT pool resize lock. */
1112 struct aso_ct_list free_cts; /* Free ASO CT objects list. */
1113 struct mlx5_aso_sq aso_sq; /* ASO queue objects. */
1117 * Shared Infiniband device context for Master/Representors
1118 * which belong to same IB device with multiple IB ports.
1120 struct mlx5_dev_ctx_shared {
1121 LIST_ENTRY(mlx5_dev_ctx_shared) next;
1123 uint32_t devx:1; /* Opened with DV. */
1124 uint32_t flow_hit_aso_en:1; /* Flow Hit ASO is supported. */
1125 uint32_t rq_ts_format:2; /* RQ timestamp formats supported. */
1126 uint32_t sq_ts_format:2; /* SQ timestamp formats supported. */
1127 uint32_t steering_format_version:4;
1128 /* Indicates the device steering logic format. */
1129 uint32_t qp_ts_format:2; /* QP timestamp formats supported. */
1130 uint32_t meter_aso_en:1; /* Flow Meter ASO is supported. */
1131 uint32_t ct_aso_en:1; /* Connection Tracking ASO is supported. */
1132 uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */
1133 uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */
1134 uint32_t reclaim_mode:1; /* Reclaim memory. */
1135 uint32_t max_port; /* Maximal IB device port index. */
1136 struct mlx5_bond_info bond; /* Bonding information. */
1137 struct mlx5_common_device *cdev; /* Backend mlx5 device. */
1138 void *ctx; /* Verbs/DV/DevX context. */
1139 void *pd; /* Protection Domain. */
1140 uint32_t pdn; /* Protection Domain number. */
1141 uint32_t tdn; /* Transport Domain number. */
1142 char ibdev_name[MLX5_FS_NAME_MAX]; /* SYSFS dev name. */
1143 char ibdev_path[MLX5_FS_PATH_MAX]; /* SYSFS dev path for secondary */
1144 struct mlx5_dev_attr device_attr; /* Device properties. */
1145 int numa_node; /* Numa node of backing physical device. */
1146 LIST_ENTRY(mlx5_dev_ctx_shared) mem_event_cb;
1147 /**< Called by memory event callback. */
1148 struct mlx5_mr_share_cache share_cache;
1149 /* Packet pacing related structure. */
1150 struct mlx5_dev_txpp txpp;
1151 /* Shared DV/DR flow data section. */
1152 uint32_t dv_meta_mask; /* flow META metadata supported mask. */
1153 uint32_t dv_mark_mask; /* flow MARK metadata supported mask. */
1154 uint32_t dv_regc0_mask; /* available bits of metatada reg_c[0]. */
1155 void *fdb_domain; /* FDB Direct Rules name space handle. */
1156 void *rx_domain; /* RX Direct Rules name space handle. */
1157 void *tx_domain; /* TX Direct Rules name space handle. */
1159 rte_spinlock_t uar_lock_cq; /* CQs share a common distinct UAR */
1160 rte_spinlock_t uar_lock[MLX5_UAR_PAGE_NUM_MAX];
1161 /* UAR same-page access control required in 32bit implementations. */
1163 struct mlx5_hlist *flow_tbls;
1164 struct mlx5_flow_tunnel_hub *tunnel_hub;
1165 /* Direct Rules tables for FDB, NIC TX+RX */
1166 void *dr_drop_action; /* Pointer to DR drop action, any domain. */
1167 void *pop_vlan_action; /* Pointer to DR pop VLAN action. */
1168 struct mlx5_hlist *encaps_decaps; /* Encap/decap action hash list. */
1169 struct mlx5_hlist *modify_cmds;
1170 struct mlx5_hlist *tag_table;
1171 struct mlx5_list *port_id_action_list; /* Port ID action list. */
1172 struct mlx5_list *push_vlan_action_list; /* Push VLAN actions. */
1173 struct mlx5_list *sample_action_list; /* List of sample actions. */
1174 struct mlx5_list *dest_array_list;
1175 /* List of destination array actions. */
1176 struct mlx5_flow_counter_mng cmng; /* Counters management structure. */
1177 void *default_miss_action; /* Default miss action. */
1178 struct mlx5_indexed_pool *ipool[MLX5_IPOOL_MAX];
1179 struct mlx5_indexed_pool *mdh_ipools[MLX5_MAX_MODIFY_NUM];
1180 /* Shared interrupt handler section. */
1181 struct rte_intr_handle intr_handle; /* Interrupt handler for device. */
1182 struct rte_intr_handle intr_handle_devx; /* DEVX interrupt handler. */
1183 void *devx_comp; /* DEVX async comp obj. */
1184 struct mlx5_devx_obj *tis; /* TIS object. */
1185 struct mlx5_devx_obj *td; /* Transport domain. */
1186 void *tx_uar; /* Tx/packet pacing shared UAR. */
1187 struct mlx5_flex_parser_profiles fp[MLX5_FLEX_PARSER_MAX];
1188 /* Flex parser profiles information. */
1189 void *devx_rx_uar; /* DevX UAR for Rx. */
1190 struct mlx5_aso_age_mng *aso_age_mng;
1191 /* Management data for aging mechanism using ASO Flow Hit. */
1192 struct mlx5_geneve_tlv_option_resource *geneve_tlv_option_resource;
1193 /* Management structure for geneve tlv option */
1194 rte_spinlock_t geneve_tlv_opt_sl; /* Lock for geneve tlv resource */
1195 struct mlx5_flow_mtr_mng *mtrmng;
1196 /* Meter management structure. */
1197 struct mlx5_aso_ct_pools_mng *ct_mng;
1198 /* Management data for ASO connection tracking. */
1199 struct mlx5_lb_ctx self_lb; /* QP to enable self loopback for Devx. */
1200 struct mlx5_dev_shared_port port[]; /* per device port data array. */
1204 * Per-process private structure.
1205 * Caution, secondary process may rebuild the struct during port start.
1207 struct mlx5_proc_priv {
1208 size_t uar_table_sz;
1209 /* Size of UAR register table. */
1211 /* Table of UAR registers for each process. */
1214 /* MTR profile list. */
1215 TAILQ_HEAD(mlx5_mtr_profiles, mlx5_flow_meter_profile);
1217 TAILQ_HEAD(mlx5_legacy_flow_meters, mlx5_legacy_flow_meter);
1219 /* RSS description. */
1220 struct mlx5_flow_rss_desc {
1222 uint32_t queue_num; /**< Number of entries in @p queue. */
1223 uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1224 uint64_t hash_fields; /* Verbs Hash fields. */
1225 uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
1226 uint32_t key_len; /**< RSS hash key len. */
1227 uint32_t tunnel; /**< Queue in tunnel. */
1228 uint32_t shared_rss; /**< Shared RSS index. */
1229 struct mlx5_ind_table_obj *ind_tbl;
1230 /**< Indirection table for shared RSS hash RX queues. */
1232 uint16_t *queue; /**< Destination queues. */
1233 const uint16_t *const_q; /**< Const pointer convert. */
1237 #define MLX5_PROC_PRIV(port_id) \
1238 ((struct mlx5_proc_priv *)rte_eth_devices[port_id].process_private)
1240 /* Verbs/DevX Rx queue elements. */
1241 struct mlx5_rxq_obj {
1242 LIST_ENTRY(mlx5_rxq_obj) next; /* Pointer to the next element. */
1243 struct mlx5_rxq_ctrl *rxq_ctrl; /* Back pointer to parent. */
1244 int fd; /* File descriptor for event channel */
1248 void *wq; /* Work Queue. */
1249 void *ibv_cq; /* Completion Queue. */
1252 struct mlx5_devx_obj *rq; /* DevX RQ object for hairpin. */
1254 struct mlx5_devx_rq rq_obj; /* DevX RQ object. */
1255 struct mlx5_devx_cq cq_obj; /* DevX CQ object. */
1261 /* Indirection table. */
1262 struct mlx5_ind_table_obj {
1263 LIST_ENTRY(mlx5_ind_table_obj) next; /* Pointer to the next element. */
1264 uint32_t refcnt; /* Reference counter. */
1267 void *ind_table; /**< Indirection table. */
1268 struct mlx5_devx_obj *rqt; /* DevX RQT object. */
1270 uint32_t queues_n; /**< Number of queues in the list. */
1271 uint16_t *queues; /**< Queue list. */
1274 /* Hash Rx queue. */
1277 struct mlx5_list_entry entry; /* List entry. */
1278 uint32_t standalone:1; /* This object used in shared action. */
1279 struct mlx5_ind_table_obj *ind_table; /* Indirection table. */
1282 void *qp; /* Verbs queue pair. */
1283 struct mlx5_devx_obj *tir; /* DevX TIR object. */
1285 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1286 void *action; /* DV QP action pointer. */
1288 uint64_t hash_fields; /* Verbs Hash fields. */
1289 uint32_t rss_key_len; /* Hash key length in bytes. */
1290 uint32_t idx; /* Hash Rx queue index. */
1291 uint8_t rss_key[]; /* Hash key. */
1294 /* Verbs/DevX Tx queue elements. */
1295 struct mlx5_txq_obj {
1296 LIST_ENTRY(mlx5_txq_obj) next; /* Pointer to the next element. */
1297 struct mlx5_txq_ctrl *txq_ctrl; /* Pointer to the control queue. */
1301 void *cq; /* Completion Queue. */
1302 void *qp; /* Queue Pair. */
1305 struct mlx5_devx_obj *sq;
1306 /* DevX object for Sx queue. */
1307 struct mlx5_devx_obj *tis; /* The TIS object. */
1310 struct rte_eth_dev *dev;
1311 struct mlx5_devx_cq cq_obj;
1312 /* DevX CQ object and its resources. */
1313 struct mlx5_devx_sq sq_obj;
1314 /* DevX SQ object and its resources. */
1319 enum mlx5_rxq_modify_type {
1320 MLX5_RXQ_MOD_ERR2RST, /* modify state from error to reset. */
1321 MLX5_RXQ_MOD_RST2RDY, /* modify state from reset to ready. */
1322 MLX5_RXQ_MOD_RDY2ERR, /* modify state from ready to error. */
1323 MLX5_RXQ_MOD_RDY2RST, /* modify state from ready to reset. */
1326 enum mlx5_txq_modify_type {
1327 MLX5_TXQ_MOD_RST2RDY, /* modify state from reset to ready. */
1328 MLX5_TXQ_MOD_RDY2RST, /* modify state from ready to reset. */
1329 MLX5_TXQ_MOD_ERR2RDY, /* modify state from error to ready. */
1332 /* HW objects operations structure. */
1333 struct mlx5_obj_ops {
1334 int (*rxq_obj_modify_vlan_strip)(struct mlx5_rxq_obj *rxq_obj, int on);
1335 int (*rxq_obj_new)(struct rte_eth_dev *dev, uint16_t idx);
1336 int (*rxq_event_get)(struct mlx5_rxq_obj *rxq_obj);
1337 int (*rxq_obj_modify)(struct mlx5_rxq_obj *rxq_obj, uint8_t type);
1338 void (*rxq_obj_release)(struct mlx5_rxq_obj *rxq_obj);
1339 int (*ind_table_new)(struct rte_eth_dev *dev, const unsigned int log_n,
1340 struct mlx5_ind_table_obj *ind_tbl);
1341 int (*ind_table_modify)(struct rte_eth_dev *dev,
1342 const unsigned int log_n,
1343 const uint16_t *queues, const uint32_t queues_n,
1344 struct mlx5_ind_table_obj *ind_tbl);
1345 void (*ind_table_destroy)(struct mlx5_ind_table_obj *ind_tbl);
1346 int (*hrxq_new)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
1347 int tunnel __rte_unused);
1348 int (*hrxq_modify)(struct rte_eth_dev *dev, struct mlx5_hrxq *hrxq,
1349 const uint8_t *rss_key,
1350 uint64_t hash_fields,
1351 const struct mlx5_ind_table_obj *ind_tbl);
1352 void (*hrxq_destroy)(struct mlx5_hrxq *hrxq);
1353 int (*drop_action_create)(struct rte_eth_dev *dev);
1354 void (*drop_action_destroy)(struct rte_eth_dev *dev);
1355 int (*txq_obj_new)(struct rte_eth_dev *dev, uint16_t idx);
1356 int (*txq_obj_modify)(struct mlx5_txq_obj *obj,
1357 enum mlx5_txq_modify_type type, uint8_t dev_port);
1358 void (*txq_obj_release)(struct mlx5_txq_obj *txq_obj);
1359 int (*lb_dummy_queue_create)(struct rte_eth_dev *dev);
1360 void (*lb_dummy_queue_release)(struct rte_eth_dev *dev);
1363 #define MLX5_RSS_HASH_FIELDS_LEN RTE_DIM(mlx5_rss_hash_fields)
1365 /* MR operations structure. */
1366 struct mlx5_mr_ops {
1367 mlx5_reg_mr_t reg_mr;
1368 mlx5_dereg_mr_t dereg_mr;
1372 struct rte_eth_dev_data *dev_data; /* Pointer to device data. */
1373 struct mlx5_dev_ctx_shared *sh; /* Shared device context. */
1374 uint32_t dev_port; /* Device port number. */
1375 struct rte_pci_device *pci_dev; /* Backend PCI device. */
1376 struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
1377 BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
1378 /* Bit-field of MAC addresses owned by the PMD. */
1379 uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
1380 unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
1381 /* Device properties. */
1382 uint16_t mtu; /* Configured MTU. */
1383 unsigned int isolated:1; /* Whether isolated mode is enabled. */
1384 unsigned int representor:1; /* Device is a port representor. */
1385 unsigned int master:1; /* Device is a E-Switch master. */
1386 unsigned int txpp_en:1; /* Tx packet pacing enabled. */
1387 unsigned int sampler_en:1; /* Whether support sampler. */
1388 unsigned int mtr_en:1; /* Whether support meter. */
1389 unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */
1390 unsigned int lb_used:1; /* Loopback queue is referred to. */
1391 uint16_t domain_id; /* Switch domain identifier. */
1392 uint16_t vport_id; /* Associated VF vport index (if any). */
1393 uint32_t vport_meta_tag; /* Used for vport index match ove VF LAG. */
1394 uint32_t vport_meta_mask; /* Used for vport index field match mask. */
1395 uint16_t representor_id; /* UINT16_MAX if not a representor. */
1396 int32_t pf_bond; /* >=0, representor owner PF index in bonding. */
1397 unsigned int if_index; /* Associated kernel network device index. */
1399 unsigned int rxqs_n; /* RX queues array size. */
1400 unsigned int txqs_n; /* TX queues array size. */
1401 struct mlx5_rxq_data *(*rxqs)[]; /* RX queues. */
1402 struct mlx5_txq_data *(*txqs)[]; /* TX queues. */
1403 struct rte_mempool *mprq_mp; /* Mempool for Multi-Packet RQ. */
1404 struct rte_eth_rss_conf rss_conf; /* RSS configuration. */
1405 unsigned int (*reta_idx)[]; /* RETA index table. */
1406 unsigned int reta_idx_n; /* RETA index size. */
1407 struct mlx5_drop drop_queue; /* Flow drop queues. */
1408 void *root_drop_action; /* Pointer to root drop action. */
1409 struct mlx5_indexed_pool *flows[MLX5_FLOW_TYPE_MAXI];
1410 /* RTE Flow rules. */
1411 uint32_t ctrl_flows; /* Control flow rules. */
1412 rte_spinlock_t flow_list_lock;
1413 struct mlx5_obj_ops obj_ops; /* HW objects operations. */
1414 LIST_HEAD(rxq, mlx5_rxq_ctrl) rxqsctrl; /* DPDK Rx queues. */
1415 LIST_HEAD(rxqobj, mlx5_rxq_obj) rxqsobj; /* Verbs/DevX Rx queues. */
1416 struct mlx5_list *hrxqs; /* Hash Rx queues. */
1417 LIST_HEAD(txq, mlx5_txq_ctrl) txqsctrl; /* DPDK Tx queues. */
1418 LIST_HEAD(txqobj, mlx5_txq_obj) txqsobj; /* Verbs/DevX Tx queues. */
1419 /* Indirection tables. */
1420 LIST_HEAD(ind_tables, mlx5_ind_table_obj) ind_tbls;
1421 /* Pointer to next element. */
1422 rte_rwlock_t ind_tbls_lock;
1423 uint32_t refcnt; /**< Reference counter. */
1424 /**< Verbs modify header action object. */
1425 uint8_t ft_type; /**< Flow table type, Rx or Tx. */
1426 uint8_t max_lro_msg_size;
1427 uint32_t link_speed_capa; /* Link speed capabilities. */
1428 struct mlx5_xstats_ctrl xstats_ctrl; /* Extended stats control. */
1429 struct mlx5_stats_ctrl stats_ctrl; /* Stats control. */
1430 struct mlx5_dev_config config; /* Device configuration. */
1431 /* Context for Verbs allocator. */
1432 int nl_socket_rdma; /* Netlink socket (NETLINK_RDMA). */
1433 int nl_socket_route; /* Netlink socket (NETLINK_ROUTE). */
1434 struct mlx5_nl_vlan_vmwa_context *vmwa_context; /* VLAN WA context. */
1435 struct mlx5_hlist *mreg_cp_tbl;
1436 /* Hash table of Rx metadata register copy table. */
1437 uint8_t mtr_sfx_reg; /* Meter prefix-suffix flow match REG_C. */
1438 uint8_t mtr_color_reg; /* Meter color match REG_C. */
1439 struct mlx5_legacy_flow_meters flow_meters; /* MTR list. */
1440 struct mlx5_l3t_tbl *mtr_profile_tbl; /* Meter index lookup table. */
1441 struct mlx5_l3t_tbl *policy_idx_tbl; /* Policy index lookup table. */
1442 struct mlx5_l3t_tbl *mtr_idx_tbl; /* Meter index lookup table. */
1443 uint8_t skip_default_rss_reta; /* Skip configuration of default reta. */
1444 uint8_t fdb_def_rule; /* Whether fdb jump to table 1 is configured. */
1445 struct mlx5_mp_id mp_id; /* ID of a multi-process process */
1446 LIST_HEAD(fdir, mlx5_fdir_flow) fdir_flows; /* fdir flows. */
1447 rte_spinlock_t shared_act_sl; /* Shared actions spinlock. */
1448 uint32_t rss_shared_actions; /* RSS shared actions. */
1449 struct mlx5_devx_obj *q_counters; /* DevX queue counter object. */
1450 uint32_t counter_set_id; /* Queue counter ID to set in DevX objects. */
1453 #define PORT_ID(priv) ((priv)->dev_data->port_id)
1454 #define ETH_DEV(priv) (&rte_eth_devices[PORT_ID(priv)])
1456 struct rte_hairpin_peer_info {
1460 uint16_t tx_explicit;
1461 uint16_t manual_bind;
1464 #define BUF_SIZE 1024
1465 enum dr_dump_rec_type {
1466 DR_DUMP_REC_TYPE_PMD_PKT_REFORMAT = 4410,
1467 DR_DUMP_REC_TYPE_PMD_MODIFY_HDR = 4420,
1468 DR_DUMP_REC_TYPE_PMD_COUNTER = 4430,
1473 int mlx5_getenv_int(const char *);
1474 int mlx5_proc_priv_init(struct rte_eth_dev *dev);
1475 void mlx5_proc_priv_uninit(struct rte_eth_dev *dev);
1476 int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
1477 struct rte_eth_udp_tunnel *udp_tunnel);
1478 uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev);
1479 int mlx5_dev_close(struct rte_eth_dev *dev);
1480 int mlx5_net_remove(struct mlx5_common_device *cdev);
1481 bool mlx5_is_hpf(struct rte_eth_dev *dev);
1482 bool mlx5_is_sf_repr(struct rte_eth_dev *dev);
1483 void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh);
1485 /* Macro to iterate over all valid ports for mlx5 driver. */
1486 #define MLX5_ETH_FOREACH_DEV(port_id, dev) \
1487 for (port_id = mlx5_eth_find_next(0, dev); \
1488 port_id < RTE_MAX_ETHPORTS; \
1489 port_id = mlx5_eth_find_next(port_id + 1, dev))
1490 int mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs);
1491 struct mlx5_dev_ctx_shared *
1492 mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
1493 const struct mlx5_dev_config *config);
1494 void mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh);
1495 int mlx5_dev_ctx_shared_mempool_subscribe(struct rte_eth_dev *dev);
1496 void mlx5_free_table_hash_list(struct mlx5_priv *priv);
1497 int mlx5_alloc_table_hash_list(struct mlx5_priv *priv);
1498 void mlx5_set_min_inline(struct mlx5_dev_spawn_data *spawn,
1499 struct mlx5_dev_config *config);
1500 void mlx5_set_metadata_mask(struct rte_eth_dev *dev);
1501 int mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
1502 struct mlx5_dev_config *config,
1503 struct rte_device *dpdk_dev);
1504 int mlx5_dev_configure(struct rte_eth_dev *dev);
1505 int mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
1506 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size);
1507 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
1508 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
1509 struct rte_eth_hairpin_cap *cap);
1510 bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);
1511 int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);
1512 int mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh);
1513 int mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh);
1514 int mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh);
1518 int mlx5_dev_configure(struct rte_eth_dev *dev);
1519 int mlx5_representor_info_get(struct rte_eth_dev *dev,
1520 struct rte_eth_representor_info *info);
1521 #define MLX5_REPRESENTOR_ID(pf, type, repr) \
1522 (((pf) << 14) + ((type) << 12) + ((repr) & 0xfff))
1523 #define MLX5_REPRESENTOR_REPR(repr_id) \
1525 #define MLX5_REPRESENTOR_TYPE(repr_id) \
1526 (((repr_id) >> 12) & 3)
1527 uint16_t mlx5_representor_id_encode(const struct mlx5_switch_info *info,
1528 enum rte_eth_representor_type hpf_type);
1529 int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver,
1531 int mlx5_dev_infos_get(struct rte_eth_dev *dev,
1532 struct rte_eth_dev_info *info);
1533 const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
1534 int mlx5_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
1535 int mlx5_hairpin_cap_get(struct rte_eth_dev *dev,
1536 struct rte_eth_hairpin_cap *cap);
1537 eth_rx_burst_t mlx5_select_rx_function(struct rte_eth_dev *dev);
1538 struct mlx5_priv *mlx5_port_to_eswitch_info(uint16_t port, bool valid);
1539 struct mlx5_priv *mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev);
1540 int mlx5_dev_configure_rss_reta(struct rte_eth_dev *dev);
1542 /* mlx5_ethdev_os.c */
1544 int mlx5_get_ifname(const struct rte_eth_dev *dev,
1545 char (*ifname)[MLX5_NAMESIZE]);
1546 unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);
1547 int mlx5_get_mac(struct rte_eth_dev *dev, uint8_t (*mac)[RTE_ETHER_ADDR_LEN]);
1548 int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);
1549 int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
1550 int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
1551 int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
1552 int mlx5_dev_get_flow_ctrl(struct rte_eth_dev *dev,
1553 struct rte_eth_fc_conf *fc_conf);
1554 int mlx5_dev_set_flow_ctrl(struct rte_eth_dev *dev,
1555 struct rte_eth_fc_conf *fc_conf);
1556 void mlx5_dev_interrupt_handler(void *arg);
1557 void mlx5_dev_interrupt_handler_devx(void *arg);
1558 int mlx5_set_link_down(struct rte_eth_dev *dev);
1559 int mlx5_set_link_up(struct rte_eth_dev *dev);
1560 int mlx5_is_removed(struct rte_eth_dev *dev);
1561 int mlx5_sysfs_switch_info(unsigned int ifindex,
1562 struct mlx5_switch_info *info);
1563 void mlx5_translate_port_name(const char *port_name_in,
1564 struct mlx5_switch_info *port_info_out);
1565 void mlx5_intr_callback_unregister(const struct rte_intr_handle *handle,
1566 rte_intr_callback_fn cb_fn, void *cb_arg);
1567 int mlx5_sysfs_bond_info(unsigned int pf_ifindex, unsigned int *ifindex,
1569 int mlx5_get_module_info(struct rte_eth_dev *dev,
1570 struct rte_eth_dev_module_info *modinfo);
1571 int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
1572 struct rte_dev_eeprom_info *info);
1573 int mlx5_os_read_dev_stat(struct mlx5_priv *priv,
1574 const char *ctr_name, uint64_t *stat);
1575 int mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats);
1576 int mlx5_os_get_stats_n(struct rte_eth_dev *dev);
1577 void mlx5_os_stats_init(struct rte_eth_dev *dev);
1581 void mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
1582 int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
1583 uint32_t index, uint32_t vmdq);
1584 int mlx5_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr);
1585 int mlx5_set_mc_addr_list(struct rte_eth_dev *dev,
1586 struct rte_ether_addr *mc_addr_set,
1587 uint32_t nb_mc_addr);
1591 int mlx5_rss_hash_update(struct rte_eth_dev *dev,
1592 struct rte_eth_rss_conf *rss_conf);
1593 int mlx5_rss_hash_conf_get(struct rte_eth_dev *dev,
1594 struct rte_eth_rss_conf *rss_conf);
1595 int mlx5_rss_reta_index_resize(struct rte_eth_dev *dev, unsigned int reta_size);
1596 int mlx5_dev_rss_reta_query(struct rte_eth_dev *dev,
1597 struct rte_eth_rss_reta_entry64 *reta_conf,
1598 uint16_t reta_size);
1599 int mlx5_dev_rss_reta_update(struct rte_eth_dev *dev,
1600 struct rte_eth_rss_reta_entry64 *reta_conf,
1601 uint16_t reta_size);
1605 int mlx5_promiscuous_enable(struct rte_eth_dev *dev);
1606 int mlx5_promiscuous_disable(struct rte_eth_dev *dev);
1607 int mlx5_allmulticast_enable(struct rte_eth_dev *dev);
1608 int mlx5_allmulticast_disable(struct rte_eth_dev *dev);
1612 int mlx5_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);
1613 int mlx5_stats_reset(struct rte_eth_dev *dev);
1614 int mlx5_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats,
1616 int mlx5_xstats_reset(struct rte_eth_dev *dev);
1617 int mlx5_xstats_get_names(struct rte_eth_dev *dev __rte_unused,
1618 struct rte_eth_xstat_name *xstats_names,
1623 int mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on);
1624 void mlx5_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on);
1625 int mlx5_vlan_offload_set(struct rte_eth_dev *dev, int mask);
1627 /* mlx5_vlan_os.c */
1629 void mlx5_vlan_vmwa_exit(void *ctx);
1630 void mlx5_vlan_vmwa_release(struct rte_eth_dev *dev,
1631 struct mlx5_vf_vlan *vf_vlan);
1632 void mlx5_vlan_vmwa_acquire(struct rte_eth_dev *dev,
1633 struct mlx5_vf_vlan *vf_vlan);
1634 void *mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex);
1636 /* mlx5_trigger.c */
1638 int mlx5_dev_start(struct rte_eth_dev *dev);
1639 int mlx5_dev_stop(struct rte_eth_dev *dev);
1640 int mlx5_traffic_enable(struct rte_eth_dev *dev);
1641 void mlx5_traffic_disable(struct rte_eth_dev *dev);
1642 int mlx5_traffic_restart(struct rte_eth_dev *dev);
1643 int mlx5_hairpin_queue_peer_update(struct rte_eth_dev *dev, uint16_t peer_queue,
1644 struct rte_hairpin_peer_info *current_info,
1645 struct rte_hairpin_peer_info *peer_info,
1646 uint32_t direction);
1647 int mlx5_hairpin_queue_peer_bind(struct rte_eth_dev *dev, uint16_t cur_queue,
1648 struct rte_hairpin_peer_info *peer_info,
1649 uint32_t direction);
1650 int mlx5_hairpin_queue_peer_unbind(struct rte_eth_dev *dev, uint16_t cur_queue,
1651 uint32_t direction);
1652 int mlx5_hairpin_bind(struct rte_eth_dev *dev, uint16_t rx_port);
1653 int mlx5_hairpin_unbind(struct rte_eth_dev *dev, uint16_t rx_port);
1654 int mlx5_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,
1655 size_t len, uint32_t direction);
1659 int mlx5_flow_discover_mreg_c(struct rte_eth_dev *eth_dev);
1660 bool mlx5_flow_ext_mreg_supported(struct rte_eth_dev *dev);
1661 void mlx5_flow_print(struct rte_flow *flow);
1662 int mlx5_flow_validate(struct rte_eth_dev *dev,
1663 const struct rte_flow_attr *attr,
1664 const struct rte_flow_item items[],
1665 const struct rte_flow_action actions[],
1666 struct rte_flow_error *error);
1667 struct rte_flow *mlx5_flow_create(struct rte_eth_dev *dev,
1668 const struct rte_flow_attr *attr,
1669 const struct rte_flow_item items[],
1670 const struct rte_flow_action actions[],
1671 struct rte_flow_error *error);
1672 int mlx5_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
1673 struct rte_flow_error *error);
1674 void mlx5_flow_list_flush(struct rte_eth_dev *dev, enum mlx5_flow_type type,
1676 int mlx5_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error);
1677 int mlx5_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow,
1678 const struct rte_flow_action *action, void *data,
1679 struct rte_flow_error *error);
1680 int mlx5_flow_isolate(struct rte_eth_dev *dev, int enable,
1681 struct rte_flow_error *error);
1682 int mlx5_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops);
1683 int mlx5_flow_start_default(struct rte_eth_dev *dev);
1684 void mlx5_flow_stop_default(struct rte_eth_dev *dev);
1685 int mlx5_flow_verify(struct rte_eth_dev *dev);
1686 int mlx5_ctrl_flow_source_queue(struct rte_eth_dev *dev, uint32_t queue);
1687 int mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev,
1688 struct rte_flow_item_eth *eth_spec,
1689 struct rte_flow_item_eth *eth_mask,
1690 struct rte_flow_item_vlan *vlan_spec,
1691 struct rte_flow_item_vlan *vlan_mask);
1692 int mlx5_ctrl_flow(struct rte_eth_dev *dev,
1693 struct rte_flow_item_eth *eth_spec,
1694 struct rte_flow_item_eth *eth_mask);
1695 int mlx5_flow_lacp_miss(struct rte_eth_dev *dev);
1696 struct rte_flow *mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev);
1697 void mlx5_flow_async_pool_query_handle(struct mlx5_dev_ctx_shared *sh,
1698 uint64_t async_id, int status);
1699 void mlx5_set_query_alarm(struct mlx5_dev_ctx_shared *sh);
1700 void mlx5_flow_query_alarm(void *arg);
1701 uint32_t mlx5_counter_alloc(struct rte_eth_dev *dev);
1702 void mlx5_counter_free(struct rte_eth_dev *dev, uint32_t cnt);
1703 int mlx5_counter_query(struct rte_eth_dev *dev, uint32_t cnt,
1704 bool clear, uint64_t *pkts, uint64_t *bytes);
1705 int mlx5_flow_dev_dump(struct rte_eth_dev *dev, struct rte_flow *flow,
1706 FILE *file, struct rte_flow_error *error);
1707 int save_dump_file(const unsigned char *data, uint32_t size,
1708 uint32_t type, uint32_t id, void *arg, FILE *file);
1709 int mlx5_flow_query_counter(struct rte_eth_dev *dev, struct rte_flow *flow,
1710 struct rte_flow_query_count *count, struct rte_flow_error *error);
1711 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1712 int mlx5_flow_dev_dump_ipool(struct rte_eth_dev *dev, struct rte_flow *flow,
1713 FILE *file, struct rte_flow_error *error);
1715 void mlx5_flow_rxq_dynf_metadata_set(struct rte_eth_dev *dev);
1716 int mlx5_flow_get_aged_flows(struct rte_eth_dev *dev, void **contexts,
1717 uint32_t nb_contexts, struct rte_flow_error *error);
1718 int mlx5_validate_action_ct(struct rte_eth_dev *dev,
1719 const struct rte_flow_action_conntrack *conntrack,
1720 struct rte_flow_error *error);
1725 int mlx5_mp_os_primary_handle(const struct rte_mp_msg *mp_msg,
1727 int mlx5_mp_os_secondary_handle(const struct rte_mp_msg *mp_msg,
1729 void mlx5_mp_os_req_start_rxtx(struct rte_eth_dev *dev);
1730 void mlx5_mp_os_req_stop_rxtx(struct rte_eth_dev *dev);
1731 int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,
1732 enum mlx5_mp_req_type req_type);
1736 int mlx5_pmd_socket_init(void);
1738 /* mlx5_flow_meter.c */
1740 int mlx5_flow_meter_ops_get(struct rte_eth_dev *dev, void *arg);
1741 struct mlx5_flow_meter_info *mlx5_flow_meter_find(struct mlx5_priv *priv,
1742 uint32_t meter_id, uint32_t *mtr_idx);
1743 struct mlx5_flow_meter_info *
1744 flow_dv_meter_find_by_idx(struct mlx5_priv *priv, uint32_t idx);
1745 int mlx5_flow_meter_attach(struct mlx5_priv *priv,
1746 struct mlx5_flow_meter_info *fm,
1747 const struct rte_flow_attr *attr,
1748 struct rte_flow_error *error);
1749 void mlx5_flow_meter_detach(struct mlx5_priv *priv,
1750 struct mlx5_flow_meter_info *fm);
1751 struct mlx5_flow_meter_policy *mlx5_flow_meter_policy_find
1752 (struct rte_eth_dev *dev,
1754 uint32_t *policy_idx);
1755 struct mlx5_flow_meter_policy *
1756 mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev,
1757 struct mlx5_flow_meter_policy *policy);
1758 int mlx5_flow_meter_flush(struct rte_eth_dev *dev,
1759 struct rte_mtr_error *error);
1760 void mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev);
1763 struct rte_pci_driver;
1764 int mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *dev_attr);
1765 void mlx5_os_free_shared_dr(struct mlx5_priv *priv);
1766 int mlx5_os_get_pdn(void *pd, uint32_t *pdn);
1767 int mlx5_os_net_probe(struct mlx5_common_device *cdev);
1768 void mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh);
1769 void mlx5_os_dev_shared_handler_uninstall(struct mlx5_dev_ctx_shared *sh);
1770 void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb,
1771 mlx5_dereg_mr_t *dereg_mr_cb);
1772 void mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index);
1773 int mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
1775 int mlx5_os_vf_mac_addr_modify(struct mlx5_priv *priv, unsigned int iface_idx,
1776 struct rte_ether_addr *mac_addr,
1778 int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
1779 int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
1780 int mlx5_os_set_nonblock_channel_fd(int fd);
1781 void mlx5_os_mac_addr_flush(struct rte_eth_dev *dev);
1785 int mlx5_txpp_start(struct rte_eth_dev *dev);
1786 void mlx5_txpp_stop(struct rte_eth_dev *dev);
1787 int mlx5_txpp_read_clock(struct rte_eth_dev *dev, uint64_t *timestamp);
1788 int mlx5_txpp_xstats_get(struct rte_eth_dev *dev,
1789 struct rte_eth_xstat *stats,
1790 unsigned int n, unsigned int n_used);
1791 int mlx5_txpp_xstats_reset(struct rte_eth_dev *dev);
1792 int mlx5_txpp_xstats_get_names(struct rte_eth_dev *dev,
1793 struct rte_eth_xstat_name *xstats_names,
1794 unsigned int n, unsigned int n_used);
1795 void mlx5_txpp_interrupt_handler(void *cb_arg);
1799 eth_tx_burst_t mlx5_select_tx_function(struct rte_eth_dev *dev);
1801 /* mlx5_flow_aso.c */
1803 int mlx5_aso_queue_init(struct mlx5_dev_ctx_shared *sh,
1804 enum mlx5_access_aso_opc_mod aso_opc_mod);
1805 int mlx5_aso_flow_hit_queue_poll_start(struct mlx5_dev_ctx_shared *sh);
1806 int mlx5_aso_flow_hit_queue_poll_stop(struct mlx5_dev_ctx_shared *sh);
1807 void mlx5_aso_queue_uninit(struct mlx5_dev_ctx_shared *sh,
1808 enum mlx5_access_aso_opc_mod aso_opc_mod);
1809 int mlx5_aso_meter_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
1810 struct mlx5_aso_mtr *mtr);
1811 int mlx5_aso_mtr_wait(struct mlx5_dev_ctx_shared *sh,
1812 struct mlx5_aso_mtr *mtr);
1813 int mlx5_aso_ct_update_by_wqe(struct mlx5_dev_ctx_shared *sh,
1814 struct mlx5_aso_ct_action *ct,
1815 const struct rte_flow_action_conntrack *profile);
1816 int mlx5_aso_ct_wait_ready(struct mlx5_dev_ctx_shared *sh,
1817 struct mlx5_aso_ct_action *ct);
1818 int mlx5_aso_ct_query_by_wqe(struct mlx5_dev_ctx_shared *sh,
1819 struct mlx5_aso_ct_action *ct,
1820 struct rte_flow_action_conntrack *profile);
1821 int mlx5_aso_ct_available(struct mlx5_dev_ctx_shared *sh,
1822 struct mlx5_aso_ct_action *ct);
1824 mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr);
1826 mlx5_get_supported_tunneling_offloads(const struct mlx5_hca_attr *attr);
1828 #endif /* RTE_PMD_MLX5_H_ */