Commit 660819a1 authored by Jiawen Wu's avatar Jiawen Wu Committed by Duanqiang Wen
Browse files

net: libwx: add phylink to libwx

mainline inclusion
from mainline-v6.8-rc1
commit e8e138cf7383cf820419fcbec63992e75a01467b
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I93QRU
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e8e138cf7383cf820419fcbec63992e75a01467b



---------------------------------------------------------

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: default avatarJiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarDuanqiang Wen <duanqiangwen@net-swift.com>
parent a75ed689
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -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);
+5 −0
Original line number Diff line number Diff line
@@ -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_ */
+8 −0
Original line number Diff line number Diff line
@@ -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_ */