From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 694E7A052A; Wed, 23 Dec 2020 13:42:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18CE1C9E4; Wed, 23 Dec 2020 13:42:11 +0100 (CET) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id 6050DC9DC for ; Wed, 23 Dec 2020 13:42:08 +0100 (CET) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 0BNCg5QQ024372; Wed, 23 Dec 2020 04:42:05 -0800 From: Rahul Lakkireddy To: dev@dpdk.org Cc: kaara.satwik@chelsio.com, xiaoyun.li@intel.com Date: Wed, 23 Dec 2020 17:55:45 +0530 Message-Id: <1608726345-1734-1-git-send-email-rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1608504422-29220-2-git-send-email-rahul.lakkireddy@chelsio.com> References: <1608504422-29220-2-git-send-email-rahul.lakkireddy@chelsio.com> Subject: [dpdk-dev] [PATCH v2] app/testpmd: increase array for fetching supported FEC caps X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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: Karra Satwik Request the driver for number of entries in the FEC caps array and then dynamically allocate the array. Signed-off-by: Karra Satwik Signed-off-by: Rahul Lakkireddy Acked-by: Xiaoyun Li --- v2: - Replace if (!speed_fec_capa) with if (speed_fec_capa == NULL) app/test-pmd/cmdline.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 2ccbaa039..aa9c32216 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -16263,29 +16263,40 @@ cmd_show_fec_capability_parsed(void *parsed_result, __rte_unused struct cmdline *cl, __rte_unused void *data) { -#define FEC_CAP_NUM 2 struct cmd_show_fec_capability_result *res = parsed_result; - struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM]; - unsigned int num = FEC_CAP_NUM; - unsigned int ret_num; - int ret; + struct rte_eth_fec_capa *speed_fec_capa; + int num, ret; if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { printf("Invalid port id %u\n", res->cmd_pid); return; } - ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); + ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0); if (ret == -ENOTSUP) { printf("Function not implemented\n"); return; } else if (ret < 0) { - printf("Get FEC capability failed\n"); + printf("Get FEC capability failed: %d\n", ret); + return; + } + + num = ret; + speed_fec_capa = calloc(num, sizeof(*speed_fec_capa)); + if (speed_fec_capa == NULL) { + printf("Failed to alloc FEC capability buffer\n"); return; } - ret_num = (unsigned int)ret; - show_fec_capability(ret_num, speed_fec_capa); + ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num); + if (ret < 0) { + printf("Error getting FEC capability: %d\n", ret); + goto out; + } + + show_fec_capability(num, speed_fec_capa); +out: + free(speed_fec_capa); } cmdline_parse_token_string_t cmd_show_fec_capability_show = -- 2.24.0