From: Aditya Kumar Singh <quic_adisi@quicinc.com>
To: <johannes@sipsolutions.net>
Cc: <linux-wireless@vger.kernel.org>,
Aditya Kumar Singh <quic_adisi@quicinc.com>
Subject: [PATCH v3 8/9] wifi: cfg80211: fix chandef identical logic for 6 GHz chandefs
Date: Wed, 15 Mar 2023 18:59:03 +0530 [thread overview]
Message-ID: <20230315132904.31779-9-quic_adisi@quicinc.com> (raw)
In-Reply-To: <20230315132904.31779-1-quic_adisi@quicinc.com>
Currently, two chandefs are identical if they point to the same
ieee80211_channel as well as other members of the chandef are same.
However, with 6 GHz regulatory power modes changes, now 6 GHz channel
can be picked from different channel pool and hence there can be a
scenario where chandefs are actually idenatical but the channels are
from a different pool (for example - AP-STA concurrency case).
In this situation, the above logic will fail.
Hence, for 6 GHz, instead of comparing the pointers, members inside
ieee80211_channel can be compared and if they are same along with above
condition then chandef can be assumed to be identical.
Fix the same for 6 GHz channel comparison.
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
---
include/net/cfg80211.h | 41 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 36 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 0120a520c58e..2f11b2451efe 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -903,6 +903,31 @@ void cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
struct ieee80211_channel *channel,
enum nl80211_channel_type chantype);
+/**
+ * cfg80211_6ghz_channel_identical - check if two 6 GHz channel definitions are
+ * identical
+ * @channel1: first channel definition
+ * @channel2: second channel definition
+ *
+ * Return: %true if the channels are identical except for the flags and power
+ * related settings, %false otherwise.
+ */
+static inline bool
+cfg80211_6ghz_channel_identical(struct ieee80211_channel *channel1,
+ struct ieee80211_channel *channel2)
+{
+ if (!channel1 || !channel2)
+ return false;
+
+ if (channel1->band == channel2->band &&
+ channel1->band != NL80211_BAND_6GHZ)
+ return false;
+
+ return (channel1->band == channel2->band &&
+ channel1->center_freq == channel2->center_freq &&
+ channel1->freq_offset == channel2->freq_offset);
+}
+
/**
* cfg80211_chandef_identical - check if two channel definitions are identical
* @chandef1: first channel definition
@@ -915,11 +940,17 @@ static inline bool
cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1,
const struct cfg80211_chan_def *chandef2)
{
- return (chandef1->chan == chandef2->chan &&
- chandef1->width == chandef2->width &&
- chandef1->center_freq1 == chandef2->center_freq1 &&
- chandef1->freq1_offset == chandef2->freq1_offset &&
- chandef1->center_freq2 == chandef2->center_freq2);
+ bool same_chan = chandef1->chan == chandef2->chan;
+ bool same_chand_def_prop = chandef1->width == chandef2->width &&
+ chandef1->center_freq1 == chandef2->center_freq1 &&
+ chandef1->freq1_offset == chandef2->freq1_offset &&
+ chandef1->center_freq2 == chandef2->center_freq2;
+
+ if (!same_chan)
+ same_chan = cfg80211_6ghz_channel_identical(chandef1->chan,
+ chandef2->chan);
+
+ return (same_chan && same_chand_def_prop);
}
/**
--
2.17.1
next prev parent reply other threads:[~2023-03-15 13:30 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 13:28 [PATCH v3 0/9] wifi: cfg80211/mac80211: extend 6 GHz support for all power modes Aditya Kumar Singh
2023-03-15 13:28 ` [PATCH v3 1/9] wifi: mac80211: rework on 6 GHz power type definition Aditya Kumar Singh
2023-03-15 13:28 ` [PATCH v3 2/9] wifi: cfg80211: save Power Spectral Density (PSD) of the regulatory rule Aditya Kumar Singh
2023-09-13 14:58 ` Johannes Berg
2023-09-14 3:15 ` Jeff Johnson
2023-09-14 3:59 ` Wen Gong
2023-12-22 3:57 ` [wireless-regdb] " Chen-Yu Tsai
2023-12-22 8:08 ` Kalle Valo
2023-09-14 3:45 ` Wen Gong
2023-09-14 7:18 ` Johannes Berg
2023-03-15 13:28 ` [PATCH v3 3/9] wifi: mac80211: add combined power type definition for 6 GHz Aditya Kumar Singh
2023-03-15 13:28 ` [PATCH v3 4/9] wifi: cfg80211: add NL command to set 6 GHz power mode Aditya Kumar Singh
2023-08-29 17:51 ` Johannes Berg
2023-08-30 5:05 ` Aditya Kumar Singh
2023-08-30 7:41 ` Johannes Berg
2023-08-30 7:50 ` Aditya Kumar Singh
2023-03-15 13:29 ` [PATCH v3 5/9] wifi: mac80211: add support for 6 GHz channels and regulatory Aditya Kumar Singh
2023-03-15 13:29 ` [PATCH v3 6/9] wifi: cfg80211: rework nl80211_parse_chandef for 6 GHz Aditya Kumar Singh
2023-03-15 13:29 ` [PATCH v3 7/9] wifi: cfg80211: save 6 GHz power mode of the regulatory rules Aditya Kumar Singh
2023-03-15 13:29 ` Aditya Kumar Singh [this message]
2023-03-15 13:29 ` [PATCH v3 9/9] wifi: mac80211: use proper API to fetch 6 GHz channel Aditya Kumar Singh
2023-03-17 5:22 ` Kalle Valo
2023-04-14 8:24 ` [PATCH v3 0/9] wifi: cfg80211/mac80211: extend 6 GHz support for all power modes Aditya Kumar Singh
2023-06-09 5:41 ` Wen Gong
2023-07-27 7:48 ` Wen Gong
2023-07-28 4:38 ` Kalle Valo
2023-08-29 17:50 ` Johannes Berg
2023-08-30 5:13 ` Aditya Kumar Singh
2023-08-30 7:44 ` Johannes Berg
2023-08-30 8:00 ` Aditya Kumar Singh
2023-08-30 5:24 ` Aditya Kumar Singh
2023-09-13 10:35 ` Wen Gong
2023-09-13 14:55 ` Johannes Berg
2023-09-13 21:47 ` 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=20230315132904.31779-9-quic_adisi@quicinc.com \
--to=quic_adisi@quicinc.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).