Skip to content

Commit 29b4220

Browse files
Russell King (Oracle)harshimogalapalli
authored andcommitted
net: dsa: add hook to determine whether EEE is supported
commit 9723a77 upstream. 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> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit f7976772b16a7da725f9156c5ab6472ba22e3bc0) Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
1 parent 48aa269 commit 29b4220

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/net/dsa.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ struct dsa_switch_ops {
10031003
/*
10041004
* Port's MAC EEE settings
10051005
*/
1006+
bool (*support_eee)(struct dsa_switch *ds, int port);
10061007
int (*set_mac_eee)(struct dsa_switch *ds, int port,
10071008
struct ethtool_keee *e);
10081009
int (*get_mac_eee)(struct dsa_switch *ds, int port,

net/dsa/user.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,10 @@ static int dsa_user_set_eee(struct net_device *dev, struct ethtool_keee *e)
12311231
struct dsa_switch *ds = dp->ds;
12321232
int ret;
12331233

1234+
/* Check whether the switch supports EEE */
1235+
if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
1236+
return -EOPNOTSUPP;
1237+
12341238
/* Port's PHY and MAC both need to be EEE capable */
12351239
if (!dev->phydev || !dp->pl)
12361240
return -ENODEV;
@@ -1251,6 +1255,10 @@ static int dsa_user_get_eee(struct net_device *dev, struct ethtool_keee *e)
12511255
struct dsa_switch *ds = dp->ds;
12521256
int ret;
12531257

1258+
/* Check whether the switch supports EEE */
1259+
if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
1260+
return -EOPNOTSUPP;
1261+
12541262
/* Port's PHY and MAC both need to be EEE capable */
12551263
if (!dev->phydev || !dp->pl)
12561264
return -ENODEV;

0 commit comments

Comments
 (0)