Re: [PATCH v3 1/3] dsa: marvell: Provide per device information about max frame size

From: Andrew Lunn
Date: Tue Jan 03 2023 - 07:55:09 EST


On Tue, Jan 03, 2023 at 10:02:51AM +0100, Lukasz Majewski wrote:
> Hi Andrew,
>
> > > @@ -3548,7 +3548,9 @@ static int mv88e6xxx_get_max_mtu(struct
> > > dsa_switch *ds, int port) if (chip->info->ops->port_set_jumbo_size)
> > > return 10240 - VLAN_ETH_HLEN - EDSA_HLEN -
> > > ETH_FCS_LEN; else if (chip->info->ops->set_max_frame_size)
> > > - return 1632 - VLAN_ETH_HLEN - EDSA_HLEN -
> > > ETH_FCS_LEN;
> > > + return (max_t(int, chip->info->max_frame_size,
> > > 1632)
> > > + - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN);
> > > +
> > > return 1522 - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
> >
> > I would also prefer if all this if/else logic is removed, and the code
> > simply returned chip->info->max_frame_size - VLAN_ETH_HLEN -
> > EDSA_HLEN - ETH_FCS_LEN;
> >
>
> So then the mv88e6xxx_get_max_mtu shall look like:
>
> WARN_ON_ONCE(!chip->info->max_frame_size)
>
> if (chip->info->ops->port_set_jumbo_size)
> ...
> else
> return chip->info->max_frame_size - VLAN_ETH_HLEN -
> EDSA_HLEN - ETH_FCS_LEN;

I think it should go even further:

{
WARN_ON_ONCE(!chip->info->max_frame_size)

return chip->info->max_frame_size - VLAN_ETH_HLEN - EDSA_HLEN - ETH_FCS_LEN;
}

If we are going to use info->max_frame_size, we should always use
info->max_frame_size.

Andrew