* [PATCH net] be2net: fix link failure after ethtool offline test
@ 2019-06-19 11:52 Petr Oros
2019-06-19 12:03 ` Ivan Vecera
0 siblings, 1 reply; 2+ messages in thread
From: Petr Oros @ 2019-06-19 11:52 UTC (permalink / raw)
To: netdev
Cc: sathya.perla, ajit.khaparde, sriharsha.basavapatna,
somnath.kotur, davem, linux-kernel, ivecera
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.
Signed-off-by: Petr Oros <poros@redhat.com>
---
.../net/ethernet/emulex/benet/be_ethtool.c | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c 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)
{
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);
}
}
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] be2net: fix link failure after ethtool offline test
2019-06-19 11:52 [PATCH net] be2net: fix link failure after ethtool offline test Petr Oros
@ 2019-06-19 12:03 ` Ivan Vecera
0 siblings, 0 replies; 2+ messages in thread
From: Ivan Vecera @ 2019-06-19 12:03 UTC (permalink / raw)
To: Petr Oros
Cc: netdev, sathya.perla, ajit.khaparde, sriharsha.basavapatna,
somnath.kotur, davem, linux-kernel
On Wed, 19 Jun 2019 13:52:31 +0200
Petr Oros <poros@redhat.com> 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.
>
> Signed-off-by: Petr Oros <poros@redhat.com>
Missing Fixes header for net stuff... Otherwise LGTM.
Ivan
> ---
> .../net/ethernet/emulex/benet/be_ethtool.c | 28
> +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c
> 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) {
> 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);
> }
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-19 12:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 11:52 [PATCH net] be2net: fix link failure after ethtool offline test Petr Oros
2019-06-19 12:03 ` Ivan Vecera
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).