[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220729085036.2b180478@pc-10.home>
Date: Fri, 29 Jul 2022 08:50:36 +0200
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: Andrew Lunn <andrew@...n.ch>, davem@...emloft.net,
Rob Herring <robh+dt@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
thomas.petazzoni@...tlin.com,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
linux-arm-kernel@...ts.infradead.org, Horatiu.Vultur@...rochip.com,
Allan.Nielsen@...rochip.com, UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH net-next 3/4] net: phy: Add helper to derive the number
of ports from a phy mode
Hello Florian, Andrew,
On Thu, 28 Jul 2022 14:44:47 -0700
Florian Fainelli <f.fainelli@...il.com> wrote:
> On 7/28/22 14:32, Andrew Lunn wrote:
> >> +int phy_interface_num_ports(phy_interface_t interface)
> >> +{
> >> + switch (interface) {
> >> + case PHY_INTERFACE_MODE_NA:
> >> + case PHY_INTERFACE_MODE_INTERNAL:
> >> + return 0;
> >
> > I've not yet looked at how this is used. Returning 0 could have
> > interesting effects i guess? INTERNAL clearly does have some sort of
> > path between the MAC and the PHY, so i think 1 would be a better
> > value. NA is less clear, it generally means Don't touch. But again,
> > there still needs to be a path between the MAC and PHY, otherwise
> > there would not be any to touch.
> >
> > Why did you pick 0?
My reasonning was that PHY_INTERNAL is likely a custom solution to link
IPs existing on the same die, so nothing prevents vendors from
multiplexing links on that interface. But it's a far-fetched
reasonning, so 1 can be good, as other interfaces that are meant to be
used on-die like XGMII.
> I would agree that returning 1 is a more sensible default to avoid
> breaking users of that function. However this makes me wonder, in
> what case will we break the following common meaning:
>
> - Q -> quad
> - P -> penta
> - O -> octal
>
> Is the helper really needed in the sense that the phy_interface_t
> enumeration is explicit enough thanks to or because of its name? --
> Florian
Good question actually ! It started as a point from Russell proposing a
helper to get the number of serdes lanes for a given interface, but
this sisn't quite fit the use-case, which was simply to simplify
if (interface == PHY_INTERFACE_MODE_QSGMII ||
interface == PHY_INTERFACE_MODE_QUSGMII)
into
if (phy_interface_num_ports(interface) == 4)
But this a slim simplification at the cost of a new helper to maintain,
so I can repove that if you want.
Thanks for the reviews,
Maxime
Powered by blists - more mailing lists