Skip to content

Commit

Permalink
mac80211: rt2x00: experimental improvements for MT7620 wifi
Browse files Browse the repository at this point in the history
Serge Vasilugin reports:

To improve mt7620 built-in wifi performance some changes:
1. Correct BW20/BW40 switching (see comments with mark (1))
2. Correct TX_SW_CFG1 MAC reg from v3 of vendor driver see
	https://gitlab.com/dm38/padavan-ng/-/blob/master/trunk/proprietary/rt_wifi/rtpci/3.0.X.X/mt76x2/chips/rt6352.c#L531
3. Set bbp66 for all chains.
4. US_CYC_CNT init based on Programming guide, default value was 33 (pci),
   set chipset bus clock with fallback to cpu clock/3.
5. Don't overwrite default values for mt7620.
6. Correct some typos.
7. Add support for external LNA:
    a) RF and BBP regs never be corrected for this mode
    b) eLNA is driven the same way as ePA with mt7620's pin PA
	but vendor driver explicitly pin PA to gpio mode (for forrect calibration?)
	so I'm not sure that request for pa_pin in dts-file will be enough

First 5 changes (really 2) improve performance for boards w/o eLNA/ePA.
Changes 7 add support for eLNA

Configuration w/o eLAN/ePA and with eLNA show results
tx/rx (from router point of view) for each stream:
 35-40/30-35 Mbps for HT20
 65-70/60-65 Mbps for HT40

Yes. Max results for 2T2R client is 140-145/135-140
with peaks 160/150, It correspond to mediatek driver results.
Boards with ePA untested.

Reported-by: Serge Vasilugin <vasilugin@yandex.ru>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Sep 12, 2022
1 parent d4feb66 commit 31a6605
Show file tree
Hide file tree
Showing 17 changed files with 467 additions and 15 deletions.
423 changes: 423 additions & 0 deletions package/kernel/mac80211/patches/rt2x00/992-rt2x00-more-fixes.patch

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions target/linux/ramips/dts/mt7620a.dtsi
Expand Up @@ -420,6 +420,13 @@
};
};

pa_gpio_pins: pa_gpio {
pa {
groups = "pa";
function = "gpio";
};
};

sdhci_pins: sdhci {
sdhci {
groups = "nd_sd";
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_buffalo_whr-300hp2.dts
Expand Up @@ -147,8 +147,9 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};

&factory {
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_cameo_810.dtsi
Expand Up @@ -138,8 +138,9 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;

ralink,mtd-eeprom = <&factory 0x0>;
nvmem-cells = <&macaddr_factory_28>;
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_dlink_dch-m225.dts
Expand Up @@ -174,8 +174,9 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};

&factory {
Expand Down
4 changes: 3 additions & 1 deletion target/linux/ramips/dts/mt7620a_fon_fon2601.dts
Expand Up @@ -143,8 +143,10 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";

pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>, <&wled_pins>;
pinctrl-1 = <&pa_gpio_pins>, <&wled_pins>;
};

&pcie {
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_hiwifi_hc5861.dts
Expand Up @@ -107,6 +107,7 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};
6 changes: 4 additions & 2 deletions target/linux/ramips/dts/mt7620a_lenovo_newifi-y1.dtsi
Expand Up @@ -90,9 +90,11 @@
};

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;

ralink,mtd-eeprom = <&factory 0x0>;
};

&state_default {
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_phicomm_k2-v22.4.dts
Expand Up @@ -18,6 +18,7 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_phicomm_k2-v22.5.dts
Expand Up @@ -24,6 +24,7 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_phicomm_k2g.dts
Expand Up @@ -42,6 +42,7 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_tplink_archer-c20-v1.dts
Expand Up @@ -69,8 +69,9 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;

nvmem-cells = <&macaddr_rom_f100>;
nvmem-cell-names = "mac-address";
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_tplink_archer-c50-v1.dts
Expand Up @@ -69,8 +69,9 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;

nvmem-cells = <&macaddr_rom_f100>;
nvmem-cell-names = "mac-address";
Expand Down
3 changes: 2 additions & 1 deletion target/linux/ramips/dts/mt7620a_wavlink_wl-wn530hg4.dts
Expand Up @@ -131,8 +131,9 @@
};

