netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: [PATCH 09/20] sfc: Reinitialise the PHY completely in case of a PHY or NIC reset
Date: Thu, 29 Jan 2009 19:19:34 +0000	[thread overview]
Message-ID: <1233256774.3656.29.camel@achroite> (raw)
In-Reply-To: <1233256358.3656.9.camel@achroite>

From: Steve Hodgson <shodgson@solarflare.com>

In particular, set pause advertising bits properly.

A PHY reset is not necessary to recover from the register self-test,
so use a "invisible" reset there instead.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/efx.c       |   26 +++++++++++++++++++-------
 drivers/net/sfc/efx.h       |    7 ++++---
 drivers/net/sfc/selftest.c  |    7 ++++---
 drivers/net/sfc/tenxpress.c |    1 +
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 7673fd9..b0e5308 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -676,9 +676,8 @@ static int efx_init_port(struct efx_nic *efx)
 	rc = efx->phy_op->init(efx);
 	if (rc)
 		return rc;
-	efx->phy_op->reconfigure(efx);
-
 	mutex_lock(&efx->mac_lock);
+	efx->phy_op->reconfigure(efx);
 	rc = falcon_switch_mac(efx);
 	mutex_unlock(&efx->mac_lock);
 	if (rc)
@@ -1622,7 +1621,8 @@ static void efx_unregister_netdev(struct efx_nic *efx)
 
 /* Tears down the entire software state and most of the hardware state
  * before reset.  */
-void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)
+void efx_reset_down(struct efx_nic *efx, enum reset_type method,
+		    struct ethtool_cmd *ecmd)
 {
 	EFX_ASSERT_RESET_SERIALISED(efx);
 
@@ -1639,6 +1639,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)
 	efx->phy_op->get_settings(efx, ecmd);
 
 	efx_fini_channels(efx);
+	if (efx->port_initialized && method != RESET_TYPE_INVISIBLE)
+		efx->phy_op->fini(efx);
 }
 
 /* This function will always ensure that the locks acquired in
@@ -1646,7 +1648,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)
  * that we were unable to reinitialise the hardware, and the
  * driver should be disabled. If ok is false, then the rx and tx
  * engines are not restarted, pending a RESET_DISABLE. */
-int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok)
+int efx_reset_up(struct efx_nic *efx, enum reset_type method,
+		 struct ethtool_cmd *ecmd, bool ok)
 {
 	int rc;
 
@@ -1658,6 +1661,15 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok)
 		ok = false;
 	}
 
