Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp638130ybi; Wed, 19 Jun 2019 05:30:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoXzYWJcvC8c3qxOLamM0JvAra5QHILgs9onAQxFsf1s5I7atl3cpkKTyzV77K3X2uvKT0 X-Received: by 2002:a17:902:28:: with SMTP id 37mr52462394pla.188.1560947447984; Wed, 19 Jun 2019 05:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560947447; cv=none; d=google.com; s=arc-20160816; b=LjA74Cn94sWZkkttv/30YFxgZlZttUh2cxvBpBMcQDYH4yglJvRcyPQCTXJn5nwGl+ LxdatjqwQYdaRYWOCVdyCAIOwBUHLXk9lGcSa4vq7LoLr/qUcJIhxblOIZ3WcVHkSptg KWUrvQv+2poZckVDZ7LpJq0X2ilM6C6xu3UyvjUqDnFaE69BOX8UgkcbU16aowHruqIE +41DTRO2Wxl3VDsMPgpprsN2nH7bwW8xY1dqxPEPwZDfjY4nur4s3ff92YBvpm1CNFVd zLoBj6qgZQ4SGdLgS6YSTkDUk2HZWzKqh8rwljUEODLOHxlGVbS3xarExMv4lZFk74JD Z/rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jXbt5gsycHDmk7QKsLjwVWv4mwXvODGDC+fQnu5GPIk=; b=BgJSyfKU8O3bV9TA4QmI11B4b6MMCXnVqKI4kbRASi8v+4czOqWFMzZO2F9mR9YBUs fN8b5KAAS7cy8dVPmluFdqzREiGQWRfIhSn3h7ub8OPtSptghhnceq8kbPA2eFChEqNk iozXcWTXjZoNm2PwToKMY9EqXx5MsdiJkWCZpwCthsdgjRhMxsqa+FfptFl47gi43wAE p/jnckXuh2aCzi7mfgeuDm7Vp5BURfToe/Zz1aXxD/vXmjiDsm+9YKEF6Nncqv0QtptQ /ylpKiZFBjTk6H4DCpSaziKcpTosGBi3rUD9Je+jEEazQ3bwDZI9/OCtf2X4+CIJJJuX 6zZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si2922476pgp.316.2019.06.19.05.30.32; Wed, 19 Jun 2019 05:30:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731768AbfFSM3x (ORCPT + 99 others); Wed, 19 Jun 2019 08:29:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38462 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731427AbfFSM3x (ORCPT ); Wed, 19 Jun 2019 08:29:53 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EB2C3004149; Wed, 19 Jun 2019 12:29:51 +0000 (UTC) Received: from hive.brq.redhat.com (unknown [10.43.2.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7F0E608A7; Wed, 19 Jun 2019 12:29:42 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: sathya.perla@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, davem@davemloft.net, linux-kernel@vger.kernel.org, ivecera@redhat.com Subject: [PATCH v2 net] be2net: fix link failure after ethtool offline test Date: Wed, 19 Jun 2019 14:29:42 +0200 Message-Id: <20190619122942.15497-1-poros@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 19 Jun 2019 12:29:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- .../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