All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Kazior <michal.kazior@tieto.com>
To: ath10k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, Michal Kazior <michal.kazior@tieto.com>
Subject: [PATCH 08/13] ath10k: implement updating shared htt txq state
Date: Thu, 21 Jan 2016 14:46:41 +0100	[thread overview]
Message-ID: <1453384006-31907-9-git-send-email-michal.kazior@tieto.com> (raw)
In-Reply-To: <1453384006-31907-1-git-send-email-michal.kazior@tieto.com>

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 <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/htt.h    |   3 +
 drivers/net/wireless/ath/ath10k/htt_tx.c | 100 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/mac.c    |   9 ++-
 3 files changed, 111 insertions(+), 1 deletion(-)

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..5ef0a1b3773c 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -22,6 +22,106 @@
 #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;
+	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;
+	count = ath10k_htt_tx_txq_calc_size(txq->qsize);
+
+	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 111baa104f8e..d9566ba70af3 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3695,12 +3695,19 @@ static void ath10k_mac_tx_push(struct ieee80211_hw *hw,
 				    txq->vif->addr, ret);
 		return;
 	}
+
+	ath10k_htt_tx_txq_update(hw, txq);
 }
 
 static void ath10k_mac_tx_wake(struct ieee80211_hw *hw,
 			       struct ieee80211_txq *txq)
 {
-	WARN_ON(1); /* TBD */
+	/* TODO: Possible optimization is to defer the updates until a certain
+	 * time/quantity threshold is reached to avoid hammering DMA and
+	 * flushing d-caches for each submitted msdu.
+	 */
+
+	ath10k_htt_tx_txq_update(hw, txq);
 }
 
 /************/
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Michal Kazior <michal.kazior@tieto.com>
To: ath10k@lists.infradead.org
Cc: linux-wireless@vger.kernel.org, Michal Kazior <michal.kazior@tieto.com>
Subject: [PATCH 08/13] ath10k: implement updating shared htt txq state
Date: Thu, 21 Jan 2016 14:46:41 +0100	[thread overview]
Message-ID: <1453384006-31907-9-git-send-email-michal.kazior@tieto.com> (raw)
In-Reply-To: <1453384006-31907-1-git-send-email-michal.kazior@tieto.com>

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 <michal.kazior@tieto.com>
---
 drivers/net/wireless/ath/ath10k/htt.h    |   3 +
 drivers/net/wireless/ath/ath10k/htt_tx.c | 100 +++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/mac.c    |   9 ++-
 3 files changed, 111 insertions(+), 1 deletion(-)

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..5ef0a1b3773c 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -22,6 +22,106 @@
 #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;
+	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;
+	count = ath10k_htt_tx_txq_calc_size(txq->qsize);
+
+	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 111baa104f8e..d9566ba70af3 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3695,12 +3695,19 @@ static void ath10k_mac_tx_push(struct ieee80211_hw *hw,
 				    txq->vif->addr, ret);
 		return;
 	}
+
+	ath10k_htt_tx_txq_update(hw, txq);
 }
 
 static void ath10k_mac_tx_wake(struct ieee80211_hw *hw,
 			       struct ieee80211_txq *txq)
 {
-	WARN_ON(1); /* TBD */
+	/* TODO: Possible optimization is to defer the updates until a certain
+	 * time/quantity threshold is reached to avoid hammering DMA and
+	 * flushing d-caches for each submitted msdu.
+	 */
+
+	ath10k_htt_tx_txq_update(hw, txq);
 }
 
 /************/
-- 
2.1.4


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

  parent reply	other threads:[~2016-01-21 13:45 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 13:46 [PATCH 00/13] ath10k: implement push-pull tx model Michal Kazior
2016-01-21 13:46 ` Michal Kazior
2016-01-21 13:46 ` [PATCH 01/13] ath10k: refactor tx code Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 02/13] ath10k: unify txpath decision Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 03/13] ath10k: refactor tx pending management Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 04/13] ath10k: maintain peer_id for each sta and vif Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 05/13] ath10k: add fast peer_map lookup Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 06/13] ath10k: add new htt message generation/parsing logic Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 07/13] ath10k: implement wake_tx_queue Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` Michal Kazior [this message]
2016-01-21 13:46   ` [PATCH 08/13] ath10k: implement updating shared htt txq state Michal Kazior
2016-01-21 13:46 ` [PATCH 09/13] ath10k: add txq placeholder Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 10/13] ath10k: implement flushing of pending frames in txqs Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-03-04  9:17   ` Valo, Kalle
2016-03-04  9:17     ` Valo, Kalle
2016-03-04  9:52     ` Michal Kazior
2016-03-04  9:52       ` Michal Kazior
2016-03-04 15:37       ` Valo, Kalle
2016-03-04 15:37         ` Valo, Kalle
2016-01-21 13:46 ` [PATCH 11/13] ath10k: store txq in skb_cb Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 12/13] ath10k: keep track of queue depth per txq Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 13:46 ` [PATCH 13/13] ath10k: implement push-pull tx Michal Kazior
2016-01-21 13:46   ` Michal Kazior
2016-01-21 17:40   ` Peter Oh
2016-01-21 17:40     ` Peter Oh
2016-01-22  7:47     ` Michal Kazior
2016-01-22  7:47       ` Michal Kazior
2016-01-26 10:28       ` Michal Kazior
2016-01-26 10:28         ` Michal Kazior
2016-01-26 19:03         ` Peter Oh
2016-01-26 19:03           ` Peter Oh
2016-01-28  8:36     ` Kalle Valo
2016-01-28  8:36       ` Kalle Valo
2016-01-22  0:43 ` [PATCH 00/13] ath10k: implement push-pull tx model Ben Greear
2016-01-22  0:43   ` Ben Greear
2016-03-01 10:32 ` [PATCH v2 00/11] " Michal Kazior
2016-03-01 10:32   ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 01/11] ath10k: refactor tx code Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 02/11] ath10k: unify txpath decision Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 03/11] ath10k: refactor tx pending management Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 04/11] ath10k: maintain peer_id for each sta and vif Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 05/11] ath10k: add fast peer_map lookup Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 06/11] ath10k: add new htt message generation/parsing logic Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 07/11] ath10k: implement wake_tx_queue Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-06 14:27     ` Valo, Kalle
2016-03-06 14:27       ` Valo, Kalle
2016-03-07  6:04       ` Michal Kazior
2016-03-07  6:04         ` Michal Kazior
2016-03-07  9:36         ` Valo, Kalle
2016-03-07  9:36           ` Valo, Kalle
2016-03-01 10:32   ` [PATCH v2 08/11] ath10k: implement updating shared htt txq state Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 09/11] ath10k: store txq in skb_cb Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 10/11] ath10k: keep track of queue depth per txq Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-01 10:32   ` [PATCH v2 11/11] ath10k: implement push-pull tx Michal Kazior
2016-03-01 10:32     ` Michal Kazior
2016-03-06 14:18   ` [PATCH v2 00/11] ath10k: implement push-pull tx model Valo, Kalle
2016-03-06 14:18     ` Valo, Kalle
2016-03-07  6:13     ` Michal Kazior
2016-03-07  6:13       ` Michal Kazior
2016-03-07  9:48   ` Valo, Kalle
2016-03-07  9:48     ` Valo, Kalle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453384006-31907-9-git-send-email-michal.kazior@tieto.com \
    --to=michal.kazior@tieto.com \
    --cc=ath10k@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.