Search Linux Wireless

[PATCH v3 8/9] wifi: cfg80211: fix chandef identical logic for 6 GHz chandefs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux