Skip to content

Commit 9a3fcf9

Browse files
sara-sKalle Valo
authored andcommitted
iwlwifi: mvm: cleanup pending frames in DQA mode
When a station is asleep, the fw will set it as "asleep". All queues that are used only by one station will be stopped by the fw. In pre-DQA mode this was relevant for aggregation queues. However, in DQA mode a queue is owned by one station only, so all queues will be stopped. As a result, we don't expect to get filtered frames back to mac80211 and don't have to maintain the entire pending_frames state logic, the same way as we do in aggregations. The correct behavior is to align DQA behavior with the aggregation queue behaviour pre-DQA: - Don't count pending frames. - Let mac80211 know we have frames in these queues so that it can properly handle trigger frames. When a trigger frame is received, mac80211 tells the driver to send frames from the queues using release_buffered_frames. The driver will tell the fw to let frames out even if the station is asleep. This is done by iwl_mvm_sta_modify_sleep_tx_count. Reported-and-tested-by: Jens Axboe <[email protected]> Reported-by: Linus Torvalds <[email protected]> Signed-off-by: Sara Sharon <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 22a0e18 commit 9a3fcf9

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw,
23192319
{
23202320
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
23212321

2322-
/* Called when we need to transmit (a) frame(s) from agg queue */
2322+
/* Called when we need to transmit (a) frame(s) from agg or dqa queue */
23232323

23242324
iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
23252325
tids, more_data, true);
@@ -2338,7 +2338,8 @@ static void __iwl_mvm_mac_sta_notify(struct ieee80211_hw *hw,
23382338
for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) {
23392339
struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
23402340

2341-
if (tid_data->state != IWL_AGG_ON &&
2341+
if (!iwl_mvm_is_dqa_supported(mvm) &&
2342+
tid_data->state != IWL_AGG_ON &&
23422343
tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA)
23432344
continue;
23442345

drivers/net/wireless/intel/iwlwifi/mvm/sta.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,7 +3135,7 @@ void iwl_mvm_sta_modify_sleep_tx_count(struct iwl_mvm *mvm,
31353135
struct ieee80211_sta *sta,
31363136
enum ieee80211_frame_release_type reason,
31373137
u16 cnt, u16 tids, bool more_data,
3138-
bool agg)
3138+
bool single_sta_queue)
31393139
{
31403140
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
31413141
struct iwl_mvm_add_sta_cmd cmd = {
@@ -3155,14 +3155,14 @@ void iwl_mvm_sta_modify_sleep_tx_count(struct iwl_mvm *mvm,
31553155
for_each_set_bit(tid, &_tids, IWL_MAX_TID_COUNT)
31563156
cmd.awake_acs |= BIT(tid_to_ucode_ac[tid]);
31573157

3158-
/* If we're releasing frames from aggregation queues then check if the
3159-
* all queues combined that we're releasing frames from have
3158+
/* If we're releasing frames from aggregation or dqa queues then check
3159+
* if all the queues that we're releasing frames from, combined, have:
31603160
* - more frames than the service period, in which case more_data
31613161
* needs to be set
31623162
* - fewer than 'cnt' frames, in which case we need to adjust the
31633163
* firmware command (but do that unconditionally)
31643164
*/
3165-
if (agg) {
3165+
if (single_sta_queue) {
31663166
int remaining = cnt;
31673167
int sleep_tx_count;
31683168

@@ -3172,7 +3172,8 @@ void iwl_mvm_sta_modify_sleep_tx_count(struct iwl_mvm *mvm,
31723172
u16 n_queued;
31733173

31743174
tid_data = &mvmsta->tid_data[tid];
3175-
if (WARN(tid_data->state != IWL_AGG_ON &&
3175+
if (WARN(!iwl_mvm_is_dqa_supported(mvm) &&
3176+
tid_data->state != IWL_AGG_ON &&
31763177
tid_data->state != IWL_EMPTYING_HW_QUEUE_DELBA,
31773178
"TID %d state is %d\n",
31783179
tid, tid_data->state)) {

drivers/net/wireless/intel/iwlwifi/mvm/sta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ void iwl_mvm_sta_modify_sleep_tx_count(struct iwl_mvm *mvm,
547547
struct ieee80211_sta *sta,
548548
enum ieee80211_frame_release_type reason,
549549
u16 cnt, u16 tids, bool more_data,
550-
bool agg);
550+
bool single_sta_queue);
551551
int iwl_mvm_drain_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta,
552552
bool drain);
553553
void iwl_mvm_sta_modify_disable_tx(struct iwl_mvm *mvm,

drivers/net/wireless/intel/iwlwifi/mvm/tx.c

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
99
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10-
* Copyright(c) 2016 Intel Deutschland GmbH
10+
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH
1111
*
1212
* This program is free software; you can redistribute it and/or modify
1313
* it under the terms of version 2 of the GNU General Public License as
@@ -34,6 +34,7 @@
3434
*
3535
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
3636
* Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37+
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH
3738
* All rights reserved.
3839
*
3940
* Redistribution and use in source and binary forms, with or without
@@ -628,8 +629,10 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
628629
* values.
629630
* Note that we don't need to make sure it isn't agg'd, since we're
630631
* TXing non-sta
632+
* For DQA mode - we shouldn't increase it though
631633
*/
632-
atomic_inc(&mvm->pending_frames[sta_id]);
634+
if (!iwl_mvm_is_dqa_supported(mvm))
635+
atomic_inc(&mvm->pending_frames[sta_id]);
633636

634637
return 0;
635638
}
@@ -1005,11 +1008,8 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
10051008

10061009
spin_unlock(&mvmsta->lock);
10071010

1008-
/* Increase pending frames count if this isn't AMPDU */
1009-
if ((iwl_mvm_is_dqa_supported(mvm) &&
1010-
mvmsta->tid_data[tx_cmd->tid_tspec].state != IWL_AGG_ON &&
1011-
mvmsta->tid_data[tx_cmd->tid_tspec].state != IWL_AGG_STARTING) ||
1012-
(!iwl_mvm_is_dqa_supported(mvm) && !is_ampdu))
1011+
/* Increase pending frames count if this isn't AMPDU or DQA queue */
1012+
if (!iwl_mvm_is_dqa_supported(mvm) && !is_ampdu)
10131013
atomic_inc(&mvm->pending_frames[mvmsta->sta_id]);
10141014

10151015
return 0;
@@ -1079,12 +1079,13 @@ static void iwl_mvm_check_ratid_empty(struct iwl_mvm *mvm,
10791079
lockdep_assert_held(&mvmsta->lock);
10801080

10811081
if ((tid_data->state == IWL_AGG_ON ||
1082-
tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA) &&
1082+
tid_data->state == IWL_EMPTYING_HW_QUEUE_DELBA ||
1083+
iwl_mvm_is_dqa_supported(mvm)) &&
10831084
iwl_mvm_tid_queued(tid_data) == 0) {
10841085
/*
1085-
* Now that this aggregation queue is empty tell mac80211 so it
1086-
* knows we no longer have frames buffered for the station on
1087-
* this TID (for the TIM bitmap calculation.)
1086+
* Now that this aggregation or DQA queue is empty tell
1087+
* mac80211 so it knows we no longer have frames buffered for
1088+
* the station on this TID (for the TIM bitmap calculation.)
10881089
*/
10891090
ieee80211_sta_set_buffered(sta, tid, false);
10901091
}
@@ -1257,7 +1258,6 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
12571258
u8 skb_freed = 0;
12581259
u16 next_reclaimed, seq_ctl;
12591260
bool is_ndp = false;
1260-
bool txq_agg = false; /* Is this TXQ aggregated */
12611261

12621262
__skb_queue_head_init(&skbs);
12631263

@@ -1283,6 +1283,10 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
12831283
info->flags |= IEEE80211_TX_STAT_ACK;
12841284
break;
12851285
case TX_STATUS_FAIL_DEST_PS:
1286+
/* In DQA, the FW should have stopped the queue and not
1287+
* return this status
1288+
*/
1289+
WARN_ON(iwl_mvm_is_dqa_supported(mvm));
12861290
info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
12871291
break;
12881292
default:
@@ -1387,15 +1391,6 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
13871391
bool send_eosp_ndp = false;
13881392

13891393
spin_lock_bh(&mvmsta->lock);
1390-
if (iwl_mvm_is_dqa_supported(mvm)) {
1391-
enum iwl_mvm_agg_state state;
1392-
1393-
state = mvmsta->tid_data[tid].state;
1394-
txq_agg = (state == IWL_AGG_ON ||
1395-
state == IWL_EMPTYING_HW_QUEUE_DELBA);
1396-
} else {
1397-
txq_agg = txq_id >= mvm->first_agg_queue;
1398-
}
13991394

14001395
if (!is_ndp) {
14011396
tid_data->next_reclaimed = next_reclaimed;
@@ -1452,11 +1447,11 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
14521447
* If the txq is not an AMPDU queue, there is no chance we freed
14531448
* several skbs. Check that out...
14541449
*/
1455-
if (txq_agg)
1450+
if (iwl_mvm_is_dqa_supported(mvm) || txq_id >= mvm->first_agg_queue)
14561451
goto out;
14571452

14581453
/* We can't free more than one frame at once on a shared queue */
1459-
WARN_ON(!iwl_mvm_is_dqa_supported(mvm) && (skb_freed > 1));
1454+
WARN_ON(skb_freed > 1);
14601455

14611456
/* If we have still frames for this STA nothing to do here */
14621457
if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id]))

0 commit comments

Comments
 (0)