[dpdk-dev] [PATCH 08/15] net/virtio: add virtio vDPA op to get features

Tiwei Bie tiwei.bie at intel.com
Mon Sep 2 08:43:40 CEST 2019


On Thu, Aug 29, 2019 at 09:59:53AM +0200, Maxime Coquelin wrote:
> This patch implements the vDPA .get_features() callback.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
>  drivers/net/virtio/virtio_vdpa.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_vdpa.c b/drivers/net/virtio/virtio_vdpa.c
> index 07ff1e090..9e2af8313 100644
> --- a/drivers/net/virtio/virtio_vdpa.c
> +++ b/drivers/net/virtio/virtio_vdpa.c
> @@ -173,8 +173,40 @@ virtio_vdpa_get_queue_num(int did, uint32_t *queue_num)
>  	return 0;
>  }
>  
> +static int
> +virtio_vdpa_get_features(int did, uint64_t *features)
> +{
> +	struct internal_list *list;
> +	struct virtio_vdpa_device *dev;
> +
> +	list = find_internal_resource_by_did(did);
> +	if (list == NULL) {
> +		DRV_LOG(ERR, "Invalid device id: %d", did);
> +		return -1;
> +	}
> +
> +	dev = list->dev;
> +
> +	*features = VTPCI_OPS(&dev->hw)->get_features(&dev->hw);
> +
> +	if (!(*features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))) {
> +		DRV_LOG(ERR, "Device does not support IOMMU");
> +		return -1;
> +	}
> +
> +	if (*features & (1ULL << VIRTIO_NET_F_CTRL_VQ))
> +		dev->has_ctrl_vq = true;
> +	else
> +		dev->has_ctrl_vq = false;
> +
> +	*features |= (1ULL << VHOST_USER_F_PROTOCOL_FEATURES);

We need to drop the VIRTIO_F_IOMMU_PLATFORM bit before
reporting features to the upper layer as the vDPA backend
doesn't support the vIOMMU yet.

Regards,
Tiwei


> +
> +	return 0;
> +}
> +
>  static struct rte_vdpa_dev_ops virtio_vdpa_ops = {
>  	.get_queue_num = virtio_vdpa_get_queue_num,
> +	.get_features = virtio_vdpa_get_features,
>  };
>  
>  static inline int
> -- 
> 2.21.0
> 


More information about the dev mailing list