Skip to contentSkip to conversation

app/testpmd: add function to display port supported ptypes

PATCH In review [email protected] 3 participants 8 messages Sep 1, 2019 – Oct 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: add function to display port supported ptypes

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display ptypes supported by the given port in different layers.

---
 app/test-pmd/cmdline.c                      | 111 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 2 files changed, 118 insertions(+)
app/test-pmd/cmdline.c +111 -0
index 56783aa..839c1b0 100644
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices probed.\n\n"
 		);
@@ -18820,6 +18824,112 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */
+struct cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t resv_mask = 0xf0000000;
+	uint16_t port_id = res->port_id;
+	int max_layer_ptypes = 16;
+	uint32_t ptypes[max_layer_ptypes];
+	char buf[256], ltype[32];
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != resv_mask) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+						       max_layer_ptypes);
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -19058,6 +19168,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
index 313e070..1acd958 100644
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.8.4
#1 lore raw

Hi Vamsi,

Quoted 69 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Sunday, September 1, 2019 5:08 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Vamsi Attunuru <[email protected]>
Subject: [dpdk-dev] [PATCH v1 1/1] app/testpmd: add function to display port supported ptypes

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display ptypes supported by the given port in different layers.

---
 app/test-pmd/cmdline.c                      | 111 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 2 files changed, 118 insertions(+)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

56783aa..839c1b0 100644

app/test-pmd/cmdline.c +4 -0
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices

probed.\n\n"

app/test-pmd/cmdline.c +27 -0
 		);
@@ -18820,6 +18824,112 @@ cmdline_parse_inst_t cmd_show_tx_metadata =
 {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */ struct
+cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");

app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_show_tx_metadata = · line 18864

Quoted 10 lines
app/test-pmd/cmdline.c +10 -0
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t resv_mask = 0xf0000000;

It would be better to replace 0xf0000000 with a macro.

app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_show_tx_metadata = { · line 18867

Quoted 4 lines
app/test-pmd/cmdline.c +4 -0
+	uint16_t port_id = res->port_id;
+	int max_layer_ptypes = 16;
+	uint32_t ptypes[max_layer_ptypes];
+	char buf[256], ltype[32];

It would be better to replace the numbers 16, 256 and 32 with macros.

Quoted 99 lines
app/test-pmd/cmdline.c +65 -0
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL,
 0);
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != resv_mask) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+						       max_layer_ptypes);
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /*

*****************************************************************
*************** */

/* list of instructions */

app/test-pmd/cmdline.c +1 -0
@@ -19058,6 +19168,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, diff --git

a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 313e070..1acd958 100644

doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -1
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
--
Quoted 1 line

2.8.4

The 19.11 release notes should also be updated to announce the new command.

Regards,

Bernard.

#2 lore raw

PATCH v2 1/1 app/testpmd: add console cmd to show port supported ptypes

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

---
V2 Changes:
* Replaced numbers with macros.
* Updated 19.11 release notes with command details.
* Corrected patch title.

 app/test-pmd/cmdline.c                      | 113 ++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_19_11.rst      |   4 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 3 files changed, 124 insertions(+)
app/test-pmd/cmdline.c +113 -0
index 56783aa..c0f77aa 100644
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices probed.\n\n"
 		);
@@ -18820,6 +18824,114 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */
+struct cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+#define RSVD_PTYPE_MASK       0xf0000000
+#define MAX_PTYPES_PER_LAYER  16
+#define LTYPE_NAMESIZE        32
+#define PTYPE_NAMESIZE        256
+	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
+	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
+	uint16_t port_id = res->port_id;
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != RSVD_PTYPE_MASK) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+						       MAX_PTYPES_PER_LAYER);
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -19058,6 +19170,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
doc/guides/rel_notes/release_19_11.rst +4 -0
index 8490d89..61e726c 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added ability to print port supported ptypes on testpmd app.**
+
+  Added a console command to testpmd app, ``show port (port_id) ptypes`` which
+  gives ability to print port supported ptypes in different protocol layers.
 
 Removed Items
 -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
index 313e070..1acd958 100644
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.8.4
#3 lore raw

Re: [dpdk-dev] [PATCH v2 1/1] app/testpmd: add console cmd to show port supported ptypes

Hi Vamsi,

Quoted 188 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, September 13, 2019 6:41 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Vamsi Attunuru <[email protected]>
Subject: [dpdk-dev] [PATCH v2 1/1] app/testpmd: add console cmd to show port supported ptypes

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

---
V2 Changes:
* Replaced numbers with macros.
* Updated 19.11 release notes with command details.
* Corrected patch title.

 app/test-pmd/cmdline.c                      | 113
