6e406ace0d8e5483da93b4f47641ea7db35a32e3
[openwrt/staging/thess.git] /
1 From 2b0ee6768f3ac09072e5fd60b36580924e1cfa1c Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Mon, 11 Apr 2022 10:46:32 +0100
4 Subject: [PATCH 08/13] net: dsa: mt7530: move autoneg handling to PCS
5 validation
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Move the autoneg bit handling to the PCS validation, which allows us to
11 get rid of mt753x_phylink_validate() and rely on the default
12 phylink_generic_validate() implementation for the MAC side.
13
14 Tested-by: Marek BehĂșn <kabel@kernel.org>
15 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
16 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
17 ---
18 drivers/net/dsa/mt7530.c | 28 ++++++++++------------------
19 1 file changed, 10 insertions(+), 18 deletions(-)
20
21 --- a/drivers/net/dsa/mt7530.c
22 +++ b/drivers/net/dsa/mt7530.c
23 @@ -3196,25 +3196,16 @@ static void mt753x_phylink_get_caps(stru
24 priv->info->mac_port_get_caps(ds, port, config);
25 }
26
27 -static void
28 -mt753x_phylink_validate(struct dsa_switch *ds, int port,
29 - unsigned long *supported,
30 - struct phylink_link_state *state)
31 -{
32 - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
33 - u32 caps;
34 -
35 - caps = dsa_to_port(ds, port)->pl_config.mac_capabilities;
36 -
37 - phylink_set_port_modes(mask);
38 - phylink_get_linkmodes(mask, state->interface, caps);
39 +static int mt753x_pcs_validate(struct phylink_pcs *pcs,
40 + unsigned long *supported,
41 + const struct phylink_link_state *state)
42 +{
43 + /* Autonegotiation is not supported in TRGMII nor 802.3z modes */
44 + if (state->interface == PHY_INTERFACE_MODE_TRGMII ||
45 + phy_interface_mode_is_8023z(state->interface))
46 + phylink_clear(supported, Autoneg);
47
48 - if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
49 - !phy_interface_mode_is_8023z(state->interface))
50 - phylink_set(mask, Autoneg);
51 -
52 - linkmode_and(supported, supported, mask);
53 - linkmode_and(state->advertising, state->advertising, mask);
54 + return 0;
55 }
56
57 static void mt7530_pcs_get_state(struct phylink_pcs *pcs,
58 @@ -3316,12 +3307,14 @@ static void mt7530_pcs_an_restart(struct
59 }
60
61 static const struct phylink_pcs_ops mt7530_pcs_ops = {
62 + .pcs_validate = mt753x_pcs_validate,
63 .pcs_get_state = mt7530_pcs_get_state,
64 .pcs_config = mt753x_pcs_config,
65 .pcs_an_restart = mt7530_pcs_an_restart,
66 };
67
68 static const struct phylink_pcs_ops mt7531_pcs_ops = {
69 + .pcs_validate = mt753x_pcs_validate,
70 .pcs_get_state = mt7531_pcs_get_state,
71 .pcs_config = mt753x_pcs_config,
72 .pcs_an_restart = mt7531_pcs_an_restart,
73 @@ -3414,7 +3407,6 @@ static const struct dsa_switch_ops mt753
74 .port_mirror_add = mt753x_port_mirror_add,
75 .port_mirror_del = mt753x_port_mirror_del,
76 .phylink_get_caps = mt753x_phylink_get_caps,
77 - .phylink_validate = mt753x_phylink_validate,
78 .phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs,
79 .phylink_mac_config = mt753x_phylink_mac_config,
80 .phylink_mac_link_down = mt753x_phylink_mac_link_down,