OK, let me give you a short walk-through at what I did:
TEST AT YOUR OWN RISK!
Make sure you have up-to-date kernel and u-boot first!
The tx- / rx- delay settings live in the devicetree file which describes your hardware (board) to the Linux kernel and configures besides many other things which drivers are used and how...
Set up a way to test your Ethernet performance against a fast machine (not a NAS or some other embedded device), I use a Windows box here on the same switch (Netgear GS716Tv3) with fully shielded CAT6 S/FTP patch cables of 3m length (please use proper cables....).
Using iperf3 on Windows as a server:
Code:
c:\iperf-3.1.3-win64>iperf3.exe -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Using iperf3 on the Pine64 as client: (switch out 192.168.1.107 for your test server's IP address...)
Code:
debian@pine64:/boot/pine64$ iperf3 -c 192.168.1.107 -p 5201
Connecting to host 192.168.1.107, port 5201
[ 4] local 192.168.1.116 port 57451 connected to 192.168.1.107 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 52.5 MBytes 441 Mbits/sec 0 243 KBytes
[ 4] 1.00-2.01 sec 78.9 MBytes 652 Mbits/sec 0 273 KBytes
[ 4] 2.01-3.00 sec 82.4 MBytes 701 Mbits/sec 0 273 KBytes
[ 4] 3.00-4.01 sec 105 MBytes 873 Mbits/sec 0 273 KBytes
[ 4] 4.01-5.01 sec 106 MBytes 892 Mbits/sec 0 273 KBytes
[ 4] 5.01-6.01 sec 106 MBytes 886 Mbits/sec 0 273 KBytes
[ 4] 6.01-7.02 sec 107 MBytes 889 Mbits/sec 0 273 KBytes
[ 4] 7.02-8.00 sec 105 MBytes 889 Mbits/sec 0 273 KBytes
[ 4] 8.00-9.00 sec 106 MBytes 888 Mbits/sec 0 273 KBytes
[ 4] 9.00-10.01 sec 107 MBytes 888 Mbits/sec 0 273 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.01 sec 955 MBytes 800 Mbits/sec 0 sender
[ 4] 0.00-10.01 sec 955 MBytes 800 Mbits/sec receiver
As you can see, results are pretty good, we are getting about 800Mbit/s here, this is sending data towards the Windows box, so we want to adjust tx-delay if we get bad results (as opposed to the values shown above)...
The devicetree files are located in /boot/pine64/ , we are looking for sun50i-a64-pine64-plus.dtb which is the binary, compiled devicetree blob. To edit the setting we first have to decompile the binary to a text file (dts) using the devicetree compiler dtc:
Code:
debian@pine64:/boot/pine64$ sudo dtc -I dtb -O dts -o sun50i-a64-pine64-plus.dts sun50i-a64-pine64-plus.dtb
Now you should have a text file called sun50i-a64-pine64-plus.dts ... it should look something like
https://github.com/longsleep/build-pine6...pine64.dts
Edit this file with your favourite text editor, search for tx-delay in the Ethernet section:
Code:
eth@01c30000 {
compatible = "allwinner,sunxi-gmac";
reg = <0x0 0x1c30000 0x0 0x40000 0x0 0x1c00000 0x0 0x30>;
pinctrl-names = "default";
interrupts = <0x0 0x52 0x4>;
interrupt-names = "gmacirq";
clocks = <0x8f>;
clock-names = "gmac";
phy-mode = "rgmii";
tx-delay = <0x3>;
rx-delay = <0x0>;
gmac_power1 = "axp81x_dc1sw:0";
status = "okay";
device_type = "gmac0";
pinctrl-0 = <0x9e>;
gmac_power2;
gmac_power3;
};
According to the driver source in /drivers/net/ethernet/allwinner/sunxi-gma.c
Code:
static unsigned long tx_delay = 0;
module_param(tx_delay, ulong, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(tx_delay, "Adjust transmit clock delay, value: 0~7");
static unsigned long rx_delay = 0;
module_param(rx_delay, ulong, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(rx_delay, "Adjust receive clock delay, value: 0~31");
tx-delay ranges from 0 to 7, rx-delay ranges from 0 to 31.... we are adjusting tx-delay for now since we are interested in tweaking the sending of packets at the moment, so pick a value and save the file....
Now it's time to generate a binary file out of the dts again, maybe
make a backup of your original dtb at this point, so if something goes wrong, you can copy it back... if you screw up the dtb, your image will most likely not boot or malfunction in some other way...
Code:
debian@pine64:/boot/pine64$ sudo dtc -I dts -O dtb -o sun50i-a64-pine64-plus.dtb sun50i-a64-pine64-plus.dts
Now reboot, and repeat the network test with iperf3, rinse repeat.... if you want to check if your devicetree changes are in effect after you reboot, you can look into the sysfs files of the driver:
Code:
debian@pine64:/boot/pine64$ cat /sys/module/sunxi_gmac/parameters/tx_delay
Happy hacking....
PS: It is by no means sure that tuning the delays will fix all the GbE issues people seem to have, I had two working boards that can get around 800Mbit/s in both directions with the default values (tx-delay 3, rx-delay 0).... BUT I can degrade my performance substantially when I move away from those values, up to a point where the GbE stops working, so testing this on a board that doesnt work with the default will be interesting...