net/sfc/base: add API to retrieve sensor limits
[dpdk.git] / drivers / net / sfc / base / efx_nvram.c
index affe496..f3107bb 100644 (file)
@@ -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:
+/* SPDX-License-Identifier: BSD-3-Clause
  *
- * 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.
- *
- * 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"
@@ -54,7 +30,7 @@ static const efx_nvram_ops_t  __efx_nvram_siena_ops = {
 
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 static const efx_nvram_ops_t   __efx_nvram_ef10_ops = {
 #if EFSYS_OPT_DIAG
@@ -73,7 +49,7 @@ static const efx_nvram_ops_t  __efx_nvram_ef10_ops = {
        ef10_nvram_buffer_validate,     /* envo_buffer_validate */
 };
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
        __checkReturn   efx_rc_t
 efx_nvram_init(
@@ -105,6 +81,12 @@ efx_nvram_init(
                break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+       case EFX_FAMILY_MEDFORD2:
+               envop = &__efx_nvram_ef10_ops;
+               break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
        default:
                EFSYS_ASSERT(0);
                rc = ENOTSUP;
@@ -162,8 +144,6 @@ efx_nvram_size(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        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;
 
@@ -196,8 +176,6 @@ efx_nvram_get_version(
        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;
 
@@ -228,9 +206,6 @@ efx_nvram_rw_start(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -266,9 +241,6 @@ efx_nvram_read_chunk(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -307,9 +279,6 @@ efx_nvram_read_backup(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -343,9 +312,6 @@ efx_nvram_erase(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -384,9 +350,6 @@ efx_nvram_write_chunk(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -419,9 +382,6 @@ efx_nvram_rw_finish(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
 
-       EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
-       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
-
        if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
                goto fail1;
 
@@ -465,8 +425,6 @@ efx_nvram_set_version(
        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;
 
@@ -506,9 +464,6 @@ efx_nvram_validate(
        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;
 
@@ -635,7 +590,7 @@ efx_mcdi_nvram_metadata(
 
        MCDI_IN_SET_DWORD(req, NVRAM_METADATA_IN_TYPE, partn);
 
-       efx_mcdi_execute(enp, &req);
+       efx_mcdi_execute_quiet(enp, &req);
 
        if (req.emr_rc != 0) {
                rc = req.emr_rc;
@@ -910,7 +865,7 @@ efx_mcdi_nvram_write(
        __in                    efx_nic_t *enp,
        __in                    uint32_t partn,
        __in                    uint32_t offset,
-       __out_bcount(size)      caddr_t data,
+       __in_bcount(size)       caddr_t data,
        __in                    size_t size)
 {
        efx_mcdi_req_t req;