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