Replace lan78xx_get_pause and lan78xx_set_pause implementations with
phylink-based functions. This transition aligns pause parameter handling
with the phylink API, simplifying the code and improving
maintainability.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/net/usb/lan78xx.c | 51 ++-------------------------------------
1 file changed, 2 insertions(+), 49 deletions(-)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 7107eaa440e5..3aa916a9ee0b 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1878,63 +1878,16 @@ static void lan78xx_get_pause(struct net_device *net,
struct ethtool_pauseparam *pause)
{
struct lan78xx_net *dev = netdev_priv(net);
- struct phy_device *phydev = net->phydev;
- struct ethtool_link_ksettings ecmd;
-
- phy_ethtool_ksettings_get(phydev, &ecmd);
-
- pause->autoneg = dev->fc_autoneg;
- if (dev->fc_request_control & FLOW_CTRL_TX)
- pause->tx_pause = 1;
-
- if (dev->fc_request_control & FLOW_CTRL_RX)
- pause->rx_pause = 1;
+ phylink_ethtool_get_pauseparam(dev->phylink, pause);
}
static int lan78xx_set_pause(struct net_device *net,
struct ethtool_pauseparam *pause)
{
struct lan78xx_net *dev = netdev_priv(net);
- struct phy_device *phydev = net->phydev;
- struct ethtool_link_ksettings ecmd;
- int ret;
-
- phy_ethtool_ksettings_get(phydev, &ecmd);
-
- if (pause->autoneg && !ecmd.base.autoneg) {
- ret = -EINVAL;
- goto exit;
- }
- dev->fc_request_control = 0;
- if (pause->rx_pause)
- dev->fc_request_control |= FLOW_CTRL_RX;
-
- if (pause->tx_pause)
- dev->fc_request_control |= FLOW_CTRL_TX;
-
- if (ecmd.base.autoneg) {
- __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) = { 0, };
- u32 mii_adv;
-
- linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
- ecmd.link_modes.advertising);
- linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
- ecmd.link_modes.advertising);
- mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control);
- mii_adv_to_linkmode_adv_t(fc, mii_adv);
- linkmode_or(ecmd.link_modes.advertising, fc,
- ecmd.link_modes.advertising);
-
- phy_ethtool_ksettings_set(phydev, &ecmd);
- }
-
- dev->fc_autoneg = pause->autoneg;
-
- ret = 0;
-exit:
- return ret;
+ return phylink_ethtool_set_pauseparam(dev->phylink, pause);
}
static int lan78xx_get_regs_len(struct net_device *netdev)
--
2.39.5
Hi Oleksij,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Oleksij-Rempel/net-usb-lan78xx-Convert-to-PHYlink-for-improved-PHY-and-MAC-management/20250310-200116
base: net-next/main
patch link: https://lore.kernel.org/r/20250310115737.784047-7-o.rempel%40pengutronix.de
patch subject: [PATCH net-next v3 6/7] net: usb: lan78xx: Transition get/set_pause to phylink
config: i386-randconfig-006-20250315 (https://download.01.org/0day-ci/archive/20250315/202503151846.f7B5hHIU-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250315/202503151846.f7B5hHIU-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503151846.f7B5hHIU-lkp@intel.com/
All errors (new ones prefixed by >>):
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_set_link_ksettings':
drivers/net/usb/lan78xx.c:1874: undefined reference to `phylink_ethtool_ksettings_set'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_get_link_ksettings':
drivers/net/usb/lan78xx.c:1866: undefined reference to `phylink_ethtool_ksettings_get'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_set_pause':
>> drivers/net/usb/lan78xx.c:1890: undefined reference to `phylink_ethtool_set_pauseparam'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_get_pause':
>> drivers/net/usb/lan78xx.c:1882: undefined reference to `phylink_ethtool_get_pauseparam'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_open':
drivers/net/usb/lan78xx.c:3205: undefined reference to `phylink_start'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_stop':
drivers/net/usb/lan78xx.c:3275: undefined reference to `phylink_stop'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_disconnect':
drivers/net/usb/lan78xx.c:4300: undefined reference to `phylink_stop'
ld: drivers/net/usb/lan78xx.c:4301: undefined reference to `phylink_disconnect_phy'
ld: drivers/net/usb/lan78xx.c:4312: undefined reference to `phylink_destroy'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_reset_resume':
drivers/net/usb/lan78xx.c:5098: undefined reference to `phylink_start'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_phy_init':
drivers/net/usb/lan78xx.c:2603: undefined reference to `phylink_connect_phy'
ld: drivers/net/usb/lan78xx.c:2571: undefined reference to `phylink_set_fixed_link'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_phylink_setup':
drivers/net/usb/lan78xx.c:2541: undefined reference to `phylink_create'
ld: drivers/net/usb/lan78xx.o: in function `lan78xx_probe':
drivers/net/usb/lan78xx.c:4534: undefined reference to `phylink_disconnect_phy'
ld: drivers/net/usb/lan78xx.c:4536: undefined reference to `phylink_destroy'
vim +1890 drivers/net/usb/lan78xx.c
1876
1877 static void lan78xx_get_pause(struct net_device *net,
1878 struct ethtool_pauseparam *pause)
1879 {
1880 struct lan78xx_net *dev = netdev_priv(net);
1881
> 1882 phylink_ethtool_get_pauseparam(dev->phylink, pause);
1883 }
1884
1885 static int lan78xx_set_pause(struct net_device *net,
1886 struct ethtool_pauseparam *pause)
1887 {
1888 struct lan78xx_net *dev = netdev_priv(net);
1889
> 1890 return phylink_ethtool_set_pauseparam(dev->phylink, pause);
1891 }
1892
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Oleksij,
On Mon, 10 Mar 2025 12:57:36 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> Replace lan78xx_get_pause and lan78xx_set_pause implementations with
> phylink-based functions. This transition aligns pause parameter handling
> with the phylink API, simplifying the code and improving
> maintainability.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
Some very minor things below :
> drivers/net/usb/lan78xx.c | 51 ++-------------------------------------
> 1 file changed, 2 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 7107eaa440e5..3aa916a9ee0b 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1878,63 +1878,16 @@ static void lan78xx_get_pause(struct net_device *net,
> struct ethtool_pauseparam *pause)
> {
> struct lan78xx_net *dev = netdev_priv(net);
> - struct phy_device *phydev = net->phydev;
> - struct ethtool_link_ksettings ecmd;
> -
> - phy_ethtool_ksettings_get(phydev, &ecmd);
> -
> - pause->autoneg = dev->fc_autoneg;
>
> - if (dev->fc_request_control & FLOW_CTRL_TX)
> - pause->tx_pause = 1;
> -
> - if (dev->fc_request_control & FLOW_CTRL_RX)
> - pause->rx_pause = 1;
> + phylink_ethtool_get_pauseparam(dev->phylink, pause);
> }
>
> static int lan78xx_set_pause(struct net_device *net,
> struct ethtool_pauseparam *pause)
> {
> struct lan78xx_net *dev = netdev_priv(net);
> - struct phy_device *phydev = net->phydev;
> - struct ethtool_link_ksettings ecmd;
> - int ret;
> -
> - phy_ethtool_ksettings_get(phydev, &ecmd);
> -
> - if (pause->autoneg && !ecmd.base.autoneg) {
> - ret = -EINVAL;
> - goto exit;
> - }
>
> - dev->fc_request_control = 0;
> - if (pause->rx_pause)
> - dev->fc_request_control |= FLOW_CTRL_RX;
> -
> - if (pause->tx_pause)
> - dev->fc_request_control |= FLOW_CTRL_TX;
Sorry not to have spotted that before, but after that patch you no
longer need dev->fc_request_control, you can get rid of that in
struct lan78xx_net.
Related to other patches (probably patch 1), it also appears you can get
rid of :
- dev->fc_autoneg
- dev->interface
- dev->link_on
Thanks,
Maxime
© 2016 - 2026 Red Hat, Inc.