[v8,08/13] vdpa/ifc: add get device type ops to ifc driver

Message ID 1652876035-70513-9-git-send-email-andy.pei@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series add virtio_blk device support to vdpa/ifc |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pei, Andy May 18, 2022, 12:13 p.m. UTC
  Add get device type ops to ifc driver.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
  

Comments

Chenbo Xia May 23, 2022, 7:30 a.m. UTC | #1
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Wednesday, May 18, 2022 8:14 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Cao,
> Gang <gang.cao@intel.com>; Liu, Changpeng <changpeng.liu@intel.com>; Xu,
> Rosen <rosen.xu@intel.com>; Xiao, QimaiX <qimaix.xiao@intel.com>
> Subject: [PATCH v8 08/13] vdpa/ifc: add get device type ops to ifc driver
> 
> Add get device type ops to ifc driver.
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 3e78c7d..0acfa8c 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -1189,6 +1189,29 @@ struct rte_vdpa_dev_info {
>  	return 0;
>  }
> 
> +static int
> +ifcvf_get_device_type(struct rte_vdpa_device *vdev,
> +	uint32_t *type)
> +{
> +	struct ifcvf_internal *internal;
> +	struct internal_list *list;
> +
> +	list = find_internal_resource_by_vdev(vdev);
> +	if (list == NULL) {
> +		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> +		return -1;
> +	}
> +
> +	internal = list->internal;
> +
> +	if (internal->hw.device_type == IFCVF_BLK)
> +		*type = VDPA_DEVICE_TYPE_BLK;
> +	else
> +		*type = VDPA_DEVICE_TYPE_NET;
> +
> +	return 0;
> +}
> +
>  static struct rte_vdpa_dev_ops ifcvf_ops = {
>  	.get_queue_num = ifcvf_get_queue_num,
>  	.get_features = ifcvf_get_vdpa_features,
> @@ -1201,6 +1224,7 @@ struct rte_vdpa_dev_info {
>  	.get_vfio_group_fd = ifcvf_get_vfio_group_fd,
>  	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
>  	.get_notify_area = ifcvf_get_notify_area,
> +	.get_dev_type = ifcvf_get_device_type,
>  };
> 
>  static inline int
> @@ -1327,6 +1351,7 @@ struct rte_vdpa_dev_info {
>  	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
>  	.get_notify_area = ifcvf_get_notify_area,
>  	.get_config = ifcvf_blk_get_config,
> +	.get_dev_type = ifcvf_get_device_type,
>  };
> 
>  struct rte_vdpa_dev_info dev_info[] = {
> --
> 1.8.3.1

With renaming fixed mentioned in patch 7:

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  
Pei, Andy May 23, 2022, 8:31 a.m. UTC | #2
Sure

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Monday, May 23, 2022 3:30 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; Cao, Gang <gang.cao@intel.com>; Liu,
> Changpeng <changpeng.liu@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Xiao, QimaiX <qimaix.xiao@intel.com>
> Subject: RE: [PATCH v8 08/13] vdpa/ifc: add get device type ops to ifc driver
> 
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Wednesday, May 18, 2022 8:14 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; maxime.coquelin@redhat.com;
> > Cao, Gang <gang.cao@intel.com>; Liu, Changpeng
> > <changpeng.liu@intel.com>; Xu, Rosen <rosen.xu@intel.com>; Xiao,
> > QimaiX <qimaix.xiao@intel.com>
> > Subject: [PATCH v8 08/13] vdpa/ifc: add get device type ops to ifc
> > driver
> >
> > Add get device type ops to ifc driver.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 25 +++++++++++++++++++++++++
> >  1 file changed, 25 insertions(+)
> >
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 3e78c7d..0acfa8c 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -1189,6 +1189,29 @@ struct rte_vdpa_dev_info {
> >  	return 0;
> >  }
> >
> > +static int
> > +ifcvf_get_device_type(struct rte_vdpa_device *vdev,
> > +	uint32_t *type)
> > +{
> > +	struct ifcvf_internal *internal;
> > +	struct internal_list *list;
> > +
> > +	list = find_internal_resource_by_vdev(vdev);
> > +	if (list == NULL) {
> > +		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> > +		return -1;
> > +	}
> > +
> > +	internal = list->internal;
> > +
> > +	if (internal->hw.device_type == IFCVF_BLK)
> > +		*type = VDPA_DEVICE_TYPE_BLK;
> > +	else
> > +		*type = VDPA_DEVICE_TYPE_NET;
> > +
> > +	return 0;
> > +}
> > +
> >  static struct rte_vdpa_dev_ops ifcvf_ops = {
> >  	.get_queue_num = ifcvf_get_queue_num,
> >  	.get_features = ifcvf_get_vdpa_features, @@ -1201,6 +1224,7 @@
> > struct rte_vdpa_dev_info {
> >  	.get_vfio_group_fd = ifcvf_get_vfio_group_fd,
> >  	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
> >  	.get_notify_area = ifcvf_get_notify_area,
> > +	.get_dev_type = ifcvf_get_device_type,
> >  };
> >
> >  static inline int
> > @@ -1327,6 +1351,7 @@ struct rte_vdpa_dev_info {
> >  	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
> >  	.get_notify_area = ifcvf_get_notify_area,
> >  	.get_config = ifcvf_blk_get_config,
> > +	.get_dev_type = ifcvf_get_device_type,
> >  };
> >
> >  struct rte_vdpa_dev_info dev_info[] = {
> > --
> > 1.8.3.1
> 
> With renaming fixed mentioned in patch 7:
> 
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  

Patch

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 3e78c7d..0acfa8c 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -1189,6 +1189,29 @@  struct rte_vdpa_dev_info {
 	return 0;
 }
 
+static int
+ifcvf_get_device_type(struct rte_vdpa_device *vdev,
+	uint32_t *type)
+{
+	struct ifcvf_internal *internal;
+	struct internal_list *list;
+
+	list = find_internal_resource_by_vdev(vdev);
+	if (list == NULL) {
+		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
+		return -1;
+	}
+
+	internal = list->internal;
+
+	if (internal->hw.device_type == IFCVF_BLK)
+		*type = VDPA_DEVICE_TYPE_BLK;
+	else
+		*type = VDPA_DEVICE_TYPE_NET;
+
+	return 0;
+}
+
 static struct rte_vdpa_dev_ops ifcvf_ops = {
 	.get_queue_num = ifcvf_get_queue_num,
 	.get_features = ifcvf_get_vdpa_features,
@@ -1201,6 +1224,7 @@  struct rte_vdpa_dev_info {
 	.get_vfio_group_fd = ifcvf_get_vfio_group_fd,
 	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
 	.get_notify_area = ifcvf_get_notify_area,
+	.get_dev_type = ifcvf_get_device_type,
 };
 
 static inline int
@@ -1327,6 +1351,7 @@  struct rte_vdpa_dev_info {
 	.get_vfio_device_fd = ifcvf_get_vfio_device_fd,
 	.get_notify_area = ifcvf_get_notify_area,
 	.get_config = ifcvf_blk_get_config,
+	.get_dev_type = ifcvf_get_device_type,
 };
 
 struct rte_vdpa_dev_info dev_info[] = {