lib/dmadev: get DMA device using device ID

Message ID 20231208075526.2696553-1-amitprakashs@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series lib/dmadev: get DMA device using device ID |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Amit Prakash Shukla Dec. 8, 2023, 7:55 a.m. UTC
  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(+)
  

Comments

Chengwen Feng Dec. 9, 2023, 7:11 a.m. UTC | #1
Hi Amit,

On 2023/12/8 15:55, Amit Prakash Shukla 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.
> 
> 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;

Should arranged alphabetically in version.map

With above fixed
Acked-by: Chengwen Feng <fengchengwen@huawei.com>

Thanks

>  
>  	local: *;
>  };
>
  
Bruce Richardson Dec. 11, 2023, 10:23 a.m. UTC | #2
On Fri, Dec 08, 2023 at 01:25:25PM +0530, Amit Prakash Shukla 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.
> 
> 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(+)
> 
What is the use-case for these functions? With the dmadev library
abstraction, other libs and apps should never need a pointer to an dmadev
struct.
  
Amit Prakash Shukla Dec. 18, 2023, 10:41 a.m. UTC | #3
Hi Chengwen,

Thanks for the review and feedback. I will send the next version with suggested changes.

Thanks,
Amit Shukla

> -----Original Message-----
> From: fengchengwen <fengchengwen@huawei.com>
> Sent: Saturday, December 9, 2023 12:42 PM
> To: Amit Prakash Shukla <amitprakashs@marvell.com>; Kevin Laatz
> <kevin.laatz@intel.com>; Bruce Richardson <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Vamsi
> Krishna Attunuru <vattunuru@marvell.com>; Nithin Kumar Dabilpuram
> <ndabilpuram@marvell.com>; Anoob Joseph <anoobj@marvell.com>;
> mb@smartsharesystems.com
> Subject: [EXT] Re: [PATCH] lib/dmadev: get DMA device using device ID
> 
> External Email
> 
> ----------------------------------------------------------------------
> Hi Amit,
> 
> On 2023/12/8 15:55, Amit Prakash Shukla 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.
> >
> > 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;
> 
> Should arranged alphabetically in version.map
> 
> With above fixed
> Acked-by: Chengwen Feng <fengchengwen@huawei.com>
> 
> Thanks
> 
> >
> >  	local: *;
> >  };
> >
  
Amit Prakash Shukla Dec. 18, 2023, 11:27 a.m. UTC | #4
Hi Bruce,

Thanks for the review and feedback. Please find my reply in-line.

Thanks,
Amit Shukla

> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Monday, December 11, 2023 3:54 PM
> To: Amit Prakash Shukla <amitprakashs@marvell.com>
> Cc: Chengwen Feng <fengchengwen@huawei.com>; Kevin Laatz
> <kevin.laatz@intel.com>; dev@dpdk.org; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>; Vamsi Krishna Attunuru <vattunuru@marvell.com>;
> Nithin Kumar Dabilpuram <ndabilpuram@marvell.com>; Anoob Joseph
> <anoobj@marvell.com>; mb@smartsharesystems.com
> Subject: [EXT] Re: [PATCH] lib/dmadev: get DMA device using device ID
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Fri, Dec 08, 2023 at 01:25:25PM +0530, Amit Prakash Shukla 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.
> >
> > 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(+)
> >
> What is the use-case for these functions? With the dmadev library
> abstraction, other libs and apps should never need a pointer to an dmadev
> struct.
[Amit]: The dmadev struct pointer is needed at driver layer to verify certain underlying device parameters which cannot be done as part of dma lib. This api is been used in the patch: https://patches.dpdk.org/project/dpdk/patch/20231208082835.2817601-3-amitprakashs@marvell.com/
  

Patch

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: *;
 };