[v2,09/13] ethdev: add firmware version in telemetry info command

Message ID 20230607074209.4798-10-haijie1@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series support telemetry query ethdev info |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jie Hai June 7, 2023, 7:42 a.m. UTC
  This patch adds firmware version in telemetry info command.
An example is like:
--> /ethdev/info,0
{
  "/ethdev/info": {
    "name": "0000:bd:00.0",
    "fw_version": "1.20.0.17",
    ....
   }
}

Signed-off-by: Jie Hai <haijie1@huawei.com>
---
 lib/ethdev/rte_ethdev_telemetry.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index f69bcedac86f..930181e5324f 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -281,6 +281,7 @@  eth_dev_handle_port_info(const char *cmd __rte_unused,
 {
 	struct rte_tel_data *rx_offload, *tx_offload;
 	struct rte_tel_data *rxq_state, *txq_state;
+	char fw_version[RTE_TEL_MAX_STRING_LEN];
 	char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
 	struct rte_eth_dev *eth_dev;
 	uint16_t port_id;
@@ -312,6 +313,11 @@  eth_dev_handle_port_info(const char *cmd __rte_unused,
 
 	rte_tel_data_start_dict(d);
 	rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+
+	if (rte_eth_dev_fw_version_get(port_id, fw_version,
+					 RTE_TEL_MAX_STRING_LEN) == 0)
+		rte_tel_data_add_dict_string(d, "fw_version", fw_version);
+
 	rte_tel_data_add_dict_int(d, "state", eth_dev->state);
 	rte_tel_data_add_dict_int(d, "nb_rx_queues",
 			eth_dev->data->nb_rx_queues);