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 03/15] net/ionic: consolidate adminq code
Date: Tue, 16 Feb 2021 12:35:28 -0800
Message-ID: <20210216203540.29290-4-aboyer@pensando.io> (raw)
In-Reply-To: <20210216203540.29290-1-aboyer@pensando.io>
In-Reply-To: <20210204195853.13411-1-aboyer@pensando.io>

The adminq is the only caller of ionic_q_service(), so absorb it
into ionic_adminq_service().
Move all of the adminq code together into ionic_main.c.
Staticize a few things.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
---
 drivers/net/ionic/ionic.h           | 13 ++++-
 drivers/net/ionic/ionic_dev.c       | 85 ----------------------------
 drivers/net/ionic/ionic_dev.h       | 15 -----
 drivers/net/ionic/ionic_lif.c       | 16 ------
 drivers/net/ionic/ionic_lif.h       |  2 -
 drivers/net/ionic/ionic_main.c      | 87 ++++++++++++++++++++++++++---
 drivers/net/ionic/ionic_rx_filter.c |  1 +
 7 files changed, 93 insertions(+), 126 deletions(-)

diff --git a/drivers/net/ionic/ionic.h b/drivers/net/ionic/ionic.h
index 49d1fc003f..49b90d1b7c 100644
--- a/drivers/net/ionic/ionic.h
+++ b/drivers/net/ionic/ionic.h
@@ -65,8 +65,19 @@ struct ionic_adapter {
 	LIST_ENTRY(ionic_adapter) pci_adapters;
 };
 
-int ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout);
+/** ionic_admin_ctx - Admin command context.
+ * @pending_work:       Flag that indicates a completion.
+ * @cmd:                Admin command (64B) to be copied to the queue.
+ * @comp:               Admin completion (16B) copied from the queue.
+ */
+struct ionic_admin_ctx {
+	bool pending_work;
+	union ionic_adminq_cmd cmd;
+	union ionic_adminq_comp comp;
+};
+
 int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
+
 int ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait);
 int ionic_setup(struct ionic_adapter *adapter);
 
diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index f837817a0a..0eb9f6f21a 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -465,88 +465,3 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, desc_cb cb,
 	if (ring_doorbell)
 		ionic_q_flush(q);
 }
-
-void
-ionic_q_service(struct ionic_queue *q, uint32_t cq_desc_index,
-		uint32_t stop_index, void *service_cb_arg)
-{
-	struct ionic_desc_info *desc_info;
-	uint32_t curr_q_tail_idx;
-
-	do {
-		desc_info = &q->info[q->tail_idx];
-
-		if (desc_info->cb)
-			desc_info->cb(q, q->tail_idx, cq_desc_index,
-				desc_info->cb_arg, service_cb_arg);
-
-		desc_info->cb = NULL;
-		desc_info->cb_arg = NULL;
-
-		curr_q_tail_idx = q->tail_idx;
-		q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
-
-	} while (curr_q_tail_idx != stop_index);
-}
-
-static void
-ionic_adminq_cb(struct ionic_queue *q,
-		uint32_t q_desc_index, uint32_t cq_desc_index,
-		void *cb_arg, void *service_cb_arg __rte_unused)
-{
-	struct ionic_admin_ctx *ctx = cb_arg;
-	struct ionic_admin_comp *cq_desc_base = q->bound_cq->base;
-	struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
-	uint16_t comp_index;
-
-	if (!ctx)
-		return;
-
-	comp_index = rte_le_to_cpu_16(cq_desc->comp_index);
-	if (unlikely(comp_index != q_desc_index)) {
-		IONIC_WARN_ON(comp_index != q_desc_index);
-		return;
-	}
-
-	memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
-
-	ctx->pending_work = false; /* done */
-}
-
-/** ionic_adminq_post - Post an admin command.
- * @lif:		Handle to lif.
- * @cmd_ctx:		Api admin command context.
- *
- * Post the command to an admin queue in the ethernet driver.  If this command
- * succeeds, then the command has been posted, but that does not indicate a
- * completion.  If this command returns success, then the completion callback
- * will eventually be called.
- *
- * Return: zero or negative error status.
- */
-int
-ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
-{
-	struct ionic_queue *adminq = &lif->adminqcq->q;
-	struct ionic_admin_cmd *q_desc_base = adminq->base;
-	struct ionic_admin_cmd *q_desc;
-	int err = 0;
-
-	rte_spinlock_lock(&lif->adminq_lock);
-
-	if (ionic_q_space_avail(adminq) < 1) {
-		err = -ENOSPC;
-		goto err_out;
-	}
-
-	q_desc = &q_desc_base[adminq->head_idx];
-
-	memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
-
-	ionic_q_post(adminq, true, ionic_adminq_cb, ctx);
-
-err_out:
-	rte_spinlock_unlock(&lif->adminq_lock);
-
-	return err;
-}
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index e1b93b1b05..5b258a9e65 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -184,17 +184,6 @@ struct ionic_cq {
 	rte_iova_t base_pa;
 };
 
