From patchwork Tue Jun 26 07:16:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Pubbisetty X-Patchwork-Id: 10488097 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40659602D8 for ; Tue, 26 Jun 2018 07:17:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B31528789 for ; Tue, 26 Jun 2018 07:17:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 202B428795; Tue, 26 Jun 2018 07:17:29 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8242328789 for ; Tue, 26 Jun 2018 07:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752510AbeFZHR2 (ORCPT ); Tue, 26 Jun 2018 03:17:28 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53150 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752409AbeFZHR0 (ORCPT ); Tue, 26 Jun 2018 03:17:26 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1C5BC60AD8; Tue, 26 Jun 2018 07:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529997446; bh=cROn3nW8waOtkjZ66wuKkXZzFPLTfpPOFGBFpf/xbWE=; h=From:To:Cc:Subject:Date:From; b=Z7R+H3B58EXpTILe5qPC8cEr1NYtngZK+BNZAHWUDx2ERrYUVyu5FNzWEXDQ41fZp HPh+JIU63h8efX6RwSXmxoBmdufPgRYIzRDBNbpGgCz9v4q41E3QoD9zrE0u/Xlcsg fVWP1wHr/dHIx9KLChwJAeOO+9dvVL2UBWTKQQjg= Received: from tejas.qca.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: mpubbise@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6BE1860AD8; Tue, 26 Jun 2018 07:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529997444; bh=cROn3nW8waOtkjZ66wuKkXZzFPLTfpPOFGBFpf/xbWE=; h=From:To:Cc:Subject:Date:From; b=fGCdnbIXvFxgJpZzConaT+NlRb6MStjEMKxPIbQSYcAc4TK5MDCFA+NYL+3OX/18S 3vlegaGdPExDEA4TapCJtZuKr8N6zNk4wKXvyb8work8yv3CzoqeUjRExa+hnFGO8U /2KJ3a5IsU2yoEEXOfEx6EM/87/J+QofP/LlfvrU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6BE1860AD8 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=mpubbise@codeaurora.org From: Manikanta Pubbisetty To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Manikanta Pubbisetty Subject: [PATCH] mac80211: add stop/start logic for software TXQs Date: Tue, 26 Jun 2018 12:46:55 +0530 Message-Id: <1529997415-20551-1-git-send-email-mpubbise@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes, it is required to stop the transmissions momentarily and resume it later; stopping the txqs becomes very critical in scenarios where the packet transmission has to be ceased completely. For example, during the hardware restart, during off channel operations, when initiating CSA(upon detecting a radar on the DFS channel), etc. The TX queue stop/start logic in mac80211 works well in stopping the TX when drivers make use of netdev queues, i.e, when Qdiscs in network layer take care of traffic scheduling. Since the devices implementing wake_tx_queue can run without Qdiscs, packets will be handed to mac80211 directly without queueing them in the netdev queues. Also, mac80211 does not invoke any of the netif_stop_*/netif_wake_* APIs if wake_tx_queue is implemented. Since the queues are not stopped in this case, transmissions can continue and this will impact negatively on the operation of the wireless device. For example, During hardware restart, we stop the netdev queues so that packets are not sent to the driver. Since ath10k implements wake_tx_queue, TX queues will not be stopped and packets might reach the hardware while it is restarting; this can make hardware unresponsive and the only possible option for recovery is to reboot the entire system. There is another problem to this, it is observed that the packets were sent on the DFS channel for a prolonged duration after radar detection impacting the channel closing times. We can still invoke netif stop/wake APIs when wake_tx_queue is implemented but this could lead to packet drops in network layer; adding stop/start logic for software TXQs in mac80211 instead makes more sense; the change proposed adds the same in mac80211. Signed-off-by: Manikanta Pubbisetty --- net/mac80211/ieee80211_i.h | 6 +++++ net/mac80211/sta_info.h | 1 + net/mac80211/tx.c | 13 +++++++++- net/mac80211/util.c | 65 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 172aeae..500da15 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -818,6 +818,7 @@ enum txq_info_flags { IEEE80211_TXQ_STOP, IEEE80211_TXQ_AMPDU, IEEE80211_TXQ_NO_AMSDU, + IEEE80211_TXQ_PAUSED, }; /** @@ -1139,6 +1140,11 @@ struct ieee80211_local { /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ spinlock_t queue_stop_reason_lock; + /* pause/resume logic for intermediate software queues, + * applicable when wake_tx_queue is defined. + */ + unsigned long txqs_stopped; + int open_count; int monitors, cooked_mntrs; /* number of interfaces with corresponding FIF_ flags */ diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h index 9a04327..82e5bbb 100644 --- a/net/mac80211/sta_info.h +++ b/net/mac80211/sta_info.h @@ -582,6 +582,7 @@ struct sta_info { u8 reserved_tid; struct cfg80211_chan_def tdls_chandef; + atomic_t txqs_paused; /* keep last! */ struct ieee80211_sta sta; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 5b93bde..9b30ee6 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3467,12 +3467,23 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, struct ieee80211_tx_data tx; ieee80211_tx_result r; struct ieee80211_vif *vif; + struct sta_info *sta; spin_lock_bh(&fq->lock); - if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags)) + if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags) || + test_bit(IEEE80211_TXQ_PAUSED, &txqi->flags)) goto out; + if (local->txqs_stopped) { + set_bit(IEEE80211_TXQ_PAUSED, &txqi->flags); + if (txq->sta) { + sta = container_of(txq->sta, struct sta_info, sta); + atomic_set(&sta->txqs_paused, 1); + } + goto out; + } + /* Make sure fragments stay together. */ skb = __skb_dequeue(&txqi->frags); if (skb) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index c77c843..b9db417 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -273,6 +273,62 @@ void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue) } } +static void ieee80211_wake_txqs(struct ieee80211_local *local) +{ + struct ieee80211_sub_if_data *sdata; + struct sta_info *sta; + struct txq_info *txqi; + int i; + + if (!local->ops->wake_tx_queue) + return; + + rcu_read_lock(); + + list_for_each_entry_rcu(sta, &local->sta_list, list) { + if (!atomic_read(&sta->txqs_paused)) + continue; + + atomic_set(&sta->txqs_paused, 0); + + for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) { + txqi = to_txq_info(sta->sta.txq[i]); + + if (!test_and_clear_bit(IEEE80211_TXQ_PAUSED, + &txqi->flags)) + continue; + + drv_wake_tx_queue(local, txqi); + } + } + + list_for_each_entry_rcu(sdata, &local->interfaces, list) { + struct ieee80211_vif *vif = &sdata->vif; + struct ps_data *ps = NULL; + + /* Software interfaces like AP_VLAN, monitor do not have + * vif specific queues. + */ + if (!sdata->dev || !vif->txq) + continue; + + txqi = to_txq_info(vif->txq); + + if (!test_and_clear_bit(IEEE80211_TXQ_PAUSED, &txqi->flags)) + continue; + + if (sdata->vif.type == NL80211_IFTYPE_AP) + ps = &sdata->bss->ps; + + if (ps && atomic_read(&ps->num_sta_ps)) + continue; + + drv_wake_tx_queue(local, txqi); + } + + rcu_read_unlock(); +} + static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue, enum queue_stop_reason reason, bool refcounted) @@ -298,10 +354,15 @@ static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue, if (local->q_stop_reasons[queue][reason] == 0) __clear_bit(reason, &local->queue_stop_reasons[queue]); + if (local->ops->wake_tx_queue) + __clear_bit(reason, &local->txqs_stopped); + if (local->queue_stop_reasons[queue] != 0) /* someone still has this queue stopped */ return; + ieee80211_wake_txqs(local); + if (skb_queue_empty(&local->pending[queue])) { rcu_read_lock(); ieee80211_propagate_queue_wake(local, queue); @@ -351,8 +412,10 @@ static void __ieee80211_stop_queue(struct ieee80211_hw *hw, int queue, if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue])) return; - if (local->ops->wake_tx_queue) + if (local->ops->wake_tx_queue) { + __set_bit(reason, &local->txqs_stopped); return; + } if (local->hw.queues < IEEE80211_NUM_ACS) n_acs = 1;