[v15,7/7] app/testpmd: add command to set supported ptype mask
Checks
Commit Message
From: Pavan Nikhilesh <pbhagavatula@marvell.com>
Add command to set supported ptype mask.
Usage:
set port <port_id> ptype_mask <ptype_mask>
Disable ptype parsing by default.
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
---
app/test-pmd/cmdline.c | 80 +++++++++++++++++++++
app/test-pmd/testpmd.c | 6 ++
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++
3 files changed, 93 insertions(+)
Comments
Hi Pavan,
> -----Original Message-----
> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
> Sent: Tuesday, October 29, 2019 3:37 PM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>; arybchenko@solarflare.com;
> jerinj@marvell.com; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>; Mcnamara, John
> <john.mcnamara@intel.com>; Kovacevic, Marko
> <marko.kovacevic@intel.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
> Subject: [dpdk-dev] [PATCH v15 7/7] app/testpmd: add command to set
> supported ptype mask
>
> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
> Add command to set supported ptype mask.
> Usage:
> set port <port_id> ptype_mask <ptype_mask>
>
> Disable ptype parsing by default.
>
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> ---
> app/test-pmd/cmdline.c | 80 +++++++++++++++++++++
> app/test-pmd/testpmd.c | 6 ++
> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++
> 3 files changed, 93 insertions(+)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 447806991..9f0356b50 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
The help text should be updated to describe the new command at line 240 in cmdline.c
> @@ -18915,6 +18915,85 @@ cmdline_parse_inst_t
> cmd_show_port_supported_ptypes = {
> },
> };
>
> +/* Common result structure for set port ptypes */ struct
> +cmd_set_port_supported_ptypes_result {
> + cmdline_fixed_string_t set;
> + cmdline_fixed_string_t port;
> + portid_t port_id;
> + cmdline_fixed_string_t ptype_mask;
> + uint32_t mask;
> +};
> +
> +/* Common CLI fields for set port ptypes */
> +cmdline_parse_token_string_t cmd_set_port_supported_ptypes_set =
> + TOKEN_STRING_INITIALIZER
> + (struct cmd_set_port_supported_ptypes_result,
> + set, "set");
> +cmdline_parse_token_string_t cmd_set_port_supported_ptypes_port =
> + TOKEN_STRING_INITIALIZER
> + (struct cmd_set_port_supported_ptypes_result,
> + port, "port");
> +cmdline_parse_token_num_t cmd_set_port_supported_ptypes_port_id =
> + TOKEN_NUM_INITIALIZER
> + (struct cmd_set_port_supported_ptypes_result,
> + port_id, UINT16);
> +cmdline_parse_token_string_t
> cmd_set_port_supported_ptypes_mask_str =
> + TOKEN_STRING_INITIALIZER
> + (struct cmd_set_port_supported_ptypes_result,
> + ptype_mask, "ptype_mask");
> +cmdline_parse_token_num_t
> cmd_set_port_supported_ptypes_mask_u32 =
> + TOKEN_NUM_INITIALIZER
> + (struct cmd_set_port_supported_ptypes_result,
> + mask, UINT32);
> +
> +static void
> +cmd_set_port_supported_ptypes_parsed(
> + void *parsed_result,
> + __attribute__((unused)) struct cmdline *cl,
> + __attribute__((unused)) void *data)
> +{
> + struct cmd_set_port_supported_ptypes_result *res =
> parsed_result;
> +#define PTYPE_NAMESIZE 256
> + char ptype_name[PTYPE_NAMESIZE];
> + uint16_t port_id = res->port_id;
> + uint32_t ptype_mask = res->mask;
> + int ret, i;
> +
> + ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask,
> NULL, 0);
> + if (ret <= 0) {
> + printf("Port %d doesn't support any ptypes.\n", port_id);
> + return;
> + }
> +
> + uint32_t ptypes[ret];
Might be better to move above variable declaration to top of function with the other declarations.
> + ret = rte_eth_dev_set_supported_ptypes(port_id, ptype_mask,
> ptypes,
> + ret);
> + if (ret <= 0) {
> + printf("Unable to set requested ptypes for Port %d\n",
> port_id);
> + return;
> + }
> +
> + printf("Successfully set following ptypes for Port %d\n", port_id);
> + for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
> + rte_get_ptype_name(ptypes[i], ptype_name,
> sizeof(ptype_name));
> + printf("%s\n", ptype_name);
> + }
> +}
> +
> +cmdline_parse_inst_t cmd_set_port_supported_ptypes = {
> + .f = cmd_set_port_supported_ptypes_parsed,
> + .data = NULL,
> + .help_str = "set port <port_id> ptype_mask <mask>",
> + .tokens = {
> + (void *)&cmd_set_port_supported_ptypes_set,
> + (void *)&cmd_set_port_supported_ptypes_port,
> + (void *)&cmd_set_port_supported_ptypes_port_id,
> + (void *)&cmd_set_port_supported_ptypes_mask_str,
> + (void *)&cmd_set_port_supported_ptypes_mask_u32,
> + NULL,
> + },
> +};
> +
> /*
> **********************************************************
> ********************** */
>
> /* list of instructions */
> @@ -19154,6 +19233,7 @@ cmdline_parse_ctx_t main_ctx[] = {
> (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_set_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/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> 38acbc58a..fd2c04d64 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -2028,6 +2028,7 @@ start_port(portid_t pid)
> queueid_t qi;
> struct rte_port *port;
> struct rte_ether_addr mac_addr;
> + static uint8_t clr_ptypes = 1;
>
> if (port_id_is_invalid(pid, ENABLED_WARN))
> return 0;
> @@ -2157,6 +2158,11 @@ start_port(portid_t pid)
> }
> }
> configure_rxtx_dump_callbacks(verbose_level);
> + if (clr_ptypes) {
> + clr_ptypes = 0;
> + rte_eth_dev_set_supported_ptypes(pi,
> RTE_PTYPE_UNKNOWN,
> + NULL, 0);
> + }
> /* start port */
> if (rte_eth_dev_start(pi) < 0) {
> printf("Fail to start port %d\n", pi); diff --git
> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index c68a742eb..9c4dc92aa 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -472,6 +472,13 @@ Show ptypes supported for a specific port::
>
> testpmd> show port (port_id) ptypes
>
> +set port supported ptypes
> +~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Inform packet types classification interested in for a specific port::
The description of the command is not very clear.
Perhaps something like the following would be better:
"set packet types classification for a specific port::"
> +
> + testpmd> set port (port_id) ptypes_mask (mask)
> +
> show device info
> ~~~~~~~~~~~~~~~~
>
> --
> 2.17.1
Regards,
Bernard.
Hi Bernard,
>Hi Pavan,
>
>> -----Original Message-----
>> From: pbhagavatula@marvell.com <pbhagavatula@marvell.com>
>> Sent: Tuesday, October 29, 2019 3:37 PM
>> To: Yigit, Ferruh <ferruh.yigit@intel.com>;
>arybchenko@solarflare.com;
>> jerinj@marvell.com; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu,
>Jingjing
>> <jingjing.wu@intel.com>; Iremonger, Bernard
>> <bernard.iremonger@intel.com>; Mcnamara, John
>> <john.mcnamara@intel.com>; Kovacevic, Marko
>> <marko.kovacevic@intel.com>
>> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@marvell.com>
>> Subject: [dpdk-dev] [PATCH v15 7/7] app/testpmd: add command to
>set
>> supported ptype mask
>>
>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>
>> Add command to set supported ptype mask.
>> Usage:
>> set port <port_id> ptype_mask <ptype_mask>
>>
>> Disable ptype parsing by default.
>>
>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>> ---
>> app/test-pmd/cmdline.c | 80 +++++++++++++++++++++
>> app/test-pmd/testpmd.c | 6 ++
>> doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 ++
>> 3 files changed, 93 insertions(+)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
>> 447806991..9f0356b50 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>
>The help text should be updated to describe the new command at line
>240 in cmdline.c
>
Will add in v16.
>> @@ -18915,6 +18915,85 @@ cmdline_parse_inst_t
>> cmd_show_port_supported_ptypes = {
>> },
>> };
>>
>> +/* Common result structure for set port ptypes */ struct
>> +cmd_set_port_supported_ptypes_result {
>> + cmdline_fixed_string_t set;
>> + cmdline_fixed_string_t port;
>> + portid_t port_id;
>> + cmdline_fixed_string_t ptype_mask;
>> + uint32_t mask;
>> +};
>> +
>> +/* Common CLI fields for set port ptypes */
>> +cmdline_parse_token_string_t
>cmd_set_port_supported_ptypes_set =
>> + TOKEN_STRING_INITIALIZER
>> + (struct cmd_set_port_supported_ptypes_result,
>> + set, "set");
>> +cmdline_parse_token_string_t
>cmd_set_port_supported_ptypes_port =
>> + TOKEN_STRING_INITIALIZER
>> + (struct cmd_set_port_supported_ptypes_result,
>> + port, "port");
>> +cmdline_parse_token_num_t
>cmd_set_port_supported_ptypes_port_id =
>> + TOKEN_NUM_INITIALIZER
>> + (struct cmd_set_port_supported_ptypes_result,
>> + port_id, UINT16);
>> +cmdline_parse_token_string_t
>> cmd_set_port_supported_ptypes_mask_str =
>> + TOKEN_STRING_INITIALIZER
>> + (struct cmd_set_port_supported_ptypes_result,
>> + ptype_mask, "ptype_mask");
>> +cmdline_parse_token_num_t
>> cmd_set_port_supported_ptypes_mask_u32 =
>> + TOKEN_NUM_INITIALIZER
>> + (struct cmd_set_port_supported_ptypes_result,
>> + mask, UINT32);
>> +
>> +static void
>> +cmd_set_port_supported_ptypes_parsed(
>> + void *parsed_result,
>> + __attribute__((unused)) struct cmdline *cl,
>> + __attribute__((unused)) void *data)
>> +{
>> + struct cmd_set_port_supported_ptypes_result *res =
>> parsed_result;
>> +#define PTYPE_NAMESIZE 256
>> + char ptype_name[PTYPE_NAMESIZE];
>> + uint16_t port_id = res->port_id;
>> + uint32_t ptype_mask = res->mask;
>> + int ret, i;
>> +
>> + ret = rte_eth_dev_get_supported_ptypes(port_id,
>ptype_mask,
>> NULL, 0);
>> + if (ret <= 0) {
>> + printf("Port %d doesn't support any ptypes.\n",
>port_id);
>> + return;
>> + }
>> +
>> + uint32_t ptypes[ret];
>
>Might be better to move above variable declaration to top of function
>with the other declarations.
I intentionally placed it here as the array size depends on ret and there is
no readily available macro for max number of packet types.
>
>> + ret = rte_eth_dev_set_supported_ptypes(port_id,
>ptype_mask,
>> ptypes,
>> + ret);
>> + if (ret <= 0) {
>> + printf("Unable to set requested ptypes for Port %d\n",
>> port_id);
>> + return;
>> + }
>> +
>> + printf("Successfully set following ptypes for Port %d\n",
>port_id);
>> + for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
>> + rte_get_ptype_name(ptypes[i], ptype_name,
>> sizeof(ptype_name));
>> + printf("%s\n", ptype_name);
>> + }
>> +}
>> +
>> +cmdline_parse_inst_t cmd_set_port_supported_ptypes = {
>> + .f = cmd_set_port_supported_ptypes_parsed,
>> + .data = NULL,
>> + .help_str = "set port <port_id> ptype_mask <mask>",
>> + .tokens = {
>> + (void *)&cmd_set_port_supported_ptypes_set,
>> + (void *)&cmd_set_port_supported_ptypes_port,
>> + (void *)&cmd_set_port_supported_ptypes_port_id,
>> + (void *)&cmd_set_port_supported_ptypes_mask_str,
>> + (void *)&cmd_set_port_supported_ptypes_mask_u32,
>> + NULL,
>> + },
>> +};
>> +
>> /*
>>
>******************************************************
>****
>> ********************** */
>>
>> /* list of instructions */
>> @@ -19154,6 +19233,7 @@ cmdline_parse_ctx_t main_ctx[] = {
>> (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_set_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/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
>> 38acbc58a..fd2c04d64 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -2028,6 +2028,7 @@ start_port(portid_t pid)
>> queueid_t qi;
>> struct rte_port *port;
>> struct rte_ether_addr mac_addr;
>> + static uint8_t clr_ptypes = 1;
>>
>> if (port_id_is_invalid(pid, ENABLED_WARN))
>> return 0;
>> @@ -2157,6 +2158,11 @@ start_port(portid_t pid)
>> }
>> }
>> configure_rxtx_dump_callbacks(verbose_level);
>> + if (clr_ptypes) {
>> + clr_ptypes = 0;
>> + rte_eth_dev_set_supported_ptypes(pi,
>> RTE_PTYPE_UNKNOWN,
>> + NULL, 0);
>> + }
>> /* start port */
>> if (rte_eth_dev_start(pi) < 0) {
>> printf("Fail to start port %d\n", pi); diff --git
>> a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> index c68a742eb..9c4dc92aa 100644
>> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
>> @@ -472,6 +472,13 @@ Show ptypes supported for a specific port::
>>
>> testpmd> show port (port_id) ptypes
>>
>> +set port supported ptypes
>> +~~~~~~~~~~~~~~~~~~~~~~~~~
>> +
>> +Inform packet types classification interested in for a specific port::
>
>The description of the command is not very clear.
>Perhaps something like the following would be better:
>
>"set packet types classification for a specific port::"
Sure will update in v16
>
>> +
>> + testpmd> set port (port_id) ptypes_mask (mask)
>> +
>> show device info
>> ~~~~~~~~~~~~~~~~
>>
>> --
>> 2.17.1
>
>Regards,
>
>Bernard.
Thanks,
Pavan.
@@ -18915,6 +18915,85 @@ cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
},
};
+/* Common result structure for set port ptypes */
+struct cmd_set_port_supported_ptypes_result {
+ cmdline_fixed_string_t set;
+ cmdline_fixed_string_t port;
+ portid_t port_id;
+ cmdline_fixed_string_t ptype_mask;
+ uint32_t mask;
+};
+
+/* Common CLI fields for set port ptypes */
+cmdline_parse_token_string_t cmd_set_port_supported_ptypes_set =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_set_port_supported_ptypes_result,
+ set, "set");
+cmdline_parse_token_string_t cmd_set_port_supported_ptypes_port =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_set_port_supported_ptypes_result,
+ port, "port");
+cmdline_parse_token_num_t cmd_set_port_supported_ptypes_port_id =
+ TOKEN_NUM_INITIALIZER
+ (struct cmd_set_port_supported_ptypes_result,
+ port_id, UINT16);
+cmdline_parse_token_string_t cmd_set_port_supported_ptypes_mask_str =
+ TOKEN_STRING_INITIALIZER
+ (struct cmd_set_port_supported_ptypes_result,
+ ptype_mask, "ptype_mask");
+cmdline_parse_token_num_t cmd_set_port_supported_ptypes_mask_u32 =
+ TOKEN_NUM_INITIALIZER
+ (struct cmd_set_port_supported_ptypes_result,
+ mask, UINT32);
+
+static void
+cmd_set_port_supported_ptypes_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_set_port_supported_ptypes_result *res = parsed_result;
+#define PTYPE_NAMESIZE 256
+ char ptype_name[PTYPE_NAMESIZE];
+ uint16_t port_id = res->port_id;
+ uint32_t ptype_mask = res->mask;
+ int ret, i;
+
+ ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
+ if (ret <= 0) {
+ printf("Port %d doesn't support any ptypes.\n", port_id);
+ return;
+ }
+
+ uint32_t ptypes[ret];
+ ret = rte_eth_dev_set_supported_ptypes(port_id, ptype_mask, ptypes,
+ ret);
+ if (ret <= 0) {
+ printf("Unable to set requested ptypes for Port %d\n", port_id);
+ return;
+ }
+
+ printf("Successfully set following ptypes for Port %d\n", port_id);
+ for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
+ rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
+ printf("%s\n", ptype_name);
+ }
+}
+
+cmdline_parse_inst_t cmd_set_port_supported_ptypes = {
+ .f = cmd_set_port_supported_ptypes_parsed,
+ .data = NULL,
+ .help_str = "set port <port_id> ptype_mask <mask>",
+ .tokens = {
+ (void *)&cmd_set_port_supported_ptypes_set,
+ (void *)&cmd_set_port_supported_ptypes_port,
+ (void *)&cmd_set_port_supported_ptypes_port_id,
+ (void *)&cmd_set_port_supported_ptypes_mask_str,
+ (void *)&cmd_set_port_supported_ptypes_mask_u32,
+ NULL,
+ },
+};
+
/* ******************************************************************************** */
/* list of instructions */
@@ -19154,6 +19233,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(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_set_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,
@@ -2028,6 +2028,7 @@ start_port(portid_t pid)
queueid_t qi;
struct rte_port *port;
struct rte_ether_addr mac_addr;
+ static uint8_t clr_ptypes = 1;
if (port_id_is_invalid(pid, ENABLED_WARN))
return 0;
@@ -2157,6 +2158,11 @@ start_port(portid_t pid)
}
}
configure_rxtx_dump_callbacks(verbose_level);
+ if (clr_ptypes) {
+ clr_ptypes = 0;
+ rte_eth_dev_set_supported_ptypes(pi, RTE_PTYPE_UNKNOWN,
+ NULL, 0);
+ }
/* start port */
if (rte_eth_dev_start(pi) < 0) {
printf("Fail to start port %d\n", pi);
@@ -472,6 +472,13 @@ Show ptypes supported for a specific port::
testpmd> show port (port_id) ptypes
+set port supported ptypes
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Inform packet types classification interested in for a specific port::
+
+ testpmd> set port (port_id) ptypes_mask (mask)
+
show device info
~~~~~~~~~~~~~~~~