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
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
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.
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>
18 drivers/net/dsa/mt7530.c | 28 ++++++++++------------------
19 1 file changed, 10 insertions(+), 18 deletions(-)
21 --- a/drivers/net/dsa/mt7530.c
22 +++ b/drivers/net/dsa/mt7530.c
23 @@ -2963,25 +2963,16 @@ static void mt753x_phylink_get_caps(stru
24 priv->info->mac_port_get_caps(ds, port, config);
28 -mt753x_phylink_validate(struct dsa_switch *ds, int port,
29 - unsigned long *supported,
30 - struct phylink_link_state *state)
32 - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
35 - caps = dsa_to_port(ds, port)->pl_config.mac_capabilities;
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)
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);
48 - if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
49 - !phy_interface_mode_is_8023z(state->interface))
50 - phylink_set(mask, Autoneg);
52 - linkmode_and(supported, supported, mask);
53 - linkmode_and(state->advertising, state->advertising, mask);
57 static void mt7530_pcs_get_state(struct phylink_pcs *pcs,
58 @@ -3083,12 +3074,14 @@ static void mt7530_pcs_an_restart(struct
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,
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 @@ -3180,7 +3173,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,