DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array
@ 2020-12-20 22:47 Rahul Lakkireddy
  2020-12-20 22:47 ` [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported FEC caps Rahul Lakkireddy
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-20 22:47 UTC (permalink / raw)
  To: dev; +Cc: kaara.satwik, stable

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

Start from index 0 when going through the FEC array. This will allow
"off" to get printed for RTE_ETH_FEC_NOFEC mode.

Fixes: b19da32e3151 ("app/testpmd: add FEC command")
Cc: stable@dpdk.org

Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 app/test-pmd/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 3f6c8642b..a6a5baa4e 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3701,7 +3701,7 @@ show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
 		printf("%s : ",
 			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
 
-		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name); j++) {
+		for (j = 0; j < RTE_DIM(fec_mode_name); j++) {
 			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
 						speed_fec_capa[i].capa)
 				printf("%s ", fec_mode_name[j].name);
-- 
2.24.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported FEC caps
  2020-12-20 22:47 [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array Rahul Lakkireddy
@ 2020-12-20 22:47 ` Rahul Lakkireddy
  2020-12-23  6:02   ` Li, Xiaoyun
                     ` (2 more replies)
  2020-12-21  9:07 ` [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array Min Hu (Connor)
  2020-12-23  6:07 ` [dpdk-dev] [dpdk-stable] " Li, Xiaoyun
  2 siblings, 3 replies; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-20 22:47 UTC (permalink / raw)
  To: dev; +Cc: kaara.satwik

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) {
+		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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array
  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-21  9:07 ` Min Hu (Connor)
  2020-12-23 12:31   ` Rahul Lakkireddy
  2020-12-23  6:07 ` [dpdk-dev] [dpdk-stable] " Li, Xiaoyun
  2 siblings, 1 reply; 13+ messages in thread
From: Min Hu (Connor) @ 2020-12-21  9:07 UTC (permalink / raw)
  To: dev



在 2020/12/21 6:47, Rahul Lakkireddy 写道:
> From: Karra Satwik <kaara.satwik@chelsio.com>
> 
> Start from index 0 when going through the FEC array. This will allow
> "off" to get printed for RTE_ETH_FEC_NOFEC mode.
> 
> Fixes: b19da32e3151 ("app/testpmd: add FEC command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>   app/test-pmd/config.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 3f6c8642b..a6a5baa4e 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -3701,7 +3701,7 @@ show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
>   		printf("%s : ",
>   			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
>   
> -		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name); j++) {
> +		for (j = 0; j < RTE_DIM(fec_mode_name); j++) {

As RTE_ETH_FEC_NOFEC is mode which every device  has, so we think it
should not be regarged as "capabilities".
Thanks.

>   			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
>   						speed_fec_capa[i].capa)
>   				printf("%s ", fec_mode_name[j].name);
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported FEC caps
  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  7:53   ` [dpdk-dev] [PATCH] " Min Hu (Connor)
  2 siblings, 0 replies; 13+ messages in thread
From: Li, Xiaoyun @ 2020-12-23  6:02 UTC (permalink / raw)
  To: Rahul Lakkireddy, dev; +Cc: kaara.satwik

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix start index for showing FEC array
  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-21  9:07 ` [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array Min Hu (Connor)
@ 2020-12-23  6:07 ` Li, Xiaoyun
  2021-01-15 13:53   ` Ferruh Yigit
  2 siblings, 1 reply; 13+ messages in thread
From: Li, Xiaoyun @ 2020-12-23  6:07 UTC (permalink / raw)
  To: Rahul Lakkireddy, dev; +Cc: kaara.satwik, stable

Acked-by: Xiaoyun Li <xiaoyun.li@intel.com>

> -----Original Message-----
> From: stable <stable-bounces@dpdk.org> On Behalf Of Rahul Lakkireddy
> Sent: Monday, December 21, 2020 06:47
> To: dev@dpdk.org
> Cc: kaara.satwik@chelsio.com; stable@dpdk.org
> Subject: [dpdk-stable] [PATCH] app/testpmd: fix start index for showing FEC
> array
> 
> From: Karra Satwik <kaara.satwik@chelsio.com>
> 
> Start from index 0 when going through the FEC array. This will allow "off" to get
> printed for RTE_ETH_FEC_NOFEC mode.
> 
> Fixes: b19da32e3151 ("app/testpmd: add FEC command")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>  app/test-pmd/config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> 3f6c8642b..a6a5baa4e 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -3701,7 +3701,7 @@ show_fec_capability(unsigned int num, struct
> rte_eth_fec_capa *speed_fec_capa)
>  		printf("%s : ",
>  			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
> 
> -		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name);
> j++) {
> +		for (j = 0; j < RTE_DIM(fec_mode_name); j++) {
>  			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
>  						speed_fec_capa[i].capa)
>  				printf("%s ", fec_mode_name[j].name);
> --
> 2.24.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v2] app/testpmd: increase array for fetching supported FEC caps
  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
  2020-12-24 11:18     ` [dpdk-dev] [PATCH v3] " Rahul Lakkireddy
  2020-12-24  7:53   ` [dpdk-dev] [PATCH] " Min Hu (Connor)
  2 siblings, 1 reply; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-23 12:25 UTC (permalink / raw)
  To: dev; +Cc: kaara.satwik, xiaoyun.li

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-23 12:31 UTC (permalink / raw)
  To: Min Hu (Connor); +Cc: dev

On Monday, December 12/21/20, 2020 at 17:07:21 +0800, Min Hu (Connor) wrote:
> 
> 
> 在 2020/12/21 6:47, Rahul Lakkireddy 写道:
> >From: Karra Satwik <kaara.satwik@chelsio.com>
> >
> >Start from index 0 when going through the FEC array. This will allow
> >"off" to get printed for RTE_ETH_FEC_NOFEC mode.
> >
> >Fixes: b19da32e3151 ("app/testpmd: add FEC command")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
> >Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> >---
> >  app/test-pmd/config.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> >index 3f6c8642b..a6a5baa4e 100644
> >--- a/app/test-pmd/config.c
> >+++ b/app/test-pmd/config.c
> >@@ -3701,7 +3701,7 @@ show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
> >  		printf("%s : ",
> >  			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
> >-		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name); j++) {
> >+		for (j = 0; j < RTE_DIM(fec_mode_name); j++) {
> 
> As RTE_ETH_FEC_NOFEC is mode which every device  has, so we think it
> should not be regarged as "capabilities".
> Thanks.
> 

We had gotten several requests asking if device supported turning
FEC "off" because it was not listed in capabilities. Hence, the
motiviation for this patch to explicitly show that "off" is
supported.


> >  			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
> >  						speed_fec_capa[i].capa)
> >  				printf("%s ", fec_mode_name[j].name);
> >

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: increase array for fetching supported FEC caps
  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  7:53   ` Min Hu (Connor)
  2 siblings, 0 replies; 13+ messages in thread
From: Min Hu (Connor) @ 2020-12-24  7:53 UTC (permalink / raw)
  To: dev



在 2020/12/21 6:47, Rahul Lakkireddy 写道:
> 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);
Hi, the type of num is "unsigned int" in rte_eth_fec_get_capability,
please keep in accordance with it.

