From patchwork Wed Nov 30 10:10:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 9454065 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 C7A8260756 for ; Wed, 30 Nov 2016 11:24:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD6028387 for ; Wed, 30 Nov 2016 11:24:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A268F28443; Wed, 30 Nov 2016 11:24:20 +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 49FF528429 for ; Wed, 30 Nov 2016 11:24:20 +0000 (UTC) Received: from localhost ([::1]:42511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC1r2-00040O-Oa for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Nov 2016 05:11:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cC1qd-0003zZ-9g for qemu-devel@nongnu.org; Wed, 30 Nov 2016 05:10:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cC1qZ-0001CG-UZ for qemu-devel@nongnu.org; Wed, 30 Nov 2016 05:10:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cC1qZ-0001Bb-IT for qemu-devel@nongnu.org; Wed, 30 Nov 2016 05:10:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 C2E9D7F7DF; Wed, 30 Nov 2016 10:10:38 +0000 (UTC) Received: from max-t460s.redhat.com (vpn1-6-15.ams2.redhat.com [10.36.6.15]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAUAAOuH030698; Wed, 30 Nov 2016 05:10:34 -0500 From: Maxime Coquelin 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 Date: Wed, 30 Nov 2016 11:10:16 +0100 Message-Id: <20161130101017.13382-3-maxime.coquelin@redhat.com> In-Reply-To: <20161130101017.13382-1-maxime.coquelin@redhat.com> References: <20161130101017.13382-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 30 Nov 2016 10:10:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v3 2/3] vhost-net: Notify the backend about the host 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: Maxime Coquelin , jasowang@redhat.com, yuanhan.liu@linux.intel.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch provides a way for virtio-net to notify the backend about the host MTU set by the user. Cc: Michael S. Tsirkin Cc: Aaron Conole Signed-off-by: Maxime Coquelin --- hw/net/vhost_net.c | 22 ++++++++++++++++++++++ include/net/vhost_net.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index f2d49ad..d7c13d4 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -51,6 +51,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_NET_F_MRG_RXBUF, VIRTIO_F_VERSION_1, + VIRTIO_NET_F_MTU, VHOST_INVALID_FEATURE_BIT }; @@ -74,6 +75,7 @@ static const int user_feature_bits[] = { VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_MRG_RXBUF, + VIRTIO_NET_F_MTU, /* This bit implies RARP isn't sent by QEMU out of band */ VIRTIO_NET_F_GUEST_ANNOUNCE, @@ -435,6 +437,22 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) return 0; } +int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) +{ + const VhostOps *vhost_ops = net->dev.vhost_ops; + int ret; + + if (!vhost_ops->vhost_net_set_mtu) { + return -ENOSYS; + } + + ret = vhost_ops->vhost_net_set_mtu(&net->dev, mtu); + if (ret < 0) { + return -errno; + } + return 0; +} + #else uint64_t vhost_net_get_max_queues(VHostNetState *net) { @@ -501,4 +519,8 @@ int vhost_set_vring_enable(NetClientState *nc, int enable) { return 0; } + +int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu) +{ +} #endif diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 5a08eff..afc1499 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -35,4 +35,6 @@ int vhost_set_vring_enable(NetClientState * nc, int enable); uint64_t vhost_net_get_acked_features(VHostNetState *net); +int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu); + #endif