Skip to contentSkip to conversation

be2net: fix link failure after ethtool offline test

PATCH Applied Petr Oros 3 participants 3 messages Jun 19, 2019 – Jun 22, 2019

Subsystems (3)
lore
Share & tools
lore

Petr Oros

author
#0 lore raw

PATCH v2 1/1 be2net: fix link failure after ethtool offline test

Certain cards in conjunction with certain switches need a little more time for link setup that results in ethtool link test failure after offline test. Patch adds a loop that waits for a link setup finish.

Changes in v2:
- added fixes header

Fixes 4276e47e2d1c ("be2net: Add link test to list of ethtool self tests.")
---
 .../net/ethernet/emulex/benet/be_ethtool.c    | 28 +++++++++++++++----
 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/net/ethernet/emulex/benet/be_ethtool.c +22 -6
index 8a6785173228f3..492f8769ac12c2 100644
@@ -891,7 +891,7 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
 			 u64 *data)
 {
 	struct be_adapter *adapter = netdev_priv(netdev);
-	int status;
+	int status, cnt;
 	u8 link_status = 0;
 
 	if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) {
@@ -902,6 +902,9 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
 
 	memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
 
+	/* check link status before offline tests */
+	link_status = netif_carrier_ok(netdev);
+
 	if (test->flags & ETH_TEST_FL_OFFLINE) {
 		if (be_loopback_test(adapter, BE_MAC_LOOPBACK, &data[0]) != 0)
 			test->flags |= ETH_TEST_FL_FAILED;
@@ -922,13 +925,26 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
 		test->flags |= ETH_TEST_FL_FAILED;
 	}
 
-	status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
-	if (status) {
-		test->flags |= ETH_TEST_FL_FAILED;
-		data[4] = -1;
-	} else if (!link_status) {
+	/* link status was down prior to test */
+	if (!link_status) {
 		test->flags |= ETH_TEST_FL_FAILED;
 		data[4] = 1;
+		return;
+	}
+
+	for (cnt = 10; cnt; cnt--) {
+		status = be_cmd_link_status_query(adapter, NULL, &link_status,
+						  0);
+		if (status) {
+			test->flags |= ETH_TEST_FL_FAILED;
+			data[4] = -1;
+			break;
+		}
+
+		if (link_status)
+			break;
+
+		msleep_interruptible(500);
 	}
 }
 
Signature · 1 line
2.21.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 68 lines · On Wed, 19 Jun 2019 14:29:42 +0200 Petr Oros <[email protected]> wrote:

Certain cards in conjunction with certain switches need a little more time for link setup that results in ethtool link test failure after offline test. Patch adds a loop that waits for a link setup finish.

Changes in v2:
- added fixes header

Fixes 4276e47e2d1c ("be2net: Add link test to list of ethtool self

tests.") Signed-off-by: Petr Oros <[email protected]>

---
 .../net/ethernet/emulex/benet/be_ethtool.c    | 28

+++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)

(quoted diff) +0 -0

b/drivers/net/ethernet/emulex/benet/be_ethtool.c index 8a6785173228f3..492f8769ac12c2 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -891,7 +891,7 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data) {

drivers/net/ethernet/emulex/benet/be_ethtool.c +22 -6
 	struct be_adapter *adapter = netdev_priv(netdev);
-	int status;
+	int status, cnt;
 	u8 link_status = 0;
 
 	if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) {
@@ -902,6 +902,9 @@ static void be_self_test(struct net_device
 *netdev, struct ethtool_test *test, 
 	memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
 
+	/* check link status before offline tests */
+	link_status = netif_carrier_ok(netdev);
+
 	if (test->flags & ETH_TEST_FL_OFFLINE) {
 		if (be_loopback_test(adapter, BE_MAC_LOOPBACK,
 &data[0]) != 0) test->flags |= ETH_TEST_FL_FAILED;
@@ -922,13 +925,26 @@ static void be_self_test(struct net_device
 *netdev, struct ethtool_test *test, test->flags |= ETH_TEST_FL_FAILED;
 	}
 
-	status = be_cmd_link_status_query(adapter, NULL,
 &link_status, 0);
-	if (status) {
-		test->flags |= ETH_TEST_FL_FAILED;
-		data[4] = -1;
-	} else if (!link_status) {
+	/* link status was down prior to test */
+	if (!link_status) {
 		test->flags |= ETH_TEST_FL_FAILED;
 		data[4] = 1;
+		return;
+	}
+
+	for (cnt = 10; cnt; cnt--) {
+		status = be_cmd_link_status_query(adapter, NULL,
 &link_status,
+						  0);
+		if (status) {
+			test->flags |= ETH_TEST_FL_FAILED;
+			data[4] = -1;
+			break;
+		}
+
+		if (link_status)
+			break;
+
+		msleep_interruptible(500);
 	}
Quoted 2 lines

}

LGTM

maintainer Applied
#2 lore raw
In reply to Petr Oros

From: Petr Oros <[email protected]>
Date: Wed, 19 Jun 2019 14:29:42 +0200

Quoted 9 lines

Certain cards in conjunction with certain switches need a little more time for link setup that results in ethtool link test failure after offline test. Patch adds a loop that waits for a link setup finish.

Changes in v2:
- added fixes header

Fixes 4276e47e2d1c ("be2net: Add link test to list of ethtool self tests.")

Applied, thanks.