All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces
@ 2021-10-27  9:03 Russell King (Oracle)
  2021-10-27  9:03 ` [PATCH net-next 1/3] net: mvneta: populate supported_interfaces member Russell King
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-10-27  9:03 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: netdev, Thomas Petazzoni

Hi,

This patch series converts mvneta to use phylinks supported_interfaces
bitmap to simplify the validate() implementation. The patches:

1) Add the supported interface modes the supported_interfaces bitmap.
2) Removes the checks for the interface type being supported from
   the validate callback
3) Removes the now unnecessary checks and call to
   phylink_helper_basex_speed() to support switching between
   1000base-X and 2500base-X for SFPs

(3) becomes possible because when asking the MAC for its complete
support, we walk all supported interfaces which will include 1000base-X
and 2500base-X only if the comphy is present.

 drivers/net/ethernet/marvell/mvneta.c | 48 ++++++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 18 deletions(-)

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

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

* [PATCH net-next 1/3] net: mvneta: populate supported_interfaces member
  2021-10-27  9:03 [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces Russell King (Oracle)
@ 2021-10-27  9:03 ` Russell King
  2021-10-27  9:03 ` [PATCH net-next 2/3] net: mvneta: remove interface checks in mvneta_validate() Russell King (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King @ 2021-10-27  9:03 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: Thomas Petazzoni, netdev

Populate the phy_interface_t bitmap for the Marvell mvneta driver with
interfaces modes supported by the MAC.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/marvell/mvneta.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index b6c636592dfa..7df923648bc4 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5179,6 +5179,31 @@ static int mvneta_probe(struct platform_device *pdev)
 
 	pp->phylink_config.dev = &dev->dev;
 	pp->phylink_config.type = PHYLINK_NETDEV;
+	phy_interface_set_rgmii(pp->phylink_config.supported_interfaces);
+	__set_bit(PHY_INTERFACE_MODE_QSGMII,
+		  pp->phylink_config.supported_interfaces);
+	if (comphy) {
+		/* If a COMPHY is present, we can support any of the serdes
+		 * modes and switch between them.
+		 */
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  pp->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_1000BASEX,
+			  pp->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+			  pp->phylink_config.supported_interfaces);
+	} else if (phy_mode == PHY_INTERFACE_MODE_2500BASEX) {
+		/* No COMPHY, with only 2500BASE-X mode supported */
+		__set_bit(PHY_INTERFACE_MODE_2500BASEX,
+			  pp->phylink_config.supported_interfaces);
+	} else if (phy_mode == PHY_INTERFACE_MODE_1000BASEX ||
+		   phy_mode == PHY_INTERFACE_MODE_SGMII) {
+		/* No COMPHY, we can switch between 1000BASE-X and SGMII */
+		__set_bit(PHY_INTERFACE_MODE_1000BASEX,
+			  pp->phylink_config.supported_interfaces);
+		__set_bit(PHY_INTERFACE_MODE_SGMII,
+			  pp->phylink_config.supported_interfaces);
+	}
 
 	phylink = phylink_create(&pp->phylink_config, pdev->dev.fwnode,
 				 phy_mode, &mvneta_phylink_ops);
-- 
2.30.2


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

* [PATCH net-next 2/3] net: mvneta: remove interface checks in mvneta_validate()
  2021-10-27  9:03 [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces Russell King (Oracle)
  2021-10-27  9:03 ` [PATCH net-next 1/3] net: mvneta: populate supported_interfaces member Russell King
