From: Amar Singhal <asinghal@codeaurora.org>
To: jouni@codeaurora.org
Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org,
jjohnson@codeaurora.org, rmanohar@codeaurora.org,
Amar Singhal <asinghal@codeaurora.org>
Subject: [PATCH] cfg80211: Add new helper function for channels
Date: Thu, 29 Aug 2019 14:49:41 -0700 [thread overview]
Message-ID: <1567115381-7831-1-git-send-email-asinghal@codeaurora.org> (raw)
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 <asinghal@codeaurora.org>
---
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
next reply other threads:[~2019-08-29 21:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 21:49 Amar Singhal [this message]
2019-08-30 7:16 ` [PATCH] cfg80211: Add new helper function for channels Johannes Berg
2019-08-30 10:40 ` Arend Van Spriel
2019-08-30 10:41 ` Johannes Berg
2019-08-30 11:03 ` Arend Van Spriel
2019-08-30 14:09 ` Jeff Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1567115381-7831-1-git-send-email-asinghal@codeaurora.org \
--to=asinghal@codeaurora.org \
--cc=jjohnson@codeaurora.org \
--cc=johannes@sipsolutions.net \
--cc=jouni@codeaurora.org \
--cc=linux-wireless@vger.kernel.org \
--cc=rmanohar@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.