From: Matthew Wilcox <willy@infradead.org>
To: netdev@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Subject: [PATCH 09/38] ath10k: Convert pending_tx to XArray
Date: Tue, 20 Aug 2019 15:32:30 -0700 [thread overview]
Message-ID: <20190820223259.22348-10-willy@infradead.org> (raw)
In-Reply-To: <20190820223259.22348-1-willy@infradead.org>
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Leave the tx_lock in place; it might be removable around some of the
places that use the XArray, but err on the side of double locking for now.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
drivers/net/wireless/ath/ath10k/htt.h | 2 +-
drivers/net/wireless/ath/ath10k/htt_tx.c | 31 ++++++++++++------------
drivers/net/wireless/ath/ath10k/mac.c | 4 +--
drivers/net/wireless/ath/ath10k/txrx.c | 2 +-
4 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
index 30c080094af1..971f0a8629bc 100644
--- a/drivers/net/wireless/ath/ath10k/htt.h
+++ b/drivers/net/wireless/ath/ath10k/htt.h
@@ -1965,7 +1965,7 @@ struct ath10k_htt {
int max_num_pending_tx;
int num_pending_tx;
int num_pending_mgmt_tx;
- struct idr pending_tx;
+ struct xarray pending_tx;
wait_queue_head_t empty_tx_wq;
/* FIFO for storing tx done status {ack, no-ack, discard} and msdu id */
diff --git a/drivers/net/wireless/ath/ath10k/htt_tx.c b/drivers/net/wireless/ath/ath10k/htt_tx.c
index 2ef717f18795..c25b01fcfa53 100644
--- a/drivers/net/wireless/ath/ath10k/htt_tx.c
+++ b/drivers/net/wireless/ath/ath10k/htt_tx.c
@@ -195,13 +195,16 @@ void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt)
int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb)
{
struct ath10k *ar = htt->ar;
- int ret;
+ int ret, id;
spin_lock_bh(&htt->tx_lock);
- ret = idr_alloc(&htt->pending_tx, skb, 0,
- htt->max_num_pending_tx, GFP_ATOMIC);
+ ret = xa_alloc(&htt->pending_tx, &id, skb,
+ XA_LIMIT(0, htt->max_num_pending_tx - 1), GFP_ATOMIC);
spin_unlock_bh(&htt->tx_lock);
+ if (ret == 0)
+ ret = id;
+
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx alloc msdu_id %d\n", ret);
return ret;
@@ -215,7 +218,7 @@ void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id)
ath10k_dbg(ar, ATH10K_DBG_HTT, "htt tx free msdu_id %hu\n", msdu_id);
- idr_remove(&htt->pending_tx, msdu_id);
+ xa_erase(&htt->pending_tx, msdu_id);
}
static void ath10k_htt_tx_free_cont_txbuf_32(struct ath10k_htt *htt)
@@ -479,7 +482,7 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)
htt->max_num_pending_tx);
spin_lock_init(&htt->tx_lock);
- idr_init(&htt->pending_tx);
+ xa_init_flags(&htt->pending_tx, XA_FLAGS_ALLOC);
if (htt->tx_mem_allocated)
return 0;
@@ -489,21 +492,15 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)
ret = ath10k_htt_tx_alloc_buf(htt);
if (ret)
- goto free_idr_pending_tx;
+ return ret;
htt->tx_mem_allocated = true;
return 0;
-
-free_idr_pending_tx:
- idr_destroy(&htt->pending_tx);
-
- return ret;
}
-static int ath10k_htt_tx_clean_up_pending(int msdu_id, void *skb, void *ctx)
+static int ath10k_htt_tx_clean_up_pending(int msdu_id, struct ath10k *ar)
{
- struct ath10k *ar = ctx;
struct ath10k_htt *htt = &ar->htt;
struct htt_tx_done tx_done = {0};
@@ -531,8 +528,12 @@ void ath10k_htt_tx_destroy(struct ath10k_htt *htt)
void ath10k_htt_tx_stop(struct ath10k_htt *htt)
{
- idr_for_each(&htt->pending_tx, ath10k_htt_tx_clean_up_pending, htt->ar);
- idr_destroy(&htt->pending_tx);
+ struct sk_buff *skb;
+ unsigned long index;
+
+ xa_for_each(&htt->pending_tx, index, skb)
+ ath10k_htt_tx_clean_up_pending(index, htt->ar);
+ xa_destroy(&htt->pending_tx);
}
void ath10k_htt_tx_free(struct ath10k_htt *htt)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 12dad659bf68..9c4cb2e31b76 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -3939,13 +3939,13 @@ static void ath10k_mac_txq_unref(struct ath10k *ar, struct ieee80211_txq *txq)
{
struct ath10k_skb_cb *cb;
struct sk_buff *msdu;
- int msdu_id;
+ unsigned long msdu_id;
if (!txq)
return;
spin_lock_bh(&ar->htt.tx_lock);
- idr_for_each_entry(&ar->htt.pending_tx, msdu, msdu_id) {
+ xa_for_each(&ar->htt.pending_tx, msdu_id, msdu) {
cb = ATH10K_SKB_CB(msdu);
if (cb->txq == txq)
cb->txq = NULL;
diff --git a/drivers/net/wireless/ath/ath10k/txrx.c b/drivers/net/wireless/ath/ath10k/txrx.c
index 4102df016931..87bf6ab65347 100644
--- a/drivers/net/wireless/ath/ath10k/txrx.c
+++ b/drivers/net/wireless/ath/ath10k/txrx.c
@@ -62,7 +62,7 @@ int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
}
spin_lock_bh(&htt->tx_lock);
- msdu = idr_find(&htt->pending_tx, tx_done->msdu_id);
+ msdu = xa_load(&htt->pending_tx, tx_done->msdu_id);
if (!msdu) {
ath10k_warn(ar, "received tx completion for invalid msdu_id: %d\n",
tx_done->msdu_id);
--
2.23.0.rc1
next prev parent reply other threads:[~2019-08-20 22:34 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 22:32 [PATCH 00/38] Convert networking to use the XArray Matthew Wilcox
2019-08-20 22:32 ` [PATCH 01/38] mlx4: Convert cq_table->tree to XArray Matthew Wilcox
2019-08-20 22:32 ` [PATCH 02/38] mlx4: Convert srq_table->tree " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 03/38] mlx4: Convert qp_table_tree " Matthew Wilcox
2019-08-27 19:18 ` Saeed Mahameed
2019-08-20 22:32 ` [PATCH 04/38] mlx5: Convert cq_table " Matthew Wilcox
2019-08-27 19:22 ` Saeed Mahameed
2019-08-20 22:32 ` [PATCH 05/38] mlx5: Convert mlx5_qp_table " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 06/38] mlx5: Convert counters_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 07/38] mlx5: Convert fpga IDRs " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 08/38] nfp: Convert " Matthew Wilcox
2019-08-21 3:59 ` Jakub Kicinski
2019-08-20 22:32 ` Matthew Wilcox [this message]
2019-08-20 22:32 ` [PATCH 10/38] ath10k: Convert mgmt_pending_tx IDR " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 11/38] mt76: Convert token " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 12/38] mwifiex: Convert ack_status_frames " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 13/38] ppp: Convert units_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 14/38] tap: Convert minor_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 15/38] nfp: Convert internal ports " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 16/38] qrtr: Convert qrtr_nodes " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 17/38] qrtr: Convert qrtr_ports " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 18/38] rxrpc: Convert " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 19/38] 9p: Convert reqs IDR " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 20/38] 9p: Convert fids " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 21/38] 9p: Move lock from client to trans_fd Matthew Wilcox
2019-08-20 22:32 ` [PATCH 22/38] sctp: Convert sctp_assocs_id to XArray Matthew Wilcox
2019-08-20 22:32 ` [PATCH 23/38] cls_api: Convert tcf_net " Matthew Wilcox
2019-08-20 23:57 ` David Miller
2019-08-21 0:52 ` Matthew Wilcox
2019-08-20 22:32 ` [PATCH 24/38] cls_u32: Convert tc_u_common->handle_idr " Matthew Wilcox
2019-08-21 21:13 ` Jakub Kicinski
2019-08-21 21:25 ` Matthew Wilcox
2019-08-21 21:38 ` Jakub Kicinski
2019-08-20 22:32 ` [PATCH 25/38] cls_u32: Convert tc_u_hnode->handle_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 26/38] cls_bpf: Convert handle_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 27/38] cls_bpf: Remove list of programs Matthew Wilcox
2019-08-20 22:32 ` [PATCH 28/38] cls_bpf: Use XArray marks to accelerate re-offload Matthew Wilcox
2019-08-20 22:32 ` [PATCH 29/38] cls_flower: Convert handle_idr to XArray Matthew Wilcox
2019-08-20 23:58 ` David Miller
2019-08-21 0:50 ` Matthew Wilcox
2019-08-21 18:27 ` Vlad Buslov
2019-08-25 18:32 ` Cong Wang
2019-08-26 10:11 ` Vlad Buslov
2019-08-20 22:32 ` [PATCH 30/38] cls_flower: Use XArray list of filters in fl_walk Matthew Wilcox
2019-08-21 18:32 ` Vlad Buslov
2019-08-20 22:32 ` [PATCH 31/38] cls_flower: Use XArray marks instead of separate list Matthew Wilcox
2019-08-21 19:12 ` Vlad Buslov
2019-08-20 22:32 ` [PATCH 32/38] cls_basic: Convert handle_idr to XArray Matthew Wilcox
2019-08-20 22:32 ` [PATCH 33/38] act_api: Convert action_idr " Matthew Wilcox
2019-08-21 19:41 ` Vlad Buslov
2019-08-21 20:35 ` Matthew Wilcox
2019-08-20 22:32 ` [PATCH 34/38] net_namespace: Convert netns_ids " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 35/38] tipc: Convert conn_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 36/38] netlink: Convert genl_fam_idr " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 37/38] mac80211: Convert ack_status_frames " Matthew Wilcox
2019-08-20 22:32 ` [PATCH 38/38] mac80211: Convert function_inst_ids " Matthew Wilcox
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=20190820223259.22348-10-willy@infradead.org \
--to=willy@infradead.org \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).