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