From patchwork Thu Apr 26 13:37:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= X-Patchwork-Id: 905066 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n1KRTAZv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Wymh3CpPz9s02 for ; Thu, 26 Apr 2018 23:37:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932085AbeDZNhh (ORCPT ); Thu, 26 Apr 2018 09:37:37 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:55687 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755354AbeDZNhg (ORCPT ); Thu, 26 Apr 2018 09:37:36 -0400 Received: by mail-wm0-f48.google.com with SMTP id a8so13048360wmg.5 for ; Thu, 26 Apr 2018 06:37:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:from:to:cc:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+C4XtcNg1egh0yyBUifjiMUbDu5l9sZ329P9vtZOpNw=; b=n1KRTAZvMtFxaN0LbeQsucmJf5H6/UnHR0u4w+XRM56O4uUM56v5wARZnEHdB/K26o 4vZDYON7wAKJeIAiVKgBKmPzb0pzVq4yQAaiWJQNH3pQbanE9iR9j1geu/x5a3LMOeDJ A4LeUiLi4/CHVP8MLmKOlnCdDbrptUmDWI3IeOj4+oKMEuVC1HkmR5AgNixbCcrulgkw UhMGzTlQUZGfuSFMjMkkjWJTVx52EwFW4vZHoEhBM7TY8j2nh1m84xtE1cIjsyrxfL3m f7lKxuDzatDu2T9pAQsxs8bOALAd8M5vIG9nux81hTWRzUrdCK4DMFAcoPuCsZiwgWcT q+aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:from:to:cc:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=+C4XtcNg1egh0yyBUifjiMUbDu5l9sZ329P9vtZOpNw=; b=J5A7VjBokKKK5QcF3CMNNT8pm+FE9s51zjs/cYhcI5QjcDFLQW6jAIg+gakIBO74DJ DnGJoY6AKHHiPkr27mgIU9w0auTAozJZ9wrR7dISk4BvS6sBn/qC+g2SO0rrxw9w87Qz x1bkTXKU6HK1b8OVD28qrQBqlQ57+h1xYKNXncWUMgXKI7FgTvypon+kSyNx/RQkYvu0 kw/F88Ij5J9bhOoHZtosWwIxjZ7aYgmdv9Z6ZrWY31djfLyYb9zrgAuCTJzIpYVWfgiN fZdilk/u8oQsarUPsptoQ5GyNOl68bBfGcOt85AvPNmW21z+yX/rDBha4bca+71SYgYV G/WA== X-Gm-Message-State: ALQs6tAx3xKDQsKsF9iPB1EzbzoukFEwDfBB1LnyF3fA8i8u5eYSsdVT wrV+1YnndhLDBSARMDcMfVk= X-Google-Smtp-Source: AB8JxZr4AS7ysmTbfIMKW8PfgpkuEUbaR0wtHa3F3BMiItGJJFB6n9T1knhql4bj8/5VHES+6siUmw== X-Received: by 10.28.215.85 with SMTP id o82mr8622986wmg.71.1524749854693; Thu, 26 Apr 2018 06:37:34 -0700 (PDT) Received: from [10.1.8.111] ([89.24.100.190]) by smtp.gmail.com with ESMTPSA id 11sm16052416wmd.26.2018.04.26.06.37.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 06:37:33 -0700 (PDT) Subject: i.MX6S/DL and QCA8334 switch using DSA driver - CPU port not working References: <037faf3c-8e8f-a696-8312-d1380c3b8656@gmail.com> From: =?utf-8?b?TWljaGFsIFZva8OhxI0=?= To: netdev@vger.kernel.org Cc: Andrew Lunn ";" Vivien Didelot ";" Florian Fainelli X-Forwarded-Message-Id: <037faf3c-8e8f-a696-8312-d1380c3b8656@gmail.com> Message-ID: <649c06a4-ca63-cb38-f105-ffd9dc17f5d2@gmail.com> Date: Thu, 26 Apr 2018 15:37:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <037faf3c-8e8f-a696-8312-d1380c3b8656@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Ahoj, Sorry for bothering you guys but I could not come up with a more appropriate place to ask my question. I would very much appreciate some adivce to the DSA/QCA8K driver usage. I am not (yet) very educated in networking internals so my wording may not be right and my expectations may be wrong. I am working on custom boards based on i.MX6S and i.MX6DL with QCA8334 four port switch chip. The switch is connected to CPU using MDIO and RGMII interface. _____ _____________ | | | QCA8334 | | | RGMII | port2| eth2 <---> LAN (DHCP server) | CPU | <------> eth0 |port0 | | | MDIO | port3| eth1 <---> Some device |_____| <------> |_____________| HW issue is out of question as we are using the HW for a long time with older kernel and a custom PHY driver for the switch. I am now in a process of upgrading the kernel from 3.14 to 4.9 and I would like to get rid of our ugly driver and utilize the mainline code. I went through a lot of documentation/slides/video regarding the DSA subsystem. I am still having a hard time to make the switch work as I expect with DSA and qca8k driver. I will describe my problem in three steps: - 1. The old version - this is what we were using so far. - 2. Current state - this is what I was able to come up with. - 3. Questions ------------------ 1. The old version ------------------ - Linux 3.14 (Freescale 3.14-1.1.x-imx branch) - Custom PHY driver for the switch chip Device tree snippet: &fec { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet_4>; phy-mode = "rgmii"; phy-reset-gpios = <&gpio1 25 0>; phy-reset-duration = <0x14>; phy-supply = <&sw2_reg>; phy-handle = <ðphy0>; status = "okay"; mdio { #address-cells = <1>; #size-cells = <0>; ethphy0: ethernet-phy@0 { compatible = "ethernet-phy-id004d.d036"; reg = <0>; max-speed = <1000>; }; }; }; In my old setup I see only one ethernet interface. The driver leaves most internal registers of the switch in its default state. The major change is that forwarding is enabled not just across all the user ports (HW default) but to the CPU port as well. qca8k_write(priv, 0x0624, 0x007F7F7F); Regardless of state of the eth0 interface, communication is possible through the switch. Device connected to port3 can get IP address from local DHCP server. This is what you get by default without touching a single bit of the switch internal registers. Then when I bring up the eth0 interface also the CPU itself can get IP address from local DHCP server and communicate to LAN or with the device. ---------------- 2. Current state ---------------- - Linux 4.9.84 (Freescale 4.9-1.0.x-imx branch) - Mainline DSA drivers - Mainline qca8k driver The Freescale branch does not introduce any changes to the DSA nor to the QCA8K drivers from mainline. The QCA8K driver currently supports only the seven-port variant QCA8337. AFAIK the only difference between the QCA8337 and QCA8334 we use is the number of ports - 7 vs 4 respectively. So I added "qca,qca8334" compatible string to the qca8k_of_match table in qca8k.c driver. These corresponding configs are enabled: CONFIG_HAVE_NET_DSA=y CONFIG_NET_DSA=y CONFIG_NET_DSA_TAG_QCA=y CONFIG_NET_DSA_QCA8K=y Device tree snippet: &fec { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet_4>; phy-mode = "rgmii"; phy-reset-gpios = <&gpio1 25 0>; phy-reset-duration = <0x14>; phy-supply = <&sw2_reg>; phy-handle = <ðphy0>; status = "okay"; mdio { #address-cells = <1>; #size-cells = <0>; phy_port2: phy@1 { reg = <1>; }; phy_port3: phy@2 { reg = <2>; }; switch@0 { compatible = "qca,qca8334"; #address-cells = <1>; #size-cells = <0>; reg = <0>; ports { #address-cells = <1>; #size-cells = <0>; ethphy0: port@0 { reg = <0>; label = "cpu"; phy-mode = "rgmii"; ethernet = <&fec>; fixed-link { speed = <1000>; full-duplex; }; }; ethphy2: port@2 { reg = <2>; label = "eth2"; phy-handle = <&phy_port2>; }; ethphy3: port@3 { reg = <3>; label = "eth1"; phy-handle = <&phy_port3>; }; }; }; }; }; # dmesg [ 1.954903] libphy: fec_enet_mii_bus: probed [ 1.955457] mdio_bus 2188000.ethernet-1:00: mdio_device_register [ 1.955763] dsa2: enabling port: 2 [ 1.955770] dsa2: enabling port: 3 [ 1.956493] fec 2188000.ethernet eth0: registered PHC device 0 ... [ 2.920810] dsa2: enabling port: 2 [ 2.920817] dsa2: enabling port: 3 [ 2.920878] DSA: switch 0 0 parsed [ 2.920884] DSA: tree 0 parsed [ 2.927628] libphy: dsa slave smi: probed [ 2.928161] Generic PHY 2188000.ethernet-1:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=2188000.ethernet-1:01, irq=-1) [ 2.929326] Generic PHY dsa-0.0:02: attached PHY driver [Generic PHY] (mii_bus:phy_addr=dsa-0.0:02, irq=-1) # ip a 2: eth0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 68:7c:d5:04:01:5a brd ff:ff:ff:ff:ff:ff 3: eth2@eth0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 68:7c:d5:04:01:5a brd ff:ff:ff:ff:ff:ff 4: eth1@eth0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 68:7c:d5:04:01:5a brd ff:ff:ff:ff:ff:ff At this point I am able to bring up all three interfaces, create a bridge, add eth1 and eth2 to the bridge and bring up the bridge. But the bridge does not work. No communication is possible from one port to the other. To make the bridge work I need to enable forwarding across all the switch ports at setup. --- Then when I do: # ifconfig eth0 up # ifconfig eth1 up # ifconfig eth2 up # brctl addbr br0 # brctl addif eth1 # brctl addif eth2 # ifconfig br0 up the bridge works fine. But I am still not able to make work the CPU port though. # udhcpc -i eth2 Sending discover... [FOREVER] The same for eth1, eth2 and br0. I suspect the problem may be at different levels: - The RGMII interface is not properly configured -- at the CPU side, or -- at the switch chip side. - Some setup that I have not done needs to be done (in userspace). ------------ 3. Questions ------------ Q: What is the correct interface that the CPU should use to talk to the outside world? I am convinced any of the eth1, eth2, br0 interfaces can be used. Q: Is there something else that needs to be done to get networking going on the CPU interface? Q: Is my device tree correct? Q: Lets assume the CPU port is working. Is NFS boot of the CPU possible from at least one port of the switch? Any hints how to deal with that will be much appreciated. BR, Michal --- a/drivers/net/dsa/qca8k.c +++ b/drivers/net/dsa/qca8k.c @@ -578,12 +578,12 @@ qca8k_setup(struct dsa_switch *ds) if (ds->enabled_port_mask & BIT(i)) qca8k_port_set_status(priv, i, 0); - /* Forward all unknown frames to CPU port for Linux processing */ + /* Forward all unknown frames to all pors */ qca8k_write(priv, QCA8K_REG_GLOBAL_FW_CTRL1, BIT(0) << QCA8K_GLOBAL_FW_CTRL1_IGMP_DP_S | - BIT(0) << QCA8K_GLOBAL_FW_CTRL1_BC_DP_S | - BIT(0) << QCA8K_GLOBAL_FW_CTRL1_MC_DP_S | - BIT(0) << QCA8K_GLOBAL_FW_CTRL1_UC_DP_S); + 0x7f << QCA8K_GLOBAL_FW_CTRL1_BC_DP_S | + 0x7f << QCA8K_GLOBAL_FW_CTRL1_MC_DP_S | + 0x7f << QCA8K_GLOBAL_FW_CTRL1_UC_DP_S); /* Setup connection between CPU port & user ports */ for (i = 0; i < DSA_MAX_PORTS; i++) {