Adding second gmac to 4.14


#41

The packets seemed to be trimmed in Wireshark (also checksums were reported as invalid but this is because of trimmed content I believe).

I have the board now working with both lan*@eth0 and wan@eth1 used. Packets are not corrupted.


(Frank W.) #42

ok, i will try it…but trgmii-driver should also be ok because actual dts (here from my 4.14-main) without 2nd gmac is working with trgmii

gmac0: mac@0 {
	compatible = "mediatek,eth-mac";
	reg = <0>;
	phy-mode = "trgmii";

	fixed-link {
		speed = <1000>;
		full-duplex;
		pause;
	};
};

			port@6 {
				reg = <6>;
				label = "cpu";
				ethernet = <&gmac0>;
				phy-mode = "trgmii";

				fixed-link {
					speed = <1000>;
					full-duplex;
				};
			};

btw. have you seen my tests:

17:13:42.430047 IP truncated-ip - 6 bytes missing! 192.168.0.10 > 192.168.0.5: ICMP echo request, id 815, seq 9, length 64

tcpdump from my other router…means outgoing packets are damaged not (only) incoming


#43

Interesting… This seems something complex – my patch definitely helped me and I can’t run more tests now but I’ll maybe try switching trgmii on and off on both ports later and see what happens.

FWIW I also have some funkiness regarding speed negotiation (with a host which works with other router) but it doesn’t seem to be related at the first glance.

Yes, you are right – I meant incoming to the other host which I tested this on. Packets incoming on R2 seemed well.


#44

I have some news – I’ve tried to enable TRGMII on both ports instead and voila, it still works! I’ll take some time to verify that current kernel image has the modified DTB – just in case.


(Frank W.) #45

i can confirm, that cpu-port0 works with this patch (changing trgmii to rgmii)


(Frank W.) #46

you mean the problem may be that the other port was not in trgmii-mode?


#47

Yeah, seems so. I’ve pushed an updated patch to my branch.


(Frank W.) #48

can confirm it works with wan and lan0, but currently not with lan1,2,3

i get dhcp-reply (ip set by my router), but i cannot ping it…strange

ignore it…dhcp sets same address to all tested interfaces, so i have to manually shut down the prior ports not only move cable

in my gmac-branch there is a file mt7623a-rfb-emmc.dts created by any of the patches…is that really necessary? can’t compile without it, but found nowhere it is referenced (not in mt7623.dtsi and not in bananapi-r2.dts). do you have this in your tree?

+++ b/arch/arm/boot/dts/Makefile
@@ -1061,6 +1061,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
 	mt6580-evbp1.dtb \
 	mt6589-aquaris5.dtb \
 	mt6592-evb.dtb \
+	mt7623a-rfb-emmc.dtb \

#49

I have this one too, I think it’s a reference board for MT7623 (rfb – reference board). It comes from 0064-dts.patch. Not sure why can’t you compile without it but I didn’t try.


(Frank W.) #50

I will try to comment-out in makefile when i’m at home…

works also without reference-board

see last commit in gmac-branch: https://github.com/frank-w/BPI-R2-4.14/commits/gmac

@abbradar can you push the changes to official lede and mainline?

@pkalemba now you can try hnat on top of this

created a single patch for 4.14: gmac.diff (23,6 KB) (based on 4.14.19)


(Frank W.) #51

created a new branch from actual 4.14 (4.14.52) and applied patch to it.

works well in my short test

root@bpi-r2-ubuntu:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defau0
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP g0
    link/ether 0a:18:b3:77:d6:79 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::818:b3ff:fe77:d679/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP g0
    link/ether ce:96:6b:35:f5:b2 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::cc96:6bff:fe35:f5b2/64 scope link 
       valid_lft forever preferred_lft forever
4: wan@eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group defa0
    link/ether ce:96:6b:35:f5:b2 brd ff:ff:ff:ff:ff:ff
