All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed
@ 2018-10-05 14:42 Marek Behún
  2018-10-05 21:20 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behún @ 2018-10-05 14:42 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Florian Fainelli, David S . Miller, Marek Behún

The port_set_speed method for the Topaz family must not be the same
as for Peridot family, since on Topaz port 5 is the SERDES port and it
can be set to 2500mbps speed mode.

This patch adds a new method for the Topaz family, allowing the alt_bit
mode only for port 0 and the 2500 mbps mode for port 5.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 drivers/net/dsa/mv88e6xxx/chip.c |  4 ++--
 drivers/net/dsa/mv88e6xxx/port.c | 25 +++++++++++++++++++++++--
 drivers/net/dsa/mv88e6xxx/port.h |  1 +
 3 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 78ce820b5257..e05d4eddc935 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2907,7 +2907,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
 	.port_set_link = mv88e6xxx_port_set_link,
 	.port_set_duplex = mv88e6xxx_port_set_duplex,
 	.port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
-	.port_set_speed = mv88e6390_port_set_speed,
+	.port_set_speed = mv88e6341_port_set_speed,
 	.port_tag_remap = mv88e6095_port_tag_remap,
 	.port_set_frame_mode = mv88e6351_port_set_frame_mode,
 	.port_set_egress_floods = mv88e6352_port_set_egress_floods,
