diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-02-27 08:04:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-02 06:15:02 -0500 |
commit | 22ef02c23a236cb825b13f3335ff05ef5072a03d (patch) | |
tree | e7f77a91ebbd0aa811c56b12ba6e408a27d03346 | |
parent | c747583d19d5d5147a9f0eae480c1fdbc84c4252 (diff) |
sfc: SFT9001: Include non-breaking cable diagnostics in online self-tests
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/sfc/tenxpress.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c index 5b0f45166628..23583ba2e7eb 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c | |||
@@ -679,12 +679,10 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) | |||
679 | { | 679 | { |
680 | struct ethtool_cmd ecmd; | 680 | struct ethtool_cmd ecmd; |
681 | int phy_id = efx->mii.phy_id; | 681 | int phy_id = efx->mii.phy_id; |
682 | int rc = 0, rc2, i, res_reg; | 682 | int rc = 0, rc2, i, ctrl_reg, res_reg; |
683 | 683 | ||
684 | if (!(flags & ETH_TEST_FL_OFFLINE)) | 684 | if (flags & ETH_TEST_FL_OFFLINE) |
685 | return 0; | 685 | efx->phy_op->get_settings(efx, &ecmd); |
686 | |||
687 | efx->phy_op->get_settings(efx, &ecmd); | ||
688 | 686 | ||
689 | /* Initialise cable diagnostic results to unknown failure */ | 687 | /* Initialise cable diagnostic results to unknown failure */ |
690 | for (i = 1; i < 9; ++i) | 688 | for (i = 1; i < 9; ++i) |
@@ -692,18 +690,22 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) | |||
692 | 690 | ||
693 | /* Run cable diagnostics; wait up to 5 seconds for them to complete. | 691 | /* Run cable diagnostics; wait up to 5 seconds for them to complete. |
694 | * A cable fault is not a self-test failure, but a timeout is. */ | 692 | * A cable fault is not a self-test failure, but a timeout is. */ |
693 | ctrl_reg = ((1 << CDIAG_CTRL_IMMED_LBN) | | ||
694 | (CDIAG_CTRL_LEN_METRES << CDIAG_CTRL_LEN_UNIT_LBN)); | ||
695 | if (flags & ETH_TEST_FL_OFFLINE) { | ||
696 | /* Break the link in order to run full diagnostics. We | ||
697 | * must reset the PHY to resume normal service. */ | ||
698 | ctrl_reg |= (1 << CDIAG_CTRL_BRK_LINK_LBN); | ||
699 | } | ||
695 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, | 700 | mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD, |
696 | PMA_PMD_CDIAG_CTRL_REG, | 701 | PMA_PMD_CDIAG_CTRL_REG, ctrl_reg); |
697 | (1 << CDIAG_CTRL_IMMED_LBN) | | ||
698 | (1 << CDIAG_CTRL_BRK_LINK_LBN) | | ||
699 | (CDIAG_CTRL_LEN_METRES << CDIAG_CTRL_LEN_UNIT_LBN)); | ||
700 | i = 0; | 702 | i = 0; |
701 | while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, | 703 | while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, |
702 | PMA_PMD_CDIAG_CTRL_REG) & | 704 | PMA_PMD_CDIAG_CTRL_REG) & |
703 | (1 << CDIAG_CTRL_IN_PROG_LBN)) { | 705 | (1 << CDIAG_CTRL_IN_PROG_LBN)) { |
704 | if (++i == 50) { | 706 | if (++i == 50) { |
705 | rc = -ETIMEDOUT; | 707 | rc = -ETIMEDOUT; |
706 | goto reset; | 708 | goto out; |
707 | } | 709 | } |
708 | msleep(100); | 710 | msleep(100); |
709 | } | 711 | } |
@@ -728,17 +730,18 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) | |||
728 | results[5 + i] = len_reg; | 730 | results[5 + i] = len_reg; |
729 | } | 731 | } |
730 | 732 | ||
731 | /* We must reset to exit cable diagnostic mode. The BIST will | 733 | out: |
732 | * also run when we do this. */ | 734 | if (flags & ETH_TEST_FL_OFFLINE) { |
733 | reset: | 735 | /* Reset, running the BIST and then resuming normal service. */ |
734 | rc2 = tenxpress_special_reset(efx); | 736 | rc2 = tenxpress_special_reset(efx); |
735 | results[0] = rc2 ? -1 : 1; | 737 | results[0] = rc2 ? -1 : 1; |
736 | if (!rc) | 738 | if (!rc) |
737 | rc = rc2; | 739 | rc = rc2; |
738 | 740 | ||
739 | rc2 = efx->phy_op->set_settings(efx, &ecmd); | 741 | rc2 = efx->phy_op->set_settings(efx, &ecmd); |
740 | if (!rc) | 742 | if (!rc) |
741 | rc = rc2; | 743 | rc = rc2; |
744 | } | ||
742 | 745 | ||
743 | return rc; | 746 | return rc; |
744 | } | 747 | } |