Skip to contentSkip to conversation

Configure the MTU on DSA switches

PATCH Superseded Vladimir Oltean 6 participants 37 messages Mar 25, 2020 – Mar 26, 2020

Subsystems (10)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Vladimir Oltean

author maintainer
#0 lore raw

v2 cover Configure the MTU on DSA switches

From: Vladimir Oltean <[email protected]>

This series adds support for configuring the MTU on front-panel switch ports, while seamlessly adapting the CPU port and the DSA master to the largest value plus the tagger overhead.

It also implements bridge MTU auto-normalization, as discussed with Florian in the comments of v1.

Support was added for quite a number of switches, in the hope that this series would gain some traction:
- sja1105
- felix
- vsc73xx
- b53 and rest of the platform

V1 of this series was submitted here:
https://patchwork.ozlabs.org/cover/1199868/

Murali Krishna Policharla (5):
net: phy: bcm7xx: Add jumbo frame configuration to PHY
bgmac: Add support for Jumbo frames
bgmac: Add MTU configuration support to the driver
bgmac: Add DMA support to handle frames beyond 8192 bytes
net: dsa: b53: Add MTU configuration support

Vladimir Oltean (5):
net: dsa: configure the MTU for switch ports
net: dsa: sja1105: Implement the port MTU callbacks
net: dsa: vsc73xx: Make the MTU configurable
net: dsa: felix: support changing the MTU
net: bridge: implement auto-normalization of MTU for hardware datapath

 drivers/net/dsa/b53/b53_common.c       |  35 +++++++++
 drivers/net/dsa/ocelot/felix.c         |  18 +++++
 drivers/net/dsa/sja1105/sja1105.h      |   1 +
 drivers/net/dsa/sja1105/sja1105_main.c |  48 +++++++++++-
 drivers/net/dsa/vitesse-vsc73xx-core.c |  30 ++++---
 drivers/net/ethernet/broadcom/bgmac.c  |  12 +++
 drivers/net/ethernet/broadcom/bgmac.h  |   5 +-
 drivers/net/ethernet/mscc/ocelot.c     |  45 ++++++++---
 drivers/net/phy/bcm-phy-lib.c          |  28 +++++++
 drivers/net/phy/bcm-phy-lib.h          |   1 +
 drivers/net/phy/bcm7xxx.c              |   4 +
 include/linux/brcmphy.h                |   1 +
 include/net/dsa.h                      |  10 +++
 include/soc/mscc/ocelot.h              |   7 ++
 net/bridge/br.c                        |   1 +
 net/bridge/br_if.c                     |  93 ++++++++++++++++++++++
 net/bridge/br_private.h                |   1 +
 net/dsa/dsa_priv.h                     |  10 +++
 net/dsa/master.c                       |  14 ++--
 net/dsa/port.c                         |  11 +++
 net/dsa/slave.c                        | 104 ++++++++++++++++++++++++-
 net/dsa/switch.c                       |  34 ++++++++
 22 files changed, 478 insertions(+), 35 deletions(-)
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v2 1/10 net: dsa: configure the MTU for switch ports

From: Vladimir Oltean <[email protected]>

It is useful be able to configure port policers on a switch to accept frames of various sizes:

- Increase the MTU for better throughput from the default of 1500 if it is known that there is no 10/100 Mbps device in the network.
- Decrease the MTU to limit the latency of high-priority frames under congestion.

For DSA slave ports, this is mostly a pass-through callback, called through the regular ndo ops and at probe time (to ensure consistency across all supported switches).

The CPU port is called with an MTU equal to the largest configured MTU of the slave ports. The assumption is that the user might want to sustain a bidirectional conversation with a partner over any switch port.

The DSA master is configured the same as the CPU port, plus the tagger overhead. Since the MTU is by definition L2 payload (sans Ethernet header), it is up to each individual driver to figure out if it needs to do anything special for its frame tags on the CPU port (it shouldn't except in special cases). So the MTU does not contain the tagger overhead on the CPU port.
However the MTU of the DSA master, minus the tagger overhead, is used as a proxy for the MTU of the CPU port, which does not have a net device. This is to avoid uselessly calling the .change_mtu function on the CPU port when nothing should change.

So it is safe to assume that the DSA master and the CPU port MTUs are apart by exactly the tagger's overhead in bytes.

This patch also makes MTU configuration on the DSA master interface mandatory (errors from dsa_master_set_mtu now really are propagated). The reasoning is that it's better to be safe than sorry. With cascaded DSA setups, things can easily spiral out of control if they're ignored, since the user is not notified of what went wrong, and large packets just get lost.

Some inspiration (mainly in the MTU DSA notifier) was taken from a vaguely similar patch from Murali and Florian, who are credited as co-developers down below.

---
 include/net/dsa.h  |  10 +++++
 net/dsa/dsa_priv.h |  10 +++++
 net/dsa/master.c   |  14 +++---
 net/dsa/port.c     |  11 +++++
 net/dsa/slave.c    | 104 ++++++++++++++++++++++++++++++++++++++++++++-
 net/dsa/switch.c   |  34 +++++++++++++++
 6 files changed, 174 insertions(+), 9 deletions(-)
include/net/dsa.h +10 -0
index beeb81a532e3..1bb1e0852e31 100644
@@ -579,6 +579,16 @@ struct dsa_switch_ops {
 				     struct devlink_param_gset_ctx *ctx);
 	int	(*devlink_param_set)(struct dsa_switch *ds, u32 id,
 				     struct devlink_param_gset_ctx *ctx);
+
+	/*
+	 * MTU change functionality. Switches can also adjust their MRU through
+	 * this method. By MTU, one understands the SDU, aka L2 payload length.
+	 * If the switch needs to account for the DSA tag on the CPU port, this
+	 * method needs to to do so privately.
+	 */
+	int	(*port_change_mtu)(struct dsa_switch *ds, int port,
+				   int new_mtu);
+	int	(*port_max_mtu)(struct dsa_switch *ds, int port);
 };
 
 #define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes)		\
net/dsa/dsa_priv.h +10 -0
index 760e6ea3178a..b43d5713ff90 100644
@@ -22,6 +22,7 @@ enum {
 	DSA_NOTIFIER_MDB_DEL,
 	DSA_NOTIFIER_VLAN_ADD,
 	DSA_NOTIFIER_VLAN_DEL,
+	DSA_NOTIFIER_MTU,
 };
 
 /* DSA_NOTIFIER_AGEING_TIME */
@@ -61,6 +62,13 @@ struct dsa_notifier_vlan_info {
 	int port;
 };
 
+/* DSA_NOTIFIER_MTU */
+struct dsa_notifier_mtu_info {
+	int sw_index;
+	int port;
+	int mtu;
+};
+
 struct dsa_slave_priv {
 	/* Copy of CPU port xmit for faster access in slave transmit hot path */
 	struct sk_buff *	(*xmit)(struct sk_buff *skb,
@@ -98,6 +106,7 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
 /* master.c */
 int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp);
 void dsa_master_teardown(struct net_device *dev);
+int dsa_master_set_mtu(struct net_device *dev, int mtu);
 
 static inline struct net_device *dsa_master_find_slave(struct net_device *dev,
 						       int device, int port)
@@ -127,6 +136,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
 			    struct switchdev_trans *trans);
 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
 			 struct switchdev_trans *trans);
+int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu);
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 		     u16 vid);
 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
net/dsa/master.c +6 -8
index bd44bde272f4..e37f14d6a8a6 100644
@@ -314,18 +314,18 @@ static const struct attribute_group dsa_group = {
 	.attrs	= dsa_slave_attrs,
 };
 
-static void dsa_master_set_mtu(struct net_device *dev, struct dsa_port *cpu_dp)
+/* Needs to be called under rtnl_lock */
+int dsa_master_set_mtu(struct net_device *dev, int mtu)
 {
-	unsigned int mtu = ETH_DATA_LEN + cpu_dp->tag_ops->overhead;
-	int err;
+	int err = -ERANGE;
 
-	rtnl_lock();
 	if (mtu <= dev->max_mtu) {
 		err = dev_set_mtu(dev, mtu);
 		if (err)
-			netdev_dbg(dev, "Unable to set MTU to include for DSA overheads\n");
+			netdev_err(dev, "Unable to set MTU to include for DSA overheads\n");
 	}
-	rtnl_unlock();
+
+	return err;
 }
 
 static void dsa_master_reset_mtu(struct net_device *dev)
