[dpdk-dev] [PATCH v2 2/3] app/testpmd: add commands of modify MAC address

Jack Min jackmin at mellanox.com
Wed Oct 10 15:11:42 CEST 2018


add commands to support following actions:

- RTE_FLOW_ACTION_TYPE_SET_MAC_SRC
- RTE_FLOW_ACTION_TYPE_SET_MAC_DST

Signed-off-by: Xiaoyu Min <jackmin at mellanox.com>
Acked-by: Yongseok Koh <yskoh at mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 50 +++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 ++++
 2 files changed, 58 insertions(+)

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index fae825462..d06e75799 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -258,6 +258,10 @@ enum index {
 	ACTION_DEC_TTL,
 	ACTION_SET_TTL,
 	ACTION_SET_TTL_TTL,
+	ACTION_SET_MAC_SRC,
+	ACTION_SET_MAC_SRC_MAC_SRC,
+	ACTION_SET_MAC_DST,
+	ACTION_SET_MAC_DST_MAC_DST,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -839,6 +843,8 @@ static const enum index next_action[] = {
 	ACTION_SET_TP_DST,
 	ACTION_DEC_TTL,
 	ACTION_SET_TTL,
+	ACTION_SET_MAC_SRC,
+	ACTION_SET_MAC_DST,
 	ZERO,
 };
 
@@ -947,6 +953,12 @@ static const enum index action_set_ipv4_src[] = {
 	ZERO,
 };
 
+static const enum index action_set_mac_src[] = {
+	ACTION_SET_MAC_SRC_MAC_SRC,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static const enum index action_set_ipv4_dst[] = {
 	ACTION_SET_IPV4_DST_IPV4_DST,
 	ACTION_NEXT,
@@ -989,6 +1001,12 @@ static const enum index action_jump[] = {
 	ZERO,
 };
 
+static const enum index action_set_mac_dst[] = {
+	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2654,6 +2672,38 @@ static const struct token token_list[] = {
 			     (struct rte_flow_action_set_ttl, ttl_value)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_SET_MAC_SRC] = {
+		.name = "set_mac_src",
+		.help = "set source mac address",
+		.priv = PRIV_ACTION(SET_MAC_SRC,
+			sizeof(struct rte_flow_action_set_mac)),
+		.next = NEXT(action_set_mac_src),
+		.call = parse_vc,
+	},
+	[ACTION_SET_MAC_SRC_MAC_SRC] = {
+		.name = "mac_addr",
+		.help = "new source mac address",
+		.next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_set_mac, mac_addr)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_SET_MAC_DST] = {
+		.name = "set_mac_dst",
+		.help = "set destination mac address",
+		.priv = PRIV_ACTION(SET_MAC_DST,
+			sizeof(struct rte_flow_action_set_mac)),
+		.next = NEXT(action_set_mac_dst),
+		.call = parse_vc,
+	},
+	[ACTION_SET_MAC_DST_MAC_DST] = {
+		.name = "mac_addr",
+		.help = "new destination mac address to set",
+		.next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			     (struct rte_flow_action_set_mac, mac_addr)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 16cd4468e..ab478fa96 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3733,6 +3733,14 @@ This section lists supported actions and their attributes, if any.
 - ``set_ttl``: Set TTL value with specificed value
   - ``ttl_value {unsigned}``: The new TTL value to be set
 
+- ``set_mac_src``: set source MAC address
+
+  - ``mac_addr {MAC-48}``: new source MAC address
+
+- ``set_mac_dst``: set destination MAC address
+
+  - ``mac_addr {MAC-48}``: new destination MAC address
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.17.1



More information about the dev mailing list