Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6277607yba; Wed, 1 May 2019 09:10:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFpVQzOfHbl9B/xlDVophAz0F7js6zdLAw75hW86HIh0UePgl7g6sPsKW2FNOu43+mVUm8 X-Received: by 2002:a62:1ec5:: with SMTP id e188mr5334870pfe.242.1556727022771; Wed, 01 May 2019 09:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556727022; cv=none; d=google.com; s=arc-20160816; b=cnU5r1/zSKI9coQ0MottAIykxk8PhfVp/BKcq0CW7Vqucm93cBdSgG7Q60hId2dYcj s6QPtgVYvyBuZNlJYlm8m2JRbcBgicCn8iz4qdkMsYSJXNvpSetuc1eqXOmX5QWj79DR T6nnZZjkAHMkS04dBZVXY8lLLqNXYMj0TuPfnuLBpNG/8086mAeR3g7cBGYtfuC87kVI EJeEviK1J1kgfdZNGhGYZg3PyjVVpv+rZ/VEaDLmsd7DvmZlrEyt0V2Z9D2oM//pAqRP TYh8aBqQGN5GQU6ONNOiHmhUQayxxZMbgmJS9yqOncvnVSbHreLn8TXWNRpu+15AX18k fQUw== 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=aEDypifChdJElF0lUgUfm8L27tmcYHZb0AaAePAOF0U=; b=ArqXQIbLs8kruz13aLh2g5xajv35rqG5xmMAy1p5bHxqDbtOD4YRZUDN3IGFIlpsSl NcUn4OhIt6YWbDVdnZk8DgQPvmGNxqMEMIvbzDrHMzxiaOb2888xoZ+CHK0z0HntyCPF fJIDiI3gNHDTdtyFJ7opkY04CZmoQT0Jf674s91Z/k611rBWs8D0CayGYnz9fDknNKAY A0a2Sko8FLoZV+Lr3rTwne/uByuIlS9H1plA8nmARxiDNV6hBlnQuTQlmomrBAMqhfRo 3VwfzIca2bohvC8gD9ETm6IwyTLWAg6ikipIkGh4Sh8oNAypZpN7+cVW68STIE8hnB5Z gTqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1vhNRIud; 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 i7si40645556plt.332.2019.05.01.09.10.08; Wed, 01 May 2019 09:10:22 -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=1vhNRIud; 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 S1726881AbfEAQH7 (ORCPT + 99 others); Wed, 1 May 2019 12:07:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbfEAQH6 (ORCPT ); Wed, 1 May 2019 12:07:58 -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 CAEC5208C3; Wed, 1 May 2019 16:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556726877; bh=y6zwq5TmNpkmP0Fjp1KhxhPVexi9KgxZXbLVfd6RL1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1vhNRIud6wifd+uGh9Ogyx0EGt7onzkwI4NSXnb0up0T9MD/1yRbe68OppB7G8WW6 C/CUjeACE8oltnpXmheOU1uql7eKSfvbbCdxP1sHc+2Kv6PR1THWUtRS5McUKGmo1+ n+KIeEPYI8R5bSu1iolgOk28m9oG+LFwSuCAhVhY= 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 04/17] mt7615: mcu: use proper msg size in mt7615_mcu_add_wtbl_bmc Date: Wed, 1 May 2019 18:07:26 +0200 Message-Id: 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_bmc 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 c79df00a6da6..8c76274fd79b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -987,39 +987,33 @@ int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid, &wtbl_sec_key, buf_len); } -int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) +int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, + struct ieee80211_vif *vif) { struct mt7615_vif *mvif = (struct mt7615_vif *)vif->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); - eth_broadcast_addr(wtbl_generic->peer_addr); - wtbl_generic->muar_idx = 0xe; - - 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 = 1; - wtbl_rx->rca2 = 1; - wtbl_rx->rv = 1; - - ret = __mt7615_mcu_set_wtbl(dev, mvif->sta.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 = 0xe, + }, + .rx_wtbl = { + .tag = cpu_to_le16(WTBL_RX), + .len = cpu_to_le16(sizeof(struct wtbl_rx)), + .rca1 = 1, + .rca2 = 1, + .rv = 1, + }, + }; + eth_broadcast_addr(data.g_wtbl.peer_addr); - kfree(buf); - return ret; + return __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, + WTBL_RESET_AND_SET, 2, &data, + sizeof(struct wtbl_generic) + + sizeof(struct wtbl_rx)); } int mt7615_mcu_del_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) -- 2.20.1