@@ -344,8 +344,6 @@ int dsa_master_setup(struct net_device *dev, struct dsa_port *cpu_dp)
 {
 	int ret;
 
-	dsa_master_set_mtu(dev,  cpu_dp);
-
 	/* If we use a tagging format that doesn't have an ethertype
 	 * field, make sure that all packets from this point on get
 	 * sent to the tag format's receive function.
net/dsa/port.c +11 -0
index a18e65a474a5..428d02d3c2e7 100644
@@ -297,6 +297,17 @@ int dsa_port_mrouter(struct dsa_port *dp, bool mrouter,
 	return ds->ops->port_egress_floods(ds, port, true, mrouter);
 }
 
+int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu)
+{
+	struct dsa_notifier_mtu_info info = {
+		.sw_index = dp->ds->index,
+		.port = dp->index,
+		.mtu = new_mtu,
+	};
+
+	return dsa_port_notify(dp, DSA_NOTIFIER_MTU, &info);
+}
+
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 		     u16 vid)
 {
net/dsa/slave.c +103 -1

128 lines not on this page · raw message

net/dsa/switch.c +34 -0
index df4abe897ed6..6b0b6f9d219c 100644
@@ -52,6 +52,37 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds,
 	return 0;
 }
 
+static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port,
+				 struct dsa_notifier_mtu_info *info)
+{
+	if (ds->index == info->sw_index && port == info->port)
+		return true;
+
+	if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port))
+		return true;
+
+	return false;
+}
+
+static int dsa_switch_mtu(struct dsa_switch *ds,
+			  struct dsa_notifier_mtu_info *info)
+{
+	int port, ret;
+
+	if (!ds->ops->port_change_mtu)
+		return -EOPNOTSUPP;
+
+	for (port = 0; port < ds->num_ports; port++) {
+		if (dsa_switch_mtu_match(ds, port, info)) {
+			ret = ds->ops->port_change_mtu(ds, port, info->mtu);
+			if (ret)
+				return ret;
+		}
+	}
+
+	return 0;
+}
+
 static int dsa_switch_bridge_join(struct dsa_switch *ds,
 				  struct dsa_notifier_bridge_info *info)
 {
@@ -328,6 +359,9 @@ static int dsa_switch_event(struct notifier_block *nb,
 	case DSA_NOTIFIER_VLAN_DEL:
 		err = dsa_switch_vlan_del(ds, info);
 		break;
+	case DSA_NOTIFIER_MTU:
+		err = dsa_switch_mtu(ds, info);
+		break;
 	default:
 		err = -EOPNOTSUPP;
 		break;
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v2 2/10 net: phy: bcm7xx: Add jumbo frame configuration to PHY

In reply to Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add API to configure jumbo frame settings in PHY during initial PHY configuration.

---
 drivers/net/phy/bcm-phy-lib.c | 28 ++++++++++++++++++++++++++++
 drivers/net/phy/bcm-phy-lib.h |  1 +
 drivers/net/phy/bcm7xxx.c     |  4 ++++
 include/linux/brcmphy.h       |  1 +
 4 files changed, 34 insertions(+)
drivers/net/phy/bcm-phy-lib.c +28 -0
index e0d3310957ff..a26c80e13b43 100644
@@ -423,6 +423,34 @@ int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_28nm_a0b0_afe_config_init);
 
+int bcm_phy_enable_jumbo(struct phy_device *phydev)
+{
+	int val = 0, ret = 0;
+
+	ret = phy_write(phydev, MII_BCM54XX_AUX_CTL,
+			MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
+	if (ret < 0)
+		return ret;
+
+	val = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+
+	/* Enable extended length packet reception */
+	val |= MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN;
+	ret = phy_write(phydev, MII_BCM54XX_AUX_CTL, val);
+
+	if (ret < 0)
+		return ret;
+
+	val = phy_read(phydev, MII_BCM54XX_ECR);
+
+	/* Enable 10K byte packet length reception */
+	val |= BIT(0);
+	ret =  phy_write(phydev, MII_BCM54XX_ECR, val);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(bcm_phy_enable_jumbo);
+
 MODULE_DESCRIPTION("Broadcom PHY Library");
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Broadcom Corporation");
drivers/net/phy/bcm-phy-lib.h +1 -0
index c86fb9d1240c..129df819be8c 100644
@@ -65,5 +65,6 @@ void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
 		       struct ethtool_stats *stats, u64 *data);
 void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
 int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
+int bcm_phy_enable_jumbo(struct phy_device *phydev);
 
 #endif /* _LINUX_BCM_PHY_LIB_H */
drivers/net/phy/bcm7xxx.c +4 -0
index af8eabe7a6d4..692048d86ab1 100644
@@ -178,6 +178,10 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
 		break;
 	}
 
+	if (ret)
+		return ret;
+
+	ret =  bcm_phy_enable_jumbo(phydev);
 	if (ret)
 		return ret;
 
include/linux/brcmphy.h +1 -0
index b475e7f20d28..19bd86019e93 100644
@@ -119,6 +119,7 @@
 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL	0x00
 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB		0x0400
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA	0x0800
+#define MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN	0x4000
 
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC			0x07
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN	0x0010
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH v2 net-next 02/10] net: phy: bcm7xx: Add jumbo frame configuration to PHY

Quoted 28 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add API to configure jumbo frame settings in PHY during initial PHY configuration.

---
 drivers/net/phy/bcm-phy-lib.c | 28 ++++++++++++++++++++++++++++
 drivers/net/phy/bcm-phy-lib.h |  1 +
 drivers/net/phy/bcm7xxx.c     |  4 ++++
 include/linux/brcmphy.h       |  1 +
 4 files changed, 34 insertions(+)
drivers/net/phy/bcm-phy-lib.c +5 -0
index e0d3310957ff..a26c80e13b43 100644
@@ -423,6 +423,34 @@ int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_28nm_a0b0_afe_config_init);
 
+int bcm_phy_enable_jumbo(struct phy_device *phydev)
+{
+	int val = 0, ret = 0;
+
+	ret = phy_write(phydev, MII_BCM54XX_AUX_CTL,

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 440

Quoted 10 lines
drivers/net/phy/bcm-phy-lib.c +10 -0
+			MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
+	if (ret < 0)
+		return ret;
+
+	val = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+
+	/* Enable extended length packet reception */
+	val |= MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN;
+	ret = phy_write(phydev, MII_BCM54XX_AUX_CTL, val);
+

There are different helpers already in bcm-phy-lib, e.g. bcm54xx_auxctl_read. Also bcm_phy_write_misc() has has quite something in common with your new function. It would be good if a helper could be used here.

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 449

Quoted 9 lines
drivers/net/phy/bcm-phy-lib.c +9 -0
+	if (ret < 0)
+		return ret;
+
+	val = phy_read(phydev, MII_BCM54XX_ECR);
+
+	/* Enable 10K byte packet length reception */
+	val |= BIT(0);
+	ret =  phy_write(phydev, MII_BCM54XX_ECR, val);
+

Why not use phy_set_bits() ?

Quoted 46 lines
drivers/net/phy/bcm-phy-lib.c +4 -0
+	return ret;
+}
+EXPORT_SYMBOL_GPL(bcm_phy_enable_jumbo);
+
 MODULE_DESCRIPTION("Broadcom PHY Library");
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Broadcom Corporation");
drivers/net/phy/bcm-phy-lib.h +1 -0
index c86fb9d1240c..129df819be8c 100644
@@ -65,5 +65,6 @@ void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
 		       struct ethtool_stats *stats, u64 *data);
 void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
 int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
+int bcm_phy_enable_jumbo(struct phy_device *phydev);
 
 #endif /* _LINUX_BCM_PHY_LIB_H */
drivers/net/phy/bcm7xxx.c +4 -0
index af8eabe7a6d4..692048d86ab1 100644
@@ -178,6 +178,10 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
 		break;
 	}
 
+	if (ret)
+		return ret;
+
+	ret =  bcm_phy_enable_jumbo(phydev);
 	if (ret)
 		return ret;
 
include/linux/brcmphy.h +1 -0
index b475e7f20d28..19bd86019e93 100644
@@ -119,6 +119,7 @@
 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL	0x00
 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB		0x0400
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA	0x0800
+#define MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN	0x4000
 
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC			0x07
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN	0x0010
author maintainer
#4 lore raw

Re: [PATCH v2 net-next 02/10] net: phy: bcm7xx: Add jumbo frame configuration to PHY

Quoted 37 lines · Heiner Kallweit
Quoted 35 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add API to configure jumbo frame settings in PHY during initial PHY configuration.

---
 drivers/net/phy/bcm-phy-lib.c | 28 ++++++++++++++++++++++++++++
 drivers/net/phy/bcm-phy-lib.h |  1 +
 drivers/net/phy/bcm7xxx.c     |  4 ++++
 include/linux/brcmphy.h       |  1 +
 4 files changed, 34 insertions(+)
drivers/net/phy/bcm-phy-lib.c +12 -0
index e0d3310957ff..a26c80e13b43 100644
@@ -423,6 +423,34 @@ int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_28nm_a0b0_afe_config_init);
 
+int bcm_phy_enable_jumbo(struct phy_device *phydev)
+{
+     int val = 0, ret = 0;
+
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL,
+                     MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
+     if (ret < 0)
+             return ret;
+
+     val = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+
+     /* Enable extended length packet reception */
Quoted 9 lines

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 440

Quoted 3 lines
drivers/net/phy/bcm-phy-lib.c +3 -0
+     val |= MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN;
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL, val);
+

There are different helpers already in bcm-phy-lib, e.g. bcm54xx_auxctl_read. Also bcm_phy_write_misc() has has quite something in common with your new function. It would be good if a helper could be used here.

