Skip to contentSkip to conversation

ath10k: kill off htt_tx_info wrapper

RFC New Michal Kazior 2 participants 8 messages Apr 17, 2013 – Apr 23, 2013 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

cover ath10k: kill off htt_tx_info wrapper

This patchset merges the htt_tx_info into
ath10k_skb_cb. This depends upon my 'htt tx
cleanup' patchset.

Michal Kazior (2):
ath10k: simplify txi lifespan
ath10k: merge htt_tx_info into ath10k_skb_cb

 drivers/net/wireless/ath/ath10k/core.h   |    7 +-
 drivers/net/wireless/ath/ath10k/htt.h    |   31 +---
 drivers/net/wireless/ath/ath10k/htt_tx.c |  263 ++++++++++++------------------
 drivers/net/wireless/ath/ath10k/mac.c    |   13 +-
 drivers/net/wireless/ath/ath10k/txrx.c   |   65 +++++---
 drivers/net/wireless/ath/ath10k/txrx.h   |    1 +
 6 files changed, 170 insertions(+), 210 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

RFC 1/2 ath10k: simplify txi lifespan

Up until now we were using two booleans to keep track of htt and htc tx completions. These can come in no specific order.

Keep in mind that it was safe to access those without any locks since tx completion processing is done one endpoint at a time (that's the current PCI backend implementation).

The new approach uses refcount. Since we need 2 completions we setup refcount=2 for mgmt and data tx. This also depends on the tx completion behaviour.

If the PCI tx completion scheme ever changes we'll need locking to synchronize tx completions for htt.

---
 drivers/net/wireless/ath/ath10k/core.h   |    5 ++-
 drivers/net/wireless/ath/ath10k/htt.h    |    2 -
 drivers/net/wireless/ath/ath10k/htt_tx.c |   60 ++++++------------------------
 drivers/net/wireless/ath/ath10k/txrx.c   |   41 +++++++++++++-------
 drivers/net/wireless/ath/ath10k/txrx.h   |    1 +
 5 files changed, 45 insertions(+), 64 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +4 -1
index 1aef940..0c3cfe4 100644
@@ -59,13 +59,16 @@ struct ath10k_skb_cb {
 		u16 msdu_id;
 		bool is_offchan;
 		bool is_conf;
+		bool discard;
+		bool no_ack;
+		u8 refcount;
 	} __packed htt;
 
 	struct {
 		u8 credits_used;
 	} __packed htc;
 
-	/* 24 bytes left on 64bit arch */
+	/* 21 bytes left on 64bit arch */
 } __packed;
 
 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/htt.h +0 -2
index e98f079..8f85a42 100644
@@ -1115,8 +1115,6 @@ struct htt_tx_info {
 	u16 msdu_id;
 
 	atomic_t is_used;
-	bool htc_tx_completed;
-	bool htt_tx_completed;
 
 	struct sk_buff *txdesc;
 	struct sk_buff *txfrag; /* not used for mgmt tx */
drivers/net/wireless/ath/ath10k/htt_tx.c +12 -48

106 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.c +28 -13

72 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.h +1 -0
index c80a472..7a1bbfe 100644
@@ -19,6 +19,7 @@
 
 #include "htt.h"
 
+void ath10k_txrx_tx_unref(struct htt_struct *htt, struct htt_tx_info *txi);
 void ath10k_txrx_tx_completed(struct htt_struct *htt,
 			      const struct htt_tx_done *tx_done);
 void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
Signature · 1 line
1.7.9.5
#2 lore raw

RFC 2/2 ath10k: merge htt_tx_info into ath10k_skb_cb

In reply to Michal Kazior

This eliminates the wrapper structure htt_tx_info.

---
 drivers/net/wireless/ath/ath10k/core.h   |    4 +-
 drivers/net/wireless/ath/ath10k/htt.h    |   29 ++---
 drivers/net/wireless/ath/ath10k/htt_tx.c |  205 ++++++++++++++----------------
 drivers/net/wireless/ath/ath10k/mac.c    |   13 +-
 drivers/net/wireless/ath/ath10k/txrx.c   |   52 ++++----
 drivers/net/wireless/ath/ath10k/txrx.h   |    2 +-
 6 files changed, 142 insertions(+), 163 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +3 -1
index 0c3cfe4..e689212 100644
@@ -62,13 +62,15 @@ struct ath10k_skb_cb {
 		bool discard;
 		bool no_ack;
 		u8 refcount;
+		struct sk_buff *txfrag;
+		struct sk_buff *msdu;
 	} __packed htt;
 
 	struct {
 		u8 credits_used;
 	} __packed htc;
 
-	/* 21 bytes left on 64bit arch */
+	/* 5 bytes left on 64bit arch */
 } __packed;
 
 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/htt.h +8 -21
