From patchwork Mon Nov 4 12:09:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathishkumar Muruganandam X-Patchwork-Id: 11225669 X-Patchwork-Delegate: kvalo@adurom.com 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 20DB7913 for ; Mon, 4 Nov 2019 12:09:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED5A521D81 for ; Mon, 4 Nov 2019 12:09:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RCMWwn8V"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="Bz2dwIYA"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="lnJ2PJox" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED5A521D81 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org 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:References: In-Reply-To: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:List-Owner; bh=1DgyhA49DZ35B9Ytw7Q/DzQ1Yzgk+EjvQ5D7laDrHgk=; b=RCMWwn8VaCR7fyUiHw9SEk1WQy 8G9HR/u7Uv3QhSNDdzO+afkigU2gFpyLt6+mhEfiZzznTjqnx3bg9L9gQZ1uH4cXtHIHxI1iulH/M U1xO5CihcFPLbKoBAaLjHjqunsfoY8IMDRZzfqjXgbOV7xhZtUoicEcjlz5PDTvalEGjon3vaBu1y K+K3GXyAMWfDB5lzC1tmGy47JIy59Vfiphiup0jtzwYYdKM6VVChq9ljR20Rhuou2FeUyoXt9fm8M U1stwgNgjeZJkeXbyfJVWF1Qe9JJSRSE/NCTedqy1KcPqFssoa72SCddmzq7kit1ItnHu/GernQfL Nz4s5cYA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRbBA-00029l-Ce; Mon, 04 Nov 2019 12:09:52 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRbB6-00028A-PB for ath11k@lists.infradead.org; Mon, 04 Nov 2019 12:09:50 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 40B6B60BEB; Mon, 4 Nov 2019 12:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572869387; bh=h16W9ouH0Q6hvZKSxICDM1iFfESootghw0lpokufnn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bz2dwIYA1TMn21JLb0vlLprw6f0UPnqy7yo1HG3jCmw8X57rbdzAWB4CMpOdZBej3 B6tMm8pCEtTwaQpL6b0I3f0ocZPoZJks+5/EEWJDWbNP0+FdY/8sM3KfNfkaor9RBT ItNuHglK7hHwgA0CBwdb8yBQkb9VJxqpqrw4yDLg= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,SPF_NONE autolearn=no autolearn_force=no version=3.4.0 Received: from murugana-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: murugana@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 24919603A3; Mon, 4 Nov 2019 12:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1572869386; bh=h16W9ouH0Q6hvZKSxICDM1iFfESootghw0lpokufnn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnJ2PJox1dWZYCN+oXq+GhrelSbLlgIjUF2JxT0oEdnjOXrjN+2iYr6oL81wudmhs h36zOmtNR9lHLEdgavn929JFgIdXUmKGYoTm4YPtGhk76sExoE5LVDOfhoY7C1eAfk X7b+3Fc7ZXzUFpnri8W0a1g2uB0Dke+1tEGI9WvI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 24919603A3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=murugana@codeaurora.org From: Sathishkumar Muruganandam To: johannes@sipsolutions.net Subject: [PATCH v2 1/2] nl80211: add Wide Band Scan support Date: Mon, 4 Nov 2019 17:39:33 +0530 Message-Id: <1572869374-9635-2-git-send-email-murugana@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1572869374-9635-1-git-send-email-murugana@codeaurora.org> References: <1572869374-9635-1-git-send-email-murugana@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191104_040948_861567_B0D340CA X-CRM114-Status: GOOD ( 16.62 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [198.145.29.96 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, ath11k@lists.infradead.org MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org New nl80211 ext_feature and scan_flag added to support wide band scan which allows driver to scan on requested channel with corresponding phy mode/bandwidth (40Mhz, 80Mhz). To handle center frequency of 80Mhz channel, struct cfg80211_chan_def is included in cfg80211_scan_request. Signed-off-by: Sathishkumar Muruganandam --- v2: Updated message on cover letter include/net/cfg80211.h | 2 ++ include/uapi/linux/nl80211.h | 7 +++++ net/mac80211/scan.c | 2 ++ net/wireless/nl80211.c | 68 ++++++++++++++++++++++++++++---------------- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 4ab2c49423dc..c303344e5832 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1906,6 +1906,7 @@ struct cfg80211_scan_info { * @channels: channels to scan on. * @n_channels: total number of channels to scan * @scan_width: channel width for scanning + * @chandef: defines the channel to do wide band scan * @ie: optional information element(s) to add into Probe Request or %NULL * @ie_len: length of ie in octets * @duration: how long to listen on each channel, in TUs. If @@ -1932,6 +1933,7 @@ struct cfg80211_scan_request { int n_ssids; u32 n_channels; enum nl80211_bss_scan_width scan_width; + struct cfg80211_chan_def *chandef; const u8 *ie; size_t ie_len; u16 duration; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 64135ab3a7ac..7b87e9a06d1f 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -5492,6 +5492,9 @@ enum nl80211_feature_flags { * @NL80211_EXT_FEATURE_SAE_OFFLOAD: Device wants to do SAE authentication in * station mode (SAE password is passed as part of the connect command). * + * @NL80211_EXT_FEATURE_WIDE_BAND_SCAN: Driver/device supports wide band scan + * on a frequency along with its corresponding phymode (40Mhz, 80Mhz) + * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. */ @@ -5537,6 +5540,7 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_EXT_KEY_ID, NL80211_EXT_FEATURE_STA_TX_PWR, NL80211_EXT_FEATURE_SAE_OFFLOAD, + NL80211_EXT_FEATURE_WIDE_BAND_SCAN, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, @@ -5648,6 +5652,8 @@ enum nl80211_timeout_reason { * @NL80211_SCAN_FLAG_MIN_PREQ_CONTENT: minimize probe request content to * only have supported rates and no additional capabilities (unless * added by userspace explicitly.) + * @NL80211_SCAN_FLAG_WIDE_BAND_SCAN: This flag intends the driver to perform + * wide band scan only if the driver supports it. */ enum nl80211_scan_flags { NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0, @@ -5663,6 +5669,7 @@ enum nl80211_scan_flags { NL80211_SCAN_FLAG_HIGH_ACCURACY = 1<<10, NL80211_SCAN_FLAG_RANDOM_SN = 1<<11, NL80211_SCAN_FLAG_MIN_PREQ_CONTENT = 1<<12, + NL80211_SCAN_FLAG_WIDE_BAND_SCAN = 1<<13, }; /** diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index 4d31d9688dc2..343c0c6e2ecb 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -688,11 +688,13 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata, local->hw_scan_req = kmalloc( sizeof(*local->hw_scan_req) + + sizeof(*req->chandef) + req->n_channels * sizeof(req->channels[0]) + local->hw_scan_ies_bufsize, GFP_KERNEL); if (!local->hw_scan_req) return -ENOMEM; + local->hw_scan_req->req.chandef = req->chandef; local->hw_scan_req->req.ssids = req->ssids; local->hw_scan_req->req.n_ssids = req->n_ssids; ies = (u8 *)local->hw_scan_req + diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index d1451e731bb8..67d29a309eb6 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -7476,7 +7476,10 @@ nl80211_check_scan_flags(struct wiphy *wiphy, struct wireless_dev *wdev, NL80211_EXT_FEATURE_SCAN_RANDOM_SN) || !nl80211_check_scan_feat(wiphy, *flags, NL80211_SCAN_FLAG_MIN_PREQ_CONTENT, - NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT)) + NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT) || + !nl80211_check_scan_feat(wiphy, *flags, + NL80211_SCAN_FLAG_WIDE_BAND_SCAN, + NL80211_EXT_FEATURE_WIDE_BAND_SCAN)) return -EOPNOTSUPP; if (*flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { @@ -7499,10 +7502,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct wireless_dev *wdev = info->user_ptr[1]; struct cfg80211_scan_request *request; + struct cfg80211_chan_def chandef; struct nlattr *attr; struct wiphy *wiphy; - int err, tmp, n_ssids = 0, n_channels, i; + int err, tmp, n_ssids = 0, n_channels = 0, i; size_t ie_len; + bool chandef_found = false; wiphy = &rdev->wiphy; @@ -7517,7 +7522,14 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto unlock; } - if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { + if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) { + n_channels = 1; + if (nl80211_parse_chandef(rdev, info, &chandef)) { + err = -EINVAL; + goto unlock; + } + chandef_found = true; + } else if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { n_channels = validate_scan_freqs( info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]); if (!n_channels) { @@ -7548,6 +7560,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) } request = kzalloc(sizeof(*request) + + sizeof(*request->chandef) + sizeof(*request->ssids) * n_ssids + sizeof(*request->channels) * n_channels + ie_len, GFP_KERNEL); @@ -7556,6 +7569,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto unlock; } + if (chandef_found) { + request->chandef = &chandef; + request->channels[0] = chandef.chan; + request->n_channels = n_channels; + } + if (n_ssids) request->ssids = (void *)&request->channels[n_channels]; request->n_ssids = n_ssids; @@ -7586,7 +7605,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) request->channels[i] = chan; i++; } - } else { + } else if (!chandef_found) { enum nl80211_band band; /* all channels */ @@ -7609,31 +7628,32 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) } } - if (!i) { - err = -EINVAL; - goto out_free; - } - - request->n_channels = i; - - wdev_lock(wdev); - if (!cfg80211_off_channel_oper_allowed(wdev)) { - struct ieee80211_channel *chan; - - if (request->n_channels != 1) { - wdev_unlock(wdev); - err = -EBUSY; + if (!chandef_found) { + if (!i) { + err = -EINVAL; goto out_free; } + request->n_channels = i; - chan = request->channels[0]; - if (chan->center_freq != wdev->chandef.chan->center_freq) { - wdev_unlock(wdev); - err = -EBUSY; - goto out_free; + wdev_lock(wdev); + if (!cfg80211_off_channel_oper_allowed(wdev)) { + struct ieee80211_channel *chan; + + if (request->n_channels != 1) { + wdev_unlock(wdev); + err = -EBUSY; + goto out_free; + } + + chan = request->channels[0]; + if (chan->center_freq != wdev->chandef.chan->center_freq) { + wdev_unlock(wdev); + err = -EBUSY; + goto out_free; + } } + wdev_unlock(wdev); } - wdev_unlock(wdev); i = 0; if (n_ssids) {