net/txgbe: support getting FW version
authorJiawen Wu <jiawenwu@trustnetic.com>
Mon, 19 Oct 2020 08:54:06 +0000 (16:54 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:27 +0000 (23:24 +0100)
Add firmware version get operation.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/nics/features/txgbe.ini
doc/guides/nics/txgbe.rst
drivers/net/txgbe/txgbe_ethdev.c

index 13ee26a..762adc8 100644 (file)
@@ -38,6 +38,7 @@ Packet type parsing  = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+FW version           = Y
 Multiprocess aware   = Y
 Linux UIO            = Y
 Linux VFIO           = Y
index 2337870..8e97e13 100644 (file)
@@ -26,6 +26,7 @@ Features
 - Interrupt mode for RX
 - Scattered and gather for TX and RX
 - DCB
+- FW version
 - LRO
 
 Prerequisites
index 70f0246..a57d22e 100644 (file)
@@ -2223,6 +2223,27 @@ txgbe_dev_xstats_reset(struct rte_eth_dev *dev)
        return 0;
 }
 
+static int
+txgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+       struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
+       u16 eeprom_verh, eeprom_verl;
+       u32 etrack_id;
+       int ret;
+
+       hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_H, &eeprom_verh);
+       hw->rom.readw_sw(hw, TXGBE_EEPROM_VERSION_L, &eeprom_verl);
+
+       etrack_id = (eeprom_verh << 16) | eeprom_verl;
+       ret = snprintf(fw_version, fw_size, "0x%08x", etrack_id);
+
+       ret += 1; /* add the size of '\0' */
+       if (fw_size < (u32)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static int
 txgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
@@ -3425,6 +3446,7 @@ static const struct eth_dev_ops txgbe_eth_dev_ops = {
        .xstats_get_names           = txgbe_dev_xstats_get_names,
        .xstats_get_names_by_id     = txgbe_dev_xstats_get_names_by_id,
        .queue_stats_mapping_set    = txgbe_dev_queue_stats_mapping_set,
+       .fw_version_get             = txgbe_fw_version_get,
        .dev_supported_ptypes_get   = txgbe_dev_supported_ptypes_get,
        .mtu_set                    = txgbe_dev_mtu_set,
        .vlan_filter_set            = txgbe_vlan_filter_set,