On Wed, 22 Jan 2025 18:42:47 +0100 Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx> wrote: > In an effort to have a better representation of Ethernet ports, > introduce enumeration values representing the various ethernet Mediums. > > This is part of the 802.3 naming convention, for example : > > 1000 Base T 4 > | | | | > | | | \_ lanes (4) > | | \___ Medium (T == Twisted Copper Pairs) > | \_______ Baseband transmission > \____________ Speed > > Other example : > > 10000 Base K X 4 > | | \_ lanes (4) > | \___ encoding (BaseX is 8b/10b while BaseR is 66b/64b) > \_____ Medium (K is backplane ethernet) > > In the case of representing a physical port, only the medium and number > of lanes should be relevant. One exception would be 1000BaseX, which is > currently also used as a medium in what appears to be any of > 1000BaseSX, 1000BaseFX, 1000BaseCX and 1000BaseLX. > - __DEFINE_LINK_MODE_PARAMS(100, T, Half), > - __DEFINE_LINK_MODE_PARAMS(100, T, Full), > - __DEFINE_LINK_MODE_PARAMS(1000, T, Half), > - __DEFINE_LINK_MODE_PARAMS(1000, T, Full), > + __DEFINE_LINK_MODE_PARAMS_LANES(10, T, 2, 4, Half, T), > + __DEFINE_LINK_MODE_PARAMS_LANES(10, T, 2, 4, Full, T), > + __DEFINE_LINK_MODE_PARAMS_LANES(100, T, 2, 4, Half, T), > + __DEFINE_LINK_MODE_PARAMS_LANES(100, T, 2, 4, Full, T), > - __DEFINE_LINK_MODE_PARAMS(1000, KX, Full), > - __DEFINE_LINK_MODE_PARAMS(10000, KX4, Full), > - __DEFINE_LINK_MODE_PARAMS(10000, KR, Full), > + __DEFINE_LINK_MODE_PARAMS(1000, KX, Full, K), > + __DEFINE_LINK_MODE_PARAMS(10000, KX4, Full, K), > + __DEFINE_LINK_MODE_PARAMS(10000, KR, Full, K), The medium information is used twice. Maybe we could redefine the __DEFINE_LINK_MODE_PARAMS like this to avoid redundant information: #define __DEFINE_LINK_MODE_PARAMS(_speed, _medium, _encoding, _lanes, _duplex) And something like this when the lanes are not a fix number: #define __DEFINE_LINK_MODE_PARAMS_LANES_RANGE(_speed, _medium, _encoding, _min_lanes, _max_lanes, _duplex) Then we can remove all the __LINK_MODE_LANES_XX defines which may be wrong as you have spotted in patch 1. Regards, -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com