From patchwork Tue Sep 6 16:11:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 9317443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92A9D601C0 for ; Tue, 6 Sep 2016 16:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73DB028E21 for ; Tue, 6 Sep 2016 16:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6891A28E23; Tue, 6 Sep 2016 16:14:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A1B528E21 for ; Tue, 6 Sep 2016 16:14:51 +0000 (UTC) Received: from localhost ([::1]:34836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhJ1P-00016C-55 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Sep 2016 12:14:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhIy0-00075q-KF for qemu-devel@nongnu.org; Tue, 06 Sep 2016 12:11:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhIxy-00076k-Ez for qemu-devel@nongnu.org; Tue, 06 Sep 2016 12:11:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhIxy-00076b-9J for qemu-devel@nongnu.org; Tue, 06 Sep 2016 12:11:18 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2CED3B709 for ; Tue, 6 Sep 2016 16:11:17 +0000 (UTC) Received: from max-t460s.redhat.com (vpn1-7-235.ams2.redhat.com [10.36.7.235]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u86GBCoV024070; Tue, 6 Sep 2016 12:11:16 -0400 From: Maxime Coquelin To: mst@redhat.com, qemu-devel@nongnu.org Date: Tue, 6 Sep 2016 18:11:07 +0200 Message-Id: <1473178269-16718-3-git-send-email-maxime.coquelin@redhat.com> In-Reply-To: <1473178269-16718-1-git-send-email-maxime.coquelin@redhat.com> References: <1473178269-16718-1-git-send-email-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 06 Sep 2016 16:11:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC 2/4] vhost-user: Add new protocol feature MTU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jasowang@redhat.com, Aaron Conole , Maxime Coquelin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds VHOST_USER_PROTOCOL_F_MTU protocol feature. If supported, QEMU sends VHOST_USER_GET_MTU request to the client, and expects a u64 reply containing the MTU advised for the guest. Cc: Michael S. Tsirkin Cc: Aaron Conole Signed-off-by: Maxime Coquelin --- hw/virtio/vhost-user.c | 11 +++++++++++ include/hw/virtio/vhost.h | 1 + 2 files changed, 12 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index b57454a..d72dd37 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_GET_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_GET_MTU: return true; default: return false; @@ -602,6 +605,14 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque) return err; } } + + /* query the MTU we support if backend supports MTU feature */ + if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MTU)) { + err = vhost_user_get_u64(dev, VHOST_USER_GET_MTU, &dev->mtu); + if (err < 0) { + return err; + } + } } if (dev->migration_blocker == NULL && diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index e433089..99c8d9b 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -50,6 +50,7 @@ struct vhost_dev { uint64_t backend_features; uint64_t protocol_features; uint64_t max_queues; + uint64_t mtu; bool started; bool log_enabled; uint64_t log_size;