Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64695C43381 for ; Sun, 24 Feb 2019 09:11:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2888020652 for ; Sun, 24 Feb 2019 09:11:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lz8UyiWw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbfBXJLI (ORCPT ); Sun, 24 Feb 2019 04:11:08 -0500 Received: from mail-wr1-f50.google.com ([209.85.221.50]:42475 "EHLO mail-wr1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbfBXJLH (ORCPT ); Sun, 24 Feb 2019 04:11:07 -0500 Received: by mail-wr1-f50.google.com with SMTP id r5so6658946wrg.9 for ; Sun, 24 Feb 2019 01:11:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TFGghD33P+/bnM/7r0NmODIpbtleKFdIRUwFxOknYck=; b=lz8UyiWwBtBp1BcRkT8k/7H52uAWzlW/MYkKq8CQp3Tvmp6J1AXtEQSt4j9DMjefA+ Osrn9kAb/lmVDhw6aOkK183LKMUJRDLMaahMSOlNX1wjDIj92jlVIeayOhtn/qpZOd9S UL7usHNvcs67NLrhrv1fOIPaqAmbRwLjtuR1YdPkOpl6j+dfdjpwe4JF2BiJplvhX19p zLFWCPtPe61x4oJLXBjccMXPrce7yCmzyXYgKjlxlJmXAuWg09QLP+udgmztr+7uaBiH wJc8eix5Ug+BHUaqZzaijmwuqoDWGqb9JLYbCYmc9pPySjVzmNUYBl2B0Hn6eexN8rqS z1cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TFGghD33P+/bnM/7r0NmODIpbtleKFdIRUwFxOknYck=; b=iB1xs3He8WJ9au3LTvvB8I28MIqYAhBb0MmcmnpfPYVjUg2JDIH9pGX4TFXlPwD856 Zp6Eta5DdwmTwDwojtmQm5lZtYsWPzO+b/pxNPZ4oHmaPBAvxCS1cE545wGNkrdm3UJO 2uamowoKyFnQYMgxbrs8Fn87T44U91D2xOOsjJxnXMSRfr4fqS09cEqNK0cUUo75Tpfe 1DZnPf+nP8bEMLixwRfAUdjuRVnlyPRKzX+RxGIfJIxaAC9mif7kI+1kctIV5HYEwNqq Ti9x6BaK9EjVkWxKAzk6P57Szk6oDIebmNU2PbIiJzePE4gcbzCTLqqrQtOEQc9KL9Ip xQKA== X-Gm-Message-State: AHQUAuZyfSaSLtqTtN41zKUWBChF9hj78yYRpxRnEung35AbfH/UhSe5 M275e7YjEEHbeBZ9xMB1MyQ1/8uq X-Google-Smtp-Source: AHgI3Ib5FkZR0JPACoZxj8lsEbXaJijpvJhCJhqmvIWSiEg0FHfCHUgZrNXT98CzEf9PBULVkoR2Uw== X-Received: by 2002:adf:ffcf:: with SMTP id x15mr8582675wrs.277.1550999465095; Sun, 24 Feb 2019 01:11:05 -0800 (PST) Received: from ?IPv6:2003:ea:8bf1:e200:1133:81d:72d3:c59f? (p200300EA8BF1E2001133081D72D3C59F.dip0.t-ipconnect.de. [2003:ea:8bf1:e200:1133:81d:72d3:c59f]) by smtp.googlemail.com with ESMTPSA id v67sm13402022wmb.9.2019.02.24.01.11.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 01:11:04 -0800 (PST) Subject: Re: No traffic with Marvell switch and latest linux-next To: Andrew Lunn Cc: Russell King - ARM Linux admin , Florian Fainelli , "netdev@vger.kernel.org" References: <0907f213-df83-4bb8-8fad-21b1dedaeca5@gmail.com> <20190217154026.tykxexcndx7l5urk@shell.armlinux.org.uk> <291e7622-4402-e58f-503c-ffc7c6b2f055@gmail.com> <20190217165730.GF5968@lunn.ch> <20190217171027.GH5968@lunn.ch> <33f9ef8d-df62-e154-f880-f886abf54e0a@gmail.com> <20190218182136.GE14879@lunn.ch> <188fcef7-81fe-cffc-af71-1f37725b8611@gmail.com> <20190223234235.GA26626@lunn.ch> From: Heiner Kallweit Message-ID: <6dd3f82a-eea0-c9b4-8dd6-f2f313578b1f@gmail.com> Date: Sun, 24 Feb 2019 10:10:57 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190223234235.GA26626@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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