From patchwork Tue Mar 30 19:21:05 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Stevens X-Patchwork-Id: 89373 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2UJPGqg031778 for ; Tue, 30 Mar 2010 19:25:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754399Ab0C3TZO (ORCPT ); Tue, 30 Mar 2010 15:25:14 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:35232 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753277Ab0C3TZN (ORCPT ); Tue, 30 Mar 2010 15:25:13 -0400 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e33.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o2UJLUrF028057 for ; Tue, 30 Mar 2010 13:21:30 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o2UJOxBA116434 for ; Tue, 30 Mar 2010 13:25:02 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o2UJOwdW030899 for ; Tue, 30 Mar 2010 13:24:58 -0600 Received: from lab1.dls (dyn9047018083.beaverton.ibm.com [9.47.18.83]) by d03av02.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o2UJOvLJ030856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Mar 2010 13:24:57 -0600 Received: from lab1.dls (lab1.dls [127.0.0.1]) by lab1.dls (8.14.3/8.14.3) with ESMTP id o2UJL5EH003473; Tue, 30 Mar 2010 12:21:06 -0700 Message-Id: <201003301921.o2UJL5EH003473@lab1.dls> To: mst@redhat.com cc: kvm@vger.kernel.org, virtualization@lists.osdl.org Subject: [PATCH][QEMU][VHOST]fix feature bit handling for mergeable rx buffers From: David L Stevens Date: Tue, 30 Mar 2010 12:21:05 -0700 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 30 Mar 2010 19:25:17 +0000 (UTC) diff -ruNp qemu-kvm.mst/hw/vhost_net.c qemu-kvm.dls/hw/vhost_net.c --- qemu-kvm.mst/hw/vhost_net.c 2010-03-03 13:39:07.000000000 -0800 +++ qemu-kvm.dls/hw/vhost_net.c 2010-03-29 20:37:34.000000000 -0700 @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -38,15 +39,6 @@ unsigned vhost_net_get_features(struct v return features; } -void vhost_net_ack_features(struct vhost_net *net, unsigned features) -{ - net->dev.acked_features = net->dev.backend_features; - if (features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) - net->dev.acked_features |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); - if (features & (1 << VIRTIO_RING_F_INDIRECT_DESC)) - net->dev.acked_features |= (1 << VIRTIO_RING_F_INDIRECT_DESC); -} - static int vhost_net_get_fd(VLANClientState *backend) { switch (backend->info->type) { @@ -58,6 +50,25 @@ static int vhost_net_get_fd(VLANClientSt } } +void vhost_net_ack_features(struct vhost_net *net, unsigned features) +{ + int vnet_hdr_sz = sizeof(struct virtio_net_hdr); + + net->dev.acked_features = net->dev.backend_features; + if (features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) + net->dev.acked_features |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); + if (features & (1 << VIRTIO_RING_F_INDIRECT_DESC)) + net->dev.acked_features |= (1 << VIRTIO_RING_F_INDIRECT_DESC); + if (features & (1 << VIRTIO_NET_F_MRG_RXBUF)) { + net->dev.acked_features |= (1 << VIRTIO_NET_F_MRG_RXBUF); + vnet_hdr_sz = sizeof(struct virtio_net_hdr_mrg_rxbuf); + } +#ifdef TUNSETVNETHDRSZ + if (ioctl(vhost_net_get_fd(net->vc), TUNSETVNETHDRSZ, &vnet_hdr_sz) < 0) + perror("TUNSETVNETHDRSZ"); +#endif /* TUNSETVNETHDRSZ */ +} + struct vhost_net *vhost_net_init(VLANClientState *backend, int devfd) { int r; diff -ruNp qemu-kvm.mst/hw/virtio-net.c qemu-kvm.dls/hw/virtio-net.c --- qemu-kvm.mst/hw/virtio-net.c 2010-03-03 13:39:07.000000000 -0800 +++ qemu-kvm.dls/hw/virtio-net.c 2010-03-29 16:15:46.000000000 -0700 @@ -211,12 +211,16 @@ static void virtio_net_set_features(Virt n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF)); if (n->has_vnet_hdr) { + struct vhost_net *vhost_net = tap_get_vhost_net(n->nic->nc.peer); + tap_set_offload(n->nic->nc.peer, (features >> VIRTIO_NET_F_GUEST_CSUM) & 1, (features >> VIRTIO_NET_F_GUEST_TSO4) & 1, (features >> VIRTIO_NET_F_GUEST_TSO6) & 1, (features >> VIRTIO_NET_F_GUEST_ECN) & 1, (features >> VIRTIO_NET_F_GUEST_UFO) & 1); + if (vhost_net) + vhost_net_ack_features(vhost_net, features); } }