705-08-v5.19-net-dsa-mt7530-move-autoneg-handling-to-PCS-validati.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 2b0ee6768f3ac09072e5fd60b36580924e1cfa1c Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  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. Move the autoneg bit handling to the PCS validation, which allows us to
  10. get rid of mt753x_phylink_validate() and rely on the default
  11. phylink_generic_validate() implementation for the MAC side.
  12. Tested-by: Marek Behún <[email protected]>
  13. Signed-off-by: Russell King (Oracle) <[email protected]>
  14. Signed-off-by: Paolo Abeni <[email protected]>
  15. ---
  16. drivers/net/dsa/mt7530.c | 28 ++++++++++------------------
  17. 1 file changed, 10 insertions(+), 18 deletions(-)
  18. --- a/drivers/net/dsa/mt7530.c
  19. +++ b/drivers/net/dsa/mt7530.c
  20. @@ -3008,25 +3008,16 @@ static void mt753x_phylink_get_caps(stru
  21. priv->info->mac_port_get_caps(ds, port, config);
  22. }
  23. -static void
  24. -mt753x_phylink_validate(struct dsa_switch *ds, int port,
  25. - unsigned long *supported,
  26. - struct phylink_link_state *state)
  27. -{
  28. - __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
  29. - u32 caps;
  30. -
  31. - caps = dsa_to_port(ds, port)->pl_config.mac_capabilities;
  32. -
  33. - phylink_set_port_modes(mask);
  34. - phylink_get_linkmodes(mask, state->interface, caps);
  35. +static int mt753x_pcs_validate(struct phylink_pcs *pcs,
  36. + unsigned long *supported,
  37. + const struct phylink_link_state *state)
  38. +{
  39. + /* Autonegotiation is not supported in TRGMII nor 802.3z modes */
  40. + if (state->interface == PHY_INTERFACE_MODE_TRGMII ||
  41. + phy_interface_mode_is_8023z(state->interface))
  42. + phylink_clear(supported, Autoneg);
  43. - if (state->interface != PHY_INTERFACE_MODE_TRGMII &&
  44. - !phy_interface_mode_is_8023z(state->interface))
  45. - phylink_set(mask, Autoneg);
  46. -
  47. - linkmode_and(supported, supported, mask);
  48. - linkmode_and(state->advertising, state->advertising, mask);
  49. + return 0;
  50. }
  51. static void mt7530_pcs_get_state(struct phylink_pcs *pcs,
  52. @@ -3128,12 +3119,14 @@ static void mt7530_pcs_an_restart(struct
  53. }
  54. static const struct phylink_pcs_ops mt7530_pcs_ops = {
  55. + .pcs_validate = mt753x_pcs_validate,
  56. .pcs_get_state = mt7530_pcs_get_state,
  57. .pcs_config = mt753x_pcs_config,
  58. .pcs_an_restart = mt7530_pcs_an_restart,
  59. };
  60. static const struct phylink_pcs_ops mt7531_pcs_ops = {
  61. + .pcs_validate = mt753x_pcs_validate,
  62. .pcs_get_state = mt7531_pcs_get_state,
  63. .pcs_config = mt753x_pcs_config,
  64. .pcs_an_restart = mt7531_pcs_an_restart,
  65. @@ -3225,7 +3218,6 @@ static const struct dsa_switch_ops mt753
  66. .port_mirror_add = mt753x_port_mirror_add,
  67. .port_mirror_del = mt753x_port_mirror_del,
  68. .phylink_get_caps = mt753x_phylink_get_caps,
  69. - .phylink_validate = mt753x_phylink_validate,
  70. .phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs,
  71. .phylink_mac_config = mt753x_phylink_mac_config,
  72. .phylink_mac_link_down = mt753x_phylink_mac_link_down,