Skip to contentSkip to conversation

examples/flow_filtering: add more snippets

PATCH Superseded Shani Peretz 2 participants 5 messages Sep 19, 2025 – Mar 25 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/flow_filtering: add more snippets

Added the following snippets:
- Steering by Integrity Check Flags
- Match packet type
- ECN in IP Header Modification
- Random Match
- VXLAN-GPE Header Fields Matching
- VXLAN-GBP Header Fields Matching
- NVGRE Matching
- NAT64 Action Usage

---
 examples/flow_filtering/meson.build           |   8 +
 .../flow_filtering/snippets/snippet_NAT64.c   | 130 +++++++++++++
 .../flow_filtering/snippets/snippet_NAT64.h   |  45 +++++
 .../snippets/snippet_match_integrity_flags.c  | 101 ++++++++++
 .../snippets/snippet_match_integrity_flags.h  |  47 +++++
 .../snippets/snippet_match_nvgre.c            | 179 ++++++++++++++++++
 .../snippets/snippet_match_nvgre.h            |  40 ++++
 .../snippets/snippet_match_packet_type.c      | 129 +++++++++++++
 .../snippets/snippet_match_packet_type.h      |  45 +++++
 .../snippets/snippet_match_vxlan_gbp.c        | 154 +++++++++++++++
 .../snippets/snippet_match_vxlan_gbp.h        |  33 ++++
 .../snippets/snippet_match_vxlan_gpe.c        | 149 +++++++++++++++
 .../snippets/snippet_match_vxlan_gpe.h        |  32 ++++
 .../snippets/snippet_modify_ecn.c             |  60 ++++++
 .../snippets/snippet_modify_ecn.h             |  32 ++++
 .../snippets/snippet_random_match.c           | 157 +++++++++++++++
 .../snippets/snippet_random_match.h           |  33 ++++
 17 files changed, 1374 insertions(+)
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.c
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.c
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.h
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.c
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.h
examples/flow_filtering/meson.build +8 -0
index d62d3eddc2..87e0e3591c 100644
@@ -15,10 +15,18 @@ sources = files(
         'jump_flow.c',
         'snippets/snippet_match_ipv4.c',
         'snippets/snippet_match_gre.c',
+        'snippets/snippet_match_integrity_flags.c',
         'snippets/snippet_match_mpls.c',
         'snippets/snippet_match_nsh.c',
+        'snippets/snippet_match_nvgre.c',
+        'snippets/snippet_match_packet_type.c',
         'snippets/snippet_match_port_affinity.c',
         'snippets/snippet_match_roce_ib_bth.c',
+        'snippets/snippet_match_vxlan_gbp.c',
+        'snippets/snippet_match_vxlan_gpe.c',
+        'snippets/snippet_modify_ecn.c',
+        'snippets/snippet_NAT64.c',
+        'snippets/snippet_random_match.c',
         'snippets/snippet_re_route_to_kernel.c',
         'snippets/snippet_switch_granularity.c',
 )
examples/flow_filtering/snippets/snippet_NAT64.c new file +130 -0

130 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_NAT64.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.c new file +101 -0

101 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.h new file +47 -0

47 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.c new file +179 -0

179 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.h new file +40 -0
new file mode 100644
index 0000000000..2bf01ce5cd
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_NVGRE_H
+#define SNIPPET_MATCH_NVGRE_H
+
+/* NVGRE Matching
+ * PMD supports matching all NVGRE fields in HWS, including:
+ * _k_s_rsvd0_ver
+ * protocol
+ * tni
+ * flow_id
+ *
+ *  The following example shows how to build the arrays for pattern and rule
+ *  to match the NVGRE packets with tni + flow_id + inner udp_src:
+ *  ETH / IPV4 / NVGRE(TNI+FLOWID) / ETH / IPV4 / UDP(SRC).
+ */
+
+#define MAX_PATTERN_NUM		8 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_nvgre(void);
+#define snippet_init snippet_init_nvgre
+
+void
+snippet_match_nvgre_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_nvgre_create_actions
+
+void
+snippet_match_nvgre_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_nvgre_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_nvgre_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_nvgre_create_table
+
+
+#endif /* SNIPPET_MATCH_NVGRE_H */
examples/flow_filtering/snippets/snippet_match_packet_type.c new file +129 -0

