net/mlx5: extend skip scale flag
[dpdk.git] / drivers / net / mlx5 / mlx5_flow.h
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 <netinet/in.h>
9 #include <sys/queue.h>
10 #include <stdalign.h>
11 #include <stdint.h>
12 #include <string.h>
13
14 #include <rte_alarm.h>
15 #include <rte_mtr.h>
16
17 #include <mlx5_glue.h>
18 #include <mlx5_prm.h>
19
20 #include "mlx5.h"
21
22 /* Private rte flow items. */
23 enum mlx5_rte_flow_item_type {
24         MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
25         MLX5_RTE_FLOW_ITEM_TYPE_TAG,
26         MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE,
27         MLX5_RTE_FLOW_ITEM_TYPE_VLAN,
28         MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL,
29 };
30
31 /* Private (internal) rte flow actions. */
32 enum mlx5_rte_flow_action_type {
33         MLX5_RTE_FLOW_ACTION_TYPE_END = INT_MIN,
34         MLX5_RTE_FLOW_ACTION_TYPE_TAG,
35         MLX5_RTE_FLOW_ACTION_TYPE_MARK,
36         MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG,
37         MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS,
38         MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET,
39         MLX5_RTE_FLOW_ACTION_TYPE_AGE,
40 };
41
42 #define MLX5_SHARED_ACTION_TYPE_OFFSET 30
43
44 enum {
45         MLX5_SHARED_ACTION_TYPE_RSS,
46         MLX5_SHARED_ACTION_TYPE_AGE,
47 };
48
49 /* Matches on selected register. */
50 struct mlx5_rte_flow_item_tag {
51         enum modify_reg id;
52         uint32_t data;
53 };
54
55 /* Modify selected register. */
56 struct mlx5_rte_flow_action_set_tag {
57         enum modify_reg id;
58         uint32_t data;
59 };
60
61 struct mlx5_flow_action_copy_mreg {
62         enum modify_reg dst;
63         enum modify_reg src;
64 };
65
66 /* Matches on source queue. */
67 struct mlx5_rte_flow_item_tx_queue {
68         uint32_t queue;
69 };
70
71 /* Feature name to allocate metadata register. */
72 enum mlx5_feature_name {
73         MLX5_HAIRPIN_RX,
74         MLX5_HAIRPIN_TX,
75         MLX5_METADATA_RX,
76         MLX5_METADATA_TX,
77         MLX5_METADATA_FDB,
78         MLX5_FLOW_MARK,
79         MLX5_APP_TAG,
80         MLX5_COPY_MARK,
81         MLX5_MTR_COLOR,
82         MLX5_MTR_SFX,
83         MLX5_ASO_FLOW_HIT,
84 };
85
86 /* Default queue number. */
87 #define MLX5_RSSQ_DEFAULT_NUM 16
88
89 #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
90 #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
91 #define MLX5_FLOW_LAYER_OUTER_L3_IPV6 (1u << 2)
92 #define MLX5_FLOW_LAYER_OUTER_L4_UDP (1u << 3)
93 #define MLX5_FLOW_LAYER_OUTER_L4_TCP (1u << 4)
94 #define MLX5_FLOW_LAYER_OUTER_VLAN (1u << 5)
95
96 /* Pattern inner Layer bits. */
97 #define MLX5_FLOW_LAYER_INNER_L2 (1u << 6)
98 #define MLX5_FLOW_LAYER_INNER_L3_IPV4 (1u << 7)
99 #define MLX5_FLOW_LAYER_INNER_L3_IPV6 (1u << 8)
100 #define MLX5_FLOW_LAYER_INNER_L4_UDP (1u << 9)
101 #define MLX5_FLOW_LAYER_INNER_L4_TCP (1u << 10)
102 #define MLX5_FLOW_LAYER_INNER_VLAN (1u << 11)
103
104 /* Pattern tunnel Layer bits. */
105 #define MLX5_FLOW_LAYER_VXLAN (1u << 12)
106 #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13)
107 #define MLX5_FLOW_LAYER_GRE (1u << 14)
108 #define MLX5_FLOW_LAYER_MPLS (1u << 15)
109 /* List of tunnel Layer bits continued below. */
110
111 /* General pattern items bits. */
112 #define MLX5_FLOW_ITEM_METADATA (1u << 16)
113 #define MLX5_FLOW_ITEM_PORT_ID (1u << 17)
114 #define MLX5_FLOW_ITEM_TAG (1u << 18)
115 #define MLX5_FLOW_ITEM_MARK (1u << 19)
116
117 /* Pattern MISC bits. */
118 #define MLX5_FLOW_LAYER_ICMP (1u << 20)
119 #define MLX5_FLOW_LAYER_ICMP6 (1u << 21)
120 #define MLX5_FLOW_LAYER_GRE_KEY (1u << 22)
121
122 /* Pattern tunnel Layer bits (continued). */
123 #define MLX5_FLOW_LAYER_IPIP (1u << 23)
124 #define MLX5_FLOW_LAYER_IPV6_ENCAP (1u << 24)
125 #define MLX5_FLOW_LAYER_NVGRE (1u << 25)
126 #define MLX5_FLOW_LAYER_GENEVE (1u << 26)
127
128 /* Queue items. */
129 #define MLX5_FLOW_ITEM_TX_QUEUE (1u << 27)
130
131 /* Pattern tunnel Layer bits (continued). */
132 #define MLX5_FLOW_LAYER_GTP (1u << 28)
133
134 /* Pattern eCPRI Layer bit. */
135 #define MLX5_FLOW_LAYER_ECPRI (UINT64_C(1) << 29)
136
137 /* IPv6 Fragment Extension Header bit. */
138 #define MLX5_FLOW_LAYER_OUTER_L3_IPV6_FRAG_EXT (1u << 30)
139 #define MLX5_FLOW_LAYER_INNER_L3_IPV6_FRAG_EXT (1u << 31)
140
141 /* Pattern tunnel Layer bits (continued). */
142 #define MLX5_FLOW_LAYER_GENEVE_OPT (UINT64_C(1) << 32)
143 #define MLX5_FLOW_LAYER_GTP_PSC (UINT64_C(1) << 33)
144
145 /* Outer Masks. */
146 #define MLX5_FLOW_LAYER_OUTER_L3 \
147         (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
148 #define MLX5_FLOW_LAYER_OUTER_L4 \
149         (MLX5_FLOW_LAYER_OUTER_L4_UDP | MLX5_FLOW_LAYER_OUTER_L4_TCP)
150 #define MLX5_FLOW_LAYER_OUTER \
151         (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_OUTER_L3 | \
152          MLX5_FLOW_LAYER_OUTER_L4)
153
154 /* Tunnel Masks. */
155 #define MLX5_FLOW_LAYER_TUNNEL \
156         (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \
157          MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | MLX5_FLOW_LAYER_MPLS | \
158          MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP | \
159          MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP)
160
161 /* Inner Masks. */
162 #define MLX5_FLOW_LAYER_INNER_L3 \
163         (MLX5_FLOW_LAYER_INNER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
164 #define MLX5_FLOW_LAYER_INNER_L4 \
165         (MLX5_FLOW_LAYER_INNER_L4_UDP | MLX5_FLOW_LAYER_INNER_L4_TCP)
166 #define MLX5_FLOW_LAYER_INNER \
167         (MLX5_FLOW_LAYER_INNER_L2 | MLX5_FLOW_LAYER_INNER_L3 | \
168          MLX5_FLOW_LAYER_INNER_L4)
169
170 /* Layer Masks. */
171 #define MLX5_FLOW_LAYER_L2 \
172         (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_INNER_L2)
173 #define MLX5_FLOW_LAYER_L3_IPV4 \
174         (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV4)
175 #define MLX5_FLOW_LAYER_L3_IPV6 \
176         (MLX5_FLOW_LAYER_OUTER_L3_IPV6 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
177 #define MLX5_FLOW_LAYER_L3 \
178         (MLX5_FLOW_LAYER_L3_IPV4 | MLX5_FLOW_LAYER_L3_IPV6)
179 #define MLX5_FLOW_LAYER_L4 \
180         (MLX5_FLOW_LAYER_OUTER_L4 | MLX5_FLOW_LAYER_INNER_L4)
181
182 /* Actions */
183 #define MLX5_FLOW_ACTION_DROP (1u << 0)
184 #define MLX5_FLOW_ACTION_QUEUE (1u << 1)
185 #define MLX5_FLOW_ACTION_RSS (1u << 2)
186 #define MLX5_FLOW_ACTION_FLAG (1u << 3)
187 #define MLX5_FLOW_ACTION_MARK (1u << 4)
188 #define MLX5_FLOW_ACTION_COUNT (1u << 5)
189 #define MLX5_FLOW_ACTION_PORT_ID (1u << 6)
190 #define MLX5_FLOW_ACTION_OF_POP_VLAN (1u << 7)
191 #define MLX5_FLOW_ACTION_OF_PUSH_VLAN (1u << 8)
192 #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1u << 9)
193 #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1u << 10)
194 #define MLX5_FLOW_ACTION_SET_IPV4_SRC (1u << 11)
195 #define MLX5_FLOW_ACTION_SET_IPV4_DST (1u << 12)
196 #define MLX5_FLOW_ACTION_SET_IPV6_SRC (1u << 13)
197 #define MLX5_FLOW_ACTION_SET_IPV6_DST (1u << 14)
198 #define MLX5_FLOW_ACTION_SET_TP_SRC (1u << 15)
199 #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16)
200 #define MLX5_FLOW_ACTION_JUMP (1u << 17)
201 #define MLX5_FLOW_ACTION_SET_TTL (1u << 18)
202 #define MLX5_FLOW_ACTION_DEC_TTL (1u << 19)
203 #define MLX5_FLOW_ACTION_SET_MAC_SRC (1u << 20)
204 #define MLX5_FLOW_ACTION_SET_MAC_DST (1u << 21)
205 #define MLX5_FLOW_ACTION_ENCAP (1u << 22)
206 #define MLX5_FLOW_ACTION_DECAP (1u << 23)
207 #define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 24)
208 #define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 25)
209 #define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 26)
210 #define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 27)
211 #define MLX5_FLOW_ACTION_SET_TAG (1ull << 28)
212 #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 29)
213 #define MLX5_FLOW_ACTION_SET_META (1ull << 30)
214 #define MLX5_FLOW_ACTION_METER (1ull << 31)
215 #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32)
216 #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33)
217 #define MLX5_FLOW_ACTION_AGE (1ull << 34)
218 #define MLX5_FLOW_ACTION_DEFAULT_MISS (1ull << 35)
219 #define MLX5_FLOW_ACTION_SAMPLE (1ull << 36)
220 #define MLX5_FLOW_ACTION_TUNNEL_SET (1ull << 37)
221 #define MLX5_FLOW_ACTION_TUNNEL_MATCH (1ull << 38)
222
223 #define MLX5_FLOW_FATE_ACTIONS \
224         (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
225          MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \
226          MLX5_FLOW_ACTION_DEFAULT_MISS)
227
228 #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
229         (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
230          MLX5_FLOW_ACTION_JUMP)
231
232
233 #define MLX5_FLOW_MODIFY_HDR_ACTIONS (MLX5_FLOW_ACTION_SET_IPV4_SRC | \
234                                       MLX5_FLOW_ACTION_SET_IPV4_DST | \
235                                       MLX5_FLOW_ACTION_SET_IPV6_SRC | \
236                                       MLX5_FLOW_ACTION_SET_IPV6_DST | \
237                                       MLX5_FLOW_ACTION_SET_TP_SRC | \
238                                       MLX5_FLOW_ACTION_SET_TP_DST | \
239                                       MLX5_FLOW_ACTION_SET_TTL | \
240                                       MLX5_FLOW_ACTION_DEC_TTL | \
241                                       MLX5_FLOW_ACTION_SET_MAC_SRC | \
242                                       MLX5_FLOW_ACTION_SET_MAC_DST | \
243                                       MLX5_FLOW_ACTION_INC_TCP_SEQ | \
244                                       MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
245                                       MLX5_FLOW_ACTION_INC_TCP_ACK | \
246                                       MLX5_FLOW_ACTION_DEC_TCP_ACK | \
247                                       MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \
248                                       MLX5_FLOW_ACTION_SET_TAG | \
249                                       MLX5_FLOW_ACTION_MARK_EXT | \
250                                       MLX5_FLOW_ACTION_SET_META | \
251                                       MLX5_FLOW_ACTION_SET_IPV4_DSCP | \
252                                       MLX5_FLOW_ACTION_SET_IPV6_DSCP)
253
254 #define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \
255                                 MLX5_FLOW_ACTION_OF_PUSH_VLAN)
256
257 #define MLX5_FLOW_XCAP_ACTIONS (MLX5_FLOW_ACTION_ENCAP | MLX5_FLOW_ACTION_DECAP)
258
259 #ifndef IPPROTO_MPLS
260 #define IPPROTO_MPLS 137
261 #endif
262
263 /* UDP port number for MPLS */
264 #define MLX5_UDP_PORT_MPLS 6635
265
266 /* UDP port numbers for VxLAN. */
267 #define MLX5_UDP_PORT_VXLAN 4789
268 #define MLX5_UDP_PORT_VXLAN_GPE 4790
269
270 /* UDP port numbers for GENEVE. */
271 #define MLX5_UDP_PORT_GENEVE 6081
272
273 /* Priority reserved for default flows. */
274 #define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1)
275
276 /*
277  * Number of sub priorities.
278  * For each kind of pattern matching i.e. L2, L3, L4 to have a correct
279  * matching on the NIC (firmware dependent) L4 most have the higher priority
280  * followed by L3 and ending with L2.
281  */
282 #define MLX5_PRIORITY_MAP_L2 2
283 #define MLX5_PRIORITY_MAP_L3 1
284 #define MLX5_PRIORITY_MAP_L4 0
285 #define MLX5_PRIORITY_MAP_MAX 3
286
287 /* Valid layer type for IPV4 RSS. */
288 #define MLX5_IPV4_LAYER_TYPES \
289         (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
290          ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP | \
291          ETH_RSS_NONFRAG_IPV4_OTHER)
292
293 /* IBV hash source bits  for IPV4. */
294 #define MLX5_IPV4_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
295
296 /* Valid layer type for IPV6 RSS. */
297 #define MLX5_IPV6_LAYER_TYPES \
298         (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_TCP | \
299          ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_IPV6_EX  | ETH_RSS_IPV6_TCP_EX | \
300          ETH_RSS_IPV6_UDP_EX | ETH_RSS_NONFRAG_IPV6_OTHER)
301
302 /* IBV hash source bits  for IPV6. */
303 #define MLX5_IPV6_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
304
305 /* IBV hash bits for L3 SRC. */
306 #define MLX5_L3_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_SRC_IPV6)
307
308 /* IBV hash bits for L3 DST. */
309 #define MLX5_L3_DST_IBV_RX_HASH (IBV_RX_HASH_DST_IPV4 | IBV_RX_HASH_DST_IPV6)
310
311 /* IBV hash bits for TCP. */
312 #define MLX5_TCP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
313                               IBV_RX_HASH_DST_PORT_TCP)
314
315 /* IBV hash bits for UDP. */
316 #define MLX5_UDP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_UDP | \
317                               IBV_RX_HASH_DST_PORT_UDP)
318
319 /* IBV hash bits for L4 SRC. */
320 #define MLX5_L4_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
321                                  IBV_RX_HASH_SRC_PORT_UDP)
322
323 /* IBV hash bits for L4 DST. */
324 #define MLX5_L4_DST_IBV_RX_HASH (IBV_RX_HASH_DST_PORT_TCP | \
325                                  IBV_RX_HASH_DST_PORT_UDP)
326
327 /* Geneve header first 16Bit */
328 #define MLX5_GENEVE_VER_MASK 0x3
329 #define MLX5_GENEVE_VER_SHIFT 14
330 #define MLX5_GENEVE_VER_VAL(a) \
331                 (((a) >> (MLX5_GENEVE_VER_SHIFT)) & (MLX5_GENEVE_VER_MASK))
332 #define MLX5_GENEVE_OPTLEN_MASK 0x3F
333 #define MLX5_GENEVE_OPTLEN_SHIFT 8
334 #define MLX5_GENEVE_OPTLEN_VAL(a) \
335             (((a) >> (MLX5_GENEVE_OPTLEN_SHIFT)) & (MLX5_GENEVE_OPTLEN_MASK))
336 #define MLX5_GENEVE_OAMF_MASK 0x1
337 #define MLX5_GENEVE_OAMF_SHIFT 7
338 #define MLX5_GENEVE_OAMF_VAL(a) \
339                 (((a) >> (MLX5_GENEVE_OAMF_SHIFT)) & (MLX5_GENEVE_OAMF_MASK))
340 #define MLX5_GENEVE_CRITO_MASK 0x1
341 #define MLX5_GENEVE_CRITO_SHIFT 6
342 #define MLX5_GENEVE_CRITO_VAL(a) \
343                 (((a) >> (MLX5_GENEVE_CRITO_SHIFT)) & (MLX5_GENEVE_CRITO_MASK))
344 #define MLX5_GENEVE_RSVD_MASK 0x3F
345 #define MLX5_GENEVE_RSVD_VAL(a) ((a) & (MLX5_GENEVE_RSVD_MASK))
346 /*
347  * The length of the Geneve options fields, expressed in four byte multiples,
348  * not including the eight byte fixed tunnel.
349  */
350 #define MLX5_GENEVE_OPT_LEN_0 14
351 #define MLX5_GENEVE_OPT_LEN_1 63
352
353 #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_ether_hdr) + \
354                                           sizeof(struct rte_ipv4_hdr))
355 /* GTP extension header flag. */
356 #define MLX5_GTP_EXT_HEADER_FLAG 4
357
358 /* GTP extension header max PDU type value. */
359 #define MLX5_GTP_EXT_MAX_PDU_TYPE 15
360
361 /* GTP extension header PDU type shift. */
362 #define MLX5_GTP_PDU_TYPE_SHIFT(a) ((a) << 4)
363
364 /* IPv4 fragment_offset field contains relevant data in bits 2 to 15. */
365 #define MLX5_IPV4_FRAG_OFFSET_MASK \
366                 (RTE_IPV4_HDR_OFFSET_MASK | RTE_IPV4_HDR_MF_FLAG)
367
368 /* Specific item's fields can accept a range of values (using spec and last). */
369 #define MLX5_ITEM_RANGE_NOT_ACCEPTED    false
370 #define MLX5_ITEM_RANGE_ACCEPTED        true
371
372 /* Software header modify action numbers of a flow. */
373 #define MLX5_ACT_NUM_MDF_IPV4           1
374 #define MLX5_ACT_NUM_MDF_IPV6           4
375 #define MLX5_ACT_NUM_MDF_MAC            2
376 #define MLX5_ACT_NUM_MDF_VID            1
377 #define MLX5_ACT_NUM_MDF_PORT           2
378 #define MLX5_ACT_NUM_MDF_TTL            1
379 #define MLX5_ACT_NUM_DEC_TTL            MLX5_ACT_NUM_MDF_TTL
380 #define MLX5_ACT_NUM_MDF_TCPSEQ         1
381 #define MLX5_ACT_NUM_MDF_TCPACK         1
382 #define MLX5_ACT_NUM_SET_REG            1
383 #define MLX5_ACT_NUM_SET_TAG            1
384 #define MLX5_ACT_NUM_CPY_MREG           MLX5_ACT_NUM_SET_TAG
385 #define MLX5_ACT_NUM_SET_MARK           MLX5_ACT_NUM_SET_TAG
386 #define MLX5_ACT_NUM_SET_META           MLX5_ACT_NUM_SET_TAG
387 #define MLX5_ACT_NUM_SET_DSCP           1
388
389 enum mlx5_flow_drv_type {
390         MLX5_FLOW_TYPE_MIN,
391         MLX5_FLOW_TYPE_DV,
392         MLX5_FLOW_TYPE_VERBS,
393         MLX5_FLOW_TYPE_MAX,
394 };
395
396 /* Fate action type. */
397 enum mlx5_flow_fate_type {
398         MLX5_FLOW_FATE_NONE, /* Egress flow. */
399         MLX5_FLOW_FATE_QUEUE,
400         MLX5_FLOW_FATE_JUMP,
401         MLX5_FLOW_FATE_PORT_ID,
402         MLX5_FLOW_FATE_DROP,
403         MLX5_FLOW_FATE_DEFAULT_MISS,
404         MLX5_FLOW_FATE_SHARED_RSS,
405         MLX5_FLOW_FATE_MAX,
406 };
407
408 /* Matcher PRM representation */
409 struct mlx5_flow_dv_match_params {
410         size_t size;
411         /**< Size of match value. Do NOT split size and key! */
412         uint32_t buf[MLX5_ST_SZ_DW(fte_match_param)];
413         /**< Matcher value. This value is used as the mask or as a key. */
414 };
415
416 /* Matcher structure. */
417 struct mlx5_flow_dv_matcher {
418         struct mlx5_cache_entry entry; /**< Pointer to the next element. */
419         struct mlx5_flow_tbl_resource *tbl;
420         /**< Pointer to the table(group) the matcher associated with. */
421         void *matcher_object; /**< Pointer to DV matcher */
422         uint16_t crc; /**< CRC of key. */
423         uint16_t priority; /**< Priority of matcher. */
424         struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
425 };
426
427 #define MLX5_ENCAP_MAX_LEN 132
428
429 /* Encap/decap resource structure. */
430 struct mlx5_flow_dv_encap_decap_resource {
431         struct mlx5_hlist_entry entry;
432         /* Pointer to next element. */
433         uint32_t refcnt; /**< Reference counter. */
434         void *action;
435         /**< Encap/decap action object. */
436         uint8_t buf[MLX5_ENCAP_MAX_LEN];
437         size_t size;
438         uint8_t reformat_type;
439         uint8_t ft_type;
440         uint64_t flags; /**< Flags for RDMA API. */
441         uint32_t idx; /**< Index for the index memory pool. */
442 };
443
444 /* Tag resource structure. */
445 struct mlx5_flow_dv_tag_resource {
446         struct mlx5_hlist_entry entry;
447         /**< hash list entry for tag resource, tag value as the key. */
448         void *action;
449         /**< Tag action object. */
450         uint32_t refcnt; /**< Reference counter. */
451         uint32_t idx; /**< Index for the index memory pool. */
452         uint32_t tag_id; /**< Tag ID. */
453 };
454
455 /*
456  * Number of modification commands.
457  * The maximal actions amount in FW is some constant, and it is 16 in the
458  * latest releases. In some old releases, it will be limited to 8.
459  * Since there is no interface to query the capacity, the maximal value should
460  * be used to allow PMD to create the flow. The validation will be done in the
461  * lower driver layer or FW. A failure will be returned if exceeds the maximal
462  * supported actions number on the root table.
463  * On non-root tables, there is no limitation, but 32 is enough right now.
464  */
465 #define MLX5_MAX_MODIFY_NUM                     32
466 #define MLX5_ROOT_TBL_MODIFY_NUM                16
467
468 /* Modify resource structure */
469 struct mlx5_flow_dv_modify_hdr_resource {
470         struct mlx5_hlist_entry entry;
471         void *action; /**< Modify header action object. */
472         /* Key area for hash list matching: */
473         uint8_t ft_type; /**< Flow table type, Rx or Tx. */
474         uint32_t actions_num; /**< Number of modification actions. */
475         uint64_t flags; /**< Flags for RDMA API. */
476         struct mlx5_modification_cmd actions[];
477         /**< Modification actions. */
478 };
479
480 /* Modify resource key of the hash organization. */
481 union mlx5_flow_modify_hdr_key {
482         struct {
483                 uint32_t ft_type:8;     /**< Flow table type, Rx or Tx. */
484                 uint32_t actions_num:5; /**< Number of modification actions. */
485                 uint32_t group:19;      /**< Flow group id. */
486                 uint32_t cksum;         /**< Actions check sum. */
487         };
488         uint64_t v64;                   /**< full 64bits value of key */
489 };
490
491 /* Jump action resource structure. */
492 struct mlx5_flow_dv_jump_tbl_resource {
493         void *action; /**< Pointer to the rdma core action. */
494 };
495
496 /* Port ID resource structure. */
497 struct mlx5_flow_dv_port_id_action_resource {
498         struct mlx5_cache_entry entry;
499         void *action; /**< Action object. */
500         uint32_t port_id; /**< Port ID value. */
501         uint32_t idx; /**< Indexed pool memory index. */
502 };
503
504 /* Push VLAN action resource structure */
505 struct mlx5_flow_dv_push_vlan_action_resource {
506         struct mlx5_cache_entry entry; /* Cache entry. */
507         void *action; /**< Action object. */
508         uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */
509         rte_be32_t vlan_tag; /**< VLAN tag value. */
510         uint32_t idx; /**< Indexed pool memory index. */
511 };
512
513 /* Metadata register copy table entry. */
514 struct mlx5_flow_mreg_copy_resource {
515         /*
516          * Hash list entry for copy table.
517          *  - Key is 32/64-bit MARK action ID.
518          *  - MUST be the first entry.
519          */
520         struct mlx5_hlist_entry hlist_ent;
521         LIST_ENTRY(mlx5_flow_mreg_copy_resource) next;
522         /* List entry for device flows. */
523         uint32_t idx;
524         uint32_t rix_flow; /* Built flow for copy. */
525         uint32_t mark_id;
526 };
527
528 /* Table tunnel parameter. */
529 struct mlx5_flow_tbl_tunnel_prm {
530         const struct mlx5_flow_tunnel *tunnel;
531         uint32_t group_id;
532         bool external;
533 };
534
535 /* Table data structure of the hash organization. */
536 struct mlx5_flow_tbl_data_entry {
537         struct mlx5_hlist_entry entry;
538         /**< hash list entry, 64-bits key inside. */
539         struct mlx5_flow_tbl_resource tbl;
540         /**< flow table resource. */
541         struct mlx5_cache_list matchers;
542         /**< matchers' header associated with the flow table. */
543         struct mlx5_flow_dv_jump_tbl_resource jump;
544         /**< jump resource, at most one for each table created. */
545         uint32_t idx; /**< index for the indexed mempool. */
546         /**< tunnel offload */
547         const struct mlx5_flow_tunnel *tunnel;
548         uint32_t group_id;
549         uint32_t external:1;
550         uint32_t tunnel_offload:1; /* Tunnel offlod table or not. */
551         uint32_t is_egress:1; /**< Egress table. */
552         uint32_t is_transfer:1; /**< Transfer table. */
553         uint32_t dummy:1; /**<  DR table. */
554         uint32_t reserve:27; /**< Reserved to future using. */
555         uint32_t table_id; /**< Table ID. */
556 };
557
558 /* Sub rdma-core actions list. */
559 struct mlx5_flow_sub_actions_list {
560         uint32_t actions_num; /**< Number of sample actions. */
561         uint64_t action_flags;
562         void *dr_queue_action;
563         void *dr_tag_action;
564         void *dr_cnt_action;
565         void *dr_port_id_action;
566         void *dr_encap_action;
567         void *dr_jump_action;
568 };
569
570 /* Sample sub-actions resource list. */
571 struct mlx5_flow_sub_actions_idx {
572         uint32_t rix_hrxq; /**< Hash Rx queue object index. */
573         uint32_t rix_tag; /**< Index to the tag action. */
574         uint32_t cnt;
575         uint32_t rix_port_id_action; /**< Index to port ID action resource. */
576         uint32_t rix_encap_decap; /**< Index to encap/decap resource. */
577         uint32_t rix_jump; /**< Index to the jump action resource. */
578 };
579
580 /* Sample action resource structure. */
581 struct mlx5_flow_dv_sample_resource {
582         struct mlx5_cache_entry entry; /**< Cache entry. */
583         union {
584                 void *verbs_action; /**< Verbs sample action object. */
585                 void **sub_actions; /**< Sample sub-action array. */
586         };
587         struct rte_eth_dev *dev; /**< Device registers the action. */
588         uint32_t idx; /** Sample object index. */
589         uint8_t ft_type; /** Flow Table Type */
590         uint32_t ft_id; /** Flow Table Level */
591         uint32_t ratio;   /** Sample Ratio */
592         uint64_t set_action; /** Restore reg_c0 value */
593         void *normal_path_tbl; /** Flow Table pointer */
594         void *default_miss; /** default_miss dr_action. */
595         struct mlx5_flow_sub_actions_idx sample_idx;
596         /**< Action index resources. */
597         struct mlx5_flow_sub_actions_list sample_act;
598         /**< Action resources. */
599 };
600
601 #define MLX5_MAX_DEST_NUM       2
602
603 /* Destination array action resource structure. */
604 struct mlx5_flow_dv_dest_array_resource {
605         struct mlx5_cache_entry entry; /**< Cache entry. */
606         uint32_t idx; /** Destination array action object index. */
607         uint8_t ft_type; /** Flow Table Type */
608         uint8_t num_of_dest; /**< Number of destination actions. */
609         struct rte_eth_dev *dev; /**< Device registers the action. */
610         void *action; /**< Pointer to the rdma core action. */
611         struct mlx5_flow_sub_actions_idx sample_idx[MLX5_MAX_DEST_NUM];
612         /**< Action index resources. */
613         struct mlx5_flow_sub_actions_list sample_act[MLX5_MAX_DEST_NUM];
614         /**< Action resources. */
615 };
616
617 /* PMD flow priority for tunnel */
618 #define MLX5_TUNNEL_PRIO_GET(rss_desc) \
619         ((rss_desc)->level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4)
620
621
622 /** Device flow handle structure for DV mode only. */
623 struct mlx5_flow_handle_dv {
624         /* Flow DV api: */
625         struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
626         struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
627         /**< Pointer to modify header resource in cache. */
628         uint32_t rix_encap_decap;
629         /**< Index to encap/decap resource in cache. */
630         uint32_t rix_push_vlan;
631         /**< Index to push VLAN action resource in cache. */
632         uint32_t rix_tag;
633         /**< Index to the tag action. */
634         uint32_t rix_sample;
635         /**< Index to sample action resource in cache. */
636         uint32_t rix_dest_array;
637         /**< Index to destination array resource in cache. */
638 } __rte_packed;
639
640 /** Device flow handle structure: used both for creating & destroying. */
641 struct mlx5_flow_handle {
642         SILIST_ENTRY(uint32_t)next;
643         struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
644         /**< Index to next device flow handle. */
645         uint64_t layers;
646         /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */
647         void *drv_flow; /**< pointer to driver flow object. */
648         uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */
649         uint32_t mark:1; /**< Metadate rxq mark flag. */
650         uint32_t fate_action:3; /**< Fate action type. */
651         union {
652                 uint32_t rix_hrxq; /**< Hash Rx queue object index. */
653                 uint32_t rix_jump; /**< Index to the jump action resource. */
654                 uint32_t rix_port_id_action;
655                 /**< Index to port ID action resource. */
656                 uint32_t rix_fate;
657                 /**< Generic value indicates the fate action. */
658                 uint32_t rix_default_fate;
659                 /**< Indicates default miss fate action. */
660                 uint32_t rix_srss;
661                 /**< Indicates shared RSS fate action. */
662         };
663 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
664         struct mlx5_flow_handle_dv dvh;
665 #endif
666 } __rte_packed;
667
668 /*
669  * Size for Verbs device flow handle structure only. Do not use the DV only
670  * structure in Verbs. No DV flows attributes will be accessed.
671  * Macro offsetof() could also be used here.
672  */
673 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
674 #define MLX5_FLOW_HANDLE_VERBS_SIZE \
675         (sizeof(struct mlx5_flow_handle) - sizeof(struct mlx5_flow_handle_dv))
676 #else
677 #define MLX5_FLOW_HANDLE_VERBS_SIZE (sizeof(struct mlx5_flow_handle))
678 #endif
679
680 /*
681  * Max number of actions per DV flow.
682  * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED
683  * in rdma-core file providers/mlx5/verbs.c.
684  */
685 #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
686
687 /** Device flow structure only for DV flow creation. */
688 struct mlx5_flow_dv_workspace {
689         uint32_t group; /**< The group index. */
690         uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
691         int actions_n; /**< number of actions. */
692         void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; /**< Action list. */
693         struct mlx5_flow_dv_encap_decap_resource *encap_decap;
694         /**< Pointer to encap/decap resource in cache. */
695         struct mlx5_flow_dv_push_vlan_action_resource *push_vlan_res;
696         /**< Pointer to push VLAN action resource in cache. */
697         struct mlx5_flow_dv_tag_resource *tag_resource;
698         /**< pointer to the tag action. */
699         struct mlx5_flow_dv_port_id_action_resource *port_id_action;
700         /**< Pointer to port ID action resource. */
701         struct mlx5_flow_dv_jump_tbl_resource *jump;
702         /**< Pointer to the jump action resource. */
703         struct mlx5_flow_dv_match_params value;
704         /**< Holds the value that the packet is compared to. */
705         struct mlx5_flow_dv_sample_resource *sample_res;
706         /**< Pointer to the sample action resource. */
707         struct mlx5_flow_dv_dest_array_resource *dest_array_res;
708         /**< Pointer to the destination array resource. */
709 };
710
711 #ifdef HAVE_INFINIBAND_VERBS_H
712 /*
713  * Maximal Verbs flow specifications & actions size.
714  * Some elements are mutually exclusive, but enough space should be allocated.
715  * Tunnel cases: 1. Max 2 Ethernet + IP(v6 len > v4 len) + TCP/UDP headers.
716  *               2. One tunnel header (exception: GRE + MPLS),
717  *                  SPEC length: GRE == tunnel.
718  * Actions: 1. 1 Mark OR Flag.
719  *          2. 1 Drop (if any).
720  *          3. No limitation for counters, but it makes no sense to support too
721  *             many counters in a single device flow.
722  */
723 #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
724 #define MLX5_VERBS_MAX_SPEC_SIZE \
725                 ( \
726                         (2 * (sizeof(struct ibv_flow_spec_eth) + \
727                               sizeof(struct ibv_flow_spec_ipv6) + \
728                               sizeof(struct ibv_flow_spec_tcp_udp)) + \
729                         sizeof(struct ibv_flow_spec_gre) + \
730                         sizeof(struct ibv_flow_spec_mpls)) \
731                 )
732 #else
733 #define MLX5_VERBS_MAX_SPEC_SIZE \
734                 ( \
735                         (2 * (sizeof(struct ibv_flow_spec_eth) + \
736                               sizeof(struct ibv_flow_spec_ipv6) + \
737                               sizeof(struct ibv_flow_spec_tcp_udp)) + \
738                         sizeof(struct ibv_flow_spec_tunnel)) \
739                 )
740 #endif
741
742 #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \
743         defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
744 #define MLX5_VERBS_MAX_ACT_SIZE \
745                 ( \
746                         sizeof(struct ibv_flow_spec_action_tag) + \
747                         sizeof(struct ibv_flow_spec_action_drop) + \
748                         sizeof(struct ibv_flow_spec_counter_action) * 4 \
749                 )
750 #else
751 #define MLX5_VERBS_MAX_ACT_SIZE \
752                 ( \
753                         sizeof(struct ibv_flow_spec_action_tag) + \
754                         sizeof(struct ibv_flow_spec_action_drop) \
755                 )
756 #endif
757
758 #define MLX5_VERBS_MAX_SPEC_ACT_SIZE \
759                 (MLX5_VERBS_MAX_SPEC_SIZE + MLX5_VERBS_MAX_ACT_SIZE)
760
761 /** Device flow structure only for Verbs flow creation. */
762 struct mlx5_flow_verbs_workspace {
763         unsigned int size; /**< Size of the attribute. */
764         struct ibv_flow_attr attr; /**< Verbs flow attribute buffer. */
765         uint8_t specs[MLX5_VERBS_MAX_SPEC_ACT_SIZE];
766         /**< Specifications & actions buffer of verbs flow. */
767 };
768 #endif /* HAVE_INFINIBAND_VERBS_H */
769
770 #define MLX5_SCALE_FLOW_GROUP_BIT 0
771 #define MLX5_SCALE_JUMP_FLOW_GROUP_BIT 1
772
773 /** Maximal number of device sub-flows supported. */
774 #define MLX5_NUM_MAX_DEV_FLOWS 32
775
776 /** Device flow structure. */
777 __extension__
778 struct mlx5_flow {
779         struct rte_flow *flow; /**< Pointer to the main flow. */
780         uint32_t flow_idx; /**< The memory pool index to the main flow. */
781         uint64_t hash_fields; /**< Hash Rx queue hash fields. */
782         uint64_t act_flags;
783         /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
784         bool external; /**< true if the flow is created external to PMD. */
785         uint8_t ingress:1; /**< 1 if the flow is ingress. */
786         uint8_t skip_scale:2;
787         /**
788          * Each Bit be set to 1 if Skip the scale the flow group with factor.
789          * If bit0 be set to 1, then skip the scale the original flow group;
790          * If bit1 be set to 1, then skip the scale the jump flow group if
791          * having jump action.
792          * 00: Enable scale in a flow, default value.
793          * 01: Skip scale the flow group with factor, enable scale the group
794          * of jump action.
795          * 10: Enable scale the group with factor, skip scale the group of
796          * jump action.
797          * 11: Skip scale the table with factor both for flow group and jump
798          * group.
799          */
800         union {
801 #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
802                 struct mlx5_flow_dv_workspace dv;
803 #endif
804 #ifdef HAVE_INFINIBAND_VERBS_H
805                 struct mlx5_flow_verbs_workspace verbs;
806 #endif
807         };
808         struct mlx5_flow_handle *handle;
809         uint32_t handle_idx; /* Index of the mlx5 flow handle memory. */
810         const struct mlx5_flow_tunnel *tunnel;
811 };
812
813 /* Flow meter state. */
814 #define MLX5_FLOW_METER_DISABLE 0
815 #define MLX5_FLOW_METER_ENABLE 1
816
817 #define MLX5_MAN_WIDTH 8
818 /* Modify this value if enum rte_mtr_color changes. */
819 #define RTE_MTR_DROPPED RTE_COLORS
820
821 /* Meter policer statistics */
822 struct mlx5_flow_policer_stats {
823         uint32_t cnt[RTE_COLORS + 1];
824         /**< Color counter, extra for drop. */
825         uint64_t stats_mask;
826         /**< Statistics mask for the colors. */
827 };
828
829 /* Meter table structure. */
830 struct mlx5_meter_domain_info {
831         struct mlx5_flow_tbl_resource *tbl;
832         /**< Meter table. */
833         struct mlx5_flow_tbl_resource *sfx_tbl;
834         /**< Meter suffix table. */
835         void *any_matcher;
836         /**< Meter color not match default criteria. */
837         void *color_matcher;
838         /**< Meter color match criteria. */
839         void *jump_actn;
840         /**< Meter match action. */
841         void *policer_rules[RTE_MTR_DROPPED + 1];
842         /**< Meter policer for the match. */
843 };
844
845 /* Meter table set for TX RX FDB. */
846 struct mlx5_meter_domains_infos {
847         uint32_t ref_cnt;
848         /**< Table user count. */
849         struct mlx5_meter_domain_info egress;
850         /**< TX meter table. */
851         struct mlx5_meter_domain_info ingress;
852         /**< RX meter table. */
853         struct mlx5_meter_domain_info transfer;
854         /**< FDB meter table. */
855         void *drop_actn;
856         /**< Drop action as not matched. */
857         void *count_actns[RTE_MTR_DROPPED + 1];
858         /**< Counters for match and unmatched statistics. */
859         uint32_t fmp[MLX5_ST_SZ_DW(flow_meter_parameters)];
860         /**< Flow meter parameter. */
861         size_t fmp_size;
862         /**< Flow meter parameter size. */
863         void *meter_action;
864         /**< Flow meter action. */
865 };
866
867 /* Meter parameter structure. */
868 struct mlx5_flow_meter {
869         TAILQ_ENTRY(mlx5_flow_meter) next;
870         /**< Pointer to the next flow meter structure. */
871         uint32_t idx; /* Index to meter object. */
872         uint32_t meter_id;
873         /**< Meter id. */
874         struct mlx5_flow_meter_profile *profile;
875         /**< Meter profile parameters. */
876
877         rte_spinlock_t sl; /**< Meter action spinlock. */
878
879         /** Policer actions (per meter output color). */
880         enum rte_mtr_policer_action action[RTE_COLORS];
881
882         /** Set of stats counters to be enabled.
883          * @see enum rte_mtr_stats_type
884          */
885         uint64_t stats_mask;
886
887         /**< Rule applies to ingress traffic. */
888         uint32_t ingress:1;
889
890         /**< Rule applies to egress traffic. */
891         uint32_t egress:1;
892         /**
893          * Instead of simply matching the properties of traffic as it would
894          * appear on a given DPDK port ID, enabling this attribute transfers
895          * a flow rule to the lowest possible level of any device endpoints
896          * found in the pattern.
897          *
898          * When supported, this effectively enables an application to
899          * re-route traffic not necessarily intended for it (e.g. coming
900          * from or addressed to different physical ports, VFs or
901          * applications) at the device level.
902          *
903          * It complements the behavior of some pattern items such as
904          * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
905          *
906          * When transferring flow rules, ingress and egress attributes keep
907          * their original meaning, as if processing traffic emitted or
908          * received by the application.
909          */
910         uint32_t transfer:1;
911         struct mlx5_meter_domains_infos *mfts;
912         /**< Flow table created for this meter. */
913         struct mlx5_flow_policer_stats policer_stats;
914         /**< Meter policer statistics. */
915         uint32_t ref_cnt;
916         /**< Use count. */
917         uint32_t active_state:1;
918         /**< Meter state. */
919         uint32_t shared:1;
920         /**< Meter shared or not. */
921 };
922
923 /* RFC2697 parameter structure. */
924 struct mlx5_flow_meter_srtcm_rfc2697_prm {
925         /* green_saturation_value = cbs_mantissa * 2^cbs_exponent */
926         uint32_t cbs_exponent:5;
927         uint32_t cbs_mantissa:8;
928         /* cir = 8G * cir_mantissa * 1/(2^cir_exponent) Bytes/Sec */
929         uint32_t cir_exponent:5;
930         uint32_t cir_mantissa:8;
931         /* yellow _saturation_value = ebs_mantissa * 2^ebs_exponent */
932         uint32_t ebs_exponent:5;
933         uint32_t ebs_mantissa:8;
934 };
935
936 /* Flow meter profile structure. */
937 struct mlx5_flow_meter_profile {
938         TAILQ_ENTRY(mlx5_flow_meter_profile) next;
939         /**< Pointer to the next flow meter structure. */
940         uint32_t meter_profile_id; /**< Profile id. */
941         struct rte_mtr_meter_profile profile; /**< Profile detail. */
942         union {
943                 struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm_prm;
944                 /**< srtcm_rfc2697 struct. */
945         };
946         uint32_t ref_cnt; /**< Use count. */
947 };
948
949 #define MLX5_MAX_TUNNELS 256
950 #define MLX5_TNL_MISS_RULE_PRIORITY 3
951 #define MLX5_TNL_MISS_FDB_JUMP_GRP  0x1234faac
952
953 /*
954  * When tunnel offload is active, all JUMP group ids are converted
955  * using the same method. That conversion is applied both to tunnel and
956  * regular rule types.
957  * Group ids used in tunnel rules are relative to it's tunnel (!).
958  * Application can create number of steer rules, using the same
959  * tunnel, with different group id in each rule.
960  * Each tunnel stores its groups internally in PMD tunnel object.
961  * Groups used in regular rules do not belong to any tunnel and are stored
962  * in tunnel hub.
963  */
964
965 struct mlx5_flow_tunnel {
966         LIST_ENTRY(mlx5_flow_tunnel) chain;
967         struct rte_flow_tunnel app_tunnel;      /** app tunnel copy */
968         uint32_t tunnel_id;                     /** unique tunnel ID */
969         uint32_t refctn;
970         struct rte_flow_action action;
971         struct rte_flow_item item;
972         struct mlx5_hlist *groups;              /** tunnel groups */
973 };
974
975 /** PMD tunnel related context */
976 struct mlx5_flow_tunnel_hub {
977         /* Tunnels list
978          * Access to the list MUST be MT protected
979          */
980         LIST_HEAD(, mlx5_flow_tunnel) tunnels;
981          /* protect access to the tunnels list */
982         rte_spinlock_t sl;
983         struct mlx5_hlist *groups;              /** non tunnel groups */
984 };
985
986 /* convert jump group to flow table ID in tunnel rules */
987 struct tunnel_tbl_entry {
988         struct mlx5_hlist_entry hash;
989         uint32_t flow_table;
990         uint32_t tunnel_id;
991         uint32_t group;
992 };
993
994 static inline uint32_t
995 tunnel_id_to_flow_tbl(uint32_t id)
996 {
997         return id | (1u << 16);
998 }
999
1000 static inline uint32_t
1001 tunnel_flow_tbl_to_id(uint32_t flow_tbl)
1002 {
1003         return flow_tbl & ~(1u << 16);
1004 }
1005
1006 union tunnel_tbl_key {
1007         uint64_t val;
1008         struct {
1009                 uint32_t tunnel_id;
1010                 uint32_t group;
1011         };
1012 };
1013
1014 static inline struct mlx5_flow_tunnel_hub *
1015 mlx5_tunnel_hub(struct rte_eth_dev *dev)
1016 {
1017         struct mlx5_priv *priv = dev->data->dev_private;
1018         return priv->sh->tunnel_hub;
1019 }
1020
1021 static inline bool
1022 is_tunnel_offload_active(struct rte_eth_dev *dev)
1023 {
1024 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
1025         struct mlx5_priv *priv = dev->data->dev_private;
1026         return !!priv->config.dv_miss_info;
1027 #else
1028         RTE_SET_USED(dev);
1029         return false;
1030 #endif
1031 }
1032
1033 static inline bool
1034 is_flow_tunnel_match_rule(__rte_unused struct rte_eth_dev *dev,
1035                           __rte_unused const struct rte_flow_attr *attr,
1036                           __rte_unused const struct rte_flow_item items[],
1037                           __rte_unused const struct rte_flow_action actions[])
1038 {
1039         return (items[0].type == (typeof(items[0].type))
1040                                  MLX5_RTE_FLOW_ITEM_TYPE_TUNNEL);
1041 }
1042
1043 static inline bool
1044 is_flow_tunnel_steer_rule(__rte_unused struct rte_eth_dev *dev,
1045                           __rte_unused const struct rte_flow_attr *attr,
1046                           __rte_unused const struct rte_flow_item items[],
1047                           __rte_unused const struct rte_flow_action actions[])
1048 {
1049         return (actions[0].type == (typeof(actions[0].type))
1050                                    MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET);
1051 }
1052
1053 static inline const struct mlx5_flow_tunnel *
1054 flow_actions_to_tunnel(const struct rte_flow_action actions[])
1055 {
1056         return actions[0].conf;
1057 }
1058
1059 static inline const struct mlx5_flow_tunnel *
1060 flow_items_to_tunnel(const struct rte_flow_item items[])
1061 {
1062         return items[0].spec;
1063 }
1064
1065 /* Flow structure. */
1066 struct rte_flow {
1067         ILIST_ENTRY(uint32_t)next; /**< Index to the next flow structure. */
1068         uint32_t dev_handles;
1069         /**< Device flow handles that are part of the flow. */
1070         uint32_t drv_type:2; /**< Driver type. */
1071         uint32_t tunnel:1;
1072         uint32_t meter:16; /**< Holds flow meter id. */
1073         uint32_t rix_mreg_copy;
1074         /**< Index to metadata register copy table resource. */
1075         uint32_t counter; /**< Holds flow counter. */
1076         uint32_t tunnel_id;  /**< Tunnel id */
1077         uint32_t age; /**< Holds ASO age bit index. */
1078         uint32_t geneve_tlv_option; /**< Holds Geneve TLV option id. > */
1079 } __rte_packed;
1080
1081 /*
1082  * Define list of valid combinations of RX Hash fields
1083  * (see enum ibv_rx_hash_fields).
1084  */
1085 #define MLX5_RSS_HASH_IPV4 (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
1086 #define MLX5_RSS_HASH_IPV4_TCP \
1087         (MLX5_RSS_HASH_IPV4 | \
1088          IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_SRC_PORT_TCP)
1089 #define MLX5_RSS_HASH_IPV4_UDP \
1090         (MLX5_RSS_HASH_IPV4 | \
1091          IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_SRC_PORT_UDP)
1092 #define MLX5_RSS_HASH_IPV6 (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
1093 #define MLX5_RSS_HASH_IPV6_TCP \
1094         (MLX5_RSS_HASH_IPV6 | \
1095          IBV_RX_HASH_SRC_PORT_TCP | IBV_RX_HASH_SRC_PORT_TCP)
1096 #define MLX5_RSS_HASH_IPV6_UDP \
1097         (MLX5_RSS_HASH_IPV6 | \
1098          IBV_RX_HASH_SRC_PORT_UDP | IBV_RX_HASH_SRC_PORT_UDP)
1099 #define MLX5_RSS_HASH_NONE 0ULL
1100
1101 /* array of valid combinations of RX Hash fields for RSS */
1102 static const uint64_t mlx5_rss_hash_fields[] = {
1103         MLX5_RSS_HASH_IPV4,
1104         MLX5_RSS_HASH_IPV4_TCP,
1105         MLX5_RSS_HASH_IPV4_UDP,
1106         MLX5_RSS_HASH_IPV6,
1107         MLX5_RSS_HASH_IPV6_TCP,
1108         MLX5_RSS_HASH_IPV6_UDP,
1109         MLX5_RSS_HASH_NONE,
1110 };
1111
1112 /* Shared RSS action structure */
1113 struct mlx5_shared_action_rss {
1114         ILIST_ENTRY(uint32_t)next; /**< Index to the next RSS structure. */
1115         uint32_t refcnt; /**< Atomically accessed refcnt. */
1116         struct rte_flow_action_rss origin; /**< Original rte RSS action. */
1117         uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
1118         struct mlx5_ind_table_obj *ind_tbl;
1119         /**< Hash RX queues (hrxq, hrxq_tunnel fields) indirection table. */
1120         uint32_t hrxq[MLX5_RSS_HASH_FIELDS_LEN];
1121         /**< Hash RX queue indexes mapped to mlx5_rss_hash_fields */
1122         uint32_t hrxq_tunnel[MLX5_RSS_HASH_FIELDS_LEN];
1123         /**< Hash RX queue indexes for tunneled RSS */
1124         rte_spinlock_t action_rss_sl; /**< Shared RSS action spinlock. */
1125 };
1126
1127 struct rte_flow_shared_action {
1128         uint32_t id;
1129 };
1130
1131 /* Thread specific flow workspace intermediate data. */
1132 struct mlx5_flow_workspace {
1133         /* If creating another flow in same thread, push new as stack. */
1134         struct mlx5_flow_workspace *prev;
1135         struct mlx5_flow_workspace *next;
1136         uint32_t inuse; /* can't create new flow with current. */
1137         struct mlx5_flow flows[MLX5_NUM_MAX_DEV_FLOWS];
1138         struct mlx5_flow_rss_desc rss_desc;
1139         uint32_t rssq_num; /* Allocated queue num in rss_desc. */
1140         uint32_t flow_idx; /* Intermediate device flow index. */
1141 };
1142
1143 struct mlx5_flow_split_info {
1144         bool external;
1145         /**< True if flow is created by request external to PMD. */
1146         uint8_t skip_scale; /**< Skip the scale the table with factor. */
1147         uint32_t flow_idx; /**< This memory pool index to the flow. */
1148         uint32_t prefix_mark; /**< Prefix subflow mark flag. */
1149         uint64_t prefix_layers; /**< Prefix subflow layers. */
1150 };
1151
1152 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
1153                                     const struct rte_flow_attr *attr,
1154                                     const struct rte_flow_item items[],
1155                                     const struct rte_flow_action actions[],
1156                                     bool external,
1157                                     int hairpin,
1158                                     struct rte_flow_error *error);
1159 typedef struct mlx5_flow *(*mlx5_flow_prepare_t)
1160         (struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
1161          const struct rte_flow_item items[],
1162          const struct rte_flow_action actions[], struct rte_flow_error *error);
1163 typedef int (*mlx5_flow_translate_t)(struct rte_eth_dev *dev,
1164                                      struct mlx5_flow *dev_flow,
1165                                      const struct rte_flow_attr *attr,
1166                                      const struct rte_flow_item items[],
1167                                      const struct rte_flow_action actions[],
1168                                      struct rte_flow_error *error);
1169 typedef int (*mlx5_flow_apply_t)(struct rte_eth_dev *dev, struct rte_flow *flow,
1170                                  struct rte_flow_error *error);
1171 typedef void (*mlx5_flow_remove_t)(struct rte_eth_dev *dev,
1172                                    struct rte_flow *flow);
1173 typedef void (*mlx5_flow_destroy_t)(struct rte_eth_dev *dev,
1174                                     struct rte_flow *flow);
1175 typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,
1176                                  struct rte_flow *flow,
1177                                  const struct rte_flow_action *actions,
1178                                  void *data,
1179                                  struct rte_flow_error *error);
1180 typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t)
1181                                             (struct rte_eth_dev *dev,
1182                                              const struct mlx5_flow_meter *fm);
1183 typedef int (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,
1184                                         struct mlx5_meter_domains_infos *tbls);
1185 typedef int (*mlx5_flow_create_policer_rules_t)
1186                                         (struct rte_eth_dev *dev,
1187                                          struct mlx5_flow_meter *fm,
1188                                          const struct rte_flow_attr *attr);
1189 typedef int (*mlx5_flow_destroy_policer_rules_t)
1190                                         (struct rte_eth_dev *dev,
1191                                          const struct mlx5_flow_meter *fm,
1192                                          const struct rte_flow_attr *attr);
1193 typedef uint32_t (*mlx5_flow_counter_alloc_t)
1194                                    (struct rte_eth_dev *dev);
1195 typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
1196                                          uint32_t cnt);
1197 typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
1198                                          uint32_t cnt,
1199                                          bool clear, uint64_t *pkts,
1200                                          uint64_t *bytes);
1201 typedef int (*mlx5_flow_get_aged_flows_t)
1202                                         (struct rte_eth_dev *dev,
1203                                          void **context,
1204                                          uint32_t nb_contexts,
1205                                          struct rte_flow_error *error);
1206 typedef int (*mlx5_flow_action_validate_t)
1207                                 (struct rte_eth_dev *dev,
1208                                  const struct rte_flow_shared_action_conf *conf,
1209                                  const struct rte_flow_action *action,
1210                                  struct rte_flow_error *error);
1211 typedef struct rte_flow_shared_action *(*mlx5_flow_action_create_t)
1212                                 (struct rte_eth_dev *dev,
1213                                  const struct rte_flow_shared_action_conf *conf,
1214                                  const struct rte_flow_action *action,
1215                                  struct rte_flow_error *error);
1216 typedef int (*mlx5_flow_action_destroy_t)
1217                                 (struct rte_eth_dev *dev,
1218                                  struct rte_flow_shared_action *action,
1219                                  struct rte_flow_error *error);
1220 typedef int (*mlx5_flow_action_update_t)
1221                         (struct rte_eth_dev *dev,
1222                          struct rte_flow_shared_action *action,
1223                          const void *action_conf,
1224                          struct rte_flow_error *error);
1225 typedef int (*mlx5_flow_action_query_t)
1226                         (struct rte_eth_dev *dev,
1227                          const struct rte_flow_shared_action *action,
1228                          void *data,
1229                          struct rte_flow_error *error);
1230 typedef int (*mlx5_flow_sync_domain_t)
1231                         (struct rte_eth_dev *dev,
1232                          uint32_t domains,
1233                          uint32_t flags);
1234
1235 struct mlx5_flow_driver_ops {
1236         mlx5_flow_validate_t validate;
1237         mlx5_flow_prepare_t prepare;
1238         mlx5_flow_translate_t translate;
1239         mlx5_flow_apply_t apply;
1240         mlx5_flow_remove_t remove;
1241         mlx5_flow_destroy_t destroy;
1242         mlx5_flow_query_t query;
1243         mlx5_flow_create_mtr_tbls_t create_mtr_tbls;
1244         mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;
1245         mlx5_flow_create_policer_rules_t create_policer_rules;
1246         mlx5_flow_destroy_policer_rules_t destroy_policer_rules;
1247         mlx5_flow_counter_alloc_t counter_alloc;
1248         mlx5_flow_counter_free_t counter_free;
1249         mlx5_flow_counter_query_t counter_query;
1250         mlx5_flow_get_aged_flows_t get_aged_flows;
1251         mlx5_flow_action_validate_t action_validate;
1252         mlx5_flow_action_create_t action_create;
1253         mlx5_flow_action_destroy_t action_destroy;
1254         mlx5_flow_action_update_t action_update;
1255         mlx5_flow_action_query_t action_query;
1256         mlx5_flow_sync_domain_t sync_domain;
1257 };
1258
1259 /* mlx5_flow.c */
1260
1261 struct mlx5_flow_workspace *mlx5_flow_get_thread_workspace(void);
1262 __extension__
1263 struct flow_grp_info {
1264         uint64_t external:1;
1265         uint64_t transfer:1;
1266         uint64_t fdb_def_rule:1;
1267         /* force standard group translation */
1268         uint64_t std_tbl_fix:1;
1269         uint64_t skip_scale:2;
1270 };
1271
1272 static inline bool
1273 tunnel_use_standard_attr_group_translate
1274                     (struct rte_eth_dev *dev,
1275                      const struct mlx5_flow_tunnel *tunnel,
1276                      const struct rte_flow_attr *attr,
1277                      const struct rte_flow_item items[],
1278                      const struct rte_flow_action actions[])
1279 {
1280         bool verdict;
1281
1282         if (!is_tunnel_offload_active(dev))
1283                 /* no tunnel offload API */
1284                 verdict = true;
1285         else if (tunnel) {
1286                 /*
1287                  * OvS will use jump to group 0 in tunnel steer rule.
1288                  * If tunnel steer rule starts from group 0 (attr.group == 0)
1289                  * that 0 group must be translated with standard method.
1290                  * attr.group == 0 in tunnel match rule translated with tunnel
1291                  * method
1292                  */
1293                 verdict = !attr->group &&
1294                           is_flow_tunnel_steer_rule(dev, attr, items, actions);
1295         } else {
1296                 /*
1297                  * non-tunnel group translation uses standard method for
1298                  * root group only: attr.group == 0
1299                  */
1300                 verdict = !attr->group;
1301         }
1302
1303         return verdict;
1304 }
1305
1306 int mlx5_flow_group_to_table(struct rte_eth_dev *dev,
1307                              const struct mlx5_flow_tunnel *tunnel,
1308                              uint32_t group, uint32_t *table,
1309                              const struct flow_grp_info *flags,
1310                              struct rte_flow_error *error);
1311 uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
1312                                      int tunnel, uint64_t layer_types,
1313                                      uint64_t hash_fields);
1314 int mlx5_flow_discover_priorities(struct rte_eth_dev *dev);
1315 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
1316                                    uint32_t subpriority);
1317 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
1318                                      enum mlx5_feature_name feature,
1319                                      uint32_t id,
1320                                      struct rte_flow_error *error);
1321 const struct rte_flow_action *mlx5_flow_find_action
1322                                         (const struct rte_flow_action *actions,
1323                                          enum rte_flow_action_type action);
1324 int mlx5_validate_action_rss(struct rte_eth_dev *dev,
1325                              const struct rte_flow_action *action,
1326                              struct rte_flow_error *error);
1327 int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
1328                                     const struct rte_flow_attr *attr,
1329                                     struct rte_flow_error *error);
1330 int mlx5_flow_validate_action_drop(uint64_t action_flags,
1331                                    const struct rte_flow_attr *attr,
1332                                    struct rte_flow_error *error);
1333 int mlx5_flow_validate_action_flag(uint64_t action_flags,
1334                                    const struct rte_flow_attr *attr,
1335                                    struct rte_flow_error *error);
1336 int mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
1337                                    uint64_t action_flags,
1338                                    const struct rte_flow_attr *attr,
1339                                    struct rte_flow_error *error);
1340 int mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
1341                                     uint64_t action_flags,
1342                                     struct rte_eth_dev *dev,
1343                                     const struct rte_flow_attr *attr,
1344                                     struct rte_flow_error *error);
1345 int mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
1346                                   uint64_t action_flags,
1347                                   struct rte_eth_dev *dev,
1348                                   const struct rte_flow_attr *attr,
1349                                   uint64_t item_flags,
1350                                   struct rte_flow_error *error);
1351 int mlx5_flow_validate_action_default_miss(uint64_t action_flags,
1352                                 const struct rte_flow_attr *attr,
1353                                 struct rte_flow_error *error);
1354 int mlx5_flow_validate_attributes(struct rte_eth_dev *dev,
1355                                   const struct rte_flow_attr *attributes,
1356                                   struct rte_flow_error *error);
1357 int mlx5_flow_item_acceptable(const struct rte_flow_item *item,
1358                               const uint8_t *mask,
1359                               const uint8_t *nic_mask,
1360                               unsigned int size,
1361                               bool range_accepted,
1362                               struct rte_flow_error *error);
1363 int mlx5_flow_validate_item_eth(const struct rte_flow_item *item,
1364                                 uint64_t item_flags, bool ext_vlan_sup,
1365                                 struct rte_flow_error *error);
1366 int mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
1367                                 uint64_t item_flags,
1368                                 uint8_t target_protocol,
1369                                 struct rte_flow_error *error);
1370 int mlx5_flow_validate_item_gre_key(const struct rte_flow_item *item,
1371                                     uint64_t item_flags,
1372                                     const struct rte_flow_item *gre_item,
1373                                     struct rte_flow_error *error);
1374 int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
1375                                  uint64_t item_flags,
1376                                  uint64_t last_item,
1377                                  uint16_t ether_type,
1378                                  const struct rte_flow_item_ipv4 *acc_mask,
1379                                  bool range_accepted,
1380                                  struct rte_flow_error *error);
1381 int mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
1382                                  uint64_t item_flags,
1383                                  uint64_t last_item,
1384                                  uint16_t ether_type,
1385                                  const struct rte_flow_item_ipv6 *acc_mask,
1386                                  struct rte_flow_error *error);
1387 int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
1388                                  const struct rte_flow_item *item,
1389                                  uint64_t item_flags,
1390                                  uint64_t prev_layer,
1391                                  struct rte_flow_error *error);
1392 int mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,
1393                                 uint64_t item_flags,
1394                                 uint8_t target_protocol,
1395                                 const struct rte_flow_item_tcp *flow_mask,
1396                                 struct rte_flow_error *error);
1397 int mlx5_flow_validate_item_udp(const struct rte_flow_item *item,
1398                                 uint64_t item_flags,
1399                                 uint8_t target_protocol,
1400                                 struct rte_flow_error *error);
1401 int mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,
1402                                  uint64_t item_flags,
1403                                  struct rte_eth_dev *dev,
1404                                  struct rte_flow_error *error);
1405 int mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item,
1406                                   uint64_t item_flags,
1407                                   struct rte_flow_error *error);
1408 int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
1409                                       uint64_t item_flags,
1410                                       struct rte_eth_dev *dev,
1411                                       struct rte_flow_error *error);
1412 int mlx5_flow_validate_item_icmp(const struct rte_flow_item *item,
1413                                  uint64_t item_flags,
1414                                  uint8_t target_protocol,
1415                                  struct rte_flow_error *error);
1416 int mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item,
1417                                    uint64_t item_flags,
1418                                    uint8_t target_protocol,
1419                                    struct rte_flow_error *error);
1420 int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item,
1421                                   uint64_t item_flags,
1422                                   uint8_t target_protocol,
1423                                   struct rte_flow_error *error);
1424 int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
1425                                    uint64_t item_flags,
1426                                    struct rte_eth_dev *dev,
1427                                    struct rte_flow_error *error);
1428 int mlx5_flow_validate_item_geneve_opt(const struct rte_flow_item *item,
1429                                    uint64_t last_item,
1430                                    const struct rte_flow_item *geneve_item,
1431                                    struct rte_eth_dev *dev,
1432                                    struct rte_flow_error *error);
1433 int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
1434                                   uint64_t item_flags,
1435                                   uint64_t last_item,
1436                                   uint16_t ether_type,
1437                                   const struct rte_flow_item_ecpri *acc_mask,
1438                                   struct rte_flow_error *error);
1439 struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls
1440                                         (struct rte_eth_dev *dev,
1441                                          const struct mlx5_flow_meter *fm);
1442 int mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,
1443                                struct mlx5_meter_domains_infos *tbl);
1444 int mlx5_flow_create_policer_rules(struct rte_eth_dev *dev,
1445                                    struct mlx5_flow_meter *fm,
1446                                    const struct rte_flow_attr *attr);
1447 int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
1448                                     struct mlx5_flow_meter *fm,
1449                                     const struct rte_flow_attr *attr);
1450 int mlx5_flow_meter_flush(struct rte_eth_dev *dev,
1451                           struct rte_mtr_error *error);
1452 int mlx5_flow_dv_discover_counter_offset_support(struct rte_eth_dev *dev);
1453 int mlx5_shared_action_flush(struct rte_eth_dev *dev);
1454 void mlx5_release_tunnel_hub(struct mlx5_dev_ctx_shared *sh, uint16_t port_id);
1455 int mlx5_alloc_tunnel_hub(struct mlx5_dev_ctx_shared *sh);
1456
1457 /* Hash list callbacks for flow tables: */
1458 struct mlx5_hlist_entry *flow_dv_tbl_create_cb(struct mlx5_hlist *list,
1459                                                uint64_t key, void *entry_ctx);
1460 int flow_dv_tbl_match_cb(struct mlx5_hlist *list,
1461                          struct mlx5_hlist_entry *entry, uint64_t key,
1462                          void *cb_ctx);
1463 void flow_dv_tbl_remove_cb(struct mlx5_hlist *list,
1464                            struct mlx5_hlist_entry *entry);
1465 struct mlx5_flow_tbl_resource *flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
1466                 uint32_t table_id, uint8_t egress, uint8_t transfer,
1467                 bool external, const struct mlx5_flow_tunnel *tunnel,
1468                 uint32_t group_id, uint8_t dummy, struct rte_flow_error *error);
1469
1470 struct mlx5_hlist_entry *flow_dv_tag_create_cb(struct mlx5_hlist *list,
1471                                                uint64_t key, void *cb_ctx);
1472 int flow_dv_tag_match_cb(struct mlx5_hlist *list,
1473                          struct mlx5_hlist_entry *entry, uint64_t key,
1474                          void *cb_ctx);
1475 void flow_dv_tag_remove_cb(struct mlx5_hlist *list,
1476                            struct mlx5_hlist_entry *entry);
1477
1478 int flow_dv_modify_match_cb(struct mlx5_hlist *list,
1479                             struct mlx5_hlist_entry *entry,
1480                             uint64_t key, void *cb_ctx);
1481 struct mlx5_hlist_entry *flow_dv_modify_create_cb(struct mlx5_hlist *list,
1482                                                   uint64_t key, void *ctx);
1483 void flow_dv_modify_remove_cb(struct mlx5_hlist *list,
1484                               struct mlx5_hlist_entry *entry);
1485
1486 struct mlx5_hlist_entry *flow_dv_mreg_create_cb(struct mlx5_hlist *list,
1487                                                 uint64_t key, void *ctx);
1488 int flow_dv_mreg_match_cb(struct mlx5_hlist *list,
1489                           struct mlx5_hlist_entry *entry, uint64_t key,
1490                           void *cb_ctx);
1491 void flow_dv_mreg_remove_cb(struct mlx5_hlist *list,
1492                             struct mlx5_hlist_entry *entry);
1493
1494 int flow_dv_encap_decap_match_cb(struct mlx5_hlist *list,
1495                                  struct mlx5_hlist_entry *entry,
1496                                  uint64_t key, void *cb_ctx);
1497 struct mlx5_hlist_entry *flow_dv_encap_decap_create_cb(struct mlx5_hlist *list,
1498                                 uint64_t key, void *cb_ctx);
1499 void flow_dv_encap_decap_remove_cb(struct mlx5_hlist *list,
1500                                    struct mlx5_hlist_entry *entry);
1501
1502 int flow_dv_matcher_match_cb(struct mlx5_cache_list *list,
1503                              struct mlx5_cache_entry *entry, void *ctx);
1504 struct mlx5_cache_entry *flow_dv_matcher_create_cb(struct mlx5_cache_list *list,
1505                 struct mlx5_cache_entry *entry, void *ctx);
1506 void flow_dv_matcher_remove_cb(struct mlx5_cache_list *list,
1507                                struct mlx5_cache_entry *entry);
1508
1509 int flow_dv_port_id_match_cb(struct mlx5_cache_list *list,
1510                              struct mlx5_cache_entry *entry, void *cb_ctx);
1511 struct mlx5_cache_entry *flow_dv_port_id_create_cb(struct mlx5_cache_list *list,
1512                 struct mlx5_cache_entry *entry, void *cb_ctx);
1513 void flow_dv_port_id_remove_cb(struct mlx5_cache_list *list,
1514                                struct mlx5_cache_entry *entry);
1515
1516 int flow_dv_push_vlan_match_cb(struct mlx5_cache_list *list,
1517                                struct mlx5_cache_entry *entry, void *cb_ctx);
1518 struct mlx5_cache_entry *flow_dv_push_vlan_create_cb
1519                                 (struct mlx5_cache_list *list,
1520                                  struct mlx5_cache_entry *entry, void *cb_ctx);
1521 void flow_dv_push_vlan_remove_cb(struct mlx5_cache_list *list,
1522                                  struct mlx5_cache_entry *entry);
1523
1524 int flow_dv_sample_match_cb(struct mlx5_cache_list *list,
1525                             struct mlx5_cache_entry *entry, void *cb_ctx);
1526 struct mlx5_cache_entry *flow_dv_sample_create_cb
1527                                 (struct mlx5_cache_list *list,
1528                                  struct mlx5_cache_entry *entry, void *cb_ctx);
1529 void flow_dv_sample_remove_cb(struct mlx5_cache_list *list,
1530                               struct mlx5_cache_entry *entry);
1531
1532 int flow_dv_dest_array_match_cb(struct mlx5_cache_list *list,
1533                                 struct mlx5_cache_entry *entry, void *cb_ctx);
1534 struct mlx5_cache_entry *flow_dv_dest_array_create_cb
1535                                 (struct mlx5_cache_list *list,
1536                                  struct mlx5_cache_entry *entry, void *cb_ctx);
1537 void flow_dv_dest_array_remove_cb(struct mlx5_cache_list *list,
1538                                   struct mlx5_cache_entry *entry);
1539 struct mlx5_aso_age_action *flow_aso_age_get_by_idx(struct rte_eth_dev *dev,
1540                                                     uint32_t age_idx);
1541 int flow_dev_geneve_tlv_option_resource_register(struct rte_eth_dev *dev,
1542                                              const struct rte_flow_item *item,
1543                                              struct rte_flow_error *error);
1544
1545 void flow_release_workspace(void *data);
1546 int mlx5_flow_os_init_workspace_once(void);
1547 void *mlx5_flow_os_get_specific_workspace(void);
1548 int mlx5_flow_os_set_specific_workspace(struct mlx5_flow_workspace *data);
1549 void mlx5_flow_os_release_workspace(void);
1550
1551
1552 #endif /* RTE_PMD_MLX5_FLOW_H_ */