diff mbox series

[v3,1/9] cfg80211: Add helper function to identify 6GHz PSC channel

Message ID 20200526224217.11119-2-pradeepc@codeaurora.org
State New
Headers show
Series add 6GHz radio support in ath11k driver | expand

Commit Message

Pradeep Kumar Chitrapu May 26, 2020, 10:42 p.m. UTC
6GHz channels are divided into preferred scanning channels(PSC)
and non-PSC channels. One in every four 20MHz channels is a PSC.
Spec mandates to use only PSC channels as primary channels for
setting up BSS on 6GHz only AP.

The set of 20 MHz channels in the 6 GHz band, with channel center
frequency, ch_a = Channel starting frequency – 55 + 80 × n (MHz)
are referred to as preferred scanning channels (PSCs) where,
n = 1, …, 15 as per IEEE P802.11ax/D6.1.

This function can be used by drivers or cfg80211 when making
scanning decision on 6GHz channels.

Signed-off-by: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
---
v3:
 - update channel starting frequency from 5945 to 5950 as per
   IEEE P802.11ax/D6.1
 - Define helper function and remove cahnnel flag PSC

 include/net/cfg80211.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fd6a973b1249..bd27020ea8c9 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5281,6 +5281,30 @@  ieee80211_get_channel(struct wiphy *wiphy, int freq)
 	return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq));
 }
 
+/**
+ * ieee80211_is_channel_psc - is 6ghz channel a Preferred Scanning Channel (PSC)
+ *
+ * @chan: struct ieee80211_channel to determine
+ * Return: True if 6ghz channel is a PSC channel. False for the rest.
+ */
+static inline bool ieee80211_is_channel_psc(struct ieee80211_channel *chan)
+{
+	if (chan->band != NL80211_BAND_6GHZ)
+		return false;
+
+	/*
+	 * From IEEE P802.11ax/D6.1: The set of 20 MHz channels in the 6 GHz
+	 * band, with channel center frequency, ch_a = Channel starting
+	 * frequency – 55  80 × n (MHz) are referred to as preferred scanning
+	 * channels (PSCs). Channel starting frequency is defined in 27.3.23.2
+	 * (Channel allocation in the 6 GHz band), and n = 1, …, 15.
+	 */
+	if (!(((chan->center_freq - 5950 + 55) >> 4) % 5))
+		return true;
+
+	return false;
+}
+
 /**
  * ieee80211_get_response_rate - get basic rate for a given rate
  *