net/i40e: add firmware version get
authorQiming Yang <qiming.yang@intel.com>
Mon, 16 Jan 2017 10:48:30 +0000 (18:48 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Jan 2017 21:34:36 +0000 (22:34 +0100)
This patch add a new function i40e_fw_version_get.

Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
doc/guides/nics/features/i40e.ini
drivers/net/i40e/i40e_ethdev.c

index 0d143bc..0dbc3c3 100644 (file)
@@ -39,6 +39,7 @@ Packet type parsing  = Y
 Timesync             = Y
 Basic stats          = Y
 Extended stats       = Y
+FW version           = Y
 Multiprocess aware   = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
index 1687144..7e0acd0 100644 (file)
@@ -324,6 +324,8 @@ static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
                                            uint16_t queue_id,
                                            uint8_t stat_idx,
                                            uint8_t is_rx);
+static int i40e_fw_version_get(struct rte_eth_dev *dev,
+                               char *fw_version, size_t fw_size);
 static void i40e_dev_info_get(struct rte_eth_dev *dev,
                              struct rte_eth_dev_info *dev_info);
 static int i40e_vlan_filter_set(struct rte_eth_dev *dev,
@@ -503,6 +505,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
        .stats_reset                  = i40e_dev_stats_reset,
        .xstats_reset                 = i40e_dev_stats_reset,
        .queue_stats_mapping_set      = i40e_dev_queue_stats_mapping_set,
+       .fw_version_get               = i40e_fw_version_get,
        .dev_infos_get                = i40e_dev_info_get,
        .dev_supported_ptypes_get     = i40e_dev_supported_ptypes_get,
        .vlan_filter_set              = i40e_vlan_filter_set,
@@ -2594,6 +2597,34 @@ i40e_dev_queue_stats_mapping_set(__rte_unused struct rte_eth_dev *dev,
        return -ENOSYS;
 }
 
+static int
+i40e_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+       struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       u32 full_ver;
+       u8 ver, patch;
+       u16 build;
+       int ret;
+
+       full_ver = hw->nvm.oem_ver;
+       ver = (u8)(full_ver >> 24);
+       build = (u16)((full_ver >> 8) & 0xffff);
+       patch = (u8)(full_ver & 0xff);
+
+       ret = snprintf(fw_version, fw_size,
+                "%d.%d%d 0x%08x %d.%d.%d",
+                ((hw->nvm.version >> 12) & 0xf),
+                ((hw->nvm.version >> 4) & 0xff),
+                (hw->nvm.version & 0xf), hw->nvm.eetrack,
+                ver, build, patch);
+
+       ret += 1; /* add the size of '\0' */
+       if (fw_size < (u32)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static void
 i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {