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 : :
23 : : /* E-Switch Manager port, used for rte_flow_item_port_id. */
24 : : #define MLX5_PORT_ESW_MGR UINT32_MAX
25 : :
26 : : /* E-Switch Manager port, used for rte_flow_item_ethdev. */
27 : : #define MLX5_REPRESENTED_PORT_ESW_MGR UINT16_MAX
28 : :
29 : : /* Private rte flow items. */
30 : : enum mlx5_rte_flow_item_type {
31 : : MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
32 : : MLX5_RTE_FLOW_ITEM_TYPE_TAG,
33 : : MLX5_RTE_FLOW_ITEM_TYPE_SQ,
34 : : MLX5_RTE_FLOW_ITEM_TYPE_VLAN,
35 : : MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL,
36 : : };
37 : :
38 : : /* Private (internal) rte flow actions. */
39 : : enum mlx5_rte_flow_action_type {
40 : : MLX5_RTE_FLOW_ACTION_TYPE_END = INT_MIN,
41 : : MLX5_RTE_FLOW_ACTION_TYPE_TAG,
42 : : MLX5_RTE_FLOW_ACTION_TYPE_MARK,
43 : : MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG,
44 : : MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS,
45 : : MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET,
46 : : MLX5_RTE_FLOW_ACTION_TYPE_AGE,
47 : : MLX5_RTE_FLOW_ACTION_TYPE_COUNT,
48 : : MLX5_RTE_FLOW_ACTION_TYPE_JUMP,
49 : : MLX5_RTE_FLOW_ACTION_TYPE_RSS,
50 : : MLX5_RTE_FLOW_ACTION_TYPE_METER_MARK,
51 : : };
52 : :
53 : : /* Private (internal) Field IDs for MODIFY_FIELD action. */
54 : : enum mlx5_rte_flow_field_id {
55 : : MLX5_RTE_FLOW_FIELD_END = INT_MIN,
56 : : MLX5_RTE_FLOW_FIELD_META_REG,
57 : : };
58 : :
59 : : #define MLX5_INDIRECT_ACTION_TYPE_OFFSET 29
60 : :
61 : : #define MLX5_INDIRECT_ACTION_TYPE_GET(handle) \
62 : : (((uint32_t)(uintptr_t)(handle)) >> MLX5_INDIRECT_ACTION_TYPE_OFFSET)
63 : :
64 : : #define MLX5_INDIRECT_ACTION_IDX_GET(handle) \
65 : : (((uint32_t)(uintptr_t)(handle)) & \
66 : : ((1u << MLX5_INDIRECT_ACTION_TYPE_OFFSET) - 1))
67 : :
68 : : enum mlx5_indirect_type {
69 : : MLX5_INDIRECT_ACTION_TYPE_RSS,
70 : : MLX5_INDIRECT_ACTION_TYPE_AGE,
71 : : MLX5_INDIRECT_ACTION_TYPE_COUNT,
72 : : MLX5_INDIRECT_ACTION_TYPE_CT,
73 : : MLX5_INDIRECT_ACTION_TYPE_METER_MARK,
74 : : MLX5_INDIRECT_ACTION_TYPE_QUOTA,
75 : : };
76 : :
77 : : /* Now, the maximal ports will be supported is 16, action number is 32M. */
78 : : #define MLX5_INDIRECT_ACT_CT_MAX_PORT 0x10
79 : :
80 : : #define MLX5_INDIRECT_ACT_CT_OWNER_SHIFT 22
81 : : #define MLX5_INDIRECT_ACT_CT_OWNER_MASK (MLX5_INDIRECT_ACT_CT_MAX_PORT - 1)
82 : :
83 : : /* 29-31: type, 25-28: owner port, 0-24: index */
84 : : #define MLX5_INDIRECT_ACT_CT_GEN_IDX(owner, index) \
85 : : ((MLX5_INDIRECT_ACTION_TYPE_CT << MLX5_INDIRECT_ACTION_TYPE_OFFSET) | \
86 : : (((owner) & MLX5_INDIRECT_ACT_CT_OWNER_MASK) << \
87 : : MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) | (index))
88 : :
89 : : #define MLX5_INDIRECT_ACT_CT_GET_OWNER(index) \
90 : : (((index) >> MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) & \
91 : : MLX5_INDIRECT_ACT_CT_OWNER_MASK)
92 : :
93 : : #define MLX5_INDIRECT_ACT_CT_GET_IDX(index) \
94 : : ((index) & ((1 << MLX5_INDIRECT_ACT_CT_OWNER_SHIFT) - 1))
95 : :
96 : : #define MLX5_ACTION_CTX_CT_GET_IDX MLX5_INDIRECT_ACT_CT_GET_IDX
97 : : #define MLX5_ACTION_CTX_CT_GET_OWNER MLX5_INDIRECT_ACT_CT_GET_OWNER
98 : : #define MLX5_ACTION_CTX_CT_GEN_IDX MLX5_INDIRECT_ACT_CT_GEN_IDX
99 : :
100 : : enum mlx5_indirect_list_type {
101 : : MLX5_INDIRECT_ACTION_LIST_TYPE_ERR = 0,
102 : : MLX5_INDIRECT_ACTION_LIST_TYPE_LEGACY = 1,
103 : : MLX5_INDIRECT_ACTION_LIST_TYPE_MIRROR = 2,
104 : : MLX5_INDIRECT_ACTION_LIST_TYPE_REFORMAT = 3,
105 : : };
106 : :
107 : : /**
108 : : * Base type for indirect list type.
109 : : */
110 : : struct mlx5_indirect_list {
111 : : /* Indirect list type. */
112 : : enum mlx5_indirect_list_type type;
113 : : /* Optional storage list entry */
114 : : LIST_ENTRY(mlx5_indirect_list) entry;
115 : : };
116 : :
117 : : static __rte_always_inline void
118 : : mlx5_indirect_list_add_entry(void *head, struct mlx5_indirect_list *elem)
119 : : {
120 : : LIST_HEAD(, mlx5_indirect_list) *h = head;
121 : :
122 [ # # # # ]: 0 : LIST_INSERT_HEAD(h, elem, entry);
123 : : }
124 : :
125 : : static __rte_always_inline void
126 : : mlx5_indirect_list_remove_entry(struct mlx5_indirect_list *elem)
127 : : {
128 [ # # # # ]: 0 : if (elem->entry.le_prev)
129 [ # # # # ]: 0 : LIST_REMOVE(elem, entry);
130 : : }
131 : :
132 : : static __rte_always_inline enum mlx5_indirect_list_type
133 : : mlx5_get_indirect_list_type(const struct rte_flow_action_list_handle *obj)
134 : : {
135 [ # # # # : 0 : return ((const struct mlx5_indirect_list *)obj)->type;
# # # # #
# # # ]
136 : : }
137 : :
138 : : /* Matches on selected register. */
139 : : struct mlx5_rte_flow_item_tag {
140 : : enum modify_reg id;
141 : : uint32_t data;
142 : : };
143 : :
144 : : /* Modify selected register. */
145 : : struct mlx5_rte_flow_action_set_tag {
146 : : enum modify_reg id;
147 : : uint8_t offset;
148 : : uint8_t length;
149 : : uint32_t data;
150 : : };
151 : :
152 : : struct mlx5_flow_action_copy_mreg {
153 : : enum modify_reg dst;
154 : : enum modify_reg src;
155 : : };
156 : :
157 : : /* Matches on source queue. */
158 : : struct mlx5_rte_flow_item_sq {
159 : : uint32_t queue; /* DevX SQ number */
160 : : };
161 : :
162 : : /* Feature name to allocate metadata register. */
163 : : enum mlx5_feature_name {
164 : : MLX5_HAIRPIN_RX,
165 : : MLX5_HAIRPIN_TX,
166 : : MLX5_METADATA_RX,
167 : : MLX5_METADATA_TX,
168 : : MLX5_METADATA_FDB,
169 : : MLX5_FLOW_MARK,
170 : : MLX5_APP_TAG,
171 : : MLX5_COPY_MARK,
172 : : MLX5_MTR_COLOR,
173 : : MLX5_MTR_ID,
174 : : MLX5_ASO_FLOW_HIT,
175 : : MLX5_ASO_CONNTRACK,
176 : : MLX5_SAMPLE_ID,
177 : : };
178 : :
179 : : /* Default queue number. */
180 : : #define MLX5_RSSQ_DEFAULT_NUM 16
181 : :
182 : : #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
183 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
184 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV6 (1u << 2)
185 : : #define MLX5_FLOW_LAYER_OUTER_L4_UDP (1u << 3)
186 : : #define MLX5_FLOW_LAYER_OUTER_L4_TCP (1u << 4)
187 : : #define MLX5_FLOW_LAYER_OUTER_VLAN (1u << 5)
188 : :
189 : : /* Pattern inner Layer bits. */
190 : : #define MLX5_FLOW_LAYER_INNER_L2 (1u << 6)
191 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV4 (1u << 7)
192 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV6 (1u << 8)
193 : : #define MLX5_FLOW_LAYER_INNER_L4_UDP (1u << 9)
194 : : #define MLX5_FLOW_LAYER_INNER_L4_TCP (1u << 10)
195 : : #define MLX5_FLOW_LAYER_INNER_VLAN (1u << 11)
196 : :
197 : : /* Pattern tunnel Layer bits. */
198 : : #define MLX5_FLOW_LAYER_VXLAN (1u << 12)
199 : : #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13)
200 : : #define MLX5_FLOW_LAYER_GRE (1u << 14)
201 : : #define MLX5_FLOW_LAYER_MPLS (1u << 15)
202 : : /* List of tunnel Layer bits continued below. */
203 : :
204 : : /* General pattern items bits. */
205 : : #define MLX5_FLOW_ITEM_METADATA (1u << 16)
206 : : #define MLX5_FLOW_ITEM_PORT_ID (1u << 17)
207 : : #define MLX5_FLOW_ITEM_TAG (1u << 18)
208 : : #define MLX5_FLOW_ITEM_MARK (1u << 19)
209 : :
210 : : /* Pattern MISC bits. */
211 : : #define MLX5_FLOW_LAYER_ICMP (1u << 20)
212 : : #define MLX5_FLOW_LAYER_ICMP6 (1u << 21)
213 : : #define MLX5_FLOW_LAYER_GRE_KEY (1u << 22)
214 : :
215 : : /* Pattern tunnel Layer bits (continued). */
216 : : #define MLX5_FLOW_LAYER_IPIP (1u << 23)
217 : : #define MLX5_FLOW_LAYER_IPV6_ENCAP (1u << 24)
218 : : #define MLX5_FLOW_LAYER_NVGRE (1u << 25)
219 : : #define MLX5_FLOW_LAYER_GENEVE (1u << 26)
220 : :
221 : : /* Queue items. */
222 : : #define MLX5_FLOW_ITEM_SQ (1u << 27)
223 : :
224 : : /* Pattern tunnel Layer bits (continued). */
225 : : #define MLX5_FLOW_LAYER_GTP (1u << 28)
226 : :
227 : : /* Pattern eCPRI Layer bit. */
228 : : #define MLX5_FLOW_LAYER_ECPRI (UINT64_C(1) << 29)
229 : :
230 : : /* IPv6 Fragment Extension Header bit. */
231 : : #define MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT (1u << 30)
232 : : #define MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT (1u << 31)
233 : :
234 : : /* Pattern tunnel Layer bits (continued). */
235 : : #define MLX5_FLOW_LAYER_GENEVE_OPT (UINT64_C(1) << 32)
236 : : #define MLX5_FLOW_LAYER_GTP_PSC (UINT64_C(1) << 33)
237 : :
238 : : /* INTEGRITY item bits */
239 : : #define MLX5_FLOW_ITEM_OUTER_INTEGRITY (UINT64_C(1) << 34)
240 : : #define MLX5_FLOW_ITEM_INNER_INTEGRITY (UINT64_C(1) << 35)
241 : : #define MLX5_FLOW_ITEM_INTEGRITY \
242 : : (MLX5_FLOW_ITEM_OUTER_INTEGRITY | MLX5_FLOW_ITEM_INNER_INTEGRITY)
243 : :
244 : : /* Conntrack item. */
245 : : #define MLX5_FLOW_LAYER_ASO_CT (UINT64_C(1) << 36)
246 : :
247 : : /* Flex item */
248 : : #define MLX5_FLOW_ITEM_OUTER_FLEX (UINT64_C(1) << 37)
249 : : #define MLX5_FLOW_ITEM_INNER_FLEX (UINT64_C(1) << 38)
250 : : #define MLX5_FLOW_ITEM_FLEX_TUNNEL (UINT64_C(1) << 39)
251 : :
252 : : /* ESP item */
253 : : #define MLX5_FLOW_ITEM_ESP (UINT64_C(1) << 40)
254 : :
255 : : /* Port Representor/Represented Port item */
256 : : #define MLX5_FLOW_ITEM_PORT_REPRESENTOR (UINT64_C(1) << 41)
257 : : #define MLX5_FLOW_ITEM_REPRESENTED_PORT (UINT64_C(1) << 42)
258 : :
259 : : /* Meter color item */
260 : : #define MLX5_FLOW_ITEM_METER_COLOR (UINT64_C(1) << 44)
261 : : #define MLX5_FLOW_ITEM_QUOTA (UINT64_C(1) << 45)
262 : :
263 : :
264 : : /* IPv6 routing extension item */
265 : : #define MLX5_FLOW_ITEM_OUTER_IPV6_ROUTING_EXT (UINT64_C(1) << 45)
266 : : #define MLX5_FLOW_ITEM_INNER_IPV6_ROUTING_EXT (UINT64_C(1) << 46)
267 : :
268 : : /* Aggregated affinity item */
269 : : #define MLX5_FLOW_ITEM_AGGR_AFFINITY (UINT64_C(1) << 49)
270 : :
271 : : /* IB BTH ITEM. */
272 : : #define MLX5_FLOW_ITEM_IB_BTH (1ull << 51)
273 : :
274 : : /* PTYPE ITEM */
275 : : #define MLX5_FLOW_ITEM_PTYPE (1ull << 52)
276 : :
277 : : /* NSH ITEM */
278 : : #define MLX5_FLOW_ITEM_NSH (1ull << 53)
279 : :
280 : : /* Outer Masks. */
281 : : #define MLX5_FLOW_LAYER_OUTER_L3 \
282 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
283 : : #define MLX5_FLOW_LAYER_OUTER_L4 \
284 : : (MLX5_FLOW_LAYER_OUTER_L4_UDP | MLX5_FLOW_LAYER_OUTER_L4_TCP)
285 : : #define MLX5_FLOW_LAYER_OUTER \
286 : : (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_OUTER_L3 | \
287 : : MLX5_FLOW_LAYER_OUTER_L4)
288 : :
289 : : /* Tunnel Masks. */
290 : : #define MLX5_FLOW_LAYER_TUNNEL \
291 : : (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \
292 : : MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | MLX5_FLOW_LAYER_MPLS | \
293 : : MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP | \
294 : : MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP | \
295 : : MLX5_FLOW_ITEM_FLEX_TUNNEL)
296 : :
297 : : /* Inner Masks. */
298 : : #define MLX5_FLOW_LAYER_INNER_L3 \
299 : : (MLX5_FLOW_LAYER_INNER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
300 : : #define MLX5_FLOW_LAYER_INNER_L4 \
301 : : (MLX5_FLOW_LAYER_INNER_L4_UDP | MLX5_FLOW_LAYER_INNER_L4_TCP)
302 : : #define MLX5_FLOW_LAYER_INNER \
303 : : (MLX5_FLOW_LAYER_INNER_L2 | MLX5_FLOW_LAYER_INNER_L3 | \
304 : : MLX5_FLOW_LAYER_INNER_L4)
305 : :
306 : : /* Layer Masks. */
307 : : #define MLX5_FLOW_LAYER_L2 \
308 : : (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_INNER_L2)
309 : : #define MLX5_FLOW_LAYER_L3_IPV4 \
310 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV4)
311 : : #define MLX5_FLOW_LAYER_L3_IPV6 \
312 : : (MLX5_FLOW_LAYER_OUTER_L3_IPV6 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
313 : : #define MLX5_FLOW_LAYER_L3 \
314 : : (MLX5_FLOW_LAYER_L3_IPV4 | MLX5_FLOW_LAYER_L3_IPV6)
315 : : #define MLX5_FLOW_LAYER_L4 \
316 : : (MLX5_FLOW_LAYER_OUTER_L4 | MLX5_FLOW_LAYER_INNER_L4)
317 : :
318 : : /* Actions */
319 : : #define MLX5_FLOW_ACTION_DROP (1ull << 0)
320 : : #define MLX5_FLOW_ACTION_QUEUE (1ull << 1)
321 : : #define MLX5_FLOW_ACTION_RSS (1ull << 2)
322 : : #define MLX5_FLOW_ACTION_FLAG (1ull << 3)
323 : : #define MLX5_FLOW_ACTION_MARK (1ull << 4)
324 : : #define MLX5_FLOW_ACTION_COUNT (1ull << 5)
325 : : #define MLX5_FLOW_ACTION_PORT_ID (1ull << 6)
326 : : #define MLX5_FLOW_ACTION_OF_POP_VLAN (1ull << 7)
327 : : #define MLX5_FLOW_ACTION_OF_PUSH_VLAN (1ull << 8)
328 : : #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1ull << 9)
329 : : #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1ull << 10)
330 : : #define MLX5_FLOW_ACTION_SET_IPV4_SRC (1ull << 11)
331 : : #define MLX5_FLOW_ACTION_SET_IPV4_DST (1ull << 12)
332 : : #define MLX5_FLOW_ACTION_SET_IPV6_SRC (1ull << 13)
333 : : #define MLX5_FLOW_ACTION_SET_IPV6_DST (1ull << 14)
334 : : #define MLX5_FLOW_ACTION_SET_TP_SRC (1ull << 15)
335 : : #define MLX5_FLOW_ACTION_SET_TP_DST (1ull << 16)
336 : : #define MLX5_FLOW_ACTION_JUMP (1ull << 17)
337 : : #define MLX5_FLOW_ACTION_SET_TTL (1ull << 18)
338 : : #define MLX5_FLOW_ACTION_DEC_TTL (1ull << 19)
339 : : #define MLX5_FLOW_ACTION_SET_MAC_SRC (1ull << 20)
340 : : #define MLX5_FLOW_ACTION_SET_MAC_DST (1ull << 21)
341 : : #define MLX5_FLOW_ACTION_ENCAP (1ull << 22)
342 : : #define MLX5_FLOW_ACTION_DECAP (1ull << 23)
343 : : #define MLX5_FLOW_ACTION_INC_TCP_SEQ (1ull << 24)
344 : : #define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1ull << 25)
345 : : #define MLX5_FLOW_ACTION_INC_TCP_ACK (1ull << 26)
346 : : #define MLX5_FLOW_ACTION_DEC_TCP_ACK (1ull << 27)
347 : : #define MLX5_FLOW_ACTION_SET_TAG (1ull << 28)
348 : : #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 29)
349 : : #define MLX5_FLOW_ACTION_SET_META (1ull << 30)
350 : : #define MLX5_FLOW_ACTION_METER (1ull << 31)
351 : : #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32)
352 : : #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33)
353 : : #define MLX5_FLOW_ACTION_AGE (1ull << 34)
354 : : #define MLX5_FLOW_ACTION_DEFAULT_MISS (1ull << 35)
355 : : #define MLX5_FLOW_ACTION_SAMPLE (1ull << 36)
356 : : #define MLX5_FLOW_ACTION_TUNNEL_SET (1ull << 37)
357 : : #define MLX5_FLOW_ACTION_TUNNEL_MATCH (1ull << 38)
358 : : #define MLX5_FLOW_ACTION_MODIFY_FIELD (1ull << 39)
359 : : #define MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY (1ull << 40)
360 : : #define MLX5_FLOW_ACTION_CT (1ull << 41)
361 : : #define MLX5_FLOW_ACTION_SEND_TO_KERNEL (1ull << 42)
362 : : #define MLX5_FLOW_ACTION_INDIRECT_COUNT (1ull << 43)
363 : : #define MLX5_FLOW_ACTION_INDIRECT_AGE (1ull << 44)
364 : : #define MLX5_FLOW_ACTION_QUOTA (1ull << 46)
365 : : #define MLX5_FLOW_ACTION_PORT_REPRESENTOR (1ull << 47)
366 : : #define MLX5_FLOW_ACTION_IPV6_ROUTING_REMOVE (1ull << 48)
367 : : #define MLX5_FLOW_ACTION_IPV6_ROUTING_PUSH (1ull << 49)
368 : :
369 : : #define MLX5_FLOW_DROP_INCLUSIVE_ACTIONS \
370 : : (MLX5_FLOW_ACTION_COUNT | MLX5_FLOW_ACTION_SAMPLE | MLX5_FLOW_ACTION_AGE)
371 : :
372 : : #define MLX5_FLOW_FATE_ACTIONS \
373 : : (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
374 : : MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \
375 : : MLX5_FLOW_ACTION_DEFAULT_MISS | \
376 : : MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY | \
377 : : MLX5_FLOW_ACTION_SEND_TO_KERNEL | \
378 : : MLX5_FLOW_ACTION_PORT_REPRESENTOR)
379 : :
380 : : #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
381 : : (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
382 : : MLX5_FLOW_ACTION_SEND_TO_KERNEL | \
383 : : MLX5_FLOW_ACTION_JUMP | MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY)
384 : :
385 : : #define MLX5_FLOW_MODIFY_HDR_ACTIONS (MLX5_FLOW_ACTION_SET_IPV4_SRC | \
386 : : MLX5_FLOW_ACTION_SET_IPV4_DST | \
387 : : MLX5_FLOW_ACTION_SET_IPV6_SRC | \
388 : : MLX5_FLOW_ACTION_SET_IPV6_DST | \
389 : : MLX5_FLOW_ACTION_SET_TP_SRC | \
390 : : MLX5_FLOW_ACTION_SET_TP_DST | \
391 : : MLX5_FLOW_ACTION_SET_TTL | \
392 : : MLX5_FLOW_ACTION_DEC_TTL | \
393 : : MLX5_FLOW_ACTION_SET_MAC_SRC | \
394 : : MLX5_FLOW_ACTION_SET_MAC_DST | \
395 : : MLX5_FLOW_ACTION_INC_TCP_SEQ | \
396 : : MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
397 : : MLX5_FLOW_ACTION_INC_TCP_ACK | \
398 : : MLX5_FLOW_ACTION_DEC_TCP_ACK | \
399 : : MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \
400 : : MLX5_FLOW_ACTION_SET_TAG | \
401 : : MLX5_FLOW_ACTION_MARK_EXT | \
402 : : MLX5_FLOW_ACTION_SET_META | \
403 : : MLX5_FLOW_ACTION_SET_IPV4_DSCP | \
404 : : MLX5_FLOW_ACTION_SET_IPV6_DSCP | \
405 : : MLX5_FLOW_ACTION_MODIFY_FIELD)
406 : :
407 : : #define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \
408 : : MLX5_FLOW_ACTION_OF_PUSH_VLAN)
409 : :
410 : : #define MLX5_FLOW_XCAP_ACTIONS (MLX5_FLOW_ACTION_ENCAP | MLX5_FLOW_ACTION_DECAP)
411 : :
412 : : #ifndef IPPROTO_MPLS
413 : : #define IPPROTO_MPLS 137
414 : : #endif
415 : :
416 : : /* UDP port number for MPLS */
417 : : #define MLX5_UDP_PORT_MPLS 6635
418 : :
419 : : /* UDP port numbers for VxLAN. */
420 : : #define MLX5_UDP_PORT_VXLAN 4789
421 : : #define MLX5_UDP_PORT_VXLAN_GPE 4790
422 : :
423 : : /* UDP port numbers for RoCEv2. */
424 : : #define MLX5_UDP_PORT_ROCEv2 4791
425 : :
426 : : /* UDP port numbers for GENEVE. */
427 : : #define MLX5_UDP_PORT_GENEVE 6081
428 : :
429 : : /* Lowest priority indicator. */
430 : : #define MLX5_FLOW_LOWEST_PRIO_INDICATOR ((uint32_t)-1)
431 : :
432 : : /*
433 : : * Max priority for ingress\egress flow groups
434 : : * greater than 0 and for any transfer flow group.
435 : : * From user configation: 0 - 21843.
436 : : */
437 : : #define MLX5_NON_ROOT_FLOW_MAX_PRIO (21843 + 1)
438 : :
439 : : /*
440 : : * Number of sub priorities.
441 : : * For each kind of pattern matching i.e. L2, L3, L4 to have a correct
442 : : * matching on the NIC (firmware dependent) L4 most have the higher priority
443 : : * followed by L3 and ending with L2.
444 : : */
445 : : #define MLX5_PRIORITY_MAP_L2 2
446 : : #define MLX5_PRIORITY_MAP_L3 1
447 : : #define MLX5_PRIORITY_MAP_L4 0
448 : : #define MLX5_PRIORITY_MAP_MAX 3
449 : :
450 : : /* Valid layer type for IPV4 RSS. */
451 : : #define MLX5_IPV4_LAYER_TYPES \
452 : : (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | \
453 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP | RTE_ETH_RSS_NONFRAG_IPV4_UDP | \
454 : : RTE_ETH_RSS_NONFRAG_IPV4_OTHER)
455 : :
456 : : /* IBV hash source bits for IPV4. */
457 : : #define MLX5_IPV4_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
458 : :
459 : : /* Valid layer type for IPV6 RSS. */
460 : : #define MLX5_IPV6_LAYER_TYPES \
461 : : (RTE_ETH_RSS_IPV6 | RTE_ETH_RSS_FRAG_IPV6 | RTE_ETH_RSS_NONFRAG_IPV6_TCP | \
462 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP | RTE_ETH_RSS_IPV6_EX | RTE_ETH_RSS_IPV6_TCP_EX | \
463 : : RTE_ETH_RSS_IPV6_UDP_EX | RTE_ETH_RSS_NONFRAG_IPV6_OTHER)
464 : :
465 : : /* IBV hash source bits for IPV6. */
466 : : #define MLX5_IPV6_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
467 : :
468 : : /* IBV hash bits for L3 SRC. */
469 : : #define MLX5_L3_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_SRC_IPV6)
470 : :
471 : : /* IBV hash bits for L3 DST. */
472 : : #define MLX5_L3_DST_IBV_RX_HASH (IBV_RX_HASH_DST_IPV4 | IBV_RX_HASH_DST_IPV6)
473 : :
474 : : /* IBV hash bits for TCP. */
475 : : #define MLX5_TCP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
476 : : IBV_RX_HASH_DST_PORT_TCP)
477 : :
478 : : /* IBV hash bits for UDP. */
479 : : #define MLX5_UDP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_UDP | \
480 : : IBV_RX_HASH_DST_PORT_UDP)
481 : :
482 : : /* IBV hash bits for L4 SRC. */
483 : : #define MLX5_L4_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
484 : : IBV_RX_HASH_SRC_PORT_UDP)
485 : :
486 : : /* IBV hash bits for L4 DST. */
487 : : #define MLX5_L4_DST_IBV_RX_HASH (IBV_RX_HASH_DST_PORT_TCP | \
488 : : IBV_RX_HASH_DST_PORT_UDP)
489 : :
490 : : /* Geneve header first 16Bit */
491 : : #define MLX5_GENEVE_VER_MASK 0x3
492 : : #define MLX5_GENEVE_VER_SHIFT 14
493 : : #define MLX5_GENEVE_VER_VAL(a) \
494 : : (((a) >> (MLX5_GENEVE_VER_SHIFT)) & (MLX5_GENEVE_VER_MASK))
495 : : #define MLX5_GENEVE_OPTLEN_MASK 0x3F
496 : : #define MLX5_GENEVE_OPTLEN_SHIFT 8
497 : : #define MLX5_GENEVE_OPTLEN_VAL(a) \
498 : : (((a) >> (MLX5_GENEVE_OPTLEN_SHIFT)) & (MLX5_GENEVE_OPTLEN_MASK))
499 : : #define MLX5_GENEVE_OAMF_MASK 0x1
500 : : #define MLX5_GENEVE_OAMF_SHIFT 7
501 : : #define MLX5_GENEVE_OAMF_VAL(a) \
502 : : (((a) >> (MLX5_GENEVE_OAMF_SHIFT)) & (MLX5_GENEVE_OAMF_MASK))
503 : : #define MLX5_GENEVE_CRITO_MASK 0x1
504 : : #define MLX5_GENEVE_CRITO_SHIFT 6
505 : : #define MLX5_GENEVE_CRITO_VAL(a) \
506 : : (((a) >> (MLX5_GENEVE_CRITO_SHIFT)) & (MLX5_GENEVE_CRITO_MASK))
507 : : #define MLX5_GENEVE_RSVD_MASK 0x3F
508 : : #define MLX5_GENEVE_RSVD_VAL(a) ((a) & (MLX5_GENEVE_RSVD_MASK))
509 : : /*
510 : : * The length of the Geneve options fields, expressed in four byte multiples,
511 : : * not including the eight byte fixed tunnel.
512 : : */
513 : : #define MLX5_GENEVE_OPT_LEN_0 14
514 : : #define MLX5_GENEVE_OPT_LEN_1 63
515 : :
516 : : #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_ether_hdr) + \
517 : : sizeof(struct rte_ipv4_hdr))
518 : : /* GTP extension header flag. */
519 : : #define MLX5_GTP_EXT_HEADER_FLAG 4
520 : :
521 : : /* GTP extension header PDU type shift. */
522 : : #define MLX5_GTP_PDU_TYPE_SHIFT(a) ((a) << 4)
523 : :
524 : : /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
525 : : #define MLX5_IPV4_FRAG_OFFSET_MASK \
526 : : (RTE_IPV4_HDR_OFFSET_MASK | RTE_IPV4_HDR_MF_FLAG)
527 : :
528 : : /* Specific item's fields can accept a range of values (using spec and last). */
529 : : #define MLX5_ITEM_RANGE_NOT_ACCEPTED false
530 : : #define MLX5_ITEM_RANGE_ACCEPTED true
531 : :
532 : : /* Software header modify action numbers of a flow. */
533 : : #define MLX5_ACT_NUM_MDF_IPV4 1
534 : : #define MLX5_ACT_NUM_MDF_IPV6 4
535 : : #define MLX5_ACT_NUM_MDF_MAC 2
536 : : #define MLX5_ACT_NUM_MDF_VID 1
537 : : #define MLX5_ACT_NUM_MDF_PORT 1
538 : : #define MLX5_ACT_NUM_MDF_TTL 1
539 : : #define MLX5_ACT_NUM_DEC_TTL MLX5_ACT_NUM_MDF_TTL
540 : : #define MLX5_ACT_NUM_MDF_TCPSEQ 1
541 : : #define MLX5_ACT_NUM_MDF_TCPACK 1
542 : : #define MLX5_ACT_NUM_SET_REG 1
543 : : #define MLX5_ACT_NUM_SET_TAG 1
544 : : #define MLX5_ACT_NUM_CPY_MREG MLX5_ACT_NUM_SET_TAG
545 : : #define MLX5_ACT_NUM_SET_MARK MLX5_ACT_NUM_SET_TAG
546 : : #define MLX5_ACT_NUM_SET_META MLX5_ACT_NUM_SET_TAG
547 : : #define MLX5_ACT_NUM_SET_DSCP 1
548 : :
549 : : /* Maximum number of fields to modify in MODIFY_FIELD */
550 : : #define MLX5_ACT_MAX_MOD_FIELDS 5
551 : :
552 : : /* Syndrome bits definition for connection tracking. */
553 : : #define MLX5_CT_SYNDROME_VALID (0x0 << 6)
554 : : #define MLX5_CT_SYNDROME_INVALID (0x1 << 6)
555 : : #define MLX5_CT_SYNDROME_TRAP (0x2 << 6)
556 : : #define MLX5_CT_SYNDROME_STATE_CHANGE (0x1 << 1)
557 : : #define MLX5_CT_SYNDROME_BAD_PACKET (0x1 << 0)
558 : :
559 : : enum mlx5_flow_drv_type {
560 : : MLX5_FLOW_TYPE_MIN,
561 : : MLX5_FLOW_TYPE_DV,
562 : : MLX5_FLOW_TYPE_VERBS,
563 : : MLX5_FLOW_TYPE_HW,
564 : : MLX5_FLOW_TYPE_MAX,
565 : : };
566 : :
567 : : /* Fate action type. */
568 : : enum mlx5_flow_fate_type {
569 : : MLX5_FLOW_FATE_NONE, /* Egress flow. */
570 : : MLX5_FLOW_FATE_QUEUE,
571 : : MLX5_FLOW_FATE_JUMP,
572 : : MLX5_FLOW_FATE_PORT_ID,
573 : : MLX5_FLOW_FATE_DROP,
574 : : MLX5_FLOW_FATE_DEFAULT_MISS,
575 : : MLX5_FLOW_FATE_SHARED_RSS,
576 : : MLX5_FLOW_FATE_MTR,
577 : : MLX5_FLOW_FATE_SEND_TO_KERNEL,
578 : : MLX5_FLOW_FATE_MAX,
579 : : };
580 : :
581 : : /* Matcher PRM representation */
582 : : struct mlx5_flow_dv_match_params {
583 : : size_t size;
584 : : /**< Size of match value. Do NOT split size and key! */
585 : : uint32_t buf[MLX5_ST_SZ_DW(fte_match_param)];
586 : : /**< Matcher value. This value is used as the mask or as a key. */
587 : : };
588 : :
589 : : /* Matcher structure. */
590 : : struct mlx5_flow_dv_matcher {
591 : : struct mlx5_list_entry entry; /**< Pointer to the next element. */
592 : : struct mlx5_flow_tbl_resource *tbl;
593 : : /**< Pointer to the table(group) the matcher associated with. */
594 : : void *matcher_object; /**< Pointer to DV matcher */
595 : : uint16_t crc; /**< CRC of key. */
596 : : uint16_t priority; /**< Priority of matcher. */
597 : : struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
598 : : };
599 : :
600 : : #define MLX5_PUSH_MAX_LEN 128
601 : : #define MLX5_ENCAP_MAX_LEN 132
602 : :
603 : : /* Encap/decap resource structure. */
604 : : struct mlx5_flow_dv_encap_decap_resource {
605 : : struct mlx5_list_entry entry;
606 : : /* Pointer to next element. */
607 : : uint32_t refcnt; /**< Reference counter. */
608 : : void *action;
609 : : /**< Encap/decap action object. */
610 : : uint8_t buf[MLX5_ENCAP_MAX_LEN];
611 : : size_t size;
612 : : uint8_t reformat_type;
613 : : uint8_t ft_type;
614 : : uint64_t flags; /**< Flags for RDMA API. */
615 : : uint32_t idx; /**< Index for the index memory pool. */
616 : : };
617 : :
618 : : /* Tag resource structure. */
619 : : struct mlx5_flow_dv_tag_resource {
620 : : struct mlx5_list_entry entry;
621 : : /**< hash list entry for tag resource, tag value as the key. */
622 : : void *action;
623 : : /**< Tag action object. */
624 : : uint32_t refcnt; /**< Reference counter. */
625 : : uint32_t idx; /**< Index for the index memory pool. */
626 : : uint32_t tag_id; /**< Tag ID. */
627 : : };
628 : :
629 : : /* Modify resource structure */
630 : : struct mlx5_flow_dv_modify_hdr_resource {
631 : : struct mlx5_list_entry entry;
632 : : void *action; /**< Modify header action object. */
633 : : uint32_t idx;
634 : : /* Key area for hash list matching: */
635 : : uint8_t ft_type; /**< Flow table type, Rx or Tx. */
636 : : uint8_t actions_num; /**< Number of modification actions. */
637 : : bool root; /**< Whether action is in root table. */
638 : : struct mlx5_modification_cmd actions[];
639 : : /**< Modification actions. */
640 : : } __rte_packed;
641 : :
642 : : /* Modify resource key of the hash organization. */
643 : : union mlx5_flow_modify_hdr_key {
644 : : struct {
645 : : uint32_t ft_type:8; /**< Flow table type, Rx or Tx. */
646 : : uint32_t actions_num:5; /**< Number of modification actions. */
647 : : uint32_t group:19; /**< Flow group id. */
648 : : uint32_t cksum; /**< Actions check sum. */
649 : : };
650 : : uint64_t v64; /**< full 64bits value of key */
651 : : };
652 : :
653 : : /* Jump action resource structure. */
654 : : struct mlx5_flow_dv_jump_tbl_resource {
655 : : void *action; /**< Pointer to the rdma core action. */
656 : : };
657 : :
658 : : /* Port ID resource structure. */
659 : : struct mlx5_flow_dv_port_id_action_resource {
660 : : struct mlx5_list_entry entry;
661 : : void *action; /**< Action object. */
662 : : uint32_t port_id; /**< Port ID value. */
663 : : uint32_t idx; /**< Indexed pool memory index. */
664 : : };
665 : :
666 : : /* Push VLAN action resource structure */
667 : : struct mlx5_flow_dv_push_vlan_action_resource {
668 : : struct mlx5_list_entry entry; /* Cache entry. */
669 : : void *action; /**< Action object. */
670 : : uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */
671 : : rte_be32_t vlan_tag; /**< VLAN tag value. */
672 : : uint32_t idx; /**< Indexed pool memory index. */
673 : : };
674 : :
675 : : /* Metadata register copy table entry. */
676 : : struct mlx5_flow_mreg_copy_resource {
677 : : /*
678 : : * Hash list entry for copy table.
679 : : * - Key is 32/64-bit MARK action ID.
680 : : * - MUST be the first entry.
681 : : */
682 : : struct mlx5_list_entry hlist_ent;
683 : : LIST_ENTRY(mlx5_flow_mreg_copy_resource) next;
684 : : /* List entry for device flows. */
685 : : uint32_t idx;
686 : : uint32_t rix_flow; /* Built flow for copy. */
687 : : uint32_t mark_id;
688 : : };
689 : :
690 : : /* Table tunnel parameter. */
691 : : struct mlx5_flow_tbl_tunnel_prm {
692 : : const struct mlx5_flow_tunnel *tunnel;
693 : : uint32_t group_id;
694 : : bool external;
695 : : };
696 : :
697 : : /* Table data structure of the hash organization. */
698 : : struct mlx5_flow_tbl_data_entry {
699 : : struct mlx5_list_entry entry;
700 : : /**< hash list entry, 64-bits key inside. */
701 : : struct mlx5_flow_tbl_resource tbl;
702 : : /**< flow table resource. */
703 : : struct mlx5_list *matchers;
704 : : /**< matchers' header associated with the flow table. */
705 : : struct mlx5_flow_dv_jump_tbl_resource jump;
706 : : /**< jump resource, at most one for each table created. */
707 : : uint32_t idx; /**< index for the indexed mempool. */
708 : : /**< tunnel offload */
709 : : const struct mlx5_flow_tunnel *tunnel;
710 : : uint32_t group_id;
711 : : uint32_t external:1;
712 : : uint32_t tunnel_offload:1; /* Tunnel offload table or not. */
713 : : uint32_t is_egress:1; /**< Egress table. */
714 : : uint32_t is_transfer:1; /**< Transfer table. */
715 : : uint32_t dummy:1; /**< DR table. */
716 : : uint32_t id:22; /**< Table ID. */
717 : : uint32_t reserve:5; /**< Reserved to future using. */
718 : : uint32_t level; /**< Table level. */
719 : : };
720 : :
721 : : /* Sub rdma-core actions list. */
722 : : struct mlx5_flow_sub_actions_list {
723 : : uint32_t actions_num; /**< Number of sample actions. */
724 : : uint64_t action_flags;
725 : : void *dr_queue_action;
726 : : void *dr_tag_action;
727 : : void *dr_cnt_action;
728 : : void *dr_port_id_action;
729 : : void *dr_encap_action;
730 : : void *dr_jump_action;
731 : : };
732 : :
733 : : /* Sample sub-actions resource list. */
734 : : struct mlx5_flow_sub_actions_idx {
735 : : uint32_t rix_hrxq; /**< Hash Rx queue object index. */
736 : : uint32_t rix_tag; /**< Index to the tag action. */
737 : : uint32_t rix_port_id_action; /**< Index to port ID action resource. */
738 : : uint32_t rix_encap_decap; /**< Index to encap/decap resource. */
739 : : uint32_t rix_jump; /**< Index to the jump action resource. */
740 : : };
741 : :
742 : : /* Sample action resource structure. */
743 : : struct mlx5_flow_dv_sample_resource {
744 : : struct mlx5_list_entry entry; /**< Cache entry. */
745 : : union {
746 : : void *verbs_action; /**< Verbs sample action object. */
747 : : void **sub_actions; /**< Sample sub-action array. */
748 : : };
749 : : struct rte_eth_dev *dev; /**< Device registers the action. */
750 : : uint32_t idx; /** Sample object index. */
751 : : uint8_t ft_type; /** Flow Table Type */
752 : : uint32_t ft_id; /** Flow Table Level */
753 : : uint32_t ratio; /** Sample Ratio */
754 : : uint64_t set_action; /** Restore reg_c0 value */
755 : : void *normal_path_tbl; /** Flow Table pointer */
756 : : struct mlx5_flow_sub_actions_idx sample_idx;
757 : : /**< Action index resources. */
758 : : struct mlx5_flow_sub_actions_list sample_act;
759 : : /**< Action resources. */
760 : : };
761 : :
762 : : #define MLX5_MAX_DEST_NUM 2
763 : :
764 : : /* Destination array action resource structure. */
765 : : struct mlx5_flow_dv_dest_array_resource {
766 : : struct mlx5_list_entry entry; /**< Cache entry. */
767 : : uint32_t idx; /** Destination array action object index. */
768 : : uint8_t ft_type; /** Flow Table Type */
769 : : uint8_t num_of_dest; /**< Number of destination actions. */
770 : : struct rte_eth_dev *dev; /**< Device registers the action. */
771 : : void *action; /**< Pointer to the rdma core action. */
772 : : struct mlx5_flow_sub_actions_idx sample_idx[MLX5_MAX_DEST_NUM];
773 : : /**< Action index resources. */
774 : : struct mlx5_flow_sub_actions_list sample_act[MLX5_MAX_DEST_NUM];
775 : : /**< Action resources. */
776 : : };
777 : :
778 : : /* PMD flow priority for tunnel */
779 : : #define MLX5_TUNNEL_PRIO_GET(rss_desc) \
780 : : ((rss_desc)->level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4)
781 : :
782 : :
783 : : /** Device flow handle structure for DV mode only. */
784 : : struct mlx5_flow_handle_dv {
785 : : /* Flow DV api: */
786 : : struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
787 : : struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
788 : : /**< Pointer to modify header resource in cache. */
789 : : uint32_t rix_encap_decap;
790 : : /**< Index to encap/decap resource in cache. */
791 : : uint32_t rix_push_vlan;
792 : : /**< Index to push VLAN action resource in cache. */
793 : : uint32_t rix_tag;
794 : : /**< Index to the tag action. */
795 : : uint32_t rix_sample;
796 : : /**< Index to sample action resource in cache. */
797 : : uint32_t rix_dest_array;
798 : : /**< Index to destination array resource in cache. */
799 : : } __rte_packed;
800 : :
801 : : /** Device flow handle structure: used both for creating & destroying. */
802 : : struct mlx5_flow_handle {
803 : : SILIST_ENTRY(uint32_t)next;
804 : : struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
805 : : /**< Index to next device flow handle. */
806 : : uint64_t layers;
807 : : /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */
808 : : void *drv_flow; /**< pointer to driver flow object. */
809 : : uint32_t split_flow_id:27; /**< Sub flow unique match flow id. */
810 : : uint32_t is_meter_flow_id:1; /**< Indicate if flow_id is for meter. */
811 : : uint32_t fate_action:4; /**< Fate action type. */
812 : : union {
813 : : uint32_t rix_hrxq; /**< Hash Rx queue object index. */
814 : : uint32_t rix_jump; /**< Index to the jump action resource. */
815 : : uint32_t rix_port_id_action;
816 : : /**< Index to port ID action resource. */
817 : : uint32_t rix_fate;
818 : : /**< Generic value indicates the fate action. */
819 : : uint32_t rix_default_fate;
820 : : /**< Indicates default miss fate action. */
821 : : uint32_t rix_srss;
822 : : /**< Indicates shared RSS fate action. */
823 : : };
824 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
825 : : struct mlx5_flow_handle_dv dvh;
826 : : #endif
827 : : uint8_t flex_item; /**< referenced Flex Item bitmask. */
828 : : } __rte_packed;
829 : :
830 : : /*
831 : : * Size for Verbs device flow handle structure only. Do not use the DV only
832 : : * structure in Verbs. No DV flows attributes will be accessed.
833 : : * Macro offsetof() could also be used here.
834 : : */
835 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
836 : : #define MLX5_FLOW_HANDLE_VERBS_SIZE \
837 : : (sizeof(struct mlx5_flow_handle) - sizeof(struct mlx5_flow_handle_dv))
838 : : #else
839 : : #define MLX5_FLOW_HANDLE_VERBS_SIZE (sizeof(struct mlx5_flow_handle))
840 : : #endif
841 : :
842 : : /** Device flow structure only for DV flow creation. */
843 : : struct mlx5_flow_dv_workspace {
844 : : uint32_t group; /**< The group index. */
845 : : uint32_t table_id; /**< Flow table identifier. */
846 : : uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
847 : : int actions_n; /**< number of actions. */
848 : : void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; /**< Action list. */
849 : : struct mlx5_flow_dv_encap_decap_resource *encap_decap;
850 : : /**< Pointer to encap/decap resource in cache. */
851 : : struct mlx5_flow_dv_push_vlan_action_resource *push_vlan_res;
852 : : /**< Pointer to push VLAN action resource in cache. */
853 : : struct mlx5_flow_dv_tag_resource *tag_resource;
854 : : /**< pointer to the tag action. */
855 : : struct mlx5_flow_dv_port_id_action_resource *port_id_action;
856 : : /**< Pointer to port ID action resource. */
857 : : struct mlx5_flow_dv_jump_tbl_resource *jump;
858 : : /**< Pointer to the jump action resource. */
859 : : struct mlx5_flow_dv_match_params value;
860 : : /**< Holds the value that the packet is compared to. */
861 : : struct mlx5_flow_dv_sample_resource *sample_res;
862 : : /**< Pointer to the sample action resource. */
863 : : struct mlx5_flow_dv_dest_array_resource *dest_array_res;
864 : : /**< Pointer to the destination array resource. */
865 : : };
866 : :
867 : : #ifdef HAVE_INFINIBAND_VERBS_H
868 : : /*
869 : : * Maximal Verbs flow specifications & actions size.
870 : : * Some elements are mutually exclusive, but enough space should be allocated.
871 : : * Tunnel cases: 1. Max 2 Ethernet + IP(v6 len > v4 len) + TCP/UDP headers.
872 : : * 2. One tunnel header (exception: GRE + MPLS),
873 : : * SPEC length: GRE == tunnel.
874 : : * Actions: 1. 1 Mark OR Flag.
875 : : * 2. 1 Drop (if any).
876 : : * 3. No limitation for counters, but it makes no sense to support too
877 : : * many counters in a single device flow.
878 : : */
879 : : #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
880 : : #define MLX5_VERBS_MAX_SPEC_SIZE \
881 : : ( \
882 : : (2 * (sizeof(struct ibv_flow_spec_eth) + \
883 : : sizeof(struct ibv_flow_spec_ipv6) + \
884 : : sizeof(struct ibv_flow_spec_tcp_udp)) + \
885 : : sizeof(struct ibv_flow_spec_gre) + \
886 : : sizeof(struct ibv_flow_spec_mpls)) \
887 : : )
888 : : #else
889 : : #define MLX5_VERBS_MAX_SPEC_SIZE \
890 : : ( \
891 : : (2 * (sizeof(struct ibv_flow_spec_eth) + \
892 : : sizeof(struct ibv_flow_spec_ipv6) + \
893 : : sizeof(struct ibv_flow_spec_tcp_udp)) + \
894 : : sizeof(struct ibv_flow_spec_tunnel)) \
895 : : )
896 : : #endif
897 : :
898 : : #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \
899 : : defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
900 : : #define MLX5_VERBS_MAX_ACT_SIZE \
901 : : ( \
902 : : sizeof(struct ibv_flow_spec_action_tag) + \
903 : : sizeof(struct ibv_flow_spec_action_drop) + \
904 : : sizeof(struct ibv_flow_spec_counter_action) * 4 \
905 : : )
906 : : #else
907 : : #define MLX5_VERBS_MAX_ACT_SIZE \
908 : : ( \
909 : : sizeof(struct ibv_flow_spec_action_tag) + \
910 : : sizeof(struct ibv_flow_spec_action_drop) \
911 : : )
912 : : #endif
913 : :
914 : : #define MLX5_VERBS_MAX_SPEC_ACT_SIZE \
915 : : (MLX5_VERBS_MAX_SPEC_SIZE + MLX5_VERBS_MAX_ACT_SIZE)
916 : :
917 : : /** Device flow structure only for Verbs flow creation. */
918 : : struct mlx5_flow_verbs_workspace {
919 : : unsigned int size; /**< Size of the attribute. */
920 : : struct ibv_flow_attr attr; /**< Verbs flow attribute buffer. */
921 : : uint8_t specs[MLX5_VERBS_MAX_SPEC_ACT_SIZE];
922 : : /**< Specifications & actions buffer of verbs flow. */
923 : : };
924 : : #endif /* HAVE_INFINIBAND_VERBS_H */
925 : :
926 : : #define MLX5_SCALE_FLOW_GROUP_BIT 0
927 : : #define MLX5_SCALE_JUMP_FLOW_GROUP_BIT 1
928 : :
929 : : /** Maximal number of device sub-flows supported. */
930 : : #define MLX5_NUM_MAX_DEV_FLOWS 32
931 : :
932 : : /**
933 : : * tunnel offload rules type
934 : : */
935 : : enum mlx5_tof_rule_type {
936 : : MLX5_TUNNEL_OFFLOAD_NONE = 0,
937 : : MLX5_TUNNEL_OFFLOAD_SET_RULE,
938 : : MLX5_TUNNEL_OFFLOAD_MATCH_RULE,
939 : : MLX5_TUNNEL_OFFLOAD_MISS_RULE,
940 : : };
941 : :
942 : : /** Device flow structure. */
943 : : __extension__
944 : : struct mlx5_flow {
945 : : struct rte_flow *flow; /**< Pointer to the main flow. */
946 : : uint32_t flow_idx; /**< The memory pool index to the main flow. */
947 : : uint64_t hash_fields; /**< Hash Rx queue hash fields. */
948 : : uint64_t act_flags;
949 : : /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
950 : : bool external; /**< true if the flow is created external to PMD. */
951 : : uint8_t ingress:1; /**< 1 if the flow is ingress. */
952 : : uint8_t skip_scale:2;
953 : : uint8_t symmetric_hash_function:1;
954 : : /**
955 : : * Each Bit be set to 1 if Skip the scale the flow group with factor.
956 : : * If bit0 be set to 1, then skip the scale the original flow group;
957 : : * If bit1 be set to 1, then skip the scale the jump flow group if
958 : : * having jump action.
959 : : * 00: Enable scale in a flow, default value.
960 : : * 01: Skip scale the flow group with factor, enable scale the group
961 : : * of jump action.
962 : : * 10: Enable scale the group with factor, skip scale the group of
963 : : * jump action.
964 : : * 11: Skip scale the table with factor both for flow group and jump
965 : : * group.
966 : : */
967 : : union {
968 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
969 : : struct mlx5_flow_dv_workspace dv;
970 : : #endif
971 : : #ifdef HAVE_INFINIBAND_VERBS_H
972 : : struct mlx5_flow_verbs_workspace verbs;
973 : : #endif
974 : : };
975 : : struct mlx5_flow_handle *handle;
976 : : uint32_t handle_idx; /* Index of the mlx5 flow handle memory. */
977 : : const struct mlx5_flow_tunnel *tunnel;
978 : : enum mlx5_tof_rule_type tof_type;
979 : : };
980 : :
981 : : /* Flow meter state. */
982 : : #define MLX5_FLOW_METER_DISABLE 0
983 : : #define MLX5_FLOW_METER_ENABLE 1
984 : :
985 : : #define MLX5_ASO_WQE_CQE_RESPONSE_DELAY 10u
986 : : #define MLX5_MTR_POLL_WQE_CQE_TIMES 100000u
987 : :
988 : : #define MLX5_CT_POLL_WQE_CQE_TIMES MLX5_MTR_POLL_WQE_CQE_TIMES
989 : :
990 : : #define MLX5_MAN_WIDTH 8
991 : : /* Legacy Meter parameter structure. */
992 : : struct mlx5_legacy_flow_meter {
993 : : struct mlx5_flow_meter_info fm;
994 : : /* Must be the first in struct. */
995 : : TAILQ_ENTRY(mlx5_legacy_flow_meter) next;
996 : : /**< Pointer to the next flow meter structure. */
997 : : uint32_t idx;
998 : : /* Index to meter object. */
999 : : };
1000 : :
1001 : : #define MLX5_MAX_TUNNELS 256
1002 : : #define MLX5_TNL_MISS_RULE_PRIORITY 3
1003 : : #define MLX5_TNL_MISS_FDB_JUMP_GRP 0x1234faac
1004 : :
1005 : : /*
1006 : : * When tunnel offload is active, all JUMP group ids are converted
1007 : : * using the same method. That conversion is applied both to tunnel and
1008 : : * regular rule types.
1009 : : * Group ids used in tunnel rules are relative to it's tunnel (!).
1010 : : * Application can create number of steer rules, using the same
1011 : : * tunnel, with different group id in each rule.
1012 : : * Each tunnel stores its groups internally in PMD tunnel object.
1013 : : * Groups used in regular rules do not belong to any tunnel and are stored
1014 : : * in tunnel hub.
1015 : : */
1016 : :
1017 : : struct mlx5_flow_tunnel {
1018 : : LIST_ENTRY(mlx5_flow_tunnel) chain;
1019 : : struct rte_flow_tunnel app_tunnel; /** app tunnel copy */
1020 : : uint32_t tunnel_id; /** unique tunnel ID */
1021 : : uint32_t refctn;
1022 : : struct rte_flow_action action;
1023 : : struct rte_flow_item item;
1024 : : struct mlx5_hlist *groups; /** tunnel groups */
1025 : : };
1026 : :
1027 : : /** PMD tunnel related context */
1028 : : struct mlx5_flow_tunnel_hub {
1029 : : /* Tunnels list
1030 : : * Access to the list MUST be MT protected
1031 : : */
1032 : : LIST_HEAD(, mlx5_flow_tunnel) tunnels;
1033 : : /* protect access to the tunnels list */
1034 : : rte_spinlock_t sl;
1035 : : struct mlx5_hlist *groups; /** non tunnel groups */
1036 : : };
1037 : :
1038 : : /* convert jump group to flow table ID in tunnel rules */
1039 : : struct tunnel_tbl_entry {
1040 : : struct mlx5_list_entry hash;
1041 : : uint32_t flow_table;
1042 : : uint32_t tunnel_id;
1043 : : uint32_t group;
1044 : : };
1045 : :
1046 : : static inline uint32_t
1047 : : tunnel_id_to_flow_tbl(uint32_t id)
1048 : : {
1049 : 0 : return id | (1u << 16);
1050 : : }
1051 : :
1052 : : static inline uint32_t
1053 : : tunnel_flow_tbl_to_id(uint32_t flow_tbl)
1054 : : {
1055 : 0 : return flow_tbl & ~(1u << 16);
1056 : : }
1057 : :
1058 : : union tunnel_tbl_key {
1059 : : uint64_t val;
1060 : : struct {
1061 : : uint32_t tunnel_id;
1062 : : uint32_t group;
1063 : : };
1064 : : };
1065 : :
1066 : : static inline struct mlx5_flow_tunnel_hub *
1067 : : mlx5_tunnel_hub(struct rte_eth_dev *dev)
1068 : : {
1069 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
1070 [ # # ]: 0 : return priv->sh->tunnel_hub;
1071 : : }
1072 : :
1073 : : static inline bool
1074 : : is_tunnel_offload_active(const struct rte_eth_dev *dev)
1075 : : {
1076 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1077 : 0 : const struct mlx5_priv *priv = dev->data->dev_private;
1078 [ # # # # : 0 : return !!priv->sh->config.dv_miss_info;
# # # # ]
1079 : : #else
1080 : : RTE_SET_USED(dev);
1081 : : return false;
1082 : : #endif
1083 : : }
1084 : :
1085 : : static inline bool
1086 : : is_flow_tunnel_match_rule(enum mlx5_tof_rule_type tof_rule_type)
1087 : : {
1088 : : return tof_rule_type == MLX5_TUNNEL_OFFLOAD_MATCH_RULE;
1089 : : }
1090 : :
1091 : : static inline bool
1092 : : is_flow_tunnel_steer_rule(enum mlx5_tof_rule_type tof_rule_type)
1093 : : {
1094 : : return tof_rule_type == MLX5_TUNNEL_OFFLOAD_SET_RULE;
1095 : : }
1096 : :
1097 : : static inline const struct mlx5_flow_tunnel *
1098 : : flow_actions_to_tunnel(const struct rte_flow_action actions[])
1099 : : {
1100 : : return actions[0].conf;
1101 : : }
1102 : :
1103 : : static inline const struct mlx5_flow_tunnel *
1104 : : flow_items_to_tunnel(const struct rte_flow_item items[])
1105 : : {
1106 : 0 : return items[0].spec;
1107 : : }
1108 : :
1109 : : /**
1110 : : * Gets the tag array given for RTE_FLOW_FIELD_TAG type.
1111 : : *
1112 : : * In old API the value was provided in "level" field, but in new API
1113 : : * it is provided in "tag_array" field. Since encapsulation level is not
1114 : : * relevant for metadata, the tag array can be still provided in "level"
1115 : : * for backwards compatibility.
1116 : : *
1117 : : * @param[in] data
1118 : : * Pointer to tag modify data structure.
1119 : : *
1120 : : * @return
1121 : : * Tag array index.
1122 : : */
1123 : : static inline uint8_t
1124 : 0 : flow_tag_index_get(const struct rte_flow_action_modify_data *data)
1125 : : {
1126 [ # # # # ]: 0 : return data->tag_index ? data->tag_index : data->level;
1127 : : }
1128 : :
1129 : : /**
1130 : : * Fetch 1, 2, 3 or 4 byte field from the byte array
1131 : : * and return as unsigned integer in host-endian format.
1132 : : *
1133 : : * @param[in] data
1134 : : * Pointer to data array.
1135 : : * @param[in] size
1136 : : * Size of field to extract.
1137 : : *
1138 : : * @return
1139 : : * converted field in host endian format.
1140 : : */
1141 : : static inline uint32_t
1142 : 0 : flow_dv_fetch_field(const uint8_t *data, uint32_t size)
1143 : : {
1144 : : uint32_t ret;
1145 : :
1146 [ # # # # : 0 : switch (size) {
# ]
1147 : 0 : case 1:
1148 : 0 : ret = *data;
1149 : 0 : break;
1150 : 0 : case 2:
1151 [ # # ]: 0 : ret = rte_be_to_cpu_16(*(const unaligned_uint16_t *)data);
1152 : : break;
1153 : 0 : case 3:
1154 [ # # ]: 0 : ret = rte_be_to_cpu_16(*(const unaligned_uint16_t *)data);
1155 : 0 : ret = (ret << 8) | *(data + sizeof(uint16_t));
1156 : 0 : break;
1157 : 0 : case 4:
1158 [ # # ]: 0 : ret = rte_be_to_cpu_32(*(const unaligned_uint32_t *)data);
1159 : : break;
1160 : : default:
1161 : : MLX5_ASSERT(false);
1162 : : ret = 0;
1163 : : break;
1164 : : }
1165 : 0 : return ret;
1166 : : }
1167 : :
1168 : : static inline bool
1169 : : flow_modify_field_support_tag_array(enum rte_flow_field_id field)
1170 : : {
1171 [ # # # # ]: 0 : switch ((int)field) {
1172 : : case RTE_FLOW_FIELD_TAG:
1173 : : case RTE_FLOW_FIELD_MPLS:
1174 : : case MLX5_RTE_FLOW_FIELD_META_REG:
1175 : : return true;
1176 : : default:
1177 : : break;
1178 : : }
1179 : : return false;
1180 : : }
1181 : :
1182 : : struct field_modify_info {
1183 : : uint32_t size; /* Size of field in protocol header, in bytes. */
1184 : : uint32_t offset; /* Offset of field in protocol header, in bytes. */
1185 : : enum mlx5_modification_field id;
1186 : : uint32_t shift;
1187 : : uint8_t is_flex; /* Temporary indicator for flex item modify filed WA. */
1188 : : };
1189 : :
1190 : : /* HW steering flow attributes. */
1191 : : struct mlx5_flow_attr {
1192 : : uint32_t port_id; /* Port index. */
1193 : : uint32_t group; /* Flow group. */
1194 : : uint32_t priority; /* Original Priority. */
1195 : : /* rss level, used by priority adjustment. */
1196 : : uint32_t rss_level;
1197 : : /* Action flags, used by priority adjustment. */
1198 : : uint32_t act_flags;
1199 : : uint32_t tbl_type; /* Flow table type. */
1200 : : };
1201 : :
1202 : : /* Flow structure. */
1203 : : struct rte_flow {
1204 : : uint32_t dev_handles;
1205 : : /**< Device flow handles that are part of the flow. */
1206 : : uint32_t type:2;
1207 : : uint32_t drv_type:2; /**< Driver type. */
1208 : : uint32_t tunnel:1;
1209 : : uint32_t meter:24; /**< Holds flow meter id. */
1210 : : uint32_t indirect_type:2; /**< Indirect action type. */
1211 : : uint32_t rix_mreg_copy;
1212 : : /**< Index to metadata register copy table resource. */
1213 : : uint32_t counter; /**< Holds flow counter. */
1214 : : uint32_t tunnel_id; /**< Tunnel id */
1215 : : union {
1216 : : uint32_t age; /**< Holds ASO age bit index. */
1217 : : uint32_t ct; /**< Holds ASO CT index. */
1218 : : };
1219 : : uint32_t geneve_tlv_option; /**< Holds Geneve TLV option id. > */
1220 : : } __rte_packed;
1221 : :
1222 : : /*
1223 : : * HWS COUNTER ID's layout
1224 : : * 3 2 1 0
1225 : : * 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
1226 : : * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1227 : : * | T | | D | |
1228 : : * ~ Y | | C | IDX ~
1229 : : * | P | | S | |
1230 : : * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1231 : : *
1232 : : * Bit 31:29 = TYPE = MLX5_INDIRECT_ACTION_TYPE_COUNT = b'10
1233 : : * Bit 25:24 = DCS index
1234 : : * Bit 23:00 = IDX in this counter belonged DCS bulk.
1235 : : */
1236 : : typedef uint32_t cnt_id_t;
1237 : :
1238 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
1239 : :
1240 : : #ifdef PEDANTIC
1241 : : #pragma GCC diagnostic ignored "-Wpedantic"
1242 : : #endif
1243 : :
1244 : : /* HWS flow struct. */
1245 : : struct rte_flow_hw {
1246 : : uint32_t idx; /* Flow index from indexed pool. */
1247 : : uint32_t res_idx; /* Resource index from indexed pool. */
1248 : : uint32_t fate_type; /* Fate action type. */
1249 : : union {
1250 : : /* Jump action. */
1251 : : struct mlx5_hw_jump_action *jump;
1252 : : struct mlx5_hrxq *hrxq; /* TIR action. */
1253 : : };
1254 : : struct rte_flow_template_table *table; /* The table flow allcated from. */
1255 : : uint8_t mt_idx;
1256 : : uint32_t age_idx;
1257 : : cnt_id_t cnt_id;
1258 : : uint32_t mtr_id;
1259 : : uint32_t rule_idx;
1260 : : uint8_t rule[0]; /* HWS layer data struct. */
1261 : : } __rte_packed;
1262 : :
1263 : : #ifdef PEDANTIC
1264 : : #pragma GCC diagnostic error "-Wpedantic"
1265 : : #endif
1266 : :
1267 : : struct mlx5_action_construct_data;
1268 : : typedef int
1269 : : (*indirect_list_callback_t)(struct rte_eth_dev *,
1270 : : const struct mlx5_action_construct_data *,
1271 : : const struct rte_flow_action *,
1272 : : struct mlx5dr_rule_action *);
1273 : :
1274 : : #define MLX5_MHDR_MAX_CMD ((MLX5_MAX_MODIFY_NUM) * 2 + 1)
1275 : :
1276 : : /* rte flow action translate to DR action struct. */
1277 : : struct mlx5_action_construct_data {
1278 : : LIST_ENTRY(mlx5_action_construct_data) next;
1279 : : /* Ensure the action types are matched. */
1280 : : int type;
1281 : : uint32_t idx; /* Data index. */
1282 : : uint16_t action_src; /* rte_flow_action src offset. */
1283 : : uint16_t action_dst; /* mlx5dr_rule_action dst offset. */
1284 : : indirect_list_callback_t indirect_list_cb;
1285 : : union {
1286 : : struct {
1287 : : /* encap data len. */
1288 : : uint16_t len;
1289 : : } encap;
1290 : : struct {
1291 : : /* Modify header action offset in pattern. */
1292 : : uint16_t mhdr_cmds_off;
1293 : : /* Offset in pattern after modify header actions. */
1294 : : uint16_t mhdr_cmds_end;
1295 : : /*
1296 : : * True if this action is masked and does not need to
1297 : : * be generated.
1298 : : */
1299 : : bool shared;
1300 : : /*
1301 : : * Modified field definitions in dst field (SET, ADD)
1302 : : * or src field (COPY).
1303 : : */
1304 : : struct field_modify_info field[MLX5_ACT_MAX_MOD_FIELDS];
1305 : : /* Modified field definitions in dst field (COPY). */
1306 : : struct field_modify_info dcopy[MLX5_ACT_MAX_MOD_FIELDS];
1307 : : /*
1308 : : * Masks applied to field values to generate
1309 : : * PRM actions.
1310 : : */
1311 : : uint32_t mask[MLX5_ACT_MAX_MOD_FIELDS];
1312 : : } modify_header;
1313 : : struct {
1314 : : bool symmetric_hash_function; /* Symmetric RSS hash */
1315 : : uint64_t types; /* RSS hash types. */
1316 : : uint32_t level; /* RSS level. */
1317 : : uint32_t idx; /* Shared action index. */
1318 : : } shared_rss;
1319 : : struct {
1320 : : cnt_id_t id;
1321 : : } shared_counter;
1322 : : struct {
1323 : : /* IPv6 extension push data len. */
1324 : : uint16_t len;
1325 : : } ipv6_ext;
1326 : : struct {
1327 : : uint32_t id;
1328 : : uint32_t conf_masked:1;
1329 : : } shared_meter;
1330 : : };
1331 : : };
1332 : :
1333 : : /* Flow item template struct. */
1334 : : struct rte_flow_pattern_template {
1335 : : LIST_ENTRY(rte_flow_pattern_template) next;
1336 : : /* Template attributes. */
1337 : : struct rte_flow_pattern_template_attr attr;
1338 : : struct mlx5dr_match_template *mt; /* mlx5 match template. */
1339 : : uint64_t item_flags; /* Item layer flags. */
1340 : : uint64_t orig_item_nb; /* Number of pattern items provided by the user (with END item). */
1341 : : uint32_t refcnt; /* Reference counter. */
1342 : : /*
1343 : : * If true, then rule pattern should be prepended with
1344 : : * represented_port pattern item.
1345 : : */
1346 : : bool implicit_port;
1347 : : /*
1348 : : * If true, then rule pattern should be prepended with
1349 : : * tag pattern item for representor matching.
1350 : : */
1351 : : bool implicit_tag;
1352 : : uint8_t flex_item; /* flex item index. */
1353 : : };
1354 : :
1355 : : /* Flow action template struct. */
1356 : : struct rte_flow_actions_template {
1357 : : LIST_ENTRY(rte_flow_actions_template) next;
1358 : : /* Template attributes. */
1359 : : struct rte_flow_actions_template_attr attr;
1360 : : struct rte_flow_action *actions; /* Cached flow actions. */
1361 : : struct rte_flow_action *masks; /* Cached action masks.*/
1362 : : struct mlx5dr_action_template *tmpl; /* mlx5dr action template. */
1363 : : uint64_t action_flags; /* Bit-map of all valid action in template. */
1364 : : uint16_t dr_actions_num; /* Amount of DR rules actions. */
1365 : : uint16_t actions_num; /* Amount of flow actions */
1366 : : uint16_t *dr_off; /* DR action offset for given rte action offset. */
1367 : : uint16_t *src_off; /* RTE action displacement from app. template */
1368 : : uint16_t reformat_off; /* Offset of DR reformat action. */
1369 : : uint16_t mhdr_off; /* Offset of DR modify header action. */
1370 : : uint16_t recom_off; /* Offset of DR IPv6 routing push remove action. */
1371 : : uint32_t refcnt; /* Reference counter. */
1372 : : uint8_t flex_item; /* flex item index. */
1373 : : };
1374 : :
1375 : : /* Jump action struct. */
1376 : : struct mlx5_hw_jump_action {
1377 : : /* Action jump from root. */
1378 : : struct mlx5dr_action *root_action;
1379 : : /* HW steering jump action. */
1380 : : struct mlx5dr_action *hws_action;
1381 : : };
1382 : :
1383 : : /* Encap decap action struct. */
1384 : : struct mlx5_hw_encap_decap_action {
1385 : : struct mlx5_indirect_list indirect;
1386 : : enum mlx5dr_action_type action_type;
1387 : : struct mlx5dr_action *action; /* Action object. */
1388 : : /* Is header_reformat action shared across flows in table. */
1389 : : uint32_t shared:1;
1390 : : uint32_t multi_pattern:1;
1391 : : volatile uint32_t *multi_pattern_refcnt;
1392 : : size_t data_size; /* Action metadata size. */
1393 : : uint8_t data[]; /* Action data. */
1394 : : };
1395 : :
1396 : : /* Push remove action struct. */
1397 : : struct mlx5_hw_push_remove_action {
1398 : : struct mlx5dr_action *action; /* Action object. */
1399 : : /* Is push_remove action shared across flows in table. */
1400 : : uint8_t shared;
1401 : : size_t data_size; /* Action metadata size. */
1402 : : uint8_t data[]; /* Action data. */
1403 : : };
1404 : :
1405 : : /* Modify field action struct. */
1406 : : struct mlx5_hw_modify_header_action {
1407 : : /* Reference to DR action */
1408 : : struct mlx5dr_action *action;
1409 : : /* Modify header action position in action rule table. */
1410 : : uint16_t pos;
1411 : : /* Is MODIFY_HEADER action shared across flows in table. */
1412 : : uint32_t shared:1;
1413 : : uint32_t multi_pattern:1;
1414 : : volatile uint32_t *multi_pattern_refcnt;
1415 : : /* Amount of modification commands stored in the precompiled buffer. */
1416 : : uint32_t mhdr_cmds_num;
1417 : : /* Precompiled modification commands. */
1418 : : struct mlx5_modification_cmd mhdr_cmds[MLX5_MHDR_MAX_CMD];
1419 : : };
1420 : :
1421 : : /* The maximum actions support in the flow. */
1422 : : #define MLX5_HW_MAX_ACTS 16
1423 : :
1424 : : /* DR action set struct. */
1425 : : struct mlx5_hw_actions {
1426 : : /* Dynamic action list. */
1427 : : LIST_HEAD(act_list, mlx5_action_construct_data) act_list;
1428 : : struct mlx5_hw_jump_action *jump; /* Jump action. */
1429 : : struct mlx5_hrxq *tir; /* TIR action. */
1430 : : struct mlx5_hw_modify_header_action *mhdr; /* Modify header action. */
1431 : : /* Encap/Decap action. */
1432 : : struct mlx5_hw_encap_decap_action *encap_decap;
1433 : : uint16_t encap_decap_pos; /* Encap/Decap action position. */
1434 : : /* Push/remove action. */
1435 : : struct mlx5_hw_push_remove_action *push_remove;
1436 : : uint16_t push_remove_pos; /* Push/remove action position. */
1437 : : uint32_t mark:1; /* Indicate the mark action. */
1438 : : cnt_id_t cnt_id; /* Counter id. */
1439 : : uint32_t mtr_id; /* Meter id. */
1440 : : /* Translated DR action array from action template. */
1441 : : struct mlx5dr_rule_action rule_acts[MLX5_HW_MAX_ACTS];
1442 : : };
1443 : :
1444 : : /* mlx5 action template struct. */
1445 : : struct mlx5_hw_action_template {
1446 : : /* Action template pointer. */
1447 : : struct rte_flow_actions_template *action_template;
1448 : : struct mlx5_hw_actions acts; /* Template actions. */
1449 : : };
1450 : :
1451 : : /* mlx5 flow group struct. */
1452 : : struct mlx5_flow_group {
1453 : : struct mlx5_list_entry entry;
1454 : : LIST_ENTRY(mlx5_flow_group) next;
1455 : : struct rte_eth_dev *dev; /* Reference to corresponding device. */
1456 : : struct mlx5dr_table *tbl; /* HWS table object. */
1457 : : struct mlx5_hw_jump_action jump; /* Jump action. */
1458 : : struct mlx5_flow_group *miss_group; /* Group pointed to by miss action. */
1459 : : enum mlx5dr_table_type type; /* Table type. */
1460 : : uint32_t group_id; /* Group id. */
1461 : : uint32_t idx; /* Group memory index. */
1462 : : };
1463 : :
1464 : :
1465 : : #define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 2
1466 : : #define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32
1467 : :
1468 : : struct mlx5_flow_template_table_cfg {
1469 : : struct rte_flow_template_table_attr attr; /* Table attributes passed through flow API. */
1470 : : bool external; /* True if created by flow API, false if table is internal to PMD. */
1471 : : };
1472 : :
1473 : : struct rte_flow_template_table {
1474 : : LIST_ENTRY(rte_flow_template_table) next;
1475 : : struct mlx5_flow_group *grp; /* The group rte_flow_template_table uses. */
1476 : : struct mlx5dr_matcher *matcher; /* Template matcher. */
1477 : : /* Item templates bind to the table. */
1478 : : struct rte_flow_pattern_template *its[MLX5_HW_TBL_MAX_ITEM_TEMPLATE];
1479 : : /* Action templates bind to the table. */
1480 : : struct mlx5_hw_action_template ats[MLX5_HW_TBL_MAX_ACTION_TEMPLATE];
1481 : : struct mlx5_indexed_pool *flow; /* The table's flow ipool. */
1482 : : struct mlx5_indexed_pool *resource; /* The table's resource ipool. */
1483 : : struct mlx5_flow_template_table_cfg cfg;
1484 : : uint32_t type; /* Flow table type RX/TX/FDB. */
1485 : : uint8_t nb_item_templates; /* Item template number. */
1486 : : uint8_t nb_action_templates; /* Action template number. */
1487 : : uint32_t refcnt; /* Table reference counter. */
1488 : : };
1489 : :
1490 : : #endif
1491 : :
1492 : : /*
1493 : : * Define list of valid combinations of RX Hash fields
1494 : : * (see enum ibv_rx_hash_fields).
1495 : : */
1496 : : #define MLX5_RSS_HASH_IPV4 (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
1497 : : #define MLX5_RSS_HASH_IPV4_TCP \
1498 : : (MLX5_RSS_HASH_IPV4 | \
1499 : : IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP)
1500 : : #define MLX5_RSS_HASH_IPV4_UDP \
1501 : : (MLX5_RSS_HASH_IPV4 | \
1502 : : IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP)
1503 : : #define MLX5_RSS_HASH_IPV6 (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
1504 : : #define MLX5_RSS_HASH_IPV6_TCP \
1505 : : (MLX5_RSS_HASH_IPV6 | \
1506 : : IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_DST_PORT_TCP)
1507 : : #define MLX5_RSS_HASH_IPV6_UDP \
1508 : : (MLX5_RSS_HASH_IPV6 | \
1509 : : IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_DST_PORT_UDP)
1510 : : #define MLX5_RSS_HASH_IPV4_SRC_ONLY IBV_RX_HASH_SRC_IPV4
1511 : : #define MLX5_RSS_HASH_IPV4_DST_ONLY IBV_RX_HASH_DST_IPV4
1512 : : #define MLX5_RSS_HASH_IPV6_SRC_ONLY IBV_RX_HASH_SRC_IPV6
1513 : : #define MLX5_RSS_HASH_IPV6_DST_ONLY IBV_RX_HASH_DST_IPV6
1514 : : #define MLX5_RSS_HASH_IPV4_UDP_SRC_ONLY \
1515 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_SRC_PORT_UDP)
1516 : : #define MLX5_RSS_HASH_IPV4_UDP_DST_ONLY \
1517 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_DST_PORT_UDP)
1518 : : #define MLX5_RSS_HASH_IPV6_UDP_SRC_ONLY \
1519 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_SRC_PORT_UDP)
1520 : : #define MLX5_RSS_HASH_IPV6_UDP_DST_ONLY \
1521 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_DST_PORT_UDP)
1522 : : #define MLX5_RSS_HASH_IPV4_TCP_SRC_ONLY \
1523 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_SRC_PORT_TCP)
1524 : : #define MLX5_RSS_HASH_IPV4_TCP_DST_ONLY \
1525 : : (MLX5_RSS_HASH_IPV4 | IBV_RX_HASH_DST_PORT_TCP)
1526 : : #define MLX5_RSS_HASH_IPV6_TCP_SRC_ONLY \
1527 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_SRC_PORT_TCP)
1528 : : #define MLX5_RSS_HASH_IPV6_TCP_DST_ONLY \
1529 : : (MLX5_RSS_HASH_IPV6 | IBV_RX_HASH_DST_PORT_TCP)
1530 : :
1531 : : #ifndef HAVE_IBV_RX_HASH_IPSEC_SPI
1532 : : #define IBV_RX_HASH_IPSEC_SPI (1U << 8)
1533 : : #endif
1534 : :
1535 : : #define MLX5_RSS_HASH_ESP_SPI IBV_RX_HASH_IPSEC_SPI
1536 : : #define MLX5_RSS_HASH_IPV4_ESP (MLX5_RSS_HASH_IPV4 | \
1537 : : MLX5_RSS_HASH_ESP_SPI)
1538 : : #define MLX5_RSS_HASH_IPV6_ESP (MLX5_RSS_HASH_IPV6 | \
1539 : : MLX5_RSS_HASH_ESP_SPI)
1540 : : #define MLX5_RSS_HASH_NONE 0ULL
1541 : :
1542 : : #define MLX5_RSS_IS_SYMM(func) \
1543 : : (((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ) || \
1544 : : ((func) == RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ_SORT))
1545 : :
1546 : : /* extract next protocol type from Ethernet & VLAN headers */
1547 : : #define MLX5_ETHER_TYPE_FROM_HEADER(_s, _m, _itm, _prt) do { \
1548 : : (_prt) = ((const struct _s *)(_itm)->mask)->_m; \
1549 : : (_prt) &= ((const struct _s *)(_itm)->spec)->_m; \
1550 : : (_prt) = rte_be_to_cpu_16((_prt)); \
1551 : : } while (0)
1552 : :
1553 : : /* array of valid combinations of RX Hash fields for RSS */
1554 : : static const uint64_t mlx5_rss_hash_fields[] = {
1555 : : MLX5_RSS_HASH_IPV4,
1556 : : MLX5_RSS_HASH_IPV4_TCP,
1557 : : MLX5_RSS_HASH_IPV4_UDP,
1558 : : MLX5_RSS_HASH_IPV4_ESP,
1559 : : MLX5_RSS_HASH_IPV6,
1560 : : MLX5_RSS_HASH_IPV6_TCP,
1561 : : MLX5_RSS_HASH_IPV6_UDP,
1562 : : MLX5_RSS_HASH_IPV6_ESP,
1563 : : MLX5_RSS_HASH_ESP_SPI,
1564 : : MLX5_RSS_HASH_NONE,
1565 : : };
1566 : :
1567 : : /* Shared RSS action structure */
1568 : : struct mlx5_shared_action_rss {
1569 : : ILIST_ENTRY(uint32_t)next; /**< Index to the next RSS structure. */
1570 : : uint32_t refcnt; /**< Atomically accessed refcnt. */
1571 : : struct rte_flow_action_rss origin; /**< Original rte RSS action. */
1572 : : uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
1573 : : struct mlx5_ind_table_obj *ind_tbl;
1574 : : /**< Hash RX queues (hrxq, hrxq_tunnel fields) indirection table. */
1575 : : uint32_t hrxq[MLX5_RSS_HASH_FIELDS_LEN];
1576 : : /**< Hash RX queue indexes mapped to mlx5_rss_hash_fields */
1577 : : rte_spinlock_t action_rss_sl; /**< Shared RSS action spinlock. */
1578 : : };
1579 : :
1580 : : struct rte_flow_action_handle {
1581 : : uint32_t id;
1582 : : };
1583 : :
1584 : : /* Thread specific flow workspace intermediate data. */
1585 : : struct mlx5_flow_workspace {
1586 : : /* If creating another flow in same thread, push new as stack. */
1587 : : struct mlx5_flow_workspace *prev;
1588 : : struct mlx5_flow_workspace *next;
1589 : : struct mlx5_flow_workspace *gc;
1590 : : uint32_t inuse; /* can't create new flow with current. */
1591 : : struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS];
1592 : : struct mlx5_flow_rss_desc rss_desc;
1593 : : uint32_t flow_idx; /* Intermediate device flow index. */
1594 : : struct mlx5_flow_meter_info *fm; /* Pointer to the meter in flow. */
1595 : : struct mlx5_flow_meter_policy *policy;
1596 : : /* The meter policy used by meter in flow. */
1597 : : struct mlx5_flow_meter_policy *final_policy;
1598 : : /* The final policy when meter policy is hierarchy. */
1599 : : uint32_t skip_matcher_reg:1;
1600 : : /* Indicates if need to skip matcher register in translate. */
1601 : : uint32_t mark:1; /* Indicates if flow contains mark action. */
1602 : : uint32_t vport_meta_tag; /* Used for vport index match. */
1603 : : };
1604 : :
1605 : : /* Matcher translate type. */
1606 : : enum MLX5_SET_MATCHER {
1607 : : MLX5_SET_MATCHER_SW_V = 1 << 0,
1608 : : MLX5_SET_MATCHER_SW_M = 1 << 1,
1609 : : MLX5_SET_MATCHER_HS_V = 1 << 2,
1610 : : MLX5_SET_MATCHER_HS_M = 1 << 3,
1611 : : };
1612 : :
1613 : : #define MLX5_SET_MATCHER_SW (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_SW_M)
1614 : : #define MLX5_SET_MATCHER_HS (MLX5_SET_MATCHER_HS_V | MLX5_SET_MATCHER_HS_M)
1615 : : #define MLX5_SET_MATCHER_V (MLX5_SET_MATCHER_SW_V | MLX5_SET_MATCHER_HS_V)
1616 : : #define MLX5_SET_MATCHER_M (MLX5_SET_MATCHER_SW_M | MLX5_SET_MATCHER_HS_M)
1617 : :
1618 : : /* Flow matcher workspace intermediate data. */
1619 : : struct mlx5_dv_matcher_workspace {
1620 : : uint8_t priority; /* Flow priority. */
1621 : : uint64_t last_item; /* Last item in pattern. */
1622 : : uint64_t item_flags; /* Flow item pattern flags. */
1623 : : uint64_t action_flags; /* Flow action flags. */
1624 : : bool external; /* External flow or not. */
1625 : : uint32_t vlan_tag:12; /* Flow item VLAN tag. */
1626 : : uint8_t next_protocol; /* Tunnel next protocol */
1627 : : uint32_t geneve_tlv_option; /* Flow item Geneve TLV option. */
1628 : : uint32_t group; /* Flow group. */
1629 : : uint16_t udp_dport; /* Flow item UDP port. */
1630 : : const struct rte_flow_attr *attr; /* Flow attribute. */
1631 : : struct mlx5_flow_rss_desc *rss_desc; /* RSS descriptor. */
1632 : : const struct rte_flow_item *tunnel_item; /* Flow tunnel item. */
1633 : : const struct rte_flow_item *gre_item; /* Flow GRE item. */
1634 : : const struct rte_flow_item *integrity_items[2];
1635 : : };
1636 : :
1637 : : struct mlx5_flow_split_info {
1638 : : uint32_t external:1;
1639 : : /**< True if flow is created by request external to PMD. */
1640 : : uint32_t prefix_mark:1; /**< Prefix subflow mark flag. */
1641 : : uint32_t skip_scale:8; /**< Skip the scale the table with factor. */
1642 : : uint32_t flow_idx; /**< This memory pool index to the flow. */
1643 : : uint32_t table_id; /**< Flow table identifier. */
1644 : : uint64_t prefix_layers; /**< Prefix subflow layers. */
1645 : : };
1646 : :
1647 : : struct flow_hw_port_info {
1648 : : uint32_t regc_mask;
1649 : : uint32_t regc_value;
1650 : : uint32_t is_wire:1;
1651 : : };
1652 : :
1653 : : extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS];
1654 : :
1655 : : /*
1656 : : * Get metadata match tag and mask for given rte_eth_dev port.
1657 : : * Used in HWS rule creation.
1658 : : */
1659 : : static __rte_always_inline const struct flow_hw_port_info *
1660 : : flow_hw_conv_port_id(const uint16_t port_id)
1661 : : {
1662 : : struct flow_hw_port_info *port_info;
1663 : :
1664 [ # # ]: 0 : if (port_id >= RTE_MAX_ETHPORTS)
1665 : : return NULL;
1666 : 0 : port_info = &mlx5_flow_hw_port_infos[port_id];
1667 [ # # ]: 0 : return !!port_info->regc_mask ? port_info : NULL;
1668 : : }
1669 : :
1670 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1671 : : /*
1672 : : * Get metadata match tag and mask for the uplink port represented
1673 : : * by given IB context. Used in HWS context creation.
1674 : : */
1675 : : static __rte_always_inline const struct flow_hw_port_info *
1676 : : flow_hw_get_wire_port(struct ibv_context *ibctx)
1677 : : {
1678 : 0 : struct ibv_device *ibdev = ibctx->device;
1679 : : uint16_t port_id;
1680 : :
1681 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port_id, NULL) {
1682 : 0 : const struct mlx5_priv *priv =
1683 : 0 : rte_eth_devices[port_id].data->dev_private;
1684 : :
1685 [ # # # # ]: 0 : if (priv && priv->master) {
1686 : 0 : struct ibv_context *port_ibctx = priv->sh->cdev->ctx;
1687 : :
1688 [ # # ]: 0 : if (port_ibctx->device == ibdev)
1689 : : return flow_hw_conv_port_id(port_id);
1690 : : }
1691 : : }
1692 : : return NULL;
1693 : : }
1694 : : #endif
1695 : :
1696 : : /*
1697 : : * Convert metadata or tag to the actual register.
1698 : : * META: Can only be used to match in the FDB in this stage, fixed C_1.
1699 : : * TAG: C_x expect meter color reg and the reserved ones.
1700 : : */
1701 : : static __rte_always_inline int
1702 : : flow_hw_get_reg_id(struct rte_eth_dev *dev,
1703 : : enum rte_flow_item_type type, uint32_t id)
1704 : : {
1705 : 0 : struct mlx5_dev_ctx_shared *sh = MLX5_SH(dev);
1706 : : struct mlx5_dev_registers *reg = &sh->registers;
1707 : :
1708 : : switch (type) {
1709 : : case RTE_FLOW_ITEM_TYPE_META:
1710 : : #ifdef HAVE_MLX5_HWS_SUPPORT
1711 [ # # ]: 0 : if (sh->config.dv_esw_en &&
1712 : : sh->config.dv_xmeta_en == MLX5_XMETA_MODE_META32_HWS) {
1713 : : return REG_C_1;
1714 : : }
1715 : : #endif
1716 : : /*
1717 : : * On root table - PMD allows only egress META matching, thus
1718 : : * REG_A matching is sufficient.
1719 : : *
1720 : : * On non-root tables - REG_A corresponds to general_purpose_lookup_field,
1721 : : * which translates to REG_A in NIC TX and to REG_B in NIC RX.
1722 : : * However, current FW does not implement REG_B case right now, so
1723 : : * REG_B case should be rejected on pattern template validation.
1724 : : */
1725 : : return REG_A;
1726 : : case RTE_FLOW_ITEM_TYPE_CONNTRACK:
1727 : : case RTE_FLOW_ITEM_TYPE_METER_COLOR:
1728 [ # # ]: 0 : return reg->aso_reg;
1729 : : case RTE_FLOW_ITEM_TYPE_TAG:
1730 [ # # # # : 0 : if (id == RTE_PMD_MLX5_LINEAR_HASH_TAG_INDEX)
# # ]
1731 : : return REG_C_3;
1732 : : MLX5_ASSERT(id < MLX5_FLOW_HW_TAGS_MAX);
1733 [ # # # # : 0 : return reg->hw_avl_tags[id];
# # ]
1734 : : default:
1735 : : return REG_NON;
1736 : : }
1737 : : }
1738 : :
1739 : : static __rte_always_inline int
1740 : : flow_hw_get_reg_id_from_ctx(void *dr_ctx,
1741 : : enum rte_flow_item_type type, uint32_t id)
1742 : : {
1743 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1744 : : uint16_t port;
1745 : :
1746 [ # # # # : 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
# # # # #
# ]
1747 : : struct mlx5_priv *priv;
1748 : :
1749 : 0 : priv = rte_eth_devices[port].data->dev_private;
1750 [ # # # # : 0 : if (priv->dr_ctx == dr_ctx)
# # # # #
# ]
1751 : 0 : return flow_hw_get_reg_id(&rte_eth_devices[port],
1752 : : type, id);
1753 : : }
1754 : : #else
1755 : : RTE_SET_USED(dr_ctx);
1756 : : RTE_SET_USED(type);
1757 : : RTE_SET_USED(id);
1758 : : #endif
1759 : : return REG_NON;
1760 : : }
1761 : :
1762 : : void flow_hw_set_port_info(struct rte_eth_dev *dev);
1763 : : void flow_hw_clear_port_info(struct rte_eth_dev *dev);
1764 : : int flow_hw_create_vport_action(struct rte_eth_dev *dev);
1765 : : void flow_hw_destroy_vport_action(struct rte_eth_dev *dev);
1766 : :
1767 : : typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
1768 : : const struct rte_flow_attr *attr,
1769 : : const struct rte_flow_item items[],
1770 : : const struct rte_flow_action actions[],
1771 : : bool external,
1772 : : int hairpin,
1773 : : struct rte_flow_error *error);
1774 : : typedef struct mlx5_flow *(*mlx5_flow_prepare_t)
1775 : : (struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
1776 : : const struct rte_flow_item items[],
1777 : : const struct rte_flow_action actions[], struct rte_flow_error *error);
1778 : : typedef int (*mlx5_flow_translate_t)(struct rte_eth_dev *dev,
1779 : : struct mlx5_flow *dev_flow,
1780 : : const struct rte_flow_attr *attr,
1781 : : const struct rte_flow_item items[],
1782 : : const struct rte_flow_action actions[],
1783 : : struct rte_flow_error *error);
1784 : : typedef int (*mlx5_flow_apply_t)(struct rte_eth_dev *dev, struct rte_flow *flow,
1785 : : struct rte_flow_error *error);
1786 : : typedef void (*mlx5_flow_remove_t)(struct rte_eth_dev *dev,
1787 : : struct rte_flow *flow);
1788 : : typedef void (*mlx5_flow_destroy_t)(struct rte_eth_dev *dev,
1789 : : struct rte_flow *flow);
1790 : : typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,
1791 : : struct rte_flow *flow,
1792 : : const struct rte_flow_action *actions,
1793 : : void *data,
1794 : : struct rte_flow_error *error);
1795 : : typedef int (*mlx5_flow_create_mtr_tbls_t)(struct rte_eth_dev *dev,
1796 : : struct mlx5_flow_meter_info *fm,
1797 : : uint32_t mtr_idx,
1798 : : uint8_t domain_bitmap);
1799 : : typedef void (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,
1800 : : struct mlx5_flow_meter_info *fm);
1801 : : typedef void (*mlx5_flow_destroy_mtr_drop_tbls_t)(struct rte_eth_dev *dev);
1802 : : typedef struct mlx5_flow_meter_sub_policy *
1803 : : (*mlx5_flow_meter_sub_policy_rss_prepare_t)
1804 : : (struct rte_eth_dev *dev,
1805 : : struct mlx5_flow_meter_policy *mtr_policy,
1806 : : struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]);
1807 : : typedef int (*mlx5_flow_meter_hierarchy_rule_create_t)
1808 : : (struct rte_eth_dev *dev,
1809 : : struct mlx5_flow_meter_info *fm,
1810 : : int32_t src_port,
1811 : : const struct rte_flow_item *item,
1812 : : struct rte_flow_error *error);
1813 : : typedef void (*mlx5_flow_destroy_sub_policy_with_rxq_t)
1814 : : (struct rte_eth_dev *dev,
1815 : : struct mlx5_flow_meter_policy *mtr_policy);
1816 : : typedef uint32_t (*mlx5_flow_mtr_alloc_t)
1817 : : (struct rte_eth_dev *dev);
1818 : : typedef void (*mlx5_flow_mtr_free_t)(struct rte_eth_dev *dev,
1819 : : uint32_t mtr_idx);
1820 : : typedef uint32_t (*mlx5_flow_counter_alloc_t)
1821 : : (struct rte_eth_dev *dev);
1822 : : typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
1823 : : uint32_t cnt);
1824 : : typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
1825 : : uint32_t cnt,
1826 : : bool clear, uint64_t *pkts,
1827 : : uint64_t *bytes, void **action);
1828 : : typedef int (*mlx5_flow_get_aged_flows_t)
1829 : : (struct rte_eth_dev *dev,
1830 : : void **context,
1831 : : uint32_t nb_contexts,
1832 : : struct rte_flow_error *error);
1833 : : typedef int (*mlx5_flow_get_q_aged_flows_t)
1834 : : (struct rte_eth_dev *dev,
1835 : : uint32_t queue_id,
1836 : : void **context,
1837 : : uint32_t nb_contexts,
1838 : : struct rte_flow_error *error);
1839 : : typedef int (*mlx5_flow_action_validate_t)
1840 : : (struct rte_eth_dev *dev,
1841 : : const struct rte_flow_indir_action_conf *conf,
1842 : : const struct rte_flow_action *action,
1843 : : struct rte_flow_error *error);
1844 : : typedef struct rte_flow_action_handle *(*mlx5_flow_action_create_t)
1845 : : (struct rte_eth_dev *dev,
1846 : : const struct rte_flow_indir_action_conf *conf,
1847 : : const struct rte_flow_action *action,
1848 : : struct rte_flow_error *error);
1849 : : typedef int (*mlx5_flow_action_destroy_t)
1850 : : (struct rte_eth_dev *dev,
1851 : : struct rte_flow_action_handle *action,
1852 : : struct rte_flow_error *error);
1853 : : typedef int (*mlx5_flow_action_update_t)
1854 : : (struct rte_eth_dev *dev,
1855 : : struct rte_flow_action_handle *action,
1856 : : const void *update,
1857 : : struct rte_flow_error *error);
1858 : : typedef int (*mlx5_flow_action_query_t)
1859 : : (struct rte_eth_dev *dev,
1860 : : const struct rte_flow_action_handle *action,
1861 : : void *data,
1862 : : struct rte_flow_error *error);
1863 : : typedef int (*mlx5_flow_action_query_update_t)
1864 : : (struct rte_eth_dev *dev,
1865 : : struct rte_flow_action_handle *handle,
1866 : : const void *update, void *data,
1867 : : enum rte_flow_query_update_mode qu_mode,
1868 : : struct rte_flow_error *error);
1869 : : typedef struct rte_flow_action_list_handle *
1870 : : (*mlx5_flow_action_list_handle_create_t)
1871 : : (struct rte_eth_dev *dev,
1872 : : const struct rte_flow_indir_action_conf *conf,
1873 : : const struct rte_flow_action *actions,
1874 : : struct rte_flow_error *error);
1875 : : typedef int
1876 : : (*mlx5_flow_action_list_handle_destroy_t)
1877 : : (struct rte_eth_dev *dev,
1878 : : struct rte_flow_action_list_handle *handle,
1879 : : struct rte_flow_error *error);
1880 : : typedef int (*mlx5_flow_sync_domain_t)
1881 : : (struct rte_eth_dev *dev,
1882 : : uint32_t domains,
1883 : : uint32_t flags);
1884 : : typedef int (*mlx5_flow_validate_mtr_acts_t)
1885 : : (struct rte_eth_dev *dev,
1886 : : const struct rte_flow_action *actions[RTE_COLORS],
1887 : : struct rte_flow_attr *attr,
1888 : : bool *is_rss,
1889 : : uint8_t *domain_bitmap,
1890 : : uint8_t *policy_mode,
1891 : : struct rte_mtr_error *error);
1892 : : typedef int (*mlx5_flow_create_mtr_acts_t)
1893 : : (struct rte_eth_dev *dev,
1894 : : struct mlx5_flow_meter_policy *mtr_policy,
1895 : : const struct rte_flow_action *actions[RTE_COLORS],
1896 : : struct rte_flow_attr *attr,
1897 : : struct rte_mtr_error *error);
1898 : : typedef void (*mlx5_flow_destroy_mtr_acts_t)
1899 : : (struct rte_eth_dev *dev,
1900 : : struct mlx5_flow_meter_policy *mtr_policy);
1901 : : typedef int (*mlx5_flow_create_policy_rules_t)
1902 : : (struct rte_eth_dev *dev,
1903 : : struct mlx5_flow_meter_policy *mtr_policy);
1904 : : typedef void (*mlx5_flow_destroy_policy_rules_t)
1905 : : (struct rte_eth_dev *dev,
1906 : : struct mlx5_flow_meter_policy *mtr_policy);
1907 : : typedef int (*mlx5_flow_create_def_policy_t)
1908 : : (struct rte_eth_dev *dev);
1909 : : typedef void (*mlx5_flow_destroy_def_policy_t)
1910 : : (struct rte_eth_dev *dev);
1911 : : typedef int (*mlx5_flow_discover_priorities_t)
1912 : : (struct rte_eth_dev *dev,
1913 : : const uint16_t *vprio, int vprio_n);
1914 : : typedef struct rte_flow_item_flex_handle *(*mlx5_flow_item_create_t)
1915 : : (struct rte_eth_dev *dev,
1916 : : const struct rte_flow_item_flex_conf *conf,
1917 : : struct rte_flow_error *error);
1918 : : typedef int (*mlx5_flow_item_release_t)
1919 : : (struct rte_eth_dev *dev,
1920 : : const struct rte_flow_item_flex_handle *handle,
1921 : : struct rte_flow_error *error);
1922 : : typedef int (*mlx5_flow_item_update_t)
1923 : : (struct rte_eth_dev *dev,
1924 : : const struct rte_flow_item_flex_handle *handle,
1925 : : const struct rte_flow_item_flex_conf *conf,
1926 : : struct rte_flow_error *error);
1927 : : typedef int (*mlx5_flow_info_get_t)
1928 : : (struct rte_eth_dev *dev,
1929 : : struct rte_flow_port_info *port_info,
1930 : : struct rte_flow_queue_info *queue_info,
1931 : : struct rte_flow_error *error);
1932 : : typedef int (*mlx5_flow_port_configure_t)
1933 : : (struct rte_eth_dev *dev,
1934 : : const struct rte_flow_port_attr *port_attr,
1935 : : uint16_t nb_queue,
1936 : : const struct rte_flow_queue_attr *queue_attr[],
1937 : : struct rte_flow_error *err);
1938 : : typedef int (*mlx5_flow_pattern_validate_t)
1939 : : (struct rte_eth_dev *dev,
1940 : : const struct rte_flow_pattern_template_attr *attr,
1941 : : const struct rte_flow_item items[],
1942 : : struct rte_flow_error *error);
1943 : : typedef struct rte_flow_pattern_template *(*mlx5_flow_pattern_template_create_t)
1944 : : (struct rte_eth_dev *dev,
1945 : : const struct rte_flow_pattern_template_attr *attr,
1946 : : const struct rte_flow_item items[],
1947 : : struct rte_flow_error *error);
1948 : : typedef int (*mlx5_flow_pattern_template_destroy_t)
1949 : : (struct rte_eth_dev *dev,
1950 : : struct rte_flow_pattern_template *template,
1951 : : struct rte_flow_error *error);
1952 : : typedef int (*mlx5_flow_actions_validate_t)
1953 : : (struct rte_eth_dev *dev,
1954 : : const struct rte_flow_actions_template_attr *attr,
1955 : : const struct rte_flow_action actions[],
1956 : : const struct rte_flow_action masks[],
1957 : : struct rte_flow_error *error);
1958 : : typedef struct rte_flow_actions_template *(*mlx5_flow_actions_template_create_t)
1959 : : (struct rte_eth_dev *dev,
1960 : : const struct rte_flow_actions_template_attr *attr,
1961 : : const struct rte_flow_action actions[],
1962 : : const struct rte_flow_action masks[],
1963 : : struct rte_flow_error *error);
1964 : : typedef int (*mlx5_flow_actions_template_destroy_t)
1965 : : (struct rte_eth_dev *dev,
1966 : : struct rte_flow_actions_template *template,
1967 : : struct rte_flow_error *error);
1968 : : typedef struct rte_flow_template_table *(*mlx5_flow_table_create_t)
1969 : : (struct rte_eth_dev *dev,
1970 : : const struct rte_flow_template_table_attr *attr,
1971 : : struct rte_flow_pattern_template *item_templates[],
1972 : : uint8_t nb_item_templates,
1973 : : struct rte_flow_actions_template *action_templates[],
1974 : : uint8_t nb_action_templates,
1975 : : struct rte_flow_error *error);
1976 : : typedef int (*mlx5_flow_table_destroy_t)
1977 : : (struct rte_eth_dev *dev,
1978 : : struct rte_flow_template_table *table,
1979 : : struct rte_flow_error *error);
1980 : : typedef int (*mlx5_flow_group_set_miss_actions_t)
1981 : : (struct rte_eth_dev *dev,
1982 : : uint32_t group_id,
1983 : : const struct rte_flow_group_attr *attr,
1984 : : const struct rte_flow_action actions[],
1985 : : struct rte_flow_error *error);
1986 : : typedef struct rte_flow *(*mlx5_flow_async_flow_create_t)
1987 : : (struct rte_eth_dev *dev,
1988 : : uint32_t queue,
1989 : : const struct rte_flow_op_attr *attr,
1990 : : struct rte_flow_template_table *table,
1991 : : const struct rte_flow_item items[],
1992 : : uint8_t pattern_template_index,
1993 : : const struct rte_flow_action actions[],
1994 : : uint8_t action_template_index,
1995 : : void *user_data,
1996 : : struct rte_flow_error *error);
1997 : : typedef struct rte_flow *(*mlx5_flow_async_flow_create_by_index_t)
1998 : : (struct rte_eth_dev *dev,
1999 : : uint32_t queue,
2000 : : const struct rte_flow_op_attr *attr,
2001 : : struct rte_flow_template_table *table,
2002 : : uint32_t rule_index,
2003 : : const struct rte_flow_action actions[],
2004 : : uint8_t action_template_index,
2005 : : void *user_data,
2006 : : struct rte_flow_error *error);
2007 : : typedef int (*mlx5_flow_async_flow_update_t)
2008 : : (struct rte_eth_dev *dev,
2009 : : uint32_t queue,
2010 : : const struct rte_flow_op_attr *attr,
2011 : : struct rte_flow *flow,
2012 : : const struct rte_flow_action actions[],
2013 : : uint8_t action_template_index,
2014 : : void *user_data,
2015 : : struct rte_flow_error *error);
2016 : : typedef int (*mlx5_flow_async_flow_destroy_t)
2017 : : (struct rte_eth_dev *dev,
2018 : : uint32_t queue,
2019 : : const struct rte_flow_op_attr *attr,
2020 : : struct rte_flow *flow,
2021 : : void *user_data,
2022 : : struct rte_flow_error *error);
2023 : : typedef int (*mlx5_flow_pull_t)
2024 : : (struct rte_eth_dev *dev,
2025 : : uint32_t queue,
2026 : : struct rte_flow_op_result res[],
2027 : : uint16_t n_res,
2028 : : struct rte_flow_error *error);
2029 : : typedef int (*mlx5_flow_push_t)
2030 : : (struct rte_eth_dev *dev,
2031 : : uint32_t queue,
2032 : : struct rte_flow_error *error);
2033 : :
2034 : : typedef struct rte_flow_action_handle *(*mlx5_flow_async_action_handle_create_t)
2035 : : (struct rte_eth_dev *dev,
2036 : : uint32_t queue,
2037 : : const struct rte_flow_op_attr *attr,
2038 : : const struct rte_flow_indir_action_conf *conf,
2039 : : const struct rte_flow_action *action,
2040 : : void *user_data,
2041 : : struct rte_flow_error *error);
2042 : :
2043 : : typedef int (*mlx5_flow_async_action_handle_update_t)
2044 : : (struct rte_eth_dev *dev,
2045 : : uint32_t queue,
2046 : : const struct rte_flow_op_attr *attr,
2047 : : struct rte_flow_action_handle *handle,
2048 : : const void *update,
2049 : : void *user_data,
2050 : : struct rte_flow_error *error);
2051 : : typedef int (*mlx5_flow_async_action_handle_query_update_t)
2052 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2053 : : const struct rte_flow_op_attr *op_attr,
2054 : : struct rte_flow_action_handle *action_handle,
2055 : : const void *update, void *data,
2056 : : enum rte_flow_query_update_mode qu_mode,
2057 : : void *user_data, struct rte_flow_error *error);
2058 : : typedef int (*mlx5_flow_async_action_handle_query_t)
2059 : : (struct rte_eth_dev *dev,
2060 : : uint32_t queue,
2061 : : const struct rte_flow_op_attr *attr,
2062 : : const struct rte_flow_action_handle *handle,
2063 : : void *data,
2064 : : void *user_data,
2065 : : struct rte_flow_error *error);
2066 : :
2067 : : typedef int (*mlx5_flow_async_action_handle_destroy_t)
2068 : : (struct rte_eth_dev *dev,
2069 : : uint32_t queue,
2070 : : const struct rte_flow_op_attr *attr,
2071 : : struct rte_flow_action_handle *handle,
2072 : : void *user_data,
2073 : : struct rte_flow_error *error);
2074 : : typedef struct rte_flow_action_list_handle *
2075 : : (*mlx5_flow_async_action_list_handle_create_t)
2076 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2077 : : const struct rte_flow_op_attr *attr,
2078 : : const struct rte_flow_indir_action_conf *conf,
2079 : : const struct rte_flow_action *actions,
2080 : : void *user_data, struct rte_flow_error *error);
2081 : : typedef int
2082 : : (*mlx5_flow_async_action_list_handle_destroy_t)
2083 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2084 : : const struct rte_flow_op_attr *op_attr,
2085 : : struct rte_flow_action_list_handle *action_handle,
2086 : : void *user_data, struct rte_flow_error *error);
2087 : : typedef int
2088 : : (*mlx5_flow_action_list_handle_query_update_t)
2089 : : (struct rte_eth_dev *dev,
2090 : : const struct rte_flow_action_list_handle *handle,
2091 : : const void **update, void **query,
2092 : : enum rte_flow_query_update_mode mode,
2093 : : struct rte_flow_error *error);
2094 : : typedef int
2095 : : (*mlx5_flow_async_action_list_handle_query_update_t)
2096 : : (struct rte_eth_dev *dev, uint32_t queue_id,
2097 : : const struct rte_flow_op_attr *attr,
2098 : : const struct rte_flow_action_list_handle *handle,
2099 : : const void **update, void **query,
2100 : : enum rte_flow_query_update_mode mode,
2101 : : void *user_data, struct rte_flow_error *error);
2102 : : typedef int
2103 : : (*mlx5_flow_calc_table_hash_t)
2104 : : (struct rte_eth_dev *dev,
2105 : : const struct rte_flow_template_table *table,
2106 : : const struct rte_flow_item pattern[],
2107 : : uint8_t pattern_template_index,
2108 : : uint32_t *hash, struct rte_flow_error *error);
2109 : :
2110 : : struct mlx5_flow_driver_ops {
2111 : : mlx5_flow_validate_t validate;
2112 : : mlx5_flow_prepare_t prepare;
2113 : : mlx5_flow_translate_t translate;
2114 : : mlx5_flow_apply_t apply;
2115 : : mlx5_flow_remove_t remove;
2116 : : mlx5_flow_destroy_t destroy;
2117 : : mlx5_flow_query_t query;
2118 : : mlx5_flow_create_mtr_tbls_t create_mtr_tbls;
2119 : : mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;
2120 : : mlx5_flow_destroy_mtr_drop_tbls_t destroy_mtr_drop_tbls;
2121 : : mlx5_flow_mtr_alloc_t create_meter;
2122 : : mlx5_flow_mtr_free_t free_meter;
2123 : : mlx5_flow_validate_mtr_acts_t validate_mtr_acts;
2124 : : mlx5_flow_create_mtr_acts_t create_mtr_acts;
2125 : : mlx5_flow_destroy_mtr_acts_t destroy_mtr_acts;
2126 : : mlx5_flow_create_policy_rules_t create_policy_rules;
2127 : : mlx5_flow_destroy_policy_rules_t destroy_policy_rules;
2128 : : mlx5_flow_create_def_policy_t create_def_policy;
2129 : : mlx5_flow_destroy_def_policy_t destroy_def_policy;
2130 : : mlx5_flow_meter_sub_policy_rss_prepare_t meter_sub_policy_rss_prepare;
2131 : : mlx5_flow_meter_hierarchy_rule_create_t meter_hierarchy_rule_create;
2132 : : mlx5_flow_destroy_sub_policy_with_rxq_t destroy_sub_policy_with_rxq;
2133 : : mlx5_flow_counter_alloc_t counter_alloc;
2134 : : mlx5_flow_counter_free_t counter_free;
2135 : : mlx5_flow_counter_query_t counter_query;
2136 : : mlx5_flow_get_aged_flows_t get_aged_flows;
2137 : : mlx5_flow_get_q_aged_flows_t get_q_aged_flows;
2138 : : mlx5_flow_action_validate_t action_validate;
2139 : : mlx5_flow_action_create_t action_create;
2140 : : mlx5_flow_action_destroy_t action_destroy;
2141 : : mlx5_flow_action_update_t action_update;
2142 : : mlx5_flow_action_query_t action_query;
2143 : : mlx5_flow_action_query_update_t action_query_update;
2144 : : mlx5_flow_action_list_handle_create_t action_list_handle_create;
2145 : : mlx5_flow_action_list_handle_destroy_t action_list_handle_destroy;
2146 : : mlx5_flow_sync_domain_t sync_domain;
2147 : : mlx5_flow_discover_priorities_t discover_priorities;
2148 : : mlx5_flow_item_create_t item_create;
2149 : : mlx5_flow_item_release_t item_release;
2150 : : mlx5_flow_item_update_t item_update;
2151 : : mlx5_flow_info_get_t info_get;
2152 : : mlx5_flow_port_configure_t configure;
2153 : : mlx5_flow_pattern_validate_t pattern_validate;
2154 : : mlx5_flow_pattern_template_create_t pattern_template_create;
2155 : : mlx5_flow_pattern_template_destroy_t pattern_template_destroy;
2156 : : mlx5_flow_actions_validate_t actions_validate;
2157 : : mlx5_flow_actions_template_create_t actions_template_create;
2158 : : mlx5_flow_actions_template_destroy_t actions_template_destroy;
2159 : : mlx5_flow_table_create_t template_table_create;
2160 : : mlx5_flow_table_destroy_t template_table_destroy;
2161 : : mlx5_flow_group_set_miss_actions_t group_set_miss_actions;
2162 : : mlx5_flow_async_flow_create_t async_flow_create;
2163 : : mlx5_flow_async_flow_create_by_index_t async_flow_create_by_index;
2164 : : mlx5_flow_async_flow_update_t async_flow_update;
2165 : : mlx5_flow_async_flow_destroy_t async_flow_destroy;
2166 : : mlx5_flow_pull_t pull;
2167 : : mlx5_flow_push_t push;
2168 : : mlx5_flow_async_action_handle_create_t async_action_create;
2169 : : mlx5_flow_async_action_handle_update_t async_action_update;
2170 : : mlx5_flow_async_action_handle_query_update_t async_action_query_update;
2171 : : mlx5_flow_async_action_handle_query_t async_action_query;
2172 : : mlx5_flow_async_action_handle_destroy_t async_action_destroy;
2173 : : mlx5_flow_async_action_list_handle_create_t
2174 : : async_action_list_handle_create;
2175 : : mlx5_flow_async_action_list_handle_destroy_t
2176 : : async_action_list_handle_destroy;
2177 : : mlx5_flow_action_list_handle_query_update_t
2178 : : action_list_handle_query_update;
2179 : : mlx5_flow_async_action_list_handle_query_update_t
2180 : : async_action_list_handle_query_update;
2181 : : mlx5_flow_calc_table_hash_t flow_calc_table_hash;
2182 : : };
2183 : :
2184 : : /* mlx5_flow.c */
2185 : :
2186 : : struct mlx5_flow_workspace *mlx5_flow_push_thread_workspace(void);
2187 : : void mlx5_flow_pop_thread_workspace(void);
2188 : : struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace(void);
2189 : :
2190 : : __extension__
2191 : : struct flow_grp_info {
2192 : : uint64_t external:1;
2193 : : uint64_t transfer:1;
2194 : : uint64_t fdb_def_rule:1;
2195 : : /* force standard group translation */
2196 : : uint64_t std_tbl_fix:1;
2197 : : uint64_t skip_scale:2;
2198 : : };
2199 : :
2200 : : static inline bool
2201 : : tunnel_use_standard_attr_group_translate
2202 : : (const struct rte_eth_dev *dev,
2203 : : const struct rte_flow_attr *attr,
2204 : : const struct mlx5_flow_tunnel *tunnel,
2205 : : enum mlx5_tof_rule_type tof_rule_type)
2206 : : {
2207 : : bool verdict;
2208 : :
2209 [ # # # # ]: 0 : if (!is_tunnel_offload_active(dev))
2210 : : /* no tunnel offload API */
2211 : : verdict = true;
2212 [ # # ]: 0 : else if (tunnel) {
2213 : : /*
2214 : : * OvS will use jump to group 0 in tunnel steer rule.
2215 : : * If tunnel steer rule starts from group 0 (attr.group == 0)
2216 : : * that 0 group must be translated with standard method.
2217 : : * attr.group == 0 in tunnel match rule translated with tunnel
2218 : : * method
2219 : : */
2220 [ # # # # : 0 : verdict = !attr->group &&
# # # # ]
2221 : : is_flow_tunnel_steer_rule(tof_rule_type);
2222 : : } else {
2223 : : /*
2224 : : * non-tunnel group translation uses standard method for
2225 : : * root group only: attr.group == 0
2226 : : */
2227 : 0 : verdict = !attr->group;
2228 : : }
2229 : :
2230 : : return verdict;
2231 : : }
2232 : :
2233 : : /**
2234 : : * Get DV flow aso meter by index.
2235 : : *
2236 : : * @param[in] dev
2237 : : * Pointer to the Ethernet device structure.
2238 : : * @param[in] idx
2239 : : * mlx5 flow aso meter index in the container.
2240 : : * @param[out] ppool
2241 : : * mlx5 flow aso meter pool in the container,
2242 : : *
2243 : : * @return
2244 : : * Pointer to the aso meter, NULL otherwise.
2245 : : */
2246 : : static inline struct mlx5_aso_mtr *
2247 : 0 : mlx5_aso_meter_by_idx(struct mlx5_priv *priv, uint32_t idx)
2248 : : {
2249 : : struct mlx5_aso_mtr_pool *pool;
2250 : : struct mlx5_aso_mtr_pools_mng *pools_mng =
2251 : 0 : &priv->sh->mtrmng->pools_mng;
2252 : :
2253 [ # # ]: 0 : if (priv->mtr_bulk.aso)
2254 : 0 : return priv->mtr_bulk.aso + idx;
2255 : : /* Decrease to original index. */
2256 : 0 : idx--;
2257 : : MLX5_ASSERT(idx / MLX5_ASO_MTRS_PER_POOL < pools_mng->n);
2258 : 0 : rte_rwlock_read_lock(&pools_mng->resize_mtrwl);
2259 : 0 : pool = pools_mng->pools[idx / MLX5_ASO_MTRS_PER_POOL];
2260 : : rte_rwlock_read_unlock(&pools_mng->resize_mtrwl);
2261 : 0 : return &pool->mtrs[idx % MLX5_ASO_MTRS_PER_POOL];
2262 : : }
2263 : :
2264 : : static __rte_always_inline const struct rte_flow_item *
2265 : : mlx5_find_end_item(const struct rte_flow_item *item)
2266 : : {
2267 : : for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++);
2268 : : return item;
2269 : : }
2270 : :
2271 : : static __rte_always_inline bool
2272 : : mlx5_validate_integrity_item(const struct rte_flow_item_integrity *item)
2273 : : {
2274 : 0 : struct rte_flow_item_integrity test = *item;
2275 : 0 : test.l3_ok = 0;
2276 : 0 : test.l4_ok = 0;
2277 : 0 : test.ipv4_csum_ok = 0;
2278 : 0 : test.l4_csum_ok = 0;
2279 [ # # ]: 0 : return (test.value == 0);
2280 : : }
2281 : :
2282 : : /*
2283 : : * Get ASO CT action by device and index.
2284 : : *
2285 : : * @param[in] dev
2286 : : * Pointer to the Ethernet device structure.
2287 : : * @param[in] idx
2288 : : * Index to the ASO CT action.
2289 : : *
2290 : : * @return
2291 : : * The specified ASO CT action pointer.
2292 : : */
2293 : : static inline struct mlx5_aso_ct_action *
2294 : 0 : flow_aso_ct_get_by_dev_idx(struct rte_eth_dev *dev, uint32_t idx)
2295 : : {
2296 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
2297 : 0 : struct mlx5_aso_ct_pools_mng *mng = priv->sh->ct_mng;
2298 : : struct mlx5_aso_ct_pool *pool;
2299 : :
2300 : 0 : idx--;
2301 : : MLX5_ASSERT((idx / MLX5_ASO_CT_ACTIONS_PER_POOL) < mng->n);
2302 : : /* Bit operation AND could be used. */
2303 : 0 : rte_rwlock_read_lock(&mng->resize_rwl);
2304 : 0 : pool = mng->pools[idx / MLX5_ASO_CT_ACTIONS_PER_POOL];
2305 : : rte_rwlock_read_unlock(&mng->resize_rwl);
2306 : 0 : return &pool->actions[idx % MLX5_ASO_CT_ACTIONS_PER_POOL];
2307 : : }
2308 : :
2309 : : /*
2310 : : * Get ASO CT action by owner & index.
2311 : : *
2312 : : * @param[in] dev
2313 : : * Pointer to the Ethernet device structure.
2314 : : * @param[in] idx
2315 : : * Index to the ASO CT action and owner port combination.
2316 : : *
2317 : : * @return
2318 : : * The specified ASO CT action pointer.
2319 : : */
2320 : : static inline struct mlx5_aso_ct_action *
2321 : 0 : flow_aso_ct_get_by_idx(struct rte_eth_dev *dev, uint32_t own_idx)
2322 : : {
2323 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
2324 : : struct mlx5_aso_ct_action *ct;
2325 : 0 : uint16_t owner = (uint16_t)MLX5_INDIRECT_ACT_CT_GET_OWNER(own_idx);
2326 : 0 : uint32_t idx = MLX5_INDIRECT_ACT_CT_GET_IDX(own_idx);
2327 : :
2328 [ # # ]: 0 : if (owner == PORT_ID(priv)) {
2329 : 0 : ct = flow_aso_ct_get_by_dev_idx(dev, idx);
2330 : : } else {
2331 : 0 : struct rte_eth_dev *owndev = &rte_eth_devices[owner];
2332 : :
2333 : : MLX5_ASSERT(owner < RTE_MAX_ETHPORTS);
2334 [ # # ]: 0 : if (dev->data->dev_started != 1)
2335 : : return NULL;
2336 : 0 : ct = flow_aso_ct_get_by_dev_idx(owndev, idx);
2337 [ # # ]: 0 : if (ct->peer != PORT_ID(priv))
2338 : 0 : return NULL;
2339 : : }
2340 : : return ct;
2341 : : }
2342 : :
2343 : : static inline uint16_t
2344 : : mlx5_translate_tunnel_etypes(uint64_t pattern_flags)
2345 : : {
2346 [ # # # # : 0 : if (pattern_flags & MLX5_FLOW_LAYER_INNER_L2)
# # ]
2347 : : return RTE_ETHER_TYPE_TEB;
2348 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV4)
# # ]
2349 : : return RTE_ETHER_TYPE_IPV4;
2350 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_INNER_L3_IPV6)
# # ]
2351 : : return RTE_ETHER_TYPE_IPV6;
2352 [ # # # # : 0 : else if (pattern_flags & MLX5_FLOW_LAYER_MPLS)
# # ]
2353 : 0 : return RTE_ETHER_TYPE_MPLS;
2354 : : return 0;
2355 : : }
2356 : :
2357 : : int flow_hw_q_flow_flush(struct rte_eth_dev *dev,
2358 : : struct rte_flow_error *error);
2359 : :
2360 : : /*
2361 : : * Convert rte_mtr_color to mlx5 color.
2362 : : *
2363 : : * @param[in] rcol
2364 : : * rte_mtr_color.
2365 : : *
2366 : : * @return
2367 : : * mlx5 color.
2368 : : */
2369 : : static inline int
2370 : : rte_col_2_mlx5_col(enum rte_color rcol)
2371 : : {
2372 : : switch (rcol) {
2373 : : case RTE_COLOR_GREEN:
2374 : : return MLX5_FLOW_COLOR_GREEN;
2375 : : case RTE_COLOR_YELLOW:
2376 : : return MLX5_FLOW_COLOR_YELLOW;
2377 : : case RTE_COLOR_RED:
2378 : : return MLX5_FLOW_COLOR_RED;
2379 : : default:
2380 : : break;
2381 : : }
2382 : : return MLX5_FLOW_COLOR_UNDEFINED;
2383 : : }
2384 : :
2385 : : /**
2386 : : * Indicates whether flow source vport is representor port.
2387 : : *
2388 : : * @param[in] priv
2389 : : * Pointer to device private context structure.
2390 : : * @param[in] act_priv
2391 : : * Pointer to actual device private context structure if have.
2392 : : *
2393 : : * @return
2394 : : * True when the flow source vport is representor port, false otherwise.
2395 : : */
2396 : : static inline bool
2397 : : flow_source_vport_representor(struct mlx5_priv *priv, struct mlx5_priv *act_priv)
2398 : : {
2399 : : MLX5_ASSERT(priv);
2400 [ # # # # : 0 : return (!act_priv ? (priv->representor_id != UINT16_MAX) :
# # # # #
# ]
2401 : 0 : (act_priv->representor_id != UINT16_MAX));
2402 : : }
2403 : :
2404 : : /* All types of Ethernet patterns used in control flow rules. */
2405 : : enum mlx5_flow_ctrl_rx_eth_pattern_type {
2406 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL = 0,
2407 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL_MCAST,
2408 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_BCAST,
2409 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_BCAST_VLAN,
2410 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV4_MCAST,
2411 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV4_MCAST_VLAN,
2412 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV6_MCAST,
2413 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_IPV6_MCAST_VLAN,
2414 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_DMAC,
2415 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_DMAC_VLAN,
2416 : : MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_MAX,
2417 : : };
2418 : :
2419 : : /* All types of RSS actions used in control flow rules. */
2420 : : enum mlx5_flow_ctrl_rx_expanded_rss_type {
2421 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_NON_IP = 0,
2422 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4,
2423 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4_UDP,
2424 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV4_TCP,
2425 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6,
2426 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6_UDP,
2427 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_IPV6_TCP,
2428 : : MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX,
2429 : : };
2430 : :
2431 : : /**
2432 : : * Contains pattern template, template table and its attributes for a single
2433 : : * combination of Ethernet pattern and RSS action. Used to create control flow rules
2434 : : * with HWS.
2435 : : */
2436 : : struct mlx5_flow_hw_ctrl_rx_table {
2437 : : struct rte_flow_template_table_attr attr;
2438 : : struct rte_flow_pattern_template *pt;
2439 : : struct rte_flow_template_table *tbl;
2440 : : };
2441 : :
2442 : : /* Contains all templates required to create control flow rules with HWS. */
2443 : : struct mlx5_flow_hw_ctrl_rx {
2444 : : struct rte_flow_actions_template *rss[MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX];
2445 : : struct mlx5_flow_hw_ctrl_rx_table tables[MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_MAX]
2446 : : [MLX5_FLOW_HW_CTRL_RX_EXPANDED_RSS_MAX];
2447 : : };
2448 : :
2449 : : #define MLX5_CTRL_PROMISCUOUS (RTE_BIT32(0))
2450 : : #define MLX5_CTRL_ALL_MULTICAST (RTE_BIT32(1))
2451 : : #define MLX5_CTRL_BROADCAST (RTE_BIT32(2))
2452 : : #define MLX5_CTRL_IPV4_MULTICAST (RTE_BIT32(3))
2453 : : #define MLX5_CTRL_IPV6_MULTICAST (RTE_BIT32(4))
2454 : : #define MLX5_CTRL_DMAC (RTE_BIT32(5))
2455 : : #define MLX5_CTRL_VLAN_FILTER (RTE_BIT32(6))
2456 : :
2457 : : int mlx5_flow_hw_ctrl_flows(struct rte_eth_dev *dev, uint32_t flags);
2458 : : void mlx5_flow_hw_cleanup_ctrl_rx_templates(struct rte_eth_dev *dev);
2459 : :
2460 : : int mlx5_flow_group_to_table(struct rte_eth_dev *dev,
2461 : : const struct mlx5_flow_tunnel *tunnel,
2462 : : uint32_t group, uint32_t *table,
2463 : : const struct flow_grp_info *flags,
2464 : : struct rte_flow_error *error);
2465 : : uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
2466 : : int tunnel, uint64_t layer_types,
2467 : : uint64_t hash_fields);
2468 : : int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
2469 : : uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
2470 : : uint32_t subpriority);
2471 : : uint32_t mlx5_get_lowest_priority(struct rte_eth_dev *dev,
2472 : : const struct rte_flow_attr *attr);
2473 : : uint16_t mlx5_get_matcher_priority(struct rte_eth_dev *dev,
2474 : : const struct rte_flow_attr *attr,
2475 : : uint32_t subpriority, bool external);
2476 : : uint32_t mlx5_get_send_to_kernel_priority(struct rte_eth_dev *dev);
2477 : : int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
2478 : : enum mlx5_feature_name feature,
2479 : : uint32_t id,
2480 : : struct rte_flow_error *error);
2481 : : const struct rte_flow_action *mlx5_flow_find_action
2482 : : (const struct rte_flow_action *actions,
2483 : : enum rte_flow_action_type action);
2484 : : int mlx5_validate_action_rss(struct rte_eth_dev *dev,
2485 : : const struct rte_flow_action *action,
2486 : : struct rte_flow_error *error);
2487 : :
2488 : : struct mlx5_hw_encap_decap_action*
2489 : : mlx5_reformat_action_create(struct rte_eth_dev *dev,
2490 : : const struct rte_flow_indir_action_conf *conf,
2491 : : const struct rte_flow_action *encap_action,
2492 : : const struct rte_flow_action *decap_action,
2493 : : struct rte_flow_error *error);
2494 : : int mlx5_reformat_action_destroy(struct rte_eth_dev *dev,
2495 : : struct rte_flow_action_list_handle *handle,
2496 : : struct rte_flow_error *error);
2497 : : int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
2498 : : const struct rte_flow_attr *attr,
2499 : : struct rte_flow_error *error);
2500 : : int mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
2501 : : bool is_root,
2502 : : const struct rte_flow_attr *attr,
2503 : : struct rte_flow_error *error);
2504 : : int mlx5_flow_validate_action_flag(uint64_t action_flags,
2505 : : const struct rte_flow_attr *attr,
2506 : : struct rte_flow_error *error);
2507 : : int mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
2508 : : uint64_t action_flags,
2509 : : const struct rte_flow_attr *attr,
2510 : : struct rte_flow_error *error);
2511 : : int mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
2512 : : uint64_t action_flags,
2513 : : struct rte_eth_dev *dev,
2514 : : const struct rte_flow_attr *attr,
2515 : : struct rte_flow_error *error);
2516 : : int mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
2517 : : uint64_t action_flags,
2518 : : struct rte_eth_dev *dev,
2519 : : const struct rte_flow_attr *attr,
2520 : : uint64_t item_flags,
2521 : : struct rte_flow_error *error);
2522 : : int mlx5_flow_validate_action_default_miss(uint64_t action_flags,
2523 : : const struct rte_flow_attr *attr,
2524 : : struct rte_flow_error *error);
2525 : : int flow_validate_modify_field_level
2526 : : (const struct rte_flow_action_modify_data *data,
2527 : : struct rte_flow_error *error);
2528 : : int mlx5_flow_item_acceptable(const struct rte_flow_item *item,
2529 : : const uint8_t *mask,
2530 : : const uint8_t *nic_mask,
2531 : : unsigned int size,
2532 : : bool range_accepted,
2533 : : struct rte_flow_error *error);
2534 : : int mlx5_flow_validate_item_eth(const struct rte_flow_item *item,
2535 : : uint64_t item_flags, bool ext_vlan_sup,
2536 : : struct rte_flow_error *error);
2537 : : int mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
2538 : : uint64_t item_flags,
2539 : : uint8_t target_protocol,
2540 : : struct rte_flow_error *error);
2541 : : int mlx5_flow_validate_item_gre_key(const struct rte_flow_item *item,
2542 : : uint64_t item_flags,
2543 : : const struct rte_flow_item *gre_item,
2544 : : struct rte_flow_error *error);
2545 : : int mlx5_flow_validate_item_gre_option(struct rte_eth_dev *dev,
2546 : : const struct rte_flow_item *item,
2547 : : uint64_t item_flags,
2548 : : const struct rte_flow_attr *attr,
2549 : : const struct rte_flow_item *gre_item,
2550 : : struct rte_flow_error *error);
2551 : : int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
2552 : : uint64_t item_flags,
2553 : : uint64_t last_item,
2554 : : uint16_t ether_type,
2555 : : const struct rte_flow_item_ipv4 *acc_mask,
2556 : : bool range_accepted,
2557 : : struct rte_flow_error *error);
2558 : : int mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
2559 : : uint64_t item_flags,
2560 : : uint64_t last_item,
2561 : : uint16_t ether_type,
2562 : : const struct rte_flow_item_ipv6 *acc_mask,
2563 : : struct rte_flow_error *error);
2564 : : int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
2565 : : const struct rte_flow_item *item,
2566 : : uint64_t item_flags,
2567 : : uint64_t prev_layer,
2568 : : struct rte_flow_error *error);
2569 : : int mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,
2570 : : uint64_t item_flags,
2571 : : uint8_t target_protocol,
2572 : : const struct rte_flow_item_tcp *flow_mask,
2573 : : struct rte_flow_error *error);
2574 : : int mlx5_flow_validate_item_udp(const struct rte_flow_item *item,
2575 : : uint64_t item_flags,
2576 : : uint8_t target_protocol,
2577 : : struct rte_flow_error *error);
2578 : : int mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,
2579 : : uint64_t item_flags,
2580 : : struct rte_eth_dev *dev,
2581 : : struct rte_flow_error *error);
2582 : : int mlx5_flow_validate_item_vxlan(struct rte_eth_dev *dev,
2583 : : uint16_t udp_dport,
2584 : : const struct rte_flow_item *item,
2585 : : uint64_t item_flags,
2586 : : bool root,
2587 : : struct rte_flow_error *error);
2588 : : int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
2589 : : uint64_t item_flags,
2590 : : struct rte_eth_dev *dev,
2591 : : struct rte_flow_error *error);
2592 : : int mlx5_flow_validate_item_icmp(const struct rte_flow_item *item,
2593 : : uint64_t item_flags,
2594 : : uint8_t target_protocol,
2595 : : struct rte_flow_error *error);
2596 : : int mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item,
2597 : : uint64_t item_flags,
2598 : : uint8_t target_protocol,
2599 : : struct rte_flow_error *error);
2600 : : int mlx5_flow_validate_item_icmp6_echo(const struct rte_flow_item *item,
2601 : : uint64_t item_flags,
2602 : : uint8_t target_protocol,
2603 : : struct rte_flow_error *error);
2604 : : int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item,
2605 : : uint64_t item_flags,
2606 : : uint8_t target_protocol,
2607 : : struct rte_flow_error *error);
2608 : : int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
2609 : : uint64_t item_flags,
2610 : : struct rte_eth_dev *dev,
2611 : : struct rte_flow_error *error);
2612 : : int mlx5_flow_validate_item_geneve_opt(const struct rte_flow_item *item,
2613 : : uint64_t last_item,
2614 : : const struct rte_flow_item *geneve_item,
2615 : : struct rte_eth_dev *dev,
2616 : : struct rte_flow_error *error);
2617 : : int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
2618 : : uint64_t item_flags,
2619 : : uint64_t last_item,
2620 : : uint16_t ether_type,
2621 : : const struct rte_flow_item_ecpri *acc_mask,
2622 : : struct rte_flow_error *error);
2623 : : int mlx5_flow_validate_item_nsh(struct rte_eth_dev *dev,
2624 : : const struct rte_flow_item *item,
2625 : : struct rte_flow_error *error);
2626 : : int mlx5_flow_create_mtr_tbls(struct rte_eth_dev *dev,
2627 : : struct mlx5_flow_meter_info *fm,
2628 : : uint32_t mtr_idx,
2629 : : uint8_t domain_bitmap);
2630 : : void mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,
2631 : : struct mlx5_flow_meter_info *fm);
2632 : : void mlx5_flow_destroy_mtr_drop_tbls(struct rte_eth_dev *dev);
2633 : : struct mlx5_flow_meter_sub_policy *mlx5_flow_meter_sub_policy_rss_prepare
2634 : : (struct rte_eth_dev *dev,
2635 : : struct mlx5_flow_meter_policy *mtr_policy,
2636 : : struct mlx5_flow_rss_desc *rss_desc[MLX5_MTR_RTE_COLORS]);
2637 : : void mlx5_flow_destroy_sub_policy_with_rxq(struct rte_eth_dev *dev,
2638 : : struct mlx5_flow_meter_policy *mtr_policy);
2639 : : int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
2640 : : int mlx5_flow_discover_dr_action_support(struct rte_eth_dev *dev);
2641 : : int mlx5_action_handle_attach(struct rte_eth_dev *dev);
2642 : : int mlx5_action_handle_detach(struct rte_eth_dev *dev);
2643 : : int mlx5_action_handle_flush(struct rte_eth_dev *dev);
2644 : : void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id);
2645 : : int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh);
2646 : :
2647 : : struct mlx5_list_entry *flow_dv_tbl_create_cb(void *tool_ctx, void *entry_ctx);
2648 : : int flow_dv_tbl_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2649 : : void *cb_ctx);
2650 : : void flow_dv_tbl_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2651 : : struct mlx5_list_entry *flow_dv_tbl_clone_cb(void *tool_ctx,
2652 : : struct mlx5_list_entry *oentry,
2653 : : void *entry_ctx);
2654 : : void flow_dv_tbl_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2655 : : struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
2656 : : uint32_t table_level, uint8_t egress, uint8_t transfer,
2657 : : bool external, const struct mlx5_flow_tunnel *tunnel,
2658 : : uint32_t group_id, uint8_t dummy,
2659 : : uint32_t table_id, struct rte_flow_error *error);
2660 : : int flow_dv_tbl_resource_release(struct mlx5_dev_ctx_shared *sh,
2661 : : struct mlx5_flow_tbl_resource *tbl);
2662 : :
2663 : : struct mlx5_list_entry *flow_dv_tag_create_cb(void *tool_ctx, void *cb_ctx);
2664 : : int flow_dv_tag_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2665 : : void *cb_ctx);
2666 : : void flow_dv_tag_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2667 : : struct mlx5_list_entry *flow_dv_tag_clone_cb(void *tool_ctx,
2668 : : struct mlx5_list_entry *oentry,
2669 : : void *cb_ctx);
2670 : : void flow_dv_tag_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2671 : :
2672 : : int flow_dv_modify_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2673 : : void *cb_ctx);
2674 : : struct mlx5_list_entry *flow_dv_modify_create_cb(void *tool_ctx, void *ctx);
2675 : : void flow_dv_modify_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2676 : : struct mlx5_list_entry *flow_dv_modify_clone_cb(void *tool_ctx,
2677 : : struct mlx5_list_entry *oentry,
2678 : : void *ctx);
2679 : : void flow_dv_modify_clone_free_cb(void *tool_ctx,
2680 : : struct mlx5_list_entry *entry);
2681 : :
2682 : : struct mlx5_list_entry *flow_dv_mreg_create_cb(void *tool_ctx, void *ctx);
2683 : : int flow_dv_mreg_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2684 : : void *cb_ctx);
2685 : : void flow_dv_mreg_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2686 : : struct mlx5_list_entry *flow_dv_mreg_clone_cb(void *tool_ctx,
2687 : : struct mlx5_list_entry *entry,
2688 : : void *ctx);
2689 : : void flow_dv_mreg_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2690 : :
2691 : : int flow_dv_encap_decap_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2692 : : void *cb_ctx);
2693 : : struct mlx5_list_entry *flow_dv_encap_decap_create_cb(void *tool_ctx,
2694 : : void *cb_ctx);
2695 : : void flow_dv_encap_decap_remove_cb(void *tool_ctx,
2696 : : struct mlx5_list_entry *entry);
2697 : : struct mlx5_list_entry *flow_dv_encap_decap_clone_cb(void *tool_ctx,
2698 : : struct mlx5_list_entry *entry,
2699 : : void *cb_ctx);
2700 : : void flow_dv_encap_decap_clone_free_cb(void *tool_ctx,
2701 : : struct mlx5_list_entry *entry);
2702 : :
2703 : : int flow_dv_matcher_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2704 : : void *ctx);
2705 : : struct mlx5_list_entry *flow_dv_matcher_create_cb(void *tool_ctx, void *ctx);
2706 : : void flow_dv_matcher_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2707 : :
2708 : : int flow_dv_port_id_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2709 : : void *cb_ctx);
2710 : : struct mlx5_list_entry *flow_dv_port_id_create_cb(void *tool_ctx, void *cb_ctx);
2711 : : void flow_dv_port_id_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2712 : : struct mlx5_list_entry *flow_dv_port_id_clone_cb(void *tool_ctx,
2713 : : struct mlx5_list_entry *entry, void *cb_ctx);
2714 : : void flow_dv_port_id_clone_free_cb(void *tool_ctx,
2715 : : struct mlx5_list_entry *entry);
2716 : :
2717 : : int flow_dv_push_vlan_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2718 : : void *cb_ctx);
2719 : : struct mlx5_list_entry *flow_dv_push_vlan_create_cb(void *tool_ctx,
2720 : : void *cb_ctx);
2721 : : void flow_dv_push_vlan_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2722 : : struct mlx5_list_entry *flow_dv_push_vlan_clone_cb(void *tool_ctx,
2723 : : struct mlx5_list_entry *entry, void *cb_ctx);
2724 : : void flow_dv_push_vlan_clone_free_cb(void *tool_ctx,
2725 : : struct mlx5_list_entry *entry);
2726 : :
2727 : : int flow_dv_sample_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2728 : : void *cb_ctx);
2729 : : struct mlx5_list_entry *flow_dv_sample_create_cb(void *tool_ctx, void *cb_ctx);
2730 : : void flow_dv_sample_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2731 : : struct mlx5_list_entry *flow_dv_sample_clone_cb(void *tool_ctx,
2732 : : struct mlx5_list_entry *entry, void *cb_ctx);
2733 : : void flow_dv_sample_clone_free_cb(void *tool_ctx,
2734 : : struct mlx5_list_entry *entry);
2735 : :
2736 : : int flow_dv_dest_array_match_cb(void *tool_ctx, struct mlx5_list_entry *entry,
2737 : : void *cb_ctx);
2738 : : struct mlx5_list_entry *flow_dv_dest_array_create_cb(void *tool_ctx,
2739 : : void *cb_ctx);
2740 : : void flow_dv_dest_array_remove_cb(void *tool_ctx,
2741 : : struct mlx5_list_entry *entry);
2742 : : struct mlx5_list_entry *flow_dv_dest_array_clone_cb(void *tool_ctx,
2743 : : struct mlx5_list_entry *entry, void *cb_ctx);
2744 : : void flow_dv_dest_array_clone_free_cb(void *tool_ctx,
2745 : : struct mlx5_list_entry *entry);
2746 : : void flow_dv_hashfields_set(uint64_t item_flags,
2747 : : struct mlx5_flow_rss_desc *rss_desc,
2748 : : uint64_t *hash_fields);
2749 : : void flow_dv_action_rss_l34_hash_adjust(uint64_t rss_types,
2750 : : uint64_t *hash_field);
2751 : : uint32_t flow_dv_action_rss_hrxq_lookup(struct rte_eth_dev *dev, uint32_t idx,
2752 : : const uint64_t hash_fields);
2753 : :
2754 : : struct mlx5_list_entry *flow_hw_grp_create_cb(void *tool_ctx, void *cb_ctx);
2755 : : void flow_hw_grp_remove_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2756 : : int flow_hw_grp_match_cb(void *tool_ctx,
2757 : : struct mlx5_list_entry *entry,
2758 : : void *cb_ctx);
2759 : : struct mlx5_list_entry *flow_hw_grp_clone_cb(void *tool_ctx,
2760 : : struct mlx5_list_entry *oentry,
2761 : : void *cb_ctx);
2762 : : void flow_hw_grp_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry);
2763 : :
2764 : : struct mlx5_aso_age_action *flow_aso_age_get_by_idx(struct rte_eth_dev *dev,
2765 : : uint32_t age_idx);
2766 : : int flow_dev_geneve_tlv_option_resource_register(struct rte_eth_dev *dev,
2767 : : const struct rte_flow_item *item,
2768 : : struct rte_flow_error *error);
2769 : : void flow_dev_geneve_tlv_option_resource_release(struct mlx5_dev_ctx_shared *sh);
2770 : :
2771 : : void flow_release_workspace(void *data);
2772 : : int mlx5_flow_os_init_workspace_once(void);
2773 : : void *mlx5_flow_os_get_specific_workspace(void);
2774 : : int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data);
2775 : : void mlx5_flow_os_release_workspace(void);
2776 : : uint32_t mlx5_flow_mtr_alloc(struct rte_eth_dev *dev);
2777 : : void mlx5_flow_mtr_free(struct rte_eth_dev *dev, uint32_t mtr_idx);
2778 : : int mlx5_flow_validate_mtr_acts(struct rte_eth_dev *dev,
2779 : : const struct rte_flow_action *actions[RTE_COLORS],
2780 : : struct rte_flow_attr *attr,
2781 : : bool *is_rss,
2782 : : uint8_t *domain_bitmap,
2783 : : uint8_t *policy_mode,
2784 : : struct rte_mtr_error *error);
2785 : : void mlx5_flow_destroy_mtr_acts(struct rte_eth_dev *dev,
2786 : : struct mlx5_flow_meter_policy *mtr_policy);
2787 : : int mlx5_flow_create_mtr_acts(struct rte_eth_dev *dev,
2788 : : struct mlx5_flow_meter_policy *mtr_policy,
2789 : : const struct rte_flow_action *actions[RTE_COLORS],
2790 : : struct rte_flow_attr *attr,
2791 : : struct rte_mtr_error *error);
2792 : : int mlx5_flow_create_policy_rules(struct rte_eth_dev *dev,
2793 : : struct mlx5_flow_meter_policy *mtr_policy);
2794 : : void mlx5_flow_destroy_policy_rules(struct rte_eth_dev *dev,
2795 : : struct mlx5_flow_meter_policy *mtr_policy);
2796 : : int mlx5_flow_create_def_policy(struct rte_eth_dev *dev);
2797 : : void mlx5_flow_destroy_def_policy(struct rte_eth_dev *dev);
2798 : : void flow_drv_rxq_flags_set(struct rte_eth_dev *dev,
2799 : : struct mlx5_flow_handle *dev_handle);
2800 : : const struct mlx5_flow_tunnel *
2801 : : mlx5_get_tof(const struct rte_flow_item *items,
2802 : : const struct rte_flow_action *actions,
2803 : : enum mlx5_tof_rule_type *rule_type);
2804 : : void
2805 : : flow_hw_resource_release(struct rte_eth_dev *dev);
2806 : : void
2807 : : flow_hw_rxq_flag_set(struct rte_eth_dev *dev, bool enable);
2808 : : int flow_dv_action_validate(struct rte_eth_dev *dev,
2809 : : const struct rte_flow_indir_action_conf *conf,
2810 : : const struct rte_flow_action *action,
2811 : : struct rte_flow_error *err);
2812 : : struct rte_flow_action_handle *flow_dv_action_create(struct rte_eth_dev *dev,
2813 : : const struct rte_flow_indir_action_conf *conf,
2814 : : const struct rte_flow_action *action,
2815 : : struct rte_flow_error *err);
2816 : : int flow_dv_action_destroy(struct rte_eth_dev *dev,
2817 : : struct rte_flow_action_handle *handle,
2818 : : struct rte_flow_error *error);
2819 : : int flow_dv_action_update(struct rte_eth_dev *dev,
2820 : : struct rte_flow_action_handle *handle,
2821 : : const void *update,
2822 : : struct rte_flow_error *err);
2823 : : int flow_dv_action_query(struct rte_eth_dev *dev,
2824 : : const struct rte_flow_action_handle *handle,
2825 : : void *data,
2826 : : struct rte_flow_error *error);
2827 : : size_t flow_dv_get_item_hdr_len(const enum rte_flow_item_type item_type);
2828 : : int flow_dv_convert_encap_data(const struct rte_flow_item *items, uint8_t *buf,
2829 : : size_t *size, struct rte_flow_error *error);
2830 : : void mlx5_flow_field_id_to_modify_info
2831 : : (const struct rte_flow_action_modify_data *data,
2832 : : struct field_modify_info *info, uint32_t *mask,
2833 : : uint32_t width, struct rte_eth_dev *dev,
2834 : : const struct rte_flow_attr *attr, struct rte_flow_error *error);
2835 : : int flow_dv_convert_modify_action(struct rte_flow_item *item,
2836 : : struct field_modify_info *field,
2837 : : struct field_modify_info *dcopy,
2838 : : struct mlx5_flow_dv_modify_hdr_resource *resource,
2839 : : uint32_t type, struct rte_flow_error *error);
2840 : :
2841 : : #define MLX5_PF_VPORT_ID 0
2842 : : #define MLX5_ECPF_VPORT_ID 0xFFFE
2843 : :
2844 : : int16_t mlx5_flow_get_esw_manager_vport_id(struct rte_eth_dev *dev);
2845 : : int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev,
2846 : : const struct rte_flow_item *item,
2847 : : uint16_t *vport_id,
2848 : : bool *all_ports,
2849 : : struct rte_flow_error *error);
2850 : :
2851 : : int flow_dv_translate_items_hws(const struct rte_flow_item *items,
2852 : : struct mlx5_flow_attr *attr, void *key,
2853 : : uint32_t key_type, uint64_t *item_flags,
2854 : : uint8_t *match_criteria,
2855 : : struct rte_flow_error *error);
2856 : :
2857 : : int mlx5_flow_pick_transfer_proxy(struct rte_eth_dev *dev,
2858 : : uint16_t *proxy_port_id,
2859 : : struct rte_flow_error *error);
2860 : : int flow_null_get_aged_flows(struct rte_eth_dev *dev,
2861 : : void **context,
2862 : : uint32_t nb_contexts,
2863 : : struct rte_flow_error *error);
2864 : : uint32_t flow_null_counter_allocate(struct rte_eth_dev *dev);
2865 : : void flow_null_counter_free(struct rte_eth_dev *dev,
2866 : : uint32_t counter);
2867 : : int flow_null_counter_query(struct rte_eth_dev *dev,
2868 : : uint32_t counter,
2869 : : bool clear,
2870 : : uint64_t *pkts,
2871 : : uint64_t *bytes,
2872 : : void **action);
2873 : :
2874 : : int mlx5_flow_hw_flush_ctrl_flows(struct rte_eth_dev *dev);
2875 : :
2876 : : int mlx5_flow_hw_esw_create_sq_miss_flow(struct rte_eth_dev *dev,
2877 : : uint32_t sqn, bool external);
2878 : : int mlx5_flow_hw_esw_destroy_sq_miss_flow(struct rte_eth_dev *dev,
2879 : : uint32_t sqn);
2880 : : int mlx5_flow_hw_esw_create_default_jump_flow(struct rte_eth_dev *dev);
2881 : : int mlx5_flow_hw_create_tx_default_mreg_copy_flow(struct rte_eth_dev *dev);
2882 : : int mlx5_flow_hw_tx_repr_matching_flow(struct rte_eth_dev *dev, uint32_t sqn, bool external);
2883 : : int mlx5_flow_hw_lacp_rx_flow(struct rte_eth_dev *dev);
2884 : : int mlx5_flow_actions_validate(struct rte_eth_dev *dev,
2885 : : const struct rte_flow_actions_template_attr *attr,
2886 : : const struct rte_flow_action actions[],
2887 : : const struct rte_flow_action masks[],
2888 : : struct rte_flow_error *error);
2889 : : int mlx5_flow_pattern_validate(struct rte_eth_dev *dev,
2890 : : const struct rte_flow_pattern_template_attr *attr,
2891 : : const struct rte_flow_item items[],
2892 : : struct rte_flow_error *error);
2893 : : int flow_hw_table_update(struct rte_eth_dev *dev,
2894 : : struct rte_flow_error *error);
2895 : : int mlx5_flow_item_field_width(struct rte_eth_dev *dev,
2896 : : enum rte_flow_field_id field, int inherit,
2897 : : const struct rte_flow_attr *attr,
2898 : : struct rte_flow_error *error);
2899 : :
2900 : : static __rte_always_inline int
2901 : : flow_hw_get_srh_flex_parser_byte_off_from_ctx(void *dr_ctx __rte_unused)
2902 : : {
2903 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
2904 : : uint16_t port;
2905 : :
2906 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
2907 : : struct mlx5_priv *priv;
2908 : : struct mlx5_hca_flex_attr *attr;
2909 : : struct mlx5_devx_match_sample_info_query_attr *info;
2910 : :
2911 : 0 : priv = rte_eth_devices[port].data->dev_private;
2912 : 0 : attr = &priv->sh->cdev->config.hca_attr.flex;
2913 [ # # # # ]: 0 : if (priv->dr_ctx == dr_ctx && attr->query_match_sample_info) {
2914 : 0 : info = &priv->sh->srh_flex_parser.flex.devx_fp->sample_info[0];
2915 [ # # ]: 0 : if (priv->sh->srh_flex_parser.flex.mapnum)
2916 : 0 : return info->sample_dw_data * sizeof(uint32_t);
2917 : : else
2918 : : return UINT32_MAX;
2919 : : }
2920 : : }
2921 : : #endif
2922 : : return UINT32_MAX;
2923 : : }
2924 : :
2925 : : static __rte_always_inline uint8_t
2926 : : flow_hw_get_ipv6_route_ext_anchor_from_ctx(void *dr_ctx)
2927 : : {
2928 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
2929 : : uint16_t port;
2930 : : struct mlx5_priv *priv;
2931 : :
2932 [ # # ]: 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
2933 : 0 : priv = rte_eth_devices[port].data->dev_private;
2934 [ # # ]: 0 : if (priv->dr_ctx == dr_ctx)
2935 : 0 : return priv->sh->srh_flex_parser.flex.devx_fp->anchor_id;
2936 : : }
2937 : : #else
2938 : : RTE_SET_USED(dr_ctx);
2939 : : #endif
2940 : : return 0;
2941 : : }
2942 : :
2943 : : static __rte_always_inline uint16_t
2944 : : flow_hw_get_ipv6_route_ext_mod_id_from_ctx(void *dr_ctx, uint8_t idx)
2945 : : {
2946 : : #ifdef HAVE_IBV_FLOW_DV_SUPPORT
2947 : : uint16_t port;
2948 : : struct mlx5_priv *priv;
2949 : : struct mlx5_flex_parser_devx *fp;
2950 : :
2951 : : if (idx >= MLX5_GRAPH_NODE_SAMPLE_NUM || idx >= MLX5_SRV6_SAMPLE_NUM)
2952 : : return 0;
2953 [ # # # # : 0 : MLX5_ETH_FOREACH_DEV(port, NULL) {
# # # # #
# ]
2954 : 0 : priv = rte_eth_devices[port].data->dev_private;
2955 [ # # # # : 0 : if (priv->dr_ctx == dr_ctx) {
# # # # #
# ]
2956 : 0 : fp = priv->sh->srh_flex_parser.flex.devx_fp;
2957 : 0 : return fp->sample_info[idx].modify_field_id;
2958 : : }
2959 : : }
2960 : : #else
2961 : : RTE_SET_USED(dr_ctx);
2962 : : RTE_SET_USED(idx);
2963 : : #endif
2964 : : return 0;
2965 : : }
2966 : :
2967 : : void
2968 : : mlx5_indirect_list_handles_release(struct rte_eth_dev *dev);
2969 : : #ifdef HAVE_MLX5_HWS_SUPPORT
2970 : : struct mlx5_mirror;
2971 : : void
2972 : : mlx5_hw_mirror_destroy(struct rte_eth_dev *dev, struct mlx5_mirror *mirror);
2973 : : void
2974 : : mlx5_destroy_legacy_indirect(struct rte_eth_dev *dev,
2975 : : struct mlx5_indirect_list *ptr);
2976 : : void
2977 : : mlx5_hw_decap_encap_destroy(struct rte_eth_dev *dev,
2978 : : struct mlx5_indirect_list *reformat);
2979 : : #endif
2980 : : #endif /* RTE_PMD_MLX5_FLOW_H_ */
|