5: lan0@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group def0
    link/ether 0a:18:b3:77:d6:79 brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group def0
    link/ether 0a:18:b3:77:d6:79 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group def0
    link/ether 0a:18:b3:77:d6:79 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP0
    link/ether 0a:18:b3:77:d6:79 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.105/24 brd 192.168.0.255 scope global lan3
       valid_lft forever preferred_lft forever
    inet6 fe80::818:b3ff:fe77:d679/64 scope link 
       valid_lft forever preferred_lft forever

note that you have to set eth1 to up before you get wan-port up

in /etc/network/interfaces:

auto eth0
iface eth0 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

auto eth1
iface eth1 inet manual
  pre-up ip link set $IFACE up
  post-down ip link set $IFACE down

i can ping my router over all ports (only 1 have to be in that subnet! the others I have set to down)


#52

@frank-w https://github.com/openwrt/openwrt/pull/1135


(Frank W.) #53

anyone else tested it?


#54
root@gate:/proc# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 1e:cf:eb:c5:29:96 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 26:65:86:4b:08:8a brd ff:ff:ff:ff:ff:ff
4: wan@eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 02:01:02:03:04:00 brd ff:ff:ff:ff:ff:ff
    inet xx.xx.xx.xx/24 brd xx.xx.xx.xxx scope global wan
       valid_lft forever preferred_lft forever
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 1e:cf:eb:c5:29:96 brd ff:ff:ff:ff:ff:ff
    inet 192.168.22.10/24 brd 192.168.22.255 scope global lan0
       valid_lft forever preferred_lft forever
6: lan1@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 1e:cf:eb:c5:29:96 brd ff:ff:ff:ff:ff:ff
7: lan2@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 1e:cf:eb:c5:29:96 brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 1e:cf:eb:c5:29:96 brd ff:ff:ff:ff:ff:ff
9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:08:22:fa:09:fc brd ff:ff:ff:ff:ff:ff
10: ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 02:08:22:fa:09:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.25.1/24 scope global ap0
       valid_lft forever preferred_lft forever

(Frank W.) #55

Thank you

I’ve already merged 2nd gmac to 4.14 main because it looks stable now


#56

That’s already from 4.14-main and debian stretch


(Frank W.) #57

Have you done a iperf or similar? I only tested a while for packetloss


#58

I have tested only on packet loss


(Frank W.) #59

@abbradar can you help me porting second gmac to 4.18 so we can stay near mainline with our patches?

i’ve tried using my patch, but it failes ~50% of hunks, mainly in the critical parts of dsa-core (dsa.h,dsa2.c,dsa_priv.h,slave.c)

gmac.diff (23,6 KB)

pushed it separate branch: https://github.com/frank-w/BPI-R2-4.14/commit/5703b24977dee096854dcfc51eb23f04c445ab31

currently i hang at dsa_master_netdev which is non-existent since 4.15

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/net/dsa/dsa_priv.h?id=d0006b002208936d36af8e4dce1f6dfeebb2dfba

problem is that the patch depends on struct dsa_slave_priv, which i don’t have in dsa_slave_to_master (here i have only net_device) => fixed that by adding

struct dsa_slave_priv *p = netdev_priv(dev);

like it’s done in dsa_slave_to_port…

also try to figure out how enable_port_mask is removed…seems these are removed here: https://patchwork.ozlabs.org/patch/830765/ dsa2.c itself has changed much so patch cannot be applied so far…here i need help from anyone have more knowledge about dsa

also setup_timer is used here which have to changed to timer_setup…was not easy for me in wifi-driver


(Frank W.) #60

anyone here, who can help me here?

current dsa2.c says

/* DSA currently only supports a single CPU port */

in dsa_tree_setup_default_cpu which calles dsa_tree_find_first_cpu…i have no idea how to patch it to get the right CPU…

dsa_tree_setup_default_cpu gets first CPU and sets this to any port which is not the cpu-port…i guess here i need to read out the value from dts which cpu-port should be used and get this dsa_port…