Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp285254ybb; Tue, 31 Mar 2020 23:23:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsAZmQBTWL5x0vUidtnqUryeySWsv1zTL8GDUVmeB+UIOmRqZv6LbR0SB/iJlbPKcfw/3mM X-Received: by 2002:a9d:27a7:: with SMTP id c36mr5973977otb.68.1585722190280; Tue, 31 Mar 2020 23:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585722190; cv=none; d=google.com; s=arc-20160816; b=FoESNy2/s3IzrxVpswAxkha/vFsdvInKP2UKywEAD6wJ7mdqrI2G3AdxvDarIpCinn kSZN27LrZgfyh7Y4VH65UXded59DeLaBjJ557KMaQGZav3jR1y9lVheMWaFtLzP+DQFq hvfy3H225280rXJc7U4IwKgoyon7Y1C9z02dhCveq8p9x1Z3BBLIPZ/DcPdAuS3bNfZD YvaykxoHMh1dumyH2I1ewbrTNH+HAfE6OXwH0eZEdmo9y2mjTFCJrkgDByVIreGvMJjM qPWrOpcQMja/hDz0kRQ5L2Y+L6CxFczwJeFygXr2aAHMTeJ6267ie4LF0ZvoRKdTDp11 hJ3Q== 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=vLvSIkE9qstJXEwm+Hv+NlZ3eD6wG97glu0vAd3g3Kw=; b=umM9WWzEM1xB2xBcSSCOjollUlzan9XiCTsmowiOapJgRcg1zoNQs8gAH3+jjAzUXI OJ3PjCWTQhfZdRz9TTpdBb9odz1TBJDOYqn2L4VkFyAHMJaTj/8vTMGWsk5K1Gq1Mm0m NkHp/E3VZ/kQfmAfw7QXbFtpq/53U7Mp8VsOgmAZ2E5M6r0/YuDrX7/tyxplNjwGV97Y s9Of5ASB0yFi8v9hEv9V1m4xLjlZLe8mev6S9Kf2VxHUX9XvxUDqscfn90WxMhk6smL6 HLTxB6FGMLi0iw9ade085aOlI7znqT9qB4HlOEBPQL7i2hnHFgDE3MVUoTdXFqVN+xAd Ctyg== 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 w83si511337oie.244.2020.03.31.23.22.59; Tue, 31 Mar 2020 23:23:10 -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 S1731839AbgDAGWI (ORCPT + 99 others); Wed, 1 Apr 2020 02:22:08 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:36698 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731741AbgDAGWI (ORCPT ); Wed, 1 Apr 2020 02:22:08 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id 131214F7A5A; Wed, 1 Apr 2020 06:22:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at web.adapt-ip.com Received: from web.adapt-ip.com ([127.0.0.1]) by localhost (web.adapt-ip.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KFgPqD099bWG; Wed, 1 Apr 2020 06:22:04 +0000 (UTC) Received: from atlas.campbell.adapt-ip.com (gateway.adapt-ip.com [173.164.178.20]) (Authenticated sender: thomas@adapt-ip.com) by web.adapt-ip.com (Postfix) with ESMTPSA id 739044F7A54; Wed, 1 Apr 2020 06:21:53 +0000 (UTC) From: Thomas Pedersen To: Johannes Berg Cc: linux-wireless , Thomas Pedersen Subject: [RFC 7/7] nl80211: accept scan frequencies in KHz Date: Tue, 31 Mar 2020 23:21:50 -0700 Message-Id: <20200401062150.3324-8-thomas@adapt-ip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401062150.3324-1-thomas@adapt-ip.com> References: <20200401062150.3324-1-thomas@adapt-ip.com> 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 NL80211_ATTR_SCAN_FREQUENCIES_KHZ are optional in addition to the MHz frequencies specified in NL80211_ATTR_SCAN_FREQUENCIES. Signed-off-by: Thomas Pedersen --- include/uapi/linux/nl80211.h | 2 ++ net/wireless/nl80211.c | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 28401f039d75..de80ae4f8aae 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -2430,6 +2430,7 @@ enum nl80211_commands { * @NL80211_ATTR_WIPHY_EDMG_BW_CONFIG: Channel BW Configuration subfield encodes * the allowed channel bandwidth configurations. (u8 attribute) * Defined by IEEE P802.11ay/D4.0 section 9.4.2.251, Table 13. + * @NL80211_ATTR_SCAN_FREQUENCIES_KHZ: nested attribute with frequencies (in KHz) * * @NL80211_ATTR_VLAN_ID: VLAN ID (1..4094) for the station and VLAN group key * (u16). @@ -2957,6 +2958,7 @@ enum nl80211_attrs { NL80211_ATTR_WIPHY_FREQ_OFFSET, NL80211_ATTR_CENTER_FREQ1_OFFSET, + NL80211_ATTR_SCAN_FREQUENCIES_KHZ, /* add attributes here, update the policy in nl80211.c */ diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ea9310f6d981..5a8a30282bf2 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -665,6 +665,7 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_PMK_LIFETIME] = NLA_POLICY_MIN(NLA_U32, 1), [NL80211_ATTR_PMK_REAUTH_THRESHOLD] = NLA_POLICY_RANGE(NLA_U8, 1, 100), [NL80211_ATTR_WIPHY_FREQ_OFFSET] = { .type = NLA_U32 }, + [NL80211_ATTR_SCAN_FREQUENCIES_KHZ] = { .type = NLA_NESTED }, }; /* policy for the key attributes */ @@ -7749,6 +7750,8 @@ 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 nlattr *scan_freqs = NULL; + bool scan_freqs_khz = false; struct nlattr *attr; struct wiphy *wiphy; int err, tmp, n_ssids = 0, n_channels, i; @@ -7767,9 +7770,14 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto unlock; } - if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { - n_channels = validate_scan_freqs( - info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]); + if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES_KHZ]) { + scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQUENCIES_KHZ]; + scan_freqs_khz = true; + } else if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) + scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]; + + if (scan_freqs) { + n_channels = validate_scan_freqs(scan_freqs); if (!n_channels) { err = -EINVAL; goto unlock; @@ -7817,13 +7825,16 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) } i = 0; - if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { + if (scan_freqs) { /* user specified, bail out if channel not found */ - nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_FREQUENCIES], tmp) { + nla_for_each_nested(attr, scan_freqs, tmp) { struct ieee80211_channel *chan; + int freq = nla_get_u32(attr); - chan = ieee80211_get_channel(wiphy, nla_get_u32(attr)); + if (!scan_freqs_khz) + freq = MHZ_TO_KHZ(freq); + chan = ieee80211_get_channel_khz(wiphy, freq); if (!chan) { err = -EINVAL; goto out_free; -- 2.20.1