From bdb178cf071a538562e6fff2c3679430da81eb57 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 28 May 2020 21:34:25 +0200 Subject: [PATCH] BACKPORT: cfg80211: add a helper to identify 6 GHz PSCs This allows identifying whether or not a channel is a PSC (preferred scanning channel). Bug: 163110886 Link: https://lore.kernel.org/r/20200528213443.414363ecf62c.Ic15e681a0e249eab7350a06ceb582cca8bb9a080@changeid Signed-off-by: Johannes Berg Change-Id: Ia0b369ead18ce1d1e585df9467d680be4aa8adef (cherry picked from commit afbc9c9e8bfe71e8bd12a8c01bedd969fbab8f0e) Signed-off-by: Vamsi Krishna Signed-off-by: Greg Kroah-Hartman --- include/net/cfg80211.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index f80c865dd6dd..473323307e9f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5209,6 +5209,21 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq) return ieee80211_get_channel_khz(wiphy, MHZ_TO_KHZ(freq)); } +/** + * cfg80211_channel_is_psc - Check if the channel is a 6 GHz PSC + * @chan: control channel to check + * + * The Preferred Scanning Channels (PSC) are defined in + * Draft IEEE P802.11ax/D5.0, 26.17.2.3.3 + */ +static inline bool cfg80211_channel_is_psc(struct ieee80211_channel *chan) +{ + if (chan->band != NL80211_BAND_6GHZ) + return false; + + return ieee80211_frequency_to_channel(chan->center_freq) % 16 == 5; +} + /** * ieee80211_get_response_rate - get basic rate for a given rate *