From patchwork Thu Jun 27 00:35:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriram R X-Patchwork-Id: 11018825 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6C5E1575 for ; Thu, 27 Jun 2019 05:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B148F209CE for ; Thu, 27 Jun 2019 05:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1A0B28708; Thu, 27 Jun 2019 05:35:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D672209CE for ; Thu, 27 Jun 2019 05:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=M2l0mWMpubNqpmESqc4GvvnWBu2TUD0P1FNL+xONSfs=; b=Bo0 jSGs6kUe+4AqIHqVAUbDKPMi2Trg9ZCXlKBwTc4XDqrXtxDd4o7sXnVYgFQhWxO5c+lJoRxul9Ymu yQYbLP2Kp02OSiFNGN62LYEFVIkyDTxv0oe/dVWMpPnZflUD0qsx/6SvRscs1mJhX4DxdZ+9fhi+N i/7AIMRMI/yzJioCrvJPUbfWptOK8MbQrJMZ++ixdERF3yoNpRjXBkBv+RLxbkQeGJOFi3QX+pMfK 1/D/cJjW5pRRti1IZcu1W9Zuwk2qnsK09x6qBiITfUAgQgsbjZ0N4oBLsQSLGNlo9hRSnOx74u1LD MR+RMw7dSeB4bggi5oLMWij50drljIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hgN4R-0007eM-1l; Thu, 27 Jun 2019 05:35:43 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgMrq-0007bR-3j for ath11k@bombadil.infradead.org; Thu, 27 Jun 2019 05:22:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=S+fLm8NiAmgqLlVyvqMXNYz3NeaW2akkh+7pGd0N0Wk=; b=HDyZDsTB1TrsC9dGeYTyhLZLx vKbocvF6hwjkpJg9qexKLEhAXUR8FyCjcKCuC1qaUkt6qhq4Wtusm7m1NCO7wwYYYFObP/KCdbcyH yoIJxwOvwsXn0dphU9EGaS7kvJtcJUrWdbcT4KvPV4v3jm13utc9OxZxhldYZ/hup8JFuPSSkGrAb +PJm1xGfHns/wMB8ez3JnzwsyPu4kJHWCUo403nRfHV5qcS5JLE4rygxnpZolXXVnXmP9q1a25EE5 SbqgPZqLrCJ12d8KWWHbhXdFPgK3RnNORiXS7auArtJmSbX3eQtkY9j9h+7dWqIuYBTmuT2BxbgCQ b9o5clUGQ==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hgIOa-0002W4-8f for ath11k@lists.infradead.org; Thu, 27 Jun 2019 00:36:14 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 44FAF60909; Thu, 27 Jun 2019 00:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561595766; bh=OluC7wZJK9sIX0VXHfN5BAwx7IenG7iAc0dKW4dMNss=; h=From:To:Cc:Subject:Date:From; b=gNgNVBeCLZqCH9WgKlLVb3nJYGpqSJ8an1xYz9xpytkFez8s5ICw9aYB/6yMvIv9y 9CprNcjjxzYnRZIEYBJfMvfzmyzC8qbaYRL7+PlShXa5K0YzbDLIp3F/p4SQrwSNYG 5VSU9db4I6k26L5j4TZCrfdwvqXaozYMBIRjgeoQ= Received: from checstp253621-lin.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: srirrama@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 839286021C; Thu, 27 Jun 2019 00:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561595765; bh=OluC7wZJK9sIX0VXHfN5BAwx7IenG7iAc0dKW4dMNss=; h=From:To:Cc:Subject:Date:From; b=i+VCcaYWLqQTxpUymTvlUQfLlnDk6mFsWqKSbXZveZ7axO36L8hLzjplWtXP+Rd8y i2ZWsO2RfGWtxp266MTzeXtArfC2JAfppijVbUXT4V3YNonFxvZRm1F04SeLLRDeSY sta2RTIgNWwywyR5pEb7rgdnUOCQ2SoryI39kEOM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 839286021C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=srirrama@codeaurora.org From: Sriram R To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: Add probe response throttling logic Date: Thu, 27 Jun 2019 06:05:53 +0530 Message-Id: <1561595753-11351-1-git-send-email-srirrama@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190627_013612_635344_C82F2E8A X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sriram R MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Drop probe response packets when the pending management tx count has reached a certain threshold, so as to prioritize other mgmt packets like auth and assoc to be sent on time for establishing successful connections. This might be required in dense networks, multi-vap scenarios or due to emulated probe requests (DoS attack), which could lead to association failures due to failure to send auth/assoc packets as high probe response traffic occupies the limited target mgmt transmit queue. Currently the threshold is set to 3/4th of the target management tx queue. Signed-off-by: Sriram R --- drivers/net/wireless/ath/ath11k/core.h | 6 ++++++ drivers/net/wireless/ath/ath11k/mac.c | 23 +++++++++++++++++++++-- drivers/net/wireless/ath/ath11k/wmi.c | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index af5c66f..9023367 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -25,6 +25,11 @@ #define ATH11K_TX_MGMT_NUM_PENDING_MAX 512 +#define ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI 64 + +/* Pending management packets threshold for dropping probe responses */ +#define ATH11K_PRB_RSP_DROP_THRESHOLD ((ATH11K_TX_MGMT_TARGET_MAX_SUPPORT_WMI * 3) / 4) + #define ATH11K_INVALID_HW_MAC_ID 0xFF enum ath11k_supported_bw { @@ -485,6 +490,7 @@ struct ath11k { struct idr txmgmt_idr; /* protects txmgmt_idr data */ spinlock_t txmgmt_idr_lock; + atomic_t num_pending_mgmt_tx; /* cycle count is reported twice for each visited channel during scan. * access protected by data_lock diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 1a4a333..b8035ec 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3392,17 +3392,32 @@ static void ath11k_mgmt_over_wmi_tx_work(struct work_struct *work) ath11k_warn(ar->ab, "failed to transmit management frame %d\n", ret); ieee80211_free_txskb(ar->hw, skb); + } else { + atomic_inc(&ar->num_pending_mgmt_tx); } } } -static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb) +static int ath11k_mac_mgmt_tx(struct ath11k *ar, struct sk_buff *skb, + bool is_prb_rsp) { struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue; if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) return -ESHUTDOWN; + /* Drop probe response packets when the pending management tx + * count has reached a certain threshold, so as to prioritize + * other mgmt packets like auth and assoc to be sent on time + * for establishing successful connections. + */ + if (is_prb_rsp && + atomic_read(&ar->num_pending_mgmt_tx) > ATH11K_PRB_RSP_DROP_THRESHOLD) { + ath11k_warn(ar->ab, + "dropping probe response as pending queue is almost full\n"); + return -ENOSPC; + } + if (skb_queue_len(q) == ATH11K_TX_MGMT_NUM_PENDING_MAX) { ath11k_warn(ar->ab, "mgmt tx queue is full\n"); return -ENOSPC; @@ -3423,10 +3438,12 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif = info->control.vif; struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + bool is_prb_rsp; int ret; if (ieee80211_is_mgmt(hdr->frame_control)) { - ret = ath11k_mac_mgmt_tx(ar, skb); + is_prb_rsp = ieee80211_is_probe_resp(hdr->frame_control); + ret = ath11k_mac_mgmt_tx(ar, skb, is_prb_rsp); if (ret) { ath11k_warn(ar->ab, "failed to queue management frame %d\n", ret); @@ -3601,6 +3618,8 @@ static void ath11k_mac_op_stop(struct ieee80211_hw *hw) rcu_assign_pointer(ar->ab->pdevs_active[ar->pdev_idx], NULL); synchronize_rcu(); + + atomic_set(&ar->num_pending_mgmt_tx, 0); } static void diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 46a3e0f..6dad499 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -3366,6 +3366,9 @@ static int wmi_process_mgmt_tx_comp(struct ath11k *ar, u32 desc_id, ieee80211_tx_status_irqsafe(ar->hw, msdu); + WARN_ON(atomic_read(&ar->num_pending_mgmt_tx) == 0); + atomic_dec(&ar->num_pending_mgmt_tx); + return 0; }