DPDK patches and discussions
 help / color / mirror / Atom feed
From: Radha Mohan Chintakuntla <radhac@marvell.com>
To: <thomas@monjalon.net>, <fengchengwen@huawei.com>,
	<ndabilpuram@marvell.com>, <kirankumark@marvell.com>,
	<skori@marvell.com>, <skoteshwar@marvell.com>,
	<jerinj@marvell.com>, <sburla@marvell.com>
Cc: <dev@dpdk.org>, Radha Mohan Chintakuntla <radhac@marvell.com>
Subject: [dpdk-dev] [PATCH v3 5/5] dma/cnxk: add stats function
Date: Wed, 3 Nov 2021 11:01:50 -0700	[thread overview]
Message-ID: <20211103180150.10416-5-radhac@marvell.com> (raw)
In-Reply-To: <20211103180150.10416-1-radhac@marvell.com>

Add the stats function to get the DMA statistics.

Signed-off-by: Radha Mohan Chintakuntla <radhac@marvell.com>
---
 drivers/dma/cnxk/cnxk_dmadev.c | 41 ++++++++++++++++++++++++++++++++--
 drivers/dma/cnxk/cnxk_dmadev.h |  1 +
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/cnxk/cnxk_dmadev.c b/drivers/dma/cnxk/cnxk_dmadev.c
index 360e92f7ce..2824c1b44f 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.c
+++ b/drivers/dma/cnxk/cnxk_dmadev.c
@@ -271,6 +271,7 @@ cnxk_dmadev_copy(void *dev_private, uint16_t vchan, rte_iova_t src,
 			rte_wmb();
 			plt_write64(num_words,
 				    dpivf->rdpi.rbase + DPI_VDMA_DBELL);
+			dpivf->stats.submitted++;
 		}
 		dpivf->num_words += num_words;
 	}
@@ -336,6 +337,7 @@ cnxk_dmadev_copy_sg(void *dev_private, uint16_t vchan,
 			rte_wmb();
 			plt_write64(num_words,
 				    dpivf->rdpi.rbase + DPI_VDMA_DBELL);
+			dpivf->stats.submitted += nb_src;
 		}
 		dpivf->num_words += num_words;
 	}
@@ -357,12 +359,14 @@ cnxk_dmadev_completed(void *dev_private, uint16_t vchan, const uint16_t nb_cpls,
 
 		if (comp_ptr->cdata) {
 			*has_error = 1;
+			dpivf->stats.errors++;
 			break;
 		}
 	}
 
 	*last_idx = cnt - 1;
 	dpivf->conf.c_desc.tail = cnt;
+	dpivf->stats.completed += cnt;
 
 	return cnt;
 }
@@ -381,10 +385,13 @@ cnxk_dmadev_completed_status(void *dev_private, uint16_t vchan,
 		struct cnxk_dpi_compl_s *comp_ptr =
 			dpivf->conf.c_desc.compl_ptr[cnt];
 		status[cnt] = comp_ptr->cdata;
+		if (comp_ptr->cdata)
+			dpivf->stats.errors++;
 	}
 
 	*last_idx = cnt - 1;
 	dpivf->conf.c_desc.tail = 0;
+	dpivf->stats.completed += cnt;
 
 	return cnt;
 }
@@ -396,17 +403,47 @@ cnxk_dmadev_submit(void *dev_private, uint16_t vchan __rte_unused)
 
 	rte_wmb();
 	plt_write64(dpivf->num_words, dpivf->rdpi.rbase + DPI_VDMA_DBELL);
+	dpivf->stats.submitted++;
 
 	return 0;
 }
 
+static int
+cnxk_stats_get(const struct rte_dma_dev *dev, uint16_t vchan,
+	       struct rte_dma_stats *rte_stats, uint32_t size)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+	struct rte_dma_stats *stats = &dpivf->stats;
+
+	RTE_SET_USED(vchan);
+
+	if (size < sizeof(rte_stats))
+		return -EINVAL;
+	if (rte_stats == NULL)
+		return -EINVAL;
+
+	*rte_stats = *stats;
+	return 0;
+}
+
+static int
+cnxk_stats_reset(struct rte_dma_dev *dev, uint16_t vchan __rte_unused)
+{
+	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
+
+	dpivf->stats = (struct rte_dma_stats){0};
+	return 0;
+}
+
 static const struct rte_dma_dev_ops cnxk_dmadev_ops = {
-	.dev_info_get = cnxk_dmadev_info_get,
+	.dev_close = cnxk_dmadev_close,
 	.dev_configure = cnxk_dmadev_configure,
+	.dev_info_get = cnxk_dmadev_info_get,
 	.dev_start = cnxk_dmadev_start,
 	.dev_stop = cnxk_dmadev_stop,
+	.stats_get = cnxk_stats_get,
+	.stats_reset = cnxk_stats_reset,
 	.vchan_setup = cnxk_dmadev_vchan_setup,
-	.dev_close = cnxk_dmadev_close,
 };
 
 static int
