Message ID | 20200526224217.11119-2-pradeepc@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | add 6GHz radio support in ath11k driver | expand |
On Tue, 2020-05-26 at 15:42 -0700, Pradeep Kumar Chitrapu wrote: Hi, Just checked what we had here, and it was the following: > +/** > + * 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; > +} static inline bool cfg80211_is_psc(struct ieee80211_channel *chan) { int chan_num = ieee80211_frequency_to_channel(chan->center_freq); return chan->band == NL80211_BAND_6GHZ && chan_num % 16 == 5; } Apart from the naming, where I guess I prefer actually cfg80211_channel_is_psc() or so, does that seem reasonable to you? I'd prefer not to hardcode frequencies everywhere, so in that regard I like our version better. Maybe bail out earlier if band != 6 ghz: 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; } johannes
> 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; > } > > johannes sure Johannes. Above looks neat. Thanks pradeep
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 *
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(+)