sfxge: convert nvram get_version method to use partition id

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
This commit is contained in:
Andrew Rybchenko 2016-01-18 06:16:51 +00:00
parent eb9703da94
commit 9218711910
6 changed files with 42 additions and 49 deletions

View File

@ -484,8 +484,6 @@ typedef struct efx_nvram_ops_s {
#if EFSYS_OPT_DIAG
efx_rc_t (*envo_test)(efx_nic_t *);
#endif /* EFSYS_OPT_DIAG */
efx_rc_t (*envo_get_version)(efx_nic_t *, efx_nvram_type_t,
uint32_t *, uint16_t *);
efx_rc_t (*envo_set_version)(efx_nic_t *, efx_nvram_type_t,
uint16_t *);
@ -500,6 +498,8 @@ typedef struct efx_nvram_ops_s {
efx_rc_t (*envo_partn_write)(efx_nic_t *, uint32_t,
unsigned int, caddr_t, size_t);
void (*envo_partn_rw_finish)(efx_nic_t *, uint32_t);
efx_rc_t (*envo_partn_get_version)(efx_nic_t *, uint32_t,
uint32_t *, uint16_t *);
} efx_nvram_ops_t;
#endif /* EFSYS_OPT_NVRAM */

View File

@ -42,7 +42,6 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = {
#if EFSYS_OPT_DIAG
falcon_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
falcon_nvram_get_version, /* envo_get_version */
falcon_nvram_set_version, /* envo_set_version */
falcon_nvram_type_to_partn, /* envo_type_to_partn */
falcon_nvram_partn_size, /* envo_partn_size */
@ -51,6 +50,7 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = {
falcon_nvram_partn_erase, /* envo_partn_erase */
falcon_nvram_partn_write, /* envo_partn_write */
falcon_nvram_partn_rw_finish, /* envo_partn_rw_finish */
falcon_nvram_partn_get_version, /* envo_partn_get_version */
};
#endif /* EFSYS_OPT_FALCON */
@ -61,7 +61,6 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = {
#if EFSYS_OPT_DIAG
siena_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
siena_nvram_get_version, /* envo_get_version */
siena_nvram_set_version, /* envo_set_version */
siena_nvram_type_to_partn, /* envo_type_to_partn */
siena_nvram_partn_size, /* envo_partn_size */
@ -70,6 +69,7 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = {
siena_nvram_partn_erase, /* envo_partn_erase */
siena_nvram_partn_write, /* envo_partn_write */
siena_nvram_partn_rw_finish, /* envo_partn_rw_finish */
siena_nvram_partn_get_version, /* envo_partn_get_version */
};
#endif /* EFSYS_OPT_SIENA */
@ -80,7 +80,6 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = {
#if EFSYS_OPT_DIAG
ef10_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
ef10_nvram_get_version, /* envo_get_version */
ef10_nvram_set_version, /* envo_set_version */
ef10_nvram_type_to_partn, /* envo_type_to_partn */
ef10_nvram_partn_size, /* envo_partn_size */
@ -89,6 +88,7 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = {
ef10_nvram_partn_erase, /* envo_partn_erase */
ef10_nvram_partn_write, /* envo_partn_write */
ef10_nvram_partn_rw_finish, /* envo_partn_rw_finish */
ef10_nvram_partn_get_version, /* envo_partn_get_version */
};
#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
@ -211,6 +211,7 @@ efx_nvram_get_version(
__out_ecount(4) uint16_t version[4])
{
efx_nvram_ops_t *envop = enp->en_envop;
uint32_t partn;
efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
@ -219,11 +220,17 @@ efx_nvram_get_version(
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
if ((rc = envop->envo_get_version(enp, type, subtypep, version)) != 0)
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = envop->envo_partn_get_version(enp, partn,
subtypep, version)) != 0)
goto fail2;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

View File

@ -386,13 +386,6 @@ ef10_nvram_test(
#endif /* EFSYS_OPT_DIAG */
extern __checkReturn efx_rc_t
ef10_nvram_get_version(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
ef10_nvram_partn_set_version(
__in efx_nic_t *enp,
@ -451,6 +444,13 @@ ef10_nvram_partn_rw_finish(
__in efx_nic_t *enp,
__in uint32_t partn);
extern __checkReturn efx_rc_t
ef10_nvram_partn_get_version(
__in efx_nic_t *enp,
__in uint32_t partn,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
#endif /* EFSYS_OPT_NVRAM */

View File

@ -1717,29 +1717,23 @@ fail1:
#endif /* EFSYS_OPT_DIAG */
__checkReturn efx_rc_t
ef10_nvram_get_version(
ef10_nvram_partn_get_version(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__in uint32_t partn,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4])
{
uint32_t partn;
efx_rc_t rc;
if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
/* FIXME: get highest partn version from all ports */
/* FIXME: return partn description if available */
if ((rc = efx_mcdi_nvram_metadata(enp, partn, subtypep,
version, NULL, 0)) != 0)
goto fail2;
goto fail1;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

View File

@ -186,13 +186,6 @@ siena_nvram_get_subtype(
__in uint32_t partn,
__out uint32_t *subtypep);
extern __checkReturn efx_rc_t
siena_nvram_get_version(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
siena_nvram_set_version(
__in efx_nic_t *enp,
@ -245,6 +238,13 @@ siena_nvram_partn_rw_finish(
__in efx_nic_t *enp,
__in uint32_t partn);
extern __checkReturn efx_rc_t
siena_nvram_partn_get_version(
__in efx_nic_t *enp,
__in uint32_t partn,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
#endif /* EFSYS_OPT_NVRAM */

View File

@ -482,29 +482,25 @@ fail1:
}
__checkReturn efx_rc_t
siena_nvram_get_version(
siena_nvram_partn_get_version(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__in uint32_t partn,
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4])
{
siena_mc_dynamic_config_hdr_t *dcfg;
siena_parttbl_entry_t *entry;
uint32_t dcfg_partn;
uint32_t partn;
unsigned int i;
efx_rc_t rc;
if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((1 << partn) & ~enp->en_u.siena.enu_partn_mask) {
rc = ENOTSUP;
goto fail2;
goto fail1;
}
if ((rc = siena_nvram_get_subtype(enp, partn, subtypep)) != 0)
goto fail3;
goto fail2;
/*
* Some partitions are accessible from both ports (for instance BOOTROM)
@ -513,6 +509,7 @@ siena_nvram_get_version(
*/
version[0] = version[1] = version[2] = version[3] = 0;
for (i = 0; i < EFX_ARRAY_SIZE(siena_parttbl); i++) {
siena_mc_fw_version_t *verp;
unsigned int nitems;
uint16_t temp[4];
size_t length;
@ -535,32 +532,27 @@ siena_nvram_get_version(
if ((rc = siena_nvram_get_dynamic_cfg(enp, dcfg_partn,
B_FALSE, &dcfg, &length)) != 0)
goto fail4;
goto fail3;
nitems = EFX_DWORD_FIELD(dcfg->num_fw_version_items,
EFX_DWORD_0);
if (nitems < entry->partn)
goto done;
temp[0] = EFX_WORD_FIELD(dcfg->fw_version[partn].version_w,
EFX_WORD_0);
temp[1] = EFX_WORD_FIELD(dcfg->fw_version[partn].version_x,
EFX_WORD_0);
temp[2] = EFX_WORD_FIELD(dcfg->fw_version[partn].version_y,
EFX_WORD_0);
temp[3] = EFX_WORD_FIELD(dcfg->fw_version[partn].version_z,
EFX_WORD_0);
verp = &dcfg->fw_version[partn];
temp[0] = EFX_WORD_FIELD(verp->version_w, EFX_WORD_0);
temp[1] = EFX_WORD_FIELD(verp->version_x, EFX_WORD_0);
temp[2] = EFX_WORD_FIELD(verp->version_y, EFX_WORD_0);
temp[3] = EFX_WORD_FIELD(verp->version_z, EFX_WORD_0);
if (memcmp(version, temp, sizeof (temp)) < 0)
memcpy(version, temp, sizeof (temp));
done:
done:
EFSYS_KMEM_FREE(enp->en_esip, length, dcfg);
}
return (0);
fail4:
EFSYS_PROBE(fail4);
fail3:
EFSYS_PROBE(fail3);
fail2: