net/sfc/base: move RxDP config get to EF10 NIC code
[dpdk.git] / drivers / net / sfc / base / ef10_phy.c
index 9e1b9c2..aa8d6a2 100644 (file)
@@ -1,31 +1,7 @@
-/*
- * 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:
- *
- * 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.
+/* SPDX-License-Identifier: BSD-3-Clause
  *
- * 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"
@@ -235,6 +211,30 @@ ef10_phy_get_link(
                            MCDI_OUT_DWORD(req, GET_LINK_OUT_FCNTL),
                            &elsp->els_link_mode, &elsp->els_fcntl);
 
+#if EFSYS_OPT_LOOPBACK
+       /* Assert the MC_CMD_LOOPBACK and EFX_LOOPBACK namespace agree */
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_NONE == EFX_LOOPBACK_OFF);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_DATA == EFX_LOOPBACK_DATA);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMAC == EFX_LOOPBACK_GMAC);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGMII == EFX_LOOPBACK_XGMII);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGXS == EFX_LOOPBACK_XGXS);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI == EFX_LOOPBACK_XAUI);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII == EFX_LOOPBACK_GMII);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII == EFX_LOOPBACK_SGMII);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGBR == EFX_LOOPBACK_XGBR);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI == EFX_LOOPBACK_XFI);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_FAR == EFX_LOOPBACK_XAUI_FAR);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII_FAR == EFX_LOOPBACK_GMII_FAR);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII_FAR == EFX_LOOPBACK_SGMII_FAR);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_FAR == EFX_LOOPBACK_XFI_FAR);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GPHY == EFX_LOOPBACK_GPHY);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PHYXS == EFX_LOOPBACK_PHY_XS);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PCS == EFX_LOOPBACK_PCS);
+       EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMAPMD == EFX_LOOPBACK_PMA_PMD);
+
+       elsp->els_loopback = MCDI_OUT_DWORD(req, GET_LINK_OUT_LOOPBACK_MODE);
+#endif /* EFSYS_OPT_LOOPBACK */
+
        elsp->els_mac_up = MCDI_OUT_DWORD(req, GET_LINK_OUT_MAC_FAULT) == 0;
 
        return (0);
@@ -256,7 +256,9 @@ ef10_phy_reconfigure(
        uint8_t payload[MAX(MC_CMD_SET_LINK_IN_LEN,
                            MC_CMD_SET_LINK_OUT_LEN)];
        uint32_t cap_mask;
+#if EFSYS_OPT_PHY_LED_CONTROL
        unsigned int led_mode;
+#endif
        unsigned int speed;
        boolean_t supported;
        efx_rc_t rc;
@@ -289,11 +291,36 @@ ef10_phy_reconfigure(
        MCDI_IN_SET_DWORD_FIELD(req, SET_LINK_IN_CAP,
            PHY_CAP_40000FDX, (cap_mask >> EFX_PHY_CAP_40000FDX) & 0x1);
 
+#if EFSYS_OPT_LOOPBACK
+       MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE,
+                   epp->ep_loopback_type);
+       switch (epp->ep_loopback_link_mode) {
+       case EFX_LINK_100FDX:
+               speed = 100;
+               break;
+       case EFX_LINK_1000FDX:
+               speed = 1000;
+               break;
+       case EFX_LINK_10000FDX:
+               speed = 10000;
+               break;
+       case EFX_LINK_40000FDX:
+               speed = 40000;
+               break;
+       default:
+               speed = 0;
+       }
+#else
        MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE, MC_CMD_LOOPBACK_NONE);
        speed = 0;
+#endif /* EFSYS_OPT_LOOPBACK */
        MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_SPEED, speed);
 
+#if EFSYS_OPT_PHY_FLAGS
+       MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, epp->ep_phy_flags);
+#else
        MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, 0);
+#endif /* EFSYS_OPT_PHY_FLAGS */
 
        efx_mcdi_execute(enp, &req);
 
@@ -310,7 +337,26 @@ ef10_phy_reconfigure(
        req.emr_out_buf = payload;
        req.emr_out_length = MC_CMD_SET_ID_LED_OUT_LEN;
 
+#if EFSYS_OPT_PHY_LED_CONTROL
+       switch (epp->ep_phy_led_mode) {
+       case EFX_PHY_LED_DEFAULT:
+               led_mode = MC_CMD_LED_DEFAULT;
+               break;
+       case EFX_PHY_LED_OFF:
+               led_mode = MC_CMD_LED_OFF;
+               break;
+       case EFX_PHY_LED_ON:
+               led_mode = MC_CMD_LED_ON;
+               break;
+       default:
+               EFSYS_ASSERT(0);
+               led_mode = MC_CMD_LED_DEFAULT;
+       }
+
+       MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, led_mode);
+#else
        MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, MC_CMD_LED_DEFAULT);
+#endif /* EFSYS_OPT_PHY_LED_CONTROL */
 
        efx_mcdi_execute(enp, &req);
 
@@ -390,6 +436,23 @@ ef10_phy_oui_get(
        return (ENOTSUP);
 }
 
+#if EFSYS_OPT_PHY_STATS
+
+       __checkReturn                           efx_rc_t
+ef10_phy_stats_update(
+       __in                                    efx_nic_t *enp,
+       __in                                    efsys_mem_t *esmp,
+       __inout_ecount(EFX_PHY_NSTATS)          uint32_t *stat)
+{
+       /* TBD: no stats support in firmware yet */
+       _NOTE(ARGUNUSED(enp, esmp))
+       memset(stat, 0, EFX_PHY_NSTATS * sizeof (*stat));
+
+       return (0);
+}
+
+#endif /* EFSYS_OPT_PHY_STATS */
+
 #if EFSYS_OPT_BIST
 
        __checkReturn           efx_rc_t