From patchwork Tue Jan 26 20:40:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sridhar Samudrala X-Patchwork-Id: 75236 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0QKeie3031126 for ; Tue, 26 Jan 2010 20:40:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752029Ab0AZUkm (ORCPT ); Tue, 26 Jan 2010 15:40:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752033Ab0AZUkl (ORCPT ); Tue, 26 Jan 2010 15:40:41 -0500 Received: from e36.co.us.ibm.com ([32.97.110.154]:44253 "EHLO e36.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751012Ab0AZUkl (ORCPT ); Tue, 26 Jan 2010 15:40:41 -0500 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e36.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id o0QKbxWT025968; Tue, 26 Jan 2010 13:37:59 -0700 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0QKeJDu064488; Tue, 26 Jan 2010 13:40:20 -0700 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o0QKeInK026420; Tue, 26 Jan 2010 13:40:18 -0700 Received: from [9.47.18.19] (w-sridhar.beaverton.ibm.com [9.47.18.19]) by d03av03.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o0QKeH5q026359; Tue, 26 Jan 2010 13:40:17 -0700 Subject: [PATCH qemu-kvm] Add generic peer_* routines for the remaining tap specific routines From: Sridhar Samudrala To: avi@redhat.com, markmc@redhat.com, Anthony Liguori , "Michael S. Tsirkin" Cc: kvm@vger.kernel.org, qemu-devel@vger.kernel.org Date: Tue, 26 Jan 2010 12:40:17 -0800 Message-Id: <1264538417.24933.143.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 6e48997..eba578a 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -129,10 +129,13 @@ static int peer_has_vnet_hdr(VirtIONet *n) if (!n->nic->nc.peer) return 0; - if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) - return 0; - - n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer); + switch (n->nic->nc.peer->info->type) { + case NET_CLIENT_TYPE_TAP: + n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer); + break; + default: + return 0; + } return n->has_vnet_hdr; } @@ -142,11 +145,46 @@ static int peer_has_ufo(VirtIONet *n) if (!peer_has_vnet_hdr(n)) return 0; - n->has_ufo = tap_has_ufo(n->nic->nc.peer); + switch (n->nic->nc.peer->info->type) { + case NET_CLIENT_TYPE_TAP: + n->has_ufo = tap_has_ufo(n->nic->nc.peer); + break; + default: + return 0; + } return n->has_ufo; } +static void peer_using_vnet_hdr(VirtIONet *n, int using_vnet_hdr) +{ + if (!n->nic->nc.peer) + return; + + switch (n->nic->nc.peer->info->type) { + case NET_CLIENT_TYPE_TAP: + tap_using_vnet_hdr(n->nic->nc.peer, using_vnet_hdr); + break; + default: + break; + } +} + +static void peer_set_offload(VirtIONet *n, int csum, int tso4, int tso6, + int ecn, int ufo) +{ + if (!n->nic->nc.peer) + return; + + switch (n->nic->nc.peer->info->type) { + case NET_CLIENT_TYPE_TAP: + tap_set_offload(n->nic->nc.peer, csum, tso4, tso6, ecn, ufo); + break; + default: + break; + } +} + static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) { VirtIONet *n = to_virtio_net(vdev); @@ -154,7 +192,7 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) features |= (1 << VIRTIO_NET_F_MAC); if (peer_has_vnet_hdr(n)) { - tap_using_vnet_hdr(n->nic->nc.peer, 1); + peer_using_vnet_hdr(n, 1); } else { features &= ~(0x1 << VIRTIO_NET_F_CSUM); features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4); @@ -197,7 +235,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF)); if (n->has_vnet_hdr) { - tap_set_offload(n->nic->nc.peer, + peer_set_offload(n, (features >> VIRTIO_NET_F_GUEST_CSUM) & 1, (features >> VIRTIO_NET_F_GUEST_TSO4) & 1, (features >> VIRTIO_NET_F_GUEST_TSO6) & 1, @@ -761,8 +799,8 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id) } if (n->has_vnet_hdr) { - tap_using_vnet_hdr(n->nic->nc.peer, 1); - tap_set_offload(n->nic->nc.peer, + peer_using_vnet_hdr(n, 1); + peer_set_offload(n, (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_CSUM) & 1, (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_TSO4) & 1, (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_TSO6) & 1,