sfxge: convert nvram rw_start method to use partition id

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Reviewed by:    gnn
Sponsored by:   Solarflare Communications, Inc.
MFC after:      2 days
Differential Revision: https://reviews.freebsd.org/D4937
This commit is contained in:
arybchik 2016-01-15 06:28:58 +00:00
parent d4acda6c23
commit 4a70b41c18
6 changed files with 29 additions and 35 deletions

View File

@ -485,7 +485,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_rw_start)(efx_nic_t *, efx_nvram_type_t, size_t *);
efx_rc_t (*envo_read_chunk)(efx_nic_t *, efx_nvram_type_t,
unsigned int, caddr_t, size_t);
efx_rc_t (*envo_erase)(efx_nic_t *, efx_nvram_type_t);
@ -498,6 +497,7 @@ typedef struct efx_nvram_ops_s {
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_rw_start)(efx_nic_t *, uint32_t, 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_rw_start, /* envo_rw_start */
falcon_nvram_read_chunk, /* envo_read_chunk */
falcon_nvram_erase, /* envo_erase */
falcon_nvram_write_chunk, /* envo_write_chunk */
@ -51,6 +50,7 @@ static efx_nvram_ops_t __efx_nvram_falcon_ops = {
falcon_nvram_set_version, /* envo_set_version */
falcon_nvram_type_to_partn, /* envo_type_to_partn */
falcon_nvram_partn_size, /* envo_partn_size */
falcon_nvram_partn_rw_start, /* envo_partn_rw_start */
};
#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_rw_start, /* envo_rw_start */
siena_nvram_read_chunk, /* envo_read_chunk */
siena_nvram_erase, /* envo_erase */
siena_nvram_write_chunk, /* envo_write_chunk */
@ -70,6 +69,7 @@ static efx_nvram_ops_t __efx_nvram_siena_ops = {
siena_nvram_set_version, /* envo_set_version */
siena_nvram_type_to_partn, /* envo_type_to_partn */
siena_nvram_partn_size, /* envo_partn_size */
siena_nvram_partn_rw_start, /* envo_partn_rw_start */
};
#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_rw_start, /* envo_rw_start */
ef10_nvram_read_chunk, /* envo_read_chunk */
ef10_nvram_erase, /* envo_erase */
ef10_nvram_write_chunk, /* envo_write_chunk */
@ -89,6 +88,7 @@ static efx_nvram_ops_t __efx_nvram_ef10_ops = {
ef10_nvram_set_version, /* envo_set_version */
ef10_nvram_type_to_partn, /* envo_type_to_partn */
ef10_nvram_partn_size, /* envo_partn_size */
ef10_nvram_partn_rw_start, /* envo_partn_rw_start */
};
#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
@ -237,6 +237,7 @@ efx_nvram_rw_start(
__out_opt size_t *chunk_sizep)
{
efx_nvram_ops_t *envop = enp->en_envop;
uint32_t partn;
efx_rc_t rc;
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
@ -247,13 +248,18 @@ efx_nvram_rw_start(
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID);
if ((rc = envop->envo_rw_start(enp, type, chunk_sizep)) != 0)
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = envop->envo_partn_rw_start(enp, partn, chunk_sizep)) != 0)
goto fail2;
enp->en_nvram_locked = type;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

View File

@ -416,12 +416,6 @@ ef10_nvram_get_version(
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
ef10_nvram_rw_start(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__out size_t *pref_chunkp);
extern __checkReturn efx_rc_t
ef10_nvram_read_chunk(
__in efx_nic_t *enp,
@ -472,6 +466,12 @@ ef10_nvram_partn_size(
__in uint32_t partn,
__out size_t *sizep);
extern __checkReturn efx_rc_t
ef10_nvram_partn_rw_start(
__in efx_nic_t *enp,
__in uint32_t partn,
__out size_t *chunk_sizep);
#endif /* EFSYS_OPT_NVRAM */

View File

@ -1747,27 +1747,21 @@ ef10_nvram_get_version(
}
__checkReturn efx_rc_t
ef10_nvram_rw_start(
ef10_nvram_partn_rw_start(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__in uint32_t partn,
__out size_t *chunk_sizep)
{
uint32_t partn;
efx_rc_t rc;
if ((rc = ef10_nvram_type_to_partn(enp, type, &partn)) != 0)
goto fail1;
if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0)
goto fail2;
goto fail1;
if (chunk_sizep != NULL)
*chunk_sizep = EF10_NVRAM_CHUNK;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);

View File

@ -216,12 +216,6 @@ siena_nvram_get_version(
__out uint32_t *subtypep,
__out_ecount(4) uint16_t version[4]);
extern __checkReturn efx_rc_t
siena_nvram_rw_start(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__out size_t *pref_chunkp);
extern __checkReturn efx_rc_t
siena_nvram_read_chunk(
__in efx_nic_t *enp,
@ -266,6 +260,12 @@ siena_nvram_partn_size(
__in uint32_t partn,
__out size_t *sizep);
extern __checkReturn efx_rc_t
siena_nvram_partn_rw_start(
__in efx_nic_t *enp,
__in uint32_t partn,
__out size_t *chunk_sizep);
#endif /* EFSYS_OPT_NVRAM */
#if EFSYS_OPT_VPD

View File

@ -572,27 +572,21 @@ siena_nvram_get_version(
}
__checkReturn efx_rc_t
siena_nvram_rw_start(
siena_nvram_partn_rw_start(
__in efx_nic_t *enp,
__in efx_nvram_type_t type,
__in uint32_t partn,
__out size_t *chunk_sizep)
{
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_lock(enp, partn)) != 0)
goto fail2;
goto fail1;
if (chunk_sizep != NULL)
*chunk_sizep = SIENA_NVRAM_CHUNK;
return (0);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);