DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [dpdk-dev] [PATCH v3 8/9] net/bnxt: log firmware status on early init failure
Date: Tue, 21 Apr 2020 14:33:50 -0700	[thread overview]
Message-ID: <20200421213351.87219-9-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20200421213351.87219-1-ajit.khaparde@broadcom.com>

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

Firmware reports any fatal error (either ASIC or Firmware related)
via a new status register. This status register can provide more detailed
information about the firmware errors, especially if error occurs
before HWRM_VER_GET is issued. Attempt to map this register if it is
present and check for firmware status when VER_GET command fails.

Refactored the code to allocate the "bp->recovery_info" structure
in bnxt_init_fw() instead of doing in bnxt_hwrm_error_recovery_qcfg().

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h                |   5 ++
 drivers/net/bnxt/bnxt_ethdev.c         | 107 +++++++++++++++++++++++--
 drivers/net/bnxt/bnxt_hwrm.c           |  10 ---
 drivers/net/bnxt/hsi_struct_def_dpdk.h |  49 +++++++++++
 4 files changed, 155 insertions(+), 16 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index d55a57039..586d3f534 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -507,6 +507,10 @@ struct bnxt_mark_info {
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
 #define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
+#define BNXT_GRCP_BASE_MASK		0xfffff000
+#define BNXT_GRCP_OFFSET_MASK		0x00000ffc
+
+#define BNXT_FW_STATUS_HEALTHY		0x8000
 #define BNXT_FW_STATUS_SHUTDOWN		0x100000
 
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
@@ -564,6 +568,7 @@ struct bnxt {
 #define BNXT_FW_CAP_ERR_RECOVER_RELOAD	BIT(3)
 #define BNXT_FW_CAP_ADV_FLOW_MGMT	BIT(5)
 #define BNXT_FW_CAP_ADV_FLOW_COUNTERS	BIT(6)
+#define BNXT_FW_CAP_HCOMM_FW_STATUS	BIT(7)
 
 	uint32_t		flow_flags;
 #define BNXT_FLOW_FLAG_L2_HDR_SRC_FILTER_EN	BIT(0)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 589190b37..1a3c7e609 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -155,6 +155,7 @@ static int bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev);
 static void bnxt_cancel_fw_health_check(struct bnxt *bp);
 static int bnxt_restore_vlan_filters(struct bnxt *bp);
 static void bnxt_dev_recover(void *arg);
+static void bnxt_free_error_recovery_info(struct bnxt *bp);
 
 int is_bnxt_in_error(struct bnxt *bp)
 {
@@ -4967,6 +4968,89 @@ bnxt_get_fw_func_id(uint16_t port)
 	return bp->fw_fid;
 }
 
+static void bnxt_alloc_error_recovery_info(struct bnxt *bp)
+{
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+
+	if (info) {
+		if (!(bp->fw_cap & BNXT_FW_CAP_HCOMM_FW_STATUS))
+			memset(info, 0, sizeof(*info));
+		return;
+	}
+
+	if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
+		return;
+
+	info = rte_zmalloc("bnxt_hwrm_error_recovery_qcfg",
+			   sizeof(*info), 0);
+	if (!info)
+		bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY;
+
+	bp->recovery_info = info;
+}
+
+static void bnxt_check_fw_status(struct bnxt *bp)
+{
+	uint32_t fw_status;
+
+	if (!(bp->recovery_info &&
+	      (bp->fw_cap & BNXT_FW_CAP_HCOMM_FW_STATUS)))
+		return;
+
+	fw_status = bnxt_read_fw_status_reg(bp, BNXT_FW_STATUS_REG);
+	if (fw_status != BNXT_FW_STATUS_HEALTHY)
+		PMD_DRV_LOG(ERR, "Firmware not responding, status: %#x\n",
+			    fw_status);
+}
+
+static int bnxt_map_hcomm_fw_status_reg(struct bnxt *bp)
+{
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+	uint32_t status_loc;
+	uint32_t sig_ver;
+
+	rte_write32(HCOMM_STATUS_STRUCT_LOC, (uint8_t *)bp->bar0 +
+		    BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4);
+	sig_ver = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 +
+				   BNXT_GRCP_WINDOW_2_BASE +
+				   offsetof(struct hcomm_status,
+					    sig_ver)));
+	/* If the signature is absent, then FW does not support this feature */
+	if ((sig_ver & HCOMM_STATUS_SIGNATURE_MASK) !=
+	    HCOMM_STATUS_SIGNATURE_VAL)
+		return 0;
+
+	if (!info) {
+		info = rte_zmalloc("bnxt_hwrm_error_recovery_qcfg",
+				   sizeof(*info), 0);
+		if (!info)
+			return -ENOMEM;
+		bp->recovery_info = info;
+	} else {
+		memset(info, 0, sizeof(*info));
+	}
+
+	status_loc = rte_le_to_cpu_32(rte_read32((uint8_t *)bp->bar0 +
+				      BNXT_GRCP_WINDOW_2_BASE +
+				      offsetof(struct hcomm_status,
+					       fw_status_loc)));
+
+	/* Only pre-map the FW health status GRC register */
+	if (BNXT_FW_STATUS_REG_TYPE(status_loc) != BNXT_FW_STATUS_REG_TYPE_GRC)
+		return 0;
+
+	info->status_regs[BNXT_FW_STATUS_REG] = status_loc;
+	info->mapped_status_regs[BNXT_FW_STATUS_REG] =
+		BNXT_GRCP_WINDOW_2_BASE + (status_loc & BNXT_GRCP_OFFSET_MASK);
+
+	rte_write32((status_loc & BNXT_GRCP_BASE_MASK), (uint8_t *)bp->bar0 +
+		    BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4);
+
+	bp->fw_cap |= BNXT_FW_CAP_HCOMM_FW_STATUS;
+
+	return 0;
+}
+
 static int bnxt_init_fw(struct bnxt *bp)
 {
 	uint16_t mtu;
@@ -4974,10 +5058,16 @@ static int bnxt_init_fw(struct bnxt *bp)
 
 	bp->fw_cap = 0;
 
-	rc = bnxt_hwrm_ver_get(bp, DFLT_HWRM_CMD_TIMEOUT);
+	rc = bnxt_map_hcomm_fw_status_reg(bp);
 	if (rc)
 		return rc;
 
+	rc = bnxt_hwrm_ver_get(bp, DFLT_HWRM_CMD_TIMEOUT);
+	if (rc) {
+		bnxt_check_fw_status(bp);
+		return rc;
+	}
+
 	rc = bnxt_hwrm_func_reset(bp);
 	if (rc)
 		return -EIO;
@@ -5008,6 +5098,7 @@ static int bnxt_init_fw(struct bnxt *bp)
 	if (rc)
 		return rc;
 
+	bnxt_alloc_error_recovery_info(bp);
 	/* Get the adapter error recovery support info */
 	rc = bnxt_hwrm_error_recovery_qcfg(bp);
 	if (rc)
@@ -5343,6 +5434,14 @@ static void bnxt_uninit_ctx_mem(struct bnxt *bp)
 	bnxt_uninit_fc_ctx_mem(bp);
 }
 
