From patchwork Wed Oct 7 21:50:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 52357 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n97LtKPZ011101 for ; Wed, 7 Oct 2009 21:55:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754363AbZJGVvc (ORCPT ); Wed, 7 Oct 2009 17:51:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754355AbZJGVvc (ORCPT ); Wed, 7 Oct 2009 17:51:32 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:38852 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbZJGVvb (ORCPT ); Wed, 7 Oct 2009 17:51:31 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n97LeHQk010989 for ; Wed, 7 Oct 2009 15:40:17 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n97LomwY179352 for ; Wed, 7 Oct 2009 15:50:49 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n97Loi34007846 for ; Wed, 7 Oct 2009 15:50:45 -0600 Received: from [9.47.18.19] (w-sridhar.beaverton.ibm.com [9.47.18.19]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n97LohdD007788; Wed, 7 Oct 2009 15:50:43 -0600 Subject: [PATCH qemu-kvm] Enable UFO on virtio-net and tap devices From: Sridhar Samudrala To: avi@redhat.com, aliguori@us.ibm.com, kvm@vger.kernel.org Date: Wed, 07 Oct 2009 14:50:42 -0700 Message-Id: <1254952242.31575.179.camel@w-sridhar.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/virtio-net.c b/hw/virtio-net.c index ce8e6cb..c73487d 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -150,7 +150,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev) features |= (1 << VIRTIO_NET_F_HOST_TSO6); features |= (1 << VIRTIO_NET_F_HOST_ECN); features |= (1 << VIRTIO_NET_F_MRG_RXBUF); - /* Kernel can't actually handle UFO in software currently. */ + features |= (1 << VIRTIO_NET_F_GUEST_UFO); + features |= (1 << VIRTIO_NET_F_HOST_UFO); } #endif @@ -189,7 +190,8 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) (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_ECN) & 1, + (features >> VIRTIO_NET_F_GUEST_UFO) & 1); #endif } diff --git a/net.c b/net.c index 8032ff8..1942e25 100644 --- a/net.c +++ b/net.c @@ -1528,8 +1528,13 @@ static int tap_probe_vnet_hdr(int fd) } #ifdef TUNSETOFFLOAD + +#ifndef TUN_F_UFO +#define TUN_F_UFO 0x10 +#endif + static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, - int ecn) + int ecn, int ufo) { TAPState *s = vc->opaque; unsigned int offload = 0; @@ -1542,11 +1547,18 @@ static void tap_set_offload(VLANClientState *vc, int csum, int tso4, int tso6, offload |= TUN_F_TSO6; if ((tso4 || tso6) && ecn) offload |= TUN_F_TSO_ECN; + if (ufo) + offload |= TUN_F_UFO; } - if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) - fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", - strerror(errno)); + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) { + /* Try without UFO */ + offload &= ~TUN_F_UFO; + if (ioctl(s->fd, TUNSETOFFLOAD, offload) != 0) { + fprintf(stderr, "TUNSETOFFLOAD ioctl() failed: %s\n", + strerror(errno)); + } + } } #endif /* TUNSETOFFLOAD */ @@ -1583,7 +1595,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, s->vc->receive_raw = tap_receive_raw; #ifdef TUNSETOFFLOAD s->vc->set_offload = tap_set_offload; - tap_set_offload(s->vc, 0, 0, 0, 0); + tap_set_offload(s->vc, 0, 0, 0, 0, 0); #endif tap_read_poll(s, 1); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd); diff --git a/net.h b/net.h index 925c67c..ac3701c 100644 --- a/net.h +++ b/net.h @@ -14,7 +14,7 @@ typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); typedef void (NetCleanup) (VLANClientState *); typedef void (LinkStatusChanged)(VLANClientState *); -typedef void (SetOffload)(VLANClientState *, int, int, int, int); +typedef void (SetOffload)(VLANClientState *, int, int, int, int, int); struct VLANClientState { NetReceive *receive;