All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX
@ 2022-06-21  9:31 Russell King (Oracle)
  2022-06-21  9:37 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code Russell King (Oracle)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2022-06-21  9:31 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot, Marek Behún
  Cc: David S. Miller, Eric Dumazet, Florian Fainelli, Jakub Kicinski,
	netdev, Paolo Abeni, Vladimir Oltean

Hi,

This series does two things:

1. it gets rid of mv88e6065_port_set_speed_duplex() which is completely
   unused (do we support this device? I couldn't find it in the tables
   in chip.c) This has a max speed of 200Mbps which we don't support.

2. get rid of the SPEED_MAX constant, which is used to configure a DSA
   or CPU port to their maximum speed during initialisation. We no
   longer need this as we can derive the maximum port speed from the
   mac_capabilities instead.

The reason for making this change is in preparation for phylink to be
used by DSA for CPU ports. This omission has come back to bite us with
the conversion of DSA drivers to phylink_pcs, since phylink_pcs won't
get used unless phylink is being used. Particularly with this driver,
it is very common for DT descriptions to omit the fixed-link details
which means "use maximum speed".

It will eventually be necessary to hoist the selection of "max speed"
into the DSA layer (trivial) and also have a way for the DSA driver
to tell the DSA layer which interface it should be using for these
ports.

 drivers/net/dsa/mv88e6xxx/chip.c | 39 +++++++++++++++++++++++++++++----------
 drivers/net/dsa/mv88e6xxx/chip.h |  3 +--
 drivers/net/dsa/mv88e6xxx/port.c | 36 ------------------------------------
 drivers/net/dsa/mv88e6xxx/port.h |  2 --
 4 files changed, 30 insertions(+), 50 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] 4+ messages in thread

