netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vishal Kulkarni <vishal@chelsio.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: nirranjan@chelsio.com, Vishal Kulkarni <vishal@chelsio.com>
Subject: [PATCH net-next 2/4] cxgb4: Add link test to ethtool self test
Date: Fri, 17 Jul 2020 19:17:57 +0530	[thread overview]
Message-ID: <20200717134759.8268-3-vishal@chelsio.com> (raw)
In-Reply-To: <20200717134759.8268-1-vishal@chelsio.com>

This test checks whether link is up or not

Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>
---
 .../ethernet/chelsio/cxgb4/cxgb4_ethtool.c    | 35 ++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 1ec6157f8ba7..f374757e15c8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -27,11 +27,13 @@ static void set_msglevel(struct net_device *dev, u32 val)
 
 enum cxgb4_ethtool_tests {
 	CXGB4_ETHTOOL_ADAPTER_TEST,
+	CXGB4_ETHTOOL_LINK_TEST,
 	CXGB4_ETHTOOL_MAX_TEST,
 };
 
 static const char cxgb4_selftest_strings[CXGB4_ETHTOOL_MAX_TEST][ETH_GSTRING_LEN] = {
 	"Adapter health status",
+	"Link test",
 };
 
 static const char * const flash_region_strings[] = {
@@ -2085,14 +2087,45 @@ static void cxgb4_adapter_status_test(struct net_device *netdev, u64 *data)
 	*data = 0;
 }
 
+static void cxgb4_link_test(struct net_device *netdev, u64 *data)
+{
+	struct port_info *pi = netdev_priv(netdev);
+	unsigned int link = 0;
+	int ret;
+
+	ret = t4_get_link_params(pi, &link, NULL, NULL);
+	if (ret) {
+		*data = ret;
+		return;
+	}
+
+	*data = !link;
+}
+
 static void cxgb4_self_test(struct net_device *netdev,
 			    struct ethtool_test *eth_test, u64 *data)
 {
+	int i;
+
 	memset(data, 0, sizeof(u64) * CXGB4_ETHTOOL_MAX_TEST);
 
 	cxgb4_adapter_status_test(netdev, &data[CXGB4_ETHTOOL_ADAPTER_TEST]);
-	if (data[CXGB4_ETHTOOL_ADAPTER_TEST])
+	if (data[CXGB4_ETHTOOL_ADAPTER_TEST]) {
+		for (i = CXGB4_ETHTOOL_ADAPTER_TEST + 1;
+		       i < CXGB4_ETHTOOL_MAX_TEST; i++)
+			data[i] = 1;
+
 		eth_test->flags |= ETH_TEST_FL_FAILED;
+		return;
+	}
+
+	cxgb4_link_test(netdev, &data[CXGB4_ETHTOOL_LINK_TEST]);
+	for (i = CXGB4_ETHTOOL_ADAPTER_TEST; i < CXGB4_ETHTOOL_MAX_TEST; i++) {
+		if (data[i]) {
+			eth_test->flags |= ETH_TEST_FL_FAILED;
+			break;
+		}
+	}
 }
 
 static const struct ethtool_ops cxgb_ethtool_ops = {
-- 
2.21.1


  parent reply	other threads:[~2020-07-17 13:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 13:47 [PATCH net-next 0/4] cxgb4: add ethtool self_test support Vishal Kulkarni
2020-07-17 13:47 ` [PATCH net-next 1/4] cxgb4: Add ethtool self-test support Vishal Kulkarni
2020-07-17 13:47 ` Vishal Kulkarni [this message]
2020-07-17 13:47 ` [PATCH net-next 3/4] cxgb4: Add speed link test to ethtool Vishal Kulkarni
2020-07-17 13:47 ` [PATCH net-next 4/4] cxgb4: add loop back " Vishal Kulkarni
2020-07-17 18:02 ` [PATCH net-next 0/4] cxgb4: add ethtool self_test support Andrew Lunn
2020-07-20  6:28   ` Vishal Kulkarni
2020-07-20 13:35     ` Andrew Lunn
2020-07-21 13:38       ` Vishal Kulkarni
2020-07-21 13:41         ` Andrew Lunn
2020-07-21 16:49           ` Jakub Kicinski
2020-07-21 23:02           ` David Miller
2020-07-21 23:02         ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717134759.8268-3-vishal@chelsio.com \
    --to=vishal@chelsio.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nirranjan@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).