From patchwork Wed Jun 19 15:14:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Dragazis X-Patchwork-Id: 54988 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CA6411C433; Wed, 19 Jun 2019 17:16:41 +0200 (CEST) Received: from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59]) by dpdk.org (Postfix) with ESMTP id E6A831C3A1 for ; Wed, 19 Jun 2019 17:15:46 +0200 (CEST) Received: from troi.prod.arr (mail.arr [10.99.0.5]) by mx0.arrikto.com (Postfix) with ESMTP id B640818201A; Wed, 19 Jun 2019 18:15:46 +0300 (EEST) Received: from localhost.localdomain (unknown [10.89.50.133]) by troi.prod.arr (Postfix) with ESMTPSA id 38033394; Wed, 19 Jun 2019 18:15:46 +0300 (EEST) From: Nikos Dragazis To: dev@dpdk.org Cc: Maxime Coquelin , Tiwei Bie , Zhihong Wang , Stefan Hajnoczi , Wei Wang , Stojaczyk Dariusz , Vangelis Koukis Date: Wed, 19 Jun 2019 18:14:47 +0300 Message-Id: <1560957293-17294-23-git-send-email-ndragazis@arrikto.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560957293-17294-1-git-send-email-ndragazis@arrikto.com> References: <1560957293-17294-1-git-send-email-ndragazis@arrikto.com> Subject: [dpdk-dev] [PATCH 22/28] vhost: add flag for choosing vhost-user transport X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Extend the API to support the virtio-vhost-user transport as an alternative to the AF_UNIX transport. The caller provides a PCI DomBDF address: rte_vhost_driver_register("0000:00:04.0", RTE_VHOST_USER_VIRTIO_TRANSPORT); Signed-off-by: Nikos Dragazis Signed-off-by: Stefan Hajnoczi --- drivers/virtio_vhost_user/trans_virtio_vhost_user.c | 4 ++++ lib/librte_vhost/rte_vhost.h | 1 + lib/librte_vhost/socket.c | 19 ++++++++++++++++++- lib/librte_vhost/vhost.h | 6 +++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/virtio_vhost_user/trans_virtio_vhost_user.c b/drivers/virtio_vhost_user/trans_virtio_vhost_user.c index 45863bd..04dbbb1 100644 --- a/drivers/virtio_vhost_user/trans_virtio_vhost_user.c +++ b/drivers/virtio_vhost_user/trans_virtio_vhost_user.c @@ -979,6 +979,10 @@ vvu_pci_init(void) } rte_pci_register(&vvu_pci_driver); + if (rte_vhost_register_transport(VHOST_TRANSPORT_VVU, &virtio_vhost_user_trans_ops) < 0) { + RTE_LOG(ERR, VHOST_CONFIG, + "Registration of vhost-user transport (%d) failed\n", VHOST_TRANSPORT_VVU); + } } static int diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 0226b3e..0573238 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -29,6 +29,7 @@ extern "C" { #define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2) #define RTE_VHOST_USER_IOMMU_SUPPORT (1ULL << 3) #define RTE_VHOST_USER_POSTCOPY_SUPPORT (1ULL << 4) +#define RTE_VHOST_USER_VIRTIO_TRANSPORT (1ULL << 5) /** Protocol features. */ #ifndef VHOST_USER_PROTOCOL_F_MQ diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index fe1c78d..1295fdd 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -327,7 +327,16 @@ rte_vhost_driver_register(const char *path, uint64_t flags) goto out; } - trans_ops = g_transport_map[VHOST_TRANSPORT_UNIX]; + if (flags & RTE_VHOST_USER_VIRTIO_TRANSPORT) { + trans_ops = g_transport_map[VHOST_TRANSPORT_VVU]; + if (trans_ops == NULL) { + RTE_LOG(ERR, VHOST_CONFIG, + "virtio-vhost-user transport is not supported\n"); + goto out; + } + } else { + trans_ops = g_transport_map[VHOST_TRANSPORT_UNIX]; + } if (!path) return -1; @@ -400,6 +409,14 @@ rte_vhost_driver_register(const char *path, uint64_t flags) "Postcopy requested but not compiled\n"); ret = -1; goto out_free; +#else + if (flags & RTE_VHOST_USER_VIRTIO_TRANSPORT) { + RTE_LOG(ERR, VHOST_CONFIG, + "Postcopy requested but not supported " + "by the virtio-vhost-user transport\n"); + ret = -1; + goto out_free; + } #endif } diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 2e7eabe..a6131da 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -494,9 +494,13 @@ struct vhost_transport_ops { /** The traditional AF_UNIX vhost-user protocol transport. */ extern const struct vhost_transport_ops af_unix_trans_ops; +/** The virtio-vhost-user PCI vhost-user protocol transport. */ +extern const struct vhost_transport_ops virtio_vhost_user_trans_ops; + typedef enum VhostUserTransport { VHOST_TRANSPORT_UNIX = 0, - VHOST_TRANSPORT_MAX = 1 + VHOST_TRANSPORT_VVU = 1, + VHOST_TRANSPORT_MAX = 2 } VhostUserTransport; /* A list with all the available vhost-user transports. */