Thanks Heiner.
I'm not quite sure the operation is performed correctly though? My books are telling me that the "Receive Extended Packet Length" field is accessible via the Auxiliary Control Register 0x18 when the shadow value is 000, not 111 as this patch is doing. At least for BCM54xxx in terms of which the macros are defined. Am I wrong?

Quoted 12 lines

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 449

Quoted 9 lines
drivers/net/phy/bcm-phy-lib.c +9 -0
+     if (ret < 0)
+             return ret;
+
+     val = phy_read(phydev, MII_BCM54XX_ECR);
+
+     /* Enable 10K byte packet length reception */
+     val |= BIT(0);
+     ret =  phy_write(phydev, MII_BCM54XX_ECR, val);
+

Why not use phy_set_bits() ?

Well, the reason is that I didn't write the patch. I'll simplify it.

Quoted 43 lines
Quoted 43 lines
drivers/net/phy/bcm-phy-lib.c +4 -0
+     return ret;
+}
+EXPORT_SYMBOL_GPL(bcm_phy_enable_jumbo);
+
 MODULE_DESCRIPTION("Broadcom PHY Library");
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Broadcom Corporation");
drivers/net/phy/bcm-phy-lib.h +1 -0
index c86fb9d1240c..129df819be8c 100644
@@ -65,5 +65,6 @@ void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
                     struct ethtool_stats *stats, u64 *data);
 void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
 int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
+int bcm_phy_enable_jumbo(struct phy_device *phydev);
 
 #endif /* _LINUX_BCM_PHY_LIB_H */
drivers/net/phy/bcm7xxx.c +4 -0
index af8eabe7a6d4..692048d86ab1 100644
@@ -178,6 +178,10 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
              break;
      }
 
+     if (ret)
+             return ret;
+
+     ret =  bcm_phy_enable_jumbo(phydev);
      if (ret)
              return ret;
 
include/linux/brcmphy.h +1 -0
index b475e7f20d28..19bd86019e93 100644
@@ -119,6 +119,7 @@
 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL    0x00
 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB               0x0400
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA    0x0800
+#define MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN  0x4000
 
Quoted 4 lines

include/linux/brcmphy.h line 125

Quoted 3 lines
include/linux/brcmphy.h +0 -0
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC                      0x07
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN 0x0010

Regards,
-Vladimir

#5 lore raw

Re: [PATCH v2 net-next 02/10] net: phy: bcm7xx: Add jumbo frame configuration to PHY

Quoted 48 lines · Vladimir Oltean
Quoted 37 lines · Heiner Kallweit
Quoted 35 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add API to configure jumbo frame settings in PHY during initial PHY configuration.

---
 drivers/net/phy/bcm-phy-lib.c | 28 ++++++++++++++++++++++++++++
 drivers/net/phy/bcm-phy-lib.h |  1 +
 drivers/net/phy/bcm7xxx.c     |  4 ++++
 include/linux/brcmphy.h       |  1 +
 4 files changed, 34 insertions(+)
drivers/net/phy/bcm-phy-lib.c +12 -0
index e0d3310957ff..a26c80e13b43 100644
@@ -423,6 +423,34 @@ int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_28nm_a0b0_afe_config_init);
 
+int bcm_phy_enable_jumbo(struct phy_device *phydev)
+{
+     int val = 0, ret = 0;
+
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL,
+                     MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
+     if (ret < 0)
+             return ret;
+
+     val = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+
+     /* Enable extended length packet reception */
Quoted 9 lines

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 440

Quoted 3 lines
drivers/net/phy/bcm-phy-lib.c +3 -0
+     val |= MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN;
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL, val);
+

There are different helpers already in bcm-phy-lib, e.g. bcm54xx_auxctl_read. Also bcm_phy_write_misc() has has quite something in common with your new function. It would be good if a helper could be used here.

Quoted 6 lines

Thanks Heiner.
I'm not quite sure the operation is performed correctly though? My books are telling me that the "Receive Extended Packet Length" field is accessible via the Auxiliary Control Register 0x18 when the shadow value is 000, not 111 as this patch is doing. At least for BCM54xxx in terms of which the macros are defined. Am I wrong?

I can confirm that for the BCM54810 PHY as well, the extended packet length is in register 0x18 shadow 0b000.

Murali, which datsheet did you use as a reference? The internal document for the 28nm EGPHY which is what this driver is supposed to drive is also indicating the same thing.

Signature · 1 line
Florian
maintainer
#6 lore raw

Re: [PATCH v2 net-next 02/10] net: phy: bcm7xx: Add jumbo frame configuration to PHY

In reply to Vladimir Oltean
Quoted 48 lines · Vladimir Oltean
Quoted 37 lines · Heiner Kallweit
Quoted 35 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add API to configure jumbo frame settings in PHY during initial PHY configuration.

---
 drivers/net/phy/bcm-phy-lib.c | 28 ++++++++++++++++++++++++++++
 drivers/net/phy/bcm-phy-lib.h |  1 +
 drivers/net/phy/bcm7xxx.c     |  4 ++++
 include/linux/brcmphy.h       |  1 +
 4 files changed, 34 insertions(+)
drivers/net/phy/bcm-phy-lib.c +12 -0
index e0d3310957ff..a26c80e13b43 100644
@@ -423,6 +423,34 @@ int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev)
 }
 EXPORT_SYMBOL_GPL(bcm_phy_28nm_a0b0_afe_config_init);
 
+int bcm_phy_enable_jumbo(struct phy_device *phydev)
+{
+     int val = 0, ret = 0;
+
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL,
+                     MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
+     if (ret < 0)
+             return ret;
+
+     val = phy_read(phydev, MII_BCM54XX_AUX_CTL);
+
+     /* Enable extended length packet reception */
Quoted 9 lines

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 440

Quoted 3 lines
drivers/net/phy/bcm-phy-lib.c +3 -0
+     val |= MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN;
+     ret = phy_write(phydev, MII_BCM54XX_AUX_CTL, val);
+

There are different helpers already in bcm-phy-lib, e.g. bcm54xx_auxctl_read. Also bcm_phy_write_misc() has has quite something in common with your new function. It would be good if a helper could be used here.

Quoted 7 lines

Thanks Heiner.
I'm not quite sure the operation is performed correctly though? My books are telling me that the "Receive Extended Packet Length" field is accessible via the Auxiliary Control Register 0x18 when the shadow value is 000, not 111 as this patch is doing. At least for BCM54xxx in terms of which the macros are defined. Am I wrong?

I didn't check the datasheet, so I can't really comment on whether the patch does what it is supposed to do. My point was that the following pattern occurs several times in the driver:
phy_write(phydev, MII_BCM54XX_AUX_CTL, VAL_1); phy_modify(phydev, MII_BCM54XX_AUX_CTL, VAL_2, VAL_3)
(or phy_clear_bits/phy_set_bits instead of phy_modify)

Therefore a generic helper could make sense, or it could at least be written as such a two-liner always.

Quoted 67 lines
Quoted 12 lines

drivers/net/phy/bcm-phy-lib.c int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev) · line 449

Quoted 9 lines
drivers/net/phy/bcm-phy-lib.c +9 -0
+     if (ret < 0)
+             return ret;
+
+     val = phy_read(phydev, MII_BCM54XX_ECR);
+
+     /* Enable 10K byte packet length reception */
+     val |= BIT(0);
+     ret =  phy_write(phydev, MII_BCM54XX_ECR, val);
+

Why not use phy_set_bits() ?

Well, the reason is that I didn't write the patch. I'll simplify it.

Quoted 43 lines
Quoted 43 lines
drivers/net/phy/bcm-phy-lib.c +4 -0
+     return ret;
+}
+EXPORT_SYMBOL_GPL(bcm_phy_enable_jumbo);
+
 MODULE_DESCRIPTION("Broadcom PHY Library");
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Broadcom Corporation");
drivers/net/phy/bcm-phy-lib.h +1 -0
index c86fb9d1240c..129df819be8c 100644
@@ -65,5 +65,6 @@ void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
                     struct ethtool_stats *stats, u64 *data);
 void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
 int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
+int bcm_phy_enable_jumbo(struct phy_device *phydev);
 
 #endif /* _LINUX_BCM_PHY_LIB_H */
drivers/net/phy/bcm7xxx.c +4 -0
index af8eabe7a6d4..692048d86ab1 100644
@@ -178,6 +178,10 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
              break;
      }
 
+     if (ret)
+             return ret;
+
+     ret =  bcm_phy_enable_jumbo(phydev);
      if (ret)
              return ret;
 
include/linux/brcmphy.h +1 -0
index b475e7f20d28..19bd86019e93 100644
@@ -119,6 +119,7 @@
 #define MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL    0x00
 #define MII_BCM54XX_AUXCTL_ACTL_TX_6DB               0x0400
 #define MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA    0x0800
+#define MII_BCM54XX_AUXCTL_ACTL_EXT_PKT_LEN  0x4000
 
Quoted 4 lines

include/linux/brcmphy.h line 125

Quoted 3 lines
include/linux/brcmphy.h +0 -0
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC                      0x07
 #define MII_BCM54XX_AUXCTL_SHDWSEL_MISC_WIRESPEED_EN 0x0010

Regards,
-Vladimir
.

