Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1084323pxb; Wed, 3 Nov 2021 18:06:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJPY/gkvfxxU4XyBlIFBEE4AGiyeeStjEKTnvox6tp3gPhsZy9gXMwLFaF44BNF/gOuIFk X-Received: by 2002:a05:6e02:188e:: with SMTP id o14mr20335535ilu.302.1635988018656; Wed, 03 Nov 2021 18:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635988018; cv=none; d=google.com; s=arc-20160816; b=MJw5nvs4avGBs9Bcy6SG48dPwS6kr49Lqns157lgvLRf8DwNlHhzwwVVeKiV1QM5qM bMbEA1ul5W2PqXu5GBGGrIuTrbSiiGaZK88SyF9LFTZkNuP8beQ20LiI+/CvTe6zHHI1 WP6/T0HxIBsk8uwoedW9j7O0jTLXILumlH+2on7hZ/42NdX1GiKtyHIIfqncl099GE2b 8AvduD7pyCoPTRYWeKQCNwTrX41z4FrZ1vKUV3wsFDBI7uUiJzTaZwsT6erHl+dMrmGf iKzrFgr9kURwfaGnr378WdyI3LGwyq9pGD5Gplu+lFwBnhv/NYVRX0H6V6gC3Prmd4Y6 pSgw== 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=pDVUch6Lb+hKrTeJN47aVDG0/PqBE3bpo0ZhrAQR1/M=; b=ti0CjCEjB+UnG6KwP/ZbFtcErbT4n/nny+Dcod2QX7hVVRvjL1IWZQX/zdahCxIw3j 0G2bZ5YQtkVufxsF/2hsjbqt/KSsvI0xfROseGv6HMt75Beyt9q6MMb6Oitb3Z8T8RFr x2FkYhTayPjUs1rTG6nhQsWPl1EyZntBrLc5z4ceTCphEXPlWmH0y+u/jGlJMP2ijYhC lnDkKJRUeVARdZa3srYl58+LtBCNko8CrKSjQDoDrxSvNVAsmFvijHG1aFfAvroEY7BH t/1NTgqgsywISfb4lvZgxXhGXa1N9a7IBx4EluDu3S+kLBijtVOrA8wVWBYKjDppY0uK K06A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@squareup.com header.s=google header.b=U8uoq4fq; 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=REJECT sp=REJECT dis=NONE) header.from=squareup.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si5921965jag.18.2021.11.03.18.06.50; Wed, 03 Nov 2021 18:06:58 -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=@squareup.com header.s=google header.b=U8uoq4fq; 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=REJECT sp=REJECT dis=NONE) header.from=squareup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbhKDBIf (ORCPT + 66 others); Wed, 3 Nov 2021 21:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhKDBIe (ORCPT ); Wed, 3 Nov 2021 21:08:34 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BD9AC06127A for ; Wed, 3 Nov 2021 18:05:57 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id y1so4454992plk.10 for ; Wed, 03 Nov 2021 18:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squareup.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pDVUch6Lb+hKrTeJN47aVDG0/PqBE3bpo0ZhrAQR1/M=; b=U8uoq4fqQWHmmOaCZYS1pOsw/rQ1TdwFW9y36HAcsEQzjT6pHzxSGZaiPxwls7zeHO X+OiB/1m+WKs/wIUM/BJXv91mvhMk4xFCNHU1pBXV0cLPLJ70NhNAtyo2DFGH2UWARDQ UXh9VUi9yLtaLG7q6JgObJl0AUhGouRQ0/c1I= 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=pDVUch6Lb+hKrTeJN47aVDG0/PqBE3bpo0ZhrAQR1/M=; b=aHxXVRMmX0egXc4/Mtw55buy9yRFGnW9OWIOFJQwch2heUePMZYV1cqSAa2PQWFEiE 00JAV1h2gqFsUJ8MkRIk2DiqR/d7JugsylYUtNW1g3Xe6+is6TxLfyimBFanC/hdfo6A XlTlUjdHzlQTBrexVxwUhL9hRFWvOnitr6Z4xMmxoxLsdgirEO21wqf/GlftS6qqKVCx gsQrG1SQlyPkpFxOiUrhBpzkojswP2GOYec6x085fm/VpWkRi2chPQtTQfi4o/DtV43B 8da4eINZwdA/dyXsY9eJg2MiC1BwpbTqHvOqdb4/WsVIqtk47BUBpEV311BRcnA7dCUW FmsQ== X-Gm-Message-State: AOAM531R3w01TAW1ltIGcj29+xDAS64JfFr7ecfcIPhj2ftL7OqDeUel MYPRRf8uC0mEIjsfWLbRTftx8Q== X-Received: by 2002:a17:90a:5d89:: with SMTP id t9mr18386045pji.21.1635987956413; Wed, 03 Nov 2021 18:05:56 -0700 (PDT) Received: from localhost ([2600:6c50:4d00:d401:aa7a:1484:c7d0:ae82]) by smtp.gmail.com with ESMTPSA id r6sm2145571pjg.21.2021.11.03.18.05.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Nov 2021 18:05:55 -0700 (PDT) From: Benjamin Li To: Kalle Valo Cc: Bryan O'Donoghue , Loic Poulain , linux-arm-msm@vger.kernel.org, Benjamin Li , "David S. Miller" , Jakub Kicinski , wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/2] wcn36xx: populate band before determining rate on RX Date: Wed, 3 Nov 2021 18:05:47 -0700 Message-Id: <20211104010548.1107405-2-benl@squareup.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211104010548.1107405-1-benl@squareup.com> References: <20211104010548.1107405-1-benl@squareup.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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 --- 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.25.1