DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: kaara.satwik@chelsio.com, xiaoyun.li@intel.com, humin29@huawei.com
Subject: [dpdk-dev] [PATCH v3] app/testpmd: increase array for fetching supported FEC caps
Date: Thu, 24 Dec 2020 16:48:49 +0530	[thread overview]
Message-ID: <1608808729-3768-1-git-send-email-rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <1608726345-1734-1-git-send-email-rahul.lakkireddy@chelsio.com>

From: Karra Satwik <kaara.satwik@chelsio.com>

Request the driver for number of entries in the FEC caps
array and then dynamically allocate the array.

Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
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 =
-- 
2.24.0


  reply	other threads:[~2020-12-24 11:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20 22:47 [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array Rahul Lakkireddy
2020-12-20 22:47 ` [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported FEC caps Rahul Lakkireddy
2020-12-23  6:02   ` Li, Xiaoyun
2020-12-23 12:25   ` [dpdk-dev] [PATCH v2] " Rahul Lakkireddy
2020-12-24 11:18     ` Rahul Lakkireddy [this message]
2020-12-25  1:06       ` [dpdk-dev] [PATCH v3] " Min Hu (Connor)
2021-01-15 15:27         ` Ferruh Yigit
2020-12-24  7:53   ` [dpdk-dev] [PATCH] " Min Hu (Connor)
2020-12-21  9:07 ` [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array Min Hu (Connor)
2020-12-23 12:31   ` Rahul Lakkireddy
2020-12-25 13:49     ` Rahul Lakkireddy
2020-12-23  6:07 ` [dpdk-dev] [dpdk-stable] " Li, Xiaoyun
2021-01-15 13:53   ` 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=1608808729-3768-1-git-send-email-rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.com \
    --cc=kaara.satwik@chelsio.com \
    --cc=xiaoyun.li@intel.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).