From patchwork Tue Aug 28 21:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10579161 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1858A14BD for ; Tue, 28 Aug 2018 21:07:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02F3F2A7FE for ; Tue, 28 Aug 2018 21:07:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E906E2A93E; Tue, 28 Aug 2018 21:07:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FA132A7FE for ; Tue, 28 Aug 2018 21:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727181AbeH2BAm (ORCPT ); Tue, 28 Aug 2018 21:00:42 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38995 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbeH2BAl (ORCPT ); Tue, 28 Aug 2018 21:00:41 -0400 Received: by mail-wm0-f68.google.com with SMTP id q8-v6so3380083wmq.4 for ; Tue, 28 Aug 2018 14:07:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SeOQ+qws1i/hQZtbrZOZwlxgUCAOy7Q+YcJonNz9kO4=; b=kwM/fIXvmMq3CN8WpeEUelShxAEaNX+AUj2hYx84MqRGq0nvQrJTKXEveGFM2rsyJ3 tWxCjDifIQLynuobg6bKN+TZyb4XxBlUjs2AqCSh8wBE86XHHqCEPwK+MqLQMJ+7jxHT F2FZuvKm4fAOfwbUeyhfcZVYyMRDGqUA9B+v2gJDo+XzvUWowJ6EqJY/zlxdIG2G5S7m z/DnAOxZLS59SSfMmgRuqFTXjPOuvCh0ArDgNwMTFMpi+puFu2pC/o7GgQGJJSohDrvm ZGZ4e/u3cW372AoE1LfYMD4N4bqiKnUJGxym2z+TXwBZ1UaiV8g+a24NTqCic1i+9D7A DTMw== X-Gm-Message-State: APzg51CDW/pKrF9eDgNwrmEN+r8QwATyCQ4wZIWDwHEAsDny2/0EFP8X ZK2F7YlVHvM++Ui1LJeKz+1ngCKCfq8= X-Google-Smtp-Source: ANB0VdZ7e1Vk+40MqRpFjpSRLwgHpiWvd/1ujWRF1ebf6cp4mTEIuw3JAHDft/aBxcIZ/MM0S7XVAA== X-Received: by 2002:a1c:8291:: with SMTP id e139-v6mr2565072wmd.39.1535490433440; Tue, 28 Aug 2018 14:07:13 -0700 (PDT) Received: from localhost.lan ([151.66.53.29]) by smtp.gmail.com with ESMTPSA id w18-v6sm4767951wrc.38.2018.08.28.14.07.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 14:07:12 -0700 (PDT) From: Lorenzo Bianconi To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, nbd@nbd.name Subject: [PATCH] mac80211: do not aggregate frames if max_frags is set to one Date: Tue, 28 Aug 2018 23:07:07 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);