[v5] testpmd: add speed capability in device info

Message ID 20201008182513.369420-1-sarosh.arif@emumba.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v5] testpmd: add speed capability in device info |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Sarosh Arif Oct. 8, 2020, 6:25 p.m. UTC
  Called rte_eth_dev_info_get() in testpmd, to get device info
so that speed capabilities can be printed under "show device info"
​
Bugzilla ID: 496
Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
---
 app/test-pmd/config.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
  

Comments

Ferruh Yigit Oct. 9, 2020, 9:27 a.m. UTC | #1
On 10/8/2020 7:25 PM, Sarosh Arif wrote:
> Called rte_eth_dev_info_get() in testpmd, to get device info
> so that speed capabilities can be printed under "show device info"
> ​
> Bugzilla ID: 496
> Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
> ---
>   app/test-pmd/config.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 43 insertions(+)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 30bee3324..68a7de7cf 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -507,6 +507,46 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
>   	return 0;
>   }
>   
> +static void
> +device_infos_display_speeds(uint32_t speed_capa)
> +{
> +	printf("\n\tDevice speed capability:");
> +	if (speed_capa == ETH_LINK_SPEED_AUTONEG)
> +		printf(" Autonegotiate (all speeds)");
> +	if (speed_capa & ETH_LINK_SPEED_FIXED)
> +		printf(" Disable autonegotiate (fixed speed)  ");
> +	if (speed_capa & ETH_LINK_SPEED_10M_HD)
> +		printf(" 10 Mbps half-duplex  ");
> +	if (speed_capa & ETH_LINK_SPEED_10M)
> +		printf(" 10 Mbps full-duplex  ");
> +	if (speed_capa & ETH_LINK_SPEED_100M_HD)
> +		printf(" 100 Mbps half-duplex  ");
> +	if (speed_capa & ETH_LINK_SPEED_100M)
> +		printf(" 100 Mbps full-duplex  ");
> +	if (speed_capa & ETH_LINK_SPEED_1G)
> +		printf(" 1 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_2_5G)
> +		printf(" 2.5 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_5G)
> +		printf(" 5 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_10G)
> +		printf(" 10 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_20G)
> +		printf(" 20 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_25G)
> +		printf(" 25 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_40G)
> +		printf(" 40 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_50G)
> +		printf(" 50 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_56G)
> +		printf(" 56 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_100G)
> +		printf(" 100 Gbps  ");
> +	if (speed_capa & ETH_LINK_SPEED_200G)
> +		printf(" 200 Gbps  ");
> +}
> +
>   void
>   device_infos_display(const char *identifier)
>   {
> @@ -518,6 +558,7 @@ device_infos_display(const char *identifier)
>   	struct rte_device *dev;
>   	struct rte_devargs da;
>   	portid_t port_id;
> +	struct rte_eth_dev_info dev_info;
>   	char devstr[128];
>   
>   	memset(&da, 0, sizeof(da));
> @@ -569,6 +610,8 @@ device_infos_display(const char *identifier)
>   						      &mac_addr);
>   				rte_eth_dev_get_name_by_port(port_id, name);
>   				printf("\n\tDevice name: %s", name);
> +				if (rte_eth_dev_info_get(port_id, &dev_info) > 0)

My bad, this should be  (rte_eth_dev_info_get(port_id, &dev_info) == 0), I can 
fix while merging.

Except from above,
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit Oct. 9, 2020, 11:53 a.m. UTC | #2
On 10/9/2020 10:27 AM, Ferruh Yigit wrote:
> On 10/8/2020 7:25 PM, Sarosh Arif wrote:
>> Called rte_eth_dev_info_get() in testpmd, to get device info
>> so that speed capabilities can be printed under "show device info"
>> ​
>> Bugzilla ID: 496
>> Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
 >

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

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 30bee3324..68a7de7cf 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -507,6 +507,46 @@  static int bus_match_all(const struct rte_bus *bus, const void *data)
 	return 0;
 }
 
+static void
+device_infos_display_speeds(uint32_t speed_capa)
+{
+	printf("\n\tDevice speed capability:");
+	if (speed_capa == ETH_LINK_SPEED_AUTONEG)
+		printf(" Autonegotiate (all speeds)");
+	if (speed_capa & ETH_LINK_SPEED_FIXED)
+		printf(" Disable autonegotiate (fixed speed)  ");
+	if (speed_capa & ETH_LINK_SPEED_10M_HD)
+		printf(" 10 Mbps half-duplex  ");
+	if (speed_capa & ETH_LINK_SPEED_10M)
+		printf(" 10 Mbps full-duplex  ");
+	if (speed_capa & ETH_LINK_SPEED_100M_HD)
+		printf(" 100 Mbps half-duplex  ");
+	if (speed_capa & ETH_LINK_SPEED_100M)
+		printf(" 100 Mbps full-duplex  ");
+	if (speed_capa & ETH_LINK_SPEED_1G)
+		printf(" 1 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_2_5G)
+		printf(" 2.5 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_5G)
+		printf(" 5 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_10G)
+		printf(" 10 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_20G)
+		printf(" 20 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_25G)
+		printf(" 25 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_40G)
+		printf(" 40 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_50G)
+		printf(" 50 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_56G)
+		printf(" 56 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_100G)
+		printf(" 100 Gbps  ");
+	if (speed_capa & ETH_LINK_SPEED_200G)
+		printf(" 200 Gbps  ");
+}
+
 void
 device_infos_display(const char *identifier)
 {
@@ -518,6 +558,7 @@  device_infos_display(const char *identifier)
 	struct rte_device *dev;
 	struct rte_devargs da;
 	portid_t port_id;
+	struct rte_eth_dev_info dev_info;
 	char devstr[128];
 
 	memset(&da, 0, sizeof(da));
@@ -569,6 +610,8 @@  device_infos_display(const char *identifier)
 						      &mac_addr);
 				rte_eth_dev_get_name_by_port(port_id, name);
 				printf("\n\tDevice name: %s", name);
+				if (rte_eth_dev_info_get(port_id, &dev_info) > 0)
+					device_infos_display_speeds(dev_info.speed_capa);
 				printf("\n");
 			}
 		}