qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: mst@redhat.com, aconole@redhat.com, pbonzini@redhat.com,
	qemu-devel@nongnu.org, fbl@redhat.com, berrange@redhat.com,
	mlureau@redhat.com, ktraynor@redhat.com
Cc: jasowang@redhat.com, yuanhan.liu@linux.intel.com,
	Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [Qemu-devel] [RFC v3 1/3] vhost-user: Add MTU protocol feature and op
Date: Wed, 30 Nov 2016 11:10:15 +0100	[thread overview]
Message-ID: <20161130101017.13382-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20161130101017.13382-1-maxime.coquelin@redhat.com>

This patch implements VHOST_USER_PROTOCOL_F_MTU protocol
feature and VHOST_USER_SET_MTU request so that the backend
gets notified of the user defined host MTU.

Vhost-net driver sends this request through a new
vhost_net_set_mtu vhost_ops entry.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Aaron Conole <aconole@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 docs/specs/vhost-user.txt         | 13 +++++++++++++
 hw/virtio/vhost-user.c            | 13 +++++++++++++
 include/hw/virtio/vhost-backend.h |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 7890d71..1740baa 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -259,6 +259,7 @@ Protocol features
 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD      1
 #define VHOST_USER_PROTOCOL_F_RARP           2
 #define VHOST_USER_PROTOCOL_F_REPLY_ACK      3
+#define VHOST_USER_PROTOCOL_F_MTU            4
 
 Message types
 -------------
@@ -470,6 +471,18 @@ Message types
       The first 6 bytes of the payload contain the mac address of the guest to
       allow the vhost user backend to construct and broadcast the fake RARP.
 
+ * VHOST_USER_SET_MTU
+
+      Id: 20
+	  Equivalent ioctl: N/A
+	  Master payload: u64
+
+	  Set host MTU value exposed to the guest.
+	  This request should be sent only when VIRTIO_NET_F_MTU feature has been
+	  successfully negotiated, VHOST_USER_F_PROTOCOL_FEATURES is present in
+	  VHOST_USER_GET_FEATURES and protocol feature bit VHOST_USER_PROTOCOL_F_MTU
+	  is present in VHOST_USER_GET_PROTOCOL_FEATURES.
+
 VHOST_USER_PROTOCOL_F_REPLY_ACK:
 -------------------------------
 The original vhost-user specification only demands replies for certain
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 7ee92b3..86e8255 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -32,6 +32,7 @@ enum VhostUserProtocolFeature {
     VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,
     VHOST_USER_PROTOCOL_F_RARP = 2,
     VHOST_USER_PROTOCOL_F_REPLY_ACK = 3,
+    VHOST_USER_PROTOCOL_F_MTU = 4,
 
     VHOST_USER_PROTOCOL_F_MAX
 };
@@ -59,6 +60,7 @@ typedef enum VhostUserRequest {
     VHOST_USER_GET_QUEUE_NUM = 17,
     VHOST_USER_SET_VRING_ENABLE = 18,
     VHOST_USER_SEND_RARP = 19,
+    VHOST_USER_SET_MTU = 20,
     VHOST_USER_MAX
 } VhostUserRequest;
 
@@ -186,6 +188,7 @@ static bool vhost_user_one_time_request(VhostUserRequest request)
     case VHOST_USER_RESET_OWNER:
     case VHOST_USER_SET_MEM_TABLE:
     case VHOST_USER_GET_QUEUE_NUM:
+    case VHOST_USER_SET_MTU:
         return true;
     default:
         return false;
@@ -685,6 +688,15 @@ static bool vhost_user_can_merge(struct vhost_dev *dev,
     return mfd == rfd;
 }
 
+static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
+{
+    if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MTU)) {
+        return vhost_user_set_u64(dev, VHOST_USER_SET_MTU, (uint64_t)mtu);
+    }
+
+    return -1;
+}
+
 const VhostOps user_ops = {
         .backend_type = VHOST_BACKEND_TYPE_USER,
         .vhost_backend_init = vhost_user_init,
@@ -708,4 +720,5 @@ const VhostOps user_ops = {
         .vhost_requires_shm_log = vhost_user_requires_shm_log,
         .vhost_migration_done = vhost_user_migration_done,
         .vhost_backend_can_merge = vhost_user_can_merge,
+        .vhost_net_set_mtu = vhost_user_net_set_mtu,
 };
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index 6e90703..30abc11 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -32,6 +32,7 @@ typedef int (*vhost_backend_memslots_limit)(struct vhost_dev *dev);
 
 typedef int (*vhost_net_set_backend_op)(struct vhost_dev *dev,
                                 struct vhost_vring_file *file);
+typedef int (*vhost_net_set_mtu_op)(struct vhost_dev *dev, uint16_t mtu);
 typedef int (*vhost_scsi_set_endpoint_op)(struct vhost_dev *dev,
                                   struct vhost_scsi_target *target);
 typedef int (*vhost_scsi_clear_endpoint_op)(struct vhost_dev *dev,
@@ -83,6 +84,7 @@ typedef struct VhostOps {
     vhost_backend_cleanup vhost_backend_cleanup;
     vhost_backend_memslots_limit vhost_backend_memslots_limit;
     vhost_net_set_backend_op vhost_net_set_backend;
+    vhost_net_set_mtu_op vhost_net_set_mtu;
     vhost_scsi_set_endpoint_op vhost_scsi_set_endpoint;
     vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint;
     vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version;
-- 
2.9.3

  reply	other threads:[~2016-11-30 10:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-30 10:10 [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature Maxime Coquelin
2016-11-30 10:10 ` Maxime Coquelin [this message]
2016-11-30 10:25   ` [Qemu-devel] [RFC v3 1/3] vhost-user: Add MTU protocol feature and op Yuanhan Liu
2016-11-30 12:17     ` Maxime Coquelin
2016-11-30 10:10 ` [Qemu-devel] [RFC v3 2/3] vhost-net: Notify the backend about the host MTU Maxime Coquelin
2016-12-06 18:31   ` Aaron Conole
2016-12-07  7:49     ` Maxime Coquelin
2016-11-30 10:10 ` [Qemu-devel] [RFC v3 3/3] virtio-net: Add MTU feature support Maxime Coquelin
2016-11-30 11:24   ` Jason Wang
2016-11-30 12:24     ` Maxime Coquelin
2016-11-30 10:30 ` [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature no-reply
2016-11-30 11:23 ` Jason Wang
2016-11-30 12:16   ` Maxime Coquelin
2016-11-30 13:42     ` Michael S. Tsirkin
2016-12-05 16:11       ` Aaron Conole

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=20161130101017.13382-2-maxime.coquelin@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=aconole@redhat.com \
    --cc=berrange@redhat.com \
    --cc=fbl@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=ktraynor@redhat.com \
    --cc=mlureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@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).