X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsfc%2Fbase%2Fef10_vpd.c;h=c64193691f395e523e714496f42276f650ce1e77;hb=168c59cfe42b;hp=71123a9098b15b829ffbb5bcb2d8d11664c8fd16;hpb=946ba3b6941a35fc8b324a3a9b541a0e6bd91105;p=dpdk.git diff --git a/drivers/net/sfc/base/ef10_vpd.c b/drivers/net/sfc/base/ef10_vpd.c index 71123a9098..c64193691f 100644 --- a/drivers/net/sfc/base/ef10_vpd.c +++ b/drivers/net/sfc/base/ef10_vpd.c @@ -1,31 +1,7 @@ -/* - * Copyright (c) 2009-2016 Solarflare Communications Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. +/* SPDX-License-Identifier: BSD-3-Clause * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are - * those of the authors and should not be interpreted as representing official - * policies, either expressed or implied, of the FreeBSD Project. + * Copyright (c) 2009-2018 Solarflare Communications Inc. + * All rights reserved. */ #include "efx.h" @@ -34,7 +10,7 @@ #if EFSYS_OPT_VPD -#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD +#if EFX_OPTS_EF10() #include "ef10_tlv_layout.h" @@ -49,8 +25,7 @@ ef10_vpd_init( efx_rc_t rc; EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); if (enp->en_nic_cfg.enc_vpd_is_global) { tag = TLV_TAG_GLOBAL_STATIC_VPD; @@ -104,9 +79,9 @@ ef10_vpd_size( __out size_t *sizep) { efx_rc_t rc; + efx_nvram_info_t eni = { 0 }; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); /* * This function returns the total size the user should allocate @@ -114,10 +89,12 @@ ef10_vpd_size( * so we just need to return an upper bound on the dynamic vpd, * which is the size of the DYNAMIC_CONFIG partition. */ - if ((rc = efx_mcdi_nvram_info(enp, NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, - sizep, NULL, NULL, NULL)) != 0) + if ((rc = efx_mcdi_nvram_info(enp, + NVRAM_PARTITION_TYPE_DYNAMIC_CONFIG, &eni)) != 0) goto fail1; + *sizep = eni.eni_partn_size; + return (0); fail1: @@ -138,8 +115,7 @@ ef10_vpd_read( uint32_t tag; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); if (enp->en_nic_cfg.enc_vpd_is_global) { tag = TLV_TAG_GLOBAL_DYNAMIC_VPD; @@ -157,19 +133,22 @@ ef10_vpd_read( rc = ENOSPC; goto fail2; } - memcpy(data, dvpd, dvpd_size); + if (dvpd != NULL) + memcpy(data, dvpd, dvpd_size); /* Pad data with all-1s, consistent with update operations */ memset(data + dvpd_size, 0xff, size - dvpd_size); - EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd); + if (dvpd != NULL) + EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd); return (0); fail2: EFSYS_PROBE(fail2); - EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd); + if (dvpd != NULL) + EFSYS_KMEM_FREE(enp->en_esip, dvpd_size, dvpd); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); @@ -190,8 +169,7 @@ ef10_vpd_verify( unsigned int dcont; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); /* * Strictly you could take the view that dynamic vpd is optional. @@ -311,8 +289,7 @@ ef10_vpd_get( uint8_t length; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); /* Attempt to satisfy the request from svpd first */ if (enp->en_arch.ef10.ena_svpd_length > 0) { @@ -357,8 +334,7 @@ ef10_vpd_set( { efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); /* If the provided (tag,keyword) exists in svpd, then it is readonly */ if (enp->en_arch.ef10.ena_svpd_length > 0) { @@ -410,8 +386,7 @@ ef10_vpd_write( uint32_t tag; efx_rc_t rc; - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); if (enp->en_nic_cfg.enc_vpd_is_global) { tag = TLV_TAG_GLOBAL_DYNAMIC_VPD; @@ -446,8 +421,7 @@ fail1: ef10_vpd_fini( __in efx_nic_t *enp) { - EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || - enp->en_family == EFX_FAMILY_MEDFORD); + EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp)); if (enp->en_arch.ef10.ena_svpd_length > 0) { EFSYS_KMEM_FREE(enp->en_esip, enp->en_arch.ef10.ena_svpd_length, @@ -458,6 +432,6 @@ ef10_vpd_fini( } } -#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */ +#endif /* EFX_OPTS_EF10() */ #endif /* EFSYS_OPT_VPD */