DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>
Cc: <anoobj@marvell.com>, Chengwen Feng <fengchengwen@huawei.com>,
	"Vamsi Attunuru" <vattunuru@marvell.com>,
	Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [PATCH 1/4] dmadev: add function to get list of device identifiers
Date: Thu, 10 Aug 2023 17:51:08 +0530	[thread overview]
Message-ID: <20230810122111.2329-2-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20230810122111.2329-1-gmuthukrishn@marvell.com>

Add a function to get list of device identifiers for a given driver
name.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/dmadev/rte_dmadev.c | 20 ++++++++++++++++++++
 lib/dmadev/rte_dmadev.h | 21 +++++++++++++++++++++
 lib/dmadev/version.map  |  1 +
 3 files changed, 42 insertions(+)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 8c095e1f35..f2a106564d 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -388,6 +388,26 @@ rte_dma_get_dev_id_by_name(const char *name)
 	return dev->data->dev_id;
 }
 
+uint8_t
+rte_dma_get_dev_list_by_driver(const char *name, int16_t *devs, uint8_t nb_devs)
+{
+	uint8_t i, count = 0;
+
+	if (name == NULL)
+		return count;
+
+	for (i = 0; i < dma_devices_max && count < nb_devs; i++) {
+		if (rte_dma_devices[i].state == RTE_DMA_DEV_UNUSED)
+			continue;
+
+		if (strncmp(rte_dma_devices[i].device->driver->name,
+					name, strlen(name) + 1) == 0)
+			devs[count++] = i;
+	}
+
+	return count;
+}
+
 bool
 rte_dma_is_valid(int16_t dev_id)
 {
diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h
index e61d71959e..689062a686 100644
--- a/lib/dmadev/rte_dmadev.h
+++ b/lib/dmadev/rte_dmadev.h
@@ -191,6 +191,27 @@ int rte_dma_dev_max(size_t dev_max);
 __rte_experimental
 int rte_dma_get_dev_id_by_name(const char *name);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Get the list of device identifiers for the DMA driver.
+ *
+ * @param name
+ *   DMA driver name.
+ * @param devs
+ *   Output devices identifiers.
+ * @param nb_devs
+ *   Maximal number of devices.
+ *
+ * @return
+ *   Returns number of device identifiers.
+ */
+__rte_experimental
+uint8_t rte_dma_get_dev_list_by_driver(const char *name,
+				       int16_t *devs,
+				       uint8_t nb_devs);
+
 /**
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 7031d6b335..b4d56b41a0 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -7,6 +7,7 @@ EXPERIMENTAL {
 	rte_dma_dev_max;
 	rte_dma_dump;
 	rte_dma_get_dev_id_by_name;
+	rte_dma_get_dev_list_by_driver;
 	rte_dma_info_get;
 	rte_dma_is_valid;
 	rte_dma_next_dev;
-- 
2.25.1


  reply	other threads:[~2023-08-10 12:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 12:21 [PATCH 0/4] test/dma: run tests as per configured pmd Gowrishankar Muthukrishnan
2023-08-10 12:21 ` Gowrishankar Muthukrishnan [this message]
2023-10-08  1:40   ` [PATCH 1/4] dmadev: add function to get list of device identifiers fengchengwen
2023-08-10 12:21 ` [PATCH 2/4] test/dma: run tests according to PMD Gowrishankar Muthukrishnan
2023-08-10 12:21 ` [PATCH 3/4] dma/cnxk: update PCI driver name Gowrishankar Muthukrishnan
2023-08-10 12:21 ` [PATCH 4/4] test/dma: enable cnxk tests Gowrishankar Muthukrishnan

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=20230810122111.2329-2-gmuthukrishn@marvell.com \
    --to=gmuthukrishn@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=vattunuru@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).