703-06-v5.18-net-dsa-add-support-for-phylink-mac_select_pcs.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From bde018222c6b084ac32933a9f933581dd83da18e Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Thu, 17 Feb 2022 18:30:35 +0000
  4. Subject: [PATCH] net: dsa: add support for phylink mac_select_pcs()
  5. Add DSA support for the phylink mac_select_pcs() method so DSA drivers
  6. can return provide phylink with the appropriate PCS for the PHY
  7. interface mode.
  8. Signed-off-by: Russell King (Oracle) <[email protected]>
  9. Signed-off-by: David S. Miller <[email protected]>
  10. ---
  11. include/net/dsa.h | 3 +++
  12. net/dsa/port.c | 15 +++++++++++++++
  13. 2 files changed, 18 insertions(+)
  14. --- a/include/net/dsa.h
  15. +++ b/include/net/dsa.h
  16. @@ -659,6 +659,9 @@ struct dsa_switch_ops {
  17. void (*phylink_validate)(struct dsa_switch *ds, int port,
  18. unsigned long *supported,
  19. struct phylink_link_state *state);
  20. + struct phylink_pcs *(*phylink_mac_select_pcs)(struct dsa_switch *ds,
  21. + int port,
  22. + phy_interface_t iface);
  23. int (*phylink_mac_link_state)(struct dsa_switch *ds, int port,
  24. struct phylink_link_state *state);
  25. void (*phylink_mac_config)(struct dsa_switch *ds, int port,
  26. --- a/net/dsa/port.c
  27. +++ b/net/dsa/port.c
  28. @@ -1028,6 +1028,20 @@ static void dsa_port_phylink_mac_pcs_get
  29. }
  30. }
  31. +static struct phylink_pcs *
  32. +dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
  33. + phy_interface_t interface)
  34. +{
  35. + struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
  36. + struct dsa_switch *ds = dp->ds;
  37. + struct phylink_pcs *pcs = NULL;
  38. +
  39. + if (ds->ops->phylink_mac_select_pcs)
  40. + pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);
  41. +
  42. + return pcs;
  43. +}
  44. +
  45. static void dsa_port_phylink_mac_config(struct phylink_config *config,
  46. unsigned int mode,
  47. const struct phylink_link_state *state)
  48. @@ -1094,6 +1108,7 @@ static void dsa_port_phylink_mac_link_up
  49. static const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
  50. .validate = dsa_port_phylink_validate,
  51. + .mac_select_pcs = dsa_port_phylink_mac_select_pcs,
  52. .mac_pcs_get_state = dsa_port_phylink_mac_pcs_get_state,
  53. .mac_config = dsa_port_phylink_mac_config,
  54. .mac_an_restart = dsa_port_phylink_mac_an_restart,