net/sfc/base: regenerate headers to pick up CTPIO stats
[dpdk.git] / drivers / net / sfc / base / ef10_nvram.c
index 68f14d5..2883ec8 100644 (file)
@@ -1,37 +1,13 @@
-/*
- * Copyright (c) 2012-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) 2012-2018 Solarflare Communications Inc.
+ * All rights reserved.
  */
 
 #include "efx.h"
 #include "efx_impl.h"
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 
 #if EFSYS_OPT_VPD || EFSYS_OPT_NVRAM
 
@@ -672,6 +648,7 @@ ef10_nvram_buffer_validate(
        int pos;
        efx_rc_t rc;
 
+       _NOTE(ARGUNUSED(enp, partn))
        EFX_STATIC_ASSERT(sizeof (*header) <= EF10_NVRAM_CHUNK);
 
        if ((partn_data == NULL) || (partn_size == 0)) {
@@ -1282,6 +1259,8 @@ ef10_nvram_buf_read_tlv(
        caddr_t value;
        efx_rc_t rc;
 
+       _NOTE(ARGUNUSED(enp))
+
        if ((seg_data == NULL) || (max_seg_size == 0)) {
                rc = EINVAL;
                goto fail1;
@@ -1370,12 +1349,16 @@ ef10_nvram_partn_read_tlv(
         */
        retry = 10;
        do {
-               rc = ef10_nvram_read_tlv_segment(enp, partn, 0,
-                   seg_data, partn_size);
-       } while ((rc == EAGAIN) && (--retry > 0));
+               if ((rc = ef10_nvram_read_tlv_segment(enp, partn, 0,
+                   seg_data, partn_size)) != 0)
+                       --retry;
+       } while ((rc == EAGAIN) && (retry > 0));
 
        if (rc != 0) {
                /* Failed to obtain consistent segment data */
+               if (rc == EAGAIN)
+                       rc = EIO;
+
                goto fail4;
        }
 
@@ -2170,6 +2153,21 @@ static ef10_parttbl_entry_t medford_parttbl[] = {
        PARTN_MAP_ENTRY(FPGA_BACKUP,            ALL,    FPGA_BACKUP),
        PARTN_MAP_ENTRY(LICENSE,                ALL,    LICENSE),
        PARTN_MAP_ENTRY(EXPANSION_UEFI,         ALL,    UEFIROM),
+       PARTN_MAP_ENTRY(MUM_FIRMWARE,           ALL,    MUM_FIRMWARE),
+};
+
+static ef10_parttbl_entry_t medford2_parttbl[] = {
+       /*              partn                   ports   nvtype */
+       PARTN_MAP_ENTRY(MC_FIRMWARE,            ALL,    MC_FIRMWARE),
+       PARTN_MAP_ENTRY(MC_FIRMWARE_BACKUP,     ALL,    MC_GOLDEN),
+       PARTN_MAP_ENTRY(EXPANSION_ROM,          ALL,    BOOTROM),
+       PARTN_MAP_ENTRY(EXPROM_CONFIG,          ALL,    BOOTROM_CFG),
+       PARTN_MAP_ENTRY(DYNAMIC_CONFIG,         ALL,    DYNAMIC_CFG),
+       PARTN_MAP_ENTRY(FPGA,                   ALL,    FPGA),
+       PARTN_MAP_ENTRY(FPGA_BACKUP,            ALL,    FPGA_BACKUP),
+       PARTN_MAP_ENTRY(LICENSE,                ALL,    LICENSE),
+       PARTN_MAP_ENTRY(EXPANSION_UEFI,         ALL,    UEFIROM),
+       PARTN_MAP_ENTRY(MUM_FIRMWARE,           ALL,    MUM_FIRMWARE),
 };
 
 static __checkReturn           efx_rc_t
@@ -2189,6 +2187,11 @@ ef10_parttbl_get(
                *parttbl_rowsp = EFX_ARRAY_SIZE(medford_parttbl);
                break;
 
+       case EFX_FAMILY_MEDFORD2:
+               *parttblp = medford2_parttbl;
+               *parttbl_rowsp = EFX_ARRAY_SIZE(medford2_parttbl);
+               break;
+
        default:
                EFSYS_ASSERT(B_FALSE);
                return (EINVAL);
@@ -2207,6 +2210,7 @@ ef10_nvram_type_to_partn(
        size_t parttbl_rows = 0;
        unsigned int i;
 
+       EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
        EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
        EFSYS_ASSERT(partnp != NULL);
 
@@ -2381,4 +2385,4 @@ fail1:
 
 #endif /* EFSYS_OPT_NVRAM */
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */