diff mbox series

[net-next,1/2] net: dsa: mv88e6xxx: Implement MTU change

Message ID 20200711203206.1110108-2-andrew@lunn.ch
State Accepted
Delegated to: David Miller
Headers show
Series Fix MTU warnings for fec/mv886xxx combo | expand

Commit Message

Andrew Lunn July 11, 2020, 8:32 p.m. UTC
The Marvell Switches support jumbo packages. So implement the
callbacks needed for changing the MTU.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Marek BehĂșn July 11, 2020, 11:29 p.m. UTC | #1
On Sat, 11 Jul 2020 22:32:05 +0200
Andrew Lunn <andrew@lunn.ch> wrote:

> The Marvell Switches support jumbo packages. So implement the
> callbacks needed for changing the MTU.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Hi Andrew,

maybe this could be sent to net, not only net-next. Or maybe even
better, with a Fixes tag to some commit - DSA now prints warnings on
some systems when initializing switch interfaces, that MTU cannot be
changed, so maybe we could look at this patch as a fix and get it
backported...

Marek
Andrew Lunn July 11, 2020, 11:52 p.m. UTC | #2
On Sun, Jul 12, 2020 at 01:29:44AM +0200, Marek Behun wrote:
> On Sat, 11 Jul 2020 22:32:05 +0200
> Andrew Lunn <andrew@lunn.ch> wrote:
> 
> > The Marvell Switches support jumbo packages. So implement the
> > callbacks needed for changing the MTU.
> > 
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> 
> Hi Andrew,
> 
> maybe this could be sent to net, not only net-next. Or maybe even
> better, with a Fixes tag to some commit - DSA now prints warnings on
> some systems when initializing switch interfaces, that MTU cannot be
> changed, so maybe we could look at this patch as a fix and get it
> backported...

Hi Marek

It does not really 'fix' anything. The warning clearly says it is nonfatal

[    2.091447] mv88e6085 0.1:00: nonfatal error -95 setting MTU on port 1
[    2.123378] mv88e6085 0.1:00: nonfatal error -95 setting MTU on port 2
[    2.144035] mv88e6085 0.1:00: nonfatal error -95 setting MTU on port 3
[    2.165546] mv88e6085 0.1:00: nonfatal error -95 setting MTU on port 4
[    2.189840] mv88e6085 0.2:00: nonfatal error -95 setting MTU on port 1
[    2.213373] mv88e6085 0.2:00: nonfatal error -95 setting MTU on port 2
[    2.232762] mv88e6085 0.2:00: nonfatal error -95 setting MTU on port 3
[    2.253840] mv88e6085 0.2:00: nonfatal error -95 setting MTU on port 4
[    2.275925] mv88e6085 0.2:00: nonfatal error -95 setting MTU on port 9

and the switch works as before. As such, i don't think this patch
meets the requirements of stable:

Documentation/process/stable-kernel-rules.rst

	Andrew
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index d995f5bf0d40..6f019955ae42 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2693,6 +2693,31 @@  static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
 	return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_DEFAULT_VLAN, 0);
 }
 
+static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+
+	if (chip->info->ops->port_set_jumbo_size)
+		return 10240;
+	return 1522;
+}
+
+static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+	int ret = 0;
+
+	mv88e6xxx_reg_lock(chip);
+	if (chip->info->ops->port_set_jumbo_size)
+		ret = chip->info->ops->port_set_jumbo_size(chip, port, new_mtu);
+	else
+		if (new_mtu > 1522)
+			ret = -EINVAL;
+	mv88e6xxx_reg_unlock(chip);
+
+	return ret;
+}
+
 static int mv88e6xxx_port_enable(struct dsa_switch *ds, int port,
 				 struct phy_device *phydev)
 {
@@ -5525,6 +5550,8 @@  static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.get_sset_count		= mv88e6xxx_get_sset_count,
 	.port_enable		= mv88e6xxx_port_enable,
 	.port_disable		= mv88e6xxx_port_disable,
+	.port_max_mtu		= mv88e6xxx_get_max_mtu,
+	.port_change_mtu	= mv88e6xxx_change_mtu,
 	.get_mac_eee		= mv88e6xxx_get_mac_eee,
 	.set_mac_eee		= mv88e6xxx_set_mac_eee,
 	.get_eeprom_len		= mv88e6xxx_get_eeprom_len,