DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
To: <gakhil@marvell.com>, <fanzhang.oss@gmail.com>, <ashishg@marvell.com>
Cc: <dev@dpdk.org>, Nagadheeraj Rottela <rnagadheeraj@marvell.com>
Subject: [PATCH v5 5/7] compress/nitrox: add software queue management
Date: Sat, 2 Mar 2024 15:08:11 +0530	[thread overview]
Message-ID: <20240302093813.14922-6-rnagadheeraj@marvell.com> (raw)
In-Reply-To: <20240302093813.14922-1-rnagadheeraj@marvell.com>

Added software queue management code corresponding to
queue pair setup and release functions.

Signed-off-by: Nagadheeraj Rottela <rnagadheeraj@marvell.com>
---
 drivers/compress/nitrox/nitrox_comp.c | 115 +++++++++++++++++++++++---
 drivers/compress/nitrox/nitrox_comp.h |   1 +
 2 files changed, 105 insertions(+), 11 deletions(-)

diff --git a/drivers/compress/nitrox/nitrox_comp.c b/drivers/compress/nitrox/nitrox_comp.c
index e97a686fbf..299cb8e783 100644
--- a/drivers/compress/nitrox/nitrox_comp.c
+++ b/drivers/compress/nitrox/nitrox_comp.c
@@ -5,11 +5,13 @@
 #include <rte_compressdev_pmd.h>
 #include <rte_comp.h>
 #include <rte_errno.h>
+#include <rte_malloc.h>
 
 #include "nitrox_comp.h"
 #include "nitrox_device.h"
 #include "nitrox_logs.h"
 #include "nitrox_comp_reqmgr.h"
