DPDK patches and discussions
 help / color / mirror / Atom feed
From: Adrian Moreno <amorenoz@redhat.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	matan@mellanox.com, xiao.w.wang@intel.com,
	zhihong.wang@intel.com, chenbo.xia@intel.com,
	david.marchand@redhat.com, viacheslavo@mellanox.com,
	hemant.agrawal@nxp.com, sachin.saxena@nxp.com, grive@u256.net,
	dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v2 06/14] vhost: replace vDPA device ID in Vhost
Date: Fri, 26 Jun 2020 12:38:31 +0200	[thread overview]
Message-ID: <e93aef8f-2f6d-48f6-e6a4-fe834cbd6cec@redhat.com> (raw)
In-Reply-To: <20200624122701.1369327-7-maxime.coquelin@redhat.com>



On 6/24/20 2:26 PM, Maxime Coquelin wrote:
> This removes the notion of device ID in Vhost library
> as a preliminary step to get rid of the vDPA device ID.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c          | 12 ++++----
>  drivers/vdpa/mlx5/mlx5_vdpa.c          | 18 ++++-------
>  examples/vdpa/main.c                   |  9 +++++-
>  lib/librte_vhost/rte_vhost.h           | 20 ++++++------
>  lib/librte_vhost/rte_vhost_version.map |  4 +--
>  lib/librte_vhost/socket.c              | 42 ++++++++++----------------
>  lib/librte_vhost/vhost.c               | 19 +++++-------
>  lib/librte_vhost/vhost.h               |  8 ++---
>  lib/librte_vhost/vhost_user.c          | 28 +++++------------
>  9 files changed, 66 insertions(+), 94 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 0418f9a07f..4163047744 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -881,7 +881,7 @@ ifcvf_dev_config(int vid)
>  	struct internal_list *list;
>  	struct ifcvf_internal *internal;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> @@ -907,7 +907,7 @@ ifcvf_dev_close(int vid)
>  	struct internal_list *list;
>  	struct ifcvf_internal *internal;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> @@ -947,7 +947,7 @@ ifcvf_set_features(int vid)
>  	struct ifcvf_internal *internal;
>  	uint64_t log_base = 0, log_size = 0;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> @@ -978,7 +978,7 @@ ifcvf_get_vfio_group_fd(int vid)
>  	struct rte_vdpa_device *vdev;
>  	struct internal_list *list;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> @@ -994,7 +994,7 @@ ifcvf_get_vfio_device_fd(int vid)
>  	struct rte_vdpa_device *vdev;
>  	struct internal_list *list;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> @@ -1013,7 +1013,7 @@ ifcvf_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
>  	struct vfio_region_info reg = { .argsz = sizeof(reg) };
>  	int ret;
>  
> -	vdev = rte_vdpa_get_device(rte_vhost_get_vdpa_device_id(vid));
> +	vdev = rte_vhost_get_vdpa_device(vid);
>  	list = find_internal_resource_by_vdev(vdev);
>  	if (list == NULL) {
>  		DRV_LOG(ERR, "Invalid vDPA device: %p", vdev);
> diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c b/drivers/vdpa/mlx5/mlx5_vdpa.c
> index 9ea032d57b..47db5fd6f4 100644
> --- a/drivers/vdpa/mlx5/mlx5_vdpa.c
> +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c
> @@ -129,8 +129,7 @@ mlx5_vdpa_get_protocol_features(struct rte_vdpa_device *vdev,
>  static int
>  mlx5_vdpa_set_vring_state(int vid, int vring, int state)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  
> @@ -171,8 +170,7 @@ mlx5_vdpa_direct_db_prepare(struct mlx5_vdpa_priv *priv)
>  static int
>  mlx5_vdpa_features_set(int vid)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  	uint64_t log_base, log_size;
> @@ -292,8 +290,7 @@ mlx5_vdpa_mtu_set(struct mlx5_vdpa_priv *priv)
>  static int
>  mlx5_vdpa_dev_close(int vid)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  	int ret = 0;
> @@ -322,8 +319,7 @@ mlx5_vdpa_dev_close(int vid)
>  static int
>  mlx5_vdpa_dev_config(int vid)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  
> @@ -354,8 +350,7 @@ mlx5_vdpa_dev_config(int vid)
>  static int
>  mlx5_vdpa_get_device_fd(int vid)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  
> @@ -369,8 +364,7 @@ mlx5_vdpa_get_device_fd(int vid)
>  static int
>  mlx5_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
>  {
> -	struct rte_vdpa_device *vdev = rte_vdpa_get_device(
> -			rte_vhost_get_vdpa_device_id(vid));
> +	struct rte_vdpa_device *vdev = rte_vhost_get_vdpa_device(vid);
>  	struct mlx5_vdpa_priv *priv =
>  		mlx5_vdpa_find_priv_resource_by_vdev(vdev);
>  
> diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c
> index bdb00603cc..6a719e32d8 100644
> --- a/examples/vdpa/main.c
> +++ b/examples/vdpa/main.c
> @@ -149,6 +149,7 @@ start_vdpa(struct vdpa_port *vport)
>  {
>  	int ret;
>  	char *socket_path = vport->ifname;
> +	struct rte_vdpa_device *vdev;
>  	int did = vport->did;
>  
>  	if (client_mode)
> @@ -173,7 +174,13 @@ start_vdpa(struct vdpa_port *vport)
>  			"register driver ops failed: %s\n",
>  			socket_path);
>  
> -	ret = rte_vhost_driver_attach_vdpa_device(socket_path, did);
> +	vdev = rte_vdpa_get_device(did);
> +	if (!vdev)
> +		rte_exit(EXIT_FAILURE,
> +			"vDPA device retrieval failed: %p\n",
> +			vdev);
> +
> +	ret = rte_vhost_driver_attach_vdpa_device(socket_path, vdev);
>  	if (ret != 0)
>  		rte_exit(EXIT_FAILURE,
>  			"attach vdpa device failed: %s\n",
> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
> index d43669f2c2..2fbc364643 100644
> --- a/lib/librte_vhost/rte_vhost.h
> +++ b/lib/librte_vhost/rte_vhost.h
> @@ -90,6 +90,7 @@ extern "C" {
>  #define VHOST_USER_F_PROTOCOL_FEATURES	30
>  #endif
>  
> +struct rte_vdpa_device;
>  
>  /**
>   * Information relating to memory regions including offsets to
> @@ -402,14 +403,15 @@ int rte_vhost_driver_unregister(const char *path);
>   *
>   * @param path
>   *  The vhost-user socket file path
> - * @param did
> - *  Device id
> + * @param dev
> + *  vDPA device pointer
>   * @return
>   *  0 on success, -1 on failure
>   */
>  __rte_experimental
>  int
> -rte_vhost_driver_attach_vdpa_device(const char *path, int did);
> +rte_vhost_driver_attach_vdpa_device(const char *path,
> +		struct rte_vdpa_device *dev);
>  
>  /**
>   * Unset the vdpa device id
> @@ -429,11 +431,11 @@ rte_vhost_driver_detach_vdpa_device(const char *path);
>   * @param path
>   *  The vhost-user socket file path
>   * @return
> - *  Device id, -1 on failure
> + *  vDPA device pointer, NULL on failure
>   */
>  __rte_experimental
> -int
> -rte_vhost_driver_get_vdpa_device_id(const char *path);
> +struct rte_vdpa_device *
> +rte_vhost_driver_get_vdpa_device(const char *path);
>  
>  /**
>   * Set the feature bits the vhost-user driver supports.
> @@ -977,11 +979,11 @@ rte_vhost_extern_callback_register(int vid,
>   * @param vid
>   *  vhost device id
>   * @return
> - *  device id
> + *  vDPA device pointer on success, NULL on failure
>   */
>  __rte_experimental
> -int
> -rte_vhost_get_vdpa_device_id(int vid);
> +struct rte_vdpa_device *
> +rte_vhost_get_vdpa_device(int vid);
>  
>  /**
>   * Notify the guest that should get virtio configuration space from backend.
> diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
> index 9325ee4227..60d67445d7 100644
> --- a/lib/librte_vhost/rte_vhost_version.map
> +++ b/lib/librte_vhost/rte_vhost_version.map
> @@ -43,8 +43,8 @@ EXPERIMENTAL {
>  	rte_vdpa_reset_stats;
>  	rte_vhost_driver_attach_vdpa_device;
>  	rte_vhost_driver_detach_vdpa_device;
> -	rte_vhost_driver_get_vdpa_device_id;
> -	rte_vhost_get_vdpa_device_id;
> +	rte_vhost_driver_get_vdpa_device;
> +	rte_vhost_get_vdpa_device;
>  	rte_vhost_driver_get_protocol_features;
>  	rte_vhost_driver_get_queue_num;
>  	rte_vhost_get_log_base;
> diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
> index da575b608c..49267cebf9 100644
> --- a/lib/librte_vhost/socket.c
> +++ b/lib/librte_vhost/socket.c
> @@ -55,12 +55,7 @@ struct vhost_user_socket {
>  
>  	uint64_t protocol_features;
>  
> -	/*
> -	 * Device id to identify a specific backend device.
> -	 * It's set to -1 for the default software implementation.
> -	 * If valid, one socket can have 1 connection only.
> -	 */
> -	int vdpa_dev_id;
> +	struct rte_vdpa_device *vdpa_dev;
>  
>  	struct vhost_device_ops const *notify_ops;
>  };
> @@ -230,7 +225,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
>  
>  	vhost_set_builtin_virtio_net(vid, vsocket->use_builtin_virtio_net);
>  
> -	vhost_attach_vdpa_device(vid, vsocket->vdpa_dev_id);
> +	vhost_attach_vdpa_device(vid, vsocket->vdpa_dev);
>  
>  	if (vsocket->dequeue_zero_copy)
>  		vhost_enable_dequeue_zero_copy(vid);
> @@ -578,17 +573,18 @@ find_vhost_user_socket(const char *path)
>  }
>  
>  int
> -rte_vhost_driver_attach_vdpa_device(const char *path, int did)
> +rte_vhost_driver_attach_vdpa_device(const char *path,
> +		struct rte_vdpa_device *dev)
>  {
>  	struct vhost_user_socket *vsocket;
>  
> -	if (rte_vdpa_get_device(did) == NULL || path == NULL)
> +	if (dev == NULL || path == NULL)
>  		return -1;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
>  	vsocket = find_vhost_user_socket(path);
>  	if (vsocket)
> -		vsocket->vdpa_dev_id = did;
> +		vsocket->vdpa_dev = dev;
>  	pthread_mutex_unlock(&vhost_user.mutex);
>  
>  	return vsocket ? 0 : -1;
> @@ -602,25 +598,25 @@ rte_vhost_driver_detach_vdpa_device(const char *path)
>  	pthread_mutex_lock(&vhost_user.mutex);
>  	vsocket = find_vhost_user_socket(path);
>  	if (vsocket)
> -		vsocket->vdpa_dev_id = -1;
> +		vsocket->vdpa_dev = NULL;
>  	pthread_mutex_unlock(&vhost_user.mutex);
>  
>  	return vsocket ? 0 : -1;
>  }
>  
> -int
> -rte_vhost_driver_get_vdpa_device_id(const char *path)
> +struct rte_vdpa_device *
> +rte_vhost_driver_get_vdpa_device(const char *path)
>  {
>  	struct vhost_user_socket *vsocket;
> -	int did = -1;
> +	struct rte_vdpa_device *dev = NULL;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
>  	vsocket = find_vhost_user_socket(path);
>  	if (vsocket)
> -		did = vsocket->vdpa_dev_id;
> +		dev = vsocket->vdpa_dev;
>  	pthread_mutex_unlock(&vhost_user.mutex);
>  
> -	return did;
> +	return dev;
>  }
>  
>  int
> @@ -693,7 +689,6 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
>  	struct vhost_user_socket *vsocket;
>  	uint64_t vdpa_features;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  	int ret = 0;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
> @@ -705,8 +700,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
>  		goto unlock_exit;
>  	}
>  
> -	did = vsocket->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = vsocket->vdpa_dev;
>  	if (!vdpa_dev || !vdpa_dev->ops->get_features) {
>  		*features = vsocket->features;
>  		goto unlock_exit;
> @@ -748,7 +742,6 @@ rte_vhost_driver_get_protocol_features(const char *path,
>  	struct vhost_user_socket *vsocket;
>  	uint64_t vdpa_protocol_features;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  	int ret = 0;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
> @@ -760,8 +753,7 @@ rte_vhost_driver_get_protocol_features(const char *path,
>  		goto unlock_exit;
>  	}
>  
> -	did = vsocket->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = vsocket->vdpa_dev;
>  	if (!vdpa_dev || !vdpa_dev->ops->get_protocol_features) {
>  		*protocol_features = vsocket->protocol_features;
>  		goto unlock_exit;
> @@ -790,7 +782,6 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
>  	struct vhost_user_socket *vsocket;
>  	uint32_t vdpa_queue_num;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  	int ret = 0;
>  
>  	pthread_mutex_lock(&vhost_user.mutex);
> @@ -802,8 +793,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
>  		goto unlock_exit;
>  	}
>  
> -	did = vsocket->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = vsocket->vdpa_dev;
>  	if (!vdpa_dev || !vdpa_dev->ops->get_queue_num) {
>  		*queue_num = VHOST_MAX_QUEUE_PAIRS;
>  		goto unlock_exit;
> @@ -878,7 +868,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
>  			"error: failed to init connection mutex\n");
>  		goto out_free;
>  	}
> -	vsocket->vdpa_dev_id = -1;
> +	vsocket->vdpa_dev = NULL;
>  	vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY;
>  	vsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT;
>  	vsocket->linearbuf = flags & RTE_VHOST_USER_LINEARBUF_SUPPORT;
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 0266318440..0d822d6a3f 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -633,7 +633,6 @@ vhost_new_device(void)
>  	dev->vid = i;
>  	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
>  	dev->slave_req_fd = -1;
> -	dev->vdpa_dev_id = -1;
>  	dev->postcopy_ufd = -1;
>  	rte_spinlock_init(&dev->slave_req_lock);
>  
> @@ -644,11 +643,9 @@ void
>  vhost_destroy_device_notify(struct virtio_net *dev)
>  {
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did;
>  
>  	if (dev->flags & VIRTIO_DEV_RUNNING) {
> -		did = dev->vdpa_dev_id;
> -		vdpa_dev = rte_vdpa_get_device(did);
> +		vdpa_dev = dev->vdpa_dev;
>  		if (vdpa_dev && vdpa_dev->ops->dev_close)
>  			vdpa_dev->ops->dev_close(dev->vid);
>  		dev->flags &= ~VIRTIO_DEV_RUNNING;
> @@ -677,17 +674,14 @@ vhost_destroy_device(int vid)
>  }
>  
>  void
> -vhost_attach_vdpa_device(int vid, int did)
> +vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *vdpa_dev)
>  {
>  	struct virtio_net *dev = get_device(vid);
>  
>  	if (dev == NULL)
>  		return;
>  
> -	if (rte_vdpa_get_device(did) == NULL)
> -		return;
> -
> -	dev->vdpa_dev_id = did;
> +	dev->vdpa_dev = vdpa_dev;
>  }
>  
>  void
> @@ -1402,14 +1396,15 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)
>  	return ret;
>  }
>  
> -int rte_vhost_get_vdpa_device_id(int vid)
> +struct rte_vdpa_device *
> +rte_vhost_get_vdpa_device(int vid)
>  {
>  	struct virtio_net *dev = get_device(vid);
>  
>  	if (dev == NULL)
> -		return -1;
> +		return NULL;
>  
> -	return dev->vdpa_dev_id;
> +	return dev->vdpa_dev;
>  }
>  
>  int rte_vhost_get_log_base(int vid, uint64_t *log_base,
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index df98d15de6..819857a65a 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -377,11 +377,7 @@ struct virtio_net {
>  	int			postcopy_ufd;
>  	int			postcopy_listening;
>  
> -	/*
> -	 * Device id to identify a specific backend device.
> -	 * It's set to -1 for the default software implementation.
> -	 */
> -	int			vdpa_dev_id;
> +	struct rte_vdpa_device *vdpa_dev;
>  
>  	/* context data for the external message handlers */
>  	void			*extern_data;
> @@ -639,7 +635,7 @@ void free_vq(struct virtio_net *dev, struct vhost_virtqueue *vq);
>  
>  int alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx);
>  
> -void vhost_attach_vdpa_device(int vid, int did);
> +void vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *dev);
>  
>  void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
>  void vhost_enable_dequeue_zero_copy(int vid);
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index ea9cd107b9..3405cd8c0b 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -315,7 +315,6 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,
>  	uint64_t features = msg->payload.u64;
>  	uint64_t vhost_features = 0;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  
>  	if (validate_msg_fds(msg, 0) != 0)
>  		return RTE_VHOST_MSG_RESULT_ERR;
> @@ -384,8 +383,7 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,
>  		}
>  	}
>  
> -	did = dev->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = dev->vdpa_dev;
>  	if (vdpa_dev && vdpa_dev->ops->set_features)
>  		vdpa_dev->ops->set_features(dev->vid);
>  
> @@ -1971,7 +1969,6 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,
>  	int enable = (int)msg->payload.state.num;
>  	int index = (int)msg->payload.state.index;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  
>  	if (validate_msg_fds(msg, 0) != 0)
>  		return RTE_VHOST_MSG_RESULT_ERR;
> @@ -1980,8 +1977,7 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,
>  		"set queue enable: %d to qp idx: %d\n",
>  		enable, index);
>  
> -	did = dev->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = dev->vdpa_dev;
>  	if (vdpa_dev && vdpa_dev->ops->set_vring_state)
>  		vdpa_dev->ops->set_vring_state(dev->vid, index, enable);
>  
> @@ -2147,7 +2143,6 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct VhostUserMsg *msg,
>  	struct virtio_net *dev = *pdev;
>  	uint8_t *mac = (uint8_t *)&msg->payload.u64;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  
>  	if (validate_msg_fds(msg, 0) != 0)
>  		return RTE_VHOST_MSG_RESULT_ERR;
> @@ -2165,8 +2160,7 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct VhostUserMsg *msg,
>  	 * copied before the flag is set.
>  	 */
>  	__atomic_store_n(&dev->broadcast_rarp, 1, __ATOMIC_RELEASE);
> -	did = dev->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = dev->vdpa_dev;
>  	if (vdpa_dev && vdpa_dev->ops->migration_done)
>  		vdpa_dev->ops->migration_done(dev->vid);
>  
> @@ -2613,7 +2607,6 @@ vhost_user_msg_handler(int vid, int fd)
>  	struct virtio_net *dev;
>  	struct VhostUserMsg msg;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int did = -1;
>  	int ret;
>  	int unlock_required = 0;
>  	bool handled;
> @@ -2805,8 +2798,7 @@ vhost_user_msg_handler(int vid, int fd)
>  		}
>  	}
>  
> -	did = dev->vdpa_dev_id;
> -	vdpa_dev = rte_vdpa_get_device(did);
> +	vdpa_dev = dev->vdpa_dev;
>  	if (vdpa_dev && virtio_is_ready(dev) &&
>  			!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) &&
>  			msg.request.master == VHOST_USER_SET_VRING_CALL) {
> @@ -2955,7 +2947,7 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
>  {
>  	struct virtio_net *dev;
>  	struct rte_vdpa_device *vdpa_dev;
> -	int vfio_device_fd, did, ret = 0;
> +	int vfio_device_fd, ret = 0;
>  	uint64_t offset, size;
>  	unsigned int i;
>  
> @@ -2963,9 +2955,9 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
>  	if (!dev)
>  		return -ENODEV;
>  
> -	did = dev->vdpa_dev_id;
> -	if (did < 0)
> -		return -EINVAL;
> +	vdpa_dev = dev->vdpa_dev;
> +	if (vdpa_dev == NULL)
> +		return -ENODEV;
>  
>  	if (!(dev->features & (1ULL << VIRTIO_F_VERSION_1)) ||
>  	    !(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) ||
> @@ -2977,10 +2969,6 @@ int rte_vhost_host_notifier_ctrl(int vid, bool enable)
>  			(1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER)))
>  		return -ENOTSUP;
>  
> -	vdpa_dev = rte_vdpa_get_device(did);
> -	if (!vdpa_dev)
> -		return -ENODEV;
> -
>  	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_vfio_device_fd, -ENOTSUP);
>  	RTE_FUNC_PTR_OR_ERR_RET(vdpa_dev->ops->get_notify_area, -ENOTSUP);
>  
> 

