From patchwork Mon Apr 12 05:39:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shayne Chen X-Patchwork-Id: 12196863 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B563C433ED for ; Mon, 12 Apr 2021 05:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B702A610C7 for ; Mon, 12 Apr 2021 05:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbhDLFk5 (ORCPT ); Mon, 12 Apr 2021 01:40:57 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:55386 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229448AbhDLFk4 (ORCPT ); Mon, 12 Apr 2021 01:40:56 -0400 X-UUID: e7fab72f9f4e40188f4890a67e492898-20210412 X-UUID: e7fab72f9f4e40188f4890a67e492898-20210412 Received: from mtkmrs01.mediatek.inc [(172.21.131.159)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 90478055; Mon, 12 Apr 2021 13:40:35 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 12 Apr 2021 13:40:34 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 12 Apr 2021 13:40:33 +0800 From: Shayne Chen To: Felix Fietkau CC: linux-wireless , Lorenzo Bianconi , Ryder Lee , Evelyn Tsai , linux-mediatek , Shayne Chen Subject: [PATCH 2/3] mt76: mt7915: rework mt7915_tm_set_tx_len() Date: Mon, 12 Apr 2021 13:39:53 +0800 Message-ID: <20210412053954.23544-2-shayne.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210412053954.23544-1-shayne.chen@mediatek.com> References: <20210412053954.23544-1-shayne.chen@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Rework mt7915_tm_set_tx_len() with mt76_testmode_alloc_skb() to support larger packet based on a longer tx_time. Signed-off-by: Shayne Chen --- .../wireless/mediatek/mt76/mt7915/testmode.c | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c index bd798df..f9d81e3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/testmode.c @@ -257,13 +257,13 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time) { struct mt76_phy *mphy = phy->mt76; struct mt76_testmode_data *td = &mphy->test; - struct sk_buff *old = td->tx_skb, *new; struct ieee80211_supported_band *sband; struct rate_info rate = {}; u16 flags = 0, tx_len; u32 bitrate; + int ret; - if (!tx_time || !old) + if (!tx_time) return 0; rate.mcs = td->tx_rate_idx; @@ -323,21 +323,9 @@ mt7915_tm_set_tx_len(struct mt7915_phy *phy, u32 tx_time) bitrate = cfg80211_calculate_bitrate(&rate); tx_len = bitrate * tx_time / 10 / 8; - if (tx_len < sizeof(struct ieee80211_hdr)) - tx_len = sizeof(struct ieee80211_hdr); - else if (tx_len > IEEE80211_MAX_FRAME_LEN) - tx_len = IEEE80211_MAX_FRAME_LEN; - - new = alloc_skb(tx_len, GFP_KERNEL); - if (!new) - return -ENOMEM; - - skb_copy_header(new, old); - __skb_put_zero(new, tx_len); - memcpy(new->data, old->data, sizeof(struct ieee80211_hdr)); - - dev_kfree_skb(old); - td->tx_skb = new; + ret = mt76_testmode_alloc_skb(phy->mt76, tx_len); + if (ret) + return ret; return 0; }