index 8f85a42..bfb9c23 100644
@@ -1109,18 +1109,6 @@ struct htt_rx_info {
 	bool fcs_err;
 };
 
-struct htt_tx_info {
-	struct htt_struct *htt;
-
-	u16 msdu_id;
-
-	atomic_t is_used;
-
-	struct sk_buff *txdesc;
-	struct sk_buff *txfrag; /* not used for mgmt tx */
-	struct sk_buff *msdu;
-};
-
 struct htt_struct {
 	struct ath10k *ar;
 
@@ -1206,9 +1194,10 @@ struct htt_struct {
 		int htc_err_cnt;
 	} stats;
 
-#define HTT_TX_INFO_POOL_SIZE 512 /* FIXME: find proper value? */
-	struct htt_tx_info txi_pool[HTT_TX_INFO_POOL_SIZE];
-	atomic_t num_used_txi;
+#define HTT_MAX_NUM_PENDING_TX 512 /* FIXME: find proper value? */
+	spinlock_t tx_lock;
+	struct sk_buff *pending_tx[HTT_MAX_NUM_PENDING_TX];
+	DECLARE_BITMAP(used_msdu_ids, HTT_MAX_NUM_PENDING_TX);
 	wait_queue_head_t empty_tx_wq;
 
 	/* set if host-fw communication goes haywire
@@ -1259,7 +1248,7 @@ struct htt_rx_desc {
  * changing conditions.
  * Hence, this queue depth threshold spec is mostly just a formality.
  */
-#define HTT_MAX_SEND_QUEUE_DEPTH (HTT_TX_INFO_POOL_SIZE)
+#define HTT_MAX_SEND_QUEUE_DEPTH (HTT_MAX_NUM_PENDING_TX)
 
 /*
  * FIX THIS
@@ -1292,11 +1281,9 @@ void ath10k_htt_t2h_msg_handler(void *context, struct sk_buff *skb);
 int ath10k_htt_h2t_ver_req_msg(struct htt_struct *htt);
 int ath10k_htt_send_rx_ring_cfg_ll(struct htt_struct *htt);
 
-struct htt_tx_info *ath10k_htt_tx_info_alloc(struct htt_struct *htt);
-void ath10k_htt_tx_info_free(struct htt_struct *htt, struct htt_tx_info *pkt);
-void ath10k_htt_tx_info_unref(struct htt_struct *htt, struct htt_tx_info *pkt,
-		       struct sk_buff *skb);
-struct htt_tx_info *ath10k_htt_tx_info_lookup(struct htt_struct *htt, u16 msdu_id);
+int ath10k_htt_tx_alloc_msdu_id(struct htt_struct *htt);
+void ath10k_htt_tx_free_msdu_id(struct htt_struct *htt, u16 msdu_id);
+
 void htt_t2h_stats_handler(struct htt_struct *htt, u8 *stats_msg_buf);
 int ath10k_htt_mgmt_tx(struct htt_struct *htt, struct sk_buff *);
 int ath10k_htt_tx(struct htt_struct *htt, struct sk_buff *);
drivers/net/wireless/ath/ath10k/htt_tx.c +92 -113

357 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/mac.c +8 -5
index 1d2e42e..1c9c048 100644
@@ -2376,12 +2376,15 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
 	if (drop)
 		return;
 
-	ret = wait_event_timeout(ar->htt->empty_tx_wq,
-				 atomic_read(&ar->htt->num_used_txi) == 0,
-				 ATH10K_FLUSH_TIMEOUT_HZ);
+	ret = wait_event_timeout(ar->htt->empty_tx_wq, ({
+			bool empty;
+			spin_lock_bh(&ar->htt->tx_lock);
+			empty = bitmap_empty(ar->htt->used_msdu_ids, HTT_MAX_NUM_PENDING_TX);
+			spin_unlock_bh(&ar->htt->tx_lock);
+			(empty);
+		}), ATH10K_FLUSH_TIMEOUT_HZ);
 	if (ret <= 0)
-		ath10k_warn("tx not flushed (%d frames still pending)\n",
-			    atomic_read(&ar->htt->num_used_txi));
+		ath10k_warn("tx not flushed\n");
 }
 
 /* TODO: Implement this function properly
drivers/net/wireless/ath/ath10k/txrx.c +30 -22

102 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.h +1 -1
index 7a1bbfe..05bf9d8 100644
@@ -19,7 +19,7 @@
 
 #include "htt.h"
 
-void ath10k_txrx_tx_unref(struct htt_struct *htt, struct htt_tx_info *txi);
+void ath10k_txrx_tx_unref(struct htt_struct *htt, struct sk_buff *txdesc);
 void ath10k_txrx_tx_completed(struct htt_struct *htt,
 			      const struct htt_tx_done *tx_done);
 void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
Signature · 1 line
1.7.9.5
#3 lore raw

cover ath10k: kill off htt_tx_info wrapper

In reply to Michal Kazior

This patchset merges the htt_tx_info into
ath10k_skb_cb. This depends upon my 'htt tx
cleanup' patchset.

Michal Kazior (2):
ath10k: simplify txi lifespan
ath10k: merge htt_tx_info into ath10k_skb_cb

 drivers/net/wireless/ath/ath10k/core.h   |    7 +-
 drivers/net/wireless/ath/ath10k/htt.h    |   30 +---
 drivers/net/wireless/ath/ath10k/htt_tx.c |  263 ++++++++++++------------------
 drivers/net/wireless/ath/ath10k/mac.c    |   13 +-
 drivers/net/wireless/ath/ath10k/txrx.c   |   65 +++++---
 drivers/net/wireless/ath/ath10k/txrx.h   |    1 +
 6 files changed, 169 insertions(+), 210 deletions(-)
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 1/2 ath10k: simplify txi lifespan

Up until now we were using two booleans to keep track of htt and htc tx completions. These can come in no specific order.

Keep in mind that it was safe to access those without any locks since tx completion processing is done one endpoint at a time (that's the current PCI backend implementation).

The new approach uses refcount. Since we need 2 completions we setup refcount=2 for mgmt and data tx. This also depends on the tx completion behaviour.

If the PCI tx completion scheme ever changes we'll need locking to synchronize tx completions for htt.

---
 drivers/net/wireless/ath/ath10k/core.h   |    5 ++-
 drivers/net/wireless/ath/ath10k/htt.h    |    2 -
 drivers/net/wireless/ath/ath10k/htt_tx.c |   60 ++++++------------------------
 drivers/net/wireless/ath/ath10k/txrx.c   |   41 +++++++++++++-------
 drivers/net/wireless/ath/ath10k/txrx.h   |    1 +
 5 files changed, 45 insertions(+), 64 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +4 -1
index 4e19264..bb1eef1 100644
@@ -59,13 +59,16 @@ struct ath10k_skb_cb {
 		u8 tid;
 		bool is_offchan;
 		bool is_conf;
+		bool discard;
+		bool no_ack;
+		u8 refcount;
 	} __packed htt;
 
 	struct {
 		u8 credits_used;
 	} __packed htc;
 
-	/* 23 bytes left on 64bit arch */
+	/* 20 bytes left on 64bit arch */
 } __packed;
 
 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/htt.h +0 -2
