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
Subject: [dpdk-dev] [PATCH v2] app/testpmd: increase array for fetching supported FEC caps
Date: Wed, 23 Dec 2020 17:55:45 +0530
Message-ID: <1608726345-1734-1-git-send-email-rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <1608504422-29220-2-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>
---
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


  parent reply	other threads:[~2020-12-23 12:42 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   ` Rahul Lakkireddy [this message]
2020-12-24 11:18     ` [dpdk-dev] [PATCH v3] " Rahul Lakkireddy
2020-12-25  1:06       ` 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=1608726345-1734-1-git-send-email-rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git