From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: snabb-devel@googlegroups.com, thibaut.collet@6wind.com,
qemu-devel@nongnu.org, n.nikolaev@virtualopensystems.com,
luke@snabb.co, thomas.long@intel.com,
Ouyang Changchun <changchun.ouyang@intel.com>
Subject: Re: [Qemu-devel] [PATCH v6 2/2] vhost-user: new protocol feature for multi queue
Date: Tue, 1 Sep 2015 19:42:33 +0800 [thread overview]
Message-ID: <20150901114233.GD3054@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <20150901130858-mutt-send-email-mst@redhat.com>
On Tue, Sep 01, 2015 at 01:09:15PM +0300, Michael S. Tsirkin wrote:
> On Tue, Sep 01, 2015 at 05:16:31PM +0800, Yuanhan Liu wrote:
> > On Thu, Aug 13, 2015 at 12:22:50PM +0300, Michael S. Tsirkin wrote:
> > > On Wed, Aug 12, 2015 at 02:25:42PM +0800, Ouyang Changchun wrote:
> > > > This patch is based on top of "vhost-user: protocol updates" series
> > > > proposed earlier by Michael S. Tsirkin.
> > > >
> > > > Use new message VHOST_USER_SET_VRING_FLAG to enable and disable an
> > > > actual virt queue, which is similar to attach/detach queue for tap device.
> > > > virtio driver on guest doesn't have to use max virt queue pair, it could
> > > > enable any number of virt queue ranging from 1 to max virt queue pair.
> > > >
> > > > It requires that VHOST_USER_F_PROTOCOL_FEATURES is present.
> > > >
> > > > Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
> > > > ---
> > > > This is added since v5
> > > >
> > > > docs/specs/vhost-user.txt | 17 +++++++++++++++++
> > > > hw/net/vhost_net.c | 18 ++++++++++++++++++
> > > > hw/net/virtio-net.c | 2 ++
> > > > hw/virtio/vhost-user.c | 35 +++++++++++++++++++++++++++++++++--
> > > > include/hw/virtio/vhost-backend.h | 2 ++
> > > > include/net/vhost_net.h | 1 +
> > > > 6 files changed, 73 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
> > > > index 9390f89..cca3e5b 100644
> > > > --- a/docs/specs/vhost-user.txt
> > > > +++ b/docs/specs/vhost-user.txt
> > > > @@ -135,6 +135,10 @@ As older slaves don't support negotiating protocol features,
> > > > a feature bit was dedicated for this purpose:
> > > > #define VHOST_USER_F_PROTOCOL_FEATURES 30
> > > >
> > > > +The Slave uses vring flag to notify the vhost-user whether one virtq is enabled
> > > > +or not. This request doesn't require replies:
> > > > +#define VHOST_USER_PROTOCOL_F_VRING_FLAG 2
> > > > +
> > > > Multi queue support
> > > > -------------------
> > > > The protocol supports multiple queues by setting all index fields in the sent
> > > > @@ -306,3 +310,16 @@ Message types
> > > > Bits (0-7) of the payload contain the vring index. Bit 8 is the
> > > > invalid FD flag. This flag is set when there is no file descriptor
> > > > in the ancillary data.
> > > > +
> > > > + * VHOST_USER_SET_VRING_FLAG
> > > > +
> > > > + Id: 18
> > > > + Equivalent ioctl: N/A
> > > > + Master payload: vring state description
> > > > +
> > > > + Set the flag(enable or disable) in the vring, the vhost user backend
> > > > + enable or disable the vring according to state.num. Olny legal if feature
> > > > + bit VHOST_USER_F_PROTOCOL_FEATURES is present in VHOST_USER_GET_FEATURE
> > > > + and feature bit VHOST_USER_PROTOCOL_F_VRING_FLAG is present in
> > > > + VHOST_USER_GET_PROTOCOL_FEATURES. The vring is enabled when state.num is
> > > > + 1, otherwise, the vring is disabled.
> > > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > > > index 9cd6c05..5fa341c 100644
> > > > --- a/hw/net/vhost_net.c
> > > > +++ b/hw/net/vhost_net.c
> > > > @@ -405,6 +405,19 @@ VHostNetState *get_vhost_net(NetClientState *nc)
> > > >
> > > > return vhost_net;
> > > > }
> > > > +
> > > > +int vhost_set_vring_flag(NetClientState *nc, unsigned int enable)
> > > > +{
> > > > + if (nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
> > > > + struct vhost_net *net = get_vhost_net(nc);
> > > > + const VhostOps *vhost_ops = net->dev.vhost_ops;
> > > > + if (vhost_ops->vhost_backend_mq_set_vring_flag)
> > > > + return vhost_ops->vhost_backend_mq_set_vring_flag(&net->dev, enable);
> > > > + }
> > > > +
> > > > + return 0;
> > > > +}
> > > > +
> > > > #else
> > > > struct vhost_net *vhost_net_init(VhostNetOptions *options)
> > > > {
> > > > @@ -455,4 +468,9 @@ VHostNetState *get_vhost_net(NetClientState *nc)
> > > > {
> > > > return 0;
> > > > }
> > > > +
> > > > +int vhost_set_vring_flag(NetClientState *nc, unsigned int enable)
> > > > +{
> > > > + return 0;
> > > > +}
> > > > #endif
> > > > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > > > index 3af6faf..272b77d 100644
> > > > --- a/hw/net/virtio-net.c
> > > > +++ b/hw/net/virtio-net.c
> > > > @@ -396,6 +396,7 @@ static int peer_attach(VirtIONet *n, int index)
> > > > }
> > > >
> > > > if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
> > > > + vhost_set_vring_flag(nc->peer, 1);
> > > > return 0;
> > > > }
> > > >
> > > > @@ -411,6 +412,7 @@ static int peer_detach(VirtIONet *n, int index)
> > > > }
> > > >
> > > > if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
> > > > + vhost_set_vring_flag(nc->peer, 0);
> > > > return 0;
> > > > }
> > > >
> > > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> > > > index fb11d4c..d806ce2 100644
> > > > --- a/hw/virtio/vhost-user.c
> > > > +++ b/hw/virtio/vhost-user.c
> > > > @@ -25,7 +25,8 @@
> > > >
> > > > #define VHOST_MEMORY_MAX_NREGIONS 8
> > > > #define VHOST_USER_F_PROTOCOL_FEATURES 30
> > > > -#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x0ULL
> > > > +#define VHOST_USER_PROTOCOL_F_VRING_FLAG 2
> > > > +#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x7ULL
> > > >
> > > > typedef enum VhostUserRequest {
> > > > VHOST_USER_NONE = 0,
> > > > @@ -45,6 +46,7 @@ typedef enum VhostUserRequest {
> > > > VHOST_USER_SET_VRING_ERR = 14,
> > > > VHOST_USER_GET_PROTOCOL_FEATURES = 15,
> > > > VHOST_USER_SET_PROTOCOL_FEATURES = 16,
> > > > + VHOST_USER_SET_VRING_FLAG = 18,
> > > > VHOST_USER_MAX
> > > > } VhostUserRequest;
> > > >
> > > > @@ -399,6 +401,34 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
> > > > return 0;
> > > > }
> > > >
> > > > +static int vhost_user_set_vring_flag(struct vhost_dev *dev, unsigned int enable)
> > > > +{
> > > > + VhostUserMsg msg = { 0 };
> > > > + int err;
> > > > +
> > > > + assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
> > > > +
> > > > + if ((dev->backend_features & ( 1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) == 0)
> > > > + return -1;
> > > > +
> > > > + if ((dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_VRING_FLAG)) == 0)
> > > > + return -1;
> > > > +
> > > > + msg.request = VHOST_USER_SET_VRING_FLAG;
> > > > + msg.flags = VHOST_USER_VERSION;
> > > > + /* Set the virt queue pair index */
> > > > + msg.state.index = dev->vq_index / 2;
> > >
> > > Thinking about this, this means that the index value is specific to virtio net.
> > > This seems wrong.
> >
> > How about adding a new field queue_index to vhost_dev structure? So that
> > we could get rid of it.
> >
> > --yliu
>
> don't we have it already?
>
> /* the first virtqueue which would be used by this vhost dev */
> int vq_index;
Here queue_index is meant to the index of queue pair, while vq_index is
index of virtio net queue, which simply equals to 2 * queue_index.
Then, maybe we could do as Changchun suggested:
msg.state.index = dev->vp_index;
So that we could get rid of the '/2' hack(btw, is that what you worried
about?), and let the backend do the virtio queue index to queue pair index
convertion, aka, divide by 2.
--yliu
next prev parent reply other threads:[~2015-09-01 11:40 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 1:23 [Qemu-devel] [PATCH v5] vhost-user: add multi queue support Ouyang Changchun
2015-07-08 14:29 ` Michael S. Tsirkin
2015-07-08 22:00 ` Maxime Leroy
2015-07-09 1:29 ` [Qemu-devel] [snabb-devel] " Ouyang, Changchun
2015-07-09 7:31 ` Michael S. Tsirkin
2015-07-09 7:06 ` [Qemu-devel] " Michael S. Tsirkin
2015-07-09 12:00 ` Martin Kletzander
2015-07-09 12:24 ` Maxime Leroy
2015-07-09 12:33 ` Martin Kletzander
2015-07-09 12:54 ` Michael S. Tsirkin
2015-08-12 6:25 ` [Qemu-devel] [PATCH v6 0/2] vhost-user " Ouyang Changchun
2015-08-12 6:25 ` [Qemu-devel] [PATCH v6 1/2] vhost-user: add " Ouyang Changchun
2015-08-13 9:18 ` Michael S. Tsirkin
2015-08-13 10:24 ` Maxime Leroy
2015-08-13 10:55 ` Michael S. Tsirkin
2015-08-25 3:25 ` [Qemu-devel] [snabb-devel] " Ouyang, Changchun
2015-08-27 13:05 ` Michael S. Tsirkin
2015-08-28 1:53 ` Ouyang, Changchun
2015-08-30 6:16 ` Michael S. Tsirkin
2015-08-31 8:29 ` Ouyang, Changchun
2015-08-31 11:30 ` Michael S. Tsirkin
2015-08-31 15:04 ` Eric Blake
2015-09-01 9:20 ` Yuanhan Liu
2015-09-01 9:41 ` Michael S. Tsirkin
2015-09-01 12:16 ` Yuanhan Liu
2015-09-01 9:13 ` [Qemu-devel] " Yuanhan Liu
2015-09-01 10:07 ` Michael S. Tsirkin
2015-09-01 12:15 ` Yuanhan Liu
2015-09-01 14:10 ` Michael S. Tsirkin
2015-09-02 5:45 ` Ouyang, Changchun
2015-09-02 12:10 ` Michael S. Tsirkin
2015-09-07 11:07 ` Marcel Apfelbaum
2015-09-07 12:26 ` Michael S. Tsirkin
2015-09-07 13:08 ` Marcel Apfelbaum
2015-08-12 6:25 ` [Qemu-devel] [PATCH v6 2/2] vhost-user: new protocol feature for multi queue Ouyang Changchun
2015-08-13 9:22 ` Michael S. Tsirkin
2015-08-24 1:50 ` [Qemu-devel] [snabb-devel] " Ouyang, Changchun
2015-09-01 9:16 ` [Qemu-devel] " Yuanhan Liu
2015-09-01 10:09 ` Michael S. Tsirkin
2015-09-01 11:42 ` Yuanhan Liu [this message]
2015-08-30 15:28 ` [Qemu-devel] [PATCH v5] vhost-user: add multi queue support Marcel Apfelbaum
2015-08-31 5:28 ` Ouyang, Changchun
2015-08-31 5:42 ` Xu, Qian Q
2015-08-31 8:55 ` Marcel Apfelbaum
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=20150901114233.GD3054@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=changchun.ouyang@intel.com \
--cc=luke@snabb.co \
--cc=mst@redhat.com \
--cc=n.nikolaev@virtualopensystems.com \
--cc=qemu-devel@nongnu.org \
--cc=snabb-devel@googlegroups.com \
--cc=thibaut.collet@6wind.com \
--cc=thomas.long@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.