Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2018 Mellanox Technologies, Ltd
3 : : */
4 : :
5 : : #ifndef RTE_PMD_MLX5_FLOW_H_
6 : : #define RTE_PMD_MLX5_FLOW_H_
7 : :
8 : : #include <stdalign.h>
9 : : #include <stdint.h>
10 : : #include <string.h>
11 : : #include <sys/queue.h>
12 : :
13 : : #include <rte_alarm.h>
14 : : #include <rte_mtr.h>
15 : :
16 : : #include <mlx5_glue.h>
17 : : #include <mlx5_prm.h>
18 : :
19 : : #include "mlx5.h"
20 : : #include "rte_pmd_mlx5.h"
21 : : #include "hws/mlx5dr.h"
22 : : #include "mlx5_tx.h"
23 : :
24 : : #define MLX5_HW_PORT_IS_PROXY(priv) \
25 : : (!!((priv)->sh->esw_mode && (priv)->master))
26 : :
27 : : /* E-Switch Manager port, used for rte_flow_item_port_id. */
28 : : #define MLX5_PORT_ESW_MGR UINT32_MAX
29 : :
30 : : /* E-Switch Manager port, used for rte_flow_item_ethdev. */
31 : : #define MLX5_REPRESENTED_PORT_ESW_MGR UINT16_MAX
32 : :
33 : : /* Private rte flow items. */
34 : : enum mlx5_rte_flow_item_type {
35 : : MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
36 : : MLX5_RTE_FLOW_ITEM_TYPE_TAG,
37 : : MLX5_RTE_FLOW_ITEM_TYPE_SQ,
38 : : MLX5_RTE_FLOW_ITEM_TYPE_VLAN,
39 : : MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL,
40 : : };
41 : :
42 : : /* Private (internal) rte flow actions. */
43 : : enum mlx5_rte_flow_action_type {
44 : : MLX5_RTE_FLOW_ACTION_TYPE_END = INT_MIN,
45 : : MLX5_RTE_FLOW_ACTION_TYPE_TAG,
46 : : MLX5_RTE_FLOW_ACTION_TYPE_MARK,
47 : : MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG,
48 : : MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS,
49 : : MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET,
50 : : MLX5_RTE_FLOW_ACTION_TYPE_AGE,
51 : : MLX5_RTE_FLOW_ACTION_TYPE_COUNT,
52 : : MLX5_RTE_FLOW_ACTION_TYPE_JUMP,
53 : : MLX5_RTE_FLOW_ACTION_TYPE_RSS,
54 : : MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK,
55 : : MLX5_RTE_FLOW_ACTION_TYPE_MIRROR,
56 : : };
57 : :
58 : : /* Private (internal) Field IDs for MODIFY_FIELD action. */
59 : : enum mlx5_rte_flow_field_id {
60 : : MLX5_RTE_FLOW_FIELD_END = INT_MIN,
61 : : MLX5_RTE_FLOW_FIELD_META_REG,
62 : : };
63 : :
64 : : #define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29
65 : :
66 : : #define MLX5_INDIRECT_ACTION_TYPE_GET(handle) \
67 : : (((uint32_t)(uintptr_t)(handle)) >> MLX5_INDIRECT_ACTION_TYPE_OFFSET)
68 : :
69 : : #define MLX5_INDIRECT_ACTION_IDX_GET(handle) \
70 : : (((uint32_t)(uintptr_t)(handle)) & \
71 : : ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1))
72 : :
73 : : enum mlx5_indirect_type {
74 : : MLX5_INDIRECT_ACTION_TYPE_RSS,
75 : : MLX5_INDIRECT_ACTION_TYPE_AGE,
76 : : MLX5_INDIRECT_ACTION_TYPE_COUNT,
77 : : MLX5_INDIRECT_ACTION_TYPE_CT,
78 : : MLX5_INDIRECT_ACTION_TYPE_METER_MARK,
79 : : MLX5_INDIRECT_ACTION_TYPE_QUOTA,
80 : : };
81 : :
82 : : /* Now, the maximal ports will be supported is 16, action number is 32M. */
83 : : #define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10
84 : :
85 : : #define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 25
86 : : #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
87 : :
88 : : /*
89 : : * When SW steering flow engine is used, the CT action handles are encoded in a following way:
90 : : * - bits 31:29 - type
91 : : * - bits 28:25 - port index of the action owner
92 : : * - bits 24:0 - action index
93 : : */
94 : : #define MLX5_INDIRECT_ACT_CT_GEN_IDX(owner, index) \
95 : : ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \
96 : : (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
97 : : MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) | (index))
98 : :
99 : : #define MLX5_INDIRECT_ACT_CT_GET_OWNER(index) \
100 : : (((index) >> MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) & \
101 : : MLX5_INDIRECT_ACT_CT_OWNER_MASK)
102 : :
103 : : #define MLX5_INDIRECT_ACT_CT_GET_IDX(index) \
104 : : ((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1))
105 : :
106 : : #define MLX5_FLOW_CONNTRACK_PKT_STATE_ALL \
107 : : (RTE_FLOW_CONNTRACK_PKT_STATE_VALID | RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED | \
108 : : RTE_FLOW_CONNTRACK_PKT_STATE_INVALID | RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED | \
109 : : RTE_FLOW_CONNTRACK_PKT_STATE_BAD)
110 : :
111 : : /*
112 : : * When HW steering flow engine is used, the CT action handles are encoded in a following way:
113 : : * - bits 31:29 - type
114 : : * - bits 28:0 - action index
115 : : */
116 : : #define MLX5_INDIRECT_ACT_HWS_CT_GEN_IDX(index) \
117 : : ((struct rte_flow_action_handle *)(uintptr_t) \
118 : : ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | (index)))
119 : :
120 : : #define MLX5_EMPTY_ECPRI_TYPE_MASK RTE_BIT32(0)
121 : : #define MLX5_EMPTY_ECPRI_BODY_MASK RTE_BIT32(1)
122 : :
123 : : enum mlx5_indirect_list_type {
124 : : MLX5_INDIRECT_ACTION_LIST_TYPE_ERR = 0,
125 : : MLX5_INDIRECT_ACTION_LIST_TYPE_LEGACY = 1,
126 : : MLX5_INDIRECT_ACTION_LIST_TYPE_MIRROR = 2,
127 : : MLX5_INDIRECT_ACTION_LIST_TYPE_REFORMAT = 3,
128 : : };
129 : :
130 : : /**
131 : : * Base type for indirect list type.
132 : : */
133 : : struct mlx5_indirect_list {
134 : : /* Indirect list type. */
135 : : enum mlx5_indirect_list_type type;
136 : : /* Optional storage list entry */
137 : : LIST_ENTRY(mlx5_indirect_list) entry;
138 : : };
139 : :
140 : : static __rte_always_inline void
141 : : mlx5_indirect_list_add_entry(void *head, struct mlx5_indirect_list *elem)
142 : : {
143 : : LIST_HEAD(, mlx5_indirect_list) *h = head;
144 : :
145 [ # # # # ]: 0 : LIST_INSERT_HEAD(h, elem, entry);
146 : 0 : }
147 : :
148 : : static __rte_always_inline void
149 : : mlx5_indirect_list_remove_entry(struct mlx5_indirect_list *elem)
150 : : {
151 [ # # # # ]: 0 : if (elem->entry.le_prev)
152 [ # # # # ]: 0 : LIST_REMOVE(elem, entry);
153 : : }
154 : :
155 : : static __rte_always_inline enum mlx5_indirect_list_type
156 : : mlx5_get_indirect_list_type(const struct rte_flow_action_list_handle *obj)
157 : : {
158 [ # # # # : 0 : return ((const struct mlx5_indirect_list *)obj)->type;
# # # # #
# # # # #
# # ]
159 : : }
160 : :
161 : : /* Matches on selected register. */
162 : : struct mlx5_rte_flow_item_tag {
163 : : enum modify_reg id;
164 : : uint32_t data;
165 : : };
166 : :
167 : : /* Modify selected register. */
168 : : struct mlx5_rte_flow_action_set_tag {
169 : : enum modify_reg id;
170 : : uint8_t offset;
171 : : uint8_t length;
172 : : uint32_t data;
173 : : };
174 : :
175 : : struct mlx5_flow_action_copy_mreg {
176 : : enum modify_reg dst;
177 : : enum modify_reg src;
178 : : };
179 : :
180 : : /* Matches on source queue. */
181 : : struct mlx5_rte_flow_item_sq {
182 : : uint32_t queue; /* DevX SQ number */
183 : : #ifdef RTE_ARCH_64
184 : : uint32_t reserved;
185 : : #endif
186 : : };
187 : :
188 : : /* Map from registers to modify fields. */
189 : : extern enum mlx5_modification_field mlx5_reg_to_field[];
190 : : extern const size_t mlx5_mod_reg_size;
191 : :
192 : : static __rte_always_inline enum mlx5_modification_field
193 : : mlx5_convert_reg_to_field(enum modify_reg reg)
194 : : {
195 : : MLX5_ASSERT((size_t)reg < mlx5_mod_reg_size);
196 : 0 : return mlx5_reg_to_field[reg];
197 : : }
198 : :
199 : : /* Feature name to allocate metadata register. */
200 : : enum mlx5_feature_name {
201 : : MLX5_HAIRPIN_RX,
202 : : MLX5_HAIRPIN_TX,
203 : : MLX5_METADATA_RX,
204 : : MLX5_METADATA_TX,
205 : : MLX5_METADATA_FDB,
206 : : MLX5_FLOW_MARK,
207 : : MLX5_APP_TAG,
208 : : MLX5_COPY_MARK,
209 : : MLX5_MTR_COLOR,
210 : : MLX5_MTR_ID,
211 : : MLX5_ASO_FLOW_HIT,
212 : : MLX5_ASO_CONNTRACK,
213 : : MLX5_SAMPLE_ID,
214 : : };
215 : :
216 : : #define MLX5_MIRROR_MAX_CLONES_NUM 3
217 : : #define MLX5_MIRROR_MAX_SAMPLE_ACTIONS_LEN 4
218 : :
219 : : struct mlx5_mirror_clone {
220 : : enum rte_flow_action_type type;
221 : : void *action_ctx;
222 : : };
223 : :
224 : : struct mlx5_mirror {
225 : : struct mlx5_indirect_list indirect;
226 : : uint32_t clones_num;
227 : : struct mlx5dr_action *mirror_action;
228 : : struct mlx5_mirror_clone clone[MLX5_MIRROR_MAX_CLONES_NUM];
229 : : };
230 : :
231 : : #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
232 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
233 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV6 (1u << 2)
234 : : #define MLX5_FLOW_LAYER_OUTER_L4_UDP (1u << 3)
235 : : #define MLX5_FLOW_LAYER_OUTER_L4_TCP (1u << 4)
236 : : #define MLX5_FLOW_LAYER_OUTER_VLAN (1u << 5)
237 : :
238 : : /* Pattern inner Layer bits. */
239 : : #define MLX5_FLOW_LAYER_INNER_L2 (1u << 6)
240 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV4 (1u << 7)
241 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV6 (1u << 8)
242 : : #define MLX5_FLOW_LAYER_INNER_L4_UDP (1u << 9)
243 : : #define MLX5_FLOW_LAYER_INNER_L4_TCP (1u << 10)
244 : : #define MLX5_FLOW_LAYER_INNER_VLAN (1u << 11)
245 : :
246 : : /* Pattern tunnel Layer bits. */
247 : : #define MLX5_FLOW_LAYER_VXLAN (1u << 12)
248 : : #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13)
249 : : #define MLX5_FLOW_LAYER_GRE (1u << 14)
250 : : #define MLX5_FLOW_LAYER_MPLS (1u << 15)
251 : : /* List of tunnel Layer bits continued below. */
252 : :
253 : : /* General pattern items bits. */
254 : : #define MLX5_FLOW_ITEM_METADATA (1u << 16)
255 : : #define MLX5_FLOW_ITEM_PORT_ID (1u << 17)
256 : : #define MLX5_FLOW_ITEM_TAG (1u << 18)
257 : : #define MLX5_FLOW_ITEM_MARK (1u << 19)
258 : :
259 : : /* Pattern MISC bits. */
260 : : #define MLX5_FLOW_LAYER_ICMP (1u << 20)
261 : : #define MLX5_FLOW_LAYER_ICMP6 (1u << 21)
262 : : #define MLX5_FLOW_LAYER_GRE_KEY (1u << 22)
263 : :
264 : : /* Pattern tunnel Layer bits (continued). */
265 : : #define MLX5_FLOW_LAYER_IPIP (1u << 23)
266 : : #define MLX5_FLOW_LAYER_IPV6_ENCAP (1u << 24)
267 : : #define MLX5_FLOW_LAYER_NVGRE (1u << 25)
268 : : #define MLX5_FLOW_LAYER_GENEVE (1u << 26)
269 : :
270 : : /* Queue items. */
271 : : #define MLX5_FLOW_ITEM_SQ (1u << 27)
272 : :
273 : : /* Pattern tunnel Layer bits (continued). */
274 : : #define MLX5_FLOW_LAYER_GTP (1u << 28)
275 : :
276 : : /* Pattern eCPRI Layer bit. */
277 : : #define MLX5_FLOW_LAYER_ECPRI (UINT64_C(1) << 29)
278 : :
279 : : /* IPv6 Fragment Extension Header bit. */
280 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT (1u << 30)
281 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT (1u << 31)
282 : :
283 : : /* Pattern tunnel Layer bits (continued). */
284 : : #define MLX5_FLOW_LAYER_GENEVE_OPT (UINT64_C(1) << 32)
285 : : #define MLX5_FLOW_LAYER_GTP_PSC (UINT64_C(1) << 33)
286 : :
287 : : /* INTEGRITY item bits */
288 : : #define MLX5_FLOW_ITEM_OUTER_INTEGRITY (UINT64_C(1) << 34)
289 : : #define MLX5_FLOW_ITEM_INNER_INTEGRITY (UINT64_C(1) << 35)
290 : : #define MLX5_FLOW_ITEM_INTEGRITY \
291 : : (MLX5_FLOW_ITEM_OUTER_INTEGRITY | MLX5_FLOW_ITEM_INNER_INTEGRITY)
292 : :
293 : : /* Conntrack item. */
294 : : #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 36)
295 : :
296 : : /* Flex item */
297 : : #define MLX5_FLOW_ITEM_OUTER_FLEX (UINT64_C(1) << 37)
298 : : #define MLX5_FLOW_ITEM_INNER_FLEX (UINT64_C(1) << 38)
299 : : #define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 39)
300 : :
301 : : #define MLX5_FLOW_ITEM_FLEX \
302 : : (MLX5_FLOW_ITEM_OUTER_FLEX | MLX5_FLOW_ITEM_INNER_FLEX | \
303 : : MLX5_FLOW_ITEM_FLEX_TUNNEL)
304 : :
305 : : /* ESP item */
306 : : #define MLX5_FLOW_ITEM_ESP (UINT64_C(1) << 40)
307 : :
308 : : /* Port Representor/Represented Port item */
309 : : #define MLX5_FLOW_ITEM_PORT_REPRESENTOR (UINT64_C(1) << 41)
310 : : #define MLX5_FLOW_ITEM_REPRESENTED_PORT (UINT64_C(1) << 42)
311 : :
312 : : /* Meter color item */
313 : : #define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44)
314 : : #define MLX5_FLOW_ITEM_QUOTA (UINT64_C(1) << 45)
315 : :
316 : :
317 : : /* IPv6 routing extension item */
318 : : #define MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT (UINT64_C(1) << 45)
319 : : #define MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT (UINT64_C(1) << 46)
320 : :
321 : : /* Aggregated affinity item */
322 : : #define MLX5_FLOW_ITEM_AGGR_AFFINITY (UINT64_C(1) << 49)
323 : :
324 : : /* IB BTH ITEM. */
325 : : #define MLX5_FLOW_ITEM_IB_BTH (1ull << 51)
326 : :
327 : : /* PTYPE ITEM */
328 : : #define MLX5_FLOW_ITEM_PTYPE (1ull << 52)
329 : :
330 : : /* NSH ITEM */
331 : : #define MLX5_FLOW_ITEM_NSH (1ull << 53)
332 : :
333 : : /* COMPARE ITEM */
334 : : #define MLX5_FLOW_ITEM_COMPARE (1ull << 54)
335 : :
336 : : /* Random ITEM */
337 : : #define MLX5_FLOW_ITEM_RANDOM (1ull << 55)
338 : :
339 : : /* Outer Masks. */
340 : : #define MLX5_FLOW_LAYER_OUTER_L3 \
341 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
342 : : #define MLX5_FLOW_LAYER_OUTER_L4 \
343 : : (MLX5_FLOW_LAYER_OUTER_L4_UDP | MLX5_FLOW_LAYER_OUTER_L4_TCP)
344 : : #define MLX5_FLOW_LAYER_OUTER \
345 : : (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_OUTER_L3 | \
346 : : MLX5_FLOW_LAYER_OUTER_L4)
347 : :
348 : : /* Tunnel Masks. */
349 : : #define MLX5_FLOW_LAYER_TUNNEL \
350 : : (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \
351 : : MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | MLX5_FLOW_LAYER_MPLS | \
352 : : MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP | \
353 : : MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP | \
354 : : MLX5_FLOW_ITEM_FLEX_TUNNEL)
355 : :
356 : : /* Inner Masks. */
357 : : #define MLX5_FLOW_LAYER_INNER_L3 \
358 : : (MLX5_FLOW_LAYER_INNER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
359 : : #define MLX5_FLOW_LAYER_INNER_L4 \
360 : : (MLX5_FLOW_LAYER_INNER_L4_UDP | MLX5_FLOW_LAYER_INNER_L4_TCP)
361 : : #define MLX5_FLOW_LAYER_INNER \
362 : : (MLX5_FLOW_LAYER_INNER_L2 | MLX5_FLOW_LAYER_INNER_L3 | \
363 : : MLX5_FLOW_LAYER_INNER_L4)
364 : :
365 : : /* Layer Masks. */
366 : : #define MLX5_FLOW_LAYER_L2 \
367 : : (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_INNER_L2)
368 : : #define MLX5_FLOW_LAYER_L3_IPV4 \
369 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV4)
370 : : #define MLX5_FLOW_LAYER_L3_IPV6 \
371 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV6 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
372 : : #define MLX5_FLOW_LAYER_L3 \
373 : : (MLX5_FLOW_LAYER_L3_IPV4 | MLX5_FLOW_LAYER_L3_IPV6)
374 : : #define MLX5_FLOW_LAYER_L4 \
375 : : (MLX5_FLOW_LAYER_OUTER_L4 | MLX5_FLOW_LAYER_INNER_L4)
376 : :
377 : : /* Actions */
378 : : #define MLX5_FLOW_ACTION_DROP (1ull << 0)
379 : : #define MLX5_FLOW_ACTION_QUEUE (1ull << 1)
380 : : #define MLX5_FLOW_ACTION_RSS (1ull << 2)
381 : : #define MLX5_FLOW_ACTION_FLAG (1ull << 3)
382 : : #define MLX5_FLOW_ACTION_MARK (1ull << 4)
383 : : #define MLX5_FLOW_ACTION_COUNT (1ull << 5)
384 : : #define MLX5_FLOW_ACTION_PORT_ID (1ull << 6)
385 : : #define MLX5_FLOW_ACTION_OF_POP_VLAN (1ull << 7)
386 : : #define MLX5_FLOW_ACTION_OF_PUSH_VLAN (1ull << 8)
387 : : #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1ull << 9)
388 : : #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1ull << 10)
389 : : #define MLX5_FLOW_ACTION_SET_IPV4_SRC (1ull << 11)
390 : : #define MLX5_FLOW_ACTION_SET_IPV4_DST (1ull << 12)
391 : : #define MLX5_FLOW_ACTION_SET_IPV6_SRC (1ull << 13)
392 : : #define MLX5_FLOW_ACTION_SET_IPV6_DST (1ull << 14)
393 : : #define MLX5_FLOW_ACTION_SET_TP_SRC (1ull << 15)
394 : : #define MLX5_FLOW_ACTION_SET_TP_DST (1ull << 16)
395 : : #define MLX5_FLOW_ACTION_JUMP (1ull << 17)
396 : : #define MLX5_FLOW_ACTION_SET_TTL (1ull << 18)
397 : : #define MLX5_FLOW_ACTION_DEC_TTL (1ull << 19)
398 : : #define MLX5_FLOW_ACTION_SET_MAC_SRC (1ull << 20)
399 : : #define MLX5_FLOW_ACTION_SET_MAC_DST (1ull << 21)
400 : : #define MLX5_FLOW_ACTION_ENCAP (1ull << 22)
401 : : #define MLX5_FLOW_ACTION_DECAP (1ull << 23)
402 : : #define MLX5_FLOW_ACTION_INC_TCP_SEQ (1ull << 24)
403 : : #define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1ull << 25)
404 : : #define MLX5_FLOW_ACTION_INC_TCP_ACK (1ull << 26)
405 : : #define MLX5_FLOW_ACTION_DEC_TCP_ACK (1ull << 27)
406 : : #define MLX5_FLOW_ACTION_SET_TAG (1ull << 28)
407 : : #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 29)
408 : : #define MLX5_FLOW_ACTION_SET_META (1ull << 30)
409 : : #define MLX5_FLOW_ACTION_METER (1ull << 31)
410 : : #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32)
411 : : #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33)
412 : : #define MLX5_FLOW_ACTION_AGE (1ull << 34)
413 : : #define MLX5_FLOW_ACTION_DEFAULT_MISS (1ull << 35)
414 : : #define MLX5_FLOW_ACTION_SAMPLE (1ull << 36)
415 : : #define MLX5_FLOW_ACTION_TUNNEL_SET (1ull << 37)
416 : : #define MLX5_FLOW_ACTION_TUNNEL_MATCH (1ull << 38)
417 : : #define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)
418 : : #define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)
419 : : #define MLX5_FLOW_ACTION_CT (1ull << 41)
420 : : #define MLX5_FLOW_ACTION_SEND_TO_KERNEL (1ull << 42)
421 : : #define MLX5_FLOW_ACTION_INDIRECT_COUNT (1ull << 43)
422 : : #define MLX5_FLOW_ACTION_INDIRECT_AGE (1ull << 44)
423 : : #define MLX5_FLOW_ACTION_QUOTA (1ull << 46)
424 : : #define MLX5_FLOW_ACTION_PORT_REPRESENTOR (1ull << 47)
425 : : #define MLX5_FLOW_ACTION_IPV6_ROUTING_REMOVE (1ull << 48)
426 : : #define MLX5_FLOW_ACTION_IPV6_ROUTING_PUSH (1ull << 49)
427 : : #define MLX5_FLOW_ACTION_NAT64 (1ull << 50)
428 : : #define MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX (1ull << 51)
429 : :
430 : : #define MLX5_FLOW_DROP_INCLUSIVE_ACTIONS \
431 : : (MLX5_FLOW_ACTION_COUNT | MLX5_FLOW_ACTION_SAMPLE | MLX5_FLOW_ACTION_AGE)
432 : :
433 : : #define MLX5_FLOW_FATE_ACTIONS \
434 : : (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
435 : : MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \
436 : : MLX5_FLOW_ACTION_DEFAULT_MISS | \
437 : : MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \
438 : : MLX5_FLOW_ACTION_SEND_TO_KERNEL | \
439 : : MLX5_FLOW_ACTION_PORT_REPRESENTOR | \
440 : : MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX)
441 : :
442 : : #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
443 : : (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
444 : : MLX5_FLOW_ACTION_SEND_TO_KERNEL | \
445 : : MLX5_FLOW_ACTION_JUMP | MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \
446 : : MLX5_FLOW_ACTION_JUMP_TO_TABLE_INDEX)
447 : :
448 : : #define MLX5_FLOW_MODIFY_HDR_ACTIONS (MLX5_FLOW_ACTION_SET_IPV4_SRC | \
449 : : MLX5_FLOW_ACTION_SET_IPV4_DST | \
450 : : MLX5_FLOW_ACTION_SET_IPV6_SRC | \
451 : : MLX5_FLOW_ACTION_SET_IPV6_DST | \
452 : : MLX5_FLOW_ACTION_SET_TP_SRC | \
453 : : MLX5_FLOW_ACTION_SET_TP_DST | \
454 : : MLX5_FLOW_ACTION_SET_TTL | \
455 : : MLX5_FLOW_ACTION_DEC_TTL | \
456 : : MLX5_FLOW_ACTION_SET_MAC_SRC | \
457 : : MLX5_FLOW_ACTION_SET_MAC_DST | \
458 : : MLX5_FLOW_ACTION_INC_TCP_SEQ | \
459 : : MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
460 : : MLX5_FLOW_ACTION_INC_TCP_ACK | \
461 : : MLX5_FLOW_ACTION_DEC_TCP_ACK | \
462 : : MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \
463 : : MLX5_FLOW_ACTION_SET_TAG | \
464 : : MLX5_FLOW_ACTION_MARK_EXT | \
465 : : MLX5_FLOW_ACTION_SET_META | \
466 : : MLX5_FLOW_ACTION_SET_IPV4_DSCP | \
467 : : MLX5_FLOW_ACTION_SET_IPV6_DSCP | \
468 : : MLX5_FLOW_ACTION_MODIFY_FIELD)
469 : :
470 : : #define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \
471 : : MLX5_FLOW_ACTION_OF_PUSH_VLAN)
472 : :
473 : : #define MLX5_FLOW_XCAP_ACTIONS (MLX5_FLOW_ACTION_ENCAP | MLX5_FLOW_ACTION_DECAP)
474 : :
475 : : #define MLX5_IPV6_HDR_ECN_MASK 0x3
476 : : #define MLX5_IPV6_HDR_DSCP_SHIFT 2
477 : :
478 : : /* UDP port number for MPLS */
479 : : #define MLX5_UDP_PORT_MPLS 6635
480 : :
481 : : /* UDP port numbers for VxLAN. */
482 : : #define MLX5_UDP_PORT_VXLAN 4789
483 : : #define MLX5_UDP_PORT_VXLAN_GPE 4790
484 : :
485 : : /* UDP port numbers for RoCEv2. */
486 : : #define MLX5_UDP_PORT_ROCEv2 4791
487 : :
488 : : /* UDP port numbers for GENEVE. */
489 : : #define MLX5_UDP_PORT_GENEVE 6081
490 : :
491 : : /* UDP port numbers for ESP. */
492 : : #define MLX5_UDP_PORT_ESP 4500
493 : :
494 : : /* Lowest priority indicator. */
495 : : #define MLX5_FLOW_LOWEST_PRIO_INDICATOR ((uint32_t)-1)
496 : :
497 : : /*
498 : : * Max priority for ingress\egress flow groups
499 : : * greater than 0 and for any transfer flow group.
500 : : * From user configation: 0 - 21843.
501 : : */
502 : : #define MLX5_NON_ROOT_FLOW_MAX_PRIO (21843 + 1)
503 : :
504 : : /*
505 : : * Number of sub priorities.
506 : : * For each kind of pattern matching i.e. L2, L3, L4 to have a correct
507 : : * matching on the NIC (firmware dependent) L4 most have the higher priority
508 : : * followed by L3 and ending with L2.
509 : : */
510 : : #define MLX5_PRIORITY_MAP_L2 2
511 : : #define MLX5_PRIORITY_MAP_L3 1
512 : : #define MLX5_PRIORITY_MAP_L4 0
513 : : #define MLX5_PRIORITY_MAP_MAX 3
514 : :
515 : : /* Valid layer type for IPV4 RSS. */
516 : : #define MLX5_IPV4_LAYER_TYPES \
517 : : (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | \
518 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
519 : : RTE_ETH_RSS_NONFRAG_IPV4_OTHER)
520 : :
521 : : /* IBV hash source bits for IPV4. */
522 : : #define MLX5_IPV4_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
523 : :
524 : : /* Valid layer type for IPV6 RSS. */
525 : : #define MLX5_IPV6_LAYER_TYPES \
526 : : (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
527 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_IPV6_EX | RTE_ETH_RSS_IPV6_TCP_EX | \
528 : : RTE_ETH_RSS_IPV6_UDP_EX | RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
529 : :
530 : : /* IBV hash source bits for IPV6. */
531 : : #define MLX5_IPV6_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
532 : :
533 : : /* IBV hash bits for L3 SRC. */
534 : : #define MLX5_L3_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_SRC_IPV6)
535 : :
536 : : /* IBV hash bits for L3 DST. */
537 : : #define MLX5_L3_DST_IBV_RX_HASH (IBV_RX_HASH_DST_IPV4 | IBV_RX_HASH_DST_IPV6)
538 : :
539 : : /* IBV hash bits for TCP. */
540 : : #define MLX5_TCP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
541 : : IBV_RX_HASH_DST_PORT_TCP)
542 : :
543 : : /* IBV hash bits for UDP. */
544 : : #define MLX5_UDP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_UDP | \
545 : : IBV_RX_HASH_DST_PORT_UDP)
546 : :
547 : : /* IBV hash bits for L4 SRC. */
548 : : #define MLX5_L4_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
549 : : IBV_RX_HASH_SRC_PORT_UDP)
550 : :
551 : : /* IBV hash bits for L4 DST. */
552 : : #define MLX5_L4_DST_IBV_RX_HASH (IBV_RX_HASH_DST_PORT_TCP | \
553 : : IBV_RX_HASH_DST_PORT_UDP)
554 : :
555 : : /* Geneve header first 16Bit */
556 : : #define MLX5_GENEVE_VER_MASK 0x3
557 : : #define MLX5_GENEVE_VER_SHIFT 14
558 : : #define MLX5_GENEVE_VER_VAL(a) \
559 : : (((a) >> (MLX5_GENEVE_VER_SHIFT)) & (MLX5_GENEVE_VER_MASK))
560 : : #define MLX5_GENEVE_OPTLEN_MASK 0x3F
561 : : #define MLX5_GENEVE_OPTLEN_SHIFT 8
562 : : #define MLX5_GENEVE_OPTLEN_VAL(a) \
563 : : (((a) >> (MLX5_GENEVE_OPTLEN_SHIFT)) & (MLX5_GENEVE_OPTLEN_MASK))
564 : : #define MLX5_GENEVE_OAMF_MASK 0x1
565 : : #define MLX5_GENEVE_OAMF_SHIFT 7
566 : : #define MLX5_GENEVE_OAMF_VAL(a) \
567 : : (((a) >> (MLX5_GENEVE_OAMF_SHIFT)) & (MLX5_GENEVE_OAMF_MASK))
568 : : #define MLX5_GENEVE_CRITO_MASK 0x1
569 : : #define MLX5_GENEVE_CRITO_SHIFT 6
570 : : #define MLX5_GENEVE_CRITO_VAL(a) \
571 : : (((a) >> (MLX5_GENEVE_CRITO_SHIFT)) & (MLX5_GENEVE_CRITO_MASK))
572 : : #define MLX5_GENEVE_RSVD_MASK 0x3F
573 : : #define MLX5_GENEVE_RSVD_VAL(a) ((a) & (MLX5_GENEVE_RSVD_MASK))
574 : : /*
575 : : * The length of the Geneve options fields, expressed in four byte multiples,
576 : : * not including the eight byte fixed tunnel.
577 : : */
578 : : #define MLX5_GENEVE_OPT_LEN_0 14
579 : : #define MLX5_GENEVE_OPT_LEN_1 63
580 : :
581 : : #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_ether_hdr) + \
582 : : sizeof(struct rte_ipv4_hdr))
583 : : /* GTP extension header flag. */
584 : : #define MLX5_GTP_EXT_HEADER_FLAG 4
585 : :
586 : : /* GTP extension header PDU type shift. */
587 : : #define MLX5_GTP_PDU_TYPE_SHIFT(a) ((a) << 4)
588 : :
589 : : /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
590 : : #define MLX5_IPV4_FRAG_OFFSET_MASK \
591 : : (RTE_IPV4_HDR_OFFSET_MASK | RTE_IPV4_HDR_MF_FLAG)
592 : :
593 : : /* Specific item's fields can accept a range of values (using spec and last). */
594 : : #define MLX5_ITEM_RANGE_NOT_ACCEPTED false
595 : : #define MLX5_ITEM_RANGE_ACCEPTED true
596 : :
597 : : /* Software header modify action numbers of a flow. */
598 : : #define MLX5_ACT_NUM_MDF_IPV4 1
599 : : #define MLX5_ACT_NUM_MDF_IPV6 4
600 : : #define MLX5_ACT_NUM_MDF_MAC 2
601 : : #define MLX5_ACT_NUM_MDF_VID 1
602 : : #define MLX5_ACT_NUM_MDF_PORT 1
603 : : #define MLX5_ACT_NUM_MDF_TTL 1
604 : : #define MLX5_ACT_NUM_DEC_TTL MLX5_ACT_NUM_MDF_TTL
605 : : #define MLX5_ACT_NUM_MDF_TCPSEQ 1
606 : : #define MLX5_ACT_NUM_MDF_TCPACK 1
607 : : #define MLX5_ACT_NUM_SET_REG 1
608 : : #define MLX5_ACT_NUM_SET_TAG 1
609 : : #define MLX5_ACT_NUM_CPY_MREG MLX5_ACT_NUM_SET_TAG
610 : : #define MLX5_ACT_NUM_SET_MARK MLX5_ACT_NUM_SET_TAG
611 : : #define MLX5_ACT_NUM_SET_META MLX5_ACT_NUM_SET_TAG
612 : : #define MLX5_ACT_NUM_SET_DSCP 1
613 : :
614 : : /* Maximum number of fields to modify in MODIFY_FIELD */
615 : : #define MLX5_ACT_MAX_MOD_FIELDS 5
616 : :
617 : : /* Syndrome bits definition for connection tracking. */
618 : : #define MLX5_CT_SYNDROME_VALID (0x0 << 6)
619 : : #define MLX5_CT_SYNDROME_INVALID (0x1 << 6)
620 : : #define MLX5_CT_SYNDROME_TRAP (0x2 << 6)
621 : : #define MLX5_CT_SYNDROME_STATE_CHANGE (0x1 << 1)
622 : : #define MLX5_CT_SYNDROME_BAD_PACKET (0x1 << 0)
623 : :
624 : : enum mlx5_flow_drv_type {
625 : : MLX5_FLOW_TYPE_MIN,
626 : : MLX5_FLOW_TYPE_DV,
627 : : MLX5_FLOW_TYPE_VERBS,
628 : : MLX5_FLOW_TYPE_HW,
629 : : MLX5_FLOW_TYPE_MAX,
630 : : };
631 : :
632 : : /* Fate action type. */
633 : : enum mlx5_flow_fate_type {
634 : : MLX5_FLOW_FATE_NONE, /* Egress flow. */
635 : : MLX5_FLOW_FATE_QUEUE,
636 : : MLX5_FLOW_FATE_JUMP,
637 : : MLX5_FLOW_FATE_PORT_ID,
638 : : MLX5_FLOW_FATE_DROP,
639 : : MLX5_FLOW_FATE_DEFAULT_MISS,
640 : : MLX5_FLOW_FATE_SHARED_RSS,
641 : : MLX5_FLOW_FATE_MTR,
642 : : MLX5_FLOW_FATE_SEND_TO_KERNEL,
643 : : MLX5_FLOW_FATE_MAX,
644 : : };
645 : :
646 : : /* Matcher PRM representation */
647 : : struct mlx5_flow_dv_match_params {
648 : : size_t size;
649 : : /**< Size of match value. Do NOT split size and key! */
650 : : uint32_t buf[MLX5_ST_SZ_DW(fte_match_param)];
651 : : /**< Matcher value. This value is used as the mask or as a key. */
652 : : };
653 : :
654 : : /* Matcher structure. */
655 : : struct mlx5_flow_dv_matcher {
656 : : struct mlx5_list_entry entry; /**< Pointer to the next element. */
657 : : union {
658 : : struct mlx5_flow_tbl_resource *tbl;
659 : : /**< Pointer to the table(group) the matcher associated with for DV flow. */
660 : : struct mlx5_flow_group *group;
661 : : /* Group of this matcher for HWS non template flow. */
662 : : };
663 : : void *matcher_object; /**< Pointer to DV matcher */
664 : : uint16_t crc; /**< CRC of key. */
665 : : uint16_t priority; /**< Priority of matcher. */
666 : : struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
667 : : };
668 : :
669 : : /* Encap/decap resource structure. */
670 : : struct mlx5_flow_dv_encap_decap_resource {
671 : : struct mlx5_list_entry entry;
672 : : /* Pointer to next element. */
673 : : uint32_t refcnt; /**< Reference counter. */
674 : : void *action;
675 : : /**< Encap/decap action object. */
676 : : uint8_t buf[MLX5_ENCAP_MAX_LEN];
677 : : size_t size;
678 : : uint8_t reformat_type;
679 : : uint8_t ft_type;
680 : : uint64_t flags; /**< Flags for RDMA API. */
681 : : uint32_t idx; /**< Index for the index memory pool. */
682 : : };
683 : :
684 : : /* Tag resource structure. */
685 : : struct mlx5_flow_dv_tag_resource {
686 : : struct mlx5_list_entry entry;
687 : : /**< hash list entry for tag resource, tag value as the key. */
688 : : void *action;
689 : : /**< Tag action object. */
690 : : uint32_t refcnt; /**< Reference counter. */
691 : : uint32_t idx; /**< Index for the index memory pool. */
692 : : uint32_t tag_id; /**< Tag ID. */
693 : : };
694 : :
695 : : /* Modify resource structure */
696 : : struct __rte_packed_begin mlx5_flow_dv_modify_hdr_resource {
697 : : struct mlx5_list_entry entry;
698 : : void *action; /**< Modify header action object. */
699 : : uint32_t idx;
700 : : uint64_t flags; /**< Flags for RDMA API(HWS only). */
701 : : /* Key area for hash list matching: */
702 : : uint8_t ft_type; /**< Flow table type, Rx or Tx. */
703 : : uint8_t actions_num; /**< Number of modification actions. */
704 : : bool root; /**< Whether action is in root table. */
705 : : struct mlx5_modification_cmd actions[];
706 : : /**< Modification actions. */
707 : : } __rte_packed_end;
708 : :
709 : : /* Modify resource key of the hash organization. */
710 : : union mlx5_flow_modify_hdr_key {
711 : : struct {
712 : : uint32_t ft_type:8; /**< Flow table type, Rx or Tx. */
713 : : uint32_t actions_num:5; /**< Number of modification actions. */
714 : : uint32_t group:19; /**< Flow group id. */
715 : : uint32_t cksum; /**< Actions check sum. */
716 : : };
717 : : uint64_t v64; /**< full 64bits value of key */
718 : : };
719 : :
720 : : /* Jump action resource structure. */
721 : : struct mlx5_flow_dv_jump_tbl_resource {
722 : : void *action; /**< Pointer to the rdma core action. */
723 : : };
724 : :
725 : : /* Port ID resource structure. */
726 : : struct mlx5_flow_dv_port_id_action_resource {
727 : : struct mlx5_list_entry entry;
728 : : void *action; /**< Action object. */
729 : : uint32_t port_id; /**< Port ID value. */
730 : : uint32_t idx; /**< Indexed pool memory index. */
731 : : };
732 : :
733 : : /* Push VLAN action resource structure */
734 : : struct mlx5_flow_dv_push_vlan_action_resource {
735 : : struct mlx5_list_entry entry; /* Cache entry. */
736 : : void *action; /**< Action object. */
737 : : uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */
738 : : rte_be32_t vlan_tag; /**< VLAN tag value. */
739 : : uint32_t idx; /**< Indexed pool memory index. */
740 : : };
741 : :
742 : : /* Metadata register copy table entry. */
743 : : struct mlx5_flow_mreg_copy_resource {
744 : : /*
745 : : * Hash list entry for copy table.
746 : : * - Key is 32/64-bit MARK action ID.
747 : : * - MUST be the first entry.
748 : : */
749 : : struct mlx5_list_entry hlist_ent;
750 : : LIST_ENTRY(mlx5_flow_mreg_copy_resource) next;
751 : : /* List entry for device flows. */
752 : : uint32_t idx;
753 : : uint32_t mark_id;
754 : : union {
755 : : uint32_t rix_flow; /* Built flow for copy. */
756 : : uintptr_t hw_flow;
757 : : };
758 : : };
759 : :
760 : : /* Table tunnel parameter. */
761 : : struct mlx5_flow_tbl_tunnel_prm {
762 : : const struct mlx5_flow_tunnel *tunnel;
763 : : uint32_t group_id;
764 : : bool external;
765 : : };
766 : :
767 : : /* Table data structure of the hash organization. */
768 : : struct mlx5_flow_tbl_data_entry {
769 : : struct mlx5_list_entry entry;
770 : : /**< hash list entry, 64-bits key inside. */
771 : : struct mlx5_flow_tbl_resource tbl;
772 : : /**< flow table resource. */
773 : : struct mlx5_list *matchers;
774 : : /**< matchers' header associated with the flow table. */
775 : : struct mlx5_flow_dv_jump_tbl_resource jump;
776 : : /**< jump resource, at most one for each table created. */
777 : : uint32_t idx; /**< index for the indexed mempool. */
778 : : /**< tunnel offload */
779 : : const struct mlx5_flow_tunnel *tunnel;
780 : : uint32_t group_id;
781 : : uint32_t external:1;
782 : : uint32_t tunnel_offload:1; /* Tunnel offload table or not. */
783 : : uint32_t is_egress:1; /**< Egress table. */
784 : : uint32_t is_transfer:1; /**< Transfer table. */
785 : : uint32_t dummy:1; /**< DR table. */
786 : : uint32_t id:22; /**< Table ID. */
787 : : uint32_t reserve:5; /**< Reserved to future using. */
788 : : uint32_t level; /**< Table level. */
789 : : };
790 : :
791 : : /* Sub rdma-core actions list. */
792 : : struct mlx5_flow_sub_actions_list {
793 : : uint32_t actions_num; /**< Number of sample actions. */
794 : : uint64_t action_flags;
795 : : void *dr_queue_action;
796 : : void *dr_tag_action;
797 : : void *dr_cnt_action;
798 : : void *dr_port_id_action;
799 : : void *dr_encap_action;
800 : : void *dr_jump_action;
801 : : };
802 : :
803 : : /* Sample sub-actions resource list. */
804 : : struct mlx5_flow_sub_actions_idx {
805 : : uint32_t rix_hrxq; /**< Hash Rx queue object index. */
806 : : uint32_t rix_tag; /**< Index to the tag action. */
807 : : uint32_t rix_port_id_action; /**< Index to port ID action resource. */
808 : : uint32_t rix_encap_decap; /**< Index to encap/decap resource. */
809 : : uint32_t rix_jump; /**< Index to the jump action resource. */
810 : : };
811 : :
812 : : /* Sample action resource structure. */
813 : : struct mlx5_flow_dv_sample_resource {
814 : : struct mlx5_list_entry entry; /**< Cache entry. */
815 : : union {
816 : : void *verbs_action; /**< Verbs sample action object. */
817 : : void **sub_actions; /**< Sample sub-action array. */
818 : : };
819 : : struct rte_eth_dev *dev; /**< Device registers the action. */
820 : : uint32_t idx; /** Sample object index. */
821 : : uint8_t ft_type; /** Flow Table Type */
822 : : uint32_t ft_id; /** Flow Table Level */
823 : : uint32_t ratio; /** Sample Ratio */
824 : : uint64_t set_action; /** Restore reg_c0 value */
825 : : void *normal_path_tbl; /** Flow Table pointer */
826 : : struct mlx5_flow_sub_actions_idx sample_idx;
827 : : /**< Action index resources. */
828 : : struct mlx5_flow_sub_actions_list sample_act;
829 : : /**< Action resources. */
830 : : };
831 : :
832 : : #define MLX5_MAX_DEST_NUM 2
833 : :
834 : : /* Destination array action resource structure. */
835 : : struct mlx5_flow_dv_dest_array_resource {
836 : : struct mlx5_list_entry entry; /**< Cache entry. */
837 : : uint32_t idx; /** Destination array action object index. */
838 : : uint8_t ft_type; /** Flow Table Type */
839 : : uint8_t num_of_dest; /**< Number of destination actions. */
840 : : struct rte_eth_dev *dev; /**< Device registers the action. */
841 : : void *action; /**< Pointer to the rdma core action. */
842 : : struct mlx5_flow_sub_actions_idx sample_idx[MLX5_MAX_DEST_NUM];
843 : : /**< Action index resources. */
844 : : struct mlx5_flow_sub_actions_list sample_act[MLX5_MAX_DEST_NUM];
845 : : /**< Action resources. */
846 : : };
847 : :
848 : : /* PMD flow priority for tunnel */
849 : : #define MLX5_TUNNEL_PRIO_GET(rss_desc) \
850 : : ((rss_desc)->level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4)
851 : :
852 : :
853 : : /** Device flow handle structure for DV mode only. */
854 : : struct __rte_packed_begin mlx5_flow_handle_dv {
855 : : /* Flow DV api: */
856 : : struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
857 : : struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
858 : : /**< Pointer to modify header resource in cache. */
859 : : uint32_t rix_encap_decap;
860 : : /**< Index to encap/decap resource in cache. */
861 : : uint32_t rix_push_vlan;
862 : : /**< Index to push VLAN action resource in cache. */
863 : : uint32_t rix_tag;
864 : : /**< Index to the tag action. */
865 : : uint32_t rix_sample;
866 : : /**< Index to sample action resource in cache. */
867 : : uint32_t rix_dest_array;
868 : : /**< Index to destination array resource in cache. */
869 : : } __rte_packed_end;
870 : :
871 : : /** Device flow handle structure: used both for creating & destroying. */
872 : : struct __rte_packed_begin mlx5_flow_handle {
873 : : SILIST_ENTRY(uint32_t)next;
874 : : struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
875 : : /**< Index to next device flow handle. */
876 : : uint64_t layers;
877 : : /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */
878 : : void *drv_flow; /**< pointer to driver flow object. */
879 : : uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */
880 : : uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */
881 : : uint32_t fate_action:4; /**< Fate action type. */
882 : : union {
883 : : uint32_t rix_hrxq; /**< Hash Rx queue object index. */
884 : : uint32_t rix_jump; /**< Index to the jump action resource. */
885 : : uint32_t rix_port_id_action;
886 : : /**< Index to port ID action resource. */
887 : : uint32_t rix_fate;
888 : : /**< Generic value indicates the fate action. */
889 : : uint32_t rix_default_fate;
890 : : /**< Indicates default miss fate action. */
891 : : uint32_t rix_srss;
892 : : /**< Indicates shared RSS fate action. */
893 : : };
894 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
895 : : struct mlx5_flow_handle_dv dvh;
896 : : #endif
897 : : uint8_t flex_item; /**< referenced Flex Item bitmask. */
898 : : } __rte_packed_end;
899 : :
900 : : /*
901 : : * Size for Verbs device flow handle structure only. Do not use the DV only
902 : : * structure in Verbs. No DV flows attributes will be accessed.
903 : : * Macro offsetof() could also be used here.
904 : : */
905 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
906 : : #define MLX5_FLOW_HANDLE_VERBS_SIZE \
907 : : (sizeof(struct mlx5_flow_handle) - sizeof(struct mlx5_flow_handle_dv))
908 : : #else
909 : : #define MLX5_FLOW_HANDLE_VERBS_SIZE (sizeof(struct mlx5_flow_handle))
910 : : #endif
911 : :
912 : : /** Device flow structure only for DV flow creation. */
913 : : struct mlx5_flow_dv_workspace {
914 : : uint32_t group; /**< The group index. */
915 : : uint32_t table_id; /**< Flow table identifier. */
916 : : uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
917 : : int actions_n; /**< number of actions. */
918 : : void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; /**< Action list. */
919 : : struct mlx5_flow_dv_encap_decap_resource *encap_decap;
920 : : /**< Pointer to encap/decap resource in cache. */
921 : : struct mlx5_flow_dv_push_vlan_action_resource *push_vlan_res;
922 : : /**< Pointer to push VLAN action resource in cache. */
923 : : struct mlx5_flow_dv_tag_resource *tag_resource;
924 : : /**< pointer to the tag action. */
925 : : struct mlx5_flow_dv_port_id_action_resource *port_id_action;
926 : : /**< Pointer to port ID action resource. */
927 : : struct mlx5_flow_dv_jump_tbl_resource *jump;
928 : : /**< Pointer to the jump action resource. */
929 : : struct mlx5_flow_dv_match_params value;
930 : : /**< Holds the value that the packet is compared to. */
931 : : struct mlx5_flow_dv_sample_resource *sample_res;
932 : : /**< Pointer to the sample action resource. */
933 : : struct mlx5_flow_dv_dest_array_resource *dest_array_res;
934 : : /**< Pointer to the destination array resource. */
935 : : };
936 : :
937 : : #ifdef HAVE_INFINIBAND_VERBS_H
938 : : /*
939 : : * Maximal Verbs flow specifications & actions size.
940 : : * Some elements are mutually exclusive, but enough space should be allocated.
941 : : * Tunnel cases: 1. Max 2 Ethernet + IP(v6 len > v4 len) + TCP/UDP headers.
942 : : * 2. One tunnel header (exception: GRE + MPLS),
943 : : * SPEC length: GRE == tunnel.
944 : : * Actions: 1. 1 Mark OR Flag.
945 : : * 2. 1 Drop (if any).
946 : : * 3. No limitation for counters, but it makes no sense to support too
947 : : * many counters in a single device flow.
948 : : */
949 : : #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
950 : : #define MLX5_VERBS_MAX_SPEC_SIZE \
951 : : ( \
952 : : (2 * (sizeof(struct ibv_flow_spec_eth) + \
953 : : sizeof(struct ibv_flow_spec_ipv6) + \
954 : : sizeof(struct ibv_flow_spec_tcp_udp)) + \
955 : : sizeof(struct ibv_flow_spec_gre) + \
956 : : sizeof(struct ibv_flow_spec_mpls)) \
957 : : )
958 : : #else
959 : : #define MLX5_VERBS_MAX_SPEC_SIZE \
960 : : ( \
961 : : (2 * (sizeof(struct ibv_flow_spec_eth) + \
962 : : sizeof(struct ibv_flow_spec_ipv6) + \
963 : : sizeof(struct ibv_flow_spec_tcp_udp)) + \
964 : : sizeof(struct ibv_flow_spec_tunnel)) \
965 : : )
966 : : #endif
967 : :
968 : : #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \
969 : : defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
970 : : #define MLX5_VERBS_MAX_ACT_SIZE \
971 : : ( \
972 : : sizeof(struct ibv_flow_spec_action_tag) + \
973 : : sizeof(struct ibv_flow_spec_action_drop) + \
974 : : sizeof(struct ibv_flow_spec_counter_action) * 4 \
975 : : )
976 : : #else
977 : : #define MLX5_VERBS_MAX_ACT_SIZE \
978 : : ( \
979 : : sizeof(struct ibv_flow_spec_action_tag) + \
980 : : sizeof(struct ibv_flow_spec_action_drop) \
981 : : )
982 : : #endif
983 : :
984 : : #define MLX5_VERBS_MAX_SPEC_ACT_SIZE \
985 : : (MLX5_VERBS_MAX_SPEC_SIZE + MLX5_VERBS_MAX_ACT_SIZE)
986 : :
987 : : /** Device flow structure only for Verbs flow creation. */
988 : : struct mlx5_flow_verbs_workspace {
989 : : unsigned int size; /**< Size of the attribute. */
990 : : struct ibv_flow_attr attr; /**< Verbs flow attribute buffer. */
991 : : uint8_t specs[MLX5_VERBS_MAX_SPEC_ACT_SIZE];
992 : : /**< Specifications & actions buffer of verbs flow. */
993 : : };
994 : : #endif /* HAVE_INFINIBAND_VERBS_H */
995 : :
996 : : #define MLX5_SCALE_FLOW_GROUP_BIT 0
997 : : #define MLX5_SCALE_JUMP_FLOW_GROUP_BIT 1
998 : :
999 : : /** Maximal number of device sub-flows supported. */
1000 : : #define MLX5_NUM_MAX_DEV_FLOWS 64
1001 : :
1002 : : /**
1003 : : * tunnel offload rules type
1004 : : */
1005 : : enum mlx5_tof_rule_type {
1006 : : MLX5_TUNNEL_OFFLOAD_NONE = 0,
1007 : : MLX5_TUNNEL_OFFLOAD_SET_RULE,
1008 : : MLX5_TUNNEL_OFFLOAD_MATCH_RULE,
1009 : : MLX5_TUNNEL_OFFLOAD_MISS_RULE,
1010 : : };
1011 : :
1012 : : /** Device flow structure. */
1013 : : __extension__
1014 : : struct mlx5_flow {
1015 : : struct rte_flow *flow; /**< Pointer to the main flow. */
1016 : : uint32_t flow_idx; /**< The memory pool index to the main flow. */
1017 : : uint64_t hash_fields; /**< Hash Rx queue hash fields. */
1018 : : uint64_t act_flags;
1019 : : /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
1020 : : bool external; /**< true if the flow is created external to PMD. */
1021 : : uint8_t ingress:1; /**< 1 if the flow is ingress. */
1022 : : uint8_t skip_scale:2;
1023 : : uint8_t symmetric_hash_function:1;
1024 : : /**
1025 : : * Each Bit be set to 1 if Skip the scale the flow group with factor.
1026 : : * If bit0 be set to 1, then skip the scale the original flow group;
1027 : : * If bit1 be set to 1, then skip the scale the jump flow group if
1028 : : * having jump action.
1029 : : * 00: Enable scale in a flow, default value.
1030 : : * 01: Skip scale the flow group with factor, enable scale the group
1031 : : * of jump action.
1032 : : * 10: Enable scale the group with factor, skip scale the group of
1033 : : * jump action.
1034 : : * 11: Skip scale the table with factor both for flow group and jump
1035 : : * group.
1036 : : */
1037 : : union {
1038 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1039 : : struct mlx5_flow_dv_workspace dv;
1040 : : #endif
1041 : : #ifdef HAVE_INFINIBAND_VERBS_H
1042 : : struct mlx5_flow_verbs_workspace verbs;
1043 : : #endif
1044 : : };
1045 : : struct mlx5_flow_handle *handle;
1046 : : uint32_t handle_idx; /* Index of the mlx5 flow handle memory. */
1047 : : const struct mlx5_flow_tunnel *tunnel;
1048 : : enum mlx5_tof_rule_type tof_type;
1049 : : };
1050 : :
1051 : : /* Flow meter state. */
1052 : : #define MLX5_FLOW_METER_DISABLE 0
1053 : : #define MLX5_FLOW_METER_ENABLE 1
1054 : :
1055 : : #define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u
1056 : : #define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u
1057 : :
1058 : : #define MLX5_CT_POLL_WQE_CQE_TIMES MLX5_MTR_POLL_WQE_CQE_TIMES
1059 : :
1060 : : #define MLX5_MAN_WIDTH 8
1061 : : /* Legacy Meter parameter structure. */
1062 : : struct mlx5_legacy_flow_meter {
1063 : : struct mlx5_flow_meter_info fm;
1064 : : /* Must be the first in struct. */
1065 : : TAILQ_ENTRY(mlx5_legacy_flow_meter) next;
1066 : : /**< Pointer to the next flow meter structure. */
1067 : : uint32_t idx;
1068 : : /* Index to meter object. */
1069 : : };
1070 : :
1071 : : #define MLX5_MAX_TUNNELS 256
1072 : : #define MLX5_TNL_MISS_RULE_PRIORITY 3
1073 : : #define MLX5_TNL_MISS_FDB_JUMP_GRP 0x1234faac
1074 : :
1075 : : /*
1076 : : * When tunnel offload is active, all JUMP group ids are converted
1077 : : * using the same method. That conversion is applied both to tunnel and
1078 : : * regular rule types.
1079 : : * Group ids used in tunnel rules are relative to it's tunnel (!).
1080 : : * Application can create number of steer rules, using the same
1081 : : * tunnel, with different group id in each rule.
1082 : : * Each tunnel stores its groups internally in PMD tunnel object.
1083 : : * Groups used in regular rules do not belong to any tunnel and are stored
1084 : : * in tunnel hub.
1085 : : */
1086 : :
1087 : : struct mlx5_flow_tunnel {
1088 : : LIST_ENTRY(mlx5_flow_tunnel) chain;
1089 : : struct rte_flow_tunnel app_tunnel; /** app tunnel copy */
1090 : : uint32_t tunnel_id; /** unique tunnel ID */
1091 : : RTE_ATOMIC(uint32_t) refctn;
1092 : : struct rte_flow_action action;
1093 : : struct rte_flow_item item;
1094 : : struct mlx5_hlist *groups; /** tunnel groups */
1095 : : };
1096 : :
1097 : : /** PMD tunnel related context */
1098 : : struct mlx5_flow_tunnel_hub {
1099 : : /* Tunnels list
1100 : : * Access to the list MUST be MT protected
1101 : : */
1102 : : LIST_HEAD(, mlx5_flow_tunnel) tunnels;
1103 : : /* protect access to the tunnels list */
1104 : : rte_spinlock_t sl;
1105 : : struct mlx5_hlist *groups; /** non tunnel groups */
1106 : : };
1107 : :
1108 : : /* convert jump group to flow table ID in tunnel rules */
1109 : : struct tunnel_tbl_entry {
1110 : : struct mlx5_list_entry hash;
1111 : : uint32_t flow_table;
1112 : : uint32_t tunnel_id;
1113 : : uint32_t group;
1114 : : };
1115 : :
1116 : : static inline uint32_t
1117 : : tunnel_id_to_flow_tbl(uint32_t id)
1118 : : {
1119 : 0 : return id | (1u << 16);
1120 : : }
1121 : :
1122 : : static inline uint32_t
1123 : : tunnel_flow_tbl_to_id(uint32_t flow_tbl)
1124 : : {
1125 : 0 : return flow_tbl & ~(1u << 16);
1126 : : }
1127 : :
1128 : : union tunnel_tbl_key {
1129 : : uint64_t val;
1130 : : struct {
1131 : : uint32_t tunnel_id;
1132 : : uint32_t group;
1133 : : };
1134 : : };
1135 : :
1136 : : static inline struct mlx5_flow_tunnel_hub *
1137 : : mlx5_tunnel_hub(struct rte_eth_dev *dev)
1138 : : {
1139 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
1140 [ # # ]: 0 : return priv->sh->tunnel_hub;
1141 : : }
1142 : :
1143 : : static inline bool
1144 : : is_tunnel_offload_active(const struct rte_eth_dev *dev)
1145 : : {
1146 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1147 : 0 : const struct mlx5_priv *priv = dev->data->dev_private;
1148 [ # # # # : 0 : return !!priv->sh->config.dv_miss_info;
# # # # ]
1149 : : #else
1150 : : RTE_SET_USED(dev);
1151 : : return false;
1152 : : #endif
1153 : : }
1154 : :
1155 : : static inline bool
1156 : : is_flow_tunnel_match_rule(enum mlx5_tof_rule_type tof_rule_type)
1157 : : {
1158 : : return tof_rule_type == MLX5_TUNNEL_OFFLOAD_MATCH_RULE;
1159 : : }
1160 : :
1161 : : static inline bool
1162 : : is_flow_tunnel_steer_rule(enum mlx5_tof_rule_type tof_rule_type)
1163 : : {
1164 : : return tof_rule_type == MLX5_TUNNEL_OFFLOAD_SET_RULE;
1165 : : }
1166 : :
1167 : : static inline const struct mlx5_flow_tunnel *
1168 : : flow_actions_to_tunnel(const struct rte_flow_action actions[])
1169 : : {
1170 : : return actions[0].conf;
1171 : : }
1172 : :
1173 : : static inline const struct mlx5_flow_tunnel *
1174 : : flow_items_to_tunnel(const struct rte_flow_item items[])
1175 : : {
1176 : 0 : return items[0].spec;
1177 : : }
1178 : :
1179 : : /**
1180 : : * Gets the tag array given for RTE_FLOW_FIELD_TAG type.
1181 : : *
1182 : : * In old API the value was provided in "level" field, but in new API
1183 : : * it is provided in "tag_array" field. Since encapsulation level is not
1184 : : * relevant for metadata, the tag array can be still provided in "level"
1185 : : * for backwards compatibility.
1186 : : *
1187 : : * @param[in] data
1188 : : * Pointer to tag modify data structure.
1189 : : *
1190 : : * @return
1191 : : * Tag array index.
1192 : : */
1193 : : static inline uint8_t
1194 : 0 : flow_tag_index_get(const struct rte_flow_field_data *data)
1195 : : {
1196 [ # # # # ]: 0 : return data->tag_index ? data->tag_index : data->level;
1197 : : }
1198 : :
1199 : : /**
1200 : : * Fetch 1, 2, 3 or 4 byte field from the byte array
1201 : : * and return as unsigned integer in host-endian format.
1202 : : *
1203 : : * @param[in] data
1204 : : * Pointer to data array.
1205 : : * @param[in] size
1206 : : * Size of field to extract.
1207 : : *
1208 : : * @return
1209 : : * converted field in host endian format.
1210 : : */
1211 : : static inline uint32_t
1212 : 0 : flow_dv_fetch_field(const uint8_t *data, uint32_t size)
1213 : : {
1214 : : uint32_t ret;
1215 : :
1216 [ # # # # : 0 : switch (size) {
# ]
1217 : 0 : case 1:
1218 : 0 : ret = *data;
1219 : 0 : break;
1220 : 0 : case 2:
1221 [ # # ]: 0 : ret = rte_be_to_cpu_16(*(const unaligned_uint16_t *)data);
1222 : : break;
1223 : 0 : case 3:
1224 [ # # ]: 0 : ret = rte_be_to_cpu_16(*(const unaligned_uint16_t *)data);
1225 : 0 : ret = (ret << 8) | *(data + sizeof(uint16_t));
1226 : 0 : break;
1227 : 0 : case 4:
1228 [ # # ]: 0 : ret = rte_be_to_cpu_32(*(const unaligned_uint32_t *)data);
1229 : : break;
1230 : : default:
1231 : : MLX5_ASSERT(false);
1232 : : ret = 0;
1233 : : break;
1234 : : }
1235 : 0 : return ret;
1236 : : }
1237 : :
1238 : : static inline bool
1239 : : flow_modify_field_support_tag_array(enum rte_flow_field_id field)
1240 : : {
1241 [ # # # # ]: 0 : switch ((int)field) {
1242 : : case RTE_FLOW_FIELD_TAG:
1243 : : case RTE_FLOW_FIELD_MPLS:
1244 : : case MLX5_RTE_FLOW_FIELD_META_REG:
1245 : : return true;
1246 : : default:
1247 : : break;
1248 : : }
1249 : : return false;
1250 : : }
1251 : :
1252 : : struct field_modify_info {
1253 : : uint32_t size; /* Size of field in protocol header, in bytes. */
1254 : : uint32_t offset; /* Offset of field in protocol header, in bytes. */
1255 : : enum mlx5_modification_field id;
1256 : : uint32_t shift;
1257 : : uint8_t is_flex; /* Temporary indicator for flex item modify filed WA. */
1258 : : };
1259 : :
1260 : : /* HW steering flow attributes. */
1261 : : struct mlx5_flow_attr {
1262 : : uint32_t port_id; /* Port index. */
1263 : : uint32_t group; /* Flow group. */
1264 : : uint32_t priority; /* Original Priority. */
1265 : : /* rss level, used by priority adjustment. */
1266 : : uint32_t rss_level;
1267 : : /* Action flags, used by priority adjustment. */
1268 : : uint32_t act_flags;
1269 : : uint32_t tbl_type; /* Flow table type. */
1270 : : uint32_t hws_root_match_flags;
1271 : : };
1272 : :
1273 : : /* Flow structure. */
1274 : : struct __rte_packed_begin rte_flow {
1275 : : uint32_t dev_handles;
1276 : : /**< Device flow handles that are part of the flow. */
1277 : : uint32_t type:2;
1278 : : uint32_t drv_type:2; /**< Driver type. */
1279 : : uint32_t tunnel:1;
1280 : : uint32_t meter:24; /**< Holds flow meter id. */
1281 : : uint32_t indirect_type:2; /**< Indirect action type. */
1282 : : uint32_t matcher_selector:1; /**< Matcher index in resizable table. */
1283 : : uint32_t rix_mreg_copy;
1284 : : /**< Index to metadata register copy table resource. */
1285 : : uint32_t counter; /**< Holds flow counter. */
1286 : : uint32_t tunnel_id; /**< Tunnel id */
1287 : : union {
1288 : : uint32_t age; /**< Holds ASO age bit index. */
1289 : : uint32_t ct; /**< Holds ASO CT index. */
1290 : : };
1291 : : uint32_t geneve_tlv_option; /**< Holds Geneve TLV option id. > */
1292 : : } __rte_packed_end;
1293 : :
1294 : : /*
1295 : : * HWS COUNTER ID's layout
1296 : : * 3 2 1 0
1297 : : * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
1298 : : * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1299 : : * | T | | D | |
1300 : : * ~ Y | | C | IDX ~
1301 : : * | P | | S | |
1302 : : * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1303 : : *
1304 : : * Bit 31:29 = TYPE = MLX5_INDIRECT_ACTION_TYPE_COUNT = b'10
1305 : : * Bit 25:24 = DCS index
1306 : : * Bit 23:00 = IDX in this counter belonged DCS bulk.
1307 : : */
1308 : : typedef uint32_t cnt_id_t;
1309 : :
1310 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1311 : :
1312 : : enum {
1313 : : MLX5_FLOW_HW_FLOW_OP_TYPE_NONE,
1314 : : MLX5_FLOW_HW_FLOW_OP_TYPE_CREATE,
1315 : : MLX5_FLOW_HW_FLOW_OP_TYPE_DESTROY,
1316 : : MLX5_FLOW_HW_FLOW_OP_TYPE_UPDATE,
1317 : : MLX5_FLOW_HW_FLOW_OP_TYPE_RSZ_TBL_CREATE,
1318 : : MLX5_FLOW_HW_FLOW_OP_TYPE_RSZ_TBL_DESTROY,
1319 : : MLX5_FLOW_HW_FLOW_OP_TYPE_RSZ_TBL_MOVE,
1320 : : };
1321 : :
1322 : : enum {
1323 : : MLX5_FLOW_HW_FLOW_FLAG_CNT_ID = RTE_BIT32(0),
1324 : : MLX5_FLOW_HW_FLOW_FLAG_FATE_JUMP = RTE_BIT32(1),
1325 : : MLX5_FLOW_HW_FLOW_FLAG_FATE_HRXQ = RTE_BIT32(2),
1326 : : MLX5_FLOW_HW_FLOW_FLAG_AGE_IDX = RTE_BIT32(3),
1327 : : MLX5_FLOW_HW_FLOW_FLAG_MTR_ID = RTE_BIT32(4),
1328 : : MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR = RTE_BIT32(5),
1329 : : MLX5_FLOW_HW_FLOW_FLAG_UPD_FLOW = RTE_BIT32(6),
1330 : : };
1331 : :
1332 : : #define MLX5_FLOW_HW_FLOW_FLAGS_ALL ( \
1333 : : MLX5_FLOW_HW_FLOW_FLAG_CNT_ID | \
1334 : : MLX5_FLOW_HW_FLOW_FLAG_FATE_JUMP | \
1335 : : MLX5_FLOW_HW_FLOW_FLAG_FATE_HRXQ | \
1336 : : MLX5_FLOW_HW_FLOW_FLAG_AGE_IDX | \
1337 : : MLX5_FLOW_HW_FLOW_FLAG_MTR_ID | \
1338 : : MLX5_FLOW_HW_FLOW_FLAG_MATCHER_SELECTOR | \
1339 : : MLX5_FLOW_HW_FLOW_FLAG_UPD_FLOW \
1340 : : )
1341 : :
1342 : : #ifdef PEDANTIC
1343 : : #pragma GCC diagnostic ignored "-Wpedantic"
1344 : : #endif
1345 : :
1346 : : #define MLX5_DR_RULE_SIZE 72
1347 : :
1348 : : SLIST_HEAD(mlx5_nta_rss_flow_head, rte_flow_hw);
1349 : :
1350 : : struct mlx5_sample_release_ctx {
1351 : : struct mlx5_list_entry *mirror_entry;
1352 : : uint32_t sample_group;
1353 : : };
1354 : :
1355 : : /** HWS non template flow data. */
1356 : : struct rte_flow_nt2hws {
1357 : : /** BWC rule pointer. */
1358 : : struct mlx5dr_bwc_rule *nt_rule;
1359 : : /** The matcher for non template api. */
1360 : : struct mlx5_flow_dv_matcher *matcher;
1361 : : /**< Auxiliary data stored per flow. */
1362 : : struct rte_flow_hw_aux *flow_aux;
1363 : : /** Modify header pointer. */
1364 : : struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
1365 : : /** SAMPLE resources */
1366 : : struct mlx5_sample_release_ctx *sample_release_ctx;
1367 : : /** Chain NTA flows. */
1368 : : SLIST_ENTRY(rte_flow_hw) next;
1369 : : /** Encap/decap index. */
1370 : : uint32_t rix_encap_decap;
1371 : : uint32_t rix_mreg_copy;
1372 : : uint8_t chaned_flow;
1373 : : };
1374 : :
1375 : : /** HWS flow struct. */
1376 : : struct rte_flow_hw {
1377 : : union {
1378 : : /** The table flow allcated from. */
1379 : : struct rte_flow_template_table *table;
1380 : : /** Data needed for non template flows. */
1381 : : struct rte_flow_nt2hws *nt2hws;
1382 : : };
1383 : : /** Application's private data passed to enqueued flow operation. */
1384 : : void *user_data;
1385 : : union {
1386 : : /** Jump action. */
1387 : : struct mlx5_hw_jump_action *jump;
1388 : : /** TIR action. */
1389 : : struct mlx5_hrxq *hrxq;
1390 : : };
1391 : : /** Flow index from indexed pool. */
1392 : : uint32_t idx;
1393 : : /** Resource index from indexed pool. */
1394 : : uint32_t res_idx;
1395 : : /** HWS flow rule index passed to mlx5dr. */
1396 : : uint32_t rule_idx;
1397 : : /** Which flow fields (inline or in auxiliary struct) are used. */
1398 : : uint32_t flags;
1399 : : /** COUNT action index. */
1400 : : cnt_id_t cnt_id;
1401 : : /** Ongoing flow operation type. */
1402 : : uint8_t operation_type;
1403 : : /** Index of pattern template this flow is based on. */
1404 : : uint8_t mt_idx;
1405 : : /** Equals true if it is non template rule. */
1406 : : bool nt_rule;
1407 : : /**
1408 : : * Padding for alignment to 56 bytes.
1409 : : * Since mlx5dr rule is 72 bytes, whole flow is contained within 128 B (2 cache lines).
1410 : : * This space is reserved for future additions to flow struct.
1411 : : */
1412 : : uint8_t padding[9];
1413 : : /** HWS layer data struct. */
1414 : : uint8_t rule[];
1415 : : };
1416 : :
1417 : : /** Auxiliary data fields that are updatable. */
1418 : : struct rte_flow_hw_aux_fields {
1419 : : /** AGE action index. */
1420 : : uint32_t age_idx;
1421 : : /** Direct meter (METER or METER_MARK) action index. */
1422 : : uint32_t mtr_id;
1423 : : };
1424 : :
1425 : : /** Auxiliary data stored per flow which is not required to be stored in main flow structure. */
1426 : : struct rte_flow_hw_aux {
1427 : : /** Auxiliary fields associated with the original flow. */
1428 : : struct rte_flow_hw_aux_fields orig;
1429 : : /** Auxiliary fields associated with the updated flow. */
1430 : : struct rte_flow_hw_aux_fields upd;
1431 : : /** Index of resizable matcher associated with this flow. */
1432 : : uint8_t matcher_selector;
1433 : : /** Placeholder flow struct used during flow rule update operation. */
1434 : : struct rte_flow_hw upd_flow;
1435 : : };
1436 : :
1437 : : #ifdef PEDANTIC
1438 : : #pragma GCC diagnostic error "-Wpedantic"
1439 : : #endif
1440 : :
1441 : : struct mlx5_action_construct_data;
1442 : : typedef int
1443 : : (*indirect_list_callback_t)(struct rte_eth_dev *,
1444 : : const struct mlx5_action_construct_data *,
1445 : : const struct rte_flow_action *,
1446 : : struct mlx5dr_rule_action *);
1447 : :
1448 : : /* rte flow action translate to DR action struct. */
1449 : : struct mlx5_action_construct_data {
1450 : : LIST_ENTRY(mlx5_action_construct_data) next;
1451 : : /* Ensure the action types are matched. */
1452 : : int type;
1453 : : uint32_t idx; /* Data index. */
1454 : : uint16_t action_src; /* rte_flow_action src offset. */
1455 : : uint16_t action_dst; /* mlx5dr_rule_action dst offset. */
1456 : : indirect_list_callback_t indirect_list_cb;
1457 : : union {
1458 : : struct {
1459 : : /* Expected type of indirection action. */
1460 : : enum rte_flow_action_type expected_type;
1461 : : } indirect;
1462 : : struct {
1463 : : /* encap data len. */
1464 : : uint16_t len;
1465 : : } encap;
1466 : : struct {
1467 : : /* Modify header action offset in pattern. */
1468 : : uint16_t mhdr_cmds_off;
1469 : : /* Offset in pattern after modify header actions. */
1470 : : uint16_t mhdr_cmds_end;
1471 : : /*
1472 : : * True if this action is masked and does not need to
1473 : : * be generated.
1474 : : */
1475 : : bool shared;
1476 : : /*
1477 : : * Modified field definitions in dst field (SET, ADD)
1478 : : * or src field (COPY).
1479 : : */
1480 : : struct field_modify_info field[MLX5_ACT_MAX_MOD_FIELDS];
1481 : : /* Modified field definitions in dst field (COPY). */
1482 : : struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS];
1483 : : /*
1484 : : * Masks applied to field values to generate
1485 : : * PRM actions.
1486 : : */
1487 : : uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS];
1488 : : /* Copy of action passed to the action template. */
1489 : : struct rte_flow_action_modify_field action;
1490 : : } modify_header;
1491 : : struct {
1492 : : bool symmetric_hash_function; /* Symmetric RSS hash */
1493 : : uint64_t types; /* RSS hash types. */
1494 : : uint32_t level; /* RSS level. */
1495 : : uint32_t idx; /* Shared action index. */
1496 : : } shared_rss;
1497 : : struct {
1498 : : cnt_id_t id;
1499 : : } shared_counter;
1500 : : struct {
1501 : : /* IPv6 extension push data len. */
1502 : : uint16_t len;
1503 : : } ipv6_ext;
1504 : : struct {
1505 : : uint32_t id;
1506 : : uint32_t conf_masked:1;
1507 : : } shared_meter;
1508 : : };
1509 : : };
1510 : :
1511 : : #define MAX_GENEVE_OPTIONS_RESOURCES 7
1512 : :
1513 : : /* GENEVE TLV options manager structure. */
1514 : : struct mlx5_geneve_tlv_options_mng {
1515 : : uint8_t nb_options; /* Number of options inside the template. */
1516 : : struct {
1517 : : uint8_t opt_type;
1518 : : uint16_t opt_class;
1519 : : } options[MAX_GENEVE_OPTIONS_RESOURCES];
1520 : : };
1521 : :
1522 : : /* Flow item template struct. */
1523 : : struct rte_flow_pattern_template {
1524 : : LIST_ENTRY(rte_flow_pattern_template) next;
1525 : : /* Template attributes. */
1526 : : struct rte_flow_pattern_template_attr attr;
1527 : : struct mlx5dr_match_template *mt; /* mlx5 match template. */
1528 : : uint64_t item_flags; /* Item layer flags. */
1529 : : uint64_t orig_item_nb; /* Number of pattern items provided by the user (with END item). */
1530 : : RTE_ATOMIC(uint32_t) refcnt; /* Reference counter. */
1531 : : /*
1532 : : * If true, then rule pattern should be prepended with
1533 : : * represented_port pattern item.
1534 : : */
1535 : : bool implicit_port;
1536 : : /*
1537 : : * If true, then rule pattern should be prepended with
1538 : : * tag pattern item for representor matching.
1539 : : */
1540 : : bool implicit_tag;
1541 : : /* Manages all GENEVE TLV options used by this pattern template. */
1542 : : struct mlx5_geneve_tlv_options_mng geneve_opt_mng;
1543 : : uint8_t flex_item; /* flex item index. */
1544 : : /* Items on which this pattern template is based on. */
1545 : : struct rte_flow_item *items;
1546 : : };
1547 : :
1548 : : /* Flow action template struct. */
1549 : : struct rte_flow_actions_template {
1550 : : LIST_ENTRY(rte_flow_actions_template) next;
1551 : : /* Template attributes. */
1552 : : struct rte_flow_actions_template_attr attr;
1553 : : struct rte_flow_action *actions; /* Cached flow actions. */
1554 : : struct rte_flow_action *orig_actions; /* Original flow actions. */
1555 : : struct rte_flow_action *masks; /* Cached action masks.*/
1556 : : struct mlx5dr_action_template *tmpl; /* mlx5dr action template. */
1557 : : uint64_t action_flags; /* Bit-map of all valid action in template. */
1558 : : uint16_t dr_actions_num; /* Amount of DR rules actions. */
1559 : : uint16_t actions_num; /* Amount of flow actions */
1560 : : uint16_t *dr_off; /* DR action offset for given rte action offset. */
1561 : : uint16_t *src_off; /* RTE action displacement from app. template */
1562 : : uint16_t reformat_off; /* Offset of DR reformat action. */
1563 : : uint16_t mhdr_off; /* Offset of DR modify header action. */
1564 : : uint16_t recom_off; /* Offset of DR IPv6 routing push remove action. */
1565 : : RTE_ATOMIC(uint32_t) refcnt; /* Reference counter. */
1566 : : uint8_t flex_item; /* flex item index. */
1567 : : };
1568 : :
1569 : : /* Jump action struct. */
1570 : : struct mlx5_hw_jump_action {
1571 : : /* Action jump from root. */
1572 : : struct mlx5dr_action *root_action;
1573 : : /* HW steering jump action. */
1574 : : struct mlx5dr_action *hws_action;
1575 : : };
1576 : :
1577 : : /* Encap decap action struct. */
1578 : : struct mlx5_hw_encap_decap_action {
1579 : : struct mlx5_indirect_list indirect;
1580 : : enum mlx5dr_action_type action_type;
1581 : : struct mlx5dr_action *action; /* Action object. */
1582 : : /* Is header_reformat action shared across flows in table. */
1583 : : uint32_t shared:1;
1584 : : uint32_t multi_pattern:1;
1585 : : size_t data_size; /* Action metadata size. */
1586 : : uint8_t data[]; /* Action data. */
1587 : : };
1588 : :
1589 : : /* Push remove action struct. */
1590 : : struct mlx5_hw_push_remove_action {
1591 : : struct mlx5dr_action *action; /* Action object. */
1592 : : /* Is push_remove action shared across flows in table. */
1593 : : uint8_t shared;
1594 : : size_t data_size; /* Action metadata size. */
1595 : : uint8_t data[]; /* Action data. */
1596 : : };
1597 : :
1598 : : /* Modify field action struct. */
1599 : : struct mlx5_hw_modify_header_action {
1600 : : /* Reference to DR action */
1601 : : struct mlx5dr_action *action;
1602 : : /* Modify header action position in action rule table. */
1603 : : uint16_t pos;
1604 : : /* Is MODIFY_HEADER action shared across flows in table. */
1605 : : uint32_t shared:1;
1606 : : uint32_t multi_pattern:1;
1607 : : /* Amount of modification commands stored in the precompiled buffer. */
1608 : : uint32_t mhdr_cmds_num;
1609 : : /* Precompiled modification commands. */
1610 : : struct mlx5_modification_cmd mhdr_cmds[MLX5_MHDR_MAX_CMD];
1611 : : };
1612 : :
1613 : : /* The maximum actions support in the flow. */
1614 : : #define MLX5_HW_MAX_ACTS 32
1615 : :
1616 : : /* DR action set struct. */
1617 : : struct mlx5_hw_actions {
1618 : : /* Dynamic action list. */
1619 : : LIST_HEAD(act_list, mlx5_action_construct_data) act_list;
1620 : : struct mlx5_hw_jump_action *jump; /* Jump action. */
1621 : : struct mlx5_hrxq *tir; /* TIR action. */
1622 : : struct mlx5_hw_modify_header_action *mhdr; /* Modify header action. */
1623 : : /* Encap/Decap action. */
1624 : : struct mlx5_hw_encap_decap_action *encap_decap;
1625 : : uint16_t encap_decap_pos; /* Encap/Decap action position. */
1626 : : /* Push/remove action. */
1627 : : struct mlx5_hw_push_remove_action *push_remove;
1628 : : uint16_t push_remove_pos; /* Push/remove action position. */
1629 : : uint32_t mark:1; /* Indicate the mark action. */
1630 : : cnt_id_t cnt_id; /* Counter id. */
1631 : : uint32_t mtr_id; /* Meter id. */
1632 : : struct mlx5dr_action *nat64[2]; /* [RTE_FLOW_NAT64_6TO4], [RTE_FLOW_NAT64_4TO6] */
1633 : : /* Translated DR action array from action template. */
1634 : : struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS];
1635 : : };
1636 : :
1637 : : /* mlx5 action template struct. */
1638 : : struct mlx5_hw_action_template {
1639 : : /* Action template pointer. */
1640 : : struct rte_flow_actions_template *action_template;
1641 : : struct mlx5_hw_actions acts; /* Template actions. */
1642 : : };
1643 : :
1644 : : /* mlx5 flow group struct. */
1645 : : struct mlx5_flow_group {
1646 : : struct mlx5_list_entry entry;
1647 : : LIST_ENTRY(mlx5_flow_group) next;
1648 : : struct rte_eth_dev *dev; /* Reference to corresponding device. */
1649 : : struct mlx5dr_table *tbl; /* HWS table object. */
1650 : : struct mlx5_hw_jump_action jump; /* Jump action. */
1651 : : struct mlx5_flow_group *miss_group; /* Group pointed to by miss action. */
1652 : : enum mlx5dr_table_type type; /* Table type. */
1653 : : uint32_t group_id; /* Group id. */
1654 : : uint32_t idx; /* Group memory index. */
1655 : : /* List of all matchers created for this group in non template api */
1656 : : struct mlx5_list *matchers;
1657 : : };
1658 : :
1659 : : /**
1660 : : * Returns true if a group with the given index is a root group.
1661 : : *
1662 : : * @param group_id
1663 : : * Group index.
1664 : : * It is assumed that provided index is already translated from user index to PMD index
1665 : : * (as is for transfer groups for example).
1666 : : *
1667 : : * @returns
1668 : : * True if group is a root group.
1669 : : * False otherwise.
1670 : : */
1671 : : static inline bool
1672 : 0 : mlx5_group_id_is_root(uint32_t group_id)
1673 : : {
1674 : 0 : return group_id == 0;
1675 : : }
1676 : :
1677 : : #define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 32
1678 : : #define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32
1679 : :
1680 : : #define MLX5_MULTIPATTERN_ENCAP_NUM 5
1681 : : #define MLX5_MAX_TABLE_RESIZE_NUM 64
1682 : :
1683 : : struct mlx5_multi_pattern_segment {
1684 : : /*
1685 : : * Modify Header Argument Objects number allocated for action in that
1686 : : * segment.
1687 : : * Capacity is always power of 2.
1688 : : */
1689 : : uint32_t capacity;
1690 : : uint32_t head_index;
1691 : : struct mlx5dr_action *mhdr_action;
1692 : : struct mlx5dr_action *reformat_action[MLX5_MULTIPATTERN_ENCAP_NUM];
1693 : : };
1694 : :
1695 : : struct mlx5_tbl_multi_pattern_ctx {
1696 : : struct {
1697 : : uint32_t elements_num;
1698 : : struct mlx5dr_action_reformat_header reformat_hdr[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
1699 : : /**
1700 : : * insert_header structure is larger than reformat_header.
1701 : : * Enclosing these structures with union will case a gap between
1702 : : * reformat_hdr array elements.
1703 : : * mlx5dr_action_create_reformat() expects adjacent array elements.
1704 : : */
1705 : : struct mlx5dr_action_insert_header insert_hdr[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
1706 : : } reformat[MLX5_MULTIPATTERN_ENCAP_NUM];
1707 : :
1708 : : struct {
1709 : : uint32_t elements_num;
1710 : : struct mlx5dr_action_mh_pattern pattern[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
1711 : : } mh;
1712 : : struct mlx5_multi_pattern_segment segments[MLX5_MAX_TABLE_RESIZE_NUM];
1713 : : };
1714 : :
1715 : : static __rte_always_inline void
1716 : : mlx5_multi_pattern_activate(struct mlx5_tbl_multi_pattern_ctx *mpctx)
1717 : : {
1718 : 0 : mpctx->segments[0].head_index = 1;
1719 : 0 : }
1720 : :
1721 : : static __rte_always_inline bool
1722 : : mlx5_is_multi_pattern_active(const struct mlx5_tbl_multi_pattern_ctx *mpctx)
1723 : : {
1724 [ # # # # ]: 0 : return mpctx->segments[0].head_index == 1;
1725 : : }
1726 : :
1727 : : struct mlx5_flow_template_table_cfg {
1728 : : struct rte_flow_template_table_attr attr; /* Table attributes passed through flow API. */
1729 : : bool external; /* True if created by flow API, false if table is internal to PMD. */
1730 : : };
1731 : :
1732 : : struct mlx5_matcher_info {
1733 : : struct mlx5dr_matcher *matcher; /* Template matcher. */
1734 : : struct mlx5dr_action *jump; /* Jump to matcher action. */
1735 : : RTE_ATOMIC(uint32_t) refcnt;
1736 : : };
1737 : :
1738 : : struct __rte_cache_aligned mlx5_dr_rule_action_container {
1739 : : struct mlx5dr_rule_action acts[MLX5_HW_MAX_ACTS];
1740 : : };
1741 : :
1742 : : struct rte_flow_template_table {
1743 : : LIST_ENTRY(rte_flow_template_table) next;
1744 : : struct mlx5_flow_group *grp; /* The group rte_flow_template_table uses. */
1745 : : struct mlx5_matcher_info matcher_info[2];
1746 : : uint32_t matcher_selector;
1747 : : rte_rwlock_t matcher_replace_rwlk; /* RW lock for resizable tables */
1748 : : /* Item templates bind to the table. */
1749 : : struct rte_flow_pattern_template *its[MLX5_HW_TBL_MAX_ITEM_TEMPLATE];
1750 : : /* Action templates bind to the table. */
1751 : : struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
1752 : : struct mlx5_indexed_pool *flow_pool; /* The table's flow ipool. */
1753 : : struct rte_flow_hw_aux *flow_aux; /**< Auxiliary data stored per flow. */
1754 : : struct mlx5_indexed_pool *resource; /* The table's resource ipool. */
1755 : : struct mlx5_flow_template_table_cfg cfg;
1756 : : uint32_t type; /* Flow table type RX/TX/FDB. */
1757 : : uint8_t nb_item_templates; /* Item template number. */
1758 : : uint8_t nb_action_templates; /* Action template number. */
1759 : : uint32_t refcnt; /* Table reference counter. */
1760 : : struct mlx5_tbl_multi_pattern_ctx mpctx;
1761 : : struct mlx5dr_matcher_attr matcher_attr;
1762 : : /**
1763 : : * Variable length array of containers containing precalculated templates of DR actions
1764 : : * arrays. This array is allocated at template table creation time and contains
1765 : : * one container per each queue, per each actions template.
1766 : : * Essentially rule_acts is a 2-dimensional array indexed with (AT index, queue) pair.
1767 : : * Each container will provide a local "queue buffer" to work on for flow creation
1768 : : * operations when using a given actions template.
1769 : : */
1770 : : struct mlx5_dr_rule_action_container rule_acts[];
1771 : : };
1772 : :
1773 : : bool mlx5_vport_rx_metadata_passing_enabled(const struct mlx5_dev_ctx_shared *sh);
1774 : : bool mlx5_vport_tx_metadata_passing_enabled(const struct mlx5_dev_ctx_shared *sh);
1775 : : bool mlx5_esw_metadata_passing_enabled(const struct mlx5_dev_ctx_shared *sh);
1776 : :
1777 : : static __rte_always_inline struct mlx5dr_matcher *
1778 : : mlx5_table_matcher(const struct rte_flow_template_table *table)
1779 : : {
1780 : 0 : return table->matcher_info[table->matcher_selector].matcher;
1781 : : }
1782 : :
1783 : : static __rte_always_inline struct mlx5_multi_pattern_segment *
1784 : : mlx5_multi_pattern_segment_find(struct rte_flow_template_table *table,
1785 : : uint32_t flow_resource_ix)
1786 : : {
1787 : : int i;
1788 : : struct mlx5_tbl_multi_pattern_ctx *mpctx = &table->mpctx;
1789 : :
1790 [ # # # # : 0 : if (likely(!rte_flow_template_table_resizable(0, &table->cfg.attr)))
# # # # #
# # # # #
# # # # #
# ]
1791 : 0 : return &mpctx->segments[0];
1792 [ # # # # : 0 : for (i = 0; i < MLX5_MAX_TABLE_RESIZE_NUM; i++) {
# # # # #
# # # # #
# # # # #
# ]
1793 : 0 : uint32_t limit = mpctx->segments[i].head_index +
1794 : 0 : mpctx->segments[i].capacity;
1795 : :
1796 [ # # # # : 0 : if (flow_resource_ix < limit)
# # # # #
# # # # #
# # # # #
# ]
1797 : 0 : return &mpctx->segments[i];
1798 : : }
1799 : : return NULL;
1800 : : }
1801 : :
1802 : : static inline bool
1803 : : mlx5_esw_hws_xmeta_mode_meta32_enabled(const struct mlx5_dev_ctx_shared *sh)
1804 : : {
1805 : 0 : return sh->config.dv_esw_en &&
1806 : : (sh->config.dv_xmeta_en == MLX5_XMETA_MODE_META32_HWS);
1807 : : }
1808 : :
1809 : : /*
1810 : : * Convert metadata or tag to the actual register.
1811 : : * META: Fixed C_1 for FDB mode, REG_A for NIC TX and REG_B for NIC RX.
1812 : : * TAG: C_x expect meter color reg and the reserved ones.
1813 : : */
1814 : : static __rte_always_inline int
1815 : : flow_hw_get_reg_id_by_domain(struct rte_eth_dev *dev,
1816 : : enum rte_flow_item_type type,
1817 : : enum mlx5dr_table_type domain_type, uint32_t id)
1818 : : {
1819 : 0 : struct mlx5_dev_ctx_shared *sh = MLX5_SH(dev);
1820 : : struct mlx5_dev_registers *reg = &sh->registers;
1821 : :
1822 : : switch (type) {
1823 : : case RTE_FLOW_ITEM_TYPE_META:
1824 [ # # # # : 0 : if (mlx5_esw_hws_xmeta_mode_meta32_enabled(sh) ||
# # # # ]
1825 [ # # # # ]: 0 : mlx5_esw_metadata_passing_enabled(sh) ||
1826 [ # # # # ]: 0 : mlx5_vport_rx_metadata_passing_enabled(sh) ||
1827 : 0 : mlx5_vport_tx_metadata_passing_enabled(sh))
1828 : : return REG_C_1;
1829 : : /*
1830 : : * On root table - PMD allows only egress META matching, thus
1831 : : * REG_A matching is sufficient.
1832 : : *
1833 : : * On non-root tables - REG_A corresponds to general_purpose_lookup_field,
1834 : : * which translates to REG_A in NIC TX and to REG_B in NIC RX.
1835 : : * However, current FW does not implement REG_B case right now, so
1836 : : * REG_B case is return explicitly by this function for NIC RX.
1837 : : */
1838 [ # # # # ]: 0 : if (domain_type == MLX5DR_TABLE_TYPE_NIC_RX)
1839 : : return REG_B;
1840 : : return REG_A;
1841 : : case RTE_FLOW_ITEM_TYPE_CONNTRACK:
1842 : : case RTE_FLOW_ITEM_TYPE_METER_COLOR:
1843 [ # # ]: 0 : return reg->aso_reg;
1844 : : case RTE_FLOW_ITEM_TYPE_TAG:
1845 [ # # # # : 0 : if (id == RTE_PMD_MLX5_LINEAR_HASH_TAG_INDEX)
# # ]
1846 : : return REG_C_3;
1847 [ # # # # ]: 0 : if (id >= MLX5_FLOW_HW_TAGS_MAX)
1848 : : return REG_NON;
1849 [ # # # # : 0 : return reg->hw_avl_tags[id];
# # ]
1850 : : default:
1851 : : return REG_NON;
1852 : : }
1853 : : }
1854 : :
1855 : : static __rte_always_inline int
1856 : : flow_hw_get_reg_id_from_ctx(void *dr_ctx, enum rte_flow_item_type type,
1857 : : enum mlx5dr_table_type domain_type, uint32_t id)
1858 : : {
1859 : : uint16_t port;
1860 : :
1861 [ # # # # : 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
# # # # #
# # # #
# ]
1862 : : struct mlx5_priv *priv;
1863 : :
1864 : 0 : priv = rte_eth_devices[port].data->dev_private;
1865 [ # # # # : 0 : if (priv->dr_ctx == dr_ctx)
# # # # #
# # # #
# ]
1866 : 0 : return flow_hw_get_reg_id_by_domain(&rte_eth_devices[port],
1867 : : type, domain_type, id);
1868 : : }
1869 : : return REG_NON;
1870 : : }
1871 : :
1872 : : #endif
1873 : :
1874 : :
1875 : : /*
1876 : : * Define list of valid combinations of RX Hash fields
1877 : : * (see enum ibv_rx_hash_fields).
1878 : : */
1879 : : #define MLX5_RSS_HASH_IPV4 (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
1880 : : #define MLX5_RSS_HASH_IPV4_TCP \
1881 : : (MLX5_RSS_HASH_IPV4 | \
1882 : : IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP)
1883 : : #define MLX5_RSS_HASH_IPV4_UDP \
1884 : : (MLX5_RSS_HASH_IPV4 | \
1885 : : IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP)
1886 : : #define MLX5_RSS_HASH_IPV6 (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
1887 : : #define MLX5_RSS_HASH_IPV6_TCP \
1888 : : (MLX5_RSS_HASH_IPV6 | \
1889 : : IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP)
1890 : : #define MLX5_RSS_HASH_IPV6_UDP \
1891 : : (MLX5_RSS_HASH_IPV6 | \
1892 : : IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP)
1893 : : #define MLX5_RSS_HASH_IPV4_SRC_ONLY IBV_RX_HASH_SRC_IPV4
1894 : : #define MLX5_RSS_HASH_IPV4_DST_ONLY IBV_RX_HASH_DST_IPV4
1895 : : #define MLX5_RSS_HASH_IPV6_SRC_ONLY IBV_RX_HASH_SRC_IPV6
1896 : : #define MLX5_RSS_HASH_IPV6_DST_ONLY IBV_RX_HASH_DST_IPV6
1897 : : #define MLX5_RSS_HASH_IPV4_UDP_SRC_ONLY \
1898 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_SRC_PORT_UDP)
1899 : : #define MLX5_RSS_HASH_IPV4_UDP_DST_ONLY \
1900 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_DST_PORT_UDP)
1901 : : #define MLX5_RSS_HASH_IPV6_UDP_SRC_ONLY \
1902 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_SRC_PORT_UDP)
1903 : : #define MLX5_RSS_HASH_IPV6_UDP_DST_ONLY \
1904 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_DST_PORT_UDP)
1905 : : #define MLX5_RSS_HASH_IPV4_TCP_SRC_ONLY \
1906 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_SRC_PORT_TCP)
1907 : : #define MLX5_RSS_HASH_IPV4_TCP_DST_ONLY \
1908 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_DST_PORT_TCP)
1909 : : #define MLX5_RSS_HASH_IPV6_TCP_SRC_ONLY \
1910 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_SRC_PORT_TCP)
1911 : : #define MLX5_RSS_HASH_IPV6_TCP_DST_ONLY \
1912 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_DST_PORT_TCP)
1913 : :
1914 : : #ifndef HAVE_IBV_RX_HASH_IPSEC_SPI
1915 : : #define IBV_RX_HASH_IPSEC_SPI (1U << 8)
1916 : : #endif
1917 : :
1918 : : #define MLX5_RSS_HASH_ESP_SPI IBV_RX_HASH_IPSEC_SPI
1919 : : #define MLX5_RSS_HASH_IPV4_ESP (MLX5_RSS_HASH_IPV4 | \
1920 : : MLX5_RSS_HASH_ESP_SPI)
1921 : : #define MLX5_RSS_HASH_IPV6_ESP (MLX5_RSS_HASH_IPV6 | \
1922 : : MLX5_RSS_HASH_ESP_SPI)
1923 : : #define MLX5_RSS_HASH_NONE 0ULL
1924 : :
1925 : : #define MLX5_RSS_IS_SYMM(func) \
1926 : : (((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) || \
1927 : : ((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT))
1928 : :
1929 : :
1930 : : /**
1931 : : * Each enum variant corresponds to a single valid protocols combination for hrxq configuration
1932 : : * Each variant serves as an index into #mlx5_rss_hash_fields array containing default
1933 : : * bitmaps of ibv_rx_hash_fields flags for given protocols combination.
1934 : : */
1935 : : enum {
1936 : : MLX5_RSS_HASH_IDX_IPV4,
1937 : : MLX5_RSS_HASH_IDX_IPV4_TCP,
1938 : : MLX5_RSS_HASH_IDX_IPV4_UDP,
1939 : : MLX5_RSS_HASH_IDX_IPV4_ESP,
1940 : : MLX5_RSS_HASH_IDX_IPV6,
1941 : : MLX5_RSS_HASH_IDX_IPV6_TCP,
1942 : : MLX5_RSS_HASH_IDX_IPV6_UDP,
1943 : : MLX5_RSS_HASH_IDX_IPV6_ESP,
1944 : : MLX5_RSS_HASH_IDX_TCP,
1945 : : MLX5_RSS_HASH_IDX_UDP,
1946 : : MLX5_RSS_HASH_IDX_ESP_SPI,
1947 : : MLX5_RSS_HASH_IDX_NONE,
1948 : : MLX5_RSS_HASH_IDX_MAX,
1949 : : };
1950 : :
1951 : : /** Array of valid combinations of RX Hash fields for RSS. */
1952 : : extern const uint64_t mlx5_rss_hash_fields[];
1953 : :
1954 : : /* Shared RSS action structure */
1955 : : struct mlx5_shared_action_rss {
1956 : : ILIST_ENTRY(uint32_t)next; /**< Index to the next RSS structure. */
1957 : : RTE_ATOMIC(uint32_t) refcnt; /**< Atomically accessed refcnt. */
1958 : : struct rte_flow_action_rss origin; /**< Original rte RSS action. */
1959 : : uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
1960 : : struct mlx5_ind_table_obj *ind_tbl;
1961 : : /**< Hash RX queues (hrxq, hrxq_tunnel fields) indirection table. */
1962 : : uint32_t hrxq[MLX5_RSS_HASH_IDX_MAX];
1963 : : /**< Hash RX queue indexes mapped to mlx5_rss_hash_fields */
1964 : : rte_spinlock_t action_rss_sl; /**< Shared RSS action spinlock. */
1965 : : };
1966 : :
1967 : : struct rte_flow_action_handle {
1968 : : uint32_t id;
1969 : : };
1970 : :
1971 : : /* Thread specific flow workspace intermediate data. */
1972 : : struct mlx5_flow_workspace {
1973 : : /* If creating another flow in same thread, push new as stack. */
1974 : : struct mlx5_flow_workspace *prev;
1975 : : struct mlx5_flow_workspace *next;
1976 : : struct mlx5_flow_workspace *gc;
1977 : : uint32_t inuse; /* can't create new flow with current. */
1978 : : struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS];
1979 : : struct mlx5_flow_rss_desc rss_desc;
1980 : : uint32_t flow_idx; /* Intermediate device flow index. */
1981 : : struct mlx5_flow_meter_info *fm; /* Pointer to the meter in flow. */
1982 : : struct mlx5_flow_meter_policy *policy;
1983 : : /* The meter policy used by meter in flow. */
1984 : : struct mlx5_flow_meter_policy *final_policy;
1985 : : /* The final policy when meter policy is hierarchy. */
1986 : : #ifdef HAVE_MLX5_HWS_SUPPORT
1987 : : struct rte_flow_template_table *table;
1988 : : #endif
1989 : : uint32_t skip_matcher_reg:1;
1990 : : /* Indicates if need to skip matcher register in translate. */
1991 : : uint32_t mark:1; /* Indicates if flow contains mark action. */
1992 : : uint32_t empty_ecpri_type_mask:1; /* Indicates if eCPRI type was not masked. */
1993 : : uint32_t empty_ecpri_body_mask:1; /* Indicates if 1st DW of eCPRI payload was not masked. */
1994 : : uint32_t vport_meta_tag; /* Used for vport index match. */
1995 : : };
1996 : :
1997 : : /* Matcher translate type. */
1998 : : enum MLX5_SET_MATCHER {
1999 : : MLX5_SET_MATCHER_SW_V = 1 << 0,
2000 : : MLX5_SET_MATCHER_SW_M = 1 << 1,
2001 : : MLX5_SET_MATCHER_HS_V = 1 << 2,
2002 : : MLX5_SET_MATCHER_HS_M = 1 << 3,
2003 : : };
2004 : :
2005 : : #define MLX5_SET_MATCHER_SW (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_SW_M)
2006 : : #define MLX5_SET_MATCHER_HS (MLX5_SET_MATCHER_HS_V | MLX5_SET_MATCHER_HS_M)
2007 : : #define MLX5_SET_MATCHER_V (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_HS_V)
2008 : : #define MLX5_SET_MATCHER_M (MLX5_SET_MATCHER_SW_M | MLX5_SET_MATCHER_HS_M)
2009 : :
2010 : : /* Flow matcher workspace intermediate data. */
2011 : : struct mlx5_dv_matcher_workspace {
2012 : : uint8_t priority; /* Flow priority. */
2013 : : uint64_t last_item; /* Last item in pattern. */
2014 : : uint64_t item_flags; /* Flow item pattern flags. */
2015 : : uint64_t action_flags; /* Flow action flags. */
2016 : : bool external; /* External flow or not. */
2017 : : uint32_t vlan_tag:12; /* Flow item VLAN tag. */
2018 : : uint8_t next_protocol; /* Tunnel next protocol */
2019 : : uint32_t geneve_tlv_option; /* Flow item Geneve TLV option. */
2020 : : uint32_t group; /* Flow group. */
2021 : : uint16_t udp_dport; /* Flow item UDP port. */
2022 : : const struct rte_flow_attr *attr; /* Flow attribute. */
2023 : : struct mlx5_flow_rss_desc *rss_desc; /* RSS descriptor. */
2024 : : const struct rte_flow_item *tunnel_item; /* Flow tunnel item. */
2025 : : const struct rte_flow_item *gre_item; /* Flow GRE item. */
2026 : : const struct rte_flow_item *integrity_items[2];
2027 : : uint32_t *p_root_flags;
2028 : : };
2029 : :
2030 : : struct mlx5_flow_split_info {
2031 : : uint32_t external:1;
2032 : : /**< True if flow is created by request external to PMD. */
2033 : : uint32_t prefix_mark:1; /**< Prefix subflow mark flag. */
2034 : : uint32_t skip_scale:8; /**< Skip the scale the table with factor. */
2035 : : uint32_t flow_idx; /**< This memory pool index to the flow. */
2036 : : uint32_t table_id; /**< Flow table identifier. */
2037 : : uint64_t prefix_layers; /**< Prefix subflow layers. */
2038 : : };
2039 : :
2040 : : struct mlx5_flow_hw_partial_resource {
2041 : : const struct rte_flow_attr *attr;
2042 : : const struct rte_flow_item *items;
2043 : : const struct rte_flow_action *actions;
2044 : : };
2045 : :
2046 : : struct mlx5_flow_hw_split_resource {
2047 : : struct mlx5_flow_hw_partial_resource prefix;
2048 : : struct mlx5_flow_hw_partial_resource suffix;
2049 : : void *buf_start; /* start address of continuous buffer. */
2050 : : uint32_t flow_idx; /* This memory pool index to the flow. */
2051 : : };
2052 : :
2053 : : struct mlx5_hl_data {
2054 : : uint8_t dw_offset;
2055 : : uint32_t dw_mask;
2056 : : };
2057 : :
2058 : : extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];
2059 : :
2060 : : /*
2061 : : * Get sqn for given tx_queue.
2062 : : * Used in HWS rule creation.
2063 : : */
2064 : : static __rte_always_inline int
2065 : : flow_hw_get_sqn(struct rte_eth_dev *dev, uint16_t tx_queue, uint32_t *sqn)
2066 : : {
2067 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
2068 : : struct mlx5_txq_ctrl *txq;
2069 : : struct mlx5_external_q *ext_txq;
2070 : :
2071 : : /* Means Tx queue is PF0. */
2072 [ # # ]: 0 : if (tx_queue == UINT16_MAX) {
2073 : : *sqn = 0;
2074 : : return 0;
2075 : : }
2076 : : /* Validate tx_queue is within bounds before using as array index */
2077 [ # # ]: 0 : if (tx_queue >= priv->txqs_n)
2078 : : return -EINVAL;
2079 [ # # ]: 0 : if (mlx5_is_external_txq(dev, tx_queue)) {
2080 : 0 : ext_txq = mlx5_ext_txq_get(dev, tx_queue);
2081 [ # # ]: 0 : if (ext_txq == NULL)
2082 : : return -EINVAL;
2083 : 0 : *sqn = ext_txq->hw_id;
2084 : 0 : return 0;
2085 : : }
2086 : 0 : txq = mlx5_txq_get(dev, tx_queue);
2087 [ # # ]: 0 : if (unlikely(!txq))
2088 : : return -ENOENT;
2089 : 0 : *sqn = mlx5_txq_get_sqn(txq);
2090 : 0 : mlx5_txq_release(dev, tx_queue);
2091 : 0 : return 0;
2092 : : }
2093 : :
2094 : : /*
2095 : : * Convert sqn for given rte_eth_dev port.
2096 : : * Used in HWS rule creation.
2097 : : */
2098 : : static __rte_always_inline int
2099 : : flow_hw_conv_sqn(uint16_t port_id, uint16_t tx_queue, uint32_t *sqn)
2100 : : {
2101 [ # # ]: 0 : if (port_id >= RTE_MAX_ETHPORTS)
2102 : : return -EINVAL;
2103 [ # # ]: 0 : return flow_hw_get_sqn(&rte_eth_devices[port_id], tx_queue, sqn);
2104 : : }
2105 : :
2106 : : /*
2107 : : * Get given rte_eth_dev port_id.
2108 : : * Used in HWS rule creation.
2109 : : */
2110 : : static __rte_always_inline uint16_t
2111 : : flow_hw_get_port_id(void *dr_ctx)
2112 : : {
2113 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
2114 : : uint16_t port_id;
2115 : :
2116 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port_id, NULL) {
2117 : : struct mlx5_priv *priv;
2118 : :
2119 : 0 : priv = rte_eth_devices[port_id].data->dev_private;
2120 [ # # ]: 0 : if (priv->dr_ctx == dr_ctx)
2121 : : return port_id;
2122 : : }
2123 : : #else
2124 : : RTE_SET_USED(dr_ctx);
2125 : : #endif
2126 : : return UINT16_MAX;
2127 : : }
2128 : :
2129 : : /*
2130 : : * Get given eswitch manager id.
2131 : : * Used in HWS match with port creation.
2132 : : */
2133 : : static __rte_always_inline const struct flow_hw_port_info *
2134 : : flow_hw_get_esw_mgr_id(void *dr_ctx)
2135 : : {
2136 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
2137 : : uint16_t port_id;
2138 : :
2139 [ # # # # : 0 : MLX5_ETH_FOREACH_DEV(port_id, NULL) {
# # ]
2140 : : struct mlx5_priv *priv;
2141 : :
2142 : 0 : priv = rte_eth_devices[port_id].data->dev_private;
2143 [ # # # # : 0 : if (priv->dr_ctx == dr_ctx)
# # ]
2144 : 0 : return &priv->sh->dev_cap.esw_info;
2145 : : }
2146 : : #else
2147 : : RTE_SET_USED(dr_ctx);
2148 : : #endif
2149 : : return NULL;
2150 : : }
2151 : :
2152 : : /*
2153 : : * Get metadata match tag and mask for given rte_eth_dev port.
2154 : : * Used in HWS rule creation.
2155 : : */
2156 : : static __rte_always_inline const struct flow_hw_port_info *
2157 : : flow_hw_conv_port_id(void *ctx, const uint16_t port_id)
2158 : : {
2159 : : struct flow_hw_port_info *port_info;
2160 : :
2161 [ # # # # : 0 : if (port_id == UINT16_MAX && ctx)
# # ]
2162 : : return flow_hw_get_esw_mgr_id(ctx);
2163 : :
2164 [ # # # # : 0 : if (port_id >= RTE_MAX_ETHPORTS)
# # ]
2165 : : return NULL;
2166 : :
2167 : 0 : port_info = &mlx5_flow_hw_port_infos[port_id];
2168 [ # # # # : 0 : return port_info->is_set ? port_info : NULL;
# # ]
2169 : : }
2170 : :
2171 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
2172 : : /*
2173 : : * Get metadata match tag and mask for the uplink port represented
2174 : : * by given IB context. Used in HWS context creation.
2175 : : */
2176 : : static __rte_always_inline const struct flow_hw_port_info *
2177 : : flow_hw_get_wire_port(struct ibv_context *ibctx)
2178 : : {
2179 : 0 : struct ibv_device *ibdev = ibctx->device;
2180 : : uint16_t port_id;
2181 : :
2182 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port_id, NULL) {
2183 : 0 : const struct mlx5_priv *priv =
2184 : 0 : rte_eth_devices[port_id].data->dev_private;
2185 : :
2186 [ # # # # ]: 0 : if (priv && priv->master) {
2187 : 0 : struct ibv_context *port_ibctx = priv->sh->cdev->ctx;
2188 : :
2189 [ # # ]: 0 : if (port_ibctx->device == ibdev)
2190 : : return flow_hw_conv_port_id(priv->dr_ctx, port_id);
2191 : : }
2192 : : }
2193 : : return NULL;
2194 : : }
2195 : : #endif
2196 : :
2197 : : static __rte_always_inline int
2198 : : flow_hw_get_reg_id(struct rte_eth_dev *dev,
2199 : : enum rte_flow_item_type type, uint32_t id)
2200 : : {
2201 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
2202 : : return flow_hw_get_reg_id_by_domain(dev, type,
2203 : : MLX5DR_TABLE_TYPE_MAX, id);
2204 : : #else
2205 : : RTE_SET_USED(dev);
2206 : : RTE_SET_USED(type);
2207 : : RTE_SET_USED(id);
2208 : : return REG_NON;
2209 : : #endif
2210 : : }
2211 : :
2212 : : static __rte_always_inline int
2213 : : flow_hw_get_port_id_from_ctx(void *dr_ctx, uint32_t *port_val)
2214 : : {
2215 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
2216 : : uint32_t port;
2217 : :
2218 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
2219 : : struct mlx5_priv *priv;
2220 : 0 : priv = rte_eth_devices[port].data->dev_private;
2221 : :
2222 [ # # ]: 0 : if (priv->dr_ctx == dr_ctx) {
2223 : 0 : *port_val = port;
2224 : : return 0;
2225 : : }
2226 : : }
2227 : : #else
2228 : : RTE_SET_USED(dr_ctx);
2229 : : RTE_SET_USED(port_val);
2230 : : #endif
2231 : : return -EINVAL;
2232 : : }
2233 : :
2234 : : /**
2235 : : * Get GENEVE TLV option matching to given type and class.
2236 : : *
2237 : : * @param priv
2238 : : * Pointer to port's private data.
2239 : : * @param type
2240 : : * GENEVE option type.
2241 : : * @param class
2242 : : * GENEVE option class.
2243 : : *
2244 : : * @return
2245 : : * Pointer to option structure if exist, NULL otherwise and rte_errno is set.
2246 : : */
2247 : : struct mlx5_geneve_tlv_option *
2248 : : mlx5_geneve_tlv_option_get(const struct mlx5_priv *priv, uint8_t type,
2249 : : uint16_t class);
2250 : :
2251 : : /**
2252 : : * Get GENEVE TLV option FW information according type and class.
2253 : : *
2254 : : * @param[in] dr_ctx
2255 : : * Pointer to HW steering DR context.
2256 : : * @param[in] type
2257 : : * GENEVE TLV option type.
2258 : : * @param[in] class
2259 : : * GENEVE TLV option class.
2260 : : * @param[out] hl_ok_bit
2261 : : * Pointer to header layout structure describing OK bit FW information.
2262 : : * @param[out] num_of_dws
2263 : : * Pointer to fill inside the size of 'hl_dws' array.
2264 : : * @param[out] hl_dws
2265 : : * Pointer to header layout array describing data DWs FW information.
2266 : : * @param[out] ok_bit_on_class
2267 : : * Pointer to an indicator whether OK bit includes class along with type.
2268 : : *
2269 : : * @return
2270 : : * 0 on success, negative errno otherwise and rte_errno is set.
2271 : : */
2272 : : int
2273 : : mlx5_get_geneve_hl_data(const void *dr_ctx, uint8_t type, uint16_t class,
2274 : : struct mlx5_hl_data ** const hl_ok_bit,
2275 : : uint8_t *num_of_dws,
2276 : : struct mlx5_hl_data ** const hl_dws,
2277 : : bool *ok_bit_on_class);
2278 : :
2279 : : /**
2280 : : * Get modify field ID for single DW inside configured GENEVE TLV option.
2281 : : *
2282 : : * @param[in] dr_ctx
2283 : : * Pointer to HW steering DR context.
2284 : : * @param[in] type
2285 : : * GENEVE TLV option type.
2286 : : * @param[in] class
2287 : : * GENEVE TLV option class.
2288 : : * @param[in] dw_offset
2289 : : * Offset of DW inside the option.
2290 : : *
2291 : : * @return
2292 : : * Modify field ID on success, negative errno otherwise and rte_errno is set.
2293 : : */
2294 : : int
2295 : : mlx5_get_geneve_option_modify_field_id(const void *dr_ctx, uint8_t type,
2296 : : uint16_t class, uint8_t dw_offset);
2297 : :
2298 : : void *
2299 : : mlx5_geneve_tlv_parser_create(uint16_t port_id,
2300 : : const struct rte_pmd_mlx5_geneve_tlv tlv_list[],
2301 : : uint8_t nb_options);
2302 : : int mlx5_geneve_tlv_parser_destroy(void *handle);
2303 : : int mlx5_flow_geneve_tlv_option_validate(struct mlx5_priv *priv,
2304 : : const struct rte_flow_item *geneve_opt,
2305 : : struct rte_flow_error *error);
2306 : : int mlx5_geneve_opt_modi_field_get(struct mlx5_priv *priv,
2307 : : const struct rte_flow_field_data *data);
2308 : :
2309 : : struct mlx5_geneve_tlv_options_mng;
2310 : : int mlx5_geneve_tlv_option_register(struct mlx5_priv *priv,
2311 : : const struct rte_flow_item_geneve_opt *spec,
2312 : : struct mlx5_geneve_tlv_options_mng *mng);
2313 : : void mlx5_geneve_tlv_options_unregister(struct mlx5_priv *priv,
2314 : : struct mlx5_geneve_tlv_options_mng *mng);
2315 : :
2316 : : void mlx5_flow_hw_set_port_info(struct rte_eth_dev *dev);
2317 : : void mlx5_flow_hw_clear_port_info(struct rte_eth_dev *dev);
2318 : : int mlx5_flow_hw_create_vport_action(struct rte_eth_dev *dev);
2319 : : void mlx5_flow_hw_destroy_vport_action(struct rte_eth_dev *dev);
2320 : : int
2321 : : mlx5_flow_hw_init(struct rte_eth_dev *dev,
2322 : : struct rte_flow_error *error);
2323 : :
2324 : : typedef uintptr_t (*mlx5_flow_list_create_t)(struct rte_eth_dev *dev,
2325 : : enum mlx5_flow_type type,
2326 : : const struct rte_flow_attr *attr,
2327 : : const struct rte_flow_item items[],
2328 : : const struct rte_flow_action actions[],
2329 : : bool external,
2330 : : struct rte_flow_error *error);
2331 : : typedef void (*mlx5_flow_list_destroy_t)(struct rte_eth_dev *dev,
2332 : : enum mlx5_flow_type type,
2333 : : uintptr_t flow_idx);
2334 : : typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
2335 : : const struct rte_flow_attr *attr,
2336 : : const struct rte_flow_item items[],
2337 : : const struct rte_flow_action actions[],
2338 : : bool external,
2339 : : int hairpin,
2340 : : struct rte_flow_error *error);
2341 : : typedef struct mlx5_flow *(*mlx5_flow_prepare_t)
2342 : : (struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
2343 : : const struct rte_flow_item items[],
2344 : : const struct rte_flow_action actions[], struct rte_flow_error *error);
2345 : : typedef int (*mlx5_flow_translate_t)(struct rte_eth_dev *dev,
2346 : : struct mlx5_flow *dev_flow,
2347 : : const struct rte_flow_attr *attr,
2348 : : const struct rte_flow_item items[],
2349 : : const struct rte_flow_action actions[],
2350 : : struct rte_flow_error *error);
2351 : : typedef int (*mlx5_flow_apply_t)(struct rte_eth_dev *dev, struct rte_flow *flow,
2352 : : struct rte_flow_error *error);
2353 : : typedef void (*mlx5_flow_remove_t)(struct rte_eth_dev *dev,
2354 : : struct rte_flow *flow);
2355 : : typedef void (*mlx5_flow_destroy_t)(struct rte_eth_dev *dev,
2356 : : struct rte_flow *flow);
2357 : : typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,
2358 : : struct rte_flow *flow,
2359 : : const struct rte_flow_action *actions,
2360 : : void *data,
2361 : : struct rte_flow_error *error);
2362 : : typedef int (*mlx5_flow_create_mtr_tbls_t)(struct rte_eth_dev *dev,
2363 : : struct mlx5_flow_meter_info *fm,
2364 : : uint32_t mtr_idx,
2365 : : uint8_t domain_bitmap);
2366 : : typedef void (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,
2367 : : struct mlx5_flow_meter_info *fm);
2368 : : typedef void (*mlx5_flow_destroy_mtr_drop_tbls_t)(struct rte_eth_dev *dev);
2369 : : typedef struct mlx5_flow_meter_sub_policy *
2370 : : (*mlx5_flow_meter_sub_policy_rss_prepare_t)
2371 : : (struct rte_eth_dev *dev,
2372 : : struct mlx5_flow_meter_policy *mtr_policy,
2373 : : struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]);
2374 : : typedef int (*mlx5_flow_meter_hierarchy_rule_create_t)
2375 : : (struct rte_eth_dev *dev,
2376 : : struct mlx5_flow_meter_info *fm,
2377 : : int32_t src_port,
2378 : : const struct rte_flow_item *item,
2379 : : struct rte_flow_error *error);
2380 : : typedef void (*mlx5_flow_destroy_sub_policy_with_rxq_t)
2381 : : (struct rte_eth_dev *dev,
2382 : : struct mlx5_flow_meter_policy *mtr_policy);
2383 : : typedef uint32_t (*mlx5_flow_mtr_alloc_t)
2384 : : (struct rte_eth_dev *dev);
2385 : : typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
2386 : : uint32_t mtr_idx);
2387 : : typedef uint32_t (*mlx5_flow_counter_alloc_t)
2388 : : (struct rte_eth_dev *dev);
2389 : : typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
2390 : : uint32_t cnt);
2391 : : typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
2392 : : uint32_t cnt,
2393 : : bool clear, uint64_t *pkts,
2394 : : uint64_t *bytes, void **action);
2395 : : typedef int (*mlx5_flow_get_aged_flows_t)
2396 : : (struct rte_eth_dev *dev,
2397 : : void **context,
2398 : : uint32_t nb_contexts,
2399 : : struct rte_flow_error *error);
2400 : : typedef int (*mlx5_flow_get_q_aged_flows_t)
2401 : : (struct rte_eth_dev *dev,
2402 : : uint32_t queue_id,
2403 : : void **context,
2404 : : uint32_t nb_contexts,
2405 : : struct rte_flow_error *error);
2406 : : typedef int (*mlx5_flow_action_validate_t)
2407 : : (struct rte_eth_dev *dev,
2408 : : const struct rte_flow_indir_action_conf *conf,
2409 : : const struct rte_flow_action *action,
2410 : : struct rte_flow_error *error);
2411 : : typedef struct rte_flow_action_handle *(*mlx5_flow_action_create_t)
2412 : : (struct rte_eth_dev *dev,
2413 : : const struct rte_flow_indir_action_conf *conf,
2414 : : const struct rte_flow_action *action,
2415 : : struct rte_flow_error *error);
2416 : : typedef int (*mlx5_flow_action_destroy_t)
2417 : : (struct rte_eth_dev *dev,
2418 : : struct rte_flow_action_handle *action,
2419 : : struct rte_flow_error *error);
2420 : : typedef int (*mlx5_flow_action_update_t)
2421 : : (struct rte_eth_dev *dev,
2422 : : struct rte_flow_action_handle *action,
2423 : : const void *update,
2424 : : struct rte_flow_error *error);
2425 : : typedef int (*mlx5_flow_action_query_t)
2426 : : (struct rte_eth_dev *dev,
2427 : : const struct rte_flow_action_handle *action,
2428 : : void *data,
2429 : : struct rte_flow_error *error);
2430 : : typedef int (*mlx5_flow_action_query_update_t)
2431 : : (struct rte_eth_dev *dev,
2432 : : struct rte_flow_action_handle *handle,
2433 : : const void *update, void *data,
2434 : : enum rte_flow_query_update_mode qu_mode,
2435 : : struct rte_flow_error *error);
2436 : : typedef struct rte_flow_action_list_handle *
2437 : : (*mlx5_flow_action_list_handle_create_t)
2438 : : (struct rte_eth_dev *dev,
2439 : : const struct rte_flow_indir_action_conf *conf,
2440 : : const struct rte_flow_action *actions,
2441 : : struct rte_flow_error *error);
2442 : : typedef int
2443 : : (*mlx5_flow_action_list_handle_destroy_t)
2444 : : (struct rte_eth_dev *dev,
2445 : : struct rte_flow_action_list_handle *handle,
2446 : : struct rte_flow_error *error);
2447 : : typedef int (*mlx5_flow_sync_domain_t)
2448 : : (struct rte_eth_dev *dev,
2449 : : uint32_t domains,
2450 : : uint32_t flags);
2451 : : typedef int (*mlx5_flow_validate_mtr_acts_t)
2452 : : (struct rte_eth_dev *dev,
2453 : : const struct rte_flow_action *actions[RTE_COLORS],
2454 : : struct rte_flow_attr *attr,
2455 : : bool *is_rss,
2456 : : uint8_t *domain_bitmap,
2457 : : uint8_t *policy_mode,
2458 : : struct rte_mtr_error *error);
2459 : : typedef int (*mlx5_flow_create_mtr_acts_t)
2460 : : (struct rte_eth_dev *dev,
2461 : : struct mlx5_flow_meter_policy *mtr_policy,
2462 : : const struct rte_flow_action *actions[RTE_COLORS],
2463 : : struct rte_flow_attr *attr,
2464 : : struct rte_mtr_error *error);
2465 : : typedef void (*mlx5_flow_destroy_mtr_acts_t)
2466 : : (struct rte_eth_dev *dev,
2467 : : struct mlx5_flow_meter_policy *mtr_policy);
2468 : : typedef int (*mlx5_flow_create_policy_rules_t)
2469 : : (struct rte_eth_dev *dev,
2470 : : struct mlx5_flow_meter_policy *mtr_policy);
2471 : : typedef void (*mlx5_flow_destroy_policy_rules_t)
2472 : : (struct rte_eth_dev *dev,
2473 : : struct mlx5_flow_meter_policy *mtr_policy);
2474 : : typedef int (*mlx5_flow_create_def_policy_t)
2475 : : (struct rte_eth_dev *dev);
2476 : : typedef void (*mlx5_flow_destroy_def_policy_t)
2477 : : (struct rte_eth_dev *dev);
2478 : : typedef int (*mlx5_flow_discover_priorities_t)
2479 : : (struct rte_eth_dev *dev,
2480 : : const uint16_t *vprio, int vprio_n);
2481 : : typedef struct rte_flow_item_flex_handle *(*mlx5_flow_item_create_t)
2482 : : (struct rte_eth_dev *dev,
2483 : : const struct rte_flow_item_flex_conf *conf,
2484 : : struct rte_flow_error *error);
2485 : : typedef int (*mlx5_flow_item_release_t)
2486 : : (struct rte_eth_dev *dev,
2487 : : const struct rte_flow_item_flex_handle *handle,
2488 : : struct rte_flow_error *error);
2489 : : typedef int (*mlx5_flow_item_update_t)
2490 : : (struct rte_eth_dev *dev,
2491 : : const struct rte_flow_item_flex_handle *handle,
2492 : : const struct rte_flow_item_flex_conf *conf,
2493 : : struct rte_flow_error *error);
2494 : : typedef int (*mlx5_flow_info_get_t)
2495 : : (struct rte_eth_dev *dev,
2496 : : struct rte_flow_port_info *port_info,
2497 : : struct rte_flow_queue_info *queue_info,
2498 : : struct rte_flow_error *error);
2499 : : typedef int (*mlx5_flow_port_configure_t)
2500 : : (struct rte_eth_dev *dev,
2501 : : const struct rte_flow_port_attr *port_attr,
2502 : : uint16_t nb_queue,
2503 : : const struct rte_flow_queue_attr *queue_attr[],
2504 : : struct rte_flow_error *err);
2505 : : typedef int (*mlx5_flow_pattern_validate_t)
2506 : : (struct rte_eth_dev *dev,
2507 : : const struct rte_flow_pattern_template_attr *attr,
2508 : : const struct rte_flow_item items[],
2509 : : uint64_t *item_flags,
2510 : : struct rte_flow_error *error);
2511 : : typedef struct rte_flow_pattern_template *(*mlx5_flow_pattern_template_create_t)
2512 : : (struct rte_eth_dev *dev,
2513 : : const struct rte_flow_pattern_template_attr *attr,
2514 : : const struct rte_flow_item items[],
2515 : : struct rte_flow_error *error);
2516 : : typedef int (*mlx5_flow_pattern_template_destroy_t)
2517 : : (struct rte_eth_dev *dev,
2518 : : struct rte_flow_pattern_template *template,
2519 : : struct rte_flow_error *error);
2520 : : typedef int (*mlx5_flow_actions_validate_t)
2521 : : (struct rte_eth_dev *dev,
2522 : : const struct rte_flow_actions_template_attr *attr,
2523 : : const struct rte_flow_action actions[],
2524 : : const struct rte_flow_action masks[],
2525 : : struct rte_flow_error *error);
2526 : : typedef struct rte_flow_actions_template *(*mlx5_flow_actions_template_create_t)
2527 : : (struct rte_eth_dev *dev,
2528 : : const struct rte_flow_actions_template_attr *attr,
2529 : : const struct rte_flow_action actions[],
2530 : : const struct rte_flow_action masks[],
2531 : : struct rte_flow_error *error);
2532 : : typedef int (*mlx5_flow_actions_template_destroy_t)
2533 : : (struct rte_eth_dev *dev,
2534 : : struct rte_flow_actions_template *template,
2535 : : struct rte_flow_error *error);
2536 : : typedef struct rte_flow_template_table *(*mlx5_flow_table_create_t)
2537 : : (struct rte_eth_dev *dev,
2538 : : const struct rte_flow_template_table_attr *attr,
2539 : : struct rte_flow_pattern_template *item_templates[],
2540 : : uint8_t nb_item_templates,
2541 : : struct rte_flow_actions_template *action_templates[],
2542 : : uint8_t nb_action_templates,
2543 : : struct rte_flow_error *error);
2544 : : typedef int (*mlx5_flow_table_destroy_t)
2545 : : (struct rte_eth_dev *dev,
2546 : : struct rte_flow_template_table *table,
2547 : : struct rte_flow_error *error);
2548 : : typedef int (*mlx5_flow_group_set_miss_actions_t)
2549 : : (struct rte_eth_dev *dev,
2550 : : uint32_t group_id,
2551 : : const struct rte_flow_group_attr *attr,
2552 : : const struct rte_flow_action actions[],
2553 : : struct rte_flow_error *error);
2554 : : typedef struct rte_flow *(*mlx5_flow_async_flow_create_t)
2555 : : (struct rte_eth_dev *dev,
2556 : : uint32_t queue,
2557 : : const struct rte_flow_op_attr *attr,
2558 : : struct rte_flow_template_table *table,
2559 : : const struct rte_flow_item items[],
2560 : : uint8_t pattern_template_index,
2561 : : const struct rte_flow_action actions[],
2562 : : uint8_t action_template_index,
2563 : : void *user_data,
2564 : : struct rte_flow_error *error);
2565 : : typedef struct rte_flow *(*mlx5_flow_async_flow_create_by_index_t)
2566 : : (struct rte_eth_dev *dev,
2567 : : uint32_t queue,
2568 : : const struct rte_flow_op_attr *attr,
2569 : : struct rte_flow_template_table *table,
2570 : : uint32_t rule_index,
2571 : : const struct rte_flow_action actions[],
2572 : : uint8_t action_template_index,
2573 : : void *user_data,
2574 : : struct rte_flow_error *error);
2575 : : typedef int (*mlx5_flow_async_flow_update_t)
2576 : : (struct rte_eth_dev *dev,
2577 : : uint32_t queue,
2578 : : const struct rte_flow_op_attr *attr,
2579 : : struct rte_flow *flow,
2580 : : const struct rte_flow_action actions[],
2581 : : uint8_t action_template_index,
2582 : : void *user_data,
2583 : : struct rte_flow_error *error);
2584 : : typedef int (*mlx5_flow_async_flow_destroy_t)
2585 : : (struct rte_eth_dev *dev,
2586 : : uint32_t queue,
2587 : : const struct rte_flow_op_attr *attr,
2588 : : struct rte_flow *flow,
2589 : : void *user_data,
2590 : : struct rte_flow_error *error);
2591 : : typedef int (*mlx5_flow_pull_t)
2592 : : (struct rte_eth_dev *dev,
2593 : : uint32_t queue,
2594 : : struct rte_flow_op_result res[],
2595 : : uint16_t n_res,
2596 : : struct rte_flow_error *error);
2597 : : typedef int (*mlx5_flow_push_t)
2598 : : (struct rte_eth_dev *dev,
2599 : : uint32_t queue,
2600 : : struct rte_flow_error *error);
2601 : :
2602 : : typedef struct rte_flow_action_handle *(*mlx5_flow_async_action_handle_create_t)
2603 : : (struct rte_eth_dev *dev,
2604 : : uint32_t queue,
2605 : : const struct rte_flow_op_attr *attr,
2606 : : const struct rte_flow_indir_action_conf *conf,
2607 : : const struct rte_flow_action *action,
2608 : : void *user_data,
2609 : : struct rte_flow_error *error);
2610 : :
2611 : : typedef int (*mlx5_flow_async_action_handle_update_t)
2612 : : (struct rte_eth_dev *dev,
2613 : : uint32_t queue,
2614 : : const struct rte_flow_op_attr *attr,
2615 : : struct rte_flow_action_handle *handle,
2616 : : const void *update,
2617 : : void *user_data,
2618 : : struct rte_flow_error *error);
2619 : : typedef int (*mlx5_flow_async_action_handle_query_update_t)
2620 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2621 : : const struct rte_flow_op_attr *op_attr,
2622 : : struct rte_flow_action_handle *action_handle,
2623 : : const void *update, void *data,
2624 : : enum rte_flow_query_update_mode qu_mode,
2625 : : void *user_data, struct rte_flow_error *error);
2626 : : typedef int (*mlx5_flow_async_action_handle_query_t)
2627 : : (struct rte_eth_dev *dev,
2628 : : uint32_t queue,
2629 : : const struct rte_flow_op_attr *attr,
2630 : : const struct rte_flow_action_handle *handle,
2631 : : void *data,
2632 : : void *user_data,
2633 : : struct rte_flow_error *error);
2634 : :
2635 : : typedef int (*mlx5_flow_async_action_handle_destroy_t)
2636 : : (struct rte_eth_dev *dev,
2637 : : uint32_t queue,
2638 : : const struct rte_flow_op_attr *attr,
2639 : : struct rte_flow_action_handle *handle,
2640 : : void *user_data,
2641 : : struct rte_flow_error *error);
2642 : : typedef struct rte_flow_action_list_handle *
2643 : : (*mlx5_flow_async_action_list_handle_create_t)
2644 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2645 : : const struct rte_flow_op_attr *attr,
2646 : : const struct rte_flow_indir_action_conf *conf,
2647 : : const struct rte_flow_action *actions,
2648 : : void *user_data, struct rte_flow_error *error);
2649 : : typedef int
2650 : : (*mlx5_flow_async_action_list_handle_destroy_t)
2651 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2652 : : const struct rte_flow_op_attr *op_attr,
2653 : : struct rte_flow_action_list_handle *action_handle,
2654 : : void *user_data, struct rte_flow_error *error);
2655 : : typedef int
2656 : : (*mlx5_flow_action_list_handle_query_update_t)
2657 : : (struct rte_eth_dev *dev,
2658 : : const struct rte_flow_action_list_handle *handle,
2659 : : const void **update, void **query,
2660 : : enum rte_flow_query_update_mode mode,
2661 : : struct rte_flow_error *error);
2662 : : typedef int
2663 : : (*mlx5_flow_async_action_list_handle_query_update_t)
2664 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2665 : : const struct rte_flow_op_attr *attr,
2666 : : const struct rte_flow_action_list_handle *handle,
2667 : : const void **update, void **query,
2668 : : enum rte_flow_query_update_mode mode,
2669 : : void *user_data, struct rte_flow_error *error);
2670 : : typedef int
2671 : : (*mlx5_flow_calc_table_hash_t)
2672 : : (struct rte_eth_dev *dev,
2673 : : const struct rte_flow_template_table *table,
2674 : : const struct rte_flow_item pattern[],
2675 : : uint8_t pattern_template_index,
2676 : : uint32_t *hash, struct rte_flow_error *error);
2677 : : typedef int
2678 : : (*mlx5_flow_calc_encap_hash_t)
2679 : : (struct rte_eth_dev *dev,
2680 : : const struct rte_flow_item pattern[],
2681 : : enum rte_flow_encap_hash_field dest_field,
2682 : : uint8_t *hash,
2683 : : struct rte_flow_error *error);
2684 : : typedef int (*mlx5_table_resize_t)(struct rte_eth_dev *dev,
2685 : : struct rte_flow_template_table *table,
2686 : : uint32_t nb_rules, struct rte_flow_error *error);
2687 : : typedef int (*mlx5_flow_update_resized_t)
2688 : : (struct rte_eth_dev *dev, uint32_t queue,
2689 : : const struct rte_flow_op_attr *attr,
2690 : : struct rte_flow *rule, void *user_data,
2691 : : struct rte_flow_error *error);
2692 : : typedef int (*table_resize_complete_t)(struct rte_eth_dev *dev,
2693 : : struct rte_flow_template_table *table,
2694 : : struct rte_flow_error *error);
2695 : :
2696 : : struct mlx5_flow_driver_ops {
2697 : : mlx5_flow_list_create_t list_create;
2698 : : mlx5_flow_list_destroy_t list_destroy;
2699 : : mlx5_flow_validate_t validate;
2700 : : mlx5_flow_prepare_t prepare;
2701 : : mlx5_flow_translate_t translate;
2702 : : mlx5_flow_apply_t apply;
2703 : : mlx5_flow_remove_t remove;
2704 : : mlx5_flow_destroy_t destroy;
2705 : : mlx5_flow_query_t query;
2706 : : mlx5_flow_create_mtr_tbls_t create_mtr_tbls;
2707 : : mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;
2708 : : mlx5_flow_destroy_mtr_drop_tbls_t destroy_mtr_drop_tbls;
2709 : : mlx5_flow_mtr_alloc_t create_meter;
2710 : : mlx5_flow_mtr_free_t free_meter;
2711 : : mlx5_flow_validate_mtr_acts_t validate_mtr_acts;
2712 : : mlx5_flow_create_mtr_acts_t create_mtr_acts;
2713 : : mlx5_flow_destroy_mtr_acts_t destroy_mtr_acts;
2714 : : mlx5_flow_create_policy_rules_t create_policy_rules;
2715 : : mlx5_flow_destroy_policy_rules_t destroy_policy_rules;
2716 : : mlx5_flow_create_def_policy_t create_def_policy;
2717 : : mlx5_flow_destroy_def_policy_t destroy_def_policy;
2718 : : mlx5_flow_meter_sub_policy_rss_prepare_t meter_sub_policy_rss_prepare;
2719 : : mlx5_flow_meter_hierarchy_rule_create_t meter_hierarchy_rule_create;
2720 : : mlx5_flow_destroy_sub_policy_with_rxq_t destroy_sub_policy_with_rxq;
2721 : : mlx5_flow_counter_alloc_t counter_alloc;
2722 : : mlx5_flow_counter_free_t counter_free;
2723 : : mlx5_flow_counter_query_t counter_query;
2724 : : mlx5_flow_get_aged_flows_t get_aged_flows;
2725 : : mlx5_flow_get_q_aged_flows_t get_q_aged_flows;
2726 : : mlx5_flow_action_validate_t action_validate;
2727 : : mlx5_flow_action_create_t action_create;
2728 : : mlx5_flow_action_destroy_t action_destroy;
2729 : : mlx5_flow_action_update_t action_update;
2730 : : mlx5_flow_action_query_t action_query;
2731 : : mlx5_flow_action_query_update_t action_query_update;
2732 : : mlx5_flow_action_list_handle_create_t action_list_handle_create;
2733 : : mlx5_flow_action_list_handle_destroy_t action_list_handle_destroy;
2734 : : mlx5_flow_sync_domain_t sync_domain;
2735 : : mlx5_flow_discover_priorities_t discover_priorities;
2736 : : mlx5_flow_item_create_t item_create;
2737 : : mlx5_flow_item_release_t item_release;
2738 : : mlx5_flow_item_update_t item_update;
2739 : : mlx5_flow_info_get_t info_get;
2740 : : mlx5_flow_port_configure_t configure;
2741 : : mlx5_flow_pattern_validate_t pattern_validate;
2742 : : mlx5_flow_pattern_template_create_t pattern_template_create;
2743 : : mlx5_flow_pattern_template_destroy_t pattern_template_destroy;
2744 : : mlx5_flow_actions_validate_t actions_validate;
2745 : : mlx5_flow_actions_template_create_t actions_template_create;
2746 : : mlx5_flow_actions_template_destroy_t actions_template_destroy;
2747 : : mlx5_flow_table_create_t template_table_create;
2748 : : mlx5_flow_table_destroy_t template_table_destroy;
2749 : : mlx5_flow_group_set_miss_actions_t group_set_miss_actions;
2750 : : mlx5_flow_async_flow_create_t async_flow_create;
2751 : : mlx5_flow_async_flow_create_by_index_t async_flow_create_by_index;
2752 : : mlx5_flow_async_flow_update_t async_flow_update;
2753 : : mlx5_flow_async_flow_destroy_t async_flow_destroy;
2754 : : mlx5_flow_pull_t pull;
2755 : : mlx5_flow_push_t push;
2756 : : mlx5_flow_async_action_handle_create_t async_action_create;
2757 : : mlx5_flow_async_action_handle_update_t async_action_update;
2758 : : mlx5_flow_async_action_handle_query_update_t async_action_query_update;
2759 : : mlx5_flow_async_action_handle_query_t async_action_query;
2760 : : mlx5_flow_async_action_handle_destroy_t async_action_destroy;
2761 : : mlx5_flow_async_action_list_handle_create_t
2762 : : async_action_list_handle_create;
2763 : : mlx5_flow_async_action_list_handle_destroy_t
2764 : : async_action_list_handle_destroy;
2765 : : mlx5_flow_action_list_handle_query_update_t
2766 : : action_list_handle_query_update;
2767 : : mlx5_flow_async_action_list_handle_query_update_t
2768 : : async_action_list_handle_query_update;
2769 : : mlx5_flow_calc_table_hash_t flow_calc_table_hash;
2770 : : mlx5_flow_calc_encap_hash_t flow_calc_encap_hash;
2771 : : mlx5_table_resize_t table_resize;
2772 : : mlx5_flow_update_resized_t flow_update_resized;
2773 : : table_resize_complete_t table_resize_complete;
2774 : : };
2775 : :
2776 : : /* mlx5_flow.c */
2777 : :
2778 : : struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace(void);
2779 : : void mlx5_flow_pop_thread_workspace(void);
2780 : : struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace(void);
2781 : :
2782 : : __extension__
2783 : : struct flow_grp_info {
2784 : : uint64_t external:1;
2785 : : uint64_t transfer:1;
2786 : : uint64_t fdb_def_rule:1;
2787 : : /* force standard group translation */
2788 : : uint64_t std_tbl_fix:1;
2789 : : uint64_t skip_scale:2;
2790 : : };
2791 : :
2792 : : static inline bool
2793 : : tunnel_use_standard_attr_group_translate
2794 : : (const struct rte_eth_dev *dev,
2795 : : const struct rte_flow_attr *attr,
2796 : : const struct mlx5_flow_tunnel *tunnel,
2797 : : enum mlx5_tof_rule_type tof_rule_type)
2798 : : {
2799 : : bool verdict;
2800 : :
2801 [ # # # # ]: 0 : if (!is_tunnel_offload_active(dev))
2802 : : /* no tunnel offload API */
2803 : : verdict = true;
2804 [ # # ]: 0 : else if (tunnel) {
2805 : : /*
2806 : : * OvS will use jump to group 0 in tunnel steer rule.
2807 : : * If tunnel steer rule starts from group 0 (attr.group == 0)
2808 : : * that 0 group must be translated with standard method.
2809 : : * attr.group == 0 in tunnel match rule translated with tunnel
2810 : : * method
2811 : : */
2812 [ # # # # : 0 : verdict = !attr->group &&
# # # # ]
2813 : : is_flow_tunnel_steer_rule(tof_rule_type);
2814 : : } else {
2815 : : /*
2816 : : * non-tunnel group translation uses standard method for
2817 : : * root group only: attr.group == 0
2818 : : */
2819 : 0 : verdict = !attr->group;
2820 : : }
2821 : :
2822 : : return verdict;
2823 : : }
2824 : :
2825 : : /**
2826 : : * Get DV flow aso meter by index.
2827 : : *
2828 : : * @param[in] dev
2829 : : * Pointer to the Ethernet device structure.
2830 : : * @param[in] idx
2831 : : * mlx5 flow aso meter index in the container.
2832 : : * @param[out] ppool
2833 : : * mlx5 flow aso meter pool in the container,
2834 : : *
2835 : : * @return
2836 : : * Pointer to the aso meter, NULL otherwise.
2837 : : */
2838 : : static inline struct mlx5_aso_mtr *
2839 : 0 : mlx5_aso_meter_by_idx(struct mlx5_priv *priv, uint32_t idx)
2840 : : {
2841 : : struct mlx5_aso_mtr_pool *pool;
2842 : : struct mlx5_aso_mtr_pools_mng *pools_mng =
2843 : 0 : &priv->sh->mtrmng->pools_mng;
2844 : :
2845 [ # # ]: 0 : if (priv->mtr_bulk.aso)
2846 : 0 : return priv->mtr_bulk.aso + idx;
2847 : : /* Decrease to original index. */
2848 : 0 : idx--;
2849 : : MLX5_ASSERT(idx / MLX5_ASO_MTRS_PER_POOL < pools_mng->n);
2850 : 0 : rte_rwlock_read_lock(&pools_mng->resize_mtrwl);
2851 : 0 : pool = pools_mng->pools[idx / MLX5_ASO_MTRS_PER_POOL];
2852 : : rte_rwlock_read_unlock(&pools_mng->resize_mtrwl);
2853 : 0 : return &pool->mtrs[idx % MLX5_ASO_MTRS_PER_POOL];
2854 : : }
2855 : :
2856 : : static __rte_always_inline const struct rte_flow_item *
2857 : : mlx5_find_end_item(const struct rte_flow_item *item)
2858 : : {
2859 : : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++);
2860 : : return item;
2861 : : }
2862 : :
2863 : : static __rte_always_inline bool
2864 : : mlx5_validate_integrity_item(const struct rte_flow_item_integrity *item)
2865 : : {
2866 : 0 : struct rte_flow_item_integrity test = *item;
2867 : 0 : test.l3_ok = 0;
2868 : 0 : test.l4_ok = 0;
2869 : 0 : test.ipv4_csum_ok = 0;
2870 : 0 : test.l4_csum_ok = 0;
2871 [ # # ]: 0 : return (test.value == 0);
2872 : : }
2873 : :
2874 : : /*
2875 : : * Get ASO CT action by device and index.
2876 : : *
2877 : : * @param[in] dev
2878 : : * Pointer to the Ethernet device structure.
2879 : : * @param[in] idx
2880 : : * Index to the ASO CT action.
2881 : : *
2882 : : * @return
2883 : : * The specified ASO CT action pointer.
2884 : : */
2885 : : static inline struct mlx5_aso_ct_action *
2886 : 0 : flow_aso_ct_get_by_dev_idx(struct rte_eth_dev *dev, uint32_t idx)
2887 : : {
2888 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
2889 : 0 : struct mlx5_aso_ct_pools_mng *mng = priv->sh->ct_mng;
2890 : : struct mlx5_aso_ct_pool *pool;
2891 : :
2892 : 0 : idx--;
2893 : : MLX5_ASSERT((idx / MLX5_ASO_CT_ACTIONS_PER_POOL) < mng->n);
2894 : : /* Bit operation AND could be used. */
2895 : 0 : rte_rwlock_read_lock(&mng->resize_rwl);
2896 : 0 : pool = mng->pools[idx / MLX5_ASO_CT_ACTIONS_PER_POOL];
2897 : : rte_rwlock_read_unlock(&mng->resize_rwl);
2898 : 0 : return &pool->actions[idx % MLX5_ASO_CT_ACTIONS_PER_POOL];
2899 : : }
2900 : :
2901 : : /*
2902 : : * Get ASO CT action by owner & index.
2903 : : *
2904 : : * @param[in] dev
2905 : : * Pointer to the Ethernet device structure.
2906 : : * @param[in] idx
2907 : : * Index to the ASO CT action and owner port combination.
2908 : : *
2909 : : * @return
2910 : : * The specified ASO CT action pointer.
2911 : : */
2912 : : static inline struct mlx5_aso_ct_action *
2913 : 0 : flow_aso_ct_get_by_idx(struct rte_eth_dev *dev, uint32_t own_idx)
2914 : : {
2915 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
2916 : : struct mlx5_aso_ct_action *ct;
2917 : 0 : uint16_t owner = (uint16_t)MLX5_INDIRECT_ACT_CT_GET_OWNER(own_idx);
2918 : 0 : uint32_t idx = MLX5_INDIRECT_ACT_CT_GET_IDX(own_idx);
2919 : :
2920 [ # # ]: 0 : if (owner == PORT_ID(priv)) {
2921 : 0 : ct = flow_aso_ct_get_by_dev_idx(dev, idx);
2922 : : } else {
2923 : 0 : struct rte_eth_dev *owndev = &rte_eth_devices[owner];
2924 : :
2925 : : MLX5_ASSERT(owner < RTE_MAX_ETHPORTS);
2926 [ # # ]: 0 : if (dev->data->dev_started != 1)
2927 : : return NULL;
2928 : 0 : ct = flow_aso_ct_get_by_dev_idx(owndev, idx);
2929 [ # # ]: 0 : if (ct->peer != PORT_ID(priv))
2930 : 0 : return NULL;
2931 : : }
2932 : : return ct;
2933 : : }
2934 : :
2935 : : static inline uint16_t
2936 : : mlx5_translate_tunnel_etypes(uint64_t pattern_flags)
2937 : : {
2938 [ # # # # : 0 : if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
# # ]
2939 : : return RTE_ETHER_TYPE_TEB;
2940 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4)
# # ]
2941 : : return RTE_ETHER_TYPE_IPV4;
2942 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6)
# # ]
2943 : : return RTE_ETHER_TYPE_IPV6;
2944 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_MPLS)
# # ]
2945 : 0 : return RTE_ETHER_TYPE_MPLS;
2946 : : return 0;
2947 : : }
2948 : :
2949 : : int mlx5_flow_hw_q_flow_flush(struct rte_eth_dev *dev,
2950 : : struct rte_flow_error *error);
2951 : :
2952 : : /*
2953 : : * Convert rte_mtr_color to mlx5 color.
2954 : : *
2955 : : * @param[in] rcol
2956 : : * rte_mtr_color.
2957 : : *
2958 : : * @return
2959 : : * mlx5 color.
2960 : : */
2961 : : static inline int
2962 : : rte_col_2_mlx5_col(enum rte_color rcol)
2963 : : {
2964 : : switch (rcol) {
2965 : : case RTE_COLOR_GREEN:
2966 : : return MLX5_FLOW_COLOR_GREEN;
2967 : : case RTE_COLOR_YELLOW:
2968 : : return MLX5_FLOW_COLOR_YELLOW;
2969 : : case RTE_COLOR_RED:
2970 : : return MLX5_FLOW_COLOR_RED;
2971 : : default:
2972 : : break;
2973 : : }
2974 : : return MLX5_FLOW_COLOR_UNDEFINED;
2975 : : }
2976 : :
2977 : : /**
2978 : : * Indicates whether flow source vport is representor port.
2979 : : *
2980 : : * @param[in] priv
2981 : : * Pointer to device private context structure.
2982 : : * @param[in] act_priv
2983 : : * Pointer to actual device private context structure if have.
2984 : : *
2985 : : * @return
2986 : : * True when the flow source vport is representor port, false otherwise.
2987 : : */
2988 : : static inline bool
2989 : : flow_source_vport_representor(struct mlx5_priv *priv, struct mlx5_priv *act_priv)
2990 : : {
2991 : : MLX5_ASSERT(priv);
2992 [ # # # # : 0 : return (!act_priv ? (priv->representor_id != UINT16_MAX) :
# # # # #
# ]
2993 : 0 : (act_priv->representor_id != UINT16_MAX));
2994 : : }
2995 : :
2996 : : /* All types of Ethernet patterns used in control flow rules. */
2997 : : enum mlx5_flow_ctrl_rx_eth_pattern_type {
2998 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL = 0,
2999 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL_MCAST,
3000 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_BCAST,
3001 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_BCAST_VLAN,
3002 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV4_MCAST,
3003 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV4_MCAST_VLAN,
3004 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV6_MCAST,
3005 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV6_MCAST_VLAN,
3006 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_DMAC,
3007 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_DMAC_VLAN,
3008 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_MAX,
3009 : : };
3010 : :
3011 : : /* All types of RSS actions used in control flow rules. */
3012 : : enum mlx5_flow_ctrl_rx_expanded_rss_type {
3013 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6_UDP = 0,
3014 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6_TCP,
3015 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4_UDP,
3016 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4_TCP,
3017 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6,
3018 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4,
3019 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_NON_IP,
3020 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX,
3021 : : };
3022 : :
3023 : : /**
3024 : : * Contains pattern template, template table and its attributes for a single
3025 : : * combination of Ethernet pattern and RSS action. Used to create control flow rules
3026 : : * with HWS.
3027 : : */
3028 : : struct mlx5_flow_hw_ctrl_rx_table {
3029 : : struct rte_flow_template_table_attr attr;
3030 : : struct rte_flow_pattern_template *pt;
3031 : : struct rte_flow_template_table *tbl;
3032 : : };
3033 : :
3034 : : /* Contains all templates required to create control flow rules with HWS. */
3035 : : struct mlx5_flow_hw_ctrl_rx {
3036 : : struct rte_flow_actions_template *rss[MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX];
3037 : : struct mlx5_flow_hw_ctrl_rx_table tables[MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_MAX]
3038 : : [MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX];
3039 : : };
3040 : :
3041 : : /* Contains all templates and table required for redirecting LACP traffic with HWS. */
3042 : : struct mlx5_flow_hw_lacp_miss {
3043 : : struct rte_flow_pattern_template *lacp_rx_items_tmpl;
3044 : : struct rte_flow_actions_template *lacp_rx_actions_tmpl;
3045 : : struct rte_flow_template_table *hw_lacp_rx_tbl;
3046 : : };
3047 : :
3048 : : /* Contains all templates required for control flow rules in FDB with HWS. */
3049 : : struct mlx5_flow_hw_ctrl_fdb {
3050 : : struct rte_flow_pattern_template *esw_mgr_items_tmpl;
3051 : : struct rte_flow_actions_template *regc_jump_actions_tmpl;
3052 : : struct rte_flow_template_table *hw_esw_sq_miss_root_tbl;
3053 : : struct rte_flow_pattern_template *regc_sq_items_tmpl;
3054 : : struct rte_flow_actions_template *port_actions_tmpl;
3055 : : struct rte_flow_template_table *hw_esw_sq_miss_tbl;
3056 : : struct rte_flow_pattern_template *port_items_tmpl;
3057 : : struct rte_flow_actions_template *jump_one_actions_tmpl;
3058 : : struct rte_flow_template_table *hw_esw_zero_tbl;
3059 : : };
3060 : :
3061 : : struct mlx5_flow_hw_ctrl_nic {
3062 : : struct rte_flow_pattern_template *tx_meta_items_tmpl;
3063 : : struct rte_flow_actions_template *tx_meta_actions_tmpl;
3064 : : struct rte_flow_template_table *hw_tx_meta_cpy_tbl;
3065 : : };
3066 : :
3067 : : #define MLX5_CTRL_PROMISCUOUS (RTE_BIT32(0))
3068 : : #define MLX5_CTRL_ALL_MULTICAST (RTE_BIT32(1))
3069 : : #define MLX5_CTRL_BROADCAST (RTE_BIT32(2))
3070 : : #define MLX5_CTRL_IPV4_MULTICAST (RTE_BIT32(3))
3071 : : #define MLX5_CTRL_IPV6_MULTICAST (RTE_BIT32(4))
3072 : : #define MLX5_CTRL_DMAC (RTE_BIT32(5))
3073 : : #define MLX5_CTRL_VLAN_FILTER (RTE_BIT32(6))
3074 : :
3075 : : int mlx5_flow_hw_ctrl_flows(struct rte_eth_dev *dev, uint32_t flags);
3076 : : int mlx5_flow_hw_create_ctrl_rx_tables(struct rte_eth_dev *dev);
3077 : : void mlx5_flow_hw_cleanup_ctrl_rx_tables(struct rte_eth_dev *dev);
3078 : :
3079 : : /** Create a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */
3080 : : int mlx5_legacy_dmac_flow_create(struct rte_eth_dev *dev, const struct rte_ether_addr *addr);
3081 : :
3082 : : /** Destroy a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */
3083 : : int mlx5_legacy_dmac_flow_destroy(struct rte_eth_dev *dev, const struct rte_ether_addr *addr);
3084 : :
3085 : : /** Create a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */
3086 : : int mlx5_legacy_dmac_vlan_flow_create(struct rte_eth_dev *dev,
3087 : : const struct rte_ether_addr *addr,
3088 : : const uint16_t vid);
3089 : :
3090 : : /** Destroy a control flow rule for matching unicast DMAC with VLAN (Verbs and DV). */
3091 : : int mlx5_legacy_dmac_vlan_flow_destroy(struct rte_eth_dev *dev,
3092 : : const struct rte_ether_addr *addr,
3093 : : const uint16_t vid);
3094 : :
3095 : : /** Destroy a control flow rule registered on port level control flow rule type. */
3096 : : void mlx5_legacy_ctrl_flow_destroy(struct rte_eth_dev *dev, struct mlx5_ctrl_flow_entry *entry);
3097 : :
3098 : : /** Create a control flow rule for matching unicast DMAC (HWS). */
3099 : : int mlx5_flow_hw_ctrl_flow_dmac(struct rte_eth_dev *dev, const struct rte_ether_addr *addr);
3100 : :
3101 : : /** Destroy a control flow rule for matching unicast DMAC (HWS). */
3102 : : int mlx5_flow_hw_ctrl_flow_dmac_destroy(struct rte_eth_dev *dev, const struct rte_ether_addr *addr);
3103 : :
3104 : : /** Create a control flow rule for matching unicast DMAC with VLAN (HWS). */
3105 : : int mlx5_flow_hw_ctrl_flow_dmac_vlan(struct rte_eth_dev *dev,
3106 : : const struct rte_ether_addr *addr,
3107 : : const uint16_t vlan);
3108 : :
3109 : : /** Destroy a control flow rule for matching unicast DMAC with VLAN (HWS). */
3110 : : int mlx5_flow_hw_ctrl_flow_dmac_vlan_destroy(struct rte_eth_dev *dev,
3111 : : const struct rte_ether_addr *addr,
3112 : : const uint16_t vlan);
3113 : :
3114 : : void mlx5_flow_hw_cleanup_ctrl_rx_templates(struct rte_eth_dev *dev);
3115 : :
3116 : : int mlx5_flow_group_to_table(struct rte_eth_dev *dev,
3117 : : const struct mlx5_flow_tunnel *tunnel,
3118 : : uint32_t group, uint32_t *table,
3119 : : const struct flow_grp_info *flags,
3120 : : struct rte_flow_error *error);
3121 : : uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
3122 : : int tunnel, uint64_t layer_types,
3123 : : uint64_t hash_fields);
3124 : : int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
3125 : : uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
3126 : : uint32_t subpriority);
3127 : : uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev,
3128 : : const struct rte_flow_attr *attr);
3129 : : uint16_t mlx5_get_matcher_priority(struct rte_eth_dev *dev,
3130 : : const struct rte_flow_attr *attr,
3131 : : uint32_t subpriority, bool external);
3132 : : uint32_t mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev);
3133 : : int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
3134 : : enum mlx5_feature_name feature,
3135 : : uint32_t id,
3136 : : struct rte_flow_error *error);
3137 : : const struct rte_flow_action *mlx5_flow_find_action
3138 : : (const struct rte_flow_action *actions,
3139 : : enum rte_flow_action_type action);
3140 : : int mlx5_validate_action_rss(struct rte_eth_dev *dev,
3141 : : const struct rte_flow_action *action,
3142 : : struct rte_flow_error *error);
3143 : :
3144 : : struct mlx5_hw_encap_decap_action*
3145 : : mlx5_reformat_action_create(struct rte_eth_dev *dev,
3146 : : const struct rte_flow_indir_action_conf *conf,
3147 : : const struct rte_flow_action *encap_action,
3148 : : const struct rte_flow_action *decap_action,
3149 : : struct rte_flow_error *error);
3150 : : int mlx5_reformat_action_destroy(struct rte_eth_dev *dev,
3151 : : struct rte_flow_action_list_handle *handle,
3152 : : struct rte_flow_error *error);
3153 : : int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
3154 : : const struct rte_flow_attr *attr,
3155 : : struct rte_flow_error *error);
3156 : : int mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
3157 : : bool is_root,
3158 : : const struct rte_flow_attr *attr,
3159 : : struct rte_flow_error *error);
3160 : : int mlx5_flow_validate_action_flag(uint64_t action_flags,
3161 : : const struct rte_flow_attr *attr,
3162 : : struct rte_flow_error *error);
3163 : : int mlx5_flow_validate_action_mark(struct rte_eth_dev *dev,
3164 : : const struct rte_flow_action *action,
3165 : : uint64_t action_flags,
3166 : : const struct rte_flow_attr *attr,
3167 : : struct rte_flow_error *error);
3168 : : int mlx5_flow_validate_target_queue(struct rte_eth_dev *dev,
3169 : : const struct rte_flow_action *action,
3170 : : struct rte_flow_error *error);
3171 : : int mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
3172 : : uint64_t action_flags,
3173 : : struct rte_eth_dev *dev,
3174 : : const struct rte_flow_attr *attr,
3175 : : struct rte_flow_error *error);
3176 : : int mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
3177 : : uint64_t action_flags,
3178 : : struct rte_eth_dev *dev,
3179 : : const struct rte_flow_attr *attr,
3180 : : uint64_t item_flags,
3181 : : struct rte_flow_error *error);
3182 : : int mlx5_flow_validate_action_default_miss(uint64_t action_flags,
3183 : : const struct rte_flow_attr *attr,
3184 : : struct rte_flow_error *error);
3185 : : int mlx5_flow_validate_modify_field_level
3186 : : (const struct rte_flow_field_data *data,
3187 : : struct rte_flow_error *error);
3188 : : int
3189 : : mlx5_flow_dv_validate_action_l2_encap(struct rte_eth_dev *dev,
3190 : : uint64_t action_flags,
3191 : : const struct rte_flow_action *action,
3192 : : const struct rte_flow_attr *attr,
3193 : : struct rte_flow_error *error);
3194 : : int
3195 : : mlx5_flow_dv_validate_action_decap(struct rte_eth_dev *dev,
3196 : : uint64_t action_flags,
3197 : : const struct rte_flow_action *action,
3198 : : const uint64_t item_flags,
3199 : : const struct rte_flow_attr *attr,
3200 : : struct rte_flow_error *error);
3201 : : int
3202 : : mlx5_flow_dv_validate_action_aso_ct(struct rte_eth_dev *dev,
3203 : : uint64_t action_flags,
3204 : : uint64_t item_flags,
3205 : : bool root,
3206 : : struct rte_flow_error *error);
3207 : : int
3208 : : mlx5_flow_dv_validate_action_raw_encap_decap
3209 : : (struct rte_eth_dev *dev,
3210 : : const struct rte_flow_action_raw_decap *decap,
3211 : : const struct rte_flow_action_raw_encap *encap,
3212 : : const struct rte_flow_attr *attr, uint64_t *action_flags,
3213 : : int *actions_n, const struct rte_flow_action *action,
3214 : : uint64_t item_flags, struct rte_flow_error *error);
3215 : : int mlx5_flow_item_acceptable(const struct rte_eth_dev *dev,
3216 : : const struct rte_flow_item *item,
3217 : : const uint8_t *mask,
3218 : : const uint8_t *nic_mask,
3219 : : unsigned int size,
3220 : : bool range_accepted,
3221 : : struct rte_flow_error *error);
3222 : : int mlx5_flow_validate_item_eth(const struct rte_eth_dev *dev,
3223 : : const struct rte_flow_item *item,
3224 : : uint64_t item_flags, bool ext_vlan_sup,
3225 : : struct rte_flow_error *error);
3226 : : int
3227 : : mlx5_flow_dv_validate_item_vlan(const struct rte_flow_item *item,
3228 : : uint64_t item_flags,
3229 : : struct rte_eth_dev *dev,
3230 : : struct rte_flow_error *error);
3231 : : int
3232 : : mlx5_flow_dv_validate_item_ipv4(struct rte_eth_dev *dev,
3233 : : const struct rte_flow_item *item,
3234 : : uint64_t item_flags,
3235 : : uint64_t last_item,
3236 : : uint16_t ether_type,
3237 : : const struct rte_flow_item_ipv4 *acc_mask,
3238 : : struct rte_flow_error *error);
3239 : : int
3240 : : mlx5_flow_dv_validate_item_gtp(struct rte_eth_dev *dev,
3241 : : const struct rte_flow_item *item,
3242 : : uint64_t item_flags,
3243 : : struct rte_flow_error *error);
3244 : : int
3245 : : mlx5_flow_dv_validate_item_gtp_psc(const struct rte_eth_dev *dev,
3246 : : const struct rte_flow_item *item,
3247 : : uint64_t last_item,
3248 : : const struct rte_flow_item *gtp_item,
3249 : : bool root, struct rte_flow_error *error);
3250 : : int
3251 : : mlx5_flow_dv_validate_item_aso_ct(struct rte_eth_dev *dev,
3252 : : const struct rte_flow_item *item,
3253 : : uint64_t *item_flags,
3254 : : struct rte_flow_error *error);
3255 : : int mlx5_flow_validate_item_gre(const struct rte_eth_dev *dev,
3256 : : const struct rte_flow_item *item,
3257 : : uint64_t item_flags,
3258 : : uint8_t target_protocol,
3259 : : struct rte_flow_error *error);
3260 : : int mlx5_flow_validate_item_gre_key(const struct rte_eth_dev *dev,
3261 : : const struct rte_flow_item *item,
3262 : : uint64_t item_flags,
3263 : : const struct rte_flow_item *gre_item,
3264 : : struct rte_flow_error *error);
3265 : : int mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev,
3266 : : const struct rte_flow_item *item,
3267 : : uint64_t item_flags,
3268 : : const struct rte_flow_attr *attr,
3269 : : const struct rte_flow_item *gre_item,
3270 : : struct rte_flow_error *error);
3271 : : int mlx5_flow_validate_item_ipv4(const struct rte_eth_dev *dev,
3272 : : const struct rte_flow_item *item,
3273 : : uint64_t item_flags,
3274 : : uint64_t last_item,
3275 : : uint16_t ether_type,
3276 : : const struct rte_flow_item_ipv4 *acc_mask,
3277 : : bool range_accepted,
3278 : : struct rte_flow_error *error);
3279 : : int mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,
3280 : : const struct rte_flow_item *item,
3281 : : uint64_t item_flags,
3282 : : uint64_t last_item,
3283 : : uint16_t ether_type,
3284 : : const struct rte_flow_item_ipv6 *acc_mask,
3285 : : struct rte_flow_error *error);
3286 : : int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
3287 : : const struct rte_flow_item *item,
3288 : : uint64_t item_flags,
3289 : : uint64_t prev_layer,
3290 : : struct rte_flow_error *error);
3291 : : int mlx5_flow_validate_item_tcp(const struct rte_eth_dev *dev,
3292 : : const struct rte_flow_item *item,
3293 : : uint64_t item_flags,
3294 : : uint8_t target_protocol,
3295 : : const struct rte_flow_item_tcp *flow_mask,
3296 : : struct rte_flow_error *error);
3297 : : int mlx5_flow_validate_item_udp(const struct rte_eth_dev *dev,
3298 : : const struct rte_flow_item *item,
3299 : : uint64_t item_flags,
3300 : : uint8_t target_protocol,
3301 : : struct rte_flow_error *error);
3302 : : int mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,
3303 : : uint64_t item_flags,
3304 : : struct rte_eth_dev *dev,
3305 : : struct rte_flow_error *error);
3306 : : int mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,
3307 : : uint16_t udp_dport,
3308 : : const struct rte_flow_item *item,
3309 : : uint64_t item_flags,
3310 : : bool root,
3311 : : struct rte_flow_error *error);
3312 : : int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
3313 : : uint64_t item_flags,
3314 : : struct rte_eth_dev *dev,
3315 : : struct rte_flow_error *error);
3316 : : int mlx5_flow_validate_item_icmp(const struct rte_eth_dev *dev,
3317 : : const struct rte_flow_item *item,
3318 : : uint64_t item_flags,
3319 : : uint8_t target_protocol,
3320 : : struct rte_flow_error *error);
3321 : : int mlx5_flow_validate_item_icmp6(const struct rte_eth_dev *dev,
3322 : : const struct rte_flow_item *item,
3323 : : uint64_t item_flags,
3324 : : uint8_t target_protocol,
3325 : : struct rte_flow_error *error);
3326 : : int mlx5_flow_validate_item_icmp6_echo(const struct rte_eth_dev *dev,
3327 : : const struct rte_flow_item *item,
3328 : : uint64_t item_flags,
3329 : : uint8_t target_protocol,
3330 : : struct rte_flow_error *error);
3331 : : int mlx5_flow_validate_item_nvgre(const struct rte_eth_dev *dev,
3332 : : const struct rte_flow_item *item,
3333 : : uint64_t item_flags,
3334 : : uint8_t target_protocol,
3335 : : struct rte_flow_error *error);
3336 : : int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
3337 : : uint64_t item_flags,
3338 : : struct rte_eth_dev *dev,
3339 : : struct rte_flow_error *error);
3340 : : int mlx5_flow_validate_item_geneve_opt(const struct rte_flow_item *item,
3341 : : uint64_t last_item,
3342 : : const struct rte_flow_item *geneve_item,
3343 : : struct rte_eth_dev *dev,
3344 : : struct rte_flow_error *error);
3345 : : int mlx5_flow_validate_item_ecpri(const struct rte_eth_dev *dev,
3346 : : const struct rte_flow_item *item,
3347 : : uint64_t item_flags,
3348 : : uint64_t last_item,
3349 : : uint16_t ether_type,
3350 : : const struct rte_flow_item_ecpri *acc_mask,
3351 : : struct rte_flow_error *error);
3352 : : int mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev,
3353 : : const struct rte_flow_item *item,
3354 : : struct rte_flow_error *error);
3355 : : int mlx5_flow_create_mtr_tbls(struct rte_eth_dev *dev,
3356 : : struct mlx5_flow_meter_info *fm,
3357 : : uint32_t mtr_idx,
3358 : : uint8_t domain_bitmap);
3359 : : void mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,
3360 : : struct mlx5_flow_meter_info *fm);
3361 : : void mlx5_flow_destroy_mtr_drop_tbls(struct rte_eth_dev *dev);
3362 : : struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare
3363 : : (struct rte_eth_dev *dev,
3364 : : struct mlx5_flow_meter_policy *mtr_policy,
3365 : : struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]);
3366 : : void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev,
3367 : : struct mlx5_flow_meter_policy *mtr_policy);
3368 : : int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
3369 : : int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev);
3370 : : int mlx5_flow_discover_ipv6_tc_support(struct rte_eth_dev *dev);
3371 : : int mlx5_action_handle_attach(struct rte_eth_dev *dev);
3372 : : int mlx5_action_handle_detach(struct rte_eth_dev *dev);
3373 : : int mlx5_action_handle_flush(struct rte_eth_dev *dev);
3374 : : void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id);
3375 : : int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh);
3376 : :
3377 : : struct mlx5_list_entry *mlx5_flow_dv_tbl_create_cb(void *tool_ctx, void *entry_ctx);
3378 : : int mlx5_flow_dv_tbl_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3379 : : void *cb_ctx);
3380 : : void mlx5_flow_dv_tbl_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3381 : : struct mlx5_list_entry *mlx5_flow_dv_tbl_clone_cb(void *tool_ctx,
3382 : : struct mlx5_list_entry *oentry,
3383 : : void *entry_ctx);
3384 : : void mlx5_flow_dv_tbl_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3385 : : struct mlx5_flow_tbl_resource *mlx5_flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
3386 : : uint32_t table_level, uint8_t egress, uint8_t transfer,
3387 : : bool external, const struct mlx5_flow_tunnel *tunnel,
3388 : : uint32_t group_id, uint8_t dummy,
3389 : : uint32_t table_id, struct rte_flow_error *error);
3390 : : int mlx5_flow_dv_tbl_resource_release(struct mlx5_dev_ctx_shared *sh,
3391 : : struct mlx5_flow_tbl_resource *tbl);
3392 : :
3393 : : struct mlx5_list_entry *mlx5_flow_dv_tag_create_cb(void *tool_ctx, void *cb_ctx);
3394 : : int mlx5_flow_dv_tag_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3395 : : void *cb_ctx);
3396 : : void mlx5_flow_dv_tag_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3397 : : struct mlx5_list_entry *mlx5_flow_dv_tag_clone_cb(void *tool_ctx,
3398 : : struct mlx5_list_entry *oentry,
3399 : : void *cb_ctx);
3400 : : void mlx5_flow_dv_tag_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3401 : :
3402 : : int mlx5_flow_modify_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3403 : : void *cb_ctx);
3404 : : struct mlx5_list_entry *mlx5_flow_modify_create_cb(void *tool_ctx, void *ctx);
3405 : : void mlx5_flow_modify_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3406 : : struct mlx5_list_entry *mlx5_flow_modify_clone_cb(void *tool_ctx,
3407 : : struct mlx5_list_entry *oentry,
3408 : : void *ctx);
3409 : : void mlx5_flow_modify_clone_free_cb(void *tool_ctx,
3410 : : struct mlx5_list_entry *entry);
3411 : :
3412 : : struct mlx5_list_entry *mlx5_flow_dv_mreg_create_cb(void *tool_ctx, void *ctx);
3413 : : int mlx5_flow_dv_mreg_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3414 : : void *cb_ctx);
3415 : : void mlx5_flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3416 : : struct mlx5_list_entry *mlx5_flow_dv_mreg_clone_cb(void *tool_ctx,
3417 : : struct mlx5_list_entry *entry,
3418 : : void *ctx);
3419 : : void mlx5_flow_dv_mreg_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3420 : :
3421 : : int mlx5_flow_encap_decap_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3422 : : void *cb_ctx);
3423 : : struct mlx5_list_entry *mlx5_flow_encap_decap_create_cb(void *tool_ctx,
3424 : : void *cb_ctx);
3425 : : void mlx5_flow_encap_decap_remove_cb(void *tool_ctx,
3426 : : struct mlx5_list_entry *entry);
3427 : : struct mlx5_list_entry *mlx5_flow_encap_decap_clone_cb(void *tool_ctx,
3428 : : struct mlx5_list_entry *entry,
3429 : : void *cb_ctx);
3430 : : void mlx5_flow_encap_decap_clone_free_cb(void *tool_ctx,
3431 : : struct mlx5_list_entry *entry);
3432 : : int mlx5_flow_encap_decap_resource_register
3433 : : (struct rte_eth_dev *dev,
3434 : : struct mlx5_flow_dv_encap_decap_resource *resource,
3435 : : bool is_root,
3436 : : struct mlx5_flow_dv_encap_decap_resource **encap_decap,
3437 : : struct rte_flow_error *error);
3438 : : int mlx5_flow_modify_hdr_resource_register
3439 : : (struct rte_eth_dev *dev,
3440 : : struct mlx5_flow_dv_modify_hdr_resource *resource,
3441 : : struct mlx5_flow_dv_modify_hdr_resource **modify,
3442 : : struct rte_flow_error *error);
3443 : : int mlx5_flow_encap_decap_resource_release(struct rte_eth_dev *dev,
3444 : : uint32_t encap_decap_idx);
3445 : : int mlx5_flow_matcher_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3446 : : void *ctx);
3447 : : struct mlx5_list_entry *mlx5_flow_matcher_create_cb(void *tool_ctx, void *ctx);
3448 : : void mlx5_flow_matcher_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3449 : : struct mlx5_list_entry *mlx5_flow_matcher_clone_cb(void *tool_ctx __rte_unused,
3450 : : struct mlx5_list_entry *entry, void *cb_ctx);
3451 : : void mlx5_flow_matcher_clone_free_cb(void *tool_ctx __rte_unused,
3452 : : struct mlx5_list_entry *entry);
3453 : : int mlx5_flow_dv_port_id_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3454 : : void *cb_ctx);
3455 : : struct mlx5_list_entry *mlx5_flow_dv_port_id_create_cb(void *tool_ctx, void *cb_ctx);
3456 : : void mlx5_flow_dv_port_id_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3457 : : struct mlx5_list_entry *mlx5_flow_dv_port_id_clone_cb(void *tool_ctx,
3458 : : struct mlx5_list_entry *entry, void *cb_ctx);
3459 : : void mlx5_flow_dv_port_id_clone_free_cb(void *tool_ctx,
3460 : : struct mlx5_list_entry *entry);
3461 : :
3462 : : int mlx5_flow_dv_push_vlan_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3463 : : void *cb_ctx);
3464 : : struct mlx5_list_entry *mlx5_flow_dv_push_vlan_create_cb(void *tool_ctx,
3465 : : void *cb_ctx);
3466 : : void mlx5_flow_dv_push_vlan_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3467 : : struct mlx5_list_entry *mlx5_flow_dv_push_vlan_clone_cb(void *tool_ctx,
3468 : : struct mlx5_list_entry *entry,
3469 : : void *cb_ctx);
3470 : : void mlx5_flow_dv_push_vlan_clone_free_cb(void *tool_ctx,
3471 : : struct mlx5_list_entry *entry);
3472 : :
3473 : : int mlx5_flow_dv_sample_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3474 : : void *cb_ctx);
3475 : : struct mlx5_list_entry *mlx5_flow_dv_sample_create_cb(void *tool_ctx, void *cb_ctx);
3476 : : void mlx5_flow_dv_sample_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3477 : : struct mlx5_list_entry *mlx5_flow_dv_sample_clone_cb(void *tool_ctx,
3478 : : struct mlx5_list_entry *entry, void *cb_ctx);
3479 : : void mlx5_flow_dv_sample_clone_free_cb(void *tool_ctx,
3480 : : struct mlx5_list_entry *entry);
3481 : :
3482 : : int mlx5_flow_dv_dest_array_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
3483 : : void *cb_ctx);
3484 : : struct mlx5_list_entry *mlx5_flow_dv_dest_array_create_cb(void *tool_ctx,
3485 : : void *cb_ctx);
3486 : : void mlx5_flow_dv_dest_array_remove_cb(void *tool_ctx,
3487 : : struct mlx5_list_entry *entry);
3488 : : struct mlx5_list_entry *mlx5_flow_dv_dest_array_clone_cb(void *tool_ctx,
3489 : : struct mlx5_list_entry *entry,
3490 : : void *cb_ctx);
3491 : : void mlx5_flow_dv_dest_array_clone_free_cb(void *tool_ctx,
3492 : : struct mlx5_list_entry *entry);
3493 : : void mlx5_flow_dv_hashfields_set(uint64_t item_flags,
3494 : : struct mlx5_flow_rss_desc *rss_desc,
3495 : : uint64_t *hash_fields);
3496 : : void mlx5_flow_dv_action_rss_l34_hash_adjust(uint64_t rss_types,
3497 : : uint64_t *hash_field);
3498 : : uint32_t mlx5_flow_dv_action_rss_hrxq_lookup(struct rte_eth_dev *dev, uint32_t idx,
3499 : : const uint64_t hash_fields);
3500 : : int mlx5_flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
3501 : : const struct rte_flow_item items[],
3502 : : const struct rte_flow_action actions[],
3503 : : bool external, int hairpin, struct rte_flow_error *error);
3504 : :
3505 : : struct mlx5_list_entry *mlx5_flow_hw_grp_create_cb(void *tool_ctx, void *cb_ctx);
3506 : : void mlx5_flow_hw_grp_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3507 : : int mlx5_flow_hw_grp_match_cb(void *tool_ctx,
3508 : : struct mlx5_list_entry *entry,
3509 : : void *cb_ctx);
3510 : : struct mlx5_list_entry *mlx5_flow_hw_grp_clone_cb(void *tool_ctx,
3511 : : struct mlx5_list_entry *oentry,
3512 : : void *cb_ctx);
3513 : : void mlx5_flow_hw_grp_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3514 : :
3515 : : struct mlx5_aso_age_action *mlx5_flow_aso_age_get_by_idx(struct rte_eth_dev *dev,
3516 : : uint32_t age_idx);
3517 : :
3518 : : void mlx5_flow_release_workspace(void *data);
3519 : : int mlx5_flow_os_init_workspace_once(void);
3520 : : void *mlx5_flow_os_get_specific_workspace(void);
3521 : : int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data);
3522 : : void mlx5_flow_os_release_workspace(void);
3523 : : uint32_t mlx5_flow_mtr_alloc(struct rte_eth_dev *dev);
3524 : : void mlx5_flow_mtr_free(struct rte_eth_dev *dev, uint32_t mtr_idx);
3525 : : int mlx5_flow_validate_mtr_acts(struct rte_eth_dev *dev,
3526 : : const struct rte_flow_action *actions[RTE_COLORS],
3527 : : struct rte_flow_attr *attr,
3528 : : bool *is_rss,
3529 : : uint8_t *domain_bitmap,
3530 : : uint8_t *policy_mode,
3531 : : struct rte_mtr_error *error);
3532 : : void mlx5_flow_destroy_mtr_acts(struct rte_eth_dev *dev,
3533 : : struct mlx5_flow_meter_policy *mtr_policy);
3534 : : int mlx5_flow_create_mtr_acts(struct rte_eth_dev *dev,
3535 : : struct mlx5_flow_meter_policy *mtr_policy,
3536 : : const struct rte_flow_action *actions[RTE_COLORS],
3537 : : struct rte_flow_attr *attr,
3538 : : struct rte_mtr_error *error);
3539 : : int mlx5_flow_create_policy_rules(struct rte_eth_dev *dev,
3540 : : struct mlx5_flow_meter_policy *mtr_policy);
3541 : : void mlx5_flow_destroy_policy_rules(struct rte_eth_dev *dev,
3542 : : struct mlx5_flow_meter_policy *mtr_policy);
3543 : : int mlx5_flow_create_def_policy(struct rte_eth_dev *dev);
3544 : : void mlx5_flow_destroy_def_policy(struct rte_eth_dev *dev);
3545 : : void mlx5_flow_drv_rxq_flags_set(struct rte_eth_dev *dev,
3546 : : struct mlx5_flow_handle *dev_handle);
3547 : : const struct mlx5_flow_tunnel *
3548 : : mlx5_get_tof(const struct rte_flow_item *items,
3549 : : const struct rte_flow_action *actions,
3550 : : enum mlx5_tof_rule_type *rule_type);
3551 : : void
3552 : : mlx5_flow_hw_resource_release(struct rte_eth_dev *dev);
3553 : : int
3554 : : mlx5_geneve_tlv_options_destroy(struct mlx5_geneve_tlv_options *options,
3555 : : struct mlx5_physical_device *phdev);
3556 : : void
3557 : : mlx5_flow_hw_rxq_flag_set(struct rte_eth_dev *dev, bool enable);
3558 : : int mlx5_flow_dv_action_validate(struct rte_eth_dev *dev,
3559 : : const struct rte_flow_indir_action_conf *conf,
3560 : : const struct rte_flow_action *action,
3561 : : struct rte_flow_error *err);
3562 : : struct rte_flow_action_handle *mlx5_flow_dv_action_create(struct rte_eth_dev *dev,
3563 : : const struct rte_flow_indir_action_conf *conf,
3564 : : const struct rte_flow_action *action,
3565 : : struct rte_flow_error *err);
3566 : : int mlx5_flow_dv_action_destroy(struct rte_eth_dev *dev,
3567 : : struct rte_flow_action_handle *handle,
3568 : : struct rte_flow_error *error);
3569 : : int mlx5_flow_dv_action_update(struct rte_eth_dev *dev,
3570 : : struct rte_flow_action_handle *handle,
3571 : : const void *update,
3572 : : struct rte_flow_error *err);
3573 : : int mlx5_flow_dv_action_query(struct rte_eth_dev *dev,
3574 : : const struct rte_flow_action_handle *handle,
3575 : : void *data,
3576 : : struct rte_flow_error *error);
3577 : : size_t mlx5_flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);
3578 : : int mlx5_flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
3579 : : size_t *size, struct rte_flow_error *error);
3580 : : void mlx5_flow_field_id_to_modify_info
3581 : : (const struct rte_flow_field_data *data,
3582 : : struct field_modify_info *info, uint32_t *mask,
3583 : : uint32_t width, struct rte_eth_dev *dev,
3584 : : const struct rte_flow_attr *attr, struct rte_flow_error *error);
3585 : : int mlx5_flow_dv_convert_modify_action(struct rte_flow_item *item,
3586 : : struct field_modify_info *field,
3587 : : struct field_modify_info *dest,
3588 : : struct mlx5_flow_dv_modify_hdr_resource *resource,
3589 : : uint32_t type, struct rte_flow_error *error);
3590 : :
3591 : : #define MLX5_PF_VPORT_ID 0
3592 : : #define MLX5_ECPF_VPORT_ID 0xFFFE
3593 : :
3594 : : int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev);
3595 : : int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
3596 : : const struct rte_flow_item *item,
3597 : : uint16_t *vport_id,
3598 : : bool *all_ports,
3599 : : struct rte_flow_error *error);
3600 : :
3601 : : int mlx5_flow_dv_translate_items_hws(const struct rte_flow_item *items,
3602 : : struct mlx5_flow_attr *attr, void *key,
3603 : : uint32_t key_type, uint64_t *item_flags,
3604 : : uint8_t *match_criteria,
3605 : : struct rte_flow_error *error);
3606 : :
3607 : : int mlx5_flow_dv_translate_items_hws_impl(const struct rte_flow_item *items,
3608 : : struct mlx5_flow_attr *attr, void *key,
3609 : : uint32_t key_type, uint64_t *item_flags,
3610 : : uint8_t *match_criteria,
3611 : : bool nt_flow,
3612 : : struct rte_flow_error *error);
3613 : :
3614 : : int mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,
3615 : : uint16_t *proxy_port_id,
3616 : : struct rte_flow_error *error);
3617 : : int mlx5_flow_null_get_aged_flows(struct rte_eth_dev *dev,
3618 : : void **context,
3619 : : uint32_t nb_contexts,
3620 : : struct rte_flow_error *error);
3621 : : uint32_t mlx5_flow_null_counter_allocate(struct rte_eth_dev *dev);
3622 : : void mlx5_flow_null_counter_free(struct rte_eth_dev *dev,
3623 : : uint32_t counter);
3624 : : int mlx5_flow_null_counter_query(struct rte_eth_dev *dev,
3625 : : uint32_t counter,
3626 : : bool clear,
3627 : : uint64_t *pkts,
3628 : : uint64_t *bytes,
3629 : : void **action);
3630 : :
3631 : : int mlx5_flow_hw_flush_ctrl_flows(struct rte_eth_dev *dev);
3632 : :
3633 : : int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev,
3634 : : uint32_t sqn, bool external);
3635 : : int mlx5_flow_hw_esw_destroy_sq_miss_flow(struct rte_eth_dev *dev,
3636 : : uint32_t sqn, bool external);
3637 : : int mlx5_flow_hw_esw_create_default_jump_flow(struct rte_eth_dev *dev);
3638 : : int mlx5_flow_hw_create_nic_tx_default_mreg_copy_flow(struct rte_eth_dev *dev, uint32_t sqn);
3639 : : int mlx5_flow_hw_create_tx_repr_matching_flow(struct rte_eth_dev *dev,
3640 : : uint32_t sqn, bool external);
3641 : : int mlx5_flow_hw_destroy_tx_repr_matching_flow(struct rte_eth_dev *dev,
3642 : : uint32_t sqn, bool external);
3643 : : int mlx5_flow_hw_lacp_rx_flow(struct rte_eth_dev *dev);
3644 : : int mlx5_flow_actions_validate(struct rte_eth_dev *dev,
3645 : : const struct rte_flow_actions_template_attr *attr,
3646 : : const struct rte_flow_action actions[],
3647 : : const struct rte_flow_action masks[],
3648 : : struct rte_flow_error *error);
3649 : : int mlx5_flow_pattern_validate(struct rte_eth_dev *dev,
3650 : : const struct rte_flow_pattern_template_attr *attr,
3651 : : const struct rte_flow_item items[],
3652 : : struct rte_flow_error *error);
3653 : : int mlx5_flow_hw_table_update(struct rte_eth_dev *dev,
3654 : : struct rte_flow_error *error);
3655 : : int mlx5_flow_item_field_width(struct rte_eth_dev *dev,
3656 : : enum rte_flow_field_id field, int inherit,
3657 : : const struct rte_flow_attr *attr,
3658 : : struct rte_flow_error *error);
3659 : : void mlx5_flow_rxq_mark_flag_set(struct rte_eth_dev *dev);
3660 : : void mlx5_flow_rxq_flags_clear(struct rte_eth_dev *dev);
3661 : : uintptr_t mlx5_flow_legacy_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type,
3662 : : const struct rte_flow_attr *attr,
3663 : : const struct rte_flow_item items[],
3664 : : const struct rte_flow_action actions[],
3665 : : bool external, struct rte_flow_error *error);
3666 : : void mlx5_flow_legacy_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,
3667 : : uintptr_t flow_idx);
3668 : :
3669 : : static __rte_always_inline int
3670 : : flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
3671 : : {
3672 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
3673 : : uint16_t port;
3674 : :
3675 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
3676 : : struct mlx5_priv *priv;
3677 : : struct mlx5_hca_flex_attr *attr;
3678 : : struct mlx5_devx_match_sample_info_query_attr *info;
3679 : :
3680 : 0 : priv = rte_eth_devices[port].data->dev_private;
3681 : 0 : attr = &priv->sh->cdev->config.hca_attr.flex;
3682 [ # # # # ]: 0 : if (priv->dr_ctx == dr_ctx && attr->query_match_sample_info) {
3683 : 0 : info = &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[0];
3684 [ # # ]: 0 : if (priv->sh->srh_flex_parser.flex.mapnum)
3685 : 0 : return info->sample_dw_data * sizeof(uint32_t);
3686 : : else
3687 : : return UINT32_MAX;
3688 : : }
3689 : : }
3690 : : #endif
3691 : : return UINT32_MAX;
3692 : : }
3693 : :
3694 : : static __rte_always_inline uint8_t
3695 : : flow_hw_get_ipv6_route_ext_anchor_from_ctx(void *dr_ctx)
3696 : : {
3697 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
3698 : : uint16_t port;
3699 : : struct mlx5_priv *priv;
3700 : :
3701 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
3702 : 0 : priv = rte_eth_devices[port].data->dev_private;
3703 [ # # ]: 0 : if (priv->dr_ctx == dr_ctx)
3704 : 0 : return priv->sh->srh_flex_parser.flex.devx_fp->anchor_id;
3705 : : }
3706 : : #else
3707 : : RTE_SET_USED(dr_ctx);
3708 : : #endif
3709 : : return 0;
3710 : : }
3711 : :
3712 : : static __rte_always_inline uint16_t
3713 : : flow_hw_get_ipv6_route_ext_mod_id_from_ctx(void *dr_ctx, uint8_t idx)
3714 : : {
3715 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
3716 : : uint16_t port;
3717 : : struct mlx5_priv *priv;
3718 : : struct mlx5_flex_parser_devx *fp;
3719 : :
3720 : : if (idx >= MLX5_GRAPH_NODE_SAMPLE_NUM || idx >= MLX5_SRV6_SAMPLE_NUM)
3721 : : return 0;
3722 [ # # # # : 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
# # # # #
# ]
3723 : 0 : priv = rte_eth_devices[port].data->dev_private;
3724 [ # # # # : 0 : if (priv->dr_ctx == dr_ctx) {
# # # # #
# ]
3725 : 0 : fp = priv->sh->srh_flex_parser.flex.devx_fp;
3726 : 0 : return fp->sample_info[idx].modify_field_id;
3727 : : }
3728 : : }
3729 : : #else
3730 : : RTE_SET_USED(dr_ctx);
3731 : : RTE_SET_USED(idx);
3732 : : #endif
3733 : : return 0;
3734 : : }
3735 : :
3736 : : uint8_t mlx5_flex_hdr_len_mask(uint8_t shift, const struct mlx5_hca_flex_attr *attr);
3737 : :
3738 : : static inline bool
3739 : : mlx5_dv_modify_ipv6_traffic_class_supported(struct mlx5_priv *priv)
3740 : : {
3741 [ # # # # : 0 : return priv->sh->phdev->config.ipv6_tc_fallback == MLX5_IPV6_TC_OK;
# # # # ]
3742 : : }
3743 : :
3744 : : void
3745 : : mlx5_indirect_list_handles_release(struct rte_eth_dev *dev);
3746 : :
3747 : : bool mlx5_flow_is_steering_disabled(void);
3748 : :
3749 : : /**
3750 : : * Returns true if Rx control rule for LACP traffic is needed.
3751 : : *
3752 : : * mlx5 PMD needs to create a rule matching LACP traffic and forwarding it back to kernel if:
3753 : : *
3754 : : * - Underlying device is a bond interface.
3755 : : * - User did not request to handle LACP traffic in user space.
3756 : : *
3757 : : * Creation of this rule is also controlled by the E-Switch mode:
3758 : : *
3759 : : * - It must be created in legacy mode.
3760 : : * - It must be created only on proxy port in switchdev mode.
3761 : : *
3762 : : * @param[in] priv
3763 : : * Pointer to Ethernet device structure.
3764 : : *
3765 : : * @return
3766 : : * True if LACP rules must be created.
3767 : : * False otherwise.
3768 : : */
3769 : : static inline bool
3770 : 0 : mlx5_flow_lacp_miss_needed(struct rte_eth_dev *dev)
3771 : : {
3772 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
3773 : :
3774 : 0 : return !priv->sh->config.lacp_by_user &&
3775 [ # # # # ]: 0 : priv->pf_bond >= 0 &&
3776 [ # # # # ]: 0 : (!priv->sh->esw_mode || (priv->sh->esw_mode && priv->master));
3777 : : }
3778 : :
3779 : : #ifdef HAVE_MLX5_HWS_SUPPORT
3780 : :
3781 : : #define MLX5_REPR_STC_MEMORY_LOG 11
3782 : :
3783 : : struct mlx5_mirror;
3784 : : void
3785 : : mlx5_hw_mirror_destroy(struct rte_eth_dev *dev, struct mlx5_mirror *mirror);
3786 : : void
3787 : : mlx5_destroy_legacy_indirect(struct rte_eth_dev *dev,
3788 : : struct mlx5_indirect_list *ptr);
3789 : : void
3790 : : mlx5_hw_decap_encap_destroy(struct rte_eth_dev *dev,
3791 : : struct mlx5_indirect_list *reformat);
3792 : : int
3793 : : mlx5_flow_hw_create_flow(struct rte_eth_dev *dev, enum mlx5_flow_type type,
3794 : : const struct rte_flow_attr *attr,
3795 : : const struct rte_flow_item items[],
3796 : : const struct rte_flow_action actions[],
3797 : : uint64_t item_flags, uint64_t action_flags, bool external,
3798 : : struct rte_flow_hw **flow, struct rte_flow_error *error);
3799 : : void
3800 : : mlx5_flow_hw_destroy(struct rte_eth_dev *dev, struct rte_flow_hw *flow);
3801 : : void
3802 : : mlx5_flow_hw_list_destroy(struct rte_eth_dev *dev, enum mlx5_flow_type type,
3803 : : uintptr_t flow_idx);
3804 : : const struct rte_flow_action_rss *
3805 : : mlx5_flow_nta_locate_rss(struct rte_eth_dev *dev,
3806 : : const struct rte_flow_action actions[],
3807 : : struct rte_flow_error *error);
3808 : : struct rte_flow_hw *
3809 : : mlx5_flow_nta_handle_rss(struct rte_eth_dev *dev,
3810 : : const struct rte_flow_attr *attr,
3811 : : const struct rte_flow_item items[],
3812 : : const struct rte_flow_action actions[],
3813 : : const struct rte_flow_action_rss *rss_conf,
3814 : : uint64_t item_flags, uint64_t action_flags,
3815 : : bool external, enum mlx5_flow_type flow_type,
3816 : : struct rte_flow_error *error);
3817 : :
3818 : : extern const struct rte_flow_action_raw_decap empty_decap;
3819 : : extern const struct rte_flow_item_ipv6 nic_ipv6_mask;
3820 : : extern const struct rte_flow_item_tcp nic_tcp_mask;
3821 : :
3822 : : /* mlx5_nta_split.c */
3823 : : int
3824 : : mlx5_flow_nta_split_metadata(struct rte_eth_dev *dev,
3825 : : const struct rte_flow_attr *attr,
3826 : : const struct rte_flow_action actions[],
3827 : : const struct rte_flow_action *qrss,
3828 : : uint64_t action_flags,
3829 : : int actions_n,
3830 : : bool external,
3831 : : struct mlx5_flow_hw_split_resource *res,
3832 : : struct rte_flow_error *error);
3833 : : void
3834 : : mlx5_flow_nta_split_resource_free(struct rte_eth_dev *dev,
3835 : : struct mlx5_flow_hw_split_resource *res);
3836 : : struct mlx5_list_entry *
3837 : : mlx5_flow_nta_mreg_create_cb(void *tool_ctx, void *cb_ctx);
3838 : : void
3839 : : mlx5_flow_nta_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
3840 : : void
3841 : : mlx5_flow_nta_del_copy_action(struct rte_eth_dev *dev, uint32_t idx);
3842 : : void
3843 : : mlx5_flow_nta_del_default_copy_action(struct rte_eth_dev *dev);
3844 : : int
3845 : : mlx5_flow_nta_add_default_copy_action(struct rte_eth_dev *dev,
3846 : : struct rte_flow_error *error);
3847 : : int
3848 : : mlx5_flow_nta_update_copy_table(struct rte_eth_dev *dev,
3849 : : uint32_t *idx,
3850 : : const struct rte_flow_action *mark,
3851 : : uint64_t action_flags,
3852 : : struct rte_flow_error *error);
3853 : :
3854 : : struct mlx5_ecpri_parser_profile *mlx5_flow_hw_get_ecpri_parser_profile(void *dr_ctx);
3855 : :
3856 : : struct mlx5_mirror *
3857 : : mlx5_hw_create_mirror(struct rte_eth_dev *dev,
3858 : : const struct mlx5_flow_template_table_cfg *table_cfg,
3859 : : const struct rte_flow_action *actions,
3860 : : struct rte_flow_error *error);
3861 : :
3862 : : int
3863 : : mlx5_flow_hw_group_set_miss_actions(struct rte_eth_dev *dev,
3864 : : uint32_t group_id,
3865 : : const struct rte_flow_group_attr *attr,
3866 : : const struct rte_flow_action actions[],
3867 : : struct rte_flow_error *error);
3868 : :
3869 : : uint64_t
3870 : : mlx5_flow_hw_action_flags_get(const struct rte_flow_action actions[],
3871 : : const struct rte_flow_action **qrss,
3872 : : const struct rte_flow_action **mark,
3873 : : int *encap_idx,
3874 : : int *act_cnt,
3875 : : struct rte_flow_error *error);
3876 : :
3877 : : #include "mlx5_nta_sample.h"
3878 : :
3879 : : #endif /* HAVE_MLX5_HWS_SUPPORT */
3880 : : #endif /* RTE_PMD_MLX5_FLOW_H_ */
|