net/sfc/base: add NVRAM info
authorRichard Houldsworth <rhouldsworth@solarflare.com>
Mon, 10 Jun 2019 07:38:24 +0000 (08:38 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 20 Jun 2019 21:42:04 +0000 (23:42 +0200)
Add function to query partition characteristics.
Refactor efx_nvram_size to share implementation.

Signed-off-by: Richard Houldsworth <rhouldsworth@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/base/ef10_impl.h
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_impl.h
drivers/net/sfc/base/siena_nvram.c

index fae94fe..0cfbf59 100644 (file)
@@ -451,6 +451,12 @@ ef10_nvram_partn_size(
        __in                    uint32_t partn,
        __out                   size_t *sizep);
 
+extern __checkReturn           efx_rc_t
+ef10_nvram_partn_info(
+       __in                    efx_nic_t *enp,
+       __in                    uint32_t partn,
+       __out                   efx_nvram_info_t * enip);
+
 extern __checkReturn           efx_rc_t
 ef10_nvram_partn_rw_start(
        __in                    efx_nic_t *enp,
index 2aed421..a618c75 100644 (file)
@@ -1959,6 +1959,29 @@ fail1:
        return (rc);
 }
 
+       __checkReturn           efx_rc_t
+ef10_nvram_partn_info(
+       __in                    efx_nic_t *enp,
+       __in                    uint32_t partn,
+       __out                   efx_nvram_info_t *enip)
+{
+       efx_rc_t rc;
+
+       if ((rc = efx_mcdi_nvram_info_ex(enp, partn, enip)) != 0)
+               goto fail1;
+
+       if (enip->eni_write_size == 0)
+               enip->eni_write_size = EF10_NVRAM_CHUNK;
+
+       return (0);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+
        __checkReturn           efx_rc_t
 ef10_nvram_partn_lock(
        __in                    efx_nic_t *enp,
@@ -2439,22 +2462,17 @@ ef10_nvram_partn_rw_start(
        __in                    uint32_t partn,
        __out                   size_t *chunk_sizep)
 {
-       uint32_t write_size = 0;
+       efx_nvram_info_t eni = { 0 };
        efx_rc_t rc;
 
-       if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL,
-           NULL, &write_size)) != 0)
+       if ((rc = ef10_nvram_partn_info(enp, partn, &eni)) != 0)
                goto fail1;
 
        if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0)
                goto fail2;
 
-       if (chunk_sizep != NULL) {
-               if (write_size == 0)
-                       *chunk_sizep = EF10_NVRAM_CHUNK;
-               else
-                       *chunk_sizep = write_size;
-       }
+       if (chunk_sizep != NULL)
+               *chunk_sizep = eni.eni_write_size;
 
        return (0);
 
index a5342af..4905918 100644 (file)
@@ -1634,6 +1634,12 @@ efx_nvram_size(
        __in                    efx_nvram_type_t type,
        __out                   size_t *sizep);
 
