netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Arun.Ramadoss@microchip.com
Cc: andrew@lunn.ch, linux-kernel@vger.kernel.org,
	UNGLinuxDriver@microchip.com, vivien.didelot@gmail.com,
	linux@armlinux.org.uk, f.fainelli@gmail.com, kuba@kernel.org,
	edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org,
	Woojung.Huh@microchip.com, davem@davemloft.net
Subject: Re: [RFC Patch net-next 07/10] net: dsa: microchip: apply rgmii tx and rx delay in phylink mac config
Date: Thu, 21 Jul 2022 00:04:05 +0300	[thread overview]
Message-ID: <20220720210405.6wv6d3fssopnpm7x@skbuf> (raw)
In-Reply-To: <d4696bc19472e9efd3a5581ea5c3bca201c90580.camel@microchip.com>

On Wed, Jul 20, 2022 at 02:51:42PM +0000, Arun.Ramadoss@microchip.com wrote:
> > Why not all RGMII modes and only these 2? There was a discussion a long
> > time ago that the "_*ID" values refer to delays applied by an attached PHY.
> > Here you are refusing to apply RGMII TX delays in the "rgmii" and "rgmii-txid"
> > modes.
> 
> I have reused the code of ksz9477 cpu config function and added the dll
> configuration for lan937x family alone. And understood that if device
> tree specificies as rgmii_txid then apply the egress delay, for
> rgmii_rxid apply ingress delay, for rgmii_id apply both.
> From your comment, I am inferring that apply the mac delay for all the
> rgmii interface "rgmii*".
> Can you correct me if am I wrong and bit elaborate on it.

What we are trying is to interpret what's written in
Documentation/devicetree/bindings/net/ethernet-controller.yaml in a way
that is consistent, even though its wording makes it evident that that
it was written in simpler times.

There it says:

      # RX and TX delays are added by the MAC when required
      - rgmii

      # RGMII with internal RX and TX delays provided by the PHY,
      # the MAC should not add the RX or TX delays in this case
      - rgmii-id

      # RGMII with internal RX delay provided by the PHY, the MAC
      # should not add an RX delay in this case
      - rgmii-rxid

      # RGMII with internal TX delay provided by the PHY, the MAC
      # should not add an TX delay in this case
      - rgmii-txid

The fact that the PHY adds delays in the directions specified by the
phy-mode value is established behavior; yet the MAC's behavior is pretty
much subject to interpretation, and this has resulted in varying
implementations in drivers.

The wise words above say that "RX and TX delays are added by the MAC
when required" - ok but when are they required? Determining this is
impossible based on the phy-mode alone, since there aren't just 2
degrees of freedom who may add delays (the PHY and the MAC). There also
exists the possibility of using serpentine traces (PCB delays), which
practically speaking, can't be described in phy-mode because then, a
potential PHY on the same link would also think they're for itself to
apply.

So the modern interpretation of phy-mode is to say that it simply does
not describe whether a MAC should apply delays in a direction or another.

So a separate set of properties was introduced, "rx-internal-delay-ps"
and "tx-internal-delay-ps". These have the advantage of being located
under the OF node of the MAC, and under the OF node of the PHY respectively.
So it's clearer which side is supposed to configure which delays, and
you also have finer control over the clock skew.

Initially when Prasanna first tried to upstream the lan937x, we discusssed
that since it's a new driver, it should support the modern interpretation
of RGMII delays, and we agreed on that strategy.

Now, with your recent refactoring that makes all switches share the same
probing logic (and OF node parsing), things are in a bit of a greyer area.

For one thing, you seem to have involuntarily inherited support for dubious
legacy bindings, such as the "phy-mode under the switch node" that is
described by commit edecfa98f602 ("net: dsa: microchip: look for
phy-mode in port nodes").

For another, you've inherited the existing interpretation of RGMII
delays from the KSZ9477 driver, which is that the driver interprets the
"phy-mode" as if it's a PHY (when in fact it's a MAC).

The KSZ9477 isn't by far the only MAC driver that applies RGMII delays
based on the phy-mode string, however in the past we made an effort to
update existing DSA drivers to the modern interpretation, see commits:

9ca482a246f0 ("net: dsa: sja1105: parse {rx, tx}-internal-delay-ps properties for RGMII delays")
5654ec78dd7e ("net: dsa: qca8k: rework rgmii delay logic and scan for cpu port 6")

There is a possibility to have a transitioning scheme: if the
"rx-internal-delay-ps" or "tx-internal-delay-ps" properties are present
under the MAC OF node, apply delays based on those. Otherwise, apply
delays based on phy-mode, and warn.

I'd appreciate if you could consider updating the KSZ common driver to
this interpretation of RGMII delays, so that the modern interpretation
becomes more widespread, and there are fewer places from which to copy a
non-standard one.

  reply	other threads:[~2022-07-20 21:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 16:02 [RFC Patch net-next 00/10] net: dsa: microchip: add support for phylink mac config and link up Arun Ramadoss
2022-07-12 16:02 ` [RFC Patch net-next 01/10] net: dsa: microchip: lan937x: read rgmii delay from device tree Arun Ramadoss
2022-07-19 10:28   ` Vladimir Oltean
2022-07-19 15:58     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 02/10] net: dsa: microchip: add common gigabit set and get function Arun Ramadoss
2022-07-19 10:37   ` Vladimir Oltean
2022-07-12 16:03 ` [RFC Patch net-next 03/10] net: dsa: microchip: add common 100/10Mbps selection function Arun Ramadoss
2022-07-19 10:48   ` Vladimir Oltean
2022-07-19 15:56     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 04/10] net: dsa: microchip: add common duplex and flow control function Arun Ramadoss
2022-07-19 10:52   ` Vladimir Oltean
2022-07-19 15:54     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 05/10] net: dsa: microchip: add support for common phylink mac link up Arun Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 06/10] net: dsa: microchip: lan937x: add support for configuing xMII register Arun Ramadoss
2022-07-19 11:04   ` Vladimir Oltean
2022-07-19 15:55     ` Arun.Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 07/10] net: dsa: microchip: apply rgmii tx and rx delay in phylink mac config Arun Ramadoss
2022-07-19 10:25   ` Vladimir Oltean
2022-07-20 14:51     ` Arun.Ramadoss
2022-07-20 21:04       ` Vladimir Oltean [this message]
2022-07-12 16:03 ` [RFC Patch net-next 08/10] net: dsa: microchip: ksz9477: use common xmii function Arun Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 09/10] net: dsa: microchip: ksz8795: " Arun Ramadoss
2022-07-12 16:03 ` [RFC Patch net-next 10/10] net: dsa: microchip: add support for phylink mac config Arun Ramadoss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220720210405.6wv6d3fssopnpm7x@skbuf \
    --to=olteanv@gmail.com \
    --cc=Arun.Ramadoss@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).