Skip to contentSkip to conversation

testpmd: added rte_eth_dev_fw_version_get in testpmd rte_eth_dev_fw_version_get() was not called in test pmd. Added rte_eth_dev_fw_version_get() in testpmd under show port info <port no>

PATCH In review Muhammad Ahmad 2 participants 3 messages Mar 16, 2020 – Mar 17, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testpmd: added rte_eth_dev_fw_version_get in testpmd rte_eth_dev_fw_version_get() was not called in test pmd. Added rte_eth_dev_fw_version_get() in testpmd under show port info <port no>

From: Muhammad Ahmad <[email protected]>

Bugzilla ID: 225

---
 app/test-pmd/config.c  |  6 ++++++
 app/test-pmd/testpmd.h |  3 ++-
 app/test-pmd/util.c    | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
app/test-pmd/config.c +6 -0
index 8cf84ccd3..0abec7d47 100644
@@ -52,6 +52,8 @@
 
 #include "testpmd.h"
 
+#define ETHTOOL_FWVERS_LEN 32
+
 static char *flowtype_to_str(uint16_t flow_type);
 
 static const struct {
@@ -523,6 +525,7 @@ port_infos_display(portid_t port_id)
 	uint16_t mtu;
 	char name[RTE_ETH_NAME_MAX_LEN];
 	int ret;
+	char   fw_version[ETHTOOL_FWVERS_LEN];
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
 		print_valid_ports();
@@ -544,6 +547,9 @@ port_infos_display(portid_t port_id)
 	rte_eth_dev_get_name_by_port(port_id, name);
 	printf("\nDevice name: %s", name);
 	printf("\nDriver name: %s", dev_info.driver_name);
+	if (eth_dev_fw_version_get_err(port_id, fw_version,
+						 ETHTOOL_FWVERS_LEN) == 0)
+		printf("\nfirmware-version: %s", fw_version);
 	if (dev_info.device->devargs && dev_info.device->devargs->args)
 		printf("\nDevargs: %s", dev_info.device->devargs->args);
 	printf("\nConnect to socket: %u", port->socket_id);
app/test-pmd/testpmd.h +2 -1
index 7a7c73f79..6b7842d3d 100644
@@ -850,7 +850,8 @@ void eth_set_allmulticast_mode(uint16_t port, int enable);
 int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
 int eth_macaddr_get_print_err(uint16_t port_id,
 			struct rte_ether_addr *mac_addr);
-
+int eth_dev_fw_version_get_err(uint16_t port_id,
+			 char *fw_version, size_t fw_size);
 /* Functions to display the set of MAC addresses added to a port*/
 void show_macs(portid_t port_id);
 void show_mcast_macs(portid_t port_id);
app/test-pmd/util.c +14 -0
index 8488fa1a8..2ac76f18e 100644
@@ -375,3 +375,17 @@ eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr)
 
 	return ret;
 }
+
+int
+eth_dev_fw_version_get_err(uint16_t port_id, char *fw_version, size_t fw_size)
+{
+	int ret;
+
+	ret = rte_eth_dev_fw_version_get(port_id, fw_version, fw_size);
+	if (ret < 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));
+	else if (ret > 0)
+		printf("Insufficient fw version buffer size, "
+		       "the minimum size should be %d\n", ret);
+	return ret;
+}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 2 lines · Muhammad Ahmad

From: Muhammad Ahmad <[email protected]>

Hi Muhammed,

Can you please keep the patch title short, ~70 chars, and put the detail in the commit log?

Quoted 16 lines

Bugzilla ID: 225

---
 app/test-pmd/config.c  |  6 ++++++
 app/test-pmd/testpmd.h |  3 ++-
 app/test-pmd/util.c    | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
app/test-pmd/config.c +0 -0
index 8cf84ccd3..0abec7d47 100644

app/test-pmd/config.c line 55

