From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 80863C43381 for ; Wed, 20 Mar 2019 22:17:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D52D2175B for ; Wed, 20 Mar 2019 22:17:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NaoKXz7P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbfCTWR1 (ORCPT ); Wed, 20 Mar 2019 18:17:27 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:35454 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727437AbfCTWR1 (ORCPT ); Wed, 20 Mar 2019 18:17:27 -0400 Received: by mail-yw1-f68.google.com with SMTP id d132so3343769ywa.2; Wed, 20 Mar 2019 15:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ycJIYMAvOVpHjtY5xMa29AUO/2pkdwqi2Xkn2jnZHj8=; b=NaoKXz7PwSJ23yGLf5+x/P4Uo1KfoF9iQTpBp/sF0Y4wdW72ptkF3QX4aZZKfPd/TN V1kR3zEnEv899mFK+BC+6mO6HKvYPPqdurE7KKTb37oDFOtuZWboT7YnuGqPI02JIjx2 1xZyQoN7IHFbtbXolJXkNF9kGylhvTGsLF8HWaE6FDmk8fBBQIgQ6/all8IvP+INp+6t mBlYrDjdDwOmJe8+V46UqY0HWOj+PC5CWkQhwYONw0uhpToGdjt4j5UfzWqH2qClXifD xkoaBGT0XDy/djJdICfpWmeHZCdEje9j/PKs4x5BN/34mqaSKvLR0UIqmUC0ogVHXuOH /grA== 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:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ycJIYMAvOVpHjtY5xMa29AUO/2pkdwqi2Xkn2jnZHj8=; b=R2QBgs0H51yiOxpjN2VGNaEMmKmaJxSUqrzFcFhYsqf9AMfdtts6KG/9plYkO7j8f5 6qWMTPOMMxpM2pPMZpqds0Y3JsWPnXhhooczaADJHaQwWhdMOt0q8PNRLWW7EBZI7YOp s6f/bZ/F7HQr5tVd/fgbpA66ihjo2SbJGVFT+qBPUKiBUdsicpp49elNfRVqxvykz7gg stR3emgaOSa6amqMe8V7Qy7ZNn0bVC/GvIMDH6+PM2OOZljBwq0ObqowOuWCRbJEFIpG tCQbLAkm0tOxW2HGowsiL7t+Ib8d1tRp2e2jFcmf1xEfQmy3NukSdQkCEvarv88D8L7Q 81jA== X-Gm-Message-State: APjAAAWRYtLyVV0a7JpDYuJBrOJFUfBjMIcQU4io0gpJt/E5kT9yzkbK EzL2hySWnduFw+aSF7y8cxWb0XmZ X-Google-Smtp-Source: APXvYqxLbUBv87NfH6r+yH0Xz/TUN3Lomuv/jg9WHwjMSYaAzipB3j+HiRgZP6spV2onDwoVS1Ru5w== X-Received: by 2002:a81:5f83:: with SMTP id t125mr390299ywb.439.1553120246145; Wed, 20 Mar 2019 15:17:26 -0700 (PDT) Received: from [10.67.50.0] ([192.19.223.250]) by smtp.googlemail.com with ESMTPSA id g1sm1044483ywf.0.2019.03.20.15.17.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Mar 2019 15:17:25 -0700 (PDT) Subject: Re: [PATCH v3 3/3] net: dsa: qca8k: extend slave-bus implementations To: Christian Lamparter Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, Vivien Didelot , Andrew Lunn , Rob Herring , Mark Rutland References: <20190319195419.12746-1-chunkeey@gmail.com> <20190319195419.12746-3-chunkeey@gmail.com> <5cd4b993-d1fa-80a2-a03b-a494a63ae56c@gmail.com> <3792532.HfxQciIWxC@debian64> From: Florian Fainelli Openpgp: preference=signencrypt Autocrypt: addr=f.fainelli@gmail.com; prefer-encrypt=mutual; keydata= mQGiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu9cSDvWtO1hXeHIfQIE/xcqvlRH783KrihLcsmnBqOiS6rJDO2x1eAgC8meAX SAgsrBhcgGl2Rl5gh/jkeA5ykwbxA/9u1eEuL70Qzt5APJmqVXR+kWvrqdBVPoUNy/tQ8mYc nzJJ63ng3tHhnwHXZOu8hL4nqwlYHRa9eeglXYhBqja4ZvIvCEqSmEukfivk+DlIgVoOAJbh qIWgvr3SIEuR6ayY3f5j0f2ejUMYlYYnKdiHXFlF9uXm1ELrb0YX4GMHz7QnRmxvcmlhbiBG YWluZWxsaSA8Zi5mYWluZWxsaUBnbWFpbC5jb20+iGYEExECAC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: Wed, 20 Mar 2019 15:17:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <3792532.HfxQciIWxC@debian64> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 3/20/19 3:02 PM, Christian Lamparter wrote: > Sorry. I hit Sent by accident and then I had to run... > This is the full response. > > On Wednesday, March 20, 2019 7:27:09 PM CET Florian Fainelli wrote: >> On 3/19/19 12:54 PM, Christian Lamparter wrote: >>> This patch implements accessors for the QCA8337 MDIO access >>> through the MDIO_MASTER register, which makes it possible to >>> access the PHYs on slave-bus through the switch. In cases >>> where the switch ports are already mapped via external >>> "phy-phandles", the internal mdio-bus is disabled in order to >>> prevent a duplicated discovery and enumeration of the same >>> PHYs. Don't use mixed external and internal mdio-bus >>> configurations, as this is not supported by the hardware. >>> >>> Signed-off-by: Christian Lamparter >>> --- >>> Changes from v2: >>> - Make it compatible with existing configurations >>> - make it clear that's sadly a either external or >>> internal mdio bus access. >>> >>> Changes from v1: >>> - drop DT port <-> phy mapping >>> - added register definitions for the MDIO control register >>> - implemented new slave-mdio bus accessors >>> - DT-binding: fix switch's PSEUDO_PHY address. It's 0x10 not 0. >>> >>> Old patch (+ discussion) for reference: >>> >> >> LGTM, just a few comments/nits below. >> >>> >>> Tested on a Compex WPQ864 (IPQ8064 + QCA8337N) >>> internal bus: >>> qca8k 37000000.mdio-mii:10 lan1 (uninitialized): PHY [!mdio@37000000!switch@10:01] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan2 (uninitialized): PHY [!mdio@37000000!switch@10:02] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan3 (uninitialized): PHY [!mdio@37000000!switch@10:03] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan4 (uninitialized): PHY [!mdio@37000000!switch@10:04] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 wan (uninitialized): PHY [!mdio@37000000!switch@10:05] driver [Generic PHY] >>> >>> external bus: >>> qca8k 37000000.mdio-mii:10 lan1 (uninitialized): PHY [37000000.mdio-mii:00] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan2 (uninitialized): PHY [37000000.mdio-mii:01] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan3 (uninitialized): PHY [37000000.mdio-mii:02] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 lan4 (uninitialized): PHY [37000000.mdio-mii:03] driver [Generic PHY] >>> qca8k 37000000.mdio-mii:10 wan (uninitialized): PHY [37000000.mdio-mii:04] driver [Generic PHY] >>> --- >> >> [snip] >> >>> +static int >>> +qca8k_mdio_write(struct qca8k_priv *priv, int port, int regnum, u16 data) >>> +{ >>> + u32 val; >>> + int phy; >>> + >>> + phy = qca8k_port_to_phy(port); >>> + if (phy < 0 || (regnum < 0 || regnum >= QCA8K_MDIO_MASTER_MAX_REG)) >>> + return -EINVAL; >> >> Is not the first condition always true? We should fix the signature of >> phy_{read,write} in dsa.h to match what mdiobus_{read,write} takes, >> which is an u32 regnum. > > Yes in that case regnum will never be negative so this check can be > futher simplyfied as dsa_slave_phy_{read|write} checks ds->phy_mii_mask. > So port can't be invalid. In the next version this will be: > > if (regnum >= QCA8K_MDIO_MASTER_MAX_REG) > return -EINVAL; > > Since regnum > 31 will spill into QCA8K_MDIO_MASTER_PHY_ADDR > and the higher control bits. > >>> + >>> + val = QCA8K_MDIO_MASTER_BUSY | QCA8K_MDIO_MASTER_EN | >>> + QCA8K_MDIO_MASTER_WRITE | QCA8K_MDIO_MASTER_PHY_ADDR(phy) | >>> + QCA8K_MDIO_MASTER_REG_ADDR(regnum) | >>> + QCA8K_MDIO_MASTER_DATA(data); >>> + >>> + qca8k_write(priv, QCA8K_MDIO_MASTER_CTRL, val); >>> + >>> + return qca8k_busy_wait(priv, QCA8K_MDIO_MASTER_CTRL, >>> + QCA8K_MDIO_MASTER_BUSY); >>> +} >>> + >>> +static int >>> +qca8k_mdio_read(struct qca8k_priv *priv, int port, int regnum) >>> +{ >>> + u32 val; >>> + int phy; >>> + >>> + phy = qca8k_port_to_phy(port); >>> + if (phy < 0 || (regnum < 0 || regnum >= QCA8K_MDIO_MASTER_MAX_REG)) >>> + return -EINVAL; >> >> Likewise. > Yes. > >> [snip] >> >>> +static int >>> +qca8k_phy_read(struct dsa_switch *ds, int port, int regnum) >>> +{ >>> + struct qca8k_priv *priv = ds->priv; >>> + int ret = -EIO; >>> + >>> + if (ds->slave_mii_bus->phy_mask & BIT(port)) >>> + ret = qca8k_mdio_read(priv, port, regnum); >> >> I suppose in theory you could also look at the external_mdio_mask and do >> something like this: >> >> if (ds->slave_mii_bus->phy_mask & BIT(port)) >> ret = qca8k_mdio_read(priv, port, regnum); >> else >> ret = mdiobus_read_nested(priv->bus, port, regnum); >> >> Not strictly necessary for now. > > Oh, in the external mdio bus scenario, I don't have qca8k_phy_read wired up. > So the else branch would be dead code for now. (but see below) > > But there's some other room for improvement: > However since we are always called from dsa_slave_phy_read the > if (ds->slave_mii_bus->phy_mask & BIT(port)) > could be removed since dsa_slave_phy_read does that already. > >>> + >>> + return ret; >>> +} >>> + >>> +static int >>> +qca8k_setup_mdio_bus(struct qca8k_priv *priv) >>> +{ >>> + struct device_node *ports, *port; >>> + struct mii_bus *bus; >>> + u32 internal_mdio_mask = 0; >>> + u32 external_mdio_mask = 0; >>> + u32 reg; >>> + int err; >>> + >>> + ports = of_get_child_by_name(priv->dev->of_node, "ports"); >>> + if (!ports) >>> + return -EINVAL; >>> + >>> + for_each_available_child_of_node(ports, port) { >>> + err = of_property_read_u32(port, "reg", ®); >>> + if (err) >>> + return err; >>> + >>> + if (dsa_is_user_port(priv->ds, reg)) { >> >> You could reduce indentation a bit with: >> >> if (!dsa_is_user_port(priv->ds, reg)) >> continue; > > Yes. This is nicer. >> >>> + if (of_property_read_bool(port, "phy-handle")) >>> + external_mdio_mask |= BIT(reg); >>> + else >>> + internal_mdio_mask |= BIT(reg); >>> + } >>> + } >>> + >>> + if (!external_mdio_mask && !internal_mdio_mask) { >>> + dev_err(priv->dev, "no PHYs are defined.\n"); >>> + return -EINVAL; >>> + } >>> + >>> + /* The QCA8K_MDIO_MASTER_EN Bit, which grants access to PHYs through >>> + * the MDIO_MASTER register also _disconnects_ the external MDC >>> + * passthrough to the internal PHYs. It's not possible to use both >>> + * configurations at the same time! >>> + */ >> >> Right, but presumably you can do this on a per-port basis and support >> both types of configuration? bcm_sf2 is pretty much the same thing. > per-port? Sadly not that I know of, it's a per-chip (or per-switch) setting > from what I can tell by poking the chip. The MDIO_MASTER enable is also global to the switch with the bcm_sf2. It is basically a mux to indicate whether the internal roboswitch MDIO master should be used, or the glued MDIO controller should be used. Both are integrated into the switch, just not at the same level, which makes things confusing. The issue in the D0 revision of the silicon was that when you used the glued MDIO controller, any MDIO access would be snooped and interpreted by the internal MDIO slave of the switch and so while programming a seemingly ressembling external Broadcom switch, you would also happen to program the internal Broadcom switch (where they are register compatible, which is like 95%) but with possibly incompatible settings. > > I've looked at bcm_sf2 and the best hint seems to be in this commit: > > |b8c6cd1d316f net: dsa: bcm_sf2: do not use indirect reads and writes for 7445E0 > | > |7445E0 contains an ECO which disconnected the internal SF2 pseudo-PHY which was > |known to conflict with the external pseudo-PHY of BCM53125 switches. This > |motivated the need to utilize the internal SF2 MDIO controller via indirect > |register reads/writes to control external Broadcom switches due to this address > |conflict (both responded at address 30d). [...] > > But this seems to involve the pseudo-PHYs (i.e. register access)? Which does not > sound like it what happens on the QCA8337. It's largely problematic with the pseudo-PHY of the switch itself, but can be generalized to any internal or external PHY really. > > For the QCA8337 the QCA8K_MDIO_MASTER_EN bit works as a changeover switch > for just the MDC line (datasheet 5.2.13 MDIO Master Control). So the User-Port > PHYs for LAN1-4 and WAN are moved (as in "mv" not "cp") between the external or > internal bus. This causes some very weird behavior from any PHY access of the > "disabled" bus: > > [ 17.036963] Generic PHY 37000000.mdio-mii:01: Master/Slave resolution failed, maybe conflicting manual settings? > [ 17.116927] Generic PHY 37000000.mdio-mii:02: Master/Slave resolution failed, maybe conflicting manual settings? > [ 17.196894] Generic PHY 37000000.mdio-mii:03: Master/Slave resolution failed, maybe conflicting manual settings? > > I did investigate this in https://patchwork.ozlabs.org/comment/2086257/ but > I didn't find a viable solution to make this work as from my POV, this > requires synchronization between the qca8k code and the variety of external > mdio-bus driver to pull this off. So I guess my point really is that on a per MDIO transaction basis, you could theoretically flip the MDIO_MASTER_EN bit such that you always read/write to the desired PHY address, whether it sits on the internal QCA8K bus, or on an external MDIO bus. Not that I think you should do it, but it sounds like it ought to be possible unless I completely misunderstand something here. > > In my case: The WPQ864 (IPQ806x) can either use a virtual mdio-gpio driver > (which is what most boards are using) or a some dedicated hardware that's > living in GMAC0's core but has no upstream linux driver (yet). > > Note3: > The QCA8337 can be interfaced through either MDIO or UART (share the > same pins, so only one option). Or alternatively through special/ > properitary ethernet-frames sent/received on the cpu port (I guess > that's "in-band"). > > (There's also a SPI interface but it's soley for connecting a > SPI EEPROM that would store VLAN, 802.1p QoS, DiffServ/TOS > settings. So this is probably aimed at standalone switches) > >> >>> + if (external_mdio_mask && internal_mdio_mask) { >>> + dev_err(priv->dev, "either internal or external mdio bus configuration is supported.\n"); >>> + return -EINVAL; >>> + } >> >> Don't both conditions amount to: >> >> if (external_mdio_mask == internal_mdio_mask) >> error()? > I think it is either (!!external_mdio_mask == !!internal_mdio_mask) > or (!external_mdio_mask == !internal_mdio_mask). > > if (external_mdio_mask == internal_mdio_mask) will always be false, > because the external_mdio_mask and internal_mdio_mask are bitmasks > on whenever the (enumerated) port has a phy-handle or not. It's not > possible for external_mdio_mask and internal_mdio_mask to be the > same non-null value. > > As for why I did it this way: I liked having different, somewhat > descriptive error messages for these cases. Because I have been on > so many -EINVAL wild-goose chases before. So please let me keep the > two distinct messages, OK? Certainly, no problem with that. -- Florian