Subject: Re: russell's net-queue question

From: Marek Behún <[email-masked]>
Date: Wed, 21 Oct 2020 15:48:49 +0200

On Tue, 20 Oct 2020 16:45:15 +0100
Russell King - ARM Linux admin <[email-masked]> wrote:

> On Tue, Oct 20, 2020 at 05:15:39PM +0200, Marek Behún wrote:
> > Russell,
> > 
> > I think the following commits in your net-queue should be still made better:
> > 
> > 7f79709b7a15 ("net: phy: pass supported PHY interface types to phylib")
> > eba49a289d09 ("net: phy: marvell10g: select host interface configuration")
> > 
> > http://git.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=net-queue&id=eba49a289d0959eab3dfbc0320334eb5a855ca68
> > http://git.arm.linux.org.uk/cgit/linux-arm.git/commit/?h=net-queue&id=eba49a289d0959eab3dfbc0320334eb5a855ca68
> > 
> > The first one adds filling of the phydev->host_interfaces bitmap into
> > the phylink_sfp_connect_phy function. It should also fill this bitmap
> > in functions phylink_connect_phy and phylink_of_phy_connect (direct
> > copy of pl->config->supported_interfaces).  
> 
> First, the whole way interfaces are handled is really not good, even
> with the addition of the interfaces bitmap. However, it tries to solve
> at least some of the issues.
> 
> Secondly, what should we fill this in with?
> 
> Do we fill it with the firmware specified phy-mode setting? Or all the
> capabilities of the network driver's interface? What if the network
> driver supports RGMII/SGMII/10GBASE-R/etc but not all of these are
> wired?
> 
> We really don't want the PHY changing what was configured via hardware
> when it's "built in", because it's ambiguous in a very many situations
> which mode should be selected. If we take the view that the firmware
> specified phy-mode should only be specified, then the 88X3310 will
> switch to MACTYPE=6 instead of 4 on the Macchiatobin, which is the rate
> adaption mode - and this will lead to lost packets (it's a plain
> 88X3310 without the MACSEC, so the PHY is not capable of generating
> flow control packets to pace the host.)
> 

I was thinking about filling it with all interfaces supported by that
device (which, I confess, I meant to be all interfaces supported by the
SOC). You are right though that this is problematic, at least because
some of the pins will not be connected at all... And I guess it would be
overkill if devicetree had to specify all interfaces.

Although... maybe we could start interpreting the phy-mode from DT (for
SFP ports) as max supported mode. Because there may be boards with SOCs
where mac driver supports, for example, all of USXGMII, 10gbase-r,
5gbase-r, 2500base-x, 1000base-x. But the board was certified only up
to 5gbase-r, for FCC purposes, or maybe there is a connector
somewhere that guarantees only 5 GHz...

> > The reason is that phy devices may want to know what interfaces are
> > supported by host even if no SFP is used (Marvell 88X3310 is an exmaple
> > of this).  
> 
> If a SFP is not being used, then the connectivity is described via DT
> and the hardware configuration of the PHY (which we rely on for the
> 88X3310.) I don't see much of a solution to that for the 88X3310.
> If DT describes the interface mode as 10gbase-r, then that ambiguously
> could refer to MACTYPE=4,5,6 - the driver can't know.
> 
> So, I don't think there is a simple answer here.
> 
> > The second patch (adding mactype selection to marvell10g) can get rid
> > of the rate matching code, and also
> > should update the mv3310_update_interface code accordignly.
> > 
> > Should I sent you these patches updated or should I create new patches
> > on top of yours?  
> 
> These are experimental, and for the reasons I mention above, they
> need careful thought.
> 

Very well, I think you are right.

BTW, I also sent yesterday some patches for your net-queue branch
(they are tagged "russell-kings-net-queue"). What do you think about
those?

Also the way marvell10g is in your net-queue may break 88E2110
currently. I have a device with this card, I shall look into this and
maybe send you a patch for this.

Marek