Blame SOURCES/0084-netdrv-bnxt_en-Add-a-new-BNXT_FW_RESET_STATE_POLL_FW.patch

f95c89
From a10d58b1feaebcd74c4c1c0d2247c742a8d704e7 Mon Sep 17 00:00:00 2001
f95c89
From: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Date: Wed, 2 Oct 2019 18:23:39 -0400
f95c89
Subject: [PATCH 84/96] [netdrv] bnxt_en: Add a new
f95c89
 BNXT_FW_RESET_STATE_POLL_FW_DOWN state
f95c89
f95c89
Message-id: <e3f406d7947d866a0104ca7cba793749cd1bf4f3.1570027456.git.jtoppins@redhat.com>
f95c89
Patchwork-id: 276502
f95c89
O-Subject: [RHEL-8.2 PATCH 77/78] bnxt_en: Add a new BNXT_FW_RESET_STATE_POLL_FW_DOWN state.
f95c89
Bugzilla: 1724766
f95c89
RH-Acked-by: John Linville <linville@redhat.com>
f95c89
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
f95c89
f95c89
This new state is required when firmware indicates that the error
f95c89
recovery process requires polling for firmware state to be completely
f95c89
down before initiating reset.  For example, firmware may take some
f95c89
time to collect the crash dump before it is down and ready to be
f95c89
reset.
f95c89
f95c89
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
f95c89
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
f95c89
Signed-off-by: David S. Miller <davem@davemloft.net>
f95c89
(cherry picked from commit 4037eb715680caa3d80075fb54dbc35d79d5f9ff)
f95c89
Bugzilla: 1724766
f95c89
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532
f95c89
Tested: build, boot, basic ping
f95c89
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
f95c89
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
f95c89
---
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 48 +++++++++++++++++++++++++++----
f95c89
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  3 ++
f95c89
 2 files changed, 46 insertions(+), 5 deletions(-)
f95c89
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:21.286461969 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c	2020-02-06 16:23:21.672458426 +0100
f95c89
@@ -6952,6 +6952,8 @@
f95c89
 		bp->fw_cap |= BNXT_FW_CAP_EXT_STATS_SUPPORTED;
f95c89
 	if (flags &  FUNC_QCAPS_RESP_FLAGS_ERROR_RECOVERY_CAPABLE)
f95c89
 		bp->fw_cap |= BNXT_FW_CAP_ERROR_RECOVERY;
f95c89
+	if (flags & FUNC_QCAPS_RESP_FLAGS_ERR_RECOVER_RELOAD)
f95c89
+		bp->fw_cap |= BNXT_FW_CAP_ERR_RECOVER_RELOAD;
f95c89
 
f95c89
 	bp->tx_push_thresh = 0;
f95c89
 	if (flags & FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED)
f95c89
@@ -10102,6 +10104,8 @@
f95c89
 		wait_dsecs = fw_health->normal_func_wait_dsecs;
f95c89
 		bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
 	}
f95c89
+
f95c89
+	bp->fw_reset_min_dsecs = fw_health->post_reset_wait_dsecs;
f95c89
 	bp->fw_reset_max_dsecs = fw_health->post_reset_max_wait_dsecs;
f95c89
 	bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10);
f95c89
 }
f95c89
@@ -10143,7 +10147,7 @@
f95c89
 	bnxt_rtnl_lock_sp(bp);
f95c89
 	if (test_bit(BNXT_STATE_OPEN, &bp->state) &&
f95c89
 	    !test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
f95c89
-		int n = 0;
f95c89
+		int n = 0, tmo;
f95c89
 
f95c89
 		set_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
f95c89
 		if (bp->pf.active_vfs &&
f95c89
@@ -10166,8 +10170,14 @@
f95c89
 			goto fw_reset_exit;
f95c89
 		}
f95c89
 		bnxt_fw_reset_close(bp);
f95c89
-		bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
-		bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10);
f95c89
+		if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) {
f95c89
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN;
f95c89
+			tmo = HZ / 10;
f95c89
+		} else {
f95c89
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
+			tmo = bp->fw_reset_min_dsecs * HZ / 10;
f95c89
+		}
f95c89
+		bnxt_queue_fw_reset_work(bp, tmo);
f95c89
 	}
f95c89
 fw_reset_exit:
f95c89
 	bnxt_rtnl_unlock_sp(bp);
