* [PATCH] mac80211: do not aggregate frames if max_frags is set to one
[not found] <cover.1535489707.git.lorenzo.bianconi@redhat.com>
@ 2018-08-28 21:07 ` Lorenzo Bianconi
2018-08-28 21:14 ` Johannes Berg
0 siblings, 1 reply; 5+ messages in thread
From: Lorenzo Bianconi @ 2018-08-28 21:07 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, nbd
Do not try to aggregate packets in a A-MSDU frame if max_tx_fragments
or max_amsdu_subframes is set to 1. Moreover take into account
tail padding added on the first frame into flow backlog if
ieee80211_amsdu_realloc_pad routine on the second frame fails.
This patch fixes a kernel freeze that occasionally occurs running
iperf tests using mt76 driver
Fixes: 6e0456b54545 ("mac80211: add A-MSDU tx support")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
net/mac80211/tx.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 093108077edc..a5701573c83b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3185,11 +3185,11 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
u8 max_subframes = sta->sta.max_amsdu_subframes;
int max_frags = local->hw.max_tx_fragments;
int max_amsdu_len = sta->sta.max_amsdu_len;
+ int n = 1, nfrags, delta;
__be16 len;
void *data;
bool ret = false;
unsigned int orig_len;
- int n = 1, nfrags;
if (!ieee80211_hw_check(&local->hw, TX_AMSDU))
return false;
@@ -3222,9 +3222,6 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
if (skb->len + head->len > max_amsdu_len)
goto out;
- if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head))
- goto out;
-
nfrags = 1 + skb_shinfo(skb)->nr_frags;
nfrags += 1 + skb_shinfo(head)->nr_frags;
frag_tail = &skb_shinfo(head)->frag_list;
@@ -3240,10 +3237,15 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
if (max_frags && nfrags > max_frags)
goto out;
- if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(rfc1042_header) + 2,
- &subframe_len))
+ if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head))
goto out;
+ if (!ieee80211_amsdu_realloc_pad(local, skb, sizeof(rfc1042_header) + 2,
+ &subframe_len)) {
+ delta = head->len - orig_len;
+ goto update_backlog;
+ }
+
ret = true;
data = skb_push(skb, ETH_ALEN + 2);
memmove(data, data + ETH_ALEN + 2, 2 * ETH_ALEN);
@@ -3256,11 +3258,14 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
head->len += skb->len;
head->data_len += skb->len;
*frag_tail = skb;
+ delta = head->len - orig_len;
- flow->backlog += head->len - orig_len;
- tin->backlog_bytes += head->len - orig_len;
-
- fq_recalc_backlog(fq, tin, flow);
+update_backlog:
+ if (delta > 0) {
+ flow->backlog += delta;
+ tin->backlog_bytes += delta;
+ fq_recalc_backlog(fq, tin, flow);
+ }
out:
spin_unlock_bh(&fq->lock);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mac80211: do not aggregate frames if max_frags is set to one
2018-08-28 21:07 ` [PATCH] mac80211: do not aggregate frames if max_frags is set to one Lorenzo Bianconi
@ 2018-08-28 21:14 ` Johannes Berg
2018-08-28 21:41 ` Lorenzo Bianconi
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2018-08-28 21:14 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-wireless, nbd, sara.sharon
On Tue, 2018-08-28 at 23:07 +0200, Lorenzo Bianconi wrote:
> Do not try to aggregate packets in a A-MSDU frame if max_tx_fragments
> or max_amsdu_subframes is set to 1.
Yeah that seems valid.
> Moreover take into account
> tail padding added on the first frame into flow backlog if
> ieee80211_amsdu_realloc_pad routine on the second frame fails.
That's not really right - the padding shouldn't have been added to the
first subframe in the first place as the last one shouldn't have padding
at all. There's also a separate bug in that the A-MSDU subframe length
should NOT include the padding.
My colleague Sara (CC'ed now) has a patch to fix all of this (we just
did that this morning). I'll send it out tomorrow morning. Can I bother
you to try that?
We'd have to fix the first point independently though, or I guess we can
roll that into our bugfix too, which would you prefer?
johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mac80211: do not aggregate frames if max_frags is set to one
2018-08-28 21:14 ` Johannes Berg
@ 2018-08-28 21:41 ` Lorenzo Bianconi
2018-08-29 6:57 ` Johannes Berg
0 siblings, 1 reply; 5+ messages in thread
From: Lorenzo Bianconi @ 2018-08-28 21:41 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, Felix Fietkau, sara.sharon
>
> On Tue, 2018-08-28 at 23:07 +0200, Lorenzo Bianconi wrote:
> > Do not try to aggregate packets in a A-MSDU frame if max_tx_fragments
> > or max_amsdu_subframes is set to 1.
>
> Yeah that seems valid.
>
> > Moreover take into account
> > tail padding added on the first frame into flow backlog if
> > ieee80211_amsdu_realloc_pad routine on the second frame fails.
>
> That's not really right - the padding shouldn't have been added to the
> first subframe in the first place as the last one shouldn't have padding
> at all. There's also a separate bug in that the A-MSDU subframe length
> should NOT include the padding.
>
Assuming the A-MSDU subframe is composed by two packets, the last one
must not contain padding, is my understanding correct?
> My colleague Sara (CC'ed now) has a patch to fix all of this (we just
> did that this morning). I'll send it out tomorrow morning. Can I bother
> you to try that?
>
Sure, no worries :)
> We'd have to fix the first point independently though, or I guess we can
> roll that into our bugfix too, which would you prefer?
>
> johannes
>
If the patch is already done I can add the fix for the first point on
top of it, does it sound good?
Regards,
Lorenzo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mac80211: do not aggregate frames if max_frags is set to one
2018-08-28 21:41 ` Lorenzo Bianconi
@ 2018-08-29 6:57 ` Johannes Berg
2018-08-29 10:21 ` Lorenzo Bianconi
0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2018-08-29 6:57 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-wireless, Felix Fietkau, sara.sharon
On Tue, 2018-08-28 at 23:41 +0200, Lorenzo Bianconi wrote:
> Assuming the A-MSDU subframe is composed by two packets, the last one
> must not contain padding, is my understanding correct?
Yes. More generally, assuming the A-MSDU subframe is composed of *any
number of* packets, the last one must not contain padding :)
> > My colleague Sara (CC'ed now) has a patch to fix all of this (we just
> > did that this morning). I'll send it out tomorrow morning. Can I bother
> > you to try that?
> >
>
> Sure, no worries :)
Thanks, patch coming up in a second.
> > We'd have to fix the first point independently though, or I guess we can
> > roll that into our bugfix too, which would you prefer?
> >
> > johannes
> >
>
> If the patch is already done I can add the fix for the first point on
> top of it, does it sound good?
Perfect.
johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mac80211: do not aggregate frames if max_frags is set to one
2018-08-29 6:57 ` Johannes Berg
@ 2018-08-29 10:21 ` Lorenzo Bianconi
0 siblings, 0 replies; 5+ messages in thread
From: Lorenzo Bianconi @ 2018-08-29 10:21 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, Felix Fietkau, sara.sharon
> On Tue, 2018-08-28 at 23:41 +0200, Lorenzo Bianconi wrote:
>
> > Assuming the A-MSDU subframe is composed by two packets, the last one
> > must not contain padding, is my understanding correct?
>
> Yes. More generally, assuming the A-MSDU subframe is composed of *any
> number of* packets, the last one must not contain padding :)
>
> > > My colleague Sara (CC'ed now) has a patch to fix all of this (we just
> > > did that this morning). I'll send it out tomorrow morning. Can I bother
> > > you to try that?
> > >
> >
> > Sure, no worries :)
>
> Thanks, patch coming up in a second.
>
> > > We'd have to fix the first point independently though, or I guess we can
> > > roll that into our bugfix too, which would you prefer?
> > >
> > > johannes
> > >
> >
> > If the patch is already done I can add the fix for the first point on
> > top of it, does it sound good?
>
> Perfect.
Ok, I will apply it on top of Sara's patch and send it later today.
Regards,
Lorenzo
>
> johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-29 14:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1535489707.git.lorenzo.bianconi@redhat.com>
2018-08-28 21:07 ` [PATCH] mac80211: do not aggregate frames if max_frags is set to one Lorenzo Bianconi
2018-08-28 21:14 ` Johannes Berg
2018-08-28 21:41 ` Lorenzo Bianconi
2018-08-29 6:57 ` Johannes Berg
2018-08-29 10:21 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).