@@ -3528,7 +3528,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {
 	.port_set_link = mv88e6xxx_port_set_link,
 	.port_set_duplex = mv88e6xxx_port_set_duplex,
 	.port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay,
-	.port_set_speed = mv88e6390_port_set_speed,
+	.port_set_speed = mv88e6341_port_set_speed,
 	.port_tag_remap = mv88e6095_port_tag_remap,
 	.port_set_frame_mode = mv88e6351_port_set_frame_mode,
 	.port_set_egress_floods = mv88e6352_port_set_egress_floods,
diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
index 92945841c8e8..cd7db60a508b 100644
--- a/drivers/net/dsa/mv88e6xxx/port.c
+++ b/drivers/net/dsa/mv88e6xxx/port.c
@@ -228,8 +228,11 @@ static int mv88e6xxx_port_set_speed(struct mv88e6xxx_chip *chip, int port,
 		ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_1000;
 		break;
 	case 2500:
-		ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000 |
-			MV88E6390_PORT_MAC_CTL_ALTSPEED;
+		if (alt_bit)
+			ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000 |
+				MV88E6390_PORT_MAC_CTL_ALTSPEED;
+		else
+			ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000;
 		break;
 	case 10000:
 		/* all bits set, fall through... */
@@ -291,6 +294,24 @@ int mv88e6185_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
 	return mv88e6xxx_port_set_speed(chip, port, speed, false, false);
 }
 
+/* Support 10, 100, 200, 1000, 2500 Mbps (e.g. 88E6341) */
+int mv88e6341_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
+{
+	if (speed == SPEED_MAX)
+		speed = port < 5 ? 1000 : 2500;
+
+	if (speed > 2500)
+		return -EOPNOTSUPP;
+
+	if (speed == 200 && port != 0)
+		return -EOPNOTSUPP;
+
+	if (speed == 2500 && port < 5)
+		return -EOPNOTSUPP;
+
+	return mv88e6xxx_port_set_speed(chip, port, speed, !port, true);
+}
+
 /* Support 10, 100, 200, 1000 Mbps (e.g. 88E6352 family) */
 int mv88e6352_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
 {
diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h
index f32f56af8e35..36904c9bf955 100644
--- a/drivers/net/dsa/mv88e6xxx/port.h
+++ b/drivers/net/dsa/mv88e6xxx/port.h
@@ -269,6 +269,7 @@ int mv88e6xxx_port_set_duplex(struct mv88e6xxx_chip *chip, int port, int dup);
 
 int mv88e6065_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
 int mv88e6185_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
+int mv88e6341_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
 int mv88e6352_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
 int mv88e6390_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
 int mv88e6390x_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed);
-- 
2.16.4

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

* Re: [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed
  2018-10-05 14:42 [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed Marek Behún
@ 2018-10-05 21:20 ` Andrew Lunn
  2018-10-06  0:38   ` Marek Behun
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-10-05 21:20 UTC (permalink / raw)
  To: Marek Behún; +Cc: netdev, Florian Fainelli, David S . Miller

On Fri, Oct 05, 2018 at 04:42:27PM +0200, Marek Behún wrote:
> The port_set_speed method for the Topaz family must not be the same
> as for Peridot family, since on Topaz port 5 is the SERDES port and it
> can be set to 2500mbps speed mode.
> 
> This patch adds a new method for the Topaz family, allowing the alt_bit
> mode only for port 0 and the 2500 mbps mode for port 5.
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
> index 92945841c8e8..cd7db60a508b 100644
> --- a/drivers/net/dsa/mv88e6xxx/port.c
> +++ b/drivers/net/dsa/mv88e6xxx/port.c
> @@ -228,8 +228,11 @@ static int mv88e6xxx_port_set_speed(struct mv88e6xxx_chip *chip, int port,
>  		ctrl = MV88E6XXX_PORT_MAC_CTL_SPEED_1000;
>  		break;
>  	case 2500:
> -		ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000 |
> -			MV88E6390_PORT_MAC_CTL_ALTSPEED;
> +		if (alt_bit)
> +			ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000 |
> +				MV88E6390_PORT_MAC_CTL_ALTSPEED;
> +		else
> +			ctrl = MV88E6390_PORT_MAC_CTL_SPEED_10000;
>  		break;
>  	case 10000:
>  		/* all bits set, fall through... */
> @@ -291,6 +294,24 @@ int mv88e6185_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
>  	return mv88e6xxx_port_set_speed(chip, port, speed, false, false);
>  }
>  
> +/* Support 10, 100, 200, 1000, 2500 Mbps (e.g. 88E6341) */
> +int mv88e6341_port_set_speed(struct mv88e6xxx_chip *chip, int port, int speed)
> +{
> +	if (speed == SPEED_MAX)
> +		speed = port < 5 ? 1000 : 2500;
> +
> +	if (speed > 2500)
> +		return -EOPNOTSUPP;
> +
> +	if (speed == 200 && port != 0)
> +		return -EOPNOTSUPP;
> +
> +	if (speed == 2500 && port < 5)
> +		return -EOPNOTSUPP;
> +
> +	return mv88e6xxx_port_set_speed(chip, port, speed, !port, true);

Hi Marek

I'm confused.

The alt bit is used for configuring 2500. You say 2500 is only
supported on port 5. But !port is only true for port 0?

	  Andrew

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

* Re: [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed
  2018-10-05 21:20 ` Andrew Lunn
@ 2018-10-06  0:38   ` Marek Behun
  2018-10-06 18:37     ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Behun @ 2018-10-06  0:38 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Florian Fainelli, David S . Miller

> Hi Marek
> 
> I'm confused.
> 
> The alt bit is used for configuring 2500. You say 2500 is only
> supported on port 5. But !port is only true for port 0?
> 
> 	  Andrew

On Topaz alt_bit is used only for port 0 for differentiating 100 mbps
vs 200 mbps. The choices for SpdValue are 0 for 10 mbps, 1 for 100
mbps or 200 mbps (if alt_bit), 2 for 1000 mbps and 3 for 2500 mbps.
2500 is allowed only on port 5. alt_bit is not used on Topaz for port
5 (serdes), therefore I used !port.

Marek

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

* Re: [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed
  2018-10-06  0:38   ` Marek Behun
@ 2018-10-06 18:37     ` Andrew Lunn
  2018-10-06 22:00       ` Marek Behun
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-10-06 18:37 UTC (permalink / raw)
  To: Marek Behun; +Cc: netdev, Florian Fainelli, David S . Miller

On Sat, Oct 06, 2018 at 02:38:10AM +0200, Marek Behun wrote:
> > Hi Marek
> > 
> > I'm confused.
> > 
> > The alt bit is used for configuring 2500. You say 2500 is only
> > supported on port 5. But !port is only true for port 0?
> > 
> > 	  Andrew
> 
> On Topaz alt_bit is used only for port 0 for differentiating 100 mbps
> vs 200 mbps. The choices for SpdValue are 0 for 10 mbps, 1 for 100
> mbps or 200 mbps (if alt_bit), 2 for 1000 mbps and 3 for 2500 mbps.
> 2500 is allowed only on port 5. alt_bit is not used on Topaz for port
> 5 (serdes), therefore I used !port.

Hi Marek

The commit message could be clearer. It might be going too far, but
you could split this into three.

1) Basic framework code, with works correctly for ports 1-4.
2) The special 200Mbps for port 0
3) The special 2500Mbps for port 5.

But i would also accept a clearer commit message.

    Thanks
    Andrew

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

* Re: [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed
  2018-10-06 18:37     ` Andrew Lunn
@ 2018-10-06 22:00       ` Marek Behun
  0 siblings, 0 replies; 5+ messages in thread
From: Marek Behun @ 2018-10-06 22:00 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Florian Fainelli, David S . Miller

Hi Andrew, I think that dividing this patch into three would be too
much. How about this commit message?

  net: dsa: mv88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed

  This is a fix for the port_set_speed method for the Topaz family.
  Currently the same method is used as for the Peridot family, but
  this is wrong for the SERDES port.

  On Topaz, the SERDES port is port 5, not 9 and 10 as in Peridot.
  Moreover setting alt_bit on Topaz only makes sense for port 0 (for
  (differentiating 100mbps vs 200mbps). The SERDES port does not
  support more than 2500mbps, so alt_bit does not make any difference.

On Sat, 6 Oct 2018 20:37:00 +0200
Andrew Lunn <andrew@lunn.ch> wrote:

> On Sat, Oct 06, 2018 at 02:38:10AM +0200, Marek Behun wrote:
> > > Hi Marek
> > > 
> > > I'm confused.
> > > 
> > > The alt bit is used for configuring 2500. You say 2500 is only
> > > supported on port 5. But !port is only true for port 0?
> > > 
> > > 	  Andrew  
> > 
> > On Topaz alt_bit is used only for port 0 for differentiating 100
> > mbps vs 200 mbps. The choices for SpdValue are 0 for 10 mbps, 1 for
> > 100 mbps or 200 mbps (if alt_bit), 2 for 1000 mbps and 3 for 2500
> > mbps. 2500 is allowed only on port 5. alt_bit is not used on Topaz
> > for port 5 (serdes), therefore I used !port.  
> 
> Hi Marek
> 
> The commit message could be clearer. It might be going too far, but
> you could split this into three.
> 
> 1) Basic framework code, with works correctly for ports 1-4.
> 2) The special 200Mbps for port 0
> 3) The special 2500Mbps for port 5.
> 
> But i would also accept a clearer commit message.
> 
>     Thanks
>     Andrew

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

end of thread, other threads:[~2018-10-07  5:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 14:42 [PATCH net-next] net: dsa: mc88e6xxx: Fix 88E6141/6341 2500mbps SERDES speed Marek Behún
2018-10-05 21:20 ` Andrew Lunn
2018-10-06  0:38   ` Marek Behun
2018-10-06 18:37     ` Andrew Lunn
2018-10-06 22:00       ` Marek Behun

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.