openwrt / mt76

mac80211 driver for MediaTek MT76x0e, MT76x2e, MT7603, MT7615, MT7628 and MT7688
745 stars 342 forks source link

MT7628AN/MT7610E htmode limited at HT20 #673

Closed chinghanyu closed 2 years ago

chinghanyu commented 2 years ago

The chip reports that is support both HT20 and HT40

root@OpenWrt:/sys/kernel/debug/ieee80211/phy0/mt76# iwinfo wlan0 htmodelist
HT20 HT40

but only runs HT20; HT40 option is not effective.

root@OpenWrt:/sys/kernel/debug/ieee80211/phy0/mt76# iw dev wlan0 info
Interface wlan0
        ifindex 14
        wdev 0x5
        addr 68:ff:7b:4d:f9:47
        ssid OpenWrt-2G
        type AP
        wiphy 0
        channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz
        txpower 22.00 dBm
        multicast TXQ:
                qsz-byt qsz-pkt flows   drops   marks   overlmt hashcol tx-bytes        tx-packets
                0       0       151     0       0       0       0       40848           162
chinghanyu commented 2 years ago

Tried to override the source code to force using HT40 but still got HT20, implying the bandwidth setting logic is broken.

Scan result from a Raspberry Pi 3

BSS 68:ff:7b:4d:f9:47(on wlan0)
        last seen: 4780578.477s [boottime]
        TSF: 0 usec (0d, 00:00:00)
        freq: 2462
        beacon interval: 100 TUs
        capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431)
        signal: -41.00 dBm
        last seen: 10 ms ago
        SSID: OpenWrt-2G
        Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0
        DS Parameter set: channel 11
        Country: US     Environment: Indoor/Outdoor
                Channels [1 - 11] @ 30 dBm
        ERP: <no flags>
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        BSS Load:
                 * station count: 2
                 * channel utilisation: 37/255
                 * available admission capacity: 0 [*32us]
        HT capabilities:
                Capabilities: 0x1ee
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 3839 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: No restriction (0x00)
                HT TX/RX MCS rate indexes supported: 0-15
        HT operation:
                 * primary channel: 11
                 * secondary channel offset: no secondary
                 * STA channel width: 20 MHz
                 * RIFS: 0
                 * HT protection: no
                 * non-GF present: 1
                 * OBSS non-GF present: 0
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        Extended capabilities: Extended Channel Switching, QoS Map, UTF-8 SSID, 6
        WMM:     * Parameter version 1
                 * u-APSD
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec

Compare to that from my Linksys EA8500

BSS 14:91:82:6d:18:76(on wlan0)
        last seen: 4780578.477s [boottime]
        TSF: 0 usec (0d, 00:00:00)
        freq: 2412
        beacon interval: 100 TUs
        capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431)
        signal: -33.00 dBm
        last seen: 10 ms ago
        SSID: MyPlace
        Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0
        DS Parameter set: channel 1
        ERP: <no flags>
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        HT capabilities:
                Capabilities: 0x19ef
                        RX LDPC
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 8 usec (0x06)
                HT TX/RX MCS rate indexes supported: 0-31
        HT operation:
                 * primary channel: 1
                 * secondary channel offset: above
                 * STA channel width: any
                 * RIFS: 0
                 * HT protection: 20 MHz
                 * non-GF present: 1
                 * OBSS non-GF present: 0
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        Extended capabilities: Extended Channel Switching, SSID List, 6
        WMM:     * Parameter version 1
                 * BE: CW 15-1023, AIFSN 3, TXOP 2048 usec
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec

So my MT7603 reports No DSSS/CCK HT40 capability, forcing all STAs to use HT20. The proof is that my TP-Link RE220v3 (MT7603 + MT7610E) is capable of doing DSSS/CCK HT40 and the upstrem mt76 driver does not turn it on.

