DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Boyer <aboyer@pensando.io>
To: dev@dpdk.org
Cc: Alfredo Cardigliano <cardigliano@ntop.org>,
	Andrew Boyer <aboyer@pensando.io>
Subject: [dpdk-dev] [PATCH 03/14] net/ionic: convert info array to generic pointers
Date: Thu,  4 Feb 2021 11:58:42 -0800	[thread overview]
Message-ID: <20210204195853.13411-4-aboyer@pensando.io> (raw)
In-Reply-To: <20210204195853.13411-1-aboyer@pensando.io>

Drop the callback part of the object and store only the pointers.
This saves a bit of space and simplifies the code.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic_dev.c  |  8 ++------
 drivers/net/ionic/ionic_dev.h  | 21 +++++--------------
 drivers/net/ionic/ionic_main.c |  8 ++++----
 drivers/net/ionic/ionic_rxtx.c | 37 ++++++++++++++++++----------------
 4 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index 0eb9f6f21a..74ac2e67a5 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -452,13 +452,9 @@ ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
 }
 
 void
-ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
-	     void *cb_arg)
+ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg)
 {
-	struct ionic_desc_info *head = &q->info[q->head_idx];
-
-	head->cb = cb;
-	head->cb_arg = cb_arg;
+	q->info[q->head_idx] = cb_arg;
 
 	q->head_idx = (q->head_idx + 1) & (q->num_descs - 1);
 
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index 70d95af6bb..1a43ccc61f 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -129,22 +129,12 @@ struct ionic_dev {
 	uint32_t port_info_sz;
 };
 
-struct ionic_queue;
-struct ionic_desc_info;
-
-typedef void (*desc_cb)(struct ionic_queue *q,
-	uint32_t q_desc_index,
-	uint32_t cq_desc_index,
-	void *cb_arg, void *service_cb_arg);
-
-struct ionic_desc_info {
-	desc_cb cb;
-	void *cb_arg;
-};
-
 #define Q_NEXT_TO_POST(_q, _n)	(((_q)->head_idx + (_n)) & ((_q)->size_mask))
 #define Q_NEXT_TO_SRVC(_q, _n)	(((_q)->tail_idx + (_n)) & ((_q)->size_mask))
 
+#define IONIC_INFO_IDX(_q, _i)	(_i)
+#define IONIC_INFO_PTR(_q, _i)	(&(_q)->info[IONIC_INFO_IDX((_q), _i)])
+
 struct ionic_queue {
 	struct ionic_dev *idev;
 	struct ionic_lif *lif;
@@ -155,9 +145,9 @@ struct ionic_queue {
 	uint32_t hw_type;
 	void *base;
 	void *sg_base;
+	void **info;
 	rte_iova_t base_pa;
 	rte_iova_t sg_base_pa;
-	struct ionic_desc_info *info;
 	uint32_t tail_idx;
 	uint32_t head_idx;
 	uint32_t num_descs;
@@ -243,8 +233,7 @@ int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
 	size_t desc_size, size_t sg_desc_size);
 void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
 void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
-void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
-	void *cb_arg);
+void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg);
 
 static inline uint32_t
 ionic_q_space_avail(struct ionic_queue *q)
diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index acc8b87b64..c9c0123d6a 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -154,9 +154,9 @@ ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
 	struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
 	struct ionic_queue *q = &qcq->q;
 	struct ionic_admin_ctx *ctx;
-	struct ionic_desc_info *desc_info;
 	uint16_t curr_q_tail_idx;
 	uint16_t stop_index;
+	void **info;
 
 	if (!color_match(cq_desc->color, cq->done_color))
 		return false;
@@ -164,9 +164,9 @@ ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
 	stop_index = rte_le_to_cpu_16(cq_desc->comp_index);
 
 	do {
-		desc_info = &q->info[q->tail_idx];
+		info = IONIC_INFO_PTR(q, q->tail_idx);
 
-		ctx = desc_info->cb_arg;
+		ctx = info[0];
 		if (ctx) {
 			memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
 
@@ -210,7 +210,7 @@ ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 
 	memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
 
-	ionic_q_post(q, true, NULL, ctx);
+	ionic_q_post(q, true, ctx);
 
 err_out:
 	rte_spinlock_unlock(&lif->adminq_lock);
diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c
index 1ad95d8e39..81c9ff8ba8 100644
--- a/drivers/net/ionic/ionic_rxtx.c
+++ b/drivers/net/ionic/ionic_rxtx.c
@@ -72,10 +72,10 @@ ionic_tx_flush(struct ionic_qcq *txq)
 {
 	struct ionic_cq *cq = &txq->cq;
 	struct ionic_queue *q = &txq->q;
-	struct ionic_desc_info *q_desc_info;
 	struct rte_mbuf *txm, *next;
 	struct ionic_txq_comp *cq_desc_base = cq->base;
 	struct ionic_txq_comp *cq_desc;
+	void **info;
 	u_int32_t comp_index = (u_int32_t)-1;
 
 	cq_desc = &cq_desc_base[cq->tail_idx];
@@ -96,7 +96,7 @@ ionic_tx_flush(struct ionic_qcq *txq)
 
 	if (comp_index != (u_int32_t)-1) {
 		while (q->tail_idx != comp_index) {
-			q_desc_info = &q->info[q->tail_idx];
+			info = IONIC_INFO_PTR(q, q->tail_idx);
 
 			q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
 
@@ -109,7 +109,7 @@ ionic_tx_flush(struct ionic_qcq *txq)
 			 * Note: you can just use rte_pktmbuf_free,
 			 * but this loop is faster
 			 */
-			txm = q_desc_info->cb_arg;
+			txm = info[0];
 			while (txm != NULL) {
 				next = txm->next;
 				rte_pktmbuf_free_seg(txm);
@@ -311,7 +311,7 @@ ionic_tx_tso_post(struct ionic_queue *q, struct ionic_txq_desc *desc,
 	desc->hdr_len = hdrlen;
 	desc->mss = mss;
 
-	ionic_q_post(q, done, NULL, done ? txm : NULL);
+	ionic_q_post(q, done, done ? txm : NULL);
 }
 
 static struct ionic_txq_desc *
@@ -511,7 +511,7 @@ ionic_tx(struct ionic_qcq *txq, struct rte_mbuf *txm,
 		txm_seg = txm_seg->next;
 	}
 
-	ionic_q_post(q, not_xmit_more, NULL, txm);
+	ionic_q_post(q, not_xmit_more, txm);
 
 	return 0;
 }
@@ -639,12 +639,12 @@ static void __rte_cold
 ionic_rx_empty(struct ionic_queue *q)
 {
 	struct ionic_qcq *rxq = IONIC_Q_TO_QCQ(q);
-	struct ionic_desc_info *cur;
 	struct rte_mbuf *mbuf;
+	void **info;
 
 	while (q->tail_idx != q->head_idx) {
-		cur = &q->info[q->tail_idx];
-		mbuf = cur->cb_arg;
+		info = IONIC_INFO_PTR(q, q->tail_idx);
+		mbuf = info[0];
 		rte_mempool_put(rxq->mb_pool, mbuf);
 
 		q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
@@ -743,12 +743,11 @@ ionic_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
 static __rte_always_inline void
 ionic_rx_clean(struct ionic_queue *q,
 		uint32_t q_desc_index, uint32_t cq_desc_index,
-		void *cb_arg, void *service_cb_arg)
+		void *service_cb_arg)
 {
 	struct ionic_rxq_comp *cq_desc_base = q->bound_cq->base;
 	struct ionic_rxq_comp *cq_desc = &cq_desc_base[cq_desc_index];
-	struct rte_mbuf *rxm = cb_arg;
-	struct rte_mbuf *rxm_seg;
+	struct rte_mbuf *rxm, *rxm_seg;
 	struct ionic_qcq *rxq = IONIC_Q_TO_QCQ(q);
 	uint32_t max_frame_size =
 		rxq->lif->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
@@ -761,6 +760,13 @@ ionic_rx_clean(struct ionic_queue *q,
 		(rte_pktmbuf_data_room_size(rxq->mb_pool) -
 		RTE_PKTMBUF_HEADROOM);
 	uint32_t left;
+	void **info;
+
+	assert(q_desc_index == cq_desc->comp_index);
+
+	info = IONIC_INFO_PTR(q, cq_desc->comp_index);
+
+	rxm = info[0];
 
 	if (!recv_args) {
 		stats->no_cb_arg++;
@@ -898,7 +904,7 @@ ionic_rx_recycle(struct ionic_queue *q, uint32_t q_desc_index,
 	new->addr = old->addr;
 	new->len = old->len;
 
-	ionic_q_post(q, true, ionic_rx_clean, mbuf);
+	ionic_q_post(q, true, mbuf);
 }
 
 static __rte_always_inline int
@@ -969,7 +975,7 @@ ionic_rx_fill(struct ionic_qcq *rxq, uint32_t len)
 		ring_doorbell = ((q->head_idx + 1) &
 			IONIC_RX_RING_DOORBELL_STRIDE) == 0;
 
-		ionic_q_post(q, ring_doorbell, ionic_rx_clean, rxm);
+		ionic_q_post(q, ring_doorbell, rxm);
 	}
 
 	return 0;
@@ -1023,7 +1029,6 @@ ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do,
 {
 	struct ionic_cq *cq = &rxq->cq;
 	struct ionic_queue *q = &rxq->q;
-	struct ionic_desc_info *q_desc_info;
 	struct ionic_rxq_comp *cq_desc_base = cq->base;
 	struct ionic_rxq_comp *cq_desc;
 	bool more;
@@ -1048,8 +1053,6 @@ ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do,
 		do {
 			more = (q->tail_idx != cq_desc->comp_index);
 
-			q_desc_info = &q->info[q->tail_idx];
-
 			curr_q_tail_idx = q->tail_idx;
 			q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
 
@@ -1059,7 +1062,7 @@ ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do,
 				rte_prefetch0(&q->info[q->tail_idx]);
 
 			ionic_rx_clean(q, curr_q_tail_idx, curr_cq_tail_idx,
-				q_desc_info->cb_arg, service_cb_arg);
+				service_cb_arg);
 
 		} while (more);
 
-- 
2.17.1


  parent reply	other threads:[~2021-02-04 19:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 19:58 [dpdk-dev] [PATCH 00/14] net/ionic: struct optimizations, fixes Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 01/14] net/ionic: cut down completion queue structure Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 02/14] net/ionic: consolidate adminq code Andrew Boyer
2021-02-04 19:58 ` Andrew Boyer [this message]
2021-02-04 19:58 ` [dpdk-dev] [PATCH 04/14] net/ionic: remove unused field from queue structure Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 05/14] net/ionic: remove unused interrupt free function Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 06/14] net/ionic: cut down queue structure Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 07/14] net/ionic: split up queue-completion " Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 08/14] net/ionic: use the socket id passed in for Rx and Tx queues Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 09/14] net/ionic: log queue counters when tearing down Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 10/14] net/ionic: break up queue post function Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 11/14] net/ionic: ring doorbell once at the end of each burst Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 12/14] net/ionic: send as many packets as possible Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 13/14] net/ionic: fix Tx fragment limit check Andrew Boyer
2021-02-04 19:58 ` [dpdk-dev] [PATCH 14/14] net/ionic: fix code around lif init devcmd Andrew Boyer
2021-02-04 20:25 ` [dpdk-dev] [PATCH 00/14] net/ionic: struct optimizations, fixes Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 00/15] " Andrew Boyer
2021-02-25 16:07   ` Ferruh Yigit
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 01/15] net/ionic: cut down completion queue structure Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 02/15] net/ionic: remove unused filter delete function Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 03/15] net/ionic: consolidate adminq code Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 04/15] net/ionic: convert info array to generic pointers Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 05/15] net/ionic: remove unused field from queue structure Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 06/15] net/ionic: remove unused interrupt free function Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 07/15] net/ionic: cut down queue structure Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 08/15] net/ionic: split up queue-completion " Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 09/15] net/ionic: use the socket id passed in for Rx and Tx queues Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 10/15] net/ionic: log queue counters when tearing down Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 11/15] net/ionic: break up queue post function Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 12/15] net/ionic: ring doorbell once at the end of each burst Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 13/15] net/ionic: send as many packets as possible Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 14/15] net/ionic: store Tx fragment limit in queue Andrew Boyer
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 15/15] net/ionic: fix code around lif init devcmd Andrew Boyer

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=20210204195853.13411-4-aboyer@pensando.io \
    --to=aboyer@pensando.io \
    --cc=cardigliano@ntop.org \
    --cc=dev@dpdk.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).