hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/mac80211/agg-rx.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * HT handling
34 *
....@@ -8,11 +9,7 @@
89 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
910 * Copyright 2007-2010, Intel Corporation
1011 * Copyright(c) 2015-2017 Intel Deutschland GmbH
11
- * Copyright (C) 2018 Intel Corporation
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License version 2 as
15
- * published by the Free Software Foundation.
12
+ * Copyright (C) 2018-2021 Intel Corporation
1613 */
1714
1815 /**
....@@ -181,17 +178,55 @@
181178 rcu_read_unlock();
182179 }
183180
184
-static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *da, u16 tid,
185
- u8 dialog_token, u16 status, u16 policy,
186
- u16 buf_size, u16 timeout)
181
+static void ieee80211_add_addbaext(struct ieee80211_sub_if_data *sdata,
182
+ struct sk_buff *skb,
183
+ const struct ieee80211_addba_ext_ie *req)
187184 {
185
+ struct ieee80211_supported_band *sband;
186
+ struct ieee80211_addba_ext_ie *resp;
187
+ const struct ieee80211_sta_he_cap *he_cap;
188
+ u8 frag_level, cap_frag_level;
189
+ u8 *pos;
190
+
191
+ sband = ieee80211_get_sband(sdata);
192
+ if (!sband)
193
+ return;
194
+ he_cap = ieee80211_get_he_iftype_cap(sband,
195
+ ieee80211_vif_type_p2p(&sdata->vif));
196
+ if (!he_cap)
197
+ return;
198
+
199
+ pos = skb_put_zero(skb, 2 + sizeof(struct ieee80211_addba_ext_ie));
200
+ *pos++ = WLAN_EID_ADDBA_EXT;
201
+ *pos++ = sizeof(struct ieee80211_addba_ext_ie);
202
+ resp = (struct ieee80211_addba_ext_ie *)pos;
203
+ resp->data = req->data & IEEE80211_ADDBA_EXT_NO_FRAG;
204
+
205
+ frag_level = u32_get_bits(req->data,
206
+ IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK);
207
+ cap_frag_level = u32_get_bits(he_cap->he_cap_elem.mac_cap_info[0],
208
+ IEEE80211_HE_MAC_CAP0_DYNAMIC_FRAG_MASK);
209
+ if (frag_level > cap_frag_level)
210
+ frag_level = cap_frag_level;
211
+ resp->data |= u8_encode_bits(frag_level,
212
+ IEEE80211_ADDBA_EXT_FRAG_LEVEL_MASK);
213
+}
214
+
215
+static void ieee80211_send_addba_resp(struct sta_info *sta, u8 *da, u16 tid,
216
+ u8 dialog_token, u16 status, u16 policy,
217
+ u16 buf_size, u16 timeout,
218
+ const struct ieee80211_addba_ext_ie *addbaext)
219
+{
220
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
188221 struct ieee80211_local *local = sdata->local;
189222 struct sk_buff *skb;
190223 struct ieee80211_mgmt *mgmt;
191224 bool amsdu = ieee80211_hw_check(&local->hw, SUPPORTS_AMSDU_IN_AMPDU);
192225 u16 capab;
193226
194
- skb = dev_alloc_skb(sizeof(*mgmt) + local->hw.extra_tx_headroom);
227
+ skb = dev_alloc_skb(sizeof(*mgmt) +
228
+ 2 + sizeof(struct ieee80211_addba_ext_ie) +
229
+ local->hw.extra_tx_headroom);
195230 if (!skb)
196231 return;
197232
....@@ -225,13 +260,17 @@
225260 mgmt->u.action.u.addba_resp.timeout = cpu_to_le16(timeout);
226261 mgmt->u.action.u.addba_resp.status = cpu_to_le16(status);
227262
263
+ if (sta->sta.he_cap.has_he && addbaext)
264
+ ieee80211_add_addbaext(sdata, skb, addbaext);
265
+
228266 ieee80211_tx_skb(sdata, skb);
229267 }
230268
231269 void ___ieee80211_start_rx_ba_session(struct sta_info *sta,
232270 u8 dialog_token, u16 timeout,
233271 u16 start_seq_num, u16 ba_policy, u16 tid,
234
- u16 buf_size, bool tx, bool auto_seq)
272
+ u16 buf_size, bool tx, bool auto_seq,
273
+ const struct ieee80211_addba_ext_ie *addbaext)
235274 {
236275 struct ieee80211_local *local = sta->sdata->local;
237276 struct tid_ampdu_rx *tid_agg_rx;
....@@ -254,7 +293,8 @@
254293 goto end;
255294 }
256295
257
- if (!sta->sta.ht_cap.ht_supported) {
296
+ if (!sta->sta.ht_cap.ht_supported &&
297
+ sta->sdata->vif.bss_conf.chandef.chan->band != NL80211_BAND_6GHZ) {
258298 ht_dbg(sta->sdata,
259299 "STA %pM erroneously requests BA session on tid %d w/o QoS\n",
260300 sta->sta.addr, tid);
....@@ -311,7 +351,7 @@
311351 sta->sta.addr, tid);
312352 /* We have no API to update the timeout value in the
313353 * driver so reject the timeout update if the timeout
314
- * changed. If if did not change, i.e., no real update,
354
+ * changed. If it did not change, i.e., no real update,
315355 * just reply with success.
316356 */
317357 rcu_read_lock();
....@@ -413,21 +453,22 @@
413453 }
414454
415455 if (tx)
416
- ieee80211_send_addba_resp(sta->sdata, sta->sta.addr, tid,
456
+ ieee80211_send_addba_resp(sta, sta->sta.addr, tid,
417457 dialog_token, status, 1, buf_size,
418
- timeout);
458
+ timeout, addbaext);
419459 }
420460
421461 static void __ieee80211_start_rx_ba_session(struct sta_info *sta,
422462 u8 dialog_token, u16 timeout,
423463 u16 start_seq_num, u16 ba_policy,
424464 u16 tid, u16 buf_size, bool tx,
425
- bool auto_seq)
465
+ bool auto_seq,
466
+ const struct ieee80211_addba_ext_ie *addbaext)
426467 {
427468 mutex_lock(&sta->ampdu_mlme.mtx);
428469 ___ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
429470 start_seq_num, ba_policy, tid,
430
- buf_size, tx, auto_seq);
471
+ buf_size, tx, auto_seq, addbaext);
431472 mutex_unlock(&sta->ampdu_mlme.mtx);
432473 }
433474
....@@ -437,7 +478,9 @@
437478 size_t len)
438479 {
439480 u16 capab, tid, timeout, ba_policy, buf_size, start_seq_num;
481
+ struct ieee802_11_elems elems = { };
440482 u8 dialog_token;
483
+ int ies_len;
441484
442485 /* extract session parameters from addba request frame */
443486 dialog_token = mgmt->u.action.u.addba_req.dialog_token;
....@@ -450,9 +493,19 @@
450493 tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
451494 buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6;
452495
496
+ ies_len = len - offsetof(struct ieee80211_mgmt,
497
+ u.action.u.addba_req.variable);
498
+ if (ies_len) {
499
+ ieee802_11_parse_elems(mgmt->u.action.u.addba_req.variable,
500
+ ies_len, true, &elems, mgmt->bssid, NULL);
501
+ if (elems.parse_error)
502
+ return;
503
+ }
504
+
453505 __ieee80211_start_rx_ba_session(sta, dialog_token, timeout,
454506 start_seq_num, ba_policy, tid,
455
- buf_size, true, false);
507
+ buf_size, true, false,
508
+ elems.addba_ext_ie);
456509 }
457510
458511 void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,