From patchwork Mon Oct 18 10:57:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 12565985 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD144C433F5 for ; Mon, 18 Oct 2021 10:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFDE661002 for ; Mon, 18 Oct 2021 10:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhJRKsy (ORCPT ); Mon, 18 Oct 2021 06:48:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbhJRKsw (ORCPT ); Mon, 18 Oct 2021 06:48:52 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A162C061714 for ; Mon, 18 Oct 2021 03:46:41 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id m22so40696356wrb.0 for ; Mon, 18 Oct 2021 03:46:41 -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; bh=d6iwtRfuZTETciNTWdG7oGNdEZ8SIS+Jv3Ox8wXHaJg=; b=CREtg5/Sp+R0I4teGevh/5aiIIv2BLPy9vA+BN5H6e3NsiVbdKeg4tjD+D+CYEteEa hdi7PS9OStq+vez2xtUfbI8P9TnBG/xn61y+LBq3kqem8C//1TQDtaySiSKttPkzkYQV CZ88lBg4IxMYkjiPzgBH7wEtAF9lOYFIRg6qa83a8yxGw3jFDQ6Cf7AgwMo/aOGz9WkD piHkWVtGr+qWQQ1Tc3HYMOgNSAiNRS4x/tEAooKuikm5K6Q81JHUcPMjUPr/Hhb8gYaC 09wX0tN3M8+g9gs+r5IqR9vHjVtKYtEZmftRNjLU3YFLpSfTLwDWsgfd+y0jsVo/j0qj TbaQ== 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; bh=d6iwtRfuZTETciNTWdG7oGNdEZ8SIS+Jv3Ox8wXHaJg=; b=4Hr++/zbee9bsSiz6hFyExLUEn65p8JEnBF7q+fLi1GLB3d5POobkOSDATdP3Hhp2C 63t5QVn/qAOcdZMYwYA/ABKE088OMSfUPJvRFrXaNye10haUNIYOTbJtwcxIN7VcLfS6 kKcRvQnf8TYavnNrc0h0/tcSFmsXyIyKEZDOZLU03tFPzY6K7Mx12LtJJDmDjzmk5wTP SDTgn3/SGI9BVmTy6kVuc+2BwqxbuOcY/jc6QGs7QjU0cfzScJM0OoQpXC/hs4cJQj1V hqdCO6/qzrekGZI1x/Q1oSgRWxe09G7+c32WX42a9MEp8/WtEdT6OQFfy0CJPESqOAif r6PA== X-Gm-Message-State: AOAM5307SSFuTu12Bl+jutVHWzEaO8CiEQUVCGdUc7DTagn3IPE3zWVm WJiHrVU4ddPMulosd8jF6p+NaI4+YiZIwg== X-Google-Smtp-Source: ABdhPJxr98ZFI6/OKUQ3KHu+YPqL56Xyh+SxfdTEFeIIdwI2GwAEo0XKyaVbDZD26ENi/Rgwf7pWjg== X-Received: by 2002:adf:e390:: with SMTP id e16mr34975492wrm.217.1634553999896; Mon, 18 Oct 2021 03:46:39 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:9df5:c752:530b:345b]) by smtp.gmail.com with ESMTPSA id r4sm15195945wrz.58.2021.10.18.03.46.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Oct 2021 03:46:39 -0700 (PDT) From: Loic Poulain To: kvalo@codeaurora.org Cc: wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, bryan.odonoghue@linaro.org, Loic Poulain Subject: [PATCH 1/2] wcn36xx: Correct band/freq reporting on RX Date: Mon, 18 Oct 2021 12:57:57 +0200 Message-Id: <1634554678-7993-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org For packets originating from hardware scan, the channel and band is included in the buffer descriptor (bd->rf_band & bd->rx_ch). For 2Ghz band the channel value is directly reported in the 4-bit rx_ch field. For 5Ghz band, the rx_ch field contains a mapping index (given the 4-bit limitation). The reserved0 value field is also used to extend 4-bit mapping to 5-bit mapping to support more than 16 5Ghz channels. This change adds correct reporting of the frequency/band, that is used in scan mechanism. And is required for 5Ghz hardware scan support. Signed-off-by: Loic Poulain Tested-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/txrx.c | 23 +++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/txrx.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index cab196b..a3ef497 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -31,6 +31,13 @@ struct wcn36xx_rate { enum rate_info_bw bw; }; +/* Buffer descriptor rx_ch field is limited to 5-bit (4+1), a mapping is used + * for 11A Channels. + */ +static const u8 ab_rx_ch_map[] = { 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, + 108, 112, 116, 120, 124, 128, 132, 136, 140, + 149, 153, 157, 161, 165, 144 }; + static const struct wcn36xx_rate wcn36xx_rate_table[] = { /* 11b rates */ { 10, 0, RX_ENC_LEGACY, 0, RATE_INFO_BW_20 }, @@ -291,6 +298,22 @@ 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)) { diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.h b/drivers/net/wireless/ath/wcn36xx/txrx.h index 032216e..b54311f 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.h +++ b/drivers/net/wireless/ath/wcn36xx/txrx.h @@ -110,7 +110,8 @@ struct wcn36xx_rx_bd { /* 0x44 */ u32 exp_seq_num:12; u32 cur_seq_num:12; - u32 fr_type_subtype:8; + u32 rf_band:2; + u32 fr_type_subtype:6; /* 0x48 */ u32 msdu_size:16; From patchwork Mon Oct 18 10:57:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 12565987 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D249FC433F5 for ; Mon, 18 Oct 2021 10:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8D3461002 for ; Mon, 18 Oct 2021 10:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbhJRKtD (ORCPT ); Mon, 18 Oct 2021 06:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbhJRKtD (ORCPT ); Mon, 18 Oct 2021 06:49:03 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F6DBC06161C for ; Mon, 18 Oct 2021 03:46:52 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id v17so40438458wrv.9 for ; Mon, 18 Oct 2021 03:46:52 -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; bh=BaJ5lbXk0aHDbSY/0wo3ZTQDwBqF9Vwclu0gix6RmYQ=; b=xn4FIYIEzzSCxgDqLrrb44ivDe/qPvSAiYlg5UwclYfv+9u8zEktek80sUw5xKg+H2 sE+Bteza3k3y8ESdsw0M94j3ZQxob+XybcMlwBQjCDVvcgdB15JD7AO3aYFFb5Momqrk xjmCrekgwtjv70Ud8hDgjLkZ4AW3ocSoIE1M4fMT6Grv2fRIRKnfUwsJZobJCoShExGI iqmkGX6dJYi2QESU+4AtiuWttyObJ10TpEE/gtrgZWI+zeyVvsrzl+MdsdZKs5ONfXm1 F4W6/Ndnroa40dXroSW62XIu66XFnwxJ3ajpoSB89v+dni9p/RFtees18vaFMIV/opHC klAA== 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; bh=BaJ5lbXk0aHDbSY/0wo3ZTQDwBqF9Vwclu0gix6RmYQ=; b=B3Z0K94B2tYmkREs13LADAuRseV2qYtQy2kZgUKjjHoBxeStXORWbdWY/Ia9/kX/YL kmUPunmOnl3ZxGJU9nSfq3TWTt+BVtsI5HRqwTyfuYJlYAyzT9mWN/EekhHnBK+Sf/wx Uh0bdkQ9cXizXn7odVICsirwv2d5W9fND4/1NH8e344kYL8fxsMq04YlzE/LMiiHpUnh XcfIwaqDJeEAzK8D0eQAXhS/vR/Y83t0A0BK8CU5OfuIMubuwJVVqbyzRFyIzYmhf4EH JNcpLY/AxUGpPvHKRMq9AkqfXYEK1NE9+RDd+VnNNRFDq0sXyDmabC4CXvSio6iq3oLH FGkg== X-Gm-Message-State: AOAM533GjZds2QrbGRQmINsPTOttg9tNG2UvAYbs017S9/inYeY2bqs/ G7ULGVL5AvHyHYbgOj53jQ346w== X-Google-Smtp-Source: ABdhPJyPD524zCJIXTunRMo1CRVyygDS/iTkoIgvE0iorP9VLwnb9jXeTxZPDwDOMuH5aWLaAUh/Cw== X-Received: by 2002:a5d:59a9:: with SMTP id p9mr35718769wrr.386.1634554010787; Mon, 18 Oct 2021 03:46:50 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:9df5:c752:530b:345b]) by smtp.gmail.com with ESMTPSA id r4sm15195945wrz.58.2021.10.18.03.46.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Oct 2021 03:46:50 -0700 (PDT) From: Loic Poulain To: kvalo@codeaurora.org Cc: wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, bryan.odonoghue@linaro.org, Loic Poulain Subject: [PATCH 2/2] wcn36xx: Enable hardware scan offload for 5Ghz band Date: Mon, 18 Oct 2021 12:57:58 +0200 Message-Id: <1634554678-7993-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634554678-7993-1-git-send-email-loic.poulain@linaro.org> References: <1634554678-7993-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Until now, offload scanning for 5Ghz channels was considered broken. However it was mostly a driver issue, caused by bad reporting of the beacons/probe-resp bands and frequencies, which has been fixed. We can now allow offload scan for 5GHz band, this reduces the scanning time comparing to software driven scanning. Note that offloaded scan is limited to 48 channels, check for this. Signed-off-by: Loic Poulain Tested-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 263af65..2ac8efa 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -659,19 +659,19 @@ static int wcn36xx_hw_scan(struct ieee80211_hw *hw, struct ieee80211_scan_request *hw_req) { struct wcn36xx *wcn = hw->priv; - int i; if (!get_feat_caps(wcn->fw_feat_caps, SCAN_OFFLOAD)) { /* fallback to mac80211 software scan */ return 1; } - /* For unknown reason, the hardware offloaded scan only works with - * 2.4Ghz channels, fallback to software scan in other cases. + /* Firmware scan offload is limited to 48 channels, fallback to + * software driven scanning otherwise. */ - for (i = 0; i < hw_req->req.n_channels; i++) { - if (hw_req->req.channels[i]->band != NL80211_BAND_2GHZ) - return 1; + if (hw_req->req.n_channels > 48) { + wcn36xx_warn("Offload scan aborted, n_channels=%u", + hw_req->req.n_channels); + return 1; } mutex_lock(&wcn->scan_lock);