2023-01-21 22:39:45

by Alexander Wetzel

[permalink] [raw]
Subject: [stable v6.1 2/2] wifi: mac80211: Fix iTXQ AMPDU fragmentation handling

This is a backport of 'commit 592234e941f1 ("wifi: mac80211: Fix iTXQ
AMPDU fragmentation handling")' from linux 6.2.

mac80211 must not enable aggregation wile transmitting a fragmented
MPDU. Enforce that for mac80211 internal TX queues (iTXQs).

Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexander Wetzel <[email protected]>
---
net/mac80211/agg-tx.c | 2 --
net/mac80211/ht.c | 37 +++++++++++++++++++++++++++++++++++++
net/mac80211/tx.c | 13 +++++++------
3 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 07c892aa8c73..e26a72f3a104 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -511,8 +511,6 @@ void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
*/
clear_bit(HT_AGG_STATE_WANT_START, &tid_tx->state);

- ieee80211_agg_stop_txq(sta, tid);
-
/*
* Make sure no packets are being processed. This ensures that
* we have a valid starting sequence number and that in-flight
diff --git a/net/mac80211/ht.c b/net/mac80211/ht.c
index 83bc41346ae7..ae42e956eff5 100644
--- a/net/mac80211/ht.c
+++ b/net/mac80211/ht.c
@@ -391,6 +391,43 @@ void ieee80211_ba_session_work(struct work_struct *work)

tid_tx = sta->ampdu_mlme.tid_start_tx[tid];
if (!blocked && tid_tx) {
+ struct ieee80211_sub_if_data *sdata = sta->sdata;
+ struct ieee80211_local *local = sdata->local;
+
+ if (local->ops->wake_tx_queue) {
+ struct txq_info *txqi =
+ to_txq_info(sta->sta.txq[tid]);
+ struct fq *fq = &local->fq;
+
+ spin_lock_bh(&fq->lock);
+
+ /* Allow only frags to be dequeued */
+ set_bit(IEEE80211_TXQ_STOP, &txqi->flags);
+
+ if (!skb_queue_empty(&txqi->frags)) {
+ /* Fragmented Tx is ongoing, wait for it
+ * to finish. Reschedule worker to retry
+ * later.
+ */
+
+ spin_unlock_bh(&fq->lock);
+ spin_unlock_bh(&sta->lock);
+
+ /* Give the task working on the txq a
+ * chance to send out the queued frags
+ */
+ synchronize_net();
+
+ mutex_unlock(&sta->ampdu_mlme.mtx);
+
+ ieee80211_queue_work(&sdata->local->hw,
+ work);
+ return;
+ }
+
+ spin_unlock_bh(&fq->lock);
+ }
+
/*
* Assign it over to the normal tid_tx array
* where it "goes live".
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 3363e322cfd9..b114886c66de 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1295,7 +1295,8 @@ ieee80211_tx_prepare(struct ieee80211_sub_if_data *sdata,
if (!(info->flags & IEEE80211_TX_CTL_DONTFRAG)) {
if (!(tx->flags & IEEE80211_TX_UNICAST) ||
skb->len + FCS_LEN <= local->hw.wiphy->frag_threshold ||
- info->flags & IEEE80211_TX_CTL_AMPDU)
+ (info->flags & IEEE80211_TX_CTL_AMPDU &&
+ !local->ops->wake_tx_queue))
info->flags |= IEEE80211_TX_CTL_DONTFRAG;
}

@@ -3725,7 +3726,6 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
return NULL;

begin:
- skb = NULL;
spin_lock(&local->queue_stop_reason_lock);
q_stopped = local->queue_stop_reasons[q];
spin_unlock(&local->queue_stop_reason_lock);
@@ -3738,9 +3738,6 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,

spin_lock_bh(&fq->lock);

- if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags)))
- goto out;
-
/* Make sure fragments stay together. */
skb = __skb_dequeue(&txqi->frags);
if (unlikely(skb)) {
@@ -3750,6 +3747,9 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
IEEE80211_SKB_CB(skb)->control.flags &=
~IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
} else {
+ if (unlikely(test_bit(IEEE80211_TXQ_STOP, &txqi->flags)))
+ goto out;
+
skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);
}

@@ -3800,7 +3800,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
}

if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))
- info->flags |= IEEE80211_TX_CTL_AMPDU;
+ info->flags |= (IEEE80211_TX_CTL_AMPDU |
+ IEEE80211_TX_CTL_DONTFRAG);
else
info->flags &= ~IEEE80211_TX_CTL_AMPDU;

--
2.39.0