diff --git a/drivers/dma/cnxk/cnxk_dmadev.h b/drivers/dma/cnxk/cnxk_dmadev.h
index eb94ff8ec7..5fc241b55e 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.h
+++ b/drivers/dma/cnxk/cnxk_dmadev.h
@@ -35,6 +35,7 @@ struct cnxk_dpi_conf {
 struct cnxk_dpi_vf_s {
 	struct roc_dpi rdpi;
 	struct cnxk_dpi_conf conf;
+	struct rte_dma_stats stats;
 	uint64_t cmd[DPI_MAX_CMD_SIZE];
 	uint32_t num_words;
 	uint16_t desc_idx;
-- 
2.17.1


      parent reply	other threads:[~2021-11-03 18:02 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-26  4:12 [dpdk-dev] [PATCH 1/4] common/cnxk: add DPI DMA support Radha Mohan Chintakuntla
2021-10-26  4:12 ` [dpdk-dev] [PATCH 2/4] dma/cnxk: create and initialize dmadev on pci probe Radha Mohan Chintakuntla
2021-10-26  8:36   ` Jerin Jacob
2021-10-26 21:05     ` Radha Mohan
2021-10-26  4:12 ` [dpdk-dev] [PATCH 3/4] dma/cnxk: add dma channel operations Radha Mohan Chintakuntla
2021-10-26  8:41   ` Jerin Jacob
2021-10-28 18:18     ` Radha Mohan
2021-10-29 14:54       ` Jerin Jacob
2021-10-29 18:02         ` Radha Mohan
2021-10-26  4:13 ` [dpdk-dev] [PATCH 4/4] dma/cnxk: add copy_sg function Radha Mohan Chintakuntla
2021-10-26  8:42   ` Jerin Jacob
2021-10-26  8:33 ` [dpdk-dev] [PATCH 1/4] common/cnxk: add DPI DMA support Jerin Jacob
2021-10-26 15:57   ` Radha Mohan
2021-11-02  3:40 ` [dpdk-dev] [PATCH v2 " Radha Mohan Chintakuntla
2021-11-02  3:40   ` [dpdk-dev] [PATCH v2 2/4] dma/cnxk: create and initialize dmadev on pci probe Radha Mohan Chintakuntla
2021-11-02  4:02     ` Jerin Jacob
2021-11-02 11:49     ` fengchengwen
2021-11-02  3:40   ` [dpdk-dev] [PATCH v2 3/4] dma/cnxk: add dma channel operations Radha Mohan Chintakuntla
2021-11-02 11:59     ` fengchengwen
2021-11-02 18:11       ` Radha Mohan
2021-11-02  3:40   ` [dpdk-dev] [PATCH v2 4/4] dma/cnxk: add copy_sg function Radha Mohan Chintakuntla
2021-11-02 12:02     ` fengchengwen
2021-11-02 11:45   ` [dpdk-dev] [PATCH v2 1/4] common/cnxk: add DPI DMA support fengchengwen
2021-11-03 18:01   ` [dpdk-dev] [PATCH v3 1/5] " Radha Mohan Chintakuntla
2021-11-03 18:01     ` [dpdk-dev] [PATCH v3 2/5] dma/cnxk: create and initialize dmadev on pci probe Radha Mohan Chintakuntla
2021-11-07 20:55       ` Thomas Monjalon
2021-11-07 23:04       ` Thomas Monjalon
2021-11-09  3:52         ` Radha Mohan
2021-11-09  8:11           ` Thomas Monjalon
2021-11-03 18:01     ` [dpdk-dev] [PATCH v3 3/5] dma/cnxk: add dma channel operations Radha Mohan Chintakuntla
2021-11-03 18:01     ` [dpdk-dev] [PATCH v3 4/5] dma/cnxk: add copy_sg function Radha Mohan Chintakuntla
2021-11-03 18:01     ` Radha Mohan Chintakuntla [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=20211103180150.10416-5-radhac@marvell.com \
    --to=radhac@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=sburla@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=thomas@monjalon.net \
    /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).