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