Skip to contentSkip to conversation

net: dsa: mt7530: enable jumbo frame

PATCH In review DENG Qingfang 4 participants 8 messages Apr 9, 2020 – Apr 14, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: mt7530: enable jumbo frame

Enable jumbo frame for MT7530
It allows frames up to 15 KB (including FCS)

---
 drivers/net/dsa/mt7530.c | 16 ++++++++++++++++
 drivers/net/dsa/mt7530.h |  7 +++++++
 2 files changed, 23 insertions(+)
drivers/net/dsa/mt7530.c +16 -0
index 2d0d91db0ddb..ed080ded34a7 100644
@@ -1284,6 +1284,19 @@ mtk_get_tag_protocol(struct dsa_switch *ds, int port,
 	}
 }
 
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+	if (kilobytes > 15)
+		kilobytes = 15;
+
+	if (kilobytes > 1)
+		mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_JUMBO_MASK | MAX_RX_PKT_LEN_MASK,
+			   MAX_RX_JUMBO_KB(kilobytes) | MAX_RX_PKT_LEN_JMB);
+	else
+		mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_PKT_LEN_MASK, MAX_RX_PKT_LEN_1536);
+}
+
 static int
 mt7530_setup(struct dsa_switch *ds)
 {
@@ -1428,6 +1441,9 @@ mt7530_setup(struct dsa_switch *ds)
 	if (ret < 0)
 		return ret;
 
+	/* Enable jumbo frame up to 15 KB */
+	mt7530_set_jumbo(priv, 15);
+
 	return 0;
 }
 
