Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2016 6WIND S.A.
3 : : * Copyright 2016 Mellanox Technologies, Ltd
4 : : */
5 : :
6 : : #ifndef RTE_FLOW_H_
7 : : #define RTE_FLOW_H_
8 : :
9 : : /**
10 : : * @file
11 : : * RTE generic flow API
12 : : *
13 : : * This interface provides the ability to program packet matching and
14 : : * associated actions in hardware through flow rules.
15 : : */
16 : :
17 : : #include <stddef.h>
18 : : #include <stdint.h>
19 : :
20 : : #include <rte_compat.h>
21 : : #include <rte_common.h>
22 : : #include <rte_ether.h>
23 : : #include <rte_arp.h>
24 : : #include <rte_icmp.h>
25 : : #include <rte_ip.h>
26 : : #include <rte_sctp.h>
27 : : #include <rte_tcp.h>
28 : : #include <rte_udp.h>
29 : : #include <rte_vxlan.h>
30 : : #include <rte_esp.h>
31 : : #include <rte_higig.h>
32 : : #include <rte_ecpri.h>
33 : : #include <rte_bitops.h>
34 : : #include <rte_mbuf_dyn.h>
35 : : #include <rte_meter.h>
36 : : #include <rte_gtp.h>
37 : : #include <rte_l2tpv2.h>
38 : : #include <rte_ppp.h>
39 : : #include <rte_gre.h>
40 : : #include <rte_macsec.h>
41 : : #include <rte_ib.h>
42 : :
43 : : #include "rte_ethdev.h"
44 : :
45 : : #ifdef __cplusplus
46 : : extern "C" {
47 : : #endif
48 : :
49 : : /**
50 : : * Flow rule attributes.
51 : : *
52 : : * Priorities are set on a per rule based within groups.
53 : : *
54 : : * Lower values denote higher priority, the highest priority for a flow rule
55 : : * is 0, so that a flow that matches for than one rule, the rule with the
56 : : * lowest priority value will always be matched.
57 : : *
58 : : * Although optional, applications are encouraged to group similar rules as
59 : : * much as possible to fully take advantage of hardware capabilities
60 : : * (e.g. optimized matching) and work around limitations (e.g. a single
61 : : * pattern type possibly allowed in a given group). Applications should be
62 : : * aware that groups are not linked by default, and that they must be
63 : : * explicitly linked by the application using the JUMP action.
64 : : *
65 : : * Priority levels are arbitrary and up to the application, they
66 : : * do not need to be contiguous nor start from 0, however the maximum number
67 : : * varies between devices and may be affected by existing flow rules.
68 : : *
69 : : * If a packet is matched by several rules of a given group for a given
70 : : * priority level, the outcome is undefined. It can take any path, may be
71 : : * duplicated or even cause unrecoverable errors.
72 : : *
73 : : * Note that support for more than a single group and priority level is not
74 : : * guaranteed.
75 : : *
76 : : * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
77 : : * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
78 : : * At embedded switch level, flow rules apply to all traffic seen by it
79 : : * unless fitting meta items are used to set concrete traffic source(s).
80 : : *
81 : : * Several pattern items and actions are valid and can be used in both
82 : : * directions. Those valid for only one direction are described as such.
83 : : *
84 : : * At least one direction must be specified.
85 : : *
86 : : * Specifying both directions at once for a given rule is not recommended
87 : : * but may be valid in a few cases.
88 : : */
89 : : struct rte_flow_attr {
90 : : /**
91 : : * A group is a superset of multiple rules.
92 : : * The default group is 0 and is processed for all packets.
93 : : * Rules in other groups are processed only if the group is chained
94 : : * by a jump action from a previously matched rule.
95 : : * It means the group hierarchy is made by the flow rules,
96 : : * and the group 0 is the hierarchy root.
97 : : * Note there is no automatic dead loop protection.
98 : : * @see rte_flow_action_jump
99 : : */
100 : : uint32_t group;
101 : : uint32_t priority; /**< Rule priority level within group. */
102 : : /**
103 : : * The rule in question applies to ingress traffic (non-"transfer").
104 : : */
105 : : uint32_t ingress:1;
106 : : /**
107 : : * The rule in question applies to egress traffic (non-"transfer").
108 : : */
109 : : uint32_t egress:1;
110 : : /**
111 : : * Instead of simply matching the properties of traffic as it would
112 : : * appear on a given DPDK port ID, enabling this attribute transfers
113 : : * a flow rule to the lowest possible level of any device endpoints
114 : : * found in the pattern.
115 : : *
116 : : * When supported, this effectively enables an application to
117 : : * re-route traffic not necessarily intended for it (e.g. coming
118 : : * from or addressed to different physical ports, VFs or
119 : : * applications) at the device level.
120 : : *
121 : : * The application should match traffic originating from precise
122 : : * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
123 : : *
124 : : * Managing "transfer" flows requires that the user communicate them
125 : : * through a suitable port. @see rte_flow_pick_transfer_proxy().
126 : : */
127 : : uint32_t transfer:1;
128 : : uint32_t reserved:29; /**< Reserved, must be zero. */
129 : : };
130 : :
131 : : struct rte_flow_group_attr {
132 : : uint32_t ingress:1;
133 : : uint32_t egress:1;
134 : : uint32_t transfer:1;
135 : : };
136 : :
137 : : /**
138 : : * Matching pattern item types.
139 : : *
140 : : * Pattern items fall in two categories:
141 : : *
142 : : * - Matching protocol headers and packet data, usually associated with a
143 : : * specification structure. These must be stacked in the same order as the
144 : : * protocol layers to match inside packets, starting from the lowest.
145 : : *
146 : : * - Matching meta-data or affecting pattern processing, often without a
147 : : * specification structure. Since they do not match packet contents, their
148 : : * position in the list is usually not relevant.
149 : : *
150 : : * See the description of individual types for more information. Those
151 : : * marked with [META] fall into the second category.
152 : : */
153 : : enum rte_flow_item_type {
154 : : /**
155 : : * [META]
156 : : *
157 : : * End marker for item lists. Prevents further processing of items,
158 : : * thereby ending the pattern.
159 : : *
160 : : * No associated specification structure.
161 : : */
162 : : RTE_FLOW_ITEM_TYPE_END,
163 : :
164 : : /**
165 : : * [META]
166 : : *
167 : : * Used as a placeholder for convenience. It is ignored and simply
168 : : * discarded by PMDs.
169 : : *
170 : : * No associated specification structure.
171 : : */
172 : : RTE_FLOW_ITEM_TYPE_VOID,
173 : :
174 : : /**
175 : : * [META]
176 : : *
177 : : * Inverted matching, i.e. process packets that do not match the
178 : : * pattern.
179 : : *
180 : : * No associated specification structure.
181 : : */
182 : : RTE_FLOW_ITEM_TYPE_INVERT,
183 : :
184 : : /**
185 : : * Matches any protocol in place of the current layer, a single ANY
186 : : * may also stand for several protocol layers.
187 : : *
188 : : * See struct rte_flow_item_any.
189 : : */
190 : : RTE_FLOW_ITEM_TYPE_ANY,
191 : :
192 : : /**
193 : : * @deprecated
194 : : * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
195 : : * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
196 : : *
197 : : * [META]
198 : : *
199 : : * Matches traffic originating from (ingress) or going to (egress) a
200 : : * given DPDK port ID.
201 : : *
202 : : * See struct rte_flow_item_port_id.
203 : : */
204 : : RTE_FLOW_ITEM_TYPE_PORT_ID,
205 : :
206 : : /**
207 : : * Matches a byte string of a given length at a given offset.
208 : : *
209 : : * See struct rte_flow_item_raw.
210 : : */
211 : : RTE_FLOW_ITEM_TYPE_RAW,
212 : :
213 : : /**
214 : : * Matches an Ethernet header.
215 : : *
216 : : * See struct rte_flow_item_eth.
217 : : */
218 : : RTE_FLOW_ITEM_TYPE_ETH,
219 : :
220 : : /**
221 : : * Matches an 802.1Q/ad VLAN tag.
222 : : *
223 : : * See struct rte_flow_item_vlan.
224 : : */
225 : : RTE_FLOW_ITEM_TYPE_VLAN,
226 : :
227 : : /**
228 : : * Matches an IPv4 header.
229 : : *
230 : : * See struct rte_flow_item_ipv4.
231 : : */
232 : : RTE_FLOW_ITEM_TYPE_IPV4,
233 : :
234 : : /**
235 : : * Matches an IPv6 header.
236 : : *
237 : : * See struct rte_flow_item_ipv6.
238 : : */
239 : : RTE_FLOW_ITEM_TYPE_IPV6,
240 : :
241 : : /**
242 : : * Matches an ICMP header.
243 : : *
244 : : * See struct rte_flow_item_icmp.
245 : : */
246 : : RTE_FLOW_ITEM_TYPE_ICMP,
247 : :
248 : : /**
249 : : * Matches a UDP header.
250 : : *
251 : : * See struct rte_flow_item_udp.
252 : : */
253 : : RTE_FLOW_ITEM_TYPE_UDP,
254 : :
255 : : /**
256 : : * Matches a TCP header.
257 : : *
258 : : * See struct rte_flow_item_tcp.
259 : : */
260 : : RTE_FLOW_ITEM_TYPE_TCP,
261 : :
262 : : /**
263 : : * Matches a SCTP header.
264 : : *
265 : : * See struct rte_flow_item_sctp.
266 : : */
267 : : RTE_FLOW_ITEM_TYPE_SCTP,
268 : :
269 : : /**
270 : : * Matches a VXLAN header.
271 : : *
272 : : * See struct rte_flow_item_vxlan.
273 : : */
274 : : RTE_FLOW_ITEM_TYPE_VXLAN,
275 : :
276 : : /**
277 : : * Matches a E_TAG header.
278 : : *
279 : : * See struct rte_flow_item_e_tag.
280 : : */
281 : : RTE_FLOW_ITEM_TYPE_E_TAG,
282 : :
283 : : /**
284 : : * Matches a NVGRE header.
285 : : *
286 : : * See struct rte_flow_item_nvgre.
287 : : */
288 : : RTE_FLOW_ITEM_TYPE_NVGRE,
289 : :
290 : : /**
291 : : * Matches a MPLS header.
292 : : *
293 : : * See struct rte_flow_item_mpls.
294 : : */
295 : : RTE_FLOW_ITEM_TYPE_MPLS,
296 : :
297 : : /**
298 : : * Matches a GRE header.
299 : : *
300 : : * See struct rte_flow_item_gre.
301 : : */
302 : : RTE_FLOW_ITEM_TYPE_GRE,
303 : :
304 : : /**
305 : : * [META]
306 : : *
307 : : * Fuzzy pattern match, expect faster than default.
308 : : *
309 : : * This is for device that support fuzzy matching option.
310 : : * Usually a fuzzy matching is fast but the cost is accuracy.
311 : : *
312 : : * See struct rte_flow_item_fuzzy.
313 : : */
314 : : RTE_FLOW_ITEM_TYPE_FUZZY,
315 : :
316 : : /**
317 : : * Matches a GTP header.
318 : : *
319 : : * Configure flow for GTP packets.
320 : : *
321 : : * See struct rte_flow_item_gtp.
322 : : */
323 : : RTE_FLOW_ITEM_TYPE_GTP,
324 : :
325 : : /**
326 : : * Matches a GTP header.
327 : : *
328 : : * Configure flow for GTP-C packets.
329 : : *
330 : : * See struct rte_flow_item_gtp.
331 : : */
332 : : RTE_FLOW_ITEM_TYPE_GTPC,
333 : :
334 : : /**
335 : : * Matches a GTP header.
336 : : *
337 : : * Configure flow for GTP-U packets.
338 : : *
339 : : * See struct rte_flow_item_gtp.
340 : : */
341 : : RTE_FLOW_ITEM_TYPE_GTPU,
342 : :
343 : : /**
344 : : * Matches a ESP header.
345 : : *
346 : : * See struct rte_flow_item_esp.
347 : : */
348 : : RTE_FLOW_ITEM_TYPE_ESP,
349 : :
350 : : /**
351 : : * Matches a GENEVE header.
352 : : *
353 : : * See struct rte_flow_item_geneve.
354 : : */
355 : : RTE_FLOW_ITEM_TYPE_GENEVE,
356 : :
357 : : /**
358 : : * @deprecated
359 : : * @see RTE_FLOW_ITEM_TYPE_VXLAN
360 : : *
361 : : * Matches a VXLAN-GPE header.
362 : : *
363 : : * See struct rte_flow_item_vxlan_gpe.
364 : : */
365 : : RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
366 : :
367 : : /**
368 : : * Matches an ARP header for Ethernet/IPv4.
369 : : *
370 : : * See struct rte_flow_item_arp_eth_ipv4.
371 : : */
372 : : RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
373 : :
374 : : /**
375 : : * Matches the presence of any IPv6 extension header.
376 : : *
377 : : * See struct rte_flow_item_ipv6_ext.
378 : : */
379 : : RTE_FLOW_ITEM_TYPE_IPV6_EXT,
380 : :
381 : : /**
382 : : * Matches any ICMPv6 header.
383 : : *
384 : : * See struct rte_flow_item_icmp6.
385 : : */
386 : : RTE_FLOW_ITEM_TYPE_ICMP6,
387 : :
388 : : /**
389 : : * Matches an ICMPv6 neighbor discovery solicitation.
390 : : *
391 : : * See struct rte_flow_item_icmp6_nd_ns.
392 : : */
393 : : RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
394 : :
395 : : /**
396 : : * Matches an ICMPv6 neighbor discovery advertisement.
397 : : *
398 : : * See struct rte_flow_item_icmp6_nd_na.
399 : : */
400 : : RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
401 : :
402 : : /**
403 : : * Matches the presence of any ICMPv6 neighbor discovery option.
404 : : *
405 : : * See struct rte_flow_item_icmp6_nd_opt.
406 : : */
407 : : RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
408 : :
409 : : /**
410 : : * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
411 : : * address option.
412 : : *
413 : : * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
414 : : */
415 : : RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
416 : :
417 : : /**
418 : : * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
419 : : * address option.
420 : : *
421 : : * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
422 : : */
423 : : RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
424 : :
425 : : /**
426 : : * Matches specified mark field.
427 : : *
428 : : * See struct rte_flow_item_mark.
429 : : */
430 : : RTE_FLOW_ITEM_TYPE_MARK,
431 : :
432 : : /**
433 : : * [META]
434 : : *
435 : : * Matches a metadata value.
436 : : *
437 : : * See struct rte_flow_item_meta.
438 : : */
439 : : RTE_FLOW_ITEM_TYPE_META,
440 : :
441 : : /**
442 : : * Matches a GRE optional key field.
443 : : *
444 : : * The value should a big-endian 32bit integer.
445 : : *
446 : : * When this item present the K bit is implicitly matched as "1"
447 : : * in the default mask.
448 : : *
449 : : * @p spec/mask type:
450 : : * @code rte_be32_t * @endcode
451 : : */
452 : : RTE_FLOW_ITEM_TYPE_GRE_KEY,
453 : :
454 : : /**
455 : : * Matches a GTP extension header: PDU session container.
456 : : *
457 : : * Configure flow for GTP packets with extension header type 0x85.
458 : : *
459 : : * See struct rte_flow_item_gtp_psc.
460 : : */
461 : : RTE_FLOW_ITEM_TYPE_GTP_PSC,
462 : :
463 : : /**
464 : : * Matches a PPPoE header.
465 : : *
466 : : * Configure flow for PPPoE session packets.
467 : : *
468 : : * See struct rte_flow_item_pppoe.
469 : : */
470 : : RTE_FLOW_ITEM_TYPE_PPPOES,
471 : :
472 : : /**
473 : : * Matches a PPPoE header.
474 : : *
475 : : * Configure flow for PPPoE discovery packets.
476 : : *
477 : : * See struct rte_flow_item_pppoe.
478 : : */
479 : : RTE_FLOW_ITEM_TYPE_PPPOED,
480 : :
481 : : /**
482 : : * Matches a PPPoE optional proto_id field.
483 : : *
484 : : * It only applies to PPPoE session packets.
485 : : *
486 : : * See struct rte_flow_item_pppoe_proto_id.
487 : : */
488 : : RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
489 : :
490 : : /**
491 : : * Matches Network service header (NSH).
492 : : * See struct rte_flow_item_nsh.
493 : : *
494 : : */
495 : : RTE_FLOW_ITEM_TYPE_NSH,
496 : :
497 : : /**
498 : : * Matches Internet Group Management Protocol (IGMP).
499 : : * See struct rte_flow_item_igmp.
500 : : *
501 : : */
502 : : RTE_FLOW_ITEM_TYPE_IGMP,
503 : :
504 : : /**
505 : : * Matches IP Authentication Header (AH).
506 : : * See struct rte_flow_item_ah.
507 : : *
508 : : */
509 : : RTE_FLOW_ITEM_TYPE_AH,
510 : :
511 : : /**
512 : : * Matches a HIGIG header.
513 : : * see struct rte_flow_item_higig2_hdr.
514 : : */
515 : : RTE_FLOW_ITEM_TYPE_HIGIG2,
516 : :
517 : : /**
518 : : * [META]
519 : : *
520 : : * Matches a tag value.
521 : : *
522 : : * See struct rte_flow_item_tag.
523 : : */
524 : : RTE_FLOW_ITEM_TYPE_TAG,
525 : :
526 : : /**
527 : : * Matches a L2TPv3 over IP header.
528 : : *
529 : : * Configure flow for L2TPv3 over IP packets.
530 : : *
531 : : * See struct rte_flow_item_l2tpv3oip.
532 : : */
533 : : RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
534 : :
535 : : /**
536 : : * Matches PFCP Header.
537 : : * See struct rte_flow_item_pfcp.
538 : : *
539 : : */
540 : : RTE_FLOW_ITEM_TYPE_PFCP,
541 : :
542 : : /**
543 : : * Matches eCPRI Header.
544 : : *
545 : : * Configure flow for eCPRI over ETH or UDP packets.
546 : : *
547 : : * See struct rte_flow_item_ecpri.
548 : : */
549 : : RTE_FLOW_ITEM_TYPE_ECPRI,
550 : :
551 : : /**
552 : : * Matches the presence of IPv6 fragment extension header.
553 : : *
554 : : * See struct rte_flow_item_ipv6_frag_ext.
555 : : */
556 : : RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
557 : :
558 : : /**
559 : : * Matches Geneve Variable Length Option
560 : : *
561 : : * See struct rte_flow_item_geneve_opt
562 : : */
563 : : RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
564 : :
565 : : /**
566 : : * [META]
567 : : *
568 : : * Matches on packet integrity.
569 : : * For some devices application needs to enable integration checks in HW
570 : : * before using this item.
571 : : *
572 : : * @see struct rte_flow_item_integrity.
573 : : */
574 : : RTE_FLOW_ITEM_TYPE_INTEGRITY,
575 : :
576 : : /**
577 : : * [META]
578 : : *
579 : : * Matches conntrack state.
580 : : *
581 : : * @see struct rte_flow_item_conntrack.
582 : : */
583 : : RTE_FLOW_ITEM_TYPE_CONNTRACK,
584 : :
585 : : /**
586 : : * [META]
587 : : *
588 : : * Matches traffic entering the embedded switch from the given ethdev.
589 : : *
590 : : * @see struct rte_flow_item_ethdev
591 : : */
592 : : RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
593 : :
594 : : /**
595 : : * [META]
596 : : *
597 : : * Matches traffic entering the embedded switch from
598 : : * the entity represented by the given ethdev.
599 : : *
600 : : * @see struct rte_flow_item_ethdev
601 : : */
602 : : RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
603 : :
604 : : /**
605 : : * Matches a configured set of fields at runtime calculated offsets
606 : : * over the generic network header with variable length and
607 : : * flexible pattern
608 : : *
609 : : * @see struct rte_flow_item_flex.
610 : : */
611 : : RTE_FLOW_ITEM_TYPE_FLEX,
612 : :
613 : : /**
614 : : * Matches L2TPv2 Header.
615 : : *
616 : : * See struct rte_flow_item_l2tpv2.
617 : : */
618 : : RTE_FLOW_ITEM_TYPE_L2TPV2,
619 : :
620 : : /**
621 : : * Matches PPP Header.
622 : : *
623 : : * See struct rte_flow_item_ppp.
624 : : */
625 : : RTE_FLOW_ITEM_TYPE_PPP,
626 : :
627 : : /**
628 : : * Matches GRE optional fields.
629 : : *
630 : : * See struct rte_flow_item_gre_opt.
631 : : */
632 : : RTE_FLOW_ITEM_TYPE_GRE_OPTION,
633 : :
634 : : /**
635 : : * Matches MACsec Ethernet Header.
636 : : *
637 : : * See struct rte_flow_item_macsec.
638 : : */
639 : : RTE_FLOW_ITEM_TYPE_MACSEC,
640 : :
641 : : /**
642 : : * Matches Meter Color Marker.
643 : : *
644 : : * See struct rte_flow_item_meter_color.
645 : : */
646 : : RTE_FLOW_ITEM_TYPE_METER_COLOR,
647 : :
648 : : /**
649 : : * Matches the presence of IPv6 routing extension header.
650 : : *
651 : : * @see struct rte_flow_item_ipv6_routing_ext.
652 : : */
653 : : RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
654 : :
655 : : /**
656 : : * Matches an ICMPv6 echo request.
657 : : *
658 : : * @see struct rte_flow_item_icmp6_echo.
659 : : */
660 : : RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST,
661 : :
662 : : /**
663 : : * Matches an ICMPv6 echo reply.
664 : : *
665 : : * @see struct rte_flow_item_icmp6_echo.
666 : : */
667 : : RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY,
668 : :
669 : : /**
670 : : * Match Quota state
671 : : *
672 : : * @see struct rte_flow_item_quota
673 : : */
674 : : RTE_FLOW_ITEM_TYPE_QUOTA,
675 : :
676 : : /**
677 : : * Matches on the aggregated port of the received packet.
678 : : * Used in case multiple ports are aggregated to the a DPDK port.
679 : : * First port is number 1.
680 : : *
681 : : * @see struct rte_flow_item_aggr_affinity.
682 : : */
683 : : RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY,
684 : :
685 : : /**
686 : : * Match Tx queue number.
687 : : * This is valid only for egress rules.
688 : : *
689 : : * @see struct rte_flow_item_tx_queue
690 : : */
691 : : RTE_FLOW_ITEM_TYPE_TX_QUEUE,
692 : :
693 : : /**
694 : : * Matches an InfiniBand base transport header in RoCE packet.
695 : : *
696 : : * @see struct rte_flow_item_ib_bth.
697 : : */
698 : : RTE_FLOW_ITEM_TYPE_IB_BTH,
699 : :
700 : : /**
701 : : * Matches the packet type as defined in rte_mbuf_ptype.
702 : : *
703 : : * See struct rte_flow_item_ptype.
704 : : *
705 : : */
706 : : RTE_FLOW_ITEM_TYPE_PTYPE,
707 : :
708 : : /**
709 : : * [META]
710 : : *
711 : : * Matches a random value.
712 : : *
713 : : * This value is not based on the packet data/headers.
714 : : * The application shouldn't assume that this value is kept
715 : : * during the lifetime of the packet.
716 : : *
717 : : * @see struct rte_flow_item_random.
718 : : */
719 : : RTE_FLOW_ITEM_TYPE_RANDOM,
720 : :
721 : : /**
722 : : * Match packet with various comparison types.
723 : : *
724 : : * See struct rte_flow_item_compare.
725 : : */
726 : : RTE_FLOW_ITEM_TYPE_COMPARE,
727 : : };
728 : :
729 : : /**
730 : : * QUOTA state.
731 : : *
732 : : * @see struct rte_flow_item_quota
733 : : */
734 : : enum rte_flow_quota_state {
735 : : RTE_FLOW_QUOTA_STATE_PASS, /**< PASS quota state */
736 : : RTE_FLOW_QUOTA_STATE_BLOCK /**< BLOCK quota state */
737 : : };
738 : :
739 : : /**
740 : : * RTE_FLOW_ITEM_TYPE_QUOTA
741 : : *
742 : : * Matches QUOTA state
743 : : */
744 : : struct rte_flow_item_quota {
745 : : enum rte_flow_quota_state state;
746 : : };
747 : :
748 : : /**
749 : : * Default mask for RTE_FLOW_ITEM_TYPE_QUOTA
750 : : */
751 : : #ifndef __cplusplus
752 : : static const struct rte_flow_item_quota rte_flow_item_quota_mask = {
753 : : .state = (enum rte_flow_quota_state)0xff
754 : : };
755 : : #endif
756 : :
757 : : /**
758 : : *
759 : : * RTE_FLOW_ITEM_TYPE_HIGIG2
760 : : * Matches higig2 header
761 : : */
762 : : struct rte_flow_item_higig2_hdr {
763 : : struct rte_higig2_hdr hdr;
764 : : };
765 : :
766 : : /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
767 : : #ifndef __cplusplus
768 : : static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
769 : : .hdr = {
770 : : .ppt1 = {
771 : : .classification = RTE_BE16(UINT16_MAX),
772 : : .vid = RTE_BE16(0xfff),
773 : : },
774 : : },
775 : : };
776 : : #endif
777 : :
778 : : /**
779 : : * RTE_FLOW_ITEM_TYPE_ANY
780 : : *
781 : : * Matches any protocol in place of the current layer, a single ANY may also
782 : : * stand for several protocol layers.
783 : : *
784 : : * This is usually specified as the first pattern item when looking for a
785 : : * protocol anywhere in a packet.
786 : : *
787 : : * A zeroed mask stands for any number of layers.
788 : : */
789 : : struct rte_flow_item_any {
790 : : uint32_t num; /**< Number of layers covered. */
791 : : };
792 : :
793 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
794 : : #ifndef __cplusplus
795 : : static const struct rte_flow_item_any rte_flow_item_any_mask = {
796 : : .num = 0x00000000,
797 : : };
798 : : #endif
799 : :
800 : : /**
801 : : * @deprecated
802 : : * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
803 : : * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
804 : : *
805 : : * RTE_FLOW_ITEM_TYPE_PORT_ID
806 : : *
807 : : * Matches traffic originating from (ingress) or going to (egress) a given
808 : : * DPDK port ID.
809 : : *
810 : : * Normally only supported if the port ID in question is known by the
811 : : * underlying PMD and related to the device the flow rule is created
812 : : * against.
813 : : */
814 : : struct rte_flow_item_port_id {
815 : : uint32_t id; /**< DPDK port ID. */
816 : : };
817 : :
818 : : /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
819 : : #ifndef __cplusplus
820 : : static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
821 : : .id = 0xffffffff,
822 : : };
823 : : #endif
824 : :
825 : : /**
826 : : * RTE_FLOW_ITEM_TYPE_RAW
827 : : *
828 : : * Matches a byte string of a given length at a given offset.
829 : : *
830 : : * Offset is either absolute (using the start of the packet) or relative to
831 : : * the end of the previous matched item in the stack, in which case negative
832 : : * values are allowed.
833 : : *
834 : : * If search is enabled, offset is used as the starting point. The search
835 : : * area can be delimited by setting limit to a nonzero value, which is the
836 : : * maximum number of bytes after offset where the pattern may start.
837 : : *
838 : : * Matching a zero-length pattern is allowed, doing so resets the relative
839 : : * offset for subsequent items.
840 : : *
841 : : * This type does not support ranges (struct rte_flow_item.last).
842 : : */
843 : : struct rte_flow_item_raw {
844 : : uint32_t relative:1; /**< Look for pattern after the previous item. */
845 : : uint32_t search:1; /**< Search pattern from offset (see also limit). */
846 : : uint32_t reserved:30; /**< Reserved, must be set to zero. */
847 : : int32_t offset; /**< Absolute or relative offset for pattern. */
848 : : uint16_t limit; /**< Search area limit for start of pattern. */
849 : : uint16_t length; /**< Pattern length. */
850 : : const uint8_t *pattern; /**< Byte string to look for. */
851 : : };
852 : :
853 : : /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
854 : : #ifndef __cplusplus
855 : : static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
856 : : .relative = 1,
857 : : .search = 1,
858 : : .reserved = 0x3fffffff,
859 : : .offset = 0xffffffff,
860 : : .limit = 0xffff,
861 : : .length = 0xffff,
862 : : .pattern = NULL,
863 : : };
864 : : #endif
865 : :
866 : : /**
867 : : * RTE_FLOW_ITEM_TYPE_ETH
868 : : *
869 : : * Matches an Ethernet header.
870 : : *
871 : : * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
872 : : * or TPID, depending on whether the item is followed by a VLAN item or not. If
873 : : * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
874 : : * contains the inner TPID in the similar header field. The innermost VLAN item
875 : : * contains a layer-3 EtherType. All of that follows the order seen on the wire.
876 : : *
877 : : * If the field in question contains a TPID value, only tagged packets with the
878 : : * specified TPID will match the pattern. Alternatively, it's possible to match
879 : : * any type of tagged packets by means of the field @p has_vlan rather than use
880 : : * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
881 : : * If this is the case, both tagged and untagged packets will match the pattern.
882 : : */
883 : : struct rte_flow_item_eth {
884 : : union {
885 : : struct {
886 : : /*
887 : : * These fields are retained for compatibility.
888 : : * Please switch to the new header field below.
889 : : */
890 : : struct rte_ether_addr dst; /**< Destination MAC. */
891 : : struct rte_ether_addr src; /**< Source MAC. */
892 : : rte_be16_t type; /**< EtherType or TPID. */
893 : : };
894 : : struct rte_ether_hdr hdr;
895 : : };
896 : : uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
897 : : uint32_t reserved:31; /**< Reserved, must be zero. */
898 : : };
899 : :
900 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
901 : : #ifndef __cplusplus
902 : : static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
903 : : .hdr.dst_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
904 : : .hdr.src_addr.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
905 : : .hdr.ether_type = RTE_BE16(0x0000),
906 : : };
907 : : #endif
908 : :
909 : : /**
910 : : * RTE_FLOW_ITEM_TYPE_VLAN
911 : : *
912 : : * Matches an 802.1Q/ad VLAN tag.
913 : : *
914 : : * The corresponding standard outer EtherType (TPID) values are
915 : : * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
916 : : * the preceding pattern item.
917 : : * If a @p VLAN item is present in the pattern, then only tagged packets will
918 : : * match the pattern.
919 : : * The field @p has_more_vlan can be used to match any type of tagged packets,
920 : : * instead of using the @p eth_proto field of @p hdr.
921 : : * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
922 : : * then any tagged packets will match the pattern.
923 : : */
924 : : struct rte_flow_item_vlan {
925 : : union {
926 : : struct {
927 : : /*
928 : : * These fields are retained for compatibility.
929 : : * Please switch to the new header field below.
930 : : */
931 : : rte_be16_t tci; /**< Tag control information. */
932 : : rte_be16_t inner_type; /**< Inner EtherType or TPID. */
933 : : };
934 : : struct rte_vlan_hdr hdr;
935 : : };
936 : : /** Packet header contains at least one more VLAN, after this VLAN. */
937 : : uint32_t has_more_vlan:1;
938 : : uint32_t reserved:31; /**< Reserved, must be zero. */
939 : : };
940 : :
941 : : /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
942 : : #ifndef __cplusplus
943 : : static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
944 : : .hdr.vlan_tci = RTE_BE16(0x0fff),
945 : : .hdr.eth_proto = RTE_BE16(0x0000),
946 : : };
947 : : #endif
948 : :
949 : : /**
950 : : * RTE_FLOW_ITEM_TYPE_IPV4
951 : : *
952 : : * Matches an IPv4 header.
953 : : *
954 : : * Note: IPv4 options are handled by dedicated pattern items.
955 : : */
956 : : struct rte_flow_item_ipv4 {
957 : : struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
958 : : };
959 : :
960 : : /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
961 : : #ifndef __cplusplus
962 : : static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
963 : : .hdr = {
964 : : .src_addr = RTE_BE32(0xffffffff),
965 : : .dst_addr = RTE_BE32(0xffffffff),
966 : : },
967 : : };
968 : : #endif
969 : :
970 : : /**
971 : : * RTE_FLOW_ITEM_TYPE_IPV6.
972 : : *
973 : : * Matches an IPv6 header.
974 : : *
975 : : * Dedicated flags indicate if header contains specific extension headers.
976 : : */
977 : : struct rte_flow_item_ipv6 {
978 : : struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
979 : : /** Header contains Hop-by-Hop Options extension header. */
980 : : uint32_t has_hop_ext:1;
981 : : /** Header contains Routing extension header. */
982 : : uint32_t has_route_ext:1;
983 : : /** Header contains Fragment extension header. */
984 : : uint32_t has_frag_ext:1;
985 : : /** Header contains Authentication extension header. */
986 : : uint32_t has_auth_ext:1;
987 : : /** Header contains Encapsulation Security Payload extension header. */
988 : : uint32_t has_esp_ext:1;
989 : : /** Header contains Destination Options extension header. */
990 : : uint32_t has_dest_ext:1;
991 : : /** Header contains Mobility extension header. */
992 : : uint32_t has_mobil_ext:1;
993 : : /** Header contains Host Identity Protocol extension header. */
994 : : uint32_t has_hip_ext:1;
995 : : /** Header contains Shim6 Protocol extension header. */
996 : : uint32_t has_shim6_ext:1;
997 : : /** Reserved for future extension headers, must be zero. */
998 : : uint32_t reserved:23;
999 : : };
1000 : :
1001 : : /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
1002 : : #ifndef __cplusplus
1003 : : static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
1004 : : .hdr = {
1005 : : .src_addr = RTE_IPV6_MASK_FULL,
1006 : : .dst_addr = RTE_IPV6_MASK_FULL,
1007 : : },
1008 : : };
1009 : : #endif
1010 : :
1011 : : /**
1012 : : * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
1013 : : *
1014 : : * Matches an IPv6 routing extension header.
1015 : : */
1016 : : struct rte_flow_item_ipv6_routing_ext {
1017 : : struct rte_ipv6_routing_ext hdr;
1018 : : };
1019 : :
1020 : : /**
1021 : : * RTE_FLOW_ITEM_TYPE_ICMP.
1022 : : *
1023 : : * Matches an ICMP header.
1024 : : */
1025 : : struct rte_flow_item_icmp {
1026 : : struct rte_icmp_hdr hdr; /**< ICMP header definition. */
1027 : : };
1028 : :
1029 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
1030 : : #ifndef __cplusplus
1031 : : static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1032 : : .hdr = {
1033 : : .icmp_type = 0xff,
1034 : : .icmp_code = 0xff,
1035 : : },
1036 : : };
1037 : : #endif
1038 : :
1039 : : /**
1040 : : * RTE_FLOW_ITEM_TYPE_UDP.
1041 : : *
1042 : : * Matches a UDP header.
1043 : : */
1044 : : struct rte_flow_item_udp {
1045 : : struct rte_udp_hdr hdr; /**< UDP header definition. */
1046 : : };
1047 : :
1048 : : /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1049 : : #ifndef __cplusplus
1050 : : static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1051 : : .hdr = {
1052 : : .src_port = RTE_BE16(0xffff),
1053 : : .dst_port = RTE_BE16(0xffff),
1054 : : },
1055 : : };
1056 : : #endif
1057 : :
1058 : : /**
1059 : : * RTE_FLOW_ITEM_TYPE_TCP.
1060 : : *
1061 : : * Matches a TCP header.
1062 : : */
1063 : : struct rte_flow_item_tcp {
1064 : : struct rte_tcp_hdr hdr; /**< TCP header definition. */
1065 : : };
1066 : :
1067 : : /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1068 : : #ifndef __cplusplus
1069 : : static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1070 : : .hdr = {
1071 : : .src_port = RTE_BE16(0xffff),
1072 : : .dst_port = RTE_BE16(0xffff),
1073 : : },
1074 : : };
1075 : : #endif
1076 : :
1077 : : /**
1078 : : * RTE_FLOW_ITEM_TYPE_SCTP.
1079 : : *
1080 : : * Matches a SCTP header.
1081 : : */
1082 : : struct rte_flow_item_sctp {
1083 : : struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1084 : : };
1085 : :
1086 : : /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1087 : : #ifndef __cplusplus
1088 : : static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1089 : : .hdr = {
1090 : : .src_port = RTE_BE16(0xffff),
1091 : : .dst_port = RTE_BE16(0xffff),
1092 : : },
1093 : : };
1094 : : #endif
1095 : :
1096 : : /**
1097 : : * RTE_FLOW_ITEM_TYPE_VXLAN.
1098 : : *
1099 : : * Matches a VXLAN header (RFC 7348),
1100 : : * including GPE (draft-ietf-nvo3-vxlan-gpe-13.txt)
1101 : : * and GBP (draft-smith-vxlan-group-policy-05.txt).
1102 : : *
1103 : : * GPE is distinguished with its UDP port.
1104 : : * UDP port may be specified with ``rte_eth_dev_udp_tunnel_port_add()``.
1105 : : */
1106 : : struct rte_flow_item_vxlan {
1107 : : union {
1108 : : struct {
1109 : : /*
1110 : : * These fields are retained for compatibility.
1111 : : * Please switch to the new header field below.
1112 : : */
1113 : : uint8_t flags; /**< Normally 0x08 (I flag). */
1114 : : uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1115 : : uint8_t vni[3]; /**< VXLAN identifier. */
1116 : : uint8_t rsvd1; /**< Reserved, normally 0x00. */
1117 : : };
1118 : : struct rte_vxlan_hdr hdr;
1119 : : };
1120 : : };
1121 : :
1122 : : /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1123 : : #ifndef __cplusplus
1124 : : static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1125 : : .hdr.vni = { 0xff, 0xff, 0xff },
1126 : : };
1127 : : #endif
1128 : :
1129 : : /**
1130 : : * RTE_FLOW_ITEM_TYPE_E_TAG.
1131 : : *
1132 : : * Matches a E-tag header.
1133 : : *
1134 : : * The corresponding standard outer EtherType (TPID) value is
1135 : : * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1136 : : */
1137 : : struct rte_flow_item_e_tag {
1138 : : /**
1139 : : * E-Tag control information (E-TCI).
1140 : : * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1141 : : */
1142 : : rte_be16_t epcp_edei_in_ecid_b;
1143 : : /** Reserved (2b), GRP (2b), E-CID base (12b). */
1144 : : rte_be16_t rsvd_grp_ecid_b;
1145 : : uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1146 : : uint8_t ecid_e; /**< E-CID ext. */
1147 : : rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1148 : : };
1149 : :
1150 : : /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1151 : : #ifndef __cplusplus
1152 : : static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1153 : : .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1154 : : };
1155 : : #endif
1156 : :
1157 : : /**
1158 : : * RTE_FLOW_ITEM_TYPE_NVGRE.
1159 : : *
1160 : : * Matches a NVGRE header.
1161 : : */
1162 : : struct rte_flow_item_nvgre {
1163 : : /**
1164 : : * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1165 : : * reserved 0 (9b), version (3b).
1166 : : *
1167 : : * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1168 : : */
1169 : : rte_be16_t c_k_s_rsvd0_ver;
1170 : : rte_be16_t protocol; /**< Protocol type (0x6558). */
1171 : : uint8_t tni[3]; /**< Virtual subnet ID. */
1172 : : uint8_t flow_id; /**< Flow ID. */
1173 : : };
1174 : :
1175 : : /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1176 : : #ifndef __cplusplus
1177 : : static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1178 : : .tni = { 0xff, 0xff, 0xff },
1179 : : };
1180 : : #endif
1181 : :
1182 : : /**
1183 : : * RTE_FLOW_ITEM_TYPE_MPLS.
1184 : : *
1185 : : * Matches a MPLS header.
1186 : : */
1187 : : struct rte_flow_item_mpls {
1188 : : /**
1189 : : * Label (20b), TC (3b), Bottom of Stack (1b).
1190 : : */
1191 : : uint8_t label_tc_s[3];
1192 : : uint8_t ttl; /** Time-to-Live. */
1193 : : };
1194 : :
1195 : : /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1196 : : #ifndef __cplusplus
1197 : : static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1198 : : .label_tc_s = { 0xff, 0xff, 0xf0 },
1199 : : };
1200 : : #endif
1201 : :
1202 : : /**
1203 : : * RTE_FLOW_ITEM_TYPE_GRE.
1204 : : *
1205 : : * Matches a GRE header.
1206 : : */
1207 : : struct rte_flow_item_gre {
1208 : : /**
1209 : : * Checksum (1b), reserved 0 (12b), version (3b).
1210 : : * Refer to RFC 2784.
1211 : : */
1212 : : rte_be16_t c_rsvd0_ver;
1213 : : rte_be16_t protocol; /**< Protocol type. */
1214 : : };
1215 : :
1216 : : /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1217 : : #ifndef __cplusplus
1218 : : static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1219 : : .protocol = RTE_BE16(0xffff),
1220 : : };
1221 : : #endif
1222 : :
1223 : : /**
1224 : : * RTE_FLOW_ITEM_TYPE_GRE_OPTION.
1225 : : *
1226 : : * Matches GRE optional fields in header.
1227 : : */
1228 : : struct rte_flow_item_gre_opt {
1229 : : struct rte_gre_hdr_opt_checksum_rsvd checksum_rsvd;
1230 : : struct rte_gre_hdr_opt_key key;
1231 : : struct rte_gre_hdr_opt_sequence sequence;
1232 : : };
1233 : :
1234 : : /**
1235 : : * RTE_FLOW_ITEM_TYPE_MACSEC.
1236 : : *
1237 : : * Matches MACsec header.
1238 : : */
1239 : : struct rte_flow_item_macsec {
1240 : : struct rte_macsec_hdr macsec_hdr;
1241 : : };
1242 : :
1243 : : /**
1244 : : * RTE_FLOW_ITEM_TYPE_FUZZY
1245 : : *
1246 : : * Fuzzy pattern match, expect faster than default.
1247 : : *
1248 : : * This is for device that support fuzzy match option.
1249 : : * Usually a fuzzy match is fast but the cost is accuracy.
1250 : : * i.e. Signature Match only match pattern's hash value, but it is
1251 : : * possible two different patterns have the same hash value.
1252 : : *
1253 : : * Matching accuracy level can be configure by threshold.
1254 : : * Driver can divide the range of threshold and map to different
1255 : : * accuracy levels that device support.
1256 : : *
1257 : : * Threshold 0 means perfect match (no fuzziness), while threshold
1258 : : * 0xffffffff means fuzziest match.
1259 : : */
1260 : : struct rte_flow_item_fuzzy {
1261 : : uint32_t thresh; /**< Accuracy threshold. */
1262 : : };
1263 : :
1264 : : /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1265 : : #ifndef __cplusplus
1266 : : static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1267 : : .thresh = 0xffffffff,
1268 : : };
1269 : : #endif
1270 : :
1271 : : /**
1272 : : * RTE_FLOW_ITEM_TYPE_GTP.
1273 : : *
1274 : : * Matches a GTPv1 header.
1275 : : */
1276 : : struct rte_flow_item_gtp {
1277 : : union {
1278 : : struct {
1279 : : /*
1280 : : * These are old fields kept for compatibility.
1281 : : * Please prefer hdr field below.
1282 : : */
1283 : : /**
1284 : : * Version (3b), protocol type (1b), reserved (1b),
1285 : : * Extension header flag (1b),
1286 : : * Sequence number flag (1b),
1287 : : * N-PDU number flag (1b).
1288 : : */
1289 : : uint8_t v_pt_rsv_flags;
1290 : : uint8_t msg_type; /**< Message type. */
1291 : : rte_be16_t msg_len; /**< Message length. */
1292 : : rte_be32_t teid; /**< Tunnel endpoint identifier. */
1293 : : };
1294 : : struct rte_gtp_hdr hdr; /**< GTP header definition. */
1295 : : };
1296 : : };
1297 : :
1298 : : /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1299 : : #ifndef __cplusplus
1300 : : static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1301 : : .hdr.teid = RTE_BE32(UINT32_MAX),
1302 : : };
1303 : : #endif
1304 : :
1305 : : /**
1306 : : * RTE_FLOW_ITEM_TYPE_ESP
1307 : : *
1308 : : * Matches an ESP header.
1309 : : */
1310 : : struct rte_flow_item_esp {
1311 : : struct rte_esp_hdr hdr; /**< ESP header definition. */
1312 : : };
1313 : :
1314 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1315 : : #ifndef __cplusplus
1316 : : static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1317 : : .hdr = {
1318 : : .spi = RTE_BE32(0xffffffff),
1319 : : },
1320 : : };
1321 : : #endif
1322 : :
1323 : : /**
1324 : : * RTE_FLOW_ITEM_TYPE_GENEVE.
1325 : : *
1326 : : * Matches a GENEVE header.
1327 : : */
1328 : : struct rte_flow_item_geneve {
1329 : : /**
1330 : : * Version (2b), length of the options fields (6b), OAM packet (1b),
1331 : : * critical options present (1b), reserved 0 (6b).
1332 : : */
1333 : : rte_be16_t ver_opt_len_o_c_rsvd0;
1334 : : rte_be16_t protocol; /**< Protocol type. */
1335 : : uint8_t vni[3]; /**< Virtual Network Identifier. */
1336 : : uint8_t rsvd1; /**< Reserved, normally 0x00. */
1337 : : };
1338 : :
1339 : : /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1340 : : #ifndef __cplusplus
1341 : : static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1342 : : .vni = { 0xff, 0xff, 0xff },
1343 : : };
1344 : : #endif
1345 : :
1346 : : /**
1347 : : * @deprecated
1348 : : * @see rte_flow_item_vxlan
1349 : : *
1350 : : * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1351 : : *
1352 : : * Matches a VXLAN-GPE header.
1353 : : */
1354 : : struct rte_flow_item_vxlan_gpe {
1355 : : union {
1356 : : struct {
1357 : : /*
1358 : : * These are old fields kept for compatibility.
1359 : : * Please prefer hdr field below.
1360 : : */
1361 : : uint8_t flags; /**< Normally 0x0c (I and P flags). */
1362 : : uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1363 : : uint8_t protocol; /**< Protocol type. */
1364 : : uint8_t vni[3]; /**< VXLAN identifier. */
1365 : : uint8_t rsvd1; /**< Reserved, normally 0x00. */
1366 : : };
1367 : : struct rte_vxlan_gpe_hdr hdr;
1368 : : };
1369 : : };
1370 : :
1371 : : /**
1372 : : * @deprecated
1373 : : * @see rte_flow_item_vxlan_mask
1374 : : *
1375 : : * Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE.
1376 : : */
1377 : : #ifndef __cplusplus
1378 : : static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1379 : : .hdr.vni = { 0xff, 0xff, 0xff },
1380 : : };
1381 : : #endif
1382 : :
1383 : : /**
1384 : : * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1385 : : *
1386 : : * Matches an ARP header for Ethernet/IPv4.
1387 : : */
1388 : : struct rte_flow_item_arp_eth_ipv4 {
1389 : : union {
1390 : : struct {
1391 : : /*
1392 : : * These are old fields kept for compatibility.
1393 : : * Please prefer hdr field below.
1394 : : */
1395 : : rte_be16_t hrd; /**< Hardware type, normally 1. */
1396 : : rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1397 : : uint8_t hln; /**< Hardware address length, normally 6. */
1398 : : uint8_t pln; /**< Protocol address length, normally 4. */
1399 : : rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1400 : : struct rte_ether_addr sha; /**< Sender hardware address. */
1401 : : rte_be32_t spa; /**< Sender IPv4 address. */
1402 : : struct rte_ether_addr tha; /**< Target hardware address. */
1403 : : rte_be32_t tpa; /**< Target IPv4 address. */
1404 : : };
1405 : : struct rte_arp_hdr hdr; /**< ARP header definition. */
1406 : : };
1407 : : };
1408 : :
1409 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1410 : : #ifndef __cplusplus
1411 : : static const struct rte_flow_item_arp_eth_ipv4
1412 : : rte_flow_item_arp_eth_ipv4_mask = {
1413 : : .hdr.arp_data.arp_sha.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1414 : : .hdr.arp_data.arp_sip = RTE_BE32(UINT32_MAX),
1415 : : .hdr.arp_data.arp_tha.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1416 : : .hdr.arp_data.arp_tip = RTE_BE32(UINT32_MAX),
1417 : : };
1418 : : #endif
1419 : :
1420 : : /**
1421 : : * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1422 : : *
1423 : : * Matches the presence of any IPv6 extension header.
1424 : : *
1425 : : * Normally preceded by any of:
1426 : : *
1427 : : * - RTE_FLOW_ITEM_TYPE_IPV6
1428 : : * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1429 : : */
1430 : : struct rte_flow_item_ipv6_ext {
1431 : : uint8_t next_hdr; /**< Next header. */
1432 : : };
1433 : :
1434 : : /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1435 : : #ifndef __cplusplus
1436 : : static const
1437 : : struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1438 : : .next_hdr = 0xff,
1439 : : };
1440 : : #endif
1441 : :
1442 : : /**
1443 : : * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1444 : : *
1445 : : * Matches the presence of IPv6 fragment extension header.
1446 : : *
1447 : : * Preceded by any of:
1448 : : *
1449 : : * - RTE_FLOW_ITEM_TYPE_IPV6
1450 : : * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1451 : : */
1452 : : struct rte_flow_item_ipv6_frag_ext {
1453 : : struct rte_ipv6_fragment_ext hdr;
1454 : : };
1455 : :
1456 : : /**
1457 : : * RTE_FLOW_ITEM_TYPE_ICMP6
1458 : : *
1459 : : * Matches any ICMPv6 header.
1460 : : */
1461 : : struct rte_flow_item_icmp6 {
1462 : : uint8_t type; /**< ICMPv6 type. */
1463 : : uint8_t code; /**< ICMPv6 code. */
1464 : : uint16_t checksum; /**< ICMPv6 checksum. */
1465 : : };
1466 : :
1467 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1468 : : #ifndef __cplusplus
1469 : : static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1470 : : .type = 0xff,
1471 : : .code = 0xff,
1472 : : };
1473 : : #endif
1474 : :
1475 : : /**
1476 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REQUEST
1477 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ECHO_REPLY
1478 : : *
1479 : : * Matches an ICMPv6 echo request or reply.
1480 : : */
1481 : : struct rte_flow_item_icmp6_echo {
1482 : : struct rte_icmp_echo_hdr hdr;
1483 : : };
1484 : :
1485 : : /**
1486 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1487 : : *
1488 : : * Matches an ICMPv6 neighbor discovery solicitation.
1489 : : */
1490 : : struct rte_flow_item_icmp6_nd_ns {
1491 : : uint8_t type; /**< ICMPv6 type, normally 135. */
1492 : : uint8_t code; /**< ICMPv6 code, normally 0. */
1493 : : rte_be16_t checksum; /**< ICMPv6 checksum. */
1494 : : rte_be32_t reserved; /**< Reserved, normally 0. */
1495 : : struct rte_ipv6_addr target_addr; /**< Target address. */
1496 : : };
1497 : :
1498 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1499 : : #ifndef __cplusplus
1500 : : static const
1501 : : struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1502 : : .target_addr = RTE_IPV6_MASK_FULL,
1503 : : };
1504 : : #endif
1505 : :
1506 : : /**
1507 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1508 : : *
1509 : : * Matches an ICMPv6 neighbor discovery advertisement.
1510 : : */
1511 : : struct rte_flow_item_icmp6_nd_na {
1512 : : uint8_t type; /**< ICMPv6 type, normally 136. */
1513 : : uint8_t code; /**< ICMPv6 code, normally 0. */
1514 : : rte_be16_t checksum; /**< ICMPv6 checksum. */
1515 : : /**
1516 : : * Route flag (1b), solicited flag (1b), override flag (1b),
1517 : : * reserved (29b).
1518 : : */
1519 : : rte_be32_t rso_reserved;
1520 : : struct rte_ipv6_addr target_addr; /**< Target address. */
1521 : : };
1522 : :
1523 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1524 : : #ifndef __cplusplus
1525 : : static const
1526 : : struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1527 : : .target_addr = RTE_IPV6_MASK_FULL,
1528 : : };
1529 : : #endif
1530 : :
1531 : : /**
1532 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1533 : : *
1534 : : * Matches the presence of any ICMPv6 neighbor discovery option.
1535 : : *
1536 : : * Normally preceded by any of:
1537 : : *
1538 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1539 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1540 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1541 : : */
1542 : : struct rte_flow_item_icmp6_nd_opt {
1543 : : uint8_t type; /**< ND option type. */
1544 : : uint8_t length; /**< ND option length. */
1545 : : };
1546 : :
1547 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1548 : : #ifndef __cplusplus
1549 : : static const struct rte_flow_item_icmp6_nd_opt
1550 : : rte_flow_item_icmp6_nd_opt_mask = {
1551 : : .type = 0xff,
1552 : : };
1553 : : #endif
1554 : :
1555 : : /**
1556 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1557 : : *
1558 : : * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1559 : : * option.
1560 : : *
1561 : : * Normally preceded by any of:
1562 : : *
1563 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1564 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1565 : : */
1566 : : struct rte_flow_item_icmp6_nd_opt_sla_eth {
1567 : : uint8_t type; /**< ND option type, normally 1. */
1568 : : uint8_t length; /**< ND option length, normally 1. */
1569 : : struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1570 : : };
1571 : :
1572 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1573 : : #ifndef __cplusplus
1574 : : static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1575 : : rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1576 : : .sla.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1577 : : };
1578 : : #endif
1579 : :
1580 : : /**
1581 : : * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1582 : : *
1583 : : * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1584 : : * option.
1585 : : *
1586 : : * Normally preceded by any of:
1587 : : *
1588 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1589 : : * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1590 : : */
1591 : : struct rte_flow_item_icmp6_nd_opt_tla_eth {
1592 : : uint8_t type; /**< ND option type, normally 2. */
1593 : : uint8_t length; /**< ND option length, normally 1. */
1594 : : struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1595 : : };
1596 : :
1597 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1598 : : #ifndef __cplusplus
1599 : : static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1600 : : rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1601 : : .tla.addr_bytes = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
1602 : : };
1603 : : #endif
1604 : :
1605 : : /**
1606 : : * RTE_FLOW_ITEM_TYPE_META
1607 : : *
1608 : : * Matches a specified metadata value. On egress, metadata can be set
1609 : : * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1610 : : * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1611 : : * sets metadata for a packet and the metadata will be reported via mbuf
1612 : : * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1613 : : * mbuf field must be registered in advance by
1614 : : * rte_flow_dynf_metadata_register().
1615 : : */
1616 : : struct rte_flow_item_meta {
1617 : : uint32_t data;
1618 : : };
1619 : :
1620 : : /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1621 : : #ifndef __cplusplus
1622 : : static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1623 : : .data = UINT32_MAX,
1624 : : };
1625 : : #endif
1626 : :
1627 : : /**
1628 : : * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1629 : : *
1630 : : * Matches a GTP PDU extension header with type 0x85.
1631 : : */
1632 : : struct rte_flow_item_gtp_psc {
1633 : : struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1634 : : };
1635 : :
1636 : : /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1637 : : #ifndef __cplusplus
1638 : : static const struct rte_flow_item_gtp_psc
1639 : : rte_flow_item_gtp_psc_mask = {
1640 : : .hdr.qfi = 0x3f,
1641 : : };
1642 : : #endif
1643 : :
1644 : : /**
1645 : : * RTE_FLOW_ITEM_TYPE_PPPOE.
1646 : : *
1647 : : * Matches a PPPoE header.
1648 : : */
1649 : : struct rte_flow_item_pppoe {
1650 : : /**
1651 : : * Version (4b), type (4b).
1652 : : */
1653 : : uint8_t version_type;
1654 : : uint8_t code; /**< Message type. */
1655 : : rte_be16_t session_id; /**< Session identifier. */
1656 : : rte_be16_t length; /**< Payload length. */
1657 : : };
1658 : :
1659 : : /**
1660 : : * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1661 : : *
1662 : : * Matches a PPPoE optional proto_id field.
1663 : : *
1664 : : * It only applies to PPPoE session packets.
1665 : : *
1666 : : * Normally preceded by any of:
1667 : : *
1668 : : * - RTE_FLOW_ITEM_TYPE_PPPOE
1669 : : * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1670 : : */
1671 : : struct rte_flow_item_pppoe_proto_id {
1672 : : rte_be16_t proto_id; /**< PPP protocol identifier. */
1673 : : };
1674 : :
1675 : : /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1676 : : #ifndef __cplusplus
1677 : : static const struct rte_flow_item_pppoe_proto_id
1678 : : rte_flow_item_pppoe_proto_id_mask = {
1679 : : .proto_id = RTE_BE16(0xffff),
1680 : : };
1681 : : #endif
1682 : :
1683 : : /**
1684 : : * RTE_FLOW_ITEM_TYPE_TAG
1685 : : *
1686 : : * Matches a specified tag value at the specified index.
1687 : : */
1688 : : struct rte_flow_item_tag {
1689 : : uint32_t data;
1690 : : uint8_t index;
1691 : : };
1692 : :
1693 : : /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1694 : : #ifndef __cplusplus
1695 : : static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1696 : : .data = 0xffffffff,
1697 : : .index = 0xff,
1698 : : };
1699 : : #endif
1700 : :
1701 : : /**
1702 : : * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1703 : : *
1704 : : * Matches a L2TPv3 over IP header.
1705 : : */
1706 : : struct rte_flow_item_l2tpv3oip {
1707 : : rte_be32_t session_id; /**< Session ID. */
1708 : : };
1709 : :
1710 : : /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1711 : : #ifndef __cplusplus
1712 : : static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1713 : : .session_id = RTE_BE32(UINT32_MAX),
1714 : : };
1715 : : #endif
1716 : :
1717 : :
1718 : : /**
1719 : : * RTE_FLOW_ITEM_TYPE_MARK
1720 : : *
1721 : : * Matches an arbitrary integer value which was set using the ``MARK`` action
1722 : : * in a previously matched rule.
1723 : : *
1724 : : * This item can only be specified once as a match criteria as the ``MARK``
1725 : : * action can only be specified once in a flow action.
1726 : : *
1727 : : * This value is arbitrary and application-defined. Maximum allowed value
1728 : : * depends on the underlying implementation.
1729 : : *
1730 : : * Depending on the underlying implementation the MARK item may be supported on
1731 : : * the physical device, with virtual groups in the PMD or not at all.
1732 : : */
1733 : : struct rte_flow_item_mark {
1734 : : uint32_t id; /**< Integer value to match against. */
1735 : : };
1736 : :
1737 : : /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1738 : : #ifndef __cplusplus
1739 : : static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1740 : : .id = 0xffffffff,
1741 : : };
1742 : : #endif
1743 : :
1744 : : /**
1745 : : * RTE_FLOW_ITEM_TYPE_NSH
1746 : : *
1747 : : * Match network service header (NSH), RFC 8300
1748 : : */
1749 : : struct rte_flow_item_nsh {
1750 : : uint32_t version:2;
1751 : : uint32_t oam_pkt:1;
1752 : : uint32_t reserved:1;
1753 : : uint32_t ttl:6;
1754 : : uint32_t length:6;
1755 : : uint32_t reserved1:4;
1756 : : uint32_t mdtype:4;
1757 : : uint32_t next_proto:8;
1758 : : uint32_t spi:24;
1759 : : uint32_t sindex:8;
1760 : : };
1761 : :
1762 : : /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1763 : : #ifndef __cplusplus
1764 : : static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1765 : : .mdtype = 0xf,
1766 : : .next_proto = 0xff,
1767 : : .spi = 0xffffff,
1768 : : .sindex = 0xff,
1769 : : };
1770 : : #endif
1771 : :
1772 : : /**
1773 : : * RTE_FLOW_ITEM_TYPE_IGMP
1774 : : *
1775 : : * Match Internet Group Management Protocol (IGMP), RFC 2236
1776 : : */
1777 : : struct rte_flow_item_igmp {
1778 : : uint32_t type:8;
1779 : : uint32_t max_resp_time:8;
1780 : : uint32_t checksum:16;
1781 : : uint32_t group_addr;
1782 : : };
1783 : :
1784 : : /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1785 : : #ifndef __cplusplus
1786 : : static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1787 : : .group_addr = 0xffffffff,
1788 : : };
1789 : : #endif
1790 : :
1791 : : /**
1792 : : * RTE_FLOW_ITEM_TYPE_AH
1793 : : *
1794 : : * Match IP Authentication Header (AH), RFC 4302
1795 : : */
1796 : : struct rte_flow_item_ah {
1797 : : uint32_t next_hdr:8;
1798 : : uint32_t payload_len:8;
1799 : : uint32_t reserved:16;
1800 : : uint32_t spi;
1801 : : uint32_t seq_num;
1802 : : };
1803 : :
1804 : : /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1805 : : #ifndef __cplusplus
1806 : : static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1807 : : .spi = 0xffffffff,
1808 : : };
1809 : : #endif
1810 : :
1811 : : /**
1812 : : * RTE_FLOW_ITEM_TYPE_PFCP
1813 : : *
1814 : : * Match PFCP Header
1815 : : */
1816 : : struct rte_flow_item_pfcp {
1817 : : uint8_t s_field;
1818 : : uint8_t msg_type;
1819 : : rte_be16_t msg_len;
1820 : : rte_be64_t seid;
1821 : : };
1822 : :
1823 : : /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1824 : : #ifndef __cplusplus
1825 : : static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1826 : : .s_field = 0x01,
1827 : : .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1828 : : };
1829 : : #endif
1830 : :
1831 : : /**
1832 : : * RTE_FLOW_ITEM_TYPE_ECPRI
1833 : : *
1834 : : * Match eCPRI Header
1835 : : */
1836 : : struct rte_flow_item_ecpri {
1837 : : struct rte_ecpri_combined_msg_hdr hdr;
1838 : : };
1839 : :
1840 : : /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1841 : : #ifndef __cplusplus
1842 : : static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1843 : : .hdr = {
1844 : : .common = {
1845 : : .u32 = 0x0,
1846 : : },
1847 : : },
1848 : : };
1849 : : #endif
1850 : :
1851 : : /**
1852 : : * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1853 : : *
1854 : : * Matches a GENEVE Variable Length Option
1855 : : */
1856 : : struct rte_flow_item_geneve_opt {
1857 : : rte_be16_t option_class;
1858 : : uint8_t option_type;
1859 : : uint8_t option_len;
1860 : : uint32_t *data;
1861 : : };
1862 : :
1863 : : /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1864 : : #ifndef __cplusplus
1865 : : static const struct rte_flow_item_geneve_opt
1866 : : rte_flow_item_geneve_opt_mask = {
1867 : : .option_type = 0xff,
1868 : : };
1869 : : #endif
1870 : :
1871 : : /**
1872 : : * RTE_FLOW_ITEM_TYPE_INTEGRITY
1873 : : *
1874 : : * Match on packet integrity check result.
1875 : : */
1876 : : struct rte_flow_item_integrity {
1877 : : /** Tunnel encapsulation level the item should apply to.
1878 : : * @see rte_flow_action_rss
1879 : : */
1880 : : uint32_t level;
1881 : : union {
1882 : : __extension__
1883 : : struct {
1884 : : /** The packet is valid after passing all HW checks. */
1885 : : uint64_t packet_ok:1;
1886 : : /** L2 layer is valid after passing all HW checks. */
1887 : : uint64_t l2_ok:1;
1888 : : /** L3 layer is valid after passing all HW checks. */
1889 : : uint64_t l3_ok:1;
1890 : : /** L4 layer is valid after passing all HW checks. */
1891 : : uint64_t l4_ok:1;
1892 : : /** L2 layer CRC is valid. */
1893 : : uint64_t l2_crc_ok:1;
1894 : : /** IPv4 layer checksum is valid. */
1895 : : uint64_t ipv4_csum_ok:1;
1896 : : /** L4 layer checksum is valid. */
1897 : : uint64_t l4_csum_ok:1;
1898 : : /** L3 length is smaller than frame length. */
1899 : : uint64_t l3_len_ok:1;
1900 : : uint64_t reserved:56;
1901 : : };
1902 : : uint64_t value;
1903 : : };
1904 : : };
1905 : :
1906 : : #ifndef __cplusplus
1907 : : static const struct rte_flow_item_integrity
1908 : : rte_flow_item_integrity_mask = {
1909 : : .level = 0,
1910 : : .value = 0,
1911 : : };
1912 : : #endif
1913 : :
1914 : : /**
1915 : : * The packet is valid after conntrack checking.
1916 : : */
1917 : : #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1918 : : /**
1919 : : * The state of the connection is changed.
1920 : : */
1921 : : #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1922 : : /**
1923 : : * Error is detected on this packet for this connection and
1924 : : * an invalid state is set.
1925 : : */
1926 : : #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1927 : : /**
1928 : : * The HW connection tracking module is disabled.
1929 : : * It can be due to application command or an invalid state.
1930 : : */
1931 : : #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1932 : : /**
1933 : : * The packet contains some bad field(s) and cannot continue
1934 : : * with the conntrack module checking.
1935 : : */
1936 : : #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1937 : :
1938 : : /**
1939 : : * RTE_FLOW_ITEM_TYPE_CONNTRACK
1940 : : *
1941 : : * Matches the state of a packet after it passed the connection tracking
1942 : : * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1943 : : * or a reasonable combination of these bits.
1944 : : */
1945 : : struct rte_flow_item_conntrack {
1946 : : uint32_t flags;
1947 : : };
1948 : :
1949 : : /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1950 : : #ifndef __cplusplus
1951 : : static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1952 : : .flags = 0xffffffff,
1953 : : };
1954 : : #endif
1955 : :
1956 : : /**
1957 : : * Provides an ethdev port ID for use with the following items:
1958 : : * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1959 : : * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1960 : : */
1961 : : struct rte_flow_item_ethdev {
1962 : : uint16_t port_id; /**< ethdev port ID */
1963 : : };
1964 : :
1965 : : /** Default mask for items based on struct rte_flow_item_ethdev */
1966 : : #ifndef __cplusplus
1967 : : static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1968 : : .port_id = 0xffff,
1969 : : };
1970 : : #endif
1971 : :
1972 : : /**
1973 : : * RTE_FLOW_ITEM_TYPE_L2TPV2
1974 : : *
1975 : : * Matches L2TPv2 Header
1976 : : */
1977 : : struct rte_flow_item_l2tpv2 {
1978 : : struct rte_l2tpv2_combined_msg_hdr hdr;
1979 : : };
1980 : :
1981 : : /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1982 : : #ifndef __cplusplus
1983 : : static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1984 : : /*
1985 : : * flags and version bit mask
1986 : : * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1987 : : * T L x x S x O P x x x x V V V V
1988 : : */
1989 : : .hdr = {
1990 : : .common = {
1991 : : .flags_version = RTE_BE16(0xcb0f),
1992 : : },
1993 : : },
1994 : : };
1995 : : #endif
1996 : :
1997 : : /**
1998 : : * RTE_FLOW_ITEM_TYPE_PPP
1999 : : *
2000 : : * Matches PPP Header
2001 : : */
2002 : : struct rte_flow_item_ppp {
2003 : : struct rte_ppp_hdr hdr;
2004 : : };
2005 : :
2006 : : /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
2007 : : #ifndef __cplusplus
2008 : : static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
2009 : : .hdr = {
2010 : : .addr = 0xff,
2011 : : .ctrl = 0xff,
2012 : : .proto_id = RTE_BE16(0xffff),
2013 : : }
2014 : : };
2015 : : #endif
2016 : :
2017 : : /**
2018 : : * RTE_FLOW_ITEM_TYPE_IB_BTH.
2019 : : *
2020 : : * Matches an InfiniBand base transport header in RoCE packet.
2021 : : */
2022 : : struct rte_flow_item_ib_bth {
2023 : : struct rte_ib_bth hdr; /**< InfiniBand base transport header definition. */
2024 : : };
2025 : :
2026 : : /** Default mask for RTE_FLOW_ITEM_TYPE_IB_BTH. */
2027 : : #ifndef __cplusplus
2028 : : static const struct rte_flow_item_ib_bth rte_flow_item_ib_bth_mask = {
2029 : : .hdr = {
2030 : : .opcode = 0xff,
2031 : : .dst_qp = { 0xff, 0xff, 0xff },
2032 : : },
2033 : : };
2034 : : #endif
2035 : :
2036 : : /**
2037 : : * RTE_FLOW_ITEM_TYPE_RANDOM
2038 : : *
2039 : : * Matches a random value.
2040 : : */
2041 : : struct rte_flow_item_random {
2042 : : uint32_t value;
2043 : : };
2044 : :
2045 : : /** Default mask for RTE_FLOW_ITEM_TYPE_RANDOM. */
2046 : : #ifndef __cplusplus
2047 : : static const struct rte_flow_item_random rte_flow_item_random_mask = {
2048 : : .value = UINT32_MAX,
2049 : : };
2050 : : #endif
2051 : :
2052 : : /**
2053 : : * Matching pattern item definition.
2054 : : *
2055 : : * A pattern is formed by stacking items starting from the lowest protocol
2056 : : * layer to match. This stacking restriction does not apply to meta items
2057 : : * which can be placed anywhere in the stack without affecting the meaning
2058 : : * of the resulting pattern.
2059 : : *
2060 : : * Patterns are terminated by END items.
2061 : : *
2062 : : * The spec field should be a valid pointer to a structure of the related
2063 : : * item type. It may remain unspecified (NULL) in many cases to request
2064 : : * broad (nonspecific) matching. In such cases, last and mask must also be
2065 : : * set to NULL.
2066 : : *
2067 : : * Optionally, last can point to a structure of the same type to define an
2068 : : * inclusive range. This is mostly supported by integer and address fields,
2069 : : * may cause errors otherwise. Fields that do not support ranges must be set
2070 : : * to 0 or to the same value as the corresponding fields in spec.
2071 : : *
2072 : : * Only the fields defined to nonzero values in the default masks (see
2073 : : * rte_flow_item_{name}_mask constants) are considered relevant by
2074 : : * default. This can be overridden by providing a mask structure of the
2075 : : * same type with applicable bits set to one. It can also be used to
2076 : : * partially filter out specific fields (e.g. as an alternate mean to match
2077 : : * ranges of IP addresses).
2078 : : *
2079 : : * Mask is a simple bit-mask applied before interpreting the contents of
2080 : : * spec and last, which may yield unexpected results if not used
2081 : : * carefully. For example, if for an IPv4 address field, spec provides
2082 : : * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
2083 : : * effective range becomes 10.1.0.0 to 10.3.255.255.
2084 : : */
2085 : : struct rte_flow_item {
2086 : : enum rte_flow_item_type type; /**< Item type. */
2087 : : const void *spec; /**< Pointer to item specification structure. */
2088 : : const void *last; /**< Defines an inclusive range (spec to last). */
2089 : : const void *mask; /**< Bit-mask applied to spec and last. */
2090 : : };
2091 : :
2092 : : /**
2093 : : * RTE_FLOW_ITEM_TYPE_FLEX
2094 : : *
2095 : : * Matches a specified set of fields within the network protocol
2096 : : * header. Each field is presented as set of bits with specified width, and
2097 : : * bit offset from the header beginning.
2098 : : *
2099 : : * The pattern is concatenation of bit fields configured at item creation
2100 : : * by rte_flow_flex_item_create(). At configuration the fields are presented
2101 : : * by sample_data array.
2102 : : *
2103 : : * This type does not support ranges (struct rte_flow_item.last).
2104 : : */
2105 : : struct rte_flow_item_flex {
2106 : : struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
2107 : : uint32_t length; /**< Pattern length in bytes. */
2108 : : const uint8_t *pattern; /**< Combined bitfields pattern to match. */
2109 : : };
2110 : : /**
2111 : : * Field bit offset calculation mode.
2112 : : */
2113 : : enum rte_flow_item_flex_field_mode {
2114 : : /**
2115 : : * Dummy field, used for byte boundary alignment in pattern.
2116 : : * Pattern mask and data are ignored in the match. All configuration
2117 : : * parameters besides field size are ignored.
2118 : : */
2119 : : FIELD_MODE_DUMMY = 0,
2120 : : /**
2121 : : * Fixed offset field. The bit offset from header beginning
2122 : : * is permanent and defined by field_base parameter.
2123 : : */
2124 : : FIELD_MODE_FIXED,
2125 : : /**
2126 : : * The field bit offset is extracted from other header field (indirect
2127 : : * offset field). The resulting field offset to match is calculated as:
2128 : : *
2129 : : * field_base + (*offset_base & offset_mask) << offset_shift
2130 : : */
2131 : : FIELD_MODE_OFFSET,
2132 : : /**
2133 : : * The field bit offset is extracted from other header field (indirect
2134 : : * offset field), the latter is considered as bitmask containing some
2135 : : * number of one bits, the resulting field offset to match is
2136 : : * calculated as:
2137 : : *
2138 : : * field_base + bitcount(*offset_base & offset_mask) << offset_shift
2139 : : */
2140 : : FIELD_MODE_BITMASK,
2141 : : };
2142 : :
2143 : : /**
2144 : : * Flex item field tunnel mode
2145 : : */
2146 : : enum rte_flow_item_flex_tunnel_mode {
2147 : : /**
2148 : : * The protocol header can be present in the packet only once.
2149 : : * No multiple flex item flow inclusions (for inner/outer) are allowed.
2150 : : * No any relations with tunnel protocols are imposed. The drivers
2151 : : * can optimize hardware resource usage to handle match on single flex
2152 : : * item of specific type.
2153 : : */
2154 : : FLEX_TUNNEL_MODE_SINGLE = 0,
2155 : : /**
2156 : : * Flex item presents outer header only.
2157 : : */
2158 : : FLEX_TUNNEL_MODE_OUTER,
2159 : : /**
2160 : : * Flex item presents inner header only.
2161 : : */
2162 : : FLEX_TUNNEL_MODE_INNER,
2163 : : /**
2164 : : * Flex item presents either inner or outer header. The driver
2165 : : * handles as many multiple inners as hardware supports.
2166 : : */
2167 : : FLEX_TUNNEL_MODE_MULTI,
2168 : : /**
2169 : : * Flex item presents tunnel protocol header.
2170 : : */
2171 : : FLEX_TUNNEL_MODE_TUNNEL,
2172 : : };
2173 : :
2174 : : /**
2175 : : * Description of a single field of a flex item.
2176 : : */
2177 : : __extension__
2178 : : struct rte_flow_item_flex_field {
2179 : : /** Defines how match field offset is calculated over the packet. */
2180 : : enum rte_flow_item_flex_field_mode field_mode;
2181 : : uint32_t field_size; /**< Field size in bits. */
2182 : : int32_t field_base; /**< Field offset in bits. */
2183 : : uint32_t offset_base; /**< Indirect offset field offset in bits. */
2184 : : uint32_t offset_mask; /**< Indirect offset field bit mask. */
2185 : : int32_t offset_shift; /**< Indirect offset multiply factor. */
2186 : : uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2187 : : uint32_t reserved:16; /**< Reserved field. */
2188 : : };
2189 : :
2190 : : /**
2191 : : * Description of a link between a flex item and its neighbour headers.
2192 : : */
2193 : : struct rte_flow_item_flex_link {
2194 : : /**
2195 : : * Preceding/following header. The item type must be always provided.
2196 : : * For preceding one item must specify the header value/mask to match
2197 : : * for the link be taken and start the flex item header parsing.
2198 : : */
2199 : : struct rte_flow_item item;
2200 : : /**
2201 : : * Next field value to match to continue with one of the configured
2202 : : * next protocols.
2203 : : */
2204 : : uint32_t next;
2205 : : };
2206 : :
2207 : : /**
2208 : : * Flex item configuration: field descriptions and neighbour links.
2209 : : */
2210 : : struct rte_flow_item_flex_conf {
2211 : : /**
2212 : : * Specifies the flex item and tunnel relations and tells the PMD
2213 : : * whether flex item can be used for inner, outer or both headers,
2214 : : * or whether flex item presents the tunnel protocol itself.
2215 : : */
2216 : : enum rte_flow_item_flex_tunnel_mode tunnel;
2217 : : /**
2218 : : * The next header offset, it presents the network header size covered
2219 : : * by the flex item and can be obtained with all supported offset
2220 : : * calculating methods (fixed, dedicated field, bitmask, etc).
2221 : : */
2222 : : struct rte_flow_item_flex_field next_header;
2223 : : /**
2224 : : * Specifies the next protocol field to match with link next protocol
2225 : : * values and continue packet parsing with matching link.
2226 : : */
2227 : : struct rte_flow_item_flex_field next_protocol;
2228 : : /**
2229 : : * The fields will be sampled and presented for explicit match
2230 : : * with pattern in the rte_flow_flex_item. There can be multiple
2231 : : * fields descriptors, the number should be specified by nb_samples.
2232 : : */
2233 : : struct rte_flow_item_flex_field *sample_data;
2234 : : /** Number of field descriptors in the sample_data array. */
2235 : : uint32_t nb_samples;
2236 : : /**
2237 : : * Input link defines the flex item relation with preceding
2238 : : * header. It specified the preceding item type and provides pattern
2239 : : * to match. The flex item will continue parsing and will provide the
2240 : : * data to flow match in case if there is the match with one of input
2241 : : * links.
2242 : : */
2243 : : struct rte_flow_item_flex_link *input_link;
2244 : : /** Number of link descriptors in the input link array. */
2245 : : uint32_t nb_inputs;
2246 : : /**
2247 : : * Output link defines the next protocol field value to match and
2248 : : * the following protocol header to continue packet parsing. Also
2249 : : * defines the tunnel-related behaviour.
2250 : : */
2251 : : struct rte_flow_item_flex_link *output_link;
2252 : : /** Number of link descriptors in the output link array. */
2253 : : uint32_t nb_outputs;
2254 : : };
2255 : :
2256 : : /**
2257 : : * RTE_FLOW_ITEM_TYPE_METER_COLOR.
2258 : : *
2259 : : * Matches Color Marker set by a Meter.
2260 : : */
2261 : : struct rte_flow_item_meter_color {
2262 : : enum rte_color color; /**< Meter color marker. */
2263 : : };
2264 : :
2265 : : /** Default mask for RTE_FLOW_ITEM_TYPE_METER_COLOR. */
2266 : : #ifndef __cplusplus
2267 : : static const struct rte_flow_item_meter_color rte_flow_item_meter_color_mask = {
2268 : : .color = RTE_COLORS,
2269 : : };
2270 : : #endif
2271 : :
2272 : : /**
2273 : : * RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY
2274 : : *
2275 : : * For multiple ports aggregated to a single DPDK port,
2276 : : * match the aggregated port receiving the packets.
2277 : : */
2278 : : struct rte_flow_item_aggr_affinity {
2279 : : /**
2280 : : * An aggregated port receiving the packets.
2281 : : * Numbering starts from 1.
2282 : : * Number of aggregated ports is reported by rte_eth_dev_count_aggr_ports().
2283 : : */
2284 : : uint8_t affinity;
2285 : : };
2286 : :
2287 : : /** Default mask for RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY. */
2288 : : #ifndef __cplusplus
2289 : : static const struct rte_flow_item_aggr_affinity
2290 : : rte_flow_item_aggr_affinity_mask = {
2291 : : .affinity = 0xff,
2292 : : };
2293 : : #endif
2294 : :
2295 : : /**
2296 : : * RTE_FLOW_ITEM_TYPE_TX_QUEUE
2297 : : *
2298 : : * Tx queue number.
2299 : : *
2300 : : * @see struct rte_flow_item_tx_queue
2301 : : */
2302 : : struct rte_flow_item_tx_queue {
2303 : : /** Tx queue number of packet being transmitted. */
2304 : : uint16_t tx_queue;
2305 : : };
2306 : :
2307 : : /** Default mask for RTE_FLOW_ITEM_TX_QUEUE. */
2308 : : #ifndef __cplusplus
2309 : : static const struct rte_flow_item_tx_queue rte_flow_item_tx_queue_mask = {
2310 : : .tx_queue = 0xffff,
2311 : : };
2312 : : #endif
2313 : :
2314 : : /**
2315 : : *
2316 : : * RTE_FLOW_ITEM_TYPE_PTYPE
2317 : : *
2318 : : * Matches the packet type as defined in rte_mbuf_ptype.
2319 : : */
2320 : : struct rte_flow_item_ptype {
2321 : : uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
2322 : : };
2323 : :
2324 : : /** Default mask for RTE_FLOW_ITEM_TYPE_PTYPE. */
2325 : : #ifndef __cplusplus
2326 : : static const struct rte_flow_item_ptype rte_flow_item_ptype_mask = {
2327 : : .packet_type = 0xffffffff,
2328 : : };
2329 : : #endif
2330 : :
2331 : : /**
2332 : : * Packet header field IDs, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2333 : : * and RTE_FLOW_ITEM_TYPE_COMPARE.
2334 : : */
2335 : : enum rte_flow_field_id {
2336 : : RTE_FLOW_FIELD_START = 0, /**< Start of a packet. */
2337 : : RTE_FLOW_FIELD_MAC_DST, /**< Destination MAC Address. */
2338 : : RTE_FLOW_FIELD_MAC_SRC, /**< Source MAC Address. */
2339 : : RTE_FLOW_FIELD_VLAN_TYPE, /**< VLAN Tag Identifier. */
2340 : : RTE_FLOW_FIELD_VLAN_ID, /**< VLAN Identifier. */
2341 : : RTE_FLOW_FIELD_MAC_TYPE, /**< EtherType. */
2342 : : RTE_FLOW_FIELD_IPV4_DSCP, /**< IPv4 DSCP. */
2343 : : RTE_FLOW_FIELD_IPV4_TTL, /**< IPv4 Time To Live. */
2344 : : RTE_FLOW_FIELD_IPV4_SRC, /**< IPv4 Source Address. */
2345 : : RTE_FLOW_FIELD_IPV4_DST, /**< IPv4 Destination Address. */
2346 : : RTE_FLOW_FIELD_IPV6_DSCP, /**< IPv6 DSCP. */
2347 : : RTE_FLOW_FIELD_IPV6_HOPLIMIT, /**< IPv6 Hop Limit. */
2348 : : RTE_FLOW_FIELD_IPV6_SRC, /**< IPv6 Source Address. */
2349 : : RTE_FLOW_FIELD_IPV6_DST, /**< IPv6 Destination Address. */
2350 : : RTE_FLOW_FIELD_TCP_PORT_SRC, /**< TCP Source Port Number. */
2351 : : RTE_FLOW_FIELD_TCP_PORT_DST, /**< TCP Destination Port Number. */
2352 : : RTE_FLOW_FIELD_TCP_SEQ_NUM, /**< TCP Sequence Number. */
2353 : : RTE_FLOW_FIELD_TCP_ACK_NUM, /**< TCP Acknowledgment Number. */
2354 : : RTE_FLOW_FIELD_TCP_FLAGS, /**< TCP Flags. */
2355 : : RTE_FLOW_FIELD_UDP_PORT_SRC, /**< UDP Source Port Number. */
2356 : : RTE_FLOW_FIELD_UDP_PORT_DST, /**< UDP Destination Port Number. */
2357 : : RTE_FLOW_FIELD_VXLAN_VNI, /**< VXLAN Network Identifier. */
2358 : : RTE_FLOW_FIELD_GENEVE_VNI, /**< GENEVE Network Identifier. */
2359 : : RTE_FLOW_FIELD_GTP_TEID, /**< GTP Tunnel Endpoint Identifier. */
2360 : : RTE_FLOW_FIELD_TAG, /**< Tag value. */
2361 : : RTE_FLOW_FIELD_MARK, /**< Mark value. */
2362 : : RTE_FLOW_FIELD_META, /**< Metadata value. */
2363 : : RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */
2364 : : RTE_FLOW_FIELD_VALUE, /**< Immediate value. */
2365 : : RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */
2366 : : RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */
2367 : : RTE_FLOW_FIELD_GTP_PSC_QFI, /**< GTP QFI. */
2368 : : RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */
2369 : : RTE_FLOW_FIELD_IPV6_PROTO, /**< IPv6 next header. */
2370 : : RTE_FLOW_FIELD_FLEX_ITEM, /**< Flex item. */
2371 : : RTE_FLOW_FIELD_HASH_RESULT, /**< Hash result. */
2372 : : RTE_FLOW_FIELD_GENEVE_OPT_TYPE, /**< GENEVE option type. */
2373 : : RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */
2374 : : RTE_FLOW_FIELD_GENEVE_OPT_DATA, /**< GENEVE option data. */
2375 : : RTE_FLOW_FIELD_MPLS, /**< MPLS header. */
2376 : : RTE_FLOW_FIELD_TCP_DATA_OFFSET, /**< TCP data offset. */
2377 : : RTE_FLOW_FIELD_IPV4_IHL, /**< IPv4 IHL. */
2378 : : RTE_FLOW_FIELD_IPV4_TOTAL_LEN, /**< IPv4 total length. */
2379 : : RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN,/**< IPv6 payload length. */
2380 : : RTE_FLOW_FIELD_IPV4_PROTO, /**< IPv4 next protocol. */
2381 : : RTE_FLOW_FIELD_IPV6_FLOW_LABEL, /**< IPv6 flow label. */
2382 : : RTE_FLOW_FIELD_IPV6_TRAFFIC_CLASS, /**< IPv6 traffic class. */
2383 : : RTE_FLOW_FIELD_ESP_SPI, /**< ESP SPI. */
2384 : : RTE_FLOW_FIELD_ESP_SEQ_NUM, /**< ESP Sequence Number. */
2385 : : RTE_FLOW_FIELD_ESP_PROTO, /**< ESP next protocol value. */
2386 : : RTE_FLOW_FIELD_RANDOM, /**< Random value. */
2387 : : RTE_FLOW_FIELD_VXLAN_LAST_RSVD, /**< VXLAN last reserved byte. */
2388 : : };
2389 : :
2390 : : /**
2391 : : * Packet header field descriptions, used by RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2392 : : * and RTE_FLOW_ITEM_TYPE_COMPARE.
2393 : : */
2394 : : struct rte_flow_field_data {
2395 : : enum rte_flow_field_id field; /**< Field or memory type ID. */
2396 : : union {
2397 : : struct {
2398 : : /** Encapsulation level and tag index or flex item handle. */
2399 : : union {
2400 : : struct {
2401 : : /**
2402 : : * Packet encapsulation level containing
2403 : : * the field to modify.
2404 : : *
2405 : : * - @p 0 requests the default behavior.
2406 : : * Depending on the packet type, it
2407 : : * can mean outermost, innermost or
2408 : : * anything in between.
2409 : : *
2410 : : * It basically stands for the
2411 : : * innermost encapsulation level.
2412 : : * Modification can be performed
2413 : : * according to PMD and device
2414 : : * capabilities.
2415 : : *
2416 : : * - @p 1 requests modification to be
2417 : : * performed on the outermost packet
2418 : : * encapsulation level.
2419 : : *
2420 : : * - @p 2 and subsequent values request
2421 : : * modification to be performed on
2422 : : * the specified inner packet
2423 : : * encapsulation level, from
2424 : : * outermost to innermost (lower to
2425 : : * higher values).
2426 : : *
2427 : : * Values other than @p 0 are not
2428 : : * necessarily supported.
2429 : : *
2430 : : * @note that for MPLS field,
2431 : : * encapsulation level also include
2432 : : * tunnel since MPLS may appear in
2433 : : * outer, inner or tunnel.
2434 : : */
2435 : : uint8_t level;
2436 : : union {
2437 : : /**
2438 : : * Tag index array inside
2439 : : * encapsulation level.
2440 : : * Used for VLAN, MPLS or TAG types.
2441 : : */
2442 : : uint8_t tag_index;
2443 : : /**
2444 : : * Geneve option identifier.
2445 : : * Relevant only for
2446 : : * RTE_FLOW_FIELD_GENEVE_OPT_XXXX
2447 : : * modification type.
2448 : : */
2449 : : struct {
2450 : : /**
2451 : : * Geneve option type.
2452 : : */
2453 : : uint8_t type;
2454 : : /**
2455 : : * Geneve option class.
2456 : : */
2457 : : rte_be16_t class_id;
2458 : : };
2459 : : };
2460 : : };
2461 : : struct rte_flow_item_flex_handle *flex_handle;
2462 : : };
2463 : : /** Number of bits to skip from a field. */
2464 : : uint32_t offset;
2465 : : };
2466 : : /**
2467 : : * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
2468 : : * same byte order and length as in relevant rte_flow_item_xxx.
2469 : : * The immediate source bitfield offset is inherited from
2470 : : * the destination's one.
2471 : : */
2472 : : uint8_t value[16];
2473 : : /**
2474 : : * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
2475 : : * should be the same as for relevant field in the
2476 : : * rte_flow_item_xxx structure.
2477 : : */
2478 : : void *pvalue;
2479 : : };
2480 : : };
2481 : :
2482 : : /**
2483 : : * Expected operation types for compare item.
2484 : : */
2485 : : enum rte_flow_item_compare_op {
2486 : : RTE_FLOW_ITEM_COMPARE_EQ, /* Compare result equal. */
2487 : : RTE_FLOW_ITEM_COMPARE_NE, /* Compare result not equal. */
2488 : : RTE_FLOW_ITEM_COMPARE_LT, /* Compare result less than. */
2489 : : RTE_FLOW_ITEM_COMPARE_LE, /* Compare result less than or equal. */
2490 : : RTE_FLOW_ITEM_COMPARE_GT, /* Compare result great than. */
2491 : : RTE_FLOW_ITEM_COMPARE_GE, /* Compare result great than or equal. */
2492 : : };
2493 : :
2494 : : /**
2495 : : *
2496 : : * RTE_FLOW_ITEM_TYPE_COMPARE
2497 : : *
2498 : : * Matches the packet with compare result.
2499 : : *
2500 : : * The operation means a compare with b result.
2501 : : */
2502 : : struct rte_flow_item_compare {
2503 : : enum rte_flow_item_compare_op operation; /* The compare operation. */
2504 : : struct rte_flow_field_data a; /* Field be compared. */
2505 : : struct rte_flow_field_data b; /* Field as comparator. */
2506 : : uint32_t width; /* Compare width. */
2507 : : };
2508 : :
2509 : : /**
2510 : : * Action types.
2511 : : *
2512 : : * Each possible action is represented by a type.
2513 : : * An action can have an associated configuration object.
2514 : : * Several actions combined in a list can be assigned
2515 : : * to a flow rule and are performed in order.
2516 : : *
2517 : : * They fall in three categories:
2518 : : *
2519 : : * - Actions that modify the fate of matching traffic, for instance by
2520 : : * dropping or assigning it a specific destination.
2521 : : *
2522 : : * - Actions that modify matching traffic contents or its properties. This
2523 : : * includes adding/removing encapsulation, encryption, compression and
2524 : : * marks.
2525 : : *
2526 : : * - Actions related to the flow rule itself, such as updating counters or
2527 : : * making it non-terminating.
2528 : : *
2529 : : * Flow rules being terminating by default, not specifying any action of the
2530 : : * fate kind results in undefined behavior. This applies to both ingress and
2531 : : * egress.
2532 : : *
2533 : : * PASSTHRU, when supported, makes a flow rule non-terminating.
2534 : : */
2535 : : enum rte_flow_action_type {
2536 : : /**
2537 : : * End marker for action lists. Prevents further processing of
2538 : : * actions, thereby ending the list.
2539 : : *
2540 : : * No associated configuration structure.
2541 : : */
2542 : : RTE_FLOW_ACTION_TYPE_END,
2543 : :
2544 : : /**
2545 : : * Used as a placeholder for convenience. It is ignored and simply
2546 : : * discarded by PMDs.
2547 : : *
2548 : : * No associated configuration structure.
2549 : : */
2550 : : RTE_FLOW_ACTION_TYPE_VOID,
2551 : :
2552 : : /**
2553 : : * Leaves traffic up for additional processing by subsequent flow
2554 : : * rules; makes a flow rule non-terminating.
2555 : : *
2556 : : * No associated configuration structure.
2557 : : */
2558 : : RTE_FLOW_ACTION_TYPE_PASSTHRU,
2559 : :
2560 : : /**
2561 : : * RTE_FLOW_ACTION_TYPE_JUMP
2562 : : *
2563 : : * Redirects packets to a group on the current device.
2564 : : *
2565 : : * See struct rte_flow_action_jump.
2566 : : */
2567 : : RTE_FLOW_ACTION_TYPE_JUMP,
2568 : :
2569 : : /**
2570 : : * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2571 : : * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2572 : : *
2573 : : * See struct rte_flow_action_mark.
2574 : : *
2575 : : * One should negotiate mark delivery from the NIC to the PMD.
2576 : : * @see rte_eth_rx_metadata_negotiate()
2577 : : * @see RTE_ETH_RX_METADATA_USER_MARK
2578 : : */
2579 : : RTE_FLOW_ACTION_TYPE_MARK,
2580 : :
2581 : : /**
2582 : : * Flags packets. Similar to MARK without a specific value; only
2583 : : * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2584 : : *
2585 : : * No associated configuration structure.
2586 : : *
2587 : : * One should negotiate flag delivery from the NIC to the PMD.
2588 : : * @see rte_eth_rx_metadata_negotiate()
2589 : : * @see RTE_ETH_RX_METADATA_USER_FLAG
2590 : : */
2591 : : RTE_FLOW_ACTION_TYPE_FLAG,
2592 : :
2593 : : /**
2594 : : * Assigns packets to a given queue index.
2595 : : *
2596 : : * See struct rte_flow_action_queue.
2597 : : */
2598 : : RTE_FLOW_ACTION_TYPE_QUEUE,
2599 : :
2600 : : /**
2601 : : * Drops packets.
2602 : : *
2603 : : * PASSTHRU overrides this action if both are specified.
2604 : : *
2605 : : * No associated configuration structure.
2606 : : */
2607 : : RTE_FLOW_ACTION_TYPE_DROP,
2608 : :
2609 : : /**
2610 : : * Enables counters for this flow rule.
2611 : : *
2612 : : * These counters can be retrieved and reset through rte_flow_query() or
2613 : : * rte_flow_action_handle_query() if the action provided via handle,
2614 : : * see struct rte_flow_query_count.
2615 : : *
2616 : : * See struct rte_flow_action_count.
2617 : : */
2618 : : RTE_FLOW_ACTION_TYPE_COUNT,
2619 : :
2620 : : /**
2621 : : * Similar to QUEUE, except RSS is additionally performed on packets
2622 : : * to spread them among several queues according to the provided
2623 : : * parameters.
2624 : : *
2625 : : * See struct rte_flow_action_rss.
2626 : : */
2627 : : RTE_FLOW_ACTION_TYPE_RSS,
2628 : :
2629 : : /**
2630 : : * @deprecated
2631 : : * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2632 : : * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2633 : : *
2634 : : * Directs matching traffic to the physical function (PF) of the
2635 : : * current device.
2636 : : *
2637 : : * No associated configuration structure.
2638 : : */
2639 : : RTE_FLOW_ACTION_TYPE_PF,
2640 : :
2641 : : /**
2642 : : * @deprecated
2643 : : * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2644 : : * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2645 : : *
2646 : : * Directs matching traffic to a given virtual function of the
2647 : : * current device.
2648 : : *
2649 : : * See struct rte_flow_action_vf.
2650 : : */
2651 : : RTE_FLOW_ACTION_TYPE_VF,
2652 : :
2653 : : /**
2654 : : * @deprecated
2655 : : * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2656 : : * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2657 : : *
2658 : : * Directs matching traffic to a given DPDK port ID.
2659 : : *
2660 : : * See struct rte_flow_action_port_id.
2661 : : */
2662 : : RTE_FLOW_ACTION_TYPE_PORT_ID,
2663 : :
2664 : : /**
2665 : : * Traffic metering and policing (MTR).
2666 : : *
2667 : : * See struct rte_flow_action_meter.
2668 : : * See file rte_mtr.h for MTR object configuration.
2669 : : */
2670 : : RTE_FLOW_ACTION_TYPE_METER,
2671 : :
2672 : : /**
2673 : : * Redirects packets to security engine of current device for security
2674 : : * processing as specified by security session.
2675 : : *
2676 : : * See struct rte_flow_action_security.
2677 : : */
2678 : : RTE_FLOW_ACTION_TYPE_SECURITY,
2679 : :
2680 : : /**
2681 : : * @warning This is a legacy action.
2682 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2683 : : *
2684 : : * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2685 : : * the OpenFlow Switch Specification.
2686 : : *
2687 : : * No associated configuration structure.
2688 : : */
2689 : : RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2690 : :
2691 : : /**
2692 : : * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2693 : : * by the OpenFlow Switch Specification.
2694 : : *
2695 : : * No associated configuration structure.
2696 : : */
2697 : : RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2698 : :
2699 : : /**
2700 : : * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2701 : : * the OpenFlow Switch Specification.
2702 : : *
2703 : : * See struct rte_flow_action_of_push_vlan.
2704 : : */
2705 : : RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2706 : :
2707 : : /**
2708 : : * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2709 : : * defined by the OpenFlow Switch Specification.
2710 : : *
2711 : : * See struct rte_flow_action_of_set_vlan_vid.
2712 : : */
2713 : : RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2714 : :
2715 : : /**
2716 : : * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2717 : : * defined by the OpenFlow Switch Specification.
2718 : : *
2719 : : * See struct rte_flow_action_of_set_vlan_pcp.
2720 : : */
2721 : : RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2722 : :
2723 : : /**
2724 : : * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2725 : : * by the OpenFlow Switch Specification.
2726 : : *
2727 : : * See struct rte_flow_action_of_pop_mpls.
2728 : : */
2729 : : RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2730 : :
2731 : : /**
2732 : : * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2733 : : * the OpenFlow Switch Specification.
2734 : : *
2735 : : * See struct rte_flow_action_of_push_mpls.
2736 : : */
2737 : : RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2738 : :
2739 : : /**
2740 : : * Encapsulate flow in VXLAN tunnel as defined in
2741 : : * rte_flow_action_vxlan_encap action structure.
2742 : : *
2743 : : * See struct rte_flow_action_vxlan_encap.
2744 : : */
2745 : : RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2746 : :
2747 : : /**
2748 : : * Decapsulate outer most VXLAN tunnel from matched flow.
2749 : : *
2750 : : * If flow pattern does not define a valid VXLAN tunnel (as specified by
2751 : : * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2752 : : * error.
2753 : : */
2754 : : RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2755 : :
2756 : : /**
2757 : : * Encapsulate flow in NVGRE tunnel defined in the
2758 : : * rte_flow_action_nvgre_encap action structure.
2759 : : *
2760 : : * See struct rte_flow_action_nvgre_encap.
2761 : : */
2762 : : RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2763 : :
2764 : : /**
2765 : : * Decapsulate outer most NVGRE tunnel from matched flow.
2766 : : *
2767 : : * If flow pattern does not define a valid NVGRE tunnel (as specified by
2768 : : * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2769 : : * error.
2770 : : */
2771 : : RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2772 : :
2773 : : /**
2774 : : * Add outer header whose template is provided in its data buffer
2775 : : *
2776 : : * See struct rte_flow_action_raw_encap.
2777 : : */
2778 : : RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2779 : :
2780 : : /**
2781 : : * Remove outer header whose template is provided in its data buffer.
2782 : : *
2783 : : * See struct rte_flow_action_raw_decap
2784 : : */
2785 : : RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2786 : :
2787 : : /**
2788 : : * @warning This is a legacy action.
2789 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2790 : : *
2791 : : * Modify IPv4 source address in the outermost IPv4 header.
2792 : : *
2793 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2794 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2795 : : *
2796 : : * See struct rte_flow_action_set_ipv4.
2797 : : */
2798 : : RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2799 : :
2800 : : /**
2801 : : * @warning This is a legacy action.
2802 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2803 : : *
2804 : : * Modify IPv4 destination address in the outermost IPv4 header.
2805 : : *
2806 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2807 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2808 : : *
2809 : : * See struct rte_flow_action_set_ipv4.
2810 : : */
2811 : : RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2812 : :
2813 : : /**
2814 : : * @warning This is a legacy action.
2815 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2816 : : *
2817 : : * Modify IPv6 source address in the outermost IPv6 header.
2818 : : *
2819 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2820 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2821 : : *
2822 : : * See struct rte_flow_action_set_ipv6.
2823 : : */
2824 : : RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2825 : :
2826 : : /**
2827 : : * @warning This is a legacy action.
2828 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2829 : : *
2830 : : * Modify IPv6 destination address in the outermost IPv6 header.
2831 : : *
2832 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2833 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2834 : : *
2835 : : * See struct rte_flow_action_set_ipv6.
2836 : : */
2837 : : RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2838 : :
2839 : : /**
2840 : : * @warning This is a legacy action.
2841 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2842 : : *
2843 : : * Modify source port number in the outermost TCP/UDP header.
2844 : : *
2845 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2846 : : * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2847 : : * RTE_FLOW_ERROR_TYPE_ACTION error.
2848 : : *
2849 : : * See struct rte_flow_action_set_tp.
2850 : : */
2851 : : RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2852 : :
2853 : : /**
2854 : : * @warning This is a legacy action.
2855 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2856 : : *
2857 : : * Modify destination port number in the outermost TCP/UDP header.
2858 : : *
2859 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2860 : : * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2861 : : * RTE_FLOW_ERROR_TYPE_ACTION error.
2862 : : *
2863 : : * See struct rte_flow_action_set_tp.
2864 : : */
2865 : : RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2866 : :
2867 : : /**
2868 : : * Swap the source and destination MAC addresses in the outermost
2869 : : * Ethernet header.
2870 : : *
2871 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2872 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2873 : : *
2874 : : * No associated configuration structure.
2875 : : */
2876 : : RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2877 : :
2878 : : /**
2879 : : * @warning This is a legacy action.
2880 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2881 : : *
2882 : : * Decrease TTL value directly
2883 : : *
2884 : : * No associated configuration structure.
2885 : : */
2886 : : RTE_FLOW_ACTION_TYPE_DEC_TTL,
2887 : :
2888 : : /**
2889 : : * @warning This is a legacy action.
2890 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2891 : : *
2892 : : * Set TTL value
2893 : : *
2894 : : * See struct rte_flow_action_set_ttl
2895 : : */
2896 : : RTE_FLOW_ACTION_TYPE_SET_TTL,
2897 : :
2898 : : /**
2899 : : * @warning This is a legacy action.
2900 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2901 : : *
2902 : : * Set source MAC address from matched flow.
2903 : : *
2904 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2905 : : * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2906 : : *
2907 : : * See struct rte_flow_action_set_mac.
2908 : : */
2909 : : RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2910 : :
2911 : : /**
2912 : : * @warning This is a legacy action.
2913 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2914 : : *
2915 : : * Set destination MAC address from matched flow.
2916 : : *
2917 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2918 : : * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2919 : : *
2920 : : * See struct rte_flow_action_set_mac.
2921 : : */
2922 : : RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2923 : :
2924 : : /**
2925 : : * @warning This is a legacy action.
2926 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2927 : : *
2928 : : * Increase sequence number in the outermost TCP header.
2929 : : *
2930 : : * Action configuration specifies the value to increase
2931 : : * TCP sequence number as a big-endian 32 bit integer.
2932 : : *
2933 : : * @p conf type:
2934 : : * @code rte_be32_t * @endcode
2935 : : *
2936 : : * Using this action on non-matching traffic will result in
2937 : : * undefined behavior.
2938 : : */
2939 : : RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2940 : :
2941 : : /**
2942 : : * @warning This is a legacy action.
2943 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2944 : : *
2945 : : * Decrease sequence number in the outermost TCP header.
2946 : : *
2947 : : * Action configuration specifies the value to decrease
2948 : : * TCP sequence number as a big-endian 32 bit integer.
2949 : : *
2950 : : * @p conf type:
2951 : : * @code rte_be32_t * @endcode
2952 : : *
2953 : : * Using this action on non-matching traffic will result in
2954 : : * undefined behavior.
2955 : : */
2956 : : RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2957 : :
2958 : : /**
2959 : : * @warning This is a legacy action.
2960 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2961 : : *
2962 : : * Increase acknowledgment number in the outermost TCP header.
2963 : : *
2964 : : * Action configuration specifies the value to increase
2965 : : * TCP acknowledgment number as a big-endian 32 bit integer.
2966 : : *
2967 : : * @p conf type:
2968 : : * @code rte_be32_t * @endcode
2969 : :
2970 : : * Using this action on non-matching traffic will result in
2971 : : * undefined behavior.
2972 : : */
2973 : : RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2974 : :
2975 : : /**
2976 : : * @warning This is a legacy action.
2977 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2978 : : *
2979 : : * Decrease acknowledgment number in the outermost TCP header.
2980 : : *
2981 : : * Action configuration specifies the value to decrease
2982 : : * TCP acknowledgment number as a big-endian 32 bit integer.
2983 : : *
2984 : : * @p conf type:
2985 : : * @code rte_be32_t * @endcode
2986 : : *
2987 : : * Using this action on non-matching traffic will result in
2988 : : * undefined behavior.
2989 : : */
2990 : : RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2991 : :
2992 : : /**
2993 : : * @warning This is a legacy action.
2994 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2995 : : *
2996 : : * Set Tag.
2997 : : *
2998 : : * Tag is for internal flow usage only and
2999 : : * is not delivered to the application.
3000 : : *
3001 : : * See struct rte_flow_action_set_tag.
3002 : : */
3003 : : RTE_FLOW_ACTION_TYPE_SET_TAG,
3004 : :
3005 : : /**
3006 : : * @warning This is a legacy action.
3007 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3008 : : *
3009 : : * Set metadata on ingress or egress path.
3010 : : *
3011 : : * See struct rte_flow_action_set_meta.
3012 : : */
3013 : : RTE_FLOW_ACTION_TYPE_SET_META,
3014 : :
3015 : : /**
3016 : : * @warning This is a legacy action.
3017 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3018 : : *
3019 : : * Modify IPv4 DSCP in the outermost IP header.
3020 : : *
3021 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
3022 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
3023 : : *
3024 : : * See struct rte_flow_action_set_dscp.
3025 : : */
3026 : : RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
3027 : :
3028 : : /**
3029 : : * @warning This is a legacy action.
3030 : : * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3031 : : *
3032 : : * Modify IPv6 DSCP in the outermost IP header.
3033 : : *
3034 : : * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
3035 : : * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
3036 : : *
3037 : : * See struct rte_flow_action_set_dscp.
3038 : : */
3039 : : RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
3040 : :
3041 : : /**
3042 : : * Report as aged flow if timeout passed without any matching on the
3043 : : * flow.
3044 : : *
3045 : : * See struct rte_flow_action_age.
3046 : : * See function rte_flow_get_q_aged_flows
3047 : : * See function rte_flow_get_aged_flows
3048 : : * see enum RTE_ETH_EVENT_FLOW_AGED
3049 : : * See struct rte_flow_query_age
3050 : : * See struct rte_flow_update_age
3051 : : */
3052 : : RTE_FLOW_ACTION_TYPE_AGE,
3053 : :
3054 : : /**
3055 : : * The matching packets will be duplicated with specified ratio and
3056 : : * applied with own set of actions with a fate action.
3057 : : *
3058 : : * See struct rte_flow_action_sample.
3059 : : */
3060 : : RTE_FLOW_ACTION_TYPE_SAMPLE,
3061 : :
3062 : : /**
3063 : : * @deprecated
3064 : : * @see RTE_FLOW_ACTION_TYPE_INDIRECT
3065 : : *
3066 : : * Describe action shared across multiple flow rules.
3067 : : *
3068 : : * Allow multiple rules reference the same action by handle (see
3069 : : * struct rte_flow_shared_action).
3070 : : */
3071 : : RTE_FLOW_ACTION_TYPE_SHARED,
3072 : :
3073 : : /**
3074 : : * Modify a packet header field, tag, mark or metadata.
3075 : : *
3076 : : * Allow the modification of an arbitrary header field via
3077 : : * set, add and sub operations or copying its content into
3078 : : * tag, meta or mark for future processing.
3079 : : *
3080 : : * See struct rte_flow_action_modify_field.
3081 : : */
3082 : : RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
3083 : :
3084 : : /**
3085 : : * An action handle is referenced in a rule through an indirect action.
3086 : : *
3087 : : * The same action handle may be used in multiple rules for the same
3088 : : * or different ethdev ports.
3089 : : */
3090 : : RTE_FLOW_ACTION_TYPE_INDIRECT,
3091 : :
3092 : : /**
3093 : : * [META]
3094 : : *
3095 : : * Enable tracking a TCP connection state.
3096 : : *
3097 : : * @see struct rte_flow_action_conntrack.
3098 : : */
3099 : : RTE_FLOW_ACTION_TYPE_CONNTRACK,
3100 : :
3101 : : /**
3102 : : * Color the packet to reflect the meter color result.
3103 : : * Set the meter color in the mbuf to the selected color.
3104 : : *
3105 : : * See struct rte_flow_action_meter_color.
3106 : : */
3107 : : RTE_FLOW_ACTION_TYPE_METER_COLOR,
3108 : :
3109 : : /**
3110 : : * At embedded switch level, sends matching traffic to the given ethdev.
3111 : : *
3112 : : * @see struct rte_flow_action_ethdev
3113 : : */
3114 : : RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3115 : :
3116 : : /**
3117 : : * At embedded switch level, send matching traffic to
3118 : : * the entity represented by the given ethdev.
3119 : : *
3120 : : * @see struct rte_flow_action_ethdev
3121 : : */
3122 : : RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
3123 : :
3124 : : /**
3125 : : * Traffic metering and marking (MTR).
3126 : : *
3127 : : * @see struct rte_flow_action_meter_mark
3128 : : * See file rte_mtr.h for MTR profile object configuration.
3129 : : */
3130 : : RTE_FLOW_ACTION_TYPE_METER_MARK,
3131 : :
3132 : : /**
3133 : : * Send packets to the kernel, without going to userspace at all.
3134 : : * The packets will be received by the kernel driver sharing
3135 : : * the same device as the DPDK port on which this action is configured.
3136 : : * This action mostly suits bifurcated driver model.
3137 : : *
3138 : : * No associated configuration structure.
3139 : : */
3140 : : RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
3141 : :
3142 : : /**
3143 : : * Apply the quota verdict (PASS or BLOCK) to a flow.
3144 : : *
3145 : : * @see struct rte_flow_action_quota
3146 : : * @see struct rte_flow_query_quota
3147 : : * @see struct rte_flow_update_quota
3148 : : */
3149 : : RTE_FLOW_ACTION_TYPE_QUOTA,
3150 : :
3151 : : /**
3152 : : * Skip congestion management configuration.
3153 : : *
3154 : : * Using rte_eth_cman_config_set(), the application
3155 : : * can configure ethdev Rx queue's congestion mechanism.
3156 : : * This flow action allows skipping the congestion configuration
3157 : : * applied to the given ethdev Rx queue.
3158 : : */
3159 : : RTE_FLOW_ACTION_TYPE_SKIP_CMAN,
3160 : :
3161 : : /**
3162 : : * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH
3163 : : *
3164 : : * Push IPv6 extension into IPv6 packet.
3165 : : *
3166 : : * @see struct rte_flow_action_ipv6_ext_push.
3167 : : */
3168 : : RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH,
3169 : :
3170 : : /**
3171 : : * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE
3172 : : *
3173 : : * Remove IPv6 extension from IPv6 packet whose type
3174 : : * is provided in its configuration buffer.
3175 : : *
3176 : : * @see struct rte_flow_action_ipv6_ext_remove.
3177 : : */
3178 : : RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE,
3179 : :
3180 : : /**
3181 : : * Action handle to reference flow actions list.
3182 : : *
3183 : : * @see struct rte_flow_action_indirect_list
3184 : : */
3185 : : RTE_FLOW_ACTION_TYPE_INDIRECT_LIST,
3186 : :
3187 : : /**
3188 : : * Program action. These actions are defined by the program currently
3189 : : * loaded on the device. For example, these actions are applicable to
3190 : : * devices that can be programmed through the P4 language.
3191 : : *
3192 : : * @see struct rte_flow_action_prog.
3193 : : */
3194 : : RTE_FLOW_ACTION_TYPE_PROG,
3195 : :
3196 : : /**
3197 : : * NAT64 translation of IPv4/IPv6 headers.
3198 : : *
3199 : : * @see struct rte_flow_action_nat64
3200 : : */
3201 : : RTE_FLOW_ACTION_TYPE_NAT64,
3202 : :
3203 : : /**
3204 : : * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
3205 : : *
3206 : : * Redirects packets to a particular index in a flow table.
3207 : : *
3208 : : * @see struct rte_flow_action_jump_to_table_index.
3209 : : */
3210 : : RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX,
3211 : : };
3212 : :
3213 : : /**
3214 : : * QUOTA operational mode.
3215 : : *
3216 : : * @see struct rte_flow_action_quota
3217 : : */
3218 : : enum rte_flow_quota_mode {
3219 : : RTE_FLOW_QUOTA_MODE_PACKET = 1, /**< Count packets. */
3220 : : RTE_FLOW_QUOTA_MODE_L2 = 2, /**< Count packet bytes starting from L2. */
3221 : : RTE_FLOW_QUOTA_MODE_L3 = 3, /**< Count packet bytes starting from L3. */
3222 : : };
3223 : :
3224 : : /**
3225 : : * Create QUOTA action.
3226 : : *
3227 : : * @see RTE_FLOW_ACTION_TYPE_QUOTA
3228 : : */
3229 : : struct rte_flow_action_quota {
3230 : : enum rte_flow_quota_mode mode; /**< Quota operational mode. */
3231 : : int64_t quota; /**< Quota value. */
3232 : : };
3233 : :
3234 : : /**
3235 : : * Query indirect QUOTA action.
3236 : : *
3237 : : * @see RTE_FLOW_ACTION_TYPE_QUOTA
3238 : : */
3239 : : struct rte_flow_query_quota {
3240 : : int64_t quota; /**< Quota value. */
3241 : : };
3242 : :
3243 : : /**
3244 : : * Indirect QUOTA update operations.
3245 : : *
3246 : : * @see struct rte_flow_update_quota
3247 : : */
3248 : : enum rte_flow_update_quota_op {
3249 : : RTE_FLOW_UPDATE_QUOTA_SET, /**< Set new quota value. */
3250 : : RTE_FLOW_UPDATE_QUOTA_ADD, /**< Increase quota value. */
3251 : : };
3252 : :
3253 : : /**
3254 : : * @see RTE_FLOW_ACTION_TYPE_QUOTA
3255 : : *
3256 : : * Update indirect QUOTA action.
3257 : : */
3258 : : struct rte_flow_update_quota {
3259 : : enum rte_flow_update_quota_op op; /**< Update operation. */
3260 : : int64_t quota; /**< Quota value. */
3261 : : };
3262 : :
3263 : : /**
3264 : : * RTE_FLOW_ACTION_TYPE_MARK
3265 : : *
3266 : : * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
3267 : : * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
3268 : : *
3269 : : * This value is arbitrary and application-defined. Maximum allowed value
3270 : : * depends on the underlying implementation. It is returned in the
3271 : : * hash.fdir.hi mbuf field.
3272 : : */
3273 : : struct rte_flow_action_mark {
3274 : : uint32_t id; /**< Integer value to return with packets. */
3275 : : };
3276 : :
3277 : : /**
3278 : : * RTE_FLOW_ACTION_TYPE_JUMP
3279 : : *
3280 : : * Redirects packets to a group on the current device.
3281 : : *
3282 : : * In a hierarchy of groups, which can be used to represent physical or logical
3283 : : * flow tables on the device, this action allows the action to be a redirect to
3284 : : * a group on that device.
3285 : : */
3286 : : struct rte_flow_action_jump {
3287 : : uint32_t group;
3288 : : };
3289 : :
3290 : : /**
3291 : : * RTE_FLOW_ACTION_TYPE_QUEUE
3292 : : *
3293 : : * Assign packets to a given queue index.
3294 : : */
3295 : : struct rte_flow_action_queue {
3296 : : uint16_t index; /**< Queue index to use. */
3297 : : };
3298 : :
3299 : : /**
3300 : : * RTE_FLOW_ACTION_TYPE_AGE
3301 : : *
3302 : : * Report flow as aged-out if timeout passed without any matching
3303 : : * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
3304 : : * port detects new aged-out flows.
3305 : : *
3306 : : * The flow context and the flow handle will be reported by the either
3307 : : * rte_flow_get_aged_flows or rte_flow_get_q_aged_flows APIs.
3308 : : */
3309 : : struct rte_flow_action_age {
3310 : : uint32_t timeout:24; /**< Time in seconds. */
3311 : : uint32_t reserved:8; /**< Reserved, must be zero. */
3312 : : /** The user flow context, NULL means the rte_flow pointer. */
3313 : : void *context;
3314 : : };
3315 : :
3316 : : /**
3317 : : * RTE_FLOW_ACTION_TYPE_AGE (query)
3318 : : *
3319 : : * Query structure to retrieve the aging status information of a
3320 : : * shared AGE action, or a flow rule using the AGE action.
3321 : : */
3322 : : struct rte_flow_query_age {
3323 : : uint32_t reserved:6; /**< Reserved, must be zero. */
3324 : : uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
3325 : : /** sec_since_last_hit value is valid. */
3326 : : uint32_t sec_since_last_hit_valid:1;
3327 : : uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
3328 : : };
3329 : :
3330 : : /**
3331 : : * RTE_FLOW_ACTION_TYPE_AGE
3332 : : *
3333 : : * Update indirect AGE action attributes:
3334 : : * - Timeout can be updated including stop/start action:
3335 : : * +-------------+-------------+------------------------------+
3336 : : * | Old Timeout | New Timeout | Updating |
3337 : : * +=============+=============+==============================+
3338 : : * | 0 | positive | Start aging with new value |
3339 : : * +-------------+-------------+------------------------------+
3340 : : * | positive | 0 | Stop aging |
3341 : : * +-------------+-------------+------------------------------+
3342 : : * | positive | positive | Change timeout to new value |
3343 : : * +-------------+-------------+------------------------------+
3344 : : * - sec_since_last_hit can be reset.
3345 : : */
3346 : : struct rte_flow_update_age {
3347 : : uint32_t reserved:6; /**< Reserved, must be zero. */
3348 : : uint32_t timeout_valid:1; /**< The timeout is valid for update. */
3349 : : uint32_t timeout:24; /**< Time in seconds. */
3350 : : /** Means that aging should assume packet passed the aging. */
3351 : : uint32_t touch:1;
3352 : : };
3353 : :
3354 : : /**
3355 : : * RTE_FLOW_ACTION_TYPE_COUNT
3356 : : *
3357 : : * Adds a counter action to a matched flow.
3358 : : *
3359 : : * If more than one count action is specified in a single flow rule, then each
3360 : : * action must specify a unique ID.
3361 : : *
3362 : : * Counters can be retrieved and reset through ``rte_flow_query()``, see
3363 : : * ``struct rte_flow_query_count``.
3364 : : *
3365 : : * For ports within the same switch domain then the counter ID namespace extends
3366 : : * to all ports within that switch domain.
3367 : : */
3368 : : struct rte_flow_action_count {
3369 : : uint32_t id; /**< Counter ID. */
3370 : : };
3371 : :
3372 : : /**
3373 : : * RTE_FLOW_ACTION_TYPE_COUNT (query)
3374 : : *
3375 : : * Query structure to retrieve and reset flow rule counters.
3376 : : */
3377 : : struct rte_flow_query_count {
3378 : : uint32_t reset:1; /**< Reset counters after query [in]. */
3379 : : uint32_t hits_set:1; /**< hits field is set [out]. */
3380 : : uint32_t bytes_set:1; /**< bytes field is set [out]. */
3381 : : uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
3382 : : uint64_t hits; /**< Number of hits for this rule [out]. */
3383 : : uint64_t bytes; /**< Number of bytes through this rule [out]. */
3384 : : };
3385 : :
3386 : : /**
3387 : : * RTE_FLOW_ACTION_TYPE_RSS
3388 : : *
3389 : : * Similar to QUEUE, except RSS is additionally performed on packets to
3390 : : * spread them among several queues according to the provided parameters.
3391 : : *
3392 : : * Unlike global RSS settings used by other DPDK APIs, unsetting the
3393 : : * @p types field does not disable RSS in a flow rule. Doing so instead
3394 : : * requests safe unspecified "best-effort" settings from the underlying PMD,
3395 : : * which depending on the flow rule, may result in anything ranging from
3396 : : * empty (single queue) to all-inclusive RSS.
3397 : : *
3398 : : * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
3399 : : * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
3400 : : * both can be requested simultaneously.
3401 : : */
3402 : : struct rte_flow_action_rss {
3403 : : enum rte_eth_hash_function func; /**< RSS hash function to apply. */
3404 : : /**
3405 : : * Packet encapsulation level RSS hash @p types apply to.
3406 : : *
3407 : : * - @p 0 requests the default behavior. Depending on the packet
3408 : : * type, it can mean outermost, innermost, anything in between or
3409 : : * even no RSS.
3410 : : *
3411 : : * It basically stands for the innermost encapsulation level RSS
3412 : : * can be performed on according to PMD and device capabilities.
3413 : : *
3414 : : * - @p 1 requests RSS to be performed on the outermost packet
3415 : : * encapsulation level.
3416 : : *
3417 : : * - @p 2 and subsequent values request RSS to be performed on the
3418 : : * specified inner packet encapsulation level, from outermost to
3419 : : * innermost (lower to higher values).
3420 : : *
3421 : : * Values other than @p 0 are not necessarily supported.
3422 : : *
3423 : : * Requesting a specific RSS level on unrecognized traffic results
3424 : : * in undefined behavior. For predictable results, it is recommended
3425 : : * to make the flow rule pattern match packet headers up to the
3426 : : * requested encapsulation level so that only matching traffic goes
3427 : : * through.
3428 : : */
3429 : : uint32_t level;
3430 : : uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
3431 : : uint32_t key_len; /**< Hash key length in bytes. */
3432 : : uint32_t queue_num; /**< Number of entries in @p queue. */
3433 : : const uint8_t *key; /**< Hash key. */
3434 : : const uint16_t *queue; /**< Queue indices to use. */
3435 : : };
3436 : :
3437 : : /**
3438 : : * @deprecated
3439 : : * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3440 : : * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3441 : : *
3442 : : * RTE_FLOW_ACTION_TYPE_VF
3443 : : *
3444 : : * Directs matching traffic to a given virtual function of the current
3445 : : * device.
3446 : : *
3447 : : * Packets matched by a VF pattern item can be redirected to their original
3448 : : * VF ID instead of the specified one. This parameter may not be available
3449 : : * and is not guaranteed to work properly if the VF part is matched by a
3450 : : * prior flow rule or if packets are not addressed to a VF in the first
3451 : : * place.
3452 : : */
3453 : : struct rte_flow_action_vf {
3454 : : uint32_t original:1; /**< Use original VF ID if possible. */
3455 : : uint32_t reserved:31; /**< Reserved, must be zero. */
3456 : : uint32_t id; /**< VF ID. */
3457 : : };
3458 : :
3459 : : /**
3460 : : * @deprecated
3461 : : * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3462 : : * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3463 : : *
3464 : : * RTE_FLOW_ACTION_TYPE_PORT_ID
3465 : : *
3466 : : * Directs matching traffic to a given DPDK port ID.
3467 : : *
3468 : : * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3469 : : */
3470 : : struct rte_flow_action_port_id {
3471 : : uint32_t original:1; /**< Use original DPDK port ID if possible. */
3472 : : uint32_t reserved:31; /**< Reserved, must be zero. */
3473 : : uint32_t id; /**< DPDK port ID. */
3474 : : };
3475 : :
3476 : : /**
3477 : : * RTE_FLOW_ACTION_TYPE_METER
3478 : : *
3479 : : * Traffic metering and policing (MTR).
3480 : : *
3481 : : * Packets matched by items of this type can be either dropped or passed to the
3482 : : * next item with their color set by the MTR object.
3483 : : */
3484 : : struct rte_flow_action_meter {
3485 : : uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3486 : : };
3487 : :
3488 : : /**
3489 : : * RTE_FLOW_ACTION_TYPE_SECURITY
3490 : : *
3491 : : * Perform the security action on flows matched by the pattern items
3492 : : * according to the configuration of the security session.
3493 : : *
3494 : : * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3495 : : * security protocol headers and IV are fully provided by the application as
3496 : : * specified in the flow pattern. The payload of matching packets is
3497 : : * encrypted on egress, and decrypted and authenticated on ingress.
3498 : : * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3499 : : * providing full encapsulation and decapsulation of packets in security
3500 : : * protocols. The flow pattern specifies both the outer security header fields
3501 : : * and the inner packet fields. The security session specified in the action
3502 : : * must match the pattern parameters.
3503 : : *
3504 : : * The security session specified in the action must be created on the same
3505 : : * port as the flow action that is being specified.
3506 : : *
3507 : : * The ingress/egress flow attribute should match that specified in the
3508 : : * security session if the security session supports the definition of the
3509 : : * direction.
3510 : : *
3511 : : * Multiple flows can be configured to use the same security session.
3512 : : *
3513 : : * The NULL value is allowed for security session. If security session is NULL,
3514 : : * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3515 : : * 'IPv6' will be allowed to be a range. The rule thus created can enable
3516 : : * security processing on multiple flows.
3517 : : */
3518 : : struct rte_flow_action_security {
3519 : : void *security_session; /**< Pointer to security session structure. */
3520 : : };
3521 : :
3522 : : /**
3523 : : * NAT64 translation type for IP headers.
3524 : : */
3525 : : enum rte_flow_nat64_type {
3526 : : RTE_FLOW_NAT64_6TO4 = 0, /**< IPv6 to IPv4 headers translation. */
3527 : : RTE_FLOW_NAT64_4TO6 = 1, /**< IPv4 to IPv6 headers translation. */
3528 : : };
3529 : :
3530 : : /**
3531 : : * RTE_FLOW_ACTION_TYPE_NAT64
3532 : : *
3533 : : * Specify the NAT64 translation type.
3534 : : */
3535 : : struct rte_flow_action_nat64 {
3536 : : enum rte_flow_nat64_type type;
3537 : : };
3538 : :
3539 : : /**
3540 : : * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3541 : : *
3542 : : * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3543 : : * OpenFlow Switch Specification.
3544 : : */
3545 : : struct rte_flow_action_of_push_vlan {
3546 : : rte_be16_t ethertype; /**< EtherType. */
3547 : : };
3548 : :
3549 : : /**
3550 : : * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3551 : : *
3552 : : * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3553 : : * the OpenFlow Switch Specification.
3554 : : */
3555 : : struct rte_flow_action_of_set_vlan_vid {
3556 : : rte_be16_t vlan_vid; /**< VLAN ID. */
3557 : : };
3558 : :
3559 : : /**
3560 : : * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3561 : : *
3562 : : * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3563 : : * the OpenFlow Switch Specification.
3564 : : */
3565 : : struct rte_flow_action_of_set_vlan_pcp {
3566 : : uint8_t vlan_pcp; /**< VLAN priority. */
3567 : : };
3568 : :
3569 : : /**
3570 : : * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3571 : : *
3572 : : * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3573 : : * OpenFlow Switch Specification.
3574 : : */
3575 : : struct rte_flow_action_of_pop_mpls {
3576 : : rte_be16_t ethertype; /**< EtherType. */
3577 : : };
3578 : :
3579 : : /**
3580 : : * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3581 : : *
3582 : : * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3583 : : * OpenFlow Switch Specification.
3584 : : */
3585 : : struct rte_flow_action_of_push_mpls {
3586 : : rte_be16_t ethertype; /**< EtherType. */
3587 : : };
3588 : :
3589 : : /**
3590 : : * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3591 : : *
3592 : : * VXLAN tunnel end-point encapsulation data definition
3593 : : *
3594 : : * The tunnel definition is provided through the flow item pattern, the
3595 : : * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3596 : : * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3597 : : * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3598 : : *
3599 : : * The mask field allows user to specify which fields in the flow item
3600 : : * definitions can be ignored and which have valid data and can be used
3601 : : * verbatim.
3602 : : *
3603 : : * Note: the last field is not used in the definition of a tunnel and can be
3604 : : * ignored.
3605 : : *
3606 : : * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3607 : : *
3608 : : * - ETH / IPV4 / UDP / VXLAN / END
3609 : : * - ETH / IPV6 / UDP / VXLAN / END
3610 : : * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3611 : : */
3612 : : struct rte_flow_action_vxlan_encap {
3613 : : /**
3614 : : * Encapsulating vxlan tunnel definition
3615 : : * (terminated by the END pattern item).
3616 : : */
3617 : : struct rte_flow_item *definition;
3618 : : };
3619 : :
3620 : : /**
3621 : : * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3622 : : *
3623 : : * NVGRE tunnel end-point encapsulation data definition
3624 : : *
3625 : : * The tunnel definition is provided through the flow item pattern the
3626 : : * provided pattern must conform with RFC7637. The flow definition must be
3627 : : * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3628 : : * which is specified by RTE_FLOW_ITEM_TYPE_END.
3629 : : *
3630 : : * The mask field allows user to specify which fields in the flow item
3631 : : * definitions can be ignored and which have valid data and can be used
3632 : : * verbatim.
3633 : : *
3634 : : * Note: the last field is not used in the definition of a tunnel and can be
3635 : : * ignored.
3636 : : *
3637 : : * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3638 : : *
3639 : : * - ETH / IPV4 / NVGRE / END
3640 : : * - ETH / VLAN / IPV6 / NVGRE / END
3641 : : */
3642 : : struct rte_flow_action_nvgre_encap {
3643 : : /**
3644 : : * Encapsulating nvgre tunnel definition
3645 : : * (terminated by the END pattern item).
3646 : : */
3647 : : struct rte_flow_item *definition;
3648 : : };
3649 : :
3650 : : /**
3651 : : * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3652 : : *
3653 : : * Raw tunnel end-point encapsulation data definition.
3654 : : *
3655 : : * The data holds the headers definitions to be applied on the packet.
3656 : : * The data must start with ETH header up to the tunnel item header itself.
3657 : : * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3658 : : * example MPLSoGRE) the data will just hold layer 2 header.
3659 : : *
3660 : : * The preserve parameter holds which bits in the packet the PMD is not allowed
3661 : : * to change, this parameter can also be NULL and then the PMD is allowed
3662 : : * to update any field.
3663 : : *
3664 : : * size holds the number of bytes in @p data and @p preserve.
3665 : : */
3666 : : struct rte_flow_action_raw_encap {
3667 : : uint8_t *data; /**< Encapsulation data. */
3668 : : uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3669 : : size_t size; /**< Size of @p data and @p preserve. */
3670 : : };
3671 : :
3672 : : /**
3673 : : * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3674 : : *
3675 : : * Raw tunnel end-point decapsulation data definition.
3676 : : *
3677 : : * The data holds the headers definitions to be removed from the packet.
3678 : : * The data must start with ETH header up to the tunnel item header itself.
3679 : : * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3680 : : * example MPLSoGRE) the data will just hold layer 2 header.
3681 : : *
3682 : : * size holds the number of bytes in @p data.
3683 : : */
3684 : : struct rte_flow_action_raw_decap {
3685 : : uint8_t *data; /**< Encapsulation data. */
3686 : : size_t size; /**< Size of @p data and @p preserve. */
3687 : : };
3688 : :
3689 : : /**
3690 : : * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3691 : : * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3692 : : *
3693 : : * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3694 : : * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3695 : : * specified outermost IPv4 header.
3696 : : */
3697 : : struct rte_flow_action_set_ipv4 {
3698 : : rte_be32_t ipv4_addr;
3699 : : };
3700 : :
3701 : : /**
3702 : : * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3703 : : * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3704 : : *
3705 : : * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3706 : : * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3707 : : * specified outermost IPv6 header.
3708 : : */
3709 : : struct rte_flow_action_set_ipv6 {
3710 : : struct rte_ipv6_addr ipv6_addr;
3711 : : };
3712 : :
3713 : : /**
3714 : : * RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH
3715 : : *
3716 : : * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH include:
3717 : : *
3718 : : * - IPV6_EXT TYPE / IPV6_EXT_HEADER_IN_TYPE / END
3719 : : *
3720 : : * The data must be added as the last IPv6 extension.
3721 : : */
3722 : : struct rte_flow_action_ipv6_ext_push {
3723 : : uint8_t *data; /**< IPv6 extension header data. */
3724 : : size_t size; /**< Size (in bytes) of @p data. */
3725 : : uint8_t type; /**< Type of IPv6 extension. */
3726 : : };
3727 : :
3728 : : /**
3729 : : * RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE
3730 : : *
3731 : : * Valid flow definition for RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE include:
3732 : : *
3733 : : * - IPV6_EXT TYPE / END
3734 : : */
3735 : : struct rte_flow_action_ipv6_ext_remove {
3736 : : uint8_t type; /**< Type of IPv6 extension. */
3737 : : };
3738 : :
3739 : : /**
3740 : : * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3741 : : * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3742 : : *
3743 : : * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3744 : : * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3745 : : * in the specified outermost TCP/UDP header.
3746 : : */
3747 : : struct rte_flow_action_set_tp {
3748 : : rte_be16_t port;
3749 : : };
3750 : :
3751 : : /**
3752 : : * RTE_FLOW_ACTION_TYPE_SET_TTL
3753 : : *
3754 : : * Set the TTL value directly for IPv4 or IPv6
3755 : : */
3756 : : struct rte_flow_action_set_ttl {
3757 : : uint8_t ttl_value;
3758 : : };
3759 : :
3760 : : /**
3761 : : * RTE_FLOW_ACTION_TYPE_SET_MAC
3762 : : *
3763 : : * Set MAC address from the matched flow
3764 : : */
3765 : : struct rte_flow_action_set_mac {
3766 : : uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3767 : : };
3768 : :
3769 : : /**
3770 : : * RTE_FLOW_ACTION_TYPE_SET_TAG
3771 : : *
3772 : : * Set a tag which is a transient data used during flow matching. This is not
3773 : : * delivered to application. Multiple tags are supported by specifying index.
3774 : : */
3775 : : struct rte_flow_action_set_tag {
3776 : : uint32_t data;
3777 : : uint32_t mask;
3778 : : uint8_t index;
3779 : : };
3780 : :
3781 : : /**
3782 : : * RTE_FLOW_ACTION_TYPE_SET_META
3783 : : *
3784 : : * Set metadata. Metadata set by mbuf metadata dynamic field with
3785 : : * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3786 : : * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3787 : : * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set. The dynamic mbuf field
3788 : : * must be registered in advance by rte_flow_dynf_metadata_register().
3789 : : *
3790 : : * Altering partial bits is supported with mask. For bits which have never
3791 : : * been set, unpredictable value will be seen depending on driver
3792 : : * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3793 : : * or may not be propagated to the other path depending on HW capability.
3794 : : *
3795 : : * RTE_FLOW_ITEM_TYPE_META matches metadata.
3796 : : */
3797 : : struct rte_flow_action_set_meta {
3798 : : uint32_t data;
3799 : : uint32_t mask;
3800 : : };
3801 : :
3802 : : /**
3803 : : * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3804 : : * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3805 : : *
3806 : : * Set the DSCP value for IPv4/IPv6 header.
3807 : : * DSCP in low 6 bits, rest ignored.
3808 : : */
3809 : : struct rte_flow_action_set_dscp {
3810 : : uint8_t dscp;
3811 : : };
3812 : :
3813 : : /**
3814 : : * RTE_FLOW_ACTION_TYPE_INDIRECT
3815 : : *
3816 : : * Opaque type returned after successfully creating an indirect action object.
3817 : : * The definition of the object handle is different per driver or
3818 : : * per direct action type.
3819 : : *
3820 : : * This handle can be used to manage and query the related direct action:
3821 : : * - referenced in single flow rule or across multiple flow rules
3822 : : * over multiple ports
3823 : : * - update action object configuration
3824 : : * - query action object data
3825 : : * - destroy action object
3826 : : */
3827 : : struct rte_flow_action_handle;
3828 : :
3829 : : /**
3830 : : * The state of a TCP connection.
3831 : : */
3832 : : enum rte_flow_conntrack_state {
3833 : : /** SYN-ACK packet was seen. */
3834 : : RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3835 : : /** 3-way handshake was done. */
3836 : : RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3837 : : /** First FIN packet was received to close the connection. */
3838 : : RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3839 : : /** First FIN was ACKed. */
3840 : : RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3841 : : /** Second FIN was received, waiting for the last ACK. */
3842 : : RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3843 : : /** Second FIN was ACKed, connection was closed. */
3844 : : RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3845 : : };
3846 : :
3847 : : /**
3848 : : * The last passed TCP packet flags of a connection.
3849 : : */
3850 : : enum rte_flow_conntrack_tcp_last_index {
3851 : : RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3852 : : RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3853 : : RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3854 : : RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3855 : : RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3856 : : RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3857 : : };
3858 : :
3859 : : /**
3860 : : * Configuration parameters for each direction of a TCP connection.
3861 : : * All fields should be in host byte order.
3862 : : * If needed, driver should convert all fields to network byte order
3863 : : * if HW needs them in that way.
3864 : : */
3865 : : struct rte_flow_tcp_dir_param {
3866 : : /** TCP window scaling factor, 0xF to disable. */
3867 : : uint32_t scale:4;
3868 : : /** The FIN was sent by this direction. */
3869 : : uint32_t close_initiated:1;
3870 : : /** An ACK packet has been received by this side. */
3871 : : uint32_t last_ack_seen:1;
3872 : : /**
3873 : : * If set, it indicates that there is unacknowledged data for the
3874 : : * packets sent from this direction.
3875 : : */
3876 : : uint32_t data_unacked:1;
3877 : : /**
3878 : : * Maximal value of sequence + payload length in sent
3879 : : * packets (next ACK from the opposite direction).
3880 : : */
3881 : : uint32_t sent_end;
3882 : : /**
3883 : : * Maximal value of (ACK + window size) in received packet + length
3884 : : * over sent packet (maximal sequence could be sent).
3885 : : */
3886 : : uint32_t reply_end;
3887 : : /** Maximal value of actual window size in sent packets. */
3888 : : uint32_t max_win;
3889 : : /** Maximal value of ACK in sent packets. */
3890 : : uint32_t max_ack;
3891 : : };
3892 : :
3893 : : /**
3894 : : * RTE_FLOW_ACTION_TYPE_CONNTRACK
3895 : : *
3896 : : * Configuration and initial state for the connection tracking module.
3897 : : * This structure could be used for both setting and query.
3898 : : * All fields should be in host byte order.
3899 : : */
3900 : : struct rte_flow_action_conntrack {
3901 : : /** The peer port number, can be the same port. */
3902 : : uint16_t peer_port;
3903 : : /**
3904 : : * Direction of this connection when creating a flow rule, the
3905 : : * value only affects the creation of subsequent flow rules.
3906 : : */
3907 : : uint32_t is_original_dir:1;
3908 : : /**
3909 : : * Enable / disable the conntrack HW module. When disabled, the
3910 : : * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3911 : : * In this state the HW will act as passthrough.
3912 : : * It only affects this conntrack object in the HW without any effect
3913 : : * to the other objects.
3914 : : */
3915 : : uint32_t enable:1;
3916 : : /** At least one ack was seen after the connection was established. */
3917 : : uint32_t live_connection:1;
3918 : : /** Enable selective ACK on this connection. */
3919 : : uint32_t selective_ack:1;
3920 : : /** A challenge ack has passed. */
3921 : : uint32_t challenge_ack_passed:1;
3922 : : /**
3923 : : * 1: The last packet is seen from the original direction.
3924 : : * 0: The last packet is seen from the reply direction.
3925 : : */
3926 : : uint32_t last_direction:1;
3927 : : /** No TCP check will be done except the state change. */
3928 : : uint32_t liberal_mode:1;
3929 : : /** The current state of this connection. */
3930 : : enum rte_flow_conntrack_state state;
3931 : : /** Scaling factor for maximal allowed ACK window. */
3932 : : uint8_t max_ack_window;
3933 : : /** Maximal allowed number of retransmission times. */
3934 : : uint8_t retransmission_limit;
3935 : : /** TCP parameters of the original direction. */
3936 : : struct rte_flow_tcp_dir_param original_dir;
3937 : : /** TCP parameters of the reply direction. */
3938 : : struct rte_flow_tcp_dir_param reply_dir;
3939 : : /** The window value of the last packet passed this conntrack. */
3940 : : uint16_t last_window;
3941 : : enum rte_flow_conntrack_tcp_last_index last_index;
3942 : : /** The sequence of the last packet passed this conntrack. */
3943 : : uint32_t last_seq;
3944 : : /** The acknowledgment of the last packet passed this conntrack. */
3945 : : uint32_t last_ack;
3946 : : /**
3947 : : * The total value ACK + payload length of the last packet
3948 : : * passed this conntrack.
3949 : : */
3950 : : uint32_t last_end;
3951 : : };
3952 : :
3953 : : /**
3954 : : * RTE_FLOW_ACTION_TYPE_CONNTRACK
3955 : : *
3956 : : * Wrapper structure for the context update interface.
3957 : : * Ports cannot support updating, and the only valid solution is to
3958 : : * destroy the old context and create a new one instead.
3959 : : */
3960 : : struct rte_flow_modify_conntrack {
3961 : : /** New connection tracking parameters to be updated. */
3962 : : struct rte_flow_action_conntrack new_ct;
3963 : : /** The direction field will be updated. */
3964 : : uint32_t direction:1;
3965 : : /** All the other fields except direction will be updated. */
3966 : : uint32_t state:1;
3967 : : /** Reserved bits for the future usage. */
3968 : : uint32_t reserved:30;
3969 : : };
3970 : :
3971 : : /**
3972 : : * RTE_FLOW_ACTION_TYPE_METER_COLOR
3973 : : *
3974 : : * The meter color should be set in the packet meta-data
3975 : : * (i.e. struct rte_mbuf::sched::color).
3976 : : */
3977 : : struct rte_flow_action_meter_color {
3978 : : enum rte_color color; /**< Packet color. */
3979 : : };
3980 : :
3981 : : /**
3982 : : * Provides an ethdev port ID for use with the following actions:
3983 : : * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3984 : : * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3985 : : */
3986 : : struct rte_flow_action_ethdev {
3987 : : uint16_t port_id; /**< ethdev port ID */
3988 : : };
3989 : :
3990 : : /**
3991 : : * Operation types for MODIFY_FIELD action.
3992 : : */
3993 : : enum rte_flow_modify_op {
3994 : : RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3995 : : RTE_FLOW_MODIFY_ADD, /**< Add a value to a field. */
3996 : : RTE_FLOW_MODIFY_SUB, /**< Subtract a value from a field. */
3997 : : };
3998 : :
3999 : : /**
4000 : : * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
4001 : : *
4002 : : * Modify a destination header field according to the specified
4003 : : * operation. Another field of the packet can be used as a source as well
4004 : : * as tag, mark, metadata, immediate value or a pointer to it.
4005 : : */
4006 : : struct rte_flow_action_modify_field {
4007 : : enum rte_flow_modify_op operation; /**< Operation to perform. */
4008 : : struct rte_flow_field_data dst; /**< Destination field. */
4009 : : struct rte_flow_field_data src; /**< Source field. */
4010 : : uint32_t width; /**< Number of bits to use from a source field. */
4011 : : };
4012 : :
4013 : : /**
4014 : : * RTE_FLOW_ACTION_TYPE_METER_MARK
4015 : : *
4016 : : * Traffic metering and marking (MTR).
4017 : : *
4018 : : * Meters a packet stream and marks its packets either
4019 : : * green, yellow, or red according to the specified profile.
4020 : : * The policy is optional and may be specified for defining
4021 : : * subsequent actions based on a color assigned by MTR.
4022 : : * Alternatively, the METER_COLOR item may be used for this.
4023 : : */
4024 : : struct rte_flow_action_meter_mark {
4025 : :
4026 : : /**< Profile config retrieved with rte_mtr_profile_get(). */
4027 : : struct rte_flow_meter_profile *profile;
4028 : : /**< Policy config retrieved with rte_mtr_policy_get(). */
4029 : : struct rte_flow_meter_policy *policy;
4030 : : /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */
4031 : : int color_mode;
4032 : : /** Metering state: 0 - Disabled, 1 - Enabled. */
4033 : : int state;
4034 : : };
4035 : :
4036 : : /**
4037 : : * RTE_FLOW_ACTION_TYPE_METER_MARK
4038 : : *
4039 : : * Wrapper structure for the context update interface.
4040 : : */
4041 : : struct rte_flow_update_meter_mark {
4042 : : /** New meter_mark parameters to be updated. */
4043 : : struct rte_flow_action_meter_mark meter_mark;
4044 : : /** The profile will be updated. */
4045 : : uint32_t profile_valid:1;
4046 : : /** The policy will be updated. */
4047 : : uint32_t policy_valid:1;
4048 : : /** The color mode will be updated. */
4049 : : uint32_t color_mode_valid:1;
4050 : : /** The meter state will be updated. */
4051 : : uint32_t state_valid:1;
4052 : : /** Reserved bits for the future usage. */
4053 : : uint32_t reserved:28;
4054 : : };
4055 : :
4056 : : /**
4057 : : * @see RTE_FLOW_ACTION_TYPE_METER_MARK
4058 : : * @see RTE_FLOW_ACTION_TYPE_INDIRECT_LIST
4059 : : *
4060 : : * Update flow mutable context.
4061 : : */
4062 : : struct rte_flow_indirect_update_flow_meter_mark {
4063 : : /** Updated init color applied to packet */
4064 : : enum rte_color init_color;
4065 : : };
4066 : :
4067 : : /**
4068 : : * Program action argument configuration parameters.
4069 : : *
4070 : : * For each action argument, its *size* must be non-zero and its *value* must
4071 : : * point to a valid array of *size* bytes specified in network byte order.
4072 : : *
4073 : : * @see struct rte_flow_action_prog
4074 : : */
4075 : : struct rte_flow_action_prog_argument {
4076 : : /** Argument name. */
4077 : : const char *name;
4078 : : /** Argument size in bytes. */
4079 : : uint32_t size;
4080 : : /** Argument value. */
4081 : : const uint8_t *value;
4082 : : };
4083 : :
4084 : : /**
4085 : : * RTE_FLOW_ACTION_TYPE_PROG
4086 : : *
4087 : : * Program action configuration parameters.
4088 : : *
4089 : : * Each action can have zero or more arguments. When *args_num* is non-zero, the
4090 : : * *args* parameter must point to a valid array of *args_num* elements.
4091 : : *
4092 : : * @see RTE_FLOW_ACTION_TYPE_PROG
4093 : : */
4094 : : struct rte_flow_action_prog {
4095 : : /** Action name. */
4096 : : const char *name;
4097 : : /** Number of action arguments. */
4098 : : uint32_t args_num;
4099 : : /** Action arguments array. */
4100 : : const struct rte_flow_action_prog_argument *args;
4101 : : };
4102 : :
4103 : : /* Mbuf dynamic field offset for metadata. */
4104 : : extern int32_t rte_flow_dynf_metadata_offs;
4105 : :
4106 : : /* Mbuf dynamic field flag mask for metadata. */
4107 : : extern uint64_t rte_flow_dynf_metadata_mask;
4108 : :
4109 : : /* Mbuf dynamic field pointer for metadata. */
4110 : : #define RTE_FLOW_DYNF_METADATA(m) \
4111 : : RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
4112 : :
4113 : : /* Mbuf dynamic flags for metadata. */
4114 : : #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
4115 : : #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
4116 : :
4117 : : static inline uint32_t
4118 : : rte_flow_dynf_metadata_get(struct rte_mbuf *m)
4119 : : {
4120 : : return *RTE_FLOW_DYNF_METADATA(m);
4121 : : }
4122 : :
4123 : : static inline void
4124 : : rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
4125 : : {
4126 : : *RTE_FLOW_DYNF_METADATA(m) = v;
4127 : : }
4128 : :
4129 : : /**
4130 : : * RTE_FLOW_ACTION_TYPE_JUMP_TO_TABLE_INDEX
4131 : : *
4132 : : * Redirects packets to a particular index in a flow table.
4133 : : */
4134 : : struct rte_flow_action_jump_to_table_index {
4135 : : struct rte_flow_template_table *table;
4136 : : uint32_t index;
4137 : : };
4138 : :
4139 : : /**
4140 : : * Definition of a single action.
4141 : : *
4142 : : * A list of actions is terminated by a END action.
4143 : : *
4144 : : * For simple actions without a configuration object, conf remains NULL.
4145 : : */
4146 : : struct rte_flow_action {
4147 : : enum rte_flow_action_type type; /**< Action type. */
4148 : : const void *conf; /**< Pointer to action configuration object. */
4149 : : };
4150 : :
4151 : : /**
4152 : : * Opaque type returned after successfully creating a flow.
4153 : : *
4154 : : * This handle can be used to manage and query the related flow (e.g. to
4155 : : * destroy it or retrieve counters).
4156 : : */
4157 : : struct rte_flow;
4158 : :
4159 : : /**
4160 : : * Opaque type for Meter profile object returned by MTR API.
4161 : : *
4162 : : * This handle can be used to create Meter actions instead of profile ID.
4163 : : */
4164 : : struct rte_flow_meter_profile;
4165 : :
4166 : : /**
4167 : : * Opaque type for Meter policy object returned by MTR API.
4168 : : *
4169 : : * This handle can be used to create Meter actions instead of policy ID.
4170 : : */
4171 : : struct rte_flow_meter_policy;
4172 : :
4173 : : /**
4174 : : * RTE_FLOW_ACTION_TYPE_SAMPLE
4175 : : *
4176 : : * Adds a sample action to a matched flow.
4177 : : *
4178 : : * The matching packets will be duplicated with specified ratio and applied
4179 : : * with own set of actions with a fate action, the sampled packet could be
4180 : : * redirected to queue or port. All the packets continue processing on the
4181 : : * default flow path.
4182 : : *
4183 : : * When the sample ratio is set to 1 then the packets will be 100% mirrored.
4184 : : * Additional action list be supported to add for sampled or mirrored packets.
4185 : : */
4186 : : struct rte_flow_action_sample {
4187 : : uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
4188 : : /** sub-action list specific for the sampling hit cases. */
4189 : : const struct rte_flow_action *actions;
4190 : : };
4191 : :
4192 : : /**
4193 : : * Verbose error types.
4194 : : *
4195 : : * Most of them provide the type of the object referenced by struct
4196 : : * rte_flow_error.cause.
4197 : : */
4198 : : enum rte_flow_error_type {
4199 : : RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
4200 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
4201 : : RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
4202 : : RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
4203 : : RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
4204 : : RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
4205 : : RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
4206 : : RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
4207 : : RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
4208 : : RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
4209 : : RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
4210 : : RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
4211 : : RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
4212 : : RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
4213 : : RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
4214 : : RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
4215 : : RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
4216 : : RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
4217 : : };
4218 : :
4219 : : /**
4220 : : * Verbose error structure definition.
4221 : : *
4222 : : * This object is normally allocated by applications and set by PMDs, the
4223 : : * message points to a constant string which does not need to be freed by
4224 : : * the application, however its pointer can be considered valid only as long
4225 : : * as its associated DPDK port remains configured. Closing the underlying
4226 : : * device or unloading the PMD invalidates it.
4227 : : *
4228 : : * Both cause and message may be NULL regardless of the error type.
4229 : : */
4230 : : struct rte_flow_error {
4231 : : enum rte_flow_error_type type; /**< Cause field and error types. */
4232 : : const void *cause; /**< Object responsible for the error. */
4233 : : const char *message; /**< Human-readable error message. */
4234 : : };
4235 : :
4236 : : /**
4237 : : * Complete flow rule description.
4238 : : *
4239 : : * This object type is used when converting a flow rule description.
4240 : : *
4241 : : * @see RTE_FLOW_CONV_OP_RULE
4242 : : * @see rte_flow_conv()
4243 : : */
4244 : : struct rte_flow_conv_rule {
4245 : : union {
4246 : : const struct rte_flow_attr *attr_ro; /**< RO attributes. */
4247 : : struct rte_flow_attr *attr; /**< Attributes. */
4248 : : };
4249 : : union {
4250 : : const struct rte_flow_item *pattern_ro; /**< RO pattern. */
4251 : : struct rte_flow_item *pattern; /**< Pattern items. */
4252 : : };
4253 : : union {
4254 : : const struct rte_flow_action *actions_ro; /**< RO actions. */
4255 : : struct rte_flow_action *actions; /**< List of actions. */
4256 : : };
4257 : : };
4258 : :
4259 : : /**
4260 : : * Conversion operations for flow API objects.
4261 : : *
4262 : : * @see rte_flow_conv()
4263 : : */
4264 : : enum rte_flow_conv_op {
4265 : : /**
4266 : : * No operation to perform.
4267 : : *
4268 : : * rte_flow_conv() simply returns 0.
4269 : : */
4270 : : RTE_FLOW_CONV_OP_NONE,
4271 : :
4272 : : /**
4273 : : * Convert attributes structure.
4274 : : *
4275 : : * This is a basic copy of an attributes structure.
4276 : : *
4277 : : * - @p src type:
4278 : : * @code const struct rte_flow_attr * @endcode
4279 : : * - @p dst type:
4280 : : * @code struct rte_flow_attr * @endcode
4281 : : */
4282 : : RTE_FLOW_CONV_OP_ATTR,
4283 : :
4284 : : /**
4285 : : * Convert a single item.
4286 : : *
4287 : : * Duplicates @p spec, @p last and @p mask but not outside objects.
4288 : : *
4289 : : * - @p src type:
4290 : : * @code const struct rte_flow_item * @endcode
4291 : : * - @p dst type:
4292 : : * @code struct rte_flow_item * @endcode
4293 : : */
4294 : : RTE_FLOW_CONV_OP_ITEM,
4295 : :
4296 : : /**
4297 : : * Convert a single item mask.
4298 : : *
4299 : : * Duplicates only @p mask.
4300 : : *
4301 : : * - @p src type:
4302 : : * @code const struct rte_flow_item * @endcode
4303 : : * - @p dst type:
4304 : : * @code struct rte_flow_item * @endcode
4305 : : */
4306 : : RTE_FLOW_CONV_OP_ITEM_MASK,
4307 : :
4308 : : /**
4309 : : * Convert a single action.
4310 : : *
4311 : : * Duplicates @p conf but not outside objects.
4312 : : *
4313 : : * - @p src type:
4314 : : * @code const struct rte_flow_action * @endcode
4315 : : * - @p dst type:
4316 : : * @code struct rte_flow_action * @endcode
4317 : : */
4318 : : RTE_FLOW_CONV_OP_ACTION,
4319 : :
4320 : : /**
4321 : : * Convert an entire pattern.
4322 : : *
4323 : : * Duplicates all pattern items at once with the same constraints as
4324 : : * RTE_FLOW_CONV_OP_ITEM.
4325 : : *
4326 : : * - @p src type:
4327 : : * @code const struct rte_flow_item * @endcode
4328 : : * - @p dst type:
4329 : : * @code struct rte_flow_item * @endcode
4330 : : */
4331 : : RTE_FLOW_CONV_OP_PATTERN,
4332 : :
4333 : : /**
4334 : : * Convert a list of actions.
4335 : : *
4336 : : * Duplicates the entire list of actions at once with the same
4337 : : * constraints as RTE_FLOW_CONV_OP_ACTION.
4338 : : *
4339 : : * - @p src type:
4340 : : * @code const struct rte_flow_action * @endcode
4341 : : * - @p dst type:
4342 : : * @code struct rte_flow_action * @endcode
4343 : : */
4344 : : RTE_FLOW_CONV_OP_ACTIONS,
4345 : :
4346 : : /**
4347 : : * Convert a complete flow rule description.
4348 : : *
4349 : : * Comprises attributes, pattern and actions together at once with
4350 : : * the usual constraints.
4351 : : *
4352 : : * - @p src type:
4353 : : * @code const struct rte_flow_conv_rule * @endcode
4354 : : * - @p dst type:
4355 : : * @code struct rte_flow_conv_rule * @endcode
4356 : : */
4357 : : RTE_FLOW_CONV_OP_RULE,
4358 : :
4359 : : /**
4360 : : * Convert item type to its name string.
4361 : : *
4362 : : * Writes a NUL-terminated string to @p dst. Like snprintf(), the
4363 : : * returned value excludes the terminator which is always written
4364 : : * nonetheless.
4365 : : *
4366 : : * - @p src type:
4367 : : * @code (const void *)enum rte_flow_item_type @endcode
4368 : : * - @p dst type:
4369 : : * @code char * @endcode
4370 : : */
4371 : : RTE_FLOW_CONV_OP_ITEM_NAME,
4372 : :
4373 : : /**
4374 : : * Convert action type to its name string.
4375 : : *
4376 : : * Writes a NUL-terminated string to @p dst. Like snprintf(), the
4377 : : * returned value excludes the terminator which is always written
4378 : : * nonetheless.
4379 : : *
4380 : : * - @p src type:
4381 : : * @code (const void *)enum rte_flow_action_type @endcode
4382 : : * - @p dst type:
4383 : : * @code char * @endcode
4384 : : */
4385 : : RTE_FLOW_CONV_OP_ACTION_NAME,
4386 : :
4387 : : /**
4388 : : * Convert item type to pointer to item name.
4389 : : *
4390 : : * Retrieves item name pointer from its type. The string itself is
4391 : : * not copied; instead, a unique pointer to an internal static
4392 : : * constant storage is written to @p dst.
4393 : : *
4394 : : * - @p src type:
4395 : : * @code (const void *)enum rte_flow_item_type @endcode
4396 : : * - @p dst type:
4397 : : * @code const char ** @endcode
4398 : : */
4399 : : RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
4400 : :
4401 : : /**
4402 : : * Convert action type to pointer to action name.
4403 : : *
4404 : : * Retrieves action name pointer from its type. The string itself is
4405 : : * not copied; instead, a unique pointer to an internal static
4406 : : * constant storage is written to @p dst.
4407 : : *
4408 : : * - @p src type:
4409 : : * @code (const void *)enum rte_flow_action_type @endcode
4410 : : * - @p dst type:
4411 : : * @code const char ** @endcode
4412 : : */
4413 : : RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
4414 : : };
4415 : :
4416 : : /**
4417 : : * Dump hardware internal representation information of
4418 : : * rte flow to file.
4419 : : *
4420 : : * @param[in] port_id
4421 : : * The port identifier of the Ethernet device.
4422 : : * @param[in] flow
4423 : : * The pointer of flow rule to dump. Dump all rules if NULL.
4424 : : * @param[in] file
4425 : : * A pointer to a file for output.
4426 : : * @param[out] error
4427 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4428 : : * structure in case of error only.
4429 : : * @return
4430 : : * 0 on success, a negative value otherwise.
4431 : : */
4432 : : int
4433 : : rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
4434 : : FILE *file, struct rte_flow_error *error);
4435 : :
4436 : : /**
4437 : : * Check if mbuf dynamic field for metadata is registered.
4438 : : *
4439 : : * @return
4440 : : * True if registered, false otherwise.
4441 : : */
4442 : : static inline int
4443 : : rte_flow_dynf_metadata_avail(void)
4444 : : {
4445 [ # # ]: 0 : return !!rte_flow_dynf_metadata_mask;
4446 : : }
4447 : :
4448 : : /**
4449 : : * Register mbuf dynamic field and flag for metadata.
4450 : : *
4451 : : * This function must be called prior to use SET_META action in order to
4452 : : * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
4453 : : * application.
4454 : : *
4455 : : * @return
4456 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4457 : : */
4458 : : int
4459 : : rte_flow_dynf_metadata_register(void);
4460 : :
4461 : : /**
4462 : : * Check whether a flow rule can be created on a given port.
4463 : : *
4464 : : * The flow rule is validated for correctness and whether it could be accepted
4465 : : * by the device given sufficient resources. The rule is checked against the
4466 : : * current device mode and queue configuration. The flow rule may also
4467 : : * optionally be validated against existing flow rules and device resources.
4468 : : * This function has no effect on the target device.
4469 : : *
4470 : : * The returned value is guaranteed to remain valid only as long as no
4471 : : * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4472 : : * the meantime and no device parameter affecting flow rules in any way are
4473 : : * modified, due to possible collisions or resource limitations (although in
4474 : : * such cases EINVAL should not be returned).
4475 : : *
4476 : : * @param port_id
4477 : : * Port identifier of Ethernet device.
4478 : : * @param[in] attr
4479 : : * Flow rule attributes.
4480 : : * @param[in] pattern
4481 : : * Pattern specification (list terminated by the END pattern item).
4482 : : * @param[in] actions
4483 : : * Associated actions (list terminated by the END action).
4484 : : * @param[out] error
4485 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4486 : : * structure in case of error only.
4487 : : *
4488 : : * @return
4489 : : * 0 if flow rule is valid and can be created. A negative errno value
4490 : : * otherwise (rte_errno is also set), the following errors are defined:
4491 : : *
4492 : : * -ENOSYS: underlying device does not support this functionality.
4493 : : *
4494 : : * -EIO: underlying device is removed.
4495 : : *
4496 : : * -EINVAL: unknown or invalid rule specification.
4497 : : *
4498 : : * -ENOTSUP: valid but unsupported rule specification (e.g. partial
4499 : : * bit-masks are unsupported).
4500 : : *
4501 : : * -EEXIST: collision with an existing rule. Only returned if device
4502 : : * supports flow rule collision checking and there was a flow rule
4503 : : * collision. Not receiving this return code is no guarantee that creating
4504 : : * the rule will not fail due to a collision.
4505 : : *
4506 : : * -ENOMEM: not enough memory to execute the function, or if the device
4507 : : * supports resource validation, resource limitation on the device.
4508 : : *
4509 : : * -EBUSY: action cannot be performed due to busy device resources, may
4510 : : * succeed if the affected queues or even the entire port are in a stopped
4511 : : * state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4512 : : */
4513 : : int
4514 : : rte_flow_validate(uint16_t port_id,
4515 : : const struct rte_flow_attr *attr,
4516 : : const struct rte_flow_item pattern[],
4517 : : const struct rte_flow_action actions[],
4518 : : struct rte_flow_error *error);
4519 : :
4520 : : /**
4521 : : * Create a flow rule on a given port.
4522 : : *
4523 : : * @param port_id
4524 : : * Port identifier of Ethernet device.
4525 : : * @param[in] attr
4526 : : * Flow rule attributes.
4527 : : * @param[in] pattern
4528 : : * Pattern specification (list terminated by the END pattern item).
4529 : : * @param[in] actions
4530 : : * Associated actions (list terminated by the END action).
4531 : : * @param[out] error
4532 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4533 : : * structure in case of error only.
4534 : : *
4535 : : * @return
4536 : : * A valid handle in case of success, NULL otherwise and rte_errno is set
4537 : : * to the positive version of one of the error codes defined for
4538 : : * rte_flow_validate().
4539 : : */
4540 : : struct rte_flow *
4541 : : rte_flow_create(uint16_t port_id,
4542 : : const struct rte_flow_attr *attr,
4543 : : const struct rte_flow_item pattern[],
4544 : : const struct rte_flow_action actions[],
4545 : : struct rte_flow_error *error);
4546 : :
4547 : : /**
4548 : : * Destroy a flow rule on a given port.
4549 : : *
4550 : : * Failure to destroy a flow rule handle may occur when other flow rules
4551 : : * depend on it, and destroying it would result in an inconsistent state.
4552 : : *
4553 : : * This function is only guaranteed to succeed if handles are destroyed in
4554 : : * reverse order of their creation.
4555 : : *
4556 : : * @param port_id
4557 : : * Port identifier of Ethernet device.
4558 : : * @param flow
4559 : : * Flow rule handle to destroy.
4560 : : * @param[out] error
4561 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4562 : : * structure in case of error only.
4563 : : *
4564 : : * @return
4565 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4566 : : */
4567 : : int
4568 : : rte_flow_destroy(uint16_t port_id,
4569 : : struct rte_flow *flow,
4570 : : struct rte_flow_error *error);
4571 : :
4572 : : /**
4573 : : * Update a flow rule with new actions on a given port.
4574 : : *
4575 : : * @param port_id
4576 : : * Port identifier of Ethernet device.
4577 : : * @param flow
4578 : : * Flow rule handle to update.
4579 : : * @param[in] actions
4580 : : * Associated actions (list terminated by the END action).
4581 : : * @param[out] error
4582 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4583 : : * structure in case of error only.
4584 : : *
4585 : : * @return
4586 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4587 : : */
4588 : : int
4589 : : rte_flow_actions_update(uint16_t port_id,
4590 : : struct rte_flow *flow,
4591 : : const struct rte_flow_action actions[],
4592 : : struct rte_flow_error *error);
4593 : :
4594 : : /**
4595 : : * Destroy all flow rules associated with a port.
4596 : : *
4597 : : * In the unlikely event of failure, handles are still considered destroyed
4598 : : * and no longer valid but the port must be assumed to be in an inconsistent
4599 : : * state.
4600 : : *
4601 : : * @param port_id
4602 : : * Port identifier of Ethernet device.
4603 : : * @param[out] error
4604 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4605 : : * structure in case of error only.
4606 : : *
4607 : : * @return
4608 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4609 : : */
4610 : : int
4611 : : rte_flow_flush(uint16_t port_id,
4612 : : struct rte_flow_error *error);
4613 : :
4614 : : /**
4615 : : * Query an existing flow rule.
4616 : : *
4617 : : * This function allows retrieving flow-specific data such as counters.
4618 : : * Data is gathered by special actions which must be present in the flow
4619 : : * rule definition.
4620 : : *
4621 : : * \see RTE_FLOW_ACTION_TYPE_COUNT
4622 : : *
4623 : : * @param port_id
4624 : : * Port identifier of Ethernet device.
4625 : : * @param flow
4626 : : * Flow rule handle to query.
4627 : : * @param action
4628 : : * Action definition as defined in original flow rule.
4629 : : * @param[in, out] data
4630 : : * Pointer to storage for the associated query data type.
4631 : : * @param[out] error
4632 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4633 : : * structure in case of error only.
4634 : : *
4635 : : * @return
4636 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4637 : : */
4638 : : int
4639 : : rte_flow_query(uint16_t port_id,
4640 : : struct rte_flow *flow,
4641 : : const struct rte_flow_action *action,
4642 : : void *data,
4643 : : struct rte_flow_error *error);
4644 : :
4645 : : /**
4646 : : * Restrict ingress traffic to the defined flow rules.
4647 : : *
4648 : : * Isolated mode guarantees that all ingress traffic comes from defined flow
4649 : : * rules only (current and future).
4650 : : * When enabled with a bifurcated driver,
4651 : : * non-matched packets are routed to the kernel driver interface.
4652 : : * When disabled (the default),
4653 : : * there may be some default rules routing traffic to the DPDK port.
4654 : : *
4655 : : * Besides making ingress more deterministic, it allows PMDs to safely reuse
4656 : : * resources otherwise assigned to handle the remaining traffic, such as
4657 : : * global RSS configuration settings, VLAN filters, MAC address entries,
4658 : : * legacy filter API rules and so on in order to expand the set of possible
4659 : : * flow rule types.
4660 : : *
4661 : : * Calling this function as soon as possible after device initialization,
4662 : : * ideally before the first call to rte_eth_dev_configure(), is recommended
4663 : : * to avoid possible failures due to conflicting settings.
4664 : : *
4665 : : * Once effective, leaving isolated mode may not be possible depending on
4666 : : * PMD implementation.
4667 : : *
4668 : : * Additionally, the following functionality has no effect on the underlying
4669 : : * port and may return errors such as ENOTSUP ("not supported"):
4670 : : *
4671 : : * - Toggling promiscuous mode.
4672 : : * - Toggling allmulticast mode.
4673 : : * - Configuring MAC addresses.
4674 : : * - Configuring multicast addresses.
4675 : : * - Configuring VLAN filters.
4676 : : * - Configuring Rx filters through the legacy API (e.g. FDIR).
4677 : : * - Configuring global RSS settings.
4678 : : *
4679 : : * @param port_id
4680 : : * Port identifier of Ethernet device.
4681 : : * @param set
4682 : : * Nonzero to enter isolated mode, attempt to leave it otherwise.
4683 : : * @param[out] error
4684 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4685 : : * structure in case of error only.
4686 : : *
4687 : : * @return
4688 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
4689 : : */
4690 : : int
4691 : : rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4692 : :
4693 : : /**
4694 : : * Initialize flow error structure.
4695 : : *
4696 : : * @param[out] error
4697 : : * Pointer to flow error structure (may be NULL).
4698 : : * @param code
4699 : : * Related error code (rte_errno).
4700 : : * @param type
4701 : : * Cause field and error types.
4702 : : * @param cause
4703 : : * Object responsible for the error.
4704 : : * @param message
4705 : : * Human-readable error message.
4706 : : *
4707 : : * @return
4708 : : * Negative error code (errno value) and rte_errno is set.
4709 : : */
4710 : : int
4711 : : rte_flow_error_set(struct rte_flow_error *error,
4712 : : int code,
4713 : : enum rte_flow_error_type type,
4714 : : const void *cause,
4715 : : const char *message);
4716 : :
4717 : : /**
4718 : : * @deprecated
4719 : : * @see rte_flow_copy()
4720 : : */
4721 : : struct rte_flow_desc {
4722 : : size_t size; /**< Allocated space including data[]. */
4723 : : struct rte_flow_attr attr; /**< Attributes. */
4724 : : struct rte_flow_item *items; /**< Items. */
4725 : : struct rte_flow_action *actions; /**< Actions. */
4726 : : uint8_t data[]; /**< Storage for items/actions. */
4727 : : };
4728 : :
4729 : : /**
4730 : : * @deprecated
4731 : : * Copy an rte_flow rule description.
4732 : : *
4733 : : * This interface is kept for compatibility with older applications but is
4734 : : * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4735 : : * lack of flexibility and reliance on a type unusable with C++ programs
4736 : : * (struct rte_flow_desc).
4737 : : *
4738 : : * @param[in] fd
4739 : : * Flow rule description.
4740 : : * @param[in] len
4741 : : * Total size of allocated data for the flow description.
4742 : : * @param[in] attr
4743 : : * Flow rule attributes.
4744 : : * @param[in] items
4745 : : * Pattern specification (list terminated by the END pattern item).
4746 : : * @param[in] actions
4747 : : * Associated actions (list terminated by the END action).
4748 : : *
4749 : : * @return
4750 : : * If len is greater or equal to the size of the flow, the total size of the
4751 : : * flow description and its data.
4752 : : * If len is lower than the size of the flow, the number of bytes that would
4753 : : * have been written to desc had it been sufficient. Nothing is written.
4754 : : */
4755 : : __rte_deprecated
4756 : : size_t
4757 : : rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4758 : : const struct rte_flow_attr *attr,
4759 : : const struct rte_flow_item *items,
4760 : : const struct rte_flow_action *actions);
4761 : :
4762 : : /**
4763 : : * Flow object conversion helper.
4764 : : *
4765 : : * This function performs conversion of various flow API objects to a
4766 : : * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4767 : : * operations and details about each of them.
4768 : : *
4769 : : * Since destination buffer must be large enough, it works in a manner
4770 : : * reminiscent of snprintf():
4771 : : *
4772 : : * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4773 : : * non-NULL.
4774 : : * - If positive, the returned value represents the number of bytes needed
4775 : : * to store the conversion of @p src to @p dst according to @p op
4776 : : * regardless of the @p size parameter.
4777 : : * - Since no more than @p size bytes can be written to @p dst, output is
4778 : : * truncated and may be inconsistent when the returned value is larger
4779 : : * than that.
4780 : : * - In case of conversion error, a negative error code is returned and
4781 : : * @p dst contents are unspecified.
4782 : : *
4783 : : * @param op
4784 : : * Operation to perform, related to the object type of @p dst.
4785 : : * @param[out] dst
4786 : : * Destination buffer address. Must be suitably aligned by the caller.
4787 : : * @param size
4788 : : * Destination buffer size in bytes.
4789 : : * @param[in] src
4790 : : * Source object to copy. Depending on @p op, its type may differ from
4791 : : * that of @p dst.
4792 : : * @param[out] error
4793 : : * Perform verbose error reporting if not NULL. Initialized in case of
4794 : : * error only.
4795 : : *
4796 : : * @return
4797 : : * The number of bytes required to convert @p src to @p dst on success, a
4798 : : * negative errno value otherwise and rte_errno is set.
4799 : : *
4800 : : * @see rte_flow_conv_op
4801 : : */
4802 : : int
4803 : : rte_flow_conv(enum rte_flow_conv_op op,
4804 : : void *dst,
4805 : : size_t size,
4806 : : const void *src,
4807 : : struct rte_flow_error *error);
4808 : :
4809 : : /**
4810 : : * Get aged-out flows of a given port.
4811 : : *
4812 : : * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4813 : : * out flow was detected after the last call to rte_flow_get_aged_flows.
4814 : : * This function can be called to get the aged flows asynchronously from the
4815 : : * event callback or synchronously regardless the event.
4816 : : * This is not safe to call rte_flow_get_aged_flows function with other flow
4817 : : * functions from multiple threads simultaneously.
4818 : : *
4819 : : * @param port_id
4820 : : * Port identifier of Ethernet device.
4821 : : * @param[in, out] contexts
4822 : : * The address of an array of pointers to the aged-out flows contexts.
4823 : : * @param[in] nb_contexts
4824 : : * The length of context array pointers.
4825 : : * @param[out] error
4826 : : * Perform verbose error reporting if not NULL. Initialized in case of
4827 : : * error only.
4828 : : *
4829 : : * @return
4830 : : * if nb_contexts is 0, return the amount of all aged contexts.
4831 : : * if nb_contexts is not 0 , return the amount of aged flows reported
4832 : : * in the context array, otherwise negative errno value.
4833 : : *
4834 : : * @see rte_flow_action_age
4835 : : * @see RTE_ETH_EVENT_FLOW_AGED
4836 : : */
4837 : : int
4838 : : rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4839 : : uint32_t nb_contexts, struct rte_flow_error *error);
4840 : :
4841 : : /**
4842 : : * Get aged-out flows of a given port on the given flow queue.
4843 : : *
4844 : : * If application configure port attribute with RTE_FLOW_PORT_FLAG_STRICT_QUEUE,
4845 : : * there is no RTE_ETH_EVENT_FLOW_AGED event and this function must be called to
4846 : : * get the aged flows synchronously.
4847 : : *
4848 : : * If application configure port attribute without
4849 : : * RTE_FLOW_PORT_FLAG_STRICT_QUEUE, RTE_ETH_EVENT_FLOW_AGED event will be
4850 : : * triggered at least one new aged out flow was detected on any flow queue after
4851 : : * the last call to rte_flow_get_q_aged_flows.
4852 : : * In addition, the @p queue_id will be ignored.
4853 : : * This function can be called to get the aged flows asynchronously from the
4854 : : * event callback or synchronously regardless the event.
4855 : : *
4856 : : * @param[in] port_id
4857 : : * Port identifier of Ethernet device.
4858 : : * @param[in] queue_id
4859 : : * Flow queue to query. Ignored when RTE_FLOW_PORT_FLAG_STRICT_QUEUE not set.
4860 : : * @param[in, out] contexts
4861 : : * The address of an array of pointers to the aged-out flows contexts.
4862 : : * @param[in] nb_contexts
4863 : : * The length of context array pointers.
4864 : : * @param[out] error
4865 : : * Perform verbose error reporting if not NULL. Initialized in case of
4866 : : * error only.
4867 : : *
4868 : : * @return
4869 : : * if nb_contexts is 0, return the amount of all aged contexts.
4870 : : * if nb_contexts is not 0 , return the amount of aged flows reported
4871 : : * in the context array, otherwise negative errno value.
4872 : : *
4873 : : * @see rte_flow_action_age
4874 : : * @see RTE_ETH_EVENT_FLOW_AGED
4875 : : * @see rte_flow_port_flag
4876 : : */
4877 : : int
4878 : : rte_flow_get_q_aged_flows(uint16_t port_id, uint32_t queue_id, void **contexts,
4879 : : uint32_t nb_contexts, struct rte_flow_error *error);
4880 : :
4881 : : /**
4882 : : * Specify indirect action object configuration
4883 : : */
4884 : : struct rte_flow_indir_action_conf {
4885 : : /**
4886 : : * Flow direction for the indirect action configuration.
4887 : : *
4888 : : * Action should be valid at least for one flow direction,
4889 : : * otherwise it is invalid for both ingress and egress rules.
4890 : : */
4891 : : /** Action valid for rules applied to ingress traffic. */
4892 : : uint32_t ingress:1;
4893 : : /** Action valid for rules applied to egress traffic. */
4894 : : uint32_t egress:1;
4895 : : /**
4896 : : * When set to 1, indicates that the action is valid for
4897 : : * transfer traffic; otherwise, for non-transfer traffic.
4898 : : */
4899 : : uint32_t transfer:1;
4900 : : };
4901 : :
4902 : : /**
4903 : : * Create an indirect action object that can be used in flow rules
4904 : : * via its handle.
4905 : : * The created object handle has single state and configuration
4906 : : * across all the flow rules using it.
4907 : : *
4908 : : * @param[in] port_id
4909 : : * The port identifier of the Ethernet device.
4910 : : * @param[in] conf
4911 : : * Action configuration for the indirect action object creation.
4912 : : * @param[in] action
4913 : : * Specific configuration of the indirect action object.
4914 : : * @param[out] error
4915 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4916 : : * structure in case of error only.
4917 : : * @return
4918 : : * A valid handle in case of success, NULL otherwise and rte_errno is set
4919 : : * to one of the error codes defined:
4920 : : * - (ENODEV) if *port_id* invalid.
4921 : : * - (ENOSYS) if underlying device does not support this functionality.
4922 : : * - (EIO) if underlying device is removed.
4923 : : * - (EINVAL) if *action* invalid.
4924 : : * - (ENOTSUP) if *action* valid but unsupported.
4925 : : */
4926 : : struct rte_flow_action_handle *
4927 : : rte_flow_action_handle_create(uint16_t port_id,
4928 : : const struct rte_flow_indir_action_conf *conf,
4929 : : const struct rte_flow_action *action,
4930 : : struct rte_flow_error *error);
4931 : :
4932 : : /**
4933 : : * Destroy indirect action by handle.
4934 : : *
4935 : : * @param[in] port_id
4936 : : * The port identifier of the Ethernet device.
4937 : : * @param[in] handle
4938 : : * Handle for the indirect action object to be destroyed.
4939 : : * @param[out] error
4940 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4941 : : * structure in case of error only.
4942 : : * @return
4943 : : * - (0) if success.
4944 : : * - (-ENODEV) if *port_id* invalid.
4945 : : * - (-ENOSYS) if underlying device does not support this functionality.
4946 : : * - (-EIO) if underlying device is removed.
4947 : : * - (-ENOENT) if action pointed by *action* handle was not found.
4948 : : * - (-EBUSY) if action pointed by *action* handle still used by some rules
4949 : : * rte_errno is also set.
4950 : : */
4951 : : int
4952 : : rte_flow_action_handle_destroy(uint16_t port_id,
4953 : : struct rte_flow_action_handle *handle,
4954 : : struct rte_flow_error *error);
4955 : :
4956 : : /**
4957 : : * Update in-place the action configuration and / or state pointed
4958 : : * by action *handle* with the configuration provided as *update* argument.
4959 : : * The update of the action configuration effects all flow rules reusing
4960 : : * the action via *handle*.
4961 : : * The update general pointer provides the ability of partial updating.
4962 : : *
4963 : : * @param[in] port_id
4964 : : * The port identifier of the Ethernet device.
4965 : : * @param[in] handle
4966 : : * Handle for the indirect action object to be updated.
4967 : : * @param[in] update
4968 : : * Update profile specification used to modify the action pointed by handle.
4969 : : * *update* could be with the same type of the immediate action corresponding
4970 : : * to the *handle* argument when creating, or a wrapper structure includes
4971 : : * action configuration to be updated and bit fields to indicate the member
4972 : : * of fields inside the action to update.
4973 : : * @param[out] error
4974 : : * Perform verbose error reporting if not NULL. PMDs initialize this
4975 : : * structure in case of error only.
4976 : : * @return
4977 : : * - (0) if success.
4978 : : * - (-ENODEV) if *port_id* invalid.
4979 : : * - (-ENOSYS) if underlying device does not support this functionality.
4980 : : * - (-EIO) if underlying device is removed.
4981 : : * - (-EINVAL) if *update* invalid.
4982 : : * - (-ENOTSUP) if *update* valid but unsupported.
4983 : : * - (-ENOENT) if indirect action object pointed by *handle* was not found.
4984 : : * rte_errno is also set.
4985 : : */
4986 : : int
4987 : : rte_flow_action_handle_update(uint16_t port_id,
4988 : : struct rte_flow_action_handle *handle,
4989 : : const void *update,
4990 : : struct rte_flow_error *error);
4991 : :
4992 : : /**
4993 : : * Query the direct action by corresponding indirect action object handle.
4994 : : *
4995 : : * Retrieve action-specific data such as counters.
4996 : : * Data is gathered by special action which may be present/referenced in
4997 : : * more than one flow rule definition.
4998 : : *
4999 : : * @see RTE_FLOW_ACTION_TYPE_COUNT
5000 : : *
5001 : : * @param port_id
5002 : : * Port identifier of Ethernet device.
5003 : : * @param[in] handle
5004 : : * Handle for the action object to query.
5005 : : * @param[in, out] data
5006 : : * Pointer to storage for the associated query data type.
5007 : : * @param[out] error
5008 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5009 : : * structure in case of error only.
5010 : : *
5011 : : * @return
5012 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5013 : : */
5014 : : int
5015 : : rte_flow_action_handle_query(uint16_t port_id,
5016 : : const struct rte_flow_action_handle *handle,
5017 : : void *data, struct rte_flow_error *error);
5018 : :
5019 : : /* Tunnel has a type and the key information. */
5020 : : struct rte_flow_tunnel {
5021 : : /**
5022 : : * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
5023 : : * RTE_FLOW_ITEM_TYPE_NVGRE etc.
5024 : : */
5025 : : enum rte_flow_item_type type;
5026 : : uint64_t tun_id; /**< Tunnel identification. */
5027 : :
5028 : : union {
5029 : : struct {
5030 : : rte_be32_t src_addr; /**< IPv4 source address. */
5031 : : rte_be32_t dst_addr; /**< IPv4 destination address. */
5032 : : } ipv4;
5033 : : struct {
5034 : : struct rte_ipv6_addr src_addr; /**< IPv6 source address. */
5035 : : struct rte_ipv6_addr dst_addr; /**< IPv6 destination address. */
5036 : : } ipv6;
5037 : : };
5038 : : rte_be16_t tp_src; /**< Tunnel port source. */
5039 : : rte_be16_t tp_dst; /**< Tunnel port destination. */
5040 : : uint16_t tun_flags; /**< Tunnel flags. */
5041 : :
5042 : : bool is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
5043 : :
5044 : : /**
5045 : : * the following members are required to restore packet
5046 : : * after miss
5047 : : */
5048 : : uint8_t tos; /**< TOS for IPv4, TC for IPv6. */
5049 : : uint8_t ttl; /**< TTL for IPv4, HL for IPv6. */
5050 : : uint32_t label; /**< Flow Label for IPv6. */
5051 : : };
5052 : :
5053 : : /**
5054 : : * Indicate that the packet has a tunnel.
5055 : : */
5056 : : #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
5057 : :
5058 : : /**
5059 : : * Indicate that the packet has a non decapsulated tunnel header.
5060 : : */
5061 : : #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
5062 : :
5063 : : /**
5064 : : * Indicate that the packet has a group_id.
5065 : : */
5066 : : #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
5067 : :
5068 : : /**
5069 : : * Restore information structure to communicate the current packet processing
5070 : : * state when some of the processing pipeline is done in hardware and should
5071 : : * continue in software.
5072 : : */
5073 : : struct rte_flow_restore_info {
5074 : : /**
5075 : : * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
5076 : : * other fields in struct rte_flow_restore_info.
5077 : : */
5078 : : uint64_t flags;
5079 : : uint32_t group_id; /**< Group ID where packed missed */
5080 : : struct rte_flow_tunnel tunnel; /**< Tunnel information. */
5081 : : };
5082 : :
5083 : : /**
5084 : : * Allocate an array of actions to be used in rte_flow_create, to implement
5085 : : * tunnel-decap-set for the given tunnel.
5086 : : * Sample usage:
5087 : : * actions vxlan_decap / tunnel-decap-set(tunnel properties) /
5088 : : * jump group 0 / end
5089 : : *
5090 : : * @param port_id
5091 : : * Port identifier of Ethernet device.
5092 : : * @param[in] tunnel
5093 : : * Tunnel properties.
5094 : : * @param[out] actions
5095 : : * Array of actions to be allocated by the PMD. This array should be
5096 : : * concatenated with the actions array provided to rte_flow_create.
5097 : : * @param[out] num_of_actions
5098 : : * Number of actions allocated.
5099 : : * @param[out] error
5100 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5101 : : * structure in case of error only.
5102 : : *
5103 : : * @return
5104 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5105 : : */
5106 : : int
5107 : : rte_flow_tunnel_decap_set(uint16_t port_id,
5108 : : struct rte_flow_tunnel *tunnel,
5109 : : struct rte_flow_action **actions,
5110 : : uint32_t *num_of_actions,
5111 : : struct rte_flow_error *error);
5112 : :
5113 : : /**
5114 : : * Allocate an array of items to be used in rte_flow_create, to implement
5115 : : * tunnel-match for the given tunnel.
5116 : : * Sample usage:
5117 : : * pattern tunnel-match(tunnel properties) / outer-header-matches /
5118 : : * inner-header-matches / end
5119 : : *
5120 : : * @param port_id
5121 : : * Port identifier of Ethernet device.
5122 : : * @param[in] tunnel
5123 : : * Tunnel properties.
5124 : : * @param[out] items
5125 : : * Array of items to be allocated by the PMD. This array should be
5126 : : * concatenated with the items array provided to rte_flow_create.
5127 : : * @param[out] num_of_items
5128 : : * Number of items allocated.
5129 : : * @param[out] error
5130 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5131 : : * structure in case of error only.
5132 : : *
5133 : : * @return
5134 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5135 : : */
5136 : : int
5137 : : rte_flow_tunnel_match(uint16_t port_id,
5138 : : struct rte_flow_tunnel *tunnel,
5139 : : struct rte_flow_item **items,
5140 : : uint32_t *num_of_items,
5141 : : struct rte_flow_error *error);
5142 : :
5143 : : /**
5144 : : * On reception of a mbuf from HW, a call to rte_flow_get_restore_info() may be
5145 : : * required to retrieve some metadata.
5146 : : * This function returns the associated mbuf ol_flags.
5147 : : *
5148 : : * Note: the dynamic flag is registered during a call to
5149 : : * rte_eth_rx_metadata_negotiate() with RTE_ETH_RX_METADATA_TUNNEL_ID.
5150 : : *
5151 : : * @return
5152 : : * The offload flag indicating rte_flow_get_restore_info() must be called.
5153 : : */
5154 : : uint64_t
5155 : : rte_flow_restore_info_dynflag(void);
5156 : :
5157 : : /**
5158 : : * If a mbuf contains the rte_flow_restore_info_dynflag() flag in ol_flags,
5159 : : * populate the current packet processing state.
5160 : : *
5161 : : * One should negotiate tunnel metadata delivery from the NIC to the HW.
5162 : : * @see rte_eth_rx_metadata_negotiate()
5163 : : * @see RTE_ETH_RX_METADATA_TUNNEL_ID
5164 : : *
5165 : : * @param port_id
5166 : : * Port identifier of Ethernet device.
5167 : : * @param[in] m
5168 : : * Mbuf struct.
5169 : : * @param[out] info
5170 : : * Restore information. Upon success contains the HW state.
5171 : : * @param[out] error
5172 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5173 : : * structure in case of error only.
5174 : : *
5175 : : * @return
5176 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5177 : : */
5178 : : int
5179 : : rte_flow_get_restore_info(uint16_t port_id,
5180 : : struct rte_mbuf *m,
5181 : : struct rte_flow_restore_info *info,
5182 : : struct rte_flow_error *error);
5183 : :
5184 : : /**
5185 : : * Release the action array as allocated by rte_flow_tunnel_decap_set.
5186 : : *
5187 : : * @param port_id
5188 : : * Port identifier of Ethernet device.
5189 : : * @param[in] actions
5190 : : * Array of actions to be released.
5191 : : * @param[in] num_of_actions
5192 : : * Number of elements in actions array.
5193 : : * @param[out] error
5194 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5195 : : * structure in case of error only.
5196 : : *
5197 : : * @return
5198 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5199 : : */
5200 : : int
5201 : : rte_flow_tunnel_action_decap_release(uint16_t port_id,
5202 : : struct rte_flow_action *actions,
5203 : : uint32_t num_of_actions,
5204 : : struct rte_flow_error *error);
5205 : :
5206 : : /**
5207 : : * Release the item array as allocated by rte_flow_tunnel_match.
5208 : : *
5209 : : * @param port_id
5210 : : * Port identifier of Ethernet device.
5211 : : * @param[in] items
5212 : : * Array of items to be released.
5213 : : * @param[in] num_of_items
5214 : : * Number of elements in item array.
5215 : : * @param[out] error
5216 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5217 : : * structure in case of error only.
5218 : : *
5219 : : * @return
5220 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5221 : : */
5222 : : int
5223 : : rte_flow_tunnel_item_release(uint16_t port_id,
5224 : : struct rte_flow_item *items,
5225 : : uint32_t num_of_items,
5226 : : struct rte_flow_error *error);
5227 : :
5228 : : /**
5229 : : * Get a proxy port to manage "transfer" flows.
5230 : : *
5231 : : * Managing "transfer" flows requires that the user communicate them
5232 : : * via a port which has the privilege to control the embedded switch.
5233 : : * For some vendors, all ports in a given switching domain have
5234 : : * this privilege. For other vendors, it's only one port.
5235 : : *
5236 : : * This API indicates such a privileged port (a "proxy")
5237 : : * for a given port in the same switching domain.
5238 : : *
5239 : : * @note
5240 : : * If the PMD serving @p port_id doesn't have the corresponding method
5241 : : * implemented, the API will return @p port_id via @p proxy_port_id.
5242 : : *
5243 : : * @param port_id
5244 : : * Indicates the port to get a "proxy" for
5245 : : * @param[out] proxy_port_id
5246 : : * Indicates the "proxy" port
5247 : : * @param[out] error
5248 : : * If not NULL, allows the PMD to provide verbose report in case of error
5249 : : *
5250 : : * @return
5251 : : * 0 on success, a negative error code otherwise
5252 : : */
5253 : : int
5254 : : rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
5255 : : struct rte_flow_error *error);
5256 : :
5257 : : /**
5258 : : * Create the flex item with specified configuration over
5259 : : * the Ethernet device.
5260 : : *
5261 : : * @param port_id
5262 : : * Port identifier of Ethernet device.
5263 : : * @param[in] conf
5264 : : * Item configuration.
5265 : : * @param[out] error
5266 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5267 : : * structure in case of error only.
5268 : : *
5269 : : * @return
5270 : : * Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
5271 : : */
5272 : : struct rte_flow_item_flex_handle *
5273 : : rte_flow_flex_item_create(uint16_t port_id,
5274 : : const struct rte_flow_item_flex_conf *conf,
5275 : : struct rte_flow_error *error);
5276 : :
5277 : : /**
5278 : : * Release the flex item on the specified Ethernet device.
5279 : : *
5280 : : * @param port_id
5281 : : * Port identifier of Ethernet device.
5282 : : * @param[in] handle
5283 : : * Handle of the item existing on the specified device.
5284 : : * @param[out] error
5285 : : * Perform verbose error reporting if not NULL. PMDs initialize this
5286 : : * structure in case of error only.
5287 : : *
5288 : : * @return
5289 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5290 : : */
5291 : : int
5292 : : rte_flow_flex_item_release(uint16_t port_id,
5293 : : const struct rte_flow_item_flex_handle *handle,
5294 : : struct rte_flow_error *error);
5295 : :
5296 : : /**
5297 : : * Indicate all operations for a given flow rule will _strictly_
5298 : : * happen on the same queue (create/destroy/query/update).
5299 : : */
5300 : : #define RTE_FLOW_PORT_FLAG_STRICT_QUEUE RTE_BIT32(0)
5301 : :
5302 : : /**
5303 : : * Indicate all steering objects should be created on contexts
5304 : : * of the host port, providing indirect object sharing between
5305 : : * ports.
5306 : : */
5307 : : #define RTE_FLOW_PORT_FLAG_SHARE_INDIRECT RTE_BIT32(1)
5308 : :
5309 : : /**
5310 : : * Information about flow engine resources.
5311 : : * The zero value means a resource is not supported.
5312 : : */
5313 : : struct rte_flow_port_info {
5314 : : /**
5315 : : * Maximum number of queues for asynchronous operations.
5316 : : */
5317 : : uint32_t max_nb_queues;
5318 : : /**
5319 : : * Maximum number of counters.
5320 : : * @see RTE_FLOW_ACTION_TYPE_COUNT
5321 : : */
5322 : : uint32_t max_nb_counters;
5323 : : /**
5324 : : * Maximum number of aging objects.
5325 : : * @see RTE_FLOW_ACTION_TYPE_AGE
5326 : : */
5327 : : uint32_t max_nb_aging_objects;
5328 : : /**
5329 : : * Maximum number traffic meters.
5330 : : * @see RTE_FLOW_ACTION_TYPE_METER
5331 : : */
5332 : : uint32_t max_nb_meters;
5333 : : /**
5334 : : * Maximum number connection trackings.
5335 : : * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
5336 : : */
5337 : : uint32_t max_nb_conn_tracks;
5338 : : /**
5339 : : * Maximum number of quota actions.
5340 : : * @see RTE_FLOW_ACTION_TYPE_QUOTA
5341 : : */
5342 : : uint32_t max_nb_quotas;
5343 : : /**
5344 : : * Port supported flags (RTE_FLOW_PORT_FLAG_*).
5345 : : */
5346 : : uint32_t supported_flags;
5347 : : };
5348 : :
5349 : : /**
5350 : : * Information about flow engine asynchronous queues.
5351 : : * The value only valid if @p port_attr.max_nb_queues is not zero.
5352 : : */
5353 : : struct rte_flow_queue_info {
5354 : : /**
5355 : : * Maximum number of operations a queue can hold.
5356 : : */
5357 : : uint32_t max_size;
5358 : : };
5359 : :
5360 : : /**
5361 : : * Get information about flow engine resources.
5362 : : *
5363 : : * @param port_id
5364 : : * Port identifier of Ethernet device.
5365 : : * @param[out] port_info
5366 : : * A pointer to a structure of type *rte_flow_port_info*
5367 : : * to be filled with the resources information of the port.
5368 : : * @param[out] queue_info
5369 : : * A pointer to a structure of type *rte_flow_queue_info*
5370 : : * to be filled with the asynchronous queues information.
5371 : : * @param[out] error
5372 : : * Perform verbose error reporting if not NULL.
5373 : : * PMDs initialize this structure in case of error only.
5374 : : *
5375 : : * @return
5376 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5377 : : */
5378 : : int
5379 : : rte_flow_info_get(uint16_t port_id,
5380 : : struct rte_flow_port_info *port_info,
5381 : : struct rte_flow_queue_info *queue_info,
5382 : : struct rte_flow_error *error);
5383 : :
5384 : : /**
5385 : : * Flow engine resources settings.
5386 : : * The zero value means on demand resource allocations only.
5387 : : */
5388 : : struct rte_flow_port_attr {
5389 : : /**
5390 : : * Number of counters to configure.
5391 : : * @see RTE_FLOW_ACTION_TYPE_COUNT
5392 : : */
5393 : : uint32_t nb_counters;
5394 : : /**
5395 : : * Number of aging objects to configure.
5396 : : * @see RTE_FLOW_ACTION_TYPE_AGE
5397 : : */
5398 : : uint32_t nb_aging_objects;
5399 : : /**
5400 : : * Number of traffic meters to configure.
5401 : : * @see RTE_FLOW_ACTION_TYPE_METER
5402 : : */
5403 : : uint32_t nb_meters;
5404 : : /**
5405 : : * Number of connection trackings to configure.
5406 : : * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
5407 : : */
5408 : : uint32_t nb_conn_tracks;
5409 : : /**
5410 : : * Port to base shared objects on.
5411 : : */
5412 : : uint16_t host_port_id;
5413 : : /**
5414 : : * Maximum number of quota actions.
5415 : : * @see RTE_FLOW_ACTION_TYPE_QUOTA
5416 : : */
5417 : : uint32_t nb_quotas;
5418 : : /**
5419 : : * Port flags (RTE_FLOW_PORT_FLAG_*).
5420 : : */
5421 : : uint32_t flags;
5422 : : };
5423 : :
5424 : : /**
5425 : : * Flow engine asynchronous queues settings.
5426 : : * The value means default value picked by PMD.
5427 : : */
5428 : : struct rte_flow_queue_attr {
5429 : : /**
5430 : : * Number of flow rule operations a queue can hold.
5431 : : */
5432 : : uint32_t size;
5433 : : };
5434 : :
5435 : : /**
5436 : : * Configure the port's flow API engine.
5437 : : *
5438 : : * This API can only be invoked before the application
5439 : : * starts using the rest of the flow library functions.
5440 : : *
5441 : : * The API can be invoked multiple times to change the settings.
5442 : : * The port, however, may reject changes and keep the old config.
5443 : : *
5444 : : * Parameters in configuration attributes must not exceed
5445 : : * numbers of resources returned by the rte_flow_info_get API.
5446 : : *
5447 : : * @param port_id
5448 : : * Port identifier of Ethernet device.
5449 : : * @param[in] port_attr
5450 : : * Port configuration attributes.
5451 : : * @param[in] nb_queue
5452 : : * Number of flow queues to be configured.
5453 : : * @param[in] queue_attr
5454 : : * Array that holds attributes for each flow queue.
5455 : : * Number of elements is set in @p port_attr.nb_queues.
5456 : : * @param[out] error
5457 : : * Perform verbose error reporting if not NULL.
5458 : : * PMDs initialize this structure in case of error only.
5459 : : *
5460 : : * @return
5461 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5462 : : */
5463 : : int
5464 : : rte_flow_configure(uint16_t port_id,
5465 : : const struct rte_flow_port_attr *port_attr,
5466 : : uint16_t nb_queue,
5467 : : const struct rte_flow_queue_attr *queue_attr[],
5468 : : struct rte_flow_error *error);
5469 : :
5470 : : /**
5471 : : * Opaque type returned after successful creation of pattern template.
5472 : : * This handle can be used to manage the created pattern template.
5473 : : */
5474 : : struct rte_flow_pattern_template;
5475 : :
5476 : : /**
5477 : : * Flow pattern template attributes.
5478 : : */
5479 : : __extension__
5480 : : struct rte_flow_pattern_template_attr {
5481 : : /**
5482 : : * Relaxed matching policy.
5483 : : * - If 1, matching is performed only on items with the mask member set
5484 : : * and matching on protocol layers specified without any masks is skipped.
5485 : : * - If 0, matching on protocol layers specified without any masks is done
5486 : : * as well. This is the standard behaviour of Flow API now.
5487 : : */
5488 : : uint32_t relaxed_matching:1;
5489 : : /**
5490 : : * Flow direction for the pattern template.
5491 : : * At least one direction must be specified.
5492 : : */
5493 : : /** Pattern valid for rules applied to ingress traffic. */
5494 : : uint32_t ingress:1;
5495 : : /** Pattern valid for rules applied to egress traffic. */
5496 : : uint32_t egress:1;
5497 : : /** Pattern valid for rules applied to transfer traffic. */
5498 : : uint32_t transfer:1;
5499 : : };
5500 : :
5501 : : /**
5502 : : * Create flow pattern template.
5503 : : *
5504 : : * The pattern template defines common matching fields without values.
5505 : : * For example, matching on 5 tuple TCP flow, the template will be
5506 : : * eth(null) + IPv4(source + dest) + TCP(s_port + d_port),
5507 : : * while values for each rule will be set during the flow rule creation.
5508 : : * The number and order of items in the template must be the same
5509 : : * at the rule creation.
5510 : : *
5511 : : * @param port_id
5512 : : * Port identifier of Ethernet device.
5513 : : * @param[in] template_attr
5514 : : * Pattern template attributes.
5515 : : * @param[in] pattern
5516 : : * Pattern specification (list terminated by the END pattern item).
5517 : : * The spec member of an item is not used unless the end member is used.
5518 : : * @param[out] error
5519 : : * Perform verbose error reporting if not NULL.
5520 : : * PMDs initialize this structure in case of error only.
5521 : : *
5522 : : * @return
5523 : : * Handle on success, NULL otherwise and rte_errno is set.
5524 : : */
5525 : : struct rte_flow_pattern_template *
5526 : : rte_flow_pattern_template_create(uint16_t port_id,
5527 : : const struct rte_flow_pattern_template_attr *template_attr,
5528 : : const struct rte_flow_item pattern[],
5529 : : struct rte_flow_error *error);
5530 : :
5531 : : /**
5532 : : * Destroy flow pattern template.
5533 : : *
5534 : : * This function may be called only when
5535 : : * there are no more tables referencing this template.
5536 : : *
5537 : : * @param port_id
5538 : : * Port identifier of Ethernet device.
5539 : : * @param[in] pattern_template
5540 : : * Handle of the template to be destroyed.
5541 : : * @param[out] error
5542 : : * Perform verbose error reporting if not NULL.
5543 : : * PMDs initialize this structure in case of error only.
5544 : : *
5545 : : * @return
5546 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5547 : : */
5548 : : int
5549 : : rte_flow_pattern_template_destroy(uint16_t port_id,
5550 : : struct rte_flow_pattern_template *pattern_template,
5551 : : struct rte_flow_error *error);
5552 : :
5553 : : /**
5554 : : * Opaque type returned after successful creation of actions template.
5555 : : * This handle can be used to manage the created actions template.
5556 : : */
5557 : : struct rte_flow_actions_template;
5558 : :
5559 : : /**
5560 : : * Flow actions template attributes.
5561 : : */
5562 : : __extension__
5563 : : struct rte_flow_actions_template_attr {
5564 : : /**
5565 : : * Flow direction for the actions template.
5566 : : * At least one direction must be specified.
5567 : : */
5568 : : /** Action valid for rules applied to ingress traffic. */
5569 : : uint32_t ingress:1;
5570 : : /** Action valid for rules applied to egress traffic. */
5571 : : uint32_t egress:1;
5572 : : /** Action valid for rules applied to transfer traffic. */
5573 : : uint32_t transfer:1;
5574 : : };
5575 : :
5576 : : /**
5577 : : * Create flow actions template.
5578 : : *
5579 : : * The actions template holds a list of action types without values.
5580 : : * For example, the template to change TCP ports is TCP(s_port + d_port),
5581 : : * while values for each rule will be set during the flow rule creation.
5582 : : * The number and order of actions in the template must be the same
5583 : : * at the rule creation.
5584 : : *
5585 : : * @param port_id
5586 : : * Port identifier of Ethernet device.
5587 : : * @param[in] template_attr
5588 : : * Template attributes.
5589 : : * @param[in] actions
5590 : : * Associated actions (list terminated by the END action).
5591 : : * The spec member is only used if @p masks spec is non-zero.
5592 : : * @param[in] masks
5593 : : * List of actions that marks which of the action's member is constant.
5594 : : * A mask has the same format as the corresponding action.
5595 : : * If the action field in @p masks is not 0,
5596 : : * the corresponding value in an action from @p actions will be the part
5597 : : * of the template and used in all flow rules.
5598 : : * The order of actions in @p masks is the same as in @p actions.
5599 : : * In case of indirect actions present in @p actions,
5600 : : * the actual action type should be present in @p mask.
5601 : : * @param[out] error
5602 : : * Perform verbose error reporting if not NULL.
5603 : : * PMDs initialize this structure in case of error only.
5604 : : *
5605 : : * @return
5606 : : * Handle on success, NULL otherwise and rte_errno is set.
5607 : : */
5608 : : struct rte_flow_actions_template *
5609 : : rte_flow_actions_template_create(uint16_t port_id,
5610 : : const struct rte_flow_actions_template_attr *template_attr,
5611 : : const struct rte_flow_action actions[],
5612 : : const struct rte_flow_action masks[],
5613 : : struct rte_flow_error *error);
5614 : :
5615 : : /**
5616 : : * Destroy flow actions template.
5617 : : *
5618 : : * This function may be called only when
5619 : : * there are no more tables referencing this template.
5620 : : *
5621 : : * @param port_id
5622 : : * Port identifier of Ethernet device.
5623 : : * @param[in] actions_template
5624 : : * Handle to the template to be destroyed.
5625 : : * @param[out] error
5626 : : * Perform verbose error reporting if not NULL.
5627 : : * PMDs initialize this structure in case of error only.
5628 : : *
5629 : : * @return
5630 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5631 : : */
5632 : : int
5633 : : rte_flow_actions_template_destroy(uint16_t port_id,
5634 : : struct rte_flow_actions_template *actions_template,
5635 : : struct rte_flow_error *error);
5636 : :
5637 : : /**
5638 : : * Opaque type returned after successful creation of a template table.
5639 : : * This handle can be used to manage the created template table.
5640 : : */
5641 : : struct rte_flow_template_table;
5642 : :
5643 : : /**@{@name Flags for template table attribute.
5644 : : * Each bit is an optional hint for table specialization,
5645 : : * offering a potential optimization at driver layer.
5646 : : * The driver can ignore the hints silently.
5647 : : * The hints do not replace any matching criteria.
5648 : : */
5649 : : /**
5650 : : * Specialize table for transfer flows which come only from wire.
5651 : : * It allows PMD not to allocate resources for non-wire originated traffic.
5652 : : * This bit is not a matching criteria, just an optimization hint.
5653 : : * Flow rules which match non-wire originated traffic will be missed
5654 : : * if the hint is supported.
5655 : : */
5656 : : #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG RTE_BIT32(0)
5657 : : /**
5658 : : * Specialize table for transfer flows which come only from vport (e.g. VF, SF).
5659 : : * It allows PMD not to allocate resources for non-vport originated traffic.
5660 : : * This bit is not a matching criteria, just an optimization hint.
5661 : : * Flow rules which match non-vport originated traffic will be missed
5662 : : * if the hint is supported.
5663 : : */
5664 : : #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1)
5665 : : /**
5666 : : * Specialize table for resize.
5667 : : */
5668 : : #define RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE RTE_BIT32(2)
5669 : : /**@}*/
5670 : :
5671 : : /**
5672 : : * Template table flow rules insertion type.
5673 : : */
5674 : : enum rte_flow_table_insertion_type {
5675 : : /**
5676 : : * Pattern-based insertion.
5677 : : */
5678 : : RTE_FLOW_TABLE_INSERTION_TYPE_PATTERN,
5679 : : /**
5680 : : * Index-based insertion.
5681 : : */
5682 : : RTE_FLOW_TABLE_INSERTION_TYPE_INDEX,
5683 : : /**
5684 : : * Index-based insertion with pattern.
5685 : : */
5686 : : RTE_FLOW_TABLE_INSERTION_TYPE_INDEX_WITH_PATTERN,
5687 : : };
5688 : :
5689 : : /**
5690 : : * Template table hash index calculation function.
5691 : : */
5692 : : enum rte_flow_table_hash_func {
5693 : : /**
5694 : : * Default hash calculation.
5695 : : */
5696 : : RTE_FLOW_TABLE_HASH_FUNC_DEFAULT,
5697 : : /**
5698 : : * Linear hash calculation.
5699 : : */
5700 : : RTE_FLOW_TABLE_HASH_FUNC_LINEAR,
5701 : : /**
5702 : : * 32-bit checksum hash calculation.
5703 : : */
5704 : : RTE_FLOW_TABLE_HASH_FUNC_CRC32,
5705 : : /**
5706 : : * 16-bit checksum hash calculation.
5707 : : */
5708 : : RTE_FLOW_TABLE_HASH_FUNC_CRC16,
5709 : : };
5710 : :
5711 : : /**
5712 : : * Table attributes.
5713 : : */
5714 : : struct rte_flow_template_table_attr {
5715 : : /**
5716 : : * Flow attributes to be used in each rule generated from this table.
5717 : : */
5718 : : struct rte_flow_attr flow_attr;
5719 : : /**
5720 : : * Maximum number of flow rules that this table holds.
5721 : : */
5722 : : uint32_t nb_flows;
5723 : : /**
5724 : : * Optional hint flags for driver optimization.
5725 : : * The effect may vary in the different drivers.
5726 : : * The functionality must not rely on the hints.
5727 : : * Value is composed with RTE_FLOW_TABLE_SPECIALIZE_* based on application
5728 : : * design choices.
5729 : : * Misused hints may mislead the driver, it may result in an undefined behavior.
5730 : : */
5731 : : uint32_t specialize;
5732 : : /**
5733 : : * Insertion type for flow rules.
5734 : : */
5735 : : enum rte_flow_table_insertion_type insertion_type;
5736 : : /**
5737 : : * Hash calculation function for the packet matching.
5738 : : */
5739 : : enum rte_flow_table_hash_func hash_func;
5740 : : };
5741 : :
5742 : : /**
5743 : : * Query whether a table can be resized.
5744 : : *
5745 : : * @param port_id
5746 : : * Port identifier of Ethernet device.
5747 : : * @param tbl_attr
5748 : : * Template table.
5749 : : *
5750 : : * @return
5751 : : * True if the table can be resized.
5752 : : */
5753 : : bool
5754 : : rte_flow_template_table_resizable(__rte_unused uint16_t port_id,
5755 : : const struct rte_flow_template_table_attr *tbl_attr);
5756 : :
5757 : : /**
5758 : : * Create flow template table.
5759 : : *
5760 : : * A template table consists of multiple pattern templates and actions
5761 : : * templates associated with a single set of rule attributes (group ID,
5762 : : * priority and traffic direction).
5763 : : *
5764 : : * Each rule is free to use any combination of pattern and actions templates
5765 : : * and specify particular values for items and actions it would like to change.
5766 : : *
5767 : : * @param port_id
5768 : : * Port identifier of Ethernet device.
5769 : : * @param[in] table_attr
5770 : : * Template table attributes.
5771 : : * @param[in] pattern_templates
5772 : : * Array of pattern templates to be used in this table.
5773 : : * @param[in] nb_pattern_templates
5774 : : * The number of pattern templates in the pattern_templates array.
5775 : : * @param[in] actions_templates
5776 : : * Array of actions templates to be used in this table.
5777 : : * @param[in] nb_actions_templates
5778 : : * The number of actions templates in the actions_templates array.
5779 : : * @param[out] error
5780 : : * Perform verbose error reporting if not NULL.
5781 : : * PMDs initialize this structure in case of error only.
5782 : : *
5783 : : * @return
5784 : : * Handle on success, NULL otherwise and rte_errno is set.
5785 : : */
5786 : : struct rte_flow_template_table *
5787 : : rte_flow_template_table_create(uint16_t port_id,
5788 : : const struct rte_flow_template_table_attr *table_attr,
5789 : : struct rte_flow_pattern_template *pattern_templates[],
5790 : : uint8_t nb_pattern_templates,
5791 : : struct rte_flow_actions_template *actions_templates[],
5792 : : uint8_t nb_actions_templates,
5793 : : struct rte_flow_error *error);
5794 : :
5795 : : /**
5796 : : * Destroy flow template table.
5797 : : *
5798 : : * This function may be called only when
5799 : : * there are no more flow rules referencing this table.
5800 : : *
5801 : : * @param port_id
5802 : : * Port identifier of Ethernet device.
5803 : : * @param[in] template_table
5804 : : * Handle to the table to be destroyed.
5805 : : * @param[out] error
5806 : : * Perform verbose error reporting if not NULL.
5807 : : * PMDs initialize this structure in case of error only.
5808 : : *
5809 : : * @return
5810 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5811 : : */
5812 : : int
5813 : : rte_flow_template_table_destroy(uint16_t port_id,
5814 : : struct rte_flow_template_table *template_table,
5815 : : struct rte_flow_error *error);
5816 : :
5817 : : /**
5818 : : * Set group miss actions.
5819 : : *
5820 : : * @param port_id
5821 : : * Port identifier of Ethernet device.
5822 : : * @param group_id
5823 : : * Identifier of a group to set miss actions for.
5824 : : * @param attr
5825 : : * Group attributes.
5826 : : * @param actions
5827 : : * List of group miss actions.
5828 : : * @param[out] error
5829 : : * Perform verbose error reporting if not NULL.
5830 : : * PMDs initialize this structure in case of error only.
5831 : : *
5832 : : * @return
5833 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
5834 : : */
5835 : : int
5836 : : rte_flow_group_set_miss_actions(uint16_t port_id,
5837 : : uint32_t group_id,
5838 : : const struct rte_flow_group_attr *attr,
5839 : : const struct rte_flow_action actions[],
5840 : : struct rte_flow_error *error);
5841 : :
5842 : : /**
5843 : : * Asynchronous operation attributes.
5844 : : */
5845 : : __extension__
5846 : : struct rte_flow_op_attr {
5847 : : /**
5848 : : * When set, the requested action will not be sent to the HW immediately.
5849 : : * The application must call the rte_flow_queue_push to actually send it.
5850 : : */
5851 : : uint32_t postpone:1;
5852 : : };
5853 : :
5854 : : /**
5855 : : * Enqueue rule creation operation.
5856 : : *
5857 : : * @param port_id
5858 : : * Port identifier of Ethernet device.
5859 : : * @param queue_id
5860 : : * Flow queue used to insert the rule.
5861 : : * @param[in] op_attr
5862 : : * Rule creation operation attributes.
5863 : : * @param[in] template_table
5864 : : * Template table to select templates from.
5865 : : * @param[in] pattern
5866 : : * List of pattern items to be used.
5867 : : * The list order should match the order in the pattern template.
5868 : : * The spec is the only relevant member of the item that is being used.
5869 : : * @param[in] pattern_template_index
5870 : : * Pattern template index in the table.
5871 : : * @param[in] actions
5872 : : * List of actions to be used.
5873 : : * The list order should match the order in the actions template.
5874 : : * @param[in] actions_template_index
5875 : : * Actions template index in the table.
5876 : : * @param[in] user_data
5877 : : * The user data that will be returned on the completion events.
5878 : : * @param[out] error
5879 : : * Perform verbose error reporting if not NULL.
5880 : : * PMDs initialize this structure in case of error only.
5881 : : *
5882 : : * @return
5883 : : * Handle on success, NULL otherwise and rte_errno is set.
5884 : : * The rule handle doesn't mean that the rule has been populated.
5885 : : * Only completion result indicates that if there was success or failure.
5886 : : */
5887 : : struct rte_flow *
5888 : : rte_flow_async_create(uint16_t port_id,
5889 : : uint32_t queue_id,
5890 : : const struct rte_flow_op_attr *op_attr,
5891 : : struct rte_flow_template_table *template_table,
5892 : : const struct rte_flow_item pattern[],
5893 : : uint8_t pattern_template_index,
5894 : : const struct rte_flow_action actions[],
5895 : : uint8_t actions_template_index,
5896 : : void *user_data,
5897 : : struct rte_flow_error *error);
5898 : :
5899 : : /**
5900 : : * Enqueue rule creation operation.
5901 : : *
5902 : : * @param port_id
5903 : : * Port identifier of Ethernet device.
5904 : : * @param queue_id
5905 : : * Flow queue used to insert the rule.
5906 : : * @param[in] op_attr
5907 : : * Rule creation operation attributes.
5908 : : * @param[in] template_table
5909 : : * Template table to select templates from.
5910 : : * @param[in] rule_index
5911 : : * Rule index in the table.
5912 : : * @param[in] actions
5913 : : * List of actions to be used.
5914 : : * The list order should match the order in the actions template.
5915 : : * @param[in] actions_template_index
5916 : : * Actions template index in the table.
5917 : : * @param[in] user_data
5918 : : * The user data that will be returned on the completion events.
5919 : : * @param[out] error
5920 : : * Perform verbose error reporting if not NULL.
5921 : : * PMDs initialize this structure in case of error only.
5922 : : *
5923 : : * @return
5924 : : * Handle on success, NULL otherwise and rte_errno is set.
5925 : : * The rule handle doesn't mean that the rule has been populated.
5926 : : * Only completion result indicates that if there was success or failure.
5927 : : */
5928 : : struct rte_flow *
5929 : : rte_flow_async_create_by_index(uint16_t port_id,
5930 : : uint32_t queue_id,
5931 : : const struct rte_flow_op_attr *op_attr,
5932 : : struct rte_flow_template_table *template_table,
5933 : : uint32_t rule_index,
5934 : : const struct rte_flow_action actions[],
5935 : : uint8_t actions_template_index,
5936 : : void *user_data,
5937 : : struct rte_flow_error *error);
5938 : :
5939 : : /**
5940 : : * Enqueue rule creation by index with pattern operation.
5941 : : * Packets are only matched if there is a rule inserted at the index.
5942 : : *
5943 : : * @param port_id
5944 : : * Port identifier of Ethernet device.
5945 : : * @param queue_id
5946 : : * Flow queue used to insert the rule.
5947 : : * @param[in] op_attr
5948 : : * Rule creation operation attributes.
5949 : : * @param[in] template_table
5950 : : * Template table to select templates from.
5951 : : * @param[in] rule_index
5952 : : * Rule index in the table.
5953 : : * Inserting a rule to already occupied index results in undefined behavior.
5954 : : * @param[in] pattern
5955 : : * List of pattern items to be used.
5956 : : * The list order should match the order in the pattern template.
5957 : : * The spec is the only relevant member of the item that is being used.
5958 : : * @param[in] pattern_template_index
5959 : : * Pattern template index in the table.
5960 : : * @param[in] actions
5961 : : * List of actions to be used.
5962 : : * The list order should match the order in the actions template.
5963 : : * @param[in] actions_template_index
5964 : : * Actions template index in the table.
5965 : : * @param[in] user_data
5966 : : * The user data that will be returned on the completion events.
5967 : : * @param[out] error
5968 : : * Perform verbose error reporting if not NULL.
5969 : : * PMDs initialize this structure in case of error only.
5970 : : *
5971 : : * @return
5972 : : * Handle on success, NULL otherwise and rte_errno is set.
5973 : : * The rule handle doesn't mean that the rule has been populated.
5974 : : * Only completion result indicates that if there was success or failure.
5975 : : */
5976 : : struct rte_flow *
5977 : : rte_flow_async_create_by_index_with_pattern(uint16_t port_id,
5978 : : uint32_t queue_id,
5979 : : const struct rte_flow_op_attr *op_attr,
5980 : : struct rte_flow_template_table *template_table,
5981 : : uint32_t rule_index,
5982 : : const struct rte_flow_item pattern[],
5983 : : uint8_t pattern_template_index,
5984 : : const struct rte_flow_action actions[],
5985 : : uint8_t actions_template_index,
5986 : : void *user_data,
5987 : : struct rte_flow_error *error);
5988 : :
5989 : : /**
5990 : : * Enqueue rule destruction operation.
5991 : : *
5992 : : * This function enqueues a destruction operation on the queue.
5993 : : * Application should assume that after calling this function
5994 : : * the rule handle is not valid anymore.
5995 : : * Completion indicates the full removal of the rule from the HW.
5996 : : *
5997 : : * @param port_id
5998 : : * Port identifier of Ethernet device.
5999 : : * @param queue_id
6000 : : * Flow queue which is used to destroy the rule.
6001 : : * This must match the queue on which the rule was created.
6002 : : * @param[in] op_attr
6003 : : * Rule destruction operation attributes.
6004 : : * @param[in] flow
6005 : : * Flow handle to be destroyed.
6006 : : * @param[in] user_data
6007 : : * The user data that will be returned on the completion events.
6008 : : * @param[out] error
6009 : : * Perform verbose error reporting if not NULL.
6010 : : * PMDs initialize this structure in case of error only.
6011 : : *
6012 : : * @return
6013 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6014 : : */
6015 : : int
6016 : : rte_flow_async_destroy(uint16_t port_id,
6017 : : uint32_t queue_id,
6018 : : const struct rte_flow_op_attr *op_attr,
6019 : : struct rte_flow *flow,
6020 : : void *user_data,
6021 : : struct rte_flow_error *error);
6022 : :
6023 : : /**
6024 : : * Enqueue rule update operation.
6025 : : *
6026 : : * @param port_id
6027 : : * Port identifier of Ethernet device.
6028 : : * @param queue_id
6029 : : * Flow queue used to insert the rule.
6030 : : * @param[in] op_attr
6031 : : * Rule creation operation attributes.
6032 : : * @param[in] flow
6033 : : * Flow rule to be updated.
6034 : : * @param[in] actions
6035 : : * List of actions to be used.
6036 : : * The list order should match the order in the actions template.
6037 : : * @param[in] actions_template_index
6038 : : * Actions template index in the table.
6039 : : * @param[in] user_data
6040 : : * The user data that will be returned on the completion events.
6041 : : * @param[out] error
6042 : : * Perform verbose error reporting if not NULL.
6043 : : * PMDs initialize this structure in case of error only.
6044 : : *
6045 : : * @return
6046 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6047 : : */
6048 : : int
6049 : : rte_flow_async_actions_update(uint16_t port_id,
6050 : : uint32_t queue_id,
6051 : : const struct rte_flow_op_attr *op_attr,
6052 : : struct rte_flow *flow,
6053 : : const struct rte_flow_action actions[],
6054 : : uint8_t actions_template_index,
6055 : : void *user_data,
6056 : : struct rte_flow_error *error);
6057 : :
6058 : : /**
6059 : : * Push all internally stored rules to the HW.
6060 : : * Postponed rules are rules that were inserted with the postpone flag set.
6061 : : * Can be used to notify the HW about batch of rules prepared by the SW to
6062 : : * reduce the number of communications between the HW and SW.
6063 : : *
6064 : : * @param port_id
6065 : : * Port identifier of Ethernet device.
6066 : : * @param queue_id
6067 : : * Flow queue to be pushed.
6068 : : * @param[out] error
6069 : : * Perform verbose error reporting if not NULL.
6070 : : * PMDs initialize this structure in case of error only.
6071 : : *
6072 : : * @return
6073 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6074 : : */
6075 : : int
6076 : : rte_flow_push(uint16_t port_id,
6077 : : uint32_t queue_id,
6078 : : struct rte_flow_error *error);
6079 : :
6080 : : /**
6081 : : * Asynchronous operation status.
6082 : : */
6083 : : enum rte_flow_op_status {
6084 : : /**
6085 : : * The operation was completed successfully.
6086 : : */
6087 : : RTE_FLOW_OP_SUCCESS,
6088 : : /**
6089 : : * The operation was not completed successfully.
6090 : : */
6091 : : RTE_FLOW_OP_ERROR,
6092 : : };
6093 : :
6094 : : /**
6095 : : * Asynchronous operation result.
6096 : : */
6097 : : __extension__
6098 : : struct rte_flow_op_result {
6099 : : /**
6100 : : * Returns the status of the operation that this completion signals.
6101 : : */
6102 : : enum rte_flow_op_status status;
6103 : : /**
6104 : : * The user data that will be returned on the completion events.
6105 : : */
6106 : : void *user_data;
6107 : : };
6108 : :
6109 : : /**
6110 : : * Pull a rte flow operation.
6111 : : * The application must invoke this function in order to complete
6112 : : * the flow rule offloading and to retrieve the flow rule operation status.
6113 : : *
6114 : : * @param port_id
6115 : : * Port identifier of Ethernet device.
6116 : : * @param queue_id
6117 : : * Flow queue which is used to pull the operation.
6118 : : * @param[out] res
6119 : : * Array of results that will be set.
6120 : : * @param[in] n_res
6121 : : * Maximum number of results that can be returned.
6122 : : * This value is equal to the size of the res array.
6123 : : * @param[out] error
6124 : : * Perform verbose error reporting if not NULL.
6125 : : * PMDs initialize this structure in case of error only.
6126 : : *
6127 : : * @return
6128 : : * Number of results that were pulled,
6129 : : * a negative errno value otherwise and rte_errno is set.
6130 : : */
6131 : : int
6132 : : rte_flow_pull(uint16_t port_id,
6133 : : uint32_t queue_id,
6134 : : struct rte_flow_op_result res[],
6135 : : uint16_t n_res,
6136 : : struct rte_flow_error *error);
6137 : :
6138 : : /**
6139 : : * Enqueue indirect action creation operation.
6140 : : * @see rte_flow_action_handle_create
6141 : : *
6142 : : * @param[in] port_id
6143 : : * Port identifier of Ethernet device.
6144 : : * @param[in] queue_id
6145 : : * Flow queue which is used to create the rule.
6146 : : * @param[in] op_attr
6147 : : * Indirect action creation operation attributes.
6148 : : * @param[in] indir_action_conf
6149 : : * Action configuration for the indirect action object creation.
6150 : : * @param[in] action
6151 : : * Specific configuration of the indirect action object.
6152 : : * @param[in] user_data
6153 : : * The user data that will be returned on the completion events.
6154 : : * @param[out] error
6155 : : * Perform verbose error reporting if not NULL.
6156 : : * PMDs initialize this structure in case of error only.
6157 : : *
6158 : : * @return
6159 : : * A valid handle in case of success, NULL otherwise and rte_errno is set.
6160 : : */
6161 : : struct rte_flow_action_handle *
6162 : : rte_flow_async_action_handle_create(uint16_t port_id,
6163 : : uint32_t queue_id,
6164 : : const struct rte_flow_op_attr *op_attr,
6165 : : const struct rte_flow_indir_action_conf *indir_action_conf,
6166 : : const struct rte_flow_action *action,
6167 : : void *user_data,
6168 : : struct rte_flow_error *error);
6169 : :
6170 : : /**
6171 : : * Enqueue indirect action destruction operation.
6172 : : * The destroy queue must be the same
6173 : : * as the queue on which the action was created.
6174 : : *
6175 : : * @param[in] port_id
6176 : : * Port identifier of Ethernet device.
6177 : : * @param[in] queue_id
6178 : : * Flow queue which is used to destroy the rule.
6179 : : * @param[in] op_attr
6180 : : * Indirect action destruction operation attributes.
6181 : : * @param[in] action_handle
6182 : : * Handle for the indirect action object to be destroyed.
6183 : : * @param[in] user_data
6184 : : * The user data that will be returned on the completion events.
6185 : : * @param[out] error
6186 : : * Perform verbose error reporting if not NULL.
6187 : : * PMDs initialize this structure in case of error only.
6188 : : *
6189 : : * @return
6190 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6191 : : */
6192 : : int
6193 : : rte_flow_async_action_handle_destroy(uint16_t port_id,
6194 : : uint32_t queue_id,
6195 : : const struct rte_flow_op_attr *op_attr,
6196 : : struct rte_flow_action_handle *action_handle,
6197 : : void *user_data,
6198 : : struct rte_flow_error *error);
6199 : :
6200 : : /**
6201 : : * Enqueue indirect action update operation.
6202 : : * @see rte_flow_action_handle_create
6203 : : *
6204 : : * @param[in] port_id
6205 : : * Port identifier of Ethernet device.
6206 : : * @param[in] queue_id
6207 : : * Flow queue which is used to update the rule.
6208 : : * @param[in] op_attr
6209 : : * Indirect action update operation attributes.
6210 : : * @param[in] action_handle
6211 : : * Handle for the indirect action object to be updated.
6212 : : * @param[in] update
6213 : : * Update profile specification used to modify the action pointed by handle.
6214 : : * *update* could be with the same type of the immediate action corresponding
6215 : : * to the *handle* argument when creating, or a wrapper structure includes
6216 : : * action configuration to be updated and bit fields to indicate the member
6217 : : * of fields inside the action to update.
6218 : : * @param[in] user_data
6219 : : * The user data that will be returned on the completion events.
6220 : : * @param[out] error
6221 : : * Perform verbose error reporting if not NULL.
6222 : : * PMDs initialize this structure in case of error only.
6223 : : *
6224 : : * @return
6225 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6226 : : */
6227 : : int
6228 : : rte_flow_async_action_handle_update(uint16_t port_id,
6229 : : uint32_t queue_id,
6230 : : const struct rte_flow_op_attr *op_attr,
6231 : : struct rte_flow_action_handle *action_handle,
6232 : : const void *update,
6233 : : void *user_data,
6234 : : struct rte_flow_error *error);
6235 : :
6236 : : /**
6237 : : * Enqueue indirect action query operation.
6238 : : *
6239 : : * Retrieve action-specific data such as counters.
6240 : : * Data is gathered by special action which may be present/referenced in
6241 : : * more than one flow rule definition.
6242 : : * Data will be available only when completion event returns.
6243 : : *
6244 : : * @see rte_flow_async_action_handle_query
6245 : : *
6246 : : * @param port_id
6247 : : * Port identifier of Ethernet device.
6248 : : * @param[in] queue_id
6249 : : * Flow queue which is used to query the action.
6250 : : * @param[in] op_attr
6251 : : * Indirect action update operation attributes.
6252 : : * @param[in] action_handle
6253 : : * Handle for the action object to query.
6254 : : * @param[in, out] data
6255 : : * Pointer to storage for the associated query data type.
6256 : : * The out data will be available only when completion event returns
6257 : : * from rte_flow_pull.
6258 : : * @param[in] user_data
6259 : : * The user data that will be returned on the completion events.
6260 : : * @param[out] error
6261 : : * Perform verbose error reporting if not NULL. PMDs initialize this
6262 : : * structure in case of error only.
6263 : : *
6264 : : * @return
6265 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6266 : : */
6267 : : int
6268 : : rte_flow_async_action_handle_query(uint16_t port_id,
6269 : : uint32_t queue_id,
6270 : : const struct rte_flow_op_attr *op_attr,
6271 : : const struct rte_flow_action_handle *action_handle,
6272 : : void *data,
6273 : : void *user_data,
6274 : : struct rte_flow_error *error);
6275 : :
6276 : : /**
6277 : : * Query and update operational mode.
6278 : : *
6279 : : * @see rte_flow_action_handle_query_update()
6280 : : * @see rte_flow_async_action_handle_query_update()
6281 : : */
6282 : : enum rte_flow_query_update_mode {
6283 : : RTE_FLOW_QU_QUERY_FIRST = 1, /**< Query before update. */
6284 : : RTE_FLOW_QU_UPDATE_FIRST, /**< Query after update. */
6285 : : };
6286 : :
6287 : : /**
6288 : : * Query and/or update indirect flow action.
6289 : : * If both query and update not NULL, the function atomically
6290 : : * queries and updates indirect action. Query and update are carried in order
6291 : : * specified in the mode parameter.
6292 : : * If ether query or update is NULL, the function executes
6293 : : * complementing operation.
6294 : : *
6295 : : * @param port_id
6296 : : * Port identifier of Ethernet device.
6297 : : * @param handle
6298 : : * Handle for the indirect action object to be updated.
6299 : : * @param update
6300 : : * If not NULL, update profile specification used to modify the action
6301 : : * pointed by handle.
6302 : : * @param query
6303 : : * If not NULL pointer to storage for the associated query data type.
6304 : : * @param mode
6305 : : * Operational mode.
6306 : : * @param error
6307 : : * Perform verbose error reporting if not NULL.
6308 : : * PMDs initialize this structure in case of error only.
6309 : : *
6310 : : * @return
6311 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6312 : : * - (-ENODEV) if *port_id* invalid.
6313 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6314 : : * - (-EINVAL) if *handle* or *mode* invalid or
6315 : : * both *query* and *update* are NULL.
6316 : : */
6317 : : int
6318 : : rte_flow_action_handle_query_update(uint16_t port_id,
6319 : : struct rte_flow_action_handle *handle,
6320 : : const void *update, void *query,
6321 : : enum rte_flow_query_update_mode mode,
6322 : : struct rte_flow_error *error);
6323 : :
6324 : : /**
6325 : : * Enqueue async indirect flow action query and/or update
6326 : : *
6327 : : * @param port_id
6328 : : * Port identifier of Ethernet device.
6329 : : * @param queue_id
6330 : : * Flow queue which is used to update the rule.
6331 : : * @param attr
6332 : : * Indirect action update operation attributes.
6333 : : * @param handle
6334 : : * Handle for the indirect action object to be updated.
6335 : : * @param update
6336 : : * If not NULL, update profile specification used to modify the action
6337 : : * pointed by handle.
6338 : : * @param query
6339 : : * If not NULL, pointer to storage for the associated query data type.
6340 : : * Query result returned on async completion event.
6341 : : * @param mode
6342 : : * Operational mode.
6343 : : * @param user_data
6344 : : * The user data that will be returned on async completion event.
6345 : : * @param error
6346 : : * Perform verbose error reporting if not NULL.
6347 : : * PMDs initialize this structure in case of error only.
6348 : : *
6349 : : * @return
6350 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
6351 : : * - (-ENODEV) if *port_id* invalid.
6352 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6353 : : * - (-EINVAL) if *handle* or *mode* invalid or
6354 : : * both *update* and *query* are NULL.
6355 : : */
6356 : : int
6357 : : rte_flow_async_action_handle_query_update(uint16_t port_id, uint32_t queue_id,
6358 : : const struct rte_flow_op_attr *attr,
6359 : : struct rte_flow_action_handle *handle,
6360 : : const void *update, void *query,
6361 : : enum rte_flow_query_update_mode mode,
6362 : : void *user_data,
6363 : : struct rte_flow_error *error);
6364 : :
6365 : : struct rte_flow_action_list_handle;
6366 : :
6367 : : /**
6368 : : * Configure INDIRECT_LIST flow action.
6369 : : *
6370 : : * @see RTE_FLOW_ACTION_TYPE_INDIRECT_LIST
6371 : : */
6372 : : struct rte_flow_action_indirect_list {
6373 : : /** Indirect action list handle */
6374 : : struct rte_flow_action_list_handle *handle;
6375 : : /**
6376 : : * Flow mutable configuration array.
6377 : : * NULL if the handle has no flow mutable configuration update.
6378 : : * Otherwise, if the handle was created with list A1 / A2 .. An / END
6379 : : * size of conf is n.
6380 : : * conf[i] points to flow mutable update of Ai in the handle
6381 : : * actions list or NULL if Ai has no update.
6382 : : */
6383 : : const void **conf;
6384 : : };
6385 : :
6386 : : /**
6387 : : * Create an indirect flow action object from flow actions list.
6388 : : * The object is identified by a unique handle.
6389 : : * The handle has single state and configuration
6390 : : * across all the flow rules using it.
6391 : : *
6392 : : * @param[in] port_id
6393 : : * The port identifier of the Ethernet device.
6394 : : * @param[in] conf
6395 : : * Action configuration for the indirect action list creation.
6396 : : * @param[in] actions
6397 : : * Specific configuration of the indirect action lists.
6398 : : * @param[out] error
6399 : : * Perform verbose error reporting if not NULL. PMDs initialize this
6400 : : * structure in case of error only.
6401 : : * @return
6402 : : * A valid handle in case of success, NULL otherwise and rte_errno is set
6403 : : * to one of the error codes defined:
6404 : : * - (-ENODEV) if *port_id* invalid.
6405 : : * - (-ENOSYS) if underlying device does not support this functionality.
6406 : : * - (-EIO) if underlying device is removed.
6407 : : * - (-EINVAL) if *actions* list invalid.
6408 : : * - (-ENOTSUP) if *action* list element valid but unsupported.
6409 : : */
6410 : : struct rte_flow_action_list_handle *
6411 : : rte_flow_action_list_handle_create(uint16_t port_id,
6412 : : const
6413 : : struct rte_flow_indir_action_conf *conf,
6414 : : const struct rte_flow_action *actions,
6415 : : struct rte_flow_error *error);
6416 : :
6417 : : /**
6418 : : * Async function call to create an indirect flow action object
6419 : : * from flow actions list.
6420 : : * The object is identified by a unique handle.
6421 : : * The handle has single state and configuration
6422 : : * across all the flow rules using it.
6423 : : *
6424 : : * @param[in] port_id
6425 : : * The port identifier of the Ethernet device.
6426 : : * @param[in] queue_id
6427 : : * Flow queue which is used to update the rule.
6428 : : * @param[in] attr
6429 : : * Indirect action update operation attributes.
6430 : : * @param[in] conf
6431 : : * Action configuration for the indirect action list creation.
6432 : : * @param[in] actions
6433 : : * Specific configuration of the indirect action list.
6434 : : * @param[in] user_data
6435 : : * The user data that will be returned on async completion event.
6436 : : * @param[out] error
6437 : : * Perform verbose error reporting if not NULL. PMDs initialize this
6438 : : * structure in case of error only.
6439 : : * @return
6440 : : * A valid handle in case of success, NULL otherwise and rte_errno is set
6441 : : * to one of the error codes defined:
6442 : : * - (-ENODEV) if *port_id* invalid.
6443 : : * - (-ENOSYS) if underlying device does not support this functionality.
6444 : : * - (-EIO) if underlying device is removed.
6445 : : * - (-EINVAL) if *actions* list invalid.
6446 : : * - (-ENOTSUP) if *action* list element valid but unsupported.
6447 : : */
6448 : : struct rte_flow_action_list_handle *
6449 : : rte_flow_async_action_list_handle_create(uint16_t port_id, uint32_t queue_id,
6450 : : const struct rte_flow_op_attr *attr,
6451 : : const struct rte_flow_indir_action_conf *conf,
6452 : : const struct rte_flow_action *actions,
6453 : : void *user_data,
6454 : : struct rte_flow_error *error);
6455 : :
6456 : : /**
6457 : : * Destroy indirect actions list by handle.
6458 : : *
6459 : : * @param[in] port_id
6460 : : * The port identifier of the Ethernet device.
6461 : : * @param[in] handle
6462 : : * Handle for the indirect actions list to be destroyed.
6463 : : * @param[out] error
6464 : : * Perform verbose error reporting if not NULL. PMDs initialize this
6465 : : * structure in case of error only.
6466 : : * @return
6467 : : * - (0) if success.
6468 : : * - (-ENODEV) if *port_id* invalid.
6469 : : * - (-ENOSYS) if underlying device does not support this functionality.
6470 : : * - (-EIO) if underlying device is removed.
6471 : : * - (-ENOENT) if actions list pointed by *action* handle was not found.
6472 : : * - (-EBUSY) if actions list pointed by *action* handle still used
6473 : : */
6474 : : int
6475 : : rte_flow_action_list_handle_destroy(uint16_t port_id,
6476 : : struct rte_flow_action_list_handle *handle,
6477 : : struct rte_flow_error *error);
6478 : :
6479 : : /**
6480 : : * Enqueue indirect action list destruction operation.
6481 : : * The destroy queue must be the same
6482 : : * as the queue on which the action was created.
6483 : : *
6484 : : * @param[in] port_id
6485 : : * Port identifier of Ethernet device.
6486 : : * @param[in] queue_id
6487 : : * Flow queue which is used to destroy the rule.
6488 : : * @param[in] op_attr
6489 : : * Indirect action destruction operation attributes.
6490 : : * @param[in] handle
6491 : : * Handle for the indirect action object to be destroyed.
6492 : : * @param[in] user_data
6493 : : * The user data that will be returned on the completion events.
6494 : : * @param[out] error
6495 : : * Perform verbose error reporting if not NULL.
6496 : : * PMDs initialize this structure in case of error only.
6497 : : *
6498 : : * @return
6499 : : * - (0) if success.
6500 : : * - (-ENODEV) if *port_id* invalid.
6501 : : * - (-ENOSYS) if underlying device does not support this functionality.
6502 : : * - (-EIO) if underlying device is removed.
6503 : : * - (-ENOENT) if actions list pointed by *action* handle was not found.
6504 : : * - (-EBUSY) if actions list pointed by *action* handle still used
6505 : : */
6506 : : int
6507 : : rte_flow_async_action_list_handle_destroy
6508 : : (uint16_t port_id, uint32_t queue_id,
6509 : : const struct rte_flow_op_attr *op_attr,
6510 : : struct rte_flow_action_list_handle *handle,
6511 : : void *user_data, struct rte_flow_error *error);
6512 : :
6513 : : /**
6514 : : * Query and/or update indirect flow actions list.
6515 : : * If both query and update not NULL, the function atomically
6516 : : * queries and updates indirect action. Query and update are carried in order
6517 : : * specified in the mode parameter.
6518 : : * If ether query or update is NULL, the function executes
6519 : : * complementing operation.
6520 : : *
6521 : : * @param port_id
6522 : : * Port identifier of Ethernet device.
6523 : : * @param handle
6524 : : * Handle for the indirect actions list object to be updated.
6525 : : * @param update
6526 : : * If the action list handle was created from n actions A1 / A2 ... An / END
6527 : : * non-NULL update parameter is an array [U1, U2, ... Un] where Ui points to
6528 : : * Ai update context or NULL if Ai should not be updated.
6529 : : * @param query
6530 : : * If the action list handle was created from n actions A1 / A2 ... An / END
6531 : : * non-NULL query parameter is an array [Q1, Q2, ... Qn] where Qi points to
6532 : : * Ai query context or NULL if Ai should not be queried.
6533 : : * @param mode
6534 : : * Operational mode.
6535 : : * @param error
6536 : : * Perform verbose error reporting if not NULL.
6537 : : * PMDs initialize this structure in case of error only.
6538 : : *
6539 : : * @return
6540 : : * - (0) if success.
6541 : : * - (-ENODEV) if *port_id* invalid.
6542 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6543 : : * - (-EINVAL) if *handle* or *mode* invalid or
6544 : : * both *query* and *update* are NULL.
6545 : : */
6546 : : int
6547 : : rte_flow_action_list_handle_query_update(uint16_t port_id,
6548 : : const struct rte_flow_action_list_handle *handle,
6549 : : const void **update, void **query,
6550 : : enum rte_flow_query_update_mode mode,
6551 : : struct rte_flow_error *error);
6552 : :
6553 : : /**
6554 : : * Enqueue async indirect flow actions list query and/or update
6555 : : * If both query and update not NULL, the function atomically
6556 : : * queries and updates indirect action. Query and update are carried in order
6557 : : * specified in the mode parameter.
6558 : : * If ether query or update is NULL, the function executes
6559 : : * complementing operation.
6560 : : *
6561 : : * @param port_id
6562 : : * Port identifier of Ethernet device.
6563 : : * @param queue_id
6564 : : * Flow queue which is used to update the rule.
6565 : : * @param attr
6566 : : * Indirect action update operation attributes.
6567 : : * @param handle
6568 : : * Handle for the indirect actions list object to be updated.
6569 : : * @param update
6570 : : * If the action list handle was created from n actions A1 / A2 ... An / END
6571 : : * non-NULL update parameter is an array [U1, U2, ... Un] where Ui points to
6572 : : * Ai update context or NULL if Ai should not be updated.
6573 : : * @param query
6574 : : * If the action list handle was created from n actions A1 / A2 ... An / END
6575 : : * non-NULL query parameter is an array [Q1, Q2, ... Qn] where Qi points to
6576 : : * Ai query context or NULL if Ai should not be queried.
6577 : : * Query result returned on async completion event.
6578 : : * @param mode
6579 : : * Operational mode.
6580 : : * @param user_data
6581 : : * The user data that will be returned on async completion event.
6582 : : * @param error
6583 : : * Perform verbose error reporting if not NULL.
6584 : : * PMDs initialize this structure in case of error only.
6585 : : *
6586 : : * @return
6587 : : * - (0) if success.
6588 : : * - (-ENODEV) if *port_id* invalid.
6589 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6590 : : * - (-EINVAL) if *handle* or *mode* invalid or
6591 : : * both *update* and *query* are NULL.
6592 : : */
6593 : : int
6594 : : rte_flow_async_action_list_handle_query_update(uint16_t port_id, uint32_t queue_id,
6595 : : const struct rte_flow_op_attr *attr,
6596 : : const struct rte_flow_action_list_handle *handle,
6597 : : const void **update, void **query,
6598 : : enum rte_flow_query_update_mode mode,
6599 : : void *user_data,
6600 : : struct rte_flow_error *error);
6601 : :
6602 : : /**
6603 : : * Calculate the hash for a given pattern in a given table as
6604 : : * calculated by the HW.
6605 : : *
6606 : : * @param port_id
6607 : : * Port identifier of Ethernet device.
6608 : : * @param table
6609 : : * The table the SW wishes to simulate.
6610 : : * @param pattern
6611 : : * The values to be used in the hash calculation.
6612 : : * @param pattern_template_index
6613 : : * The pattern index in the table to be used for the calculation.
6614 : : * @param hash
6615 : : * Used to return the calculated hash.
6616 : : * @param error
6617 : : * Perform verbose error reporting if not NULL.
6618 : : * PMDs initialize this structure in case of error only.
6619 : : *
6620 : : * @return
6621 : : * - (0) if success.
6622 : : * - (-ENODEV) if *port_id* invalid.
6623 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6624 : : */
6625 : : int
6626 : : rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table *table,
6627 : : const struct rte_flow_item pattern[], uint8_t pattern_template_index,
6628 : : uint32_t *hash, struct rte_flow_error *error);
6629 : :
6630 : : /**
6631 : : * Destination field type for the hash calculation, when encap action is used.
6632 : : * The encap field implies the size, meaning XXX_SRC_PORT hash len is 2 bytes,
6633 : : * while XXX_NVGRE_FLOW_ID hash len is 1 byte.
6634 : : *
6635 : : * @see function rte_flow_calc_encap_hash
6636 : : */
6637 : : enum rte_flow_encap_hash_field {
6638 : : /** Calculate hash placed in UDP source port field. */
6639 : : RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT,
6640 : : /** Calculate hash placed in NVGRE flow ID field. */
6641 : : RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID,
6642 : : };
6643 : :
6644 : : /**
6645 : : * Simulate HW hash calculation that is done when an encap action is being used.
6646 : : * This hash can be stored in tunnel outer header to improve packet distribution.
6647 : : *
6648 : : * @param[in] port_id
6649 : : * Port identifier of Ethernet device.
6650 : : * @param[in] pattern
6651 : : * The values to be used in the hash calculation.
6652 : : * @param[in] dest_field
6653 : : * Type of destination field for hash calculation.
6654 : : * @param[in] hash_len
6655 : : * The length of the hash pointer in bytes. Should be according to dest_field.
6656 : : * @param[out] hash
6657 : : * Used to return the calculated hash. It will be written in network order,
6658 : : * so hash[0] is the MSB.
6659 : : * The number of bytes is based on the destination field type.
6660 : : * @param[out] error
6661 : : * Perform verbose error reporting if not NULL.
6662 : : * PMDs initialize this structure in case of error only.
6663 : : *
6664 : : * @return
6665 : : * - (0) if success.
6666 : : * - (-ENODEV) if *port_id* invalid.
6667 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6668 : : * - (-EINVAL) if *pattern* doesn't hold enough information to calculate the hash
6669 : : * or the dest is not supported.
6670 : : */
6671 : : int
6672 : : rte_flow_calc_encap_hash(uint16_t port_id, const struct rte_flow_item pattern[],
6673 : : enum rte_flow_encap_hash_field dest_field, uint8_t hash_len,
6674 : : uint8_t *hash, struct rte_flow_error *error);
6675 : :
6676 : : /**
6677 : : * Update template table for new flow rules capacity.
6678 : : *
6679 : : * @param port_id
6680 : : * Port identifier of Ethernet device.
6681 : : * @param table
6682 : : * Template table to modify.
6683 : : * @param nb_rules
6684 : : * New flow rules capacity.
6685 : : * @param error
6686 : : * Perform verbose error reporting if not NULL.
6687 : : * PMDs initialize this structure in case of error only.
6688 : : *
6689 : : * @return
6690 : : * - (0) if success.
6691 : : * - (-ENODEV) if *port_id* invalid.
6692 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6693 : : * - (-EINVAL) if *table* is not resizable or
6694 : : * *table* resize to *nb_rules* is not supported or
6695 : : * unrecoverable *table* error.
6696 : : */
6697 : : int
6698 : : rte_flow_template_table_resize(uint16_t port_id,
6699 : : struct rte_flow_template_table *table,
6700 : : uint32_t nb_rules,
6701 : : struct rte_flow_error *error);
6702 : : /**
6703 : : * Update *rule* for the new *table* configuration after table resize.
6704 : : * Must be called for each *rule* created before *table* resize.
6705 : : * If called for *rule* created after *table* resize returns success.
6706 : : *
6707 : : * @param port_id
6708 : : * Port identifier of Ethernet device.
6709 : : * @param queue
6710 : : * Flow queue for async operation.
6711 : : * @param attr
6712 : : * Async operation attributes.
6713 : : * @param rule
6714 : : * Flow rule to update.
6715 : : * @param user_data
6716 : : * The user data that will be returned on async completion event.
6717 : : * @param error
6718 : : * Perform verbose error reporting if not NULL.
6719 : : * PMDs initialize this structure in case of error only.
6720 : : *
6721 : : * @return
6722 : : * - (0) if success.
6723 : : * - (-ENODEV) if *port_id* invalid.
6724 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6725 : : * - (-EINVAL) if *table* was not resized.
6726 : : * If *rule* cannot be updated after *table* resize,
6727 : : * unrecoverable *table* error.
6728 : : */
6729 : : int
6730 : : rte_flow_async_update_resized(uint16_t port_id, uint32_t queue,
6731 : : const struct rte_flow_op_attr *attr,
6732 : : struct rte_flow *rule, void *user_data,
6733 : : struct rte_flow_error *error);
6734 : :
6735 : : /**
6736 : : * Resume normal operational mode after table was resized and
6737 : : * table rules were updated for the new table configuration.
6738 : : *
6739 : : * @param port_id
6740 : : * Port identifier of Ethernet device.
6741 : : * @param table
6742 : : * Template table that undergoing resize operation.
6743 : : * @param error
6744 : : * Perform verbose error reporting if not NULL.
6745 : : * PMDs initialize this structure in case of error only.
6746 : : *
6747 : : * @return
6748 : : * - (0) if success.
6749 : : * - (-ENODEV) if *port_id* invalid.
6750 : : * - (-ENOTSUP) if underlying device does not support this functionality.
6751 : : * - (-EBUSY) if not all *table* rules were updated.
6752 : : * - (-EINVAL) if *table* cannot complete table resize,
6753 : : * unrecoverable error.
6754 : : */
6755 : : int
6756 : : rte_flow_template_table_resize_complete(uint16_t port_id,
6757 : : struct rte_flow_template_table *table,
6758 : : struct rte_flow_error *error);
6759 : :
6760 : : #ifdef __cplusplus
6761 : : }
6762 : : #endif
6763 : :
6764 : : #endif /* RTE_FLOW_H_ */
|