Messages in this thread | | | Date | Thu, 5 Jan 2023 11:37:12 +0100 | From | Lukasz Majewski <> | Subject | Re: [PATCH v3 1/3] dsa: marvell: Provide per device information about max frame size |
| |
Hi Andrew, Alexander,
> 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; > > > Or shall I put WARN_ON_ONCE to the mv88e6xxx_probe() function? > > > The above approach is contrary to one proposed by Alexander, who > wanted to improve the defensive approach in this driver (to avoid > situation where the max_frame_size callback is not defined and > max_frame_size member of *_info struct is not added by developer). > > Which approach is the recommended one for this driver?
Is there any decision regarding the preferred approach to rewrite this code?
> > > > +++ b/drivers/net/dsa/mv88e6xxx/chip.h > > > @@ -132,6 +132,7 @@ struct mv88e6xxx_info { > > > unsigned int num_gpio; > > > unsigned int max_vid; > > > unsigned int max_sid; > > > + unsigned int max_frame_size; > > > > It might be worth adding a comment here what this value actually > > represents. > > Ok. I will add proper comment. > > > We don't want any mixups where the value already has the > > frame checksum removed for example. > > Could you be more specific here about this use case? > > The max_frame_size is the maximal size of the ethernet frame for which > the IC designer provided specified amount of RAM (it is a different > value for different SoCs in the Link Street family). > > > > > Andrew > > > Best regards, > > Lukasz Majewski > > -- > > DENX Software Engineering GmbH, Managing Director: Erika Unter > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: > lukma@denx.de
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de [unhandled content-type:application/pgp-signature] | |