Skip to content

ath79: add support for COMFAST CF-E313AC#1942

Closed
rogerpueyo wants to merge 1 commit intoopenwrt:masterfrom
rogerpueyo:ath79-cf-e313ac
Closed

ath79: add support for COMFAST CF-E313AC#1942
rogerpueyo wants to merge 1 commit intoopenwrt:masterfrom
rogerpueyo:ath79-cf-e313ac

Conversation

@rogerpueyo
Copy link
Copy Markdown
Contributor

This patch adds support for the COMFAST CF-E313AC, an outdoor wireless
CPE with two Ethernet ports and a 802.11ac radio (see patch below).

Everything is working fine but there are two issues for which I'd like to get some advise:

  1. target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata

    I had to add "rm /lib/firmware/ath10k/QCA9888/hw2.0/board-2.bin", since
    the driver tries to load board-2.bin (the default calibration data from the firmware package) first and, only when that file is not found, falls back to board.bin (the calibration data read from the flash).

    I haven't seen this on any other device, so I guess there must be a more elegant way to deal with it. Any idea?

  2. target/linux/ath79/dts/qca9531_comfast_cf-e313ac.dts

    The device is equipped with a "w25q128" flash chip (16384 Kbytes) but the stock firmware image only used half of it (nvram partition finishes at 0x000000800000, i.e., 8192 Kbytes):

    *** stock firmware bootlog ***
    [...]
    [ 0.730000] 0x000000000000-0x000000010000 : "u-boot"
    [ 0.740000] 0x000000010000-0x000000020000 : "art"
    [ 0.740000] 0x000000020000-0x0000001a0000 : "kernel"
    [ 0.750000] 0x0000001a0000-0x0000007e0000 : "rootfs"
    [ 0.760000] mtd: device 3 (rootfs) set to be root filesystem
    [ 0.760000] 1 squashfs-split partitions found on MTD device rootfs
    [ 0.770000] 0x0000006c0000-0x0000007e0000 : "rootfs_data"
    [ 0.780000] 0x0000007e0000-0x0000007f0000 : "configs"
    [ 0.780000] 0x0000007f0000-0x000000800000 : "nvram"
    [ 0.790000] 0x000000020000-0x0000007e0000 : "firmware"
    [...]

    Is there a way to use the remaining half of the flash?

Any comments regarding these or other issues will be highly appreciated.

@ynezz ynezz added RFC pull request ready for comments target/ath79 pull request/issue for ath79 target needs changes labels Mar 24, 2019
@rogerpueyo
Copy link
Copy Markdown
Contributor Author

Sorry for bugging you, @ynezz .

I made the required changes so that the commit does not have conflicts with master. Would you please be so kind as to remove the "needs changes" tag, to see if the PR gets more attention?

Thanks!

@ynezz
Copy link
Copy Markdown
Member

ynezz commented Apr 5, 2019

remove the "needs changes" tag, to see if the PR gets more attention?

From my point of view this PR still needs changes and it doesn't mean, that PRs without needs changes have more attention. Simply there is a lack of manpower to handle everything in timely fashion. This PR is open just for 14 days, there are other PRs (and patches qeued in patchwork) open for > 6 months, so you either need to be patient or find the solution to your 2 issues by yourself.

the driver tries to load board-2.bin (the default calibration data from the firmware package) first and

I would say, that this is correct behavior. Add ath10k_core debug_mask=0x20 (BOOT) to your /etc/modules.d/ath10k-ct, reboot and provide the output of dmesg | grep ath10k.

The device is equipped with a "w25q128" flash chip (16384 Kbytes) but the stock firmware image only used half of it (nvram partition finishes at 0x000000800000, i.e., 8192 Kbytes):

Although being marketed as 16M, it's using just the first half of the memory, maybe it's for some reason? It could be defective memory or some other issues, who knows.

@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 2 times, most recently from 450d689 to d0532b0 Compare April 24, 2019 17:54
@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 2 times, most recently from a5b007c to 333f40a Compare May 22, 2019 10:06
@rogerpueyo rogerpueyo changed the title [RFC] ath79: add support for COMFAST CF-E313AC ath79: add support for COMFAST CF-E313AC May 22, 2019
@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 4 times, most recently from 9f50e95 to 6f47862 Compare June 26, 2019 11:19
@rogerpueyo
Copy link
Copy Markdown
Contributor Author

Dear @adrianschmutzler,

Thank you very much for reviewing this pull request. I've made the changes you suggested, rebased master and also fixed the eth0/eth1 wan/lan assignation (a recent patch in ath79 had swapped them).

@adschm
Copy link
Copy Markdown
Member

adschm commented Jun 26, 2019

You're welcome. Note that I did only a selective review, so there are parts I have not checked.

@rogerpueyo
Copy link
Copy Markdown
Contributor Author

rogerpueyo commented Jun 26, 2019

Dear @ynezz , I am sorry but I did not have access to the device for a few weeks; now it's back on my desk.

I would say, that this is correct behavior. Add ath10k_core debug_mask=0x20 (BOOT) to your /etc/modules.d/ath10k-ct, reboot and provide the output of dmesg | grep ath10k.

Here are the dmesg outputs:

  • kmod-ath10k-ct, ath10k-firmware-qca9888-ct, ath10k_core debug_mask=0x20, removing board-2.bin:
root@OpenWrt:~# dmesg | grep ath10k
[   12.422600] ath10k 4.19 driver, optimized for CT firmware, probing pci device: 0x56.
[   12.449092] ath10k_pci 0000:00:00.0: enabling device (0000 -> 0002)
[   12.455886] ath10k_pci 0000:00:00.0: pci irq legacy oper_irq_mode 1 irq_mode 0 reset_mode 0
[   12.902297] firmware ath10k!fwcfg-pci-0000:00:00.0.txt: firmware_loading_store: map pages failed
[   13.145060] firmware ath10k!QCA9888!hw2.0!ct-firmware-5.bin: firmware_loading_store: map pages failed
[   13.381074] firmware ath10k!QCA9888!hw2.0!ct-firmware-2.bin: firmware_loading_store: map pages failed
[   13.618926] firmware ath10k!QCA9888!hw2.0!firmware-6.bin: firmware_loading_store: map pages failed
[   14.578131] ath10k_pci 0000:00:00.0: qca9888 hw2.0 target 0x01000000 chip_id 0x00000000 sub 0000:0000
[   14.587678] ath10k_pci 0000:00:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 0
[   14.611491] ath10k_pci 0000:00:00.0: firmware ver 10.4b-ct-9888-fW-012-e8020273 api 5 features mfp,peer-flow-ctrl,txstatus-noack,wmi-10.x-CT,ratemask-CT,regdump-CT,txrate-CT,flush-all-CT,pingpong-CT,ch-regs-CT,nop-CT,set-special-CT,tx-rc-CT,cust-stats-CT,txrate2-CT,beacon-cb-CT,wmi-block-ack-CT,wmi-bcn-rc-CT crc32 d41e2174
[   15.060622] firmware ath10k!QCA9888!hw2.0!board-2.bin: firmware_loading_store: map pages failed
[   15.071062] ath10k_pci 0000:00:00.0: board_file api 1 bmi_id 0:24 crc32 fe8667a8
[   17.173126] ath10k_pci 0000:00:00.0: 10.4 wmi init: vdevs: 16  peers: 48  tid: 96
[   17.180934] ath10k_pci 0000:00:00.0: msdu-desc: 2500  skid: 32
[   17.232269] ath10k_pci 0000:00:00.0: wmi print 'P 48/48 V 16 K 144 PH 176 T 186  msdu-desc: 2500  sw-crypt: 0 ct-sta: 0'
[   17.243636] ath10k_pci 0000:00:00.0: wmi print 'free: 117936 iram: 22724 sram: 29708'
[   17.461026] ath10k_pci 0000:00:00.0: htt-ver 2.2 wmi-op 6 htt-op 4 cal pre-cal-file max-sta 32 raw 0 hwcrypto 1
root@OpenWrt:~# iwinfo 
wlan0     ESSID: unknown
          Access Point: 40:A5:EF:2E:45:41
          Mode: Client  Channel: unknown (unknown)
          Tx-Power: 0 dBm  Link Quality: unknown/70
          Signal: unknown  Noise: unknown
          Bit Rate: unknown
          Encryption: unknown
          Type: nl80211  HW Mode(s): 802.11nac
          Hardware: 168C:0056 0000:0000 [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: yes  PHY name: phy0
  • kmod-ath10k-ct, ath10k-firmware-qca9888-ct, ath10k_core debug_mask=0x20, keeping board2.bin:
[   12.442586] ath10k 4.19 driver, optimized for CT firmware, probing pci device: 0x56.
[   12.470976] ath10k_pci 0000:00:00.0: enabling device (0000 -> 0002)
[   12.477782] ath10k_pci 0000:00:00.0: pci irq legacy oper_irq_mode 1 irq_mode 0 reset_mode 0
[   12.922725] firmware ath10k!fwcfg-pci-0000:00:00.0.txt: firmware_loading_store: map pages failed
[   13.164935] firmware ath10k!QCA9888!hw2.0!ct-firmware-5.bin: firmware_loading_store: map pages failed
[   13.399239] firmware ath10k!QCA9888!hw2.0!ct-firmware-2.bin: firmware_loading_store: map pages failed
[   13.637575] firmware ath10k!QCA9888!hw2.0!firmware-6.bin: firmware_loading_store: map pages failed
[   14.592990] ath10k_pci 0000:00:00.0: qca9888 hw2.0 target 0x01000000 chip_id 0x00000000 sub 0000:0000
[   14.602589] ath10k_pci 0000:00:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 0
[   14.626397] ath10k_pci 0000:00:00.0: firmware ver 10.4b-ct-9888-fW-012-e8020273 api 5 features mfp,peer-flow-ctrl,txstatus-noack,wmi-10.x-CT,ratemask-CT,regdump-CT,txrate-CT,flush-all-CT,pingpong-CT,ch-regs-CT,nop-CT,set-special-CT,tx-rc-CT,cust-stats-CT,txrate2-CT,beacon-cb-CT,wmi-block-ack-CT,wmi-bcn-rc-CT crc32 d41e2174
[   14.966302] ath10k_pci 0000:00:00.0: board_file api 2 bmi_id 0:24 crc32 d65c17b1
[   17.015408] ath10k_pci 0000:00:00.0: 10.4 wmi init: vdevs: 16  peers: 48  tid: 96
[   17.023224] ath10k_pci 0000:00:00.0: msdu-desc: 2500  skid: 32
[   17.074783] ath10k_pci 0000:00:00.0: wmi print 'P 48/48 V 16 K 144 PH 176 T 186  msdu-desc: 2500  sw-crypt: 0 ct-sta: 0'
[   17.086122] ath10k_pci 0000:00:00.0: wmi print 'free: 117936 iram: 22724 sram: 29708'
[   17.300012] ath10k_pci 0000:00:00.0: htt-ver 2.2 wmi-op 6 htt-op 4 cal pre-cal-file max-sta 32 raw 0 hwcrypto 1
root@OpenWrt:~# iwinfo 
wlan0     ESSID: unknown
          Access Point: 12:34:56:78:90:12
          Mode: Client  Channel: unknown (unknown)
          Tx-Power: 0 dBm  Link Quality: unknown/70
          Signal: unknown  Noise: unknown
          Bit Rate: unknown
          Encryption: unknown
          Type: nl80211  HW Mode(s): 802.11nac
          Hardware: 168C:0056 0000:0000 [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: yes  PHY name: phy0


In both cases I am be able to use the interface in equal terms, but the MAC address in the latter one is autogenerated, instead of using the appropriate one.

@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 3 times, most recently from 8c03d7e to f7e00fe Compare June 26, 2019 18:54
@adschm
Copy link
Copy Markdown
Member

adschm commented Jul 5, 2019

I'm currently working on a PR to store the label-mac-address in the DTS (#2159).

I would appreciate if you could provide information about your device:
Please run
find /proc/device-tree/ -name "*mac-address*"
on your device (just with the current firmware, no need to update anything; just has to be ath79, no ar71xx).
For each of the returned paths (if there are any), retrieve the mac-address with cat, e.g.
cat /proc/device-tree/ahb/eth@19000000/mac-address

Now check which of those returned MAC addresses matches the one on the label/sticker/case of your device and tell me the device-tree path leading to it. Note that you do not have to post your MAC addresses here, but just a statement about which match, e.g. like

/proc/device-tree/ahb/eth@1a000000/mac-address
/proc/device-tree/ahb/eth@1a000000/mtd-mac-address-increment
/proc/device-tree/ahb/eth@1a000000/mtd-mac-address
/proc/device-tree/ahb/eth@19000000/mac-address <== this one
/proc/device-tree/ahb/eth@19000000/mtd-mac-address
/proc/device-tree/ahb/apb/wmac@18100000/mac-address
/proc/device-tree/ahb/apb/wmac@18100000/mtd-mac-address

There may be one, two or no paths giving the correct address. It may also happen that the find command returns nothing. Thanks.

@adschm
Copy link
Copy Markdown
Member

adschm commented Jul 5, 2019

Unfortunately, my description is slightly incorrect. The MAC addresses are stored binary, so you can't read with cat, but have to use the following code to read from the paths retrieved by find:

. /lib/functions/system.sh
get_mac_binary "$yourpath" 0

The include is obviously only required once. Sorry.

@adschm
Copy link
Copy Markdown
Member

adschm commented Aug 9, 2019

And you need another rebase, unfortunately ...

@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 2 times, most recently from 9730fd7 to 2d3bf1c Compare September 3, 2019 15:59
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The decimal values in the two lines above should be updated to hex values (this has been changed treewide recently, just have a look at the other devices in the file now).

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.

True. I hadn't seen this changes, it makes sense. Fixed and rebased master.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also change the second line: 4098 -> 0x1002

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.

Sorry, I should have checked more carefully myself.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

BTW: Have you checked that there actually is a (correct) MAC address in this location? I'm just asking because this location normally is used by &wmac, which you do not have here. So it looks odd that the vendor would put the address there.
Just want to make sure ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, it's even more complicated:
ucidef_set_interfaces_lan_wan "eth0" "eth1" is referring to ethX on the running device, so what I wrote refers to the running device, too:
eth0 0x0 (=lan)
eth1 0x1002 (=wan)
wlan 0x6

In DTS, eth0/eth1 are swapped, so we have
&eth0 0x1002 (=wan)
&eth1 0x0 (=lan)

So, based on your current commit state, you need to change &eth0 to 0x1002 and the WiFi setup to 0x6 ...

(This still assumes that your ports are correctly assigned to WAN and LAN...)

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.

Thank you very much for your detailed analysis.

Thank you for reviewing the PR! 🤗

No matter what I'd like to say about people like the developers at this vendor, I would do the following:

1. The ports (!) should keep the same state (i.e. wan/lan) as in stock firmware.

👍 That's for granted, specially since they're labeled as LAN and WAN.

2. We cannot easily change what's eth0 and eth1 on the running device, so the assignment to wan and lan is determined by 1.

Well, kind of. I can use either the current configuration in the DTS file:

&eth0 {
	status = "okay";
	phy-handle = <&swphy0>;
	mtd-mac-address = <&art 0xXXX>;

	gmac-config {
		device = <&gmac>;
		switch-phy-swap = <1>;
	};
};

&eth1 {
	status = "okay";
	mtd-mac-address = <&art 0xYYY>;
};

or this one which also works and does not swap eth0 and eth1:

&eth0 {
	status = "okay";
	phy-handle = <&swphy4>;
	mtd-mac-address = <&art 0xZZZ>;
};

&eth1 {
	status = "okay";
	mtd-mac-address = <&art 0x0>;
	mtd-mac-address = <&art 0xTTT>;
};

(then, of course, setting XXX/YYY/ZZZ/TTT to the correct values, and also 01_leds and 02_network).

Both work; which one is preferred? I'd rather stick with the first one because I like the "default" eth0=>LAN eth1=>WAN, but I have no other reasoning than that.

3. I would slightly prefer to base MAC assignment on what the ports are doing. This means the address found on the stock WAN port should be the address set for the OpenWrt WAN port. The port modes will be what most of the user care about, while the internal assignment of eth0/eth1 is hidden to the typical user. However, note the word "slightly" here, we could also have thrown a coin to decide.

👍 Same MACs on the physical ports as the stock firmware, I agree, is a must. Beyond that... I flipped a coin already in 2. 😃

So, assuming that the current ucidef_set_interfaces_lan_wan "eth0" "eth1" sets the port modes > correctly, I think this would be:
eth0 0x0
eth1 0x1002
wlan 0x6

Hmm, it's even more complicated:
ucidef_set_interfaces_lan_wan "eth0" "eth1" is referring to ethX on the running device, so what I wrote refers to the running device, too:
eth0 0x0 (=lan)
eth1 0x1002 (=wan)
wlan 0x6

In DTS, eth0/eth1 are swapped, so we have
&eth0 0x1002 (=wan)
&eth1 0x0 (=lan)

So, based on your current commit state, you need to change &eth0 to 0x1002 and the WiFi setup to 0x6 ...

(This still assumes that your ports are correctly assigned to WAN and LAN...)

That's right. Anyway, whatever ends up regarding point 2, I'll make sure the stock Ethernet port - MAC assignment is maintained.

And BTW: Have you checked what happens if you do not set the MAC address in 11_ath10k_caldata?
Normally, if you read caldata from 0x5000, it might automatically read the the MAC address from 0x5006 (which is present). So, as for the ethernet, it might be the case the radio is initialized with a valid address which is then overwritten by another one ...
(You do not need to check that, unless you are curious...)

It gets the mac at 0x5006 (40:A5:EF:2E:45:43) which, :open_mouth: surprise!, it's not the one used by the stock firmware :smile:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you swap eth0 and eth1 with switch-phy-swap, are you sure that both ports work in both cases? From my experience, only one of the settings made it possible to have both ports working, while with the other one only one port worked. So, in the end there was only one possible case.

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.

If you swap eth0 and eth1 with switch-phy-swap, are you sure that both ports work in both cases? From my experience, only one of the settings made it possible to have both ports working, while with the other one only one port worked. So, in the end there was only one possible case.

Hmmm... I'll double check and report.

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.

If you swap eth0 and eth1 with switch-phy-swap, are you sure that both ports work in both cases? From my experience, only one of the settings made it possible to have both ports working, while with the other one only one port worked. So, in the end there was only one possible case.

If I'm not doing anything wrong, https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac and https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac-no-swap are equivalent. In the first one I get eth0 for LAN, eth1 for WAN. In the second one I get eth0 for WAN, eth1 for LAN.

In both cases I'm able to use LAN/WAN correctly, iperf3 bandwidth is the same (~95 Mbps) so, unless if I'm missing something, I can't tell any practical difference.

@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 3 times, most recently from 56f635d to e259d2d Compare September 5, 2019 19:10
@adschm
Copy link
Copy Markdown
Member

adschm commented Sep 6, 2019

@981213

If I'm not doing anything wrong, https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac and https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac-no-swap are equivalent. In the first one I get eth0 for LAN, eth1 for WAN. In the second one I get eth0 for WAN, eth1 for LAN.

In both cases I'm able to use LAN/WAN correctly, iperf3 bandwidth is the same (~95 Mbps) so, unless if I'm missing something, I can't tell any practical difference.

On this device, it looks like we can arbitrarily choose whether we have switch-phy-swap enabled or not (with corresponding phy-handle adjustments).
Can you comment on whether that means we can actually choose eth0/eth1 order without restrictions here, or is there a preference for some reason?

(I we can choose freely, I would prefer having the same order for eth0/eth1 on the running device as in DTS. Note that we still have to exploit 02_network to correct port modes here, as this is not relevant for the test.)

@adschm
Copy link
Copy Markdown
Member

adschm commented Sep 6, 2019

@rogerpueyo If it comes out that we can choose freely, I would prefer the noswap path, as this one would have eth0/eth1 at runtime match the DTS &eth0/&eth1...

@adschm
Copy link
Copy Markdown
Member

adschm commented Sep 6, 2019

@rogerpueyo One other thing: If we have sorted out which way to go, you should comment on the MAC address setup in the commit message, so our findings are preserved for anyone looking at this years later. I would put something like:
"Note that MAC address setup on this device is very special:
In STOCK firmware, lan/wan bridges force swapped MAC addresses compared to the underlying eth0/eth1:
lan with *:40 from 0x0 on top of eth1 with *:41 from 0x1002
wan with *:41 from 0x1002 on top of eth0 with *:40 from 0x0
wlan0 (5 GHz WiFi) with *:42 from 0x6
Unused *:43 in 0x5006 (note that 5 GHz Wifi reads caldata from 0x5000, so also WiFi address is overwritten by 0x6)

In OPENWRT, this has been implemented to have the same MAC addresses as in stock firmware based on the device ports:
lan (ethX when running, &ethX in DTS) from 0x0
wan (ethX when running, &ethX in DTS) from 0x1002
For radio0, the caldata address in 0x5006 will be set by ath10kcal_extract and then immediately overwritten to 0x6 by ath10kcal_patch_mac_crc."

@rogerpueyo
Copy link
Copy Markdown
Contributor Author

@rogerpueyo If it comes out that we can choose freely, I would prefer the noswap path, as this one would have eth0/eth1 at runtime match the DTS &eth0/&eth1...
@rogerpueyo One other thing: If we have sorted out which way to go, you should comment on the MAC address setup in the commit message, so our findings are preserved for anyone looking at this years later. I would put something like:

I think I prefer the swap one, eth0/eth1 with MACs *:A0/*:A1 as LAN/WAN, because it seems more common and straightforward to me than than eth1/eth0 with MACs *:A0/*:A1 as LAN/WAN but, to be true, I just want this PR to make it through so I'll be fine with whatever goes upstream 😄

I've pushed the two versions, with their corresponding commit notes, to the following branches:
https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac-swap
https://github.com/rogerpueyo/openwrt/tree/ath79-cf-e313ac-no-swap

@adrianschmutzler, if you merge this PR into your staging tree, please add yourself as a contributor to the commit 🙏

@adschm
Copy link
Copy Markdown
Member

adschm commented Sep 6, 2019

@rogerpueyo I'm not a core-developer, I do not have commit-access.
You will have to wait for someone else...
And I'm still curious whether @981213 can provide additional insights.

@981213
Copy link
Copy Markdown
Member

981213 commented Sep 7, 2019

@adrianschmutzler

On this device, it looks like we can arbitrarily choose whether we have switch-phy-swap enabled or not (with corresponding phy-handle adjustments).
Can you comment on whether that means we can actually choose eth0/eth1 order without restrictions here, or is there a preference for some reason?

It's preferred to use the first gmac which is directly connected to a PHY as wan port because we can't get port link status from the second one connecting to switch. We don't care about link status on lan ports but this is helpful when the port is used as wan (e.g. restart DHCP negotiation when we re-plug wan cable.)

@adschm
Copy link
Copy Markdown
Member

adschm commented Sep 9, 2019

It's preferred to use the first gmac which is directly connected to a PHY as wan port because we can't get port link status from the second one connecting to switch.

Hmm, but it looks like this will still allow both versions, if we set WAN/LAN correctly in 02_network?
So the currently "chosen" solution with phy-swap is valid.

So, this PR should be ready for review now...

@rogerpueyo rogerpueyo force-pushed the ath79-cf-e313ac branch 2 times, most recently from 15c7dd5 to 9b2f94a Compare September 9, 2019 15:08
@981213 981213 removed RFC pull request ready for comments needs changes labels Sep 9, 2019
@rogerpueyo
Copy link
Copy Markdown
Contributor Author

@981213,

It's preferred to use the first gmac which is directly connected to a PHY as wan port because we can't get port link status from the second one connecting to switch. We don't care about link status on lan ports but this is helpful when the port is used as wan (e.g. restart DHCP negotiation when we re-plug wan cable.)

Thanks for your comments, that makes complete sense. To achieve this behaviour, I've got to use:

&eth0 {
	status = "okay";
	phy-handle = <&swphy0>;

which allows detecting link changes on the WAN port:

root@OpenWrt:~# dmesg -c
[unplug WAN]
[  123.549485] eth1: link down
[re-plug WAN]
[  125.631009] eth1: link up (100Mbps/Full duplex)

Instead, using phy-handle = <&swphy4>; connects the gmac PHY to the other port (labeled as LAN) which is not of our interest.

@adrianschmutzler now comes the funny part.

Hmm, but it looks like this will still allow both versions, if we set WAN/LAN correctly in 02_network?
So the currently "chosen" solution with phy-swap is valid.

The switch-phy-swap = <1>; option in:

&eth0 {
	status = "okay";
	phy-handle = <&swphy0>;
	mtd-mac-address = <&art 0x1002>;

	gmac-config {
		device = <&gmac>;
		switch-phy-swap = <1>;
	};
};

is the one that really works. Setting it to <0> (i.e., not setting it) and using the appropriate ucidef_set_interfaces_lan_wan "eth1" "eth0" in 02_network makes the interfaces work, but, when the WAN port is unplugged, also the br-lan interface stops responding. I've double-checked this, since I found it strange, but it seems the board behaves like this.

So, this PR should be ready for review now...

I think so too. I've rebased master and pushed.

Thank you for your help! :)

@rogerpueyo
Copy link
Copy Markdown
Contributor Author

Rebased master.

@adschm
Copy link
Copy Markdown
Member

adschm commented Oct 6, 2019

@blocktrron @981213 @ynezz Maybe have a look at this one, it's lying around for a long time already and should be in a good state.

This patch adds support for the COMFAST CF-E313AC, an  outdoor wireless
CPE with two Ethernet ports and a 802.11ac radio.

Specifications:

 - QCA9531 SoC
 - 650/400/216 MHz (CPU/DDR/AHB)
 - 1x 10/100 Mbps WAN Ethernet, 48V PoE-in
 - 1x 10/100 Mbps LAN Ethernet, pass-through 48V PoE-out
 - 1x manual pass-through PoE switch
 - 64 MB RAM (DDR2)
 - 16 MB FLASH
 - QCA9886 2T2R 5 GHz 802.11ac, 23 dBm
 - 12 dBi built-in antenna
 - POWER/LAN/WAN/WLAN green LEDs
 - 4x RSSI LEDs (2x red, 2x green)
 - UART (115200 8N1)

Flashing instructions:

 The original firmware is based on OpenWrt so a sysupgrade image can be
 installed via the stock web GUI. Settings from the original firmware
 will be saved and restored on the new one, so a factory reset will be
 needed. To do so, once the new firmware is flashed, enter into failsafe
 mode by pressing the reset button several times during the boot
 process, while the WAN LED flashes, until it starts flashing faster.
 Once in failsafe mode, perform a factory reset as usual.

 Alternatively, the U-boot bootloader contains a recovery HTTP server
 to upload the  firmware. Push the reset button while powering the
 device on and keep it pressed for >10 seconds. The device's LEDs will
 blink several times and the recovery page will be at
 http://192.168.1.1; use it to upload the sysupgrade image.

Note:

 Four MAC addresses are stored in the "art" partition (read-only):
  - 0x0000: 40:A5:EF:AA:AA:A0
  - 0x0006: 40:A5:EF:AA:AA:A2
  - 0x1002: 40:A5:EF:AA:AA:A1
  - 0x5006: 40:A5:EF:AA.AA:A3 (inside the 5 GHz calibration data)

 The stock firmware assigns MAC addresses to physical and virtual
 interfaces in a very particular way:
  - eth0 corresponds to the physical Ethernet port labeled as WAN
  - eth1 corresponds to the physical Ethernet port labeled as LAN

  - eth0 belongs to the bridge interface br-wan
  - eth1 belongs to the bridge interface br-lan

  - eth0 is assigned the MAC from 0x0 (*:A0)
  - eth1 is assigned the MAC from 0x1002 (*:A1)

  - br-wan is forced to use the MAC from 0x1002 (*:A1)
  - br-lan is forced to use the MAC from 0x0 (*:A0)

  - radio0 uses the calibration data from 0x5000 (which contains
    a valid MAC address, *:A3). However, it is overwritten by the
    one at 0x6 (*:A2)

 This commit preserves the LAN/WAN roles of the physical Ethernet
 ports (as labeled on the router) and the MAC addresses they expose
 by default (i.e., *:A0 on LAN, *:A1 on WAN), but swaps the position
 of the eth0/eth1 compared to the stock firmware:
  - eth0 corresponds to the physical Ethernet port labeled as LAN
  - eth1 corresponds to the physical Ethernet port labeled as WAN

  - eth0 belongs to the bridge interface br-lan
  - eth1 is the interface at @wan

  - eth0 is assigned the MAC from 0x0 (*:A0)
  - eth1 is assigned the MAC from 0x1002 (*:A1)

  - br-lan inherits the MAC from eth0 (*:A0)
  - @wan inherits the MAC from eth1 (*:A1)

  - radio0's MAC is overwritten to the one at 0x6

This way, eth0/eth1's positions differ from the stock firmware, but
the weird MAC ressignations in br-lan/br-wan are avoided while the
external behaviour of the router is maintained. Additionally, WAN
port is connected to the PHY gmac, allowing to monitor the link
status (e.g., to restart DHCP negotiation when plugging a cable).

Signed-off-by: Roger Pueyo Centelles <[email protected]>
@981213
Copy link
Copy Markdown
Member

981213 commented Oct 12, 2019

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

Labels

target/ath79 pull request/issue for ath79 target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants