[v3,net-next,5/8] net: dsa: b53: add MTU configuration support
diff mbox series

Message ID 20200326224040.32014-6-olteanv@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series
  • Configure the MTU on DSA switches
Related show

Commit Message

Vladimir Oltean March 26, 2020, 10:40 p.m. UTC
From: Murali Krishna Policharla <murali.policharla@broadcom.com>

It looks like the Broadcomm switches supported by the b53 driver don't
support precise configuration of the MTU, but just a mumbo-jumbo boolean
flag. Set that.

Also configure BCM583XX devices to send and receive jumbo frames when
ports are configured with 10/100 Mbps speed.

Signed-off-by: Murali Krishna Policharla <murali.policharla@broadcom.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Changes in v3:
Using the b53_set_jumbo function that was already there.

Changes in v2:
Patch is new.

 drivers/net/dsa/b53/b53_common.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

Comments

Florian Fainelli March 26, 2020, 11:16 p.m. UTC | #1
On 3/26/2020 3:40 PM, Vladimir Oltean wrote:
> From: Murali Krishna Policharla <murali.policharla@broadcom.com>
> 
> It looks like the Broadcomm switches supported by the b53 driver don't
                            ^= one too many m's, the attempt to acquire
Qualcomm failed a few years ago :)

> support precise configuration of the MTU, but just a mumbo-jumbo boolean
> flag. Set that.
> 
> Also configure BCM583XX devices to send and receive jumbo frames when
> ports are configured with 10/100 Mbps speed.
> 
> Signed-off-by: Murali Krishna Policharla <murali.policharla@broadcom.com>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---

[snip]

> +static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
> +{
> +	struct b53_device *dev = ds->priv;
> +	bool enable_jumbo;
> +	bool allow_10_100;
> +
> +	if (is5325(dev) || is5365(dev))
> +		return -EOPNOTSUPP;
> +
> +	enable_jumbo = (mtu >= JMS_MIN_SIZE);
> +	allow_10_100 = (dev->chip_id == BCM58XX_DEVICE_ID);

I believe this was meant to be BCM583XX_DEVICE_ID to be consistent with
the previous patch version. With that:

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Vladimir Oltean March 27, 2020, 1:01 p.m. UTC | #2
On Fri, 27 Mar 2020 at 01:16, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> On 3/26/2020 3:40 PM, Vladimir Oltean wrote:
> > From: Murali Krishna Policharla <murali.policharla@broadcom.com>
> >
> > It looks like the Broadcomm switches supported by the b53 driver don't
>                             ^= one too many m's, the attempt to acquire
> Qualcomm failed a few years ago :)
>

I knew you guys were jealous of their extra m!

> > support precise configuration of the MTU, but just a mumbo-jumbo boolean
> > flag. Set that.

I'm more concerned of the mumbo-jumbo, in fact. Right now, DSA sets
dev->mtu = mtu in slave.c. But for hardware like this, it would be
confusing to do that. I would do dev->mtu = JMS_MIN_SIZE or dev->mtu =
JMS_MAX_SIZE depending on configuration, so that the user isn't led
into thinking that their exact requested value went into the hardware.
Any ideas on how I could structure things differently for that?

> >
> > Also configure BCM583XX devices to send and receive jumbo frames when
> > ports are configured with 10/100 Mbps speed.
> >
> > Signed-off-by: Murali Krishna Policharla <murali.policharla@broadcom.com>
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
>
> [snip]
>
> > +static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
> > +{
> > +     struct b53_device *dev = ds->priv;
> > +     bool enable_jumbo;
> > +     bool allow_10_100;
> > +
> > +     if (is5325(dev) || is5365(dev))
> > +             return -EOPNOTSUPP;
> > +
> > +     enable_jumbo = (mtu >= JMS_MIN_SIZE);
> > +     allow_10_100 = (dev->chip_id == BCM58XX_DEVICE_ID);
>
> I believe this was meant to be BCM583XX_DEVICE_ID to be consistent with
> the previous patch version. With that:
>

Ok.

> Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> --
> Florian

Patch
diff mbox series

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index ceafce446317..f432edf618e1 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -699,9 +699,6 @@  int b53_configure_vlan(struct dsa_switch *ds)
 		b53_write16(dev, B53_VLAN_PAGE,
 			    B53_VLAN_PORT_DEF_TAG(i), def_vid);
 
-	if (!is5325(dev) && !is5365(dev))
-		b53_set_jumbo(dev, dev->enable_jumbo, false);
-
 	return 0;
 }
 EXPORT_SYMBOL(b53_configure_vlan);
@@ -807,8 +804,6 @@  static int b53_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
 static int b53_reset_switch(struct b53_device *priv)
 {
 	/* reset vlans */
-	priv->enable_jumbo = false;
-
 	memset(priv->vlans, 0, sizeof(*priv->vlans) * priv->num_vlans);
 	memset(priv->ports, 0, sizeof(*priv->ports) * priv->num_ports);
 
@@ -2065,6 +2060,26 @@  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;
+	bool enable_jumbo;
+	bool allow_10_100;
+
+	if (is5325(dev) || is5365(dev))
+		return -EOPNOTSUPP;
+
+	enable_jumbo = (mtu >= JMS_MIN_SIZE);
+	allow_10_100 = (dev->chip_id == BCM58XX_DEVICE_ID);
+
+	return b53_set_jumbo(dev, enable_jumbo, allow_10_100);
+}
+
+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 +2117,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 {