-/** ionic_admin_ctx - Admin command context.
- * @pending_work:	Flag that indicates a completion.
- * @cmd:		Admin command (64B) to be copied to the queue.
- * @comp:		Admin completion (16B) copied from the queue.
- */
-struct ionic_admin_ctx {
-	bool pending_work;
-	union ionic_adminq_cmd cmd;
-	union ionic_adminq_comp comp;
-};
-
 struct ionic_lif;
 struct ionic_adapter;
 struct ionic_qcq;
@@ -255,8 +244,6 @@ 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_service(struct ionic_queue *q, uint32_t cq_desc_index,
-	uint32_t stop_index, void *service_cb_arg);
 
 static inline uint32_t
 ionic_q_space_avail(struct ionic_queue *q)
@@ -279,6 +266,4 @@ ionic_q_flush(struct ionic_queue *q)
 	rte_write64(rte_cpu_to_le_64(val), q->db);
 }
 
-int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx);
-
 #endif /* _IONIC_DEV_H_ */
diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c
index a9fe34c0f2..52bc0b178d 100644
--- a/drivers/net/ionic/ionic_lif.c
+++ b/drivers/net/ionic/ionic_lif.c
@@ -1163,22 +1163,6 @@ ionic_lif_notifyq_deinit(struct ionic_lif *lif)
 	nqcq->flags &= ~IONIC_QCQ_F_INITED;
 }
 
-bool
-ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
-		void *cb_arg __rte_unused)
-{
-	struct ionic_admin_comp *cq_desc_base = cq->base;
-	struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index];
-	struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
-
-	if (!color_match(cq_desc->color, cq->done_color))
-		return false;
-
-	ionic_q_service(&qcq->q, cq_desc_index, cq_desc->comp_index, NULL);
-
-	return true;
-}
-
 /* This acts like ionic_napi */
 int
 ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h
index 1a898a0ef9..c4cb7514fb 100644
--- a/drivers/net/ionic/ionic_lif.h
+++ b/drivers/net/ionic/ionic_lif.h
@@ -154,8 +154,6 @@ void ionic_lif_reset(struct ionic_lif *lif);
 int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
 void ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr);
 
-bool ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
-	void *cb_arg);
 int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
 	void *cb_arg);
 
diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c
index 3f1a764888..012103921d 100644
--- a/drivers/net/ionic/ionic_main.c
+++ b/drivers/net/ionic/ionic_main.c
@@ -122,7 +122,7 @@ ionic_opcode_to_str(enum ionic_cmd_opcode opcode)
 	}
 }
 
-int
+static int
 ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
 {
 	const char *name;
@@ -145,8 +145,81 @@ ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
 	return 0;
 }
 
