From nobody Sun Feb 8 02:26:06 2026 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3421B1F2BAD for ; Fri, 2 May 2025 19:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746215052; cv=none; b=h9UdwS3sKzHVIH2oAj/KnZyYOGcQjiBMJ/3bNC/dcBuJozXPFYOMYhNPLcrnRwmYvSz4aoZjG0QSHLvz9VQLSkDp7d667dDV6V+sP3NmxdLKMr//B4JF/adqYX7gdnWJq3HKeJMoFqDL2x1IdAgJmJeY8V/4GeRBovky/F7PWW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746215052; c=relaxed/simple; bh=u7M8GWj4IaX6mHqj2i5wR0WVsdjlkUXEkduLTA39lkM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=srGMgqALQoT3qNaOCho5C78VbFb8fageoTzDSz9IKjs1yTzGrRkfV0WAtEf2TYtowo+lG+n3KCT4SVSPG7y48eOipGBTzpn8NBDBH/KSN6Uh8b7jRBgVmh/I+Ah/Ba5A4d1W9SUejjsj3w4+HF2wrgQmuk/XFo+H36euyvJSFXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b=N/8AKUe6; arc=none smtp.client-ip=212.77.101.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b="N/8AKUe6" Received: (wp-smtpd smtp.wp.pl 515 invoked from network); 2 May 2025 21:44:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=20241105; t=1746215047; bh=M8iujvxQGOpd8snMonMxwTWSoEQvZ8kYbB55eRI/Mo0=; h=From:To:Cc:Subject; b=N/8AKUe6Injy9Ohy5Wkyyu/L+NPlcfznrBAkLB8+T9oV+0O+5Vn9y6Nap6W+piWxk fXoabanY3CIrc+3IHpmAQUNZOMnT1mjFqdR+rorFGs9zaJ8skIsKPs3RS73sFr/vZq /Gys/YVPdza1NRBe/68jItaqRypxg6Gc3Nm2iThM9aRpxGLmdQ42yNioZbgRgLKXbF Cbh8Hu9ta/9V8GXXir2lUYnzM6Q/S0czV3LOJ35dDLqXMwAw110wugXnjCImLOtmZo hUu3+jys4dwBeyevSYmq0Ov9j2WxWSLjrZR937ijgSFSNjGfJz/6/ri8Q1K6VSZSWp XZT93LH+6cXyQ== Received: from 83.5.150.21.ipv4.supernova.orange.pl (HELO laptop-olek.home) (olek2@wp.pl@[83.5.150.21]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 2 May 2025 21:44:07 +0200 From: Aleksander Jan Bajkowski To: johannes.berg@intel.com, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Aleksander Jan Bajkowski Subject: [PATCH iw,v2] iw: fix EHT capabilities on Big Endian platforms Date: Fri, 2 May 2025 21:44:05 +0200 Message-Id: <20250502194405.3489240-1-olek2@wp.pl> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-WP-DKIM-Status: good (id: wp.pl) X-WP-MailID: 2b1ff6474733ec445ba36c34ed366773 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 000000A [EcME] Content-Type: text/plain; charset="utf-8" IE fields are encoded in Little Endian and are not correctly printed on Big Endian platforms. Fixes: 5a71b722270c ("iw: Print local EHT capabilities") Signed-off-by: Aleksander Jan Bajkowski --- util.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/util.c b/util.c index c6d5974..9403528 100644 --- a/util.c +++ b/util.c @@ -1538,22 +1538,31 @@ static void __print_eht_capa(int band, unsigned int i; const char *pre =3D indent ? "\t" : ""; =20 - #define PRINT_EHT_CAP(_var, _idx, _bit, _str) \ + #define PRINT_EHT_MAC_CAP(_idx, _bit, _str) \ do { \ - if (_var[_idx] & BIT(_bit)) \ + if (mac_cap[_idx] & BIT(_bit)) \ printf("%s\t\t\t" _str "\n", pre); \ } while (0) =20 - #define PRINT_EHT_CAP_MASK(_var, _idx, _shift, _mask, _str) \ + #define PRINT_EHT_MAC_CAP_MASK(_idx, _shift, _mask, _str) \ do { \ - if ((_var[_idx] >> _shift) & _mask) \ - printf("%s\t\t\t" _str ": %d\n", pre, (_var[_idx] >> _shift) & _mask); \ + if ((mac_cap[_idx] >> _shift) & _mask) \ + printf("%s\t\t\t" _str ": %d\n", pre, \ + (mac_cap[_idx] >> _shift) & _mask); \ + } while (0) + + #define PRINT_EHT_PHY_CAP(_idx, _bit, _str) \ + do { \ + if (le32toh(phy_cap[_idx]) & BIT(_bit)) \ + printf("%s\t\t\t" _str "\n", pre); \ } while (0) =20 - #define PRINT_EHT_MAC_CAP(...) PRINT_EHT_CAP(mac_cap, __VA_ARGS__) - #define PRINT_EHT_MAC_CAP_MASK(...) PRINT_EHT_CAP_MASK(mac_cap, __VA_ARGS= __) - #define PRINT_EHT_PHY_CAP(...) PRINT_EHT_CAP(phy_cap, __VA_ARGS__) - #define PRINT_EHT_PHY_CAP_MASK(...) PRINT_EHT_CAP_MASK(phy_cap, __VA_ARGS= __) + #define PRINT_EHT_PHY_CAP_MASK(_idx, _shift, _mask, _str) \ + do { \ + if ((le32toh(phy_cap[_idx]) >> _shift) & _mask) \ + printf("%s\t\t\t" _str ": %d\n", pre, \ + (le32toh(phy_cap[_idx]) >> _shift) & _mask); \ + } while (0) =20 printf("%s\t\tEHT MAC Capabilities (0x", pre); for (i =3D 0; i < 2; i++) @@ -1627,7 +1636,7 @@ static void __print_eht_capa(int band, PRINT_EHT_PHY_CAP(2, 1, "Rx 4096-QAM In Wider Bandwidth DL OFDMA Supporte= d"); =20 if (!from_ap && - !(he_phy_cap[0] & ((BIT(1) | BIT(2) | BIT(3) | BIT(4)) << 8))) { + !(le16toh(he_phy_cap[0]) & ((BIT(1) | BIT(2) | BIT(3) | BIT(4)) << 8)= )) { static const char * const mcs[] =3D { "0-7", "8-9", "10-11", "12-13" }; =20 printf("%s\t\tEHT-MCS Map (20 Mhz Non-AP STA) (0x", pre); @@ -1649,8 +1658,9 @@ static void __print_eht_capa(int band, * If no Channel Width bits are set, but we are an AP, we use * this MCS logic also. */ - if (he_phy_cap[0] & ((BIT(1) | BIT(2)) << 8) || - (from_ap && !(he_phy_cap[0] & ((BIT(1) | BIT(2) | BIT(3) | BIT(4)) <= < 8)))) { + if (le16toh(he_phy_cap[0]) & ((BIT(1) | BIT(2)) << 8) || + (from_ap && !(le16toh(he_phy_cap[0]) & + ((BIT(1) | BIT(2) | BIT(3) | BIT(4)) << 8)))) { printf("%s\t\tEHT-MCS Map (BW <=3D 80) (0x", pre); for (i =3D 0; i < 3; i++) printf("%02x", ((__u8 *)mcs_set)[i]); @@ -1665,7 +1675,7 @@ static void __print_eht_capa(int band, } mcs_set +=3D 3; =20 - if (he_phy_cap[0] & (BIT(3) << 8)) { + if (le16toh(he_phy_cap[0]) & (BIT(3) << 8)) { printf("%s\t\tEHT-MCS Map (BW =3D 160) (0x", pre); for (i =3D 0; i < 3; i++) printf("%02x", ((__u8 *)mcs_set)[i]); @@ -1680,7 +1690,7 @@ static void __print_eht_capa(int band, } =20 mcs_set +=3D 3; - if (band =3D=3D NL80211_BAND_6GHZ && (phy_cap[0] & BIT(1))) { + if (band =3D=3D NL80211_BAND_6GHZ && (le32toh(phy_cap[0]) & BIT(1))) { printf("%s\t\tEHT-MCS Map (BW =3D 320) (0x", pre); for (i =3D 0; i < 3; i++) printf("%02x", ((__u8 *)mcs_set)[i]); @@ -1695,7 +1705,7 @@ static void __print_eht_capa(int band, } } =20 - if (ppet && ppet_len && (phy_cap[1] & BIT(11))) { + if (ppet && ppet_len && (le32toh(phy_cap[1]) & BIT(11))) { printf("%s\t\tEHT PPE Thresholds ", pre); for (i =3D 0; i < ppet_len; i++) if (ppet[i]) --=20 2.39.5