From ff70acdf4299e5e8156e0fb12dddfe02bafb5741 Mon Sep 17 00:00:00 2001 From: Selwin Sebastian Date: Wed, 6 Jan 2021 13:30:58 +0530 Subject: [PATCH] net/axgbe: support reading FW version Added support for fw_version_get API Signed-off-by: Selwin Sebastian Acked-by: Somalapuram Amaranath --- doc/guides/nics/features/axgbe.ini | 1 + drivers/net/axgbe/axgbe_ethdev.c | 1 + drivers/net/axgbe/axgbe_rxtx.c | 28 ++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_rxtx.h | 3 +++ 4 files changed, 33 insertions(+) diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini index 4da9e62630..e2ad6efaf0 100644 --- a/doc/guides/nics/features/axgbe.ini +++ b/doc/guides/nics/features/axgbe.ini @@ -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 diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index f524a3be96..ddd903680d 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -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) diff --git a/drivers/net/axgbe/axgbe_rxtx.c b/drivers/net/axgbe/axgbe_rxtx.c index 71e3cffc50..e34bb6d448 100644 --- a/drivers/net/axgbe/axgbe_rxtx.c +++ b/drivers/net/axgbe/axgbe_rxtx.c @@ -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) { diff --git a/drivers/net/axgbe/axgbe_rxtx.h b/drivers/net/axgbe/axgbe_rxtx.h index f2fbe9299d..c2b11bb0e6 100644 --- a/drivers/net/axgbe/axgbe_rxtx.h +++ b/drivers/net/axgbe/axgbe_rxtx.h @@ -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,