715-20-v6.5-net-phylink-add-function-to-resolve-clause-73-negoti.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From aa8b6bd2b1f235b262bd27f317a0516f196c2c6a Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Tue, 23 May 2023 11:15:58 +0100
  4. Subject: [PATCH 18/21] net: phylink: add function to resolve clause 73
  5. negotiation
  6. Add a function to resolve clause 73 negotiation according to the
  7. priority resolution function described in clause 73.3.6.
  8. Signed-off-by: Russell King (Oracle) <[email protected]>
  9. Reviewed-by: Andrew Lunn <[email protected]>
  10. Signed-off-by: Jakub Kicinski <[email protected]>
  11. ---
  12. drivers/net/phy/phylink.c | 39 +++++++++++++++++++++++++++++++++++++++
  13. include/linux/phylink.h | 2 ++
  14. 2 files changed, 41 insertions(+)
  15. --- a/drivers/net/phy/phylink.c
  16. +++ b/drivers/net/phy/phylink.c
  17. @@ -3212,6 +3212,45 @@ static const struct sfp_upstream_ops sfp
  18. /* Helpers for MAC drivers */
  19. +static struct {
  20. + int bit;
  21. + int speed;
  22. +} phylink_c73_priority_resolution[] = {
  23. + { ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT, SPEED_100000 },
  24. + { ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT, SPEED_100000 },
  25. + /* 100GBASE-KP4 and 100GBASE-CR10 not supported */
  26. + { ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT, SPEED_40000 },
  27. + { ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT, SPEED_40000 },
  28. + { ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, SPEED_10000 },
  29. + { ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, SPEED_10000 },
  30. + /* 5GBASE-KR not supported */
  31. + { ETHTOOL_LINK_MODE_2500baseX_Full_BIT, SPEED_2500 },
  32. + { ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, SPEED_1000 },
  33. +};
  34. +
  35. +void phylink_resolve_c73(struct phylink_link_state *state)
  36. +{
  37. + int i;
  38. +
  39. + for (i = 0; i < ARRAY_SIZE(phylink_c73_priority_resolution); i++) {
  40. + int bit = phylink_c73_priority_resolution[i].bit;
  41. + if (linkmode_test_bit(bit, state->advertising) &&
  42. + linkmode_test_bit(bit, state->lp_advertising))
  43. + break;
  44. + }
  45. +
  46. + if (i < ARRAY_SIZE(phylink_c73_priority_resolution)) {
  47. + state->speed = phylink_c73_priority_resolution[i].speed;
  48. + state->duplex = DUPLEX_FULL;
  49. + } else {
  50. + /* negotiation failure */
  51. + state->link = false;
  52. + }
  53. +
  54. + phylink_resolve_an_pause(state);
  55. +}
  56. +EXPORT_SYMBOL_GPL(phylink_resolve_c73);
  57. +
  58. static void phylink_decode_c37_word(struct phylink_link_state *state,
  59. uint16_t config_reg, int speed)
  60. {
  61. --- a/include/linux/phylink.h
  62. +++ b/include/linux/phylink.h
  63. @@ -656,6 +656,8 @@ int phylink_mii_c22_pcs_config(struct md
  64. const unsigned long *advertising);
  65. void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
  66. +void phylink_resolve_c73(struct phylink_link_state *state);
  67. +
  68. void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
  69. struct phylink_link_state *state);