net: usb: asix: ax88772: add generic selftest support
authorOleksij Rempel <o.rempel@pengutronix.de>
Mon, 7 Jun 2021 08:27:24 +0000 (10:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Jun 2021 20:23:02 +0000 (13:23 -0700)
With working phylib support we are able now to use generic selftests.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/Kconfig
drivers/net/usb/asix.h
drivers/net/usb/asix_devices.c

index 6f7be47..4c5d697 100644 (file)
@@ -165,6 +165,7 @@ config USB_NET_AX8817X
        select CRC32
        select PHYLIB
        select AX88796B_PHY
+       imply NET_SELFTESTS
        default y
        help
          This option adds support for ASIX AX88xxx based USB 2.0
index 2122d30..e1994a2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/if_vlan.h>
 #include <linux/phy.h>
+#include <net/selftests.h>
 
 #define DRIVER_VERSION "22-Dec-2011"
 #define DRIVER_NAME "asix"
index e4cd85e..57dafb3 100644 (file)
@@ -283,6 +283,26 @@ out:
        return ret;
 }
 
+static void ax88772_ethtool_get_strings(struct net_device *netdev, u32 sset,
+                                       u8 *data)
+{
+       switch (sset) {
+       case ETH_SS_TEST:
+               net_selftest_get_strings(data);
+               break;
+       }
+}
+
+static int ax88772_ethtool_get_sset_count(struct net_device *ndev, int sset)
+{
+       switch (sset) {
+       case ETH_SS_TEST:
+               return net_selftest_get_count();
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 static const struct ethtool_ops ax88772_ethtool_ops = {
        .get_drvinfo            = asix_get_drvinfo,
        .get_link               = usbnet_get_link,
@@ -296,6 +316,9 @@ static const struct ethtool_ops ax88772_ethtool_ops = {
        .nway_reset             = phy_ethtool_nway_reset,
        .get_link_ksettings     = phy_ethtool_get_link_ksettings,
        .set_link_ksettings     = phy_ethtool_set_link_ksettings,
+       .self_test              = net_selftest,
+       .get_strings            = ax88772_ethtool_get_strings,
+       .get_sset_count         = ax88772_ethtool_get_sset_count,
 };
 
 static int ax88772_reset(struct usbnet *dev)