[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200717134759.8268-3-vishal@chelsio.com>
Date: Fri, 17 Jul 2020 19:17:57 +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 2/4] cxgb4: Add link test to ethtool self test
This test checks whether link is up or not
Signed-off-by: Vishal Kulkarni <vishal@...lsio.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
Powered by blists - more mailing lists