* [PATCH net-next 1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code
  2022-06-21  9:31 [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX Russell King (Oracle)
@ 2022-06-21  9:37 ` Russell King (Oracle)
  2022-06-21  9:37 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX setting Russell King
  2022-06-24  3:30 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2022-06-21  9:37 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot
  Cc: David S. Miller, Eric Dumazet, Florian Fainelli, Jakub Kicinski,
	netdev, Paolo Abeni, Vladimir Oltean

Remove mv88e6065_port_set_speed_duplex() - this is never called, and
thus is completely redundant.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/mv88e6xxx/port.c | 15 ---------------
 drivers/net/dsa/mv88e6xxx/port.h |  2 --
 2 files changed, 17 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index 795b3128768f..3cdc985b79e2 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -294,21 +294,6 @@ static int mv88e6xxx_port_set_speed_duplex(struct mv88e6xxx_chip *chip,
 	return 0;
 }
 
-/* Support 10, 100, 200 Mbps (e.g. 88E6065 family) */
-int mv88e6065_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
-				    int speed, int duplex)
-{
-	if (speed == SPEED_MAX)
-		speed = 200;
-
-	if (speed > 200)
-		return -EOPNOTSUPP;
-
-	/* Setting 200 Mbps on port 0 to 3 selects 100 Mbps */
-	return mv88e6xxx_port_set_speed_duplex(chip, port, speed, false, false,
-					       duplex);
-}
-
 /* Support 10, 100, 1000 Mbps (e.g. 88E6185 family) */
 int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h
index e0a705d82019..cb04243f37c1 100644
--- a/drivers/net/dsa/mv88e6xxx/port.h
+++ b/drivers/net/dsa/mv88e6xxx/port.h
@@ -342,8 +342,6 @@ int mv88e6xxx_port_set_link(struct mv88e6xxx_chip *chip, int port, int link);
 int mv88e6xxx_port_sync_link(struct mv88e6xxx_chip *chip, int port, unsigned int mode, bool isup);
 int mv88e6185_port_sync_link(struct mv88e6xxx_chip *chip, int port, unsigned int mode, bool isup);
 
-int mv88e6065_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
-				    int speed, int duplex);
 int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex);
 int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
-- 
2.30.2


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

* [PATCH net-next 2/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX setting
  2022-06-21  9:31 [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX Russell King (Oracle)
  2022-06-21  9:37 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code Russell King (Oracle)
@ 2022-06-21  9:37 ` Russell King
  2022-06-24  3:30 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Russell King @ 2022-06-21  9:37 UTC (permalink / raw)
  To: Andrew Lunn, Vivien Didelot
  Cc: David S. Miller, Eric Dumazet, Florian Fainelli, Jakub Kicinski,
	netdev, Paolo Abeni, Vladimir Oltean

Currently, all the device specific speed setting functions convert
SPEED_MAX to the actual speed of the port. Rather than having each
of the mv88e6xxx chip specifics handling SPEED_MAX, derive it from
the mac_capabilities instead.

This is only needed for CPU and DSA ports, so move the logic up into
mv88e6xxx_setup_port() - which allows us to kill off all users of
SPEED_MAX throughout the driver.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 39 ++++++++++++++++++++++++--------
 drivers/net/dsa/mv88e6xxx/chip.h |  3 +--
 drivers/net/dsa/mv88e6xxx/port.c | 21 -----------------
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 0b49d243e00b..37b649501500 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -449,9 +449,6 @@ static int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port,
 			goto restore_link;
 	}
 
-	if (speed == SPEED_MAX && chip->info->ops->port_max_speed_mode)
-		mode = chip->info->ops->port_max_speed_mode(port);
-
 	if (chip->info->ops->port_set_pause) {
 		err = chip->info->ops->port_set_pause(chip, port, pause);
 		if (err)
@@ -3280,28 +3277,51 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
 {
 	struct device_node *phy_handle = NULL;
 	struct dsa_switch *ds = chip->ds;
+	phy_interface_t mode;
 	struct dsa_port *dp;
-	int tx_amp;
+	int tx_amp, speed;
 	int err;
 	u16 reg;
 
 	chip->ports[port].chip = chip;
 	chip->ports[port].port = port;
 
+	dp = dsa_to_port(ds, port);
+
 	/* MAC Forcing register: don't force link, speed, duplex or flow control
 	 * state to any particular values on physical ports, but force the CPU
 	 * port and all DSA ports to their maximum bandwidth and full duplex.
 	 */
-	if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port))
+	if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) {
+		unsigned long caps = dp->pl_config.mac_capabilities;
+
+		if (chip->info->ops->port_max_speed_mode)
+			mode = chip->info->ops->port_max_speed_mode(port);
+		else
+			mode = PHY_INTERFACE_MODE_NA;
+
+		if (caps & MAC_10000FD)
+			speed = SPEED_10000;
+		else if (caps & MAC_5000FD)
+			speed = SPEED_5000;
+		else if (caps & MAC_2500FD)
+			speed = SPEED_2500;
+		else if (caps & MAC_1000)
+			speed = SPEED_1000;
+		else if (caps & MAC_100)
+			speed = SPEED_100;
+		else
+			speed = SPEED_10;
+
 		err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP,
-					       SPEED_MAX, DUPLEX_FULL,
-					       PAUSE_OFF,
-					       PHY_INTERFACE_MODE_NA);
-	else
+					       speed, DUPLEX_FULL,
+					       PAUSE_OFF, mode);
+	} else {
 		err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED,
 					       SPEED_UNFORCED, DUPLEX_UNFORCED,
 					       PAUSE_ON,
 					       PHY_INTERFACE_MODE_NA);
+	}
 	if (err)
 		return err;
 
@@ -3473,7 +3493,6 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
 	}
 
 	if (chip->info->ops->serdes_set_tx_amplitude) {
-		dp = dsa_to_port(ds, port);
 		if (dp)
 			phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0);
 
diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index 5e03cfe50156..e693154cf803 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -488,14 +488,13 @@ struct mv88e6xxx_ops {
 	int (*port_set_pause)(struct mv88e6xxx_chip *chip, int port,
 			      int pause);
 
-#define SPEED_MAX		INT_MAX
 #define SPEED_UNFORCED		-2
 #define DUPLEX_UNFORCED		-2
 
 	/* Port's MAC speed (in Mbps) and MAC duplex mode
 	 *
 	 * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid.
-	 * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value.
+	 * Use SPEED_UNFORCED for normal detection.
 	 *
 	 * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex,
 	 * or DUPLEX_UNFORCED for normal duplex detection.
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index 3cdc985b79e2..90c55f23b7c9 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -298,9 +298,6 @@ static int mv88e6xxx_port_set_speed_duplex(struct mv88e6xxx_chip *chip,
 int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = 1000;
-
 	if (speed == 200 || speed > 1000)
 		return -EOPNOTSUPP;
 
@@ -312,9 +309,6 @@ int mv88e6185_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = 100;
-
 	if (speed > 100)
 		return -EOPNOTSUPP;
 
@@ -326,9 +320,6 @@ int mv88e6250_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 int mv88e6341_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = port < 5 ? 1000 : 2500;
-
 	if (speed > 2500)
 		return -EOPNOTSUPP;
 
@@ -354,9 +345,6 @@ phy_interface_t mv88e6341_port_max_speed_mode(int port)
 int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = 1000;
-
 	if (speed > 1000)
 		return -EOPNOTSUPP;
 
@@ -371,9 +359,6 @@ int mv88e6352_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 int mv88e6390_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				    int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = port < 9 ? 1000 : 2500;
-
 	if (speed > 2500)
 		return -EOPNOTSUPP;
 
@@ -399,9 +384,6 @@ phy_interface_t mv88e6390_port_max_speed_mode(int port)
 int mv88e6390x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 				     int speed, int duplex)
 {
-	if (speed == SPEED_MAX)
-		speed = port < 9 ? 1000 : 10000;
-
 	if (speed == 200 && port != 0)
 		return -EOPNOTSUPP;
 
@@ -430,9 +412,6 @@ int mv88e6393x_port_set_speed_duplex(struct mv88e6xxx_chip *chip, int port,
 	u16 reg, ctrl;
 	int err;
 
-	if (speed == SPEED_MAX)
-		speed = (port > 0 && port < 9) ? 1000 : 10000;
-
 	if (speed == 200 && port != 0)
 		return -EOPNOTSUPP;
 
-- 
2.30.2


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

* Re: [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX
  2022-06-21  9:31 [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX Russell King (Oracle)
  2022-06-21  9:37 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code Russell King (Oracle)
  2022-06-21  9:37 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX setting Russell King
@ 2022-06-24  3:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-24  3:30 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, vivien.didelot, kabel, davem, edumazet, f.fainelli, kuba,
	netdev, pabeni, olteanv

Hello:

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

On Tue, 21 Jun 2022 10:31:50 +0100 you wrote:
> Hi,
> 
> This series does two things:
> 
> 1. it gets rid of mv88e6065_port_set_speed_duplex() which is completely
>    unused (do we support this device? I couldn't find it in the tables
>    in chip.c) This has a max speed of 200Mbps which we don't support.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code
    https://git.kernel.org/netdev/net-next/c/aa64bc1990b2
  - [net-next,2/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX setting
    https://git.kernel.org/netdev/net-next/c/3c783b83bd0f

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

end of thread, other threads:[~2022-06-24  3:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21  9:31 [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX Russell King (Oracle)
2022-06-21  9:37 ` [PATCH net-next 1/2] net: dsa: mv88e6xxx: remove mv88e6065 dead code Russell King (Oracle)
2022-06-21  9:37 ` [PATCH net-next 2/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX setting Russell King
2022-06-24  3:30 ` [PATCH net-next 0/2] net: dsa: mv88e6xxx: get rid of SPEED_MAX 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.