[dpdk-dev] [PATCH] vhost/crypto: handle virtually non-contiguous buffers

Maxime Coquelin maxime.coquelin at redhat.com
Wed May 16 11:46:24 CEST 2018



On 05/10/2018 05:41 PM, Fan Zhang wrote:
> This patch enables the handling of buffers non-contiguous in
> virtual address space in the vhost_crypto. Instead of using
> rte_vhost_va_from_guest_pa(), the host virtual address is
> converted by vhost_iova_to_vva() for wider use cases.
> 
> For copy mode, the copy length is limited to the chunck size,
> next chuncks VAs being fetched afterward.
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang at intel.com>
> ---
>   lib/librte_vhost/vhost_crypto.c | 201 ++++++++++++++++++++++++++--------------
>   1 file changed, 129 insertions(+), 72 deletions(-)
...
> +	req = get_data_ptr(vc_req, &desc, sizeof(*req), VHOST_ACCESS_RO);
> +	if (unlikely(req == NULL))

Adding braces around the switch would be less error prone IMHO.

> +		switch (vcrypto->option) {
> +		case RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE:
> +			err = VIRTIO_CRYPTO_BADMSG;
> +			VC_LOG_ERR("Invalid descriptor");
> +			goto error_exit;
> +		case RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE:
> +			req = &tmp_req;
> +			if (unlikely(copy_data(req, vc_req, &desc, sizeof(*req))
> +					< 0)) {
> +				err = VIRTIO_CRYPTO_BADMSG;
> +				VC_LOG_ERR("Invalid descriptor");
> +				goto error_exit;
> +			}
> +			break;
> +		default:
> +			err = VIRTIO_CRYPTO_ERR;
> +			VC_LOG_ERR("Invalid option");
> +			goto error_exit;
> +		}
>   

Other than than, it looks good to me.

Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>

I will add the braces when applying.

Thanks,
Maxime


More information about the dev mailing list