Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp589638yba; Sat, 4 May 2019 08:32:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9ahKAjNM2JGQVJG4NoFMoimG8AR1LD3Fcqi5CeK/RctbYgCs2KDFkU+epvKN4+6y0qL/p X-Received: by 2002:a63:4a5a:: with SMTP id j26mr18477440pgl.361.1556983945704; Sat, 04 May 2019 08:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556983945; cv=none; d=google.com; s=arc-20160816; b=vG7fl4wTm4TnDybG7S/cdh4Q2wx5s8HCtJDyvWtCCmI8p+JPPcph8gL8AwwlZQwrFN EHZsM/Inp2iJICIuqjE4J6NVH1sj4pr1TIfsBmJmGYRX9EXJaqS6QTrM7ngssYKOlraY X/AVE3B/cBNE0wxH9M/A9lOQ4JU+4ZFfF65qhEwXIPlTdkmVfr225qSb0iyUi73r65X9 H9B/GBTl3Qhkk7P9waegqDb4gTkrngwyfpvM1IPT6cjcjRE3a8K1w6iLXhCSs9diUqev +NOnx4VzTgax35WIo2FGmiYv9St1La/ttv6hO/MIQNoFNWcY3Jj+TkFOf7UKGv1iO4M2 EiWw== 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=XwsOuaLre3wKCDAeL+4Dt/xdhZcac8YPhjGpcRenLjc=; b=QztB2cDbNdtJfRBVMgUMk8ErY3oRTJHXKiQP0VuSC7ISt8W14D5Z0AF2VxEeBzaxGM 6gFc+IRbx6359iPqTtCFw9RQmQHaNLRZCfQA1AkW1ZxWsx7f+dIKXVsKo1I+rCllebcw Igxpjb7IAdhcLJkGwuyrDYjvGWIg6r2I5vkGFdYaTPtAxXFpMFueMXj/yZdhVHui/1Ap 25kUBI6PSJmaTWmsu5tsmpJR93IWOY/aHcO+GVtUGH/rVdIIikOM0aWrBdZNzPXfmLu0 VHZPTLhYLMSzNju41e4LT+hIxpyVWZrn0fxjwMff6d3DgjUnIQoSwAUZmcESV1zozLni +Ukg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yewiZs7j; 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 d30si8084794pla.105.2019.05.04.08.32.11; Sat, 04 May 2019 08:32:25 -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=yewiZs7j; 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 S1726555AbfEDP33 (ORCPT + 99 others); Sat, 4 May 2019 11:29:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfEDP33 (ORCPT ); Sat, 4 May 2019 11:29:29 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.59.15]) (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 EA95420862; Sat, 4 May 2019 15:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556983768; bh=0L2o4V5O+/4GXqDiaH3NTOwWm4XK8nBmqa0nkoiVwJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yewiZs7j2Z4jFbNCQGOgiUE7IOlzwF1aj7BAiiVMJtrmh3PNAcNo+kNwRoypY4qQi 02VoTF3GgIMzGJ9hm26uCdeFvjVPsB/kRllCFRDmwQMmx+qxkATWdYkohCQSUrg8NB GyVi085wnRCCumRIKgsRCO4OoIDsr7GcdMFYBmgU= 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: [PATCH 01/17] mt7615: mcu: simplify __mt7615_mcu_set_wtbl Date: Sat, 4 May 2019 17:28:53 +0200 Message-Id: <56ec48c43cade7bd961dfb39b9512dac8808c573.1556981521.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 Do not loop over cmd payload in __mt7615_mcu_set_wtbl since it is already done in before running __mt7615_mcu_set_wtbl (e.g. mt7615_mcu_set_wtbl_key) Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index dc1301effa24..3de20c8111cf 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -918,37 +918,24 @@ int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, struct ieee80211_vif *vif, return __mt7615_mcu_set_bss_info(dev, &bss_info); } -static int __mt7615_mcu_set_wtbl(struct mt7615_dev *dev, int wlan_idx, - int operation, void *buf, int buf_len) +static int +__mt7615_mcu_set_wtbl(struct mt7615_dev *dev, int wlan_idx, + int operation, int ntlv, void *buf, + int buf_len) { struct req_hdr { u8 wlan_idx; u8 operation; __le16 tlv_num; u8 rsv[4]; - } __packed req_hdr = {0}; - struct tlv { - __le16 tag; - __le16 len; - u8 buf[0]; - } __packed; + } __packed req_hdr = { + .wlan_idx = wlan_idx, + .operation = operation, + .tlv_num = cpu_to_le16(ntlv), + }; struct sk_buff *skb; - u16 tlv_num = 0; - int offset = 0; - - while (offset < buf_len) { - struct tlv *tlv = (struct tlv *)((u8 *)buf + offset); - - tlv_num++; - offset += tlv->len; - } skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + buf_len); - - req_hdr.wlan_idx = wlan_idx; - req_hdr.operation = operation; - req_hdr.tlv_num = cpu_to_le16(tlv_num); - memcpy(skb_put(skb, sizeof(req_hdr)), &req_hdr, sizeof(req_hdr)); if (buf && buf_len) @@ -1015,8 +1002,8 @@ int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid, wtbl_sec_key.key_len = sizeof(wtbl_sec_key.key_material); } - return __mt7615_mcu_set_wtbl(dev, wcid, WTBL_SET, &wtbl_sec_key, - buf_len); + return __mt7615_mcu_set_wtbl(dev, wcid, WTBL_SET, 1, + &wtbl_sec_key, buf_len); } int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) @@ -1047,7 +1034,8 @@ int mt7615_mcu_add_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) wtbl_rx->rv = 1; ret = __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, - WTBL_RESET_AND_SET, buf, buf_len); + WTBL_RESET_AND_SET, 2, buf, + buf_len); kfree(buf); return ret; @@ -1058,7 +1046,7 @@ int mt7615_mcu_del_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif) struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; return __mt7615_mcu_set_wtbl(dev, mvif->sta.wcid.idx, - WTBL_RESET_AND_SET, NULL, 0); + WTBL_RESET_AND_SET, 0, NULL, 0); } int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, @@ -1092,8 +1080,8 @@ int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, wtbl_rx->rca2 = 1; wtbl_rx->rv = 1; - ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, - WTBL_RESET_AND_SET, buf, buf_len); + ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_RESET_AND_SET, + 2, buf, buf_len); kfree(buf); return ret; @@ -1105,12 +1093,12 @@ int mt7615_mcu_del_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif, struct mt7615_sta *msta = (struct mt7615_sta *)sta->drv_priv; return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, - WTBL_RESET_AND_SET, NULL, 0); + WTBL_RESET_AND_SET, 0, NULL, 0); } int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev) { - return __mt7615_mcu_set_wtbl(dev, 0, WTBL_RESET_ALL, NULL, 0); + return __mt7615_mcu_set_wtbl(dev, 0, WTBL_RESET_ALL, 0, NULL, 0); } static int __mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, int bss_idx, @@ -1367,7 +1355,7 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, struct wtbl_ht *wtbl_ht; struct wtbl_raw *wtbl_raw; struct sta_rec_ht *sta_rec_ht; - int buf_len, ret; + int buf_len, ret, ntlv = 2; u32 msk, val = 0; u8 *buf; @@ -1400,6 +1388,7 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, wtbl_vht->len = cpu_to_le16(sizeof(*wtbl_vht)); wtbl_vht->ldpc = sta->vht_cap.cap & IEEE80211_VHT_CAP_RXLDPC; wtbl_vht->vht = 1; + ntlv++; if (sta->vht_cap.cap & IEEE80211_VHT_CAP_SHORT_GI_80) val |= MT_WTBL_W5_SHORT_GI_80; @@ -1416,6 +1405,7 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, wtbl_smps->tag = cpu_to_le16(WTBL_SMPS); wtbl_smps->len = cpu_to_le16(sizeof(*wtbl_smps)); wtbl_smps->smps = 1; + ntlv++; } /* sgi */ @@ -1431,8 +1421,8 @@ int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif, wtbl_raw->msk = cpu_to_le32(~msk); wtbl_raw->val = cpu_to_le32(val); - ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, buf, - buf_len); + ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, ntlv, + buf, buf_len); if (ret) { kfree(buf); return ret; @@ -1501,8 +1491,8 @@ int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev, wtbl_ba.ba_winsize_idx = idx; } - ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, &wtbl_ba, - buf_len); + ret = __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, 1, + &wtbl_ba, buf_len); if (ret) return ret; @@ -1561,7 +1551,7 @@ int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev, wtbl_ba.rst_ba_sb = 1; return __mt7615_mcu_set_wtbl(dev, msta->wcid.idx, WTBL_SET, - &wtbl_ba, buf_len); + 1, &wtbl_ba, buf_len); } void mt7615_mcu_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta, -- 2.20.1