]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
net: ngbe: move the WOL functions to libwx
authorJiawen Wu <jiawenwu@trustnetic.com>
Tue, 7 Apr 2026 02:56:09 +0000 (10:56 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 15:42:28 +0000 (08:42 -0700)
Remove duplicate-defined register macros, move the WOL implementation to
the library module. So that the WOL functions can be reused in txgbe
later.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://patch.msgid.link/20260407025616.33652-3-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
drivers/net/ethernet/wangxun/libwx/wx_ethtool.h
drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
drivers/net/ethernet/wangxun/ngbe/ngbe_type.h

index f362e51c73ee6c984dd4eaa3906e7c4c3ef97024..2de1170db8c7e4a4ac13b71967b8b66994202c71 100644 (file)
@@ -262,6 +262,39 @@ int wx_set_link_ksettings(struct net_device *netdev,
 }
 EXPORT_SYMBOL(wx_set_link_ksettings);
 
+void wx_get_wol(struct net_device *netdev,
+               struct ethtool_wolinfo *wol)
+{
+       struct wx *wx = netdev_priv(netdev);
+
+       if (!wx->wol_hw_supported)
+               return;
+       wol->supported = WAKE_MAGIC;
+       wol->wolopts = 0;
+       if (wx->wol & WX_PSR_WKUP_CTL_MAG)
+               wol->wolopts |= WAKE_MAGIC;
+}
+EXPORT_SYMBOL(wx_get_wol);
+
+int wx_set_wol(struct net_device *netdev,
+              struct ethtool_wolinfo *wol)
+{
+       struct wx *wx = netdev_priv(netdev);
+       struct pci_dev *pdev = wx->pdev;
+
+       if (!wx->wol_hw_supported)
+               return -EOPNOTSUPP;
+
+       wx->wol = 0;
+       if (wol->wolopts & WAKE_MAGIC)
+               wx->wol = WX_PSR_WKUP_CTL_MAG;
+       wr32(wx, WX_PSR_WKUP_CTL, wx->wol);
+       device_set_wakeup_enable(&pdev->dev, !!(wx->wol));
+
+       return 0;
+}
+EXPORT_SYMBOL(wx_set_wol);
+
 void wx_get_pauseparam(struct net_device *netdev,
                       struct ethtool_pauseparam *pause)
 {
index 72709397046254636bbe21542bc846d65bc930b2..5b187d1587b1122f96412c99b7cf727ab75273f2 100644 (file)
@@ -18,6 +18,10 @@ 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);
+void wx_get_wol(struct net_device *netdev,
+               struct ethtool_wolinfo *wol);
+int wx_set_wol(struct net_device *netdev,
+              struct ethtool_wolinfo *wol);
 void wx_get_pauseparam(struct net_device *netdev,
                       struct ethtool_pauseparam *pause);
 int wx_set_pauseparam(struct net_device *netdev,
index 40779fee0fdfeb6f5d69b54580e10f0f16213ded..2b6356622a13ecace9321e12e6c6d5f1f3b33379 100644 (file)
 #include "ngbe_ethtool.h"
 #include "ngbe_type.h"
 
-static void ngbe_get_wol(struct net_device *netdev,
-                        struct ethtool_wolinfo *wol)
-{
-       struct wx *wx = netdev_priv(netdev);
-
-       if (!wx->wol_hw_supported)
-               return;
-       wol->supported = WAKE_MAGIC;
-       wol->wolopts = 0;
-       if (wx->wol & WX_PSR_WKUP_CTL_MAG)
-               wol->wolopts |= WAKE_MAGIC;
-}
-
-static int ngbe_set_wol(struct net_device *netdev,
-                       struct ethtool_wolinfo *wol)
-{
-       struct wx *wx = netdev_priv(netdev);
-       struct pci_dev *pdev = wx->pdev;
-
-       if (!wx->wol_hw_supported)
-               return -EOPNOTSUPP;
-
-       wx->wol = 0;
-       if (wol->wolopts & WAKE_MAGIC)
-               wx->wol = WX_PSR_WKUP_CTL_MAG;
-       wr32(wx, WX_PSR_WKUP_CTL, wx->wol);
-       device_set_wakeup_enable(&pdev->dev, !!(wx->wol));
-
-       return 0;
-}
-
 static int ngbe_set_ringparam(struct net_device *netdev,
                              struct ethtool_ringparam *ring,
                              struct kernel_ethtool_ringparam *kernel_ring,
@@ -121,8 +90,8 @@ static const struct ethtool_ops ngbe_ethtool_ops = {
        .get_link_ksettings     = wx_get_link_ksettings,
        .set_link_ksettings     = wx_set_link_ksettings,
        .nway_reset             = wx_nway_reset,
-       .get_wol                = ngbe_get_wol,
-       .set_wol                = ngbe_set_wol,
+       .get_wol                = wx_get_wol,
+       .set_wol                = wx_set_wol,
        .get_sset_count         = wx_get_sset_count,
        .get_strings            = wx_get_strings,
        .get_ethtool_stats      = wx_get_ethtool_stats,
index 58488e138beb4321f49fdf773f481abf6310192a..e28ddf684a060dc198281ff120feabe31b487c89 100644 (file)
@@ -58,14 +58,14 @@ static void ngbe_init_type_code(struct wx *wx)
        wx->mac.type = wx_mac_em;
        type_mask = (u16)(wx->subsystem_device_id & NGBE_OEM_MASK);
        ncsi_mask = wx->subsystem_device_id & NGBE_NCSI_MASK;
-       wol_mask = wx->subsystem_device_id & NGBE_WOL_MASK;
+       wol_mask = wx->subsystem_device_id & WX_WOL_MASK;
 
        val = rd32(wx, WX_CFG_PORT_ST);
        wx->mac_type = (val & BIT(7)) >> 7 ?
                       em_mac_type_rgmii :
                       em_mac_type_mdi;
 
-       wx->wol_hw_supported = (wol_mask == NGBE_WOL_SUP) ? 1 : 0;
+       wx->wol_hw_supported = (wol_mask == WX_WOL_SUP) ? 1 : 0;
        wx->ncsi_enabled = (ncsi_mask == NGBE_NCSI_MASK ||
                           type_mask == NGBE_SUBID_OCP_CARD) ? 1 : 0;
 
@@ -520,9 +520,9 @@ static void ngbe_dev_shutdown(struct pci_dev *pdev, bool *enable_wake)
        if (wufc) {
                wx_set_rx_mode(netdev);
                wx_configure_rx(wx);
-               wr32(wx, NGBE_PSR_WKUP_CTL, wufc);
+               wr32(wx, WX_PSR_WKUP_CTL, wufc);
        } else {
-               wr32(wx, NGBE_PSR_WKUP_CTL, 0);
+               wr32(wx, WX_PSR_WKUP_CTL, 0);
        }
        pci_wake_from_d3(pdev, !!wufc);
        *enable_wake = !!wufc;
@@ -742,10 +742,10 @@ static int ngbe_probe(struct pci_dev *pdev,
 
        wx->wol = 0;
        if (wx->wol_hw_supported)
-               wx->wol = NGBE_PSR_WKUP_CTL_MAG;
+               wx->wol = WX_PSR_WKUP_CTL_MAG;
 
        netdev->ethtool->wol_enabled = !!(wx->wol);
-       wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol);
+       wr32(wx, WX_PSR_WKUP_CTL, wx->wol);
        device_set_wakeup_enable(&pdev->dev, wx->wol);
 
        /* Save off EEPROM version number and Option Rom version which
index 3b2ca7f47e332cedb53d0473fc0ff648ed767d16..f1957fa0add47d49ad90fd78af21dc95c4008834 100644 (file)
@@ -39,8 +39,6 @@
 
 #define NGBE_NCSI_SUP                          0x8000
 #define NGBE_NCSI_MASK                         0x8000
-#define NGBE_WOL_SUP                           0x4000
-#define NGBE_WOL_MASK                          0x4000
 
 /**************** EM Registers ****************************/
 /* chip control Registers */
 #define NGBE_CFG_LAN_SPEED                     0x14440
 #define NGBE_CFG_PORT_ST                       0x14404
 
-/* Wake up registers */
-#define NGBE_PSR_WKUP_CTL                      0x15B80
-/* Wake Up Filter Control Bit */
-#define NGBE_PSR_WKUP_CTL_LNKC                 BIT(0) /* Link Status Change Wakeup Enable*/
-#define NGBE_PSR_WKUP_CTL_MAG                  BIT(1) /* Magic Packet Wakeup Enable */
-#define NGBE_PSR_WKUP_CTL_EX                   BIT(2) /* Directed Exact Wakeup Enable */
-#define NGBE_PSR_WKUP_CTL_MC                   BIT(3) /* Directed Multicast Wakeup Enable*/
-#define NGBE_PSR_WKUP_CTL_BC                   BIT(4) /* Broadcast Wakeup Enable */
-#define NGBE_PSR_WKUP_CTL_ARP                  BIT(5) /* ARP Request Packet Wakeup Enable*/
-#define NGBE_PSR_WKUP_CTL_IPV4                 BIT(6) /* Directed IPv4 Pkt Wakeup Enable */
-#define NGBE_PSR_WKUP_CTL_IPV6                 BIT(7) /* Directed IPv6 Pkt Wakeup Enable */
-
 #define NGBE_FW_EEPROM_CHECKSUM_CMD            0xE9
 #define NGBE_FW_NVM_DATA_OFFSET                        3
 #define NGBE_FW_CMD_DEFAULT_CHECKSUM           0xFF /* checksum always 0xFF */