703-03-v5.16-net-dsa-populate-supported_interfaces-member.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From c07c6e8eb4b38bae921f9e2f108d1e7f8e14226e Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <[email protected]>
  3. Date: Thu, 28 Oct 2021 18:00:14 +0100
  4. Subject: [PATCH] net: dsa: populate supported_interfaces member
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Add a new DSA switch operation, phylink_get_interfaces, which should
  9. fill in which PHY_INTERFACE_MODE_* are supported by given port.
  10. Use this before phylink_create() to fill phylinks supported_interfaces
  11. member, allowing phylink to determine which PHY_INTERFACE_MODEs are
  12. supported.
  13. Signed-off-by: Marek Behún <[email protected]>
  14. [tweaked patch and description to add more complete support -- rmk]
  15. Signed-off-by: Russell King <[email protected]>
  16. Signed-off-by: Russell King (Oracle) <[email protected]>
  17. Signed-off-by: David S. Miller <[email protected]>
  18. ---
  19. include/net/dsa.h | 2 ++
  20. net/dsa/port.c | 4 ++++
  21. net/dsa/slave.c | 4 ++++
  22. 3 files changed, 10 insertions(+)
  23. --- a/include/net/dsa.h
  24. +++ b/include/net/dsa.h
  25. @@ -654,6 +654,8 @@ struct dsa_switch_ops {
  26. /*
  27. * PHYLINK integration
  28. */
  29. + void (*phylink_get_interfaces)(struct dsa_switch *ds, int port,
  30. + unsigned long *supported_interfaces);
  31. void (*phylink_validate)(struct dsa_switch *ds, int port,
  32. unsigned long *supported,
  33. struct phylink_link_state *state);
  34. --- a/net/dsa/port.c
  35. +++ b/net/dsa/port.c
  36. @@ -1188,6 +1188,10 @@ static int dsa_port_phylink_register(str
  37. dp->pl_config.type = PHYLINK_DEV;
  38. dp->pl_config.pcs_poll = ds->pcs_poll;
  39. + if (ds->ops->phylink_get_interfaces)
  40. + ds->ops->phylink_get_interfaces(ds, dp->index,
  41. + dp->pl_config.supported_interfaces);
  42. +
  43. dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn),
  44. mode, &dsa_port_phylink_mac_ops);
  45. if (IS_ERR(dp->pl)) {
  46. --- a/net/dsa/slave.c
  47. +++ b/net/dsa/slave.c
  48. @@ -1837,6 +1837,10 @@ static int dsa_slave_phy_setup(struct ne
  49. dp->pl_config.poll_fixed_state = true;
  50. }
  51. + if (ds->ops->phylink_get_interfaces)
  52. + ds->ops->phylink_get_interfaces(ds, dp->index,
  53. + dp->pl_config.supported_interfaces);
  54. +
  55. dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode,
  56. &dsa_port_phylink_mac_ops);
  57. if (IS_ERR(dp->pl)) {