+	if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) {
+		if (ok) {
+			rc = efx->phy_op->init(efx);
+			if (rc)
+				ok = false;
+		} else
+			efx->port_initialized = false;
+	}
+
 	if (ok) {
 		efx_init_channels(efx);
 
@@ -1702,7 +1714,7 @@ static int efx_reset(struct efx_nic *efx)
 
 	EFX_INFO(efx, "resetting (%d)\n", method);
 
-	efx_reset_down(efx, &ecmd);
+	efx_reset_down(efx, method, &ecmd);
 
 	rc = falcon_reset_hw(efx, method);
 	if (rc) {
@@ -1721,10 +1733,10 @@ static int efx_reset(struct efx_nic *efx)
 
 	/* Leave device stopped if necessary */
 	if (method == RESET_TYPE_DISABLE) {
-		efx_reset_up(efx, &ecmd, false);
+		efx_reset_up(efx, method, &ecmd, false);
 		rc = -EIO;
 	} else {
-		rc = efx_reset_up(efx, &ecmd, true);
+		rc = efx_reset_up(efx, method, &ecmd, true);
 	}
 
 out_disable:
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index 0dd7a53..ac20158 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -40,9 +40,10 @@ extern void efx_reconfigure_port(struct efx_nic *efx);
 extern void __efx_reconfigure_port(struct efx_nic *efx);
 
 /* Reset handling */
-extern void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd);
-extern int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd,
-			bool ok);
+extern void efx_reset_down(struct efx_nic *efx, enum reset_type method,
+			   struct ethtool_cmd *ecmd);
+extern int efx_reset_up(struct efx_nic *efx, enum reset_type method,
+			struct ethtool_cmd *ecmd, bool ok);
 
 /* Global */
 extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index dba0d64..0a59808 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -665,6 +665,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
 {
 	enum efx_loopback_mode loopback_mode = efx->loopback_mode;
 	int phy_mode = efx->phy_mode;
+	enum reset_type reset_method = RESET_TYPE_INVISIBLE;
 	struct ethtool_cmd ecmd;
 	struct efx_channel *channel;
 	int rc_test = 0, rc_reset = 0, rc;
@@ -718,21 +719,21 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
 	mutex_unlock(&efx->mac_lock);
 
 	/* free up all consumers of SRAM (including all the queues) */
-	efx_reset_down(efx, &ecmd);
+	efx_reset_down(efx, reset_method, &ecmd);
 
 	rc = efx_test_chip(efx, tests);
 	if (rc && !rc_test)
 		rc_test = rc;
 
 	/* reset the chip to recover from the register test */
-	rc_reset = falcon_reset_hw(efx, RESET_TYPE_ALL);
+	rc_reset = falcon_reset_hw(efx, reset_method);
 
 	/* Ensure that the phy is powered and out of loopback
 	 * for the bist and loopback tests */
 	efx->phy_mode &= ~PHY_MODE_LOW_POWER;
 	efx->loopback_mode = LOOPBACK_NONE;
 
-	rc = efx_reset_up(efx, &ecmd, rc_reset == 0);
+	rc = efx_reset_up(efx, reset_method, &ecmd, rc_reset == 0);
 	if (rc && !rc_reset)
 		rc_reset = rc;
 
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index ec3e38b..1ab14d5 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -357,6 +357,7 @@ static int tenxpress_phy_init(struct efx_nic *efx)
 	rc = tenxpress_init(efx);
 	if (rc < 0)
 		goto fail;
+	mdio_clause45_set_pause(efx);
 
 	if (efx->phy_type == PHY_TYPE_SFT9001B) {
 		rc = device_create_file(&efx->pci_dev->dev,

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


  parent reply	other threads:[~2009-01-29 19:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-29 19:12 [PATCH 00/20] sfc: Fixes and new PHY support for 2.6.29 Ben Hutchings
2009-01-29 19:15 ` [PATCH 01/20] sfc: SFT9001: Include non-breaking cable diagnostics in online self-tests Ben Hutchings
2009-01-29 19:16 ` [PATCH 02/20] sfc: Fix test for MDIO read failure Ben Hutchings
2009-01-29 19:17 ` [PATCH 03/20] sfc: SFT9001: Enable robust link training Ben Hutchings
2009-01-29 19:23   ` Ben Hutchings
2009-01-29 19:17 ` [PATCH 04/20] sfc: SFX7101: Remove workaround for bad " Ben Hutchings
2009-01-29 19:23   ` Ben Hutchings
2009-01-29 19:17 ` [PATCH 05/20] sfc: SFT9001/SFN4111T: Check PHY boot status during board initialisation Ben Hutchings
2009-01-29 19:17 ` [PATCH 06/20] sfc: SFT9001: Fix speed reporting in 1G PHY loopback Ben Hutchings
2009-01-29 19:18 ` [PATCH 07/20] sfc: SFN4111T: Fix GPIO sharing between I2C and FLASH_CFG_1 Ben Hutchings
2009-01-29 19:19 ` [PATCH 08/20] sfc: Fix post-reset MAC selection Ben Hutchings
2009-01-29 19:19 ` Ben Hutchings [this message]
2009-01-29 19:19 ` [PATCH 10/20] sfc: Test for PHYXS faults whenever we cannot test link state bits Ben Hutchings
2009-01-29 19:19 ` [PATCH 11/20] sfc: Update board info for hardware monitor on SFN4111T-R5 and later Ben Hutchings
2009-01-29 19:20 ` [PATCH 12/20] sfc: SFT9001: Always enable XNP exchange on SFT9001 rev B Ben Hutchings
2009-01-29 19:20 ` [PATCH 13/20] sfc: SFX7101/SFT9001: Fix AN advertisements Ben Hutchings
2009-01-29 19:20 ` [PATCH 14/20] sfc: Remove "XFP" from log messages that are not specific to XFP Ben Hutchings
2009-01-29 19:20 ` [PATCH 15/20] sfc: Fix reporting of PHY id Ben Hutchings
2009-01-29 19:21 ` [PATCH 16/20] sfc: Add support for QT2025C PHY Ben Hutchings
2009-01-29 19:21 ` [PATCH 17/20] sfc: Delete unused efx_blinker::led_num field Ben Hutchings
2009-01-29 19:21 ` [PATCH 18/20] sfc: Clean up LED control Ben Hutchings
2009-01-29 19:21 ` [PATCH 19/20] sfc: Add support for SFN4112F SFP+ reference design Ben Hutchings
2009-01-29 19:22 ` [PATCH 20/20] sfc: Replace stats_enabled flag with a disable count Ben Hutchings
2009-01-29 23:26 ` [PATCH 00/20] sfc: Fixes and new PHY support for 2.6.29 David Miller
2009-01-30  1:05   ` Ben Hutchings
2009-01-30  1:08     ` David Miller
2009-01-30  3:48       ` [PATCH 01/11] sfc: SFT9001: Enable robust link training Ben Hutchings
2009-01-30 22:09         ` David Miller
2009-01-31  0:04           ` Ben Hutchings
2009-01-31  0:02             ` David Miller
2009-01-30  3:48       ` [PATCH 02/11] sfc: SFX7101: Remove workaround for bad " Ben Hutchings
2009-01-30  3:49       ` [PATCH 03/11] sfc: SFT9001: Fix speed reporting in 1G PHY loopback Ben Hutchings
2009-01-30  3:49       ` [PATCH 04/11] sfc: SFN4111T: Fix GPIO sharing between I2C and FLASH_CFG_1 Ben Hutchings
2009-01-30  3:49       ` [PATCH 05/11] sfc: Fix post-reset MAC selection Ben Hutchings
2009-01-30  3:50       ` [PATCH 06/11] sfc: Reinitialise the PHY completely in case of a PHY or NIC reset Ben Hutchings
2009-01-30  3:51       ` [PATCH 07/11] sfc: Test for PHYXS faults whenever we cannot test link state bits Ben Hutchings
2009-01-30  3:51       ` [PATCH 08/11] sfc: Update board info for hardware monitor on SFN4111T-R5 and later Ben Hutchings
2009-01-30  3:52       ` [PATCH 09/11] sfc: SFT9001: Always enable XNP exchange on SFT9001 rev B Ben Hutchings
2009-01-30  3:59       ` [PATCH 10/11] sfc: SFX7101/SFT9001: Fix AN advertisements Ben Hutchings
2009-01-30  4:00       ` [PATCH 11/11] sfc: Replace stats_enabled flag with a disable count Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1233256774.3656.29.camel@achroite \
    --to=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=linux-net-drivers@solarflare.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).