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 9185BA09FF; Fri, 25 Dec 2020 02:06:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 899CBCA1A; Fri, 25 Dec 2020 02:06:29 +0100 (CET) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 17273CA16 for ; Fri, 25 Dec 2020 02:06:28 +0100 (CET) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4D27zS1js6zhxyc; Fri, 25 Dec 2020 09:05:40 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Fri, 25 Dec 2020 09:06:23 +0800 To: Rahul Lakkireddy , CC: , References: <1608726345-1734-1-git-send-email-rahul.lakkireddy@chelsio.com> <1608808729-3768-1-git-send-email-rahul.lakkireddy@chelsio.com> From: "Min Hu (Connor)" Message-ID: <0f3e6ee5-9ab0-86e1-f30f-7281d5f056cc@huawei.com> Date: Fri, 25 Dec 2020 09:06:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <1608808729-3768-1-git-send-email-rahul.lakkireddy@chelsio.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH v3] 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" Acked-by: Min Hu (Connor) ÔÚ 2020/12/24 19:18, Rahul Lakkireddy дµÀ: > 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 > --- > v3: > - Use unsigned int num, instead of int num > > v2: > - Replace if (!speed_fec_capa) with if (speed_fec_capa == NULL) > > app/test-pmd/cmdline.c | 28 ++++++++++++++++++++-------- > 1 file changed, 20 insertions(+), 8 deletions(-) > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 2ccbaa039..1dfad5df4 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -16263,11 +16263,9 @@ 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; > + struct rte_eth_fec_capa *speed_fec_capa; > + unsigned int num; > int ret; > > if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { > @@ -16275,17 +16273,31 @@ cmd_show_fec_capability_parsed(void *parsed_result, > 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 = (unsigned int)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 = >