Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2909359ybl; Thu, 29 Aug 2019 14:56:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQJ01p8tz8HBKyN3SvcZh0bNmCfLdVmGv07Ehj6g7RdH3D89H0TuWdK1Hrqd/JcRL85np3 X-Received: by 2002:a65:6495:: with SMTP id e21mr10325215pgv.359.1567115785484; Thu, 29 Aug 2019 14:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567115785; cv=none; d=google.com; s=arc-20160816; b=j3WqlPAWgYEV56H/2yrEaBKrr0yUzxdgn2vM57a01jqbabMh6ooNQLkgap8mJJO6L2 I/+eAONGckavk8iEEBWTwCdSw2L6vsjJ+CXBHaPJA4n7pRVRyj9Z2GMRrRnBsnxe/m0w sBnDNz8WMamlX3rw6y0lkpkh9CaHh/+ZjhSCo4fS413cSIrE71hV3c/m1+VimJWCDUPr 9+6mVgdZipczqwdOhpin0Lht/EsBbTf/K8N7k2ygoSBRkD1/ox80FeRWqeaeajczUJ7H /OHJUVEsL0uCzZiUxWRw84dBvfnx0UKIPz06uThwOqtaFRqgjQJ+z9LWk7iayhZf4K3i EqrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=B6/ieiVkGVxzOWihp+U6TbLTi2JSEcyMcQ6mdKM8kQg=; b=B770iHGBsU996MgxrEmqSTH7HspVI9uSkFzqNYk/PtmDq/fV6PS0lzwxD5FxtJ3gL5 XrPjJTWLTIREA7LgJqca2dmqEA7ol7YaLaem6bwpdrAA+QwFxbmwW748S2qC1aYPyoXx LBAC+LAvPuX5WcWpomWO64wHweNXTIceCafjoKZq8HYDU/T//IpeJBqSs6xRXqnVn2hn pbDUJAnTB+uyR0f3U45bEBQwdf7aOD6emlu5TQmbe3jcOy6TI4O53D/ckGypq0hna4M2 C+1gvXorO/y8S3q2gLXek20amcGNC3mfjJITjrOUqBeXf1WXmsE9Wq+VAaj9fj33qrOk aAKA== 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 x12si3179913pgq.220.2019.08.29.14.55.59; Thu, 29 Aug 2019 14:56:25 -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 S1727826AbfH2Vzs (ORCPT + 99 others); Thu, 29 Aug 2019 17:55:48 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:3609 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbfH2Vzs (ORCPT ); Thu, 29 Aug 2019 17:55:48 -0400 X-Greylist: delayed 361 seconds by postgrey-1.27 at vger.kernel.org; Thu, 29 Aug 2019 17:55:47 EDT Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 29 Aug 2019 14:49:46 -0700 Received: from asinghal-linux.qualcomm.com ([10.234.220.60]) by ironmsg03-sd.qualcomm.com with ESMTP; 29 Aug 2019 14:49:46 -0700 Received: by asinghal-linux.qualcomm.com (Postfix, from userid 73644) id 3DC8A36AC; Thu, 29 Aug 2019 14:49:46 -0700 (PDT) From: Amar Singhal To: jouni@codeaurora.org Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, jjohnson@codeaurora.org, rmanohar@codeaurora.org, Amar Singhal Subject: [PATCH] cfg80211: Add new helper function for channels Date: Thu, 29 Aug 2019 14:49:41 -0700 Message-Id: <1567115381-7831-1-git-send-email-asinghal@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add new helper function to convert (chan_number, oper_class) pair to frequency. Call this function ieee80211_channel_op_class_to_frequency. This function would be very useful in the context of 6 GHz channels, where channel number is not unique. Signed-off-by: Amar Singhal --- include/net/cfg80211.h | 10 ++++++++++ net/wireless/util.c | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 6467b60..decafba 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4914,1 +4914,1 @@ static inline void *wdev_priv(struct wireless_dev *wdev) int ieee80211_channel_to_frequency(int chan, enum nl80211_band band); /** + * ieee80211_channel_op_class_to_frequency - convert + * (channel, operating class) to frequency + * @chan_num: channel number + * @global_op_class: global operating class + * + * Return: The corresponding frequency, or 0 if the conversion failed. + */ +int ieee80211_channel_op_class_to_frequency(u8 chan_num, u8 global_op_class); + +/** * ieee80211_frequency_to_channel - convert frequency to channel number * @freq: center frequency * Return: The corresponding channel, or 0 if the conversion failed. diff --git a/net/wireless/util.c b/net/wireless/util.c index 9aba8d54..7f64b4a 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -144,6 +144,29 @@ struct ieee80211_channel *ieee80211_get_channel(struct wiphy *wiphy, int freq) } EXPORT_SYMBOL(ieee80211_get_channel); +int ieee80211_channel_op_class_to_frequency(u8 chan_num, u8 global_op_class) +{ + if (global_op_class >= 131 && global_op_class <= 135) + return (5940 + 5 * chan_num); + else if (global_op_class >= 115 && global_op_class <= 130) + return (5000 + 5 * chan_num); + else if (global_op_class >= 112 && global_op_class <= 113) + return (5000 + 5 * chan_num); + else if (global_op_class >= 109 && global_op_class <= 110) + return (4000 + 5 * chan_num); + else if (global_op_class >= 83 && global_op_class <= 84) + return (2407 + 5 * chan_num); + else if (global_op_class == 81) + return (2407 + 5 * chan_num); + else if (global_op_class == 82) + return (2414 + 5 * chan_num); + else if (global_op_class == 180) + return (56160 + 5 * chan_num); + else + return 0; +} +EXPORT_SYMBOL(ieee80211_channel_op_class_to_frequency); + static void set_mandatory_flags_band(struct ieee80211_supported_band *sband) { int i, want; -- 1.9.1