Date: Sat, 4 Jun 2016 14:26:40 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301321 - stable/10/sys/dev/sfxge/common Message-ID: <201606041426.u54EQej6088287@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Sat Jun 4 14:26:40 2016 New Revision: 301321 URL: https://svnweb.freebsd.org/changeset/base/301321 Log: MFC r299318 sfxge(4): restructure TLV buffer validation Move TLV buffer validation into ef10-specific function and add accessor function which also converts the partition ID to the internal representation. Submitted by: Richard Houldsworth <rhouldsworth at solarflare.com> Sponsored by: Solarflare Communications, Inc. Modified: stable/10/sys/dev/sfxge/common/efx.h stable/10/sys/dev/sfxge/common/efx_impl.h stable/10/sys/dev/sfxge/common/efx_nvram.c stable/10/sys/dev/sfxge/common/hunt_impl.h stable/10/sys/dev/sfxge/common/hunt_nvram.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/sfxge/common/efx.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx.h Sat Jun 4 14:23:11 2016 (r301320) +++ stable/10/sys/dev/sfxge/common/efx.h Sat Jun 4 14:26:40 2016 (r301321) @@ -1370,11 +1370,10 @@ efx_nvram_set_version( __in efx_nvram_type_t type, __in_ecount(4) uint16_t version[4]); -/* Validate contents of TLV formatted partition */ extern __checkReturn efx_rc_t -efx_nvram_tlv_validate( +efx_nvram_validate( __in efx_nic_t *enp, - __in uint32_t partn, + __in efx_nvram_type_t type, __in_bcount(partn_size) caddr_t partn_data, __in size_t partn_size); Modified: stable/10/sys/dev/sfxge/common/efx_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_impl.h Sat Jun 4 14:23:11 2016 (r301320) +++ stable/10/sys/dev/sfxge/common/efx_impl.h Sat Jun 4 14:26:40 2016 (r301321) @@ -499,9 +499,19 @@ typedef struct efx_nvram_ops_s { uint32_t *, uint16_t *); efx_rc_t (*envo_partn_set_version)(efx_nic_t *, uint32_t, uint16_t *); + efx_rc_t (*envo_buffer_validate)(efx_nic_t *, uint32_t, + caddr_t, size_t); } efx_nvram_ops_t; #endif /* EFSYS_OPT_NVRAM */ +extern __checkReturn efx_rc_t +efx_nvram_tlv_validate( + __in efx_nic_t *enp, + __in uint32_t partn, + __in_bcount(partn_size) caddr_t partn_data, + __in size_t partn_size); + + #if EFSYS_OPT_VPD typedef struct efx_vpd_ops_s { efx_rc_t (*evpdo_init)(efx_nic_t *); Modified: stable/10/sys/dev/sfxge/common/efx_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/efx_nvram.c Sat Jun 4 14:23:11 2016 (r301320) +++ stable/10/sys/dev/sfxge/common/efx_nvram.c Sat Jun 4 14:26:40 2016 (r301321) @@ -51,6 +51,7 @@ static efx_nvram_ops_t __efx_nvram_falco falcon_nvram_partn_rw_finish, /* envo_partn_rw_finish */ falcon_nvram_partn_get_version, /* envo_partn_get_version */ falcon_nvram_partn_set_version, /* envo_partn_set_version */ + NULL, /* envo_partn_validate */ }; #endif /* EFSYS_OPT_FALCON */ @@ -70,6 +71,7 @@ static efx_nvram_ops_t __efx_nvram_siena siena_nvram_partn_rw_finish, /* envo_partn_rw_finish */ siena_nvram_partn_get_version, /* envo_partn_get_version */ siena_nvram_partn_set_version, /* envo_partn_set_version */ + NULL, /* envo_partn_validate */ }; #endif /* EFSYS_OPT_SIENA */ @@ -89,6 +91,7 @@ static efx_nvram_ops_t __efx_nvram_ef10_ ef10_nvram_partn_rw_finish, /* envo_partn_rw_finish */ ef10_nvram_partn_get_version, /* envo_partn_get_version */ ef10_nvram_partn_set_version, /* envo_partn_set_version */ + ef10_nvram_buffer_validate, /* envo_buffer_validate */ }; #endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ @@ -446,6 +449,44 @@ fail1: return (rc); } +/* Validate buffer contents (before writing to flash) */ + __checkReturn efx_rc_t +efx_nvram_validate( + __in efx_nic_t *enp, + __in efx_nvram_type_t type, + __in_bcount(partn_size) caddr_t partn_data, + __in size_t partn_size) +{ + efx_nvram_ops_t *envop = enp->en_envop; + uint32_t partn; + efx_rc_t rc; + + EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); + EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM); + + EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES); + + + if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0) + goto fail1; + + if (envop->envo_type_to_partn != NULL && + ((rc = envop->envo_buffer_validate(enp, partn, + partn_data, partn_size)) != 0)) + goto fail2; + + return (0); + +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + + void efx_nvram_fini( __in efx_nic_t *enp) Modified: stable/10/sys/dev/sfxge/common/hunt_impl.h ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_impl.h Sat Jun 4 14:23:11 2016 (r301320) +++ stable/10/sys/dev/sfxge/common/hunt_impl.h Sat Jun 4 14:26:40 2016 (r301321) @@ -458,6 +458,14 @@ ef10_nvram_partn_set_version( __in uint32_t partn, __in_ecount(4) uint16_t version[4]); +extern __checkReturn efx_rc_t +ef10_nvram_buffer_validate( + __in efx_nic_t *enp, + __in uint32_t partn, + __in_bcount(buffer_size) + caddr_t bufferp, + __in size_t buffer_size); + #endif /* EFSYS_OPT_NVRAM */ Modified: stable/10/sys/dev/sfxge/common/hunt_nvram.c ============================================================================== --- stable/10/sys/dev/sfxge/common/hunt_nvram.c Sat Jun 4 14:23:11 2016 (r301320) +++ stable/10/sys/dev/sfxge/common/hunt_nvram.c Sat Jun 4 14:26:40 2016 (r301321) @@ -472,7 +472,7 @@ fail1: /* Validate TLV formatted partition contents (before writing to flash) */ __checkReturn efx_rc_t -efx_nvram_tlv_validate( +ef10_nvram_buffer_validate( __in efx_nic_t *enp, __in uint32_t partn, __in_bcount(partn_size) caddr_t partn_data,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606041426.u54EQej6088287>