2
0

715-21-v6.5-net-phylink-provide-phylink_pcs_config-and-phylink_p.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From 796d709363135a6bd6a8ccc07b509c939e5b855f Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Tue, 23 May 2023 16:31:50 +0100
  4. Subject: [PATCH 19/21] net: phylink: provide phylink_pcs_config() and
  5. phylink_pcs_link_up()
  6. Add two helper functions for calling PCS methods. phylink_pcs_config()
  7. allows us to handle PCS configuration specifics in one location, rather
  8. than the two call sites. phylink_pcs_link_up() gives us consistency.
  9. Signed-off-by: Russell King (Oracle) <[email protected]>
  10. Link: https://lore.kernel.org/r/[email protected]
  11. Signed-off-by: Jakub Kicinski <[email protected]>
  12. ---
  13. drivers/net/phy/phylink.c | 53 ++++++++++++++++++++++++---------------
  14. 1 file changed, 33 insertions(+), 20 deletions(-)
  15. --- a/drivers/net/phy/phylink.c
  16. +++ b/drivers/net/phy/phylink.c
  17. @@ -991,6 +991,25 @@ static void phylink_resolve_an_pause(str
  18. }
  19. }
  20. +static int phylink_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
  21. + const struct phylink_link_state *state,
  22. + bool permit_pause_to_mac)
  23. +{
  24. + if (!pcs)
  25. + return 0;
  26. +
  27. + return pcs->ops->pcs_config(pcs, mode, state->interface,
  28. + state->advertising, permit_pause_to_mac);
  29. +}
  30. +
  31. +static void phylink_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
  32. + phy_interface_t interface, int speed,
  33. + int duplex)
  34. +{
  35. + if (pcs && pcs->ops->pcs_link_up)
  36. + pcs->ops->pcs_link_up(pcs, mode, interface, speed, duplex);
  37. +}
  38. +
  39. static void phylink_pcs_poll_stop(struct phylink *pl)
  40. {
  41. if (pl->cfg_link_an_mode == MLO_AN_INBAND)
  42. @@ -1074,18 +1093,15 @@ static void phylink_major_config(struct
  43. phylink_mac_config(pl, state);
  44. - if (pl->pcs) {
  45. - err = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode,
  46. - state->interface,
  47. - state->advertising,
  48. - !!(pl->link_config.pause &
  49. - MLO_PAUSE_AN));
  50. - if (err < 0)
  51. - phylink_err(pl, "pcs_config failed: %pe\n",
  52. - ERR_PTR(err));
  53. - if (err > 0)
  54. - restart = true;
  55. - }
  56. + err = phylink_pcs_config(pl->pcs, pl->cur_link_an_mode, state,
  57. + !!(pl->link_config.pause &
  58. + MLO_PAUSE_AN));
  59. + if (err < 0)
  60. + phylink_err(pl, "pcs_config failed: %pe\n",
  61. + ERR_PTR(err));
  62. + else if (err > 0)
  63. + restart = true;
  64. +
  65. if (restart)
  66. phylink_mac_pcs_an_restart(pl);
  67. @@ -1136,11 +1152,9 @@ static int phylink_change_inband_advert(
  68. * restart negotiation if the pcs_config() helper indicates that
  69. * the programmed advertisement has changed.
  70. */
  71. - ret = pl->pcs->ops->pcs_config(pl->pcs, pl->cur_link_an_mode,
  72. - pl->link_config.interface,
  73. - pl->link_config.advertising,
  74. - !!(pl->link_config.pause &
  75. - MLO_PAUSE_AN));
  76. + ret = phylink_pcs_config(pl->pcs, pl->cur_link_an_mode,
  77. + &pl->link_config,
  78. + !!(pl->link_config.pause & MLO_PAUSE_AN));
  79. if (ret < 0)
  80. return ret;
  81. @@ -1272,9 +1286,8 @@ static void phylink_link_up(struct phyli
  82. pl->cur_interface = link_state.interface;
  83. - if (pl->pcs && pl->pcs->ops->pcs_link_up)
  84. - pl->pcs->ops->pcs_link_up(pl->pcs, pl->cur_link_an_mode,
  85. - pl->cur_interface, speed, duplex);
  86. + phylink_pcs_link_up(pl->pcs, pl->cur_link_an_mode, pl->cur_interface,
  87. + speed, duplex);
  88. pl->mac_ops->mac_link_up(pl->config, pl->phydev, pl->cur_link_an_mode,
  89. pl->cur_interface, speed, duplex,