Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp775384ybk; Wed, 13 May 2020 12:46:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmefFNOhn3Rx8Wc3qBw4ib7kfzf5eZ3/BGuC7AfioYZMVdmmPYZptW3MLJj6bGUvUcUAxV X-Received: by 2002:a17:906:edbd:: with SMTP id sa29mr632095ejb.128.1589399179937; Wed, 13 May 2020 12:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589399179; cv=none; d=google.com; s=arc-20160816; b=Tgem7kiiLMOLVWboBWj6gbfwMTiyhJP4hZ7dAeknQqTwWNBm5Ec0N1F8tPBDrv4SvO tcvY09w88mTfMmqhP5M5bmUpSu0ATjYwm2hIFYmYxJx6lLgfFgu8fedlr7ye1J0GiYb4 Zt6FVsO3QdvfS+ZmIZw1TtHtaY0pbSn9hqJWPbZjorI+EN3N6FWQOqHrljhSmFP3H1tA Wp9fV0iNjTF9ak2QUdQLVE6qoCl4r7/vLPRI7m4fttMbZVepXzuG/CS5X8HI2Ii/2PxE rOFq1nlM6qyJV9Q/zhRlr0AY7FeKXtQIMjxFxtsQwgwXNVM4PI2RnVZDT+jUopHcCAVU J3KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=EzEnigHGU2wO6SDIqcO/vP5fXHbj3ghPk5W4u5iro60=; b=0uypndnPYoAUtwuj+MWxOnDojH/XARvbojD8PWgkb/R+TICWfOd0cDaq4EH/vyXw0N MRNzlCAjSO0JO+g9otURpIJrS86b0DkeDZu1u06fC2G/3x0rHVdZFwp/CNqIQbGq8Epr Kjb+JsSPQUqzJlzYYCfUQtBLBlcqT6sXu4NnmtD69/PddnkjpqaSEOEK28vNBfiXIDwo eLLnJl/BnX/sHm+d32HNPGA6Prqh+L3kbpEI5Q0V6bzg0kJAl/2xeL5vMMo9mpSsqxcb XTuV7U7wzB/gnvb8QhOW77ICFxIBZvamUdxTObbHyOaQhsHNAMJGX4ZaegZJy7d1wS+q XdJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=wOrY9iIa; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a26si312291edr.356.2020.05.13.12.45.46; Wed, 13 May 2020 12:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=wOrY9iIa; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390725AbgEMTpg (ORCPT + 99 others); Wed, 13 May 2020 15:45:36 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:60600 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387616AbgEMTpg (ORCPT ); Wed, 13 May 2020 15:45:36 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589399134; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=EzEnigHGU2wO6SDIqcO/vP5fXHbj3ghPk5W4u5iro60=; b=wOrY9iIatb2ueB599tPqNJqzgJS05F7WNrlaJ/0MEQQas/ymTztNZENNnMPKvkHm0ugHLSLZ EbmQiMudNBU6XNVYwp95se31a7owctu0wiMOVktQm6X4zhwnbn6Ey3ImKiYJ3sijezfXMgxV xpgXOzKps7Ad/Kt0Rxt1w4s2K1g= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ebc4e5d.7f63c9f7eca8-smtp-out-n04; Wed, 13 May 2020 19:45:33 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BC39DC433BA; Wed, 13 May 2020 19:45:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from rmanohar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rmanohar) by smtp.codeaurora.org (Postfix) with ESMTPSA id B5DACC433F2; Wed, 13 May 2020 19:45:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B5DACC433F2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=rmanohar@codeaurora.org From: Rajkumar Manoharan To: johannes@sipsolutions.net, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org, Rajkumar Manoharan Subject: [PATCH v3 10/11] mac80211: determine chantype from HE operation in 6 GHz Date: Wed, 13 May 2020 12:45:04 -0700 Message-Id: <1589399105-25472-10-git-send-email-rmanohar@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589399105-25472-1-git-send-email-rmanohar@codeaurora.org> References: <1589399105-25472-1-git-send-email-rmanohar@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In 6 GHz band, determine chandef from 6 GHz operation information of HE operation element. Reported-by: kernel test robot Signed-off-by: Rajkumar Manoharan --- net/mac80211/ieee80211_i.h | 3 ++ net/mac80211/mesh.c | 1 + net/mac80211/mlme.c | 12 ++++++ net/mac80211/util.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 0bb442feb1db..42a7782c973a 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -2194,6 +2194,9 @@ bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, const struct ieee80211_vht_operation *oper, const struct ieee80211_ht_operation *htop, struct cfg80211_chan_def *chandef); +bool ieee80211_chandef_he_oper(struct ieee80211_sub_if_data *sdata, + const struct ieee80211_he_operation *heop, + struct cfg80211_chan_def *chandef); u32 ieee80211_chandef_downgrade(struct cfg80211_chan_def *c); int __must_check diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 04d3da733bc8..0521b57939e1 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -99,6 +99,7 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, ieee80211_chandef_vht_oper(&sdata->local->hw, ie->vht_operation, ie->ht_operation, &sta_chan_def); + ieee80211_chandef_he_oper(sdata, ie->he_operation, &sta_chan_def); if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef, &sta_chan_def)) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index b4dfefd482a6..9115dc9c7d78 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -163,6 +163,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, chandef->width = NL80211_CHAN_WIDTH_20_NOHT; chandef->center_freq1 = channel->center_freq; + if (channel->band == NL80211_BAND_6GHZ) + goto skip_ht_vht_oper; + if (!ht_oper || !sta_ht_cap.ht_supported) { ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT | @@ -263,6 +266,15 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata, *chandef = vht_chandef; +skip_ht_vht_oper: + if (!ieee80211_chandef_he_oper(sdata, he_oper, chandef)) { + if (!(ifmgd->flags & IEEE80211_STA_DISABLE_HE)) + sdata_info(sdata, + "AP HE information is invalid, disable HE\n"); + ret = IEEE80211_STA_DISABLE_HE; + goto out; + } + ret = 0; out: diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 90b8c42b1aa8..f6ab8835d69a 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -3170,6 +3170,102 @@ bool ieee80211_chandef_vht_oper(struct ieee80211_hw *hw, return true; } +bool ieee80211_chandef_he_oper(struct ieee80211_sub_if_data *sdata, + const struct ieee80211_he_operation *heop, + struct cfg80211_chan_def *chandef) +{ + struct ieee80211_he_oper_6ghz_op_info info; + const struct ieee80211_sta_he_cap *he_cap; + struct ieee80211_supported_band *sband; + struct cfg80211_chan_def new = *chandef; + int cf0, cf1; + int ccf0, ccf1; + bool support_80_80; + bool support_160; + u8 he_phy_cap; + u8 pos = 0; + + /* Below HE Operation check is required only for 6 GHz band */ + if (chandef->chan->band != NL80211_BAND_6GHZ) + return true; + + if (!heop) + return false; + + sband = sdata->local->hw.wiphy->bands[chandef->chan->band]; + if (!sband) + return false; + + he_cap = ieee80211_get_he_iftype_cap(sband, sdata->vif.type); + if (!he_cap) + return false; + + if (!(le32_to_cpu(heop->he_oper_params) & + IEEE80211_HE_OPERATION_6GHZ_OP_INFO)) + return false; + + he_phy_cap = he_cap->he_cap_elem.phy_cap_info[0]; + support_160 = + !!(he_phy_cap & + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G); + support_80_80 = + !!(he_phy_cap & + IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G); + + if (le32_to_cpu(heop->he_oper_params) & + IEEE80211_HE_OPERATION_VHT_OPER_INFO) + pos += 3; + if (le32_to_cpu(heop->he_oper_params) & + IEEE80211_HE_OPERATION_CO_HOSTED_BSS) + pos += 1; + + memcpy(&info, &heop->optional[pos], sizeof(info)); + ccf0 = info.center_freq_seg0_idx; + ccf1 = info.center_freq_seg1_idx; + + cf0 = ieee80211_channel_to_frequency(ccf0, chandef->chan->band); + cf1 = ieee80211_channel_to_frequency(ccf1, chandef->chan->band); + + switch (info.control & 0x3) { + case IEEE80211_HE_6GHZ_CHANWIDTH_20MHZ: + new.center_freq1 = cf0; + new.width = NL80211_CHAN_WIDTH_20; + break; + case IEEE80211_HE_6GHZ_CHANWIDTH_40MHZ: + new.center_freq1 = cf0; + new.width = NL80211_CHAN_WIDTH_40; + break; + case IEEE80211_HE_6GHZ_CHANWIDTH_80MHZ: + new.center_freq1 = cf0; + new.width = NL80211_CHAN_WIDTH_80; + break; + case IEEE80211_HE_6GHZ_CHANWIDTH_160MHZ_80P80MHZ: + new.center_freq1 = cf0; + new.width = NL80211_CHAN_WIDTH_80; + if (ccf1) { + unsigned int diff; + + diff = abs(ccf1 - ccf0); + if (diff == 8 && support_160) { + new.width = NL80211_CHAN_WIDTH_160; + new.center_freq1 = cf1; + } else if ((diff > 8) && support_80_80) { + new.width = NL80211_CHAN_WIDTH_80P80; + new.center_freq2 = cf1; + } + } + break; + default: + return false; + } + + if (!cfg80211_chandef_valid(&new)) + return false; + + *chandef = new; + return true; +} + int ieee80211_parse_bitrates(struct cfg80211_chan_def *chandef, const struct ieee80211_supported_band *sband, const u8 *srates, int srates_len, u32 *rates) -- 2.7.4