lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 30 Oct 2020 10:58:12 +0800
From:   DENG Qingfang <dqfext@...il.com>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev <netdev@...r.kernel.org>,
        Sean Wang <sean.wang@...iatek.com>,
        Landen Chao <Landen.Chao@...iatek.com>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        René van Dorst <opensource@...rst.com>
Subject: Re: [PATCH] net: dsa: mt7530: support setting MTU

On Fri, Oct 30, 2020 at 6:42 AM Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Thu, 29 Oct 2020 02:12:21 +0800 DENG Qingfang wrote:
> > MT7530/7531 has a global RX packet length register, which can be used
> > to set MTU.
> >
> > Signed-off-by: DENG Qingfang <dqfext@...il.com>
>
> Please wrap your code at 80 chars.
>
> > diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> > index de7692b763d8..7764c66a47c9 100644
> > --- a/drivers/net/dsa/mt7530.c
> > +++ b/drivers/net/dsa/mt7530.c
> > @@ -1021,6 +1021,40 @@ mt7530_port_disable(struct dsa_switch *ds, int port)
> >       mutex_unlock(&priv->reg_mutex);
> >  }
> >
> > +static int
> > +mt7530_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
> > +{
> > +     struct mt7530_priv *priv = ds->priv;
> > +     int length;
> > +
> > +     /* When a new MTU is set, DSA always set the CPU port's MTU to the largest MTU
> > +      * of the slave ports. Because the switch only has a global RX length register,
> > +      * only allowing CPU port here is enough.
> > +      */
> > +     if (!dsa_is_cpu_port(ds, port))
> > +             return 0;
> > +
> > +     /* RX length also includes Ethernet header, MTK tag, and FCS length */
> > +     length = new_mtu + ETH_HLEN + MTK_HDR_LEN + ETH_FCS_LEN;
> > +     if (length <= 1522)
> > +             mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_PKT_LEN_MASK, MAX_RX_PKT_LEN_1522);
> > +     else if (length <= 1536)
> > +             mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_PKT_LEN_MASK, MAX_RX_PKT_LEN_1536);
> > +     else if (length <= 1552)
> > +             mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_PKT_LEN_MASK, MAX_RX_PKT_LEN_1552);
> > +     else
> > +             mt7530_rmw(priv, MT7530_GMACCR, MAX_RX_JUMBO_MASK | MAX_RX_PKT_LEN_MASK,
> > +                     MAX_RX_JUMBO(DIV_ROUND_UP(length, 1024)) | MAX_RX_PKT_LEN_JUMBO);
>
> this line should start under priv, so it aligns to the opening
> parenthesis.
>
> Besides, don't you need to reset the JUMBO bit when going from jumbo to
> non-jumbo? The mask should always include jumbo.

MAX_RX_JUMBO works only when MAX_RX_PKT_LEN is set to 0x3, so just
changing MAX_RX_PKT_LEN to non-jumbo is enough.
FYI, the default value of MAX_RX_JUMBO is 0x9.

>
> I assume you're duplicating the mt7530_rmw() for the benefit of the
> constant validation, but it seems to be counterproductive here.

As I mentioned above, MAX_RX_JUMBO does not need to be changed when
going from jumbo to non-jumbo.
Perhaps I should use mt7530_mii_read() and mt7530_mii_write() instead?

>
> > +     return 0;
> > +}
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