net/sfc/base: add extensible NVRAM info function

Includes the partition read-only flag, to allow for
checks before opening the partition.

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:23 +01:00 committed by Ferruh Yigit
parent 51781c706f
commit 2a8156a559
3 changed files with 68 additions and 14 deletions

View File

@ -1606,6 +1606,16 @@ typedef enum efx_nvram_type_e {
EFX_NVRAM_NTYPES,
} efx_nvram_type_t;
typedef struct efx_nvram_info_s {
uint32_t eni_flags;
uint32_t eni_partn_size;
uint32_t eni_address;
uint32_t eni_erase_size;
uint32_t eni_write_size;
} efx_nvram_info_t;
#define EFX_NVRAM_FLAG_READ_ONLY (1 << 0)
extern __checkReturn efx_rc_t
efx_nvram_init(
__in efx_nic_t *enp);

View File

@ -567,6 +567,12 @@ efx_mcdi_nvram_info(
__out_opt uint32_t *erase_sizep,
__out_opt uint32_t *write_sizep);
__checkReturn efx_rc_t
efx_mcdi_nvram_info_ex(
__in efx_nic_t *enp,
__in uint32_t partn,
__out efx_nvram_info_t *eni);
__checkReturn efx_rc_t
efx_mcdi_nvram_update_start(
__in efx_nic_t *enp,

View File

@ -657,13 +657,10 @@ efx_mcdi_nvram_metadata(
}
__checkReturn efx_rc_t
efx_mcdi_nvram_info(
efx_mcdi_nvram_info_ex(
__in efx_nic_t *enp,
__in uint32_t partn,
__out_opt size_t *sizep,
__out_opt uint32_t *addressp,
__out_opt uint32_t *erase_sizep,
__out_opt uint32_t *write_sizep)
__out efx_nvram_info_t *enip)
{
EFX_MCDI_DECLARE_BUF(payload, MC_CMD_NVRAM_INFO_IN_LEN,
MC_CMD_NVRAM_INFO_V2_OUT_LEN);
@ -690,21 +687,26 @@ efx_mcdi_nvram_info(
goto fail2;
}
if (sizep)
*sizep = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_SIZE);
enip->eni_partn_size = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_SIZE);
if (addressp)
*addressp = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_PHYSADDR);
enip->eni_address = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_PHYSADDR);
if (erase_sizep)
*erase_sizep = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_ERASESIZE);
enip->eni_erase_size = MCDI_OUT_DWORD(req, NVRAM_INFO_OUT_ERASESIZE);
if (write_sizep) {
*write_sizep =
enip->eni_write_size =
(req.emr_out_length_used <
MC_CMD_NVRAM_INFO_V2_OUT_LEN) ?
0 : MCDI_OUT_DWORD(req, NVRAM_INFO_V2_OUT_WRITESIZE);
}
enip->eni_flags = 0;
if (MCDI_OUT_DWORD_FIELD(req, NVRAM_INFO_OUT_FLAGS,
NVRAM_INFO_OUT_PROTECTED))
enip->eni_flags |= EFX_NVRAM_FLAG_READ_ONLY;
if (MCDI_OUT_DWORD_FIELD(req, NVRAM_INFO_OUT_FLAGS,
NVRAM_INFO_OUT_READ_ONLY))
enip->eni_flags |= EFX_NVRAM_FLAG_READ_ONLY;
return (0);
@ -716,6 +718,42 @@ efx_mcdi_nvram_info(
return (rc);
}
__checkReturn efx_rc_t
efx_mcdi_nvram_info(
__in efx_nic_t *enp,
__in uint32_t partn,
__out_opt size_t *sizep,
__out_opt uint32_t *addressp,
__out_opt uint32_t *erase_sizep,
__out_opt uint32_t *write_sizep)
{
efx_nvram_info_t eni;
efx_rc_t rc;
if ((rc = efx_mcdi_nvram_info_ex(enp, partn, &eni)) != 0)
goto fail1;
if (sizep)
*sizep = eni.eni_partn_size;
if (addressp)
*addressp = eni.eni_address;
if (erase_sizep)
*erase_sizep = eni.eni_erase_size;
if (write_sizep)
*write_sizep = eni.eni_write_size;
return (0);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
/*
* MC_CMD_NVRAM_UPDATE_START_V2 must be used to support firmware-verified
* NVRAM updates. Older firmware will ignore the flags field in the request.