++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_19_11.rst      |   4 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 3 files changed, 124 insertions(+)
app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0 -0

56783aa..c0f77aa 100644

app/test-pmd/cmdline.c +4 -0
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void
 *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices

probed.\n\n"

app/test-pmd/cmdline.c +12 -0
 		);
@@ -18820,6 +18824,114 @@ cmdline_parse_inst_t
 cmd_show_tx_metadata = {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */ struct
+cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show

=

app/test-pmd/cmdline.c +8 -0
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id

=

app/test-pmd/cmdline.c +4 -0
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t

cmd_show_port_supported_ptypes_ptypes =

app/test-pmd/cmdline.c +15 -0
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+#define RSVD_PTYPE_MASK       0xf0000000
+#define MAX_PTYPES_PER_LAYER  16
+#define LTYPE_NAMESIZE        32
+#define PTYPE_NAMESIZE        256
+	struct cmd_show_port_supported_ptypes_result *res =

parsed_result;

app/test-pmd/cmdline.c +7 -0
+	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
+	uint16_t port_id = res->port_id;
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask,

NULL, 0);

app/test-pmd/cmdline.c +34 -0
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != RSVD_PTYPE_MASK) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+

MAX_PTYPES_PER_LAYER);

app/test-pmd/cmdline.c +28 -0
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /*

**********************************************************
********************** */

/* list of instructions */

app/test-pmd/cmdline.c +1 -0
@@ -19058,6 +19170,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, diff --git

a/doc/guides/rel_notes/release_19_11.rst
b/doc/guides/rel_notes/release_19_11.rst
index 8490d89..61e726c 100644

doc/guides/rel_notes/release_19_11.rst +0 -0
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
 

=========================================================

Quoted 1 line

+* **Added ability to print port supported ptypes on testpmd app.**

Suggest rewording above line to something like the following:

* **Added command to print port supported ptypes to testpmd application.**

Quoted 27 lines
doc/guides/rel_notes/release_19_11.rst +3 -0
+
+  Added a console command to testpmd app, ``show port (port_id)
+ ptypes`` which  gives ability to print port supported ptypes in different

protocol layers.

Removed Items
-------------

doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -1
index 313e070..1acd958 100644
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
--
Quoted 1 line

2.8.4

Regards,

Bernard.

#4 lore raw

PATCH v3 1/1 app/testpmd: add console cmd to show port supported ptypes

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

---
V3 Change:
* Reworded documentation in release notes.

V2 Changes:
* Replaced numbers with macros.
* Updated 19.11 release notes with command details.
* Corrected patch title.

 app/test-pmd/cmdline.c                      | 113 ++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_19_11.rst      |   4 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 3 files changed, 124 insertions(+)
app/test-pmd/cmdline.c +113 -0
index 56783aa..c0f77aa 100644
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices probed.\n\n"
 		);
@@ -18820,6 +18824,114 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */
+struct cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+#define RSVD_PTYPE_MASK       0xf0000000
+#define MAX_PTYPES_PER_LAYER  16
+#define LTYPE_NAMESIZE        32
+#define PTYPE_NAMESIZE        256
+	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
+	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
+	uint16_t port_id = res->port_id;
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != RSVD_PTYPE_MASK) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+						       MAX_PTYPES_PER_LAYER);
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -19058,6 +19170,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
doc/guides/rel_notes/release_19_11.rst +4 -0
index 8490d89..ed03ffa 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added command to print port supported ptypes on testpmd application.**
+
+  Added a console command to testpmd app, ``show port (port_id) ptypes`` which
+  gives ability to print port supported ptypes in different protocol layers.
 
 Removed Items
 -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
index 313e070..1acd958 100644
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.8.4
#5 lore raw

PATCH v3 1/1 app/testpmd: add console cmd to show port supported ptypes

In reply to [email protected]

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

---
V3 Change:
* Reworded documentation in release notes.

V2 Changes:
* Replaced numbers with macros.
* Updated 19.11 release notes with command details.
* Corrected patch title.

 app/test-pmd/cmdline.c                      | 113 ++++++++++++++++++++++++++++
 doc/guides/rel_notes/release_19_11.rst      |   4 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   7 ++
 3 files changed, 124 insertions(+)
app/test-pmd/cmdline.c +113 -0
index 56783aa..c0f77aa 100644
@@ -238,6 +238,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"    Show Tx metadata value set"
 			" for a specific port\n\n"
 
+			"show port (port_id) ptypes\n"
+			"    Show port supported ptypes"
+			" for a specific port\n\n"
+
 			"show device info (<identifier>|all)"
 			"       Show general information about devices probed.\n\n"
 		);
