Message ID | 20250122174252.82730-1-maxime.chevallier@bootlin.com |
---|---|
Headers | show |
Series | net: phy: Introduce a port representation | expand |
On Wed, Jan 22, 2025 at 06:42:46PM +0100, Maxime Chevallier wrote: > When referring to BaseT ethernet, we are most of the time thinking of > BaseT4 ethernet on Cat5/6/7 cables. This is therefore BaseT4, although > BaseT4 is also possible for 100BaseTX. This is even more true now that > we have a special __LINK_MODE_LANES_T1 mode especially for Single Pair > ethernet. > > Mark BaseT as being a 4-lanes mode. This is a problem: 1.4.50 10BASE-T: IEEE 802.3 Physical Layer specification for a 10 Mb/s CSMA/CD local area network over two pairs of twisted-pair telephone wire. (See IEEE Std 802.3, Clause 14.) Then we have the 100BASE-T* family, which can be T1, T2, T4 or TX. T1 is over a single balanced twisted pair. T2 is over two pairs of Cat 3 or better. T4 is over four pairs of Cat3/4/5. The common 100BASE-T* type is TX, which is over two pairs of Cat5. This is sadly what the ethtool 100baseT link modes are used to refer to. We do have a separate link mode for 100baseT1, but not 100baseT4. So, these ethtool modes that are of the form baseT so far are describing generally two pairs, one pair in each direction. (T1 is a single pair that is bidirectional.) It's only once we get to 1000BASE-T (1000baseT) that we get to an ethtool link mode that has four lanes in a bidirectional fashion. So, simply redefining this ends up changing 10baseT and 100baseT from a single lane in each direction to four lanes (and is a "lane" here defined as the total number of pairs used for communication in both directions, or the total number of lanes used in either direction. Hence, I'm not sure this makes sense.
On Wed, Jan 22, 2025 at 06:55:17PM +0000, Russell King (Oracle) wrote: > On Wed, Jan 22, 2025 at 06:42:46PM +0100, Maxime Chevallier wrote: > > When referring to BaseT ethernet, we are most of the time thinking of > > BaseT4 ethernet on Cat5/6/7 cables. This is therefore BaseT4, although > > BaseT4 is also possible for 100BaseTX. This is even more true now that > > we have a special __LINK_MODE_LANES_T1 mode especially for Single Pair > > ethernet. > > > > Mark BaseT as being a 4-lanes mode. > > This is a problem: > > 1.4.50 10BASE-T: IEEE 802.3 Physical Layer specification for a 10 Mb/s > CSMA/CD local area network over two pairs of twisted-pair telephone > wire. (See IEEE Std 802.3, Clause 14.) > > Then we have the 100BASE-T* family, which can be T1, T2, T4 or TX. > T1 is over a single balanced twisted pair. T2 is over two pairs of > Cat 3 or better. T4 is over four pairs of Cat3/4/5. > > The common 100BASE-T* type is TX, which is over two pairs of Cat5. > This is sadly what the ethtool 100baseT link modes are used to refer > to. > > We do have a separate link mode for 100baseT1, but not 100baseT4. > > So, these ethtool modes that are of the form baseT so far are > describing generally two pairs, one pair in each direction. (T1 is > a single pair that is bidirectional.) > > It's only once we get to 1000BASE-T (1000baseT) that we get to an > ethtool link mode that has four lanes in a bidirectional fashion. > > So, simply redefining this ends up changing 10baseT and 100baseT from > a single lane in each direction to four lanes (and is a "lane" here > defined as the total number of pairs used for communication in both > directions, or the total number of lanes used in either direction. > > Hence, I'm not sure this makes sense. Looking at patch 2, I don't see why you need patch 1. It's not really improving the situation. Before the patch, the number of lanes for some BASE-T is wrong. After the patch, the number of lanes for some BASE-T is also wrong - just a different subset. I think you should drop this patch and just have patch 2.
On Wed, Jan 22, 2025 at 06:42:45PM +0100, Maxime Chevallier wrote: > First, a short disclaimer. This series is RFC, and there are quite a lot of > shortcomings : > > - The port representation is in a minimal form > - No SFP support is included, but it will be required for that series to come > out of RFC as we can't gracefully handle multi-port interfaces without it. Agreed - because I think SFP brings with it a whole host of issues that describing the media facing port would be error prone - and to do it accurately, we'd need a table of quirks to fix lots of broken modules. For example, many SFP modules with RJ45 connectors describe themselves as having a LC connector!
On Wed, 22 Jan 2025 18:42:47 +0100 Maxime Chevallier <maxime.chevallier@bootlin.com> 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,
On Wed, Jan 22, 2025 at 06:42:49PM +0100, Maxime Chevallier wrote: > Ethernet provides a wide variety of layer 1 protocols and standards for > data transmission. The front-facing ports of an interface have their own > complexity and configurability. > > Introduce a representation of these front-facing ports. The current code > is minimalistic and only support ports controlled by PHY devices, but > the plan is to extend that to SFP as well as raw Ethernet MACs that > don't use PHY devices. > > This minimal port representation allows describing the media and number > of lanes of a port. From that information, we can derive the linkmodes > usable on the port, which can be used to limit the capabilities of an > interface. > > For now, the port lanes and medium is derived from devicetree, defined > by the PHY driver, or populated with default values (as we assume that > all PHYs expose at least one port). > > The typical example is 100M ethernet. 100BaseT can work using only 2 > lanes on a Cat 5 cables. However, in the situation where a 10/100/1000 > capable PHY is wired to its RJ45 port through 2 lanes only, we have no > way of detecting that. The "max-speed" DT property can be used, but a > more accurate representation can be used : > > mdi { > port-0 { > media = "BaseT"; > lanes = <2>; > }; > }; > > >From that information, we can derive the max speed reachable on the > port. > > Another benefit of having that is to avoid vendor-specific DT properties > (micrel,fiber-mode or ti,fiber-mode). > > This basic representation is meant to be expanded, by the introduction > of port ops, userspace listing of ports, and support for multi-port > devices. > > Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> ... > diff --git a/drivers/net/phy/phy_port.c b/drivers/net/phy/phy_port.c ... > +/** > + * phy_port_destroy: Free a struct phy_port > + */ > +void phy_port_destroy(struct phy_port *port) nit: The Kernel doc for this function should include documentation of the port parameter. Flagged, along with several other Kernel doc issues, by ./scripts/kernel-doc -none ...
On Wed, 22 Jan 2025 18:42:45 +0100 Maxime Chevallier <maxime.chevallier@bootlin.com> wrote: > Hello everyone, > > This is a second RFC for the introduction of a front-facing interfaces > for ethernet devices. > > The firts RFC[1] already got some reviews, focusing on the DT part of > that work. To better lay the ground for further discussions, this second > round includes a binding :) > > Oleksij suggested some further possibilities for improving this binding, > as we could consider describing connectors in great details for > crossover detection, PoE ping mappings, etc. However, as this is > preliminary work, the included binding is still quite simple but can > certainly be extended. > > This RFC V2 doesn't bring much compared to V1 : > - A binding was introduced > - A warning has been fixed in the dp83822 patch > - The "lanes" property has been made optional Small question, I know you want to begin with something simple but would it be possible to consider how to support the port representation in NIT and switch drivers? Maybe it is out of your scope but it would be nice if you consider how NIT and switches can support it in your development. Regards,
On Thu, 23 Jan 2025 11:31:21 +0100 Kory Maincent <kory.maincent@bootlin.com> wrote: > On Wed, 22 Jan 2025 18:42:45 +0100 > Maxime Chevallier <maxime.chevallier@bootlin.com> wrote: > > > Hello everyone, > > > > This is a second RFC for the introduction of a front-facing interfaces > > for ethernet devices. > > > > The firts RFC[1] already got some reviews, focusing on the DT part of > > that work. To better lay the ground for further discussions, this second > > round includes a binding :) > > > > Oleksij suggested some further possibilities for improving this binding, > > as we could consider describing connectors in great details for > > crossover detection, PoE ping mappings, etc. However, as this is > > preliminary work, the included binding is still quite simple but can > > certainly be extended. > > > > This RFC V2 doesn't bring much compared to V1 : > > - A binding was introduced > > - A warning has been fixed in the dp83822 patch > > - The "lanes" property has been made optional > > Small question, I know you want to begin with something simple but would it be > possible to consider how to support the port representation in NIT and > switch drivers? Maybe it is out of your scope but it would be nice if you > consider how NIT and switches can support it in your development. s/NIT/NIC/ Sorry.
Hello Russell, On Wed, 22 Jan 2025 18:55:17 +0000 "Russell King (Oracle)" <linux@armlinux.org.uk> wrote: > On Wed, Jan 22, 2025 at 06:42:46PM +0100, Maxime Chevallier wrote: > > When referring to BaseT ethernet, we are most of the time thinking of > > BaseT4 ethernet on Cat5/6/7 cables. This is therefore BaseT4, although > > BaseT4 is also possible for 100BaseTX. This is even more true now that > > we have a special __LINK_MODE_LANES_T1 mode especially for Single Pair > > ethernet. > > > > Mark BaseT as being a 4-lanes mode. > > This is a problem: > > 1.4.50 10BASE-T: IEEE 802.3 Physical Layer specification for a 10 Mb/s > CSMA/CD local area network over two pairs of twisted-pair telephone > wire. (See IEEE Std 802.3, Clause 14.) > > Then we have the 100BASE-T* family, which can be T1, T2, T4 or TX. > T1 is over a single balanced twisted pair. T2 is over two pairs of > Cat 3 or better. T4 is over four pairs of Cat3/4/5. > > The common 100BASE-T* type is TX, which is over two pairs of Cat5. > This is sadly what the ethtool 100baseT link modes are used to refer > to. > > We do have a separate link mode for 100baseT1, but not 100baseT4. > > So, these ethtool modes that are of the form baseT so far are > describing generally two pairs, one pair in each direction. (T1 is > a single pair that is bidirectional.) > > It's only once we get to 1000BASE-T (1000baseT) that we get to an > ethtool link mode that has four lanes in a bidirectional fashion. > > So, simply redefining this ends up changing 10baseT and 100baseT from > a single lane in each direction to four lanes (and is a "lane" here > defined as the total number of pairs used for communication in both > directions, or the total number of lanes used in either direction. > > Hence, I'm not sure this makes sense. > I'm fine with your justification, so let's simplify and drop that patch then. That should also avoid the lanes/pairs confusion as well. Thanks for the feedback ! Maxime
Hi Köry, On Thu, 23 Jan 2025 10:35:34 +0100 Kory Maincent <kory.maincent@bootlin.com> wrote: > On Wed, 22 Jan 2025 18:42:47 +0100 > Maxime Chevallier <maxime.chevallier@bootlin.com> 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. My apologies, I missed your review and didn't address it in the new iteration :( I will give this a try, see hw this looks, so that we can separate the encoding info from the medium info. Thanks ! Maxime > Regards,
Hi again Köry, > Hi Köry, > > On Thu, 23 Jan 2025 10:35:34 +0100 > Kory Maincent <kory.maincent@bootlin.com> wrote: > > > On Wed, 22 Jan 2025 18:42:47 +0100 > > Maxime Chevallier <maxime.chevallier@bootlin.com> 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