129 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_packet_type.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c new file +154 -0

154 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h new file +33 -0
new file mode 100644
index 0000000000..a50674b746
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GBP_H
+#define SNIPPET_MATCH_VXLAN_GBP_H
+
+/* VXLAN-GBP Header Fields Matching
+ * Added support of matching VXLAN-GBP header fields in the PMD,
+ * such as VNI and flags (first 8 bits), group policy ID and reserved field 0.
+ */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gbp(void);
+#define snippet_init snippet_init_vxlan_gbp
+
+void
+snippet_match_vxlan_gbp_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gbp_create_actions
+
+void
+snippet_match_vxlan_gbp_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gbp_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gbp_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gbp_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GBP_H */
examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c new file +149 -0

149 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h new file +32 -0
new file mode 100644
index 0000000000..63c5f3b61b
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GPE_H
+#define SNIPPET_MATCH_VXLAN_GPE_H
+
+#include <rte_flow.h>
+
+/* VXLAN-GPE Header Fields Matching */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gpe(void);
+#define snippet_init snippet_init_vxlan_gpe
+
+void
+snippet_match_vxlan_gpe_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gpe_create_actions
+
+void
+snippet_match_vxlan_gpe_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gpe_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gpe_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gpe_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GPE_H */
examples/flow_filtering/snippets/snippet_modify_ecn.c new file +60 -0

60 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_modify_ecn.h new file +32 -0
new file mode 100644
index 0000000000..e2a78adea2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MODIFY_ECN_H
+#define SNIPPET_MODIFY_ECN_H
+
+/* ECN in IP Header Modification
+ * ECN field in the IPv4/IPv6 header can now be modified using the modify field action
+ * which now can be modified in the meter policy.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      3 /* Maximal number of actions for this example. */
+
+void
+snippet_init_modify_ecn(void);
+#define snippet_init snippet_init_modify_ecn
+
+void
+snippet_match_modify_ecn_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_modify_ecn_create_actions
+
+void
+snippet_match_modify_ecn_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_modify_ecn_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_modify_ecn_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_modify_ecn_create_table
+
+#endif /* SNIPPET_MODIFY_ECN_H */
examples/flow_filtering/snippets/snippet_random_match.c new file +157 -0

157 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_random_match.h new file +33 -0
new file mode 100644
index 0000000000..1c6bb42577
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_RANDOM_MATCH_H
+#define SNIPPET_RANDOM_MATCH_H
+
+
+/* Random Match
+ * Add support for random matching 16 bits in template async API.
+ * This value is not based on the packet data/headers.
+ * Application shouldn't assume that this value is kept during the lifetime of the packet.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      2 /* Maximal number of actions for this example. */
+
+static void
+snippet_init_random_match(void);
+#define snippet_init snippet_init_random_match
+
+static void
+snippet_match_random_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_random_create_actions
+
+static void
+snippet_match_random_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_random_create_patterns
+
+static struct rte_flow_template_table *
+snippet_match_random_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_random_create_table
+#endif /* SNIPPET_RANDOM_MATCH_H */
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 examples/flow_filtering: add more snippets

Added the following snippets:
- Steering by Integrity Check Flags
- Match packet type
- ECN in IP Header Modification
- Random Match
- VXLAN-GPE Header Fields Matching
- VXLAN-GBP Header Fields Matching
- NVGRE Matching
- NAT64 Action Usage

--------------
v2: fix compilation errors

