Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1038338lqd; Thu, 25 Apr 2024 04:29:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0AbMSEsIN8/by7OV6DOmvken3HWX5BJm3bDRlhMvtkSoGHYH/gkiZod/4gQ3WvpI/Cn7OS8jjlAbLsY6HdJNb7YRH/JzQgBz+x3zkDg== X-Google-Smtp-Source: AGHT+IFsZ3Vj/nbGq5JszAJ8tGV+gTEw4QrecW/AYlHGJrX89prObuGOlw2k0icEvNjvHWI4dCcq X-Received: by 2002:ac8:7d92:0:b0:43a:3b8a:e4c8 with SMTP id c18-20020ac87d92000000b0043a3b8ae4c8mr2843003qtd.45.1714044573684; Thu, 25 Apr 2024 04:29:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714044573; cv=pass; d=google.com; s=arc-20160816; b=SrGmd0y1WfSsb/SGB6ZJ7QgydF3tDgRwsWeMkyHSZL/L9An0pP03rOaTz+aIoCbzn/ Tu0sMhNKlQ2g4u2bMifxtASF5BGU7pusCLDrD2RQ5mb86Aqr8XRQMImMyJ8/FvPtB0FT Gye+yOqowne4uUzW8PkhNz8r95M6xEcV1baMlkZgjCR1SLHBDUYj5rJ6WxrMW7v5cwVw wNALRJCoVn/4REzJ0fir4mWZHO/g9wahfYyF3YAyWRZNMGo8+4dNrN3V8l/1aWfMJlkR JElbPSQY2SaMJ5b2XHMx4TJIiRXJZc1fWL9hfffZ1TCW4sbl6XWsLOrFM7Fdff5AmNp/ lPPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=K1+y4WWWoZ+L/bJ3SklLkM/Tg17nzU+eQyVoIX8zmlI=; fh=Q+3JKoLZIMN+muDUq31kjnNN0UgJXr8C3Bak/Yf/zn8=; b=Lq5PU/Y747Elo8OtmMqU5SAuybCgmm99WVJjPaDsOh0ngbtWXHuYdMmjtpTB5HL1g8 h63hDqIy2iYCjD8kMIDl4W7MI9wjm01WoYuxNMuBh5kXHaQrfnOrZQxDOQRnU7IGiV00 we8HzkoLP/+utVnDrxg5w1CQFxlEROEbGISn1go4MIw38aDjrcEdP68RWr4vBbXND60a EUFNoIJ404EdfpFPqxKpf1QcK1ADRakeYlGBhZuaVQCbxV8XonzUpn6mQWo5d+7Fi/Hh tcQEL1ZFPlm8VmZdDrBFHdOusZ7ydR/2AB18pmJ59kpBI/QhvkAiXEe6xKJrOtNqT6Qt p6HA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-6841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6841-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h8-20020ac85848000000b00437794a2971si17692586qth.221.2024.04.25.04.29.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 04:29:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-6841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6841-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3102D1C22C8F for ; Thu, 25 Apr 2024 11:29:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC89E12A17B; Thu, 25 Apr 2024 11:29:20 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24A1F83CCD for ; Thu, 25 Apr 2024 11:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714044560; cv=none; b=ssaZCmIGLcGWQPQj2nFVFWZm4yG5HDDcc9dX3HAo/BuDQdXwTBTB0dm6yx5Mp6T6+fJZ2Sn08AQFwDEzrrkZm+CoWStnyWGO4bb2pTyPhsCP4i4Qv51F2C8x5kfp2ibSQXMh3e3q4j1+6EZDslClF7E0g9S6R4buPumMszrbEJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714044560; c=relaxed/simple; bh=+bMqIaw4lELvhzEHUN6zE22oLGhZ45ojHfcJG3uds2k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IjTYTAQAA/BC7LABolL2H177riBs21nGIDl3qGRxNOxTUJ32YMiE54MvUfqI3aM2YrrZoh3DKrdiOCyZmHqwjDXUmwfs0swIpvql2xt/DgLLV5btE2tYrQ9anvqw88humJiODtb0CCjXRSLFc0lXIEvj+MmL59RRyOmSqNgSmPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 43PBTH9t83482353, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 43PBTH9t83482353 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Apr 2024 19:29:17 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 25 Apr 2024 19:29:17 +0800 Received: from [127.0.1.1] (172.16.16.129) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 25 Apr 2024 19:29:16 +0800 From: Ping-Ke Shih To: CC: , Subject: [PATCH 08/12] wifi: rtw89: wow: add GTK rekey feature related H2C commands Date: Thu, 25 Apr 2024 19:28:12 +0800 Message-ID: <20240425112816.26431-9-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240425112816.26431-1-pkshih@realtek.com> References: <20240425112816.26431-1-pkshih@realtek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback From: Chih-Kang Chang Add PTK TRX IV, GTK RX IV, key encryption algorithm to H2C command to enable GTK rekey feature. Signed-off-by: Chih-Kang Chang Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/cam.c | 38 ++++++++++++++++++++++++ drivers/net/wireless/realtek/rtw89/fw.c | 8 ++++- drivers/net/wireless/realtek/rtw89/wow.c | 12 ++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw89/cam.c b/drivers/net/wireless/realtek/rtw89/cam.c index 9581cd108298..67f13e4c3d15 100644 --- a/drivers/net/wireless/realtek/rtw89/cam.c +++ b/drivers/net/wireless/realtek/rtw89/cam.c @@ -756,6 +756,8 @@ void rtw89_cam_fill_dctl_sec_cam_info_v1(struct rtw89_dev *rtwdev, struct rtw89_h2c_dctlinfo_ud_v1 *h2c) { struct rtw89_addr_cam_entry *addr_cam = rtw89_get_addr_cam_of(rtwvif, rtwsta); + struct rtw89_wow_param *rtw_wow = &rtwdev->wow; + u8 *ptk_tx_iv = rtw_wow->key_info.ptk_tx_iv; h2c->c0 = le32_encode_bits(rtwsta ? rtwsta->mac_id : rtwvif->mac_id, DCTLINFO_V1_C0_MACID) | @@ -808,6 +810,23 @@ void rtw89_cam_fill_dctl_sec_cam_info_v1(struct rtw89_dev *rtwdev, DCTLINFO_V1_W6_SEC_ENT4 | DCTLINFO_V1_W6_SEC_ENT5 | DCTLINFO_V1_W6_SEC_ENT6); + + if (rtw_wow->ptk_alg) { + h2c->w0 = le32_encode_bits(ptk_tx_iv[0] | ptk_tx_iv[1] << 8, + DCTLINFO_V1_W0_AES_IV_L); + h2c->m0 = cpu_to_le32(DCTLINFO_V1_W0_AES_IV_L); + + h2c->w1 = le32_encode_bits(ptk_tx_iv[4] | + ptk_tx_iv[5] << 8 | + ptk_tx_iv[6] << 16 | + ptk_tx_iv[7] << 24, + DCTLINFO_V1_W1_AES_IV_H); + h2c->m1 = cpu_to_le32(DCTLINFO_V1_W1_AES_IV_H); + + h2c->w4 |= le32_encode_bits(rtw_wow->ptk_keyidx, + DCTLINFO_V1_W4_SEC_KEY_ID); + h2c->m4 |= cpu_to_le32(DCTLINFO_V1_W4_SEC_KEY_ID); + } } void rtw89_cam_fill_dctl_sec_cam_info_v2(struct rtw89_dev *rtwdev, @@ -816,6 +835,8 @@ void rtw89_cam_fill_dctl_sec_cam_info_v2(struct rtw89_dev *rtwdev, struct rtw89_h2c_dctlinfo_ud_v2 *h2c) { struct rtw89_addr_cam_entry *addr_cam = rtw89_get_addr_cam_of(rtwvif, rtwsta); + struct rtw89_wow_param *rtw_wow = &rtwdev->wow; + u8 *ptk_tx_iv = rtw_wow->key_info.ptk_tx_iv; h2c->c0 = le32_encode_bits(rtwsta ? rtwsta->mac_id : rtwvif->mac_id, DCTLINFO_V2_C0_MACID) | @@ -869,4 +890,21 @@ void rtw89_cam_fill_dctl_sec_cam_info_v2(struct rtw89_dev *rtwdev, DCTLINFO_V2_W7_SEC_ENT6_V1); h2c->m7 = cpu_to_le32(DCTLINFO_V2_W7_SEC_ENT5_V1 | DCTLINFO_V2_W7_SEC_ENT6_V1); + + if (rtw_wow->ptk_alg) { + h2c->w0 = le32_encode_bits(ptk_tx_iv[0] | ptk_tx_iv[1] << 8, + DCTLINFO_V2_W0_AES_IV_L); + h2c->m0 = cpu_to_le32(DCTLINFO_V2_W0_AES_IV_L); + + h2c->w1 = le32_encode_bits(ptk_tx_iv[4] | + ptk_tx_iv[5] << 8 | + ptk_tx_iv[6] << 16 | + ptk_tx_iv[7] << 24, + DCTLINFO_V2_W1_AES_IV_H); + h2c->m1 = cpu_to_le32(DCTLINFO_V2_W1_AES_IV_H); + + h2c->w4 |= le32_encode_bits(rtw_wow->ptk_keyidx, + DCTLINFO_V2_W4_SEC_KEY_ID); + h2c->m4 |= cpu_to_le32(DCTLINFO_V2_W4_SEC_KEY_ID); + } } diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c index a7ae5f85d57d..f47bdede6c62 100644 --- a/drivers/net/wireless/realtek/rtw89/fw.c +++ b/drivers/net/wireless/realtek/rtw89/fw.c @@ -6404,6 +6404,7 @@ int rtw89_fw_h2c_disconnect_detect(struct rtw89_dev *rtwdev, int rtw89_fw_h2c_wow_global(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, bool enable) { + struct rtw89_wow_param *rtw_wow = &rtwdev->wow; struct rtw89_h2c_wow_global *h2c; u8 macid = rtwvif->mac_id; u32 len = sizeof(*h2c); @@ -6420,7 +6421,12 @@ int rtw89_fw_h2c_wow_global(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, h2c = (struct rtw89_h2c_wow_global *)skb->data; h2c->w0 = le32_encode_bits(enable, RTW89_H2C_WOW_GLOBAL_W0_ENABLE) | - le32_encode_bits(macid, RTW89_H2C_WOW_GLOBAL_W0_MAC_ID); + le32_encode_bits(macid, RTW89_H2C_WOW_GLOBAL_W0_MAC_ID) | + le32_encode_bits(rtw_wow->ptk_alg, + RTW89_H2C_WOW_GLOBAL_W0_PAIRWISE_SEC_ALGO) | + le32_encode_bits(rtw_wow->gtk_alg, + RTW89_H2C_WOW_GLOBAL_W0_GROUP_SEC_ALGO); + h2c->key_info = rtw_wow->key_info; rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C, H2C_CAT_MAC, diff --git a/drivers/net/wireless/realtek/rtw89/wow.c b/drivers/net/wireless/realtek/rtw89/wow.c index 185e24626691..3fb352f65e67 100644 --- a/drivers/net/wireless/realtek/rtw89/wow.c +++ b/drivers/net/wireless/realtek/rtw89/wow.c @@ -845,6 +845,12 @@ static int rtw89_wow_fw_start(struct rtw89_dev *rtwdev) goto out; } + ret = rtw89_fw_h2c_wow_gtk_ofld(rtwdev, rtwvif, true); + if (ret) { + rtw89_err(rtwdev, "wow: failed to enable GTK offload\n"); + goto out; + } + ret = rtw89_wow_cfg_wake(rtwdev, true); if (ret) { rtw89_err(rtwdev, "wow: failed to config wake\n"); @@ -881,6 +887,12 @@ static int rtw89_wow_fw_stop(struct rtw89_dev *rtwdev) goto out; } + ret = rtw89_fw_h2c_wow_gtk_ofld(rtwdev, rtwvif, false); + if (ret) { + rtw89_err(rtwdev, "wow: failed to disable GTK offload\n"); + goto out; + } + rtw89_fw_release_general_pkt_list(rtwdev, true); ret = rtw89_wow_cfg_wake(rtwdev, false); -- 2.25.1