public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: "Hauke Mehrtens" <hauke@hauke-m.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>
Subject: Re: [PATCH 3/4] net: dsa: realtek: rtl8365mb: Add setting MTU
Date: Mon, 9 May 2022 13:55:53 +0200	[thread overview]
Message-ID: <YnkBSTbn04SYyV+J@lunn.ch> (raw)
In-Reply-To: <CAJq09z75yzP-V=bwnK6QNGQW+eoj-pnx2q0CB-03VYH65dKhgA@mail.gmail.com>

> > +static int rtl8365mb_port_change_mtu(struct dsa_switch *ds, int port,
> > +                                    int new_mtu)
> > +{
> > +       struct dsa_port *dp = dsa_to_port(ds, port);
> > +       struct realtek_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;
> > +
> > +       length = new_mtu + ETH_HLEN + ETH_FCS_LEN;
> > +       length += dp->tag_ops->needed_headroom;
> > +       length += dp->tag_ops->needed_tailroom;
> 
> Isn't it better to keep that within the driver? No matter the tag
> position, it will be either 4 (RTL8365MB_CPU_FORMAT_4BYTES) or 8
> (RTL8365MB_CPU_FORMAT_8BYTES) bytes. You can retrieve that from
> priv->chip_data->cpu->format, but the driver will probably never
> support RTL8365MB_CPU_FORMAT_4BYTES. Until someone does implement the
> 4-bytes tag (for some mysterious reason), I believe we could simply
> use a constant here (using a proper new macro).

Another option is to simply always use the bigger header length. I
doubt there are many people actually using jumbo frames, and do they
really care about 0x3FFF-4, vs 0x3FFF-8?
 
> > +
> > +       if (length > RTL8365MB_CFG0_MAX_LEN_MASK)
> > +               return -EINVAL;
> > +
> > +       return regmap_update_bits(priv->map, RTL8365MB_CFG0_MAX_LEN_REG,
> > +                                 RTL8365MB_CFG0_MAX_LEN_MASK,
> > +                                 FIELD_PREP(RTL8365MB_CFG0_MAX_LEN_MASK,
> > +                                            length));
> > +}
> > +
> > +static int rtl8365mb_port_max_mtu(struct dsa_switch *ds, int port)
> > +{
> > +       return RTL8365MB_CFG0_MAX_LEN_MASK - ETH_HLEN - ETH_FCS_LEN - 8;
> 
> What is this magic 8? RTL8_4_TAG_LEN?

There are some DSA headers in include/linux/dsa, probably a new one
should be added with this RTL8_4_TAG_LEN.
 
	Andrew

  reply	other threads:[~2022-05-09 11:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 22:48 [PATCH 0/4] net: dsa: realtek: rtl8365mb: Add SGMII and HSGMII support Hauke Mehrtens
2022-05-08 22:48 ` [PATCH 1/4] net: dsa: realtek: rtl8365mb: Fix interface type mask Hauke Mehrtens
2022-05-10 16:33   ` Alvin Šipraga
2022-05-08 22:48 ` [PATCH 2/4] net: dsa: realtek: rtl8365mb: Get chip option Hauke Mehrtens
2022-05-09  8:03   ` Luiz Angelo Daros de Luca
2022-05-10 16:32   ` Alvin Šipraga
2022-05-08 22:48 ` [PATCH 3/4] net: dsa: realtek: rtl8365mb: Add setting MTU Hauke Mehrtens
2022-05-09  6:45   ` Luiz Angelo Daros de Luca
2022-05-09 11:55     ` Andrew Lunn [this message]
2022-05-10 16:49   ` Alvin Šipraga
2022-05-10 17:31   ` Vladimir Oltean
2022-05-08 22:48 ` [PATCH 4/4] net: dsa: realtek: rtl8365mb: Add SGMII and HSGMII support Hauke Mehrtens
2022-05-10 17:29   ` Vladimir Oltean
2022-05-10 19:23     ` Alvin Šipraga
2022-05-11 23:44       ` Luiz Angelo Daros de Luca
2022-05-10 18:57   ` Alvin Šipraga
2022-05-09  6:28 ` [PATCH 0/4] " Luiz Angelo Daros de Luca
2022-05-09  7:38   ` Luiz Angelo Daros de Luca
2022-05-09 15:36     ` Florian Fainelli
2022-05-09 15:40       ` Vladimir Oltean
2022-05-09 15:41         ` Florian Fainelli
2022-05-09 15:49           ` Vladimir Oltean
2022-05-10 22:55   ` Hauke Mehrtens
2022-05-10 17:08 ` Alvin Šipraga

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=YnkBSTbn04SYyV+J@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=alsi@bang-olufsen.dk \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.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