author maintainer
#7 lore raw

PATCH v2 3/10 bgmac: Add support for Jumbo frames

In reply to Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Max frame length updated to enable support for jumbo frames.

---
 drivers/net/ethernet/broadcom/bgmac.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bgmac.h +2 -1
index 40d02fec2747..041ad069b5c8 100644
@@ -366,7 +366,8 @@
 #define BGMAC_RX_FRAME_OFFSET			30		/* There are 2 unused bytes between header and real data */
 #define BGMAC_RX_BUF_OFFSET			(NET_SKB_PAD + NET_IP_ALIGN - \
 						 BGMAC_RX_FRAME_OFFSET)
-#define BGMAC_RX_MAX_FRAME_SIZE			1536		/* Copied from b44/tg3 */
+/* Jumbo frame size */
+#define BGMAC_RX_MAX_FRAME_SIZE			9720
 #define BGMAC_RX_BUF_SIZE			(BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE)
 #define BGMAC_RX_ALLOC_SIZE			(SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \
 						 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
Signature · 1 line
2.17.1
author maintainer
#8 lore raw

PATCH v2 4/10 bgmac: Add MTU configuration support to the driver

In reply to Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add bgmac_change_mtu API to configure new mtu settings in bgmac driver.

---
 drivers/net/ethernet/broadcom/bgmac.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/broadcom/bgmac.c +10 -0
index 1bb07a5d82c9..c530dff0353b 100644
@@ -1248,6 +1248,14 @@ static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)
 	return 0;
 }
 
+static int bgmac_change_mtu(struct net_device *net_dev, int mtu)
+{
+	struct bgmac *bgmac = netdev_priv(net_dev);
+
+	bgmac_write(bgmac, BGMAC_RXMAX_LENGTH, 32 + mtu);
+	return 0;
+}
+
 static const struct net_device_ops bgmac_netdev_ops = {
 	.ndo_open		= bgmac_open,
 	.ndo_stop		= bgmac_stop,
@@ -1256,6 +1264,7 @@ static const struct net_device_ops bgmac_netdev_ops = {
 	.ndo_set_mac_address	= bgmac_set_mac_address,
 	.ndo_validate_addr	= eth_validate_addr,
 	.ndo_do_ioctl           = phy_do_ioctl_running,
+	.ndo_change_mtu		= bgmac_change_mtu,
 };
 
 /**************************************************
@@ -1529,6 +1538,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
 	net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 	net_dev->hw_features = net_dev->features;
 	net_dev->vlan_features = net_dev->features;
+	net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE;
 
 	err = register_netdev(bgmac->net_dev);
 	if (err) {
Signature · 1 line
2.17.1
author maintainer
#9 lore raw

PATCH v2 5/10 bgmac: Add DMA support to handle frames beyond 8192 bytes

In reply to Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add DMA support in driver to handle jumbo frames beyond 8192 bytes. Also update jumbo frame max size to include FCS, the DMA packet length received includes FCS.

---
 drivers/net/ethernet/broadcom/bgmac.c | 4 +++-
 drivers/net/ethernet/broadcom/bgmac.h | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +3 -1
index c530dff0353b..98ec1b8a7d8e 100644
@@ -1538,7 +1538,9 @@ int bgmac_enet_probe(struct bgmac *bgmac)
 	net_dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 	net_dev->hw_features = net_dev->features;
 	net_dev->vlan_features = net_dev->features;
-	net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE;
+
+	/* Omit FCS from max MTU size */
+	net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE - ETH_FCS_LEN;
 
 	err = register_netdev(bgmac->net_dev);
 	if (err) {
drivers/net/ethernet/broadcom/bgmac.h +3 -3
index 041ad069b5c8..351c598a3ec6 100644
@@ -351,7 +351,7 @@
 #define BGMAC_DESC_CTL0_IOC			0x20000000	/* IRQ on complete */
 #define BGMAC_DESC_CTL0_EOF			0x40000000	/* End of frame */
 #define BGMAC_DESC_CTL0_SOF			0x80000000	/* Start of frame */
-#define BGMAC_DESC_CTL1_LEN			0x00001FFF
+#define BGMAC_DESC_CTL1_LEN			0x00003FFF
 
 #define BGMAC_PHY_NOREGS			BRCM_PSEUDO_PHY_ADDR
 #define BGMAC_PHY_MASK				0x1F
@@ -366,8 +366,8 @@
 #define BGMAC_RX_FRAME_OFFSET			30		/* There are 2 unused bytes between header and real data */
 #define BGMAC_RX_BUF_OFFSET			(NET_SKB_PAD + NET_IP_ALIGN - \
 						 BGMAC_RX_FRAME_OFFSET)
-/* Jumbo frame size */
-#define BGMAC_RX_MAX_FRAME_SIZE			9720
+/* Jumbo frame size with FCS */
+#define BGMAC_RX_MAX_FRAME_SIZE			9724
 #define BGMAC_RX_BUF_SIZE			(BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE)
 #define BGMAC_RX_ALLOC_SIZE			(SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \
 						 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH v2 net-next 05/10] bgmac: Add DMA support to handle frames beyond 8192 bytes

Quoted 9 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add DMA support in driver to handle jumbo frames beyond 8192 bytes. Also update jumbo frame max size to include FCS, the DMA packet length received includes FCS.

This patch and the previous one should probably be squashed together. I will try to get this tested on a Northstar platform.

Signature · 1 line
Florian
author maintainer
#11 lore raw

PATCH v2 6/10 net: dsa: b53: Add MTU configuration support

In reply to Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add b53_change_mtu API to configure mtu settings in B53 switch. Enable jumbo frame support if configured mtu size is for jumbo frame. Also configure BCM583XX devices to send and receive jumbo frames when ports are configured with 10/100 Mbps speed.

---
 drivers/net/dsa/b53/b53_common.c | 35 ++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
drivers/net/dsa/b53/b53_common.c +35 -0
index ceafce446317..e32e05803800 100644
@@ -644,6 +644,7 @@ EXPORT_SYMBOL(b53_brcm_hdr_setup);
 
 static void b53_enable_cpu_port(struct b53_device *dev, int port)
 {
+	u32 port_mask;
 	u8 port_ctrl;
 
 	/* BCM5325 CPU port is at 8 */
@@ -658,6 +659,14 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
 	b53_brcm_hdr_setup(dev->ds, port);
 
 	b53_br_egress_floods(dev->ds, port, true, true);
+
+	b53_read32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, &port_mask);
+
+	if (dev->chip_id == BCM583XX_DEVICE_ID)
+		port_mask |= JPM_10_100_JUMBO_EN;
+
+	port_mask |= BIT(port);
+	b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask);
 }
 
 static void b53_enable_mib(struct b53_device *dev)
@@ -2065,6 +2074,30 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
 }
 EXPORT_SYMBOL(b53_set_mac_eee);
 
+static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
+{
+	struct b53_device *dev = ds->priv;
+	u32 port_mask;
+
+	if (dev->chip_id == BCM58XX_DEVICE_ID ||
+	    is5325(dev) || is5365(dev))
+		return -EOPNOTSUPP;
+
+	b53_read32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, &port_mask);
+
+	if (mtu >= JMS_MIN_SIZE)
+		port_mask |= BIT(port);
+	else
+		port_mask &= ~BIT(port);
+
+	return b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask);
+}
+
+static int b53_get_max_mtu(struct dsa_switch *ds, int port)
+{
+	return JMS_MAX_SIZE;
+}
+
 static const struct dsa_switch_ops b53_switch_ops = {
 	.get_tag_protocol	= b53_get_tag_protocol,
 	.setup			= b53_setup,
@@ -2102,6 +2135,8 @@ static const struct dsa_switch_ops b53_switch_ops = {
 	.port_mdb_prepare	= b53_mdb_prepare,
 	.port_mdb_add		= b53_mdb_add,
 	.port_mdb_del		= b53_mdb_del,
+	.port_max_mtu		= b53_get_max_mtu,
+	.port_change_mtu	= b53_change_mtu,
 };
 
 struct b53_chip_data {
Signature · 1 line
2.17.1
Acked-by on v2 6/10
#12 lore raw

Re: [PATCH v2 net-next 06/10] net: dsa: b53: Add MTU configuration support

Quoted 9 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add b53_change_mtu API to configure mtu settings in B53 switch. Enable jumbo frame support if configured mtu size is for jumbo frame. Also configure BCM583XX devices to send and receive jumbo frames when ports are configured with 10/100 Mbps speed.

[snip]

drivers/net/dsa/b53/b53_common.c static void b53_enable_cpu_port(struct b53_device *dev, int port) · line 669

Quoted 12 lines
drivers/net/dsa/b53/b53_common.c +8 -0
@@ -658,6 +659,14 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
 	b53_brcm_hdr_setup(dev->ds, port);
 
 	b53_br_egress_floods(dev->ds, port, true, true);
+
+	b53_read32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, &port_mask);
+
+	if (dev->chip_id == BCM583XX_DEVICE_ID)
+		port_mask |= JPM_10_100_JUMBO_EN;
+
+	port_mask |= BIT(port);
+	b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask);

