Re: [PATCH v2 4/6] net: ocelot: add support for ndo_change_mtu

From: Clément Léger
Date: Wed Nov 03 2021 - 09:07:31 EST


Le Wed, 3 Nov 2021 12:40:55 +0000,
Vladimir Oltean <vladimir.oltean@xxxxxxx> a écrit :

> > +static int ocelot_change_mtu(struct net_device *dev, int new_mtu)
> > +{
> > + struct ocelot_port_private *priv = netdev_priv(dev);
> > + struct ocelot_port *ocelot_port = &priv->port;
> > + struct ocelot *ocelot = ocelot_port->ocelot;
> > +
> > + ocelot_port_set_maxlen(ocelot, priv->chip_port, new_mtu);
> > + WRITE_ONCE(dev->mtu, new_mtu);
>
> The WRITE_ONCE seems absolutely gratuitous to me.

I applied what is recommended in netdevice.h for the mtu field of the
netdev.
(https://elixir.bootlin.com/linux/v5.15/source/include/linux/netdevice.h#L1989)
And used in __dev_set_mtu
(https://elixir.bootlin.com/linux/v5.15/source/net/core/dev.c#L8849)

>
> > +
> > + return 0;
> > +}
> > +
> > enum ocelot_action_type {
> > OCELOT_MACT_LEARN,
> > OCELOT_MACT_FORGET,


--
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com