]> git.droids-corp.org - dpdk.git/commitdiff
net/sfc/base: add background mode firmware updating
authorRichard Houldsworth <rhouldsworth@solarflare.com>
Mon, 10 Jun 2019 07:38:29 +0000 (08:38 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 20 Jun 2019 21:42:04 +0000 (23:42 +0200)
Request firmware updates be performed in background mode.
In this mode MCDI to the function processing the update
remains accessible and the client polls for completion.
This is supported for lengthy partition updates such as
MCFW and bundles. The MC ignores the flags used for this
mode for other partition updates.

Signed-off-by: Richard Houldsworth <rhouldsworth@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/base/ef10_nic.c
drivers/net/sfc/base/ef10_nvram.c
drivers/net/sfc/base/efx.h
drivers/net/sfc/base/efx_impl.h
drivers/net/sfc/base/efx_nvram.c
drivers/net/sfc/base/siena_nvram.c

index 27508e1992a52c61341d21b3c141e3c04c9ac7b4..4c90e10a8b5fcd5ff4a67f985397b62c00c834c0 100644 (file)
@@ -1216,6 +1216,11 @@ ef10_get_datapath_caps(
        else
                encp->enc_nvram_update_verify_result_supported = B_FALSE;
 
+       if (CAP_FLAGS2(req, NVRAM_UPDATE_POLL_VERIFY_RESULT))
+               encp->enc_nvram_update_poll_verify_result_supported = B_TRUE;
+       else
+               encp->enc_nvram_update_poll_verify_result_supported = B_FALSE;
+
        /*
         * Check if firmware update via the BUNDLE partition is supported
         */
index 1fb7185f7903e58a0f61e96da4d9fa9188a72d33..ed88e83898820abb796f9663b9d1057f14378f67 100644 (file)
@@ -2177,6 +2177,10 @@ fail1:
        return (rc);
 }
 
+#define        EF10_NVRAM_INITIAL_POLL_DELAY_US 10000
+#define        EF10_NVRAM_MAX_POLL_DELAY_US     1000000
+#define        EF10_NVRAM_POLL_RETRIES          100
+
        __checkReturn           efx_rc_t
 ef10_nvram_partn_unlock(
        __in                    efx_nic_t *enp,
@@ -2184,17 +2188,58 @@ ef10_nvram_partn_unlock(
        __out_opt               uint32_t *verify_resultp)
 {
        boolean_t reboot = B_FALSE;
+       uint32_t poll_delay_us = EF10_NVRAM_INITIAL_POLL_DELAY_US;
+       uint32_t poll_retry = 0;
+       uint32_t verify_result = MC_CMD_NVRAM_VERIFY_RC_UNKNOWN;
        efx_rc_t rc;
 
-       if (verify_resultp != NULL)
-               *verify_resultp = MC_CMD_NVRAM_VERIFY_RC_UNKNOWN;
+       rc = efx_mcdi_nvram_update_finish(enp, partn, reboot,
+           EFX_NVRAM_UPDATE_FLAGS_BACKGROUND, &verify_result);
 
-       rc = efx_mcdi_nvram_update_finish(enp, partn, reboot, verify_resultp);
-       if (rc != 0)
-               goto fail1;
+       /*
+        * NVRAM updates can take a long time (e.g. up to 1 minute for bundle
+        * images). Polling for NVRAM update completion ensures that other MCDI
+        * commands can be issued before the background NVRAM update completes.
+        *
+        * Without polling, other MCDI commands can only be issued before the
+        * NVRAM update completes if the MCDI transport and the firmware
+        * support the Asynchronous MCDI protocol extensions in SF-116575-PS.
+        *
+        * The initial call either completes the update synchronously, or
+        * returns RC_PENDING to indicate processing is continuing. In the
+        * latter case, we poll for at least 1 minute, at increasing intervals
+        * (10ms, 100ms, 1s).
+        */
+       while (verify_result == MC_CMD_NVRAM_VERIFY_RC_PENDING) {
+
+               if (poll_retry > EF10_NVRAM_POLL_RETRIES) {
+                       rc = ETIMEDOUT;
+                       goto fail1;
+               }
+               poll_retry++;
+
+               EFSYS_SLEEP(poll_delay_us);
+               if (poll_delay_us < EF10_NVRAM_MAX_POLL_DELAY_US)
+                       poll_delay_us *= 10;
+
+               /* Poll for completion of background NVRAM update. */
+               verify_result = MC_CMD_NVRAM_VERIFY_RC_UNKNOWN;
+
+               rc = efx_mcdi_nvram_update_finish(enp, partn, reboot,
+                   EFX_NVRAM_UPDATE_FLAGS_POLL, &verify_result);
+               if (rc != 0) {
+                       /* Poll failed, so assume NVRAM update failed. */
+                       goto fail2;
+               }
+       }
+
+       if (verify_resultp != NULL)
+               *verify_resultp = verify_result;
 
        return (0);
 
+fail2:
+       EFSYS_PROBE(fail2);
 fail1:
        EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
index d46e6509f8de929b4ac4648fd0bb837336b53340..43853797a9b9d35871c02b5175bea53a091445e1 100644 (file)
@@ -1395,6 +1395,8 @@ typedef struct efx_nic_cfg_s {
        uint32_t                enc_max_pcie_link_gen;
        /* Firmware verifies integrity of NVRAM updates */
        boolean_t               enc_nvram_update_verify_result_supported;
+       /* Firmware supports polled NVRAM updates on select partitions */
+       boolean_t               enc_nvram_update_poll_verify_result_supported;
        /* Firmware accepts updates via the BUNDLE partition */
        boolean_t               enc_nvram_bundle_update_supported;
        /* Firmware support for extended MAC_STATS buffer */
index d8cadda89298b46334a0d31cb7d157917db09490..067cec303c8e9cd19177b88057e8d23c1813c1c5 100644 (file)
@@ -594,11 +594,15 @@ efx_mcdi_nvram_write(
        __in_bcount(size)       caddr_t data,
        __in                    size_t size);
 
+#define        EFX_NVRAM_UPDATE_FLAGS_BACKGROUND       0x00000001
+#define        EFX_NVRAM_UPDATE_FLAGS_POLL             0x00000002
+
        __checkReturn           efx_rc_t
 efx_mcdi_nvram_update_finish(
        __in                    efx_nic_t *enp,
        __in                    uint32_t partn,
        __in                    boolean_t reboot,
+       __in                    uint32_t flags,
        __out_opt               uint32_t *verify_resultp);
 
 #if EFSYS_OPT_DIAG
index 74dac41520b58a3fae023cc672cd3b27fa744324..5e7236ca7566878f3dabc3faacbd86786e996d7a 100644 (file)
@@ -965,6 +965,7 @@ efx_mcdi_nvram_update_finish(
        __in                    efx_nic_t *enp,
        __in                    uint32_t partn,
        __in                    boolean_t reboot,
+       __in                    uint32_t flags,
        __out_opt               uint32_t *verify_resultp)
 {
        const efx_nic_cfg_t *encp = &enp->en_nic_cfg;
@@ -972,7 +973,7 @@ efx_mcdi_nvram_update_finish(
        EFX_MCDI_DECLARE_BUF(payload, MC_CMD_NVRAM_UPDATE_FINISH_V2_IN_LEN,
                MC_CMD_NVRAM_UPDATE_FINISH_V2_OUT_LEN);
        uint32_t verify_result = MC_CMD_NVRAM_VERIFY_RC_UNKNOWN;
-       efx_rc_t rc;
+       efx_rc_t rc = 0;
 
        req.emr_cmd = MC_CMD_NVRAM_UPDATE_FINISH;
        req.emr_in_buf = payload;
@@ -983,8 +984,19 @@ efx_mcdi_nvram_update_finish(
        MCDI_IN_SET_DWORD(req, NVRAM_UPDATE_FINISH_V2_IN_TYPE, partn);
        MCDI_IN_SET_DWORD(req, NVRAM_UPDATE_FINISH_V2_IN_REBOOT, reboot);
 
-       MCDI_IN_POPULATE_DWORD_1(req, NVRAM_UPDATE_FINISH_V2_IN_FLAGS,
-           NVRAM_UPDATE_FINISH_V2_IN_FLAG_REPORT_VERIFY_RESULT, 1);
+       if (!encp->enc_nvram_update_poll_verify_result_supported) {
+               flags &= ~EFX_NVRAM_UPDATE_FLAGS_BACKGROUND;
+               flags &= ~EFX_NVRAM_UPDATE_FLAGS_POLL;
+       }
+
+       MCDI_IN_POPULATE_DWORD_3(req, NVRAM_UPDATE_FINISH_V2_IN_FLAGS,
+           NVRAM_UPDATE_FINISH_V2_IN_FLAG_REPORT_VERIFY_RESULT,
+           1,
+           NVRAM_UPDATE_FINISH_V2_IN_FLAG_RUN_IN_BACKGROUND,
+           (flags & EFX_NVRAM_UPDATE_FLAGS_BACKGROUND) ? 1 : 0,
+           NVRAM_UPDATE_FINISH_V2_IN_FLAG_POLL_VERIFY_RESULT,
+           (flags & EFX_NVRAM_UPDATE_FLAGS_POLL) ? 1 : 0
+           );
 
        efx_mcdi_execute(enp, &req);
 
@@ -1005,11 +1017,13 @@ efx_mcdi_nvram_update_finish(
                    MCDI_OUT_DWORD(req, NVRAM_UPDATE_FINISH_V2_OUT_RESULT_CODE);
        }
 
-       if ((encp->enc_nvram_update_verify_result_supported) &&
-           (verify_result != MC_CMD_NVRAM_VERIFY_RC_SUCCESS)) {
-               /* Update verification failed */
-               rc = EINVAL;
-               goto fail3;
+       if (encp->enc_nvram_update_verify_result_supported) {
+               if ((verify_result != MC_CMD_NVRAM_VERIFY_RC_SUCCESS) &&
+                   (verify_result != MC_CMD_NVRAM_VERIFY_RC_PENDING)) {
+                       /* Update verification failed */
+                       rc = EINVAL;
+                       goto fail3;
+               }
        }
 
        if (verify_resultp != NULL)
index 47a8ca20a6b734938dc7d98eafcb84234396938d..51e601ec1902b47018031a6b7f5112bf15606d5b 100644 (file)
@@ -174,6 +174,7 @@ siena_nvram_partn_unlock(
        __out_opt               uint32_t *verify_resultp)
 {
        boolean_t reboot;
+       uint32_t flags = 0;
        efx_rc_t rc;
 
        /*
@@ -184,7 +185,8 @@ siena_nvram_partn_unlock(
                    partn == MC_CMD_NVRAM_TYPE_PHY_PORT1 ||
                    partn == MC_CMD_NVRAM_TYPE_DISABLED_CALLISTO);
 
-       rc = efx_mcdi_nvram_update_finish(enp, partn, reboot, verify_resultp);
+       rc = efx_mcdi_nvram_update_finish(enp, partn, reboot, flags,
+                   verify_resultp);
        if (rc != 0)
                goto fail1;