&wmac {
pinctrl-names = "default";
pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;

ralink,mtd-eeprom = <&factory 0x0>;
};
Expand Down
4 changes: 3 additions & 1 deletion target/linux/ramips/dts/mt7620a_xiaomi_miwifi-mini.dts
Expand Up @@ -146,8 +146,10 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";

pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};

&pcie {
Expand Down
4 changes: 4 additions & 0 deletions target/linux/ramips/dts/mt7620a_youku_yk-l1.dtsi
Expand Up @@ -113,6 +113,10 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;

pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};

&sdhci {
Expand Down
4 changes: 3 additions & 1 deletion target/linux/ramips/dts/mt7620a_zbtlink_zbt-ape522ii.dts
Expand Up @@ -106,8 +106,10 @@

&wmac {
ralink,mtd-eeprom = <&factory 0x0>;
pinctrl-names = "default";

pinctrl-names = "default", "pa_gpio";
pinctrl-0 = <&pa_pins>;
pinctrl-1 = <&pa_gpio_pins>;
};

&pcie {
Expand Down

20 comments on commit 31a6605

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

is it planned to backport these changes to the 22.03 branch?

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but after some more reports about performance of users of different mt7620 boards have been received.

@DragonBluep
Copy link
Contributor

Choose a reason for hiding this comment

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

@dangowrt Thank you, I've picked this commit from your staging branch since June, and upload and download speeds can easily reach 100+ Mbps on HiWiFi HC5661, w/o PA/LNA. Everything works fine except for some unimportant warnings under heavy load.

ieee80211 phy0: rt2x00lib_rxdone_read_signal: Warning - Frame received with unrecognized signal, mode=0x0001, signal=0x010f, type=4

And one more question, youku_yk-l1 has no PA and LNA, why do we still set its PA pin? thanks again.

@HiGarfield
Copy link

Choose a reason for hiding this comment

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

Another serious issue of MT7620.

#10707

@DragonBluep
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not related to this commit, but mt7620's TX power is incorrect. I can set it to 30 dbm, but not much different from 17-20 dbm. It seems that all devices have this problem. If anyone interested in this question, maybe this document will be helpful. MT7620_EEPROM_Content_v1_7

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

And one more question, youku_yk-l1 has no PA and LNA, why do we still set its PA pin? thanks again.

Oh.... Thank you for pointing that out. That change to the youku_yk-l1 was committed by mistake. I used this board for testing the new pinctrl codepaths which only have effect on eLNA/ePA devices (because I don't have any other MT7620 device). Will revert that part in a later commit.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

mt7620's TX power is incorrect. I can set it to 30 dbm, but not much different from 17-20 dbm. It seems that all devices have this problem.

True. TSSI is still missing entirely in rt2x00 and has to be implemented for power levels to be accurate. See here in the vendor driver to get an idea.

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

@dangowrt i tested two devices (TP-Link RE210 & Netgear EX3700) but had the same throughput on 2GHz - didn't matter if the patchset was applied or not. i tested the throughput with iperf3. i'd like to help with testing as i have 2-3 more devices but i'd like to know the testing method you were using to see the performance increase.

@DragonBluep
Copy link
Contributor

Choose a reason for hiding this comment

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

@achterin There have been some ipv6 issues related to dnsmasq (perhaps nftables). We can solve it by disabling ipv6 or upgrading dnsmasq. see #10820

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

@achterin There have been some ipv6 issues related to dnsmasq (perhaps nftables). We can solve it by disabling ipv6 or upgrading dnsmasq. see #10820

i used ipv4 addresses, so this should not be related

@DragonBluep
Copy link
Contributor

@DragonBluep DragonBluep commented on 31a6605 Sep 28, 2022

Choose a reason for hiding this comment

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

My carrier also does not provide ipv6. Anyway when I disable all ipv6 options, I can really get a significant speed increase. 40-60M to 120+M with 2 * 2 mimo and force 40 mhz, tested with iperf3. Using the top command, you can see that some soft interrupts occupy a lot of CPU resource in ipv6 mode.

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the top command
what command are you talking about?
both devices achieved ~80Mbit/s throughput with 2*2 mimo & 40mhz, with and without this patch. i used one pc connected via cable as server and another pc connected via wifi as client - no carrier dhcp involved.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

@achterin The improvements reported by forum user 123serge123 mostly affect devices with external LNA. However, also HT40 mode was significantly improved and you should notice.
Did you set option noscan '1' (to force HT40 mode despite the presence of other networks in the same band)?

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

@achterin The improvements reported by forum user 123serge123 mostly affect devices with external LNA. However, also HT40 mode was significantly improved and you should notice. Did you set option noscan '1' (to force HT40 mode despite the presence of other networks in the same band)?

no, i only set htmode to ht40 but i will try this option next time. thanks for the hint!

@DragonBluep
Copy link
Contributor

Choose a reason for hiding this comment

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

@achterin The name of this command is top😂, we can execute it in OpenWrt SSH to watch cpu status. 80 Mbit/s is already a significant improvement. Before this commit, I remember it had never been reached to 40 Mbit/s.

@achterin
Copy link
Contributor

Choose a reason for hiding this comment

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

@achterin The name of this command is topjoy, we can execute it in OpenWrt SSH to watch cpu status. 80 Mbit/s is already a significant improvement. Before this commit, I remember it had never been reached to 40 Mbit/s.

haha, now i get it xD i know what top is for, i just misunderstood your answer. as said, both devices achieved ~80Mbit/s regardless of the patch being applied or not. but is will redo the test with the option @dangowrt suggested.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

Also, set option txpower '5' or something similarly low. With full output power the chip quickly overheats which harms performance.

@rankaiyx
Copy link

Choose a reason for hiding this comment

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

Does this improvement apply to mt7620n as well as mt7620a? If so, I have a mt7620n router and I can test it.

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this should improve performance also on mt7620n, though the difference before/after is bigger on mt7620a.

@DragonBluep
Copy link
Contributor

Choose a reason for hiding this comment

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

Feedback from Phicomm K2:

  1. The external PA / LNA work well. The signal strength and speed are also very good. However, the signal strength showed by iwinfo is very weak (only the value is very weak, but the actual signal strength is normal). There is another feedback: Upgrade 21.02.03 to 22.03.02: 2.4GHz incoming WiFi signal (bgn) drops by 20dBm after upgrade #11036
phy0-ap0  ESSID: "PhantomXT-5G"
          Access Point: 00:6B:8E:
          Mode: Master  Channel: 36 (5.180 GHz)  HT Mode: VHT80
          Center Channel 1: 42 2: unknown
          Tx-Power: 24 dBm  Link Quality: 45/70
          Signal: -65 dBm  Noise: unknown
          Bit Rate: 663.0 MBit/s
          Encryption: mixed WPA/WPA2 PSK (CCMP)
          Type: nl80211  HW Mode(s): 802.11ac/n
          Hardware: 14C3:7662 14C3:7662 [MediaTek MT76x2E]
          TX power offset: none
          Frequency offset: none
          Supports VAPs: yes  PHY name: phy0

phy1-ap0  ESSID: "PhantomXT"
          Access Point: 00:6B:8E:
          Mode: Master  Channel: 1 (2.412 GHz)  HT Mode: HT40
          Center Channel 1: 3 2: unknown
          Tx-Power: 12 dBm  Link Quality: 32/70
          Signal: -78 dBm  Noise: unknown
          Bit Rate: 107.3 MBit/s
          Encryption: mixed WPA/WPA2 PSK (CCMP)
          Type: nl80211  HW Mode(s): 802.11b/g/n
          Hardware: embedded [MediaTek MT7620]
          TX power offset: none
          Frequency offset: none
          Supports VAPs: yes  PHY name: phy1
  1. explicitly pin PA to gpio mode will not take effect. Referring to the mt7620 pinctrl driver, the PA pin should still be used as the PA mode.
  2. Externel PA RTC5641EX / LNA does not seem to need to be driven by PA pin. PA and LNA are separate chips. It seems that only FEM chips need to use specific PWM waves to drive.

Please sign in to comment.