@@ -18820,6 +18824,114 @@ cmdline_parse_inst_t cmd_show_tx_metadata = {
 	},
 };
 
+/* show port supported ptypes */
+
+/* Common result structure for show port ptypes */
+struct cmd_show_port_supported_ptypes_result {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t ptypes;
+};
+
+/* Common CLI fields for show port ptypes */
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 show, "show");
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port, "port");
+cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 port_id, UINT16);
+cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_show_port_supported_ptypes_result,
+		 ptypes, "ptypes");
+
+static void
+cmd_show_port_supported_ptypes_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+#define RSVD_PTYPE_MASK       0xf0000000
+#define MAX_PTYPES_PER_LAYER  16
+#define LTYPE_NAMESIZE        32
+#define PTYPE_NAMESIZE        256
+	struct cmd_show_port_supported_ptypes_result *res = parsed_result;
+	char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
+	uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
+	uint32_t ptypes[MAX_PTYPES_PER_LAYER];
+	uint16_t port_id = res->port_id;
+	int ret, i;
+
+	ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
+	if (ret < 0)
+		return;
+
+	while (ptype_mask != RSVD_PTYPE_MASK) {
+
+		switch (ptype_mask) {
+		case RTE_PTYPE_L2_MASK:
+			strlcpy(ltype, "L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L3_MASK:
+			strlcpy(ltype, "L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_L4_MASK:
+			strlcpy(ltype, "L4", sizeof(ltype));
+			break;
+		case RTE_PTYPE_TUNNEL_MASK:
+			strlcpy(ltype, "Tunnel", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L2_MASK:
+			strlcpy(ltype, "Inner L2", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L3_MASK:
+			strlcpy(ltype, "Inner L3", sizeof(ltype));
+			break;
+		case RTE_PTYPE_INNER_L4_MASK:
+			strlcpy(ltype, "Inner L4", sizeof(ltype));
+			break;
+		default:
+			return;
+		}
+
+		ret = rte_eth_dev_get_supported_ptypes(res->port_id,
+						       ptype_mask, ptypes,
+						       MAX_PTYPES_PER_LAYER);
+
+		if (ret > 0)
+			printf("Supported %s ptypes:\n", ltype);
+		else
+			printf("%s ptypes unsupported\n", ltype);
+
+		for (i = 0; i < ret; ++i) {
+			rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
+			printf("%s\n", buf);
+		}
+
+		ptype_mask <<= 4;
+	}
+}
+
+cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
+	.f = cmd_show_port_supported_ptypes_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> ptypes",
+	.tokens = {
+		(void *)&cmd_show_port_supported_ptypes_show,
+		(void *)&cmd_show_port_supported_ptypes_port,
+		(void *)&cmd_show_port_supported_ptypes_port_id,
+		(void *)&cmd_show_port_supported_ptypes_ptypes,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -19058,6 +19170,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,
 	(cmdline_parse_inst_t *)&cmd_clear_vf_stats,
+	(cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
 	(cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
doc/guides/rel_notes/release_19_11.rst +4 -0
index 8490d89..ed03ffa 100644
@@ -56,6 +56,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added command to print port supported ptypes on testpmd application.**
+
+  Added a console command to testpmd app, ``show port (port_id) ptypes`` which
+  gives ability to print port supported ptypes in different protocol layers.
 
 Removed Items
 -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +7 -0
index 313e070..1acd958 100644
@@ -467,6 +467,13 @@ Show Tx metadata value set for a specific port::
 
    testpmd> show port (port_id) tx_metadata
 
+show port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Show ptypes supported for a specific port::
+
+   testpmd> show port (port_id) ptypes
+
 show device info
 ~~~~~~~~~~~~~~~~
 
Signature · 1 line
2.8.4
Acked-by on v3 1/1
#6 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] app/testpmd: add console cmd to show port supported ptypes

Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, September 19, 2019 4:50 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Vamsi Attunuru <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/1] app/testpmd: add console cmd to show port supported ptypes

Quoted 6 lines

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

Applied
#7 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] app/testpmd: add console cmd to show port supported ptypes

Quoted 11 lines · Bernard
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, September 19, 2019 4:50 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Wu, Jingjing <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Vamsi Attunuru <[email protected]>
Subject: [dpdk-dev] [PATCH v3 1/1] app/testpmd: add console cmd to show port supported ptypes

Quoted 9 lines
Quoted 6 lines

From: Vamsi Attunuru <[email protected]>

Patch adds a runtime function to display port supported ptypes in different layers.

Applied to dpdk-next-net/master, thanks.