From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44F74A0C43; Thu, 30 Sep 2021 19:12:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4053C4111F; Thu, 30 Sep 2021 19:12:30 +0200 (CEST) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by mails.dpdk.org (Postfix) with ESMTP id E619341104 for ; Thu, 30 Sep 2021 19:12:28 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.14.7/8.14.7) with ESMTP id 18UHCNiO001709; Thu, 30 Sep 2021 10:12:24 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: nikhil.vasoya@chelsio.com Date: Thu, 30 Sep 2021 22:39:59 +0530 Message-Id: X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 2/2] net/cxgbe: add support to get firmware version X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Nikhil Vasoya Implement eth_dev_ops callback to get firmware version. Signed-off-by: Nikhil Vasoya Signed-off-by: Rahul Lakkireddy --- v2: - Update FW version feature in cxgbe.ini and cxgbevf.ini doc/guides/nics/features/cxgbe.ini | 1 + doc/guides/nics/features/cxgbevf.ini | 1 + drivers/net/cxgbe/cxgbe_ethdev.c | 26 ++++++++++++++++++++++++++ drivers/net/cxgbe/cxgbe_pfvf.h | 2 ++ drivers/net/cxgbe/cxgbevf_ethdev.c | 1 + 5 files changed, 31 insertions(+) diff --git a/doc/guides/nics/features/cxgbe.ini b/doc/guides/nics/features/cxgbe.ini index 6721740fbd..f41fc14825 100644 --- a/doc/guides/nics/features/cxgbe.ini +++ b/doc/guides/nics/features/cxgbe.ini @@ -26,6 +26,7 @@ Packet type parsing = Y Basic stats = Y Extended stats = Y Stats per queue = Y +FW version = Y EEPROM dump = Y Registers dump = Y Multiprocess aware = Y diff --git a/doc/guides/nics/features/cxgbevf.ini b/doc/guides/nics/features/cxgbevf.ini index c8a25c9a8b..a3174ef399 100644 --- a/doc/guides/nics/features/cxgbevf.ini +++ b/doc/guides/nics/features/cxgbevf.ini @@ -22,6 +22,7 @@ Packet type parsing = Y Basic stats = Y Extended stats = Y Stats per queue = Y +FW version = Y Multiprocess aware = Y Linux = Y x86-32 = Y 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, }; /* -- 2.27.0