---
 examples/flow_filtering/meson.build           |   8 +
 .../flow_filtering/snippets/snippet_NAT64.c   | 130 +++++++++++++
 .../flow_filtering/snippets/snippet_NAT64.h   |  45 +++++
 .../snippets/snippet_match_integrity_flags.c  | 101 ++++++++++
 .../snippets/snippet_match_integrity_flags.h  |  47 +++++
 .../snippets/snippet_match_nvgre.c            | 179 ++++++++++++++++++
 .../snippets/snippet_match_nvgre.h            |  40 ++++
 .../snippets/snippet_match_packet_type.c      | 129 +++++++++++++
 .../snippets/snippet_match_packet_type.h      |  45 +++++
 .../snippets/snippet_match_vxlan_gbp.c        | 151 +++++++++++++++
 .../snippets/snippet_match_vxlan_gbp.h        |  33 ++++
 .../snippets/snippet_match_vxlan_gpe.c        | 149 +++++++++++++++
 .../snippets/snippet_match_vxlan_gpe.h        |  32 ++++
 .../snippets/snippet_modify_ecn.c             |  60 ++++++
 .../snippets/snippet_modify_ecn.h             |  32 ++++
 .../snippets/snippet_random_match.c           | 157 +++++++++++++++
 .../snippets/snippet_random_match.h           |  33 ++++
 17 files changed, 1371 insertions(+)
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.c
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.c
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.h
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.c
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.h
examples/flow_filtering/meson.build +8 -0
index d62d3eddc2..87e0e3591c 100644
@@ -15,10 +15,18 @@ sources = files(
         'jump_flow.c',
         'snippets/snippet_match_ipv4.c',
         'snippets/snippet_match_gre.c',
+        'snippets/snippet_match_integrity_flags.c',
         'snippets/snippet_match_mpls.c',
         'snippets/snippet_match_nsh.c',
+        'snippets/snippet_match_nvgre.c',
+        'snippets/snippet_match_packet_type.c',
         'snippets/snippet_match_port_affinity.c',
         'snippets/snippet_match_roce_ib_bth.c',
+        'snippets/snippet_match_vxlan_gbp.c',
+        'snippets/snippet_match_vxlan_gpe.c',
+        'snippets/snippet_modify_ecn.c',
+        'snippets/snippet_NAT64.c',
+        'snippets/snippet_random_match.c',
         'snippets/snippet_re_route_to_kernel.c',
         'snippets/snippet_switch_granularity.c',
 )
examples/flow_filtering/snippets/snippet_NAT64.c new file +130 -0

130 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_NAT64.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.c new file +101 -0

101 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.h new file +47 -0

47 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.c new file +179 -0

179 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.h new file +40 -0
new file mode 100644
index 0000000000..2bf01ce5cd
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_NVGRE_H
+#define SNIPPET_MATCH_NVGRE_H
+
+/* NVGRE Matching
+ * PMD supports matching all NVGRE fields in HWS, including:
+ * _k_s_rsvd0_ver
+ * protocol
+ * tni
+ * flow_id
+ *
+ *  The following example shows how to build the arrays for pattern and rule
+ *  to match the NVGRE packets with tni + flow_id + inner udp_src:
+ *  ETH / IPV4 / NVGRE(TNI+FLOWID) / ETH / IPV4 / UDP(SRC).
+ */
+
+#define MAX_PATTERN_NUM		8 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_nvgre(void);
+#define snippet_init snippet_init_nvgre
+
+void
+snippet_match_nvgre_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_nvgre_create_actions
+
+void
+snippet_match_nvgre_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_nvgre_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_nvgre_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_nvgre_create_table
+
+
+#endif /* SNIPPET_MATCH_NVGRE_H */
examples/flow_filtering/snippets/snippet_match_packet_type.c new file +129 -0

129 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_packet_type.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c new file +151 -0

151 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h new file +33 -0
new file mode 100644
index 0000000000..a50674b746
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GBP_H
+#define SNIPPET_MATCH_VXLAN_GBP_H
+
+/* VXLAN-GBP Header Fields Matching
+ * Added support of matching VXLAN-GBP header fields in the PMD,
+ * such as VNI and flags (first 8 bits), group policy ID and reserved field 0.
+ */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gbp(void);
+#define snippet_init snippet_init_vxlan_gbp
+
+void
+snippet_match_vxlan_gbp_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gbp_create_actions
+
+void
+snippet_match_vxlan_gbp_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gbp_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gbp_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gbp_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GBP_H */
examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c new file +149 -0

149 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h new file +32 -0
new file mode 100644
index 0000000000..63c5f3b61b
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GPE_H
+#define SNIPPET_MATCH_VXLAN_GPE_H
+
+#include <rte_flow.h>
+
+/* VXLAN-GPE Header Fields Matching */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gpe(void);
+#define snippet_init snippet_init_vxlan_gpe
+
+void
+snippet_match_vxlan_gpe_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gpe_create_actions
+
+void
+snippet_match_vxlan_gpe_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gpe_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gpe_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gpe_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GPE_H */
examples/flow_filtering/snippets/snippet_modify_ecn.c new file +60 -0

