DPDK patches and discussions
 help / color / mirror / Atom feed
From: Amit Prakash Shukla <amitprakashs@marvell.com>
To: Chengwen Feng <fengchengwen@huawei.com>,
	Kevin Laatz <kevin.laatz@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Cc: <dev@dpdk.org>, <jerinj@marvell.com>, <conor.walsh@intel.com>,
	<vattunuru@marvell.com>, <g.singh@nxp.com>,
	<sachin.saxena@oss.nxp.com>, <hemant.agrawal@nxp.com>,
	<cheng1.jiang@intel.com>, <ndabilpuram@marvell.com>,
	<anoobj@marvell.com>, <mb@smartsharesystems.com>,
	Amit Prakash Shukla <amitprakashs@marvell.com>
Subject: [PATCH v2] dmadev: get DMA device using device ID
Date: Tue, 19 Sep 2023 17:11:37 +0530	[thread overview]
Message-ID: <20230919114137.2466750-1-amitprakashs@marvell.com> (raw)
In-Reply-To: <20230918123227.1562074-1-amitprakashs@marvell.com>

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>
---
v2:
- Dropped patch with dma event op structure.
- Resolved review suggestions.

 lib/dmadev/rte_dmadev.c     | 12 ++++++++++++
 lib/dmadev/rte_dmadev_pmd.h | 15 +++++++++++++++
 lib/dmadev/version.map      |  1 +
 3 files changed, 28 insertions(+)

diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c
index bf7d5ec519..d82464f0ca 100644
--- a/lib/dmadev/rte_dmadev.c
+++ b/lib/dmadev/rte_dmadev.c
@@ -121,6 +121,18 @@ dma_find_by_name(const char *name)
 	return NULL;
 }
 
+struct rte_dma_dev*
+rte_dma_pmd_dev_get(uint8_t dev_id)
+{
+	if (rte_dma_devices == NULL || dev_id >= dma_devices_max)
+		return NULL;
+
+	if (rte_dma_devices[dev_id].state == RTE_DMA_DEV_UNUSED)
+		return NULL;
+
+	return &rte_dma_devices[dev_id];
+}
+
 static void dma_fp_object_dummy(struct rte_dma_fp_object *obj);
 
 static int
diff --git a/lib/dmadev/rte_dmadev_pmd.h b/lib/dmadev/rte_dmadev_pmd.h
index c61cedfb23..b1f50c3931 100644
--- a/lib/dmadev/rte_dmadev_pmd.h
+++ b/lib/dmadev/rte_dmadev_pmd.h
@@ -167,6 +167,21 @@ 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.
+ *
+ * @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_dev_get(uint8_t dev_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/dmadev/version.map b/lib/dmadev/version.map
index 7031d6b335..22aaa73419 100644
--- a/lib/dmadev/version.map
+++ b/lib/dmadev/version.map
@@ -25,6 +25,7 @@ INTERNAL {
 
 	rte_dma_fp_objs;
 	rte_dma_pmd_allocate;
+	rte_dma_pmd_dev_get;
 	rte_dma_pmd_release;
 
 	local: *;
-- 
2.25.1


  parent reply	other threads:[~2023-09-19 11:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 12:32 [PATCH v1 1/2] dmadev: add DMA operation structure Amit Prakash Shukla
2023-09-18 12:32 ` [PATCH v1 2/2] dmadev: get DMA device using device ID Amit Prakash Shukla
2023-09-18 13:42   ` Jerin Jacob
2023-09-18 13:47     ` [EXT] " Amit Prakash Shukla
2023-09-18 12:59 ` [PATCH v1 1/2] dmadev: add DMA operation structure Bruce Richardson
2023-09-18 13:42   ` [EXT] " Amit Prakash Shukla
2023-09-19 11:41 ` Amit Prakash Shukla [this message]
2023-09-21 15:43   ` [PATCH v2] dmadev: get DMA device using device ID Jerin Jacob
2023-09-26 11:09     ` [EXT] " Amit Prakash Shukla

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=20230919114137.2466750-1-amitprakashs@marvell.com \
    --to=amitprakashs@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=cheng1.jiang@intel.com \
    --cc=conor.walsh@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=g.singh@nxp.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=kevin.laatz@intel.com \
    --cc=mb@smartsharesystems.com \
    --cc=ndabilpuram@marvell.com \
    --cc=sachin.saxena@oss.nxp.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).