2023-01-27 07:36:44

by Greg KH

[permalink] [raw]
Subject: Re: [stable v6.1 2/2] wifi: mac80211: Fix iTXQ AMPDU fragmentation handling

On Sat, Jan 21, 2023 at 11:33:30PM +0100, Alexander Wetzel wrote:
> This is a backport of 'commit 592234e941f1 ("wifi: mac80211: Fix iTXQ
> AMPDU fragmentation handling")' from linux 6.2.
>
> mac80211 must not enable aggregation wile transmitting a fragmented
> MPDU. Enforce that for mac80211 internal TX queues (iTXQs).
>
> Cc: [email protected]
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Alexander Wetzel <[email protected]>
> ---
> net/mac80211/agg-tx.c | 2 --
> net/mac80211/ht.c | 37 +++++++++++++++++++++++++++++++++++++
> net/mac80211/tx.c | 13 +++++++------
> 3 files changed, 44 insertions(+), 8 deletions(-)

This backport fails to apply to the 6.1.y tree:

Applying patch wifi-mac80211-fix-itxq-ampdu-fragmentation-handling.patch
patching file net/mac80211/agg-tx.c
patching file net/mac80211/ht.c
patching file net/mac80211/tx.c
Hunk #2 FAILED at 3726.
Hunk #3 FAILED at 3739.
Hunk #4 succeeded at 3744 (offset -7 lines).
Hunk #5 succeeded at 3797 (offset -7 lines).
2 out of 5 hunks FAILED -- rejects in file net/mac80211/tx.c


Try again?

thanks,

greg k-h

2023-01-27 07:37:08

by Greg KH

[permalink] [raw]
Subject: Re: [stable v6.1 2/2] wifi: mac80211: Fix iTXQ AMPDU fragmentation handling

On Fri, Jan 27, 2023 at 08:36:37AM +0100, Greg KH wrote:
> On Sat, Jan 21, 2023 at 11:33:30PM +0100, Alexander Wetzel wrote:
> > This is a backport of 'commit 592234e941f1 ("wifi: mac80211: Fix iTXQ
> > AMPDU fragmentation handling")' from linux 6.2.
> >
> > mac80211 must not enable aggregation wile transmitting a fragmented
> > MPDU. Enforce that for mac80211 internal TX queues (iTXQs).
> >
> > Cc: [email protected]
> > Link: https://lore.kernel.org/r/[email protected]
> > Signed-off-by: Alexander Wetzel <[email protected]>
> > ---
> > net/mac80211/agg-tx.c | 2 --
> > net/mac80211/ht.c | 37 +++++++++++++++++++++++++++++++++++++
> > net/mac80211/tx.c | 13 +++++++------
> > 3 files changed, 44 insertions(+), 8 deletions(-)
>
> This backport fails to apply to the 6.1.y tree:
>
> Applying patch wifi-mac80211-fix-itxq-ampdu-fragmentation-handling.patch
> patching file net/mac80211/agg-tx.c
> patching file net/mac80211/ht.c
> patching file net/mac80211/tx.c
> Hunk #2 FAILED at 3726.
> Hunk #3 FAILED at 3739.
> Hunk #4 succeeded at 3744 (offset -7 lines).
> Hunk #5 succeeded at 3797 (offset -7 lines).
> 2 out of 5 hunks FAILED -- rejects in file net/mac80211/tx.c
>
>
> Try again?

Argh, forgot to apply patch 1/2...

{sigh} I need more coffee...

2023-01-27 07:38:48

by Greg KH

[permalink] [raw]
Subject: Re: [stable v6.1 2/2] wifi: mac80211: Fix iTXQ AMPDU fragmentation handling

On Sat, Jan 21, 2023 at 11:33:30PM +0100, Alexander Wetzel wrote:
> This is a backport of 'commit 592234e941f1 ("wifi: mac80211: Fix iTXQ
> AMPDU fragmentation handling")' from linux 6.2.
>
> mac80211 must not enable aggregation wile transmitting a fragmented
> MPDU. Enforce that for mac80211 internal TX queues (iTXQs).
>
> Cc: [email protected]
> Link: https://lore.kernel.org/r/[email protected]
> Signed-off-by: Alexander Wetzel <[email protected]>
> ---
> net/mac80211/agg-tx.c | 2 --
> net/mac80211/ht.c | 37 +++++++++++++++++++++++++++++++++++++
> net/mac80211/tx.c | 13 +++++++------
> 3 files changed, 44 insertions(+), 8 deletions(-)
>

Both now queued up, thanks.

greg k-h