From patchwork Sat Oct 23 00:39:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Li X-Patchwork-Id: 12579231 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 56C48C4332F for ; Sat, 23 Oct 2021 00:40:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42F2C60FC4 for ; Sat, 23 Oct 2021 00:40:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232263AbhJWAmf (ORCPT ); Fri, 22 Oct 2021 20:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbhJWAmc (ORCPT ); Fri, 22 Oct 2021 20:42:32 -0400 Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A269C061766 for ; Fri, 22 Oct 2021 17:40:14 -0700 (PDT) Received: by mail-il1-x12a.google.com with SMTP id l7so6042817iln.8 for ; Fri, 22 Oct 2021 17:40:14 -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=RpFO/O8OJtCCTXoNPY6I7vBtlJtuEAebpHNwcVp0mrs=; b=eGRxqCs470PqWufr+LBwbmCqk4jplUIcjZEiiDcmwk7hfArmQOqmBx96+lfQjRUBkT WpFxJwYG0oFHv7Jk5Em6LZ5YClfBy3gxaxY0Mhh//4RpLRXl7pwYsVDL5xFre1LGf1f4 AVV4Z8kjcITfXwgMd/aeO9IXNyydC1L6aND/U= 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=RpFO/O8OJtCCTXoNPY6I7vBtlJtuEAebpHNwcVp0mrs=; b=vm38+KlqV5BOjL4rNvqDzFU6bU5ESiCX5pfa76Sp5vj/jDHcvB1N7DlE3uV/DlixNd /ulFeh+68qYox6na3HZ55kZWBIN/lCkYLiaWXWXFuV/1NsyEyEMqKuvHuF3r/pjQ48Be 4J7IFCYmBnEMAWfxiPgBlGVV1Fgzphe+falQhhb3bAhXi+oUOQb4Vs35MR3wgzvhVX5m 6xydLgkKv0qAZsCSsWRzqzhDpY2xNzu6g8Ul2EmvzN+0Y2mWZbtheW3g2uTH/YO/c8zz bcpYdJE3GEHHPckIBmcSahef228c8qRcAAVeDK3nnvHcHd0hpoJtW1uJ3CuWkkB7uFF7 0ZAw== X-Gm-Message-State: AOAM533CLuRwjJcV/QkpH0e81ZjdcV80L9Ig7y1gPRlicboONUyCFeM4 uYMsTmEhDpWBLz05j4Lu90llvA== X-Google-Smtp-Source: ABdhPJwdXiQmYkDN0aV5a+y49XXFI/iSmA+a2vItLSezpw39bYgk/Le3YtZnTauxjBQ1DbydkOX2uQ== X-Received: by 2002:a92:c56c:: with SMTP id b12mr1870927ilj.45.1634949613566; Fri, 22 Oct 2021 17:40:13 -0700 (PDT) Received: from localhost ([2600:6c50:4d00:cd01::382]) by smtp.gmail.com with ESMTPSA id y6sm4689189iol.11.2021.10.22.17.40.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Oct 2021 17:40:13 -0700 (PDT) From: Benjamin Li To: Kalle Valo Cc: Joseph Gates , Bryan O'Donoghue , Loic Poulain , linux-arm-msm@vger.kernel.org, Benjamin Li , "David S. Miller" , Jakub Kicinski , Eugene Krasnikov , "John W. Linville" , wcn36xx@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] wcn36xx: implement flush op to speed up connected scan Date: Fri, 22 Oct 2021 17:39:47 -0700 Message-Id: <20211023003949.3082900-3-benl@squareup.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211023003949.3082900-1-benl@squareup.com> References: <20211023003949.3082900-1-benl@squareup.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Without ieee80211_ops->flush implemented to empty HW queues, mac80211 will do a 100ms dead wait after stopping SW queues, before leaving the operating channel to resume a software connected scan[1]. (see ieee80211_scan_state_resume) This wait is correctly included in the calculation for whether or not we've exceeded max off-channel time, as it occurs after sending the null frame with PS bit set. Thus, with 125 ms max off-channel time we only have 25 ms of scan time, which technically isn't even enough to scan one channel (although mac80211 always scans at least one channel per off- channel window). Moreover, for passive probes we end up spending at least 100 ms + 111 ms (IEEE80211_PASSIVE_CHANNEL_TIME) "off-channel"[2], which exceeds the listen interval of 200 ms that we provide in our association request frame. That's technically out-of-spec. [1]: Until recently, wcn36xx performed software (rather than FW-offloaded) scanning when 5GHz channels are requested. This apparent limitation is now resolved -- see commit 1395f8a6a4d5 ("wcn36xx: Enable hardware scan offload for 5Ghz band"). [2]: in quotes because about 100 ms of it is still on-channel but with PS set Signed-off-by: Benjamin Li --- drivers/net/wireless/ath/wcn36xx/dxe.c | 47 +++++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/dxe.h | 1 + drivers/net/wireless/ath/wcn36xx/main.c | 11 ++++++ 3 files changed, 59 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c index 8e1dbfda65386..c4e9e939d7d6d 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.c +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c @@ -831,6 +831,53 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn, return ret; } +static bool _wcn36xx_dxe_tx_channel_is_empty(struct wcn36xx_dxe_ch *ch) +{ + int flags; + struct wcn36xx_dxe_ctl *ctl_bd_start, *ctl_skb_start; + struct wcn36xx_dxe_ctl *ctl_bd, *ctl_skb; + bool ret = true; + + spin_lock_irqsave(&ch->lock, flags); + + /* Loop through ring buffer looking for nonempty entries. */ + ctl_bd_start = ch->head_blk_ctl; + ctl_bd = ctl_bd_start; + ctl_skb_start = ctl_bd_start->next; + ctl_skb = ctl_skb_start; + do { + if (ctl_skb->skb) { + ret = false; + goto unlock; + } + ctl_bd = ctl_skb->next; + ctl_skb = ctl_bd->next; + } while (ctl_skb != ctl_skb_start); + +unlock: + spin_unlock_irqrestore(&ch->lock, flags); + return ret; +} + +int wcn36xx_dxe_tx_flush(struct wcn36xx *wcn) +{ + int i = 0; + + /* Called with mac80211 queues stopped. Wait for empty HW queues. */ + do { + if (_wcn36xx_dxe_tx_channel_is_empty(&wcn->dxe_tx_l_ch) && + _wcn36xx_dxe_tx_channel_is_empty(&wcn->dxe_tx_h_ch)) { + return 0; + } + /* This ieee80211_ops callback is specifically allowed to + * sleep. + */ + usleep_range(1000, 1100); + } while (++i < 100); + + return -EBUSY; +} + int wcn36xx_dxe_init(struct wcn36xx *wcn) { int reg_data = 0, ret; diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.h b/drivers/net/wireless/ath/wcn36xx/dxe.h index 31b81b7547a32..26a31edf52e99 100644 --- a/drivers/net/wireless/ath/wcn36xx/dxe.h +++ b/drivers/net/wireless/ath/wcn36xx/dxe.h @@ -466,5 +466,6 @@ int wcn36xx_dxe_tx_frame(struct wcn36xx *wcn, struct wcn36xx_tx_bd *bd, struct sk_buff *skb, bool is_low); +int wcn36xx_dxe_tx_flush(struct wcn36xx *wcn); void wcn36xx_dxe_tx_ack_ind(struct wcn36xx *wcn, u32 status); #endif /* _DXE_H_ */ diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index 81ac86eeaf60b..24bfb30a30f31 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1275,6 +1275,16 @@ static void wcn36xx_ipv6_addr_change(struct ieee80211_hw *hw, } #endif +static void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 queues, bool drop) +{ + struct wcn36xx *wcn = hw->priv; + + if (wcn36xx_dxe_tx_flush(wcn)) { + wcn36xx_err("Failed to flush hardware tx queues\n"); + } +} + static const struct ieee80211_ops wcn36xx_ops = { .start = wcn36xx_start, .stop = wcn36xx_stop, @@ -1302,6 +1312,7 @@ static const struct ieee80211_ops wcn36xx_ops = { #if IS_ENABLED(CONFIG_IPV6) .ipv6_addr_change = wcn36xx_ipv6_addr_change, #endif + .flush = wcn36xx_flush, CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd) };