[PATCH net-next 05/13] net: phy: Use an internal, searchable storage for the linkmodes
Kory Maincent
kory.maincent at bootlin.com
Mon Feb 24 05:33:39 PST 2025
On Sat, 22 Feb 2025 15:27:17 +0100
Maxime Chevallier <maxime.chevallier at bootlin.com> wrote:
Only small typos:
> The canonical definition for all the link modes is in linux/ethtol.h,
ethtool
> which is complemented by the link_mode_params array stored in
> net/ethtool/common.h . That array contains all the metadata about each
> of these modes, including the Speed and Duplex information.
>
> Phylib and phylink needs that information as well for internal
> managmement of the link, which was done by duplicating that information
management
> in locally-stored arrays and lookup functions. This makes it easy for
> developpers adding new modes to forget modifying phylib and phylink
> accordingly.
>
> However, the link_mode_params array in net/ethtool/common.c is fairly
> inefficient to search through, as it isn't sorted in any manner. Phylib
> and phylink perform a lot of lookup operations, mostly to filter modes
> by speed and/or duplex.
>
> We therefore introduce the link_caps private array in phy_caps.c, that
> indexes linkmodes in a more efficient manner. Each element associated a
> tuple <speed, duplex> to a bitfield of all the linkmodes runs at these
> speed/duplex.
>
> We end-up with an array that's fairly short, easily addressable and that
> it optimised for the typical use-cases of phylib/phylink.
>
> That array is initialized at the same time as phylib. As the
> link_mode_params array is part of the net stack, which phylink depends
> on, it should always be accessible from phylib.
The rest looks ok for me.
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
More information about the linux-arm-kernel
mailing list