From: Marcel Apfelbaum <marcel@redhat.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>, qemu-devel@nongnu.org
Cc: jasowang@redhat.com, Changchun.ouyang@hotmail.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v11 4/7] vhost-user: add VHOST_USER_GET_QUEUE_NUM message
Date: Thu, 24 Sep 2015 13:25:08 +0300 [thread overview]
Message-ID: <5603CF84.2020803@redhat.com> (raw)
In-Reply-To: <1442982001-10669-5-git-send-email-yuanhan.liu@linux.intel.com>
On 09/23/2015 07:19 AM, Yuanhan Liu wrote:
> This is for querying how many queues the backend supports if it has mq
> support(when VHOST_USER_PROTOCOL_F_MQ flag is set from the quried
/s/quried/queried
Only if you plan to send another version, we can fix it on top.
> protocol features).
>
> vhost_net_get_max_queues() is the interface to export that value, and
> to tell if the backend supports # of queues user requested, which is
> done in the following patch.
>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>
> ---
> v11: define a dummy vhost_net_get_max_queues when !CONFIG_VHOST_NET.
> ---
> docs/specs/vhost-user.txt | 11 +++++++++++
> hw/net/vhost_net.c | 12 ++++++++++++
> hw/virtio/vhost-user.c | 15 ++++++++++++++-
> include/hw/virtio/vhost.h | 1 +
> include/net/vhost_net.h | 1 +
> 5 files changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
> index ccbbcbb..43db9b4 100644
> --- a/docs/specs/vhost-user.txt
> +++ b/docs/specs/vhost-user.txt
> @@ -301,3 +301,14 @@ 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_GET_QUEUE_NUM
> +
> + Id: 17
> + Equivalent ioctl: N/A
> + Master payload: N/A
> + Slave payload: u64
> +
> + Query how many queues the backend supports. This request should be
> + sent only when VHOST_USER_PROTOCOL_F_MQ is set in quried protocol
> + features by VHOST_USER_GET_PROTOCOL_FEATURES.
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index b7d29b7..f663e5a 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -122,6 +122,11 @@ void vhost_net_ack_features(struct vhost_net *net, uint64_t features)
> vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
> }
>
> +uint64_t vhost_net_get_max_queues(VHostNetState *net)
> +{
> + return net->dev.max_queues;
> +}
> +
> static int vhost_net_get_fd(NetClientState *backend)
> {
> switch (backend->info->type) {
> @@ -144,6 +149,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
> goto fail;
> }
>
> + net->dev.max_queues = 1;
> +
> if (backend_kernel) {
> r = vhost_net_get_fd(options->net_backend);
> if (r < 0) {
> @@ -414,6 +421,11 @@ VHostNetState *get_vhost_net(NetClientState *nc)
> return vhost_net;
> }
> #else
> +uint64_t vhost_net_get_max_queues(VHostNetState *net)
> +{
> + return 1;
> +}
> +
> struct vhost_net *vhost_net_init(VhostNetOptions *options)
> {
> error_report("vhost-net support is not compiled in");
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 9cb2f52..694fde5 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -25,7 +25,9 @@
>
> #define VHOST_MEMORY_MAX_NREGIONS 8
> #define VHOST_USER_F_PROTOCOL_FEATURES 30
> -#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x0ULL
> +#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x1ULL
> +
> +#define VHOST_USER_PROTOCOL_F_MQ 0
>
> typedef enum VhostUserRequest {
> VHOST_USER_NONE = 0,
> @@ -45,6 +47,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_SET_VRING_ERR = 14,
> VHOST_USER_GET_PROTOCOL_FEATURES = 15,
> VHOST_USER_SET_PROTOCOL_FEATURES = 16,
> + VHOST_USER_GET_QUEUE_NUM = 17,
> VHOST_USER_MAX
> } VhostUserRequest;
>
> @@ -211,6 +214,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
> switch (msg_request) {
> case VHOST_USER_GET_FEATURES:
> case VHOST_USER_GET_PROTOCOL_FEATURES:
> + case VHOST_USER_GET_QUEUE_NUM:
> need_reply = 1;
> break;
>
> @@ -315,6 +319,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
> switch (msg_request) {
> case VHOST_USER_GET_FEATURES:
> case VHOST_USER_GET_PROTOCOL_FEATURES:
> + case VHOST_USER_GET_QUEUE_NUM:
> if (msg.size != sizeof(m.u64)) {
> error_report("Received bad msg size.");
> return -1;
> @@ -366,6 +371,14 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
> if (err < 0) {
> return err;
> }
> +
> + /* query the max queues we support if backend supports Multiple Queue */
> + if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)) {
> + err = vhost_user_call(dev, VHOST_USER_GET_QUEUE_NUM, &dev->max_queues);
> + if (err < 0) {
> + return err;
> + }
> + }
> }
>
> return 0;
> diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
> index 6467c73..c3758f3 100644
> --- a/include/hw/virtio/vhost.h
> +++ b/include/hw/virtio/vhost.h
> @@ -48,6 +48,7 @@ struct vhost_dev {
> unsigned long long acked_features;
> unsigned long long backend_features;
> unsigned long long protocol_features;
> + unsigned long long max_queues;
> bool started;
> bool log_enabled;
> unsigned long long log_size;
> diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
> index 840d4b1..8db723e 100644
> --- a/include/net/vhost_net.h
> +++ b/include/net/vhost_net.h
> @@ -13,6 +13,7 @@ typedef struct VhostNetOptions {
> void *opaque;
> } VhostNetOptions;
>
> +uint64_t vhost_net_get_max_queues(VHostNetState *net);
> struct vhost_net *vhost_net_init(VhostNetOptions *options);
>
> int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queues);
>
--
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
next prev parent reply other threads:[~2015-09-24 10:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 4:19 [Qemu-devel] [PATCH v11 0/7] vhost-user multiple queue support Yuanhan Liu
2015-09-23 4:19 ` [Qemu-devel] [PATCH v11 1/7] vhost-user: use VHOST_USER_XXX macro for switch statement Yuanhan Liu
2015-09-24 10:05 ` Marcel Apfelbaum
2015-09-24 10:18 ` Michael S. Tsirkin
2015-09-24 10:27 ` Marcel Apfelbaum
2015-09-23 4:19 ` [Qemu-devel] [PATCH v11 2/7] vhost-user: add protocol feature negotiation Yuanhan Liu
2015-09-24 10:13 ` Marcel Apfelbaum
2015-09-24 11:25 ` Yuanhan Liu
2015-09-24 11:29 ` Yuanhan Liu
2015-09-23 4:19 ` [Qemu-devel] [PATCH v11 3/7] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE Yuanhan Liu
2015-09-24 10:18 ` Marcel Apfelbaum
2015-09-23 4:19 ` [Qemu-devel] [PATCH v11 4/7] vhost-user: add VHOST_USER_GET_QUEUE_NUM message Yuanhan Liu
2015-09-24 10:25 ` Marcel Apfelbaum [this message]
2015-09-23 4:19 ` [Qemu-devel] [PATCH v11 5/7] vhost: introduce vhost_backend_get_vq_index method Yuanhan Liu
2015-09-23 4:20 ` [Qemu-devel] [PATCH v11 6/7] vhost-user: add multiple queue support Yuanhan Liu
2015-09-23 6:56 ` Yuanhan Liu
2015-09-24 5:34 ` Jason Wang
2015-09-24 5:57 ` Yuanhan Liu
2015-09-24 6:15 ` Jason Wang
2015-09-23 4:20 ` [Qemu-devel] [PATCH v11 7/7] vhost-user: add a new message to disable/enable a specific virt queue Yuanhan Liu
2015-09-24 5:43 ` Jason Wang
2015-09-24 10:03 ` [Qemu-devel] [PATCH v11 0/7] vhost-user multiple queue support 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=5603CF84.2020803@redhat.com \
--to=marcel@redhat.com \
--cc=Changchun.ouyang@hotmail.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuanhan.liu@linux.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).