From patchwork Tue Apr 20 16:04:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1468393 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=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.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=desiato.20200630 header.b=Tfqanmd8; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4FPpVM0y17z9vDc for ; Wed, 21 Apr 2021 02:07:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=lvEgxzBmERVzbBDyY8Q8xNLe5fgKyp+0DBRiM3XvqyA=; b=Tfqanmd8YJgB8/ lXFvJ59+fahzd1zdhUzhXLgYmg5nG3uJPKFVVqV5MKMT/K/nOcHNiaS7Yk4IdTqqv1iymC2F9GE30 Ogt5qG3STR5DFD8/R2NsjMpSYM7yV9ZtalCN0XgkVx0SEYK+9dmjXWGB8CLlQVh+4HZrX77usMLiz XQ+wMriTGtGi6GFXA1Ua/TVR+teBqEpEwuCyARsTRd2z+lsixdExZu3p4Ntu/XRQh/gm08wKQGzBU 0dDXMcWEUsdg9pPzmgDG732U4mqxL5w7wCtwecUnSnygbm7c9t81mQv3QUEFvOitftEK39opoZPuf EYH39SdkU0HQDtvoSAwQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYssL-00CXPT-MZ; Tue, 20 Apr 2021 16:05:21 +0000 Received: from perseus.uberspace.de ([95.143.172.134]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYssH-00CXO2-4f for openwrt-devel@lists.openwrt.org; Tue, 20 Apr 2021 16:05:19 +0000 Received: (qmail 31587 invoked from network); 20 Apr 2021 16:05:05 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by perseus.uberspace.de with SMTP; 20 Apr 2021 16:05:05 -0000 From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/2] iwinfo: nl80211: perform split wiphy dump Date: Tue, 20 Apr 2021 18:04:53 +0200 Message-Id: <20210420160454.29660-1-mail@david-bauer.net> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_170517_265585_336AE4F0 X-CRM114-Status: GOOD ( 14.81 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Perform a split wiphy dump when acquiring the hw modelist of a mac80211 device. Otherwise HE capabilities are missing from the message. This is necessary since upstream commit f8d504caa ("nl80211: reduce non-split wiphy dump size") (Kernel 5.9). Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [95.143.172.134 listed in list.dnswl.org] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 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 Perform a split wiphy dump when acquiring the hw modelist of a mac80211 device. Otherwise HE capabilities are missing from the message. This is necessary since upstream commit f8d504caa ("nl80211: reduce non-split wiphy dump size") (Kernel 5.9). Signed-off-by: David Bauer --- iwinfo_nl80211.c | 188 +++++++++++++++++++++++++++-------------------- 1 file changed, 110 insertions(+), 78 deletions(-) diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 6e79ec8..aeff778 100644 --- a/iwinfo_nl80211.c +++ b/iwinfo_nl80211.c @@ -2941,8 +2941,73 @@ struct nl80211_modes bool ok; uint32_t hw; uint32_t ht; + + uint32_t nl_freq; + uint16_t nl_ht; + uint32_t nl_vht; + uint16_t he_phy_cap[6]; }; +static int nl80211_eval_modelist(struct nl80211_modes *m) +{ + /* Treat any nonzero capability as 11n */ + if (m->nl_ht > 0) + { + m->hw |= IWINFO_80211_N; + m->ht |= IWINFO_HTMODE_HT20; + + if (m->nl_ht & (1 << 1)) + m->ht |= IWINFO_HTMODE_HT40; + } + + if (m->he_phy_cap[0] != 0) { + m->hw |= IWINFO_80211_AX; + m->ht |= IWINFO_HTMODE_HE20; + + if (m->he_phy_cap[0] & BIT(9)) + m->ht |= IWINFO_HTMODE_HE40; + if (m->he_phy_cap[0] & BIT(10)) + m->ht |= IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80; + if (m->he_phy_cap[0] & BIT(11)) + m->ht |= IWINFO_HTMODE_HE160; + if (m->he_phy_cap[0] & BIT(12)) + m->ht |= IWINFO_HTMODE_HE160 | IWINFO_HTMODE_HE80_80; + } + + if (m->nl_freq < 2485) + { + m->hw |= IWINFO_80211_B; + m->hw |= IWINFO_80211_G; + } + else if (m->nl_vht) + { + /* Treat any nonzero capability as 11ac */ + if (m->nl_vht > 0) + { + m->hw |= IWINFO_80211_AC; + m->ht |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80; + + switch ((m->nl_vht >> 2) & 3) + { + case 2: + m->ht |= IWINFO_HTMODE_VHT80_80; + /* fall through */ + + case 1: + m->ht |= IWINFO_HTMODE_VHT160; + } + } + } + else if (m->nl_freq >= 56160) + { + m->hw |= IWINFO_80211_AD; + } + else if (!(m->hw & IWINFO_80211_AC)) + { + m->hw |= IWINFO_80211_A; + } +} + static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg) { struct nl80211_modes *m = arg; @@ -2962,94 +3027,43 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg) nla_data(band), nla_len(band), NULL); if (bands[NL80211_BAND_ATTR_HT_CAPA]) - caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]); + m->nl_ht = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]); - /* Treat any nonzero capability as 11n */ - if (caps > 0) - { - m->hw |= IWINFO_80211_N; - m->ht |= IWINFO_HTMODE_HT20; - - if (caps & (1 << 1)) - m->ht |= IWINFO_HTMODE_HT40; - } + if (bands[NL80211_BAND_ATTR_VHT_CAPA]) + m->nl_vht = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]); 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], + if (len > sizeof(m->he_phy_cap) - 1) + len = sizeof(m->he_phy_cap) - 1; + memcpy(&((__u8 *)m->he_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) - { - nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, - nla_data(freq), nla_len(freq), NULL); - - if (!freqs[NL80211_FREQUENCY_ATTR_FREQ]) - continue; - - if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485) - { - m->hw |= IWINFO_80211_B; - m->hw |= IWINFO_80211_G; - } - else if (bands[NL80211_BAND_ATTR_VHT_CAPA]) + if (bands[NL80211_BAND_ATTR_FREQS]) { + nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS], + freqs_remain) { - vht_caps = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]); + nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX, + nla_data(freq), nla_len(freq), NULL); - /* Treat any nonzero capability as 11ac */ - if (vht_caps > 0) - { - m->hw |= IWINFO_80211_AC; - m->ht |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80; - - switch ((vht_caps >> 2) & 3) - { - case 2: - m->ht |= IWINFO_HTMODE_VHT80_80; - /* fall through */ - - case 1: - m->ht |= IWINFO_HTMODE_VHT160; - } - } - } - else if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) >= 56160) - { - m->hw |= IWINFO_80211_AD; - } - else if (!(m->hw & IWINFO_80211_AC)) - { - m->hw |= IWINFO_80211_A; + if (!freqs[NL80211_FREQUENCY_ATTR_FREQ]) + continue; + + m->nl_freq = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]); } } } @@ -3062,20 +3076,29 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg) static int nl80211_get_hwmodelist(const char *ifname, int *buf) { - struct nl80211_modes m = { 0 }; + struct nl80211_msg_conveyor *cv; + struct nl80211_modes m = {}; + uint32_t features = nl80211_get_protocol_features(ifname); + int flags; - if (nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0, - nl80211_get_modelist_cb, &m)) + flags = features & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP ? NLM_F_DUMP : 0; + cv = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, flags); + if (!cv) goto out; - if (!m.ok) - goto out; + NLA_PUT_FLAG(cv->msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); + if (nl80211_send(cv, nl80211_get_modelist_cb, &m)) + goto nla_put_failure; + + nl80211_eval_modelist(&m); *buf = m.hw; + return 0; +nla_put_failure: + nl80211_free(cv); out: - *buf = 0; return -1; } @@ -3150,20 +3173,29 @@ static int nl80211_get_htmode(const char *ifname, int *buf) static int nl80211_get_htmodelist(const char *ifname, int *buf) { - struct nl80211_modes m = { 0 }; + struct nl80211_msg_conveyor *cv; + struct nl80211_modes m = {}; + uint32_t features = nl80211_get_protocol_features(ifname); + int flags; - if (nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0, - nl80211_get_modelist_cb, &m)) + flags = features & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP ? NLM_F_DUMP : 0; + cv = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, flags); + if (!cv) goto out; - if (!m.ok) - goto out; + NLA_PUT_FLAG(cv->msg, NL80211_ATTR_SPLIT_WIPHY_DUMP); + if (nl80211_send(cv, nl80211_get_modelist_cb, &m)) + goto nla_put_failure; + + nl80211_eval_modelist(&m); *buf = m.ht; + return 0; +nla_put_failure: + nl80211_free(cv); out: - *buf = 0; return -1; } From patchwork Tue Apr 20 16:04:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1468394 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=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.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=desiato.20200630 header.b=PpvW214t; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4FPpVR0GJyz9vDc for ; Wed, 21 Apr 2021 02:07:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=e6Y90pYBnspx36tefyeWgwZn1AX9yC+KrtA3QFR0dS0=; b=PpvW214tRD337JpN/+czKesqk jTW2tdx+YEFCao2g4b3txGkW0ugZdLA8uJ0vsWxzBfm4E+facs3a1FR3DBCAh0/68GIOYuc53k0k8 5Ceupb/E6vRbkQsiG9Lw3dM/LwISDGbS2iPN5WL7Vy7LZ1W0vm+xk3TJDa8z303oLQU0r9iSsaaYJ D6MARfgTlQkbz/zU9BOgevFZePvgU7IC/dDR7hE46HOuxtMRLlDD+1tDfPB9NnmqNtFHAZkYDKQ2H 3qzgMhkhzSoeHnSLZiuUUH4UE/XKOTrSt2pbtRe5tD6oCGCzhj7JL8aBEs6ZftJJkXJHicAQy5624 aP3f4go7Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYssS-00CXQh-Va; Tue, 20 Apr 2021 16:05:29 +0000 Received: from perseus.uberspace.de ([95.143.172.134]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYssH-00CXO3-5z for openwrt-devel@lists.openwrt.org; Tue, 20 Apr 2021 16:05:19 +0000 Received: (qmail 32059 invoked from network); 20 Apr 2021 16:05:06 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by perseus.uberspace.de with SMTP; 20 Apr 2021 16:05:06 -0000 From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/2] iwinfo: cli: fix hwmode formatting Date: Tue, 20 Apr 2021 18:04:54 +0200 Message-Id: <20210420160454.29660-2-mail@david-bauer.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210420160454.29660-1-mail@david-bauer.net> References: <20210420160454.29660-1-mail@david-bauer.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_170517_343500_14688F10 X-CRM114-Status: UNSURE ( 6.69 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The placeholder for the 802.11ax hwmode was missing. Signed-off-by: David Bauer --- iwinfo_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iwinfo_cli.c b/iwinfo_cli.c index ee5a0e2..82b409c 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -274, 12 +274,12 @@ static char * format_encryption(struct iwinfo_crypto_entry *c) Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [95.143.172.134 listed in list.dnswl.org] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 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 The placeholder for the 802.11ax hwmode was missing. Signed-off-by: David Bauer --- iwinfo_cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iwinfo_cli.c b/iwinfo_cli.c index ee5a0e2..82b409c 100644 --- a/iwinfo_cli.c +++ b/iwinfo_cli.c @@ -274,12 +274,12 @@ static char * format_encryption(struct iwinfo_crypto_entry *c) static char * format_hwmodes(int modes) { - static char buf[15]; + static char buf[17]; if (modes <= 0) snprintf(buf, sizeof(buf), "unknown"); else - snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s%s", + snprintf(buf, sizeof(buf), "802.11%s%s%s%s%s%s%s", (modes & IWINFO_80211_A) ? "a" : "", (modes & IWINFO_80211_B) ? "b" : "", (modes & IWINFO_80211_G) ? "g" : "",