+static void
+bnxt_free_error_recovery_info(struct bnxt *bp)
+{
+	rte_free(bp->recovery_info);
+	bp->recovery_info = NULL;
+	bp->fw_cap &= ~BNXT_FW_CAP_ERROR_RECOVERY;
+}
+
 static void
 bnxt_uninit_locks(struct bnxt *bp)
 {
@@ -5363,11 +5462,7 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
 	bnxt_free_ctx_mem(bp);
 	if (!reconfig_dev) {
 		bnxt_free_hwrm_resources(bp);
-
-		if (bp->recovery_info != NULL) {
-			rte_free(bp->recovery_info);
-			bp->recovery_info = NULL;
-		}
+		bnxt_free_error_recovery_info(bp);
 	}
 
 	bnxt_uninit_ctx_mem(bp);
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index dc0b40560..666056ac1 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -5076,16 +5076,6 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 	if (!(bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY))
 		return 0;
 
-	if (!info) {
-		info = rte_zmalloc("bnxt_hwrm_error_recovery_qcfg",
-				   sizeof(*info), 0);
-		bp->recovery_info = info;
-		if (info == NULL)
-			return -ENOMEM;
-	} else {
-		memset(info, 0, sizeof(*info));
-	}
-
 	HWRM_PREP(&req, HWRM_ERROR_RECOVERY_QCFG, BNXT_USE_CHIMP_MB);
 
 	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB);
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index da22b6249..7e30c9ffc 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -38622,4 +38622,53 @@ struct hwrm_cfa_counter_qstats_output {
 	uint8_t	valid;
 } __rte_packed;
 
