net: libwx: add phylink to libwx
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 3 Jan 2024 02:08:47 +0000 (10:08 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jan 2024 10:49:35 +0000 (10:49 +0000)
For the following implementation, add struct phylink and phylink_config
to wx structure. Add the helper function for converting phylink to wx,
implement ethtool ksetting and nway reset in libwx.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
drivers/net/ethernet/wangxun/libwx/wx_ethtool.h
drivers/net/ethernet/wangxun/libwx/wx_type.h

index 6e9e5f01c1525c32fc6f35e5da705e089a5c5592..ba37ba6f03e4ddf57da3504a9443e100871b5d34 100644 (file)
@@ -185,3 +185,29 @@ void wx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info)
        }
 }
 EXPORT_SYMBOL(wx_get_drvinfo);
+
+int wx_nway_reset(struct net_device *netdev)
+{
+       struct wx *wx = netdev_priv(netdev);
+
+       return phylink_ethtool_nway_reset(wx->phylink);
+}
+EXPORT_SYMBOL(wx_nway_reset);
+
+int wx_get_link_ksettings(struct net_device *netdev,
+                         struct ethtool_link_ksettings *cmd)
+{
+       struct wx *wx = netdev_priv(netdev);
+
+       return phylink_ethtool_ksettings_get(wx->phylink, cmd);
+}
+EXPORT_SYMBOL(wx_get_link_ksettings);
+
+int wx_set_link_ksettings(struct net_device *netdev,
+                         const struct ethtool_link_ksettings *cmd)
+{
+       struct wx *wx = netdev_priv(netdev);
+
+       return phylink_ethtool_ksettings_set(wx->phylink, cmd);
+}
+EXPORT_SYMBOL(wx_set_link_ksettings);
index 16d1a09369a6108328b3a09bfd8696dcacf1ffa3..f15cc445ae0fd400c660f80101bf0e58ef9d619f 100644 (file)
@@ -13,4 +13,9 @@ void wx_get_mac_stats(struct net_device *netdev,
 void wx_get_pause_stats(struct net_device *netdev,
                        struct ethtool_pause_stats *stats);
 void wx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info);
+int wx_nway_reset(struct net_device *netdev);
+int wx_get_link_ksettings(struct net_device *netdev,
+                         struct ethtool_link_ksettings *cmd);
+int wx_set_link_ksettings(struct net_device *netdev,
+                         const struct ethtool_link_ksettings *cmd);
 #endif /* _WX_ETHTOOL_H_ */
index 83f9bb7b3c22a04f3361bee53bd2d4aa0d70e704..5b064c43405333d4f612cd24720c87ed44f48a39 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/bitfield.h>
 #include <linux/netdevice.h>
 #include <linux/if_vlan.h>
+#include <linux/phylink.h>
 #include <net/ip.h>
 
 #define WX_NCSI_SUP                             0x8000
@@ -939,6 +940,8 @@ struct wx {
        int speed;
        int duplex;
        struct phy_device *phydev;
+       struct phylink *phylink;
+       struct phylink_config phylink_config;
 
        bool wol_hw_supported;
        bool ncsi_enabled;
@@ -1044,4 +1047,9 @@ rd64(struct wx *wx, u32 reg)
 #define wx_dbg(wx, fmt, arg...) \
        dev_dbg(&(wx)->pdev->dev, fmt, ##arg)
 
+static inline struct wx *phylink_to_wx(struct phylink_config *config)
+{
+       return container_of(config, struct wx, phylink_config);
+}
+
 #endif /* _WX_TYPE_H_ */