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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 2 Nov 2020 15:40:17 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     DENG Qingfang <dqfext@...il.com>
Cc:     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>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        René van Dorst <opensource@...rst.com>,
        Chuanhong Guo <gch981213@...il.com>
Subject: Re: [PATCH v2 net-next] net: dsa: mt7530: support setting MTU

On Mon, Nov 02, 2020 at 03:58:21PM +0800, DENG Qingfang wrote:
> MT7530/7531 has a global RX packet length register, which can be used
> to set MTU.
> 
> Supported packet length values are 1522 (1518 if untagged), 1536, 1552,
> and multiple of 1024 (from 2048 to 15360).
> 
> Signed-off-by: DENG Qingfang <dqfext@...il.com>
> ---
> v1 -> v2:
> 	Avoid duplication of mt7530_rmw()
> 	Fix code wrapping
> ---
>  drivers/net/dsa/mt7530.c | 49 ++++++++++++++++++++++++++++++++++++++++
>  drivers/net/dsa/mt7530.h | 12 ++++++++++
>  2 files changed, 61 insertions(+)
> 
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index de7692b763d8..ca39f81de75a 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -1021,6 +1021,53 @@ 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;
> +	struct mii_bus *bus = priv->bus;
> +	int length;
> +	u32 val;
> +
> +	/* 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;
> +
> +	mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
> +
> +	val = mt7530_mii_read(priv, MT7530_GMACCR);
> +	val &= ~MAX_RX_PKT_LEN_MASK;
> +
> +	/* 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)
> +		val |= MAX_RX_PKT_LEN_1522;

Could you please fix the checkpatch warnings here?

> +	else if (length <= 1536)
> +		val |= MAX_RX_PKT_LEN_1536;
> +	else if (length <= 1552)
> +		val |= MAX_RX_PKT_LEN_1552;
> +	else {
> +		val &= ~MAX_RX_JUMBO_MASK;
> +		val |= MAX_RX_JUMBO(DIV_ROUND_UP(length, 1024));
> +		val |= MAX_RX_PKT_LEN_JUMBO;
> +	}
> +
> +	mt7530_mii_write(priv, MT7530_GMACCR, val);
> +
> +	mutex_unlock(&bus->mdio_lock);
> +
> +	return 0;
> +}
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