> +	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) {
> +		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 =
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v3] app/testpmd: increase array for fetching supported FEC caps
  2020-12-23 12:25   ` [dpdk-dev] [PATCH v2] " Rahul Lakkireddy
@ 2020-12-24 11:18     ` Rahul Lakkireddy
  2020-12-25  1:06       ` Min Hu (Connor)
  0 siblings, 1 reply; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-24 11:18 UTC (permalink / raw)
  To: dev; +Cc: kaara.satwik, xiaoyun.li, humin29

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH v3] app/testpmd: increase array for fetching supported FEC caps
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Min Hu (Connor) @ 2020-12-25  1:06 UTC (permalink / raw)
  To: Rahul Lakkireddy, dev; +Cc: kaara.satwik, xiaoyun.li

Acked-by: Min Hu (Connor) <humin29@huawei.com>

在 2020/12/24 19:18, Rahul Lakkireddy 写道:
> 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 =
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: fix start index for showing FEC array
  2020-12-23 12:31   ` Rahul Lakkireddy
@ 2020-12-25 13:49     ` Rahul Lakkireddy
  0 siblings, 0 replies; 13+ messages in thread
From: Rahul Lakkireddy @ 2020-12-25 13:49 UTC (permalink / raw)
  To: Min Hu (Connor); +Cc: dev, kaara.satwik

+dev@dpdk.org which seems to have been dropped by accident.

On Friday, December 12/25/20, 2020 at 09:03:43 +0800, Min Hu (Connor) wrote:
> 
> 
> 在 2020/12/24 19:25, Rahul Lakkireddy 写道:
> >On Thursday, December 12/24/20, 2020 at 17:36:27 +0800, Min Hu (Connor) wrote:
> >>
> >>
> >>在 2020/12/23 20:31, Rahul Lakkireddy 写道:
> >>>On Monday, December 12/21/20, 2020 at 17:07:21 +0800, Min Hu (Connor) wrote:
> >>>>
> >>>>
> >>>>在 2020/12/21 6:47, Rahul Lakkireddy 写道:
> >>>>>From: Karra Satwik <kaara.satwik@chelsio.com>
> >>>>>
> >>>>>Start from index 0 when going through the FEC array. This will allow
> >>>>>"off" to get printed for RTE_ETH_FEC_NOFEC mode.
> >>>>>
> >>>>>Fixes: b19da32e3151 ("app/testpmd: add FEC command")
> >>>>>Cc: stable@dpdk.org
> >>>>>
> >>>>>Signed-off-by: Karra Satwik <kaara.satwik@chelsio.com>
> >>>>>Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> >>>>>---
> >>>>>  app/test-pmd/config.c | 2 +-
> >>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>
> >>>>>diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> >>>>>index 3f6c8642b..a6a5baa4e 100644
> >>>>>--- a/app/test-pmd/config.c
> >>>>>+++ b/app/test-pmd/config.c
> >>>>>@@ -3701,7 +3701,7 @@ show_fec_capability(unsigned int num, struct rte_eth_fec_capa *speed_fec_capa)
> >>>>>  		printf("%s : ",
> >>>>>  			rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
> >>>>>-		for (j = RTE_ETH_FEC_AUTO; j < RTE_DIM(fec_mode_name); j++) {
> >>>>>+		for (j = 0; j < RTE_DIM(fec_mode_name); j++) {
> >>>>
> >>>>As RTE_ETH_FEC_NOFEC is mode which every device  has, so we think it
> >>>>should not be regarged as "capabilities".
> >>>>Thanks.
> >>>>
> >>>
> >>>We had gotten several requests asking if device supported turning
> >>>FEC "off" because it was not listed in capabilities. Hence, the
> >>>motiviation for this patch to explicitly show that "off" is
> >>>supported.
> >>
> >>HI, we have referred to other netcard in kernel driver mode, it shows like
> >>this:
> >>
> >>[root@centos197-test_dpdk]$ethtool  --show-fec  eth9
> >>FEC parameters for eth9:
> >>Configured FEC encodings: Auto BaseR
> >>Active FEC encoding: Off
> >>
> >>Here, "Configured FEC encodings" means the capability it supports, it
> >>does not include "off", although it can be configured using "off".
> >>thanks.
> >>
> >
> >It is the same with our own card too using our kernel driver and
> >have gotten the same questions in the past with our kernel driver
> >too.
> >
> ># ethtool --show-fec enp2s0f4
> >FEC parameters for enp2s0f4:
> >Configured FEC encodings: Auto BaseR RS
> >Active FEC encoding: RS
> >
> >We don't have any strong opinion on this. We just wanted to let
> >testpmd show the 'off' caps since it's also an available option.
> >If the intention is confusing, then sure we will drop the patch.
> >Let us know your feedback.
> Hi, I've got your opinion, but I think the display about FEC in dpdk
> testpmd had better be in accordance with that in kernel ethtool.
> IF the two is different, it may confuse users, thanks.
> So, what about everybody? any opinion will be welcome.
> 
> >
> >>
> >>
> >>>
> >>>
> >>>>>  			if (RTE_ETH_FEC_MODE_TO_CAPA(j) &
> >>>>>  						speed_fec_capa[i].capa)
> >>>>>  				printf("%s ", fec_mode_name[j].name);
> >>>>>
> >>>.
> >>>
> >.
> >

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [dpdk-stable] [PATCH] app/testpmd: fix start index for showing FEC array
  2020-12-23  6:07 ` [dpdk-dev] [dpdk-stable] " Li, Xiaoyun
