From patchwork Mon Mar 15 12:09:34 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: 400411 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3356675jai; Mon, 15 Mar 2021 05:09:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeY9k7V9ry/X/Pb452L7OkCHZC0OAa1U+KAIieRHLmzyH7eec+mXkPtnlrTlmg2Kr+c0et X-Received: by 2002:a1c:7415:: with SMTP id p21mr26083867wmc.187.1615810154972; Mon, 15 Mar 2021 05:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615810154; cv=none; d=google.com; s=arc-20160816; b=HjntoK/uTuVlIXY4uBsbu4ZWXl7sQqt27mM4JBbuX1HTwHaNAnASSQf1S7sW07rWpf GHcoihpOj/KpNecBxjDY5noLHthpLEYxia8JW1bUI/Ziv8hV/AisquVuLRASgXcnJOnd a+Lg/1Nv816LpMDPQB5sPjUDBUrbto17hF9ryMbqm/deVSkX/gSe1+YVviSOs8HoO90s VwjyC+3VR2TrLrksOqPhzV6OjXNS+3FWa36b7WHcyzl8QUC5wzu9iXAtSQSSv1iCXr/g /YU1E3BSEZPmjAN68k0khlQj2ZJVHzEPrwkkLYCFW/Ph21suiTXYI83v4Oe6SmICiGhW M8Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=M+2k43GlohQyEEjWyLFfl9zhuXIM/JV216tEQnXkr3c=; b=DDURHS9gZYX1kd2MM5EZw80fKnqLayKSuqKpWMukE0qX3ZkBaH8NFm1sZbJS/Kv27s dsKDM96Z5HoRZpJQY9Y2m/ebga/Q2aFRuQVQ6ujjlvTuV7gy+c5rUQXoajBd/OYYffcr wbFiQ3UFQ37o7W5iB7tTR+N1r6raTA+SO85W8fc5qi9lFVHLJ6vIn1Fw0WmmEkaju2uB 94Ohn4YPxTCkFHTrx1zE5kCyaQPbrQq94ZIebPtoGvU8gFu5kIEoorLCBQBp1f86nBXf hyTDsNjxRljNBxyLwWQ+jxXKqfIUxu4/MZV4kYtxLSspk4oAIT4A3y6qgYrGQt1cu5pe mfag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qsCCd5/w"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si9901547wmk.85.2021.03.15.05.09.14; Mon, 15 Mar 2021 05:09:14 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b="qsCCd5/w"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231172AbhCOMIo (ORCPT + 2 others); Mon, 15 Mar 2021 08:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbhCOMIU (ORCPT ); Mon, 15 Mar 2021 08:08:20 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A277C061574 for ; Mon, 15 Mar 2021 05:08:19 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id j2so8539905wrx.9 for ; Mon, 15 Mar 2021 05:08:19 -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=M+2k43GlohQyEEjWyLFfl9zhuXIM/JV216tEQnXkr3c=; b=qsCCd5/w2qa9aPQxKdSYxAW8VueU/zTY1aV0pC1xA2cmHNR0KXfBH7XFCjv3FHlcMP fXmHxObrZsWEyHpRHm/UyNP/uIB74S5y1v+/QGErtf3q6NDRZ+5DiVbj1/LkoL4KixYf C4JGDEGUsFs0xGD0czwrbwJzP5jDFuC4fOKA3fjI+3010VR7uC482ijE/9Qb8qUw+wAr KBHbKZyx1FpkJBUAJZZdOxYCOS0w/Lk2YszK2FN0aNls4UN6m+naNqsioGzKmw8tK+Z9 EVKv+zBCvWV0BzWgxI93/VoYYxil4Vu7hLm+CPUx0X9vrcla/C/p3uk45cUwlfr79h5y QOfw== 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=M+2k43GlohQyEEjWyLFfl9zhuXIM/JV216tEQnXkr3c=; b=cIn2rDP6YC7TYEwpDQ4PtGQ3OAjZXFYyMhwngiPoacL+PniDYz5O08kOEGIkljK5p5 bhNeF8Sg4FFVnUVeCcGEQTTPDOH9hsi1WDCCsHtGRh43JK6fIzCj8be9sQabbXtqSQuJ lF9oI4hf6zdiU7eEeuBge22BAjaVUlwvBieC0/C0i8NZFcYqA3WBFU9T1Kee4wu1+uQJ 9MDQXR/OyLIAKLTzbOtua20DwLln68jKdM7cH2gCdSU6xMmBMqsmkX4o1qxRDIhZRDBO eJx7XBJedBuQubASo9D186vwlgMkfpZF1OghTxaacIgjYhJJaX+4oTYx628cX5dQx6Dq gDaA== X-Gm-Message-State: AOAM530k/CcpLhGt6+//V46EotRikGkQhvhlMuf48TDO+dOvG/j30xbT sZT4ZkFJCJqYnmQZtpNQ0x54+79WLHoo8ZXh X-Received: by 2002:adf:e5cf:: with SMTP id a15mr26409527wrn.226.1615810098384; Mon, 15 Mar 2021 05:08:18 -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 c18sm29239891wmk.0.2021.03.15.05.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 05:08:17 -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 v2 09/12] wcn36xx: Add GTK offload info to WoWLAN resume Date: Mon, 15 Mar 2021 12:09:34 +0000 Message-Id: <20210315120937.2512341-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210315120937.2512341-1-bryan.odonoghue@linaro.org> References: <20210315120937.2512341-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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 --- 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 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 a138b84d0aec..a84128e04cc4 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1149,6 +1149,7 @@ static int wcn36xx_resume(struct ieee80211_hw *hw) goto out; 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 c3e384803141..6064fdef69ac 100644 --- a/drivers/net/wireless/ath/wcn36xx/smd.c +++ b/drivers/net/wireless/ath/wcn36xx/smd.c @@ -2885,6 +2885,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) { @@ -2935,6 +3006,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_ */