drivers/net/dsa/mt7530.h +7 -0
index ef9b52f3152b..62f5ea64670d 100644
@@ -223,6 +223,13 @@ enum mt7530_vlan_port_attr {
 #define  PMSR_DPX			BIT(1)
 #define  PMSR_LINK			BIT(0)
 
+#define MT7530_GMACCR			0x30e0
+#define  MAX_RX_JUMBO_KB(x)		((x) << 2)
+#define  MAX_RX_JUMBO_MASK		MAX_RX_JUMBO_KB(0xf)
+#define  MAX_RX_PKT_LEN_MASK		0x3
+#define  MAX_RX_PKT_LEN_1536		0x1
+#define  MAX_RX_PKT_LEN_JMB		MAX_RX_PKT_LEN_MASK
+
 /* Register for MIB */
 #define MT7530_PORT_MIB_COUNTER(x)	(0x4000 + (x) * 0x100)
 #define MT7530_MIB_CCR			0x4fe0
Signature · 1 line
2.26.0
maintainer
#1 lore raw

From: DENG Qingfang <[email protected]>
Date: Thu, 9 Apr 2020 23:54:09 +0800

Quoted 5 lines
drivers/net/dsa/mt7530.c +5 -0
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+	if (kilobytes > 15)
+		kilobytes = 15;

...

drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1445

Quoted 2 lines
drivers/net/dsa/mt7530.c +2 -0
+	/* Enable jumbo frame up to 15 KB */
+	mt7530_set_jumbo(priv, 15);

You've made the test quite pointless, honestly.

#2 lore raw

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

Quoted 14 lines · David Miller

From: DENG Qingfang <[email protected]>
Date: Thu, 9 Apr 2020 23:54:09 +0800

Quoted 5 lines
drivers/net/dsa/mt7530.c +5 -0
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+     if (kilobytes > 15)
+             kilobytes = 15;

...

drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1445

Quoted 2 lines
drivers/net/dsa/mt7530.c +2 -0
+     /* Enable jumbo frame up to 15 KB */
+     mt7530_set_jumbo(priv, 15);

You've made the test quite pointless, honestly.

#3 lore raw
Quoted 2 lines · DENG Qingfang

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

(please do not top-post on netdev)

There is a proper way to support the MTU configuration for DSA switch drivers which is:

/*
* MTU change functionality. Switches can also adjust their MRU
through
* this method. By MTU, one understands the SDU (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);
Quoted 16 lines · David Miller
Quoted 14 lines

From: DENG Qingfang <[email protected]>
Date: Thu, 9 Apr 2020 23:54:09 +0800

Quoted 5 lines
drivers/net/dsa/mt7530.c +5 -0
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+     if (kilobytes > 15)
+             kilobytes = 15;

...

drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1445

Quoted 2 lines
drivers/net/dsa/mt7530.c +2 -0
+     /* Enable jumbo frame up to 15 KB */
+     mt7530_set_jumbo(priv, 15);

You've made the test quite pointless, honestly.

Signature · 1 line
Florian
#4 lore raw
Quoted 18 lines · Florian Fainelli
Quoted 2 lines · DENG Qingfang

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

(please do not top-post on netdev)

There is a proper way to support the MTU configuration for DSA switch drivers which is:

/*
* MTU change functionality. Switches can also adjust their MRU
through
* this method. By MTU, one understands the SDU (L2 payload) length.
* If the switch needs to account for the DSA tag on the CPU
port, this

Quoted 5 lines
         * 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);

MT7530 does not support configuring jumbo frame per-port The register affects globally

Quoted 20 lines
Quoted 13 lines · David Miller
Quoted 10 lines

From: DENG Qingfang <[email protected]>
Date: Thu, 9 Apr 2020 23:54:09 +0800

Quoted 5 lines
drivers/net/dsa/mt7530.c +5 -0
+static void
+mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
+{
+     if (kilobytes > 15)
+             kilobytes = 15;

...

Quoted 4 lines
Quoted 4 lines

drivers/net/dsa/mt7530.c mt7530_setup(struct dsa_switch *ds) · line 1445

Quoted 2 lines
drivers/net/dsa/mt7530.c +2 -0
+     /* Enable jumbo frame up to 15 KB */
+     mt7530_set_jumbo(priv, 15);

You've made the test quite pointless, honestly.

--
Florian

maintainer
#5 lore raw

Hi Qingfang,

Quoted 26 lines · DENG Qingfang
Quoted 18 lines · Florian Fainelli
Quoted 2 lines · DENG Qingfang

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

(please do not top-post on netdev)

There is a proper way to support the MTU configuration for DSA switch drivers which is:

/*
* MTU change functionality. Switches can also adjust their MRU
through
* this method. By MTU, one understands the SDU (L2 payload) length.
* If the switch needs to account for the DSA tag on the CPU
port, this

Quoted 5 lines
         * 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);
Quoted 6 lines

MT7530 does not support configuring jumbo frame per-port The register affects globally

Quoted 3 lines

--
Florian

This is a bit more tricky, but I think you can still deal with it using the port_change_mtu functionality. Basically it is only a problem when the other ports are standalone - otherwise the dsa_bridge_mtu_normalization function should kick in.
So if you implement port_change_mtu, you should do something along the lines of:

for (i = 0; i < MT7530_NUM_PORTS; i++) {
    struct net_device *slave;

    if (!dsa_is_user_port(ds, i))
        continue;

    slave = ds->ports[i].slave;

    slave->mtu = new_mtu;
}

to update the MTU known by the stack for all net devices.

Hope this helps,
-Vladimir

#6 lore raw
Quoted 54 lines · Vladimir Oltean

Hi Qingfang,

Quoted 26 lines · DENG Qingfang
Quoted 18 lines · Florian Fainelli
Quoted 2 lines · DENG Qingfang

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

(please do not top-post on netdev)

There is a proper way to support the MTU configuration for DSA switch drivers which is:

/*
* MTU change functionality. Switches can also adjust their MRU
through
* this method. By MTU, one understands the SDU (L2 payload) length.
* If the switch needs to account for the DSA tag on the CPU
port, this

Quoted 5 lines
         * 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);
Quoted 6 lines

MT7530 does not support configuring jumbo frame per-port The register affects globally

Quoted 3 lines

--
Florian

This is a bit more tricky, but I think you can still deal with it using the port_change_mtu functionality. Basically it is only a problem when the other ports are standalone - otherwise the dsa_bridge_mtu_normalization function should kick in.
So if you implement port_change_mtu, you should do something along the lines of:

for (i = 0; i < MT7530_NUM_PORTS; i++) {
    struct net_device *slave;

    if (!dsa_is_user_port(ds, i))
        continue;

    slave = ds->ports[i].slave;

    slave->mtu = new_mtu;
}
Quoted 1 line

to update the MTU known by the stack for all net devices.

Should we warn users that all ports will be affected?

Quoted 3 lines

Hope this helps,
-Vladimir

maintainer
#7 lore raw
Quoted 51 lines · DENG Qingfang
Quoted 49 lines · Vladimir Oltean

Hi Qingfang,

Quoted 26 lines · DENG Qingfang
Quoted 18 lines · Florian Fainelli
Quoted 2 lines · DENG Qingfang

So, since nothing else uses the mt7530_set_jumbo function, should I remove the function and just add a single rmw to mt7530_setup?

(please do not top-post on netdev)

There is a proper way to support the MTU configuration for DSA switch drivers which is:

/*
* MTU change functionality. Switches can also adjust their MRU
through
* this method. By MTU, one understands the SDU (L2 payload) length.
* If the switch needs to account for the DSA tag on the CPU
port, this

Quoted 5 lines
         * 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);
Quoted 6 lines

MT7530 does not support configuring jumbo frame per-port The register affects globally

Quoted 3 lines

--
Florian

This is a bit more tricky, but I think you can still deal with it using the port_change_mtu functionality. Basically it is only a problem when the other ports are standalone - otherwise the dsa_bridge_mtu_normalization function should kick in.
So if you implement port_change_mtu, you should do something along the lines of:

for (i = 0; i < MT7530_NUM_PORTS; i++) {
    struct net_device *slave;

    if (!dsa_is_user_port(ds, i))
        continue;
Quoted 10 lines
Quoted 6 lines
    slave = ds->ports[i].slave;

    slave->mtu = new_mtu;
}

to update the MTU known by the stack for all net devices.

Should we warn users that all ports will be affected?

Quoted 3 lines

Hope this helps,
-Vladimir

Unless I'm missing something, all ports are affected anyway, so changing the MTU _is_ informing users that all switch ports are affected.

Thanks,
-Vladimir