forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
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,75 @@
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 = sta->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
+ params.ssn = sta->tid_seq[tid] >> 4;
525
+ ret = drv_ampdu_action(local, sdata, &params);
526
+ tid_tx->ssn = params.ssn;
527
+ if (ret == IEEE80211_AMPDU_TX_START_DELAY_ADDBA) {
528
+ return;
529
+ } else if (ret == IEEE80211_AMPDU_TX_START_IMMEDIATE) {
530
+ /*
531
+ * We didn't send the request yet, so don't need to check
532
+ * here if we already got a response, just mark as driver
533
+ * ready immediately.
534
+ */
535
+ set_bit(HT_AGG_STATE_DRV_READY, &tid_tx->state);
536
+ } else if (ret) {
537
+ ht_dbg(sdata,
538
+ "BA request denied - HW unavailable for %pM tid %d\n",
539
+ sta->sta.addr, tid);
540
+ spin_lock_bh(&sta->lock);
541
+ ieee80211_agg_splice_packets(sdata, tid_tx, tid);
542
+ ieee80211_assign_tid_tx(sta, tid, NULL);
543
+ ieee80211_agg_splice_finish(sdata, tid);
544
+ spin_unlock_bh(&sta->lock);
545
+
546
+ ieee80211_agg_start_txq(sta, tid, false);
547
+
548
+ kfree_rcu(tid_tx, rcu_head);
549
+ return;
550
+ }
551
+
552
+ ieee80211_send_addba_with_timeout(sta, tid_tx);
533553 }
534554
535555 /*
....@@ -574,7 +594,8 @@
574594 "Requested to start BA session on reserved tid=%d", tid))
575595 return -EINVAL;
576596
577
- if (!pubsta->ht_cap.ht_supported)
597
+ if (!pubsta->ht_cap.ht_supported &&
598
+ sta->sdata->vif.bss_conf.chandef.chan->band != NL80211_BAND_6GHZ)
578599 return -EINVAL;
579600
580601 if (WARN_ON_ONCE(!local->ops->ampdu_action))
....@@ -601,6 +622,14 @@
601622 if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) {
602623 ht_dbg(sdata,
603624 "BA sessions blocked - Denying BA session request %pM tid %d\n",
625
+ sta->sta.addr, tid);
626
+ return -EINVAL;
627
+ }
628
+
629
+ if (test_sta_flag(sta, WLAN_STA_MFP) &&
630
+ !test_sta_flag(sta, WLAN_STA_AUTHORIZED)) {
631
+ ht_dbg(sdata,
632
+ "MFP STA not authorized - deny BA session request %pM tid %d\n",
604633 sta->sta.addr, tid);
605634 return -EINVAL;
606635 }
....@@ -750,6 +779,12 @@
750779 if (WARN_ON(test_and_set_bit(HT_AGG_STATE_DRV_READY, &tid_tx->state)))
751780 return;
752781
782
+ if (!test_bit(HT_AGG_STATE_SENT_ADDBA, &tid_tx->state)) {
783
+ ieee80211_send_addba_with_timeout(sta, tid_tx);
784
+ /* RESPONSE_RECEIVED state whould trigger the flow again */
785
+ return;
786
+ }
787
+
753788 if (test_bit(HT_AGG_STATE_RESPONSE_RECEIVED, &tid_tx->state))
754789 ieee80211_agg_tx_operational(local, sta, tid);
755790 }
....@@ -863,6 +898,7 @@
863898 {
864899 struct ieee80211_sub_if_data *sdata = sta->sdata;
865900 bool send_delba = false;
901
+ bool start_txq = false;
866902
867903 ht_dbg(sdata, "Stopping Tx BA session for %pM tid %d\n",
868904 sta->sta.addr, tid);
....@@ -880,10 +916,14 @@
880916 send_delba = true;
881917
882918 ieee80211_remove_tid_tx(sta, tid);
919
+ start_txq = true;
883920
884921 unlock_sta:
885922 spin_unlock_bh(&sta->lock);
886923
924
+ if (start_txq)
925
+ ieee80211_agg_start_txq(sta, tid, false);
926
+
887927 if (send_delba)
888928 ieee80211_send_delba(sdata, sta->sta.addr, tid,
889929 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE);