Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3623872pxb; Mon, 24 Jan 2022 13:46:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwk+qVxfis1G6+qIua2ECopGb59ZvyoPqgB2uO2/x4ewODGZLsoS/ni6Bwpa7OxOgskyHKS X-Received: by 2002:a63:5b1d:: with SMTP id p29mr13278581pgb.266.1643060798052; Mon, 24 Jan 2022 13:46:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060798; cv=none; d=google.com; s=arc-20160816; b=cqzCgCb8uyrmdtyO2oio7qjmEqh7PXdoL/61SWoPG+ZNMLocBhWSWOv+goP/shOagr D+GPLe1DnkUcbkeMFzJHas3x5uIlvGljLp29TNGmeRLW74PRMIjrLz0f3bwibrL7QCNi Ez77IfxGPkjKH5X1ZfA8qV1c+7xqIcV3MZBeL387GLR1UTnzVO2fPO+8/7wKLKWmh5tm IJr8EQI5fnMhHGHTqvqi2D+g8rr12SJfiASNUpjsbIUZFKR9Sj7gXwocSyq6MGxrQim9 m/TCwXekme22sMCTLrQD+ARDnezmKNNUOQiBjpMNuot48M4KKsDuMS2B/jcXRP2D2GRH WLhQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YAFITXYDnM2eC3l38+KZ0iQtCuXER2gnLxB0IGfEZbU=; b=jED8Tw0lERqSwKQdmmIO8b7P+o8DPn8keFbMGa60BkA92EOynfYy0RI9AwWA4s2EgS Fzhj6+AQnN1KrvJ4WhUA5rrwDtnNZeFimG1yhY5klfBF01I5UQ8tB29HEeGwVF33GkCB F+x/drRQG6Q3nxAqdb2Ay0QrAvD+FGjjz/xD1dhUpPyhh8egVtHhumR9EsWHDmjCHcu2 xJMX4rmvfF5AxvbeABVss0jhCIrZ7AaaBJBI+99lHjvsifohCKPjkChwpMeMB3T9IGOU AyeL2kEWzCpHhm7dvN7GtHcjhhVgbzGC59nWRfv9V+TZ/aBEf3kCCrnbgL68EN3Y4Tcf cR7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Er3iSV1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kx1si451150pjb.157.2022.01.24.13.46.25; Mon, 24 Jan 2022 13:46:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=Er3iSV1N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1452412AbiAXVZd (ORCPT + 99 others); Mon, 24 Jan 2022 16:25:33 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:51218 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359437AbiAXU6V (ORCPT ); Mon, 24 Jan 2022 15:58:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB3D860B28; Mon, 24 Jan 2022 20:58:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A512AC340E5; Mon, 24 Jan 2022 20:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057899; bh=KNx+81XLGMGGQOWm3ipy3nUWBHABpFfh8FamoSzrYhY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Er3iSV1Nya/0t4UynVzACFwr5pbYaqS2SdC7H/QYlL22eQxnvKVDbCa8rhVeAlSMG 8ft5BRas7I4XjlkcMkxUKV1FMxgRGdJq0b94OwFDkWxiZ6lcHH5RY4wxtRpTVYVTT+ u01pyyMdRvwIRaS/PoIHJ955FCyu3WAOubq6pHNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Li , Loic Poulain , Kalle Valo , Sasha Levin Subject: [PATCH 5.16 0114/1039] wcn36xx: populate band before determining rate on RX Date: Mon, 24 Jan 2022 19:31:43 +0100 Message-Id: <20220124184128.961150656@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Li [ Upstream commit c9c5608fafe4dae975c9644c7d14c51ad3b0ed73 ] status.band is used in determination of status.rate -- for 5GHz on legacy rates there is a linear shift between the BD descriptor's rate field and the wcn36xx driver's rate table (wcn_5ghz_rates). We have a special clause to populate status.band for hardware scan offload frames. However, this block occurs after status.rate is already populated. Correctly handle this dependency by moving the band block before the rate block. This patch addresses kernel warnings & missing scan results for 5GHz APs that send their beacons/probe responses at the higher four legacy rates (24-54 Mbps), when using hardware scan offload: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 0 at net/mac80211/rx.c:4532 ieee80211_rx_napi+0x744/0x8d8 Modules linked in: wcn36xx [...] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 4.19.107-g73909fa #1 Hardware name: Square, Inc. T2 (all variants) (DT) Call trace: dump_backtrace+0x0/0x148 show_stack+0x14/0x1c dump_stack+0xb8/0xf0 __warn+0x2ac/0x2d8 warn_slowpath_null+0x44/0x54 ieee80211_rx_napi+0x744/0x8d8 ieee80211_tasklet_handler+0xa4/0xe0 tasklet_action_common+0xe0/0x118 tasklet_action+0x20/0x28 __do_softirq+0x108/0x1ec irq_exit+0xd4/0xd8 __handle_domain_irq+0x84/0xbc gic_handle_irq+0x4c/0xb8 el1_irq+0xe8/0x190 lpm_cpuidle_enter+0x220/0x260 cpuidle_enter_state+0x114/0x1c0 cpuidle_enter+0x34/0x48 do_idle+0x150/0x268 cpu_startup_entry+0x20/0x24 rest_init+0xd4/0xe0 start_kernel+0x398/0x430 ---[ end trace ae28cb759352b403 ]--- Fixes: 8a27ca394782 ("wcn36xx: Correct band/freq reporting on RX") Signed-off-by: Benjamin Li Tested-by: Loic Poulain Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20211104010548.1107405-2-benl@squareup.com Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wcn36xx/txrx.c | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index 75951ccbc840e..f0a9f069a92a9 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -314,8 +314,6 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) fc = __le16_to_cpu(hdr->frame_control); sn = IEEE80211_SEQ_TO_SN(__le16_to_cpu(hdr->seq_ctrl)); - status.freq = WCN36XX_CENTER_FREQ(wcn); - status.band = WCN36XX_BAND(wcn); status.mactime = 10; status.signal = -get_rssi0(bd); status.antenna = 1; @@ -327,6 +325,25 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag); + if (bd->scan_learn) { + /* If packet originate from hardware scanning, extract the + * band/channel from bd descriptor. + */ + u8 hwch = (bd->reserved0 << 4) + bd->rx_ch; + + if (bd->rf_band != 1 && hwch <= sizeof(ab_rx_ch_map) && hwch >= 1) { + status.band = NL80211_BAND_5GHZ; + status.freq = ieee80211_channel_to_frequency(ab_rx_ch_map[hwch - 1], + status.band); + } else { + status.band = NL80211_BAND_2GHZ; + status.freq = ieee80211_channel_to_frequency(hwch, status.band); + } + } else { + status.band = WCN36XX_BAND(wcn); + status.freq = WCN36XX_CENTER_FREQ(wcn); + } + if (bd->rate_id < ARRAY_SIZE(wcn36xx_rate_table)) { rate = &wcn36xx_rate_table[bd->rate_id]; status.encoding = rate->encoding; @@ -353,22 +370,6 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) ieee80211_is_probe_resp(hdr->frame_control)) status.boottime_ns = ktime_get_boottime_ns(); - if (bd->scan_learn) { - /* If packet originates from hardware scanning, extract the - * band/channel from bd descriptor. - */ - u8 hwch = (bd->reserved0 << 4) + bd->rx_ch; - - if (bd->rf_band != 1 && hwch <= sizeof(ab_rx_ch_map) && hwch >= 1) { - status.band = NL80211_BAND_5GHZ; - status.freq = ieee80211_channel_to_frequency(ab_rx_ch_map[hwch - 1], - status.band); - } else { - status.band = NL80211_BAND_2GHZ; - status.freq = ieee80211_channel_to_frequency(hwch, status.band); - } - } - memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); if (ieee80211_is_beacon(hdr->frame_control)) { -- 2.34.1