Skip to content

Commit 2e5db6e

Browse files
orospdavem330
authored andcommitted
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: 4276e47 ("be2net: Add link test to list of ethtool self tests.") Signed-off-by: Petr Oros <poros@redhat.com> Reviewed-by: Ivan Vecera <ivecera@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c356dc4 commit 2e5db6e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

drivers/net/ethernet/emulex/benet/be_ethtool.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
891891
u64 *data)
892892
{
893893
struct be_adapter *adapter = netdev_priv(netdev);
894-
int status;
894+
int status, cnt;
895895
u8 link_status = 0;
896896

897897
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,
902902

903903
memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
904904

905+
/* check link status before offline tests */
906+
link_status = netif_carrier_ok(netdev);
907+
905908
if (test->flags & ETH_TEST_FL_OFFLINE) {
906909
if (be_loopback_test(adapter, BE_MAC_LOOPBACK, &data[0]) != 0)
907910
test->flags |= ETH_TEST_FL_FAILED;
@@ -922,13 +925,26 @@ static void be_self_test(struct net_device *netdev, struct ethtool_test *test,
922925
test->flags |= ETH_TEST_FL_FAILED;
923926
}
924927

925-
status = be_cmd_link_status_query(adapter, NULL, &link_status, 0);
926-
if (status) {
927-
test->flags |= ETH_TEST_FL_FAILED;
928-
data[4] = -1;
929-
} else if (!link_status) {
928+
/* link status was down prior to test */
929+
if (!link_status) {
930930
test->flags |= ETH_TEST_FL_FAILED;
931931
data[4] = 1;
932+
return;
933+
}
934+
935+
for (cnt = 10; cnt; cnt--) {
936+
status = be_cmd_link_status_query(adapter, NULL, &link_status,
937+
0);
938+
if (status) {
939+
test->flags |= ETH_TEST_FL_FAILED;
940+
data[4] = -1;
941+
break;
942+
}
943+
944+
if (link_status)
945+
break;
946+
947+
msleep_interruptible(500);
932948
}
933949
}
934950

0 commit comments

Comments
 (0)