diff mbox

[dpdk-dev,RFC,6/7] lib/librte_vhost: Add vhost-cuse/user specific initialization

Message ID 1415272471-3299-7-git-send-email-mukawa@igel.co.jp (mailing list archive)
State RFC, archived
Headers show

Commit Message

Tetsuya Mukawa Nov. 6, 2014, 11:14 a.m. UTC
Initialization of vhost-cuse and vhost-user are different.
To call each initialization, the patch is needed.

Signed-off-by: Tetsuya Mukawa <mukawa@igel.co.jp>
---
 lib/librte_vhost/virtio-net-cdev.c | 12 +++++++++++-
 lib/librte_vhost/virtio-net.c      | 13 ++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/lib/librte_vhost/virtio-net-cdev.c b/lib/librte_vhost/virtio-net-cdev.c
index ac97551..a1ba1f9 100644
--- a/lib/librte_vhost/virtio-net-cdev.c
+++ b/lib/librte_vhost/virtio-net-cdev.c
@@ -42,7 +42,7 @@ 
 #include "eventfd_link/eventfd_link.h"
 
 /* Functions defined in virtio_net.c */
-static void init_device(struct virtio_net *dev);
+static void init_device(struct vhost_device_ctx ctx, struct virtio_net *dev);
 static void cleanup_device(struct virtio_net *dev);
 static void free_device(struct virtio_net_config_ll *ll_dev);
 static int new_device(struct vhost_device_ctx ctx);
@@ -186,6 +186,16 @@  cdev_get_config_ll_root(void)
 	return cdev_ll_root;
 }
 
+
+/**
+ * CUSE specific device initialization.
+ */
+static void
+cdev_init_device(struct vhost_device_ctx ctx __rte_unused,
+		struct virtio_net *dev __rte_unused)
+{
+}
+
 /*
  * Locate the file containing QEMU's memory space and map it to our address space.
  */
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 603bb09..13fbb6f 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -212,7 +212,7 @@  get_config_ll_root(struct vhost_device_ctx ctx)
  *  Initialise all variables in device structure.
  */
 static void
-init_device(struct virtio_net *dev)
+init_device(struct vhost_device_ctx ctx, struct virtio_net *dev)
 {
 	uint64_t vq_offset;
 
@@ -228,6 +228,13 @@  init_device(struct virtio_net *dev)
 	/* Backends are set to -1 indicating an inactive device. */
 	dev->virtqueue[VIRTIO_RXQ]->backend = VIRTIO_DEV_STOPPED;
 	dev->virtqueue[VIRTIO_TXQ]->backend = VIRTIO_DEV_STOPPED;
+
+	switch (ctx.type) {
+	case VHOST_DRV_CUSE:
+		return cdev_init_device(ctx, dev);
+	default:
+		break;
+	}
 }
 
 /*
@@ -273,7 +280,7 @@  new_device(struct vhost_device_ctx ctx)
 	new_ll_dev->dev.virtqueue[VIRTIO_TXQ] = virtqueue_tx;
 
 	/* Initialise device and virtqueues. */
-	init_device(&new_ll_dev->dev);
+	init_device(ctx, &new_ll_dev->dev);
 
 	new_ll_dev->next = NULL;
 
@@ -339,7 +346,7 @@  reset_owner(struct vhost_device_ctx ctx)
 	ll_dev = get_config_ll_entry(ctx);
 
 	cleanup_device(&ll_dev->dev);
-	init_device(&ll_dev->dev);
+	init_device(ctx, &ll_dev->dev);
 
 	return 0;
 }