From patchwork Wed Feb 3 19:20:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1435578 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Cl0SNK9e; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DWBQF0n6Xz9tlJ for ; Thu, 4 Feb 2021 06:22:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=b1cH7KbI/Yq0RmC9cN4SPvatdK9Zx8rAsmwbq2ETG1A=; b=Cl0SNK9eHnTYLd9VI4iVDEj0Ez Sk899rEzzb0Nxj4RpAaZiSz8pBve2zsgZY0y5Tmd1+VWmB1jtZaUl3K3uIDoFG+7ty/t4P7Tf8EfZ j/5vC62kKlNQ2grmBovyIljVDWeksvg7WkWIfEKSdl0cAckvPzXeYtH2kKyOcopmMKkkqvWd+x5f4 f04mXMyT1vgjaZJLGGABpQKKC7idPSjtE+859DqmDA+lT5bTYSwHtsDUZlbH/fDT9Zjv14ggNVrO4 bTqcLFTCXQSZU1dJ1UsdXo6NMTNe1HPn/CPzhXH2FHbfIloMBAnRyKv/Pbb9CM2E3vB3s8S+E+Sf9 BQXQO2Kw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7Nhh-0000Bu-90; Wed, 03 Feb 2021 19:20:41 +0000 Received: from mars.blocktrron.ovh ([2001:41d0:401:3000::cbd] helo=mail.blocktrron.ovh) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7Nhc-0000AC-Tt for openwrt-devel@lists.openwrt.org; Wed, 03 Feb 2021 19:20:38 +0000 Received: from localhost.localdomain (p200300e53f08060015c942f5c963d2bc.dip0.t-ipconnect.de [IPv6:2003:e5:3f08:600:15c9:42f5:c963:d2bc]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.blocktrron.ovh (Postfix) with ESMTPSA id 87DC31E729 for ; Wed, 3 Feb 2021 20:20:20 +0100 (CET) From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH iwinfo] iwinfo: add basic IEEE 802.11ax support Date: Wed, 3 Feb 2021 20:20:11 +0100 Message-Id: <20210203192011.256391-1-mail@david-bauer.net> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210203_142037_188210_42388E6F X-CRM114-Status: GOOD ( 15.92 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This adds basic support for IEEE 802.11ax when requesting HW or HT Modelist for a PHY from iwinfo. This way, applications using iwinfo can detect HE phys. Signed-off-by: David Bauer --- api/nl80211.h | 38 ++++++++++++++++++++++++++++++++++++++ include/iwinfo.h | 8 +++++++- iwinfo_cli.c | 3 ++- iwinfo_lib.c | 7 ++++++- iwinfo_lua.c | 3 +++ iwinfo_nl80211.c | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 3 deletions(-) diff --git a/api/nl80211.h b/api/nl80211.h index 5b7b5eb..3d252e4 100644 --- a/api/nl80211.h +++ b/api/nl80211.h @@ -2582,6 +2582,41 @@ enum nl80211_mpath_info { NL80211_MPATH_INFO_MAX = __NL80211_MPATH_INFO_AFTER_LAST - 1 }; +/** + * enum nl80211_band_iftype_attr - Interface type data attributes + * + * @__NL80211_BAND_IFTYPE_ATTR_INVALID: attribute number 0 is reserved + * @NL80211_BAND_IFTYPE_ATTR_IFTYPES: nested attribute containing a flag attribute + * for each interface type that supports the band data + * @NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC: HE MAC capabilities as in HE + * capabilities IE + * @NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY: HE PHY capabilities as in HE + * capabilities IE + * @NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET: HE supported NSS/MCS as in HE + * capabilities IE + * @NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE: HE PPE thresholds information as + * defined in HE capabilities IE + * @NL80211_BAND_IFTYPE_ATTR_MAX: highest band HE capability attribute currently + * defined + * @NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA: HE 6GHz band capabilities (__le16), + * given for all 6 GHz band channels + * @__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST: internal use + */ +enum nl80211_band_iftype_attr { + __NL80211_BAND_IFTYPE_ATTR_INVALID, + + NL80211_BAND_IFTYPE_ATTR_IFTYPES, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET, + NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE, + NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA, + + /* keep last */ + __NL80211_BAND_IFTYPE_ATTR_AFTER_LAST, + NL80211_BAND_IFTYPE_ATTR_MAX = __NL80211_BAND_IFTYPE_ATTR_AFTER_LAST - 1 +}; + /** * enum nl80211_band_attr - band attributes * @__NL80211_BAND_ATTR_INVALID: attribute number 0 is reserved @@ -2597,6 +2632,8 @@ enum nl80211_mpath_info { * @NL80211_BAND_ATTR_VHT_MCS_SET: 32-byte attribute containing the MCS set as * defined in 802.11ac * @NL80211_BAND_ATTR_VHT_CAPA: VHT capabilities, as in the HT information IE + * @NL80211_BAND_ATTR_IFTYPE_DATA: nested array attribute, with each entry using + * attributes from &enum nl80211_band_iftype_attr * @NL80211_BAND_ATTR_MAX: highest band attribute currently defined * @__NL80211_BAND_ATTR_AFTER_LAST: internal use */ @@ -2612,6 +2649,7 @@ enum nl80211_band_attr { NL80211_BAND_ATTR_VHT_MCS_SET, NL80211_BAND_ATTR_VHT_CAPA, + NL80211_BAND_ATTR_IFTYPE_DATA, /* keep last */ __NL80211_BAND_ATTR_AFTER_LAST, diff --git a/include/iwinfo.h b/include/iwinfo.h index 5e64294..d1753ef 100644 --- a/include/iwinfo.h +++ b/include/iwinfo.h @@ -29,6 +29,7 @@ #define IWINFO_80211_N (1 << 3) #define IWINFO_80211_AC (1 << 4) #define IWINFO_80211_AD (1 << 5) +#define IWINFO_80211_AX (1 << 6) #define IWINFO_CIPHER_NONE (1 << 0) #define IWINFO_CIPHER_WEP40 (1 << 1) @@ -89,8 +90,13 @@ enum iwinfo_htmode { IWINFO_HTMODE_VHT80_80 = (1 << 5), IWINFO_HTMODE_VHT160 = (1 << 6), IWINFO_HTMODE_NOHT = (1 << 7), + IWINFO_HTMODE_HE20 = (1 << 8), + IWINFO_HTMODE_HE40 = (1 << 9), + IWINFO_HTMODE_HE80 = (1 << 10), + IWINFO_HTMODE_HE80_80 = (1 << 11), + IWINFO_HTMODE_HE160 = (1 << 12), - IWINFO_HTMODE_COUNT = 8 + IWINFO_HTMODE_COUNT = 13 }; extern const char *IWINFO_HTMODE_NAMES[IWINFO_HTMODE_COUNT]; diff --git a/iwinfo_cli.c b/iwinfo_cli.c index 0332bc2..c18ea49 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -282,7 +282,8 @@ static char * format_hwmodes(int modes) (modes & IWINFO_80211_G) ? "g" : "", (modes & IWINFO_80211_N) ? "n" : "", (modes & IWINFO_80211_AC) ? "ac" : "", - (modes & IWINFO_80211_AD) ? "ad" : ""); + (modes & IWINFO_80211_AD) ? "ad" : "", + (modes & IWINFO_80211_AX) ? "ax" : ""); return buf; } diff --git a/iwinfo_lib.c b/iwinfo_lib.c index 7a33a35..70b080c 100644 --- a/iwinfo_lib.c +++ b/iwinfo_lib.c @@ -65,7 +65,12 @@ const char *IWINFO_HTMODE_NAMES[] = { "VHT80", "VHT80+80", "VHT160", - "NOHT" + "NOHT", + "HE20", + "HE40", + "HE80", + "HE80+80", + "HE160" }; diff --git a/iwinfo_lua.c b/iwinfo_lua.c index 58a5537..652633b 100644 --- a/iwinfo_lua.c +++ b/iwinfo_lua.c @@ -527,6 +527,9 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *)) lua_pushboolean(L, hwmodes & IWINFO_80211_AD); lua_setfield(L, -2, "ad"); + lua_pushboolean(L, hwmodes & IWINFO_80211_AX); + lua_setfield(L, -2, "ax"); + return 1; } diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 2b2a043..8b13782 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -2887,6 +2887,40 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg) m->ht |= IWINFO_HTMODE_HT40; } + if (bands[NL80211_BAND_ATTR_IFTYPE_DATA]) { + struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1]; + uint16_t phy_cap[6] = { 0 }; + struct nlattr *nl_iftype; + int rem_band; + int len; + + m->hw |= IWINFO_80211_AX; + m->ht |= IWINFO_HTMODE_HE20; + + nla_for_each_nested(nl_iftype, bands[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band) { + nla_parse(tb, NL80211_BAND_IFTYPE_ATTR_MAX, + nla_data(nl_iftype), nla_len(nl_iftype), NULL); + if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]) { + len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]); + + if (len > sizeof(phy_cap) - 1) + len = sizeof(phy_cap) - 1; + memcpy(&((__u8 *)phy_cap)[1], + nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]), + len); + } + + if (phy_cap[0] & BIT(9)) + m->ht |= IWINFO_HTMODE_HE40; + if (phy_cap[0] & BIT(10)) + m->ht |= IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80; + if (phy_cap[0] & BIT(11)) + m->ht |= IWINFO_HTMODE_HE160; + if (phy_cap[0] & BIT(12)) + m->ht |= IWINFO_HTMODE_HE160 | IWINFO_HTMODE_HE80_80; + } + } + nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], freqs_remain) {