From patchwork Thu Sep 9 14:44:27 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: 508358 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp387621jai; Thu, 9 Sep 2021 07:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySx4isxEszwh2AtvLDmgrWXjWKwW/kxDeWmLaH2Nb02Mc17IIxGy7g5CGcucpwj2mLN4T9 X-Received: by 2002:a62:1b56:0:b0:405:9140:5e37 with SMTP id b83-20020a621b56000000b0040591405e37mr3466480pfb.57.1631198564954; Thu, 09 Sep 2021 07:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631198564; cv=none; d=google.com; s=arc-20160816; b=EfnhwF5q74qItQfZtC9EC1wkb1u39LBbbov2g7/ILP6N8YG1BNYPSbwjPeUGsBDjf9 slIRNdtIvAEVv6q/fcSnaUmIQCbyAAy43x9amurfFSUYQO/D1UNHD73wg13EzwgY41Q2 rq6Gem3CNfUYrwK2Kf8yC5TM/kbsN/be9ZpR51WpsY6qw20khSZFG1XIELD+jDSY7n/G ZT0fciqXQD2r18L8i5ZwkRtM+iYTjd9yb/NEHj3/W56vzVXPk+88z36yzH53rS5QpkQv Ng0RRsDweMO1ib2yeMyYh1kAqTFiGciYcwSrZWHOX9dg9z50qHdPNqU9ZdTdrxNVqtnG O/dQ== 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=2w1m5EGSGhGEjETbScsnKgjbDCM8+Pc678bBecWa9cg=; b=KbL+XrFhyUk324g6aUV9M3zl5MntsA+q0lY5qmKCxgCyCkxOXa0eJTzREuXI5PLeiP M/boEsL/7pFmqrY9PNCBVODdYTYlB8zq5hYCgVkF1Yo/YYdz7acj6oLSs8T7ZQuPylDx O2gO/MaDN0pm4/0PRIAbRAniWr2Adk0owdOwG5Vp4jEmhQQhNT0VkEAtAQ2VZovQZ8PS 7P6kpOZruiXmFhSexOYmRykl2LrdOlHTtdXnaFPSuuPVAvxjidO720sLWIde8Mpbx4BY kTAXUp+H+jmQ0pChwuV/+5Go83ZOTX0WBVzCVIYTaKupca+uYfy+Hxyo1V1tYn1gzlzh WJkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=GuexNQV8; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=oNvmUs2w; 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 t11si2444772plb.20.2021.09.09.07.42.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 07:42:44 -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=GuexNQV8; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=oNvmUs2w; 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=2w1m5EGSGhGEjETbScsnKgjbDCM8+Pc678bBecWa9cg=; b=GuexNQV89OAy5Q p1Odfqd3Skkl+3+/YMFM6i/dICZ6z03JHjEgsaJYM0DXxgb0d3GvNh03DtM41gXSjRVSy1NoVG05k 6xzl7PeXdAp+naivAEXQVKhGJ5/w2ejM3x9EhGXfvl4cbTfaDZ2u5GND/8rO1p69ggh2uZb050B66 BtUxXaLwSHFX+tEc0PYKiZviJJUTXFDLKHzkFJs142INGrfRe6ENaM+m45bVhbHqXhSdn+Q36Vxg9 hMCZOHKmMJWr3xpYv0GGgPiKQ/3poPGcVocS/XPt5h5Xl8Q4MIAc/C4ilbwkdnXQi182u6LZMEdQG Nurth/aOzGwb6xHbFZAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOLGF-00AAhx-A9; Thu, 09 Sep 2021 14:42:43 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOLGB-00AAfe-SL for wcn36xx@lists.infradead.org; Thu, 09 Sep 2021 14:42:41 +0000 Received: by mail-wm1-x330.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so1587082wml.3 for ; Thu, 09 Sep 2021 07:42:36 -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=wdQxDk1iBotMAEMT0YZyzMXJd33U25RYM7qDuPyiwec=; b=oNvmUs2wFhrcARSXxoegbGdq8fJSKF/gCMtg/N8fLbYM4ub3m3RH/Sj/oPrl7WBqLw MqSI6ZwX17F/E+sWzpHV7iXpiFFtTbDqYB283nSa1HjKStoKzWq2eUKwHkZ97rXeYMVK HpHWxMptN/k9typ6CYAOC+yLDAfakArQfeEfvLJ1nVQuNrprxeCgZ+teE3+W8fPcnl3h rXzGyQaq8TCBkU4OZyS+yDIsclfEI780JMzKMsQKdz51ggKFqgtDWreza7jt0zmxsCDd zRZGgxDG5ywCWvW9sT+vKKYp+cGdcqqLKoH+9Z2zcZLIyy5wD6t5Artbjq4FPBT+e8X1 T7Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wdQxDk1iBotMAEMT0YZyzMXJd33U25RYM7qDuPyiwec=; b=RNzw7wWSwb+k4QBjK55Ox6AjZua7S9S41Vhygo3phVbeBXp/svhnAc/BPBRA7K4Zvb hzVNAvLNYYqVdiV8D/BOcnDWbrU5ZuHkeXVHvfBboXtzKm7li3rx9zW2Y/v0EyrHssIo vWwXeZpOQN0nuG5tVMkq1Tisns2vV8aD93xMGA8XT40KF9l5oUyKLeSgisIq0PFEyEsm 4hfj8VZZt26e0z295NpmO7Lnu430ooZMJL/vKBCmcnCoSNtf2GrgWVU7CJFo7ppR8A28 ZG4nKFunNuswr+k7TXPBSqTItWy5qq9kQfxck4tkw3SfNtlwqIOSM4xh45Asu41Ndy0n BakQ== X-Gm-Message-State: AOAM531INN/XYWBIadn2ZxLuBDFwLHoHQJJR054Ipvt4Ccx+ZYClD1/I oMkYazEJi8BWj1T1Ox+0xjo6SCRkNARiOA== X-Received: by 2002:a7b:c08d:: with SMTP id r13mr3419613wmh.186.1631198555611; Thu, 09 Sep 2021 07:42:35 -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 k29sm1160712wms.24.2021.09.09.07.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 07:42:35 -0700 (PDT) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org Cc: loic.poulain@linaro.org, benl@squareup.com, bryan.odonoghue@linaro.org Subject: [PATCH v2 1/2] wcn36xx: Fix Antenna Diversity Switching Date: Thu, 9 Sep 2021 15:44:27 +0100 Message-Id: <20210909144428.2564650-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210909144428.2564650-1-bryan.odonoghue@linaro.org> References: <20210909144428.2564650-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-20210909_074239_980466_49B0EEA3 X-CRM114-Status: GOOD ( 25.62 ) 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: We have been tracking a strange bug with Antenna Diversity Switching (ADS) on wcn3680b for a while. ADS is configured like this: A. Via a firmware configuration table baked into the NV area. 1. Defines if ADS is enabled. 2. Defines which GPIOs are connected to which antenna enable pin. 3. Defines wh [...] 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:330 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 We have been tracking a strange bug with Antenna Diversity Switching (ADS) on wcn3680b for a while. ADS is configured like this: A. Via a firmware configuration table baked into the NV area. 1. Defines if ADS is enabled. 2. Defines which GPIOs are connected to which antenna enable pin. 3. Defines which antenna/GPIO is primary and which is secondary. B. WCN36XX_CFG_VAL(ANTENNA_DIVERSITY, N) N is a bitmask of available antenna. Setting N to 3 indicates a bitmask of enabled antenna (1 | 2). Obviously then we can set N to 1 or N to 2 to fix to a particular antenna and disable antenna diversity. C. WCN36XX_CFG_VAL(ASD_PROBE_INTERVAL, XX) XX is the number of beacons between each antenna RSSI check. Setting this value to 50 means, every 50 received beacons, run the ADS algorithm. D. WCN36XX_CFG_VAL(ASD_TRIGGER_THRESHOLD, YY) YY is a two's complement integer which specifies the RSSI decibel threshold below which ADS will run. We default to -60db here, meaning a measured RSSI <= -60db will trigger an ADS probe. E. WCN36XX_CFG_VAL(ASD_RTT_RSSI_HYST_THRESHOLD, Z) Z is a hysteresis value, indicating a delta which the RSSI must exceed for the antenna switch to be valid. For example if HYST_THRESHOLD == 3 AntennaId1-RSSI == -60db and AntennaId-2-RSSI == -58db then firmware will not switch antenna. The threshold needs to be -57db or better to satisfy the criteria. F. A firmware feature bit also exists ANTENNA_DIVERSITY_SELECTION. This feature bit is used by the firmware to report if ANTENNA_DIVERSITY_SELECTION is supported. The host is not required to toggle this bit to enable or disable ADS. ADS works like this: A. Every XX beacons the firmware switches to or remains on the primary antenna. B. The firmware then sends a Request-To-Send (RTS) packet to the AP. C. The firmware waits for a Clear-To-Send (CTS) response from the AP. D. The firmware then notes the received RSSI on the CTS packet. E. The firmware then repeats steps A-D on the secondary antenna. F. Subsequently if the RSSI on the measured antenna is better than ASD_TRIGGER_THRESHOLD + the active antenna's RSSI then the measured antenna becomes the active antenna. G. If RSSI rises past ASD_TRIGGER_THRESHOLD then ADS doesn't run at all even if there is a substantially better RSSI on the alternative antenna. What we have been observing is that the RTS packet is being sent but the MAC address is a byte-swapped version of the target MAC. The ADS/RTS MAC is corrupted only when the link is encrypted, if the AP is open the RTS MAC is correct. Similarly if we configure the firmware to an RTS/CTS sequence for regular data - the transmitted RTS MAC is correctly formatted. Internally the wcn36xx firmware uses the indexes in the SMD commands to populate and extract data from specific entries in an STA lookup table. The AP's MAC appears a number of times in different indexes within this lookup table, so the MAC address extracted for the data-transmit RTS and the MAC address extracted for the ADS/RTS packet are not the same STA table index. Our analysis indicates the relevant firmware STA table index is "bssSelfStaIdx". There is an STA populate function responsible for formatting the MAC address of the bssSelfStaIdx including byte-swapping the MAC address. Its clear then that the required STA populate command did not run for bssSelfStaIdx. So taking a look at the sequence of SMD commands sent to the firmware we see the following downstream when moving from an unencrypted to encrypted BSS setup. - WLAN_HAL_CONFIG_BSS_REQ - WLAN_HAL_CONFIG_STA_REQ - WLAN_HAL_SET_STAKEY_REQ Upstream in wcn36xx we have - WLAN_HAL_CONFIG_BSS_REQ - WLAN_HAL_SET_STAKEY_REQ The solution then is to add the missing WLAN_HAL_CONFIG_STA_REQ between WLAN_HAL_CONFIG_BSS_REQ and WLAN_HAL_SET_STAKEY_REQ. No surprise WLAN_HAL_CONFIG_STA_REQ is the routine responsible for populating the STA lookup table in the firmware and once done the MAC sent by the ADS routine is in the correct byte-order. This bug is apparent with ADS but it is also the case that any other firmware routine that depends on the "bssSelfStaIdx" would retrieve malformed data on an encrypted link. Fixes: 3e977c5c523d ("wcn36xx: Define wcn3680 specific firmware parameters") Signed-off-by: Bryan O'Donoghue Tested-by: Benjamin Li --- drivers/net/wireless/ath/wcn36xx/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.33.0 _______________________________________________ wcn36xx mailing list wcn36xx@lists.infradead.org http://lists.infradead.org/mailman/listinfo/wcn36xx Reviewed-by: Loic Poulain diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 9e4fa55d8118..65b4e618d61e 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -580,12 +580,14 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags) { sta_priv->is_data_encrypted = true; /* Reconfigure bss with encrypt_type */ - if (NL80211_IFTYPE_STATION == vif->type) + if (NL80211_IFTYPE_STATION == vif->type) { wcn36xx_smd_config_bss(wcn, vif, sta, sta->addr, true); + wcn36xx_smd_config_sta(wcn, vif, sta); + } wcn36xx_smd_set_stakey(wcn, vif_priv->encrypt_type,