hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/mac80211/agg-tx.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 - 2019 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 - 2022 Intel Corporation
1613 */
1714
1815 #include <linux/ieee80211.h>
....@@ -216,6 +213,8 @@
216213 struct ieee80211_txq *txq = sta->sta.txq[tid];
217214 struct txq_info *txqi;
218215
216
+ lockdep_assert_held(&sta->ampdu_mlme.mtx);
217
+
219218 if (!txq)
220219 return;
221220
....@@ -229,7 +228,7 @@
229228 clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
230229 local_bh_disable();
231230 rcu_read_lock();
232
- drv_wake_tx_queue(sta->sdata->local, txqi);
231
+ schedule_and_wake_txq(sta->sdata->local, txqi);
233232 rcu_read_unlock();
234233 local_bh_enable();
235234 }
....@@ -293,7 +292,6 @@
293292 ieee80211_assign_tid_tx(sta, tid, NULL);
294293
295294 ieee80211_agg_splice_finish(sta->sdata, tid);
296
- ieee80211_agg_start_txq(sta, tid, false);
297295
298296 kfree_rcu(tid_tx, rcu_head);
299297 }
....@@ -451,58 +449,13 @@
451449 ieee80211_stop_tx_ba_session(&sta->sta, tid);
452450 }
453451
454
-void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
452
+static void ieee80211_send_addba_with_timeout(struct sta_info *sta,
453
+ struct tid_ampdu_tx *tid_tx)
455454 {
456
- struct tid_ampdu_tx *tid_tx;
457
- struct ieee80211_local *local = sta->local;
458455 struct ieee80211_sub_if_data *sdata = sta->sdata;
459
- struct ieee80211_ampdu_params params = {
460
- .sta = &sta->sta,
461
- .action = IEEE80211_AMPDU_TX_START,
462
- .tid = tid,
463
- .buf_size = 0,
464
- .amsdu = false,
465
- .timeout = 0,
466
- };
467
- int ret;
456
+ struct ieee80211_local *local = sta->local;
457
+ u8 tid = tid_tx->tid;
468458 u16 buf_size;
469
-
470
- tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
471
-
472
- /*
473
- * Start queuing up packets for this aggregation session.
474
- * We're going to release them once the driver is OK with
475
- * that.
476
- */
477
- clear_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);
478
-
479
- ieee80211_agg_stop_txq(sta, tid);
480
-
481
- /*
482
- * Make sure no packets are being processed. This ensures that
483
- * we have a valid starting sequence number and that in-flight
484
- * packets have been flushed out and no packets for this TID
485
- * will go into the driver during the ampdu_action call.
486
- */
487
- synchronize_net();
488
-
489
- params.ssn = sta->tid_seq[tid] >> 4;
490
- ret = drv_ampdu_action(local, sdata, &params);
491
- if (ret) {
492
- ht_dbg(sdata,
493
- "BA request denied - HW unavailable for %pM tid %d\n",
494
- sta->sta.addr, tid);
495
- spin_lock_bh(&sta->lock);
496
- ieee80211_agg_splice_packets(sdata, tid_tx, tid);
497
- ieee80211_assign_tid_tx(sta, tid, NULL);
498
- ieee80211_agg_splice_finish(sdata, tid);
499
- spin_unlock_bh(&sta->lock);
500
-
501
- ieee80211_agg_start_txq(sta, tid, false);
502
-
503
- kfree_rcu(tid_tx, rcu_head);
504
- return;
505
- }
506459
507460 /* activate the timer for the recipient's addBA response */
508461 mod_timer(&tid_tx->addba_resp_timer, jiffies + ADDBA_RESP_INTERVAL);
....@@ -528,8 +481,79 @@
528481
529482 /* send AddBA request */
530483 ieee80211_send_addba_request(sdata, sta->sta.addr, tid,
531
- tid_tx->dialog_token, params.ssn,
484
+ tid_tx->dialog_token, tid_tx->ssn,
532485 buf_size, tid_tx->timeout);
486
+
487
+ WARN_ON(test_and_set_bit(HT_AGG_STATE_SENT_ADDBA, &tid_tx->state));
488
+}
489
+
490
+void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
491
+{
492
+ struct tid_ampdu_tx *tid_tx;
493
+ struct ieee80211_local *local = sta->local;
494
+ struct ieee80211_sub_if_data *sdata;
495
+ struct ieee80211_ampdu_params params = {
496
+ .sta = &sta->sta,
497
+ .action = IEEE80211_AMPDU_TX_START,
498
+ .tid = tid,
499
+ .buf_size = 0,
500
+ .amsdu = false,
501
+ .timeout = 0,
502
+ };
503
+ int ret;
504
+
505
+ tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
506
+
507
+ /*
508
+ * Start queuing up packets for this aggregation session.
509
+ * We're going to release them once the driver is OK with
510
+ * that.
511
+ */
512
+ clear_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);
513
+
514
+ ieee80211_agg_stop_txq(sta, tid);
515
+
516
+ /*
517
+ * Make sure no packets are being processed. This ensures that
518
+ * we have a valid starting sequence number and that in-flight
519
+ * packets have been flushed out and no packets for this TID
520
+ * will go into the driver during the ampdu_action call.
521
+ */
522
+ synchronize_net();
523
+
524
+ sdata = sta->sdata;
525
+ params.ssn = sta->tid_seq[tid] >> 4;
526
+ ret = drv_ampdu_action(local, sdata, &params);
527
+ tid_tx->ssn = params.ssn;
528
+ if (ret == IEEE80211_AMPDU_TX_START_DELAY_ADDBA) {
529
+ return;
530
+ } else if (ret == IEEE80211_AMPDU_TX_START_IMMEDIATE) {
531
+ /*
532
+ * We didn't send the request yet, so don't need to check
533
+ * here if we already got a response, just mark as driver
534
+ * ready immediately.
535
+ */
536
+ set_bit(HT_AGG_STATE_DRV_READY, &tid_tx->state);
537
+ } else if (ret) {
538
+ if (!sdata)
539
+ return;
540
+
541
+ ht_dbg(sdata,
542
+ "BA request denied - HW unavailable for %pM tid %d\n",
543
+ sta->sta.addr, tid);
544
+ spin_lock_bh(&sta->lock);
545
+ ieee80211_agg_splice_packets(sdata, tid_tx, tid);
546
+ ieee80211_assign_tid_tx(sta, tid, NULL);
547
+ ieee80211_agg_splice_finish(sdata, tid);
548
+ spin_unlock_bh(&sta->lock);
549
+
550
+ ieee80211_agg_start_txq(sta, tid, false);
551
+
552
+ kfree_rcu(tid_tx, rcu_head);
553
+ return;
554
+ }
555
+
556
+ ieee80211_send_addba_with_timeout(sta, tid_tx);
533557 }
534558
535559 /*
....@@ -574,7 +598,8 @@
574598 "Requested to start BA session on reserved tid=%d", tid))
575599 return -EINVAL;
576600
577
- if (!pubsta->ht_cap.ht_supported)
601
+ if (!pubsta->ht_cap.ht_supported &&
602
+ sta->sdata->vif.bss_conf.chandef.chan->band != NL80211_BAND_6GHZ)
578603 return -EINVAL;
579604
580605 if (WARN_ON_ONCE(!local->ops->ampdu_action))
....@@ -601,6 +626,14 @@
601626 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
602627 ht_dbg(sdata,
603628 "BA sessions blocked - Denying BA session request %pM tid %d\n",
629
+ sta->sta.addr, tid);
630
+ return -EINVAL;
631
+ }
632
+
633
+ if (test_sta_flag(sta, WLAN_STA_MFP) &&
634
+ !test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
635
+ ht_dbg(sdata,
636
+ "MFP STA not authorized - deny BA session request %pM tid %d\n",
604637 sta->sta.addr, tid);
605638 return -EINVAL;
606639 }
....@@ -750,6 +783,12 @@
750783 if (WARN_ON(test_and_set_bit(HT_AGG_STATE_DRV_READY, &tid_tx->state)))
751784 return;
752785
786
+ if (!test_bit(HT_AGG_STATE_SENT_ADDBA, &tid_tx->state)) {
787
+ ieee80211_send_addba_with_timeout(sta, tid_tx);
788
+ /* RESPONSE_RECEIVED state whould trigger the flow again */
789
+ return;
790
+ }
791
+
753792 if (test_bit(HT_AGG_STATE_RESPONSE_RECEIVED, &tid_tx->state))
754793 ieee80211_agg_tx_operational(local, sta, tid);
755794 }
....@@ -863,6 +902,7 @@
863902 {
864903 struct ieee80211_sub_if_data *sdata = sta->sdata;
865904 bool send_delba = false;
905
+ bool start_txq = false;
866906
867907 ht_dbg(sdata, "Stopping Tx BA session for %pM tid %d\n",
868908 sta->sta.addr, tid);
....@@ -880,10 +920,14 @@
880920 send_delba = true;
881921
882922 ieee80211_remove_tid_tx(sta, tid);
923
+ start_txq = true;
883924
884925 unlock_sta:
885926 spin_unlock_bh(&sta->lock);
886927
928
+ if (start_txq)
929
+ ieee80211_agg_start_txq(sta, tid, false);
930
+
887931 if (send_delba)
888932 ieee80211_send_delba(sdata, sta->sta.addr, tid,
889933 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);