Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1687784ybi; Wed, 17 Jul 2019 20:09:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLSAXMCeaJPhqIB73Q+5gNpF7oTfLyLmz/0m7XZsbZJcN2SV7B1/304CNPrxZNAUREImEH X-Received: by 2002:a63:f50d:: with SMTP id w13mr44953062pgh.411.1563419340628; Wed, 17 Jul 2019 20:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419340; cv=none; d=google.com; s=arc-20160816; b=ZVdf9GgQZlWxDKH2QdFrW2gvu0+ymPyAiSukAN711KvZ6c6JrYISA8BeBMQef8cYww okYrnLBfCqIx6X2QAiD4Dazy3qTK4zWbmYKoucJ1KHodPvU0Q9eqqukBBOPA1AUzhmrK DT0iwU7YjSvPc/OI6sB4c3gzDWViCanr0UZziefYRl8sIKqek3E1UPBRO9YpVtqQEX+K 4gOf44elY4ueruS3MRgKcMVyMwqEgSwYm/c3KHT14ELux+1hNVXWvHZ23qPLTKR6KWhU tIjSPajBsYSJpDMc04Lr1e+aMN7HZE1gaGT0DVXPdP1NXkz8hx8sfEuqdJ5VeTNo70y7 6uTA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mparWoQnkHIkrfKDj2LKHsrDXUlxyH25MqK/bb3JZ3g=; b=UWwGqwAZt+a8MMm0phNjsoFWeYqfIWbLPA7yRksG5bQKydRpvZ10Y4MgNKg8YBEM/C e8RT76+ppe9xBaRRZ+zMjtwVpDklquVXPs6h+swAX6uys2LMmcn1t2S/0cS+5o8aJ8ki K9wDKlI1zehP4CzGN1efk4pcrpCS8SlLgu8sQ75EiBNh7Th2dllyU10Kd3wL1fc9qsLF H9P5WQROfdzIDmd2uqBZObMBoYb583++xA3bzWfb+TvyJyN3YvqFptpMlfFVYTMXfbxn jjBrTUE7t6ugvbkrP6nu6nNbmcWG/ScGXgxZu3FHKOfo7jE+DEl/DVFAHrUT8WgJ51jP N37w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RA0YNxGC; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl13si516826plb.97.2019.07.17.20.08.44; Wed, 17 Jul 2019 20:09:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=RA0YNxGC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390487AbfGRDHe (ORCPT + 99 others); Wed, 17 Jul 2019 23:07:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390460AbfGRDHb (ORCPT ); Wed, 17 Jul 2019 23:07:31 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 41BDC2173E; Thu, 18 Jul 2019 03:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419250; bh=bE2enI5xvjxZALLm1U9tjjHIdAb7DAaS0QTXeC3g0oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RA0YNxGCMyeBO/dyRTvJinfdhTM/LjCIaY28qha16ACYxVQbUQcivse06p9f65JS/ +U2/GG/1dObhoGsrD5YKxgDLifpZXbzOX2GN/4qZvdUXdfpn0K5Y3aaYxdpIK6DgmS F9GCWZsR4XgtdsKFjfwm5qXLTlLchXVw63GAc32s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Oros , Ivan Vecera , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 15/47] be2net: fix link failure after ethtool offline test Date: Thu, 18 Jul 2019 12:01:29 +0900 Message-Id: <20190718030049.933115197@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 2e5db6eb3c23e5dc8171eb8f6af7a97ef9fcf3a9 ] 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 Reviewed-by: Ivan Vecera Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../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 bfb16a474490..d1905d50c26c 100644 --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -895,7 +895,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) { @@ -906,6 +906,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; @@ -926,13 +929,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.20.1