netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg
@ 2023-06-09  8:03 Maxime Chevallier
  2023-06-09  8:03 ` [PATCH net v2 1/2] net: phylink: report correct max speed for QUSGMII Maxime Chevallier
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Maxime Chevallier @ 2023-06-09  8:03 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King,
	linux-arm-kernel, Horatiu.Vultur, Allan.Nielsen, UNGLinuxDriver,
	Vladimir Oltean, Simon Horman

This is the second version of a small changeset for QUSGMII support,
fixing inconsistencies in reported max speed and control word parsing.

As reported here [1], there are some inconsistencies for the Q-USGMII
mode speeds and configuration. The first patch in this fixup series
makes so that we correctly report the max speed of 1Gbps for this mode.

The second patch uses a dedicated helper to decode the control word.
This is necessary as although USGMII control words are close to USXGMII,
they don't support the same speeds.

Thanks,

Maxime

[1] : https://lore.kernel.org/netdev/ZHnd+6FUO77XFJvQ@shell.armlinux.org.uk/

V1->V2: Fix decoding logic for usgmii control word, as per Russell's review

Maxime Chevallier (2):
  net: phylink: report correct max speed for QUSGMII
  net: phylink: use a dedicated helper to parse usgmii control word

 drivers/net/phy/phylink.c | 41 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

-- 
2.40.1


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

* [PATCH net v2 1/2] net: phylink: report correct max speed for QUSGMII
  2023-06-09  8:03 [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Maxime Chevallier
@ 2023-06-09  8:03 ` Maxime Chevallier
  2023-06-09  8:03 ` [PATCH net v2 2/2] net: phylink: use a dedicated helper to parse usgmii control word Maxime Chevallier
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2023-06-09  8:03 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King,
	linux-arm-kernel, Horatiu.Vultur, Allan.Nielsen, UNGLinuxDriver,
	Vladimir Oltean, Simon Horman

Q-USGMII is the quad port version of USGMII, and supports a max speed of
1Gbps on each line. Make so that phylink_interface_max_speed() reports
this information correctly.

Fixes: ae0e4bb2a0e0 ("net: phylink: Adjust link settings based on rate matching")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V1->V2: No changes

 drivers/net/phy/phylink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 508434fd4da8..590469261b98 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -205,6 +205,7 @@ static int phylink_interface_max_speed(phy_interface_t interface)
 	case PHY_INTERFACE_MODE_RGMII_ID:
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_QSGMII:
+	case PHY_INTERFACE_MODE_QUSGMII:
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_GMII:
 		return SPEED_1000;
@@ -221,7 +222,6 @@ static int phylink_interface_max_speed(phy_interface_t interface)
 	case PHY_INTERFACE_MODE_10GBASER:
 	case PHY_INTERFACE_MODE_10GKR:
 	case PHY_INTERFACE_MODE_USXGMII:
-	case PHY_INTERFACE_MODE_QUSGMII:
 		return SPEED_10000;
 
 	case PHY_INTERFACE_MODE_25GBASER:
-- 
2.40.1


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

* [PATCH net v2 2/2] net: phylink: use a dedicated helper to parse usgmii control word
  2023-06-09  8:03 [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Maxime Chevallier
  2023-06-09  8:03 ` [PATCH net v2 1/2] net: phylink: report correct max speed for QUSGMII Maxime Chevallier
