app/testpmd: add command to print representor info
Checks
Commit Message
From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Make it simpler to debug configurations and code related to the representor
info API.
Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
app/test-pmd/cmdline.c | 117 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
Comments
Hi
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Friday, August 27, 2021 14:40
> To: Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; Xueming Li <xuemingl@nvidia.com>; Viacheslav Galaktionov
> <viacheslav.galaktionov@oktetlabs.ru>; Andy Moreton <amoreton@xilinx.com>
> Subject: [PATCH] app/testpmd: add command to print representor info
>
> From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
>
> Make it simpler to debug configurations and code related to the representor
> info API.
>
> Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
> app/test-pmd/cmdline.c | 117
> +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
<snip>
> 2.30.2
Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
Thanks for getting this feature more complete!
> -----Original Message-----
> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Sent: Friday, August 27, 2021 2:40 PM
> To: Xiaoyun Li <xiaoyun.li@intel.com>
> Cc: dev@dpdk.org; Xueming(Steven) Li <xuemingl@nvidia.com>; Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>; Andy
> Moreton <amoreton@xilinx.com>
> Subject: [PATCH] app/testpmd: add command to print representor info
>
> From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
>
> Make it simpler to debug configurations and code related to the representor info API.
>
> Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
> app/test-pmd/cmdline.c | 117 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 82253bc751..49e6e63471 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -236,6 +236,10 @@ static void cmd_help_long_parsed(void *parsed_result,
> " Show port supported ptypes"
> " for a specific port\n\n"
>
> + "show port (port_id) representors\n"
> + " Show supported representors"
> + " for a specific port\n\n"
Confusing name, code below shows representor info, not probed representor devices.
How about "show port (port_id) representor info"?
> +
> "show device info (<identifier>|all)"
> " Show general information about devices probed.\n\n"
>
> @@ -16962,6 +16966,118 @@ cmdline_parse_inst_t cmd_show_capability = {
> },
> };
>
> +/* *** show port representors information *** */ struct
> +cmd_representor_info_result {
> + cmdline_fixed_string_t cmd_show;
> + cmdline_fixed_string_t cmd_port;
> + cmdline_fixed_string_t cmd_keyword;
> + portid_t cmd_pid;
> +};
> +
> +static void
> +cmd_representor_info_parsed(void *parsed_result,
> + __rte_unused struct cmdline *cl,
> + __rte_unused void *data)
> +{
> + struct cmd_representor_info_result *res = parsed_result;
> + struct rte_eth_representor_info *info;
> + uint32_t i;
> + int ret;
> + int num;
> +
> + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
Seems port "all" not supported, is there a check?
> + fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
> + return;
> + }
> +
> + ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
> + if (ret < 0) {
> + fprintf(stderr,
> + "Failed to get the number of representor info ranges for port %hu: %s\n",
> + res->cmd_pid, rte_strerror(-ret));
> + return;
> + }
> + num = ret;
> +
> + info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
> + if (info == NULL) {
> + fprintf(stderr,
> + "Failed to allocate memory for representor info for port %hu\n",
> + res->cmd_pid);
> + return;
> + }
> + info->nb_ranges_alloc = num;
> +
> + ret = rte_eth_representor_info_get(res->cmd_pid, info);
> + if (ret < 0) {
> + fprintf(stderr,
> + "Failed to get the representor info for port %hu: %s\n",
> + res->cmd_pid, rte_strerror(-ret));
> + free(info);
> + return;
> + }
> +
> + printf("Port controller: %hu\n", info->controller);
> + printf("Port PF: %hu\n", info->pf);
> + printf("Ranges: %u\n", info->nb_ranges);
> + for (i = 0; i < info->nb_ranges; i++) {
> + printf("%u:\n", i);
Normally there will be certain amount of ranges here, how about output as a table?
> + printf(" Name: %s\n", info->ranges[i].name);
> + printf(" Controller: %d\n", info->ranges[i].controller);
> + printf(" PF: %d\n", info->ranges[i].pf);
> + switch (info->ranges[i].type) {
> + case RTE_ETH_REPRESENTOR_NONE:
> + printf(" Type: NONE\n");
> + break;
> + case RTE_ETH_REPRESENTOR_VF:
> + printf(" Type: VF\n");
> + printf(" VF: %d\n", info->ranges[i].vf);
> + break;
> + case RTE_ETH_REPRESENTOR_SF:
> + printf(" Type: SF\n");
> + printf(" SF: %d\n", info->ranges[i].sf);
> + break;
> + case RTE_ETH_REPRESENTOR_PF:
> + printf(" Type: PF\n");
> + break;
> + default:
> + printf(" Type: UNKNOWN VALUE %d\n",
> + info->ranges[i].type);
> + break;
> + }
> + printf(" Range: [%u-%u]\n", info->ranges[i].id_base,
> + info->ranges[i].id_end);
> + }
> +
> + free(info);
> +}
> +
> +cmdline_parse_token_string_t cmd_representor_info_show =
> + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
> + cmd_show, "show");
> +cmdline_parse_token_string_t cmd_representor_info_port =
> + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
> + cmd_port, "port");
> +cmdline_parse_token_num_t cmd_representor_info_pid =
> + TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
> + cmd_pid, RTE_UINT16);
> +cmdline_parse_token_string_t cmd_representor_info_keyword =
> + TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
> + cmd_keyword, "representors");
> +
> +cmdline_parse_inst_t cmd_representor_info = {
> + .f = cmd_representor_info_parsed,
> + .data = NULL,
> + .help_str = "show port <port_id> representors",
> + .tokens = {
> + (void *)&cmd_representor_info_show,
> + (void *)&cmd_representor_info_port,
> + (void *)&cmd_representor_info_pid,
> + (void *)&cmd_representor_info_keyword,
> + NULL,
> + },
> +};
> +
> /* *** show fec mode per port configuration *** */ struct cmd_show_fec_metadata_result {
> cmdline_fixed_string_t cmd_show;
> @@ -17816,6 +17932,7 @@ cmdline_parse_ctx_t main_ctx[] = {
> (cmdline_parse_inst_t *)&cmd_show_fec_mode,
> (cmdline_parse_inst_t *)&cmd_set_fec_mode,
> (cmdline_parse_inst_t *)&cmd_show_capability,
> + (cmdline_parse_inst_t *)&cmd_representor_info,
> NULL,
> };
>
> --
> 2.30.2
On 2021-08-27 11:20, Xueming(Steven) Li wrote:
> Thanks for getting this feature more complete!
>
>> -----Original Message-----
>> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> Sent: Friday, August 27, 2021 2:40 PM
>> To: Xiaoyun Li <xiaoyun.li@intel.com>
>> Cc: dev@dpdk.org; Xueming(Steven) Li <xuemingl@nvidia.com>; Viacheslav
>> Galaktionov <viacheslav.galaktionov@oktetlabs.ru>; Andy
>> Moreton <amoreton@xilinx.com>
>> Subject: [PATCH] app/testpmd: add command to print representor info
>>
>> From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
>>
>> Make it simpler to debug configurations and code related to the
>> representor info API.
>>
>> Signed-off-by: Viacheslav Galaktionov
>> <viacheslav.galaktionov@oktetlabs.ru>
>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
>> ---
>> app/test-pmd/cmdline.c | 117
>> +++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 117 insertions(+)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
>> 82253bc751..49e6e63471 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>> @@ -236,6 +236,10 @@ static void cmd_help_long_parsed(void
>> *parsed_result,
>> " Show port supported ptypes"
>> " for a specific port\n\n"
>>
>> + "show port (port_id) representors\n"
>> + " Show supported representors"
>> + " for a specific port\n\n"
>
> Confusing name, code below shows representor info, not probed
> representor devices.
> How about "show port (port_id) representor info"?
That's a good point, thank you!
[snip]
>> +static void
>> +cmd_representor_info_parsed(void *parsed_result,
>> + __rte_unused struct cmdline *cl,
>> + __rte_unused void *data)
>> +{
>> + struct cmd_representor_info_result *res = parsed_result;
>> + struct rte_eth_representor_info *info;
>> + uint32_t i;
>> + int ret;
>> + int num;
>> +
>> + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
>
> Seems port "all" not supported, is there a check?
What kind of check do you mean?
I suppose support for "all" can be added. In such a case, testpmd can go
over
all available ports that aren't representors and print their representor
info.
Does this sound good to you?
[snip]
>> + printf("Port controller: %hu\n", info->controller);
>> + printf("Port PF: %hu\n", info->pf);
>> + printf("Ranges: %u\n", info->nb_ranges);
>> + for (i = 0; i < info->nb_ranges; i++) {
>> + printf("%u:\n", i);
>
> Normally there will be certain amount of ranges here, how about output
> as a table?
I'm not sure what the layout of this table should be, could you provide
an
example?
[snip]
> -----Original Message-----
> From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
> Sent: Friday, August 27, 2021 5:21 PM
> To: Xueming(Steven) Li <xuemingl@nvidia.com>
> Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>; Xiaoyun Li <xiaoyun.li@intel.com>; dev@dpdk.org; Andy Moreton
> <amoreton@xilinx.com>
> Subject: Re: [PATCH] app/testpmd: add command to print representor info
>
> On 2021-08-27 11:20, Xueming(Steven) Li wrote:
> > Thanks for getting this feature more complete!
> >
> >> -----Original Message-----
> >> From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> >> Sent: Friday, August 27, 2021 2:40 PM
> >> To: Xiaoyun Li <xiaoyun.li@intel.com>
> >> Cc: dev@dpdk.org; Xueming(Steven) Li <xuemingl@nvidia.com>;
> >> Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>; Andy
> >> Moreton <amoreton@xilinx.com>
> >> Subject: [PATCH] app/testpmd: add command to print representor info
> >>
> >> From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
> >>
> >> Make it simpler to debug configurations and code related to the
> >> representor info API.
> >>
> >> Signed-off-by: Viacheslav Galaktionov
> >> <viacheslav.galaktionov@oktetlabs.ru>
> >> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> >> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> >> ---
> >> app/test-pmd/cmdline.c | 117
> >> +++++++++++++++++++++++++++++++++++++++++
> >> 1 file changed, 117 insertions(+)
> >>
> >> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> >> 82253bc751..49e6e63471 100644
> >> --- a/app/test-pmd/cmdline.c
> >> +++ b/app/test-pmd/cmdline.c
> >> @@ -236,6 +236,10 @@ static void cmd_help_long_parsed(void
> >> *parsed_result,
> >> " Show port supported ptypes"
> >> " for a specific port\n\n"
> >>
> >> + "show port (port_id) representors\n"
> >> + " Show supported representors"
> >> + " for a specific port\n\n"
> >
> > Confusing name, code below shows representor info, not probed
> > representor devices.
> > How about "show port (port_id) representor info"?
>
> That's a good point, thank you!
>
> [snip]
>
> >> +static void
> >> +cmd_representor_info_parsed(void *parsed_result,
> >> + __rte_unused struct cmdline *cl,
> >> + __rte_unused void *data)
> >> +{
> >> + struct cmd_representor_info_result *res = parsed_result;
> >> + struct rte_eth_representor_info *info;
> >> + uint32_t i;
> >> + int ret;
> >> + int num;
> >> +
> >> + if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
> >
> > Seems port "all" not supported, is there a check?
>
> What kind of check do you mean?
> I suppose support for "all" can be added. In such a case, testpmd can go over all available ports that aren't representors and print
> their representor info.
> Does this sound good to you?
Sorry, "all" will not pass the check, please ignore my comment.
Dump a single port is good enough.
>
> [snip]
>
> >> + printf("Port controller: %hu\n", info->controller);
> >> + printf("Port PF: %hu\n", info->pf);
> >> + printf("Ranges: %u\n", info->nb_ranges);
> >> + for (i = 0; i < info->nb_ranges; i++) {
> >> + printf("%u:\n", i);
> >
> > Normally there will be certain amount of ranges here, how about output
> > as a table?
>
> I'm not sure what the layout of this table should be, could you provide an example?
Range entry fields is dump in vertical here, how about dump range entry as a row? No need to align columns.
>
> [snip]
@@ -236,6 +236,10 @@ static void cmd_help_long_parsed(void *parsed_result,
" Show port supported ptypes"
" for a specific port\n\n"
+ "show port (port_id) representors\n"
+ " Show supported representors"
+ " for a specific port\n\n"
+
"show device info (<identifier>|all)"
" Show general information about devices probed.\n\n"
@@ -16962,6 +16966,118 @@ cmdline_parse_inst_t cmd_show_capability = {
},
};
+/* *** show port representors information *** */
+struct cmd_representor_info_result {
+ cmdline_fixed_string_t cmd_show;
+ cmdline_fixed_string_t cmd_port;
+ cmdline_fixed_string_t cmd_keyword;
+ portid_t cmd_pid;
+};
+
+static void
+cmd_representor_info_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_representor_info_result *res = parsed_result;
+ struct rte_eth_representor_info *info;
+ uint32_t i;
+ int ret;
+ int num;
+
+ if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
+ fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
+ return;
+ }
+
+ ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
+ if (ret < 0) {
+ fprintf(stderr,
+ "Failed to get the number of representor info ranges for port %hu: %s\n",
+ res->cmd_pid, rte_strerror(-ret));
+ return;
+ }
+ num = ret;
+
+ info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
+ if (info == NULL) {
+ fprintf(stderr,
+ "Failed to allocate memory for representor info for port %hu\n",
+ res->cmd_pid);
+ return;
+ }
+ info->nb_ranges_alloc = num;
+
+ ret = rte_eth_representor_info_get(res->cmd_pid, info);
+ if (ret < 0) {
+ fprintf(stderr,
+ "Failed to get the representor info for port %hu: %s\n",
+ res->cmd_pid, rte_strerror(-ret));
+ free(info);
+ return;
+ }
+
+ printf("Port controller: %hu\n", info->controller);
+ printf("Port PF: %hu\n", info->pf);
+ printf("Ranges: %u\n", info->nb_ranges);
+ for (i = 0; i < info->nb_ranges; i++) {
+ printf("%u:\n", i);
+ printf(" Name: %s\n", info->ranges[i].name);
+ printf(" Controller: %d\n", info->ranges[i].controller);
+ printf(" PF: %d\n", info->ranges[i].pf);
+ switch (info->ranges[i].type) {
+ case RTE_ETH_REPRESENTOR_NONE:
+ printf(" Type: NONE\n");
+ break;
+ case RTE_ETH_REPRESENTOR_VF:
+ printf(" Type: VF\n");
+ printf(" VF: %d\n", info->ranges[i].vf);
+ break;
+ case RTE_ETH_REPRESENTOR_SF:
+ printf(" Type: SF\n");
+ printf(" SF: %d\n", info->ranges[i].sf);
+ break;
+ case RTE_ETH_REPRESENTOR_PF:
+ printf(" Type: PF\n");
+ break;
+ default:
+ printf(" Type: UNKNOWN VALUE %d\n",
+ info->ranges[i].type);
+ break;
+ }
+ printf(" Range: [%u-%u]\n", info->ranges[i].id_base,
+ info->ranges[i].id_end);
+ }
+
+ free(info);
+}
+
+cmdline_parse_token_string_t cmd_representor_info_show =
+ TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
+ cmd_show, "show");
+cmdline_parse_token_string_t cmd_representor_info_port =
+ TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
+ cmd_port, "port");
+cmdline_parse_token_num_t cmd_representor_info_pid =
+ TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
+ cmd_pid, RTE_UINT16);
+cmdline_parse_token_string_t cmd_representor_info_keyword =
+ TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
+ cmd_keyword, "representors");
+
+cmdline_parse_inst_t cmd_representor_info = {
+ .f = cmd_representor_info_parsed,
+ .data = NULL,
+ .help_str = "show port <port_id> representors",
+ .tokens = {
+ (void *)&cmd_representor_info_show,
+ (void *)&cmd_representor_info_port,
+ (void *)&cmd_representor_info_pid,
+ (void *)&cmd_representor_info_keyword,
+ NULL,
+ },
+};
+
/* *** show fec mode per port configuration *** */
struct cmd_show_fec_metadata_result {
cmdline_fixed_string_t cmd_show;
@@ -17816,6 +17932,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_show_fec_mode,
(cmdline_parse_inst_t *)&cmd_set_fec_mode,
(cmdline_parse_inst_t *)&cmd_show_capability,
+ (cmdline_parse_inst_t *)&cmd_representor_info,
NULL,
};