Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6277503yba; Wed, 1 May 2019 09:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNe14XGjmaAtzklws1Todzc0oBqQnzKtZHv0ai7WIlB9P8K9N5qdSm/oJRE5nUvJNW2N3p X-Received: by 2002:a63:da51:: with SMTP id l17mr33322447pgj.115.1556727016488; Wed, 01 May 2019 09:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556727016; cv=none; d=google.com; s=arc-20160816; b=FY0RZ6fSeIzVzCNM1tGL6sR3lCw3MKjciFIezvzTxfwGJvvEALIUslAWMuWyDXyrPv sJ1FxAaI4elYfkIrwatnG+reuAJAo+7S1WIQ+LI5oCgqFzqNA+ARO9/J2psXjm/V31bJ mquXtwVRUSqWkfdjT59vcJOEP5x4CF2c1e3mQyvzJr2R1LaMFIYkdltS/07serEHU+oX 7owclc5wJGGmkgcK9NDl4Sw+RnMcu/RlXeUJb3e1JZjWdi9Mlceq2gcknnyrI5GT0PxT bhStHhIpgzv2ig81Zmp0U5CEya/xo0IDQLD+kiLgA0RssHLglPazTIWtHtCuUpSCYuLY Dvtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WYsSbzzvUXMeGplbBkWmqSmFjWlTE1reCD93riSpllo=; b=V1DrTxSjTaK1fuuAPeHQv4Dj/jXtID7Qx7fQhRw31oMhXlVdSTGS+DclBzDOysTP97 yPthlnOS3d4hfDyQP8ZZDy0utv27FGnKw2RI1zRJXRtgIUkfZ9IZAHXCbKsLsDI7t7Oj HmXZMSggix8fpS8ZYR6Z0dg2974+W/BExl19ZhPoHgskzplm3UJVjXlUqoKgjG3zAAwd dtQF5Uf/amSX+kOredfLobIYDffbLbkXnPqJNrgQoZXJasZsS4l1+jBTFyk1vlqLEEgq 5SZOauyWA4zl80P2Sm/aEkqQQht/fF6+sfme/tTB+T/aTX+9cmgl4I2oAtjRypbmsLvD jTxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1ho/+M22"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3si39786036pgs.37.2019.05.01.09.10.01; Wed, 01 May 2019 09:10:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1ho/+M22"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726903AbfEAQIA (ORCPT + 99 others); Wed, 1 May 2019 12:08:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:36936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726891AbfEAQIA (ORCPT ); Wed, 1 May 2019 12:08:00 -0400 Received: from localhost.localdomain (unknown [151.66.22.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 592462177B; Wed, 1 May 2019 16:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556726879; bh=zUf7rDK62Ax1d3lMjUdPwaUVfYGPr3d0dspTrJM4C/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ho/+M22f5SFTlmXnPHz9XW1CmvZlYLWFGikCwPmBtTavmA8y7cc4SXc0DnO/Lyau lvtBa+HLB8zIpEwdAIgxJCQC9ryN2JfAqnHsylxIXCM87y1QwWVZSezNXX3wkGlHYb 3bW3efDAGX1b0P7Y0DyTLqkC7tQpEODJWCP9zT0I= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com, royluo@google.com Subject: [RFC 05/17] mt7615: mcu: use proper msg size in mt7615_mcu_add_wtbl Date: Wed, 1 May 2019 18:07:27 +0200 Message-Id: <96456a49763d7410f1fc9183930552fb29ef1d35.1556726268.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use proper mcu message size in mt7615_mcu_add_wtbl and do not allocate a huge buffer. Moreover use stack memory instead of heap one Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 54 +++++++++---------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 8c76274fd79b..1d7c8cf56040 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -1029,37 +1029,31 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, { struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; - struct wtbl_generic *wtbl_generic; - struct wtbl_rx *wtbl_rx; - int buf_len, ret; - u8 *buf; - - buf = kzalloc(MT7615_WTBL_UPDATE_MAX_SIZE, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - wtbl_generic = (struct wtbl_generic *)buf; - buf_len = sizeof(*wtbl_generic); - wtbl_generic->tag = cpu_to_le16(WTBL_GENERIC); - wtbl_generic->len = cpu_to_le16(buf_len); - memcpy(wtbl_generic->peer_addr, sta->addr, ETH_ALEN); - wtbl_generic->muar_idx = mvif->omac_idx; - wtbl_generic->qos = sta->wme; - wtbl_generic->partial_aid = cpu_to_le16(sta->aid); - - wtbl_rx = (struct wtbl_rx *)(buf + buf_len); - buf_len += sizeof(*wtbl_rx); - wtbl_rx->tag = cpu_to_le16(WTBL_RX); - wtbl_rx->len = cpu_to_le16(sizeof(*wtbl_rx)); - wtbl_rx->rca1 = (vif->type == NL80211_IFTYPE_AP) ? 0 : 1; - wtbl_rx->rca2 = 1; - wtbl_rx->rv = 1; - - ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_RESET_AND_SET, - 2, buf, buf_len); + struct { + struct wtbl_generic g_wtbl; + struct wtbl_rx rx_wtbl; + } data = { + .g_wtbl = { + .tag = cpu_to_le16(WTBL_GENERIC), + .len = cpu_to_le16(sizeof(struct wtbl_generic)), + .muar_idx = mvif->omac_idx, + .qos = sta->wme, + .partial_aid = cpu_to_le16(sta->aid), + }, + .rx_wtbl = { + .tag = cpu_to_le16(WTBL_RX), + .len = cpu_to_le16(sizeof(struct wtbl_rx)), + .rca1 = vif->type != NL80211_IFTYPE_AP, + .rca2 = 1, + .rv = 1, + }, + }; + memcpy(data.g_wtbl.peer_addr, sta->addr, ETH_ALEN); - kfree(buf); - return ret; + return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, + WTBL_RESET_AND_SET, 2, &data, + sizeof(struct wtbl_generic) + + sizeof(struct wtbl_rx)); } int mt7615_mcu_del_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, -- 2.20.1