net/axgbe: support reading FW version
authorSelwin Sebastian <selwin.sebastian@amd.com>
Wed, 6 Jan 2021 08:00:58 +0000 (13:30 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 13 Jan 2021 17:51:57 +0000 (18:51 +0100)
Added support for fw_version_get API

Signed-off-by: Selwin Sebastian <selwin.sebastian@amd.com>
Acked-by: Somalapuram Amaranath <asomalap@amd.com>
doc/guides/nics/features/axgbe.ini
drivers/net/axgbe/axgbe_ethdev.c
drivers/net/axgbe/axgbe_rxtx.c
drivers/net/axgbe/axgbe_rxtx.h

index 4da9e62..e2ad6ef 100644 (file)
@@ -18,6 +18,7 @@ CRC offload          = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Basic stats          = Y
+FW version           = Y
 Linux UIO            = Y
 x86-32               = Y
 x86-64               = Y
index f524a3b..ddd9036 100644 (file)
@@ -267,6 +267,7 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
        .timesync_adjust_time         = axgbe_timesync_adjust_time,
        .timesync_read_time           = axgbe_timesync_read_time,
        .timesync_write_time          = axgbe_timesync_write_time,
+       .fw_version_get                 = axgbe_dev_fw_version_get,
 };
 
 static int axgbe_phy_reset(struct axgbe_port *pdata)
index 71e3cff..e34bb6d 100644 (file)
@@ -613,6 +613,34 @@ int axgbe_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
        return 0;
 }
 
+int axgbe_dev_fw_version_get(struct rte_eth_dev *eth_dev,
+               char *fw_version, size_t fw_size)
+{
+       struct axgbe_port *pdata;
+       struct axgbe_hw_features *hw_feat;
+       int ret;
+
+       pdata = (struct axgbe_port *)eth_dev->data->dev_private;
+       hw_feat = &pdata->hw_feat;
+
+       if (fw_version == NULL)
+               return -EINVAL;
+
+       ret = snprintf(fw_version, fw_size, "%d.%d.%d",
+                       AXGMAC_GET_BITS(hw_feat->version, MAC_VR, USERVER),
+                       AXGMAC_GET_BITS(hw_feat->version, MAC_VR, DEVID),
+                       AXGMAC_GET_BITS(hw_feat->version, MAC_VR, SNPSVER));
+       if (ret < 0)
+               return -EINVAL;
+
+       ret += 1; /* add the size of '\0' */
+
+       if (fw_size < (size_t)ret)
+               return ret;
+       else
+               return 0;
+}
+
 static void axgbe_txq_prepare_tx_stop(struct axgbe_port *pdata,
                                      unsigned int queue)
 {
index f2fbe92..c2b11bb 100644 (file)
@@ -162,6 +162,9 @@ void axgbe_dev_disable_tx(struct rte_eth_dev *dev);
 int axgbe_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int axgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 
+int axgbe_dev_fw_version_get(struct rte_eth_dev *eth_dev,
+                       char *fw_version, size_t fw_size);
+
 uint16_t axgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                         uint16_t nb_pkts);
 uint16_t axgbe_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,