From patchwork Thu Jan 21 13:23:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 8081091 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D47579F1CC for ; Thu, 21 Jan 2016 13:22:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED2DF20461 for ; Thu, 21 Jan 2016 13:22:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56F9520445 for ; Thu, 21 Jan 2016 13:22:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965156AbcAUNWD (ORCPT ); Thu, 21 Jan 2016 08:22:03 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:33720 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965064AbcAUNWB (ORCPT ); Thu, 21 Jan 2016 08:22:01 -0500 Received: by mail-lb0-f176.google.com with SMTP id x4so23400640lbm.0 for ; Thu, 21 Jan 2016 05:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uDj3DfYedMOtUu8thfObzGiK0Av5l0j6OGNA527RFZo=; b=QGFWypeFvw8ZJLWvZ59y8hr4jNT30L50AsFUH7P7xHNQjuLI+XUPSa/rhX6Fyp95JR uAOkIhXOHNvuE41pEq9miwrfdmkXwolZ2WvHFai591TTphELwBe1o/Z+hWauOhVA7d2j JaTUVA6aTQGgFUBS5c8EFR+G3j/jQDqMmrgSY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uDj3DfYedMOtUu8thfObzGiK0Av5l0j6OGNA527RFZo=; b=B04bPniqeTC/suH6h5c4URvmJnoZXu2+uT25KsgPeHB+SIrcxOtusSsENSo+sPojeC 6YB1DcIFIpTw63f94kQAI9nFD57zmeb4u9ttFHNMeYdQDxSSvS3Qamdi87URYNcOfLhf Noy+myju2Ddd9lg5/+HnivFEMg+gNkBBHioU3nyBn3MW+oEa/8MM8n50kKLbwhk6maaG DRG4I0IX+uyJ61as4GAt4JPKFNj0lIcDklckh2JPk2XaIhUHKw9oXo7tCU1XlAujzX8h /q9k4WjLbM7fb+lXh1CpNHCjhGYBBKVugEeuxYV97N8G7XOw6pB8va5e0DaSulBF2FzW 8oRQ== X-Gm-Message-State: ALoCoQlnI4h7n/TER0qL6OF+i2MiEv7dHMltKJvKu7x+cT8nmOHFwJPAW+XlMP7F2NfBzBvCC5Ef//HJA+AUsGemljsyKXDq6Yg3yixhsxB20xnDVfn+232kP9phdlSbjdI+4GpvQOu/n4vVRoJZMZygTB7Qupw6ZOfIzCz4gTZtZWeFCq8oCLGT8Axnu4DbwX0UCtgyXL2pqiw/cxEEUJNpDCMGSH1Lhw== X-Received: by 10.112.161.201 with SMTP id xu9mr15437111lbb.35.1453382519727; Thu, 21 Jan 2016 05:21:59 -0800 (PST) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id d18sm195087lfb.1.2016.01.21.05.21.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 05:21:58 -0800 (PST) From: Michal Kazior To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, Michal Kazior Subject: [PATCH 2/2] mac80211: expose txq queue depth and size to drivers Date: Thu, 21 Jan 2016 14:23:08 +0100 Message-Id: <1453382588-27105-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453382588-27105-1-git-send-email-michal.kazior@tieto.com> References: <1453382588-27105-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This will allow drivers to make more educated decisions whether to defer transmission or not. Relying on wake_tx_queue() call count implicitly was not possible because it could be called without queued frame count actually changing on software tx aggregation start/stop code paths. It was also not possible to know how long byte-wise queue was without dequeueing. Signed-off-by: Michal Kazior --- include/net/mac80211.h | 4 ++++ net/mac80211/iface.c | 2 ++ net/mac80211/sta_info.c | 2 ++ net/mac80211/tx.c | 11 ++++++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 566df20dc957..c29ca8be9ac2 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1781,6 +1781,8 @@ struct ieee80211_tx_control { * * @vif: &struct ieee80211_vif pointer from the add_interface callback. * @sta: station table entry, %NULL for per-vif queue + * @qdepth: number of pending frames + * @qsize: number of pending bytes * @tid: the TID for this queue (unused for per-vif queue) * @ac: the AC for this queue * @drv_priv: driver private area, sized by hw->txq_data_size @@ -1791,6 +1793,8 @@ struct ieee80211_tx_control { struct ieee80211_txq { struct ieee80211_vif *vif; struct ieee80211_sta *sta; + int qdepth; + int qsize; u8 tid; u8 ac; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 0451f120746e..dfcb19080eb0 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -979,6 +979,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, spin_lock_bh(&txqi->queue.lock); ieee80211_purge_tx_queue(&local->hw, &txqi->queue); + txqi->txq.qdepth = 0; + txqi->txq.qsize = 0; spin_unlock_bh(&txqi->queue.lock); atomic_set(&sdata->txqs_len[txqi->txq.ac], 0); diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 7e007cf12cb2..4b93a11f4a0d 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -116,6 +116,8 @@ static void __cleanup_single_sta(struct sta_info *sta) ieee80211_purge_tx_queue(&local->hw, &txqi->queue); atomic_sub(n, &sdata->txqs_len[txqi->txq.ac]); + txqi->txq.qdepth = 0; + txqi->txq.qsize = 0; } } diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 3311ce0f3d6c..6f9a0db3824e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1266,7 +1266,13 @@ static void ieee80211_drv_tx(struct ieee80211_local *local, if (atomic_read(&sdata->txqs_len[ac]) >= local->hw.txq_ac_max_pending) netif_stop_subqueue(sdata->dev, ac); - skb_queue_tail(&txqi->queue, skb); + spin_lock_bh(&txqi->queue.lock); + txq->qdepth++; + txq->qsize += skb->len; + + __skb_queue_tail(&txqi->queue, skb); + spin_unlock_bh(&txqi->queue.lock); + drv_wake_tx_queue(local, txqi); return; @@ -1294,6 +1300,9 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw, if (!skb) goto out; + txq->qdepth--; + txq->qsize -= skb->len; + atomic_dec(&sdata->txqs_len[ac]); if (__netif_subqueue_stopped(sdata->dev, ac)) ieee80211_propagate_queue_wake(local, sdata->vif.hw_queue[ac]);