net/ice: support FW version getting
authorWenzhuo Lu <wenzhuo.lu@intel.com>
Tue, 18 Dec 2018 08:46:36 +0000 (16:46 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 21 Dec 2018 15:22:41 +0000 (16:22 +0100)
Add ops fw_version_get.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Signed-off-by: Qiming Yang <qiming.yang@intel.com>
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
doc/guides/nics/features/ice.ini
drivers/net/ice/ice_ethdev.c

index 4d6ca4f..c2d91a0 100644 (file)
@@ -24,6 +24,7 @@ QinQ offload         = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+FW version           = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
 Linux VFIO           = Y
index 7c9ddcb..36295fd 100644 (file)
@@ -52,6 +52,8 @@ static int ice_rx_queue_intr_enable(struct rte_eth_dev *dev,
                                    uint16_t queue_id);
 static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
                                     uint16_t queue_id);
+static int ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+                             size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
                             uint16_t pvid, int on);
 
@@ -92,6 +94,7 @@ static const struct eth_dev_ops ice_eth_dev_ops = {
        .rss_hash_conf_get            = ice_rss_hash_conf_get,
        .rx_queue_intr_enable         = ice_rx_queue_intr_enable,
        .rx_queue_intr_disable        = ice_rx_queue_intr_disable,
+       .fw_version_get               = ice_fw_version_get,
        .vlan_pvid_set                = ice_vlan_pvid_set,
        .rxq_info_get                 = ice_rxq_info_get,
        .txq_info_get                 = ice_txq_info_get,
@@ -2482,6 +2485,24 @@ static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
        return 0;
 }
 
+static int
+ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
+{
+       struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       int ret;
+
+       ret = snprintf(fw_version, fw_size, "%d.%d.%05d %d.%d",
+                      hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build,
+                      hw->api_maj_ver, hw->api_min_ver);
+
+       /* add the size of '\0' */
+       ret += 1;
+       if (fw_size < (u32)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static int
 ice_vsi_vlan_pvid_set(struct ice_vsi *vsi, struct ice_vsi_vlan_pvid_info *info)
 {