Quoted 4 lines
app/test-pmd/config.c +1 -0
@@ -52,6 +52,8 @@
 
 #include "testpmd.h"
 
+#define ETHTOOL_FWVERS_LEN 32> +

Why "ETHTOOL" ?

Quoted 12 lines
app/test-pmd/config.c +1 -0
 static char *flowtype_to_str(uint16_t flow_type);
 
 static const struct {
@@ -523,6 +525,7 @@ port_infos_display(portid_t port_id)
 	uint16_t mtu;
 	char name[RTE_ETH_NAME_MAX_LEN];
 	int ret;
+	char   fw_version[ETHTOOL_FWVERS_LEN];
 
 	if (port_id_is_invalid(port_id, ENABLED_WARN)) {
 		print_valid_ports();

app/test-pmd/config.c port_infos_display(portid_t port_id) · line 552

Quoted 6 lines
app/test-pmd/config.c +3 -0
@@ -544,6 +547,9 @@ port_infos_display(portid_t port_id)
 	rte_eth_dev_get_name_by_port(port_id, name);
 	printf("\nDevice name: %s", name);
 	printf("\nDriver name: %s", dev_info.driver_name);
+	if (eth_dev_fw_version_get_err(port_id, fw_version,
+						 ETHTOOL_FWVERS_LEN) == 0)
+		printf("\nfirmware-version: %s", fw_version);

What do you think starting with uppercase, like "Firmware-version: ...", to be consistent.

Quoted 24 lines
app/test-pmd/config.c +0 -0
 	if (dev_info.device->devargs && dev_info.device->devargs->args)
 		printf("\nDevargs: %s", dev_info.device->devargs->args);
 	printf("\nConnect to socket: %u", port->socket_id);
app/test-pmd/testpmd.h +2 -1
index 7a7c73f79..6b7842d3d 100644
@@ -850,7 +850,8 @@ void eth_set_allmulticast_mode(uint16_t port, int enable);
 int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
 int eth_macaddr_get_print_err(uint16_t port_id,
 			struct rte_ether_addr *mac_addr);
-
+int eth_dev_fw_version_get_err(uint16_t port_id,
+			 char *fw_version, size_t fw_size);
 /* Functions to display the set of MAC addresses added to a port*/
 void show_macs(portid_t port_id);
 void show_mcast_macs(portid_t port_id);
app/test-pmd/util.c +0 -0
index 8488fa1a8..2ac76f18e 100644
@@ -375,3 +375,17 @@ eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr)
 
 	return ret;

app/test-pmd/util.c eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr) · line 386

Quoted 10 lines
app/test-pmd/util.c +9 -0
 }
+
+int
+eth_dev_fw_version_get_err(uint16_t port_id, char *fw_version, size_t fw_size)
+{
+	int ret;
+
+	ret = rte_eth_dev_fw_version_get(port_id, fw_version, fw_size);
+	if (ret < 0)
+		printf("firmware version get error: (%s)\n", strerror(-ret));

For the drivers doesn't support getting FW version, these errors are printed in the middle of the port info, so instead of this helper function, what do you think calling rte_eth_dev_fw_version_get() directly from port_infos_display()?

Quoted 6 lines
app/test-pmd/util.c +5 -0
+	else if (ret > 0)
+		printf("Insufficient fw version buffer size, "
+		       "the minimum size should be %d\n", ret);
+	return ret;
+}
#2 lore raw

Hi Ferruh,
Thank you for the comments.

Quoted 9 lines · Ferruh Yigit
Quoted 2 lines · Muhammad Ahmad

From: Muhammad Ahmad <[email protected]>

Hi Muhammed,

Can you please keep the patch title short, ~70 chars, and put the detail in the commit log?

Sure will do that.

Quoted 18 lines
Quoted 18 lines

Bugzilla ID: 225

---
 app/test-pmd/config.c  |  6 ++++++
 app/test-pmd/testpmd.h |  3 ++-
 app/test-pmd/util.c    | 14 ++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
app/test-pmd/config.c +0 -0
index 8cf84ccd3..0abec7d47 100644
@@ -52,6 +52,8 @@
 
Quoted 5 lines

app/test-pmd/config.c

Quoted 3 lines
app/test-pmd/config.c +1 -0
 #include "testpmd.h"
 
+#define ETHTOOL_FWVERS_LEN 32> +

Why "ETHTOOL" ?

I mistakenly wrote "ETHTOOL" instead of "ETHDEV". I will update it to "ETHDEV"

Quoted 10 lines
Quoted 10 lines
app/test-pmd/config.c +1 -0
 static char *flowtype_to_str(uint16_t flow_type);
 
 static const struct {
@@ -523,6 +525,7 @@ port_infos_display(portid_t port_id)
      uint16_t mtu;
      char name[RTE_ETH_NAME_MAX_LEN];
      int ret;
+     char   fw_version[ETHTOOL_FWVERS_LEN];
 
Quoted 12 lines

app/test-pmd/config.c port_infos_display(portid_t port_id) · line 552

Quoted 9 lines
app/test-pmd/config.c +3 -0
      if (port_id_is_invalid(port_id, ENABLED_WARN)) {
              print_valid_ports();
@@ -544,6 +547,9 @@ port_infos_display(portid_t port_id)
      rte_eth_dev_get_name_by_port(port_id, name);
      printf("\nDevice name: %s", name);
      printf("\nDriver name: %s", dev_info.driver_name);
+     if (eth_dev_fw_version_get_err(port_id, fw_version,
+                                              ETHTOOL_FWVERS_LEN) == 0)
+             printf("\nfirmware-version: %s", fw_version);

What do you think starting with uppercase, like "Firmware-version: ...", to be consistent.

Will do that.

Quoted 24 lines
Quoted 24 lines
app/test-pmd/config.c +0 -0
      if (dev_info.device->devargs && dev_info.device->devargs->args)
              printf("\nDevargs: %s", dev_info.device->devargs->args);
      printf("\nConnect to socket: %u", port->socket_id);
app/test-pmd/testpmd.h +2 -1
index 7a7c73f79..6b7842d3d 100644
@@ -850,7 +850,8 @@ void eth_set_allmulticast_mode(uint16_t port, int enable);
 int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link);
 int eth_macaddr_get_print_err(uint16_t port_id,
                      struct rte_ether_addr *mac_addr);
-
+int eth_dev_fw_version_get_err(uint16_t port_id,
+                      char *fw_version, size_t fw_size);
 /* Functions to display the set of MAC addresses added to a port*/
 void show_macs(portid_t port_id);
 void show_mcast_macs(portid_t port_id);
app/test-pmd/util.c +0 -0
index 8488fa1a8..2ac76f18e 100644
@@ -375,3 +375,17 @@ eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr)
 
Quoted 15 lines

app/test-pmd/util.c eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr) · line 386

Quoted 11 lines
app/test-pmd/util.c +9 -0
      return ret;
 }
+
+int
+eth_dev_fw_version_get_err(uint16_t port_id, char *fw_version, size_t fw_size)
+{
+     int ret;
+
+     ret = rte_eth_dev_fw_version_get(port_id, fw_version, fw_size);
+     if (ret < 0)
+             printf("firmware version get error: (%s)\n", strerror(-ret));

For the drivers doesn't support getting FW version, these errors are printed in the middle of the port info, so instead of this helper function, what do you think calling rte_eth_dev_fw_version_get() directly from port_infos_display()?

If I call the rte_eth_dev_fw_version_get() from port_infos_display() It will still print the error at the same place.
Do you want skip printing the error?

Quoted 8 lines
Quoted 7 lines
app/test-pmd/util.c +5 -0
+     else if (ret > 0)
+             printf("Insufficient fw version buffer size, "
+                    "the minimum size should be %d\n", ret);
+     return ret;
+}