700-net-phylink-add-phylink_get_link_timer_ns-helper.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From 9c5a170677c3c8facc83e931a57f4c99c0511ae0 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Thu, 27 Oct 2022 14:10:37 +0100
  4. Subject: [PATCH] net: phylink: add phylink_get_link_timer_ns() helper
  5. Add a helper to convert the PHY interface mode to the required link
  6. timer setting as stated by the appropriate standard. Inappropriate
  7. interface modes return an error.
  8. Signed-off-by: Russell King (Oracle) <[email protected]>
  9. Signed-off-by: Jakub Kicinski <[email protected]>
  10. ---
  11. include/linux/phylink.h | 24 ++++++++++++++++++++++++
  12. 1 file changed, 24 insertions(+)
  13. --- a/include/linux/phylink.h
  14. +++ b/include/linux/phylink.h
  15. @@ -614,6 +614,30 @@ int phylink_speed_up(struct phylink *pl)
  16. void phylink_set_port_modes(unsigned long *bits);
  17. +/**
  18. + * phylink_get_link_timer_ns - return the PCS link timer value
  19. + * @interface: link &typedef phy_interface_t mode
  20. + *
  21. + * Return the PCS link timer setting in nanoseconds for the PHY @interface
  22. + * mode, or -EINVAL if not appropriate.
  23. + */
  24. +static inline int phylink_get_link_timer_ns(phy_interface_t interface)
  25. +{
  26. + switch (interface) {
  27. + case PHY_INTERFACE_MODE_SGMII:
  28. + case PHY_INTERFACE_MODE_QSGMII:
  29. + case PHY_INTERFACE_MODE_USXGMII:
  30. + return 1600000;
  31. +
  32. + case PHY_INTERFACE_MODE_1000BASEX:
  33. + case PHY_INTERFACE_MODE_2500BASEX:
  34. + return 10000000;
  35. +
  36. + default:
  37. + return -EINVAL;
  38. + }
  39. +}
  40. +
  41. void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
  42. u16 bmsr, u16 lpa);
  43. void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,