From patchwork Thu Jan 29 19:15:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 21055 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 108AADDF7C for ; Fri, 30 Jan 2009 06:15:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752080AbZA2TPZ (ORCPT ); Thu, 29 Jan 2009 14:15:25 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751965AbZA2TPZ (ORCPT ); Thu, 29 Jan 2009 14:15:25 -0500 Received: from smarthost03.mail.zen.net.uk ([212.23.3.142]:53141 "EHLO smarthost03.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751824AbZA2TPY (ORCPT ); Thu, 29 Jan 2009 14:15:24 -0500 Received: from [82.69.137.158] (helo=opal.uk.level5networks.com) by smarthost03.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1LScME-0006ia-6V; Thu, 29 Jan 2009 19:15:22 +0000 Received: from [10.17.20.50] (achroite.uk.level5networks.com [10.17.20.50]) by opal.uk.level5networks.com (8.12.8/8.12.8) with ESMTP id n0TJFLXx025142; Thu, 29 Jan 2009 19:15:21 GMT Subject: [PATCH 01/20] sfc: SFT9001: Include non-breaking cable diagnostics in online self-tests From: Ben Hutchings To: David Miller Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com In-Reply-To: <1233256358.3656.9.camel@achroite> References: <1233256358.3656.9.camel@achroite> Organization: Solarflare Communications Date: Thu, 29 Jan 2009 19:15:21 +0000 Message-Id: <1233256521.3656.12.camel@achroite> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) X-Originating-Smarthost03-IP: [82.69.137.158] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Ben Hutchings --- 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 9ecb77d..9f5c8b8 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c @@ -708,12 +708,10 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) { struct ethtool_cmd ecmd; 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; - - efx->phy_op->get_settings(efx, &ecmd); + if (flags & ETH_TEST_FL_OFFLINE) + efx->phy_op->get_settings(efx, &ecmd); /* Initialise cable diagnostic results to unknown failure */ for (i = 1; i < 9; ++i) @@ -721,18 +719,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. * A cable fault is not a self-test failure, but a timeout is. */ + ctrl_reg = ((1 << CDIAG_CTRL_IMMED_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, - (1 << CDIAG_CTRL_IMMED_LBN) | - (1 << CDIAG_CTRL_BRK_LINK_LBN) | - (CDIAG_CTRL_LEN_METRES << CDIAG_CTRL_LEN_UNIT_LBN)); + PMA_PMD_CDIAG_CTRL_REG, ctrl_reg); i = 0; while (mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD, PMA_PMD_CDIAG_CTRL_REG) & (1 << CDIAG_CTRL_IN_PROG_LBN)) { if (++i == 50) { rc = -ETIMEDOUT; - goto reset; + goto out; } msleep(100); } @@ -757,17 +759,18 @@ static int sft9001_run_tests(struct efx_nic *efx, int *results, unsigned flags) results[5 + i] = len_reg; } - /* We must reset to exit cable diagnostic mode. The BIST will - * also run when we do this. */ -reset: - rc2 = tenxpress_special_reset(efx); - results[0] = rc2 ? -1 : 1; - if (!rc) - rc = rc2; - - rc2 = efx->phy_op->set_settings(efx, &ecmd); - if (!rc) - rc = rc2; +out: + if (flags & ETH_TEST_FL_OFFLINE) { + /* Reset, running the BIST and then resuming normal service. */ + rc2 = tenxpress_special_reset(efx); + results[0] = rc2 ? -1 : 1; + if (!rc) + rc = rc2; + + rc2 = efx->phy_op->set_settings(efx, &ecmd); + if (!rc) + rc = rc2; + } return rc; }