public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: DENG Qingfang <dqfext@gmail.com>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, "Sean Wang" <sean.wang@mediatek.com>,
	"Landen Chao" <Landen.Chao@mediatek.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	"René van Dorst" <opensource@vdorst.com>,
	"Linus Walleij" <linus.walleij@linaro.org>
Subject: Re: [PATCH] net: dsa: mt7530: support setting MTU
Date: Wed, 28 Oct 2020 20:31:31 +0200	[thread overview]
Message-ID: <20201028183131.d4mxlqwl5v2hy2tb@skbuf> (raw)
In-Reply-To: <20201028181221.30419-1-dqfext@gmail.com>

On Thu, Oct 29, 2020 at 02:12:21AM +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@gmail.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

Also, please format your patches with --subject-prefix="PATCH net-next"
in the future. Jakub installed some patchwork scripts that "guess" the
tree based on the commit message, but maybe sometimes they might fail:

https://patchwork.ozlabs.org/project/netdev/patch/e5fdcddeda21884a21162e441d1e8a04994f2825.1603837679.git.pavana.sharma@digi.com/

>  drivers/net/dsa/mt7530.c | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/net/dsa/mt7530.h | 12 ++++++++++++
>  2 files changed, 48 insertions(+)
> 
> 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.
> +	 */

Good point, please tell that to Linus (cc) - I'm talking about
e0b2e0d8e669 ("net: dsa: rtl8366rb: Roof MTU for switch"),

> +	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);
> +
> +	return 0;
> +}
> +
> +static int
> +mt7530_port_max_mtu(struct dsa_switch *ds, int port)
> +{
> +	return MT7530_MAX_MTU;
> +}
> +
>  static void
>  mt7530_stp_state_set(struct dsa_switch *ds, int port, u8 state)
>  {
> @@ -2519,6 +2553,8 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
>  	.get_sset_count		= mt7530_get_sset_count,
>  	.port_enable		= mt7530_port_enable,
>  	.port_disable		= mt7530_port_disable,
> +	.port_change_mtu	= mt7530_port_change_mtu,
> +	.port_max_mtu		= mt7530_port_max_mtu,
>  	.port_stp_state_set	= mt7530_stp_state_set,
>  	.port_bridge_join	= mt7530_port_bridge_join,
>  	.port_bridge_leave	= mt7530_port_bridge_leave,

  reply	other threads:[~2020-10-29  0:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 18:12 [PATCH] net: dsa: mt7530: support setting MTU DENG Qingfang
2020-10-28 18:31 ` Vladimir Oltean [this message]
2020-10-29  3:32   ` DENG Qingfang
2020-10-29  8:11     ` Jonathan McDowell
2020-10-29  8:19       ` DENG Qingfang
2020-10-28 18:46 ` Florian Fainelli
2020-10-29 22:42 ` Jakub Kicinski
2020-10-30  2:58   ` DENG Qingfang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201028183131.d4mxlqwl5v2hy2tb@skbuf \
    --to=olteanv@gmail.com \
    --cc=Landen.Chao@mediatek.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dqfext@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=opensource@vdorst.com \
    --cc=sean.wang@mediatek.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox