2
0

703-v4.20-net-ethernet-Add-helper-for-set_pauseparam-for-Asym-.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From ce825df56e0480a2cbb296e38976babafb57e503 Mon Sep 17 00:00:00 2001
  2. From: Andrew Lunn <[email protected]>
  3. Date: Wed, 12 Sep 2018 01:53:17 +0200
  4. Subject: [PATCH 601/660] net: ethernet: Add helper for set_pauseparam for Asym
  5. Pause
  6. ethtool can be used to enable/disable pause. Add a helper to configure
  7. the PHY when asym pause is supported.
  8. Signed-off-by: Andrew Lunn <[email protected]>
  9. Reviewed-by: Florian Fainelli <[email protected]>
  10. Signed-off-by: David S. Miller <[email protected]>
  11. ---
  12. drivers/net/phy/phy_device.c | 30 ++++++++++++++++++++++++++++++
  13. include/linux/phy.h | 1 +
  14. 2 files changed, 31 insertions(+)
  15. --- a/drivers/net/phy/phy_device.c
  16. +++ b/drivers/net/phy/phy_device.c
  17. @@ -1790,6 +1790,36 @@ void phy_support_asym_pause(struct phy_d
  18. }
  19. EXPORT_SYMBOL(phy_support_asym_pause);
  20. +/**
  21. + * phy_set_asym_pause - Configure Pause and Asym Pause
  22. + * @phydev: target phy_device struct
  23. + * @rx: Receiver Pause is supported
  24. + * @tx: Transmit Pause is supported
  25. + *
  26. + * Description: Configure advertised Pause support depending on if
  27. + * transmit and receiver pause is supported. If there has been a
  28. + * change in adverting, trigger a new autoneg. Generally called from
  29. + * the set_pauseparam .ndo.
  30. + */
  31. +void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx)
  32. +{
  33. + u16 oldadv = phydev->advertising;
  34. + u16 newadv = oldadv &= ~(SUPPORTED_Pause | SUPPORTED_Asym_Pause);
  35. +
  36. + if (rx)
  37. + newadv |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
  38. + if (tx)
  39. + newadv ^= SUPPORTED_Asym_Pause;
  40. +
  41. + if (oldadv != newadv) {
  42. + phydev->advertising = newadv;
  43. +
  44. + if (phydev->autoneg)
  45. + phy_start_aneg(phydev);
  46. + }
  47. +}
  48. +EXPORT_SYMBOL(phy_set_asym_pause);
  49. +
  50. static void of_set_phy_supported(struct phy_device *phydev)
  51. {
  52. struct device_node *node = phydev->mdio.dev.of_node;
  53. --- a/include/linux/phy.h
  54. +++ b/include/linux/phy.h
  55. @@ -1050,6 +1050,7 @@ int phy_start_interrupts(struct phy_devi
  56. void phy_print_status(struct phy_device *phydev);
  57. int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
  58. void phy_support_asym_pause(struct phy_device *phydev);
  59. +void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
  60. int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
  61. int (*run)(struct phy_device *));