Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: move ethtool-related netdev state into its own struct

net_dev->ethtool is a pointer to new struct ethtool_netdev_state, which
currently contains only the wol_enabled field.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://patch.msgid.link/293a562278371de7534ed1eb17531838ca090633.1719502239.git.ecree.xilinx@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Edward Cree and committed by
Jakub Kicinski
3ebbd9f6 c2dd2139

+29 -14
+2 -2
drivers/net/ethernet/realtek/r8169_main.c
··· 1608 1608 1609 1609 if (!tp->dash_enabled) { 1610 1610 rtl_set_d3_pll_down(tp, !wolopts); 1611 - tp->dev->wol_enabled = wolopts ? 1 : 0; 1611 + tp->dev->ethtool->wol_enabled = wolopts ? 1 : 0; 1612 1612 } 1613 1613 } 1614 1614 ··· 5478 5478 rtl_set_d3_pll_down(tp, true); 5479 5479 } else { 5480 5480 rtl_set_d3_pll_down(tp, false); 5481 - dev->wol_enabled = 1; 5481 + dev->ethtool->wol_enabled = 1; 5482 5482 } 5483 5483 5484 5484 jumbo_max = rtl_jumbo_max(tp);
+2 -2
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
··· 37 37 wx->wol = 0; 38 38 if (wol->wolopts & WAKE_MAGIC) 39 39 wx->wol = WX_PSR_WKUP_CTL_MAG; 40 - netdev->wol_enabled = !!(wx->wol); 40 + netdev->ethtool->wol_enabled = !!(wx->wol); 41 41 wr32(wx, WX_PSR_WKUP_CTL, wx->wol); 42 - device_set_wakeup_enable(&pdev->dev, netdev->wol_enabled); 42 + device_set_wakeup_enable(&pdev->dev, netdev->ethtool->wol_enabled); 43 43 44 44 return 0; 45 45 }
+1 -1
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
··· 650 650 if (wx->wol_hw_supported) 651 651 wx->wol = NGBE_PSR_WKUP_CTL_MAG; 652 652 653 - netdev->wol_enabled = !!(wx->wol); 653 + netdev->ethtool->wol_enabled = !!(wx->wol); 654 654 wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); 655 655 device_set_wakeup_enable(&pdev->dev, wx->wol); 656 656
+1 -1
drivers/net/phy/phy.c
··· 1309 1309 if (netdev) { 1310 1310 struct device *parent = netdev->dev.parent; 1311 1311 1312 - if (netdev->wol_enabled) 1312 + if (netdev->ethtool->wol_enabled) 1313 1313 pm_system_wakeup(); 1314 1314 else if (device_may_wakeup(&netdev->dev)) 1315 1315 pm_wakeup_dev_event(&netdev->dev, 0, true);
+3 -2
drivers/net/phy/phy_device.c
··· 296 296 if (!netdev) 297 297 goto out; 298 298 299 - if (netdev->wol_enabled) 299 + if (netdev->ethtool->wol_enabled) 300 300 return false; 301 301 302 302 /* As long as not all affected network drivers support the ··· 1984 1984 return 0; 1985 1985 1986 1986 phy_ethtool_get_wol(phydev, &wol); 1987 - phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); 1987 + phydev->wol_enabled = wol.wolopts || 1988 + (netdev && netdev->ethtool->wol_enabled); 1988 1989 /* If the device has WOL enabled, we cannot suspend the PHY */ 1989 1990 if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) 1990 1991 return -EBUSY;
+1 -1
drivers/net/phy/phylink.c
··· 2282 2282 { 2283 2283 ASSERT_RTNL(); 2284 2284 2285 - if (mac_wol && (!pl->netdev || pl->netdev->wol_enabled)) { 2285 + if (mac_wol && (!pl->netdev || pl->netdev->ethtool->wol_enabled)) { 2286 2286 /* Wake-on-Lan enabled, MAC handling */ 2287 2287 mutex_lock(&pl->state_mutex); 2288 2288
+8
include/linux/ethtool.h
··· 1004 1004 const struct ethtool_link_ksettings *cmd, 1005 1005 u32 *dev_speed, u8 *dev_duplex); 1006 1006 1007 + /** 1008 + * struct ethtool_netdev_state - per-netdevice state for ethtool features 1009 + * @wol_enabled: Wake-on-LAN is enabled 1010 + */ 1011 + struct ethtool_netdev_state { 1012 + unsigned wol_enabled:1; 1013 + }; 1014 + 1007 1015 struct phy_device; 1008 1016 struct phy_tdr_config; 1009 1017 struct phy_plca_cfg;
+5 -3
include/linux/netdevice.h
··· 80 80 struct xdp_frame; 81 81 struct xdp_metadata_ops; 82 82 struct xdp_md; 83 + struct ethtool_netdev_state; 83 84 84 85 typedef u32 xdp_features_t; 85 86 ··· 1987 1986 * switch driver and used to set the phys state of the 1988 1987 * switch port. 1989 1988 * 1990 - * @wol_enabled: Wake-on-LAN is enabled 1991 - * 1992 1989 * @threaded: napi threaded mode is enabled 1993 1990 * 1994 1991 * @module_fw_flash_in_progress: Module firmware flashing is in progress. ··· 2000 2001 * @udp_tunnel_nic_info: static structure describing the UDP tunnel 2001 2002 * offload capabilities of the device 2002 2003 * @udp_tunnel_nic: UDP tunnel offload state 2004 + * @ethtool: ethtool related state 2003 2005 * @xdp_state: stores info on attached XDP BPF programs 2004 2006 * 2005 2007 * @nested_level: Used as a parameter of spin_lock_nested() of ··· 2375 2375 struct lock_class_key *qdisc_tx_busylock; 2376 2376 bool proto_down; 2377 2377 bool threaded; 2378 - unsigned wol_enabled:1; 2378 + 2379 2379 unsigned module_fw_flash_in_progress:1; 2380 2380 struct list_head net_notifier_list; 2381 2381 ··· 2385 2385 #endif 2386 2386 const struct udp_tunnel_nic_info *udp_tunnel_nic_info; 2387 2387 struct udp_tunnel_nic *udp_tunnel_nic; 2388 + 2389 + struct ethtool_netdev_state *ethtool; 2388 2390 2389 2391 /* protected by rtnl_lock */ 2390 2392 struct bpf_xdp_entity xdp_state[__MAX_XDP_MODE];
+4
net/core/dev.c
··· 11116 11116 dev->real_num_rx_queues = rxqs; 11117 11117 if (netif_alloc_rx_queues(dev)) 11118 11118 goto free_all; 11119 + dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT); 11120 + if (!dev->ethtool) 11121 + goto free_all; 11119 11122 11120 11123 strcpy(dev->name, name); 11121 11124 dev->name_assign_type = name_assign_type; ··· 11169 11166 return; 11170 11167 } 11171 11168 11169 + kfree(dev->ethtool); 11172 11170 netif_free_tx_queues(dev); 11173 11171 netif_free_rx_queues(dev); 11174 11172
+1 -1
net/ethtool/ioctl.c
··· 1509 1509 if (ret) 1510 1510 return ret; 1511 1511 1512 - dev->wol_enabled = !!wol.wolopts; 1512 + dev->ethtool->wol_enabled = !!wol.wolopts; 1513 1513 ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL); 1514 1514 1515 1515 return 0;
+1 -1
net/ethtool/wol.c
··· 137 137 ret = dev->ethtool_ops->set_wol(dev, &wol); 138 138 if (ret) 139 139 return ret; 140 - dev->wol_enabled = !!wol.wolopts; 140 + dev->ethtool->wol_enabled = !!wol.wolopts; 141 141 return 1; 142 142 } 143 143