From patchwork Tue Apr 16 12:33:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 1086276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phrozen.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YFzNqY9k"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44k4Z74Sq5z9s0W for ; Tue, 16 Apr 2019 22:34:39 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=l0krTLhNOsO+9CC1+50uGWQFpGVW16ACmiU+yufcA1U=; b=YFz NqY9kSAVZVwr0bjLcR56P3mCHvvKtJy432JSD1PEeesD2qGav+Q7G3k9RiPRgUI5/11R6ermcHuYE uL0KnfYW6ydYtdqAO7S9HSAvbILlMNWg6VaFboGjEUVNeJCKtJy029YUpYTvuKT6FHy+Y45ZaWgNA H4JRjmL3r8s/mAx48pPP8q5M6zbr/j//gRPB+9aSK0owJLiGPbXo/1ZlKcPeMlG6MZf0r1s3Simry hGRD9TnhWVNcs+1LlmV70LXiTrJ1+dZ+n2a/mqgMQfLS1sOANXLZ1qOWISvselMUpZvhVrE/Ol+06 lMgP0N/wyv0DSPEx9YrkvKyvYcuw1ig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGNIJ-0002Yl-UJ; Tue, 16 Apr 2019 12:34:35 +0000 Received: from nbd.name ([2a01:4f8:221:3d45::2]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGNHx-000278-Lm for hostap@lists.infradead.org; Tue, 16 Apr 2019 12:34:16 +0000 Received: from p548c879a.dip0.t-ipconnect.de ([84.140.135.154] helo=bertha.fritz.box) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hGNHr-0000Ir-Vc; Tue, 16 Apr 2019 14:34:08 +0200 From: John Crispin To: Jouni Malinen Subject: [PATCH 1/5] nl80211: add HW capabilities parsing support Date: Tue, 16 Apr 2019 14:33:57 +0200 Message-Id: <20190416123401.12379-1-john@phrozen.org> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190416_053413_913158_80B38A4E X-CRM114-Status: GOOD ( 14.01 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hostap@lists.infradead.org, Shashidhar Lakkavalli , Srini Kode , John Crispin MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add code to parse the iftype element when reading the band info. This is required to find out about the HE capabilities of an AP. Signed-off-by: Shashidhar Lakkavalli Signed-off-by: John Crispin --- src/drivers/driver.h | 10 +++-- src/drivers/driver_nl80211_capa.c | 77 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index e7c8f318f..7658e4b56 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -159,7 +159,9 @@ struct hostapd_channel_data { }; #define HE_MAX_NUM_SS 8 -#define HE_MAX_PHY_CAPAB_SIZE 3 +#define HE_MAX_MAC_CAPAB_SIZE 6 +#define HE_MAX_PHY_CAPAB_SIZE 11 +#define HE_MAX_MCS_CAPAB_SIZE 12 /** * struct he_ppe_threshold - IEEE 802.11ax HE PPE Threshold @@ -175,9 +177,9 @@ struct he_ppe_threshold { */ struct he_capabilities { u8 he_supported; - u32 phy_cap[HE_MAX_PHY_CAPAB_SIZE]; - u32 mac_cap; - u32 mcs; + u8 phy_cap[HE_MAX_PHY_CAPAB_SIZE]; + u8 mac_cap[HE_MAX_MAC_CAPAB_SIZE]; + u8 mcs[HE_MAX_MCS_CAPAB_SIZE]; struct he_ppe_threshold ppet; }; diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 37eeb5e66..85e6546eb 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -18,7 +18,6 @@ #include "common/qca-vendor-attr.h" #include "driver_nl80211.h" - static int protocol_feature_handler(struct nl_msg *msg, void *arg) { u32 *feat = arg; @@ -1598,6 +1597,70 @@ static int phy_info_rates(struct hostapd_hw_modes *mode, struct nlattr *tb) } +static int phy_info_iftype(struct hostapd_hw_modes *mode, struct nlattr *nl_iftype) +{ + struct nlattr *tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_MAX + 1]; + struct he_capabilities *he_capab = &mode->he_capab; + struct nlattr *tb_iftypes[NL80211_IFTYPE_MAX + 1]; + int len; + + nla_parse(tb_band_iftypes, NL80211_BAND_IFTYPE_ATTR_MAX, nla_data(nl_iftype), + nla_len(nl_iftype), NULL); + + if (!tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_IFTYPES]) + return NL_STOP; + + if (nla_parse_nested(tb_iftypes, NL80211_IFTYPE_MAX, tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_IFTYPES], NULL)) + return NL_STOP; + + if (!nla_get_flag(tb_iftypes[NL80211_IFTYPE_AP])) + return NL_OK; + + he_capab->he_supported = 1; + + if (tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]) { + len = nla_len(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]); + + if (len > sizeof(he_capab->phy_cap)) + len = sizeof(he_capab->phy_cap); + os_memcpy(he_capab->phy_cap, + nla_data(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]), + len); + } + + if (tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]) { + len = nla_len(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]); + + if (len > sizeof(he_capab->mac_cap)) + len = sizeof(he_capab->mac_cap); + os_memcpy(he_capab->mac_cap, + nla_data(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MAC]), + len); + } + + if (tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]) { + len = nla_len(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]); + + if (len > sizeof(he_capab->mcs)) + len = sizeof(he_capab->mcs); + os_memcpy(he_capab->mcs, + nla_data(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET]), + len); + } + + if (tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]) { + len = nla_len(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]); + + if (len > sizeof(he_capab->ppet)) + len = sizeof(he_capab->ppet); + os_memcpy(&he_capab->ppet, + nla_data(tb_band_iftypes[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE]), + len); + } + + return NL_OK; +} + static int phy_info_band(struct phy_info_arg *phy_info, struct nlattr *nl_band) { struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; @@ -1654,6 +1717,18 @@ static int phy_info_band(struct phy_info_arg *phy_info, struct nlattr *nl_band) return ret; } + if (tb_band[NL80211_BAND_ATTR_IFTYPE_DATA]) { + struct nlattr *nl_iftype; + int rem_band; + + nla_for_each_nested(nl_iftype, tb_band[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band) + { + ret = phy_info_iftype(mode, nl_iftype); + if (ret != NL_OK) + return ret; + } + } + return NL_OK; }