All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Russell King - ARM Linux admin <linux@armlinux.org.uk>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: No traffic with Marvell switch and latest linux-next
Date: Sun, 24 Feb 2019 10:10:57 +0100	[thread overview]
Message-ID: <6dd3f82a-eea0-c9b4-8dd6-f2f313578b1f@gmail.com> (raw)
In-Reply-To: <20190223234235.GA26626@lunn.ch>

On 24.02.2019 00:42, Andrew Lunn wrote:
>> it took me quite some time to debug this issue ..
>>
>> At first a bisect pointed to one of my commits:
>> 5502b218e001 ("net: phy: use phy_resolve_aneg_linkmode in genphy_read_status")
>>
>> Further digging lead me to some suspicious dsa code:
>> In dsa_port_fixed_link_register_of() there's a call to genphy_read_status().
>> At the time of the call phydev->advertising is empty, therefore the fixed phy
>> settings are overwritten with defaults (10/half) what breaks the system.
>>
>> Worth to be mentioned is that for the PHY these two flags are set:
>> - is_pseudo_fixed_link (that's ok)
>> - autoneg -> I'm not sure this is correct.
>>
>> It seems that you once added the code in question:
>> 39b0c705195e ("net: dsa: Allow configuration of CPU & DSA port speeds/duplex")
> 
> Hi Heiner
> 
> For Ethernet switches, you can have device trees like this:
> 
>                        switch0: switch@0 {
>                                 compatible = "marvell,mv88e6085";
>                                 pinctrl-0 = <&pinctrl_gpio_switch0>;
>                                 pinctrl-names = "default";
>                                 reg = <0>;
>                                 dsa,member = <0 0>;
>                                 interrupt-parent = <&gpio0>;
>                                 interrupts = <27 IRQ_TYPE_LEVEL_LOW>;
>                                 interrupt-controller;
>                                 #interrupt-cells = <2>;
>                                 eeprom-length = <512>;
> 
>                                 ports {
>                                         #address-cells = <1>;
>                                         #size-cells = <0>;
> 
>                                         port@0 {
>                                                 reg = <0>;
>                                                 label = "lan0";
>                                                 phy-handle = <&switch0phy0>;
>                                         };
> 
> ...
>                                         switch0port5: port@5 {
>                                                 reg = <5>;
>                                                 label = "dsa";
>                                                 phy-mode = "rgmii-txid";
>                                                 link = <&switch1port6
>                                                         &switch2port9>;
>                                                 fixed-link {
>                                                         speed = <1000>;
>                                                         full-duplex;
>                                                 };
>                                         };
> 
> This is a DSA port. It is used to connect two Ethernet switches
> together. In this case, the MACs are connected back to back. There are
> no PHYs involved. These ports don't have a netdev associated with
> them, since they are just pipes between switches, not user interfaces.
> 
> If i remember correctly, the code you are looking at was to deal with
> the "rgmii-txid". Without the TXID, i could not get frames to pass
> between the ports.
> 
> There is a second use case as well. The Vybrid FEC ethernet controller
> is a Fast Ethernet port. The switch ports are 1G. DSA drivers set the
> port connecting to the SoC to its highest speed. Again, there is no
> netdev associated to the switch port, and generally the MAC ports are
> connected back to back. This 100 vs 1000 does not work for the
> Vybrid. So we add a fixed PHY to the CPU port.
> 
>                                         port@6 {
>                                                 reg = <6>;
>                                                 label = "cpu";
>                                                 ethernet = <&fec1>;
> 
>                                                 fixed-link {
>                                                         speed = <100>;
>                                                         full-duplex;
>                                                 };
>                                         };
> 
> And there is a third use case:
> 
>                                        port@4 {
>                                                 reg = <4>;
>                                                 label = "optical4";
> 
>                                                 fixed-link {
>                                                         speed = <1000>;
>                                                         full-duplex;
>                                                         link-gpios = <&gpio6 3
>                                                               GPIO_ACTIVE_HIGH>;
>                                                 };
>                                         };
> 
> We have a GPIO which tells us if the link it up, because there is not
> a PHY here, but an optical module. The GPIO tells us about loss of
> signal. Unfortunately we cannot use the SFP driver here, because of a
> hardware issue.
> 
> In all cases end up in the same code. We want to tell the MAC to
> configure RGMII delays, or to configure the port speed, or to have the
> correct initial link state. The adjust_link() call can do this, if
> passed a phydev. And we have a phydev for the fixed-link PHY. However,
> since it has never been attached to a netdev, phy_start() called, etc,
> the state information is maybe not correct. So we call config_init()
> and read_status(), so phydev should reflect the state of the
> fixed-link PHY. And a fixed-link PHY is always c22, and it can be
> driven by genphy. Take a look at drivers/net/phy/swphy.c which is the
> core of the simulation, and fixed_phy.c
> 
Thanks a lot for the very comprehensive explanation!

I think what's not correct is that phydev->autoneg is set
(by phy_device_create) for a fixed link. genphy_config_init() ensures
that aneg isn't set in the "supported" bitmap, but it doesn't care
about phydev->autoneg. IMO we need to consider this at few places:

- genphy_config_init
  It should clear phydev->autoneg if aneg isn't supported.

- phy_probe
  After having read the chip features we should clear phydev->autoneg
  if aneg isn't supported.

- In __fixed_phy_register() we should clear phydev->autoneg.

>> I did what I like to do most and removed some code.
>> W/o the calls to genphy_config_init() and genphy_read_status() it works again.
>> Do these calls have some purpose here with a fixed link?
> 
> Maybe with all the core changes, these calls are no longer needed? We
> just need to ensure the state in phydev reflects the state of the
> fixed link, i.e. in this case 100 Full.
> 
I think at least the call to genphy_config_init can be removed. I don't
really like the name of this function anyway, because it doesn't
initialize anything but is a sanity check that reads chip capabilities
and removes unsupported modes from the "supported" bitmap.

genphy_read_status() we need to read the link status from GPIO
(if applicable in the use case). To be more precise, most likely
calling genphy_update_link() would be sufficient because speed and
duplex are fixed.

> Looking forward, at some point we are going to have to make fixed-link
> support higher speeds. That probably means we need a swphy-c45 which
> emulates the standard registers for 2.5G, 5G and 10G. At that point
> genphy will not work...
> 
>       Andrew
> .
> 
Heiner

  reply	other threads:[~2019-02-24  9:11 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-17 15:34 No traffic with Marvell switch and latest linux-next Heiner Kallweit
2019-02-17 15:40 ` Russell King - ARM Linux admin
2019-02-17 15:50   ` Heiner Kallweit
2019-02-17 16:40     ` Heiner Kallweit
2019-02-17 16:57       ` Andrew Lunn
2019-02-17 17:06         ` Heiner Kallweit
2019-02-17 17:10           ` Andrew Lunn
2019-02-18 18:16             ` Heiner Kallweit
2019-02-18 18:21               ` Andrew Lunn
2019-02-23 21:48                 ` Heiner Kallweit
2019-02-23 23:42                   ` Andrew Lunn
2019-02-24  9:10                     ` Heiner Kallweit [this message]
2019-02-24 15:04                       ` Andrew Lunn
2019-02-24 15:15                         ` Russell King - ARM Linux admin
2019-02-24 15:28                           ` Heiner Kallweit
2019-02-24 15:34                             ` Russell King - ARM Linux admin
2019-02-24 15:39                               ` Heiner Kallweit
2019-02-24 15:49                                 ` Russell King - ARM Linux admin
2019-02-24 16:32                                   ` Florian Fainelli
2019-02-24 17:04                                     ` Andrew Lunn
2019-02-24 21:26                                       ` Florian Fainelli
2019-02-24 21:42                                         ` Heiner Kallweit
2019-02-24 15:31                     ` Russell King - ARM Linux admin
2019-02-24 17:28                       ` Andrew Lunn
2019-02-24 19:41                         ` Russell King - ARM Linux admin
2019-02-23 23:55                   ` Florian Fainelli
2019-02-17 15:45 ` Andrew Lunn
2019-02-17 15:48   ` Heiner Kallweit
2019-02-17 15:57     ` Andrew Lunn
2019-02-17 16:01       ` Heiner Kallweit
2019-02-17 15:51 ` Andrew Lunn
2019-02-17 15:55   ` Heiner Kallweit

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=6dd3f82a-eea0-c9b4-8dd6-f2f313578b1f@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.