[v3] testpmd: add speed capability in device info
Checks
Commit Message
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>
---
v2:
display all speed capabilities in a single line
remove switch case
v3:
add missing speeds
make a function for displaying speed capabilities
---
app/test-pmd/config.c | 45 ++++++++++++++++++++++++++++++++++++++++++
app/test-pmd/testpmd.h | 1 +
2 files changed, 46 insertions(+)
Comments
On 10/8/2020 12:49 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>
> ---
> v2:
> display all speed capabilities in a single line
> remove switch case
> v3:
> add missing speeds
> make a function for displaying speed capabilities
> ---
> app/test-pmd/config.c | 45 ++++++++++++++++++++++++++++++++++++++++++
> app/test-pmd/testpmd.h | 1 +
> 2 files changed, 46 insertions(+)
>
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
> index 30bee3324..95c2798c8 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;
> }
>
> +void
> +device_infos_display_speeds(uint32_t speed_capa)
> +{
Can you please make the function static?
<...>
> @@ -569,6 +611,9 @@ device_infos_display(const char *identifier)
> &mac_addr);
> rte_eth_dev_get_name_by_port(port_id, name);
> printf("\n\tDevice name: %s", name);
> + rte_eth_dev_info_get(port_id, &dev_info);
It is very unlikely that it will fail but still it can be good add the return
value check
if (rte_eth_dev_info_get(port_id, &dev_info) > 0)
device_infos_display_speeds(dev_info.speed_capa);
> + speed_capa = dev_info.speed_capa;
> + device_infos_display_speeds(speed_capa);
Is the 'speed_capa' variable still needed? Why not directly use
'dev_info.speed_capa'?
> printf("\n");
> }
> }
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 25a12b14f..0773016f7 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -694,6 +694,7 @@ void nic_stats_clear(portid_t port_id);
> void nic_xstats_display(portid_t port_id);
> void nic_xstats_clear(portid_t port_id);
> void nic_stats_mapping_display(portid_t port_id);
> +void device_infos_display_speeds(uint32_t speed_capa);
If function becomes static this deceleration won't be needed.
@@ -507,6 +507,46 @@ static int bus_match_all(const struct rte_bus *bus, const void *data)
return 0;
}
+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,7 +558,9 @@ 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];
+ uint32_t speed_capa;
memset(&da, 0, sizeof(da));
if (!identifier)
@@ -569,6 +611,9 @@ device_infos_display(const char *identifier)
&mac_addr);
rte_eth_dev_get_name_by_port(port_id, name);
printf("\n\tDevice name: %s", name);
+ rte_eth_dev_info_get(port_id, &dev_info);
+ speed_capa = dev_info.speed_capa;
+ device_infos_display_speeds(speed_capa);
printf("\n");
}
}
@@ -694,6 +694,7 @@ void nic_stats_clear(portid_t port_id);
void nic_xstats_display(portid_t port_id);
void nic_xstats_clear(portid_t port_id);
void nic_stats_mapping_display(portid_t port_id);
+void device_infos_display_speeds(uint32_t speed_capa);
void device_infos_display(const char *identifier);
void port_infos_display(portid_t port_id);
void port_summary_display(portid_t port_id);