Hi again Köry, > Hi Köry, > > On Thu, 23 Jan 2025 10:35:34 +0100 > Kory Maincent <kory.maincent@xxxxxxxxxxx> wrote: > > > 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. > > I will give this a try, see hw this looks, so that we can separate the > encoding info from the medium info. So I did give it a go, but it turns out to be much more complex than expected... The _type information from definitions like : __DEFINE_LINK_MODE_PARAMS(10000, KX4, Full, K), (here _type is KX4) can't really be split into the individual attributes <Medium, Encoding, Lanes> without having some complex macro logic. This type is used to convert to actual linkmodes that already exist in the kernel : #define ETHTOOL_LINK_MODE(speed, type, duplex) \ ETHTOOL_LINK_MODE_ ## speed ## base ## type ## _ ## duplex ## _BIT Say we want to generate the _type from <Medium, Encoding, Lanes> with a macro, we have to cover all the weird cases : 1000BaseT => No encoding, no lanes 10000BaseKX4 => K medium, X encoding, 4 lanes 10000BeseKX => K medium, X encding, no lanes (which means 1 lane) 1000BaseX => Just encoding 100000BaseLR4_ER4 => One link mode that applies for 2 mediums ? While doable, this will probably end-up more complex and hard to maintain than re-specifying the medium :( Maxime