49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Copyright (c) 2009-2015 Solarflare Communications Inc.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * All rights reserved.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Redistribution and use in source and binary forms, with or without
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * modification, are permitted provided that the following conditions are met:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 1. Redistributions of source code must retain the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright notice,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * this list of conditions and the following disclaimer in the documentation
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * and/or other materials provided with the distribution.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * The views and conclusions contained in the software and documentation are
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * those of the authors and should not be interpreted as representing official
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * policies, either expressed or implied, of the FreeBSD Project.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_10HDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_10FDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_100HDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_100FDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_1000HDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_1000FDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_10000FDX_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_PAUSE_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_ASYM_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (mcdi_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (1 << MC_CMD_GET_LINK_OUT_FULL_DUPLEX_LBN));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *link_modep = fd ? EFX_LINK_1000FDX : EFX_LINK_1000HDX;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *link_modep = fd ? EFX_LINK_100FDX : EFX_LINK_100HDX;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *link_modep = fd ? EFX_LINK_10FDX : EFX_LINK_10HDX;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore *fcntlp = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * Convert the LINKCHANGE speed enumeration into mbit/s, in the
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * same way as GET_LINK encodes the speed
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore switch (MCDI_EV_FIELD(eqp, LINKCHANGE_SPEED)) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore link_flags = MCDI_EV_FIELD(eqp, LINKCHANGE_LINK_FLAGS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_link_mode(enp, link_flags, speed,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_cap(MCDI_EV_FIELD(eqp, LINKCHANGE_LP_CAP),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * It's safe to update ep_lp_cap_mask without the driver's port lock
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * because presumably any concurrently running efx_port_poll() is
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * only going to arrive at the same value.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * ep_fcntl has two meanings. It's either the link common fcntl
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * (if the PHY supports AN), or it's the forced link state. If
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * the former, it's safe to update the value for the same reason as
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * for ep_lp_cap_mask. If the latter, then just ignore the value,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore * because we can race with efx_mac_fcntl_set().
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (epp->ep_phy_cap_mask & (1 << EFX_PHY_CAP_AN))
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Check if the PHY is a zombie */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_GET_LINK_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_GET_LINK_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_cap(MCDI_OUT_DWORD(req, GET_LINK_OUT_CAP),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_cap(MCDI_OUT_DWORD(req, GET_LINK_OUT_LP_CAP),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_link_mode(enp, MCDI_OUT_DWORD(req, GET_LINK_OUT_FLAGS),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, GET_LINK_OUT_LINK_SPEED),
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Assert the MC_CMD_LOOPBACK and EFX_LOOPBACK namespace agree */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_NONE == EFX_LOOPBACK_OFF);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_DATA == EFX_LOOPBACK_DATA);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMAC == EFX_LOOPBACK_GMAC);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGMII == EFX_LOOPBACK_XGMII);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGXS == EFX_LOOPBACK_XGXS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI == EFX_LOOPBACK_XAUI);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII == EFX_LOOPBACK_GMII);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII == EFX_LOOPBACK_SGMII);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XGBR == EFX_LOOPBACK_XGBR);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI == EFX_LOOPBACK_XFI);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XAUI_FAR == EFX_LOOPBACK_XAUI_FAR);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GMII_FAR == EFX_LOOPBACK_GMII_FAR);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_SGMII_FAR == EFX_LOOPBACK_SGMII_FAR);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_XFI_FAR == EFX_LOOPBACK_XFI_FAR);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_GPHY == EFX_LOOPBACK_GPHY);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PHYXS == EFX_LOOPBACK_PHY_XS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PCS == EFX_LOOPBACK_PCS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFX_STATIC_ASSERT(MC_CMD_LOOPBACK_PMAPMD == EFX_LOOPBACK_PMA_PMD);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore slsp->sls_loopback = MCDI_OUT_DWORD(req, GET_LINK_OUT_LOOPBACK_MODE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_LOOPBACK */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore slsp->sls_mac_up = MCDI_OUT_DWORD(req, GET_LINK_OUT_MAC_FAULT) == 0;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MAX(MC_CMD_SET_ID_LED_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_SET_LINK_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_POPULATE_DWORD_10(req, SET_LINK_IN_CAP,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_10HDX, (cap_mask >> EFX_PHY_CAP_10HDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_10FDX, (cap_mask >> EFX_PHY_CAP_10FDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_100HDX, (cap_mask >> EFX_PHY_CAP_100HDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_100FDX, (cap_mask >> EFX_PHY_CAP_100FDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_1000HDX, (cap_mask >> EFX_PHY_CAP_1000HDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_1000FDX, (cap_mask >> EFX_PHY_CAP_1000FDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_10000FDX, (cap_mask >> EFX_PHY_CAP_10000FDX) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_PAUSE, (cap_mask >> EFX_PHY_CAP_PAUSE) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_ASYM, (cap_mask >> EFX_PHY_CAP_ASYM) & 0x1,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore PHY_CAP_AN, (cap_mask >> EFX_PHY_CAP_AN) & 0x1);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_MODE, MC_CMD_LOOPBACK_NONE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_LOOPBACK */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_LINK_IN_LOOPBACK_SPEED, speed);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, epp->ep_phy_flags);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_LINK_IN_FLAGS, 0);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_PHY_FLAGS */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* And set the blink mode */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_SET_ID_LED_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_SET_ID_LED_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, led_mode);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, SET_ID_LED_IN_STATE, MC_CMD_LED_DEFAULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_PHY_LED_CONTROL */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_GET_PHY_STATE_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_GET_PHY_STATE_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_GET_PHY_STATE_OUT_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_GET_PHY_STATE_OUT_LEN) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore state = MCDI_OUT_DWORD(req, GET_PHY_STATE_OUT_STATE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#define SIENA_SIMPLE_STAT_SET(_vmask, _esmp, _smask, _stat, \
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((_stat) != NULL && !EFSYS_MEM_IS_NULL(_esmp)) { \
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_MEM_READD(_esmp, (_mc_record) * 4, &dword);\
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#define SIENA_SIMPLE_STAT_SET2(_vmask, _esmp, _smask, _stat, _record) \
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(_vmask, _esmp, _smask, _stat, \
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __inout_ecount_opt(EFX_PHY_NSTATS) uint32_t *stat)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, OUI);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PMA_PMD_LINK_UP);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PMA_PMD_RX_FAULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PMA_PMD_TX_FAULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore smask |= ((1ULL << EFX_PHY_STAT_PMA_PMD_SIGNAL_A) |
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (stat != NULL && esmp != NULL && !EFSYS_MEM_IS_NULL(esmp)) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_MEM_READD(esmp, 4 * MC_CMD_PMA_PMD_SIGNAL,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PMA_PMD_SIGNAL_A] = (sig >> 1) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PMA_PMD_SIGNAL_B] = (sig >> 2) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PMA_PMD_SIGNAL_C] = (sig >> 3) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PMA_PMD_SIGNAL_D] = (sig >> 4) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PMA_PMD_SNR_A,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PMA_PMD_SNR_B,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PMA_PMD_SNR_C,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PMA_PMD_SNR_D,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PCS_LINK_UP);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PCS_RX_FAULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PCS_TX_FAULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PCS_BER);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, PCS_BLOCK_ERRORS);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PHYXS_LINK_UP,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PHYXS_RX_FAULT,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PHYXS_TX_FAULT,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_PHYXS_ALIGN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore smask |= ((1 << EFX_PHY_STAT_PHY_XS_SYNC_A) |
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (stat != NULL && !EFSYS_MEM_IS_NULL(esmp)) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_MEM_READD(esmp, 4 * MC_CMD_PHYXS_SYNC, &dword);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PHY_XS_SYNC_A] = (sync >> 0) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PHY_XS_SYNC_B] = (sync >> 1) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PHY_XS_SYNC_C] = (sync >> 2) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore stat[EFX_PHY_STAT_PHY_XS_SYNC_D] = (sync >> 3) & 1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, AN_LINK_UP);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET2(vmask, esmp, smask, stat, AN_COMPLETE);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore SIENA_SIMPLE_STAT_SET(vmask, esmp, smask, stat, MC_CMD_CL22_LINK_UP,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __inout_ecount(EFX_PHY_NSTATS) uint32_t *stat)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint32_t vmask = encp->enc_mcdi_phy_stat_mask;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_PHY_STATS_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_PHY_STATS_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length = MC_CMD_PHY_STATS_OUT_DMA_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, PHY_STATS_IN_DMA_ADDR_LO,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_IN_SET_DWORD(req, PHY_STATS_IN_DMA_ADDR_HI,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT3U(req.emr_out_length, ==, MC_CMD_PHY_STATS_OUT_DMA_LEN);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore siena_phy_decode_stats(enp, vmask, esmp, &smask, stat);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore EFSYS_ASSERT(smask == encp->enc_phy_stat_mask);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_PHY_STATS */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if ((rc = efx_mcdi_bist_start(enp, type)) != 0)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestatic __checkReturn unsigned long
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore case MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return (EFX_PHY_CABLE_STATUS_INTERPAIRSHORT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore case MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT:
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore return (EFX_PHY_CABLE_STATUS_INTRAPAIRSHORT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore __out_ecount_opt(count) __drv_when(count > 0, __notnull)
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned long *valuesp,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore uint8_t payload[MAX(MC_CMD_POLL_BIST_IN_LEN,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(payload, 0, sizeof (payload));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_in_length = MC_CMD_POLL_BIST_IN_LEN;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore if (req.emr_out_length_used < MC_CMD_POLL_BIST_OUT_RESULT_OFST + 4) {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (void) memset(valuesp, '\0', count * sizeof (unsigned long));
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore result = MCDI_OUT_DWORD(req, POLL_BIST_OUT_RESULT);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Extract PHY specific results */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length_used >= MC_CMD_POLL_BIST_OUT_SFT9001_LEN &&
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_LENGTH_A);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_LENGTH_B);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_LENGTH_C);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_LENGTH_D);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_STATUS_A);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_STATUS_B);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_STATUS_C);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore value_mask |= (1 << EFX_BIST_PHY_CABLE_STATUS_D);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore } else if (result == MC_CMD_POLL_BIST_FAILED &&
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore req.emr_out_length >= MC_CMD_POLL_BIST_OUT_MRSFP_LEN &&
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MCDI_OUT_DWORD(req, POLL_BIST_OUT_MRSFP_TEST);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* There is no way to stop BIST on Siena */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_BIST */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#endif /* EFSYS_OPT_SIENA */