This should eventually be brought into b53_set_jumbo() where we already have existing logic to configure whether to accept jumbo frames and for 10/100M ports, too, not strictly necessary for now though:

Signature · 1 line
Florian
author maintainer
#13 lore raw

Re: [PATCH v2 net-next 06/10] net: dsa: b53: Add MTU configuration support

Quoted 33 lines · Florian Fainelli
Quoted 9 lines · Vladimir Oltean

From: Murali Krishna Policharla <[email protected]>

Add b53_change_mtu API to configure mtu settings in B53 switch. Enable jumbo frame support if configured mtu size is for jumbo frame. Also configure BCM583XX devices to send and receive jumbo frames when ports are configured with 10/100 Mbps speed.

[snip]

drivers/net/dsa/b53/b53_common.c static void b53_enable_cpu_port(struct b53_device *dev, int port) · line 669

Quoted 12 lines
drivers/net/dsa/b53/b53_common.c +8 -0
@@ -658,6 +659,14 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port)
      b53_brcm_hdr_setup(dev->ds, port);
 
      b53_br_egress_floods(dev->ds, port, true, true);
+
+     b53_read32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, &port_mask);
+
+     if (dev->chip_id == BCM583XX_DEVICE_ID)
+             port_mask |= JPM_10_100_JUMBO_EN;
+
+     port_mask |= BIT(port);
+     b53_write32(dev, B53_JUMBO_PAGE, dev->jumbo_pm_reg, port_mask);

This should eventually be brought into b53_set_jumbo() where we already have existing logic to configure whether to accept jumbo frames and for 10/100M ports, too, not strictly necessary for now though:

Quoted 3 lines

--
Florian

What do you mean should be done? This?

     if (!is5325(dev) && !is5365(dev))

- b53_set_jumbo(dev, dev->enable_jumbo, false);
+ b53_set_jumbo(dev, dev->enable_jumbo, is58xx(dev));

Regards,
-Vladimir

author maintainer
#14 lore raw

PATCH v2 7/10 net: dsa: sja1105: Implement the port MTU callbacks

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

On this switch, the frame length enforcements are performed by the ingress policers. There are 2 types of those: regular L2 (also called best-effort) and Virtual Link policers (an ARINC664/AFDX concept for defining L2 streams with certain QoS abilities). To avoid future confusion, I prefer to call the reset reason "Best-effort policers", even though the VL policers are not yet supported.

We also need to change the setup of the initial static config, such that DSA calls to .change_mtu (which are expensive) become no-ops and don't reset the switch 5 times.

A driver-level decision is to unconditionally allow single VLAN-tagged traffic on all ports. The CPU port must accept an additional VLAN header for the DSA tag, which is again a driver-level decision.

The policers actually count bytes not only from the SDU, but also from the Ethernet header and FCS, so those need to be accounted for as well.

---
 drivers/net/dsa/sja1105/sja1105.h      |  1 +
 drivers/net/dsa/sja1105/sja1105_main.c | 48 +++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 4 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +1 -0
index a358fc89a6db..0e5b739b2fe8 100644
@@ -126,6 +126,7 @@ enum sja1105_reset_reason {
 	SJA1105_RX_HWTSTAMPING,
 	SJA1105_AGEING_TIME,
 	SJA1105_SCHEDULING,
+	SJA1105_BEST_EFFORT_POLICING,
 };
 
 int sja1105_static_config_reload(struct sja1105_private *priv,
drivers/net/dsa/sja1105/sja1105_main.c +44 -4

86 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v2 7/10
#15 lore raw

Re: [PATCH v2 net-next 07/10] net: dsa: sja1105: Implement the port MTU callbacks

Quoted 13 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

On this switch, the frame length enforcements are performed by the ingress policers. There are 2 types of those: regular L2 (also called best-effort) and Virtual Link policers (an ARINC664/AFDX concept for defining L2 streams with certain QoS abilities). To avoid future confusion, I prefer to call the reset reason "Best-effort policers", even though the VL policers are not yet supported.

We also need to change the setup of the initial static config, such that DSA calls to .change_mtu (which are expensive) become no-ops and don't reset the switch 5 times.

Quoted 7 lines

A driver-level decision is to unconditionally allow single VLAN-tagged traffic on all ports. The CPU port must accept an additional VLAN header for the DSA tag, which is again a driver-level decision.

The policers actually count bytes not only from the SDU, but also from the Ethernet header and FCS, so those need to be accounted for as well.

Quoted 1 line
Signature · 1 line
Florian
author maintainer
#16 lore raw

PATCH v2 8/10 net: dsa: vsc73xx: Make the MTU configurable

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Instead of hardcoding the MTU to the maximum value allowed by the hardware, obey the value known by the operating system.

---
 drivers/net/dsa/vitesse-vsc73xx-core.c | 30 +++++++++++++++++---------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/net/dsa/vitesse-vsc73xx-core.c +20 -10
index 6e21a2a5cf01..19ce4aa0973b 100644
@@ -664,16 +664,6 @@ static void vsc73xx_init_port(struct vsc73xx *vsc, int port)
 		      VSC73XX_MAC_CFG_TX_EN |
 		      VSC73XX_MAC_CFG_RX_EN);
 
