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 3/4] cxgb4: Add speed link test to ethtool
Date: Fri, 17 Jul 2020 19:17:58 +0530	[thread overview]
Message-ID: <20200717134759.8268-4-vishal@chelsio.com> (raw)
In-Reply-To: <20200717134759.8268-1-vishal@chelsio.com>

This test checks whether the current speed is supported or not

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

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index f374757e15c8..5d3eb44dee46 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -28,12 +28,14 @@ static void set_msglevel(struct net_device *dev, u32 val)
 enum cxgb4_ethtool_tests {
 	CXGB4_ETHTOOL_ADAPTER_TEST,
 	CXGB4_ETHTOOL_LINK_TEST,
+	CXGB4_ETHTOOL_LINK_SPEED_TEST,
 	CXGB4_ETHTOOL_MAX_TEST,
 };
 
 static const char cxgb4_selftest_strings[CXGB4_ETHTOOL_MAX_TEST][ETH_GSTRING_LEN] = {
 	"Adapter health status",
 	"Link test",
+	"Link speed test",
 };
 
 static const char * const flash_region_strings[] = {
@@ -2102,6 +2104,26 @@ static void cxgb4_link_test(struct net_device *netdev, u64 *data)
 	*data = !link;
 }
 
+static void cxgb4_link_speed_test(struct net_device *netdev, u64 *data)
+{
+	struct port_info *pi = netdev_priv(netdev);
+	unsigned int speed;
+	int ret;
+
+	ret = t4_get_link_params(pi, NULL, &speed, NULL);
+	if (ret) {
+		*data = ret;
+		return;
+	}
+
+	if (!speed_to_fw_caps(speed)) {
+		*data = 1;
+		return;
+	}
+
+	*data = 0;
+}
+
 static void cxgb4_self_test(struct net_device *netdev,
 			    struct ethtool_test *eth_test, u64 *data)
 {
@@ -2120,6 +2142,8 @@ static void cxgb4_self_test(struct net_device *netdev,
 	}
 
 	cxgb4_link_test(netdev, &data[CXGB4_ETHTOOL_LINK_TEST]);
+	cxgb4_link_speed_test(netdev, &data[CXGB4_ETHTOOL_LINK_SPEED_TEST]);
+
 	for (i = CXGB4_ETHTOOL_ADAPTER_TEST; i < CXGB4_ETHTOOL_MAX_TEST; i++) {
 		if (data[i]) {
 			eth_test->flags |= ETH_TEST_FL_FAILED;
-- 
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 ` [PATCH net-next 2/4] cxgb4: Add link test to ethtool self test Vishal Kulkarni
2020-07-17 13:47 ` Vishal Kulkarni [this message]
2020-07-17 13:47 ` [PATCH net-next 4/4] cxgb4: add loop back test to ethtool 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-4-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).