From: Andy Moreton Date: Thu, 16 Nov 2017 08:03:57 +0000 (+0000) Subject: net/sfc/base: check NVRAM locking by partition ID X-Git-Tag: spdx-start~676 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=f4332a5f486905cfd9547e90ea27fe410fa8dc33;p=dpdk.git net/sfc/base: check NVRAM locking by partition ID Tracking which partition is locked avoids being overly conservative when EFX_NVRAM_xxx maps to more than one partition (depnding on the current port number). Signed-off-by: Andy Moreton Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h index 6cb015a59f..7b07f3465d 100644 --- a/drivers/net/sfc/base/efx_impl.h +++ b/drivers/net/sfc/base/efx_impl.h @@ -461,6 +461,10 @@ typedef struct efx_mcdi_s { #endif /* EFSYS_OPT_MCDI */ #if EFSYS_OPT_NVRAM + +/* Invalid partition ID for en_nvram_partn_locked field of efx_nc_t */ +#define EFX_NVRAM_PARTN_INVALID (0xffffffffu) + typedef struct efx_nvram_ops_s { #if EFSYS_OPT_DIAG efx_rc_t (*envo_test)(efx_nic_t *); @@ -648,7 +652,7 @@ struct efx_nic_s { efx_mcdi_t en_mcdi; #endif /* EFSYS_OPT_MCDI */ #if EFSYS_OPT_NVRAM - efx_nvram_type_t en_nvram_locked; + uint32_t en_nvram_partn_locked; const efx_nvram_ops_t *en_envop; #endif /* EFSYS_OPT_NVRAM */ #if EFSYS_OPT_VPD diff --git a/drivers/net/sfc/base/efx_nvram.c b/drivers/net/sfc/base/efx_nvram.c index 6e22169acc..a2b0e053f4 100644 --- a/drivers/net/sfc/base/efx_nvram.c +++ b/drivers/net/sfc/base/efx_nvram.c @@ -112,6 +112,8 @@ efx_nvram_init( enp->en_envop = envop; enp->en_mod_flags |= EFX_MOD_NVRAM; + enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID; + return (0); fail1: @@ -227,15 +229,15 @@ efx_nvram_rw_start( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID); - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID); + if ((rc = envop->envo_partn_rw_start(enp, partn, chunk_sizep)) != 0) goto fail2; - enp->en_nvram_locked = type; + enp->en_nvram_partn_locked = partn; return (0); @@ -265,11 +267,11 @@ efx_nvram_read_chunk( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type); - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn); + if ((rc = envop->envo_partn_read(enp, partn, offset, data, size)) != 0) goto fail2; @@ -300,11 +302,11 @@ efx_nvram_erase( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type); - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn); + if ((rc = envop->envo_partn_size(enp, partn, &size)) != 0) goto fail2; @@ -341,11 +343,11 @@ efx_nvram_write_chunk( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type); - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn); + if ((rc = envop->envo_partn_write(enp, partn, offset, data, size)) != 0) goto fail2; @@ -376,15 +378,15 @@ efx_nvram_rw_finish( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type); - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn); + if ((rc = envop->envo_partn_rw_finish(enp, partn, &verify_result)) != 0) goto fail2; - enp->en_nvram_locked = EFX_NVRAM_INVALID; + enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID; if (verify_resultp != NULL) *verify_resultp = verify_result; @@ -393,7 +395,7 @@ efx_nvram_rw_finish( fail2: EFSYS_PROBE(fail2); - enp->en_nvram_locked = EFX_NVRAM_INVALID; + enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID; fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); @@ -421,15 +423,15 @@ efx_nvram_set_version( EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); + if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) + goto fail1; + /* * The Siena implementation of envo_set_version() will attempt to - * acquire the NVRAM_UPDATE lock for the DYNAMIC_CONFIG sector. + * acquire the NVRAM_UPDATE lock for the DYNAMIC_CONFIG partition. * Therefore, you can't have already acquired the NVRAM_UPDATE lock. */ - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID); - - if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) - goto fail1; + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID); if ((rc = envop->envo_partn_set_version(enp, partn, version)) != 0) goto fail2; @@ -490,7 +492,7 @@ efx_nvram_fini( EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM); - EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID); + EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID); enp->en_envop = NULL; enp->en_mod_flags &= ~EFX_MOD_NVRAM;