[PATCH 2/8] app/testpmd: add support for NAT64 in the command line

Bing Zhao bingz at nvidia.com
Wed Dec 27 10:07:25 CET 2023


The type of NAT64 action will be parsed.

Usage example with template API:
  ...
  flow actions_template 0 create ingress actions_template_id 1 \
    template count / nat64 / jump / end mask count / nat64 / \
    jump / end
  flow template_table 0 create group 1 priority 0 ingress table_id \
    0x1 rules_number 8 pattern_template 0 actions_template 1
  flow queue 0 create 2 template_table 0x1 pattern_template 0 \
    actions_template 0 postpone no pattern eth / end actions count / \
    nat64 type 1 / jump group 2 / end
   ...

Signed-off-by: Bing Zhao <bingz at nvidia.com>
---
 app/test-pmd/cmdline_flow.c                 | 23 +++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  4 ++++
 2 files changed, 27 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index ce71818705..6fb252d3d5 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -728,6 +728,8 @@ enum index {
 	ACTION_IPV6_EXT_PUSH,
 	ACTION_IPV6_EXT_PUSH_INDEX,
 	ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
+	ACTION_NAT64,
+	ACTION_NAT64_MODE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -2193,6 +2195,7 @@ static const enum index next_action[] = {
 	ACTION_QUOTA_QU,
 	ACTION_IPV6_EXT_REMOVE,
 	ACTION_IPV6_EXT_PUSH,
+	ACTION_NAT64,
 	ZERO,
 };
 
@@ -2534,6 +2537,12 @@ static const enum index action_represented_port[] = {
 	ZERO,
 };
 
+static const enum index action_nat64[] = {
+	ACTION_NAT64_MODE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_set_raw_encap_decap(struct context *, const struct token *,
 				     const char *, unsigned int,
 				     void *, unsigned int);
@@ -7022,6 +7031,20 @@ static const struct token token_list[] = {
 		.call = parse_vc_action_ipv6_ext_push_index,
 		.comp = comp_set_ipv6_ext_index,
 	},
+	[ACTION_NAT64] = {
+		.name = "nat64",
+		.help = "NAT64 IP headers translation",
+		.priv = PRIV_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
+		.next = NEXT(action_nat64),
+		.call = parse_vc,
+	},
+	[ACTION_NAT64_MODE] = {
+		.name = "type",
+		.help = "NAT64 translation type",
+		.next = NEXT(action_nat64, NEXT_ENTRY(COMMON_UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
+		.call = parse_vc_conf,
+	},
 	/* Top level command. */
 	[SET] = {
 		.name = "set",
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 447e28e694..01044043d0 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -4151,6 +4151,10 @@ This section lists supported actions and their attributes, if any.
   - ``src_ptr``: pointer to source immediate value.
   - ``width``: number of bits to copy.
 
+- ``nat64``: NAT64 IP headers translation
+
+  - ``type {unsigned}``: NAT64 translation type
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.25.1



More information about the dev mailing list