diff mbox series

[v2,11/15] net/ionic: break up queue post function

Message ID 20210216203540.29290-12-aboyer@pensando.io (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series net/ionic: struct optimizations, fixes | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Andrew Boyer Feb. 16, 2021, 8:35 p.m. UTC
Break it up rather than inlining it, so that we can remove
branches from the hot path.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic_dev.c  | 11 ----------
 drivers/net/ionic/ionic_dev.h  |  1 -
 drivers/net/ionic/ionic_main.c | 10 ++++++++-
 drivers/net/ionic/ionic_rxtx.c | 37 ++++++++++++++++++++++++++++++----
 4 files changed, 42 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index cfaf4abc23..43e9ca3de3 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -438,14 +438,3 @@  ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa)
 	q->sg_base = base;
 	q->sg_base_pa = base_pa;
 }
-
-void
-ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg)
-{
-	q->info[q->head_idx] = cb_arg;
-
-	q->head_idx = Q_NEXT_TO_POST(q, 1);
-
-	if (ring_doorbell)
-		ionic_q_flush(q);
-}
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index 2f27e63646..38c078efdf 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -224,7 +224,6 @@  uint32_t ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
 int ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs);
 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, void *cb_arg);
 
 static inline uint16_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 0d2e02fdd0..9aa7b2e96c 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -197,6 +197,7 @@  ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 	struct ionic_queue *q = &lif->adminqcq->qcq.q;
 	struct ionic_admin_cmd *q_desc_base = q->base;
 	struct ionic_admin_cmd *q_desc;
+	void **info;
 	int err = 0;
 
 	rte_spinlock_lock(&lif->adminq_lock);
@@ -210,7 +211,14 @@  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, ctx);
+	info = IONIC_INFO_PTR(q, q->head_idx);
+	info[0] = ctx;
+
+	q->head_idx = Q_NEXT_TO_POST(q, 1);
+
+	/* Ring doorbell */
+	rte_wmb();
+	ionic_q_flush(q);
 
 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 fa92fca2f5..5236cae211 100644
--- a/drivers/net/ionic/ionic_rxtx.c
+++ b/drivers/net/ionic/ionic_rxtx.c
@@ -302,6 +302,7 @@  ionic_tx_tso_post(struct ionic_queue *q, struct ionic_txq_desc *desc,
 		uint16_t vlan_tci, bool has_vlan,
 		bool start, bool done)
 {
+	void **info;
 	uint8_t flags = 0;
 	flags |= has_vlan ? IONIC_TXQ_DESC_FLAG_VLAN : 0;
 	flags |= encap ? IONIC_TXQ_DESC_FLAG_ENCAP : 0;
@@ -315,7 +316,15 @@  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, done ? txm : NULL);
+	if (done) {
+		info = IONIC_INFO_PTR(q, q->head_idx);
+		info[0] = txm;
+	}
+
+	q->head_idx = Q_NEXT_TO_POST(q, 1);
+
+	if (done)
+		ionic_q_flush(q);
 }
 
 static struct ionic_txq_desc *
@@ -465,6 +474,7 @@  ionic_tx(struct ionic_tx_qcq *txq, struct rte_mbuf *txm,
 	struct ionic_txq_sg_elem *elem;
 	struct ionic_tx_stats *stats = &txq->stats;
 	struct rte_mbuf *txm_seg;
+	void **info;
 	bool encap;
 	bool has_vlan;
 	uint64_t ol_flags = txm->ol_flags;
@@ -473,6 +483,7 @@  ionic_tx(struct ionic_tx_qcq *txq, struct rte_mbuf *txm,
 	uint8_t flags = 0;
 
 	desc = &desc_base[q->head_idx];
+	info = IONIC_INFO_PTR(q, q->head_idx);
 
 	if ((ol_flags & PKT_TX_IP_CKSUM) &&
 	    (txq->flags & IONIC_QCQ_F_CSUM_L3)) {
@@ -506,7 +517,10 @@  ionic_tx(struct ionic_tx_qcq *txq, struct rte_mbuf *txm,
 	desc->len = txm->data_len;
 	desc->vlan_tci = txm->vlan_tci;
 
+	info[0] = txm;
+
 	elem = sg_desc_base[q->head_idx].elems;
+
 	txm_seg = txm->next;
 	while (txm_seg != NULL) {
 		elem->len = txm_seg->data_len;
@@ -515,7 +529,10 @@  ionic_tx(struct ionic_tx_qcq *txq, struct rte_mbuf *txm,
 		txm_seg = txm_seg->next;
 	}
 
-	ionic_q_post(q, not_xmit_more, txm);
+	q->head_idx = Q_NEXT_TO_POST(q, 1);
+
+	if (not_xmit_more)
+		ionic_q_flush(q);
 
 	return 0;
 }
@@ -920,7 +937,11 @@  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, mbuf);
+	q->info[q->head_idx] = mbuf;
+
+	q->head_idx = Q_NEXT_TO_POST(q, 1);
+
+	ionic_q_flush(q);
 }
 
 static __rte_always_inline int
@@ -930,6 +951,7 @@  ionic_rx_fill(struct ionic_rx_qcq *rxq, uint32_t len)
 	struct ionic_rxq_desc *desc, *desc_base = q->base;
 	struct ionic_rxq_sg_desc *sg_desc, *sg_desc_base = q->sg_base;
 	struct ionic_rxq_sg_elem *elem;
+	void **info;
 	rte_iova_t dma_addr;
 	uint32_t i, j, nsegs, buf_size, size;
 	bool ring_doorbell;
@@ -947,6 +969,8 @@  ionic_rx_fill(struct ionic_rx_qcq *rxq, uint32_t len)
 			return -ENOMEM;
 		}
 
+		info = IONIC_INFO_PTR(q, q->head_idx);
+
 		nsegs = (len + buf_size - 1) / buf_size;
 
 		desc = &desc_base[q->head_idx];
@@ -989,7 +1013,12 @@  ionic_rx_fill(struct ionic_rx_qcq *rxq, uint32_t len)
 		ring_doorbell = ((q->head_idx + 1) &
 			IONIC_RX_RING_DOORBELL_STRIDE) == 0;
 
-		ionic_q_post(q, ring_doorbell, rxm);
+		info[0] = rxm;
+
+		q->head_idx = Q_NEXT_TO_POST(q, 1);
+
+		if (ring_doorbell)
+			ionic_q_flush(q);
 	}
 
 	return 0;