[v8,08/12] vdpa/ifc: add internal API to get device
Checks
Commit Message
Add new internal API "find_internal_resource_by_rte_dev"
to get device.
Signed-off-by: Andy Pei <andy.pei@intel.com>
---
drivers/vdpa/ifc/ifcvf_vdpa.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
Comments
On 10/18/22 14:07, Andy Pei wrote:
> Add new internal API "find_internal_resource_by_rte_dev"
> to get device.
>
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
> drivers/vdpa/ifc/ifcvf_vdpa.c | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
Hi Maxime,
Thanks for your efforts.
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Tuesday, October 18, 2022 9:48 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xia, Chenbo <Chenbo.Xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Huang, Wei <wei.huang@intel.com>; Cao, Gang <gang.cao@intel.com>
> Subject: Re: [PATCH v8 08/12] vdpa/ifc: add internal API to get device
>
>
>
> On 10/18/22 14:07, Andy Pei wrote:
> > Add new internal API "find_internal_resource_by_rte_dev"
> > to get device.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> > drivers/vdpa/ifc/ifcvf_vdpa.c | 28 ++++++++++++++++++++++++++--
> > 1 file changed, 26 insertions(+), 2 deletions(-)
> >
>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> Thanks,
> Maxime
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Tuesday, October 18, 2022 8:08 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Huang, Wei <wei.huang@intel.com>; Cao, Gang <gang.cao@intel.com>;
> maxime.coquelin@redhat.com
> Subject: [PATCH v8 08/12] vdpa/ifc: add internal API to get device
>
> Add new internal API "find_internal_resource_by_rte_dev"
> to get device.
>
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
> drivers/vdpa/ifc/ifcvf_vdpa.c | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 73d04ed..c16e263 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -144,6 +144,29 @@ struct rte_vdpa_dev_info {
> return list;
> }
>
> +static struct internal_list *
> +find_internal_resource_by_rte_dev(struct rte_device *rte_dev)
> +{
> + int found = 0;
> + struct internal_list *list;
> +
> + pthread_mutex_lock(&internal_list_lock);
> +
> + TAILQ_FOREACH(list, &internal_list, next) {
> + if (rte_dev == &list->internal->pdev->device) {
> + found = 1;
> + break;
> + }
> + }
> +
> + pthread_mutex_unlock(&internal_list_lock);
> +
> + if (!found)
> + return NULL;
> +
> + return list;
> +}
> +
> static int
> ifcvf_vfio_setup(struct ifcvf_internal *internal)
> {
> @@ -1398,10 +1421,11 @@ struct rte_vdpa_dev_info {
> {
> struct ifcvf_internal *internal;
> struct internal_list *list;
> + struct rte_device *rte_dev = vdev->device;
>
> - list = find_internal_resource_by_vdev(vdev);
> + list = find_internal_resource_by_rte_dev(rte_dev);
> if (list == NULL) {
> - DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> + DRV_LOG(ERR, "Invalid rte device: %p", rte_dev);
> return -1;
> }
>
> --
> 1.8.3.1
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Hi Chenbo,
Thanks for your review.
> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Wednesday, October 19, 2022 3:04 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xu, Rosen <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>;
> Cao, Gang <gang.cao@intel.com>; maxime.coquelin@redhat.com
> Subject: RE: [PATCH v8 08/12] vdpa/ifc: add internal API to get device
>
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Tuesday, October 18, 2022 8:08 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen
> > <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>; Cao, Gang
> > <gang.cao@intel.com>; maxime.coquelin@redhat.com
> > Subject: [PATCH v8 08/12] vdpa/ifc: add internal API to get device
> >
> > Add new internal API "find_internal_resource_by_rte_dev"
> > to get device.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> > drivers/vdpa/ifc/ifcvf_vdpa.c | 28 ++++++++++++++++++++++++++--
> > 1 file changed, 26 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 73d04ed..c16e263 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -144,6 +144,29 @@ struct rte_vdpa_dev_info {
> > return list;
> > }
> >
> > +static struct internal_list *
> > +find_internal_resource_by_rte_dev(struct rte_device *rte_dev) {
> > + int found = 0;
> > + struct internal_list *list;
> > +
> > + pthread_mutex_lock(&internal_list_lock);
> > +
> > + TAILQ_FOREACH(list, &internal_list, next) {
> > + if (rte_dev == &list->internal->pdev->device) {
> > + found = 1;
> > + break;
> > + }
> > + }
> > +
> > + pthread_mutex_unlock(&internal_list_lock);
> > +
> > + if (!found)
> > + return NULL;
> > +
> > + return list;
> > +}
> > +
> > static int
> > ifcvf_vfio_setup(struct ifcvf_internal *internal) { @@ -1398,10
> > +1421,11 @@ struct rte_vdpa_dev_info { {
> > struct ifcvf_internal *internal;
> > struct internal_list *list;
> > + struct rte_device *rte_dev = vdev->device;
> >
> > - list = find_internal_resource_by_vdev(vdev);
> > + list = find_internal_resource_by_rte_dev(rte_dev);
> > if (list == NULL) {
> > - DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> > + DRV_LOG(ERR, "Invalid rte device: %p", rte_dev);
> > return -1;
> > }
> >
> > --
> > 1.8.3.1
>
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
@@ -144,6 +144,29 @@ struct rte_vdpa_dev_info {
return list;
}
+static struct internal_list *
+find_internal_resource_by_rte_dev(struct rte_device *rte_dev)
+{
+ int found = 0;
+ struct internal_list *list;
+
+ pthread_mutex_lock(&internal_list_lock);
+
+ TAILQ_FOREACH(list, &internal_list, next) {
+ if (rte_dev == &list->internal->pdev->device) {
+ found = 1;
+ break;
+ }
+ }
+
+ pthread_mutex_unlock(&internal_list_lock);
+
+ if (!found)
+ return NULL;
+
+ return list;
+}
+
static int
ifcvf_vfio_setup(struct ifcvf_internal *internal)
{
@@ -1398,10 +1421,11 @@ struct rte_vdpa_dev_info {
{
struct ifcvf_internal *internal;
struct internal_list *list;
+ struct rte_device *rte_dev = vdev->device;
- list = find_internal_resource_by_vdev(vdev);
+ list = find_internal_resource_by_rte_dev(rte_dev);
if (list == NULL) {
- DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
+ DRV_LOG(ERR, "Invalid rte device: %p", rte_dev);
return -1;
}