blob: 54b59e121e4e00d0b6fef46a08e9f6bf8a6b5e4a [file] [log] [blame]
developer4e85d132023-09-06 16:30:15 +08001From e7247da28b7d7e90abd9ced10438df1cbe59af7e Mon Sep 17 00:00:00 2001
2From: Michael-CY Lee <michael-cy.lee@mediatek.com>
3Date: Thu, 28 Sep 2023 09:28:50 +0800
4Subject: mac80211: mtk: refactor STA CSA parsing flows
5
6This patch changes the flows when STA parses csa IE:
7
81. If Extended CSA IE is presented, this patch uses the subfield op_class
9 to build the VHT and HE operation in 5 GHz and 6 GHz, respectively.
102. If Extended CSA IE is NOT presented but the Wide Bandwidth Channel
11 Switch IE is presented, the new channel width is at least 40 MHz.
12 Therefore this patch first prepares a 40 MHz chandef, then build the
13 VHT and HE operation in 5 GHz and 6 GHz, respectively.
14 Note that in a 6 GHz BSS, the subfield of Wide Bandwidth Channel Switch
15 IE might be the VHT, deprecated VHT or HE operation, so this patch
16 checks the combination of new channel width, ccfs0 and ccfs1 to build
17 the correct HE operation.
183. From the HE/VHT operation created in step 1 or 2, this patch then
19 creates the chandef and assigns it to csa_ie.
20
21Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
22---
23 net/mac80211/spectmgmt.c | 508 ++++++++++++++++++++++++++++++++++-----
24 1 file changed, 454 insertions(+), 54 deletions(-)
25
26diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c
27index 871cdac..dee7a60 100644
28--- a/net/mac80211/spectmgmt.c
29+++ b/net/mac80211/spectmgmt.c
30@@ -19,6 +19,332 @@
31 #include "sta_info.h"
32 #include "wme.h"
33
34+static inline void
35+op_class_to_6ghz_he_eht_oper(u8 op_class, struct ieee80211_channel *chan,
36+ struct ieee80211_he_operation *he_oper,
37+ struct ieee80211_eht_operation *eht_oper)
38+{
39+ u8 new_chan_width;
40+ u32 he_oper_params, center_freq1 = 0, center_freq2 = 0;
41+ struct ieee80211_he_6ghz_oper *he_6ghz_oper;
42+ struct ieee80211_eht_operation_info *eht_oper_info;
43+
44+ new_chan_width = ieee80211_operating_class_to_chan_width(op_class);
45+ if (!ieee80211_operating_class_to_center_freq(op_class, chan,
46+ &center_freq1,
47+ &center_freq2)) {
48+ new_chan_width = NL80211_CHAN_WIDTH_20;
49+ center_freq1 = chan->center_freq;
50+ }
51+
52+ he_oper_params =
53+ u32_encode_bits(1, IEEE80211_HE_OPERATION_6GHZ_OP_INFO);
54+ he_oper->he_oper_params = cpu_to_le32(he_oper_params);
55+
56+ he_6ghz_oper = (struct ieee80211_he_6ghz_oper *)he_oper->optional;
57+ he_6ghz_oper->primary =
58+ ieee80211_frequency_to_channel(chan->center_freq);
59+ he_6ghz_oper->ccfs0 = ieee80211_frequency_to_channel(center_freq1);
60+ he_6ghz_oper->ccfs1 = center_freq2 ?
61+ ieee80211_frequency_to_channel(center_freq2) : 0;
62+
63+ switch (new_chan_width) {
64+ case NL80211_CHAN_WIDTH_320:
65+ /* Cannot derive center frequency for 320 MHZ from op_class
66+ * since it might be 320-1 or 320-2
67+ */
68+ WARN_ON(1);
69+ break;
70+ case NL80211_CHAN_WIDTH_160:
71+ he_6ghz_oper->ccfs1 = he_6ghz_oper->ccfs0;
72+ he_6ghz_oper->ccfs0 += chan->center_freq < center_freq1 ? -8 : 8;
73+ fallthrough;
74+ case NL80211_CHAN_WIDTH_80P80:
75+ he_6ghz_oper->control =
76+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ;
77+ break;
78+ case NL80211_CHAN_WIDTH_80:
79+ he_6ghz_oper->control =
80+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ;
81+ break;
82+ case NL80211_CHAN_WIDTH_40:
83+ he_6ghz_oper->control =
84+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ;
85+ break;
86+ default:
87+ he_6ghz_oper->control =
88+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_20MHZ;
89+ break;
90+ }
91+
92+ eht_oper->params = IEEE80211_EHT_OPER_INFO_PRESENT;
93+
94+ eht_oper_info =
95+ (struct ieee80211_eht_operation_info *)eht_oper->optional;
96+ eht_oper_info->control = he_6ghz_oper->control;
97+ eht_oper_info->ccfs0 = he_6ghz_oper->ccfs0;
98+ eht_oper_info->ccfs1 = he_6ghz_oper->ccfs1;
99+}
100+
101+static inline void
102+wbcs_ie_to_6ghz_he_eht_oper(const struct ieee80211_wide_bw_chansw_ie *wbcs_ie,
103+ u8 new_chan_no,
104+ struct ieee80211_he_operation *he_oper,
105+ struct ieee80211_eht_operation *eht_oper)
106+{
107+ u32 he_oper_params;
108+ struct ieee80211_he_6ghz_oper *he_6ghz_oper;
109+ struct ieee80211_eht_operation_info *eht_oper_info;
110+ bool fallback_20mhz;
111+ u8 ccfs_diff;
112+
113+ he_oper_params =
114+ u32_encode_bits(1, IEEE80211_HE_OPERATION_6GHZ_OP_INFO);
115+ he_oper->he_oper_params = cpu_to_le32(he_oper_params);
116+
117+ he_6ghz_oper = (struct ieee80211_he_6ghz_oper *)he_oper->optional;
118+ he_6ghz_oper->primary = new_chan_no;
119+
120+ /* The Wide Bandwidth Channel Switch IE in a 6 GHz BSS migth be
121+ * deprecated VHT operation, VHT operation (IEEE 802.11-2020 9.4.2.160)
122+ * or HE operation (IEEE P80211be D3.2 9.4.2.159).
123+ * Check the combination of width, ccfs0 and ccfs1 to build the correct
124+ * HE/EHT operation.
125+ */
126+ he_6ghz_oper->ccfs0 = wbcs_ie->new_center_freq_seg0;
127+ he_6ghz_oper->ccfs1 = wbcs_ie->new_center_freq_seg1;
128+ switch (wbcs_ie->new_channel_width) {
129+ case 0:
130+ /* Must be [deprecated] VHT operation with 40 MHz bandwidth */
131+ he_6ghz_oper->control =
132+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ;
133+ break;
134+ case 1:
135+ if (he_6ghz_oper->ccfs1) {
136+ /* VHT operation with 160/80P80 MHz bandwidth */
137+ he_6ghz_oper->control =
138+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ;
139+ } else if ((he_6ghz_oper->ccfs0 - 7) % 16 == 0) {
140+ /* [deprecated] VHT operation with 80 MHz bandwidth */
141+ he_6ghz_oper->control =
142+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ;
143+ } else {
144+ /* HE operation with 40 MHz bandwidth */
145+ he_6ghz_oper->control =
146+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ;
147+ }
148+ break;
149+ case 2:
150+ if ((he_6ghz_oper->ccfs0 - 15) % 32 == 0) {
151+ /* deprecated VHT operation with 160 MHz bandwidth */
152+ he_6ghz_oper->control =
153+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ;
154+ he_6ghz_oper->ccfs1 = he_6ghz_oper->ccfs0;
155+ he_6ghz_oper->ccfs0 +=
156+ new_chan_no < he_6ghz_oper->ccfs0 ? -8 : 8;
157+ } else {
158+ /* HE operation with 80 MHz bandwidth */
159+ he_6ghz_oper->control =
160+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ;
161+ }
162+ break;
163+ case 3:
164+ /* Can be
165+ * 1. deprecated VHT operation with 80P80 MHz bandwidth
166+ * 2. HE operation with 160/80P80 MHz bandwidth
167+ */
168+ he_6ghz_oper->control =
169+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ;
170+ break;
171+ case 4:
172+ /* 320 MHz bandwidth
173+ * TODO channel switch to 320 MHz bandwidth should be indiated
174+ * by Bandwidth Indication IE (IEEE P80211be D3.2 9.4.2.159)
175+ */
176+ he_6ghz_oper->control = IEEE80211_EHT_OPER_CHAN_WIDTH_320MHZ;
177+ break;
178+ default:
179+ /* Ignore invalid width */
180+ break;
181+ }
182+
183+ /* Validate the relationship between new channel width and center frequency
184+ * segments, and fallback to 20 MHz if the relationship is wrong.
185+ */
186+ fallback_20mhz = false;
187+ switch (he_6ghz_oper->control) {
188+ case IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_40MHZ:
189+ if ((he_6ghz_oper->ccfs0 - 3) % 8 != 0)
190+ fallback_20mhz = true;
191+ break;
192+ case IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_80MHZ:
193+ if ((he_6ghz_oper->ccfs0 - 7) % 16 != 0)
194+ fallback_20mhz = true;
195+ break;
196+ case IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_160MHZ:
197+ ccfs_diff = abs(he_6ghz_oper->ccfs1 - he_6ghz_oper->ccfs0);
198+ if ((ccfs_diff == 8 && (he_6ghz_oper->ccfs1 - 15) % 32 != 0) ||
199+ (ccfs_diff > 16 && ((he_6ghz_oper->ccfs0 - 7) % 16 != 0 ||
200+ (he_6ghz_oper->ccfs1 - 7) % 16 != 0)))
201+ fallback_20mhz = true;
202+ break;
203+ case IEEE80211_EHT_OPER_CHAN_WIDTH_320MHZ:
204+ if ((he_6ghz_oper->ccfs1 - 31) % 32 != 0)
205+ fallback_20mhz = true;
206+ break;
207+ }
208+
209+ if (fallback_20mhz) {
210+ he_6ghz_oper->control =
211+ IEEE80211_HE_6GHZ_OPER_CTRL_CHANWIDTH_20MHZ;
212+ he_6ghz_oper->ccfs0 = he_6ghz_oper->primary;
213+ he_6ghz_oper->ccfs1 = 0;
214+ }
215+
216+ eht_oper->params = IEEE80211_EHT_OPER_INFO_PRESENT;
217+ eht_oper_info =
218+ (struct ieee80211_eht_operation_info *)eht_oper->optional;
219+ eht_oper_info->control = he_6ghz_oper->control;
220+ eht_oper_info->ccfs0 = he_6ghz_oper->ccfs0;
221+ eht_oper_info->ccfs1 = he_6ghz_oper->ccfs1;
222+}
223+
224+static inline void
225+op_class_to_ht_vht_oper(u8 op_class, struct ieee80211_channel *chan,
226+ struct ieee80211_ht_operation *ht_oper,
227+ struct ieee80211_vht_operation *vht_oper)
228+{
229+ u8 new_chan_width;
230+ u32 center_freq1 = 0, center_freq2 = 0;
231+
232+ new_chan_width = ieee80211_operating_class_to_chan_width(op_class);
233+ if (!ieee80211_operating_class_to_center_freq(op_class, chan,
234+ &center_freq1,
235+ &center_freq2)) {
236+ new_chan_width = NL80211_CHAN_WIDTH_20;
237+ center_freq1 = chan->center_freq;
238+ }
239+
240+ vht_oper->center_freq_seg0_idx =
241+ ieee80211_frequency_to_channel(center_freq1);
242+ vht_oper->center_freq_seg1_idx = center_freq2 ?
243+ ieee80211_frequency_to_channel(center_freq2) : 0;
244+
245+ ht_oper->ht_param = (chan->center_freq / 20) & 1 ?
246+ IEEE80211_HT_PARAM_CHA_SEC_ABOVE :
247+ IEEE80211_HT_PARAM_CHA_SEC_BELOW;
248+
249+ switch (new_chan_width) {
250+ case NL80211_CHAN_WIDTH_320:
251+ WARN_ON(1);
252+ break;
253+ case NL80211_CHAN_WIDTH_160:
254+ vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
255+ vht_oper->center_freq_seg1_idx = vht_oper->center_freq_seg0_idx;
256+ vht_oper->center_freq_seg0_idx +=
257+ chan->center_freq < center_freq1 ? -8 : 8;
258+ break;
259+ case NL80211_CHAN_WIDTH_80P80:
260+ vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
261+ break;
262+ case NL80211_CHAN_WIDTH_80:
263+ vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_80MHZ;
264+ break;
265+ default:
266+ vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT;
267+ if (chan->center_freq != center_freq1)
268+ ht_oper->ht_param = chan->center_freq > center_freq1 ?
269+ IEEE80211_HT_PARAM_CHA_SEC_BELOW :
270+ IEEE80211_HT_PARAM_CHA_SEC_ABOVE;
271+ else
272+ ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
273+ }
274+
275+ ht_oper->operation_mode =
276+ cpu_to_le16(vht_oper->center_freq_seg1_idx <<
277+ IEEE80211_HT_OP_MODE_CCFS2_SHIFT);
278+}
279+
280+static inline void
281+wbcs_ie_to_ht_vht_oper(struct ieee80211_channel *chan,
282+ const struct ieee80211_wide_bw_chansw_ie *wbcs_ie,
283+ struct ieee80211_ht_operation *ht_oper,
284+ struct ieee80211_vht_operation *vht_oper)
285+{
286+ u8 new_chan_width, new_ccfs0, new_ccfs1;
287+ bool fallback_20mhz;
288+
289+ new_chan_width = wbcs_ie->new_channel_width;
290+ new_ccfs0 = wbcs_ie->new_center_freq_seg0;
291+ new_ccfs1 = wbcs_ie->new_center_freq_seg1;
292+
293+ /* Validate the relationship between new channel width and center frequency
294+ * segments, and fallback to 20 MHz if the relationship is wrong.
295+ */
296+ fallback_20mhz = false;
297+ switch (new_chan_width) {
298+ case IEEE80211_VHT_CHANWIDTH_USE_HT:
299+ /* If the wide bandwidth channel switch IE is presented,
300+ * the new channel width is at least 40 MHz.
301+ */
302+ if (!new_ccfs1) {
303+ new_ccfs0 -= (new_ccfs0 >= 149) ? 151 : 38;
304+ if (new_ccfs0 % 8 != 0)
305+ fallback_20mhz = true;
306+ } else {
307+ fallback_20mhz = true;
308+ }
309+ break;
310+ case IEEE80211_VHT_CHANWIDTH_80MHZ:
311+ if (!new_ccfs1) {
312+ new_ccfs0 -= (new_ccfs0 >= 149) ? 155 : 42;
313+ if (new_ccfs0 % 16 != 0)
314+ fallback_20mhz = true;
315+ break;
316+ } else if (abs(new_ccfs1 - new_ccfs0) == 8) {
317+ new_ccfs0 = new_ccfs1;
318+ new_ccfs1 = 0;
319+ }
320+ fallthrough;
321+ case IEEE80211_VHT_CHANWIDTH_160MHZ:
322+ if (!new_ccfs1) {
323+ if (new_ccfs0 != 50 && new_ccfs0 != 114 && new_ccfs0 != 163)
324+ fallback_20mhz = true;
325+ break;
326+ }
327+ fallthrough;
328+ case IEEE80211_VHT_CHANWIDTH_80P80MHZ:
329+ new_ccfs0 -= (new_ccfs0 >= 149) ? 155 : 42;
330+ new_ccfs1 -= (new_ccfs1 >= 149) ? 155 : 42;
331+ if (new_ccfs0 % 16 != 0 || new_ccfs1 % 16 != 0)
332+ fallback_20mhz = true;
333+ break;
334+ default:
335+ fallback_20mhz = true;
336+ }
337+
338+ if (fallback_20mhz) {
339+ ht_oper->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
340+
341+ vht_oper->chan_width = IEEE80211_VHT_CHANWIDTH_USE_HT;
342+ vht_oper->center_freq_seg0_idx =
343+ ieee80211_frequency_to_channel(chan->center_freq);
344+ vht_oper->center_freq_seg1_idx = 0;
345+
346+ } else {
347+ ht_oper->ht_param = (chan->center_freq / 20) & 1 ?
348+ IEEE80211_HT_PARAM_CHA_SEC_ABOVE :
349+ IEEE80211_HT_PARAM_CHA_SEC_BELOW;
350+
351+ vht_oper->chan_width = new_chan_width;
352+ vht_oper->center_freq_seg0_idx = wbcs_ie->new_center_freq_seg0;
353+ vht_oper->center_freq_seg1_idx = wbcs_ie->new_center_freq_seg1;
354+ }
355+
356+ ht_oper->operation_mode = cpu_to_le16(vht_oper->center_freq_seg1_idx <<
357+ IEEE80211_HT_OP_MODE_CCFS2_SHIFT);
358+}
359+
360 int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
361 struct ieee802_11_elems *elems,
362 enum nl80211_band current_band,
363@@ -26,19 +352,27 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
364 ieee80211_conn_flags_t conn_flags, u8 *bssid,
365 struct ieee80211_csa_ie *csa_ie)
366 {
367+ struct ieee80211_supported_band *sband;
368 enum nl80211_band new_band = current_band;
369- int new_freq;
370- u8 new_chan_no;
371+ int new_freq, size;
372+ u8 new_chan_no = 0, new_op_class = 0;
373 struct ieee80211_channel *new_chan;
374- struct cfg80211_chan_def new_vht_chandef = {};
375+ struct cfg80211_chan_def new_chandef = {};
376 const struct ieee80211_sec_chan_offs_ie *sec_chan_offs;
377 const struct ieee80211_wide_bw_chansw_ie *wide_bw_chansw_ie;
378+ const struct ieee80211_ext_chansw_ie *ext_chansw_ie;
379+ struct ieee80211_ht_operation *ht_oper;
380+ struct ieee80211_vht_operation *vht_oper;
381+ struct ieee80211_he_operation *he_oper;
382+ struct ieee80211_eht_operation *eht_oper;
383+ struct ieee80211_sta_ht_cap sta_ht_cap;
384 int secondary_channel_offset = -1;
385
386 memset(csa_ie, 0, sizeof(*csa_ie));
387
388 sec_chan_offs = elems->sec_chan_offs;
389 wide_bw_chansw_ie = elems->wide_bw_chansw_ie;
390+ ext_chansw_ie = elems->ext_chansw_ie;
391
392 if (conn_flags & (IEEE80211_CONN_DISABLE_HT |
393 IEEE80211_CONN_DISABLE_40MHZ)) {
394@@ -46,29 +380,30 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
395 wide_bw_chansw_ie = NULL;
396 }
397
398- if (conn_flags & IEEE80211_CONN_DISABLE_VHT)
399- wide_bw_chansw_ie = NULL;
400-
401- if (elems->ext_chansw_ie) {
402- if (!ieee80211_operating_class_to_band(
403- elems->ext_chansw_ie->new_operating_class,
404- &new_band)) {
405- sdata_info(sdata,
406- "cannot understand ECSA IE operating class, %d, ignoring\n",
407- elems->ext_chansw_ie->new_operating_class);
408+ if (ext_chansw_ie) {
409+ new_op_class = ext_chansw_ie->new_operating_class;
410+ if (!ieee80211_operating_class_to_band(new_op_class, &new_band)) {
411+ new_op_class = 0;
412+ sdata_info(sdata, "cannot understand ECSA IE "
413+ "operating class, %d, ignoring\n",
414+ ext_chansw_ie->new_operating_class);
415+ } else {
416+ new_chan_no = ext_chansw_ie->new_ch_num;
417+ csa_ie->count = ext_chansw_ie->count;
418+ csa_ie->mode = ext_chansw_ie->mode;
419 }
420- new_chan_no = elems->ext_chansw_ie->new_ch_num;
421- csa_ie->count = elems->ext_chansw_ie->count;
422- csa_ie->mode = elems->ext_chansw_ie->mode;
423- } else if (elems->ch_switch_ie) {
424+ }
425+
426+ if (!new_op_class && elems->ch_switch_ie) {
427 new_chan_no = elems->ch_switch_ie->new_ch_num;
428 csa_ie->count = elems->ch_switch_ie->count;
429 csa_ie->mode = elems->ch_switch_ie->mode;
430- } else {
431- /* nothing here we understand */
432- return 1;
433 }
434
435+ /* nothing here we understand */
436+ if (!new_chan_no)
437+ return 1;
438+
439 /* Mesh Channel Switch Parameters Element */
440 if (elems->mesh_chansw_params_ie) {
441 csa_ie->ttl = elems->mesh_chansw_params_ie->mesh_ttl;
442@@ -132,54 +467,119 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
443 break;
444 }
445
446- if (wide_bw_chansw_ie) {
447- u8 new_seg1 = wide_bw_chansw_ie->new_center_freq_seg1;
448- struct ieee80211_vht_operation vht_oper = {
449- .chan_width =
450- wide_bw_chansw_ie->new_channel_width,
451- .center_freq_seg0_idx =
452- wide_bw_chansw_ie->new_center_freq_seg0,
453- .center_freq_seg1_idx = new_seg1,
454- /* .basic_mcs_set doesn't matter */
455- };
456- struct ieee80211_ht_operation ht_oper = {
457- .operation_mode =
458- cpu_to_le16(new_seg1 <<
459- IEEE80211_HT_OP_MODE_CCFS2_SHIFT),
460- };
461-
462- /* default, for the case of IEEE80211_VHT_CHANWIDTH_USE_HT,
463- * to the previously parsed chandef
464- */
465- new_vht_chandef = csa_ie->chandef;
466+ if (new_band == NL80211_BAND_6GHZ) {
467+ size = sizeof(struct ieee80211_he_operation) +
468+ sizeof(struct ieee80211_he_6ghz_oper);
469+ he_oper = kzalloc(size, GFP_KERNEL);
470+ if (!he_oper)
471+ return -ENOMEM;
472+
473+ size = sizeof(struct ieee80211_eht_operation) +
474+ sizeof(struct ieee80211_eht_operation_info);
475+ eht_oper = kzalloc(size, GFP_KERNEL);
476+ if (!eht_oper) {
477+ kfree(he_oper);
478+ return -ENOMEM;
479+ }
480+
481+ if (new_op_class && new_op_class != 135 && new_op_class != 137) {
482+ /* There is no way to tell the ccfs1 for op_class 135
483+ * (80P80 MHz) and 137 (320 MHz).
484+ */
485+ op_class_to_6ghz_he_eht_oper(new_op_class, new_chan,
486+ he_oper, eht_oper);
487+ } else if (wide_bw_chansw_ie) {
488+ wbcs_ie_to_6ghz_he_eht_oper(wide_bw_chansw_ie,
489+ new_chan_no, he_oper,
490+ eht_oper);
491+ }
492+
493+ new_chandef = csa_ie->chandef;
494
495 /* ignore if parsing fails */
496- if (!ieee80211_chandef_vht_oper(&sdata->local->hw,
497- vht_cap_info,
498- &vht_oper, &ht_oper,
499- &new_vht_chandef))
500- new_vht_chandef.chan = NULL;
501+ if (!ieee80211_chandef_he_6ghz_oper(sdata, he_oper, eht_oper,
502+ &new_chandef))
503+ new_chandef.chan = NULL;
504+
505+ kfree(he_oper);
506+ kfree(eht_oper);
507+ } else {
508+ sband = sdata->local->hw.wiphy->bands[new_band];
509+ memcpy(&sta_ht_cap, &sband->ht_cap, sizeof(sta_ht_cap));
510+ ieee80211_apply_htcap_overrides(sdata, &sta_ht_cap);
511+
512+ if (!sta_ht_cap.ht_supported ||
513+ !(sta_ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
514+ goto out;
515+
516+ ht_oper = kzalloc(sizeof(*ht_oper), GFP_KERNEL);
517+ if (!ht_oper)
518+ return -ENOMEM;
519+
520+ vht_oper = kzalloc(sizeof(*vht_oper), GFP_KERNEL);
521+ if (!vht_oper) {
522+ kfree(ht_oper);
523+ return -ENOMEM;
524+ }
525+
526+ if (new_op_class && new_op_class != 130) {
527+ /* There is no way to tell the ccfs1 for op_class 130
528+ * (80P80 MHz).
529+ */
530+ op_class_to_ht_vht_oper(new_op_class, new_chan, ht_oper,
531+ vht_oper);
532+ } else if (wide_bw_chansw_ie && new_band == NL80211_BAND_5GHZ &&
533+ sband->vht_cap.vht_supported) {
534+ /* It is assumed that there is no WBCS IE in the beacon
535+ * from a 2 GHz BSS during a channel switch.
536+ */
537+ wbcs_ie_to_ht_vht_oper(new_chan, wide_bw_chansw_ie,
538+ ht_oper, vht_oper);
539+ } else {
540+ kfree(ht_oper);
541+ kfree(vht_oper);
542+ goto out;
543+ }
544+
545+ new_chandef = csa_ie->chandef;
546+
547+ ieee80211_chandef_ht_oper(ht_oper, &new_chandef);
548+
549+ /* ignore if parsing fails */
550+ if (sband->vht_cap.vht_supported &&
551+ !ieee80211_chandef_vht_oper(&sdata->local->hw, vht_cap_info,
552+ vht_oper, ht_oper, &new_chandef))
553+ new_chandef.chan = NULL;
554+
555+ kfree(ht_oper);
556+ kfree(vht_oper);
557+ }
558+
559+ if (new_chandef.chan) {
560+ if (conn_flags & IEEE80211_CONN_DISABLE_320MHZ &&
561+ new_chandef.width == NL80211_CHAN_WIDTH_320)
562+ ieee80211_chandef_downgrade(&new_chandef);
563
564 if (conn_flags & IEEE80211_CONN_DISABLE_80P80MHZ &&
565- new_vht_chandef.width == NL80211_CHAN_WIDTH_80P80)
566- ieee80211_chandef_downgrade(&new_vht_chandef);
567+ new_chandef.width == NL80211_CHAN_WIDTH_80P80)
568+ ieee80211_chandef_downgrade(&new_chandef);
569+
570 if (conn_flags & IEEE80211_CONN_DISABLE_160MHZ &&
571- new_vht_chandef.width == NL80211_CHAN_WIDTH_160)
572- ieee80211_chandef_downgrade(&new_vht_chandef);
573- }
574+ new_chandef.width == NL80211_CHAN_WIDTH_160)
575+ ieee80211_chandef_downgrade(&new_chandef);
576
577- /* if VHT data is there validate & use it */
578- if (new_vht_chandef.chan) {
579- if (!cfg80211_chandef_compatible(&new_vht_chandef,
580+ if (!cfg80211_chandef_compatible(&new_chandef,
581 &csa_ie->chandef)) {
582 sdata_info(sdata,
583 "BSS %pM: CSA has inconsistent channel data, disconnecting\n",
584 bssid);
585 return -EINVAL;
586 }
587- csa_ie->chandef = new_vht_chandef;
588+
589+ csa_ie->chandef = new_chandef;
590 }
591
592+out:
593 if (elems->max_channel_switch_time)
594 csa_ie->max_switch_time =
595 (elems->max_channel_switch_time[0] << 0) |
596--
5972.25.1
598