]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: move ethtool-related netdev state into its own struct
authorEdward Cree <ecree.xilinx@gmail.com>
Thu, 27 Jun 2024 15:33:46 +0000 (16:33 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 29 Jun 2024 01:53:17 +0000 (18:53 -0700)
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>
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/phy/phylink.c
include/linux/ethtool.h
include/linux/netdevice.h
net/core/dev.c
net/ethtool/ioctl.c
net/ethtool/wol.c

index 9246ea2118ff2ca4a59fd4b3ce327a9fbf739f13..714d2e80469404ef0e950998a8cbce85449fa8f2 100644 (file)
@@ -1608,7 +1608,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
 
        if (!tp->dash_enabled) {
                rtl_set_d3_pll_down(tp, !wolopts);
-               tp->dev->wol_enabled = wolopts ? 1 : 0;
+               tp->dev->ethtool->wol_enabled = wolopts ? 1 : 0;
        }
 }
 
@@ -5478,7 +5478,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                rtl_set_d3_pll_down(tp, true);
        } else {
                rtl_set_d3_pll_down(tp, false);
-               dev->wol_enabled = 1;
+               dev->ethtool->wol_enabled = 1;
        }
 
        jumbo_max = rtl_jumbo_max(tp);
index 46a5a3e952021a1369d7883a4e3d4eeef212b3b7..e868f7ef492032ef5439a3d0fa530b2877bc370c 100644 (file)
@@ -37,9 +37,9 @@ static int ngbe_set_wol(struct net_device *netdev,
        wx->wol = 0;
        if (wol->wolopts & WAKE_MAGIC)
                wx->wol = WX_PSR_WKUP_CTL_MAG;
-       netdev->wol_enabled = !!(wx->wol);
+       netdev->ethtool->wol_enabled = !!(wx->wol);
        wr32(wx, WX_PSR_WKUP_CTL, wx->wol);
-       device_set_wakeup_enable(&pdev->dev, netdev->wol_enabled);
+       device_set_wakeup_enable(&pdev->dev, netdev->ethtool->wol_enabled);
 
        return 0;
 }
index e894e01d030d15bf28ae197ac698a8d44795168c..a8119de60deb7e28e0f78f892dacdf3f91b5d71e 100644 (file)
@@ -650,7 +650,7 @@ static int ngbe_probe(struct pci_dev *pdev,
        if (wx->wol_hw_supported)
                wx->wol = NGBE_PSR_WKUP_CTL_MAG;
 
-       netdev->wol_enabled = !!(wx->wol);
+       netdev->ethtool->wol_enabled = !!(wx->wol);
        wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol);
        device_set_wakeup_enable(&pdev->dev, wx->wol);
 
index c4236564c1cd01422db451f9118b3217b55ada97..785182fa5fe01f950de7cb5082865fd8c3c5ba3a 100644 (file)
@@ -1309,7 +1309,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
                if (netdev) {
                        struct device *parent = netdev->dev.parent;
 
-                       if (netdev->wol_enabled)
+                       if (netdev->ethtool->wol_enabled)
                                pm_system_wakeup();
                        else if (device_may_wakeup(&netdev->dev))
                                pm_wakeup_dev_event(&netdev->dev, 0, true);
index 6c6ec947570929536fe321c4063eefd32afb6649..473cbc1d497b33070b830388ccad33f74349cd3d 100644 (file)
@@ -296,7 +296,7 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
        if (!netdev)
                goto out;
 
-       if (netdev->wol_enabled)
+       if (netdev->ethtool->wol_enabled)
                return false;
 
        /* As long as not all affected network drivers support the
@@ -1984,7 +1984,8 @@ int phy_suspend(struct phy_device *phydev)
                return 0;
 
        phy_ethtool_get_wol(phydev, &wol);
-       phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled);
+       phydev->wol_enabled = wol.wolopts ||
+                             (netdev && netdev->ethtool->wol_enabled);
        /* If the device has WOL enabled, we cannot suspend the PHY */
        if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND))
                return -EBUSY;