+extern __checkReturn           efx_rc_t
+efx_nvram_info(
+       __in                    efx_nic_t *enp,
+       __in                    efx_nvram_type_t type,
+       __out                   efx_nvram_info_t *enip);
+
 extern __checkReturn           efx_rc_t
 efx_nvram_rw_start(
        __in                    efx_nic_t *enp,
index 684403f..577d5aa 100644 (file)
@@ -501,7 +501,8 @@ typedef struct efx_nvram_ops_s {
 #endif /* EFSYS_OPT_DIAG */
        efx_rc_t        (*envo_type_to_partn)(efx_nic_t *, efx_nvram_type_t,
                                            uint32_t *);
-       efx_rc_t        (*envo_partn_size)(efx_nic_t *, uint32_t, size_t *);
+       efx_rc_t        (*envo_partn_info)(efx_nic_t *, uint32_t,
+                                           efx_nvram_info_t *);
        efx_rc_t        (*envo_partn_rw_start)(efx_nic_t *, uint32_t, size_t *);
        efx_rc_t        (*envo_partn_read)(efx_nic_t *, uint32_t,
                                            unsigned int, caddr_t, size_t);
index df7e851..b817cb6 100644 (file)
@@ -16,7 +16,7 @@ static const efx_nvram_ops_t  __efx_nvram_siena_ops = {
        siena_nvram_test,               /* envo_test */
 #endif /* EFSYS_OPT_DIAG */
        siena_nvram_type_to_partn,      /* envo_type_to_partn */
-       siena_nvram_partn_size,         /* envo_partn_size */
+       siena_nvram_partn_info,         /* envo_partn_info */
        siena_nvram_partn_rw_start,     /* envo_partn_rw_start */
        siena_nvram_partn_read,         /* envo_partn_read */
        siena_nvram_partn_read,         /* envo_partn_read_backup */
@@ -37,7 +37,7 @@ static const efx_nvram_ops_t  __efx_nvram_ef10_ops = {
        ef10_nvram_test,                /* envo_test */
 #endif /* EFSYS_OPT_DIAG */
        ef10_nvram_type_to_partn,       /* envo_type_to_partn */
-       ef10_nvram_partn_size,          /* envo_partn_size */
+       ef10_nvram_partn_info,          /* envo_partn_info */
        ef10_nvram_partn_rw_start,      /* envo_partn_rw_start */
        ef10_nvram_partn_read,          /* envo_partn_read */
        ef10_nvram_partn_read_backup,   /* envo_partn_read_backup */
@@ -138,6 +138,7 @@ efx_nvram_size(
        __out                   size_t *sizep)
 {
        const efx_nvram_ops_t *envop = enp->en_envop;
+       efx_nvram_info_t eni = { 0 };
        uint32_t partn;
        efx_rc_t rc;
 
@@ -147,9 +148,11 @@ efx_nvram_size(
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
-       if ((rc = envop->envo_partn_size(enp, partn, sizep)) != 0)
+       if ((rc = envop->envo_partn_info(enp, partn, &eni)) != 0)
                goto fail2;
 
+       *sizep = eni.eni_partn_size;
+
        return (0);
 
 fail2:
@@ -161,6 +164,36 @@ fail1:
        return (rc);
 }
 
+extern __checkReturn           efx_rc_t
+efx_nvram_info(
+       __in                    efx_nic_t *enp,
+       __in                    efx_nvram_type_t type,
+       __out                   efx_nvram_info_t *enip)
+{
+       const efx_nvram_ops_t *envop = enp->en_envop;
+       uint32_t partn;
+       efx_rc_t rc;
+
+       EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+       EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
+
+       if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
+               goto fail1;
+
+       if ((rc = envop->envo_partn_info(enp, partn, enip)) != 0)
+               goto fail2;
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+
        __checkReturn           efx_rc_t
 efx_nvram_get_version(
        __in                    efx_nic_t *enp,
@@ -305,7 +338,7 @@ efx_nvram_erase(
 {
        const efx_nvram_ops_t *envop = enp->en_envop;
        unsigned int offset = 0;
-       size_t size = 0;
+       efx_nvram_info_t eni = { 0 };
        uint32_t partn;
        efx_rc_t rc;
 
@@ -317,10 +350,11 @@ efx_nvram_erase(
 
        EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn);
 
-       if ((rc = envop->envo_partn_size(enp, partn, &size)) != 0)
+       if ((rc = envop->envo_partn_info(enp, partn, &eni)) != 0)
                goto fail2;
 
-       if ((rc = envop->envo_partn_erase(enp, partn, offset, size)) != 0)
+       if ((rc = envop->envo_partn_erase(enp, partn, offset,
+                   eni.eni_partn_size)) != 0)
                goto fail3;
 
        return (0);
index 1adb8a4..38d0289 100644 (file)
@@ -191,6 +191,12 @@ siena_nvram_partn_size(
        __in                    uint32_t partn,
        __out                   size_t *sizep);
 
+extern __checkReturn           efx_rc_t
+siena_nvram_partn_info(
+       __in                    efx_nic_t *enp,
+       __in                    uint32_t partn,
+       __out                   efx_nvram_info_t * enip);
+
 extern __checkReturn           efx_rc_t
 siena_nvram_partn_rw_start(
        __in                    efx_nic_t *enp,
index b8ea8a7..7d423d2 100644 (file)
@@ -39,6 +39,29 @@ fail1:
        return (rc);
 }
 
+       __checkReturn           efx_rc_t
+siena_nvram_partn_info(
+       __in                    efx_nic_t *enp,
+       __in                    uint32_t partn,
+       __out                   efx_nvram_info_t * enip)
+{
+       efx_rc_t rc;
+
+       if ((rc = efx_mcdi_nvram_info_ex(enp, partn, enip)) != 0)
+               goto fail1;
+
+       if (enip->eni_write_size == 0)
+               enip->eni_write_size = SIENA_NVRAM_CHUNK;
+
+       return (0);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
+
        __checkReturn           efx_rc_t
 siena_nvram_partn_lock(
        __in                    efx_nic_t *enp,