@ 2021-01-15 13:53   ` Ferruh Yigit
  0 siblings, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2021-01-15 13:53 UTC (permalink / raw)
  To: Li, Xiaoyun, Rahul Lakkireddy, dev; +Cc: kaara.satwik, stable

On 12/23/2020 6:07 AM, Li, Xiaoyun wrote:

>> -----Original Message-----
>> From: stable <stable-bounces@dpdk.org> On Behalf Of Rahul Lakkireddy
>> Sent: Monday, December 21, 2020 06:47
>> To: dev@dpdk.org
>> Cc: kaara.satwik@chelsio.com; stable@dpdk.org
>> Subject: [dpdk-stable] [PATCH] app/testpmd: fix start index for showing FEC
>> array
>>
>> From: Karra Satwik <kaara.satwik@chelsio.com>
>>
>> Start from index 0 when going through the FEC array. This will allow "off" to get
>> printed for RTE_ETH_FEC_NOFEC mode.
>>
>> Fixes: b19da32e3151 ("app/testpmd: add FEC command")
>> Cc: stable@dpdk.org
>>
>> 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>
> 

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH v3] app/testpmd: increase array for fetching supported FEC caps
  2020-12-25  1:06       ` Min Hu (Connor)
@ 2021-01-15 15:27         ` Ferruh Yigit
  0 siblings, 0 replies; 13+ messages in thread
From: Ferruh Yigit @ 2021-01-15 15:27 UTC (permalink / raw)
  To: Min Hu (Connor), Rahul Lakkireddy, dev; +Cc: kaara.satwik, xiaoyun.li

On 12/25/2020 1:06 AM, Min Hu (Connor) wrote:

> 在 2020/12/24 19:18, Rahul Lakkireddy 写道:
>> 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>
 > Acked-by: Min Hu (Connor) <humin29@huawei.com>
 >

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-01-15 15:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [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

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