[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200717134759.8268-4-vishal@chelsio.com>
Date: Fri, 17 Jul 2020 19:17:58 +0530
From: Vishal Kulkarni <vishal@...lsio.com>
To: netdev@...r.kernel.org, davem@...emloft.net
Cc: nirranjan@...lsio.com, Vishal Kulkarni <vishal@...lsio.com>
Subject: [PATCH net-next 3/4] cxgb4: Add speed link test to ethtool
This test checks whether the current speed is supported or not
Signed-off-by: Vishal Kulkarni <vishal@...lsio.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
Powered by blists - more mailing lists