From: Maxime Coquelin Date: Mon, 6 Nov 2017 20:38:12 +0000 (+0100) Subject: net/vhost: add parameter to enable IOMMU feature X-Git-Tag: spdx-start~920 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=447e0d379756;p=dpdk.git net/vhost: add parameter to enable IOMMU feature Introduce a new iommu-support parameter to Vhost PMD that passes the RTE_VHOST_USER_IOMMU_SUPPORT flag at vhost device register time. Default value is 0, meaning that IOMMU support is disabled if not specified explicitly. Example to enable IOMMU support for a given device: --vdev 'net_vhost0,iface=/tmp/vhost-user2,iommu-support=1' Signed-off-by: Maxime Coquelin Acked-by: Yuanhan Liu Tested-by: Mark Kavanagh Acked-by: Mark Kavanagh --- diff --git a/doc/guides/nics/vhost.rst b/doc/guides/nics/vhost.rst index e651a16610..4f7ae89905 100644 --- a/doc/guides/nics/vhost.rst +++ b/doc/guides/nics/vhost.rst @@ -66,6 +66,11 @@ The user can specify below arguments in `--vdev` option. It is used to specify the number of queues virtio-net device has. (Default: 1) +#. ``iommu-support``: + + It is used to enable iommu support in vhost library. + (Default: 0 (disabled)) + Vhost PMD event handling ------------------------ diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index f98c980675..a28cc3b9a8 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -52,6 +52,7 @@ enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; #define ETH_VHOST_QUEUES_ARG "queues" #define ETH_VHOST_CLIENT_ARG "client" #define ETH_VHOST_DEQUEUE_ZERO_COPY "dequeue-zero-copy" +#define ETH_VHOST_IOMMU_SUPPORT "iommu-support" #define VHOST_MAX_PKT_BURST 32 static const char *valid_arguments[] = { @@ -59,6 +60,7 @@ static const char *valid_arguments[] = { ETH_VHOST_QUEUES_ARG, ETH_VHOST_CLIENT_ARG, ETH_VHOST_DEQUEUE_ZERO_COPY, + ETH_VHOST_IOMMU_SUPPORT, NULL }; @@ -1164,6 +1166,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev) uint64_t flags = 0; int client_mode = 0; int dequeue_zero_copy = 0; + int iommu_support = 0; RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", rte_vdev_device_name(dev)); @@ -1211,6 +1214,16 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev) flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY; } + if (rte_kvargs_count(kvlist, ETH_VHOST_IOMMU_SUPPORT) == 1) { + ret = rte_kvargs_process(kvlist, ETH_VHOST_IOMMU_SUPPORT, + &open_int, &iommu_support); + if (ret < 0) + goto out_free; + + if (iommu_support) + flags |= RTE_VHOST_USER_IOMMU_SUPPORT; + } + if (dev->device.numa_node == SOCKET_ID_ANY) dev->device.numa_node = rte_socket_id();