]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: dsa: add hook to determine whether EEE is supported
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 10 Dec 2024 14:18:16 +0000 (14:18 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 12 Dec 2024 04:29:38 +0000 (20:29 -0800)
Add a hook to determine whether the switch supports EEE. This will
return false if the switch does not, or true if it does. If the
method is not implemented, we assume (currently) that the switch
supports EEE.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/E1tL144-006cZD-El@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/dsa.h
net/dsa/user.c

index 72ae65e7246a7c094c50e3f88c12dfdec7631fb7..aaa75bbaa0eac6a6ed045dbe2340ce0a75c62b86 100644 (file)
@@ -988,6 +988,7 @@ struct dsa_switch_ops {
        /*
         * Port's MAC EEE settings
         */
+       bool    (*support_eee)(struct dsa_switch *ds, int port);
        int     (*set_mac_eee)(struct dsa_switch *ds, int port,
                               struct ethtool_keee *e);
        int     (*get_mac_eee)(struct dsa_switch *ds, int port,
index e1a0b153c3535af7a4f26c08e66c9dd348436322..a74339680010474e2f6c22b804d655fd08b0f9eb 100644 (file)
@@ -1229,6 +1229,10 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_keee *e)
        struct dsa_switch *ds = dp->ds;
        int ret;
 
+       /* Check whether the switch supports EEE */
+       if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
+               return -EOPNOTSUPP;
+
        /* Port's PHY and MAC both need to be EEE capable */
        if (!dev->phydev)
                return -ENODEV;
@@ -1249,6 +1253,10 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e)
        struct dsa_switch *ds = dp->ds;
        int ret;
 
+       /* Check whether the switch supports EEE */
+       if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
+               return -EOPNOTSUPP;
+
        /* Port's PHY and MAC both need to be EEE capable */
        if (!dev->phydev)
                return -ENODEV;