@ 2023-06-09  8:03 ` Maxime Chevallier
  2023-06-09  8:23 ` [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Russell King (Oracle)
  2023-06-13  0:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2023-06-09  8:03 UTC (permalink / raw)
  To: davem
  Cc: Maxime Chevallier, netdev, linux-kernel, thomas.petazzoni,
	Andrew Lunn, Florian Fainelli, Heiner Kallweit, Russell King,
	linux-arm-kernel, Horatiu.Vultur, Allan.Nielsen, UNGLinuxDriver,
	Vladimir Oltean, Simon Horman

Q-USGMII is a derivative of USGMII, that uses a specific formatting for
the control word. The layout is close to the USXGMII control word, but
doesn't support speeds over 1Gbps. Use a dedicated decoding logic for
the USGMII control word, re-using USXGMII definitions but only considering
10/100/1000Mbps speeds

Fixes: 5e61fe157a27 ("net: phy: Introduce QUSGMII PHY mode")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V1->V2: - Fix the decoding logic, by dropping the custom, wrong, speed mask
	- Fix a typo in the function doc ("expect" -> "except")
	- Slightly reword the commit log

 drivers/net/phy/phylink.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 590469261b98..b82d66e8dda2 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -3359,6 +3359,41 @@ void phylink_decode_usxgmii_word(struct phylink_link_state *state,
 }
 EXPORT_SYMBOL_GPL(phylink_decode_usxgmii_word);
 
+/**
+ * phylink_decode_usgmii_word() - decode the USGMII word from a MAC PCS
+ * @state: a pointer to a struct phylink_link_state.
+ * @lpa: a 16 bit value which stores the USGMII auto-negotiation word
+ *
+ * Helper for MAC PCS supporting the USGMII protocol and the auto-negotiation
+ * code word.  Decode the USGMII code word and populate the corresponding fields
+ * (speed, duplex) into the phylink_link_state structure. The structure for this
+ * word is the same as the USXGMII word, except it only supports speeds up to
+ * 1Gbps.
+ */
+static void phylink_decode_usgmii_word(struct phylink_link_state *state,
+				       uint16_t lpa)
+{
+	switch (lpa & MDIO_USXGMII_SPD_MASK) {
+	case MDIO_USXGMII_10:
+		state->speed = SPEED_10;
+		break;
+	case MDIO_USXGMII_100:
+		state->speed = SPEED_100;
+		break;
+	case MDIO_USXGMII_1000:
+		state->speed = SPEED_1000;
+		break;
+	default:
+		state->link = false;
+		return;
+	}
+
+	if (lpa & MDIO_USXGMII_FULL_DUPLEX)
+		state->duplex = DUPLEX_FULL;
+	else
+		state->duplex = DUPLEX_HALF;
+}
+
 /**
  * phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers
  * @state: a pointer to a &struct phylink_link_state.
@@ -3396,9 +3431,11 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
 
 	case PHY_INTERFACE_MODE_SGMII:
 	case PHY_INTERFACE_MODE_QSGMII:
-	case PHY_INTERFACE_MODE_QUSGMII:
 		phylink_decode_sgmii_word(state, lpa);
 		break;
+	case PHY_INTERFACE_MODE_QUSGMII:
+		phylink_decode_usgmii_word(state, lpa);
+		break;
 
 	default:
 		state->link = false;
-- 
2.40.1


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

* Re: [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg
  2023-06-09  8:03 [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Maxime Chevallier
  2023-06-09  8:03 ` [PATCH net v2 1/2] net: phylink: report correct max speed for QUSGMII Maxime Chevallier
  2023-06-09  8:03 ` [PATCH net v2 2/2] net: phylink: use a dedicated helper to parse usgmii control word Maxime Chevallier
@ 2023-06-09  8:23 ` Russell King (Oracle)
  2023-06-13  0:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2023-06-09  8:23 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: davem, netdev, linux-kernel, thomas.petazzoni, Andrew Lunn,
	Florian Fainelli, Heiner Kallweit, linux-arm-kernel,
	Horatiu.Vultur, Allan.Nielsen, UNGLinuxDriver, Vladimir Oltean,
	Simon Horman

On Fri, Jun 09, 2023 at 10:03:03AM +0200, Maxime Chevallier wrote:
> This is the second version of a small changeset for QUSGMII support,
> fixing inconsistencies in reported max speed and control word parsing.
> 
> As reported here [1], there are some inconsistencies for the Q-USGMII
> mode speeds and configuration. The first patch in this fixup series
> makes so that we correctly report the max speed of 1Gbps for this mode.
> 
> The second patch uses a dedicated helper to decode the control word.
> This is necessary as although USGMII control words are close to USXGMII,
> they don't support the same speeds.
> 
> Thanks,
> 
> Maxime
> 
> [1] : https://lore.kernel.org/netdev/ZHnd+6FUO77XFJvQ@shell.armlinux.org.uk/
> 
> V1->V2: Fix decoding logic for usgmii control word, as per Russell's review

Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Thanks!

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg
  2023-06-09  8:03 [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Maxime Chevallier
                   ` (2 preceding siblings ...)
  2023-06-09  8:23 ` [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Russell King (Oracle)
@ 2023-06-13  0:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-13  0:00 UTC (permalink / raw)
  To: Maxime Chevallier
  Cc: davem, netdev, linux-kernel, thomas.petazzoni, andrew,
	f.fainelli, hkallweit1, linux, linux-arm-kernel, Horatiu.Vultur,
	Allan.Nielsen, UNGLinuxDriver, vladimir.oltean, simon.horman

Hello:

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

On Fri,  9 Jun 2023 10:03:03 +0200 you wrote:
> This is the second version of a small changeset for QUSGMII support,
> fixing inconsistencies in reported max speed and control word parsing.
> 
> As reported here [1], there are some inconsistencies for the Q-USGMII
> mode speeds and configuration. The first patch in this fixup series
> makes so that we correctly report the max speed of 1Gbps for this mode.
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] net: phylink: report correct max speed for QUSGMII
    https://git.kernel.org/netdev/net/c/b9dc1046edfe
  - [net,v2,2/2] net: phylink: use a dedicated helper to parse usgmii control word
    https://git.kernel.org/netdev/net/c/923454c0368b

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] 5+ messages in thread

end of thread, other threads:[~2023-06-13  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09  8:03 [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Maxime Chevallier
2023-06-09  8:03 ` [PATCH net v2 1/2] net: phylink: report correct max speed for QUSGMII Maxime Chevallier
2023-06-09  8:03 ` [PATCH net v2 2/2] net: phylink: use a dedicated helper to parse usgmii control word Maxime Chevallier
2023-06-09  8:23 ` [PATCH net v2 0/2] fixes for Q-USGMII speeds and autoneg Russell King (Oracle)
2023-06-13  0:00 ` 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).