net/sfc: avoid panic in the case of MCDI timeout
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 17 Sep 2020 06:34:38 +0000 (07:34 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 30 Sep 2020 17:19:08 +0000 (19:19 +0200)
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
drivers/net/sfc/sfc_mcdi.h

index 8f446e8..928a08c 100644 (file)
@@ -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");
index e210536..b93b268 100644 (file)
@@ -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
 };