From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Lad, Prabhakar" Subject: Re: [Query]: DSA Understanding Date: Thu, 26 Jul 2018 16:20:43 +0100 Message-ID: References: <20180725161923.GD16819@lunn.ch> <20180726140818.GB8325@lunn.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Cc: netdev To: Andrew Lunn Return-path: Received: from mail-ed1-f67.google.com ([209.85.208.67]:38179 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729801AbeGZQig (ORCPT ); Thu, 26 Jul 2018 12:38:36 -0400 Received: by mail-ed1-f67.google.com with SMTP id t2-v6so1740006edr.5 for ; Thu, 26 Jul 2018 08:21:15 -0700 (PDT) In-Reply-To: <20180726140818.GB8325@lunn.ch> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, Jul 26, 2018 at 3:08 PM, Andrew Lunn wrote: >> Yes I am using fixed phy on slave1, following is my dts: > > Posting the original DTS file is better, not the decompiled version. > My bad will take care of it next time. >> >> ethernet@48484000 { >> compatible =3D "ti,dra7-cpsw", "ti,cpsw"; >> ti,hwmods =3D "gmac"; >> clocks =3D <0x124 0x125>; >> clock-names =3D "fck", "cpts"; >> cpdma_channels =3D <0x8>; >> ale_entries =3D <0x400>; >> bd_ram_size =3D <0x2000>; >> mac_control =3D <0x20>; >> slaves =3D <0x2>; >> active_slave =3D <0x0>; >> cpts_clock_mult =3D <0x784cfe14>; >> cpts_clock_shift =3D <0x1d>; >> reg =3D <0x48484000 0x1000 0x48485200 0x2e00>; >> #address-cells =3D <0x1>; >> #size-cells =3D <0x1>; >> ti,no-idle; >> interrupts =3D <0x0 0x14e 0x4 0x0 0x14f 0x4 0x0 0x150 0x4 >> 0x0 0x151 0x4>; >> ranges; >> syscon =3D <0x8>; >> status =3D "okay"; >> pinctrl-names =3D "default", "sleep"; >> pinctrl-0 =3D <0x126 0x127>; >> pinctrl-1 =3D <0x128 0x129>; >> dual_emac; >> linux,phandle =3D <0x500>; >> phandle =3D <0x500>; > > So here is 0x500 > >> >> mdio@48485000 { >> compatible =3D "ti,cpsw-mdio", "ti,davinci_mdio"; >> #address-cells =3D <0x1>; >> #size-cells =3D <0x0>; >> ti,hwmods =3D "davinci_mdio"; >> bus_freq =3D <0xf4240>; >> reg =3D <0x48485000 0x100>; >> status =3D "okay"; >> pinctrl-names =3D "default", "sleep"; >> pinctrl-0 =3D <0x12a>; >> pinctrl-1 =3D <0x12b>; >> >> ethernet-phy@1 { >> reg =3D <0x1>; >> linux,phandle =3D <0x12c>; >> phandle =3D <0x12c>; >> }; >> }; >> >> slave@48480200 { >> mac-address =3D [00 00 00 00 00 00]; >> status =3D "okay"; >> phy-handle =3D <0x12c>; >> phy-mode =3D "rgmii"; >> dual_emac_res_vlan =3D <0x1>; >> }; >> >> slave@48480300 { >> mac-address =3D [00 00 00 00 00 00]; >> status =3D "okay"; >> phy-mode =3D "rgmii"; >> dual_emac_res_vlan =3D <0x2>; >> linux,phandle =3D <0xf3>; >> phandle =3D <0xf3>; > > This is the actual interface you are using and it has a phandle of > 0xf3. > The dsa of_find_net_device_by_node() looks for ethernet device node, but the above node is for the cpsw slave. I tried adding 0xf3 and got probe defer, that is the reason I added 0x500 (mdio) reference to cpu switch and patched to pick up eth1 instead of eth0. >> >> fixed-link { >> speed =3D <0x3e8>; >> full-duplex; >> }; >> }; >> >> cpsw-phy-sel@4a002554 { >> compatible =3D "ti,dra7xx-cpsw-phy-sel"; >> reg =3D <0x4a002554 0x4>; >> reg-names =3D "gmii-sel"; >> }; >> }; >> >> spi@480ba000 { >> compatible =3D "ti,omap4-mcspi"; >> reg =3D <0x480ba000 0x200>; >> interrupts =3D <0x0 0x2b 0x4>; >> #address-cells =3D <0x1>; >> #size-cells =3D <0x0>; >> ti,hwmods =3D "mcspi4"; >> ti,spi-num-cs =3D <0x1>; >> dmas =3D <0xb2 0x46 0xb2 0x47>; >> dma-names =3D "tx0", "rx0"; >> status =3D "okay"; >> ti,pindir-d0-out-d1-in; >> >> ksz9477@0 { >> compatible =3D "microchip,ksz9477"; >> reg =3D <0x0>; >> spi-max-frequency =3D <0x2dc6c00>; >> spi-cpha; >> spi-cpol; >> >> ports { >> #address-cells =3D <0x1>; >> #size-cells =3D <0x0>; >> >> port@0 { >> reg =3D <0x0>; >> label =3D "lan0"; >> }; >> >> port@1 { >> reg =3D <0x1>; >> label =3D "lan1"; >> }; >> >> port@2 { >> reg =3D <0x2>; >> label =3D "lan2"; >> }; >> >> port@3 { >> reg =3D <0x3>; >> label =3D "lan3"; >> }; >> >> port@4 { >> reg =3D <0x4>; >> label =3D "lan4"; >> }; >> >> port@5 { >> reg =3D <0x5>; >> label =3D "cpu"; >> ethernet =3D <0x500>; > > So here you are pointing to the container node, not the actual > interface. You talk of having to patch DSA. That i would say is > wrong. You should be using the phandle of the actual interface. > As mentioned due to above reason. agreed the patch is wrong. >> }; >> >> port@6 { >> reg =3D <0x6>; >> label =3D "lan6"; >> }; >> }; >> }; >> }; >> >> Where port 6 of ksz9897 chip is connected to slave 1 (eth1) of cpsw >> via rgmii interface. Following is the dmesg log: >> >> [ 2.596958] Microchip KSZ9477 dsa-0.0:00: attached PHY driver >> [Microchip KSZ9477] (mii_bus:phy_addr=3Ddsa-0.0:00, irq=3DPOLL) >> [ 2.714959] Microchip KSZ9477 dsa-0.0:01: attached PHY driver >> [Microchip KSZ9477] (mii_bus:phy_addr=3Ddsa-0.0:01, irq=3DPOLL) >> [ 2.832958] Microchip KSZ9477 dsa-0.0:02: attached PHY driver >> [Microchip KSZ9477] (mii_bus:phy_addr=3Ddsa-0.0:02, irq=3DPOLL) >> [ 2.950960] Microchip KSZ9477 dsa-0.0:03: attached PHY driver >> [Microchip KSZ9477] (mii_bus:phy_addr=3Ddsa-0.0:03, irq=3DPOLL) >> [ 3.068958] Microchip KSZ9477 dsa-0.0:04: attached PHY driver >> [Microchip KSZ9477] (mii_bus:phy_addr=3Ddsa-0.0:04, irq=3DPOLL) >> [ 3.080953] Generic PHY dsa-0.0:06: attached PHY driver [Generic >> PHY] (mii_bus:phy_addr=3Ddsa-0.0:06, irq=3DPOLL) > > You might also need a fixed-link for the cpu port of the switch. > > What do the statistics counters show? Is it trying to send/receiver > frames out eth1? Are bad frames received? Maybe you need to set rgmii > delays? > Yes I can see the statistics, I was sending dhcp requests from the devices connected on lan0 and lan4 ports. ~$ ifconfig eth0 Link encap:Ethernet HWaddr C4:F3:12:08:FE:7E UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:102 eth1 Link encap:Ethernet HWaddr C4:F3:12:08:FE:7F inet6 addr: fe80::c6f3:12ff:fe08:fe7f%lo/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:879 errors:0 dropped:0 overruns:0 frame:0 TX packets:171 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:389836 (380.6 KiB) TX bytes:23128 (22.5 KiB) lan0 Link encap:Ethernet HWaddr C4:F3:12:08:FE:7F UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:660 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:336530 (328.6 KiB) TX bytes:0 (0.0 B) lan3 Link encap:Ethernet HWaddr C4:F3:12:08:FE:7F UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lan4 Link encap:Ethernet HWaddr C4:F3:12:08:FE:7F inet6 addr: fe80::c6f3:12ff:fe08:fe7f%lo/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:219 errors:0 dropped:0 overruns:0 frame:0 TX packets:85 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:36605 (35.7 KiB) TX bytes:11732 (11.4 KiB) ~$ I am bit confused on how dsa needs to be actually working, Q's 1] should I be running a dhcp server on eth1 (where switch is connected) so that devices connected on lan* devices get an ip ? 2] From the device where switch is connected if the cpu port wants to send any data to any other user ports lan* how do i do it (just open socket on eth1 or lan*) ? I wrote a simple C code to dump some data onto port with lan0 but couldn=E2=80=99t see anything on the device where lan0 is connected (using tcpdump). I also tried sending data from lan0 to lan4 but I couldnt see anything on tcpdump but I can ping lan0 and lan4. (I have set lan0 and lan4 as local link onl= y) 3] What is the ideal setup for dsa to work Cheers, --Prabhakar