-	/* Max length, we can do up to 9.6 KiB, so allow that.
-	 * According to application not "VSC7398 Jumbo Frames" setting
-	 * up the MTU to 9.6 KB does not affect the performance on standard
-	 * frames, so just enable it. It is clear from the application note
-	 * that "9.6 kilobytes" == 9600 bytes.
-	 */
-	vsc73xx_write(vsc, VSC73XX_BLOCK_MAC,
-		      port,
-		      VSC73XX_MAXLEN, 9600);
-
 	/* Flow control for the CPU port:
 	 * Use a zero delay pause frame when pause condition is left
 	 * Obey pause control frames
@@ -1030,6 +1020,24 @@ static void vsc73xx_get_ethtool_stats(struct dsa_switch *ds, int port,
 	}
 }
 
+static int vsc73xx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+{
+	struct vsc73xx *vsc = ds->priv;
+
+	return vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port,
+			     VSC73XX_MAXLEN, new_mtu);
+}
+
+/* According to application not "VSC7398 Jumbo Frames" setting
+ * up the MTU to 9.6 KB does not affect the performance on standard
+ * frames. It is clear from the application note that
+ * "9.6 kilobytes" == 9600 bytes.
+ */
+static int vsc73xx_get_max_mtu(struct dsa_switch *ds, int port)
+{
+	return 9600;
+}
+
 static const struct dsa_switch_ops vsc73xx_ds_ops = {
 	.get_tag_protocol = vsc73xx_get_tag_protocol,
 	.setup = vsc73xx_setup,
@@ -1041,6 +1049,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = {
 	.get_sset_count = vsc73xx_get_sset_count,
 	.port_enable = vsc73xx_port_enable,
 	.port_disable = vsc73xx_port_disable,
+	.port_change_mtu = vsc73xx_change_mtu,
+	.port_max_mtu = vsc73xx_get_max_mtu,
 };
 
 static int vsc73xx_gpio_get(struct gpio_chip *chip, unsigned int offset)
Signature · 1 line
2.17.1
author maintainer
#18 lore raw

PATCH v2 9/10 net: dsa: felix: support changing the MTU

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Changing the MTU for this switch means altering the DEV_GMII:MAC_CFG_STATUS:MAC_MAXLEN_CFG field MAX_LEN, which in turn limits the size of frames that can be received.

Special accounting needs to be done for the DSA CPU port (NPI port in hardware terms). The NPI port configuration needs to be held inside the private ocelot structure, since it is now accessed from multiple places.

---
 drivers/net/dsa/ocelot/felix.c     | 18 ++++++++++++
 drivers/net/ethernet/mscc/ocelot.c | 45 +++++++++++++++++++++++-------
 include/soc/mscc/ocelot.h          |  7 +++++
 3 files changed, 60 insertions(+), 10 deletions(-)
drivers/net/dsa/ocelot/felix.c +18 -0
index 9f9efb974003..598f42f14525 100644
@@ -610,6 +610,22 @@ static bool felix_txtstamp(struct dsa_switch *ds, int port,
 	return false;
 }
 
+static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
+{
+	struct ocelot *ocelot = ds->priv;
+
+	ocelot_port_set_maxlen(ocelot, port, new_mtu);
+
+	return 0;
+}
+
+static int felix_get_max_mtu(struct dsa_switch *ds, int port)
+{
+	struct ocelot *ocelot = ds->priv;
+
+	return ocelot_get_max_mtu(ocelot, port);
+}
+
 static int felix_cls_flower_add(struct dsa_switch *ds, int port,
 				struct flow_cls_offload *cls, bool ingress)
 {
@@ -665,6 +681,8 @@ static const struct dsa_switch_ops felix_switch_ops = {
 	.port_hwtstamp_set	= felix_hwtstamp_set,
 	.port_rxtstamp		= felix_rxtstamp,
 	.port_txtstamp		= felix_txtstamp,
+	.port_change_mtu	= felix_change_mtu,
+	.port_max_mtu		= felix_get_max_mtu,
 	.cls_flower_add		= felix_cls_flower_add,
 	.cls_flower_del		= felix_cls_flower_del,
 	.cls_flower_stats	= felix_cls_flower_stats,
drivers/net/ethernet/mscc/ocelot.c +35 -10

79 lines not on this page · raw message

include/soc/mscc/ocelot.h +7 -0
index db2fb14bd775..23a78d927838 100644
@@ -522,6 +522,11 @@ struct ocelot {
 	 */
 	u8				num_phys_ports;
 
+	int				npi;
+
+	enum ocelot_tag_prefix		inj_prefix;
+	enum ocelot_tag_prefix		xtr_prefix;
+
 	u32				*lags;
 
 	struct list_head		multicast;
@@ -616,6 +621,8 @@ int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr);
 int ocelot_port_add_txtstamp_skb(struct ocelot_port *ocelot_port,
 				 struct sk_buff *skb);
 void ocelot_get_txtstamp(struct ocelot *ocelot);
+void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu);
+int ocelot_get_max_mtu(struct ocelot *ocelot, int port);
 int ocelot_cls_flower_replace(struct ocelot *ocelot, int port,
 			      struct flow_cls_offload *f, bool ingress);
 int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
Signature · 1 line
2.17.1
Reviewed-by on v2 9/10
#19 lore raw

Re: [PATCH v2 net-next 09/10] net: dsa: felix: support changing the MTU

Quoted 11 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

Changing the MTU for this switch means altering the DEV_GMII:MAC_CFG_STATUS:MAC_MAXLEN_CFG field MAX_LEN, which in turn limits the size of frames that can be received.

Special accounting needs to be done for the DSA CPU port (NPI port in hardware terms). The NPI port configuration needs to be held inside the private ocelot structure, since it is now accessed from multiple places.

Signature · 1 line
Florian
author maintainer
#20 lore raw

PATCH v2 10/10 net: bridge: implement auto-normalization of MTU for hardware datapath

In reply to Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

Florian's idea was that all hardware ports having the same netdev_port_same_parent_id should be adjusted to have the same MTU. The MTU that we attempt to configure the ports to is the most recently modified MTU. The attempt is to follow user intention as closely as possible and not be annoying at that.

So there are 2 cases really:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

The above sequence will make sw0p0 inherit MTU 1400 as well.

The second case:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 master br0
ip link set dev sw0p0 mtu 1400

This sequence will make sw0p1 inherit MTU 1400 from sw0p0.

---
 net/bridge/br.c         |  1 +
 net/bridge/br_if.c      | 93 +++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_private.h |  1 +
 3 files changed, 95 insertions(+)
net/bridge/br.c +1 -0
index b6fe30e3768f..5f05380df1ee 100644
@@ -57,6 +57,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 
 	switch (event) {
 	case NETDEV_CHANGEMTU:
+		br_mtu_normalization(br, dev);
 		br_mtu_auto_adjust(br);
 		break;
 
net/bridge/br_if.c +93 -0

105 lines not on this page · raw message

net/bridge/br_private.h +1 -0
index 1f97703a52ff..df010e36228e 100644
@@ -693,6 +693,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
 	      struct netlink_ext_ack *extack);
 int br_del_if(struct net_bridge *br, struct net_device *dev);
 void br_mtu_auto_adjust(struct net_bridge *br);
+void br_mtu_normalization(struct net_bridge *br, struct net_device *br_if);
 netdev_features_t br_features_recompute(struct net_bridge *br,
 					netdev_features_t features);
 void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
Signature · 1 line
2.17.1
#21 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 65 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

Florian's idea was that all hardware ports having the same netdev_port_same_parent_id should be adjusted to have the same MTU. The MTU that we attempt to configure the ports to is the most recently modified MTU. The attempt is to follow user intention as closely as possible and not be annoying at that.

So there are 2 cases really:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

The above sequence will make sw0p0 inherit MTU 1400 as well.

The second case:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 master br0
ip link set dev sw0p0 mtu 1400

This sequence will make sw0p1 inherit MTU 1400 from sw0p0.

---
 net/bridge/br.c         |  1 +
 net/bridge/br_if.c      | 93 +++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_private.h |  1 +
 3 files changed, 95 insertions(+)
net/bridge/br.c +0 -0
index b6fe30e3768f..5f05380df1ee 100644

net/bridge/br.c static int br_device_event(struct notifier_block *unused, unsigned long event, v · line 60

Quoted 4 lines
net/bridge/br.c +1 -0
@@ -57,6 +57,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 
 	switch (event) {
 	case NETDEV_CHANGEMTU:
+		br_mtu_normalization(br, dev);

I do not remember if you are allowed to sleep in a netdevice notifier, I believe not, so you may need to pass a gfp_t to br_mtu_normalization for allocations to be GFP_ATOMIC when called from that context, and GFP_KERNEL from br_add_if().

It would be nice if we could avoid doing these allocations when called from the netdev notifier though, could we just keep the information around since the br_hw_port follows the same lifetime as the net_bridge_port structure. Other than that, this looks good to me, thanks!

Signature · 1 line
Florian
author maintainer
#22 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 70 lines · Florian Fainelli
Quoted 66 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

Florian's idea was that all hardware ports having the same netdev_port_same_parent_id should be adjusted to have the same MTU. The MTU that we attempt to configure the ports to is the most recently modified MTU. The attempt is to follow user intention as closely as possible and not be annoying at that.

So there are 2 cases really:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

The above sequence will make sw0p0 inherit MTU 1400 as well.

The second case:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 master br0
ip link set dev sw0p0 mtu 1400

This sequence will make sw0p1 inherit MTU 1400 from sw0p0.

---
 net/bridge/br.c         |  1 +
 net/bridge/br_if.c      | 93 +++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_private.h |  1 +
 3 files changed, 95 insertions(+)
net/bridge/br.c +0 -0
index b6fe30e3768f..5f05380df1ee 100644
@@ -57,6 +57,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 
Quoted 9 lines

net/bridge/br.c static int br_device_event(struct notifier_block *unused, unsigned long event, v · line 60

Quoted 3 lines
net/bridge/br.c +1 -0
      switch (event) {
      case NETDEV_CHANGEMTU:
+             br_mtu_normalization(br, dev);

I do not remember if you are allowed to sleep in a netdevice notifier, I believe not, so you may need to pass a gfp_t to br_mtu_normalization for allocations to be GFP_ATOMIC when called from that context, and GFP_KERNEL from br_add_if().

Not only can you sleep, but the RTNL is also held. It's a bliss!

Quoted 4 lines

It would be nice if we could avoid doing these allocations when called from the netdev notifier though, could we just keep the information around since the br_hw_port follows the same lifetime as the net_bridge_port structure. Other than that, this looks good to me, thanks!

So does this comment still apply then?
I wanted to be as self-contained as possible, it's a pain to keep the old_mtu list for rollback as the code probably shows. I wouldn't go as far as to add more stuff into struct net_bridge_port for the sole purpose of passing data around in this function.

Quoted 2 lines

--
Florian

Thanks,
-Vladimir

#23 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

In reply to Vladimir Oltean

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Quoted 169 lines

Florian's idea was that all hardware ports having the same netdev_port_same_parent_id should be adjusted to have the same MTU. The MTU that we attempt to configure the ports to is the most recently modified MTU. The attempt is to follow user intention as closely as possible and not be annoying at that.

So there are 2 cases really:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

The above sequence will make sw0p0 inherit MTU 1400 as well.

The second case:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 master br0
ip link set dev sw0p0 mtu 1400

This sequence will make sw0p1 inherit MTU 1400 from sw0p0.

---
 net/bridge/br.c         |  1 +
 net/bridge/br_if.c      | 93 +++++++++++++++++++++++++++++++++++++++++
 net/bridge/br_private.h |  1 +
 3 files changed, 95 insertions(+)
net/bridge/br.c +1 -0
index b6fe30e3768f..5f05380df1ee 100644
@@ -57,6 +57,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
 
 	switch (event) {
 	case NETDEV_CHANGEMTU:
+		br_mtu_normalization(br, dev);
 		br_mtu_auto_adjust(br);
 		break;
 
net/bridge/br_if.c +93 -0
index 4fe30b182ee7..a228668920a6 100644
@@ -514,6 +514,98 @@ void br_mtu_auto_adjust(struct net_bridge *br)
 	br_opt_toggle(br, BROPT_MTU_SET_BY_USER, false);
 }
 
+struct br_hw_port {
+	struct list_head list;
+	struct net_device *dev;
+	int old_mtu;
+};
+
+static int br_hw_port_list_set_mtu(struct list_head *hw_port_list, int mtu)
+{
+	const struct br_hw_port *p;
+	int err;
+
+	list_for_each_entry(p, hw_port_list, list) {
+		if (p->dev->mtu == mtu)
+			continue;
+
+		err = dev_set_mtu(p->dev, mtu);
+		if (err)
+			goto rollback;
+	}
+
+	return 0;
+
+rollback:
+	list_for_each_entry_continue_reverse(p, hw_port_list, list) {
+		if (p->dev->mtu == p->old_mtu)
+			continue;
+
+		if (dev_set_mtu(p->dev, p->old_mtu))
+			netdev_err(p->dev, "Failed to restore MTU\n");
+	}
+
+	return err;
+}
+
+static void br_hw_port_list_free(struct list_head *hw_port_list)
+{
+	struct br_hw_port *p, *n;
+
+	list_for_each_entry_safe(p, n, hw_port_list, list)
+		kfree(p);
+}
+
+/* Make the hardware datapath to/from @br_if limited to a common MTU */
+void br_mtu_normalization(struct net_bridge *br, struct net_device *br_if)
+{
+	const struct net_bridge_port *p;
+	struct list_head hw_port_list;
+	int min_mtu = ETH_MAX_MTU;
+	int err;
+
+	INIT_LIST_HEAD(&hw_port_list);
+
+	/* Populate the list of ports that are part of the same hardware bridge
+	 * as the newly added port
+	 */
+	list_for_each_entry(p, &br->port_list, list) {
+		struct br_hw_port *hw_port;
+
+		if (!netdev_port_same_parent_id(p->dev, br_if))
+			continue;
+
+		if (min_mtu > p->dev->mtu)
+			min_mtu = p->dev->mtu;
+
+		hw_port = kzalloc(sizeof(*hw_port), GFP_KERNEL);
+		if (!hw_port)
+			goto out;
+
+		hw_port->dev = p->dev;
+		hw_port->old_mtu = p->dev->mtu;
+
+		list_add(&hw_port->list, &hw_port_list);
+	}
+
+	/* Attempt to configure the entire hardware bridge to the newly added
+	 * interface's MTU first, regardless of whether the intention of the
+	 * user was to raise or lower it.
+	 */
+	err = br_hw_port_list_set_mtu(&hw_port_list, br_if->mtu);
+	if (!err)
+		goto out;
+
+	/* Clearly that didn't work out so well, so just set the minimum MTU on
+	 * all hardware bridge ports now. If this fails too, then all ports will
+	 * still have their old MTU rolled back anyway.
+	 */
+	br_hw_port_list_set_mtu(&hw_port_list, min_mtu);
+
+out:
+	br_hw_port_list_free(&hw_port_list);
+}
+
 static void br_set_gso_limits(struct net_bridge *br)
 {
 	unsigned int gso_max_size = GSO_MAX_SIZE;
@@ -676,6 +768,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
 	if (changed_addr)
 		call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);
 
+	br_mtu_normalization(br, dev);
 	br_mtu_auto_adjust(br);
 	br_set_gso_limits(br);
 
net/bridge/br_private.h +1 -0
index 1f97703a52ff..df010e36228e 100644
@@ -693,6 +693,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
 	      struct netlink_ext_ack *extack);
 int br_del_if(struct net_bridge *br, struct net_device *dev);
 void br_mtu_auto_adjust(struct net_bridge *br);
+void br_mtu_normalization(struct net_bridge *br, struct net_device *br_if);
 netdev_features_t br_features_recompute(struct net_bridge *br,
 					netdev_features_t features);
 void br_port_flags_change(struct net_bridge_port *port, unsigned long mask);
Signature · 1 line
2.17.1
author maintainer
#24 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Hi Ido,

Quoted 37 lines · Ido Schimmel

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

Quoted 7 lines

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Actually I think the problem can be better understood if I explain what the switches I'm dealing with look like.
None of them really has a 'MTU' register. They perform length-based admission control on RX. At this moment in time I don't think anybody wants to introduce an MRU knob in iproute2, so we're adjusting that maximum ingress length through the MTU. But it becomes an inverted problem, since the 'MTU' needs to be controlled for all possible sources of traffic that are going to egress on this port, in order for the real MTU on the port itself to be observed.

Regards,
-Vladimir

#25 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 48 lines · Vladimir Oltean

Hi Ido,

Quoted 37 lines · Ido Schimmel

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

Quoted 7 lines

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Quoted 4 lines

Actually I think the problem can be better understood if I explain what the switches I'm dealing with look like.
None of them really has a 'MTU' register. They perform length-based admission control on RX.

IIUC, by that you mean that these switches only perform length-based filtering on RX, but not on TX?

Quoted 6 lines

At this moment in time I don't think anybody wants to introduce an MRU knob in iproute2, so we're adjusting that maximum ingress length through the MTU. But it becomes an inverted problem, since the 'MTU' needs to be controlled for all possible sources of traffic that are going to egress on this port, in order for the real MTU on the port itself to be observed.

Looking at your example from the changelog:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

Without your patch, after these commands sw0p0 has an MTU of 1500 and sw0p1 has an MTU of 1400. Are you saying that a frame with a length of 1450 bytes received on sw0p0 will be able to egress sw0p1 (assuming it should be forwarded there)?

If so, then I think I understand the problem. However, I don't think such code belongs in the bridge driver as this restriction does not apply to all switches. Also, I think that having the kernel change MTU of port A following MTU change of port B is a bit surprising and not intuitive.

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

author maintainer
#26 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 50 lines · Ido Schimmel
Quoted 48 lines · Vladimir Oltean

Hi Ido,

Quoted 44 lines · Ido Schimmel

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Quoted 8 lines
Quoted 4 lines

Actually I think the problem can be better understood if I explain what the switches I'm dealing with look like.
None of them really has a 'MTU' register. They perform length-based admission control on RX.

IIUC, by that you mean that these switches only perform length-based filtering on RX, but not on TX?

Yes.

Quoted 9 lines
Quoted 6 lines

At this moment in time I don't think anybody wants to introduce an MRU knob in iproute2, so we're adjusting that maximum ingress length through the MTU. But it becomes an inverted problem, since the 'MTU' needs to be controlled for all possible sources of traffic that are going to egress on this port, in order for the real MTU on the port itself to be observed.

Looking at your example from the changelog:

Quoted 9 lines

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

Without your patch, after these commands sw0p0 has an MTU of 1500 and sw0p1 has an MTU of 1400. Are you saying that a frame with a length of 1450 bytes received on sw0p0 will be able to egress sw0p1 (assuming it should be forwarded there)?

Yes.

Quoted 3 lines

If so, then I think I understand the problem. However, I don't think such code belongs in the bridge driver as this restriction does not apply to all switches.

How do Mellanox switches deal with this?

Quoted 4 lines

Also, I think that having the kernel change MTU
of port A following MTU change of port B is a bit surprising and not intuitive.

It already changes the MTU of br0, this just goes along the same path.

Quoted 5 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

I suppose that is an alternative approach. This would be done from the DSA core then? But instead of veto, just do the normalization thing.

Thanks,
-Vladimir

#27 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 81 lines · Vladimir Oltean
Quoted 50 lines · Ido Schimmel
Quoted 48 lines · Vladimir Oltean

Hi Ido,

Quoted 44 lines · Ido Schimmel

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Quoted 8 lines
Quoted 4 lines

Actually I think the problem can be better understood if I explain what the switches I'm dealing with look like.
None of them really has a 'MTU' register. They perform length-based admission control on RX.

IIUC, by that you mean that these switches only perform length-based filtering on RX, but not on TX?

Yes.

Quoted 9 lines
Quoted 6 lines

At this moment in time I don't think anybody wants to introduce an MRU knob in iproute2, so we're adjusting that maximum ingress length through the MTU. But it becomes an inverted problem, since the 'MTU' needs to be controlled for all possible sources of traffic that are going to egress on this port, in order for the real MTU on the port itself to be observed.

Looking at your example from the changelog:

Quoted 9 lines

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

Without your patch, after these commands sw0p0 has an MTU of 1500 and sw0p1 has an MTU of 1400. Are you saying that a frame with a length of 1450 bytes received on sw0p0 will be able to egress sw0p1 (assuming it should be forwarded there)?

Quoted 7 lines

Yes.

Quoted 3 lines

If so, then I think I understand the problem. However, I don't think such code belongs in the bridge driver as this restriction does not apply to all switches.

How do Mellanox switches deal with this?

Frames will be discarded on the egress of sw0p1.

Quoted 7 lines
Quoted 5 lines

Also, I think that having the kernel change MTU
of port A following MTU change of port B is a bit surprising and not intuitive.

It already changes the MTU of br0, this just goes along the same path.

Yea, but this is an established behavior already. And it applies regardless if the data path is offloaded or not, unlike this change.

Quoted 8 lines
Quoted 5 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

I suppose that is an alternative approach. This would be done from the DSA core then? But instead of veto, just do the normalization thing.

Not really my call, but I think the veto is better because you are being explicit about it and informing the user with an appropriate message.

Quoted 3 lines

Thanks,
-Vladimir

author maintainer
#28 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 10 lines · Ido Schimmel
Quoted 8 lines · Vladimir Oltean
Quoted 6 lines · Ido Schimmel

Also, I think that having the kernel change MTU
of port A following MTU change of port B is a bit surprising and not intuitive.

Quoted 5 lines
Quoted 1 line

It already changes the MTU of br0, this just goes along the same path.

Yea, but this is an established behavior already. And it applies regardless if the data path is offloaded or not, unlike this change.

I don't understand the 'established behavior' argument.
And I need to make a correction regarding the fact that it applies regardless of whether the data path is offloaded or not.
If the data path is offloaded, it applies, sure, but it has no effect. That is my issue with it.

Regards,
-Vladimir

#29 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 11 lines · Vladimir Oltean
Quoted 10 lines · Ido Schimmel
Quoted 8 lines · Vladimir Oltean
Quoted 6 lines · Ido Schimmel

Also, I think that having the kernel change MTU
of port A following MTU change of port B is a bit surprising and not intuitive.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

It already changes the MTU of br0, this just goes along the same path.

Yea, but this is an established behavior already. And it applies regardless if the data path is offloaded or not, unlike this change.

I don't understand the 'established behavior' argument.

I meant that this behavior is always the same. There is no difference between pre-5.7 kernels and later ones.

Quoted 4 lines

And I need to make a correction regarding the fact that it applies regardless of whether the data path is offloaded or not.
If the data path is offloaded, it applies, sure, but it has no effect. That is my issue with it.

But it does have effect. At least on switches that support L3 offload. If the MTU of the bridge is changed, then we also change the MTU of the corresponding router interface (RIF).

#30 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

In reply to Ido Schimmel
Quoted 81 lines · Ido Schimmel
Quoted 48 lines · Vladimir Oltean

Hi Ido,

Quoted 37 lines · Ido Schimmel

Hi Vladimir,

Quoted 25 lines · Vladimir Oltean

From: Vladimir Oltean <[email protected]>

In the initial attempt to add MTU configuration for DSA:

https://patchwork.ozlabs.org/cover/1199868/

Florian raised a concern about the bridge MTU normalization logic (when you bridge an interface with MTU 9000 and one with MTU 1500). His expectation was that the bridge would automatically change the MTU of all its slave ports to the minimum MTU, if those slaves are part of the same hardware bridge. However, it doesn't do that, and for good reason, I think. What br_mtu_auto_adjust() does is it adjusts the MTU of the bridge net device itself, and not that of any slave port. If it were to modify the MTU of the slave ports, the effect would be that the user wouldn't be able to increase the MTU of any bridge slave port as long as it was part of the bridge, which would be a bit annoying to say the least.

The idea behind this behavior is that normal termination from Linux over the L2 forwarding domain described by DSA should happen over the bridge net device, which _is_ properly limited by the minimum MTU. And termination over individual slave device is possible even if those are bridged. But that is not "forwarding", so there's no reason to do normalization there, since only a single interface sees that packet.

Quoted 4 lines

The real problem is with the offloaded data path, where of course, the bridge net device MTU is ignored. So a packet received on an interface with MTU 9000 would still be forwarded to an interface with MTU 1500. And that is exactly what this patch is trying to prevent from happening.

How is that different from the software data path where the CPU needs to forward the packet between port A with MTU X and port B with MTU X/2 ?

Quoted 7 lines

I don't really understand what problem you are trying to solve here. It seems like the user did some misconfiguration and now you're introducing a policy to mitigate it? If so, it should be something the user can disable. It also seems like something that can be easily handled by a user space application. You get netlink notifications for all these operations.

Quoted 4 lines

Actually I think the problem can be better understood if I explain what the switches I'm dealing with look like.
None of them really has a 'MTU' register. They perform length-based admission control on RX.

IIUC, by that you mean that these switches only perform length-based filtering on RX, but not on TX?

Quoted 6 lines

At this moment in time I don't think anybody wants to introduce an MRU knob in iproute2, so we're adjusting that maximum ingress length through the MTU. But it becomes an inverted problem, since the 'MTU' needs to be controlled for all possible sources of traffic that are going to egress on this port, in order for the real MTU on the port itself to be observed.

Looking at your example from the changelog:

ip link set dev sw0p0 master br0
ip link set dev sw0p1 mtu 1400
ip link set dev sw0p1 master br0

Without your patch, after these commands sw0p0 has an MTU of 1500 and sw0p1 has an MTU of 1400. Are you saying that a frame with a length of 1450 bytes received on sw0p0 will be able to egress sw0p1 (assuming it should be forwarded there)?

If so, then I think I understand the problem. However, I don't think such code belongs in the bridge driver as this restriction does not apply to all switches. Also, I think that having the kernel change MTU of port A following MTU change of port B is a bit surprising and not intuitive.

Quoted 6 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

+1, this sounds more appropriate IMO

author maintainer
#31 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 10 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

+1, this sounds more appropriate IMO

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

#32 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 18 lines · Vladimir Oltean
Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 8 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

Quoted 7 lines
Quoted 2 lines

+1, this sounds more appropriate IMO

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

I was referring to moving the logic to NETDEV_PRECHANGEMTU, the rest is up to you.

author maintainer
#33 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 23 lines · Nikolay Aleksandrov
Quoted 21 lines · Vladimir Oltean
Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 10 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

+1, this sounds more appropriate IMO

Quoted 7 lines
Quoted 4 lines

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

I was referring to moving the logic to NETDEV_PRECHANGEMTU, the rest is up to you.

If I'm not going to veto, then I don't see a lot of sense in listening on this particular notifier either. I can do the normalization just fine on NETDEV_CHANGEMTU.

#34 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 30 lines · Vladimir Oltean
Quoted 28 lines · Nikolay Aleksandrov
Quoted 25 lines · Vladimir Oltean
Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 10 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

+1, this sounds more appropriate IMO

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

Quoted 7 lines
Quoted 2 lines

I was referring to moving the logic to NETDEV_PRECHANGEMTU, the rest is up to you.

If I'm not going to veto, then I don't see a lot of sense in listening on this particular notifier either. I can do the normalization just fine on NETDEV_CHANGEMTU.

I should've been more explicit - I meant I agree that this change doesn't belong in the bridge, and handling it in a notifier in the driver seems like a better place. Yes - if it's not going to be a vetto, then CHANGEMTU is fine.

maintainer
#35 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 34 lines · On Thu, 26 Mar 2020 14:38:57 +0200 Nikolay Aleksandrov wrote:
Quoted 33 lines · Vladimir Oltean
Quoted 30 lines · Nikolay Aleksandrov
Quoted 18 lines · Vladimir Oltean
Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 8 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

Quoted 7 lines
Quoted 2 lines

+1, this sounds more appropriate IMO

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

I was referring to moving the logic to NETDEV_PRECHANGEMTU, the rest is up to you.

Quoted 7 lines
Quoted 3 lines

If I'm not going to veto, then I don't see a lot of sense in listening on this particular notifier either. I can do the normalization just fine on NETDEV_CHANGEMTU.

I should've been more explicit - I meant I agree that this change doesn't belong in the bridge, and handling it in a notifier in the driver seems like a better place. Yes - if it's not going to be a vetto, then CHANGEMTU is fine.

I'm not sure pushing behavior decisions like that out to the drivers is ever a good idea. Linux should abstract HW differences after all, we don't want different drivers to perform different magic behind user's back.

I'd think if HW is unable to apply given configuration vetoing is both correct and expected..

#36 lore raw

Re: [PATCH v2 net-next 10/10] net: bridge: implement auto-normalization of MTU for hardware datapath

Quoted 43 lines · Jakub Kicinski
Quoted 34 lines · On Thu, 26 Mar 2020 14:38:57 +0200 Nikolay Aleksandrov wrote:
Quoted 33 lines · Vladimir Oltean
Quoted 30 lines · Nikolay Aleksandrov
Quoted 18 lines · Vladimir Oltean
Quoted 7 lines · Nikolay Aleksandrov
Quoted 5 lines · Ido Schimmel
Quoted 4 lines · Vladimir Oltean

Hi Ido,

Quoted 1 line · Ido Schimmel

[snip]

Quoted 8 lines
Quoted 7 lines

I think you should be more explicit about it. Did you consider listening to 'NETDEV_PRECHANGEMTU' notifications in relevant drivers and vetoing unsupported configurations with an appropriate extack message? If you can't veto (in order not to break user space), you can still emit an extack message.

Quoted 7 lines
Quoted 2 lines

+1, this sounds more appropriate IMO

And what does vetoing gain me exactly? The practical inability to change the MTU of any interface that is already bridged and applies length check on RX?

I was referring to moving the logic to NETDEV_PRECHANGEMTU, the rest is up to you.

Quoted 7 lines
Quoted 3 lines

If I'm not going to veto, then I don't see a lot of sense in listening on this particular notifier either. I can do the normalization just fine on NETDEV_CHANGEMTU.

I should've been more explicit - I meant I agree that this change doesn't belong in the bridge, and handling it in a notifier in the driver seems like a better place. Yes - if it's not going to be a vetto, then CHANGEMTU is fine.

Quoted 8 lines

I'm not sure pushing behavior decisions like that out to the drivers is ever a good idea. Linux should abstract HW differences after all, we don't want different drivers to perform different magic behind user's back.

I'd think if HW is unable to apply given configuration vetoing is both correct and expected..

This change implements a policy and makes it default for all HW-offloaded devices, but not all of them have these restrictions or need it. Moreover MTU handling has always been a vendor/driver-specific problem.
I do agree about the veto part, in my experience we've had countless problem reports due to the bridge auto-MTU adjusting, but it seems to me it's the driver authors' right to implement any policy they want as long as it doesn't affect everyone else.