Re: [PATCH net-next v4 02/13] net: phy: Use an internal, searchable storage for the linkmodes

From: Paolo Abeni
Date: Thu Mar 06 2025 - 05:47:52 EST


On 3/6/25 9:57 AM, Maxime Chevallier wrote:
> On Thu, 6 Mar 2025 09:30:11 +0100
> Paolo Abeni <pabeni@xxxxxxxxxx> wrote:
>> On 3/3/25 10:03 AM, Maxime Chevallier wrote:
[...]
>>> +/**
>>> + * phy_caps_init() - Initializes the link_caps array from the link_mode_params.
>>> + */
>>> +void phy_caps_init(void)
>>> +{
>>> + const struct link_mode_info *linkmode;
>>> + int i, capa;
>>> +
>>> + /* Fill the caps array from net/ethtool/common.c */
>>> + for (i = 0; i < __ETHTOOL_LINK_MODE_MASK_NBITS; i++) {
>>> + linkmode = &link_mode_params[i];
>>> + capa = speed_duplex_to_capa(linkmode->speed, linkmode->duplex);
>>> +
>>> + if (capa < 0)
>>> + continue;
>>
>> Or even error-out here.
>
> Good point yes indeed. Russell raised the point for the need of keeping
> this in sync with new SPEED_XXX definitions, I'll add a check that
> errors out.
>
> I hope that's OK though, as higher speeds are introduced and used by
> NICs that usually don't use phylib at all, so there's a good chance
> that the developper introducing the new speed won't have CONFIG_PHYLIB
> enabled.
>
> Is that still good ?

I think so. New linkmodes should be added on net-next. Booting the
kernel with phylib support on any device should catch the error. I think
even the CI should catch this.

Thanks,

Paolo