Commit a355020a authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

sfc: Include XGXS in XMAC link status check except in XGMII loopback

The XGXS block may not get a link immediately in XGXS or XAUI loopback
modes, so we still need to check it.  Split falcon_xaui_link_ok() into
falcon_xgxs_link_ok(), which checks only the Falcon XGXS block, and
falcon_xmac_link_ok(), which checks one or both sides of the link as
appropriate.  Also rename falcon_check_xaui_link() to
falcon_xmac_link_ok_retry().
Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff3b00a0
...@@ -111,16 +111,12 @@ static void falcon_mask_status_intr(struct efx_nic *efx, bool enable) ...@@ -111,16 +111,12 @@ static void falcon_mask_status_intr(struct efx_nic *efx, bool enable)
efx_writeo(efx, &reg, FR_AB_XM_MGT_INT_MASK); efx_writeo(efx, &reg, FR_AB_XM_MGT_INT_MASK);
} }
/* Get status of XAUI link */ static bool falcon_xgxs_link_ok(struct efx_nic *efx)
static bool falcon_xaui_link_ok(struct efx_nic *efx)
{ {
efx_oword_t reg; efx_oword_t reg;
bool align_done, link_ok = false; bool align_done, link_ok = false;
int sync_status; int sync_status;
if (LOOPBACK_INTERNAL(efx))
return true;
/* Read link status */ /* Read link status */
efx_reado(efx, &reg, FR_AB_XX_CORE_STAT); efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
...@@ -135,14 +131,24 @@ static bool falcon_xaui_link_ok(struct efx_nic *efx) ...@@ -135,14 +131,24 @@ static bool falcon_xaui_link_ok(struct efx_nic *efx)
EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES); EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES);
efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT); efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
/* If the link is up, then check the phy side of the xaui link */
if (efx->link_state.up && link_ok)
if (efx->mdio.mmds & (1 << MDIO_MMD_PHYXS))
link_ok = efx_mdio_phyxgxs_lane_sync(efx);
return link_ok; return link_ok;
} }
static bool falcon_xmac_link_ok(struct efx_nic *efx)
{
/*
* Check MAC's XGXS link status except when using XGMII loopback
* which bypasses the XGXS block.
* If possible, check PHY's XGXS link status except when using
* MAC loopback.
*/
return (efx->loopback_mode == LOOPBACK_XGMII ||
falcon_xgxs_link_ok(efx)) &&
(!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) ||
LOOPBACK_INTERNAL(efx) ||
efx_mdio_phyxgxs_lane_sync(efx));
}
void falcon_reconfigure_xmac_core(struct efx_nic *efx) void falcon_reconfigure_xmac_core(struct efx_nic *efx)
{ {
unsigned int max_frame_len; unsigned int max_frame_len;
...@@ -245,9 +251,9 @@ static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) ...@@ -245,9 +251,9 @@ static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
/* Try to bring up the Falcon side of the Falcon-Phy XAUI link */ /* Try to bring up the Falcon side of the Falcon-Phy XAUI link */
static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries) static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
{ {
bool mac_up = falcon_xaui_link_ok(efx); bool mac_up = falcon_xmac_link_ok(efx);
if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS || if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS ||
efx_phy_mode_disabled(efx->phy_mode)) efx_phy_mode_disabled(efx->phy_mode))
...@@ -261,7 +267,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries) ...@@ -261,7 +267,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
falcon_reset_xaui(efx); falcon_reset_xaui(efx);
udelay(200); udelay(200);
mac_up = falcon_xaui_link_ok(efx); mac_up = falcon_xmac_link_ok(efx);
--tries; --tries;
} }
...@@ -272,7 +278,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries) ...@@ -272,7 +278,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
static bool falcon_xmac_check_fault(struct efx_nic *efx) static bool falcon_xmac_check_fault(struct efx_nic *efx)
{ {
return !falcon_check_xaui_link_up(efx, 5); return !falcon_xmac_link_ok_retry(efx, 5);
} }
static int falcon_reconfigure_xmac(struct efx_nic *efx) static int falcon_reconfigure_xmac(struct efx_nic *efx)
...@@ -284,7 +290,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx) ...@@ -284,7 +290,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx)
falcon_reconfigure_mac_wrapper(efx); falcon_reconfigure_mac_wrapper(efx);
efx->xmac_poll_required = !falcon_check_xaui_link_up(efx, 5); efx->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5);
falcon_mask_status_intr(efx, true); falcon_mask_status_intr(efx, true);
return 0; return 0;
...@@ -357,7 +363,7 @@ void falcon_poll_xmac(struct efx_nic *efx) ...@@ -357,7 +363,7 @@ void falcon_poll_xmac(struct efx_nic *efx)
return; return;
falcon_mask_status_intr(efx, false); falcon_mask_status_intr(efx, false);
efx->xmac_poll_required = !falcon_check_xaui_link_up(efx, 1); efx->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
falcon_mask_status_intr(efx, true); falcon_mask_status_intr(efx, true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment