DPDK-dev Archive mirror
 help / color / mirror / Atom feed
From: Andrew Boyer <andrew.boyer@amd.com>
To: <dev@dpdk.org>
Cc: Andrew Boyer <andrew.boyer@amd.com>
Subject: [PATCH v2 9/9] crypto/ionic: add stats support
Date: Tue, 30 Apr 2024 13:21:44 -0700	[thread overview]
Message-ID: <20240430202144.49899-10-andrew.boyer@amd.com> (raw)
In-Reply-To: <20240430202144.49899-1-andrew.boyer@amd.com>

This defines the stats handlers and exposes them to the stack.

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
---
 drivers/crypto/ionic/ionic_crypto.h      |  8 ++++
 drivers/crypto/ionic/ionic_crypto_main.c | 48 ++++++++++++++++++++++++
 drivers/crypto/ionic/ionic_crypto_ops.c  | 33 +++++++++++++++-
 3 files changed, 87 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ionic/ionic_crypto.h b/drivers/crypto/ionic/ionic_crypto.h
index 69c17887fb..db87ea0490 100644
--- a/drivers/crypto/ionic/ionic_crypto.h
+++ b/drivers/crypto/ionic/ionic_crypto.h
@@ -174,6 +174,8 @@ struct iocpt_crypto_q {
 	uint16_t flags;
 
 	/* cacheline3 */
+	struct rte_cryptodev_stats stats;
+
 	uint64_t enqueued_wdogs;
 	uint64_t dequeued_wdogs;
 	uint8_t wdog_iv[IOCPT_Q_WDOG_IV_LEN];
@@ -252,6 +254,8 @@ struct iocpt_dev {
 
 	struct iocpt_qtype_info qtype_info[IOCPT_QTYPE_MAX];
 	uint8_t qtype_ver[IOCPT_QTYPE_MAX];
+
+	struct rte_cryptodev_stats stats_base;
 };
 
 struct iocpt_dev_intf {
@@ -313,6 +317,10 @@ typedef bool (*iocpt_cq_cb)(struct iocpt_cq *cq, uint16_t cq_desc_index,
 uint32_t iocpt_cq_service(struct iocpt_cq *cq, uint32_t work_to_do,
 	iocpt_cq_cb cb, void *cb_arg);
 
+void iocpt_get_stats(const struct iocpt_dev *dev,
+	struct rte_cryptodev_stats *stats);
+void iocpt_reset_stats(struct iocpt_dev *dev);
+
 static inline uint16_t
 iocpt_q_space_avail(struct iocpt_queue *q)
 {
diff --git a/drivers/crypto/ionic/ionic_crypto_main.c b/drivers/crypto/ionic/ionic_crypto_main.c
index 113347c57a..0685ddd457 100644
--- a/drivers/crypto/ionic/ionic_crypto_main.c
+++ b/drivers/crypto/ionic/ionic_crypto_main.c
@@ -128,6 +128,52 @@ iocpt_q_free(struct iocpt_queue *q)
 	}
 }
 
+static void
+iocpt_get_abs_stats(const struct iocpt_dev *dev,
+		struct rte_cryptodev_stats *stats)
+{
+	uint32_t i;
+
+	memset(stats, 0, sizeof(*stats));
+
+	/* Sum up the per-queue stats counters */
+	for (i = 0; i < dev->crypto_dev->data->nb_queue_pairs; i++) {
+		struct rte_cryptodev_stats *q_stats = &dev->cryptoqs[i]->stats;
+
+		stats->enqueued_count    += q_stats->enqueued_count;
+		stats->dequeued_count    += q_stats->dequeued_count;
+		stats->enqueue_err_count += q_stats->enqueue_err_count;
+		stats->dequeue_err_count += q_stats->dequeue_err_count;
+	}
+}
+
+void
+iocpt_get_stats(const struct iocpt_dev *dev, struct rte_cryptodev_stats *stats)
+{
+	/* Retrieve the new absolute stats values */
+	iocpt_get_abs_stats(dev, stats);
+
+	/* Subtract the base stats values to get relative values */
+	stats->enqueued_count    -= dev->stats_base.enqueued_count;
+	stats->dequeued_count    -= dev->stats_base.dequeued_count;
+	stats->enqueue_err_count -= dev->stats_base.enqueue_err_count;
+	stats->dequeue_err_count -= dev->stats_base.dequeue_err_count;
+}
+
+void
+iocpt_reset_stats(struct iocpt_dev *dev)
+{
+	uint32_t i;
+
+	/* Erase the per-queue stats counters */
+	for (i = 0; i < dev->crypto_dev->data->nb_queue_pairs; i++)
+		memset(&dev->cryptoqs[i]->stats, 0,
+			sizeof(dev->cryptoqs[i]->stats));
+
+	/* Update the base stats values */
+	iocpt_get_abs_stats(dev, &dev->stats_base);
+}
+
 static int
 iocpt_session_write(struct iocpt_session_priv *priv,
 		enum iocpt_sess_control_oper oper)
@@ -669,6 +715,8 @@ iocpt_init(struct iocpt_dev *dev)
 {
 	int err;
 
+	memset(&dev->stats_base, 0, sizeof(dev->stats_base));
+
 	/* Uses dev_cmds */
 	err = iocpt_dev_init(dev, dev->info_pa);
 	if (err != 0)
diff --git a/drivers/crypto/ionic/ionic_crypto_ops.c b/drivers/crypto/ionic/ionic_crypto_ops.c
index 0330fd76ad..839bbf69d1 100644
--- a/drivers/crypto/ionic/ionic_crypto_ops.c
+++ b/drivers/crypto/ionic/ionic_crypto_ops.c
@@ -65,6 +65,23 @@ iocpt_op_info_get(struct rte_cryptodev *cdev, struct rte_cryptodev_info *info)
 	info->min_mbuf_tailroom_req = 0;
 }
 
+static void
+iocpt_op_stats_get(struct rte_cryptodev *cdev,
+		struct rte_cryptodev_stats *stats)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	iocpt_get_stats(dev, stats);
+}
+
+static void
+iocpt_op_stats_reset(struct rte_cryptodev *cdev)
+{
+	struct iocpt_dev *dev = cdev->data->dev_private;
+
+	iocpt_reset_stats(dev);
+}
+
 static int
 iocpt_op_queue_release(struct rte_cryptodev *cdev, uint16_t queue_id)
 {
@@ -350,6 +367,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	struct iocpt_crypto_q *cptq = qp;
 	struct rte_crypto_op *op;
 	struct iocpt_session_priv *priv;
+	struct rte_cryptodev_stats *stats = &cptq->stats;
 	uint16_t avail, count;
 	int err;
 
@@ -375,6 +393,7 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		err = iocpt_enq_one_aead(cptq, priv, op);
 		if (unlikely(err != 0)) {
 			op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+			stats->enqueue_err_count++;
 			break;
 		}
 
@@ -386,6 +405,8 @@ iocpt_enqueue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 
 		/* Restart timer if ops are being enqueued */
 		cptq->last_wdog_cycles = rte_get_timer_cycles();
+
+		stats->enqueued_count += count;
 	}
 
 	return count;
@@ -439,8 +460,8 @@ iocpt_enqueue_wdog(struct iocpt_crypto_q *cptq)
 	q->info[q->head_idx] = wdog_op;
 	q->head_idx = Q_NEXT_TO_POST(q, 1);
 
-	IOCPT_PRINT(DEBUG, "Queue %u wdog enq %p",
-		q->index, wdog_op);
+	IOCPT_PRINT(DEBUG, "Queue %u wdog enq %p ops %"PRIu64,
+		q->index, wdog_op, cptq->stats.enqueued_count);
 	cptq->enqueued_wdogs++;
 
 out_flush:
@@ -456,6 +477,7 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 	struct rte_crypto_op *op;
 	struct iocpt_crypto_comp *cq_desc_base = cq->base;
 	volatile struct iocpt_crypto_comp *cq_desc;
+	struct rte_cryptodev_stats *stats = &cptq->stats;
 	uint64_t then, now, hz, delta;
 	uint16_t count = 0;
 
@@ -515,6 +537,9 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 			continue;
 		}
 
+		if (unlikely(op->status != RTE_CRYPTO_OP_STATUS_SUCCESS))
+			stats->dequeue_err_count++;
+
 		ops[count] = op;
 		q->info[q->tail_idx] = NULL;
 
@@ -542,6 +567,8 @@ iocpt_dequeue_sym(void *qp, struct rte_crypto_op **ops, uint16_t nb_ops)
 		/* Restart timer if the queue is making progress */
 		cptq->last_wdog_cycles = rte_get_timer_cycles();
 
+	stats->dequeued_count += count;
+
 	return count;
 }
 
@@ -552,6 +579,8 @@ static struct rte_cryptodev_ops iocpt_ops = {
 	.dev_close = iocpt_op_close,
 	.dev_infos_get = iocpt_op_info_get,
 
+	.stats_get = iocpt_op_stats_get,
+	.stats_reset = iocpt_op_stats_reset,
 	.queue_pair_setup = iocpt_op_queue_setup,
 	.queue_pair_release = iocpt_op_queue_release,
 
-- 
2.17.1


      parent reply	other threads:[~2024-04-30 20:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19 19:53 [PATCH 0/6] crypto/ionic: introduce AMD Pensando ionic crypto driver Andrew Boyer
2024-04-19 19:53 ` [PATCH 1/6] " Andrew Boyer
2024-04-19 19:53 ` [PATCH 2/6] crypto/ionic: add device and admin command handlers Andrew Boyer
2024-04-22 12:29   ` Boyer, Andrew
2024-04-19 19:53 ` [PATCH 3/6] common/ionic: add crypto vdev support Andrew Boyer
2024-04-19 19:53 ` [PATCH 4/6] crypto/ionic: add device object and " Andrew Boyer
2024-04-19 19:53 ` [PATCH 5/6] crypto/ionic: add datapath and capabilities support Andrew Boyer
2024-04-19 19:53 ` [PATCH 6/6] crypto/ionic: add documentation and connect to build Andrew Boyer
2024-04-24 18:21 ` [EXTERNAL] [PATCH 0/6] crypto/ionic: introduce AMD Pensando ionic crypto driver Akhil Goyal
2024-04-30 20:21 ` [PATCH v2 0/9] " Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 1/9] " Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 2/9] crypto/ionic: add the firmware interface definition file Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 3/9] crypto/ionic: add device commands Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 4/9] crypto/ionic: add adminq command support Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 5/9] crypto/ionic: add capabilities and basic ops Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 6/9] crypto/ionic: add session support Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 7/9] crypto/ionic: add datapath Andrew Boyer
2024-04-30 20:21   ` [PATCH v2 8/9] crypto/ionic: add a watchdog operation Andrew Boyer
2024-04-30 20:21   ` Andrew Boyer [this message]

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=20240430202144.49899-10-andrew.boyer@amd.com \
    --to=andrew.boyer@amd.com \
    --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 read-only IMAP folder(s) and NNTP newsgroup(s).