netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Detsch <adetsch@br.ibm.com>
To: netdev@vger.kernel.org, e1000-devel@lists.sourceforge.net
Subject: [PATCH] Fix link test for e1000 and e1000e when iface is down
Date: Tue, 10 Feb 2009 14:35:58 -0200	[thread overview]
Message-ID: <200902101435.58331.adetsch@br.ibm.com> (raw)


When running ethtool -t on an interface that was just
brought down, the link test was failing. That's because
we need to perform a reset on the interface to be able
to check the link status correctly. There is no problem
on doing such reset right before the test, as the link
test routine is prepared to wait for autoneg to complete
if that is the case.

Signed-off-by: Andre Detsch <adetsch@br.ibm.com>
---

The bug can be produced with the following commands
(assuming eth0 is an e1000 or e1000e iface):
 ifconfig eth0 up;
 ifconfig eth0 down;
 ethtool -t eth0;

 drivers/net/e1000/e1000_ethtool.c |   10 ++++++----
 drivers/net/e1000e/ethtool.c      |   10 +++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index c854c96..bed7c88 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1646,16 +1646,18 @@ static void e1000_diag_test(struct net_device *netdev,
 
 		DPRINTK(HW, INFO, "offline testing starting\n");
 
-		/* Link test performed before hardware reset so autoneg doesn't
-		 * interfere with test result */
+		if (!if_running)
+			e1000_reset(adapter);
+
+		/* Due to the reset above, autoneg may be undergoing.
+		 * But link test is prepared to handle such situation.
+		 */
 		if (e1000_link_test(adapter, &data[4]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
 
 		if (if_running)
 			/* indicate we're in test mode */
 			dev_close(netdev);
-		else
-			e1000_reset(adapter);
 
 		if (e1000_reg_test(adapter, &data[0]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index e48956d..d14a5be 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -1647,9 +1647,11 @@ static void e1000_diag_test(struct net_device *netdev,
 
 		e_info("offline testing starting\n");
 
-		/*
-		 * Link test performed before hardware reset so autoneg doesn't
-		 * interfere with test result
+		if (!if_running)
+			e1000e_reset(adapter);
+
+		/* Due to the reset above, autoneg may be undergoing.
+		 * But link test is prepared to handle such situation.
 		 */
 		if (e1000_link_test(adapter, &data[4]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1657,8 +1659,6 @@ static void e1000_diag_test(struct net_device *netdev,
 		if (if_running)
 			/* indicate we're in test mode */
 			dev_close(netdev);
-		else
-			e1000e_reset(adapter);
 
 		if (e1000_reg_test(adapter, &data[0]))
 			eth_test->flags |= ETH_TEST_FL_FAILED;
-- 
1.5.4.3


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com

             reply	other threads:[~2009-02-10 16:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 16:35 Andre Detsch [this message]
2009-02-13  0:29 ` [PATCH] Fix link test for e1000 and e1000e when iface is down David Miller
2009-02-13  1:10 ` Jeff Kirsher
2009-02-13  1:17   ` David Miller
2009-02-13 12:08   ` [E1000-devel] " André Detsch
2009-02-13 12:52     ` Jeff Kirsher

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=200902101435.58331.adetsch@br.ibm.com \
    --to=adetsch@br.ibm.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --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).