index 38762ca..dbd2912 100644
@@ -1115,8 +1115,6 @@ struct htt_tx_info {
 	u16 msdu_id;
 
 	atomic_t is_used;
-	bool htc_tx_completed;
-	bool htt_tx_completed;
 
 	struct sk_buff *txdesc;
 	struct sk_buff *txfrag; /* not used for mgmt tx */
drivers/net/wireless/ath/ath10k/htt_tx.c +12 -48

106 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.c +28 -13

72 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.h +1 -0
index c80a472..7a1bbfe 100644
@@ -19,6 +19,7 @@
 
 #include "htt.h"
 
+void ath10k_txrx_tx_unref(struct htt_struct *htt, struct htt_tx_info *txi);
 void ath10k_txrx_tx_completed(struct htt_struct *htt,
 			      const struct htt_tx_done *tx_done);
 void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH 1/2 ath10k: simplify txi lifespan

Quoted 14 lines · Michal Kazior

Up until now we were using two booleans to keep track of htt and htc tx completions. These can come in no specific order.

Keep in mind that it was safe to access those without any locks since tx completion processing is done one endpoint at a time (that's the current PCI backend implementation).

The new approach uses refcount. Since we need 2 completions we setup refcount=2 for mgmt and data tx. This also depends on the tx completion behaviour.

Quoted 5 lines

If the PCI tx completion scheme ever changes we'll need locking to synchronize tx completions for htt.

Few comments, can you send a followup patch to address those separately, please?

[...]

Quoted 10 lines

int ath10k_htt_h2t_ver_req_msg(struct htt_struct *htt)

drivers/net/wireless/ath/ath10k/htt_tx.c +1 -0
@@ -315,6 +277,7 @@ int ath10k_htt_mgmt_tx(struct htt_struct *htt, struct sk_buff *msdu)
 
 	skb_cb = ATH10K_SKB_CB(txi->txdesc);
 	skb_cb->htt.msdu_id = txi->msdu_id;
+	skb_cb->htt.refcount = 2;
 
 	res = ath10k_htc_send(htt->htc, htt->eid, txi->txdesc);
 	if (res)

drivers/net/wireless/ath/ath10k/htt_tx.c int ath10k_htt_tx(struct htt_struct *htt, struct sk_buff *msdu) · line 402

Quoted 4 lines
drivers/net/wireless/ath/ath10k/htt_tx.c +1 -0
@@ -436,6 +399,7 @@ int ath10k_htt_tx(struct htt_struct *htt, struct sk_buff *msdu)
 
 	skb_cb = ATH10K_SKB_CB(txi->txdesc);
 	skb_cb->htt.msdu_id = txi->msdu_id;
+	skb_cb->htt.refcount = 2;

It would be good to have a comment in the code why refcount needs to be
2. I know you had it in the commit log already, but people go through commit logs only when they are really desparate :)

[...]

Quoted 16 lines
drivers/net/wireless/ath/ath10k/txrx.c +1 -4
@@ -44,22 +44,17 @@ out:
 	spin_unlock_bh(&ar->data_lock);
 }
 
