From patchwork Wed Nov 18 03:39:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 11913821 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 978F5138B for ; Wed, 18 Nov 2020 03:42:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7221420867 for ; Wed, 18 Nov 2020 03:42:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ncH0FAie" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726544AbgKRDmS (ORCPT ); Tue, 17 Nov 2020 22:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgKRDmS (ORCPT ); Tue, 17 Nov 2020 22:42:18 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D4B0C0613D4 for ; Tue, 17 Nov 2020 19:42:17 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id q10so565553pfn.0 for ; Tue, 17 Nov 2020 19:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cQEG9lGjRyun+NVxBQxKRLJCfXxOi94FoslIBSyCrw8=; b=ncH0FAieyWAoMh5s0sdFfGDjcaffhIFAtiFHIBrm8mtVleG72qMgfrqeTuCP4lP8Tf MEEz1pQEsMo/Xkty1uS6wGSwb/gVSpQZe6WxA4T1J9hhYcrtID9nmTM3GjDuNPWuonJk W/kEDRKgGuPbqzsQLjCo2zFgSbje64uousP3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cQEG9lGjRyun+NVxBQxKRLJCfXxOi94FoslIBSyCrw8=; b=DVq4XXR/X1R3vwvbrAl8MP56icUt3zsIVwgquE8wMZdtyTEPtMSaP5u2NChAQKVHwq Gd3dk4Aw9OUP6UzzxBNvzXxrqOlIlgSYFZvM521GqHerJbx3BCYFxjQJpYjuHtG2j53f yNkIMN3D6qhxgXizYSjd614NjtxT2a1oTcEQKNCLCGfAU8urfWlHqtgP+Kk6JwHzMl5V 1G1JwRNHzekw45ubvwG1tqJJlaRFERdQdVSilql+KrDpzsFtrcfKJ6MlEr5uqbpyaePr Zw2ofrln+OrsYfiHedopg0QSTHEqoeSdp7wDD33Lv7CUga7LWTPP5Q8tzpop63/Cv5vy 9P+Q== X-Gm-Message-State: AOAM5336FUSPGQlhe7mNr871Cn7echo/lWEinNDIfCOhF/eRx0q+bnuC yCVNOvtpJ7fDftoXaO7B+bSZAw== X-Google-Smtp-Source: ABdhPJzV3zte1JhSqqODElM1DggxOI/hkTdjU8slbRR9OX5zeeRKnC+xGhOI5qy7aJmcvnDizScs/w== X-Received: by 2002:a05:6a00:c:b029:18b:eae3:bff0 with SMTP id h12-20020a056a00000cb029018beae3bff0mr2506827pfk.9.1605670936641; Tue, 17 Nov 2020 19:42:16 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:8edc:d4ff:fe53:350d]) by smtp.gmail.com with ESMTPSA id w2sm16097617pfb.104.2020.11.17.19.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 19:42:15 -0800 (PST) From: Brian Norris To: Johannes Berg Cc: linux-wireless@vger.kernel.org, David Poole , Ben Greear , John Crispin , Brian Norris Subject: [PATCH 1/4] iw: scan: add extension tag parsing Date: Tue, 17 Nov 2020 19:39:33 -0800 Message-Id: <20201118033936.3667788-2-briannorris@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201118033936.3667788-1-briannorris@chromium.org> References: <20201118033936.3667788-1-briannorris@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org HE IEs are part of the extension tag (ID 255). Signed-off-by: Brian Norris --- scan.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scan.c b/scan.c index 8c23483ecede..58a09983c5c7 100644 --- a/scan.c +++ b/scan.c @@ -2272,6 +2272,36 @@ static void print_vendor(unsigned char len, unsigned char *data, printf("\n"); } +static const struct ie_print ext_printers[] = { +}; + +static void print_extension(unsigned char len, unsigned char *ie, + bool unknown, enum print_ie_type ptype) +{ + unsigned char tag; + + if (len < 1) { + printf("\tExtension IE: \n"); + return; + } + + tag = ie[0]; + if (tag < ARRAY_SIZE(ext_printers) && ext_printers[tag].name && + ext_printers[tag].flags & BIT(ptype)) { + print_ie(&ext_printers[tag], tag, len - 1, ie + 1, NULL); + return; + } + + if (unknown) { + int i; + + printf("\tUnknown Extension ID (%d):", ie[0]); + for (i = 1; i < len; i++) + printf(" %.2x", ie[i]); + printf("\n"); + } +} + void print_ies(unsigned char *ie, int ielen, bool unknown, enum print_ie_type ptype) { @@ -2290,6 +2320,8 @@ void print_ies(unsigned char *ie, int ielen, bool unknown, ie[0], ie[1], ie + 2, &ie_buffer); } else if (ie[0] == 221 /* vendor */) { print_vendor(ie[1], ie + 2, unknown, ptype); + } else if (ie[0] == 255 /* extension */) { + print_extension(ie[1], ie + 2, unknown, ptype); } else if (unknown) { int i; From patchwork Wed Nov 18 03:39:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 11913823 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4057D174A for ; Wed, 18 Nov 2020 03:42:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12DE620BED for ; Wed, 18 Nov 2020 03:42:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="GGupgtpX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbgKRDmT (ORCPT ); Tue, 17 Nov 2020 22:42:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgKRDmT (ORCPT ); Tue, 17 Nov 2020 22:42:19 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C73C0613D4 for ; Tue, 17 Nov 2020 19:42:19 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id v21so262998pgi.2 for ; Tue, 17 Nov 2020 19:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/LaYu7vNqtmnOmBx1mzr8JcKAfCDfyUf5hKrbUfA630=; b=GGupgtpXB6A2CKTMckO7UvMDqEJlEMiDtSCk8Ef7E+vWeWl5ustxu43PGARLBFq0FO VwMQx0Sp4ETW0ctOT3KsMPem/v08/64O4qlYAbzylnEJ3bP5WIuP+fRxONnEqG1KpxCn RuuSKSZlWPqklPVE4F6LG34GT+hypuFPAqOJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/LaYu7vNqtmnOmBx1mzr8JcKAfCDfyUf5hKrbUfA630=; b=BRYb2OivrUa63wODThQKNvlPSWblyHUpEC9ZBBqttAZSRTwIMrSOxrgwpl3Nx7Yuyv dXnHyIu6UlrLoJpQwFdAFV4Z0QLfwqLGmWBrXIMEKOgKvIt2Ryxrl2VVA1z10t5qoRHb kmrVq3EKh0IXOeClbkZZRPW9zFd58NnNW/Z1439d/FB9wXreaoo02Gi3rVBeeqbTq5P6 Z5QYjrumO6ikvCSxeQO7C4aejXcd5PB0H5wTeNvyo29NS4QtxFEJisWjO6Isv35gVJVe ct8apMsE6MDmrpVb8JSrjL8q/HhHMJsws79WlJ6+mVVlz1Xp0GYtp4pRERh3nxop4k4o RmGw== X-Gm-Message-State: AOAM532ZXpPyfRyWkgnXGehQbui3Hx1Xx8KOHPeAaqmHEjFErBx2IGn7 UtiFF+2dL2w/QcAnaXd1I6ePsA== X-Google-Smtp-Source: ABdhPJw/9azfJ5ND8OZb1jndZDMbKNV6Ql1uII33VN60ga/PjSzueXjA/BfvjMEldTD/zhiKM4j+4Q== X-Received: by 2002:a63:c644:: with SMTP id x4mr6443717pgg.421.1605670938571; Tue, 17 Nov 2020 19:42:18 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:8edc:d4ff:fe53:350d]) by smtp.gmail.com with ESMTPSA id w2sm16097617pfb.104.2020.11.17.19.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 19:42:17 -0800 (PST) From: Brian Norris To: Johannes Berg Cc: linux-wireless@vger.kernel.org, David Poole , Ben Greear , John Crispin , Brian Norris Subject: [PATCH 2/4] iw: util: factor out HE capability parser Date: Tue, 17 Nov 2020 19:39:34 -0800 Message-Id: <20201118033936.3667788-3-briannorris@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201118033936.3667788-1-briannorris@chromium.org> References: <20201118033936.3667788-1-briannorris@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We're going to use this for scan parsing. Signed-off-by: Brian Norris --- util.c | 144 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 64 deletions(-) diff --git a/util.c b/util.c index 0a9083c613a4..4591cbf77ec1 100644 --- a/util.c +++ b/util.c @@ -989,19 +989,11 @@ void print_vht_info(__u32 capa, const __u8 *mcs) printf("\t\tVHT TX highest supported: %d Mbps\n", tmp & 0x1fff); } -void print_he_info(struct nlattr *nl_iftype) +static void __print_he_capa(const __u16 *mac_cap, + const __u16 *phy_cap, + const __u16 *mcs_set, size_t mcs_len, + const __u8 *ppet, int ppet_len) { - struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1]; - struct nlattr *tb_flags[NL80211_IFTYPE_MAX + 1]; - char *iftypes[NUM_NL80211_IFTYPES] = { - "Unspec", "Adhoc", "Station", "AP", "AP/VLAN", "WDS", "Monitor", - "Mesh", "P2P/Client", "P2P/Go", "P2P/Device", "OCB", "NAN", - }; - __u16 mac_cap[3] = { 0 }; - __u16 phy_cap[6] = { 0 }; - __u16 mcs_set[6] = { 0 }; - __u8 ppet[25] = { 0 }; - size_t len; int i; #define PRINT_HE_CAP(_var, _idx, _bit, _str) \ @@ -1022,30 +1014,6 @@ void print_he_info(struct nlattr *nl_iftype) #define PRINT_HE_PHY_CAP0(_idx, _bit, ...) PRINT_HE_CAP(phy_cap, _idx, _bit + 8, __VA_ARGS__) #define PRINT_HE_PHY_CAP_MASK(...) PRINT_HE_CAP_MASK(phy_cap, __VA_ARGS__) - nla_parse(tb, NL80211_BAND_IFTYPE_ATTR_MAX, - nla_data(nl_iftype), nla_len(nl_iftype), NULL); - - if (!tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES]) - return; - - if (nla_parse_nested(tb_flags, NL80211_IFTYPE_MAX, - tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES], NULL)) - return; - - printf("\t\tHE Iftypes:"); - for (i = 0; i < NUM_NL80211_IFTYPES; i++) - if (nla_get_flag(tb_flags[i]) && iftypes[i]) - printf(" %s", iftypes[i]); - printf("\n"); - - if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]) { - len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]); - if (len > sizeof(mac_cap)) - len = sizeof(mac_cap); - memcpy(mac_cap, - nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]), - len); - } printf("\t\t\tHE MAC Capabilities (0x"); for (i = 0; i < 3; i++) printf("%04x", mac_cap[i]); @@ -1086,15 +1054,6 @@ void print_he_info(struct nlattr *nl_iftype) PRINT_HE_MAC_CAP(2, 11, "UL 2x996-Tone RU"); PRINT_HE_MAC_CAP(2, 12, "OM Control UL MU Data Disable RX"); - 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); - } printf("\t\t\tHE PHY Capabilities: (0x"); for (i = 0; i < 11; i++) printf("%02x", ((__u8 *)phy_cap)[i + 1]); @@ -1165,15 +1124,6 @@ void print_he_info(struct nlattr *nl_iftype) PRINT_HE_PHY_CAP(5, 4, "RX Full BW SU Using HE MU PPDU with Compression SIGB"); PRINT_HE_PHY_CAP(5, 5, "RX Full BW SU Using HE MU PPDU with Non-Compression SIGB"); - if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]) { - len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]); - if (len > sizeof(mcs_set)) - len = sizeof(mcs_set); - memcpy(mcs_set, - nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]), - len); - } - for (i = 0; i < 3; i++) { __u8 phy_cap_support[] = { BIT(1) | BIT(2), BIT(3), BIT(4) }; char *bw[] = { "<= 80", "160", "80+80" }; @@ -1182,6 +1132,10 @@ void print_he_info(struct nlattr *nl_iftype) if ((phy_cap[0] & (phy_cap_support[i] << 8)) == 0) continue; + /* Supports more, but overflow? Abort. */ + if ((i * 2 + 2) * sizeof(mcs_set[0]) >= mcs_len) + return; + for (j = 0; j < 2; j++) { int k; printf("\t\t\tHE %s MCS and NSS set %s MHz\n", j ? "TX" : "RX", bw[i]); @@ -1199,7 +1153,76 @@ void print_he_info(struct nlattr *nl_iftype) } } - len = 0; + if (ppet_len && (phy_cap[3] & BIT(15))) { + printf("\t\t\tPPE Threshold "); + for (i = 0; i < ppet_len; i++) + if (ppet[i]) + printf("0x%02x ", ppet[i]); + printf("\n"); + } +} + +void print_he_info(struct nlattr *nl_iftype) +{ + struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1]; + struct nlattr *tb_flags[NL80211_IFTYPE_MAX + 1]; + char *iftypes[NUM_NL80211_IFTYPES] = { + "Unspec", "Adhoc", "Station", "AP", "AP/VLAN", "WDS", "Monitor", + "Mesh", "P2P/Client", "P2P/Go", "P2P/Device", "OCB", "NAN", + }; + __u16 mac_cap[3] = { 0 }; + __u16 phy_cap[6] = { 0 }; + __u16 mcs_set[6] = { 0 }; + __u8 ppet[25] = { 0 }; + size_t len; + int i; + int mcs_len = 0, ppet_len = 0; + + nla_parse(tb, NL80211_BAND_IFTYPE_ATTR_MAX, + nla_data(nl_iftype), nla_len(nl_iftype), NULL); + + if (!tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES]) + return; + + if (nla_parse_nested(tb_flags, NL80211_IFTYPE_MAX, + tb[NL80211_BAND_IFTYPE_ATTR_IFTYPES], NULL)) + return; + + printf("\t\tHE Iftypes:"); + for (i = 0; i < NUM_NL80211_IFTYPES; i++) + if (nla_get_flag(tb_flags[i]) && iftypes[i]) + printf(" %s", iftypes[i]); + printf("\n"); + + if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]) { + len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]); + if (len > sizeof(mac_cap)) + len = sizeof(mac_cap); + memcpy(mac_cap, + nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]), + len); + } + + 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 (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]) { + len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]); + if (len > sizeof(mcs_set)) + len = sizeof(mcs_set); + memcpy(mcs_set, + nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]), + len); + mcs_len = len; + } + if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]) { len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]); if (len > sizeof(ppet)) @@ -1207,17 +1230,10 @@ void print_he_info(struct nlattr *nl_iftype) memcpy(ppet, nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]), len); + ppet_len = len; } - if (len && (phy_cap[3] & BIT(15))) { - size_t i; - - printf("\t\t\tPPE Threshold "); - for (i = 0; i < len; i++) - if (ppet[i]) - printf("0x%02x ", ppet[i]); - printf("\n"); - } + __print_he_capa(mac_cap, phy_cap, mcs_set, mcs_len, ppet, ppet_len); } void iw_hexdump(const char *prefix, const __u8 *buf, size_t size) From patchwork Wed Nov 18 03:39:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 11913825 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A1F65138B for ; Wed, 18 Nov 2020 03:42:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BD4820BED for ; Wed, 18 Nov 2020 03:42:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="O40FBp07" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbgKRDmU (ORCPT ); Tue, 17 Nov 2020 22:42:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgKRDmU (ORCPT ); Tue, 17 Nov 2020 22:42:20 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94130C0613D4 for ; Tue, 17 Nov 2020 19:42:20 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id r9so324605pjl.5 for ; Tue, 17 Nov 2020 19:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=STixirzAd4J7+QdE4FgirGi/qOtSsNZnU5WpIzam3eo=; b=O40FBp07HfOQpWiaxf/hohRTktBBYkM6cFZOYzXO5Mt1PmRhFOKjryswj+p43pEkbY 1nyAf8OzAdZ1ADUqxrLBrCJ7myf+HmxVgoZi5BUU+ntsp8J2nvI+3ZyDXjdXHjSs4F8P 1SHpxLMcIp/7y1E3ah0yhtSbZYemIG6yb/O+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=STixirzAd4J7+QdE4FgirGi/qOtSsNZnU5WpIzam3eo=; b=tIu4tXuwCYh7FOXQ/5poHTWQnOgfBxwf5HJW7ys5VAx/ON3htrYyvhCkJk7qxnU9Q6 Eo4dBpxI2pfFKW3JOCaO+8Twa8nohLtn4IebI6ugDwD/241QrwQuqlbGwV3ErHnbEY0e qqgPYfgFSSAeKmHFJ4oLuA3Uut7yflHXY/89iocL1ktVDoUFdMYhfmNidGY7z3nuWtgx ZNpodXOD1CT6igiISCa39BQSxHFz47ro4HbV4b7pvL4Y5rr2PRyxb3HkfJbmIudy60Uj 4jNgm9r9521xcDPh1EzEVBkejOHE9dcMjeROMppU58j5wkyNRtsFSkuSYP9/aJSoAN6R heTQ== X-Gm-Message-State: AOAM5337bdTxJTfSJiCEOm+iapuNrfnndc3XqN0ML8X/pmm8YLcQNJRK uFsUhGzZf6wuEqSJ2JCUTojj6g== X-Google-Smtp-Source: ABdhPJynnhM4GywOaMiJnVQRAECkPahvCmG97HEfu/QqnNJxzoYooov1JVci8I8DCY5phJzlCmSXsA== X-Received: by 2002:a17:90b:94f:: with SMTP id dw15mr2181872pjb.125.1605670940214; Tue, 17 Nov 2020 19:42:20 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:8edc:d4ff:fe53:350d]) by smtp.gmail.com with ESMTPSA id w2sm16097617pfb.104.2020.11.17.19.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 19:42:19 -0800 (PST) From: Brian Norris To: Johannes Berg Cc: linux-wireless@vger.kernel.org, David Poole , Ben Greear , John Crispin , Brian Norris Subject: [PATCH 3/4] iw: scan: parse HE capabilities Date: Tue, 17 Nov 2020 19:39:35 -0800 Message-Id: <20201118033936.3667788-4-briannorris@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201118033936.3667788-1-briannorris@chromium.org> References: <20201118033936.3667788-1-briannorris@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Signed-off-by: Brian Norris --- iw.h | 1 + scan.c | 8 ++++++++ util.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/iw.h b/iw.h index 77ed097f229b..807adecd3b06 100644 --- a/iw.h +++ b/iw.h @@ -213,6 +213,7 @@ void print_ampdu_length(__u8 exponent); void print_ampdu_spacing(__u8 spacing); void print_ht_capability(__u16 cap); void print_vht_info(__u32 capa, const __u8 *mcs); +void print_he_capability(const uint8_t *ie, int len); void print_he_info(struct nlattr *nl_iftype); char *channel_width_name(enum nl80211_chan_width width); diff --git a/scan.c b/scan.c index 58a09983c5c7..dfc136a3943e 100644 --- a/scan.c +++ b/scan.c @@ -2272,7 +2272,15 @@ static void print_vendor(unsigned char len, unsigned char *data, printf("\n"); } +static void print_he_capa(const uint8_t type, uint8_t len, const uint8_t *data, + const struct print_ies_data *ie_buffer) +{ + printf("\n"); + print_he_capability(data, len); +} + static const struct ie_print ext_printers[] = { + [35] = { "HE capabilities", print_he_capa, 21, 54, BIT(PRINT_SCAN), }, }; static void print_extension(unsigned char len, unsigned char *ie, diff --git a/util.c b/util.c index 4591cbf77ec1..b09bcaf743fc 100644 --- a/util.c +++ b/util.c @@ -994,6 +994,7 @@ static void __print_he_capa(const __u16 *mac_cap, const __u16 *mcs_set, size_t mcs_len, const __u8 *ppet, int ppet_len) { + size_t mcs_used; int i; #define PRINT_HE_CAP(_var, _idx, _bit, _str) \ @@ -1124,6 +1125,7 @@ static void __print_he_capa(const __u16 *mac_cap, PRINT_HE_PHY_CAP(5, 4, "RX Full BW SU Using HE MU PPDU with Compression SIGB"); PRINT_HE_PHY_CAP(5, 5, "RX Full BW SU Using HE MU PPDU with Non-Compression SIGB"); + mcs_used = 0; for (i = 0; i < 3; i++) { __u8 phy_cap_support[] = { BIT(1) | BIT(2), BIT(3), BIT(4) }; char *bw[] = { "<= 80", "160", "80+80" }; @@ -1151,6 +1153,16 @@ static void __print_he_capa(const __u16 *mac_cap, } } + mcs_used += 2 * sizeof(mcs_set[0]); + } + + /* Caller didn't provide ppet; infer it, if there's trailing space. */ + if (!ppet) { + ppet = (const void *)(mcs_set + mcs_used); + if (mcs_used < mcs_len) + ppet_len = mcs_len - mcs_used; + else + ppet_len = 0; } if (ppet_len && (phy_cap[3] & BIT(15))) { @@ -1236,6 +1248,24 @@ void print_he_info(struct nlattr *nl_iftype) __print_he_capa(mac_cap, phy_cap, mcs_set, mcs_len, ppet, ppet_len); } +void print_he_capability(const uint8_t *ie, int len) +{ + const void *mac_cap, *phy_cap, *mcs_set; + int mcs_len; + int i = 0; + + mac_cap = &ie[i]; + i += 6; + + phy_cap = &ie[i]; + i += 11; + + mcs_set = &ie[i]; + mcs_len = len - i; + + __print_he_capa(mac_cap, phy_cap - 1, mcs_set, mcs_len, NULL, 0); +} + void iw_hexdump(const char *prefix, const __u8 *buf, size_t size) { size_t i; From patchwork Wed Nov 18 03:39:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 11913827 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C835A1398 for ; Wed, 18 Nov 2020 03:42:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACA4320867 for ; Wed, 18 Nov 2020 03:42:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="EDWCwX4L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726863AbgKRDmY (ORCPT ); Tue, 17 Nov 2020 22:42:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgKRDmX (ORCPT ); Tue, 17 Nov 2020 22:42:23 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67230C0613D4 for ; Tue, 17 Nov 2020 19:42:22 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id 5so247049plj.8 for ; Tue, 17 Nov 2020 19:42:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0q7uTzWf+NvnLsIKiQv5WVy1jGL93/4S1PO8Gde9U2o=; b=EDWCwX4Liz49xKw5jFNq+kGUw+J4mUiu3Wpwcwn+fykUYBS+zY5nULzCJueB2kfuKL eOodKs+HRtJChUgjfI0kVAcJS7qnNHkl6ZhOT2zVfH8JGABjenfuBfBrAR6N+kDCQ8xx TCSJJHDl3bptVBnUda9JEKzlXAKJR16LK+aII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0q7uTzWf+NvnLsIKiQv5WVy1jGL93/4S1PO8Gde9U2o=; b=osK+9yOWfXVOCDXUfRrUe1G82OypzMOwp8T05ha3tI2LcqA4YFRdhyATXqqQKcsNwN kRveKGyY5bU70VdIPtTFH2CFp5bKFyRlls5SW9ei3v3TAs2nzACRlhS/X8SiyccH8cbg QZ6GTjALxmst6ATaTBCyH3e5swExxiryHUm+EgCz2VTfyUQP2Il1EYTzscqjNgemZrKb xoOMUMReqEZTgIaJndoeIKxg3A9MqYkIEPdIWyiZ+Bkhx7mHWRA62MNI4ZmXt5RqVUia WPRkKDBVmTb+QY/H8OjjNWoUfuQGekREkCaiD1TYchrykccOlckr6hNiyhhcaziitJAI saAg== X-Gm-Message-State: AOAM532KTMoTaA+gwdyqbhLbY2JbtwAD+3Wz8JWBT8BmDcaapBYUtGyy vJXdzXRCA5S/rI0YAbGNje2Vgw== X-Google-Smtp-Source: ABdhPJxioomSZ3J7VrUGlZB+bKoULpC8AXgrL2qz07+Mw25NmF1SoFdAr0Idwd+fTwj+FQSvNZU+Vw== X-Received: by 2002:a17:90a:4093:: with SMTP id l19mr2177198pjg.65.1605670941976; Tue, 17 Nov 2020 19:42:21 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:8edc:d4ff:fe53:350d]) by smtp.gmail.com with ESMTPSA id w2sm16097617pfb.104.2020.11.17.19.42.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 19:42:21 -0800 (PST) From: Brian Norris To: Johannes Berg Cc: linux-wireless@vger.kernel.org, David Poole , Ben Greear , John Crispin , Brian Norris Subject: [PATCH 4/4] iw: scan: fixup HE caps whitespace Date: Tue, 17 Nov 2020 19:39:36 -0800 Message-Id: <20201118033936.3667788-5-briannorris@chromium.org> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog In-Reply-To: <20201118033936.3667788-1-briannorris@chromium.org> References: <20201118033936.3667788-1-briannorris@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org For scans, it's nicer to drop an indentation level, because we don't have the "interface type" section that we do in the phy-info version. The NSS print also had an extra level of indentation, and a spare leading space, which made it a bit inconsistent with other sections. Signed-off-by: Brian Norris --- util.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/util.c b/util.c index b09bcaf743fc..00f3755b1000 100644 --- a/util.c +++ b/util.c @@ -992,21 +992,23 @@ void print_vht_info(__u32 capa, const __u8 *mcs) static void __print_he_capa(const __u16 *mac_cap, const __u16 *phy_cap, const __u16 *mcs_set, size_t mcs_len, - const __u8 *ppet, int ppet_len) + const __u8 *ppet, int ppet_len, + bool indent) { size_t mcs_used; int i; + const char *pre = indent ? "\t" : ""; #define PRINT_HE_CAP(_var, _idx, _bit, _str) \ do { \ if (_var[_idx] & BIT(_bit)) \ - printf("\t\t\t\t" _str "\n"); \ + printf("%s\t\t\t" _str "\n", pre); \ } while (0) #define PRINT_HE_CAP_MASK(_var, _idx, _shift, _mask, _str) \ do { \ if ((_var[_idx] >> _shift) & _mask) \ - printf("\t\t\t\t" _str ": %d\n", (_var[_idx] >> _shift) & _mask); \ + printf("%s\t\t\t" _str ": %d\n", pre, (_var[_idx] >> _shift) & _mask); \ } while (0) #define PRINT_HE_MAC_CAP(...) PRINT_HE_CAP(mac_cap, __VA_ARGS__) @@ -1015,7 +1017,7 @@ static void __print_he_capa(const __u16 *mac_cap, #define PRINT_HE_PHY_CAP0(_idx, _bit, ...) PRINT_HE_CAP(phy_cap, _idx, _bit + 8, __VA_ARGS__) #define PRINT_HE_PHY_CAP_MASK(...) PRINT_HE_CAP_MASK(phy_cap, __VA_ARGS__) - printf("\t\t\tHE MAC Capabilities (0x"); + printf("%s\t\tHE MAC Capabilities (0x", pre); for (i = 0; i < 3; i++) printf("%04x", mac_cap[i]); printf("):\n"); @@ -1055,7 +1057,7 @@ static void __print_he_capa(const __u16 *mac_cap, PRINT_HE_MAC_CAP(2, 11, "UL 2x996-Tone RU"); PRINT_HE_MAC_CAP(2, 12, "OM Control UL MU Data Disable RX"); - printf("\t\t\tHE PHY Capabilities: (0x"); + printf("%s\t\tHE PHY Capabilities: (0x", pre); for (i = 0; i < 11; i++) printf("%02x", ((__u8 *)phy_cap)[i + 1]); printf("):\n"); @@ -1140,12 +1142,12 @@ static void __print_he_capa(const __u16 *mac_cap, for (j = 0; j < 2; j++) { int k; - printf("\t\t\tHE %s MCS and NSS set %s MHz\n", j ? "TX" : "RX", bw[i]); + printf("%s\t\tHE %s MCS and NSS set %s MHz\n", pre, j ? "TX" : "RX", bw[i]); for (k = 0; k < 8; k++) { __u16 mcs = mcs_set[(i * 2) + j]; mcs >>= k * 2; mcs &= 0x3; - printf("\t\t\t\t\t %d streams: ", k + 1); + printf("%s\t\t\t%d streams: ", pre, k + 1); if (mcs == 3) printf("not supported\n"); else @@ -1166,7 +1168,7 @@ static void __print_he_capa(const __u16 *mac_cap, } if (ppet_len && (phy_cap[3] & BIT(15))) { - printf("\t\t\tPPE Threshold "); + printf("%s\t\tPPE Threshold ", pre); for (i = 0; i < ppet_len; i++) if (ppet[i]) printf("0x%02x ", ppet[i]); @@ -1245,7 +1247,8 @@ void print_he_info(struct nlattr *nl_iftype) ppet_len = len; } - __print_he_capa(mac_cap, phy_cap, mcs_set, mcs_len, ppet, ppet_len); + __print_he_capa(mac_cap, phy_cap, mcs_set, mcs_len, ppet, ppet_len, + true); } void print_he_capability(const uint8_t *ie, int len) @@ -1263,7 +1266,7 @@ void print_he_capability(const uint8_t *ie, int len) mcs_set = &ie[i]; mcs_len = len - i; - __print_he_capa(mac_cap, phy_cap - 1, mcs_set, mcs_len, NULL, 0); + __print_he_capa(mac_cap, phy_cap - 1, mcs_set, mcs_len, NULL, 0, false); } void iw_hexdump(const char *prefix, const __u8 *buf, size_t size)