From patchwork Tue Mar 1 10:32:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 8464091 Return-Path: X-Original-To: patchwork-ath10k@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 9394A9F372 for ; Tue, 1 Mar 2016 10:32:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 879FE201BC for ; Tue, 1 Mar 2016 10:32:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B4C42012D for ; Tue, 1 Mar 2016 10:32:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aahbn-0000pK-25; Tue, 01 Mar 2016 10:32:51 +0000 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aahbc-0000Sr-SC for ath10k@lists.infradead.org; Tue, 01 Mar 2016 10:32:45 +0000 Received: by mail-lf0-x232.google.com with SMTP id j78so110093672lfb.1 for ; Tue, 01 Mar 2016 02:32:20 -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=BhAjYt0zYO6ZP6Fd37SxRnmtR/i9+9+dpHaVo8i/7Qo=; b=cx0Vyh3Ee+9qVa6v9Y8V4dc6xFwip0hhX17E1Layl5X+CVc2vz38tNEnxb1BXFs784 qHNxWRe5E9WG4w+86uccB90vtTKoxQfMFB5qeIwyQTRrAl/F6+LwoAzL2uQIuUIg7wmO JucQFnB7kMGSYIb0fVqw6VzukRuvjwNcBrOl0= 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=BhAjYt0zYO6ZP6Fd37SxRnmtR/i9+9+dpHaVo8i/7Qo=; b=OdBEtqc7ozeCXVicEKOb6+2Qj/EeZFoxm9Ia1VgVLw3HD85qTEfZgB8v41o6v3IG3z 83gxO7xgmno8BZfwmIsb/3PVO7L3JHcG8fRL+/ehcJuA+2fI58Lkv0L3Y1GWT2C7Au2E ol5vRgcyBAmK6a2v6m0LUfON/goQnWBKiNFY08GPOx4dhUH5rgGppMaCq4xKcffocjSJ MjRcozuIhDoWkJ4PiCjU1ht+UKuKfvwiapOn660dKcaCJlkjnllxz9GFzC/V6N5DRScS BOVrZbpRylZ5BiOITjt4p74J+XHL3YwWwRSdA5vhqjqHz5tNrbbpImxE4stHPT+46rmW 7IXw== X-Gm-Message-State: AD7BkJLj7segHVoGLB+lAIhWKrdFw/WZdpIFn42N2q5Aq23NRZQUc/X+A/xVUlfG6g/7A4qtYz4u3/1S9sDPMiZubCXyn9nBP4Y6hWVz/OMs8kSXokdtCjIIR0qSFf7WUOzKCkM0q5oSqk+gz1L4SsBhq4d5/O0a92TXV+IZpCfGlBvLHNqJTgtvmeaa7BmrqQ== X-Received: by 10.25.143.141 with SMTP id r135mr8188422lfd.100.1456828339345; Tue, 01 Mar 2016 02:32:19 -0800 (PST) Received: from localhost.localdomain ([91.198.246.10]) by smtp.gmail.com with ESMTPSA id i2sm4644857lfd.43.2016.03.01.02.32.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 02:32:18 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Subject: [PATCH v2 08/11] ath10k: implement updating shared htt txq state Date: Tue, 1 Mar 2016 11:32:53 +0100 Message-Id: <1456828376-2795-9-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456828376-2795-1-git-send-email-michal.kazior@tieto.com> References: <1453384006-31907-1-git-send-email-michal.kazior@tieto.com> <1456828376-2795-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160301_023241_331240_3D137979 X-CRM114-Status: GOOD ( 14.76 ) X-Spam-Score: -2.7 (--) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org, Michal Kazior MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 Firmware 10.4.3 onwards can support a pull-push Tx model where it shares a Tx queue state with the host. The host updates the DMA region it pointed to during HTT setup whenever number of software queued from (on host) changes. Based on this information firmware issues fetch requests to the host telling the host how many frames from a list of given stations/tids should be submitted to the firmware. The code won't be called because not all appropriate HTT events are processed yet. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/htt.h | 3 + drivers/net/wireless/ath/ath10k/htt_tx.c | 104 +++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/mac.c | 3 + 3 files changed, 110 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index 65dcd22f31df..b1e40f44e76b 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h @@ -1667,6 +1667,7 @@ struct ath10k_htt { } txbuf; struct { + bool enabled; struct htt_q_state *vaddr; dma_addr_t paddr; u16 num_peers; @@ -1758,6 +1759,8 @@ int ath10k_htt_tx_fetch_resp(struct ath10k *ar, struct htt_tx_fetch_record *records, size_t num_records); +void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw, + struct ieee80211_txq *txq); void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt, bool is_mgmt); int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt, diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c index 225f0561b3fd..6643be8692b5 100644 --- a/drivers/net/wireless/ath/ath10k/htt_tx.c +++ b/drivers/net/wireless/ath/ath10k/htt_tx.c @@ -22,6 +22,110 @@ #include "txrx.h" #include "debug.h" +static u8 ath10k_htt_tx_txq_calc_size(size_t count) +{ + int exp; + int factor; + + exp = 0; + factor = count >> 7; + + while (factor >= 64 && exp < 4) { + factor >>= 3; + exp++; + } + + if (exp == 4) + return 0xff; + + if (count > 0) + factor = max(1, factor); + + return SM(exp, HTT_TX_Q_STATE_ENTRY_EXP) | + SM(factor, HTT_TX_Q_STATE_ENTRY_FACTOR); +} + +static void __ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw, + struct ieee80211_txq *txq) +{ + struct ath10k *ar = hw->priv; + struct ath10k_sta *arsta = (void *)txq->sta->drv_priv; + struct ath10k_vif *arvif = (void *)txq->vif->drv_priv; + unsigned long frame_cnt; + unsigned long byte_cnt; + int idx; + u32 bit; + u16 peer_id; + u8 tid; + u8 count; + + lockdep_assert_held(&ar->htt.tx_lock); + + if (!ar->htt.tx_q_state.enabled) + return; + + if (txq->sta) + peer_id = arsta->peer_id; + else + peer_id = arvif->peer_id; + + tid = txq->tid; + bit = BIT(peer_id % 32); + idx = peer_id / 32; + + ieee80211_txq_get_depth(txq, &frame_cnt, &byte_cnt); + count = ath10k_htt_tx_txq_calc_size(byte_cnt); + + if (unlikely(peer_id >= ar->htt.tx_q_state.num_peers) || + unlikely(tid >= ar->htt.tx_q_state.num_tids)) { + ath10k_warn(ar, "refusing to update txq for peer_id %hu tid %hhu due to out of bounds\n", + peer_id, tid); + return; + } + + ar->htt.tx_q_state.vaddr->count[tid][peer_id] = count; + ar->htt.tx_q_state.vaddr->map[tid][idx] &= ~bit; + ar->htt.tx_q_state.vaddr->map[tid][idx] |= count ? bit : 0; + + ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx txq state update peer_id %hu tid %hhu count %hhu\n", + peer_id, tid, count); +} + +static void __ath10k_htt_tx_txq_sync(struct ath10k *ar) +{ + u32 seq; + size_t size; + + lockdep_assert_held(&ar->htt.tx_lock); + + if (!ar->htt.tx_q_state.enabled) + return; + + seq = le32_to_cpu(ar->htt.tx_q_state.vaddr->seq); + seq++; + ar->htt.tx_q_state.vaddr->seq = cpu_to_le32(seq); + + ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx txq state update commit seq %u\n", + seq); + + size = sizeof(*ar->htt.tx_q_state.vaddr); + dma_sync_single_for_device(ar->dev, + ar->htt.tx_q_state.paddr, + size, + DMA_TO_DEVICE); +} + +void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw, + struct ieee80211_txq *txq) +{ + struct ath10k *ar = hw->priv; + + spin_lock_bh(&ar->htt.tx_lock); + __ath10k_htt_tx_txq_recalc(hw, txq); + __ath10k_htt_tx_txq_sync(ar); + spin_unlock_bh(&ar->htt.tx_lock); +} + void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt, bool is_mgmt) { diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 74a42e3465e4..900c64b65b43 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -3725,6 +3725,7 @@ void ath10k_mac_tx_push_pending(struct ath10k *ar) } list_del_init(&artxq->list); + ath10k_htt_tx_txq_update(hw, txq); if (artxq == last || (ret < 0 && ret != -ENOENT)) { if (ret != -ENOENT) @@ -3967,6 +3968,8 @@ static void ath10k_mac_op_wake_tx_queue(struct ieee80211_hw *hw, tasklet_schedule(&ar->htt.txrx_compl_task); } + + ath10k_htt_tx_txq_update(hw, txq); } /* Must not be called with conf_mutex held as workers can use that also. */