From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2A5E2A0C43; Fri, 27 Aug 2021 08:39:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3130406B4; Fri, 27 Aug 2021 08:39:51 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id C55BD4067C for ; Fri, 27 Aug 2021 08:39:50 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 4B6F37F6C4; Fri, 27 Aug 2021 09:39:49 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 9D8A97F57F; Fri, 27 Aug 2021 09:39:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 9D8A97F57F Authentication-Results: shelob.oktetlabs.ru/9D8A97F57F; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Xiaoyun Li Cc: dev@dpdk.org, Xueming Li , Viacheslav Galaktionov , Andy Moreton Date: Fri, 27 Aug 2021 09:39:35 +0300 Message-Id: <20210827063935.1834143-1-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] app/testpmd: add command to print representor info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Viacheslav Galaktionov Make it simpler to debug configurations and code related to the representor info API. Signed-off-by: Viacheslav Galaktionov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- 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" + "show device info (|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 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