BSS 6c:5a:b0:82:15:62(on wlan0)
        last seen: 4782057.879s [boottime]
        TSF: 0 usec (0d, 00:00:00)
        freq: 2417
        beacon interval: 100 TUs
        capability: ESS ShortSlotTime RadioMeasure (0x1401)
        signal: -38.00 dBm
        last seen: 10 ms ago
        SSID: TP-Link_Extender
        Supported rates: 1.0* 2.0* 5.5* 11.0* 9.0 18.0 36.0 54.0
        DS Parameter set: channel 2
        ERP: Barker_Preamble_Mode
        Extended supported rates: 6.0 12.0 24.0 48.0
        HT capabilities:
                Capabilities: 0x106e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 3839 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 4 usec (0x05)
                HT RX MCS rate indexes supported: 0-15, 32
                HT TX MCS rate indexes are undefined
        HT operation:
                 * primary channel: 2
                 * secondary channel offset: above
                 * STA channel width: any
                 * RIFS: 0
                 * HT protection: 20 MHz
                 * non-GF present: 1
                 * OBSS non-GF present: 0
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        Extended capabilities: BSS Transition
        BSS Load:
                 * station count: 1
                 * channel utilisation: 46/255
                 * available admission capacity: 31250 [*32us]
        WMM:     * Parameter version 1
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec
        TPC report: TX power: 19 dBm
        Overlapping BSS scan params:
                 * passive dwell: 20 TUs
                 * active dwell: 10 TUs
                 * channel width trigger scan interval: 300 s
                 * scan passive total per channel: 200 TUs
                 * scan active total per channel: 20 TUs
                 * BSS width channel transition delay factor: 5
                 * OBSS Scan Activity Threshold: 0.25 %
        Country: US     Environment: Indoor/Outdoor
                Channels [1 - 11] @ 16 dBm
DragonBluep commented 2 years ago

Have you tried checking "Force 40Mhz" in LuCI or add option noscan '1' to /etc/config/wireless?

chinghanyu commented 2 years ago

@DragonBluep , "Force 40 MHz" does not help.

Here is where OpenWRT driver sets the HT compatibilities https://github.com/openwrt/mt76/blob/a666d5637bc3afd3e310be09fac048906560097b/mac80211.c#L309 and here is that in the GPL driver https://github.com/openwrt/mtk-wifi-gpl/blob/5e8dae211cb1b9f30dd3e7281cb8fab434a5483f/mgmt/mgmt_ht.c#L296

I managed to add IEEE80211_HT_CAP_DSSSCCK40, making my Archer C20v5 to broadcast DSSS/CCK HT40 but it does not help, either. Also, I noticed my laptop with a Intel Wireless 6205N (802.11abgn, no ac) card cannot connect to MT7610E at HT40, it only reports HT20. I start thinking that the MT40 setting is broken across many chips.

After a closer look, I think I might find the problem. OpenWRT driver dose not set the secondary channel offset

OpenWRT mt76 driver
                 * primary channel: 11
                 * secondary channel offset: no secondary

whereas the GPL driver and ath9k driver all specify the secondary channel

ath9k driver:
                 * primary channel: 1
                 * secondary channel offset: above
MTK GPL driver:
                 * primary channel: 2
                 * secondary channel offset: above

This results in STA having no idea to find the secondary channel, which is necessary to enabling HT40, so they can only associate the AP with HT20.

Update: manually setting htmode to HT40- changes broadcast message and is effective. My original setting was channel 11 and HT40, all the devices could only run at HT20; after setting it to HT40-, some devices were able to do HT40 and I saw * secondary channel offset: below in the scan result; I changed it back to HT40 but still saw * secondary channel offset: below in the scan result. This suggests if htmode is set to HT40, the driver does nothing. However, the driver should actually set it to above/below based on valid combinations.

Update2: confirmed after the HT40-/HT40 toggling, many new 802.11n/ac devices can do HT40 in 2.4 GHz band now but old 802.11abgn devices can still do HT20, even if they have 2 antenna. I think this can be solved by fixing the HT capability broadcast.

chinghanyu commented 2 years ago

See detail instructions for .11n settings at https://openwrt.org/docs/guide-user/network/wifi/basic#htmodewi-fi_channel_width

chinghanyu commented 2 years ago

I think the secondary channel offset routine is completely missing in OpenWRT driver, which can be found in the GPL driver at https://github.com/openwrt/mtk-wifi-gpl/blob/5e8dae211cb1b9f30dd3e7281cb8fab434a5483f/mgmt/mgmt_ht.c#L294

Update: same feature for MT76x0 and MT76x2 can be found at https://github.com/openwrt/mt76/blob/4e22f0dc934b8438f3a29fe7c41e8bb74eec057d/mt76x02_phy.c#L150 but this is not referred by and MT7603 code.

chinghanyu commented 2 years ago

After a deep look. OpenWRT's mt76 driver dose nothing wrong but it is difficult for some device to run at HT40 in 2.4 GHz band. Sorry for the false alarm.