Acked-by: Adrián Moreno <amorenoz@redhat.com>

-- 
Adrián Moreno


  reply	other threads:[~2020-06-26 10:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 12:26 [dpdk-dev] [PATCH v2 00/14] vDPA API and framework rework Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 01/14] bus/dpaa: fix null pointer dereference Maxime Coquelin
2020-06-26 10:13   ` Adrian Moreno
2020-06-26 10:15     ` Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 02/14] bus/fslmc: " Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 03/14] vhost: introduce vDPA devices class Maxime Coquelin
2020-06-26 10:18   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 04/14] vhost: make vDPA framework bus agnostic Maxime Coquelin
2020-06-26 10:30   ` Adrian Moreno
2020-06-26 11:28     ` Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 05/14] vhost: replace device ID in vDPA ops Maxime Coquelin
2020-06-26 10:34   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 06/14] vhost: replace vDPA device ID in Vhost Maxime Coquelin
2020-06-26 10:38   ` Adrian Moreno [this message]
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 07/14] vhost: replace device ID in applications Maxime Coquelin
2020-06-26 10:44   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 08/14] vhost: remove useless vDPA API Maxime Coquelin
2020-06-26 10:46   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 09/14] vhost: use linked-list for vDPA devices Maxime Coquelin
2020-06-26 11:03   ` Adrian Moreno
2020-06-26 11:20     ` Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 10/12] examples/vdpa: use new wrappers instead of ops Maxime Coquelin
2020-06-24 13:42   ` Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 10/14] vhost: introduce wrappers for some vDPA ops Maxime Coquelin
2020-06-26 11:10   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 11/12] examples/vdpa: remove useless device count Maxime Coquelin
2020-06-24 13:42   ` Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 11/14] examples/vdpa: use new wrappers instead of ops Maxime Coquelin
2020-06-26 11:11   ` Adrian Moreno
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 12/14] examples/vdpa: remove useless device count Maxime Coquelin
2020-06-24 12:26 ` [dpdk-dev] [PATCH v2 12/12] vhost: remove vDPA device count API Maxime Coquelin
2020-06-24 13:42   ` Maxime Coquelin
2020-06-24 12:27 ` [dpdk-dev] [PATCH v2 13/14] " Maxime Coquelin
2020-06-26 11:16   ` Adrian Moreno
2020-06-24 12:27 ` [dpdk-dev] [PATCH v2 14/14] vhost: split vDPA header file Maxime Coquelin
2020-06-26 11:19   ` Adrian Moreno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e93aef8f-2f6d-48f6-e6a4-fe834cbd6cec@redhat.com \
    --to=amorenoz@redhat.com \
    --cc=chenbo.xia@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=grive@u256.net \
    --cc=hemant.agrawal@nxp.com \
    --cc=matan@mellanox.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=sachin.saxena@nxp.com \
    --cc=viacheslavo@mellanox.com \
    --cc=xiao.w.wang@intel.com \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).