]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wifi-scripts: fix HE Operation IE parsing in iwinfo scan
authorJohn Crispin <john@phrozen.org>
Tue, 17 Mar 2026 10:37:00 +0000 (11:37 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 24 Jun 2026 09:21:28 +0000 (11:21 +0200)
cell.he was only populated when the 6 GHz Operation Information
sub-element was parsed, making HE invisible to scan results on
2.4/5 GHz bands. Fix this by setting cell.he unconditionally when
HE Operation IE (Extension Element 36) is seen.

Gate 6 GHz channel width parsing on cell.band rather than the HE
Operation Parameters bit field, which proved unreliable on MediaTek
firmware. Fix flag byte offsets in the 6 GHz path: VHT Oper Info
Present (BIT 14) and Co-Hosted BSS (BIT 15) are in byte 1 of
he_oper_params which maps to ext[2], not ext[1].

For non-6GHz bands, derive channel width from the already-parsed
VHT/HT Operation IEs instead of leaving cell.he empty.

Signed-off-by: John Crispin <john@phrozen.org>
package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc

index c56026f10453bc4660f9fef9e73c6d6c4ab4c2a8..2cea4c543001191e670fe729ac7144c55be1a887 100644 (file)
@@ -533,22 +533,27 @@ function scan_extension(ext, cell) {
 
        switch(ord(ext, 0)) {
        case 36:
-               let offset = 7;
-
-               if (!(ord(ext, 3) & 0x2))
-                       break;
-
-               if (ord(ext, 2) & 0x40)
-                       offset += 3;
-
-               if (ord(ext, 2) & 0x80)
-                       offset += 1;
-
-               cell.he = {
-                       chan_width: eht_chan_width[ord(ext, offset + 1) & 0x3],
-                       center_chan_1: ord(ext, offset + 2),
-                       center_chan_2: ord(ext, offset + 3),
-               };
+               cell.he = {};
+
+               if (cell.band == '6') {
+                       let offset = 7;
+
+                       if (ord(ext, 2) & 0x40)
+                               offset += 3;
+
+                       if (ord(ext, 2) & 0x80)
+                               offset += 1;
+
+                       cell.he.chan_width = eht_chan_width[ord(ext, offset + 1) & 0x3];
+                       cell.he.center_chan_1 = ord(ext, offset + 2);
+                       cell.he.center_chan_2 = ord(ext, offset + 3);
+               } else if (cell.vht) {
+                       cell.he.chan_width = cell.vht.chan_width;
+                       cell.he.center_chan_1 = cell.vht.center_chan_1;
+                       cell.he.center_chan_2 = cell.vht.center_chan_2;
+               } else if (cell.ht) {
+                       cell.he.chan_width = cell.ht.chan_width;
+               }
                break;
 
        case 106: