DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rasesh Mody <rmody@marvell.com>
To: <dev@dpdk.org>, <jerinj@marvell.com>, <ferruh.yigit@intel.com>
Cc: Rasesh Mody <rmody@marvell.com>,
	<GR-Everest-DPDK-Dev@marvell.com>,
	"Yash Sharma" <ysharma@marvell.com>,
	Igor Russkikh <irusskikh@marvell.com>
Subject: [dpdk-dev] [PATCH 2/2] net/qede: add support for get FW version
Date: Fri, 24 Apr 2020 23:13:47 -0700	[thread overview]
Message-ID: <20200425061347.18217-2-rmody@marvell.com> (raw)
In-Reply-To: <20200425061347.18217-1-rmody@marvell.com>

Add support for get firmware version operation.

Get and dump multi boot image (MBI) version as part of get
firmware version string along with Management fimrware (MFW) version.
Use qede_fw_version_get() for PMD info logs.

Signed-off-by: Yash Sharma <ysharma@marvell.com>
Signed-off-by: Rasesh Mody <rmody@marvell.com>
Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
---
---
 drivers/net/qede/base/ecore_mcp.c     | 37 +++++++++++
 drivers/net/qede/base/ecore_mcp_api.h | 12 ++++
 drivers/net/qede/qede_ethdev.c        | 96 ++++++++++++++++++---------
 drivers/net/qede/qede_if.h            |  9 +++
 drivers/net/qede/qede_main.c          |  3 +
 5 files changed, 126 insertions(+), 31 deletions(-)

diff --git a/drivers/net/qede/base/ecore_mcp.c b/drivers/net/qede/base/ecore_mcp.c
index 7518765a0..4dc22acd4 100644
--- a/drivers/net/qede/base/ecore_mcp.c
+++ b/drivers/net/qede/base/ecore_mcp.c
@@ -2245,6 +2245,43 @@ enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
 	return ECORE_SUCCESS;
 }
 
+int ecore_mcp_get_mbi_ver(struct ecore_hwfn *p_hwfn,
+			  struct ecore_ptt *p_ptt, u32 *p_mbi_ver)
+{
+	u32 nvm_cfg_addr, nvm_cfg1_offset, mbi_ver_addr;
+
+#ifndef ASIC_ONLY
+	if (CHIP_REV_IS_EMUL(p_hwfn->p_dev) && !ecore_mcp_is_init(p_hwfn)) {
+		DP_INFO(p_hwfn, "Emulation: Can't get MBI version\n");
+		return -EOPNOTSUPP;
+	}
+#endif
+
+	if (IS_VF(p_hwfn->p_dev))
+		return -EINVAL;
+
+	/* Read the address of the nvm_cfg */
+	nvm_cfg_addr = ecore_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0);
+	if (!nvm_cfg_addr) {
+		DP_NOTICE(p_hwfn, false, "Shared memory not initialized\n");
+		return -EINVAL;
+	}
+
+	/* Read the offset of nvm_cfg1 */
+	nvm_cfg1_offset = ecore_rd(p_hwfn, p_ptt, nvm_cfg_addr + 4);
+
+	mbi_ver_addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
+	    offsetof(struct nvm_cfg1, glob) + offsetof(struct nvm_cfg1_glob,
+						       mbi_version);
+	*p_mbi_ver =
+	    ecore_rd(p_hwfn, p_ptt,
+		     mbi_ver_addr) & (NVM_CFG1_GLOB_MBI_VERSION_0_MASK |
+				      NVM_CFG1_GLOB_MBI_VERSION_1_MASK |
+				      NVM_CFG1_GLOB_MBI_VERSION_2_MASK);
+
+	return 0;
+}
+
 enum _ecore_status_t ecore_mcp_get_media_type(struct ecore_hwfn *p_hwfn,
 					      struct ecore_ptt *p_ptt,
 					      u32 *p_media_type)
diff --git a/drivers/net/qede/base/ecore_mcp_api.h b/drivers/net/qede/base/ecore_mcp_api.h
index 7327074fd..b9ff0cd5d 100644
--- a/drivers/net/qede/base/ecore_mcp_api.h
+++ b/drivers/net/qede/base/ecore_mcp_api.h
@@ -587,6 +587,18 @@ enum _ecore_status_t ecore_mcp_get_mfw_ver(struct ecore_hwfn *p_hwfn,
 					   u32 *p_mfw_ver,
 					   u32 *p_running_bundle_id);
 