@ 2021-10-27  9:03 ` Russell King (Oracle)
  2021-10-27  9:03 ` [PATCH net-next 3/3] net: mvneta: drop use of phylink_helper_basex_speed() Russell King (Oracle)
  2021-10-27 14:40 ` [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-10-27  9:03 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: Thomas Petazzoni, netdev

As phylink checks the interface mode against the supported_interfaces
bitmap, we no longer need to validate the interface mode in the
validation function. Remove this to simplify it.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/marvell/mvneta.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 7df923648bc4..446cdd496f1b 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3832,15 +3832,8 @@ static void mvneta_validate(struct phylink_config *config,
 	 * "Bit 2 Field InBandAnEn In-band Auto-Negotiation enable. ...
 	 * When <PortType> = 1 (1000BASE-X) this field must be set to 1."
 	 */
-	if (phy_interface_mode_is_8023z(state->interface)) {
-		if (!phylink_test(state->advertising, Autoneg)) {
-			linkmode_zero(supported);
-			return;
-		}
-	} else if (state->interface != PHY_INTERFACE_MODE_NA &&
-		   state->interface != PHY_INTERFACE_MODE_QSGMII &&
-		   state->interface != PHY_INTERFACE_MODE_SGMII &&
-		   !phy_interface_mode_is_rgmii(state->interface)) {
+	if (phy_interface_mode_is_8023z(state->interface) &&
+	    !phylink_test(state->advertising, Autoneg)) {
 		linkmode_zero(supported);
 		return;
 	}
-- 
2.30.2


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

* [PATCH net-next 3/3] net: mvneta: drop use of phylink_helper_basex_speed()
  2021-10-27  9:03 [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces Russell King (Oracle)
  2021-10-27  9:03 ` [PATCH net-next 1/3] net: mvneta: populate supported_interfaces member Russell King
  2021-10-27  9:03 ` [PATCH net-next 2/3] net: mvneta: remove interface checks in mvneta_validate() Russell King (Oracle)
@ 2021-10-27  9:03 ` Russell King (Oracle)
  2021-10-27 14:40 ` [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2021-10-27  9:03 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski; +Cc: Thomas Petazzoni, netdev

Now that we have a better method to select SFP interface modes, we
no longer need to use phylink_helper_basex_speed() in a driver's
validation function, and we can also get rid of our hack to indicate
both 1000base-X and 2500base-X if the comphy is present to make that
work. Remove this hack and use of phylink_helper_basex_speed().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/marvell/mvneta.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 446cdd496f1b..5a7bdca22a63 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3823,8 +3823,6 @@ static void mvneta_validate(struct phylink_config *config,
 			    unsigned long *supported,
 			    struct phylink_link_state *state)
 {
-	struct net_device *ndev = to_net_dev(config->dev);
-	struct mvneta_port *pp = netdev_priv(ndev);
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
 
 	/* We only support QSGMII, SGMII, 802.3z and RGMII modes.
@@ -3846,11 +3844,12 @@ static void mvneta_validate(struct phylink_config *config,
 	phylink_set(mask, Pause);
 
 	/* Half-duplex at speeds higher than 100Mbit is unsupported */
-	if (pp->comphy || state->interface != PHY_INTERFACE_MODE_2500BASEX) {
+	if (state->interface != PHY_INTERFACE_MODE_2500BASEX) {
 		phylink_set(mask, 1000baseT_Full);
 		phylink_set(mask, 1000baseX_Full);
 	}
-	if (pp->comphy || state->interface == PHY_INTERFACE_MODE_2500BASEX) {
+
+	if (state->interface == PHY_INTERFACE_MODE_2500BASEX) {
 		phylink_set(mask, 2500baseT_Full);
 		phylink_set(mask, 2500baseX_Full);
 	}
@@ -3865,11 +3864,6 @@ static void mvneta_validate(struct phylink_config *config,
 
 	linkmode_and(supported, supported, mask);
 	linkmode_and(state->advertising, state->advertising, mask);
-
-	/* We can only operate at 2500BaseX or 1000BaseX.  If requested
-	 * to advertise both, only report advertising at 2500BaseX.
-	 */
-	phylink_helper_basex_speed(state);
 }
 
 static void mvneta_mac_pcs_get_state(struct phylink_config *config,
-- 
2.30.2


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

* Re: [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces
  2021-10-27  9:03 [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2021-10-27  9:03 ` [PATCH net-next 3/3] net: mvneta: drop use of phylink_helper_basex_speed() Russell King (Oracle)
@ 2021-10-27 14:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-27 14:40 UTC (permalink / raw)
  To: Russell King; +Cc: davem, kuba, netdev, thomas.petazzoni

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Wed, 27 Oct 2021 10:03:11 +0100 you wrote:
> Hi,
> 
> This patch series converts mvneta to use phylinks supported_interfaces
> bitmap to simplify the validate() implementation. The patches:
> 
> 1) Add the supported interface modes the supported_interfaces bitmap.
> 2) Removes the checks for the interface type being supported from
>    the validate callback
> 3) Removes the now unnecessary checks and call to
>    phylink_helper_basex_speed() to support switching between
>    1000base-X and 2500base-X for SFPs
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net: mvneta: populate supported_interfaces member
    https://git.kernel.org/netdev/net-next/c/fdedb695e6a8
  - [net-next,2/3] net: mvneta: remove interface checks in mvneta_validate()
    https://git.kernel.org/netdev/net-next/c/d9ca72807ecb
  - [net-next,3/3] net: mvneta: drop use of phylink_helper_basex_speed()
    https://git.kernel.org/netdev/net-next/c/099cbfa286ab

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:[~2021-10-27 14:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27  9:03 [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces Russell King (Oracle)
2021-10-27  9:03 ` [PATCH net-next 1/3] net: mvneta: populate supported_interfaces member Russell King
2021-10-27  9:03 ` [PATCH net-next 2/3] net: mvneta: remove interface checks in mvneta_validate() Russell King (Oracle)
2021-10-27  9:03 ` [PATCH net-next 3/3] net: mvneta: drop use of phylink_helper_basex_speed() Russell King (Oracle)
2021-10-27 14:40 ` [PATCH net-next 0/3] Convert mvneta to phylink supported_interfaces patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.