60 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_modify_ecn.h new file +32 -0
new file mode 100644
index 0000000000..e2a78adea2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MODIFY_ECN_H
+#define SNIPPET_MODIFY_ECN_H
+
+/* ECN in IP Header Modification
+ * ECN field in the IPv4/IPv6 header can now be modified using the modify field action
+ * which now can be modified in the meter policy.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      3 /* Maximal number of actions for this example. */
+
+void
+snippet_init_modify_ecn(void);
+#define snippet_init snippet_init_modify_ecn
+
+void
+snippet_match_modify_ecn_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_modify_ecn_create_actions
+
+void
+snippet_match_modify_ecn_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_modify_ecn_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_modify_ecn_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_modify_ecn_create_table
+
+#endif /* SNIPPET_MODIFY_ECN_H */
examples/flow_filtering/snippets/snippet_random_match.c new file +157 -0

157 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_random_match.h new file +33 -0
new file mode 100644
index 0000000000..1c6bb42577
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_RANDOM_MATCH_H
+#define SNIPPET_RANDOM_MATCH_H
+
+
+/* Random Match
+ * Add support for random matching 16 bits in template async API.
+ * This value is not based on the packet data/headers.
+ * Application shouldn't assume that this value is kept during the lifetime of the packet.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      2 /* Maximal number of actions for this example. */
+
+static void
+snippet_init_random_match(void);
+#define snippet_init snippet_init_random_match
+
+static void
+snippet_match_random_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_random_create_actions
+
+static void
+snippet_match_random_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_random_create_patterns
+
+static struct rte_flow_template_table *
+snippet_match_random_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_random_create_table
+#endif /* SNIPPET_RANDOM_MATCH_H */
Signature · 1 line
2.43.0
#2 lore raw

13/11/2025 11:13, Shani Peretz:

Quoted 10 lines

Added the following snippets:
- Steering by Integrity Check Flags
- Match packet type
- ECN in IP Header Modification
- Random Match
- VXLAN-GPE Header Fields Matching
- VXLAN-GBP Header Fields Matching
- NVGRE Matching
- NAT64 Action Usage

Quoted 4 lines

--------------
v2: fix compilation errors

There are still some issues but I fail to understand why:

/usr/bin/ld: build/snippet_NAT64.o: in function `snippet_match_nat64_create_actions':
snippet_NAT64.c:(.text+0x43): undefined reference to create_jump_flow' /usr/bin/ld: build/snippet_match_nvgre.o: in function snippet_match_nvgre_create_actions':
snippet_match_nvgre.c:(.text+0x44): undefined reference to create_jump_flow' /usr/bin/ld: build/snippet_match_vxlan_gpe.o: in function snippet_match_vxlan_gpe_create_actions':
snippet_match_vxlan_gpe.c:(.text+0x44): undefined reference to `create_jump_flow'

#3 lore raw

PATCH v3 1/1 examples/flow_filtering: add more snippets

In reply to Shani Peretz

Added the following snippets:
- Steering by Integrity Check Flags
- Match packet type
- ECN in IP Header Modification
- Random Match
- VXLAN-GPE Header Fields Matching
- VXLAN-GBP Header Fields Matching
- NVGRE Matching
- NAT64 Action Usage

-----------------
v3: fix makefile
v2: fix compilation errors

