Skip to content

ipq40xx: introduce proper ethernet and DSA support - #4721

Closed
robimarko wants to merge 19 commits into
openwrt:masterfrom
sartura:ipq40xx-dsa
Closed

robimarko wants to merge 19 commits into
openwrt:masterfrom
sartura:ipq40xx-dsa

Conversation

@robimarko

@robimarko robimarko commented Oct 25, 2021 •

Copy link
Copy Markdown
Contributor

This PR is a WIP draft for adding a working ethernet + DSA driver along with some PHY SFP improvements.

Ethernet driver is an updated and fixed version of the IPQESS driver that has been in various trees.

DSA driver is based on an older qca8k driver to which IPQ40xx specific stuff was added based on even older modified qca8k that was lingering in the same trees as the IPQESS.
DSA driver itself lacks some features that newer qca8k has like VLAN offloading but that is something that I plan on adding.
The code also isn't upstream ready due to various hacks that are specific to the IPQ40xx in regards to PSGMII.

Driver combo works surprisingly well, however it has one bug that doesn't always present itself.
The issue is that PSGMII PHY-s won't calibrate on some boots, this happens really randomly.

I have only added conversion of Jalapeno board as an example, however, I will add a few more.
Note that I don't know if RGMII works properly as I don't have any board using it.

This patch series is based on the following tree:
https://github.com/sartura/linux/tree/ipq40xx/linux-v5.10.8-DSA
It can be referenced to see the actual development in individual commits as I slightly cleaned up some things when preparing for OpenWrt submission and those are not yet reflected in our public kernel tree.
I will rebase on 5.14.14 which we are using internally and publish with OpenWrt changes.
You can see that there were actually 3 working taggers added but I only included the shinfo one which has the lowest overhead.

I find the driver combo usable, but the code requires some work regarding features and a decent cleanup.
We are publishing it in hopes that by working with the community we can eventually get support for wired networking
upstream and that will complete IPQ40xx support upstream as the only major subsystem missing.

So since the driver combo has been really fixed up I think that we need to convert all of the boards to get this merged.
So, to track that let's add a checklist:

  • 8devices Habanero
  • 8devices Jalapeno
  • Alfa AP120C-AC
  • Aruba AP-303
  • Aruba AP-303H
  • Aruba AP-365
  • Asus Lyra (MAP-AC2200)
  • Asus RT-AC42U
  • Asus RT-AC58U
  • AVM FRITZ!Box 4040
  • AVM FRITZ!Box 7530
  • AVM FRITZ!Repeater 1200
  • AVM FRITZ!Repeater 3000
  • Buffalo WTR-M2133HP
  • Cell C RTL30VW
  • Crisis Innovation Lab MeshPoint.One
  • Compex WPJ419
  • Compex WPJ428
  • devolo Magic 2 WiFi next
  • D-Link DAP-2610
  • Edgecore ECW5211
  • Edgecore OAP100
  • EnGenius EAP1300
  • EnGenius EAP2200
  • EnGenius EMD1
  • EnGenius EMR3500
  • EnGenius ENS620EXT
  • EZVIZ CS-W3-WD1200G
  • GL.iNet GL-AP1300
  • GL.iNet GL-B1300
  • GL.iNet GL-B2200
  • GL.iNet GL-S1300
  • Linksys EA6350
  • Linksys EA8300
  • Linksys MR8300
  • Luma Home WRTQ-329ACN
  • Cisco Meraki MR33
  • MobiPromo CM520-79F
  • NETGEAR EX6100 v2
  • NETGEAR EX6150 v2
  • NETGEAR RBR50
  • NETGEAR RBS50
  • NETGEAR SRS60
  • NETGEAR WAC510
  • OpenMesh A42
  • OpenMesh A62
  • P&W R619AC
  • Plasma Cloud PA1200
  • Plasma Cloud PA2200
  • Qualcomm Atheros AP-DK01.1 C1
  • Qualcomm Atheros AP-DK04.1 C1
  • Qxwlan E2600AC C1
  • Qxwlan E2600AC C2
  • Teltonika RUTX10
  • Unielec U4019
  • ZyXEL NBG6617
  • ZyXEL WRE6606
  • MikroTik hAP ac2
  • MikroTik hAP ac3
  • MikroTik Wireless Wire Dish LHGG-60ad
  • MikroTik SXTsq 5 ac
  • MikroTik cAP ac
  • ZTE MF286D
  • Telco X1 Pro