-void ath10k_txrx_tx_completed(struct htt_struct *htt,
-			      const struct htt_tx_done *tx_done)
+void ath10k_txrx_tx_unref(struct htt_struct *htt, struct htt_tx_info *txi)
 {
 	struct device *dev = htt->ar->dev;
 	struct ieee80211_tx_info *info;
-	struct htt_tx_info *txi;
 	int ret;
 
-	ath10k_dbg(ATH10K_DBG_HTT, "htt tx completion msdu_id %u discard %d no_ack %d\n",

drivers/net/wireless/ath/ath10k/txrx.c out: · line 62

Quoted 10 lines
drivers/net/wireless/ath/ath10k/txrx.c +3 -5
-		   tx_done->msdu_id, !!tx_done->discard, !!tx_done->no_ack);
+	if (ATH10K_SKB_CB(txi->txdesc)->htt.refcount == 0)
+		return;
 
-	txi = ath10k_htt_tx_info_lookup(htt, tx_done->msdu_id);
-	if (!txi) {
-		ath10k_dbg(ATH10K_DBG_HTT, "htt txi lookup fail\n");
+	if (--ATH10K_SKB_CB(txi->txdesc)->htt.refcount > 0)
 		return;
-	}

The 'if (--foo > 0)' is correct but IMHO bad style. It's easy to miss the operator in front and that's why I would prefer:

foo--;

if (foo > 0)
...

Signature · 1 line
Kalle Valo
#6 lore raw

PATCH 2/2 ath10k: merge htt_tx_info into ath10k_skb_cb

In reply to Michal Kazior

This eliminates the wrapper structure htt_tx_info.

---
 drivers/net/wireless/ath/ath10k/core.h   |    4 +-
 drivers/net/wireless/ath/ath10k/htt.h    |   28 +---
 drivers/net/wireless/ath/ath10k/htt_tx.c |  205 ++++++++++++++----------------
 drivers/net/wireless/ath/ath10k/mac.c    |   13 +-
 drivers/net/wireless/ath/ath10k/txrx.c   |   52 ++++----
 drivers/net/wireless/ath/ath10k/txrx.h   |    2 +-
 6 files changed, 141 insertions(+), 163 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +3 -1
index bb1eef1..8648202 100644
@@ -62,13 +62,15 @@ struct ath10k_skb_cb {
 		bool discard;
 		bool no_ack;
 		u8 refcount;
+		struct sk_buff *txfrag;
+		struct sk_buff *msdu;
 	} __packed htt;
 
 	struct {
 		u8 credits_used;
 	} __packed htc;
 
-	/* 20 bytes left on 64bit arch */
+	/* 4 bytes left on 64bit arch */
 } __packed;
 
 static inline struct ath10k_skb_cb *ATH10K_SKB_CB(struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/htt.h +7 -21
index dbd2912..c94f137 100644
@@ -1109,18 +1109,6 @@ struct htt_rx_info {
 	bool fcs_err;
 };
 
-struct htt_tx_info {
-	struct htt_struct *htt;
-
-	u16 msdu_id;
-
-	atomic_t is_used;
-
-	struct sk_buff *txdesc;
-	struct sk_buff *txfrag; /* not used for mgmt tx */
-	struct sk_buff *msdu;
-};
-
 struct htt_struct {
 	struct ath10k *ar;
 	struct ath10k_htc *htc;
@@ -1205,9 +1193,10 @@ struct htt_struct {
 		int htc_err_cnt;
 	} stats;
 
-#define HTT_TX_INFO_POOL_SIZE 512 /* FIXME: find proper value? */
-	struct htt_tx_info txi_pool[HTT_TX_INFO_POOL_SIZE];
-	atomic_t num_used_txi;
+#define HTT_MAX_NUM_PENDING_TX 512 /* FIXME: find proper value? */
+	spinlock_t tx_lock;
+	struct sk_buff *pending_tx[HTT_MAX_NUM_PENDING_TX];
+	DECLARE_BITMAP(used_msdu_ids, HTT_MAX_NUM_PENDING_TX);
 	wait_queue_head_t empty_tx_wq;
 
 	/* set if host-fw communication goes haywire
@@ -1258,7 +1247,7 @@ struct htt_rx_desc {
  * changing conditions.
  * Hence, this queue depth threshold spec is mostly just a formality.
  */
-#define HTT_MAX_SEND_QUEUE_DEPTH (HTT_TX_INFO_POOL_SIZE)
+#define HTT_MAX_SEND_QUEUE_DEPTH (HTT_MAX_NUM_PENDING_TX)
 
 /*
  * FIX THIS
@@ -1291,11 +1280,8 @@ void ath10k_htt_t2h_msg_handler(void *context, struct sk_buff *skb);
 int ath10k_htt_h2t_ver_req_msg(struct htt_struct *htt);
 int ath10k_htt_send_rx_ring_cfg_ll(struct htt_struct *htt);
 
-struct htt_tx_info *ath10k_htt_tx_info_alloc(struct htt_struct *htt);
-void ath10k_htt_tx_info_free(struct htt_struct *htt, struct htt_tx_info *pkt);
-void ath10k_htt_tx_info_unref(struct htt_struct *htt, struct htt_tx_info *pkt,
-			      struct sk_buff *skb);
-struct htt_tx_info *ath10k_htt_tx_info_lookup(struct htt_struct *htt, u16 msdu_id);
+int ath10k_htt_tx_alloc_msdu_id(struct htt_struct *htt);
+void ath10k_htt_tx_free_msdu_id(struct htt_struct *htt, u16 msdu_id);
 int ath10k_htt_mgmt_tx(struct htt_struct *htt, struct sk_buff *);
 int ath10k_htt_tx(struct htt_struct *htt, struct sk_buff *);
 #endif
drivers/net/wireless/ath/ath10k/htt_tx.c +92 -113

357 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/mac.c +8 -5
index 0f8869d..47a727e 100644
@@ -2365,12 +2365,15 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
 	if (drop)
 		return;
 
-	ret = wait_event_timeout(ar->htt->empty_tx_wq,
-				 atomic_read(&ar->htt->num_used_txi) == 0,
-				 ATH10K_FLUSH_TIMEOUT_HZ);
+	ret = wait_event_timeout(ar->htt->empty_tx_wq, ({
+			bool empty;
+			spin_lock_bh(&ar->htt->tx_lock);
+			empty = bitmap_empty(ar->htt->used_msdu_ids, HTT_MAX_NUM_PENDING_TX);
+			spin_unlock_bh(&ar->htt->tx_lock);
+			(empty);
+		}), ATH10K_FLUSH_TIMEOUT_HZ);
 	if (ret <= 0)
-		ath10k_warn("tx not flushed (%d frames still pending)\n",
-			    atomic_read(&ar->htt->num_used_txi));
+		ath10k_warn("tx not flushed\n");
 }
 
 /* TODO: Implement this function properly
drivers/net/wireless/ath/ath10k/txrx.c +30 -22

102 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/txrx.h +1 -1
index 7a1bbfe..05bf9d8 100644
@@ -19,7 +19,7 @@
 
 #include "htt.h"
 
-void ath10k_txrx_tx_unref(struct htt_struct *htt, struct htt_tx_info *txi);
+void ath10k_txrx_tx_unref(struct htt_struct *htt, struct sk_buff *txdesc);
 void ath10k_txrx_tx_completed(struct htt_struct *htt,
 			      const struct htt_tx_done *tx_done);
 void ath10k_process_rx(struct ath10k *ar, struct htt_rx_info *info);
Signature · 1 line
1.7.9.5
#7 lore raw

cover ath10k: kill off htt_tx_info wrapper

In reply to Michal Kazior
Quoted 7 lines · Michal Kazior

This patchset merges the htt_tx_info into
ath10k_skb_cb. This depends upon my 'htt tx
cleanup' patchset.

Michal Kazior (2):
ath10k: simplify txi lifespan
ath10k: merge htt_tx_info into ath10k_skb_cb

Thanks, both patches applied.

It's truly awesome that we can work directly with sk_buffs now. It's pain in the butt to deal with struct htc_packet, struct htt_tx_info and whatnot. Thank you very much for working on this.

Signature · 1 line
Kalle Valo