738-net-phylink-move-phylink_pcs_neg_mode.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. From 5e5401d6612ef599ad45785b941eebda7effc90f Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Thu, 4 Jan 2024 09:47:36 +0000
  4. Subject: [PATCH] net: phylink: move phylink_pcs_neg_mode() into phylink.c
  5. Move phylink_pcs_neg_mode() from the header file into the .c file since
  6. nothing should be using it.
  7. Signed-off-by: Russell King (Oracle) <[email protected]>
  8. Reviewed-by: Andrew Lunn <[email protected]>
  9. Signed-off-by: David S. Miller <[email protected]>
  10. ---
  11. drivers/net/phy/phylink.c | 66 +++++++++++++++++++++++++++++++++++++++
  12. include/linux/phylink.h | 66 ---------------------------------------
  13. 2 files changed, 66 insertions(+), 66 deletions(-)
  14. --- a/drivers/net/phy/phylink.c
  15. +++ b/drivers/net/phy/phylink.c
  16. @@ -1150,6 +1150,72 @@ static void phylink_pcs_an_restart(struc
  17. pl->pcs->ops->pcs_an_restart(pl->pcs);
  18. }
  19. +/**
  20. + * phylink_pcs_neg_mode() - helper to determine PCS inband mode
  21. + * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
  22. + * @interface: interface mode to be used
  23. + * @advertising: adertisement ethtool link mode mask
  24. + *
  25. + * Determines the negotiation mode to be used by the PCS, and returns
  26. + * one of:
  27. + *
  28. + * - %PHYLINK_PCS_NEG_NONE: interface mode does not support inband
  29. + * - %PHYLINK_PCS_NEG_OUTBAND: an out of band mode (e.g. reading the PHY)
  30. + * will be used.
  31. + * - %PHYLINK_PCS_NEG_INBAND_DISABLED: inband mode selected but autoneg
  32. + * disabled
  33. + * - %PHYLINK_PCS_NEG_INBAND_ENABLED: inband mode selected and autoneg enabled
  34. + *
  35. + * Note: this is for cases where the PCS itself is involved in negotiation
  36. + * (e.g. Clause 37, SGMII and similar) not Clause 73.
  37. + */
  38. +static unsigned int phylink_pcs_neg_mode(unsigned int mode,
  39. + phy_interface_t interface,
  40. + const unsigned long *advertising)
  41. +{
  42. + unsigned int neg_mode;
  43. +
  44. + switch (interface) {
  45. + case PHY_INTERFACE_MODE_SGMII:
  46. + case PHY_INTERFACE_MODE_QSGMII:
  47. + case PHY_INTERFACE_MODE_QUSGMII:
  48. + case PHY_INTERFACE_MODE_USXGMII:
  49. + /* These protocols are designed for use with a PHY which
  50. + * communicates its negotiation result back to the MAC via
  51. + * inband communication. Note: there exist PHYs that run
  52. + * with SGMII but do not send the inband data.
  53. + */
  54. + if (!phylink_autoneg_inband(mode))
  55. + neg_mode = PHYLINK_PCS_NEG_OUTBAND;
  56. + else
  57. + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
  58. + break;
  59. +
  60. + case PHY_INTERFACE_MODE_1000BASEX:
  61. + case PHY_INTERFACE_MODE_2500BASEX:
  62. + /* 1000base-X is designed for use media-side for Fibre
  63. + * connections, and thus the Autoneg bit needs to be
  64. + * taken into account. We also do this for 2500base-X
  65. + * as well, but drivers may not support this, so may
  66. + * need to override this.
  67. + */
  68. + if (!phylink_autoneg_inband(mode))
  69. + neg_mode = PHYLINK_PCS_NEG_OUTBAND;
  70. + else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
  71. + advertising))
  72. + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
  73. + else
  74. + neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED;
  75. + break;
  76. +
  77. + default:
  78. + neg_mode = PHYLINK_PCS_NEG_NONE;
  79. + break;
  80. + }
  81. +
  82. + return neg_mode;
  83. +}
  84. +
  85. static void phylink_major_config(struct phylink *pl, bool restart,
  86. const struct phylink_link_state *state)
  87. {
  88. --- a/include/linux/phylink.h
  89. +++ b/include/linux/phylink.h
  90. @@ -99,72 +99,6 @@ static inline bool phylink_autoneg_inban
  91. }
  92. /**
  93. - * phylink_pcs_neg_mode() - helper to determine PCS inband mode
  94. - * @mode: one of %MLO_AN_FIXED, %MLO_AN_PHY, %MLO_AN_INBAND.
  95. - * @interface: interface mode to be used
  96. - * @advertising: adertisement ethtool link mode mask
  97. - *
  98. - * Determines the negotiation mode to be used by the PCS, and returns
  99. - * one of:
  100. - *
  101. - * - %PHYLINK_PCS_NEG_NONE: interface mode does not support inband
  102. - * - %PHYLINK_PCS_NEG_OUTBAND: an out of band mode (e.g. reading the PHY)
  103. - * will be used.
  104. - * - %PHYLINK_PCS_NEG_INBAND_DISABLED: inband mode selected but autoneg
  105. - * disabled
  106. - * - %PHYLINK_PCS_NEG_INBAND_ENABLED: inband mode selected and autoneg enabled
  107. - *
  108. - * Note: this is for cases where the PCS itself is involved in negotiation
  109. - * (e.g. Clause 37, SGMII and similar) not Clause 73.
  110. - */
  111. -static inline unsigned int phylink_pcs_neg_mode(unsigned int mode,
  112. - phy_interface_t interface,
  113. - const unsigned long *advertising)
  114. -{
  115. - unsigned int neg_mode;
  116. -
  117. - switch (interface) {
  118. - case PHY_INTERFACE_MODE_SGMII:
  119. - case PHY_INTERFACE_MODE_QSGMII:
  120. - case PHY_INTERFACE_MODE_QUSGMII:
  121. - case PHY_INTERFACE_MODE_USXGMII:
  122. - /* These protocols are designed for use with a PHY which
  123. - * communicates its negotiation result back to the MAC via
  124. - * inband communication. Note: there exist PHYs that run
  125. - * with SGMII but do not send the inband data.
  126. - */
  127. - if (!phylink_autoneg_inband(mode))
  128. - neg_mode = PHYLINK_PCS_NEG_OUTBAND;
  129. - else
  130. - neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
  131. - break;
  132. -
  133. - case PHY_INTERFACE_MODE_1000BASEX:
  134. - case PHY_INTERFACE_MODE_2500BASEX:
  135. - /* 1000base-X is designed for use media-side for Fibre
  136. - * connections, and thus the Autoneg bit needs to be
  137. - * taken into account. We also do this for 2500base-X
  138. - * as well, but drivers may not support this, so may
  139. - * need to override this.
  140. - */
  141. - if (!phylink_autoneg_inband(mode))
  142. - neg_mode = PHYLINK_PCS_NEG_OUTBAND;
  143. - else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
  144. - advertising))
  145. - neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED;
  146. - else
  147. - neg_mode = PHYLINK_PCS_NEG_INBAND_DISABLED;
  148. - break;
  149. -
  150. - default:
  151. - neg_mode = PHYLINK_PCS_NEG_NONE;
  152. - break;
  153. - }
  154. -
  155. - return neg_mode;
  156. -}
  157. -
  158. -/**
  159. * struct phylink_link_state - link state structure
  160. * @advertising: ethtool bitmask containing advertised link modes
  161. * @lp_advertising: ethtool bitmask containing link partner advertised link