net/vhost: add options for linear and external buffer
[dpdk.git] / drivers / net / vhost / rte_eth_vhost.c
index 4a7b1b6..4d255c6 100644 (file)
@@ -32,6 +32,8 @@ enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
 #define ETH_VHOST_IOMMU_SUPPORT                "iommu-support"
 #define ETH_VHOST_POSTCOPY_SUPPORT     "postcopy-support"
 #define ETH_VHOST_VIRTIO_NET_F_HOST_TSO "tso"
+#define ETH_VHOST_LINEAR_BUF  "linear-buffer"
+#define ETH_VHOST_EXT_BUF  "ext-buffer"
 #define VHOST_MAX_PKT_BURST 32
 
 static const char *valid_arguments[] = {
@@ -42,6 +44,8 @@ static const char *valid_arguments[] = {
        ETH_VHOST_IOMMU_SUPPORT,
        ETH_VHOST_POSTCOPY_SUPPORT,
        ETH_VHOST_VIRTIO_NET_F_HOST_TSO,
+       ETH_VHOST_LINEAR_BUF,
+       ETH_VHOST_EXT_BUF,
        NULL
 };
 
@@ -876,6 +880,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
        unsigned int numa_node = eth_dev->device->numa_node;
        const char *name = eth_dev->device->name;
 
+       /* Don't try to setup again if it has already been done. */
+       list = find_internal_resource(internal->iface_name);
+       if (list)
+               return 0;
+
        list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
        if (list == NULL)
                return -1;
@@ -1386,6 +1395,8 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
        int iommu_support = 0;
        int postcopy_support = 0;
        int tso = 0;
+       int linear_buf = 0;
+       int ext_buf = 0;
        struct rte_eth_dev *eth_dev;
        const char *name = rte_vdev_device_name(dev);
 
@@ -1483,6 +1494,28 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev)
                }
        }
 
+       if (rte_kvargs_count(kvlist, ETH_VHOST_LINEAR_BUF) == 1) {
+               ret = rte_kvargs_process(kvlist,
+                               ETH_VHOST_LINEAR_BUF,
+                               &open_int, &linear_buf);
+               if (ret < 0)
+                       goto out_free;
+
+               if (linear_buf == 1)
+                       flags |= RTE_VHOST_USER_LINEARBUF_SUPPORT;
+       }
+
+       if (rte_kvargs_count(kvlist, ETH_VHOST_EXT_BUF) == 1) {
+               ret = rte_kvargs_process(kvlist,
+                               ETH_VHOST_EXT_BUF,
+                               &open_int, &ext_buf);
+               if (ret < 0)
+                       goto out_free;
+
+               if (ext_buf == 1)
+                       flags |= RTE_VHOST_USER_EXTBUF_SUPPORT;
+       }
+
        if (dev->device.numa_node == SOCKET_ID_ANY)
                dev->device.numa_node = rte_socket_id();
 
@@ -1534,7 +1567,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_vhost,
        "dequeue-zero-copy=<0|1> "
        "iommu-support=<0|1> "
        "postcopy-support=<0|1> "
-       "tso=<0|1>");
+       "tso=<0|1> "
+       "linear-buffer=<0|1> "
+       "ext-buffer=<0|1>");
 
 RTE_INIT(vhost_init_log)
 {