446f918fa081a659d4c0b35db478ac314568fa79
[openwrt/staging/thess.git] /
1 From 9723a77318b7c0cfd06ea207e52a042f8c815318 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Tue, 10 Dec 2024 14:18:16 +0000
4 Subject: [PATCH] net: dsa: add hook to determine whether EEE is supported
5
6 Add a hook to determine whether the switch supports EEE. This will
7 return false if the switch does not, or true if it does. If the
8 method is not implemented, we assume (currently) that the switch
9 supports EEE.
10
11 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
12 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
13 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
14 Link: https://patch.msgid.link/E1tL144-006cZD-El@rmk-PC.armlinux.org.uk
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 ---
17 include/net/dsa.h | 1 +
18 net/dsa/user.c | 8 ++++++++
19 2 files changed, 9 insertions(+)
20
21 --- a/include/net/dsa.h
22 +++ b/include/net/dsa.h
23 @@ -1003,6 +1003,7 @@ struct dsa_switch_ops {
24 /*
25 * Port's MAC EEE settings
26 */
27 + bool (*support_eee)(struct dsa_switch *ds, int port);
28 int (*set_mac_eee)(struct dsa_switch *ds, int port,
29 struct ethtool_keee *e);
30 int (*get_mac_eee)(struct dsa_switch *ds, int port,
31 --- a/net/dsa/user.c
32 +++ b/net/dsa/user.c
33 @@ -1231,6 +1231,10 @@ static int dsa_user_set_eee(struct net_d
34 struct dsa_switch *ds = dp->ds;
35 int ret;
36
37 + /* Check whether the switch supports EEE */
38 + if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
39 + return -EOPNOTSUPP;
40 +
41 /* Port's PHY and MAC both need to be EEE capable */
42 if (!dev->phydev || !dp->pl)
43 return -ENODEV;
44 @@ -1251,6 +1255,10 @@ static int dsa_user_get_eee(struct net_d
45 struct dsa_switch *ds = dp->ds;
46 int ret;
47
48 + /* Check whether the switch supports EEE */
49 + if (ds->ops->support_eee && !ds->ops->support_eee(ds, dp->index))
50 + return -EOPNOTSUPP;
51 +
52 /* Port's PHY and MAC both need to be EEE capable */
53 if (!dev->phydev || !dp->pl)
54 return -ENODEV;