+/**
+ * @brief Get the MBI version value
+ *
+ * @param p_hwfn
+ * @param p_ptt
+ * @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
+ *
+ * @return int - 0 - operation was successful.
+ */
+int ecore_mcp_get_mbi_ver(struct ecore_hwfn *p_hwfn,
+			  struct ecore_ptt *p_ptt, u32 *p_mbi_ver);
+
 /**
  * @brief Get media type value of the port.
  *
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 19d2e9619..3005495b4 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -232,6 +232,58 @@ static const struct rte_qede_xstats_name_off qede_rxq_xstats_strings[] = {
 		offsetof(struct qede_rx_queue, rx_alloc_errors)}
 };
 
+/* Get FW version string based on fw_size */
+static int
+qede_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)
+{
+	struct qede_dev *qdev = dev->data->dev_private;
+	struct ecore_dev *edev = &qdev->edev;
+	struct qed_dev_info *info = &qdev->dev_info.common;
+	static char ver_str[QEDE_PMD_DRV_VER_STR_SIZE];
+	size_t size;
+
+	if (fw_ver == NULL)
+		return 0;
+
+	if (IS_PF(edev))
+		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
+			 QEDE_PMD_FW_VERSION);
+	else
+		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%d.%d.%d.%d",
+			 info->fw_major, info->fw_minor,
+			 info->fw_rev, info->fw_eng);
+	size = strlen(ver_str);
+	if (size + 1 <= fw_size) /* Add 1 byte for "\0" */
+		strlcpy(fw_ver, ver_str, fw_size);
+	else
+		return (size + 1);
+
+	snprintf(ver_str + size, (QEDE_PMD_DRV_VER_STR_SIZE - size),
+		 " MFW: %d.%d.%d.%d",
+		 GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_3),
+		 GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_2),
+		 GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_1),
+		 GET_MFW_FIELD(info->mfw_rev, QED_MFW_VERSION_0));
+	size = strlen(ver_str);
+	if (size + 1 <= fw_size)
+		strlcpy(fw_ver, ver_str, fw_size);
+
+	if (fw_size <= 32)
+		goto out;
+
+	snprintf(ver_str + size, (QEDE_PMD_DRV_VER_STR_SIZE - size),
+		 " MBI: %d.%d.%d",
+		 GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_2),
+		 GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_1),
+		 GET_MFW_FIELD(info->mbi_version, QED_MBI_VERSION_0));
+	size = strlen(ver_str);
+	if (size + 1 <= fw_size)
+		strlcpy(fw_ver, ver_str, fw_size);
+
+out:
+	return 0;
+}
+
 static void qede_interrupt_action(struct ecore_hwfn *p_hwfn)
 {
 	ecore_int_sp_dpc((osal_int_ptr_t)(p_hwfn));
@@ -274,47 +326,27 @@ qede_alloc_etherdev(struct qede_dev *qdev, struct qed_dev_eth_info *info)
 	qdev->ops = qed_ops;
 }
 
-static void qede_print_adapter_info(struct qede_dev *qdev)
+static void qede_print_adapter_info(struct rte_eth_dev *dev)
 {
+	struct qede_dev *qdev = dev->data->dev_private;
 	struct ecore_dev *edev = &qdev->edev;
-	struct qed_dev_info *info = &qdev->dev_info.common;
 	static char ver_str[QEDE_PMD_DRV_VER_STR_SIZE];
 
 	DP_INFO(edev, "**************************************************\n");
-	DP_INFO(edev, " DPDK version\t\t\t: %s\n", rte_version());
-	DP_INFO(edev, " Chip details\t\t\t: %s %c%d\n",
+	DP_INFO(edev, " %-20s: %s\n", "DPDK version", rte_version());
+	DP_INFO(edev, " %-20s: %s %c%d\n", "Chip details",
 		  ECORE_IS_BB(edev) ? "BB" : "AH",
 		  'A' + edev->chip_rev,
 		  (int)edev->chip_metal);
 	snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
 		 QEDE_PMD_DRV_VERSION);
-	DP_INFO(edev, " Driver version\t\t\t: %s\n", ver_str);
-
+	DP_INFO(edev, " %-20s: %s\n", "Driver version", ver_str);
 	snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
 		 QEDE_PMD_BASE_VERSION);
-	DP_INFO(edev, " Base version\t\t\t: %s\n", ver_str);
-
-	if (!IS_VF(edev))
-		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%s",
-			 QEDE_PMD_FW_VERSION);
-	else
-		snprintf(ver_str, QEDE_PMD_DRV_VER_STR_SIZE, "%d.%d.%d.%d",
-			 info->fw_major, info->fw_minor,
-			 info->fw_rev, info->fw_eng);
-	DP_INFO(edev, " Firmware version\t\t\t: %s\n", ver_str);
-
-	snprintf(ver_str, MCP_DRV_VER_STR_SIZE,
-		 "%d.%d.%d.%d",
-		 (info->mfw_rev & QED_MFW_VERSION_3_MASK) >>
-		 QED_MFW_VERSION_3_OFFSET,
-		 (info->mfw_rev & QED_MFW_VERSION_2_MASK) >>
-		 QED_MFW_VERSION_2_OFFSET,
-		 (info->mfw_rev & QED_MFW_VERSION_1_MASK) >>
-		 QED_MFW_VERSION_1_OFFSET,
-		 (info->mfw_rev & QED_MFW_VERSION_0_MASK) >>
-		 QED_MFW_VERSION_0_OFFSET);
-	DP_INFO(edev, " Management Firmware version\t: %s\n", ver_str);
-	DP_INFO(edev, " Firmware file\t\t\t: %s\n", qede_fw_file);
+	DP_INFO(edev, " %-20s: %s\n", "Base version", ver_str);
+	qede_fw_version_get(dev, ver_str, sizeof(ver_str));
+	DP_INFO(edev, " %-20s: %s\n", "Firmware version", ver_str);
+	DP_INFO(edev, " %-20s: %s\n", "Firmware file", qede_fw_file);
 	DP_INFO(edev, "**************************************************\n");
 }
 
@@ -2351,6 +2383,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
 	.filter_ctrl = qede_dev_filter_ctrl,
 	.udp_tunnel_port_add = qede_udp_dst_port_add,
 	.udp_tunnel_port_del = qede_udp_dst_port_del,
+	.fw_version_get = qede_fw_version_get,
 };
 
 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -2391,6 +2424,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {
 	.mac_addr_add = qede_mac_addr_add,
 	.mac_addr_remove = qede_mac_addr_remove,
 	.mac_addr_set = qede_mac_addr_set,
+	.fw_version_get = qede_fw_version_get,
 };
 
 static void qede_update_pf_params(struct ecore_dev *edev)
@@ -2544,7 +2578,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)
 	qede_alloc_etherdev(adapter, &dev_info);
 
 	if (do_once) {
-		qede_print_adapter_info(adapter);
+		qede_print_adapter_info(eth_dev);
 		do_once = false;
 	}
 
@@ -2652,7 +2686,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf)
 
 err:
 	if (do_once) {
-		qede_print_adapter_info(adapter);
+		qede_print_adapter_info(eth_dev);
 		do_once = false;
 	}
 	return rc;
diff --git a/drivers/net/qede/qede_if.h b/drivers/net/qede/qede_if.h
index 02feaba16..858cd51d5 100644
--- a/drivers/net/qede/qede_if.h
+++ b/drivers/net/qede/qede_if.h
@@ -45,6 +45,15 @@ struct qed_dev_info {
 
 	bool smart_an;
 
+	/* MBI version */
+	uint32_t mbi_version;
+#define QED_MBI_VERSION_0_MASK          0x000000FF
+#define QED_MBI_VERSION_0_OFFSET        0
+#define QED_MBI_VERSION_1_MASK          0x0000FF00
+#define QED_MBI_VERSION_1_OFFSET        8
+#define QED_MBI_VERSION_2_MASK          0x00FF0000
+#define QED_MBI_VERSION_2_OFFSET        16
+
 	/* Out param for qede */
 	bool vxlan_enable;
 	bool gre_enable;
diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index 4eb79d0fb..257646e73 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -390,6 +390,9 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
 			ecore_mcp_get_mfw_ver(ECORE_LEADING_HWFN(edev), ptt,
 					      &dev_info->mfw_rev, NULL);
 
+			ecore_mcp_get_mbi_ver(ECORE_LEADING_HWFN(edev), ptt,
+					      &dev_info->mbi_version);
+
 			ecore_mcp_get_flash_size(ECORE_LEADING_HWFN(edev), ptt,
 						 &dev_info->flash_size);
 
-- 
2.18.1


  reply	other threads:[~2020-04-25  6:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25  6:13 [dpdk-dev] [PATCH 1/2] net/qede: add flush support to rte flow ops Rasesh Mody
2020-04-25  6:13 ` Rasesh Mody [this message]
2020-05-03 16:30   ` [dpdk-dev] [PATCH 2/2] net/qede: add support for get FW version Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200425061347.18217-2-rmody@marvell.com \
    --to=rmody@marvell.com \
    --cc=GR-Everest-DPDK-Dev@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=irusskikh@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=ysharma@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).