From patchwork Tue Jun 1 15:09:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 451391 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp1870775jao; Tue, 1 Jun 2021 08:08:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmykVlZz8iSj5ai1amamj4G12eEQV1/W8SSU6GSuLRXZvvCA0A0sXzWbabs3VtJMomlh1w X-Received: by 2002:a65:4201:: with SMTP id c1mr5982546pgq.125.1622560118280; Tue, 01 Jun 2021 08:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622560118; cv=none; d=google.com; s=arc-20160816; b=tmKD3KFEhI96FzAEQ3UBy1Q+JoriQGV8uLyS70yN1BP3tclHMGVTqm0zYY5L3Z7OP7 dR+EwTdAdZlrfXp+M+KQLJ5jcpULj2BxoNCi7+poiIacz5lFwqAlI2MVdTZWBqii8p7U n6a/XAZWlDUC8WDytSLFEtxuBptT/x5S2V027YyxB43RGvduy9b+Loi5G8QnJsFIi67B A0+vHIYpu4MeCQkwVqwtMuylW5zsvMqMBpTBw17E1F18KkK4ffgRGHIima07vK4Vqble Y9SFNUMUGmEAOhqvNusx7nvNtell/0o4zJckUM2sjxDNyaOv4KDYeX3+mKT74gvoLx5W vjaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=yEEkMwU9hNCcYzL0exiGjkrhSgYuhOmU3hLzlTfVEdg=; b=cJaKEbzfssDBlHuwT1Z95jibLuFJnsS5nkMjS3a2j+yXxfy1Gr9tO5lFAHcildHSjj hBng3Jhw4fXsq9JelisyfVoRf+T6bOjSl2v3zw0Wbue9/wR/+UYXY01LzeROrRFBrPX1 ToNLbx6lQ91zQK6QGHorsOekc+23INhmOWfGIlz/GK5GoEYgocKw0fAEMCl5jZcRCTiy VVVp4ZCLP6J2Htp41XeYAzNZadfPuihkvxFtx6uvAIvc7cJAoloOix5ciaJtQJQuL8Ex 6yGM6zkPahKuA8aE+P6w4mk9c+3crSerFhQJTcK+YgGOrVz8Rw1RvFmAbNQy00b3ggXk IxTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=gz3HookW; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=zdYZW7F5; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id j125si20232056pgc.368.2021.06.01.08.08.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:08:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=gz3HookW; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=zdYZW7F5; spf=pass (google.com: best guess record for domain of wcn36xx-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="wcn36xx-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yEEkMwU9hNCcYzL0exiGjkrhSgYuhOmU3hLzlTfVEdg=; b=gz3HookWHSisLS 7Wu93CLd2tcQZQesx93p9lXDIfA0+PxH6WboPJbk9GnzDv8YT1+tOVW/7nm4MltN3gwjSsFPznPBN +Rajzytl5/xkfe/14wUy2IOjOJ6f0GAmrG1xksRtwiQlcGhcLC4UeX/TweTuN7KPzJqpEuUHt1YvK WfR1VYPljgNLJTxjo/GToG3pM9K5c1kwKFyGshkF7zmqEiJ1qvPdIMyp48Z4CtFluAZobBp1N1YU4 l+iO5WSiWKIL1BYA8UvrdTewcppwHl2K1150s6gs80kngarKPiYwEkKiLt1lb9KCD3urkKPG38Y7j xkkThE5nvTYa5klO0pxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo60S-00H7cE-LH; Tue, 01 Jun 2021 15:08:36 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo60O-00H7Xb-Ab for wcn36xx@lists.infradead.org; Tue, 01 Jun 2021 15:08:34 +0000 Received: by mail-wr1-x430.google.com with SMTP id c3so14696272wrp.8 for ; Tue, 01 Jun 2021 08:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SzCu0Os7QusVy/mnoUQrDSZnGR8B3iHYzezmZSLH1gs=; b=zdYZW7F5mnR1liKjC8pQu3XQtgT36f12qJLgd5SsxZA5Ad6p9L8LUhsaK2sONOWhry PfDPzauil2JSU3xHSVGL6AfASos7iEfHYUkUhhpgiwfcYXiMjBNtnNPdyAk2p0KFaFTl 4452IrQ1n5HU6dki7gzDDbjGi9DiVZr+S2j3iItWD9WJAESuXBoVNQnT5f7BiwCG5Qsm YPRkPlNpzM8fGjiXIfxoPN9FbsWat17HQ9QerZenpZ7P7VkuHW0mBPtfeqGq9TscGHOx 4mBRy/Q0kZv6rzaky1ItekTjmGxiwFgmIRlRvVGtxw0fgy3arGTZaKdNnMpbxS9xqG5x c5LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SzCu0Os7QusVy/mnoUQrDSZnGR8B3iHYzezmZSLH1gs=; b=KzkecXjVynxyxmB8RjwucrdPYWgqr6zIgg5qXLWi69eb+qw6/xcULhL6Jo8valfWdM gJWjrrKVbQ2ItagDsj2ItlkYMRQxSLBhIWIBdWjRsWAXm7pa6hnFPcMLDxcUbeS00Uxi W0nQLvAv3JqlCkOTCAGxrJc6B4x2iq0W0gjgtETt8Jw55Zp2e5U7b7A+a4OWIL2eMwFy jECY/srp+v+cewYkNVI3NElxYPkn1p+G8cJcaFr4kVxCQFCA3KRa/Ldhi0bMGQF0nkyw q9jVEUa5mVX+BYp3eyLpNP+Y6u4foksHauNSeEbPUBo9mxOnsu/0DenCnZqy08B/9aB8 h6yw== X-Gm-Message-State: AOAM531Vk5TWWPOePiH9IV85cfv51XbM2JvqWq/GWHkH3AKCgeQZD6rH wA11VZkONwpemBHWaSod5LZJmA== X-Received: by 2002:a5d:4302:: with SMTP id h2mr29048790wrq.266.1622560111037; Tue, 01 Jun 2021 08:08:31 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id o129sm2822237wmo.22.2021.06.01.08.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 08:08:30 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org Cc: bryan.odonoghue@linaro.org, shawn.guo@linaro.org, benl@squareup.com, loic.poulain@linaro.org, bjorn.andersson@linaro.org Subject: [PATCH v5 09/12] wcn36xx: Add GTK offload info to WoWLAN resume Date: Tue, 1 Jun 2021 16:09:58 +0100 Message-Id: <20210601151001.1450540-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210601151001.1450540-1-bryan.odonoghue@linaro.org> References: <20210601151001.1450540-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_080832_445169_2D26750D X-CRM114-Status: GOOD ( 16.99 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Having enabled GTK rekey in suspend, we need to extract the replay counter from the firmware on resume and perform a ieee80211_gtk_rekey_notify() so that the STA remains verified from the perspective [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:430 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: wcn36xx@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "wcn36xx" Errors-To: wcn36xx-bounces+patch=linaro.org@lists.infradead.org Having enabled GTK rekey in suspend, we need to extract the replay counter from the firmware on resume and perform a ieee80211_gtk_rekey_notify() so that the STA remains verified from the perspective of the AP. In order to enable the SMD command and response we need to pack the existing command/response structures. Given these structures are currently unused, there's no need to backport this as a fix. Signed-off-by: Bryan O'Donoghue Tested-by: Benjamin Li --- drivers/net/wireless/ath/wcn36xx/hal.h | 4 +- drivers/net/wireless/ath/wcn36xx/main.c | 1 + drivers/net/wireless/ath/wcn36xx/smd.c | 72 +++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/smd.h | 3 ++ 4 files changed, 78 insertions(+), 2 deletions(-) -- 2.30.1 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h index 1f3c2e840232..455143c4164e 100644 --- a/drivers/net/wireless/ath/wcn36xx/hal.h +++ b/drivers/net/wireless/ath/wcn36xx/hal.h @@ -4919,7 +4919,7 @@ struct wcn36xx_hal_gtk_offload_rsp_msg { struct wcn36xx_hal_gtk_offload_get_info_req_msg { struct wcn36xx_hal_msg_header header; u8 bss_index; -}; +} __packed; struct wcn36xx_hal_gtk_offload_get_info_rsp_msg { struct wcn36xx_hal_msg_header header; @@ -4943,7 +4943,7 @@ struct wcn36xx_hal_gtk_offload_get_info_rsp_msg { u32 igtk_rekey_count; u8 bss_index; -}; +} __packed; struct dhcp_info { /* Indicates the device mode which indicates about the DHCP activity */ diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index db1528a14757..8e5d8326d551 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1142,6 +1142,7 @@ static int wcn36xx_resume(struct ieee80211_hw *hw) vif = wcn36xx_get_first_assoc_vif(wcn); if (vif) { wcn36xx_smd_set_power_params(wcn, false); + wcn36xx_smd_gtk_offload_get_info(wcn, vif); wcn36xx_smd_gtk_offload(wcn, vif, false); wcn36xx_smd_ipv6_ns_offload(wcn, vif, false); wcn36xx_smd_arp_offload(wcn, vif, false); diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c index f74cb16327d0..e249971c4ef7 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -2893,6 +2893,77 @@ int wcn36xx_smd_gtk_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif, return ret; } +static int wcn36xx_smd_gtk_offload_get_info_rsp(struct wcn36xx *wcn, + struct ieee80211_vif *vif) +{ + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + struct wcn36xx_hal_gtk_offload_get_info_rsp_msg *rsp; + __be64 replay_ctr; + + if (wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len)) + return -EIO; + + rsp = (struct wcn36xx_hal_gtk_offload_get_info_rsp_msg *)wcn->hal_buf; + + if (rsp->bss_index != vif_priv->bss_index) { + wcn36xx_err("gtk_offload_info invalid response bss index %d\n", + rsp->bss_index); + return -ENOENT; + } + + replay_ctr = cpu_to_be64(le64_to_cpu(rsp->key_replay_counter)); + if (vif_priv->rekey_data.replay_ctr != rsp->key_replay_counter) { + vif_priv->rekey_data.replay_ctr = rsp->key_replay_counter; + ieee80211_gtk_rekey_notify(vif, vif->bss_conf.bssid, + (void *)&replay_ctr, GFP_KERNEL); + wcn36xx_dbg(WCN36XX_DBG_HAL, + "GTK replay counter increment %llu\n", + rsp->key_replay_counter); + } + + wcn36xx_dbg(WCN36XX_DBG_HAL, + "gtk offload info status %d last_rekey_status %d " + "replay_counter %llu total_rekey_count %d gtk_rekey_count %d " + "igtk_rekey_count %d bss_index %d\n", + rsp->status, rsp->last_rekey_status, + rsp->key_replay_counter, rsp->total_rekey_count, + rsp->gtk_rekey_count, rsp->igtk_rekey_count, + rsp->bss_index); + + return 0; +} + +int wcn36xx_smd_gtk_offload_get_info(struct wcn36xx *wcn, + struct ieee80211_vif *vif) +{ + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + struct wcn36xx_hal_gtk_offload_get_info_req_msg msg_body; + int ret; + + mutex_lock(&wcn->hal_mutex); + + INIT_HAL_MSG(msg_body, WCN36XX_HAL_GTK_OFFLOAD_GETINFO_REQ); + + msg_body.bss_index = vif_priv->bss_index; + + PREPARE_HAL_BUF(wcn->hal_buf, msg_body); + + ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len); + if (ret) { + wcn36xx_err("Sending gtk_offload_get_info failed\n"); + goto out; + } + ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len); + if (ret) { + wcn36xx_err("gtk_offload_get_info failed err=%d\n", ret); + goto out; + } + ret = wcn36xx_smd_gtk_offload_get_info_rsp(wcn, vif); +out: + mutex_unlock(&wcn->hal_mutex); + return ret; +} + int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, void *buf, int len, void *priv, u32 addr) { @@ -2943,6 +3014,7 @@ int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev, case WCN36XX_HAL_STOP_SCAN_OFFLOAD_RSP: case WCN36XX_HAL_HOST_OFFLOAD_RSP: case WCN36XX_HAL_GTK_OFFLOAD_RSP: + case WCN36XX_HAL_GTK_OFFLOAD_GETINFO_RSP: memcpy(wcn->hal_buf, buf, len); wcn->hal_rsp_len = len; complete(&wcn->hal_rsp_compl); diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h index cdf4231efe26..90c7faea0ef6 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.h +++ b/drivers/net/wireless/ath/wcn36xx/smd.h @@ -156,4 +156,7 @@ int wcn36xx_smd_ipv6_ns_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif, int wcn36xx_smd_gtk_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif, bool enable); +int wcn36xx_smd_gtk_offload_get_info(struct wcn36xx *wcn, + struct ieee80211_vif *vif); + #endif /* _SMD_H_ */