mt76 icon indicating copy to clipboard operation
mt76 copied to clipboard

mt76 TX power not working in multiple chipsets (mt7610, mt7613, mt7615, mt7603)

Open dmsza opened this issue 3 years ago • 369 comments

Just looking at the bug reports here and in the OpenWRT defects repository, it is clear that for various mt76 chipsets the TX power is simply not working.

I myself am experimenting two issues with OpenWRT and mt76 drivers:

  • With mt7613 on an TP-Link Archer C6 v3 with OpenWRT where TX power is set to maximum and cannot be changed (details in the OpenWRT bug FS#181).
  • With mt7610 on an TP-Link RE200 v2 with OpenWRT TX power is too low (max 9dBm), cannot be changed above this and makes the 5Ghz radio unusable.

Searching here in the mt76 repository about similar TX power issues, I've found multiple similar reports:

TP-LINK RE200 problem with the operation of the WLAN chipset. OpenWRT rel 21.02rc4 #606 MT7610E: TX-Power Values incorrect -> low range #604 MT76x0: Correct VHT MCS 8/9 tx power eeprom offset #577 MT7615dn: 5G max power is 6dBm #574 Xiaomi r3p mt7615N low tx power 2ghz 5ghz #539 Low transmission power on MT7610EN #530 mt7603e max tx power is only 8 dBm on HiWiFi HC5962 #525 low tx power with mt76x0e driver #484 Low-incorrect txpower on Mediatek 7628 (TP-Link 840 ver 6.0) #279 Various issues with 5Ghz MT7610E #227 low tx power m7610e #216

And some other more.

While as in the TP-Link Archer C6 v3 (mt7613) where TX Power is stuck at maximum allows it to be perfectly usable, on other devices such as TP-Link RE200 v2 (mt7610) wifi is unusable due to the very weak 5Ghz signal power.

So instead of opening more bug reports here for my TX Power issues with mt7613 and mt7610, I've decided summarize the existing bug reports about TX power here so perhaps we can concentrate the developers' focus on this single bug report.

dmsza avatar Dec 05 '21 11:12 dmsza

I extracted stock firmware (Archer c2) and see that it doesn't use eeprom power values. It use values from file SingleSKU_5G_FCC.txt If we modify code to ability for load power values from file or hardcode they in variables then the issue will be fixed. But we need different values set for different routers.

Devmax21 avatar Dec 06 '21 12:12 Devmax21

I think these values are from db.txt file and we have it already so we can use that file instead wrong places in eeprom which sometimes leads to too much txpower or too little. Values from wireless-regdb - db.txt are exactly the correct values for all countries and domains.

sanitariu avatar Dec 06 '21 13:12 sanitariu

I'm not sure reg-db.txt should be used. I mean, while it correctly specifies the maximum power allowed for a given region, it might be greater than the radio supports.

I mean, let's say 30dBm is allowed for a given region/frequency. But the radio of a given device supports a maximum of 23dBm, for example.

This way, will setting the TX power for this radio to 30dBm damage it?

dmsza avatar Dec 06 '21 14:12 dmsza

I think such devices would not be allowed the be imported in your country.

sanitariu avatar Dec 06 '21 14:12 sanitariu

That's not how things work in real life. Most manufacturers use a single hardware design for their devices which are sold globally. The TX power and other regulation constraints (such allowed frequencies and DFS channels) are limited by the firmware, not by the hardware. That's why there are "US" firmware, "EU" firmware and so on.

BTW, that's beyond the point of this bug report.

The issue reported here concerns MT76 driver and make it work according to the TX power which is allowed per region configured in OpenWRT.

dmsza avatar Dec 06 '21 16:12 dmsza

As I see, stock firmwares calculate power for 5G based on value MT_EE_5G_TARGET_POWER. And adjust tx power using SingleSKU_5G_FCC. The MT76 calculate power for 5G using eeprom values (MT_EE_TX_POWER_DELTA_BW80 + offset) if tssi is disabled. And it use MT_EE_5G_TARGET_POWER if tssi is enabled. I proposed to use MT_EE_5G_TARGET_POWER in https://github.com/openwrt/mt76/issues/227#issuecomment-985809672 if tssi is disabled, but it is incorrect because power per rate doesn't corresponds to SingleSKU_5G_FCC. With that fix the real TX power is increased. I think that we should calculate correct power per rate and set proper value of delta in TX_ALC_CFG_1.

Devmax21 avatar Dec 06 '21 17:12 Devmax21

I think these values are from db.txt file and we have it already so we can use that file instead wrong places in eeprom which sometimes leads to too much txpower or too little. Values from wireless-regdb - db.txt are exactly the correct values for all countries and domains.

I think these values is not from wireless-regdb. The wireless-regdb has only max power values for frequencies. But SingleSKU_5G_FCC has power table considering power per rate.

Devmax21 avatar Dec 06 '21 19:12 Devmax21

This file from RE200. As you see, it has other values than Archer c2 SingleSKU_5G_FCC.txt

Devmax21 avatar Dec 07 '21 07:12 Devmax21

To follow this ticket

Neustradamus avatar Dec 09 '21 00:12 Neustradamus

If we modify code to ability for load power values from file or hardcode they in variables then the issue will be fixed. But we need different values set for different routers.

It is possible to specify own eeprom in openwrt for each device in dts file. see: https://github.com/openwrt/mt76/pull/567

I also did some research about my tp link vr200v with mt7610e. power was low with default openwrt firmware. I managed to edit the right vals in eprom to use the correct txpower. Works good, but this is a hack and no fix since we cannot enable one power limit for all mt76 devices and patching dts file for every device is also not the right way. Interesting is, that in stock router img theres a eprom file, but this also offers low tx power. I thought that perhaps this file is used with offset (antenna offset?) but i don't looked deeper in it.

ArtemiisFowl avatar Dec 09 '21 11:12 ArtemiisFowl

It is impossible for some devices. As I understand, dts info stored in uboot (correct me if I'm wrong). For example, we can't replace uboot for archer c2. It should be original for this device.

As I wrote, stock router doesn't use values from eeprom. It use values from the SingleSKU_5G_FCC file, placed in /etc/ and value MT_EE_5G_TARGET_POWER from eeprom as upper txpower limit.

Devmax21 avatar Dec 09 '21 12:12 Devmax21

SingleSKU does not override EEPROM, it only limits the txpower.

nbd168 avatar Dec 09 '21 12:12 nbd168

SingleSKU does not override EEPROM, it only limits the txpower.

In mediatek driver for the txpower they use EEPROM_MT76x0_5G_TARGET_POWER for 5G

RT28xx_EEPROM_READ16(pAd, EEPROM_MT76x0_5G_TARGET_POWER, ee_val);
                        pAd->DefaultTargetPwr = ee_val & 0x00ff;

In the mt76 we get the txpower from eeprom MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE when tssi is disabled -

        if (chan->band == NL80211_BAND_2GHZ) {
                addr = MT_EE_TX_POWER_DELTA_BW80 + offset;
        } else {
                switch (chan->hw_value) {
                case 42:
                        offset = 2;
                        break;
                case 58:
                        offset = 8;
                        break;
                case 106:
                        offset = 14;
                        break;
                case 122:
                        offset = 20;
                        break;
                case 155:
                        offset = 30;
                        break;
                default:
                        break;
                }
                addr = MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE + 2 + offset;
        }

        data = mt76x02_eeprom_get(dev, addr);
        *tp = data >> (8 * idx);

In archer c2 eeprom offset MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE = 0x76

000000000070:  FF FF FF FF│FF 00 00 FF│13 13 12 11│11 10 10 10
000000000080:  10 10 10 10│11 11 11 11│11 11 11 11│11 12 12 12
000000000090:  12 12 12 12│12 12 12 12│11 11 11 FF│FF FF FF FF

and value EEPROM_MT76x0_5G_TARGET_POWER = 0x1c

As you can see EEPROM_MT76x0_5G_TARGET_POWER is bigger then any values from MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE. In result we have lower power with mt76.

Yes, SingleSKU does not override EEPROM and it is used for limits power per rate. As I understand, incorrect power per rate is not good and we need to use oem SingleSKU values for calculate correct power per rate. Is it right?

Devmax21 avatar Dec 09 '21 13:12 Devmax21

Maybe I haven't been clear.

The mediatek driver set only one byte of TX_ALC_CFG_0 from MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE in MT76x0_ChipSwitchChannel (EEPROM_A_TX_PWR_OFFSET = MT_EE_TX_POWER_0_GRP4_TSSI_SLOPE + 2)

                /* 1. U-NII lower/middle band: 36, 38, 40; 44, 46, 48; 52, 54, 56; 60, 62, 64 (including central frequency in BW 40MHz)*/
                choffset = 14;
                ASSERT((pAd->TxPower[choffset].Channel == 36));
                for (i = 0; i < 6; i++)
                {
                        idx = i * 2;
                        RT28xx_EEPROM_READ16(pAd, EEPROM_A_TX_PWR_OFFSET + idx, Power.word);

                        if ((Power.field.Byte0 <= 0x3F) && (Power.field.Byte0 >= 0))
                                pAd->TxPower[idx + choffset + 0].Power = Power.field.Byte0;

                        if ((Power.field.Byte1 <= 0x3F) && (Power.field.Byte1 >= 0))
                                pAd->TxPower[idx + choffset + 1].Power = Power.field.Byte1;
                }
...

TxPwer = pAd->TxPower[Index].Power;

....

                RTMP_IO_READ32(pAd, TX_ALC_CFG_0, &Value);                                                                                                                                
                Value = Value & (~0x3F3F);                                                                                                                                                
                Value |= TxPwer;                                                                                                                                                          
                Value |= (0x2F2F << 16);                                                                                                                                                  
                RTMP_IO_WRITE32(pAd, TX_ALC_CFG_0, Value);

Higher byte set to 0. It is not clear for me. Why?

Or maybe I see wrong sources) I got it here https://github.com/zaccareal/openwrt-archer-c2/blob/master/package/mediatek/drivers/mt7610e/src/chips/mt76x0.c

Devmax21 avatar Dec 09 '21 16:12 Devmax21

same issue for me too on my tplink archer c20 v4 5ghz network is not working ( it works once for a sec if I'm lucky)

any way I can fix this?

yesrab avatar Dec 10 '21 15:12 yesrab

@Devmax21 I am on the same boat and would like to thank you for sharing your findings. I have a TP-Link RE220v2 with OpenWrt 21.02.1 r16325 installed and my tests show OpenWRT's MTK driver sets TX power large enough for the U-NII-3 band channels (149-165); however, it sets extremely low TX power for U-NII-1 and U-NII-2A band ones. In just apart 5 meters away from each other and I can see the connection becomes unstable. I tried both channel 36 and 64, and they are barely usable.

Because at least the TX power for U-NII-3 band seems to be large enough, perhaps we can take a look on that part and decide how to fix the mid/lower band TX power.

chinghanyu avatar Dec 11 '21 03:12 chinghanyu

If I am reading correctly, most comments in this discussion are related to eeprom.c and the options to make it read the correct TX power limits for various mt76 devices.

While this is an actual defect and it must be fixed for multiple devices (as I mentioned I have this issue with a RE200 v2 device), I would like to bring the attention to the fact that there is other issue at play here.

For example, even if reading the TX power is fixed, it may not work since the code to set the TX power seems also not be working.

I did some thorough tests with the Archer C6 v3.2, the results are here: https://forum.openwrt.org/t/mediatek-mt76-ignoring-wi-fi-tx-power-configuration/106788

As you will be able to see, I was trying to reduce the TX power to troubleshoot some overlapping areas and to improve 802.11r. However changing the TX power has no effect at all.

So just fixing the TX power reading in eeprom.c might not fix this issue at all if the driver cannot configure the radio with intended TX power.

dmsza avatar Dec 12 '21 11:12 dmsza

mark.

ptpt52 avatar Dec 13 '21 22:12 ptpt52

I got access to console via telnet on Archer c2 with stock firmware and see that power values looks almost the same as on mt76

Stock -

#define MT_TX_ALC_CFG_0                 0x13b0
#define MT_TX_PWR_CFG_0                 0x1314
#define MT_TX_PWR_CFG_1                 0x1318
#define MT_TX_PWR_CFG_2                 0x131c
#define MT_TX_PWR_CFG_3                 0x1320
#define MT_TX_PWR_CFG_4                 0x1324
#define MT_TX_PWR_CFG_8                 0x13d8


/var/tmp # iwpriv rai0 mac 13b0
rai0      mac:
[0x13b0]:2f2f0012  
/var/tmp # iwpriv rai0 mac 1314
rai0      mac:
[0x1314]:07070000  
/var/tmp # iwpriv rai0 mac 1318
rai0      mac:
[0x1318]:01010004  
/var/tmp # iwpriv rai0 mac 131c
rai0      mac:
[0x131c]:00000001  
/var/tmp # iwpriv rai0 mac 1320
rai0      mac:
[0x1320]:00000000  
/var/tmp # iwpriv rai0 mac 1324
rai0      mac:
[0x1324]:00000000
/var/tmp # iwpriv rai0 mac 13d8
rai0      mac:
[0x13d8]:3f3f0000

mt76 - use delta from EEPROM (-1)

MT_TX_ALC_CFG_0:2f2f1212
MT_TX_PWR_CFG_0:0x6063f3f
MT_TX_PWR_CFG_1:0x6063f03
MT_TX_PWR_CFG_2:0x3f3f3f03
MT_TX_PWR_CFG_3:0x3f3f3f3f
MT_TX_PWR_CFG_4:0x3f3f
MT_TX_PWR_CFG_8:0x3e3e003f

I tried to set the second byte for power in MT_TX_ALC_CFG to 0 and nothing changed.

As I understand power value in MT_TX_ALC_CFG changing power with step 1dB (I didn't find manual for mt7610 but I saw in manual for other similar mtk chip that step is 0.5 dB). But in the mt76 expected 0.5 dB. I made patch that is work for me and tx power on router looks like good.

iw phy0 info

               Frequencies:
                        * 5180 MHz [36] (23.0 dBm)
                        * 5200 MHz [40] (23.0 dBm)
                        * 5220 MHz [44] (23.0 dBm)
                        * 5240 MHz [48] (23.0 dBm)
                        * 5260 MHz [52] (23.0 dBm) (radar detection)
                        * 5280 MHz [56] (23.0 dBm) (radar detection)
                        * 5300 MHz [60] (23.0 dBm) (radar detection)
                        * 5320 MHz [64] (23.0 dBm) (radar detection)
                        * 5500 MHz [100] (23.0 dBm) (radar detection)
                        * 5520 MHz [104] (23.0 dBm) (radar detection)
                        * 5540 MHz [108] (23.0 dBm) (radar detection)
                        * 5560 MHz [112] (23.0 dBm) (radar detection)
                        * 5580 MHz [116] (23.0 dBm) (radar detection)
                        * 5600 MHz [120] (23.0 dBm) (radar detection)
                        * 5620 MHz [124] (23.0 dBm) (radar detection)
                        * 5640 MHz [128] (23.0 dBm) (radar detection)
                        * 5660 MHz [132] (23.0 dBm) (radar detection)
                        * 5680 MHz [136] (23.0 dBm) (radar detection)
                        * 5700 MHz [140] (23.0 dBm) (radar detection)
                        * 5720 MHz [144] (23.0 dBm) (radar detection)
                        * 5745 MHz [149] (30.0 dBm)
                        * 5765 MHz [153] (30.0 dBm)
                        * 5785 MHz [157] (30.0 dBm)
                        * 5805 MHz [161] (30.0 dBm)
                        * 5825 MHz [165] (30.0 dBm)
                        * 5845 MHz [169] (disabled)
                        * 5865 MHz [173] (disabled)

This patch only for mt76x0. I think that the fix a similar for other chipsets, but I don't have other routers for testing. Another issue - after calculated power limit, the power per rate has the same values. with this patch will be decreased txpower and power per rate will be unchanged.

020-txpower-mt76x0.patch.txt

Devmax21 avatar Dec 14 '21 15:12 Devmax21

I also did some research about my tp link vr200v with mt7610e. power was low with default openwrt firmware. I managed to edit the right vals in eprom to use the correct txpower. Works good, but this is a hack and no fix since we cannot enable one power limit for all mt76 devices and patching dts file for every device is also not the right way. Interesting is, that in stock router img theres a eprom file, but this also offers low tx power. I thought that perhaps this file is used with offset (antenna offset?) but i don't looked deeper in it.

I think the values in eeprom is correct. But we can increase the values and get tx power upper 23dB)

Devmax21 avatar Dec 14 '21 15:12 Devmax21

MT7610E-EEPROMContentv06.pdf Hope this document is helpful. I feel that only mt7610‘s transmit power is abnormal.

DragonBluep avatar Dec 14 '21 17:12 DragonBluep

I also cannot detect 5Ghz antenna on my Totolink x5000r (MT7621/MT7915e), but it looks also like a power issue since everything else seems to be working. Using openwrt snapshot from ~1w ago.

vbmithr avatar Dec 16 '21 00:12 vbmithr

Experiencing the same issue on TP-Link RE200 v1 (MediaTek MT7610E) on OpenWrt 21.02.1 r16325-88151b8303. Tx-Power limited to 9 dBm on 5 GHz, BSSID undetectable from other devices.

alessandroflaminio avatar Dec 17 '21 14:12 alessandroflaminio

Hello guys, I have also experienced the same problem with Wavlink AP, which has MediaTek MT7610E and MediaTek MT7688AN. Both 5Ghz and 2.4Ghz radios are with a similar issue.

thiagohd avatar Dec 29 '21 12:12 thiagohd

Same issue also for me with a TP-Link TL-WR902AC v3, which is using a MT7610EN. Maximum Transmit power listed is 11dBm

Using OpenWrt 21.02.1 r16325-88151b8303

workpush avatar Jan 03 '22 21:01 workpush

This problem also affects WR902ac router. No matter what country is selected, maximum transmit power for 5 GHz radio is 12 dBm.

JsBergbau avatar Jan 07 '22 00:01 JsBergbau

One solution for my router(7603e) is to modify eeprom, making my 2.4g work fine at 30dBm. but, I find out that the source code is not correspond to the document i found on the internet.

asiaon123 avatar Jan 07 '22 02:01 asiaon123

One solution for my router(7603e) is to modify eeprom, making my 2.4g work fine at 30dBm. but, I find out that the source code is not correspond to the document i found on the internet.

Hello @asiaon123, could you explain how you modified the eeprom in more details, maybe share the code? It would really help me and probably others, a lot. Thank you very much in advance!

thiagohd avatar Jan 07 '22 11:01 thiagohd

One solution for my router(7603e) is to modify eeprom, making my 2.4g work fine at 30dBm. but, I find out that the source code is not correspond to the document i found on the internet.

Hello @asiaon123, could you explain how you modified the eeprom in more details, maybe share the code? It would really help me and probably others, a lot. Thank you very much in advance!

I explained it here and in following comments. But it's not a fix, it's a dirty hack https://github.com/openwrt/mt76/issues/227#issuecomment-944611998

ArtemiisFowl avatar Jan 07 '22 11:01 ArtemiisFowl

One solution for my router(7603e) is to modify eeprom, making my 2.4g work fine at 30dBm. but, I find out that the source code is not correspond to the document i found on the internet.

The source code is right. Мaximum transmit power for 5 GHz radio is only chip power. We don't know external power for different routers. In this case code get max power from eeprom. And we use max power for router. As example on tp-link c2 we have antenna with 5dBi. Max power rate is 6. And chip max TX power is 12. As result we have effective max TX power is 12+5+6=23 dBm.

Devmax21 avatar Jan 07 '22 11:01 Devmax21