net/mlx5: add flow validation of eCPRI header
[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 /* Verbs header. */
15 /* ISO C doesn't support unnamed structs/unions, disabling -pedantic. */
16 #ifdef PEDANTIC
17 #pragma GCC diagnostic ignored "-Wpedantic"
18 #endif
19 #include <infiniband/verbs.h>
20 #ifdef PEDANTIC
21 #pragma GCC diagnostic error "-Wpedantic"
22 #endif
23
24 #include <rte_atomic.h>
25 #include <rte_alarm.h>
26 #include <rte_mtr.h>
27
28 #include <mlx5_prm.h>
29
30 #include "mlx5.h"
31
32 /* Private rte flow items. */
33 enum mlx5_rte_flow_item_type {
34         MLX5_RTE_FLOW_ITEM_TYPE_END = INT_MIN,
35         MLX5_RTE_FLOW_ITEM_TYPE_TAG,
36         MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE,
37         MLX5_RTE_FLOW_ITEM_TYPE_VLAN,
38 };
39
40 /* Private (internal) rte flow actions. */
41 enum mlx5_rte_flow_action_type {
42         MLX5_RTE_FLOW_ACTION_TYPE_END = INT_MIN,
43         MLX5_RTE_FLOW_ACTION_TYPE_TAG,
44         MLX5_RTE_FLOW_ACTION_TYPE_MARK,
45         MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG,
46         MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS,
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 /* Pattern outer Layer bits. */
86 #define MLX5_FLOW_LAYER_OUTER_L2 (1u << 0)
87 #define MLX5_FLOW_LAYER_OUTER_L3_IPV4 (1u << 1)
88 #define MLX5_FLOW_LAYER_OUTER_L3_IPV6 (1u << 2)
89 #define MLX5_FLOW_LAYER_OUTER_L4_UDP (1u << 3)
90 #define MLX5_FLOW_LAYER_OUTER_L4_TCP (1u << 4)
91 #define MLX5_FLOW_LAYER_OUTER_VLAN (1u << 5)
92
93 /* Pattern inner Layer bits. */
94 #define MLX5_FLOW_LAYER_INNER_L2 (1u << 6)
95 #define MLX5_FLOW_LAYER_INNER_L3_IPV4 (1u << 7)
96 #define MLX5_FLOW_LAYER_INNER_L3_IPV6 (1u << 8)
97 #define MLX5_FLOW_LAYER_INNER_L4_UDP (1u << 9)
98 #define MLX5_FLOW_LAYER_INNER_L4_TCP (1u << 10)
99 #define MLX5_FLOW_LAYER_INNER_VLAN (1u << 11)
100
101 /* Pattern tunnel Layer bits. */
102 #define MLX5_FLOW_LAYER_VXLAN (1u << 12)
103 #define MLX5_FLOW_LAYER_VXLAN_GPE (1u << 13)
104 #define MLX5_FLOW_LAYER_GRE (1u << 14)
105 #define MLX5_FLOW_LAYER_MPLS (1u << 15)
106 /* List of tunnel Layer bits continued below. */
107
108 /* General pattern items bits. */
109 #define MLX5_FLOW_ITEM_METADATA (1u << 16)
110 #define MLX5_FLOW_ITEM_PORT_ID (1u << 17)
111 #define MLX5_FLOW_ITEM_TAG (1u << 18)
112 #define MLX5_FLOW_ITEM_MARK (1u << 19)
113
114 /* Pattern MISC bits. */
115 #define MLX5_FLOW_LAYER_ICMP (1u << 20)
116 #define MLX5_FLOW_LAYER_ICMP6 (1u << 21)
117 #define MLX5_FLOW_LAYER_GRE_KEY (1u << 22)
118
119 /* Pattern tunnel Layer bits (continued). */
120 #define MLX5_FLOW_LAYER_IPIP (1u << 23)
121 #define MLX5_FLOW_LAYER_IPV6_ENCAP (1u << 24)
122 #define MLX5_FLOW_LAYER_NVGRE (1u << 25)
123 #define MLX5_FLOW_LAYER_GENEVE (1u << 26)
124
125 /* Queue items. */
126 #define MLX5_FLOW_ITEM_TX_QUEUE (1u << 27)
127
128 /* Pattern tunnel Layer bits (continued). */
129 #define MLX5_FLOW_LAYER_GTP (1u << 28)
130
131 /* Pattern eCPRI Layer bit. */
132 #define MLX5_FLOW_LAYER_ECPRI (UINT64_C(1) << 29)
133
134 /* Outer Masks. */
135 #define MLX5_FLOW_LAYER_OUTER_L3 \
136         (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_OUTER_L3_IPV6)
137 #define MLX5_FLOW_LAYER_OUTER_L4 \
138         (MLX5_FLOW_LAYER_OUTER_L4_UDP | MLX5_FLOW_LAYER_OUTER_L4_TCP)
139 #define MLX5_FLOW_LAYER_OUTER \
140         (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_OUTER_L3 | \
141          MLX5_FLOW_LAYER_OUTER_L4)
142
143 /* Tunnel Masks. */
144 #define MLX5_FLOW_LAYER_TUNNEL \
145         (MLX5_FLOW_LAYER_VXLAN | MLX5_FLOW_LAYER_VXLAN_GPE | \
146          MLX5_FLOW_LAYER_GRE | MLX5_FLOW_LAYER_NVGRE | MLX5_FLOW_LAYER_MPLS | \
147          MLX5_FLOW_LAYER_IPIP | MLX5_FLOW_LAYER_IPV6_ENCAP | \
148          MLX5_FLOW_LAYER_GENEVE | MLX5_FLOW_LAYER_GTP)
149
150 /* Inner Masks. */
151 #define MLX5_FLOW_LAYER_INNER_L3 \
152         (MLX5_FLOW_LAYER_INNER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
153 #define MLX5_FLOW_LAYER_INNER_L4 \
154         (MLX5_FLOW_LAYER_INNER_L4_UDP | MLX5_FLOW_LAYER_INNER_L4_TCP)
155 #define MLX5_FLOW_LAYER_INNER \
156         (MLX5_FLOW_LAYER_INNER_L2 | MLX5_FLOW_LAYER_INNER_L3 | \
157          MLX5_FLOW_LAYER_INNER_L4)
158
159 /* Layer Masks. */
160 #define MLX5_FLOW_LAYER_L2 \
161         (MLX5_FLOW_LAYER_OUTER_L2 | MLX5_FLOW_LAYER_INNER_L2)
162 #define MLX5_FLOW_LAYER_L3_IPV4 \
163         (MLX5_FLOW_LAYER_OUTER_L3_IPV4 | MLX5_FLOW_LAYER_INNER_L3_IPV4)
164 #define MLX5_FLOW_LAYER_L3_IPV6 \
165         (MLX5_FLOW_LAYER_OUTER_L3_IPV6 | MLX5_FLOW_LAYER_INNER_L3_IPV6)
166 #define MLX5_FLOW_LAYER_L3 \
167         (MLX5_FLOW_LAYER_L3_IPV4 | MLX5_FLOW_LAYER_L3_IPV6)
168 #define MLX5_FLOW_LAYER_L4 \
169         (MLX5_FLOW_LAYER_OUTER_L4 | MLX5_FLOW_LAYER_INNER_L4)
170
171 /* Actions */
172 #define MLX5_FLOW_ACTION_DROP (1u << 0)
173 #define MLX5_FLOW_ACTION_QUEUE (1u << 1)
174 #define MLX5_FLOW_ACTION_RSS (1u << 2)
175 #define MLX5_FLOW_ACTION_FLAG (1u << 3)
176 #define MLX5_FLOW_ACTION_MARK (1u << 4)
177 #define MLX5_FLOW_ACTION_COUNT (1u << 5)
178 #define MLX5_FLOW_ACTION_PORT_ID (1u << 6)
179 #define MLX5_FLOW_ACTION_OF_POP_VLAN (1u << 7)
180 #define MLX5_FLOW_ACTION_OF_PUSH_VLAN (1u << 8)
181 #define MLX5_FLOW_ACTION_OF_SET_VLAN_VID (1u << 9)
182 #define MLX5_FLOW_ACTION_OF_SET_VLAN_PCP (1u << 10)
183 #define MLX5_FLOW_ACTION_SET_IPV4_SRC (1u << 11)
184 #define MLX5_FLOW_ACTION_SET_IPV4_DST (1u << 12)
185 #define MLX5_FLOW_ACTION_SET_IPV6_SRC (1u << 13)
186 #define MLX5_FLOW_ACTION_SET_IPV6_DST (1u << 14)
187 #define MLX5_FLOW_ACTION_SET_TP_SRC (1u << 15)
188 #define MLX5_FLOW_ACTION_SET_TP_DST (1u << 16)
189 #define MLX5_FLOW_ACTION_JUMP (1u << 17)
190 #define MLX5_FLOW_ACTION_SET_TTL (1u << 18)
191 #define MLX5_FLOW_ACTION_DEC_TTL (1u << 19)
192 #define MLX5_FLOW_ACTION_SET_MAC_SRC (1u << 20)
193 #define MLX5_FLOW_ACTION_SET_MAC_DST (1u << 21)
194 #define MLX5_FLOW_ACTION_ENCAP (1u << 22)
195 #define MLX5_FLOW_ACTION_DECAP (1u << 23)
196 #define MLX5_FLOW_ACTION_INC_TCP_SEQ (1u << 24)
197 #define MLX5_FLOW_ACTION_DEC_TCP_SEQ (1u << 25)
198 #define MLX5_FLOW_ACTION_INC_TCP_ACK (1u << 26)
199 #define MLX5_FLOW_ACTION_DEC_TCP_ACK (1u << 27)
200 #define MLX5_FLOW_ACTION_SET_TAG (1ull << 28)
201 #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 29)
202 #define MLX5_FLOW_ACTION_SET_META (1ull << 30)
203 #define MLX5_FLOW_ACTION_METER (1ull << 31)
204 #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32)
205 #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33)
206 #define MLX5_FLOW_ACTION_AGE (1ull << 34)
207 #define MLX5_FLOW_ACTION_DEFAULT_MISS (1ull << 35)
208
209 #define MLX5_FLOW_FATE_ACTIONS \
210         (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \
211          MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \
212          MLX5_FLOW_ACTION_DEFAULT_MISS)
213
214 #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \
215         (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \
216          MLX5_FLOW_ACTION_JUMP)
217
218
219 #define MLX5_FLOW_MODIFY_HDR_ACTIONS (MLX5_FLOW_ACTION_SET_IPV4_SRC | \
220                                       MLX5_FLOW_ACTION_SET_IPV4_DST | \
221                                       MLX5_FLOW_ACTION_SET_IPV6_SRC | \
222                                       MLX5_FLOW_ACTION_SET_IPV6_DST | \
223                                       MLX5_FLOW_ACTION_SET_TP_SRC | \
224                                       MLX5_FLOW_ACTION_SET_TP_DST | \
225                                       MLX5_FLOW_ACTION_SET_TTL | \
226                                       MLX5_FLOW_ACTION_DEC_TTL | \
227                                       MLX5_FLOW_ACTION_SET_MAC_SRC | \
228                                       MLX5_FLOW_ACTION_SET_MAC_DST | \
229                                       MLX5_FLOW_ACTION_INC_TCP_SEQ | \
230                                       MLX5_FLOW_ACTION_DEC_TCP_SEQ | \
231                                       MLX5_FLOW_ACTION_INC_TCP_ACK | \
232                                       MLX5_FLOW_ACTION_DEC_TCP_ACK | \
233                                       MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \
234                                       MLX5_FLOW_ACTION_SET_TAG | \
235                                       MLX5_FLOW_ACTION_MARK_EXT | \
236                                       MLX5_FLOW_ACTION_SET_META | \
237                                       MLX5_FLOW_ACTION_SET_IPV4_DSCP | \
238                                       MLX5_FLOW_ACTION_SET_IPV6_DSCP)
239
240 #define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \
241                                 MLX5_FLOW_ACTION_OF_PUSH_VLAN)
242
243 #define MLX5_FLOW_XCAP_ACTIONS (MLX5_FLOW_ACTION_ENCAP | MLX5_FLOW_ACTION_DECAP)
244
245 #ifndef IPPROTO_MPLS
246 #define IPPROTO_MPLS 137
247 #endif
248
249 /* UDP port number for MPLS */
250 #define MLX5_UDP_PORT_MPLS 6635
251
252 /* UDP port numbers for VxLAN. */
253 #define MLX5_UDP_PORT_VXLAN 4789
254 #define MLX5_UDP_PORT_VXLAN_GPE 4790
255
256 /* UDP port numbers for GENEVE. */
257 #define MLX5_UDP_PORT_GENEVE 6081
258
259 /* Priority reserved for default flows. */
260 #define MLX5_FLOW_PRIO_RSVD ((uint32_t)-1)
261
262 /*
263  * Number of sub priorities.
264  * For each kind of pattern matching i.e. L2, L3, L4 to have a correct
265  * matching on the NIC (firmware dependent) L4 most have the higher priority
266  * followed by L3 and ending with L2.
267  */
268 #define MLX5_PRIORITY_MAP_L2 2
269 #define MLX5_PRIORITY_MAP_L3 1
270 #define MLX5_PRIORITY_MAP_L4 0
271 #define MLX5_PRIORITY_MAP_MAX 3
272
273 /* Valid layer type for IPV4 RSS. */
274 #define MLX5_IPV4_LAYER_TYPES \
275         (ETH_RSS_IPV4 | ETH_RSS_FRAG_IPV4 | \
276          ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV4_UDP | \
277          ETH_RSS_NONFRAG_IPV4_OTHER)
278
279 /* IBV hash source bits  for IPV4. */
280 #define MLX5_IPV4_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_DST_IPV4)
281
282 /* Valid layer type for IPV6 RSS. */
283 #define MLX5_IPV6_LAYER_TYPES \
284         (ETH_RSS_IPV6 | ETH_RSS_FRAG_IPV6 | ETH_RSS_NONFRAG_IPV6_TCP | \
285          ETH_RSS_NONFRAG_IPV6_UDP | ETH_RSS_IPV6_EX  | ETH_RSS_IPV6_TCP_EX | \
286          ETH_RSS_IPV6_UDP_EX | ETH_RSS_NONFRAG_IPV6_OTHER)
287
288 /* IBV hash source bits  for IPV6. */
289 #define MLX5_IPV6_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV6 | IBV_RX_HASH_DST_IPV6)
290
291 /* IBV hash bits for L3 SRC. */
292 #define MLX5_L3_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_IPV4 | IBV_RX_HASH_SRC_IPV6)
293
294 /* IBV hash bits for L3 DST. */
295 #define MLX5_L3_DST_IBV_RX_HASH (IBV_RX_HASH_DST_IPV4 | IBV_RX_HASH_DST_IPV6)
296
297 /* IBV hash bits for TCP. */
298 #define MLX5_TCP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
299                               IBV_RX_HASH_DST_PORT_TCP)
300
301 /* IBV hash bits for UDP. */
302 #define MLX5_UDP_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_UDP | \
303                               IBV_RX_HASH_DST_PORT_UDP)
304
305 /* IBV hash bits for L4 SRC. */
306 #define MLX5_L4_SRC_IBV_RX_HASH (IBV_RX_HASH_SRC_PORT_TCP | \
307                                  IBV_RX_HASH_SRC_PORT_UDP)
308
309 /* IBV hash bits for L4 DST. */
310 #define MLX5_L4_DST_IBV_RX_HASH (IBV_RX_HASH_DST_PORT_TCP | \
311                                  IBV_RX_HASH_DST_PORT_UDP)
312
313 /* Geneve header first 16Bit */
314 #define MLX5_GENEVE_VER_MASK 0x3
315 #define MLX5_GENEVE_VER_SHIFT 14
316 #define MLX5_GENEVE_VER_VAL(a) \
317                 (((a) >> (MLX5_GENEVE_VER_SHIFT)) & (MLX5_GENEVE_VER_MASK))
318 #define MLX5_GENEVE_OPTLEN_MASK 0x3F
319 #define MLX5_GENEVE_OPTLEN_SHIFT 7
320 #define MLX5_GENEVE_OPTLEN_VAL(a) \
321             (((a) >> (MLX5_GENEVE_OPTLEN_SHIFT)) & (MLX5_GENEVE_OPTLEN_MASK))
322 #define MLX5_GENEVE_OAMF_MASK 0x1
323 #define MLX5_GENEVE_OAMF_SHIFT 7
324 #define MLX5_GENEVE_OAMF_VAL(a) \
325                 (((a) >> (MLX5_GENEVE_OAMF_SHIFT)) & (MLX5_GENEVE_OAMF_MASK))
326 #define MLX5_GENEVE_CRITO_MASK 0x1
327 #define MLX5_GENEVE_CRITO_SHIFT 6
328 #define MLX5_GENEVE_CRITO_VAL(a) \
329                 (((a) >> (MLX5_GENEVE_CRITO_SHIFT)) & (MLX5_GENEVE_CRITO_MASK))
330 #define MLX5_GENEVE_RSVD_MASK 0x3F
331 #define MLX5_GENEVE_RSVD_VAL(a) ((a) & (MLX5_GENEVE_RSVD_MASK))
332 /*
333  * The length of the Geneve options fields, expressed in four byte multiples,
334  * not including the eight byte fixed tunnel.
335  */
336 #define MLX5_GENEVE_OPT_LEN_0 14
337 #define MLX5_GENEVE_OPT_LEN_1 63
338
339 #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_flow_item_eth) + \
340                                           sizeof(struct rte_flow_item_ipv4))
341
342 /* Software header modify action numbers of a flow. */
343 #define MLX5_ACT_NUM_MDF_IPV4           1
344 #define MLX5_ACT_NUM_MDF_IPV6           4
345 #define MLX5_ACT_NUM_MDF_MAC            2
346 #define MLX5_ACT_NUM_MDF_VID            1
347 #define MLX5_ACT_NUM_MDF_PORT           2
348 #define MLX5_ACT_NUM_MDF_TTL            1
349 #define MLX5_ACT_NUM_DEC_TTL            MLX5_ACT_NUM_MDF_TTL
350 #define MLX5_ACT_NUM_MDF_TCPSEQ         1
351 #define MLX5_ACT_NUM_MDF_TCPACK         1
352 #define MLX5_ACT_NUM_SET_REG            1
353 #define MLX5_ACT_NUM_SET_TAG            1
354 #define MLX5_ACT_NUM_CPY_MREG           MLX5_ACT_NUM_SET_TAG
355 #define MLX5_ACT_NUM_SET_MARK           MLX5_ACT_NUM_SET_TAG
356 #define MLX5_ACT_NUM_SET_META           MLX5_ACT_NUM_SET_TAG
357 #define MLX5_ACT_NUM_SET_DSCP           1
358
359 enum mlx5_flow_drv_type {
360         MLX5_FLOW_TYPE_MIN,
361         MLX5_FLOW_TYPE_DV,
362         MLX5_FLOW_TYPE_VERBS,
363         MLX5_FLOW_TYPE_MAX,
364 };
365
366 /* Fate action type. */
367 enum mlx5_flow_fate_type {
368         MLX5_FLOW_FATE_NONE, /* Egress flow. */
369         MLX5_FLOW_FATE_QUEUE,
370         MLX5_FLOW_FATE_JUMP,
371         MLX5_FLOW_FATE_PORT_ID,
372         MLX5_FLOW_FATE_DROP,
373         MLX5_FLOW_FATE_DEFAULT_MISS,
374         MLX5_FLOW_FATE_MAX,
375 };
376
377 /* Matcher PRM representation */
378 struct mlx5_flow_dv_match_params {
379         size_t size;
380         /**< Size of match value. Do NOT split size and key! */
381         uint32_t buf[MLX5_ST_SZ_DW(fte_match_param)];
382         /**< Matcher value. This value is used as the mask or as a key. */
383 };
384
385 /* Matcher structure. */
386 struct mlx5_flow_dv_matcher {
387         LIST_ENTRY(mlx5_flow_dv_matcher) next;
388         /**< Pointer to the next element. */
389         struct mlx5_flow_tbl_resource *tbl;
390         /**< Pointer to the table(group) the matcher associated with. */
391         rte_atomic32_t refcnt; /**< Reference counter. */
392         void *matcher_object; /**< Pointer to DV matcher */
393         uint16_t crc; /**< CRC of key. */
394         uint16_t priority; /**< Priority of matcher. */
395         struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
396 };
397
398 #define MLX5_ENCAP_MAX_LEN 132
399
400 /* Encap/decap resource structure. */
401 struct mlx5_flow_dv_encap_decap_resource {
402         ILIST_ENTRY(uint32_t)next;
403         /* Pointer to next element. */
404         rte_atomic32_t refcnt; /**< Reference counter. */
405         void *action;
406         /**< Encap/decap action object. */
407         uint8_t buf[MLX5_ENCAP_MAX_LEN];
408         size_t size;
409         uint8_t reformat_type;
410         uint8_t ft_type;
411         uint64_t flags; /**< Flags for RDMA API. */
412 };
413
414 /* Tag resource structure. */
415 struct mlx5_flow_dv_tag_resource {
416         struct mlx5_hlist_entry entry;
417         /**< hash list entry for tag resource, tag value as the key. */
418         void *action;
419         /**< Tag action object. */
420         rte_atomic32_t refcnt; /**< Reference counter. */
421         uint32_t idx; /**< Index for the index memory pool. */
422 };
423
424 /*
425  * Number of modification commands.
426  * The maximal actions amount in FW is some constant, and it is 16 in the
427  * latest releases. In some old releases, it will be limited to 8.
428  * Since there is no interface to query the capacity, the maximal value should
429  * be used to allow PMD to create the flow. The validation will be done in the
430  * lower driver layer or FW. A failure will be returned if exceeds the maximal
431  * supported actions number on the root table.
432  * On non-root tables, there is no limitation, but 32 is enough right now.
433  */
434 #define MLX5_MAX_MODIFY_NUM                     32
435 #define MLX5_ROOT_TBL_MODIFY_NUM                16
436
437 /* Modify resource structure */
438 struct mlx5_flow_dv_modify_hdr_resource {
439         LIST_ENTRY(mlx5_flow_dv_modify_hdr_resource) next;
440         /* Pointer to next element. */
441         rte_atomic32_t refcnt; /**< Reference counter. */
442         void *action;
443         /**< Modify header action object. */
444         uint8_t ft_type; /**< Flow table type, Rx or Tx. */
445         uint32_t actions_num; /**< Number of modification actions. */
446         uint64_t flags; /**< Flags for RDMA API. */
447         struct mlx5_modification_cmd actions[];
448         /**< Modification actions. */
449 };
450
451 /* Jump action resource structure. */
452 struct mlx5_flow_dv_jump_tbl_resource {
453         rte_atomic32_t refcnt; /**< Reference counter. */
454         uint8_t ft_type; /**< Flow table type, Rx or Tx. */
455         void *action; /**< Pointer to the rdma core action. */
456 };
457
458 /* Port ID resource structure. */
459 struct mlx5_flow_dv_port_id_action_resource {
460         ILIST_ENTRY(uint32_t)next;
461         /* Pointer to next element. */
462         rte_atomic32_t refcnt; /**< Reference counter. */
463         void *action;
464         /**< Action object. */
465         uint32_t port_id; /**< Port ID value. */
466 };
467
468 /* Push VLAN action resource structure */
469 struct mlx5_flow_dv_push_vlan_action_resource {
470         ILIST_ENTRY(uint32_t)next;
471         /* Pointer to next element. */
472         rte_atomic32_t refcnt; /**< Reference counter. */
473         void *action; /**< Action object. */
474         uint8_t ft_type; /**< Flow table type, Rx, Tx or FDB. */
475         rte_be32_t vlan_tag; /**< VLAN tag value. */
476 };
477
478 /* Metadata register copy table entry. */
479 struct mlx5_flow_mreg_copy_resource {
480         /*
481          * Hash list entry for copy table.
482          *  - Key is 32/64-bit MARK action ID.
483          *  - MUST be the first entry.
484          */
485         struct mlx5_hlist_entry hlist_ent;
486         LIST_ENTRY(mlx5_flow_mreg_copy_resource) next;
487         /* List entry for device flows. */
488         uint32_t refcnt; /* Reference counter. */
489         uint32_t appcnt; /* Apply/Remove counter. */
490         uint32_t idx;
491         uint32_t rix_flow; /* Built flow for copy. */
492 };
493
494 /* Table data structure of the hash organization. */
495 struct mlx5_flow_tbl_data_entry {
496         struct mlx5_hlist_entry entry;
497         /**< hash list entry, 64-bits key inside. */
498         struct mlx5_flow_tbl_resource tbl;
499         /**< flow table resource. */
500         LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers;
501         /**< matchers' header associated with the flow table. */
502         struct mlx5_flow_dv_jump_tbl_resource jump;
503         /**< jump resource, at most one for each table created. */
504         uint32_t idx; /**< index for the indexed mempool. */
505 };
506
507 /* Verbs specification header. */
508 struct ibv_spec_header {
509         enum ibv_flow_spec_type type;
510         uint16_t size;
511 };
512
513 /* RSS description. */
514 struct mlx5_flow_rss_desc {
515         uint32_t level;
516         uint32_t queue_num; /**< Number of entries in @p queue. */
517         uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
518         uint8_t key[MLX5_RSS_HASH_KEY_LEN]; /**< RSS hash key. */
519         uint16_t queue[]; /**< Destination queues to redirect traffic to. */
520 };
521
522
523 /** Device flow handle structure for DV mode only. */
524 struct mlx5_flow_handle_dv {
525         /* Flow DV api: */
526         struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */
527         struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
528         /**< Pointer to modify header resource in cache. */
529         uint32_t rix_encap_decap;
530         /**< Index to encap/decap resource in cache. */
531         uint32_t rix_push_vlan;
532         /**< Index to push VLAN action resource in cache. */
533         uint32_t rix_tag;
534         /**< Index to the tag action. */
535 } __rte_packed;
536
537 /** Device flow handle structure: used both for creating & destroying. */
538 struct mlx5_flow_handle {
539         SILIST_ENTRY(uint32_t)next;
540         struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */
541         /**< Index to next device flow handle. */
542         uint64_t layers;
543         /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */
544         void *drv_flow; /**< pointer to driver flow object. */
545         uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */
546         uint32_t mark:1; /**< Metadate rxq mark flag. */
547         uint32_t fate_action:3; /**< Fate action type. */
548         union {
549                 uint32_t rix_hrxq; /**< Hash Rx queue object index. */
550                 uint32_t rix_jump; /**< Index to the jump action resource. */
551                 uint32_t rix_port_id_action;
552                 /**< Index to port ID action resource. */
553                 uint32_t rix_fate;
554                 /**< Generic value indicates the fate action. */
555                 uint32_t rix_default_fate;
556                 /**< Indicates default miss fate action. */
557         };
558 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
559         struct mlx5_flow_handle_dv dvh;
560 #endif
561 } __rte_packed;
562
563 /*
564  * Size for Verbs device flow handle structure only. Do not use the DV only
565  * structure in Verbs. No DV flows attributes will be accessed.
566  * Macro offsetof() could also be used here.
567  */
568 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
569 #define MLX5_FLOW_HANDLE_VERBS_SIZE \
570         (sizeof(struct mlx5_flow_handle) - sizeof(struct mlx5_flow_handle_dv))
571 #else
572 #define MLX5_FLOW_HANDLE_VERBS_SIZE (sizeof(struct mlx5_flow_handle))
573 #endif
574
575 /*
576  * Max number of actions per DV flow.
577  * See CREATE_FLOW_MAX_FLOW_ACTIONS_SUPPORTED
578  * in rdma-core file providers/mlx5/verbs.c.
579  */
580 #define MLX5_DV_MAX_NUMBER_OF_ACTIONS 8
581
582 /** Device flow structure only for DV flow creation. */
583 struct mlx5_flow_dv_workspace {
584         uint32_t group; /**< The group index. */
585         uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
586         int actions_n; /**< number of actions. */
587         void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; /**< Action list. */
588         struct mlx5_flow_dv_encap_decap_resource *encap_decap;
589         /**< Pointer to encap/decap resource in cache. */
590         struct mlx5_flow_dv_push_vlan_action_resource *push_vlan_res;
591         /**< Pointer to push VLAN action resource in cache. */
592         struct mlx5_flow_dv_tag_resource *tag_resource;
593         /**< pointer to the tag action. */
594         struct mlx5_flow_dv_port_id_action_resource *port_id_action;
595         /**< Pointer to port ID action resource. */
596         struct mlx5_flow_dv_jump_tbl_resource *jump;
597         /**< Pointer to the jump action resource. */
598         struct mlx5_flow_dv_match_params value;
599         /**< Holds the value that the packet is compared to. */
600 };
601
602 /*
603  * Maximal Verbs flow specifications & actions size.
604  * Some elements are mutually exclusive, but enough space should be allocated.
605  * Tunnel cases: 1. Max 2 Ethernet + IP(v6 len > v4 len) + TCP/UDP headers.
606  *               2. One tunnel header (exception: GRE + MPLS),
607  *                  SPEC length: GRE == tunnel.
608  * Actions: 1. 1 Mark OR Flag.
609  *          2. 1 Drop (if any).
610  *          3. No limitation for counters, but it makes no sense to support too
611  *             many counters in a single device flow.
612  */
613 #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
614 #define MLX5_VERBS_MAX_SPEC_SIZE \
615                 ( \
616                         (2 * (sizeof(struct ibv_flow_spec_eth) + \
617                               sizeof(struct ibv_flow_spec_ipv6) + \
618                               sizeof(struct ibv_flow_spec_tcp_udp)) + \
619                         sizeof(struct ibv_flow_spec_gre) + \
620                         sizeof(struct ibv_flow_spec_mpls)) \
621                 )
622 #else
623 #define MLX5_VERBS_MAX_SPEC_SIZE \
624                 ( \
625                         (2 * (sizeof(struct ibv_flow_spec_eth) + \
626                               sizeof(struct ibv_flow_spec_ipv6) + \
627                               sizeof(struct ibv_flow_spec_tcp_udp)) + \
628                         sizeof(struct ibv_flow_spec_tunnel)) \
629                 )
630 #endif
631
632 #if defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) || \
633         defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
634 #define MLX5_VERBS_MAX_ACT_SIZE \
635                 ( \
636                         sizeof(struct ibv_flow_spec_action_tag) + \
637                         sizeof(struct ibv_flow_spec_action_drop) + \
638                         sizeof(struct ibv_flow_spec_counter_action) * 4 \
639                 )
640 #else
641 #define MLX5_VERBS_MAX_ACT_SIZE \
642                 ( \
643                         sizeof(struct ibv_flow_spec_action_tag) + \
644                         sizeof(struct ibv_flow_spec_action_drop) \
645                 )
646 #endif
647
648 #define MLX5_VERBS_MAX_SPEC_ACT_SIZE \
649                 (MLX5_VERBS_MAX_SPEC_SIZE + MLX5_VERBS_MAX_ACT_SIZE)
650
651 /** Device flow structure only for Verbs flow creation. */
652 struct mlx5_flow_verbs_workspace {
653         unsigned int size; /**< Size of the attribute. */
654         struct ibv_flow_attr attr; /**< Verbs flow attribute buffer. */
655         uint8_t specs[MLX5_VERBS_MAX_SPEC_ACT_SIZE];
656         /**< Specifications & actions buffer of verbs flow. */
657 };
658
659 /** Maximal number of device sub-flows supported. */
660 #define MLX5_NUM_MAX_DEV_FLOWS 32
661
662 /** Device flow structure. */
663 struct mlx5_flow {
664         struct rte_flow *flow; /**< Pointer to the main flow. */
665         uint32_t flow_idx; /**< The memory pool index to the main flow. */
666         uint64_t hash_fields; /**< Hash Rx queue hash fields. */
667         uint64_t act_flags;
668         /**< Bit-fields of detected actions, see MLX5_FLOW_ACTION_*. */
669         bool external; /**< true if the flow is created external to PMD. */
670         uint8_t ingress; /**< 1 if the flow is ingress. */
671         union {
672 #ifdef HAVE_IBV_FLOW_DV_SUPPORT
673                 struct mlx5_flow_dv_workspace dv;
674 #endif
675                 struct mlx5_flow_verbs_workspace verbs;
676         };
677         struct mlx5_flow_handle *handle;
678         uint32_t handle_idx; /* Index of the mlx5 flow handle memory. */
679 };
680
681 /* Flow meter state. */
682 #define MLX5_FLOW_METER_DISABLE 0
683 #define MLX5_FLOW_METER_ENABLE 1
684
685 #define MLX5_MAN_WIDTH 8
686 /* Modify this value if enum rte_mtr_color changes. */
687 #define RTE_MTR_DROPPED RTE_COLORS
688
689 /* Meter policer statistics */
690 struct mlx5_flow_policer_stats {
691         uint32_t cnt[RTE_COLORS + 1];
692         /**< Color counter, extra for drop. */
693         uint64_t stats_mask;
694         /**< Statistics mask for the colors. */
695 };
696
697 /* Meter table structure. */
698 struct mlx5_meter_domain_info {
699         struct mlx5_flow_tbl_resource *tbl;
700         /**< Meter table. */
701         struct mlx5_flow_tbl_resource *sfx_tbl;
702         /**< Meter suffix table. */
703         void *any_matcher;
704         /**< Meter color not match default criteria. */
705         void *color_matcher;
706         /**< Meter color match criteria. */
707         void *jump_actn;
708         /**< Meter match action. */
709         void *policer_rules[RTE_MTR_DROPPED + 1];
710         /**< Meter policer for the match. */
711 };
712
713 /* Meter table set for TX RX FDB. */
714 struct mlx5_meter_domains_infos {
715         uint32_t ref_cnt;
716         /**< Table user count. */
717         struct mlx5_meter_domain_info egress;
718         /**< TX meter table. */
719         struct mlx5_meter_domain_info ingress;
720         /**< RX meter table. */
721         struct mlx5_meter_domain_info transfer;
722         /**< FDB meter table. */
723         void *drop_actn;
724         /**< Drop action as not matched. */
725         void *count_actns[RTE_MTR_DROPPED + 1];
726         /**< Counters for match and unmatched statistics. */
727         uint32_t fmp[MLX5_ST_SZ_DW(flow_meter_parameters)];
728         /**< Flow meter parameter. */
729         size_t fmp_size;
730         /**< Flow meter parameter size. */
731         void *meter_action;
732         /**< Flow meter action. */
733 };
734
735 /* Meter parameter structure. */
736 struct mlx5_flow_meter {
737         TAILQ_ENTRY(mlx5_flow_meter) next;
738         /**< Pointer to the next flow meter structure. */
739         uint32_t idx; /* Index to meter object. */
740         uint32_t meter_id;
741         /**< Meter id. */
742         struct mlx5_flow_meter_profile *profile;
743         /**< Meter profile parameters. */
744
745         /** Policer actions (per meter output color). */
746         enum rte_mtr_policer_action action[RTE_COLORS];
747
748         /** Set of stats counters to be enabled.
749          * @see enum rte_mtr_stats_type
750          */
751         uint64_t stats_mask;
752
753         /**< Rule applies to ingress traffic. */
754         uint32_t ingress:1;
755
756         /**< Rule applies to egress traffic. */
757         uint32_t egress:1;
758         /**
759          * Instead of simply matching the properties of traffic as it would
760          * appear on a given DPDK port ID, enabling this attribute transfers
761          * a flow rule to the lowest possible level of any device endpoints
762          * found in the pattern.
763          *
764          * When supported, this effectively enables an application to
765          * re-route traffic not necessarily intended for it (e.g. coming
766          * from or addressed to different physical ports, VFs or
767          * applications) at the device level.
768          *
769          * It complements the behavior of some pattern items such as
770          * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
771          *
772          * When transferring flow rules, ingress and egress attributes keep
773          * their original meaning, as if processing traffic emitted or
774          * received by the application.
775          */
776         uint32_t transfer:1;
777         struct mlx5_meter_domains_infos *mfts;
778         /**< Flow table created for this meter. */
779         struct mlx5_flow_policer_stats policer_stats;
780         /**< Meter policer statistics. */
781         uint32_t ref_cnt;
782         /**< Use count. */
783         uint32_t active_state:1;
784         /**< Meter state. */
785         uint32_t shared:1;
786         /**< Meter shared or not. */
787 };
788
789 /* RFC2697 parameter structure. */
790 struct mlx5_flow_meter_srtcm_rfc2697_prm {
791         /* green_saturation_value = cbs_mantissa * 2^cbs_exponent */
792         uint32_t cbs_exponent:5;
793         uint32_t cbs_mantissa:8;
794         /* cir = 8G * cir_mantissa * 1/(2^cir_exponent) Bytes/Sec */
795         uint32_t cir_exponent:5;
796         uint32_t cir_mantissa:8;
797         /* yellow _saturation_value = ebs_mantissa * 2^ebs_exponent */
798         uint32_t ebs_exponent:5;
799         uint32_t ebs_mantissa:8;
800 };
801
802 /* Flow meter profile structure. */
803 struct mlx5_flow_meter_profile {
804         TAILQ_ENTRY(mlx5_flow_meter_profile) next;
805         /**< Pointer to the next flow meter structure. */
806         uint32_t meter_profile_id; /**< Profile id. */
807         struct rte_mtr_meter_profile profile; /**< Profile detail. */
808         union {
809                 struct mlx5_flow_meter_srtcm_rfc2697_prm srtcm_prm;
810                 /**< srtcm_rfc2697 struct. */
811         };
812         uint32_t ref_cnt; /**< Use count. */
813 };
814
815 /* Fdir flow structure */
816 struct mlx5_fdir_flow {
817         LIST_ENTRY(mlx5_fdir_flow) next; /* Pointer to the next element. */
818         struct mlx5_fdir *fdir; /* Pointer to fdir. */
819         uint32_t rix_flow; /* Index to flow. */
820 };
821
822 #define HAIRPIN_FLOW_ID_BITS 28
823
824 /* Flow structure. */
825 struct rte_flow {
826         ILIST_ENTRY(uint32_t)next; /**< Index to the next flow structure. */
827         uint32_t dev_handles;
828         /**< Device flow handles that are part of the flow. */
829         uint32_t drv_type:2; /**< Driver type. */
830         uint32_t fdir:1; /**< Identifier of associated FDIR if any. */
831         uint32_t hairpin_flow_id:HAIRPIN_FLOW_ID_BITS;
832         /**< The flow id used for hairpin. */
833         uint32_t copy_applied:1; /**< The MARK copy Flow os applied. */
834         uint32_t rix_mreg_copy;
835         /**< Index to metadata register copy table resource. */
836         uint32_t counter; /**< Holds flow counter. */
837         uint16_t meter; /**< Holds flow meter id. */
838 } __rte_packed;
839
840 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
841                                     const struct rte_flow_attr *attr,
842                                     const struct rte_flow_item items[],
843                                     const struct rte_flow_action actions[],
844                                     bool external,
845                                     int hairpin,
846                                     struct rte_flow_error *error);
847 typedef struct mlx5_flow *(*mlx5_flow_prepare_t)
848         (struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
849          const struct rte_flow_item items[],
850          const struct rte_flow_action actions[], struct rte_flow_error *error);
851 typedef int (*mlx5_flow_translate_t)(struct rte_eth_dev *dev,
852                                      struct mlx5_flow *dev_flow,
853                                      const struct rte_flow_attr *attr,
854                                      const struct rte_flow_item items[],
855                                      const struct rte_flow_action actions[],
856                                      struct rte_flow_error *error);
857 typedef int (*mlx5_flow_apply_t)(struct rte_eth_dev *dev, struct rte_flow *flow,
858                                  struct rte_flow_error *error);
859 typedef void (*mlx5_flow_remove_t)(struct rte_eth_dev *dev,
860                                    struct rte_flow *flow);
861 typedef void (*mlx5_flow_destroy_t)(struct rte_eth_dev *dev,
862                                     struct rte_flow *flow);
863 typedef int (*mlx5_flow_query_t)(struct rte_eth_dev *dev,
864                                  struct rte_flow *flow,
865                                  const struct rte_flow_action *actions,
866                                  void *data,
867                                  struct rte_flow_error *error);
868 typedef struct mlx5_meter_domains_infos *(*mlx5_flow_create_mtr_tbls_t)
869                                             (struct rte_eth_dev *dev,
870                                              const struct mlx5_flow_meter *fm);
871 typedef int (*mlx5_flow_destroy_mtr_tbls_t)(struct rte_eth_dev *dev,
872                                         struct mlx5_meter_domains_infos *tbls);
873 typedef int (*mlx5_flow_create_policer_rules_t)
874                                         (struct rte_eth_dev *dev,
875                                          struct mlx5_flow_meter *fm,
876                                          const struct rte_flow_attr *attr);
877 typedef int (*mlx5_flow_destroy_policer_rules_t)
878                                         (struct rte_eth_dev *dev,
879                                          const struct mlx5_flow_meter *fm,
880                                          const struct rte_flow_attr *attr);
881 typedef uint32_t (*mlx5_flow_counter_alloc_t)
882                                    (struct rte_eth_dev *dev);
883 typedef void (*mlx5_flow_counter_free_t)(struct rte_eth_dev *dev,
884                                          uint32_t cnt);
885 typedef int (*mlx5_flow_counter_query_t)(struct rte_eth_dev *dev,
886                                          uint32_t cnt,
887                                          bool clear, uint64_t *pkts,
888                                          uint64_t *bytes);
889 typedef int (*mlx5_flow_get_aged_flows_t)
890                                         (struct rte_eth_dev *dev,
891                                          void **context,
892                                          uint32_t nb_contexts,
893                                          struct rte_flow_error *error);
894 struct mlx5_flow_driver_ops {
895         mlx5_flow_validate_t validate;
896         mlx5_flow_prepare_t prepare;
897         mlx5_flow_translate_t translate;
898         mlx5_flow_apply_t apply;
899         mlx5_flow_remove_t remove;
900         mlx5_flow_destroy_t destroy;
901         mlx5_flow_query_t query;
902         mlx5_flow_create_mtr_tbls_t create_mtr_tbls;
903         mlx5_flow_destroy_mtr_tbls_t destroy_mtr_tbls;
904         mlx5_flow_create_policer_rules_t create_policer_rules;
905         mlx5_flow_destroy_policer_rules_t destroy_policer_rules;
906         mlx5_flow_counter_alloc_t counter_alloc;
907         mlx5_flow_counter_free_t counter_free;
908         mlx5_flow_counter_query_t counter_query;
909         mlx5_flow_get_aged_flows_t get_aged_flows;
910 };
911
912 /* mlx5_flow.c */
913
914 struct mlx5_flow_id_pool *mlx5_flow_id_pool_alloc(uint32_t max_id);
915 void mlx5_flow_id_pool_release(struct mlx5_flow_id_pool *pool);
916 uint32_t mlx5_flow_id_get(struct mlx5_flow_id_pool *pool, uint32_t *id);
917 uint32_t mlx5_flow_id_release(struct mlx5_flow_id_pool *pool,
918                               uint32_t id);
919 int mlx5_flow_group_to_table(const struct rte_flow_attr *attributes,
920                              bool external, uint32_t group, bool fdb_def_rule,
921                              uint32_t *table, struct rte_flow_error *error);
922 uint64_t mlx5_flow_hashfields_adjust(struct mlx5_flow_rss_desc *rss_desc,
923                                      int tunnel, uint64_t layer_types,
924                                      uint64_t hash_fields);
925 uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
926                                    uint32_t subpriority);
927 int mlx5_flow_get_reg_id(struct rte_eth_dev *dev,
928                                      enum mlx5_feature_name feature,
929                                      uint32_t id,
930                                      struct rte_flow_error *error);
931 const struct rte_flow_action *mlx5_flow_find_action
932                                         (const struct rte_flow_action *actions,
933                                          enum rte_flow_action_type action);
934 int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
935                                     const struct rte_flow_attr *attr,
936                                     struct rte_flow_error *error);
937 int mlx5_flow_validate_action_drop(uint64_t action_flags,
938                                    const struct rte_flow_attr *attr,
939                                    struct rte_flow_error *error);
940 int mlx5_flow_validate_action_flag(uint64_t action_flags,
941                                    const struct rte_flow_attr *attr,
942                                    struct rte_flow_error *error);
943 int mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
944                                    uint64_t action_flags,
945                                    const struct rte_flow_attr *attr,
946                                    struct rte_flow_error *error);
947 int mlx5_flow_validate_action_queue(const struct rte_flow_action *action,
948                                     uint64_t action_flags,
949                                     struct rte_eth_dev *dev,
950                                     const struct rte_flow_attr *attr,
951                                     struct rte_flow_error *error);
952 int mlx5_flow_validate_action_rss(const struct rte_flow_action *action,
953                                   uint64_t action_flags,
954                                   struct rte_eth_dev *dev,
955                                   const struct rte_flow_attr *attr,
956                                   uint64_t item_flags,
957                                   struct rte_flow_error *error);
958 int mlx5_flow_validate_action_default_miss(uint64_t action_flags,
959                                 const struct rte_flow_attr *attr,
960                                 struct rte_flow_error *error);
961 int mlx5_flow_validate_attributes(struct rte_eth_dev *dev,
962                                   const struct rte_flow_attr *attributes,
963                                   struct rte_flow_error *error);
964 int mlx5_flow_item_acceptable(const struct rte_flow_item *item,
965                               const uint8_t *mask,
966                               const uint8_t *nic_mask,
967                               unsigned int size,
968                               struct rte_flow_error *error);
969 int mlx5_flow_validate_item_eth(const struct rte_flow_item *item,
970                                 uint64_t item_flags,
971                                 struct rte_flow_error *error);
972 int mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
973                                 uint64_t item_flags,
974                                 uint8_t target_protocol,
975                                 struct rte_flow_error *error);
976 int mlx5_flow_validate_item_gre_key(const struct rte_flow_item *item,
977                                     uint64_t item_flags,
978                                     const struct rte_flow_item *gre_item,
979                                     struct rte_flow_error *error);
980 int mlx5_flow_validate_item_ipv4(const struct rte_flow_item *item,
981                                  uint64_t item_flags,
982                                  uint64_t last_item,
983                                  uint16_t ether_type,
984                                  const struct rte_flow_item_ipv4 *acc_mask,
985                                  struct rte_flow_error *error);
986 int mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
987                                  uint64_t item_flags,
988                                  uint64_t last_item,
989                                  uint16_t ether_type,
990                                  const struct rte_flow_item_ipv6 *acc_mask,
991                                  struct rte_flow_error *error);
992 int mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev,
993                                  const struct rte_flow_item *item,
994                                  uint64_t item_flags,
995                                  uint64_t prev_layer,
996                                  struct rte_flow_error *error);
997 int mlx5_flow_validate_item_tcp(const struct rte_flow_item *item,
998                                 uint64_t item_flags,
999                                 uint8_t target_protocol,
1000                                 const struct rte_flow_item_tcp *flow_mask,
1001                                 struct rte_flow_error *error);
1002 int mlx5_flow_validate_item_udp(const struct rte_flow_item *item,
1003                                 uint64_t item_flags,
1004                                 uint8_t target_protocol,
1005                                 struct rte_flow_error *error);
1006 int mlx5_flow_validate_item_vlan(const struct rte_flow_item *item,
1007                                  uint64_t item_flags,
1008                                  struct rte_eth_dev *dev,
1009                                  struct rte_flow_error *error);
1010 int mlx5_flow_validate_item_vxlan(const struct rte_flow_item *item,
1011                                   uint64_t item_flags,
1012                                   struct rte_flow_error *error);
1013 int mlx5_flow_validate_item_vxlan_gpe(const struct rte_flow_item *item,
1014                                       uint64_t item_flags,
1015                                       struct rte_eth_dev *dev,
1016                                       struct rte_flow_error *error);
1017 int mlx5_flow_validate_item_icmp(const struct rte_flow_item *item,
1018                                  uint64_t item_flags,
1019                                  uint8_t target_protocol,
1020                                  struct rte_flow_error *error);
1021 int mlx5_flow_validate_item_icmp6(const struct rte_flow_item *item,
1022                                    uint64_t item_flags,
1023                                    uint8_t target_protocol,
1024                                    struct rte_flow_error *error);
1025 int mlx5_flow_validate_item_nvgre(const struct rte_flow_item *item,
1026                                   uint64_t item_flags,
1027                                   uint8_t target_protocol,
1028                                   struct rte_flow_error *error);
1029 int mlx5_flow_validate_item_geneve(const struct rte_flow_item *item,
1030                                    uint64_t item_flags,
1031                                    struct rte_eth_dev *dev,
1032                                    struct rte_flow_error *error);
1033 int mlx5_flow_validate_item_ecpri(const struct rte_flow_item *item,
1034                                   uint64_t item_flags,
1035                                   uint64_t last_item,
1036                                   uint16_t ether_type,
1037                                   const struct rte_flow_item_ecpri *acc_mask,
1038                                   struct rte_flow_error *error);
1039 struct mlx5_meter_domains_infos *mlx5_flow_create_mtr_tbls
1040                                         (struct rte_eth_dev *dev,
1041                                          const struct mlx5_flow_meter *fm);
1042 int mlx5_flow_destroy_mtr_tbls(struct rte_eth_dev *dev,
1043                                struct mlx5_meter_domains_infos *tbl);
1044 int mlx5_flow_create_policer_rules(struct rte_eth_dev *dev,
1045                                    struct mlx5_flow_meter *fm,
1046                                    const struct rte_flow_attr *attr);
1047 int mlx5_flow_destroy_policer_rules(struct rte_eth_dev *dev,
1048                                     struct mlx5_flow_meter *fm,
1049                                     const struct rte_flow_attr *attr);
1050 int mlx5_flow_meter_flush(struct rte_eth_dev *dev,
1051                           struct rte_mtr_error *error);
1052 #endif /* RTE_PMD_MLX5_FLOW_H_ */