* [PATCH net-next] net: dsa: mt7530: enable jumbo frame
@ 2020-04-09 15:54 DENG Qingfang
2020-04-09 17:20 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: DENG Qingfang @ 2020-04-09 15:54 UTC (permalink / raw)
To: netdev
Cc: René van Dorst, John Crispin, Vivien Didelot,
Florian Fainelli, Andrew Lunn, Sean Wang, Weijie Gao
Enable jumbo frame for MT7530
It allows frames up to 15 KB (including FCS)
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
drivers/net/dsa/mt7530.c | 16 ++++++++++++++++
drivers/net/dsa/mt7530.h | 7 +++++++
2 files changed, 23 insertions(+)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 2d0d91db0ddb..ed080ded34a7 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -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;
}
diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
index ef9b52f3152b..62f5ea64670d 100644
--- a/drivers/net/dsa/mt7530.h
+++ b/drivers/net/dsa/mt7530.h
@@ -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
--
2.26.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-09 15:54 [PATCH net-next] net: dsa: mt7530: enable jumbo frame DENG Qingfang
@ 2020-04-09 17:20 ` David Miller
2020-04-10 2:19 ` DENG Qingfang
0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2020-04-09 17:20 UTC (permalink / raw)
To: dqfext
Cc: netdev, opensource, john, vivien.didelot, f.fainelli, andrew,
sean.wang, weijie.gao
From: DENG Qingfang <dqfext@gmail.com>
Date: Thu, 9 Apr 2020 23:54:09 +0800
> +static void
> +mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
> +{
> + if (kilobytes > 15)
> + kilobytes = 15;
...
> + /* Enable jumbo frame up to 15 KB */
> + mt7530_set_jumbo(priv, 15);
You've made the test quite pointless, honestly.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-09 17:20 ` David Miller
@ 2020-04-10 2:19 ` DENG Qingfang
2020-04-10 2:27 ` Florian Fainelli
0 siblings, 1 reply; 8+ messages in thread
From: DENG Qingfang @ 2020-04-10 2:19 UTC (permalink / raw)
To: David Miller
Cc: netdev, René van Dorst, John Crispin, Vivien Didelot,
Florian Fainelli, Andrew Lunn, Sean Wang, Weijie Gao,
linux-mediatek
So, since nothing else uses the mt7530_set_jumbo function, should I
remove the function and just add a single rmw to mt7530_setup?
On Fri, Apr 10, 2020 at 1:20 AM David Miller <davem@davemloft.net> wrote:
>
> From: DENG Qingfang <dqfext@gmail.com>
> Date: Thu, 9 Apr 2020 23:54:09 +0800
>
> > +static void
> > +mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
> > +{
> > + if (kilobytes > 15)
> > + kilobytes = 15;
> ...
> > + /* Enable jumbo frame up to 15 KB */
> > + mt7530_set_jumbo(priv, 15);
>
> You've made the test quite pointless, honestly.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-10 2:19 ` DENG Qingfang
@ 2020-04-10 2:27 ` Florian Fainelli
2020-04-10 2:49 ` DENG Qingfang
0 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2020-04-10 2:27 UTC (permalink / raw)
To: DENG Qingfang, David Miller
Cc: netdev, René van Dorst, John Crispin, Vivien Didelot,
Andrew Lunn, Sean Wang, Weijie Gao, linux-mediatek
On 4/9/2020 7:19 PM, DENG Qingfang wrote:
> 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);
>
> On Fri, Apr 10, 2020 at 1:20 AM David Miller <davem@davemloft.net> wrote:
>>
>> From: DENG Qingfang <dqfext@gmail.com>
>> Date: Thu, 9 Apr 2020 23:54:09 +0800
>>
>>> +static void
>>> +mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
>>> +{
>>> + if (kilobytes > 15)
>>> + kilobytes = 15;
>> ...
>>> + /* Enable jumbo frame up to 15 KB */
>>> + mt7530_set_jumbo(priv, 15);
>>
>> You've made the test quite pointless, honestly.
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-10 2:27 ` Florian Fainelli
@ 2020-04-10 2:49 ` DENG Qingfang
2020-04-10 10:46 ` Vladimir Oltean
0 siblings, 1 reply; 8+ messages in thread
From: DENG Qingfang @ 2020-04-10 2:49 UTC (permalink / raw)
To: Florian Fainelli
Cc: David Miller, netdev, René van Dorst, John Crispin,
Vivien Didelot, Andrew Lunn, Sean Wang, Weijie Gao,
linux-mediatek
On Fri, Apr 10, 2020 at 10:27 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>
>
> On 4/9/2020 7:19 PM, DENG Qingfang wrote:
> > 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);
MT7530 does not support configuring jumbo frame per-port
The register affects globally
>
> >
> > On Fri, Apr 10, 2020 at 1:20 AM David Miller <davem@davemloft.net> wrote:
> >>
> >> From: DENG Qingfang <dqfext@gmail.com>
> >> Date: Thu, 9 Apr 2020 23:54:09 +0800
> >>
> >>> +static void
> >>> +mt7530_set_jumbo(struct mt7530_priv *priv, u8 kilobytes)
> >>> +{
> >>> + if (kilobytes > 15)
> >>> + kilobytes = 15;
> >> ...
> >>> + /* Enable jumbo frame up to 15 KB */
> >>> + mt7530_set_jumbo(priv, 15);
> >>
> >> You've made the test quite pointless, honestly.
>
> --
> Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-10 2:49 ` DENG Qingfang
@ 2020-04-10 10:46 ` Vladimir Oltean
2020-04-14 3:03 ` DENG Qingfang
0 siblings, 1 reply; 8+ messages in thread
From: Vladimir Oltean @ 2020-04-10 10:46 UTC (permalink / raw)
To: DENG Qingfang
Cc: Florian Fainelli, David Miller, netdev, René van Dorst,
John Crispin, Vivien Didelot, Andrew Lunn, Sean Wang, Weijie Gao,
moderated list:ARM/Mediatek SoC support
Hi Qingfang,
On Fri, 10 Apr 2020 at 05:51, DENG Qingfang <dqfext@gmail.com> wrote:
>
> On Fri, Apr 10, 2020 at 10:27 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >
> >
> >
> > On 4/9/2020 7:19 PM, DENG Qingfang wrote:
> > > 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);
>
> MT7530 does not support configuring jumbo frame per-port
> The register affects globally
>
> >
> > --
> > 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-10 10:46 ` Vladimir Oltean
@ 2020-04-14 3:03 ` DENG Qingfang
2020-04-14 9:38 ` Vladimir Oltean
0 siblings, 1 reply; 8+ messages in thread
From: DENG Qingfang @ 2020-04-14 3:03 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Florian Fainelli, David Miller, netdev, René van Dorst,
John Crispin, Vivien Didelot, Andrew Lunn, Sean Wang, Weijie Gao,
moderated list:ARM/Mediatek SoC support
On Fri, Apr 10, 2020 at 6:46 PM Vladimir Oltean <olteanv@gmail.com> wrote:
>
> Hi Qingfang,
>
> On Fri, 10 Apr 2020 at 05:51, DENG Qingfang <dqfext@gmail.com> wrote:
> >
> > On Fri, Apr 10, 2020 at 10:27 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> > >
> > >
> > >
> > > On 4/9/2020 7:19 PM, DENG Qingfang wrote:
> > > > 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);
> >
> > MT7530 does not support configuring jumbo frame per-port
> > The register affects globally
> >
> > >
> > > --
> > > 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.
Should we warn users that all ports will be affected?
>
> Hope this helps,
> -Vladimir
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next] net: dsa: mt7530: enable jumbo frame
2020-04-14 3:03 ` DENG Qingfang
@ 2020-04-14 9:38 ` Vladimir Oltean
0 siblings, 0 replies; 8+ messages in thread
From: Vladimir Oltean @ 2020-04-14 9:38 UTC (permalink / raw)
To: DENG Qingfang
Cc: Florian Fainelli, David Miller, netdev, René van Dorst,
John Crispin, Vivien Didelot, Andrew Lunn, Sean Wang, Weijie Gao,
moderated list:ARM/Mediatek SoC support
On Tue, 14 Apr 2020 at 06:03, DENG Qingfang <dqfext@gmail.com> wrote:
>
> On Fri, Apr 10, 2020 at 6:46 PM Vladimir Oltean <olteanv@gmail.com> wrote:
> >
> > Hi Qingfang,
> >
> > On Fri, 10 Apr 2020 at 05:51, DENG Qingfang <dqfext@gmail.com> wrote:
> > >
> > > On Fri, Apr 10, 2020 at 10:27 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> > > >
> > > >
> > > >
> > > > On 4/9/2020 7:19 PM, DENG Qingfang wrote:
> > > > > 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);
> > >
> > > MT7530 does not support configuring jumbo frame per-port
> > > The register affects globally
> > >
> > > >
> > > > --
> > > > 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.
> Should we warn users that all ports will be affected?
> >
> > 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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-04-14 9:38 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-09 15:54 [PATCH net-next] net: dsa: mt7530: enable jumbo frame DENG Qingfang
2020-04-09 17:20 ` David Miller
2020-04-10 2:19 ` DENG Qingfang
2020-04-10 2:27 ` Florian Fainelli
2020-04-10 2:49 ` DENG Qingfang
2020-04-10 10:46 ` Vladimir Oltean
2020-04-14 3:03 ` DENG Qingfang
2020-04-14 9:38 ` Vladimir Oltean
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).