Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4921422ybi; Tue, 28 May 2019 04:51:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiwMUKbDGuj3lS1mgv3KQg7Nrw3cPpnePj/dB43tWMeSMOjuMhf9sxhVx2E/LkMacufEUG X-Received: by 2002:a17:902:3fa5:: with SMTP id a34mr25432852pld.317.1559044318561; Tue, 28 May 2019 04:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559044318; cv=none; d=google.com; s=arc-20160816; b=NcH2fCLcQTwKbc4sX6H7skfpiak/PgYyPqK8uudzp7ka9f7umCvo5TIRqR1rAospQG w3r9r9kmq5gXZLgY0sgoYrrSlwpPG/6bMuTDQcB8LVKstBoUQrrCoG4bvK/drS2LDGZf d2TgnDKIAonZvw6IoFzrza5tF15yskf5Z65Sad8JvVD2l0EbvCEKYu8U1oSzwXbAnjzq NrmlJItMCp5nE4RVy/eFPd83eoBsiwHIq8FzBR5Usly8MBBr/IAkPldRI0VT0jDC2uPY 42wsq3TiYPiGRB2h5mxnuhtijNC6o93EJmUFjQLD1CeyZu/19SpC9dvX+PThnnLeygoa Lq7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=dxQoWQGhXwqnjqmAn1W3Q7OGF+q2wz81W/fahTqj9Bk=; b=MPDRX8lAUehwbfh3Ol9Ea0kJ88Xm9TrbWKrzUxCxm4hxMxqGOdBUuWQKEpHGJFFDCC nCinvue5w7ggycXb0PYjkn443gCzO0VwiJmGYdolgHAVOwHHSngSTC2j3xCJEbcFIZBC 8zYCYKqHUx71CNlWw2ecJrJwK/sVr5DCstP4tGb59hLvtkTsRWeWGEEwmhYMrgdDryrn ILdrZFozkHL7A89Wx1tQD2V2gyeYaSPW0JtygWRSSu6g4W/vR6QeTT7jV62g24uRt1kJ BH+dM0cGk3yNu5Ls1jZQfj5qvxQkrlTcuxUsNZ8hmctdW660M0nBooxnC4vUO+++NLWX b6tQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si7320381pgm.592.2019.05.28.04.51.43; Tue, 28 May 2019 04:51:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbfE1LuL (ORCPT + 99 others); Tue, 28 May 2019 07:50:11 -0400 Received: from nbd.name ([46.4.11.11]:55680 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726935AbfE1LuI (ORCPT ); Tue, 28 May 2019 07:50:08 -0400 Received: from p5dcfb1b7.dip0.t-ipconnect.de ([93.207.177.183] helo=bertha.datto.lan) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hVacH-0005pk-QZ; Tue, 28 May 2019 13:50:06 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, John Crispin , Shashidhar Lakkavalli Subject: [PATCH V2 4/6] mac80211: HE: add Spatial Reuse IE parsing support Date: Tue, 28 May 2019 13:49:50 +0200 Message-Id: <20190528114952.838-5-john@phrozen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190528114952.838-1-john@phrozen.org> References: <20190528114952.838-1-john@phrozen.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support to mac80211 for parsing SPR. Signed-off-by: Shashidhar Lakkavalli Signed-off-by: John Crispin --- include/linux/ieee80211.h | 49 ++++++++++++++++++++++++++++++++++++++ net/mac80211/ieee80211_i.h | 1 + net/mac80211/util.c | 4 ++++ 3 files changed, 54 insertions(+) diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 48703ec60d06..6109aa4024ad 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -1628,6 +1628,18 @@ struct ieee80211_he_operation { u8 optional[0]; } __packed; +/** + * struct ieee80211_he_spr - HE spatial reuse element + * + * This structure is the "HE spatial reuse element" element as + * described in P802.11ax_D3.0 section 9.4.2.241 + */ +struct ieee80211_he_spr { + u8 he_sr_control; + /* Optional 0 to 19 bytes: depends on @he_sr_control */ + u8 optional[0]; +} __packed; + /** * struct ieee80211_he_mu_edca_param_ac_rec - MU AC Parameter Record field * @@ -2063,6 +2075,42 @@ ieee80211_he_oper_size(const u8 *he_oper_ie) return oper_len; } +/* HE Spatial Reuse defines */ +#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT 0x4 +#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT 0x8 + +/* + * ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size + * @he_spr_ie: byte data of the He Spatial Reuse IE, stating from the the byte + * after the ext ID byte. It is assumed that he_spr_ie has at least + * sizeof(struct ieee80211_he_spr) bytes, checked already in + * ieee802_11_parse_elems_crc() + * @return the actual size of the IE data (not including header), or 0 on error + */ +static inline u8 +ieee80211_he_spr_size(const u8 *he_spr_ie) +{ + struct ieee80211_he_spr *he_spr = (void *)he_spr_ie; + u8 spr_len = sizeof(struct ieee80211_he_spr); + u32 he_spr_params; + + /* Make sure the input is not NULL */ + if (!he_spr_ie) + return 0; + + /* Calc required length */ + he_spr_params = le32_to_cpu(he_spr->he_sr_control); + if (he_spr_params & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT) + spr_len++; + if (he_spr_params & IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) + spr_len += 18; + + /* Add the first byte (extension ID) to the total length */ + spr_len++; + + return spr_len; +} + /* Authentication algorithms */ #define WLAN_AUTH_OPEN 0 #define WLAN_AUTH_SHARED_KEY 1 @@ -2485,6 +2533,7 @@ enum ieee80211_eid_ext { WLAN_EID_EXT_HE_OPERATION = 36, WLAN_EID_EXT_UORA = 37, WLAN_EID_EXT_HE_MU_EDCA = 38, + WLAN_EID_EXT_HE_SPR = 39, WLAN_EID_EXT_MAX_CHANNEL_SWITCH_TIME = 52, WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION = 55, }; diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 159eb9506bdc..0f0d0e1ac91c 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1482,6 +1482,7 @@ struct ieee802_11_elems { const struct ieee80211_meshconf_ie *mesh_config; const u8 *he_cap; const struct ieee80211_he_operation *he_operation; + const struct ieee80211_he_spr *he_spr; const struct ieee80211_mu_edca_param_set *mu_edca_param_set; const u8 *uora_element; const u8 *mesh_id; diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 4c1655972565..1b7076d24c18 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1282,6 +1282,10 @@ _ieee802_11_parse_elems_crc(const u8 *start, size_t len, bool action, WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION && elen == 3) { elems->mbssid_config_ie = (void *)&pos[1]; + } else if (pos[0] == WLAN_EID_EXT_HE_SPR && + elen >= sizeof(*elems->he_spr) && + elen >= ieee80211_he_spr_size(&pos[1])) { + elems->he_spr = (void *)&pos[1]; } break; default: -- 2.20.1