DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jay Zhou <jianjay.zhou@huawei.com>
To: <dev@dpdk.org>
Cc: <pablo.de.lara.guarch@intel.com>, <roy.fan.zhang@intel.com>,
	<thomas@monjalon.net>, <arei.gonglei@huawei.com>,
	<xin.zeng@intel.com>, <weidong.huang@huawei.com>,
	<wangxinxin.wang@huawei.com>, <longpeng2@huawei.com>,
	<jianjay.zhou@huawei.com>
Subject: [dpdk-dev] [PATCH v8 06/11] crypto/virtio: support stats related ops
Date: Sat, 14 Apr 2018 17:34:31 +0800	[thread overview]
Message-ID: <ae0275346887bb3b112ae6077fabbe9f2a09cc8f.1523696750.git.jianjay.zhou@huawei.com> (raw)
In-Reply-To: <cover.1523696750.git.jianjay.zhou@huawei.com>

This patch implements the statistics of the packets.

Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
Reviewed-by: Fan Zhang <roy.fan.zhang@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 drivers/crypto/virtio/virtio_cryptodev.c | 66 +++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/virtio/virtio_cryptodev.c b/drivers/crypto/virtio/virtio_cryptodev.c
index 596a237..6f92e99 100644
--- a/drivers/crypto/virtio/virtio_cryptodev.c
+++ b/drivers/crypto/virtio/virtio_cryptodev.c
@@ -29,6 +29,9 @@ static int virtio_crypto_dev_configure(struct rte_cryptodev *dev,
 static int virtio_crypto_dev_close(struct rte_cryptodev *dev);
 static void virtio_crypto_dev_info_get(struct rte_cryptodev *dev,
 		struct rte_cryptodev_info *dev_info);
+static void virtio_crypto_dev_stats_get(struct rte_cryptodev *dev,
+		struct rte_cryptodev_stats *stats);
+static void virtio_crypto_dev_stats_reset(struct rte_cryptodev *dev);
 static int virtio_crypto_qp_setup(struct rte_cryptodev *dev,
 		uint16_t queue_pair_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
@@ -501,8 +504,8 @@ static int virtio_crypto_sym_configure_session(struct rte_cryptodev *dev,
 	.dev_close			 = virtio_crypto_dev_close,
 	.dev_infos_get			 = virtio_crypto_dev_info_get,
 
-	.stats_get			 = NULL,
-	.stats_reset			 = NULL,
+	.stats_get			 = virtio_crypto_dev_stats_get,
+	.stats_reset			 = virtio_crypto_dev_stats_reset,
 
 	.queue_pair_setup                = virtio_crypto_qp_setup,
 	.queue_pair_release              = virtio_crypto_qp_release,
@@ -518,6 +521,65 @@ static int virtio_crypto_sym_configure_session(struct rte_cryptodev *dev,
 	.qp_detach_session = NULL
 };
 
+static void
+virtio_crypto_update_stats(struct rte_cryptodev *dev,
+		struct rte_cryptodev_stats *stats)
+{
+	unsigned int i;
+	struct virtio_crypto_hw *hw = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	if (stats == NULL) {
+		VIRTIO_CRYPTO_DRV_LOG_ERR("invalid pointer");
+		return;
+	}
+
+	for (i = 0; i < hw->max_dataqueues; i++) {
+		const struct virtqueue *data_queue
+			= dev->data->queue_pairs[i];
+		if (data_queue == NULL)
+			continue;
+
+		stats->enqueued_count += data_queue->packets_sent_total;
+		stats->enqueue_err_count += data_queue->packets_sent_failed;
+
+		stats->dequeued_count += data_queue->packets_received_total;
+		stats->dequeue_err_count
+			+= data_queue->packets_received_failed;
+	}
+}
+
+static void
+virtio_crypto_dev_stats_get(struct rte_cryptodev *dev,
+		struct rte_cryptodev_stats *stats)
+{
+	PMD_INIT_FUNC_TRACE();
+
+	virtio_crypto_update_stats(dev, stats);
+}
+
+static void
+virtio_crypto_dev_stats_reset(struct rte_cryptodev *dev)
+{
+	unsigned int i;
+	struct virtio_crypto_hw *hw = dev->data->dev_private;
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i < hw->max_dataqueues; i++) {
+		struct virtqueue *data_queue = dev->data->queue_pairs[i];
+		if (data_queue == NULL)
+			continue;
+
+		data_queue->packets_sent_total = 0;
+		data_queue->packets_sent_failed = 0;
+
+		data_queue->packets_received_total = 0;
+		data_queue->packets_received_failed = 0;
+	}
+}
+
 static int
 virtio_crypto_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
 		const struct rte_cryptodev_qp_conf *qp_conf,
-- 
1.8.3.1

  parent reply	other threads:[~2018-04-14  9:35 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03  9:43 [dpdk-dev] [PATCH v6 00/10] crypto: add virtio poll mode driver Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 01/10] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-04 12:56   ` De Lara Guarch, Pablo
2018-04-04 13:52     ` Zhoujian (jay)
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 02/10] crypto/virtio: support virtio device init Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 03/10] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 04/10] crypto/virtio: support session related ops Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 05/10] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 06/10] crypto/virtio: support stats related ops Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 07/10] crypto/virtio: support AES-CBC Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 08/10] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 09/10] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-03  9:43 ` [dpdk-dev] [PATCH v6 10/10] doc: add virtio crypto PMD guide Jay Zhou
2018-04-04 17:03 ` [dpdk-dev] [PATCH v7 00/10] crypto: add virtio poll mode driver Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 01/10] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 02/10] crypto/virtio: support virtio device init Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 03/10] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 04/10] crypto/virtio: support session related ops Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 05/10] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 06/10] crypto/virtio: support stats related ops Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 07/10] crypto/virtio: support AES-CBC Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 08/10] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 09/10] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-04 17:03   ` [dpdk-dev] [PATCH v7 10/10] doc: add virtio crypto PMD guide Jay Zhou
2018-04-14  9:34 ` [dpdk-dev] [PATCH v8 00/11] crypto: add virtio poll mode driver Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 01/11] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 02/11] crypto/virtio: support virtio device init Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 03/11] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 04/11] crypto/virtio: support session related ops Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 05/11] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-14  9:34   ` Jay Zhou [this message]
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 07/11] crypto/virtio: support AES-CBC Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 08/11] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 09/11] crypto/virtio: build with meson Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 10/11] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-14  9:34   ` [dpdk-dev] [PATCH v8 11/11] doc: add virtio crypto PMD guide Jay Zhou
2018-04-15  8:51 ` [dpdk-dev] [PATCH v9 00/11] crypto: add virtio poll mode driver Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 01/11] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 02/11] crypto/virtio: support virtio device init Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 03/11] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 04/11] crypto/virtio: support session related ops Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 05/11] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 06/11] crypto/virtio: support stats related ops Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 07/11] crypto/virtio: support AES-CBC Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 08/11] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 09/11] crypto/virtio: build with meson Jay Zhou
2018-04-15 12:09     ` De Lara Guarch, Pablo
2018-04-16  0:56       ` Zhoujian (jay)
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 10/11] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-15  8:51   ` [dpdk-dev] [PATCH v9 11/11] doc: add virtio crypto PMD guide Jay Zhou
2018-04-16  2:21 ` [dpdk-dev] [PATCH v10 00/10] crypto: add virtio poll mode driver Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 01/10] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-16 14:15     ` De Lara Guarch, Pablo
2018-04-16 15:18       ` Zhoujian (jay)
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 02/10] crypto/virtio: support virtio device init Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 03/10] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 04/10] crypto/virtio: support session related ops Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 05/10] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 06/10] crypto/virtio: support stats related ops Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 07/10] crypto/virtio: support AES-CBC Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 08/10] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 09/10] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-16  2:21   ` [dpdk-dev] [PATCH v10 10/10] doc: add virtio crypto PMD guide Jay Zhou
2018-04-17  9:23 ` [dpdk-dev] [PATCH v11 00/10] crypto: add virtio poll mode driver Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 01/10] crypto/virtio: add virtio crypto PMD Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 02/10] crypto/virtio: support virtio device init Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 03/10] crypto/virtio: support basic PMD ops Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 04/10] crypto/virtio: support session related ops Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 05/10] crypto/virtio: support crypto enqueue/dequeue burst API Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 06/10] crypto/virtio: support stats related ops Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 07/10] crypto/virtio: support AES-CBC Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 08/10] crypto/virtio: support HMAC-SHA1 Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 09/10] test/crypto: add function tests for virtio crypto PMD Jay Zhou
2018-04-17  9:23   ` [dpdk-dev] [PATCH v11 10/10] doc: add virtio crypto PMD guide Jay Zhou
2018-04-18 10:00   ` [dpdk-dev] [PATCH v11 00/10] crypto: add virtio poll mode driver De Lara Guarch, Pablo
2018-04-18 13:07     ` Zhoujian (jay)

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=ae0275346887bb3b112ae6077fabbe9f2a09cc8f.1523696750.git.jianjay.zhou@huawei.com \
    --to=jianjay.zhou@huawei.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dev@dpdk.org \
    --cc=longpeng2@huawei.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=roy.fan.zhang@intel.com \
    --cc=thomas@monjalon.net \
    --cc=wangxinxin.wang@huawei.com \
    --cc=weidong.huang@huawei.com \
    --cc=xin.zeng@intel.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).