DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com,
	Kalesh AP <kalesh-anakkur.purayil@broadcom.com>,
	Somnath Kotur <somnath.kotur@broadcom.com>
Subject: [dpdk-dev] [PATCH 12/13] net/bnxt: add support for FW reset
Date: Wed, 21 Aug 2019 22:53:59 -0700	[thread overview]
Message-ID: <20190822055400.30119-13-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20190822055400.30119-1-ajit.khaparde@broadcom.com>

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

Added code to perform FW_RESET. When the driver detects error in FW,
it has to initiate the recovery by resetting the cores. FW advertise
the method to do a core reset, reset register offsets and values
to perform reset in response of HWRM_ERROR_RECOVERY_QCFG command.

There are 2 ways to recover from the error.
1. Master function issues core resets to recover from error.
2. Master function detects chimp dead condition and notify the Kong
   processor about the chimp dead case through FW_RESET HWRM command.
   Kong Processor send an RESET_NOTIFY async event with
   REASON_CODE_FW_EXCEPTION_FATAL to all the PF’s/VF’s that
   chimp is dead and it is going to reset the chimp.

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |   1 +
 drivers/net/bnxt/bnxt_ethdev.c | 103 ++++++++++++++++++++++++++++++++-
 drivers/net/bnxt/bnxt_hwrm.c   |  26 +++++++++
 drivers/net/bnxt/bnxt_hwrm.h   |   1 +
 4 files changed, 130 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index edaef7897..9ea84ec2f 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -389,6 +389,7 @@ struct bnxt_error_recovery_info {
 #define BNXT_FW_STATUS_REG_OFF(reg)	((reg) & ~BNXT_FW_STATUS_REG_TYPE_MASK)
 
 #define BNXT_GRCP_WINDOW_2_BASE		0x2000
+#define BNXT_GRCP_WINDOW_3_BASE		0x3000
 
 #define BNXT_HWRM_SHORT_REQ_LEN		sizeof(struct hwrm_short_input)
 struct bnxt {
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index e7b0b44c4..095395dae 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3499,6 +3499,19 @@ static const struct eth_dev_ops bnxt_dev_ops = {
 	.timesync_read_tx_timestamp = bnxt_timesync_read_tx_timestamp,
 };
 
+static uint32_t bnxt_map_reset_regs(struct bnxt *bp, uint32_t reg)
+{
+	uint32_t offset;
+
+	/* Only pre-map the reset GRC registers using window 3 */
+	rte_write32(reg & 0xfffff000, (uint8_t *)bp->bar0 +
+		    BNXT_GRCPF_REG_WINDOW_BASE_OUT + 8);
+
+	offset = BNXT_GRCP_WINDOW_3_BASE + (reg & 0xffc);
+
+	return offset;
+}
+
 int bnxt_map_fw_health_status_regs(struct bnxt *bp)
 {
 	struct bnxt_error_recovery_info *info = bp->recovery_info;
@@ -3542,6 +3555,34 @@ static void bnxt_unmap_fw_health_status_regs(struct bnxt *bp)
 		    BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4);
 }
 
+static void bnxt_write_fw_reset_reg(struct bnxt *bp, uint32_t index)
+{
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+	uint32_t delay = info->delay_after_reset[index];
+	uint32_t val = info->reset_reg_val[index];
+	uint32_t reg = info->reset_reg[index];
+	uint32_t type, offset;
+
+	type = BNXT_FW_STATUS_REG_TYPE(reg);
+	offset = BNXT_FW_STATUS_REG_OFF(reg);
+
+	switch (type) {
+	case BNXT_FW_STATUS_REG_TYPE_CFG:
+		rte_pci_write_config(bp->pdev, &val, sizeof(val), offset);
+		break;
+	case BNXT_FW_STATUS_REG_TYPE_GRC:
+		offset = bnxt_map_reset_regs(bp, offset);
+		rte_write32(val, (uint8_t *)bp->bar0 + offset);
+		break;
+	case BNXT_FW_STATUS_REG_TYPE_BAR0:
+		rte_write32(val, (uint8_t *)bp->bar0 + offset);
+		break;
+	}
+	/* wait on a specific interval of time until core reset is complete */
+	if (delay)
+		rte_delay_ms(delay);
+}
+
 static void bnxt_dev_cleanup(struct bnxt *bp)
 {
 	bnxt_set_hwrm_link_config(bp, false);
@@ -3636,6 +3677,58 @@ uint32_t bnxt_read_fw_status_reg(struct bnxt *bp, uint32_t index)
 	return val;
 }
 
+static int bnxt_fw_reset_all(struct bnxt *bp)
+{
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+	uint32_t i;
+	int rc = 0;
+
+	if (info->flags & BNXT_FLAG_ERROR_RECOVERY_HOST) {
+		/* Reset through master function driver */
+		for (i = 0; i < info->reg_array_cnt; i++)
+			bnxt_write_fw_reset_reg(bp, i);
+		/* Wait for time specified by FW after triggering reset */
+		rte_delay_ms(info->master_func_wait_period_after_reset);
+	} else if (info->flags & BNXT_FLAG_ERROR_RECOVERY_CO_CPU) {
+		/* Reset with the help of Kong processor */
+		rc = bnxt_hwrm_fw_reset(bp);
+		if (rc)
+			PMD_DRV_LOG(ERR, "Failed to reset FW\n");
+	}
+
+	return rc;
+}
+
+static void bnxt_fw_reset_cb(void *arg)
+{
+	struct bnxt *bp = arg;
+	struct bnxt_error_recovery_info *info = bp->recovery_info;
+	int rc = 0;
+
+	/* Only Master function can do FW reset */
+	if (bnxt_is_master_func(bp) &&
+	    bnxt_is_recovery_enabled(bp)) {
+		rc = bnxt_fw_reset_all(bp);
+		if (rc) {
+			PMD_DRV_LOG(ERR, "Adapter recovery failed\n");
+			return;
+		}
+	}
+
+	/* if recovery method is ERROR_RECOVERY_CO_CPU, KONG will send
+	 * EXCEPTION_FATAL_ASYNC event to all the functions
+	 * (including MASTER FUNC). After receiving this Async, all the active
+	 * drivers should treat this case as FW initiated recovery
+	 */
+	if (info->flags & BNXT_FLAG_ERROR_RECOVERY_HOST) {
+		bp->fw_reset_min_msecs = BNXT_MIN_FW_READY_TIMEOUT;
+		bp->fw_reset_max_msecs = BNXT_MAX_FW_RESET_TIMEOUT;
+
+		/* To recover from error */
+		bnxt_dev_reset_and_resume(bp);
+	}
+}
+
 /* Driver should poll FW heartbeat, reset_counter with the frequency
  * advertised by FW in HWRM_ERROR_RECOVERY_QCFG.
  * When the driver detects heartbeat stop or change in reset_counter,
@@ -3648,7 +3741,7 @@ static void bnxt_check_fw_health(void *arg)
 {
 	struct bnxt *bp = arg;
 	struct bnxt_error_recovery_info *info = bp->recovery_info;
-	uint32_t val = 0;
+	uint32_t val = 0, wait_msec;
 
 	if (!info || !bnxt_is_recovery_enabled(bp) ||
 	    is_bnxt_in_error(bp))
@@ -3676,6 +3769,14 @@ static void bnxt_check_fw_health(void *arg)
 	bp->flags |= BNXT_FLAG_FW_RESET;
 
 	PMD_DRV_LOG(ERR, "Detected FW dead condition\n");
+
+	if (bnxt_is_master_func(bp))
+		wait_msec = info->master_func_wait_period;
+	else
+		wait_msec = info->normal_func_wait_period;
+
+	rte_eal_alarm_set(US_PER_MS * wait_msec,
+			  bnxt_fw_reset_cb, (void *)bp);
 }
 
 void bnxt_schedule_fw_health_check(struct bnxt *bp)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 350e867bf..bd2cc01e1 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -4782,3 +4782,29 @@ int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp)
 	}
 	return rc;
 }
+
+int bnxt_hwrm_fw_reset(struct bnxt *bp)
+{
+	struct hwrm_fw_reset_output *resp = bp->hwrm_cmd_resp_addr;
+	struct hwrm_fw_reset_input req = {0};
+	int rc;
+
+	if (!BNXT_PF(bp))
+		return -EOPNOTSUPP;
+
+	HWRM_PREP(req, FW_RESET, BNXT_USE_KONG(bp));
+
+	req.embedded_proc_type =
+		HWRM_FW_RESET_INPUT_EMBEDDED_PROC_TYPE_CHIP;
+	req.selfrst_status =
+		HWRM_FW_RESET_INPUT_SELFRST_STATUS_SELFRSTASAP;
+	req.flags = HWRM_FW_RESET_INPUT_FLAGS_RESET_GRACEFUL;
+
+	rc = bnxt_hwrm_send_message(bp, &req, sizeof(req),
+				    BNXT_USE_KONG(bp));
+
+	HWRM_CHECK_RESULT();
+	HWRM_UNLOCK();
+
+	return rc;
+}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index 44e335507..db25ad591 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -205,4 +205,5 @@ int bnxt_hwrm_tunnel_redirect_info(struct bnxt *bp, uint8_t tun_type,
 int bnxt_hwrm_set_mac(struct bnxt *bp);
 int bnxt_hwrm_if_change(struct bnxt *bp, bool state);
 int bnxt_hwrm_error_recovery_qcfg(struct bnxt *bp);
+int bnxt_hwrm_fw_reset(struct bnxt *bp);
 #endif
-- 
2.20.1 (Apple Git-117)


  parent reply	other threads:[~2019-08-22  5:55 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22  5:53 [dpdk-dev] [PATCH 00/13] bnxt patchset to support device error recovery Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 01/13] net/bnxt: hsi version update Ajit Khaparde
2019-08-27 13:51   ` Ferruh Yigit
2019-08-30 16:35     ` [dpdk-dev] [PATCH v2 00/13] bnxt patchset to support device error recovery Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 01/13] net/bnxt: add FW reset HWRM command Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 02/13] net/bnxt: prevent device access when device is in reset Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 03/13] net/bnxt: handle reset notify async event from FW Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 04/13] net/bnxt: inform firmware about IF state changes Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 05/13] net/bnxt: handle fatal event from FW under error conditions Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 06/13] net/bnxt: query firmware error recovery capabilities Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 07/13] net/bnxt: map status registers for FW health monitoring Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 08/13] net/bnxt: advertise error recovery capability and handle async event Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 09/13] net/bnxt: add code for periodic FW health monitoring Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 10/13] net/bnxt: add support for FW reset Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 11/13] net/bnxt: reduce verbosity of logs Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 12/13] net/bnxt: use BIT macro instead of bit fields Ajit Khaparde
2019-08-30 16:35       ` [dpdk-dev] [PATCH v2 13/13] net/bnxt: avoid null pointer dereference Ajit Khaparde
2019-09-30 13:29       ` [dpdk-dev] [PATCH v2 00/13] bnxt patchset to support device error recovery Ferruh Yigit
2019-10-02  1:23         ` [dpdk-dev] [PATCH v3 00/15] " Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 01/15] net/bnxt: add FW reset HWRM command Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 02/15] net/bnxt: prevent device access when device is in reset Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 03/15] net/bnxt: handle reset notify async event from FW Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 04/15] net/bnxt: inform firmware about IF state changes Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 05/15] net/bnxt: handle fatal event from FW under error conditions Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 06/15] net/bnxt: query firmware error recovery capabilities Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 07/15] net/bnxt: map status registers for FW health monitoring Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 08/15] net/bnxt: advertise error recovery capability and handle async event Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 09/15] net/bnxt: add code for periodic FW health monitoring Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 10/15] net/bnxt: add support for FW reset Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 11/15] net/bnxt: add hot firmware upgrade support for Stingray Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 12/15] net/bnxt: reduce verbosity of logs Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 13/15] net/bnxt: avoid null pointer dereference Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 14/15] net/bnxt: use BIT macro instead of bit fields Ajit Khaparde
2019-10-02  1:23           ` [dpdk-dev] [PATCH v3 15/15] net/bnxt: add PTP support for Thor Ajit Khaparde
2019-10-02 17:02           ` [dpdk-dev] [PATCH v3 00/15] bnxt patchset to support device error recovery Ferruh Yigit
2019-08-22  5:53 ` [dpdk-dev] [PATCH 02/13] net/bnxt: prevent device access when device is in reset Ajit Khaparde
2019-08-27 15:00   ` Ferruh Yigit
2019-08-22  5:53 ` [dpdk-dev] [PATCH 03/13] net/bnxt: handle reset notify async event from FW Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 04/13] net/bnxt: inform firmware about IF state changes Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 05/13] net/bnxt: handle fatal event from FW under error conditions Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 06/13] net/bnxt: query firmware error recovery capabilities Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 07/13] net/bnxt: map status registers for FW health monitoring Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 08/13] net/bnxt: advertise error recovery capability and handle async event Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 09/13] net/bnxt: add code for periodic FW health monitoring Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 10/13] net/bnxt: use BIT macro instead of bit fields Ajit Khaparde
2019-08-22  5:53 ` [dpdk-dev] [PATCH 11/13] net/bnxt: reschedule the health check alarm correctly Ajit Khaparde
2019-08-22  5:53 ` Ajit Khaparde [this message]
2019-08-22  5:54 ` [dpdk-dev] [PATCH 13/13] net/bnxt: reduce verbosity of logs Ajit Khaparde

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=20190822055400.30119-13-ajit.khaparde@broadcom.com \
    --to=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=somnath.kotur@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).