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