[dpdk-dev] [PATCH v6 4/5] vhost: unify message handling function signature

Maxime Coquelin maxime.coquelin at redhat.com
Tue Oct 2 10:59:01 CEST 2018



On 09/24/2018 10:17 PM, Nikolay Nikolaev wrote:
> Each vhost-user message handling function will return an int result
> which is described in the new enum vh_result: error, OK and reply.
> All functions will now have two arguments, virtio_net double pointer
> and VhostUserMsg pointer.
> 
> Signed-off-by: Nikolay Nikolaev <nicknickolaev at gmail.com>
> ---
>   lib/librte_vhost/vhost_user.c |  211 ++++++++++++++++++++++++-----------------
>   1 file changed, 125 insertions(+), 86 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 77905dda0..e1b705fa7 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -71,6 +71,16 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {
>   	[VHOST_USER_CRYPTO_CLOSE_SESS] = "VHOST_USER_CRYPTO_CLOSE_SESS",
>   };
>   
> +/* The possible results of a message handling function */
> +enum vh_result {
> +	/* Message handling failed */
> +	VH_RESULT_ERR   = -1,
> +	/* Message handling successful */
> +	VH_RESULT_OK    =  0,
> +	/* Message handling successful and reply prepared */
> +	VH_RESULT_REPLY =  1,
> +};
> +


> -vhost_user_get_vring_base(struct virtio_net *dev,
> +vhost_user_get_vring_base(struct virtio_net **pdev,
>   			  struct VhostUserMsg *msg)
>   {
> +	struct virtio_net *dev = *pdev;
>   	struct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];
>   
>   	/* We have to stop the queue (virtio) if it is running. */
> @@ -1135,7 +1161,7 @@ vhost_user_get_vring_base(struct virtio_net *dev,
>   
>   	msg->size = sizeof(msg->payload.state);
>   
> -	return 0;
> +	return VH_RESULT_OK;
>   }

VH_RESULT_REPLY here.

> -static void
> -vhost_user_get_protocol_features(struct virtio_net *dev,
> +static int
> +vhost_user_get_protocol_features(struct virtio_net **pdev,
>   				 struct VhostUserMsg *msg)
>   {
> +	struct virtio_net *dev = *pdev;
>   	uint64_t features, protocol_features;
>   
>   	rte_vhost_driver_get_features(dev->ifname, &features);
> @@ -1189,40 +1217,46 @@ vhost_user_get_protocol_features(struct virtio_net *dev,
>   
>   	msg->payload.u64 = protocol_features;
>   	msg->size = sizeof(msg->payload.u64);
> +
> +	return VH_RESULT_OK;
>   }

Ditto.

I have the patches to fix these, it will be posted as preliminary part 
of my postcopy series.

Please, next time, test your series before posting.

Thanks,
Maxime


More information about the dev mailing list