+static bool
+ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
+		void *cb_arg __rte_unused)
+{
+	struct ionic_admin_comp *cq_desc_base = cq->base;
+	struct ionic_admin_comp *cq_desc = &cq_desc_base[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;
+
+	if (!color_match(cq_desc->color, cq->done_color))
+		return false;
+
+	stop_index = rte_le_to_cpu_16(cq_desc->comp_index);
+
+	do {
+		desc_info = &q->info[q->tail_idx];
+
+		ctx = desc_info->cb_arg;
+		if (ctx) {
+			memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
+
+			ctx->pending_work = false; /* done */
+		}
+
+		curr_q_tail_idx = q->tail_idx;
+		q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+	} while (curr_q_tail_idx != stop_index);
+
+	return true;
+}
+
+/** ionic_adminq_post - Post an admin command.
+ * @lif:                Handle to lif.
+ * @cmd_ctx:            Api admin command context.
+ *
+ * Post the command to an admin queue in the ethernet driver.  If this command
+ * succeeds, then the command has been posted, but that does not indicate a
+ * completion.  If this command returns success, then the completion callback
+ * will eventually be called.
+ *
+ * Return: zero or negative error status.
+ */
+static int
+ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
+{
+	struct ionic_queue *q = &lif->adminqcq->q;
+	struct ionic_admin_cmd *q_desc_base = q->base;
+	struct ionic_admin_cmd *q_desc;
+	int err = 0;
+
+	rte_spinlock_lock(&lif->adminq_lock);
+
+	if (ionic_q_space_avail(q) < 1) {
+		err = -ENOSPC;
+		goto err_out;
+	}
+
+	q_desc = &q_desc_base[q->head_idx];
+
+	memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
+
+	ionic_q_post(q, true, NULL, ctx);
+
+err_out:
+	rte_spinlock_unlock(&lif->adminq_lock);
+
+	return err;
+}
+
 static int
-ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
+ionic_adminq_wait_for_completion(struct ionic_lif *lif,
 		struct ionic_admin_ctx *ctx, unsigned long max_wait)
 {
 	unsigned long step_usec = IONIC_DEVCMD_CHECK_PERIOD_US;
@@ -156,12 +229,13 @@ ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
 
 	while (ctx->pending_work && elapsed_usec < max_wait_usec) {
 		/*
-		 * Locking here as adminq is served inline (this could be called
-		 * from multiple places)
+		 * Locking here as adminq is served inline and could be
+		 * called from multiple places
 		 */
 		rte_spinlock_lock(&lif->adminq_service_lock);
 
-		ionic_qcq_service(qcq, budget, ionic_adminq_service, NULL);
+		ionic_qcq_service(lif->adminqcq, budget,
+				ionic_adminq_service, NULL);
 
 		rte_spinlock_unlock(&lif->adminq_service_lock);
 
@@ -175,7 +249,6 @@ ionic_wait_ctx_for_completion(struct ionic_lif *lif, struct ionic_qcq *qcq,
 int
 ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 {
-	struct ionic_qcq *qcq = lif->adminqcq;
 	bool done;
 	int err;
 
@@ -189,7 +262,7 @@ ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 		return err;
 	}
 
-	done = ionic_wait_ctx_for_completion(lif, qcq, ctx,
+	done = ionic_adminq_wait_for_completion(lif, ctx,
 		IONIC_DEVCMD_TIMEOUT);
 
 	return ionic_adminq_check_err(ctx, !done /* timed out */);
diff --git a/drivers/net/ionic/ionic_rx_filter.c b/drivers/net/ionic/ionic_rx_filter.c
index 4310c91b94..bf57a9fa52 100644
--- a/drivers/net/ionic/ionic_rx_filter.c
+++ b/drivers/net/ionic/ionic_rx_filter.c
@@ -7,6 +7,7 @@
 
 #include <rte_malloc.h>
 
+#include "ionic.h"
 #include "ionic_lif.h"
 #include "ionic_rx_filter.h"
 
-- 
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 ` Andrew Boyer [this message]
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=20210216203540.29290-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

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