@robimarko

Copy link
Copy Markdown
Contributor Author

@PolynomialDivision I know that you are interested, feel free to add anybody else interested in this as well

@PolynomialDivision

PolynomialDivision commented Oct 25, 2021 •

Copy link
Copy Markdown
Member

Awesome!!! Thanks a lot! @spolack @pmelange @blocktrron @kls0e @akira25 @robertfoss

@adschm adschm added target/ipq40xx pull request/issue for ipq40xx target work in progress pull request the author is still working on labels Oct 25, 2021
@ptpt52

ptpt52 commented Oct 25, 2021

Copy link
Copy Markdown
Contributor

mark

@aparcar

aparcar commented Oct 25, 2021

Copy link
Copy Markdown
Member

This is blocked by #4620

@aparcar aparcar added the blocked pull request blocked by/waiting for another change label Oct 25, 2021
@aparcar
aparcar requested review from blocktrron and pepe2k October 25, 2021 23:23
@robimarko

Copy link
Copy Markdown
Contributor Author

This is blocked by #4620

That is fine, I just wanted to show that 5.4 won't be supported as it would require more work and its gonna get dropped anyway soon.

@mrkiko

mrkiko commented Oct 26, 2021

Copy link
Copy Markdown
Contributor

Thanks for your work!

@robimarko

Copy link
Copy Markdown
Contributor Author

I pushed some small updates to the driver.
I will start working on VLAN filtering next, any help is appreciated as I still haven't figured out why PSGMII calibration fails sometimes and then after a reboot it just works.

