net/sfc/base: add NVRAM info

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>
This commit is contained in:
Richard Houldsworth 2019-06-10 08:38:24 +01:00 committed by Ferruh Yigit
parent 2a8156a559
commit ca7b214cc5
7 changed files with 110 additions and 16 deletions

View 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,

View File

@ -1959,6 +1959,29 @@ ef10_nvram_partn_size(
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);

View 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,

View 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);

View 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 @@ efx_nvram_size(
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);

View 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,

View File

@ -39,6 +39,29 @@ siena_nvram_partn_size(
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,