common/sfc_efx/base: add API to get mport selector by ID
[dpdk.git] / drivers / common / sfc_efx / base / ef10_mcdi.c
index 9e8a0c1..f852d1c 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019-2021 Xilinx, Inc.
  * Copyright(c) 2012-2019 Solarflare Communications Inc.
  */
 
@@ -8,7 +8,7 @@
 #include "efx_impl.h"
 
 
-#if EFX_OPTS_EF10()
+#if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
 
 #if EFSYS_OPT_MCDI
 
@@ -27,7 +27,7 @@ ef10_mcdi_init(
        efx_dword_t dword;
        efx_rc_t rc;
 
-       EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp));
+       EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
        EFSYS_ASSERT(enp->en_features & EFX_FEATURE_MCDI_DMA);
 
        /*
@@ -53,7 +53,16 @@ ef10_mcdi_init(
                goto fail2;
        }
        EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 1);
-       EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE);
+       switch (enp->en_family) {
+#if EFSYS_OPT_RIVERHEAD
+       case EFX_FAMILY_RIVERHEAD:
+               EFX_BAR_FCW_WRITED(enp, ER_GZ_MC_DB_HWRD_REG, &dword);
+               break;
+#endif /* EFSYS_OPT_RIVERHEAD */
+       default:
+               EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE);
+               break;
+       }
 
        /* Save initial MC reboot status */
        (void) ef10_mcdi_poll_reboot(enp);
@@ -133,7 +142,7 @@ ef10_mcdi_send_request(
        efx_dword_t dword;
        unsigned int pos;
 
-       EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp));
+       EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
 
        /* Write the header */
        for (pos = 0; pos < hdr_len; pos += sizeof (efx_dword_t)) {
@@ -154,11 +163,29 @@ ef10_mcdi_send_request(
        /* Ring the doorbell to post the command DMA address to the MC */
        EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0,
            EFSYS_MEM_ADDR(esmp) >> 32);
-       EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE);
+       switch (enp->en_family) {
+#if EFSYS_OPT_RIVERHEAD
+       case EFX_FAMILY_RIVERHEAD:
+               EFX_BAR_FCW_WRITED(enp, ER_GZ_MC_DB_LWRD_REG, &dword);
+               break;
+#endif /* EFSYS_OPT_RIVERHEAD */
+       default:
+               EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE);
+               break;
+       }
 
        EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0,
            EFSYS_MEM_ADDR(esmp) & 0xffffffff);
-       EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE);
+       switch (enp->en_family) {
+#if EFSYS_OPT_RIVERHEAD
+       case EFX_FAMILY_RIVERHEAD:
+               EFX_BAR_FCW_WRITED(enp, ER_GZ_MC_DB_HWRD_REG, &dword);
+               break;
+#endif /* EFSYS_OPT_RIVERHEAD */
+       default:
+               EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE);
+               break;
+       }
 }
 
        __checkReturn   boolean_t
@@ -211,7 +238,17 @@ ef10_mcdi_poll_reboot(
        old_status = emip->emi_mc_reboot_status;
 
        /* Update MC reboot status word */
-       EFX_BAR_TBL_READD(enp, ER_DZ_BIU_MC_SFT_STATUS_REG, 0, &dword, B_FALSE);
+       switch (enp->en_family) {
+#if EFSYS_OPT_RIVERHEAD
+       case EFX_FAMILY_RIVERHEAD:
+               EFX_BAR_FCW_READD(enp, ER_GZ_MC_SFT_STATUS, &dword);
+               break;
+#endif /* EFSYS_OPT_RIVERHEAD */
+       default:
+               EFX_BAR_READD(enp, ER_DZ_BIU_MC_SFT_STATUS_REG,
+                             &dword, B_FALSE);
+               break;
+       }
        new_status = dword.ed_u32[0];
 
        /* MC has rebooted if the value has changed */
@@ -255,7 +292,7 @@ ef10_mcdi_feature_supported(
        uint32_t privilege_mask = encp->enc_privilege_mask;
        efx_rc_t rc;
 
-       EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp));
+       EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
 
        /*
         * Use privilege mask state at MCDI attach.
@@ -316,4 +353,4 @@ fail1:
 
 #endif /* EFSYS_OPT_MCDI */
 
-#endif /* EFX_OPTS_EF10() */
+#endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */