sfxge: convert nvram erase method to use partition id

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision: https://reviews.freebsd.org/D4957
This commit is contained in:
arybchik 2016-01-17 05:12:37 +00:00
parent 157f6a3fb8
commit 4baa9c9a10
6 changed files with 33 additions and 89 deletions

View File

@ -486,7 +486,6 @@ typedef struct efx_nvram_ops_s {
#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_erase)(efx_nic_t *, efx_nvram_type_t);
efx_rc_t (*envo_write_chunk)(efx_nic_t *, efx_nvram_type_t,
unsigned int, caddr_t, size_t);
void (*envo_rw_finish)(efx_nic_t *, efx_nvram_type_t);
@ -499,6 +498,8 @@ typedef struct efx_nvram_ops_s {
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);
efx_rc_t (*envo_partn_erase)(efx_nic_t *, uint32_t,
unsigned int, size_t);
} efx_nvram_ops_t;
#endif /* EFSYS_OPT_NVRAM */

View File

@ -43,7 +43,6 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = {
falcon_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
falcon_nvram_get_version, /* envo_get_version */
falcon_nvram_erase, /* envo_erase */
falcon_nvram_write_chunk, /* envo_write_chunk */
falcon_nvram_rw_finish, /* envo_rw_finish */
falcon_nvram_set_version, /* envo_set_version */
@ -51,6 +50,7 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = {
falcon_nvram_partn_size, /* envo_partn_size */
falcon_nvram_partn_rw_start, /* envo_partn_rw_start */
falcon_nvram_partn_read, /* envo_partn_read */
falcon_nvram_partn_erase, /* envo_partn_erase */
};
#endif /* EFSYS_OPT_FALCON */
@ -62,7 +62,6 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = {
siena_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
siena_nvram_get_version, /* envo_get_version */
siena_nvram_erase, /* envo_erase */
siena_nvram_write_chunk, /* envo_write_chunk */
siena_nvram_rw_finish, /* envo_rw_finish */
siena_nvram_set_version, /* envo_set_version */
@ -70,6 +69,7 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = {
siena_nvram_partn_size, /* envo_partn_size */
siena_nvram_partn_rw_start, /* envo_partn_rw_start */
siena_nvram_partn_read, /* envo_partn_read */
siena_nvram_partn_erase, /* envo_partn_erase */
};
#endif /* EFSYS_OPT_SIENA */
@ -81,7 +81,6 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = {
ef10_nvram_test, /* envo_test */
#endif /* EFSYS_OPT_DIAG */
ef10_nvram_get_version, /* envo_get_version */
ef10_nvram_erase, /* envo_erase */
ef10_nvram_write_chunk, /* envo_write_chunk */
ef10_nvram_rw_finish, /* envo_rw_finish */
ef10_nvram_set_version, /* envo_set_version */
@ -89,6 +88,7 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = {
ef10_nvram_partn_size, /* envo_partn_size */
ef10_nvram_partn_rw_start, /* envo_partn_rw_start */
ef10_nvram_partn_read, /* envo_partn_read */
ef10_nvram_partn_erase, /* envo_partn_erase */
};
#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
@ -308,6 +308,9 @@ efx_nvram_erase(
__in efx_nvram_type_t type)
{
efx_nvram_ops_t *envop = enp->en_envop;
unsigned int offset = 0;
size_t size = 0;
uint32_t partn;
efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
@ -318,11 +321,21 @@ efx_nvram_erase(
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type);
if ((rc = envop->envo_erase(enp, type)) != 0)
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = envop->envo_partn_size(enp, partn, &size)) != 0)
goto fail2;
if ((rc = envop->envo_partn_erase(enp, partn, offset, size)) != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

View File

@ -369,13 +369,6 @@ ef10_nvram_partn_lock(
__in efx_nic_t *enp,
__in uint32_t partn);
extern __checkReturn efx_rc_t
ef10_nvram_partn_erase(
__in efx_nic_t *enp,
__in uint32_t partn,
__in unsigned int offset,
__in size_t size);
extern __checkReturn efx_rc_t
ef10_nvram_partn_write(
__in efx_nic_t *enp,
@ -408,11 +401,6 @@ ef10_nvram_get_version(
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
ef10_nvram_erase(
__in efx_nic_t *enp,
__in efx_nvram_type_t type);
extern __checkReturn efx_rc_t
ef10_nvram_write_chunk(
__in efx_nic_t *enp,
@ -464,6 +452,13 @@ ef10_nvram_partn_read(
__out_bcount(size) caddr_t data,
__in size_t size);
extern __checkReturn efx_rc_t
ef10_nvram_partn_erase(
__in efx_nic_t *enp,
__in uint32_t partn,
__in unsigned int offset,
__in size_t size);
#endif /* EFSYS_OPT_NVRAM */

View File

@ -1765,36 +1765,6 @@ ef10_nvram_partn_rw_start(
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
ef10_nvram_erase(
__in efx_nic_t *enp,
__in efx_nvram_type_t type)
{
uint32_t partn;
size_t size;
efx_rc_t rc;
if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = ef10_nvram_partn_size(enp, partn, &size)) != 0)
goto fail2;
if ((rc = ef10_nvram_partn_erase(enp, partn, 0, size)) != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}

View File

@ -155,13 +155,6 @@ siena_nvram_partn_lock(
__in efx_nic_t *enp,
__in uint32_t partn);
extern __checkReturn efx_rc_t
siena_nvram_partn_erase(
__in efx_nic_t *enp,
__in uint32_t partn,
__in unsigned int offset,
__in size_t size);
extern __checkReturn efx_rc_t
siena_nvram_partn_write(
__in efx_nic_t *enp,
@ -208,11 +201,6 @@ siena_nvram_get_version(
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
siena_nvram_erase(
__in efx_nic_t *enp,
__in efx_nvram_type_t type);
extern __checkReturn efx_rc_t
siena_nvram_write_chunk(
__in efx_nic_t *enp,
@ -258,6 +246,13 @@ siena_nvram_partn_read(
__out_bcount(size) caddr_t data,
__in size_t size);
extern __checkReturn efx_rc_t
siena_nvram_partn_erase(
__in efx_nic_t *enp,
__in uint32_t partn,
__in unsigned int offset,
__in size_t size);
#endif /* EFSYS_OPT_NVRAM */
#if EFSYS_OPT_VPD

View File

@ -590,36 +590,6 @@ siena_nvram_partn_rw_start(
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
__checkReturn efx_rc_t
siena_nvram_erase(
__in efx_nic_t *enp,
__in efx_nvram_type_t type)
{
size_t size;
uint32_t partn;
efx_rc_t rc;
if ((rc = siena_nvram_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = siena_nvram_partn_size(enp, partn, &size)) != 0)
goto fail2;
if ((rc = siena_nvram_partn_erase(enp, partn, 0, size)) != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}