From: Aaron Conole <aconole@redhat.com>
To: Nikos Dragazis <ndragazis@arrikto.com>
Cc: dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>,
Tiwei Bie <tiwei.bie@intel.com>,
Zhihong Wang <zhihong.wang@intel.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Wei Wang <wei.w.wang@intel.com>,
Stojaczyk Dariusz <dariusz.stojaczyk@intel.com>,
Vangelis Koukis <vkoukis@arrikto.com>
Subject: Re: [dpdk-dev] [PATCH 01/28] vhost: introduce vhost transport operations structure
Date: Wed, 19 Jun 2019 16:14:09 -0400 [thread overview]
Message-ID: <f7th88lnxim.fsf@dhcp-25.97.bos.redhat.com> (raw)
In-Reply-To: <1560957293-17294-2-git-send-email-ndragazis@arrikto.com> (Nikos Dragazis's message of "Wed, 19 Jun 2019 18:14:26 +0300")
Nikos Dragazis <ndragazis@arrikto.com> writes:
> This is the first of a series of patches, whose purpose is to add
> support for the virtio-vhost-user transport. This is a vhost-user
> transport implementation that is different from the default AF_UNIX
> transport. It uses the virtio-vhost-user PCI device in order to tunnel
> vhost-user protocol messages over virtio. This lets guests act as vhost
> device backends for other guests.
>
> File descriptor passing is specific to the AF_UNIX vhost-user protocol
> transport. In order to add support for additional transports, it is
> necessary to extract transport-specific code from the main vhost-user
> code.
>
> This patch introduces struct vhost_transport_ops and associates each
> device with a transport. Core vhost-user code calls into
> vhost_transport_ops to perform transport-specific operations.
>
> Notifying callfd is a transport-specific operation, so it belongs to
> trans_af_unix.c.
>
> Several more patches follow this one to complete the task of moving
> AF_UNIX transport code out of core vhost-user code.
>
> Signed-off-by: Nikos Dragazis <ndragazis@arrikto.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
You'll need to also accommodate the meson build - probably with
something like:
diff --git a/lib/librte_vhost/meson.build b/lib/librte_vhost/meson.build
index 3090bbe08..81b70683b 100644
--- a/lib/librte_vhost/meson.build
+++ b/lib/librte_vhost/meson.build
@@ -14,6 +14,6 @@ allow_experimental_apis = true
cflags += '-fno-strict-aliasing'
sources = files('fd_man.c', 'iotlb.c', 'socket.c', 'vdpa.c',
'vhost.c', 'vhost_user.c',
- 'virtio_net.c', 'vhost_crypto.c')
+ 'virtio_net.c', 'vhost_crypto.c', 'trans_af_unix.c')
headers = files('rte_vhost.h', 'rte_vdpa.h', 'rte_vhost_crypto.h')
deps += ['ethdev', 'cryptodev', 'hash', 'pci']
> lib/librte_vhost/Makefile | 2 +-
> lib/librte_vhost/trans_af_unix.c | 20 ++++++++++++++++++++
> lib/librte_vhost/vhost.c | 1 +
> lib/librte_vhost/vhost.h | 34 +++++++++++++++++++++++++++++-----
> 4 files changed, 51 insertions(+), 6 deletions(-)
> create mode 100644 lib/librte_vhost/trans_af_unix.c
>
> diff --git a/lib/librte_vhost/Makefile b/lib/librte_vhost/Makefile
> index 8623e91..5ff5fb2 100644
> --- a/lib/librte_vhost/Makefile
> +++ b/lib/librte_vhost/Makefile
> @@ -23,7 +23,7 @@ LDLIBS += -lrte_eal -lrte_mempool -lrte_mbuf -lrte_ethdev -lrte_net
>
> # all source are stored in SRCS-y
> SRCS-$(CONFIG_RTE_LIBRTE_VHOST) := fd_man.c iotlb.c socket.c vhost.c \
> - vhost_user.c virtio_net.c vdpa.c
> + vhost_user.c virtio_net.c vdpa.c trans_af_unix.c
>
> # install includes
> SYMLINK-$(CONFIG_RTE_LIBRTE_VHOST)-include += rte_vhost.h rte_vdpa.h
> diff --git a/lib/librte_vhost/trans_af_unix.c b/lib/librte_vhost/trans_af_unix.c
> new file mode 100644
> index 0000000..3f0c308
> --- /dev/null
> +++ b/lib/librte_vhost/trans_af_unix.c
> @@ -0,0 +1,20 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2018 Intel Corporation
> + * Copyright(c) 2017 Red Hat, Inc.
> + * Copyright(c) 2019 Arrikto Inc.
> + */
> +
> +#include "vhost.h"
> +
> +static int
> +af_unix_vring_call(struct virtio_net *dev __rte_unused,
> + struct vhost_virtqueue *vq)
> +{
> + if (vq->callfd >= 0)
> + eventfd_write(vq->callfd, (eventfd_t)1);
> + return 0;
> +}
> +
> +const struct vhost_transport_ops af_unix_trans_ops = {
> + .vring_call = af_unix_vring_call,
> +};
> diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
> index 981837b..a36bc01 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -507,6 +507,7 @@ vhost_new_device(void)
> dev->vid = i;
> dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
> dev->slave_req_fd = -1;
> + dev->trans_ops = &af_unix_trans_ops;
> dev->vdpa_dev_id = -1;
> dev->postcopy_ufd = -1;
> rte_spinlock_init(&dev->slave_req_lock);
> diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
> index 884befa..077f213 100644
> --- a/lib/librte_vhost/vhost.h
> +++ b/lib/librte_vhost/vhost.h
> @@ -286,6 +286,30 @@ struct guest_page {
> uint64_t size;
> };
>
> +struct virtio_net;
> +
> +/**
> + * A structure containing function pointers for transport-specific operations.
> + */
> +struct vhost_transport_ops {
> + /**
> + * Notify the guest that used descriptors have been added to the vring.
> + * The VRING_AVAIL_F_NO_INTERRUPT flag and event idx have already been checked
> + * so this function just needs to perform the notification.
> + *
> + * @param dev
> + * vhost device
> + * @param vq
> + * vhost virtqueue
> + * @return
> + * 0 on success, -1 on failure
> + */
> + int (*vring_call)(struct virtio_net *dev, struct vhost_virtqueue *vq);
> +};
> +
> +/** The traditional AF_UNIX vhost-user protocol transport. */
> +extern const struct vhost_transport_ops af_unix_trans_ops;
> +
> /**
> * Device structure contains all configuration information relating
> * to the device.
> @@ -312,6 +336,7 @@ struct virtio_net {
> uint16_t mtu;
>
> struct vhost_device_ops const *notify_ops;
> + struct vhost_transport_ops const *trans_ops;
>
> uint32_t nr_guest_pages;
> uint32_t max_guest_pages;
> @@ -544,12 +569,11 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
> if ((vhost_need_event(vhost_used_event(vq), new, old) &&
> (vq->callfd >= 0)) ||
> unlikely(!signalled_used_valid))
> - eventfd_write(vq->callfd, (eventfd_t) 1);
> + dev->trans_ops->vring_call(dev, vq);
> } else {
> /* Kick the guest if necessary. */
> - if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT)
> - && (vq->callfd >= 0))
> - eventfd_write(vq->callfd, (eventfd_t)1);
> + if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT))
> + dev->trans_ops->vring_call(dev, vq);
> }
> }
>
> @@ -601,7 +625,7 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
> kick = true;
> kick:
> if (kick)
> - eventfd_write(vq->callfd, (eventfd_t)1);
> + dev->trans_ops->vring_call(dev, vq);
> }
>
> static __rte_always_inline void
next prev parent reply other threads:[~2019-06-19 20:14 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 15:14 [dpdk-dev] [PATCH 00/28] vhost: add virtio-vhost-user transport Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 01/28] vhost: introduce vhost transport operations structure Nikos Dragazis
2019-06-19 20:14 ` Aaron Conole [this message]
2019-06-20 10:30 ` Bruce Richardson
2019-06-20 18:24 ` Nikos Dragazis
2019-06-20 18:19 ` Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 02/28] vhost: move socket management code Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 03/28] vhost: allocate per-socket transport state Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 04/28] vhost: move socket fd and un sockaddr Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 05/28] vhost: move start server/client calls Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 06/28] vhost: move vhost-user connection Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 07/28] vhost: move vhost-user reconnection Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 08/28] vhost: move vhost-user fdset Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 09/28] vhost: propagate vhost transport operations Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 10/28] vhost: use a single structure for the device state Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 11/28] vhost: extract socket I/O into transport Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 12/28] vhost: move slave request fd and lock Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 13/28] vhost: move mmap/munmap Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 14/28] vhost: move setup of the log memory region Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 15/28] vhost: remove main fd parameter from msg handlers Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 16/28] vhost: move postcopy live migration code Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 17/28] vhost: support registering additional vhost-user transports Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 18/28] drivers/virtio_vhost_user: add virtio PCI framework Nikos Dragazis
2019-09-05 16:34 ` Maxime Coquelin
2019-09-09 8:42 ` Nikos Dragazis
2019-09-09 8:44 ` Maxime Coquelin
2019-06-19 15:14 ` [dpdk-dev] [PATCH 19/28] vhost: add index field in vhost virtqueues Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 20/28] drivers: add virtio-vhost-user transport Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 21/28] drivers/virtio_vhost_user: use additional device resources Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 22/28] vhost: add flag for choosing vhost-user transport Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 23/28] net/vhost: add virtio-vhost-user support Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 24/28] examples/vhost_scsi: add --socket-file argument Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 25/28] examples/vhost_scsi: add virtio-vhost-user support Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 26/28] mk: link apps with virtio-vhost-user driver Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 27/28] config: add option for the virtio-vhost-user transport Nikos Dragazis
2019-06-19 15:14 ` [dpdk-dev] [PATCH 28/28] usertools: add virtio-vhost-user devices to dpdk-devbind.py Nikos Dragazis
[not found] ` <CGME20190620113240eucas1p22ca4faa64a36bbb7aec38a81298ade56@eucas1p2.samsung.com>
2019-06-20 11:32 ` [dpdk-dev] [PATCH 00/28] vhost: add virtio-vhost-user transport Ilya Maximets
2019-06-20 23:44 ` Nikos Dragazis
2019-06-20 11:35 ` Maxime Coquelin
2019-06-22 20:26 ` Nikos Dragazis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7th88lnxim.fsf@dhcp-25.97.bos.redhat.com \
--to=aconole@redhat.com \
--cc=dariusz.stojaczyk@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=ndragazis@arrikto.com \
--cc=stefanha@redhat.com \
--cc=tiwei.bie@intel.com \
--cc=vkoukis@arrikto.com \
--cc=wei.w.wang@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).