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