2020-05-18 16:45:54

by Pradeep Kumar Chitrapu

[permalink] [raw]
Subject: [PATCH 1/9] cfg80211: Add new channel flag to identify 6GHz PSC channel

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.0.

This flag also will be used when making scanning decision on
6GHz channels.

Signed-off-by: Pradeep Kumar Chitrapu <[email protected]>
---
include/net/cfg80211.h | 2 ++
net/wireless/reg.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fd6a973b1249..ca3e9df7adfe 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -96,6 +96,7 @@ struct wiphy;
* @IEEE80211_CHAN_NO_10MHZ: 10 MHz bandwidth is not permitted
* on this channel.
* @IEEE80211_CHAN_NO_HE: HE operation is not permitted on this channel.
+ * @IEEE80211_CHAN_PSC: 6GHz Channel is Preferred Scanning Channel(PSC)
*
*/
enum ieee80211_channel_flags {
@@ -113,6 +114,7 @@ enum ieee80211_channel_flags {
IEEE80211_CHAN_NO_20MHZ = 1<<11,
IEEE80211_CHAN_NO_10MHZ = 1<<12,
IEEE80211_CHAN_NO_HE = 1<<13,
+ IEEE80211_CHAN_PSC = 1<<14,
};

#define IEEE80211_CHAN_NO_HT40 \
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 0d74a31ef0ab..4ebaa57e60e4 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2023,6 +2023,21 @@ static bool is_ht40_allowed(struct ieee80211_channel *chan)
return true;
}

+static bool reg_is_6ghz_channel_psc(struct ieee80211_channel *chan)
+{
+ /*
+ * From IEEE P802.11ax/D6.0: 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 - 5940 + 55) >> 4) % 5))
+ return true;
+
+ return false;
+}
+
static void reg_process_ht_flags_channel(struct wiphy *wiphy,
struct ieee80211_channel *channel)
{
@@ -2305,6 +2320,10 @@ static void handle_channel_custom(struct wiphy *wiphy,
else
chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags;

+ if (chan->band == NL80211_BAND_6GHZ &&
+ reg_is_6ghz_channel_psc(chan))
+ chan->flags |= IEEE80211_CHAN_PSC;
+
chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain);
chan->max_reg_power = chan->max_power =
(int) MBM_TO_DBM(power_rule->max_eirp);
--
2.17.1