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

sfc: SFT9001: Include non-breaking cable diagnostics in online self-tests

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c747583d
...@@ -679,11 +679,9 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) ...@@ -679,11 +679,9 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
{ {
struct ethtool_cmd ecmd; struct ethtool_cmd ecmd;
int phy_id = efx->mii.phy_id; int phy_id = efx->mii.phy_id;
int rc = 0, rc2, i, res_reg; int rc = 0, rc2, i, ctrl_reg, res_reg;
if (!(flags & ETH_TEST_FL_OFFLINE))
return 0;
if (flags & ETH_TEST_FL_OFFLINE)
efx->phy_op->get_settings(efx, &ecmd); efx->phy_op->get_settings(efx, &ecmd);
/* Initialise cable diagnostic results to unknown failure */ /* Initialise cable diagnostic results to unknown failure */
...@@ -692,18 +690,22 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) ...@@ -692,18 +690,22 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
/* Run cable diagnostics; wait up to 5 seconds for them to complete. /* Run cable diagnostics; wait up to 5 seconds for them to complete.
* A cable fault is not a self-test failure, but a timeout is. */ * A cable fault is not a self-test failure, but a timeout is. */
mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, ctrl_reg = ((1 << CDIAG_CTRL_IMMED_LBN) |
PMA_PMD_CDIAG_CTRL_REG,
(1 << CDIAG_CTRL_IMMED_LBN) |
(1 << CDIAG_CTRL_BRK_LINK_LBN) |
(CDIAG_CTRL_LEN_METRES << CDIAG_CTRL_LEN_UNIT_LBN)); (CDIAG_CTRL_LEN_METRES << CDIAG_CTRL_LEN_UNIT_LBN));
if (flags & ETH_TEST_FL_OFFLINE) {
/* Break the link in order to run full diagnostics. We
* must reset the PHY to resume normal service. */
ctrl_reg |= (1 << CDIAG_CTRL_BRK_LINK_LBN);
}
mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
PMA_PMD_CDIAG_CTRL_REG, ctrl_reg);
i = 0; i = 0;
while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
PMA_PMD_CDIAG_CTRL_REG) & PMA_PMD_CDIAG_CTRL_REG) &
(1 << CDIAG_CTRL_IN_PROG_LBN)) { (1 << CDIAG_CTRL_IN_PROG_LBN)) {
if (++i == 50) { if (++i == 50) {
rc = -ETIMEDOUT; rc = -ETIMEDOUT;
goto reset; goto out;
} }
msleep(100); msleep(100);
} }
...@@ -728,9 +730,9 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) ...@@ -728,9 +730,9 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags)
results[5 + i] = len_reg; results[5 + i] = len_reg;
} }
/* We must reset to exit cable diagnostic mode. The BIST will out:
* also run when we do this. */ if (flags & ETH_TEST_FL_OFFLINE) {
reset: /* Reset, running the BIST and then resuming normal service. */
rc2 = tenxpress_special_reset(efx); rc2 = tenxpress_special_reset(efx);
results[0] = rc2 ? -1 : 1; results[0] = rc2 ? -1 : 1;
if (!rc) if (!rc)
...@@ -739,6 +741,7 @@ reset: ...@@ -739,6 +741,7 @@ reset:
rc2 = efx->phy_op->set_settings(efx, &ecmd); rc2 = efx->phy_op->set_settings(efx, &ecmd);
if (!rc) if (!rc)
rc = rc2; rc = rc2;
}
return rc; return rc;
} }
......
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