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 v2 07/15] net/ionic: cut down queue structure
Date: Tue, 16 Feb 2021 12:35:32 -0800
Message-ID: <20210216203540.29290-8-aboyer@pensando.io> (raw)
In-Reply-To: <20210216203540.29290-1-aboyer@pensando.io>
In-Reply-To: <20210204195853.13411-1-aboyer@pensando.io>

This will conserve resources.

Rename ionic_qcq_alloc() arg from 'base' to 'type_name' for clarity.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic_dev.c  | 14 +++-------
 drivers/net/ionic/ionic_dev.h  | 34 ++++++++++-------------
 drivers/net/ionic/ionic_lif.c  | 49 ++++++++++++++++++++++------------
 drivers/net/ionic/ionic_main.c |  4 +--
 drivers/net/ionic/ionic_rxtx.c |  8 +++---
 5 files changed, 56 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index 97fb8acf9b..cfaf4abc23 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -405,26 +405,20 @@ ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
 }
 
 int
-ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
-	     struct ionic_queue *q, uint32_t index, uint32_t num_descs,
-	     size_t desc_size, size_t sg_desc_size)
+ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs)
 {
 	uint32_t ring_size;
 
-	if (desc_size == 0 || !rte_is_power_of_2(num_descs))
+	if (!rte_is_power_of_2(num_descs))
 		return -EINVAL;
 
 	ring_size = rte_log2_u32(num_descs);
-
 	if (ring_size < 2 || ring_size > 16)
 		return -EINVAL;
 
-	q->lif = lif;
-	q->idev = idev;
 	q->index = index;
 	q->num_descs = num_descs;
-	q->desc_size = desc_size;
-	q->sg_desc_size = sg_desc_size;
+	q->size_mask = num_descs - 1;
 	q->head_idx = 0;
 	q->tail_idx = 0;
 
@@ -450,7 +444,7 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg)
 {
 	q->info[q->head_idx] = cb_arg;
 
-	q->head_idx = (q->head_idx + 1) & (q->num_descs - 1);
+	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 a777695d64..2f27e63646 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -135,25 +135,21 @@ struct ionic_dev {
 #define IONIC_INFO_PTR(_q, _i)	(&(_q)->info[IONIC_INFO_IDX((_q), _i)])
 
 struct ionic_queue {
-	struct ionic_dev *idev;
-	struct ionic_lif *lif;
-	uint32_t index;
-	uint32_t type;
-	uint32_t hw_index;
-	uint32_t hw_type;
+	uint16_t num_descs;
+	uint16_t head_idx;
+	uint16_t tail_idx;
+	uint16_t size_mask;
+	uint8_t type;
+	uint8_t hw_type;
 	void *base;
 	void *sg_base;
+	struct ionic_doorbell __iomem *db;
 	void **info;
+
+	uint32_t index;
+	uint32_t hw_index;
 	rte_iova_t base_pa;
 	rte_iova_t sg_base_pa;
-	uint32_t tail_idx;
-	uint32_t head_idx;
-	uint32_t num_descs;
-	uint32_t desc_size;
-	uint32_t sg_desc_size;
-	uint32_t qid;
-	uint32_t qtype;
-	struct ionic_doorbell __iomem *db;
 };
 
 #define IONIC_INTR_NONE		(-1)
@@ -220,22 +216,20 @@ struct ionic_doorbell __iomem *ionic_db_map(struct ionic_lif *lif,
 
 int ionic_cq_init(struct ionic_cq *cq, uint16_t num_descs);
 void ionic_cq_map(struct ionic_cq *cq, void *base, rte_iova_t base_pa);
-typedef bool (*ionic_cq_cb)(struct ionic_cq *cq, uint32_t cq_desc_index,
+typedef bool (*ionic_cq_cb)(struct ionic_cq *cq, uint16_t cq_desc_index,
 		void *cb_arg);
 uint32_t ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
 	ionic_cq_cb cb, void *cb_arg);
 
-int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
-	struct ionic_queue *q, uint32_t index, uint32_t num_descs,
-	size_t desc_size, size_t sg_desc_size);
+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 uint32_t
+static inline uint16_t
 ionic_q_space_avail(struct ionic_queue *q)
 {
-	uint32_t avail = q->tail_idx;
+	uint16_t avail = q->tail_idx;
 
 	if (q->head_idx >= avail)
 		avail += q->num_descs - q->head_idx - 1;
diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c
index 462a526935..fcd6fca9a3 100644
--- a/drivers/net/ionic/ionic_lif.c
+++ b/drivers/net/ionic/ionic_lif.c
@@ -34,7 +34,7 @@ int
 ionic_qcq_enable(struct ionic_qcq *qcq)
 {
 	struct ionic_queue *q = &qcq->q;
-	struct ionic_lif *lif = q->lif;
+	struct ionic_lif *lif = qcq->lif;
 	struct ionic_admin_ctx ctx = {
 		.pending_work = true,
 		.cmd.q_control = {
@@ -52,7 +52,7 @@ int
 ionic_qcq_disable(struct ionic_qcq *qcq)
 {
 	struct ionic_queue *q = &qcq->q;
-	struct ionic_lif *lif = q->lif;
+	struct ionic_lif *lif = qcq->lif;
 	struct ionic_admin_ctx ctx = {
 		.pending_work = true,
 		.cmd.q_control = {
@@ -585,16 +585,17 @@ ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr)
 }
 
 static int
-ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
+ionic_qcq_alloc(struct ionic_lif *lif,
+		uint8_t type,
 		uint32_t index,
-		const char *base, uint32_t flags,
-		uint32_t num_descs,
-		uint32_t desc_size,
-		uint32_t cq_desc_size,
-		uint32_t sg_desc_size,
+		const char *type_name,
+		uint16_t flags,
+		uint16_t num_descs,
+		uint16_t desc_size,
+		uint16_t cq_desc_size,
+		uint16_t sg_desc_size,
 		struct ionic_qcq **qcq)
 {
-	struct ionic_dev *idev = &lif->adapter->idev;
 	struct ionic_qcq *new;
 	uint32_t q_size, cq_size, sg_size, total_size;
 	void *q_base, *cq_base, *sg_base;
@@ -642,8 +643,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 
 	new->q.type = type;
 
-	err = ionic_q_init(lif, idev, &new->q, index, num_descs,
-		desc_size, sg_desc_size);
+	err = ionic_q_init(&new->q, index, num_descs);
 	if (err) {
 		IONIC_PRINT(ERR, "Queue initialization failed");
 		goto err_out_free_info;
@@ -656,7 +656,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	}
 
 	new->base_z = rte_eth_dma_zone_reserve(lif->eth_dev,
-		base /* name */, index /* queue_idx */,
+		type_name, index /* queue_idx */,
 		total_size, IONIC_ALIGN, socket_id);
 
 	if (!new->base_z) {
@@ -727,7 +727,11 @@ ionic_rx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t nrxq_descs,
 	int err = -ENOMEM;
 
 	flags = IONIC_QCQ_F_SG;
-	err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, index, "rx", flags,
+	err = ionic_qcq_alloc(lif,
+		IONIC_QTYPE_RXQ,
+		index,
+		"rx",
+		flags,
 		nrxq_descs,
 		sizeof(struct ionic_rxq_desc),
 		sizeof(struct ionic_rxq_comp),
@@ -749,7 +753,11 @@ ionic_tx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t ntxq_descs,
 	int err = -ENOMEM;
 
 	flags = IONIC_QCQ_F_SG;
-	err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, index, "tx", flags,
+	err = ionic_qcq_alloc(lif,
+		IONIC_QTYPE_TXQ,
+		index,
+		"tx",
+		flags,
 		ntxq_descs,
 		sizeof(struct ionic_txq_desc),
 		sizeof(struct ionic_txq_comp),
@@ -770,7 +778,11 @@ ionic_admin_qcq_alloc(struct ionic_lif *lif)
 	int err = -ENOMEM;
 
 	flags = 0;
-	err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags,
+	err = ionic_qcq_alloc(lif,
+		IONIC_QTYPE_ADMINQ,
+		0,
+		"admin",
+		flags,
 		IONIC_ADMINQ_LENGTH,
 		sizeof(struct ionic_admin_cmd),
 		sizeof(struct ionic_admin_comp),
@@ -790,7 +802,10 @@ ionic_notify_qcq_alloc(struct ionic_lif *lif)
 	uint32_t flags = 0;
 	int err = -ENOMEM;
 
-	err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notify",
+	err = ionic_qcq_alloc(lif,
+		IONIC_QTYPE_NOTIFYQ,
+		0,
+		"notify",
 		flags,
 		IONIC_NOTIFYQ_LENGTH,
 		sizeof(struct ionic_notifyq_cmd),
@@ -1216,7 +1231,7 @@ ionic_lif_handle_fw_down(struct ionic_lif *lif)
 }
 
 static bool
-ionic_notifyq_cb(struct ionic_cq *cq, uint32_t cq_desc_index, void *cb_arg)
+ionic_notifyq_cb(struct ionic_cq *cq, uint16_t cq_desc_index, void *cb_arg)
 {
 	union ionic_notifyq_comp *cq_desc_base = cq->base;
 	union ionic_notifyq_comp *cq_desc = &cq_desc_base[cq_desc_index];
diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index 12f2b26570..167a97dcf4 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -146,7 +146,7 @@ ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
 }
 
 static bool
-ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
+ionic_adminq_service(struct ionic_cq *cq, uint16_t cq_desc_index,
 		void *cb_arg __rte_unused)
 {
 	struct ionic_admin_comp *cq_desc_base = cq->base;
@@ -174,7 +174,7 @@ ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
 		}
 
 		curr_q_tail_idx = q->tail_idx;
-		q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+		q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
 	} while (curr_q_tail_idx != stop_index);
 
 	return true;
diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c
index d615e5c4e1..6ecb500b9e 100644
--- a/drivers/net/ionic/ionic_rxtx.c
+++ b/drivers/net/ionic/ionic_rxtx.c
@@ -98,7 +98,7 @@ ionic_tx_flush(struct ionic_qcq *txq)
 		while (q->tail_idx != comp_index) {
 			info = IONIC_INFO_PTR(q, q->tail_idx);
 
-			q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+			q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
 
 			/* Prefetch the next 4 descriptors */
 			if ((q->tail_idx & 0x3) == 0)
@@ -540,7 +540,7 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 	while (nb_tx < nb_pkts) {
 		last = (nb_tx == (nb_pkts - 1));
 
-		next_q_head_idx = (q->head_idx + 1) & (q->num_descs - 1);
+		next_q_head_idx = Q_NEXT_TO_POST(q, 1);
 		if ((next_q_head_idx & 0x3) == 0) {
 			struct ionic_txq_desc *desc_base = q->base;
 			rte_prefetch0(&desc_base[next_q_head_idx]);
@@ -647,7 +647,7 @@ ionic_rx_empty(struct ionic_queue *q)
 		mbuf = info[0];
 		rte_mempool_put(rxq->mb_pool, mbuf);
 
-		q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+		q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
 	}
 }
 
@@ -1055,7 +1055,7 @@ ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do,
 			more = (q->tail_idx != cq_desc->comp_index);
 
 			curr_q_tail_idx = q->tail_idx;
-			q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+			q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
 
 			/* Prefetch the next 4 descriptors */
 			if ((q->tail_idx & 0x3) == 0)
-- 
2.17.1


  parent reply	other threads:[~2021-02-16 20:36 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 ` [dpdk-dev] [PATCH 03/14] net/ionic: convert info array to generic pointers Andrew Boyer
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 ` Andrew Boyer [this message]
2021-02-16 20:35 ` [dpdk-dev] [PATCH v2 08/15] net/ionic: split up queue-completion queue structure 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=20210216203540.29290-8-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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git