net/sfc/base: move BIU test code into Siena-specific file
authorMark Spender <mspender@solarflare.com>
Thu, 16 Nov 2017 08:04:41 +0000 (08:04 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Signed-off-by: Mark Spender <mspender@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/base/efx_impl.h
drivers/net/sfc/base/efx_nic.c
drivers/net/sfc/base/siena_nic.c

index fa976eb..eaa53df 100644 (file)
@@ -1073,10 +1073,6 @@ struct efx_txq_s {
        _NOTE(CONSTANTCONDITION)                                        \
        } while (B_FALSE)
 
-extern __checkReturn   efx_rc_t
-efx_nic_biu_test(
-       __in            efx_nic_t *enp);
-
 extern __checkReturn   efx_rc_t
 efx_mac_select(
        __in            efx_nic_t *enp);
index 65eed6e..4a31bca 100644 (file)
@@ -102,78 +102,6 @@ efx_family(
        return (ENOTSUP);
 }
 
-
-#define        EFX_BIU_MAGIC0  0x01234567
-#define        EFX_BIU_MAGIC1  0xfedcba98
-
-       __checkReturn   efx_rc_t
-efx_nic_biu_test(
-       __in            efx_nic_t *enp)
-{
-       efx_oword_t oword;
-       efx_rc_t rc;
-
-       /*
-        * Write magic values to scratch registers 0 and 1, then
-        * verify that the values were written correctly.  Interleave
-        * the accesses to ensure that the BIU is not just reading
-        * back the cached value that was last written.
-        */
-       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, EFX_BIU_MAGIC0);
-       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
-
-       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, EFX_BIU_MAGIC1);
-       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
-
-       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
-       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != EFX_BIU_MAGIC0) {
-               rc = EIO;
-               goto fail1;
-       }
-
-       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
-       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != EFX_BIU_MAGIC1) {
-               rc = EIO;
-               goto fail2;
-       }
-
-       /*
-        * Perform the same test, with the values swapped.  This
-        * ensures that subsequent tests don't start with the correct
-        * values already written into the scratch registers.
-        */
-       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, EFX_BIU_MAGIC1);
-       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
-
-       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, EFX_BIU_MAGIC0);
-       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
-
-       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
-       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != EFX_BIU_MAGIC1) {
-               rc = EIO;
-               goto fail3;
-       }
-
-       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
-       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != EFX_BIU_MAGIC0) {
-               rc = EIO;
-               goto fail4;
-       }
-
-       return (0);
-
-fail4:
-       EFSYS_PROBE(fail4);
-fail3:
-       EFSYS_PROBE(fail3);
-fail2:
-       EFSYS_PROBE(fail2);
-fail1:
-       EFSYS_PROBE1(fail1, efx_rc_t, rc);
-
-       return (rc);
-}
-
 #if EFSYS_OPT_SIENA
 
 static const efx_nic_ops_t     __efx_nic_siena_ops = {
index f9cda34..a9793a1 100644 (file)
@@ -213,6 +213,77 @@ fail1:
        return (rc);
 }
 
+#define        SIENA_BIU_MAGIC0        0x01234567
+#define        SIENA_BIU_MAGIC1        0xfedcba98
+
+static __checkReturn   efx_rc_t
+siena_nic_biu_test(
+       __in            efx_nic_t *enp)
+{
+       efx_oword_t oword;
+       efx_rc_t rc;
+
+       /*
+        * Write magic values to scratch registers 0 and 1, then
+        * verify that the values were written correctly.  Interleave
+        * the accesses to ensure that the BIU is not just reading
+        * back the cached value that was last written.
+        */
+       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, SIENA_BIU_MAGIC0);
+       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
+
+       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, SIENA_BIU_MAGIC1);
+       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
+
+       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
+       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != SIENA_BIU_MAGIC0) {
+               rc = EIO;
+               goto fail1;
+       }
+
+       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
+       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != SIENA_BIU_MAGIC1) {
+               rc = EIO;
+               goto fail2;
+       }
+
+       /*
+        * Perform the same test, with the values swapped.  This
+        * ensures that subsequent tests don't start with the correct
+        * values already written into the scratch registers.
+        */
+       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, SIENA_BIU_MAGIC1);
+       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
+
+       EFX_POPULATE_OWORD_1(oword, FRF_AZ_DRIVER_DW0, SIENA_BIU_MAGIC0);
+       EFX_BAR_TBL_WRITEO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
+
+       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 0, &oword, B_TRUE);
+       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != SIENA_BIU_MAGIC1) {
+               rc = EIO;
+               goto fail3;
+       }
+
+       EFX_BAR_TBL_READO(enp, FR_AZ_DRIVER_REG, 1, &oword, B_TRUE);
+       if (EFX_OWORD_FIELD(oword, FRF_AZ_DRIVER_DW0) != SIENA_BIU_MAGIC0) {
+               rc = EIO;
+               goto fail4;
+       }
+
+       return (0);
+
+fail4:
+       EFSYS_PROBE(fail4);
+fail3:
+       EFSYS_PROBE(fail3);
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+       return (rc);
+}
+
        __checkReturn   efx_rc_t
 siena_nic_probe(
        __in            efx_nic_t *enp)
@@ -227,7 +298,7 @@ siena_nic_probe(
        EFSYS_ASSERT3U(enp->en_family, ==, EFX_FAMILY_SIENA);
 
        /* Test BIU */
-       if ((rc = efx_nic_biu_test(enp)) != 0)
+       if ((rc = siena_nic_biu_test(enp)) != 0)
                goto fail1;
 
        /* Clear the region register */