netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause
@ 2024-05-29 13:59 Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 1/3] net: ethernet: cortina: Rename adjust link callback Linus Walleij
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Linus Walleij @ 2024-05-29 13:59 UTC (permalink / raw)
  To: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn
  Cc: netdev, Linus Walleij

This patch series switches the Cortina Gemini ethernet
driver to use phylib to set up RX and TX pause for the
PHY.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v4:
- Drop the register setting in .set_pauseparam(), just call
  phylib and let .adjust_link() handle this.
- Link to v3: https://lore.kernel.org/r/20240513-gemini-ethernet-fix-tso-v3-0-b442540cc140@linaro.org

Changes in v3:
- Do the pause setting unconditionally in the full duplex
  case in adjust_link just like the code used to be,
  phydev->autoneg should not influence this.
- Bail out of .set_pauseparam() if pparam->autoneg is not
  true.
- Link to v2: https://lore.kernel.org/r/20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org

Changes in v2:
- Add a new patch to rename the gmac_adjust_link callback to
  a recognized name.
- Add a new patch to make the driver use the autonegitiated
  RX and TX pause settings from phylib.
- Rewrite the set_pauseparam() patch to use the existing
  gmac_set_flow_control() function.
- Add a call to phy_set_asym_pause() in the set_pauseparam
  callback, so the phylib is informed of the new TX/RX setting.
- Link to v1: https://lore.kernel.org/r/20240509-gemini-ethernet-fix-tso-v1-0-10cd07b54d1c@linaro.org

---
Linus Walleij (3):
      net: ethernet: cortina: Rename adjust link callback
      net: ethernet: cortina: Use negotiated TX/RX pause
      net: ethernet: cortina: Implement .set_pauseparam()

 drivers/net/ethernet/cortina/gemini.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240527-gemini-phylib-fixes-c2c0460be20b

