DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Li, Xiaoyun" <xiaoyun.li@intel.com>
To: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "kaara.satwik@chelsio.com" <kaara.satwik@chelsio.com>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: increase array for fetching	supported FEC caps
Date: Wed, 23 Dec 2020 06:02:55 +0000	[thread overview]
Message-ID: <CY4PR11MB175048D8DAB099F92BE53C3999DE0@CY4PR11MB1750.namprd11.prod.outlook.com> (raw)
In-Reply-To: <1608504422-29220-2-git-send-email-rahul.lakkireddy@chelsio.com>

Hi

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Rahul Lakkireddy
> Sent: Monday, December 21, 2020 06:47
> To: dev@dpdk.org
> Cc: kaara.satwik@chelsio.com
> Subject: [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported
> FEC caps
> 
> 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>
> ---
>  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..d7a90d55e 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) {

if (speed_fec_capa == NULL) {

You can check the DPDK coding style 1.9.1. http://doc.dpdk.org/guides/contributing/coding_style.html
NULL is the preferred null pointer constant. Use NULL instead of (type *)0 or (type *)NULL, except where the compiler does not know the destination type.

Except for this minor issue, Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>

> +		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-23  6:03 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 [this message]
2020-12-23 12:25   ` [dpdk-dev] [PATCH v2] " Rahul Lakkireddy
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=CY4PR11MB175048D8DAB099F92BE53C3999DE0@CY4PR11MB1750.namprd11.prod.outlook.com \
    --to=xiaoyun.li@intel.com \
    --cc=dev@dpdk.org \
    --cc=kaara.satwik@chelsio.com \
    --cc=rahul.lakkireddy@chelsio.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).