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