index 6c24c48dcf0f4eca4135b5afcd0beb9e4ea1fc94..51c526d227fab32afc1f5dd261850fd7c51fa17d 100644 (file)
@@ -2282,7 +2282,7 @@ void phylink_suspend(struct phylink *pl, bool mac_wol)
 {
        ASSERT_RTNL();
 
-       if (mac_wol && (!pl->netdev || pl->netdev->wol_enabled)) {
+       if (mac_wol && (!pl->netdev || pl->netdev->ethtool->wol_enabled)) {
                /* Wake-on-Lan enabled, MAC handling */
                mutex_lock(&pl->state_mutex);
 
index c7f6f2bc9cacaeabad19d8e180f4850f379d2381..374639e661d190adae82d1d3e4010c63860f1254 100644 (file)
@@ -1004,6 +1004,14 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
                                       const struct ethtool_link_ksettings *cmd,
                                       u32 *dev_speed, u8 *dev_duplex);
 
+/**
+ * struct ethtool_netdev_state - per-netdevice state for ethtool features
+ * @wol_enabled:       Wake-on-LAN is enabled
+ */
+struct ethtool_netdev_state {
+       unsigned                wol_enabled:1;
+};
+
 struct phy_device;
 struct phy_tdr_config;
 struct phy_plca_cfg;
index 1e3401093c1305198ad41e972760915d66ac3356..3c719f0d5f5ae8f718a26997a4a03bc9814398e9 100644 (file)
@@ -80,6 +80,7 @@ struct xdp_buff;
 struct xdp_frame;
 struct xdp_metadata_ops;
 struct xdp_md;
+struct ethtool_netdev_state;
 
 typedef u32 xdp_features_t;
 
@@ -1986,8 +1987,6 @@ enum netdev_reg_state {
  *                     switch driver and used to set the phys state of the
  *                     switch port.
  *
- *     @wol_enabled:   Wake-on-LAN is enabled
- *
  *     @threaded:      napi threaded mode is enabled
  *
  *     @module_fw_flash_in_progress:   Module firmware flashing is in progress.
@@ -2001,6 +2000,7 @@ enum netdev_reg_state {
  *     @udp_tunnel_nic_info:   static structure describing the UDP tunnel
  *                             offload capabilities of the device
  *     @udp_tunnel_nic:        UDP tunnel offload state
+ *     @ethtool:       ethtool related state
  *     @xdp_state:             stores info on attached XDP BPF programs
  *
  *     @nested_level:  Used as a parameter of spin_lock_nested() of
@@ -2375,7 +2375,7 @@ struct net_device {
        struct lock_class_key   *qdisc_tx_busylock;
        bool                    proto_down;
        bool                    threaded;
-       unsigned                wol_enabled:1;
+
        unsigned                module_fw_flash_in_progress:1;
        struct list_head        net_notifier_list;
 
@@ -2386,6 +2386,8 @@ struct net_device {
        const struct udp_tunnel_nic_info        *udp_tunnel_nic_info;
        struct udp_tunnel_nic   *udp_tunnel_nic;
 
+       struct ethtool_netdev_state *ethtool;
+
        /* protected by rtnl_lock */
        struct bpf_xdp_entity   xdp_state[__MAX_XDP_MODE];
 
index 0a23d7da7fbc64d390c7909c6e213544d28e5a40..c0c6e200e17f0b47cb338dab88484b0317051a61 100644 (file)
@@ -11116,6 +11116,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
        dev->real_num_rx_queues = rxqs;
        if (netif_alloc_rx_queues(dev))
                goto free_all;
+       dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT);
+       if (!dev->ethtool)
+               goto free_all;
 
        strcpy(dev->name, name);
        dev->name_assign_type = name_assign_type;
@@ -11166,6 +11169,7 @@ void free_netdev(struct net_device *dev)
                return;
        }
 
+       kfree(dev->ethtool);
        netif_free_tx_queues(dev);
        netif_free_rx_queues(dev);
 
index 1cca372c0d807b78b2cbd56466324686d39eb493..94059ce9e5f256ac882a32372f4d37a7bb1aff22 100644 (file)
@@ -1509,7 +1509,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
        if (ret)
                return ret;
 
-       dev->wol_enabled = !!wol.wolopts;
+       dev->ethtool->wol_enabled = !!wol.wolopts;
        ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
 
        return 0;
index 0ed56c9ac1bc49d6b7d30d2299cd0923cbff94da..a39d8000d808ae4cd60dae268afdee5a436c5215 100644 (file)
@@ -137,7 +137,7 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info)
        ret = dev->ethtool_ops->set_wol(dev, &wol);
        if (ret)
                return ret;
-       dev->wol_enabled = !!wol.wolopts;
+       dev->ethtool->wol_enabled = !!wol.wolopts;
        return 1;
 }