+#include "nitrox_qp.h"
 
 static const char nitrox_comp_drv_name[] = RTE_STR(COMPRESSDEV_NAME_NITROX_PMD);
 static const struct rte_driver nitrox_rte_comp_drv = {
@@ -17,6 +19,9 @@ static const struct rte_driver nitrox_rte_comp_drv = {
 	.alias = nitrox_comp_drv_name
 };
 
+static int nitrox_comp_queue_pair_release(struct rte_compressdev *dev,
+					  uint16_t qp_id);
+
 static const struct rte_compressdev_capabilities
 				nitrox_comp_pmd_capabilities[] = {
 	{	.algo = RTE_COMP_ALGO_DEFLATE,
@@ -84,8 +89,15 @@ static void nitrox_comp_dev_stop(struct rte_compressdev *dev)
 
 static int nitrox_comp_dev_close(struct rte_compressdev *dev)
 {
+	int i, ret;
 	struct nitrox_comp_device *comp_dev = dev->data->dev_private;
 
+	for (i = 0; i < dev->data->nb_queue_pairs; i++) {
+		ret = nitrox_comp_queue_pair_release(dev, i);
+		if (ret)
+			return ret;
+	}
+
 	rte_mempool_free(comp_dev->xform_pool);
 	comp_dev->xform_pool = NULL;
 	return 0;
@@ -94,13 +106,33 @@ static int nitrox_comp_dev_close(struct rte_compressdev *dev)
 static void nitrox_comp_stats_get(struct rte_compressdev *dev,
 				  struct rte_compressdev_stats *stats)
 {
-	RTE_SET_USED(dev);
-	RTE_SET_USED(stats);
+	int qp_id;
+
+	for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) {
+		struct nitrox_qp *qp = dev->data->queue_pairs[qp_id];
+
+		if (!qp)
+			continue;
+
+		stats->enqueued_count += qp->stats.enqueued_count;
+		stats->dequeued_count += qp->stats.dequeued_count;
+		stats->enqueue_err_count += qp->stats.enqueue_err_count;
+		stats->dequeue_err_count += qp->stats.dequeue_err_count;
+	}
 }
 
 static void nitrox_comp_stats_reset(struct rte_compressdev *dev)
 {
-	RTE_SET_USED(dev);
+	int qp_id;
+
+	for (qp_id = 0; qp_id < dev->data->nb_queue_pairs; qp_id++) {
+		struct nitrox_qp *qp = dev->data->queue_pairs[qp_id];
+
+		if (!qp)
+			continue;
+
+		memset(&qp->stats, 0, sizeof(qp->stats));
+	}
 }
 
 static void nitrox_comp_dev_info_get(struct rte_compressdev *dev,
@@ -121,19 +153,80 @@ static int nitrox_comp_queue_pair_setup(struct rte_compressdev *dev,
 					uint16_t qp_id,
 					uint32_t max_inflight_ops, int socket_id)
 {
-	RTE_SET_USED(dev);
-	RTE_SET_USED(qp_id);
-	RTE_SET_USED(max_inflight_ops);
-	RTE_SET_USED(socket_id);
-	return -1;
+	struct nitrox_comp_device *comp_dev = dev->data->dev_private;
+	struct nitrox_device *ndev = comp_dev->ndev;
+	struct nitrox_qp *qp = NULL;
+	int err;
+
+	NITROX_LOG(DEBUG, "queue %d\n", qp_id);
+	if (qp_id >= ndev->nr_queues) {
+		NITROX_LOG(ERR, "queue %u invalid, max queues supported %d\n",
+			   qp_id, ndev->nr_queues);
+		return -EINVAL;
+	}
+
+	if (dev->data->queue_pairs[qp_id]) {
+		err = nitrox_comp_queue_pair_release(dev, qp_id);
+		if (err)
+			return err;
+	}
+
+	qp = rte_zmalloc_socket("nitrox PMD qp", sizeof(*qp),
+				RTE_CACHE_LINE_SIZE,
+				socket_id);
+	if (!qp) {
+		NITROX_LOG(ERR, "Failed to allocate nitrox qp\n");
+		return -ENOMEM;
+	}
+
+	qp->type = NITROX_QUEUE_ZIP;
+	qp->qno = qp_id;
+	err = nitrox_qp_setup(qp, ndev->bar_addr, dev->data->name,
+			      max_inflight_ops, ZIP_INSTR_SIZE,
+			      socket_id);
+	if (unlikely(err))
+		goto qp_setup_err;
+
+	dev->data->queue_pairs[qp_id] = qp;
+	NITROX_LOG(DEBUG, "queue %d setup done\n", qp_id);
+	return 0;
+
+qp_setup_err:
+	rte_free(qp);
+	return err;
 }
 
 static int nitrox_comp_queue_pair_release(struct rte_compressdev *dev,
 					  uint16_t qp_id)
 {
-	RTE_SET_USED(dev);
-	RTE_SET_USED(qp_id);
-	return 0;
+	struct nitrox_comp_device *comp_dev = dev->data->dev_private;
+	struct nitrox_device *ndev = comp_dev->ndev;
+	struct nitrox_qp *qp;
+	int err;
+
+	NITROX_LOG(DEBUG, "queue %d\n", qp_id);
+	if (qp_id >= ndev->nr_queues) {
+		NITROX_LOG(ERR, "queue %u invalid, max queues supported %d\n",
+			   qp_id, ndev->nr_queues);
+		return -EINVAL;
+	}
+
+	qp = dev->data->queue_pairs[qp_id];
+	if (!qp) {
+		NITROX_LOG(DEBUG, "queue %u already freed\n", qp_id);
+		return 0;
+	}
+
+	if (!nitrox_qp_is_empty(qp)) {
+		NITROX_LOG(ERR, "queue %d not empty\n", qp_id);
+		return -EAGAIN;
+	}
+
+	dev->data->queue_pairs[qp_id] = NULL;
+	err = nitrox_qp_release(qp, ndev->bar_addr);
+	rte_free(qp);
+	NITROX_LOG(DEBUG, "queue %d release done\n", qp_id);
+	return err;
 }
 
 static int nitrox_comp_private_xform_create(struct rte_compressdev *dev,
diff --git a/drivers/compress/nitrox/nitrox_comp.h b/drivers/compress/nitrox/nitrox_comp.h
index 90e1931b05..e49debaf6b 100644
--- a/drivers/compress/nitrox/nitrox_comp.h
+++ b/drivers/compress/nitrox/nitrox_comp.h
@@ -18,6 +18,7 @@
 #define NITROX_COMP_LEVEL_MEDIUM_END 6
 #define NITROX_COMP_LEVEL_BEST_START 7
 #define NITROX_COMP_LEVEL_BEST_END 9
+#define ZIP_INSTR_SIZE 64
 
 struct nitrox_comp_device {
 	struct rte_compressdev *cdev;
-- 
2.42.0


  parent reply	other threads:[~2024-03-02  9:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02  9:38 [PATCH 0/7] add Nitrox compress device support Nagadheeraj Rottela
2024-03-02  9:38 ` [PATCH v5 1/7] crypto/nitrox: move common code Nagadheeraj Rottela
2024-03-02  9:38 ` [PATCH v5 2/7] drivers/compress: add Nitrox driver Nagadheeraj Rottela
2024-03-02  9:38 ` [PATCH v5 3/7] common/nitrox: add compress hardware queue management Nagadheeraj Rottela
2024-03-02  9:38 ` [PATCH v5 4/7] crypto/nitrox: set queue type during queue pair setup Nagadheeraj Rottela
2024-03-02  9:38 ` Nagadheeraj Rottela [this message]
2024-03-02  9:38 ` [PATCH v5 6/7] compress/nitrox: support stateless request Nagadheeraj Rottela
2024-03-02  9:38 ` [PATCH v5 7/7] compress/nitrox: support stateful request Nagadheeraj Rottela
2024-03-04  7:14 ` [PATCH 0/7] add Nitrox compress device support Akhil Goyal

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=20240302093813.14922-6-rnagadheeraj@marvell.com \
    --to=rnagadheeraj@marvell.com \
    --cc=ashishg@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    /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).