From patchwork Sat Jun 6 00:16:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 28407 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 n560HCQe029891 for ; Sat, 6 Jun 2009 00:17:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753211AbZFFAQt (ORCPT ); Fri, 5 Jun 2009 20:16:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752976AbZFFAQs (ORCPT ); Fri, 5 Jun 2009 20:16:48 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:47155 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbZFFAQr (ORCPT ); Fri, 5 Jun 2009 20:16:47 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e9.ny.us.ibm.com (8.13.1/8.13.1) with ESMTP id n5604PB5005698; Fri, 5 Jun 2009 20:04:25 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n560GnVa232238; Fri, 5 Jun 2009 20:16:49 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n560GnTn019109; Fri, 5 Jun 2009 20:16:49 -0400 Received: from [9.47.18.19] (w-sridhar.beaverton.ibm.com [9.47.18.19]) by d01av04.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n560GmOR019104; Fri, 5 Jun 2009 20:16:48 -0400 Subject: [PATCH qemu-kvm] Enable UFO on virtio-net/tap devices From: Sridhar Samudrala To: kvm@vger.kernel.org, herbert.xu@redhat.com, rusty@rustcorp.com.au, davem@davemloft.net, netdev@vger.kernel.org Date: Fri, 05 Jun 2009 17:16:48 -0700 Message-Id: <1244247408.1526.174.camel@w-sridhar.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 (2.24.5-1.fc10) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Enable UFO on the host tap device if supported and allow setting UFO on virtio-net in the guest. Signed-off-by: Sridhar Samudrala --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 3c77b99..8a53e27 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -134,7 +134,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_HOST_UFO); + features |= (1 << VIRTIO_NET_F_GUEST_UFO); } #endif @@ -173,6 +174,7 @@ 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_UFO) & 1, (features >> VIRTIO_NET_F_GUEST_ECN) & 1); #endif } diff --git a/net.c b/net.c index 01e31db..e7dbcd0 100644 --- a/net.c +++ b/net.c @@ -990,8 +990,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; @@ -1004,11 +1009,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 */ @@ -1043,7 +1055,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, s->vc->fd_read_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 qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd); diff --git a/net.h b/net.h index 3d0b6f2..ecfb1f9 100644 --- a/net.h +++ b/net.h @@ -11,7 +11,7 @@ typedef struct VLANClientState VLANClientState; 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 { IOReadHandler *fd_read;