diff mbox series

[2/2] net/cxgbe: add support to get firmware version

Message ID db2b319f19f99e595e6443c1e6c0a664d3046441.1632763269.git.rahul.lakkireddy@chelsio.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers show
Series net/cxgbe: fetch VF xstats and firmware version | expand

Checks

Context Check Description
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Rahul Lakkireddy Sept. 27, 2021, 6:01 p.m. UTC
From: Nikhil Vasoya <nikhil.vasoya@chelsio.com>

Implement eth_dev_ops callback to get firmware version.

Signed-off-by: Nikhil Vasoya <nikhil.vasoya@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/cxgbe_ethdev.c   | 26 ++++++++++++++++++++++++++
 drivers/net/cxgbe/cxgbe_pfvf.h     |  2 ++
 drivers/net/cxgbe/cxgbevf_ethdev.c |  1 +
 3 files changed, 29 insertions(+)

Comments

Ferruh Yigit Sept. 30, 2021, 4:12 p.m. UTC | #1
On 9/27/2021 7:01 PM, Rahul Lakkireddy wrote:
> From: Nikhil Vasoya <nikhil.vasoya@chelsio.com>
> 
> Implement eth_dev_ops callback to get firmware version.
> 
> Signed-off-by: Nikhil Vasoya <nikhil.vasoya@chelsio.com>
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>  drivers/net/cxgbe/cxgbe_ethdev.c   | 26 ++++++++++++++++++++++++++
>  drivers/net/cxgbe/cxgbe_pfvf.h     |  2 ++
>  drivers/net/cxgbe/cxgbevf_ethdev.c |  1 +

Similarly can you please announce "FW version" feature in .ini files?
diff mbox series

Patch

diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c
index a6b5c0110a..304fafed25 100644
--- a/drivers/net/cxgbe/cxgbe_ethdev.c
+++ b/drivers/net/cxgbe/cxgbe_ethdev.c
@@ -1620,6 +1620,31 @@  static int cxgbe_fec_set(struct rte_eth_dev *dev, uint32_t fec_capa)
 	return ret;
 }
 
+int cxgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+			 size_t fw_size)
+{
+	struct port_info *pi = dev->data->dev_private;
+	struct adapter *adapter = pi->adapter;
+	int ret;
+
+	if (adapter->params.fw_vers == 0)
+		return -EIO;
+
+	ret = snprintf(fw_version, fw_size, "%u.%u.%u.%u",
+		       G_FW_HDR_FW_VER_MAJOR(adapter->params.fw_vers),
+		       G_FW_HDR_FW_VER_MINOR(adapter->params.fw_vers),
+		       G_FW_HDR_FW_VER_MICRO(adapter->params.fw_vers),
+		       G_FW_HDR_FW_VER_BUILD(adapter->params.fw_vers));
+	if (ret < 0)
+		return -EINVAL;
+
+	ret += 1;
+	if (fw_size < (size_t)ret)
+		return ret;
+
+	return 0;
+}
+
 static const struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.dev_start		= cxgbe_dev_start,
 	.dev_stop		= cxgbe_dev_stop,
@@ -1665,6 +1690,7 @@  static const struct eth_dev_ops cxgbe_eth_dev_ops = {
 	.fec_get_capability     = cxgbe_fec_get_capability,
 	.fec_get                = cxgbe_fec_get,
 	.fec_set                = cxgbe_fec_set,
+	.fw_version_get         = cxgbe_fw_version_get,
 };
 
 /*
diff --git a/drivers/net/cxgbe/cxgbe_pfvf.h b/drivers/net/cxgbe/cxgbe_pfvf.h
index 3c7aee0ae7..81d0fce2e5 100644
--- a/drivers/net/cxgbe/cxgbe_pfvf.h
+++ b/drivers/net/cxgbe/cxgbe_pfvf.h
@@ -63,4 +63,6 @@  int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
 			       unsigned int n);
 int cxgbe_dev_xstats_get(struct rte_eth_dev *dev,
 			 struct rte_eth_xstat *xstats, unsigned int n);
+int cxgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
+			 size_t fw_size);
 #endif /* _CXGBE_PFVF_H_ */
diff --git a/drivers/net/cxgbe/cxgbevf_ethdev.c b/drivers/net/cxgbe/cxgbevf_ethdev.c
index 4c809991b7..a62c56c2b9 100644
--- a/drivers/net/cxgbe/cxgbevf_ethdev.c
+++ b/drivers/net/cxgbe/cxgbevf_ethdev.c
@@ -92,6 +92,7 @@  static const struct eth_dev_ops cxgbevf_eth_dev_ops = {
 	.xstats_get_names       = cxgbe_dev_xstats_get_names,
 	.xstats_get_names_by_id = cxgbe_dev_xstats_get_names_by_id,
 	.mac_addr_set		= cxgbe_mac_addr_set,
+	.fw_version_get         = cxgbe_fw_version_get,
 };
 
 /*