---
 examples/flow_filtering/Makefile              |   2 +-
 examples/flow_filtering/meson.build           |   8 +
 .../flow_filtering/snippets/snippet_NAT64.c   | 130 +++++++++++++
 .../flow_filtering/snippets/snippet_NAT64.h   |  45 +++++
 .../snippets/snippet_match_integrity_flags.c  | 101 ++++++++++
 .../snippets/snippet_match_integrity_flags.h  |  47 +++++
 .../snippets/snippet_match_nvgre.c            | 179 ++++++++++++++++++
 .../snippets/snippet_match_nvgre.h            |  40 ++++
 .../snippets/snippet_match_packet_type.c      | 129 +++++++++++++
 .../snippets/snippet_match_packet_type.h      |  45 +++++
 .../snippets/snippet_match_vxlan_gbp.c        | 151 +++++++++++++++
 .../snippets/snippet_match_vxlan_gbp.h        |  33 ++++
 .../snippets/snippet_match_vxlan_gpe.c        | 149 +++++++++++++++
 .../snippets/snippet_match_vxlan_gpe.h        |  32 ++++
 .../snippets/snippet_modify_ecn.c             |  60 ++++++
 .../snippets/snippet_modify_ecn.h             |  32 ++++
 .../snippets/snippet_random_match.c           | 157 +++++++++++++++
 .../snippets/snippet_random_match.h           |  33 ++++
 18 files changed, 1372 insertions(+), 1 deletion(-)
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.c
 create mode 100644 examples/flow_filtering/snippets/snippet_NAT64.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_integrity_flags.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_nvgre.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_packet_type.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c
 create mode 100644 examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.c
 create mode 100644 examples/flow_filtering/snippets/snippet_modify_ecn.h
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.c
 create mode 100644 examples/flow_filtering/snippets/snippet_random_match.h
examples/flow_filtering/Makefile +1 -1
index f1e10b14dd..36d2660714 100644
@@ -3,7 +3,7 @@
 
 APP = flow
 
