From patchwork Sun Feb 12 13:29:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 9568369 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.web.codeaurora.org (Postfix) with ESMTP id 7BBE9601E7 for ; Sun, 12 Feb 2017 13:30:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6260D28441 for ; Sun, 12 Feb 2017 13:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56BAB28448; Sun, 12 Feb 2017 13:30:17 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 CA4D428441 for ; Sun, 12 Feb 2017 13:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256AbdBLN3o (ORCPT ); Sun, 12 Feb 2017 08:29:44 -0500 Received: from nbd.name ([46.4.11.11]:38155 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751206AbdBLN3n (ORCPT ); Sun, 12 Feb 2017 08:29:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Message-Id:Date:Subject:Cc:To:From; bh=h0TxjURA+ACU1Lvi9kLktUEofHFTF2xIKc9sMSToxSs=; b=itYyhmXl/7UD5LGh6IctfIR30YfV/aoqTVCT4AxQJy1f9BZBGdrPBckasF6pDqGutB4ze1vZUFZbptcIYRCi9u4YrCCve8qpvY9room1ZmxaNejHu+yNPCxzJATFjofOxkiKsLe+1jxf3KESkonIRJ2pKTDG1j9CnXPnOeW2QyY=; Received: by nf-4.local (Postfix, from userid 501) id 19C6418EF501B; Sun, 12 Feb 2017 14:29:32 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: kvalo@codeaurora.org, toke@toke.dk Subject: [PATCH] ath9k: clean up and fix ath_tx_count_airtime Date: Sun, 12 Feb 2017 14:29:31 +0100 Message-Id: <20170212132931.43510-1-nbd@nbd.name> X-Mailer: git-send-email 2.11.0 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 ath_tx_count_airtime is doing a lot of unnecessary work: - Redundant station lookup - Redundant rcu_read_lock/unlock - Useless memcpy of bf->rates - Useless NULL check of bf->bf_mpdu - Redundant lookup of the skb tid Additionally, it tries to look up the mac80211 queue index from the txq, which fails if the frame was delivered via the power save queue. This patch fixes all of these issues by passing down the right set of pointers instead of doing extra work Cc: stable@vger.kernel.org Fixes: 63fefa050477 ("ath9k: Introduce airtime fairness scheduling between stations") Signed-off-by: Felix Fietkau Acked-by: Toke Høiland-Jørgensen --- drivers/net/wireless/ath/ath9k/xmit.c | 52 +++++++++++------------------------ 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 8f9a87915ba9..30efe79e9d89 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -723,51 +723,31 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf) return bf_isampdu(bf) && !(info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE); } -static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_txq *txq, - struct ath_buf *bf, struct ath_tx_status *ts) +static void ath_tx_count_airtime(struct ath_softc *sc, struct ath_node *an, + struct ath_atx_tid *tid, struct ath_buf *bf, + struct ath_tx_status *ts) { - struct ath_node *an; - struct ath_acq *acq = &sc->cur_chan->acq[txq->mac80211_qnum]; - struct sk_buff *skb; - struct ieee80211_hdr *hdr; - struct ieee80211_hw *hw = sc->hw; - struct ieee80211_tx_rate rates[4]; - struct ieee80211_sta *sta; - int i; + struct ath_txq *txq = tid->txq; u32 airtime = 0; - - skb = bf->bf_mpdu; - if(!skb) - return; - - hdr = (struct ieee80211_hdr *)skb->data; - memcpy(rates, bf->rates, sizeof(rates)); - - rcu_read_lock(); - - sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2); - if(!sta) - goto exit; - - - an = (struct ath_node *) sta->drv_priv; + int i; airtime += ts->duration * (ts->ts_longretry + 1); + for(i = 0; i < ts->ts_rateindex; i++) { + int rate_dur = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i); + airtime += rate_dur * bf->rates[i].count; + } - for(i=0; i < ts->ts_rateindex; i++) - airtime += ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, i) * rates[i].count; + if (sc->airtime_flags & AIRTIME_USE_TX) { + int q = txq->mac80211_qnum; + struct ath_acq *acq = &sc->cur_chan->acq[q]; - if (!!(sc->airtime_flags & AIRTIME_USE_TX)) { spin_lock_bh(&acq->lock); - an->airtime_deficit[txq->mac80211_qnum] -= airtime; - if (an->airtime_deficit[txq->mac80211_qnum] <= 0) - __ath_tx_queue_tid(sc, ath_get_skb_tid(sc, an, skb)); + an->airtime_deficit[q] -= airtime; + if (an->airtime_deficit[q] <= 0) + __ath_tx_queue_tid(sc, tid); spin_unlock_bh(&acq->lock); } ath_debug_airtime(sc, an, 0, airtime); - -exit: - rcu_read_unlock(); } static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, @@ -791,13 +771,13 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc, ts->ts_rateindex); - ath_tx_count_airtime(sc, txq, bf, ts); hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data; sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2); if (sta) { struct ath_node *an = (struct ath_node *)sta->drv_priv; tid = ath_get_skb_tid(sc, an, bf->bf_mpdu); + ath_tx_count_airtime(sc, an, tid, bf, ts); if (ts->ts_status & (ATH9K_TXERR_FILT | ATH9K_TXERR_XRETRY)) tid->clear_ps_filter = true; }