[v2] dmadev: get DMA device using device ID
Checks
Commit Message
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(+)
Comments
On Tue, Sep 19, 2023 at 5:12 PM Amit Prakash Shukla
<amitprakashs@marvell.com> wrote:
>
> 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.
Looks like it is useful for getting nb_vchan. Could you use info_get()
API instead as it can be cached in slow path for DMA adapter?
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Thursday, September 21, 2023 9:13 PM
> To: Amit Prakash Shukla <amitprakashs@marvell.com>
> Cc: Chengwen Feng <fengchengwen@huawei.com>; Kevin Laatz
> <kevin.laatz@intel.com>; Bruce Richardson <bruce.richardson@intel.com>;
> dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> conor.walsh@intel.com; Vamsi Krishna Attunuru <vattunuru@marvell.com>;
> g.singh@nxp.com; sachin.saxena@oss.nxp.com; hemant.agrawal@nxp.com;
> cheng1.jiang@intel.com; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Anoob Joseph <anoobj@marvell.com>;
> mb@smartsharesystems.com
> Subject: [EXT] Re: [PATCH v2] dmadev: get DMA device using device ID
>
> External Email
>
> ----------------------------------------------------------------------
> On Tue, Sep 19, 2023 at 5:12 PM Amit Prakash Shukla
> <amitprakashs@marvell.com> wrote:
> >
> > 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.
>
> Looks like it is useful for getting nb_vchan. Could you use info_get() API
> instead as it can be cached in slow path for DMA adapter?
Yeah, we can cache nb_vchan using rte_dma_info_get. We can drop the patch. Thanks.
@@ -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
@@ -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
@@ -25,6 +25,7 @@ INTERNAL {
rte_dma_fp_objs;
rte_dma_pmd_allocate;
+ rte_dma_pmd_dev_get;
rte_dma_pmd_release;
local: *;