-SRCS-y := main.c flow_skeleton.c
+SRCS-y := main.c flow_skeleton.c jump_flow.c
 subdir := snippets
 snippet_objects := $(addprefix build/,$(notdir $(patsubst %.c,%.o,$(wildcard $(subdir)/*.c))))
 
examples/flow_filtering/meson.build +8 -0
index d62d3eddc2..87e0e3591c 100644
@@ -15,10 +15,18 @@ sources = files(
         'jump_flow.c',
         'snippets/snippet_match_ipv4.c',
         'snippets/snippet_match_gre.c',
+        'snippets/snippet_match_integrity_flags.c',
         'snippets/snippet_match_mpls.c',
         'snippets/snippet_match_nsh.c',
+        'snippets/snippet_match_nvgre.c',
+        'snippets/snippet_match_packet_type.c',
         'snippets/snippet_match_port_affinity.c',
         'snippets/snippet_match_roce_ib_bth.c',
+        'snippets/snippet_match_vxlan_gbp.c',
+        'snippets/snippet_match_vxlan_gpe.c',
+        'snippets/snippet_modify_ecn.c',
+        'snippets/snippet_NAT64.c',
+        'snippets/snippet_random_match.c',
         'snippets/snippet_re_route_to_kernel.c',
         'snippets/snippet_switch_granularity.c',
 )
examples/flow_filtering/snippets/snippet_NAT64.c new file +130 -0

130 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_NAT64.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.c new file +101 -0

101 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_integrity_flags.h new file +47 -0

47 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.c new file +179 -0

179 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_nvgre.h new file +40 -0
new file mode 100644
index 0000000000..2bf01ce5cd
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_NVGRE_H
+#define SNIPPET_MATCH_NVGRE_H
+
+/* NVGRE Matching
+ * PMD supports matching all NVGRE fields in HWS, including:
+ * _k_s_rsvd0_ver
+ * protocol
+ * tni
+ * flow_id
+ *
+ *  The following example shows how to build the arrays for pattern and rule
+ *  to match the NVGRE packets with tni + flow_id + inner udp_src:
+ *  ETH / IPV4 / NVGRE(TNI+FLOWID) / ETH / IPV4 / UDP(SRC).
+ */
+
+#define MAX_PATTERN_NUM		8 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_nvgre(void);
+#define snippet_init snippet_init_nvgre
+
+void
+snippet_match_nvgre_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_nvgre_create_actions
+
+void
+snippet_match_nvgre_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_nvgre_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_nvgre_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_nvgre_create_table
+
+
+#endif /* SNIPPET_MATCH_NVGRE_H */
examples/flow_filtering/snippets/snippet_match_packet_type.c new file +129 -0

129 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_packet_type.h new file +45 -0

45 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.c new file +151 -0

151 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gbp.h new file +33 -0
new file mode 100644
index 0000000000..a50674b746
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GBP_H
+#define SNIPPET_MATCH_VXLAN_GBP_H
+
+/* VXLAN-GBP Header Fields Matching
+ * Added support of matching VXLAN-GBP header fields in the PMD,
+ * such as VNI and flags (first 8 bits), group policy ID and reserved field 0.
+ */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gbp(void);
+#define snippet_init snippet_init_vxlan_gbp
+
+void
+snippet_match_vxlan_gbp_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gbp_create_actions
+
+void
+snippet_match_vxlan_gbp_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gbp_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gbp_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gbp_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GBP_H */
examples/flow_filtering/snippets/snippet_match_vxlan_gpe.c new file +149 -0

149 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_match_vxlan_gpe.h new file +32 -0
new file mode 100644
index 0000000000..63c5f3b61b
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MATCH_VXLAN_GPE_H
+#define SNIPPET_MATCH_VXLAN_GPE_H
+
+#include <rte_flow.h>
+
+/* VXLAN-GPE Header Fields Matching */
+
+#define MAX_PATTERN_NUM		5 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */
+
+void
+snippet_init_vxlan_gpe(void);
+#define snippet_init snippet_init_vxlan_gpe
+
+void
+snippet_match_vxlan_gpe_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_vxlan_gpe_create_actions
+
+void
+snippet_match_vxlan_gpe_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_vxlan_gpe_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_vxlan_gpe_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_vxlan_gpe_create_table
+
+
+#endif /* SNIPPET_MATCH_VXLAN_GPE_H */
examples/flow_filtering/snippets/snippet_modify_ecn.c new file +60 -0

60 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_modify_ecn.h new file +32 -0
new file mode 100644
index 0000000000..e2a78adea2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_MODIFY_ECN_H
+#define SNIPPET_MODIFY_ECN_H
+
+/* ECN in IP Header Modification
+ * ECN field in the IPv4/IPv6 header can now be modified using the modify field action
+ * which now can be modified in the meter policy.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      3 /* Maximal number of actions for this example. */
+
+void
+snippet_init_modify_ecn(void);
+#define snippet_init snippet_init_modify_ecn
+
+void
+snippet_match_modify_ecn_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_modify_ecn_create_actions
+
+void
+snippet_match_modify_ecn_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_modify_ecn_create_patterns
+
+struct rte_flow_template_table *
+snippet_match_modify_ecn_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_modify_ecn_create_table
+
+#endif /* SNIPPET_MODIFY_ECN_H */
examples/flow_filtering/snippets/snippet_random_match.c new file +157 -0

157 lines not on this page · raw message

examples/flow_filtering/snippets/snippet_random_match.h new file +33 -0
new file mode 100644
index 0000000000..1c6bb42577
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 2022 NVIDIA Corporation & Affiliates
+ */
+
+#ifndef SNIPPET_RANDOM_MATCH_H
+#define SNIPPET_RANDOM_MATCH_H
+
+
+/* Random Match
+ * Add support for random matching 16 bits in template async API.
+ * This value is not based on the packet data/headers.
+ * Application shouldn't assume that this value is kept during the lifetime of the packet.
+ */
+
+#define MAX_PATTERN_NUM     3 /* Maximal number of patterns for this example. */
+#define MAX_ACTION_NUM      2 /* Maximal number of actions for this example. */
+
+static void
+snippet_init_random_match(void);
+#define snippet_init snippet_init_random_match
+
+static void
+snippet_match_random_create_actions(uint16_t port_id, struct rte_flow_action *action);
+#define snippet_skeleton_flow_create_actions snippet_match_random_create_actions
+
+static void
+snippet_match_random_create_patterns(struct rte_flow_item *pattern);
+#define snippet_skeleton_flow_create_patterns snippet_match_random_create_patterns
+
+static struct rte_flow_template_table *
+snippet_match_random_create_table(uint16_t port_id, struct rte_flow_error *error);
+#define snippet_skeleton_flow_create_table snippet_match_random_create_table
+#endif /* SNIPPET_RANDOM_MATCH_H */
Signature · 1 line
2.43.0
#4 lore raw

02/12/2025 10:50, Shani Peretz:

Quoted 11 lines

Added the following snippets:
- Steering by Integrity Check Flags
- Match packet type
- ECN in IP Header Modification
- Random Match
- VXLAN-GPE Header Fields Matching
- VXLAN-GBP Header Fields Matching
- NVGRE Matching
- NAT64 Action Usage

Applied, thanks.