[09/14] net/sfc: avoid panic in the case of MCDI timeout
diff mbox series

Message ID 1599556475-27820-11-git-send-email-arybchenko@solarflare.com
State Superseded, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • net/sfc: factor out common driver library
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Rybchenko Sept. 8, 2020, 9:14 a.m. UTC
Implement dummy MCDI timeout handling which simply rejects
further MCDI requests.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/sfc_mcdi.c | 15 +++++++++++++--
 drivers/net/sfc/sfc_mcdi.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/sfc/sfc_mcdi.c b/drivers/net/sfc/sfc_mcdi.c
index 8f446e8bc8..928a08c0a2 100644
--- a/drivers/net/sfc/sfc_mcdi.c
+++ b/drivers/net/sfc/sfc_mcdi.c
@@ -33,6 +33,9 @@ 
 				RTE_FMT_TAIL(__VA_ARGS__,)));		\
 	} while (0)
 
+#define sfc_efx_mcdi_crit(mcdi, ...) \
+	sfc_efx_mcdi_log(mcdi, RTE_LOG_CRIT, __VA_ARGS__)
+
 #define sfc_efx_mcdi_err(mcdi, ...) \
 	sfc_efx_mcdi_log(mcdi, RTE_LOG_ERR, __VA_ARGS__)
 
@@ -55,7 +58,9 @@  sfc_efx_mcdi_timeout(struct sfc_adapter *sa)
 
 	sfc_efx_mcdi_warn(mcdi, "MC TIMEOUT");
 
-	sfc_panic(sa, "MCDI timeout handling is not implemented\n");
+	mcdi->state = SFC_EFX_MCDI_DEAD;
+	sfc_efx_mcdi_crit(mcdi,
+		"MCDI timeout handling is not implemented - NIC is unusable");
 }
 
 static inline boolean_t
@@ -124,6 +129,11 @@  sfc_efx_mcdi_execute(void *arg, efx_mcdi_req_t *emrp)
 	struct sfc_efx_mcdi *mcdi = &sa->mcdi;
 	uint32_t proxy_handle;
 
+	if (mcdi->state == SFC_EFX_MCDI_DEAD) {
+		emrp->emr_rc = ENOEXEC;
+		return;
+	}
+
 	rte_spinlock_lock(&mcdi->lock);
 
 	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
@@ -325,7 +335,8 @@  sfc_efx_mcdi_fini(struct sfc_adapter *sa, struct sfc_efx_mcdi *mcdi)
 
 	rte_spinlock_lock(&mcdi->lock);
 
-	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED);
+	SFC_ASSERT(mcdi->state == SFC_EFX_MCDI_INITIALIZED ||
+		   mcdi->state == SFC_EFX_MCDI_DEAD);
 	mcdi->state = SFC_EFX_MCDI_UNINITIALIZED;
 
 	sfc_efx_mcdi_info(mcdi, "fini MCDI");
diff --git a/drivers/net/sfc/sfc_mcdi.h b/drivers/net/sfc/sfc_mcdi.h
index e2105364ad..b93b268e32 100644
--- a/drivers/net/sfc/sfc_mcdi.h
+++ b/drivers/net/sfc/sfc_mcdi.h
@@ -27,6 +27,7 @@  enum sfc_efx_mcdi_state {
 	SFC_EFX_MCDI_INITIALIZED,
 	SFC_EFX_MCDI_BUSY,
 	SFC_EFX_MCDI_COMPLETED,
+	SFC_EFX_MCDI_DEAD,
 
 	SFC_EFX_MCDI_NSTATES
 };