From patchwork Tue May 28 09:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 800925 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6227317E8F3; Tue, 28 May 2024 09:17:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887868; cv=none; b=SibUHkH+SJSb9Y9OGGFJTMezJb3PnynIjEGEu/f8/ns0j9girT23KX1Kj74F0BhP+R7dvc3g/sQMAya6Xb5Rzdam27AuLBDCW54FYRlSVG3L+v0BNY9dUwl4mNvfnoZQuzIKpQVfz12LPPnein6zXrgdPEokonhLhj+jgWo6WlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887868; c=relaxed/simple; bh=0nyQIlu5xVsGZoE/lFFn1UadS4mZECJUtykGucszjaM=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=Bu4v0/UFGwxynsTfA1D4QjRZUJmNMWjdDPDY2A/rnuvLJv30K83gP6TsbAV5MhNmwhr90LI3gpd5ks7WdGimhjKpCUxnOSCT0P9G66S5HeoLedm/FO/rN1gHABhxPSKzb45RccijFYHvcTDxnfBbaqhASvU3yg+Gtr+Ygo7xl0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=bnHzTT10; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="bnHzTT10" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u6V23a4CaKODr1VkTAbDdbOLU9vRsWQDsBrqjogTQHs=; b=bnHzTT10LQ8+Nji5i/v0CM7kp+ ryT8UToGKrFvQWN3uD2o+bCmY6fuk8peQ6Y3giK2680DaiHnyhDoRjpPAtR7XQptcJxDnDNv2D2Y9 vJJtpwRfZIM8GxSUcUgCuRGMOf4itaxsLRYIvqrMFyuRVoSTM4zL6z+Z7agen9XAeJqaO+UEnufaU r1rIohJFtDUnDszYkoSmfYsKHlVCrgjVUYdi0PWtgqAFAJ/mk3G+QHFPk8sYE974SlKyXujqWrc/k t9ZVXG/whfZjBIJ78oPdcpVZ9cKcJqkcasBuZi7yDkq5IrUBGovXJBLbzzy581MicYnwdCBRIlDFN OKY6FrLA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37006 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsxf-0004XY-1s; Tue, 28 May 2024 10:17:39 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsxi-00E8vQ-5r; Tue, 28 May 2024 10:17:42 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 1/8] wifi: wlcore: correctness fix fwlog reading Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:17:42 +0100 Fix the calculation of clear_offset, which may overflow the end of the buffer. However, this is harmless if it does because in that case it will be recalculated when we copy the chunk of messages at the start of the buffer. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wlcore/event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wlcore/event.c b/drivers/net/wireless/ti/wlcore/event.c index 2499dc908305..6c3a8ea9613e 100644 --- a/drivers/net/wireless/ti/wlcore/event.c +++ b/drivers/net/wireless/ti/wlcore/event.c @@ -83,7 +83,7 @@ int wlcore_event_fw_logger(struct wl1271 *wl) /* Copy initial part up to the end of ring buffer */ len = min(actual_len, available_len); wl12xx_copy_fwlog(wl, &buffer[start_loc], len); - clear_ptr = addr_ptr + start_loc + actual_len; + clear_ptr = addr_ptr + start_loc + len; if (clear_ptr == buff_end_ptr) clear_ptr = buff_start_ptr; From patchwork Tue May 28 09:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 799798 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9148117E8F3; Tue, 28 May 2024 09:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887873; cv=none; b=Z3kzGQEib6+7lqsxqzoSn+6RC1n/e195zdS4LJMjklE2/4jHiT4Grr6s2Lx5Unu/W9h9RhfBimIOp8NkiydcO1LX01M2lT1PvjObewnHERsYcZwgb9ypZHApIJCjYVBG1b544Izfd4mjUpay1RPNvZMP7FRsXCFAJNiAuZGfFcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887873; c=relaxed/simple; bh=ZNawznvhW5dSCU+ahFKTpAmKncLydZSOo3fHfgKcY6U=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=Yfq1k7ER74isFM/ipfycAnGYqVIuzJlGLhQ9zuHSlBo22WGCnhkxS7Mi2MfS6xc1I/y0qfFCKD3u/TB15u4Ymejwg088iL/rXYThKunGITsPf7Xaunloc1gaBc/kmFrI8ctL6ypOzcktUvVUcCXbrMkwByZMm80td4ZPeKRL32w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=MQXGTzXl; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="MQXGTzXl" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s8Qr2bA8Hr30r+AbrQ3AL9uhD/eb6MQygnNFwPbBHoY=; b=MQXGTzXlC9AZhmbZSkuOcO6jAH t9PVOi7yGULEDlv4WzNOMhC8dCxXgG3WL9lavBglZt1mbZRCvO+j5l1V6dmitAy0ejR/XDv2JJETu QSKKGDAtVpUbx6sct0MHOBWL7VIbjQAvN+cO4UNtVHtcOcVus3BmsgU+I4Mpy/Z7rmlUvMTAQRxKD /dZs9DEH1fkBUSpQ03+d1B9KmvO7321RnaDqukeYi8czu55AKLosgBXbmd9C0wyPiSIf4RIHgrQWJ oFEiPkYqevuvW6LJGlvQM9AMkJTU2MmI9PM+QNEYuYdsARxXyDz6immhMr0X/tRkfvyraFOajor/Q ltc5O0WQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37010 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsxk-0004Xh-1s; Tue, 28 May 2024 10:17:44 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsxn-00E8vW-9h; Tue, 28 May 2024 10:17:47 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 2/8] wifi: wl18xx: make wl18xx_tx_immediate_complete() more efficient Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:17:47 +0100 wl18xx_tx_immediate_complete() iterates through the completed transmit descriptors in a circular fashion, and in doing so uses a modulus operation that is not a power of two. This leads to inefficient code generation, which can be easily solved by providing a helper to increment to the next descriptor. Use this more efficient solution. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wl18xx/tx.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ti/wl18xx/tx.c b/drivers/net/wireless/ti/wl18xx/tx.c index 55d9b0861c53..beef393853ef 100644 --- a/drivers/net/wireless/ti/wl18xx/tx.c +++ b/drivers/net/wireless/ti/wl18xx/tx.c @@ -129,6 +129,14 @@ static void wl18xx_tx_complete_packet(struct wl1271 *wl, u8 tx_stat_byte) wl1271_free_tx_id(wl, id); } +static u8 wl18xx_next_tx_idx(u8 idx) +{ + if (++idx >= WL18XX_FW_MAX_TX_STATUS_DESC) + idx = 0; + + return idx; +} + void wl18xx_tx_immediate_complete(struct wl1271 *wl) { struct wl18xx_fw_status_priv *status_priv = @@ -161,9 +169,8 @@ void wl18xx_tx_immediate_complete(struct wl1271 *wl) return; } - for (i = priv->last_fw_rls_idx; - i != status_priv->fw_release_idx; - i = (i + 1) % WL18XX_FW_MAX_TX_STATUS_DESC) { + for (i = priv->last_fw_rls_idx; i != status_priv->fw_release_idx; + i = wl18xx_next_tx_idx(i)) { wl18xx_tx_complete_packet(wl, status_priv->released_tx_desc[i]); From patchwork Tue May 28 09:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 800924 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D737617E8F3; Tue, 28 May 2024 09:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887878; cv=none; b=VpCTTPudTMEHQnrHn6MvkgigBi/kLtlqn28gil/xYmMmrwo1jeEpdG6955HHH0tcZqDoi4UGvpMXnSPcVXsDhXWmbAvfwozAUvNXMtJX1OOzRPpwo4yEwyAFDRfnX2Ovky0w6RmjCmLngU4VA69IPoYNw9gSj1R/gF+cW+G/rS4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887878; c=relaxed/simple; bh=NBVtuUL21VTqpumFWGrktrwmTrAumjJzvLFNX8RXO1M=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=FtxuDTi3N/QhzNiK3+i5k2P3QNgkQ4RDbNwfuOBNvIn9/pbG0yeHQ3cNmIcuk8ftzyUZ8ocv73RHTd5a5kC9GbBce5gy7u8OkCsz3gJkU2kG6lIu4vZYxRWiAe11xhOLLixv0sBE/g66t3Qz+7mBcxE5p0O4whsAG2L0q9wZTWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=J7mujtiV; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="J7mujtiV" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PfGnzg4p0KPeEdVtxHFMLkm7NDRotPoeUjFEFun08h8=; b=J7mujtiVpZoR+55wIVq4Am1X3F 2UNPARm/w4386spkel+5aGZfWeRWVoCZm7fSrgOYiT71oV7mZ5vCKsQ5Ztcy9YwUsuKoWGAtsk5Y9 FrFmRYoRC9mYeO56dTT2pKabd4sZTFsgEhNvKYzz2aAshEE9R2fdDID8BMfXoAk5Xh7TRk10KBMIM KLg/COqYC4BU8XPlEZ1han+VqdQObvYWaXuBOOwJvZtEgdL5LDCJLouecWX7EX5Nl1v2sfem/2ida 5mwNcuxbSlJncL4hb7Y/EVxQ4qD9KUPQV4QJIxBQ1j/DKD5xChshoXpwG+14ncCngyP5tQEMD62Ni JVpKbZGQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51426 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsxp-0004Xq-2K; Tue, 28 May 2024 10:17:49 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsxs-00E8vc-DD; Tue, 28 May 2024 10:17:52 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 3/8] wifi: wlcore: improve code in wlcore_fw_status() Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:17:52 +0100 Referring to status->counters.tx_lnk_free_pkts[i] multiple times leads to less efficient code. Cache this value in a local variable. This also makes the code clearer. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wlcore/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index ef12169f8044..a98b26dc3cb8 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -412,18 +412,18 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) for_each_set_bit(i, wl->links_map, wl->num_links) { - u8 diff; + u8 diff, tx_lnk_free_pkts; lnk = &wl->links[i]; /* prevent wrap-around in freed-packets counter */ - diff = (status->counters.tx_lnk_free_pkts[i] - - lnk->prev_freed_pkts) & 0xff; + tx_lnk_free_pkts = status->counters.tx_lnk_free_pkts[i]; + diff = (tx_lnk_free_pkts - lnk->prev_freed_pkts) & 0xff; if (diff == 0) continue; lnk->allocated_pkts -= diff; - lnk->prev_freed_pkts = status->counters.tx_lnk_free_pkts[i]; + lnk->prev_freed_pkts = tx_lnk_free_pkts; /* accumulate the prev_freed_pkts counter */ lnk->total_freed_pkts += diff; From patchwork Tue May 28 09:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 799797 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88C531DA5F; Tue, 28 May 2024 09:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887882; cv=none; b=BKCLlyNfUHJGRREu5iap0dcApo0QUhrxI9P2Ty7eElhBMRtoWPxV7sMJg3kQicFo4oCkTr46CPzsrJyH7viMWoaZwp0I0ZQ5bo0veW5uBnnboMD/rHwYEUPkgOzkPYZLRqwZ2CbprflywSTBzz/um/yF10A65g9rbr5o+CsTdKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887882; c=relaxed/simple; bh=LwXrmwTw34TzKIJXUTrMzBXzUMAcfJpcVULiuNUyxZ8=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=iiaeZpPC7lvJZTIIqaCBv1/pPQd9+/pLokjLhAUHB47mb+RcO48WKxS4LgCh+k3JlBJDVNt7DExTGMxDVkE/qg3Z0+tEEiTwOQwYeCoU34Y7gwrKV68bFP1COfKY+jovdO3drOO9zV+QfNlAuQMucGUFfG1Tcn6nsD+TXzkxa8g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=xd/2TId0; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="xd/2TId0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qvnXOqeSbN57VD1xQ/WachONgqYyaHMsTEDVjptCkv4=; b=xd/2TId0MrNuDId8S2fH7u3Zar koEvIXkcXRNJx7VQfzkI0Kxg4RqEGCRDB15GiOSBe4n5gvR3RSduFyXecoo2aLlmGx7lddOz1vJGR fP+zyjtvyEjtiWP23NJn1FAIa5wsXmvEkHHwkkw068jJXkpu+pdXnXobwrFzrBGPiwxSV4VWfu0WC v4RlYeKq/YUqI/dg6Ti8gm3WEj7ex0Mq0akHXSyQnG0O82xoJE4v9ROeAiZbQKak8zs5zdLOtPiK9 BsUTpufs10mcUGUKNhYtVfmEUnIA5MObLZl5w/Sy0ph97xCpbuFbsNj3vT3PgWQOX97Oc572KnqRB 3zK4yeCw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51436 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsxu-0004Xz-2m; Tue, 28 May 2024 10:17:54 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsxx-00E8vi-Gf; Tue, 28 May 2024 10:17:57 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 4/8] wifi: wlcore: pass "status" to wlcore_hw_convert_fw_status() Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:17:57 +0100 wlcore_fw_status() is passed a pointer to the struct wl_fw_status to decode the status into, which is always wl->fw_status. Rather than referencing wl->fw_status within wlcore_fw_status(), use the supplied argument so that we access this member in a consistent manner. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wlcore/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index a98b26dc3cb8..3defe49c5120 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -392,7 +392,7 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) if (ret < 0) return ret; - wlcore_hw_convert_fw_status(wl, wl->raw_fw_status, wl->fw_status); + wlcore_hw_convert_fw_status(wl, wl->raw_fw_status, status); wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, " "drv_rx_counter = %d, tx_results_counter = %d)", From patchwork Tue May 28 09:18:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 800923 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BE3D13D880; Tue, 28 May 2024 09:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887889; cv=none; b=YWczj3uRAGho9szdEJHwT7meqnBFSAyA+Mvx4WdIGj9WnptZSPzI/RR/55+rlOzMYdY2v9SUVmKw+qMggylWisO49QG/vgxvnTsRZcI/XbBxKsmRSCK0CEoSnuPWLrqE/U7+EDZjkPFbGRg5IzIFcIG3A0SAddi/IClJyULQ/F0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887889; c=relaxed/simple; bh=x1k4gsqI+QHKZYqcjtRet4AtaX2EO5HGhcwTJVyOrA8=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=fSTteYFzjxNBTLt5QxjRNOyLGj++EvG8Yzimc0YpLhoLFbeSGLDdvFbOm2UV2uDqIyvPSRlv7JJPmk7+GhNz39I/Vl3Thv5aoWl80aImL4SpSrA6R+XgQ/li/O2inWAQ1JwSAtzrTvnTqEUWNGQGOCXOblPWheKQuAeKJORiyeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=0j++Yg4X; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="0j++Yg4X" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UhjKQTZ4N5nNFgPTwE1YDpUmEfTGwnyBm7+TW+XXveY=; b=0j++Yg4X0Uc54LA0/icRYLrayu gpl3/s6FkxMROSylQSv7C5dJ+GwWcgOfOFn0stvpGjymKAeoYWTNXnzMdonC9POeyJbYr+8nKuDsU PB8TKd9YJnzh3CU+mRhtVQo4OtZAFcfxU/lMpK58Yxkfem6DfXjz01mL4SgP5bhAydPXE3erKYBIi 3veBYti41cPd3KUw5dOofHo3BIWdjgs1CqAaa6qbqdpez56yRh+YQR5ZwxRcLskznZtwGWYXs+YWQ dKElDZhYEHUcFI2EkCK5L5snvN++HJTirdvje0FiGE8b3Jbgv3xv4Qo5q62DLXIc9Z2JCa2K6hcrT BjQMenCg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43032 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsy0-0004Y8-0A; Tue, 28 May 2024 10:18:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsy2-00E8vo-KK; Tue, 28 May 2024 10:18:02 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 5/8] wifi: wlcore: store AP encryption key type Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:18:02 +0100 Updates for WL18xx firmware 8.9.1.x.x need to know the AP encryption key type. Store this when a new key is set. Patch extracted from: https://git.ti.com/cgit/wilink8-wlan/build-utilites/tree/patches/kernel_patches/4.19.38/0023-wlcore-Fixing-PN-drift-on-encrypted-link-after-recov.patch?h=r8.9&id=a2ee50aa5190ed3b334373d6cd09b1bff56ffcf7 Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wlcore/main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 3defe49c5120..8f82666f379c 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -3537,6 +3537,10 @@ int wlcore_set_key(struct wl1271 *wl, enum set_key_cmd cmd, return ret; } + /* Store AP encryption key type */ + if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wlvif->encryption_type = key_type; + /* * reconfiguring arp response if the unicast (or common) * encryption key type was changed From patchwork Tue May 28 09:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 799796 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6222E13F45F; Tue, 28 May 2024 09:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887894; cv=none; b=QjMIZi0iQzj1b8ni2oTdEcVKqOVxJ317vobRX184mMeuH5tqOh0jJrllo9s2b/Kqodp8RMzF5kO2uiq7hPA5x6G1GKHrU7LILHqn1qqVWPlaRRe3cTS/mwbN8hjB1eEEisZOiVHEizXwDu0HirGXaazc3Y1qzLDkLVQ2XjgExTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887894; c=relaxed/simple; bh=kU7Tlob7aqdGJVIIlB2bJ3z2njJBaj2p/U8Kna4zyH4=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=NoYjLgKhx4OXZLxuvsjDCRT8/khLAKu1Icda6HzjLuizsyV6iDg+yniZ/TS5r13NJZ50YuIVNwTqKkN0zK/ub/aYG2O10+aT5tnDTB3+Dny0XUXG1Y95pZWRRlw65963wuOchHbK+epSH3Bo8vlPyvpIZfvkquJ9IyTpRR5xI80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=G46LM79b; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="G46LM79b" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HuHTw1gCK5bIqEGyLd+i4Kr0r9K90c+aiGJ17Pw8vbU=; b=G46LM79b8M0SP5b+iCpqhb5V7B A2WAZcJT6h6PibIaAF2k9PAN1xtw7Hu2YYb6pRGG/QzUiBSXW5v4w8ee0dHHRni/0E8OAtCI5xQ/T tlrP2ur1oZ6LCx9V584NEhZ9Y/Fxl+Fb4fxa/B7DAaN8edsAF4giYneMYeGYik5JKUYdxoek9P9fs mVjOGCfw3HQF4XUTXIgiEgP9Gx0Aipkhe0GWpKxMbPv1uGSvJkyUNN8VVFEWlOIhJ4p4k/1APQkqG L5OaM1gP8bo3Z2bh1rYOcsjRoGosxgDvMNF+rWMjQw/JB0zJXZyPT/MTvnBR6NDcA3iFKCazmdSac 6cyLXfbA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43036 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsy5-0004YI-0I; Tue, 28 May 2024 10:18:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsy7-00E8vu-Nc; Tue, 28 May 2024 10:18:07 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 6/8] wifi: wlcore: add pn16 support Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:18:07 +0100 TI Wl18xx firmware adds a "pn16" field for AES and TKIP keys as per their patch: https://git.ti.com/cgit/wilink8-wlan/build-utilites/tree/patches/kernel_patches/4.19.38/0023-wlcore-Fixing-PN-drift-on-encrypted-link-after-recov.patch?h=r8.9&id=a2ee50aa5190ed3b334373d6cd09b1bff56ffcf7 Add support for this, but rather than requiring the field to be present (which would break existing firmwares), make it optional. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wlcore/cmd.c | 9 +++ drivers/net/wireless/ti/wlcore/main.c | 89 +++++++++++++++++++++-- drivers/net/wireless/ti/wlcore/wlcore_i.h | 4 + 3 files changed, 97 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c index a939fd89a7f5..0d1fcdca3869 100644 --- a/drivers/net/wireless/ti/wlcore/cmd.c +++ b/drivers/net/wireless/ti/wlcore/cmd.c @@ -332,6 +332,14 @@ int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) wl->fw_status->counters.tx_lnk_free_pkts[link]; wl->links[link].wlvif = wlvif; + /* + * Take the last sec_pn16 value from the current FW status. On recovery, + * we might not have fw_status yet, and tx_lnk_sec_pn16[] will be NULL. + */ + if (wl->fw_status->counters.tx_lnk_sec_pn16) + wl->links[link].prev_sec_pn16 = + le16_to_cpu(wl->fw_status->counters.tx_lnk_sec_pn16[link]); + /* * Take saved value for total freed packets from wlvif, in case this is * recovery/resume @@ -360,6 +368,7 @@ void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) wl->links[*hlid].allocated_pkts = 0; wl->links[*hlid].prev_freed_pkts = 0; + wl->links[*hlid].prev_sec_pn16 = 0; wl->links[*hlid].ba_bitmap = 0; eth_zero_addr(wl->links[*hlid].addr); diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 8f82666f379c..35d1114a28aa 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -379,6 +379,8 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) { + struct wl12xx_vif *wlvifsta; + struct wl12xx_vif *wlvifap; struct wl12xx_vif *wlvif; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; @@ -410,23 +412,100 @@ static int wlcore_fw_status(struct wl1271 *wl, struct wl_fw_status *status) wl->tx_pkts_freed[i] = status->counters.tx_released_pkts[i]; } + /* Find an authorized STA vif */ + wlvifsta = NULL; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + if (wlvif->sta.hlid != WL12XX_INVALID_LINK_ID && + test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) { + wlvifsta = wlvif; + break; + } + } + + /* Find a started AP vif */ + wlvifap = NULL; + wl12xx_for_each_wlvif(wl, wlvif) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS && + wlvif->inconn_count == 0 && + test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { + wlvifap = wlvif; + break; + } + } for_each_set_bit(i, wl->links_map, wl->num_links) { + u16 diff16, sec_pn16; u8 diff, tx_lnk_free_pkts; + lnk = &wl->links[i]; /* prevent wrap-around in freed-packets counter */ tx_lnk_free_pkts = status->counters.tx_lnk_free_pkts[i]; diff = (tx_lnk_free_pkts - lnk->prev_freed_pkts) & 0xff; - if (diff == 0) + if (diff) { + lnk->allocated_pkts -= diff; + lnk->prev_freed_pkts = tx_lnk_free_pkts; + } + + /* Get the current sec_pn16 value if present */ + if (status->counters.tx_lnk_sec_pn16) + sec_pn16 = __le16_to_cpu(status->counters.tx_lnk_sec_pn16[i]); + else + sec_pn16 = 0; + /* prevent wrap-around in pn16 counter */ + diff16 = (sec_pn16 - lnk->prev_sec_pn16) & 0xffff; + + /* FIXME: since free_pkts is a 8-bit counter of packets that + * rolls over, it can become zero. If it is zero, then we + * omit processing below. Is that really correct? + */ + if (tx_lnk_free_pkts <= 0) continue; - lnk->allocated_pkts -= diff; - lnk->prev_freed_pkts = tx_lnk_free_pkts; + /* For a station that has an authorized link: */ + if (wlvifsta && wlvifsta->sta.hlid == i) { + if (wlvifsta->encryption_type == KEY_TKIP || + wlvifsta->encryption_type == KEY_AES) { + if (diff16) { + lnk->prev_sec_pn16 = sec_pn16; + /* accumulate the prev_freed_pkts + * counter according to the PN from + * firmware + */ + lnk->total_freed_pkts += diff16; + } + } else { + if (diff) + /* accumulate the prev_freed_pkts + * counter according to the free packets + * count from firmware + */ + lnk->total_freed_pkts += diff; + } + } - /* accumulate the prev_freed_pkts counter */ - lnk->total_freed_pkts += diff; + /* For an AP that has been started */ + if (wlvifap && test_bit(i, wlvifap->ap.sta_hlid_map)) { + if (wlvifap->encryption_type == KEY_TKIP || + wlvifap->encryption_type == KEY_AES) { + if (diff16) { + lnk->prev_sec_pn16 = sec_pn16; + /* accumulate the prev_freed_pkts + * counter according to the PN from + * firmware + */ + lnk->total_freed_pkts += diff16; + } + } else { + if (diff) + /* accumulate the prev_freed_pkts + * counter according to the free packets + * count from firmware + */ + lnk->total_freed_pkts += diff; + } + } } /* prevent wrap-around in total blocks counter */ diff --git a/drivers/net/wireless/ti/wlcore/wlcore_i.h b/drivers/net/wireless/ti/wlcore/wlcore_i.h index eefae3f867b9..5fbed64302f1 100644 --- a/drivers/net/wireless/ti/wlcore/wlcore_i.h +++ b/drivers/net/wireless/ti/wlcore/wlcore_i.h @@ -151,6 +151,9 @@ struct wl_fw_status { */ u8 *tx_lnk_free_pkts; + /* PN16 of last TKIP/AES seq-num per HLID */ + __le16 *tx_lnk_sec_pn16; + /* Cumulative counter of released Voice memory blocks */ u8 tx_voice_released_blks; @@ -259,6 +262,7 @@ struct wl1271_link { /* accounting for allocated / freed packets in FW */ u8 allocated_pkts; u8 prev_freed_pkts; + u16 prev_sec_pn16; u8 addr[ETH_ALEN]; From patchwork Tue May 28 09:18:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 800922 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55AB113FD98; Tue, 28 May 2024 09:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887898; cv=none; b=etEUO34Nz1IVQCOPAT21tKq6emra61zTqKWbAX4O4+OtfKsX7Ez7vfemIf1j77Wrii39Qc02OHWnIXgxP3PC7JNln2fcTtxNjAouAeMQupR1go6i4g2cSvHSPlG4E/1RTzuceobxjC2mdWmgiQuya1GtU10rcYXXiKxWAqApYCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887898; c=relaxed/simple; bh=OrpFxVvf8L2kV0avrvZILfxK58oh+W6unS06Tvx2HWE=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=aIiA0t7QMlcAU9aJqRQqunIN92Ojk2krXki4YQ962LtXJ0hWJiDSRadJZW/3s9fnCcuvhSqpcTvkk/syOfe519zxouIN1z+jbwr0H5JlKZtBBa4KExVUcLGIyKib7rM+WsdOfz6xfSWFrZ79BhERsm6SfjaY1I+TbgCnCczlvzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=IEWWJWh3; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="IEWWJWh3" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KWRKd5sgUp41uUqnRFuTZP9wXDKBCzkvewba+Ard9/Q=; b=IEWWJWh3HGKfgi9hXj+j/O5y3O vLk51b4dpYuRmByv0SbJdJcqLtbm+lW3OQagrr0bMgcBdOCXv/MiKV5QMn15PJ+BMcu3xNDY6A78G L700Xjhgw0Y7pEU75VjQWqKy66ShwJSGkbZcCPnkaIW1gD4mulZepm32ieEd6ZwFhIlxhJ0BMCnQ3 UywLRzZ6DMUBjAylU6nVK1UnyBvGVJ0oOO3Ew+aYonE3mXIypKWv1SkISDl5BiEPOEDpNs7QMsBS+ oqvUBBYwm6EYDWiWMzdt+KpI2QRJjOUJwi8l8CDMfJpmiC/+KNT3nKZ8p8TuxrUWL0QEMjqUEF8cl 1DyoSzUg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53388 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsyA-0004YR-0e; Tue, 28 May 2024 10:18:10 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsyC-00E8w0-Rz; Tue, 28 May 2024 10:18:12 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 7/8] wifi: wl18xx: add support for reading 8.9.1 fw status Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:18:12 +0100 Add the necessary code to read the 8.9.1 firmware status into the driver private status structure, augmenting the 8.9.0 firmware status code. New structure layout taken from: https://git.ti.com/cgit/wilink8-wlan/build-utilites/tree/patches/kernel_patches/4.19.38/0023-wlcore-Fixing-PN-drift-on-encrypted-link-after-recov.patch?h=r8.9&id=a2ee50aa5190ed3b334373d6cd09b1bff56ffcf7 Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wl18xx/main.c | 71 ++++++++++++++++++++++++- drivers/net/wireless/ti/wl18xx/wl18xx.h | 60 +++++++++++++++++++++ 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c index 2ccac1cdec01..39d8eebb9b6e 100644 --- a/drivers/net/wireless/ti/wl18xx/main.c +++ b/drivers/net/wireless/ti/wl18xx/main.c @@ -1177,8 +1177,49 @@ static int wl18xx_hw_init(struct wl1271 *wl) return ret; } -static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status, - struct wl_fw_status *fw_status) +static void wl18xx_convert_fw_status_8_9_1(struct wl1271 *wl, + void *raw_fw_status, + struct wl_fw_status *fw_status) +{ + struct wl18xx_fw_status_8_9_1 *int_fw_status = raw_fw_status; + + fw_status->intr = le32_to_cpu(int_fw_status->intr); + fw_status->fw_rx_counter = int_fw_status->fw_rx_counter; + fw_status->drv_rx_counter = int_fw_status->drv_rx_counter; + fw_status->tx_results_counter = int_fw_status->tx_results_counter; + fw_status->rx_pkt_descs = int_fw_status->rx_pkt_descs; + + fw_status->fw_localtime = le32_to_cpu(int_fw_status->fw_localtime); + fw_status->link_ps_bitmap = le32_to_cpu(int_fw_status->link_ps_bitmap); + fw_status->link_fast_bitmap = + le32_to_cpu(int_fw_status->link_fast_bitmap); + fw_status->total_released_blks = + le32_to_cpu(int_fw_status->total_released_blks); + fw_status->tx_total = le32_to_cpu(int_fw_status->tx_total); + + fw_status->counters.tx_released_pkts = + int_fw_status->counters.tx_released_pkts; + fw_status->counters.tx_lnk_free_pkts = + int_fw_status->counters.tx_lnk_free_pkts; + fw_status->counters.tx_lnk_sec_pn16 = + int_fw_status->counters.tx_lnk_sec_pn16; + fw_status->counters.tx_voice_released_blks = + int_fw_status->counters.tx_voice_released_blks; + fw_status->counters.tx_last_rate = + int_fw_status->counters.tx_last_rate; + fw_status->counters.tx_last_rate_mbps = + int_fw_status->counters.tx_last_rate_mbps; + fw_status->counters.hlid = + int_fw_status->counters.hlid; + + fw_status->log_start_addr = le32_to_cpu(int_fw_status->log_start_addr); + + fw_status->priv = &int_fw_status->priv; +} + +static void wl18xx_convert_fw_status_8_9_0(struct wl1271 *wl, + void *raw_fw_status, + struct wl_fw_status *fw_status) { struct wl18xx_fw_status *int_fw_status = raw_fw_status; @@ -1214,6 +1255,15 @@ static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status, fw_status->priv = &int_fw_status->priv; } +static void wl18xx_convert_fw_status(struct wl1271 *wl, void *raw_fw_status, + struct wl_fw_status *fw_status) +{ + if (wl->chip.fw_ver[FW_VER_MAJOR] == 0) + wl18xx_convert_fw_status_8_9_0(wl, raw_fw_status, fw_status); + else + wl18xx_convert_fw_status_8_9_1(wl, raw_fw_status, fw_status); +} + static void wl18xx_set_tx_desc_csum(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc, struct sk_buff *skb) @@ -1515,12 +1565,29 @@ static int wl18xx_handle_static_data(struct wl1271 *wl, { struct wl18xx_static_data_priv *static_data_priv = (struct wl18xx_static_data_priv *) static_data->priv; + size_t fw_status_len; strscpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version, sizeof(wl->chip.phy_fw_ver_str)); wl1271_info("PHY firmware version: %s", static_data_priv->phy_version); + /* Adjust the firmware status size according to the firmware version */ + if (wl->chip.fw_ver[FW_VER_MAJOR] == 0) + fw_status_len = sizeof(struct wl18xx_fw_status); + else + fw_status_len = sizeof(struct wl18xx_fw_status_8_9_1); + + if (wl->fw_status_len != fw_status_len) { + void *new_status = krealloc(wl->raw_fw_status, fw_status_len, + GFP_KERNEL | __GFP_ZERO); + if (!new_status) + return -ENOMEM; + + wl->raw_fw_status = new_status; + wl->fw_status_len = fw_status_len; + } + return 0; } diff --git a/drivers/net/wireless/ti/wl18xx/wl18xx.h b/drivers/net/wireless/ti/wl18xx/wl18xx.h index b642e0c437bb..7fed96d71b27 100644 --- a/drivers/net/wireless/ti/wl18xx/wl18xx.h +++ b/drivers/net/wireless/ti/wl18xx/wl18xx.h @@ -155,6 +155,66 @@ struct wl18xx_fw_status { struct wl18xx_fw_status_priv priv; } __packed; +struct wl18xx_fw_packet_counters_8_9_1 { + /* Cumulative counter of released packets per AC */ + u8 tx_released_pkts[NUM_TX_QUEUES]; + + /* Cumulative counter of freed packets per HLID */ + u8 tx_lnk_free_pkts[WL18XX_MAX_LINKS]; + + /* PN16 of last TKIP/AES seq-num per HLID */ + __le16 tx_lnk_sec_pn16[WL18XX_MAX_LINKS]; + + /* Cumulative counter of released Voice memory blocks */ + u8 tx_voice_released_blks; + + /* Tx rate of the last transmitted packet */ + u8 tx_last_rate; + + /* Tx rate or Tx rate estimate pre-calculated by fw in mbps units */ + u8 tx_last_rate_mbps; + + /* hlid for which the rates were reported */ + u8 hlid; +} __packed; + +/* FW status registers */ +struct wl18xx_fw_status_8_9_1 { + __le32 intr; + u8 fw_rx_counter; + u8 drv_rx_counter; + u8 reserved; + u8 tx_results_counter; + __le32 rx_pkt_descs[WL18XX_NUM_RX_DESCRIPTORS]; + + __le32 fw_localtime; + + /* + * A bitmap (where each bit represents a single HLID) + * to indicate if the station is in PS mode. + */ + __le32 link_ps_bitmap; + + /* + * A bitmap (where each bit represents a single HLID) to indicate + * if the station is in Fast mode + */ + __le32 link_fast_bitmap; + + /* Cumulative counter of total released mem blocks since FW-reset */ + __le32 total_released_blks; + + /* Size (in Memory Blocks) of TX pool */ + __le32 tx_total; + + struct wl18xx_fw_packet_counters_8_9_1 counters; + + __le32 log_start_addr; + + /* Private status to be used by the lower drivers */ + struct wl18xx_fw_status_priv priv; +} __packed; + #define WL18XX_PHY_VERSION_MAX_LEN 20 struct wl18xx_static_data_priv { From patchwork Tue May 28 09:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 799795 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10865140386; Tue, 28 May 2024 09:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887903; cv=none; b=NyhgoBa7hkTyXSyt8SyDhCMfhGB5LyX5/qjLUxzdY8NhJuOYod6uKAO/TMIDYGu/JWHkTBNh2TJio6h6N6KcBgR8t37z7MfvKX4rCvpY+FVtXhO6es4FOR4ldpreP1SKfhZgOxrBed42Zv56tzQZAmvwF0xpR8pwISt6AwCuJfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716887903; c=relaxed/simple; bh=LKu4LRyGZp0SuwvyOaS9H+olC5GTu4VF+Xc85CYC4ek=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=PLL4LxNo2VxCPdI0UQ3SkL64aB6mRVctGJ3d4SiPwh2HygcX3e5sUoQPpttfxzyaCWG8SC3RaD+nBLSeGBuDAFtSR/R55hmuON87sTVW98p0HN8mkeWDkFXFEI2qAr6e6DT0836Gngnj7OEnvNvKmrsNg9tWCDyDYUegguwlEqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=xDk3Smty; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="xDk3Smty" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FlOsQt51ODlcWfSttNCMN/vZL8f8s6mIoZE3qIAvgdY=; b=xDk3SmtyjuJIz+pzkFgfJlAaJq JdvH9tfZ/3H8bqYWRwMvRrAPoeE52mOi5iw9VYATIfsa09vhaDzpktUgvVlO15ZJTrDs1VrhzAT3Z zQJFkq240k8ZjORkB+wHJpd6n/o211D4bSyoVuPyo57ahuH5BuE+0brCukMzSy+vqDCGZlW3YIXl2 tRVShTsTMLAtS3Txi5TgbQ9P/8h7TrGUW+5dSiJBQB3da5kkFC/NEFZUD6fu3Zy69eUygopnDOby1 xxE3LCjV7kchdNfCQNUZIGbRKkgviNIfZu+VQKaOR2vxvgK280j8I3hvFdP2w7iKM7HpCgPHJakV9 kE0jooaw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53394 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sBsyF-0004Ya-0q; Tue, 28 May 2024 10:18:15 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1sBsyH-00E8w6-Vu; Tue, 28 May 2024 10:18:18 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Kalle Valo Cc: Johannes Berg , Michael Nemanov , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH wireless-next 8/8] wifi: wl18xx: allow firmwares > 8.9.0.x.58 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 28 May 2024 10:18:17 +0100 wlcore firmware versions are structured thusly: chip.if-type.major.sub-type.minor e.g. 8 9 0 0 58 With WL18xx ignoring the major firmware version, looking for a firmware version that conforms to: chip >= 8 if-type >= 9 major (don't care) sub-type (don't care) minor >= 58 Each test is satisfied if the value read from the firmware is greater than the minimum, but if it is equal (or we don't care about the field), then the next field is checked. Thus it doesn't recognise 8.9.1.x.0 as being newer than 8.9.0.x.58 since the major and sub-type numbers are "don't care" and the minor needs to be greater or equal to 58. We need to change the major version from "ignore" to "0" for this later firmware to be correctly detected, and allow the dual-firmware version support to work. Signed-off-by: Russell King (Oracle) --- drivers/net/wireless/ti/wl18xx/wl18xx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wl18xx/wl18xx.h b/drivers/net/wireless/ti/wl18xx/wl18xx.h index 7fed96d71b27..de6c671c4be6 100644 --- a/drivers/net/wireless/ti/wl18xx/wl18xx.h +++ b/drivers/net/wireless/ti/wl18xx/wl18xx.h @@ -13,7 +13,7 @@ /* minimum FW required for driver */ #define WL18XX_CHIP_VER 8 #define WL18XX_IFTYPE_VER 9 -#define WL18XX_MAJOR_VER WLCORE_FW_VER_IGNORE +#define WL18XX_MAJOR_VER 0 #define WL18XX_SUBTYPE_VER WLCORE_FW_VER_IGNORE #define WL18XX_MINOR_VER 58