DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib/dmadev: get DMA device using device ID
@ 2023-12-08  7:55 Amit Prakash Shukla
  2023-12-09  7:11 ` fengchengwen
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Amit Prakash Shukla @ 2023-12-08  7:55 UTC (permalink / raw)
  To: Chengwen Feng, Kevin Laatz, Bruce Richardson
  Cc: dev, jerinj, vattunuru, ndabilpuram, anoobj, mb, Amit Prakash Shukla

DMA library has a function to get DMA device based on device name but
there is no function to get DMA device using device id.

Added a function that lookup for the dma device using device id and
returns the pointer to the same.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 lib/dmadev/rte_dmadev.c     |  9 +++++++++
 lib/dmadev/rte_dmadev_pmd.h | 14 ++++++++++++++
 lib/dmadev/version.map      |  1 +
 3 files changed, 24 insertions(+)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index 4e5e420c82..83f49e77f2 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -397,6 +397,15 @@ rte_dma_is_valid(int16_t dev_id)
 		rte_dma_devices[dev_id].state != RTE_DMA_DEV_UNUSED;
 }
 
+struct rte_dma_dev *
+rte_dma_pmd_get_dev_by_id(const int dev_id)
+{
+	if (!rte_dma_is_valid(dev_id))
+		return NULL;
+
+	return &rte_dma_devices[dev_id];
+}
+
 uint16_t
 rte_dma_count_avail(void)
 {
diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h
index c61cedfb23..f68c3ac6aa 100644
--- a/lib/dmadev/rte_dmadev_pmd.h
+++ b/lib/dmadev/rte_dmadev_pmd.h
@@ -167,6 +167,20 @@ struct rte_dma_dev *rte_dma_pmd_allocate(const char *name, int numa_node,
 __rte_internal
 int rte_dma_pmd_release(const char *name);
 
+/**
+ * @internal
+ * Get the rte_dma_dev structure device pointer for the device id.
+ *
+ * @param dev_id
+ *   Device ID value to select the device structure.
+ *
+ * @return
+ *   - rte_dma_dev structure pointer for the given device ID on success, NULL
+ *   otherwise.
+ */
+__rte_internal
+struct rte_dma_dev *rte_dma_pmd_get_dev_by_id(const int dev_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 2a3736514c..2cd57c43d3 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -26,6 +26,7 @@ INTERNAL {
 	rte_dma_fp_objs;
 	rte_dma_pmd_allocate;
 	rte_dma_pmd_release;
+	rte_dma_pmd_get_dev_by_id;
 
 	local: *;
 };
-- 
2.25.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-02-09 17:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08  7:55 [PATCH] lib/dmadev: get DMA device using device ID Amit Prakash Shukla
2023-12-09  7:11 ` fengchengwen
2023-12-18 10:41   ` [EXT] " Amit Prakash Shukla
2023-12-11 10:23 ` Bruce Richardson
2023-12-18 11:27   ` [EXT] " Amit Prakash Shukla
2023-12-19 11:00 ` [PATCH v2] " Amit Prakash Shukla
2024-01-08 14:47   ` Anoob Joseph
2024-02-06  6:24     ` Amit Prakash Shukla
2024-02-08 16:25   ` Thomas Monjalon
2024-02-09  8:18     ` fengchengwen
2024-02-09 11:05       ` [EXT] " Amit Prakash Shukla
2024-02-09 11:18         ` Thomas Monjalon
2024-02-09 11:30           ` Amit Prakash Shukla
2024-02-09 17:36             ` Thomas Monjalon

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).