From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
maxime.chevallier@bootlin.com, Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH net-next 11/12] net: ethernet: Add helper for set_pauseparam for Pause
Date: Sun, 2 Sep 2018 19:06:40 +0200 [thread overview]
Message-ID: <1535908001-18593-12-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1535908001-18593-1-git-send-email-andrew@lunn.ch>
ethtool can be used to enable/disable pause. Add a helper to configure
the PHY when Pause is supported.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 6 +-----
drivers/net/ethernet/freescale/fec_main.c | 8 +-------
drivers/net/phy/phy_device.c | 21 ++++++++++++++++++++
include/linux/phy.h | 1 +
4 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index c55b49b82690..e297972c63cf 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -892,11 +892,7 @@ static int bcm_enet_open(struct net_device *dev)
/* mask with MAC supported features */
phy_support_pause(phydev);
phy_set_max_speed(phydev, SPEED_100);
-
- if (priv->pause_auto && priv->pause_rx && priv->pause_tx)
- phydev->advertising |= SUPPORTED_Pause;
- else
- phydev->advertising &= ~SUPPORTED_Pause;
+ phy_set_pause(phydev, priv->pause_rx, priv->pause_auto);
phy_attached_info(phydev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 043b8c76821e..239eeac3d7ce 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2229,13 +2229,7 @@ static int fec_enet_set_pauseparam(struct net_device *ndev,
fep->pause_flag |= pause->rx_pause ? FEC_PAUSE_FLAG_ENABLE : 0;
fep->pause_flag |= pause->autoneg ? FEC_PAUSE_FLAG_AUTONEG : 0;
- if (pause->rx_pause || pause->autoneg) {
- ndev->phydev->supported |= ADVERTISED_Pause;
- ndev->phydev->advertising |= ADVERTISED_Pause;
- } else {
- ndev->phydev->supported &= ~ADVERTISED_Pause;
- ndev->phydev->advertising &= ~ADVERTISED_Pause;
- }
+ phy_set_pause(ndev->phydev, pause->rx_pause, pause->autoneg);
if (pause->autoneg) {
if (netif_running(ndev))
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bcdcd4a42d82..3078792b900f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1810,6 +1810,27 @@ void phy_support_asym_pause(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_support_asym_pause);
+/**
+ * phy_set_pause - Configure Pause
+ * @phydev: target phy_device struct
+ * @rx: Receiver Pause is supported
+ * @autoneg: Auto neg should be used
+ *
+ * Description: Configure advertised Pause support depending on if
+ * receiver pause and pause auto neg is supported. Generally called
+ * from the set_pauseparam .ndo.
+ */
+void phy_set_pause(struct phy_device *phydev, bool rx, bool autoneg)
+{
+ phydev->supported &= ~SUPPORTED_Pause;
+
+ if (rx || autoneg)
+ phydev->supported |= SUPPORTED_Pause;
+
+ phydev->advertising = phydev->supported;
+}
+EXPORT_SYMBOL(phy_set_pause);
+
/**
* phy_set_asym_pause - Configure Pause and Asym Pause
* @phydev: target phy_device struct
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f767a8f22856..205fb966d686 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1052,6 +1052,7 @@ int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode);
void phy_support_pause(struct phy_device *phydev);
void phy_support_asym_pause(struct phy_device *phydev);
+void phy_set_pause(struct phy_device *phydev, bool rx, bool autoneg);
void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
--
2.19.0.rc1
next prev parent reply other threads:[~2018-09-02 21:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 17:06 [PATCH net-next 00/12] Preparing for phylib limkmodes Andrew Lunn
2018-09-02 17:06 ` [PATCH net-next 01/12] net: phy: ste10Xp: Remove wrong SUPPORTED_Pause Andrew Lunn
2018-09-03 17:53 ` Florian Fainelli
2018-09-04 1:20 ` Andrew Lunn
2018-09-02 17:06 ` [PATCH net-next 02/12] net: phy: et1011c: Remove incorrect missing 1000 Half Andrew Lunn
2018-09-03 17:46 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 03/12] net: phy: bcm63xx: Allow to be built with COMPILE_TEST Andrew Lunn
2018-09-03 17:28 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 04/12] net: ethernet: Use phy_set_max_speed() to limit advertised speed Andrew Lunn
2018-09-03 17:31 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 05/12] net: ethernet: genet: Fix speed selection Andrew Lunn
2018-09-03 17:32 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 06/12] net: ethernet: Fix up drivers masking pause support Andrew Lunn
2018-09-03 17:33 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 07/12] net: ethernet: Add helper to remove a supported link mode Andrew Lunn
2018-09-03 17:35 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 08/12] net: ethernet: Add helper for MACs which support asym pause Andrew Lunn
2018-09-03 17:38 ` Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 09/12] net: ethernet: Add helper for MACs which support pause Andrew Lunn
2018-09-03 17:39 ` Florian Fainelli
2018-09-03 19:54 ` Andrew Lunn
2018-09-02 17:06 ` [PATCH net-next 10/12] net: ethernet: Add helper for set_pauseparam for Asym Pause Andrew Lunn
2018-09-03 17:49 ` Florian Fainelli
2018-09-03 19:58 ` Andrew Lunn
2018-09-03 22:30 ` Florian Fainelli
2018-09-02 17:06 ` Andrew Lunn [this message]
2018-09-03 17:49 ` [PATCH net-next 11/12] net: ethernet: Add helper for set_pauseparam for Pause Florian Fainelli
2018-09-02 17:06 ` [PATCH net-next 12/12] net: ethernet: Add helper to determine if pause configuration is supported Andrew Lunn
2018-09-03 17:52 ` Florian Fainelli
2018-09-04 2:44 ` [PATCH net-next 00/12] Preparing for phylib limkmodes David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535908001-18593-12-git-send-email-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).