+/*
+ * This structure is fixed at the beginning of the ChiMP SRAM (GRC
+ * offset: 0x31001F0). Host software is expected to read from this
+ * location for a defined signature. If it exists, the software can
+ * assume the presence of this structure and the validity of the
+ * FW_STATUS location in the next field.
+ */
+/* hcomm_status (size:64b/8B) */
+struct hcomm_status {
+	uint32_t	sig_ver;
+	/*
+	 * This field defines the version of the structure. The latest
+	 * version value is 1.
+	 */
+	#define HCOMM_STATUS_VER_MASK		UINT32_C(0xff)
+	#define HCOMM_STATUS_VER_SFT		0
+	#define HCOMM_STATUS_VER_LATEST		UINT32_C(0x1)
+	#define HCOMM_STATUS_VER_LAST		HCOMM_STATUS_VER_LATEST
+	/*
+	 * This field is to store the signature value to indicate the
+	 * presence of the structure.
+	 */
+	#define HCOMM_STATUS_SIGNATURE_MASK	UINT32_C(0xffffff00)
+	#define HCOMM_STATUS_SIGNATURE_SFT	8
+	#define HCOMM_STATUS_SIGNATURE_VAL	(UINT32_C(0x484353) << 8)
+	#define HCOMM_STATUS_SIGNATURE_LAST	HCOMM_STATUS_SIGNATURE_VAL
+	uint32_t	fw_status_loc;
+	#define HCOMM_STATUS_TRUE_ADDR_SPACE_MASK	UINT32_C(0x3)
+	#define HCOMM_STATUS_TRUE_ADDR_SPACE_SFT	0
+	/* PCIE configuration space */
+	#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_PCIE_CFG	UINT32_C(0x0)
+	/* GRC space */
+	#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_GRC	UINT32_C(0x1)
+	/* BAR0 space */
+	#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR0	UINT32_C(0x2)
+	/* BAR1 space */
+	#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1	UINT32_C(0x3)
+	#define HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_LAST	\
+		HCOMM_STATUS_FW_STATUS_LOC_ADDR_SPACE_BAR1
+	/*
+	 * This offset where the fw_status register is located. The value
+	 * is generally 4-byte aligned.
+	 */
+	#define HCOMM_STATUS_TRUE_OFFSET_MASK		UINT32_C(0xfffffffc)
+	#define HCOMM_STATUS_TRUE_OFFSET_SFT		2
+} __rte_packed;
+/* This is the GRC offset where the hcomm_status struct resides. */
+#define HCOMM_STATUS_STRUCT_LOC		0x31001F0UL
+
 #endif /* _HSI_STRUCT_DEF_DPDK_H_ */
-- 
2.21.1 (Apple Git-122.3)


  parent reply	other threads:[~2020-04-21 21:35 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21  9:12 [dpdk-dev] [PATCH 0/9] bnxt patchset with fixes Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 1/9] net/bnxt: use macro for PCI log format Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 2/9] net/bnxt: return speed capabilities in device info get Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 3/9] net/bnxt: fix to resend FUNC_DRV_IF_CHANGE when FW reset is in progress Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 4/9] net/bnxt: fix to use true/false for bool types Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 5/9] net/bnxt: fix to handle port start failure Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 6/9] net/bnxt: fix vlan add when port is stopped Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 7/9] net/bnxt: define FW_STATUS location structure for ChiMP devices Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 8/9] net/bnxt: log firmware status on early init failure Kalesh A P
2020-04-21  9:12 ` [dpdk-dev] [PATCH 9/9] net/bnxt: fix to not issue HWRM_PORT_MAC_QCFG on a VF Kalesh A P
2020-04-21 20:07 ` [dpdk-dev] [PATCH v2 00/10] bnxt patchset with fixes Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 01/10] net/bnxt: fix compilation on BSD Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 02/10] net/bnxt: use macro for PCI log format Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 03/10] net/bnxt: return speed capabilities in device get info Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 04/10] net/bnxt: fix HWRM command failure during FW reset Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 05/10] net/bnxt: fix to use true/false for bool types Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 06/10] net/bnxt: fix to handle port start failure Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 07/10] net/bnxt: fix vlan add when port is stopped Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 08/10] net/bnxt: add FW status location structure Ajit Khaparde
2020-04-21 21:05     ` Ferruh Yigit
2020-04-21 21:21       ` Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 09/10] net/bnxt: log firmware status on early init failure Ajit Khaparde
2020-04-21 20:07   ` [dpdk-dev] [PATCH v2 10/10] net/bnxt: fix to not issue port MAC query on a VF Ajit Khaparde
2020-04-21 21:33 ` [dpdk-dev] [PATCH v3 0/9] bnxt patchset with fixes Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 1/9] net/bnxt: fix compilation on BSD Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 2/9] net/bnxt: use macro for PCI log format Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 3/9] net/bnxt: return speed capabilities in device get info Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 4/9] net/bnxt: fix HWRM command failure during FW reset Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 5/9] net/bnxt: fix to use true/false for bool types Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 6/9] net/bnxt: fix to handle port start failure Ajit Khaparde
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 7/9] net/bnxt: fix vlan add when port is stopped Ajit Khaparde
2020-04-21 21:33   ` Ajit Khaparde [this message]
2020-04-21 21:33   ` [dpdk-dev] [PATCH v3 9/9] net/bnxt: fix to not issue port MAC query on a VF Ajit Khaparde
2020-04-22 11:44   ` [dpdk-dev] [PATCH v3 0/9] bnxt patchset with fixes Ferruh Yigit

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=20200421213351.87219-9-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kalesh-anakkur.purayil@broadcom.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).