/ {

aliases {
ethernet1 = &swport4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this used for? cant find any reference. what would i configure on devices with 4 LAN Ports and 1 WAN Port?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the bootloader to update the MAC address, it really depends on how many MAC addresses does your device has.


pinctrl-0 = <&mdio_pins>;
pinctrl-names = "default";
reset-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required to get applied to all devices? Then i'd propose to move that to the dtsi?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a hard requirement, but a good practice.
Its device-specific, so you cant have it in a DTSI.

@spolack spolack Oct 27, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for then? How do i find out whether it would be good practice on a certain device?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For resetting the PHY, if you know the pin on your device then it should be defined for the kernel to reconfigure the PHY from zero and now have whatever U-boot has put there as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

status = "okay";
};

&swport3 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the number the same which it used to be in swconfig for that specific port?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should match the port number in swconfig 1:1

@mrkiko

mrkiko commented Oct 27, 2021 via email

Copy link
Copy Markdown
Contributor

@robimarko

Copy link
Copy Markdown
Contributor Author

From stock FW GPL, DTS or U-boot if its defined anywhere, sometimes you really cant figure it out easily.

@robimarko

robimarko commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor Author

@Ansuel Since you messed with qca8k the most, have you had a VTU related timeout before?
I am porting the VLAN code and it always timeouts on writing to QCA8K_REG_ATU_FUNC

Since its MMIO HW, it really should take no time for this to work as it is way faster than MDIO

Sorry, I put the old busy function instead of regmap poll, and that one works so it's something to do with regmap.

@Ansuel

Ansuel commented Oct 27, 2021

Copy link
Copy Markdown
Member

@robimarko so now it related to something else?

@robimarko

robimarko commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor Author

It looks like its something to do with regmap_read_poll_timeout() as when I add the old busy-wait function from 5.10 it doesn't fail:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/net/dsa/qca8k.c?h=v5.10.76#n263

This is the current one:

return regmap_read_poll_timeout(priv->regmap, reg, val, val & mask,

To me 0 sleep time doesn't look right at all.

@Ansuel

Ansuel commented Oct 27, 2021 •

Copy link
Copy Markdown
Member

@robimarko make sure you have regmap registered with no cache option... i had some problem like that with ipq806x mdio driver that cached the value or try with some additional sleep ? (just to test if something is wrong)
wonder if that's the problem

the 0 sleep was used as in the qca8k code we use qca8k_read that didn't use regmap stuff.
probably a sleep value for regmap is required as it does use direct access instead of mdio (and mdio adds his sleep time)

@robimarko

robimarko commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor Author

Cached regmap actually shouldn't be an issue here, I will test and if it causes issues disable it.
Sleep time is for sure required as I actually think that it may be getting an error from regmap_read as you cant really call reads without any delay.

BTW, Is it me, or the condition to break out of the poll is incorrect?
Per the datasheet, you set it to 1 and then poll for it to become zero and the condition here is checking for val & mask which means it's checking for 1 instead.
Shouldn't it be !(val & mask) instead?

Anyway, with the changed condition, sleep 20 and timeout 20000 it now works.

@Ansuel

Ansuel commented Oct 27, 2021 •

Copy link
Copy Markdown
Member

It's in 5.15

ret = read_poll_timeout(qca8k_read, ret1, !(val & mask),
				0, QCA8K_BUSY_WAIT_TIMEOUT * USEC_PER_MSEC, false,
				priv, reg, &val);

@robimarko

Copy link
Copy Markdown
Contributor Author

Ok, so the condition was incorrect and that was the likely cause of the issue

@Ansuel

Ansuel commented Oct 27, 2021

Copy link
Copy Markdown
Member

Are you sure sleep is needed? it should be very fast in theory

@robimarko

Copy link
Copy Markdown
Contributor Author

I mean, It shouldn't really be necessary as it MMIO.
Will test it.

@robimarko

Copy link
Copy Markdown
Contributor Author

@Ansuel It looks like 0 for sleep aka tight-loop is fine, it works with that.
Thanks

@robimarko

robimarko commented Oct 27, 2021 •

Copy link
Copy Markdown
Contributor Author

Anyway, added VLAN filtering based on qca8k so if somebody can actually test whether it works as I don't really have a setup or time now to do it properly.
The pure DSA only lacks MDB offloading now, the trick is to somehow cleanup the whole QM and calibration code.
I actually have no idea what is the QM code supposed to even do

@LGA1150 I know that you were interested in VLAN filtering

@Ansuel

Ansuel commented Oct 27, 2021

Copy link
Copy Markdown
Member

@robimarko qm afaik is what handle all the buffer and detects any error

@robimarko

Copy link
Copy Markdown
Contributor Author

Well, the code is quite nasty:

ar40xx_sw_mac_polling_task(struct qca8k_priv *priv)

I still haven't figured out what is it really meant to do, I see that it's poking directly into the PHY.

@ColinTimBarndt

Copy link
Copy Markdown

When is this patch going to land in a release?
What should I do if I need to use this patch now?
I built OpenWRT with this patch a while ago, but now with updated packages, LuCI appears to be broken (bad gateway), making the OS pretty much unusable for me.

@Ansuel

Ansuel commented Oct 27, 2022

Copy link
Copy Markdown
Member

@ColinTimBarndt

  1. patch has been merged in master
  2. luci doesn't affect normal router functionality is just to view things
  3. you have to do nothing and if you can sustain regression in master you should probably use stable builds

@ColinTimBarndt

Copy link
Copy Markdown
  1. patch has been merged in master

I tried this just now and it bricked my router, no (W)LAN was working.

2. luci doesn't affect normal router functionality is just to view things

Yes, but I really don't want to configure my router via SSH on my phone.

Should I try applying the patch to the current stable release?

@professor-jonny

Copy link
Copy Markdown
Contributor

When is this patch going to land in a release?

It is in openwrt master you should be able to build from master if your device has been ported.

@professor-jonny

Copy link
Copy Markdown
Contributor
  1. patch has been merged in master

I tried this just now and it bricked my router, no (W)LAN was working.

  1. luci doesn't affect normal router functionality is just to view things

Yes, but I really don't want to configure my router via SSH on my phone.

Should I try applying the patch to the current stable release?

I'm guessing you updated your network settings to the new dsa layout?

@ColinTimBarndt

Copy link
Copy Markdown

I'm guessing you updated your network settings to the new dsa layout?

I updated without retaining my config to be on the safe side

@ColinTimBarndt

Copy link
Copy Markdown

Okay, the bricked router seems to have been a one-off thing. I did exactly the same (started off with a clean installation of the latest stable OpenWRT build and then upgraded to my master build) and it worked without any issues and I could even restore my latest backup.

@Nyshan

Nyshan commented Nov 24, 2022

Copy link
Copy Markdown

I'm not sure if I'm poking the right bear by adding a comment to this thread or not so please correct me if I'm not following the correct github etiquette:

I'm trying to get a working image for https://openwrt.org/toh/linksys/whw01_v1 as it appears the device was removed from builds due to a DSA support issue:
image

What can I do to fix this problem/test solutions in order to get a working image for the device?

@professor-jonny

Copy link
Copy Markdown
Contributor

I'm not sure if I'm poking the right bear by adding a comment to this thread or not so please correct me if I'm not following the correct github etiquette:

What can I do to fix this problem/test solutions in order to get a working image for the device?

Are you capable of building OpenWrt from Source? as you could reinstate your target and edit the DTS file to create a DSA image.
There is samples of how it has been done on other devices.

@Nyshan

Nyshan commented Nov 25, 2022

Copy link
Copy Markdown

@professor-jonny I reinstated the device, built an image and flashed it. From here I'm not quite sure what to do as I've had a lot of trouble finding an example of an edited DTS file; could you link me to an example of what you're talking about?

@yogo1212

Copy link
Copy Markdown
Contributor

@Nyshan one example

you can find other commits using the history:
https://github.com/openwrt/openwrt/commits/master/target/linux/ipq40xx

or by using git log, tig, gitk or so on target/linux/ipq40xx.
for example: gitk -- target/linux/ipq40xx/

@soloam

soloam commented Nov 28, 2022

Copy link
Copy Markdown

Hello, is this merged and currently on version 22.03? I have a Liksys MR8300 and i can't setup DSA, I still see the switch menu, and I don't have lan1, lan2... etc... I still have eth0 and eth1.

Thank You

@Leo-PL

Leo-PL commented Nov 28, 2022

Copy link
Copy Markdown
Contributor

@soloam No - it is only on snapshots, and it is very unlikely that this will be backported.

@soloam

soloam commented Nov 28, 2022

Copy link
Copy Markdown

@soloam No - it is only on snapshots, and it is very unlikely that this will be backported.

So no hopes on getting DSA on my routers? What is the best approatch? use 22.03 and configure with swconfig? Or rollback to 19.07?

Thank You

@Nyshan

Nyshan commented Nov 28, 2022

Copy link
Copy Markdown

Hello, is this merged and currently on version 22.03? I have a Liksys MR8300 and i can't setup DSA, I still see the switch menu, and I don't have lan1, lan2... etc... I still have eth0 and eth1.

Thank You

Why can't you setup DSA?

@soloam

soloam commented Nov 28, 2022

Copy link
Copy Markdown

Hello, is this merged and currently on version 22.03? I have a Liksys MR8300 and i can't setup DSA, I still see the switch menu, and I don't have lan1, lan2... etc... I still have eth0 and eth1.
Thank You

Why can't you setup DSA?

I can't get it to work, i tried several ways and never works, since I still can see the switch menu and my interfaces are named the old way, I assumed that is still not suported!

@JJWatMyself

Copy link
Copy Markdown

Thoughts and status on this for the Aruba 303h? I'm having an awful time without the DSA support and VLANs with 22.03

@PolynomialDivision

Copy link
Copy Markdown
Member

Thoughts and status on this for the Aruba 303h? I'm having an awful time without the DSA support and VLANs with 22.03

It should look like this (not compile or runtested):
#11579

Maybe you can test it. Make sure to enable wifi by default so you can easily backup your device in case the ethernet is not working anymore. If you prefer, I can also compile you an image to test the device.

@JJWatMyself

Copy link
Copy Markdown

Thoughts and status on this for the Aruba 303h? I'm having an awful time without the DSA support and VLANs with 22.03

It should look like this (not compile or runtested): #11579

Maybe you can test it. Make sure to enable wifi by default so you can easily backup your device in case the ethernet is not working anymore. If you prefer, I can also compile you an image to test the device.

I'll gladly look at this as the 303H on OpenWRT is pretty horrible when it comes to bridging between eth0 (enet0 PoE+ uplink) and eth1 (enet1, enet2, enet3 downlinks) and anything related to 802.1q.

So I would just load this updated file from the link? The config is 100% lab test and I have the serial console access to the AP also.

target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-ap-303h.dts

@PolynomialDivision

Copy link
Copy Markdown
Member

So I would just load this updated file from the link?

You can just apply on top of the normal openwrt git following cmd

curl https://patch-diff.githubusercontent.com/raw/openwrt/openwrt/pull/11579.patch | git am 

@JJWatMyself

JJWatMyself commented Dec 23, 2022 •

Copy link
Copy Markdown

Just a quick update that the work to test DSA on Aruba AP-303H over here #11579 has been incredibly positive. I would say that link I was provided for SNAPSHOT r21373+191-aa12a0fdd1 / LuCI Master git-22.351.50506-a27d2db I have tested is pretty much good to go. My testing has been dumb AP and many VLANs. I've found some niggles / other issues, but nothing I will attribute to DSA. Maybe something worth taking away on OpenWRT overall is that I think there needs to be more auto assignment of unique MAC addresses, as that was the major stumble I encountered. Looking for to doing lots more on this and may even just run with the version I have, until/unless there is something needed. Very interested to see this pull get accepted, so will be in the snapshot for all going forward.

@giannoug

Copy link
Copy Markdown

Very interested to see this pull get accepted, so will be in the snapshot for all going forward.

It's merged! No idea why it shows as Closed though

@Leo-PL

Leo-PL commented Dec 23, 2022

Copy link
Copy Markdown
Contributor

@giannoug because it went through the staging tree, not through Github, which is only a mirror for git.openwrt.org.

@PolynomialDivision

Copy link
Copy Markdown
Member

There is now a way to merge GitHub PRs via the openwrt-bot.

@Flole998

Flole998 commented Feb 17, 2023 •

Copy link
Copy Markdown
Contributor

I'm testing DSA on the RBR50 at the moment and there's an issue I described at https://forum.openwrt.org/t/ipq40xx-switch-config-strangeness/32542/108?u=flole

Long story short: All incoming packets for a certain MAC address sometimes magically disappear. That seems to be mostly the case when establishing a connection, so I can see how the DHCP request leaves on the interface labeled wan (so one of the ethernet ports that's going through the integrated switch), but the answer never shows up (even though it is definitely on the ethernet cable). So it's most likely getting lost/filtered at the switch. After a certain time it works perfectly fine. That's for each device though, so the next device might hit the same issue.

@ryancdotorg

Copy link
Copy Markdown
Contributor

I have an EAP1300 set up with a serial console, how can I get support added for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked pull request blocked by/waiting for another change target/ipq40xx pull request/issue for ipq40xx target work in progress pull request the author is still working on

Projects

None yet

Development

Successfully merging this pull request may close these issues.