Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3310065pxu; Tue, 8 Dec 2020 08:44:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/4nD0qK4k185OrRlDY3wr8Ejv6ZEaB7zWRCgiiBOBolJFtztRz3YdhZWBhN92Q8VTJpbU X-Received: by 2002:a50:ee8e:: with SMTP id f14mr18328322edr.176.1607445873243; Tue, 08 Dec 2020 08:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607445873; cv=none; d=google.com; s=arc-20160816; b=tDiOqfyVb27KVMU0Y20QOBPWPCc61bRhEPfmmWPgFmF+nS5eLWek4zgMyJMyZVuDDr XX8jSUz8GzSdztkGPFqpN+iYohWp4+Ahlf/iqEdaKzwxRaI3KVBwITjML7l+e1Z4mK1N idiKqcH3bjUwYCT/caKcw8t2a8z7F3BjjU9dXYvo5Gf4rtsptvgYOxe52eOwBf/I18wO P42ojg8c6JOsnQ0XgikrHuE2caSPcfdk2+1iCXB6Zu5a3WB3JqASpchPJRpGmEIlTJZR 52ZME7xTX9HLyuYrwNM3H6F8AnC68qkr/cSyX2L4DYS9K2HvilRHRNN3TfLWw+NnXXry l4lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Ol+yM21Wp4R6i11ecFEqvmzDNobqzRAdm7bxK9y+B5M=; b=b3BFMbY/kABeEx8zhF7uauR9syAJrm8aUkVCAAaj/4oBChw//W6iVe9hdtPtZFJ59y 1NMZEFYOne1AeIKF2e8A10zlDiB588L7YGPXLY9qg2msRCoWMAyr7sB0zub4Du2iCnLM iUBSangq0SJrdOZmQ36kYWTYrlEoAoRzPSkWPwHj4HzO8IAiQtSAoy1RSc5qckZXrH+s mMey+Rslx92BdvSnToXz5QxB51jNIAA1FTwanwhdw7GOxhubFYfFnWH6Nab0X0pyjg0b Be7QoSoUSOsHLejFgfFDH2bbdrxxduCDKjtYq/QsYHld/74CkzpOwH4cTgr/mTvmKK4j NI1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si3343751edu.542.2020.12.08.08.44.01; Tue, 08 Dec 2020 08:44:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730459AbgLHQjw (ORCPT + 99 others); Tue, 8 Dec 2020 11:39:52 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:51509 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730264AbgLHQjw (ORCPT ); Tue, 8 Dec 2020 11:39:52 -0500 X-UUID: 12cb5184cc0444f7b932f9ac09d1acaf-20201209 X-UUID: 12cb5184cc0444f7b932f9ac09d1acaf-20201209 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] 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 1393703589; Wed, 09 Dec 2020 00:39:08 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 00:39:03 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 00:39:05 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH] mt76: mt7915: fix MT_CIPHER_BIP_CMAC_128 setkey Date: Wed, 9 Dec 2020 00:39:04 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: C0C557279579C781CBF29A7B5D208ABA8F1597C2BB9689007CBEA438C2709D8B2000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org MCU expects to set WLAN_CIPHER_SUITE_CCMP and WLAN_CIPHER_SUITE_AES_CMAC at the same time, so adding an intermediate buffer for batch update. Tested-by: Sujuan Chen Signed-off-by: Ryder Lee --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 20 +++++++++++++------ .../wireless/mediatek/mt76/mt7915/mt7915.h | 7 +++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 6097653abda4..6f242d55dba3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -1016,9 +1016,10 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, /** starec & wtbl **/ static int -mt7915_mcu_sta_key_tlv(struct sk_buff *skb, struct ieee80211_key_conf *key, - enum set_key_cmd cmd) +mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb, + struct ieee80211_key_conf *key, enum set_key_cmd cmd) { + struct mt7915_sta_key_conf *bip = &msta->bip; struct sta_rec_sec *sec; struct tlv *tlv; u32 len = sizeof(*sec); @@ -1038,22 +1039,23 @@ mt7915_mcu_sta_key_tlv(struct sk_buff *skb, struct ieee80211_key_conf *key, sec_key = &sec->key[0]; sec_key->cipher_len = sizeof(*sec_key); - sec_key->key_id = key->keyidx; if (cipher == MT_CIPHER_BIP_CMAC_128) { sec_key->cipher_id = MT_CIPHER_AES_CCMP; + sec_key->key_id = bip->keyidx; sec_key->key_len = 16; - memcpy(sec_key->key, key->key, 16); + memcpy(sec_key->key, bip->key, 16); sec_key = &sec->key[1]; sec_key->cipher_id = MT_CIPHER_BIP_CMAC_128; sec_key->cipher_len = sizeof(*sec_key); sec_key->key_len = 16; - memcpy(sec_key->key, key->key + 16, 16); + memcpy(sec_key->key, key->key, 16); sec->n_cipher = 2; } else { sec_key->cipher_id = cipher; + sec_key->key_id = key->keyidx; sec_key->key_len = key->keylen; memcpy(sec_key->key, key->key, key->keylen); @@ -1063,6 +1065,12 @@ mt7915_mcu_sta_key_tlv(struct sk_buff *skb, struct ieee80211_key_conf *key, memcpy(sec_key->key + 24, key->key + 16, 8); } + /* sotre key_conf for BIP batch update */ + if (cipher == MT_CIPHER_AES_CCMP) { + memcpy(bip->key, key->key, key->keylen); + bip->keyidx = key->keyidx; + } + len -= sizeof(*sec_key); sec->n_cipher = 1; } @@ -1088,7 +1096,7 @@ int mt7915_mcu_add_key(struct mt7915_dev *dev, struct ieee80211_vif *vif, if (IS_ERR(skb)) return PTR_ERR(skb); - ret = mt7915_mcu_sta_key_tlv(skb, key, cmd); + ret = mt7915_mcu_sta_key_tlv(msta, skb, key, cmd); if (ret) return ret; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 30e53a0f01fb..5bf76c74373f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -71,6 +71,11 @@ struct mt7915_sta_stats { unsigned long jiffies; }; +struct mt7915_sta_key_conf { + s8 keyidx; + u8 key[16]; +}; + struct mt7915_sta { struct mt76_wcid wcid; /* must be first */ @@ -84,6 +89,8 @@ struct mt7915_sta { struct mt7915_sta_stats stats; unsigned long ampdu_state; + + struct mt7915_sta_key_conf bip; }; struct mt7915_vif { -- 2.18.0