From: Doug Berger <opendmb@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Doug Berger <opendmb@gmail.com>
Subject: [PATCH net-next 3/4] net: ethernet: introduce phy_set_pause
Date: Mon, 11 May 2020 17:24:09 -0700 [thread overview]
Message-ID: <1589243050-18217-4-git-send-email-opendmb@gmail.com> (raw)
In-Reply-To: <1589243050-18217-1-git-send-email-opendmb@gmail.com>
This commit introduces the phy_set_pause function to the phylib as
a helper to support the set_pauseparam ethtool method.
It is hoped that the new behavior introduced by this function will
be widely embraced and the phy_set_sym_pause and phy_set_asym_pause
functions can be deprecated. Those functions are retained for all
existing users and for any desenting opinions on my interpretation
of the functionality.
Signed-off-by: Doug Berger <opendmb@gmail.com>
---
drivers/net/phy/phy_device.c | 31 +++++++++++++++++++++++++++++++
include/linux/phy.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 48ab9efa0166..e6dafb3c3e5f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2614,6 +2614,37 @@ void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx)
EXPORT_SYMBOL(phy_set_asym_pause);
/**
+ * phy_set_pause - Configure Pause and Asym Pause with autoneg
+ * @phydev: target phy_device struct
+ * @rx: Receiver Pause is supported
+ * @tx: Transmit 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 ethtool_ops.
+ *
+ * Note: Since pause is really a MAC level function it should be
+ * notified via adjust_link to update its pause functions.
+ */
+void phy_set_pause(struct phy_device *phydev, bool rx, bool tx, bool autoneg)
+{
+ linkmode_set_pause(phydev->advertising, tx, rx, autoneg);
+
+ /* Reset the state of an already running link to force a new
+ * link up event when advertising doesn't change or when PHY
+ * autoneg is disabled.
+ */
+ mutex_lock(&phydev->lock);
+ if (phydev->state == PHY_RUNNING)
+ phydev->state = PHY_UP;
+ mutex_unlock(&phydev->lock);
+
+ phy_start_aneg(phydev);
+}
+EXPORT_SYMBOL(phy_set_pause);
+
+/**
* phy_validate_pause - Test if the PHY/MAC support the pause configuration
* @phydev: phy_device struct
* @pp: requested pause configuration
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 5d8ff5428010..71e484424e68 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1403,6 +1403,7 @@ void phy_support_asym_pause(struct phy_device *phydev);
void phy_set_sym_pause(struct phy_device *phydev, bool rx, bool tx,
bool autoneg);
void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx);
+void phy_set_pause(struct phy_device *phydev, bool rx, bool tx, bool autoneg);
bool phy_validate_pause(struct phy_device *phydev,
struct ethtool_pauseparam *pp);
void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause);
--
2.7.4
next prev parent reply other threads:[~2020-05-12 0:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 0:24 [PATCH net-next 0/4] Extend phylib implementation of pause support Doug Berger
2020-05-12 0:24 ` [PATCH net-next 1/4] net: ethernet: validate pause autoneg setting Doug Berger
2020-05-12 0:47 ` Andrew Lunn
2020-05-12 18:31 ` Doug Berger
2020-05-12 18:37 ` Andrew Lunn
2020-05-12 18:55 ` Russell King - ARM Linux admin
2020-05-13 3:48 ` Doug Berger
2020-05-13 5:34 ` Russell King - ARM Linux admin
2020-05-13 9:20 ` Russell King - ARM Linux admin
2020-05-13 13:49 ` Andrew Lunn
2020-05-13 14:59 ` Michal Kubecek
2020-05-13 17:14 ` Russell King - ARM Linux admin
2020-05-13 22:09 ` Doug Berger
2020-05-13 21:31 ` Doug Berger
2020-05-13 21:27 ` Doug Berger
2020-05-12 19:08 ` Michal Kubecek
2020-05-13 2:37 ` Doug Berger
2020-05-12 3:16 ` Florian Fainelli
2020-05-12 0:24 ` [PATCH net-next 2/4] net: add autoneg parameter to linkmode_set_pause Doug Berger
2020-05-12 0:24 ` Doug Berger [this message]
2020-05-12 0:51 ` [PATCH net-next 3/4] net: ethernet: introduce phy_set_pause Andrew Lunn
2020-05-12 18:46 ` Doug Berger
2020-05-12 3:22 ` Florian Fainelli
2020-05-13 9:42 ` Russell King - ARM Linux admin
2020-05-13 21:39 ` Doug Berger
2020-05-12 0:24 ` [PATCH net-next 4/4] net: bcmgenet: add support for ethtool flow control Doug Berger
2020-05-12 3:24 ` Florian Fainelli
2020-05-13 9:52 ` Russell King - ARM Linux admin
2020-05-13 22:00 ` Doug Berger
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=1589243050-18217-4-git-send-email-opendmb@gmail.com \
--to=opendmb@gmail.com \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--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).