f95c89
@@ -10610,6 +10620,7 @@
f95c89
 	switch (bp->fw_reset_state) {
f95c89
 	case BNXT_FW_RESET_STATE_POLL_VF: {
f95c89
 		int n = bnxt_get_registered_vfs(bp);
f95c89
+		int tmo;
f95c89
 
f95c89
 		if (n < 0) {
f95c89
 			netdev_err(bp->dev, "Firmware reset aborted, subsequent func_qcfg cmd failed, rc = %d, %d msecs since reset timestamp\n",
f95c89
@@ -10631,11 +10642,38 @@
f95c89
 		bp->fw_reset_timestamp = jiffies;
f95c89
 		rtnl_lock();
f95c89
 		bnxt_fw_reset_close(bp);
f95c89
-		bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
+		if (bp->fw_cap & BNXT_FW_CAP_ERR_RECOVER_RELOAD) {
f95c89
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW_DOWN;
f95c89
+			tmo = HZ / 10;
f95c89
+		} else {
f95c89
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
+			tmo = bp->fw_reset_min_dsecs * HZ / 10;
f95c89
+		}
f95c89
 		rtnl_unlock();
f95c89
-		bnxt_queue_fw_reset_work(bp, bp->fw_reset_min_dsecs * HZ / 10);
f95c89
+		bnxt_queue_fw_reset_work(bp, tmo);
f95c89
 		return;
f95c89
 	}
f95c89
+	case BNXT_FW_RESET_STATE_POLL_FW_DOWN: {
f95c89
+		u32 val;
f95c89
+
f95c89
+		val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
f95c89
+		if (!(val & BNXT_FW_STATUS_SHUTDOWN) &&
f95c89
+		    !time_after(jiffies, bp->fw_reset_timestamp +
f95c89
+		    (bp->fw_reset_max_dsecs * HZ / 10))) {
f95c89
+			bnxt_queue_fw_reset_work(bp, HZ / 5);
f95c89
+			return;
f95c89
+		}
f95c89
+
f95c89
+		if (!bp->fw_health->master) {
f95c89
+			u32 wait_dsecs = bp->fw_health->normal_func_wait_dsecs;
f95c89
+
f95c89
+			bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
f95c89
+			bnxt_queue_fw_reset_work(bp, wait_dsecs * HZ / 10);
f95c89
+			return;
f95c89
+		}
f95c89
+		bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW;
f95c89
+	}
f95c89
+	/* fall through */
f95c89
 	case BNXT_FW_RESET_STATE_RESET_FW: {
f95c89
 		u32 wait_dsecs = bp->fw_health->post_reset_wait_dsecs;
f95c89
 
f95c89
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.h
f95c89
===================================================================
f95c89
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.h	2020-02-06 16:23:21.412460813 +0100
f95c89
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.h	2020-02-06 16:23:21.672458426 +0100
f95c89
@@ -1398,6 +1398,7 @@
f95c89
 #define BNXT_FW_HEALTH_WIN_MAP_OFF	8
f95c89
 
f95c89
 #define BNXT_FW_STATUS_HEALTHY		0x8000
f95c89
+#define BNXT_FW_STATUS_SHUTDOWN		0x100000
f95c89
 
f95c89
 struct bnxt {
f95c89
 	void __iomem		*bar0;
f95c89
@@ -1655,6 +1656,7 @@
f95c89
 	#define BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX	0x00010000
f95c89
 	#define BNXT_FW_CAP_PCIE_STATS_SUPPORTED	0x00020000
f95c89
 	#define BNXT_FW_CAP_EXT_STATS_SUPPORTED		0x00040000
f95c89
+	#define BNXT_FW_CAP_ERR_RECOVER_RELOAD		0x00100000
f95c89
 
f95c89
 #define BNXT_NEW_RM(bp)		((bp)->fw_cap & BNXT_FW_CAP_NEW_RM)
f95c89
 	u32			hwrm_spec_code;
f95c89
@@ -1744,6 +1746,7 @@
f95c89
 #define BNXT_FW_RESET_STATE_ENABLE_DEV	3
f95c89
 #define BNXT_FW_RESET_STATE_POLL_FW	4
f95c89
 #define BNXT_FW_RESET_STATE_OPENING	5
f95c89
+#define BNXT_FW_RESET_STATE_POLL_FW_DOWN	6
f95c89
 
f95c89
 	u16			fw_reset_min_dsecs;
f95c89
 #define BNXT_DFLT_FW_RST_MIN_DSECS	20