From patchwork Thu Nov 6 11:14:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1155 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id DEAF37F80; Thu, 6 Nov 2014 12:05:52 +0100 (CET) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id 804F37F34 for ; Thu, 6 Nov 2014 12:05:41 +0100 (CET) Received: by mail-pa0-f46.google.com with SMTP id lf10so1058302pab.33 for ; Thu, 06 Nov 2014 03:15:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j3nJ/658Kjk1mOWVWVgknC9SZ4hGk5A8jg1RhI25/Ls=; b=ByvJD+dqhEqJuMH7EpQ4bsobjRA8iAuF00xv/plXO39P1820Xp8bMZKjWDK6OMQX// PcuzhO7LgaYXjJ9J2W1Dh5jyAMIJ6aJ0ufOUHPufMOlUH429KEXQzLTheRkzZbZA1IsI SgTQXlVCT0+YdzFd6Pv7s9S7ggMefYqthRUAzcOYmcJ3Yln2PeRYb43GB3sPnNdgBcf9 LhVySY1FlvHa10O22V6UeTAiWA0Zgvl9ptpl6ph1wSNUI33wTOIZH/bZAeGISkou4Uk2 epVaCTGYq2944XZuGNrbZ4YpkqxUD9PSueOQfsw6VyARNSD5xIZn+/G1MMYKPLdadccQ KD8g== X-Gm-Message-State: ALoCoQlNPvrkn6a/uBrMIlauWoIR+wxhfWW6F7pk0ZJD0jbjcI/Lh4gyweM2EEfOScvtLWLYHgnz X-Received: by 10.68.68.132 with SMTP id w4mr3529346pbt.93.1415272507992; Thu, 06 Nov 2014 03:15:07 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id jc3sm5652315pbb.49.2014.11.06.03.15.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Nov 2014 03:15:07 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 6 Nov 2014 20:14:30 +0900 Message-Id: <1415272471-3299-7-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> References: <1415272471-3299-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [RFC PATCH 6/7] lib/librte_vhost: Add vhost-cuse/user specific initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Initialization of vhost-cuse and vhost-user are different. To call each initialization, the patch is needed. Signed-off-by: Tetsuya Mukawa --- lib/librte_vhost/virtio-net-cdev.c | 12 +++++++++++- lib/librte_vhost/virtio-net.c | 13 ++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) 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; }