Best regards,
-- 
Linus Walleij <linus.walleij@linaro.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next v4 1/3] net: ethernet: cortina: Rename adjust link callback
  2024-05-29 13:59 [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause Linus Walleij
@ 2024-05-29 14:00 ` Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 2/3] net: ethernet: cortina: Use negotiated TX/RX pause Linus Walleij
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2024-05-29 14:00 UTC (permalink / raw)
  To: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn
  Cc: netdev, Linus Walleij

The callback passed to of_phy_get_and_connect() in the
Cortina Gemini driver is called "gmac_speed_set" which is
archaic, rename it to "gmac_adjust_link" following the
pattern of most other drivers.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/cortina/gemini.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index 5f0c9e1771db..ff3aeee15e5b 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -287,7 +287,7 @@ static void gmac_set_flow_control(struct net_device *netdev, bool tx, bool rx)
 	spin_unlock_irqrestore(&port->config_lock, flags);
 }
 
-static void gmac_speed_set(struct net_device *netdev)
+static void gmac_adjust_link(struct net_device *netdev)
 {
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
 	struct phy_device *phydev = netdev->phydev;
@@ -366,7 +366,7 @@ static int gmac_setup_phy(struct net_device *netdev)
 
 	phy = of_phy_get_and_connect(netdev,
 				     dev->of_node,
-				     gmac_speed_set);
+				     gmac_adjust_link);
 	if (!phy)
 		return -ENODEV;
 	netdev->phydev = phy;

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v4 2/3] net: ethernet: cortina: Use negotiated TX/RX pause
  2024-05-29 13:59 [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 1/3] net: ethernet: cortina: Rename adjust link callback Linus Walleij
@ 2024-05-29 14:00 ` Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam() Linus Walleij
  2024-06-01 23:20 ` [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2024-05-29 14:00 UTC (permalink / raw)
  To: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn
  Cc: netdev, Linus Walleij

Instead of directly poking into registers of the PHY, use
the existing function to query phylib about this directly.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/cortina/gemini.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index ff3aeee15e5b..b33f9798471e 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -292,8 +292,8 @@ static void gmac_adjust_link(struct net_device *netdev)
 	struct gemini_ethernet_port *port = netdev_priv(netdev);
 	struct phy_device *phydev = netdev->phydev;
 	union gmac_status status, old_status;
-	int pause_tx = 0;
-	int pause_rx = 0;
+	bool pause_tx = false;
+	bool pause_rx = false;
 
 	status.bits32 = readl(port->gmac_base + GMAC_STATUS);
 	old_status.bits32 = status.bits32;
@@ -328,14 +328,9 @@ static void gmac_adjust_link(struct net_device *netdev)
 	}
 
 	if (phydev->duplex == DUPLEX_FULL) {
-		u16 lcladv = phy_read(phydev, MII_ADVERTISE);
-		u16 rmtadv = phy_read(phydev, MII_LPA);
-		u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
-
-		if (cap & FLOW_CTRL_RX)
-			pause_rx = 1;
-		if (cap & FLOW_CTRL_TX)
-			pause_tx = 1;
+		phy_get_pause(phydev, &pause_tx, &pause_rx);
+		netdev_dbg(netdev, "set negotiated pause params pause TX = %s, pause RX = %s\n",
+			   pause_tx ? "ON" : "OFF", pause_rx ? "ON" : "OFF");
 	}
 
 	gmac_set_flow_control(netdev, pause_tx, pause_rx);

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam()
  2024-05-29 13:59 [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 1/3] net: ethernet: cortina: Rename adjust link callback Linus Walleij
  2024-05-29 14:00 ` [PATCH net-next v4 2/3] net: ethernet: cortina: Use negotiated TX/RX pause Linus Walleij
@ 2024-05-29 14:00 ` Linus Walleij
  2024-05-29 14:44   ` Andrew Lunn
  2024-06-01 23:20 ` [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause patchwork-bot+netdevbpf
  3 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2024-05-29 14:00 UTC (permalink / raw)
  To: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn
  Cc: netdev, Linus Walleij

The Cortina Gemini ethernet can very well set up TX or RX
pausing, so add this functionality to the driver in a
.set_pauseparam() callback. Essentially just call down to
phylib and let phylib deal with this, .adjust_link()
will respect the setting from phylib.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/cortina/gemini.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index b33f9798471e..318c521b135b 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -2111,6 +2111,19 @@ static void gmac_get_pauseparam(struct net_device *netdev,
 	pparam->autoneg = true;
 }
 
+static int gmac_set_pauseparam(struct net_device *netdev,
+			       struct ethtool_pauseparam *pparam)
+{
+	struct phy_device *phydev = netdev->phydev;
+
+	if (!pparam->autoneg)
+		return -EOPNOTSUPP;
+
+	phy_set_asym_pause(phydev, pparam->rx_pause, pparam->tx_pause);
+
+	return 0;
+}
+
 static void gmac_get_ringparam(struct net_device *netdev,
 			       struct ethtool_ringparam *rp,
 			       struct kernel_ethtool_ringparam *kernel_rp,
@@ -2231,6 +2244,7 @@ static const struct ethtool_ops gmac_351x_ethtool_ops = {
 	.set_link_ksettings = gmac_set_ksettings,
 	.nway_reset	= gmac_nway_reset,
 	.get_pauseparam	= gmac_get_pauseparam,
+	.set_pauseparam = gmac_set_pauseparam,
 	.get_ringparam	= gmac_get_ringparam,
 	.set_ringparam	= gmac_set_ringparam,
 	.get_coalesce	= gmac_get_coalesce,

-- 
2.45.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam()
  2024-05-29 14:00 ` [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam() Linus Walleij
@ 2024-05-29 14:44   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-05-29 14:44 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Hans Ulli Kroll, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev

On Wed, May 29, 2024 at 04:00:02PM +0200, Linus Walleij wrote:
> The Cortina Gemini ethernet can very well set up TX or RX
> pausing, so add this functionality to the driver in a
> .set_pauseparam() callback. Essentially just call down to
> phylib and let phylib deal with this, .adjust_link()
> will respect the setting from phylib.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause
  2024-05-29 13:59 [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause Linus Walleij
                   ` (2 preceding siblings ...)
  2024-05-29 14:00 ` [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam() Linus Walleij
@ 2024-06-01 23:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-01 23:20 UTC (permalink / raw)
  To: Linus Walleij; +Cc: ulli.kroll, davem, edumazet, kuba, pabeni, andrew, netdev

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 29 May 2024 15:59:59 +0200 you wrote:
> This patch series switches the Cortina Gemini ethernet
> driver to use phylib to set up RX and TX pause for the
> PHY.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Changes in v4:
> - Drop the register setting in .set_pauseparam(), just call
>   phylib and let .adjust_link() handle this.
> - Link to v3: https://lore.kernel.org/r/20240513-gemini-ethernet-fix-tso-v3-0-b442540cc140@linaro.org
> 
> [...]

Here is the summary with links:
  - [net-next,v4,1/3] net: ethernet: cortina: Rename adjust link callback
    https://git.kernel.org/netdev/net-next/c/a967d3cee86e
  - [net-next,v4,2/3] net: ethernet: cortina: Use negotiated TX/RX pause
    https://git.kernel.org/netdev/net-next/c/15c22101db71
  - [net-next,v4,3/3] net: ethernet: cortina: Implement .set_pauseparam()
    https://git.kernel.org/netdev/net-next/c/dbdb0918da67

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-01 23:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 13:59 [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause Linus Walleij
2024-05-29 14:00 ` [PATCH net-next v4 1/3] net: ethernet: cortina: Rename adjust link callback Linus Walleij
2024-05-29 14:00 ` [PATCH net-next v4 2/3] net: ethernet: cortina: Use negotiated TX/RX pause Linus Walleij
2024-05-29 14:00 ` [PATCH net-next v4 3/3] net: ethernet: cortina: Implement .set_pauseparam() Linus Walleij
2024-05-29 14:44   ` Andrew Lunn
2024-06-01 23:20 ` [PATCH net-next v4 0/3] net: ethernet: cortina: Use phylib for RX and TX pause patchwork-bot+netdevbpf

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).