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