From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Xiaoyun Li <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: [dpdk-dev] [PATCH v2] app/testpmd: add command to print representor info
Date: Tue, 31 Aug 2021 19:12:42 +0300 [thread overview]
Message-ID: <20210831161242.3465395-1-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210827063935.1834143-1-andrew.rybchenko@oktetlabs.ru>
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>
---
v2:
- change output format to log just one line per range
app/test-pmd/cmdline.c | 135 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 82253bc751..ae700f9dd1 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) representor info\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,136 @@ 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;
+ struct rte_eth_representor_range *range;
+ uint32_t range_diff;
+ 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++) {
+ range = &info->ranges[i];
+ range_diff = range->id_end - range->id_base;
+
+ printf("%u. ", i + 1);
+ printf("'%s' ", range->name);
+ if (range_diff > 0)
+ printf("[%u-%u]: ", range->id_base, range->id_end);
+ else
+ printf("[%u]: ", range->id_base);
+
+ printf("Controller %d, PF %d", range->controller, range->pf);
+
+ switch (range->type) {
+ case RTE_ETH_REPRESENTOR_NONE:
+ printf(", NONE\n");
+ break;
+ case RTE_ETH_REPRESENTOR_VF:
+ if (range_diff > 0) {
+ printf(", VF %d..%d\n", range->vf,
+ range->vf + range_diff);
+ } else {
+ printf(", VF %d\n", range->vf);
+ }
+ break;
+ case RTE_ETH_REPRESENTOR_SF:
+ printf(", SF %d\n", range->sf);
+ break;
+ case RTE_ETH_REPRESENTOR_PF:
+ if (range_diff > 0)
+ printf("..%d\n", range->pf + range_diff);
+ else
+ printf("\n");
+ break;
+ default:
+ printf(", UNKNOWN TYPE %d\n", range->type);
+ break;
+ }
+ }
+
+ 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_keyword1 =
+ TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
+ cmd_keyword, "representor");
+cmdline_parse_token_string_t cmd_representor_info_keyword2 =
+ TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
+ cmd_keyword, "info");
+
+cmdline_parse_inst_t cmd_representor_info = {
+ .f = cmd_representor_info_parsed,
+ .data = NULL,
+ .help_str = "show port <port_id> representor info",
+ .tokens = {
+ (void *)&cmd_representor_info_show,
+ (void *)&cmd_representor_info_port,
+ (void *)&cmd_representor_info_pid,
+ (void *)&cmd_representor_info_keyword1,
+ (void *)&cmd_representor_info_keyword2,
+ NULL,
+ },
+};
+
/* *** show fec mode per port configuration *** */
struct cmd_show_fec_metadata_result {
cmdline_fixed_string_t cmd_show;
@@ -17816,6 +17950,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
next prev parent reply other threads:[~2021-08-31 16:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 6:39 [dpdk-dev] [PATCH] " Andrew Rybchenko
2021-08-27 7:28 ` Li, Xiaoyun
2021-08-27 8:20 ` Xueming(Steven) Li
2021-08-27 9:20 ` Viacheslav Galaktionov
2021-08-28 13:28 ` Xueming(Steven) Li
2021-08-31 16:12 ` Andrew Rybchenko [this message]
2021-09-02 12:33 ` [dpdk-dev] [PATCH v2] " Xueming(Steven) Li
2021-09-14 15:52 ` Ferruh Yigit
2021-09-14 16:17 ` Andrew Rybchenko
2021-09-14 16:36 ` Ferruh Yigit
2021-09-15 13:50 ` Andrew Rybchenko
2021-09-15 13:47 ` [dpdk-dev] [PATCH v3] " Andrew Rybchenko
2021-09-28 0:55 ` Ajit Khaparde
2021-10-11 8:32 ` Li, Xiaoyun
2021-10-11 13:10 ` Andrew Rybchenko
2021-10-11 13:08 ` [dpdk-dev] [PATCH v4] " Andrew Rybchenko
2021-10-12 1:50 ` Li, Xiaoyun
2021-10-12 17:06 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210831161242.3465395-1-andrew.rybchenko@oktetlabs.ru \
--to=andrew.rybchenko@oktetlabs.ru \
--cc=amoreton@xilinx.com \
--cc=dev@dpdk.org \
--cc=viacheslav.galaktionov@oktetlabs.ru \
--cc=xiaoyun.li@intel.com \
--cc=xuemingl@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).