Skip to content

Commit c9e4d06

Browse files
amitshukla-mrvltmonjalo
authored andcommitted
dmadev: get device structure using ID
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 <[email protected]> Acked-by: Chengwen Feng <[email protected]> Acked-by: Anoob Joseph <[email protected]>
1 parent a4ce111 commit c9e4d06

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/dmadev/rte_dmadev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,15 @@ rte_dma_is_valid(int16_t dev_id)
398398
rte_dma_devices[dev_id].state != RTE_DMA_DEV_UNUSED;
399399
}
400400

401+
struct rte_dma_dev *
402+
rte_dma_pmd_get_dev_by_id(int16_t dev_id)
403+
{
404+
if (!rte_dma_is_valid(dev_id))
405+
return NULL;
406+
407+
return &rte_dma_devices[dev_id];
408+
}
409+
401410
uint16_t
402411
rte_dma_count_avail(void)
403412
{

lib/dmadev/rte_dmadev_pmd.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ struct rte_dma_dev *rte_dma_pmd_allocate(const char *name, int numa_node,
167167
__rte_internal
168168
int rte_dma_pmd_release(const char *name);
169169

170+
/**
171+
* @internal
172+
* Get the rte_dma_dev structure device pointer for the device ID.
173+
*
174+
* @param dev_id
175+
* DMA device index in dmadev library.
176+
*
177+
* @return
178+
* rte_dma_dev structure pointer on success, NULL otherwise.
179+
*/
180+
__rte_internal
181+
struct rte_dma_dev *rte_dma_pmd_get_dev_by_id(int16_t dev_id);
182+
170183
#ifdef __cplusplus
171184
}
172185
#endif

lib/dmadev/version.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ INTERNAL {
2525

2626
rte_dma_fp_objs;
2727
rte_dma_pmd_allocate;
28+
rte_dma_pmd_get_dev_by_id;
2829
rte_dma_pmd_release;
2930

3031
local: *;

0 commit comments

Comments
 (0)