From patchwork Tue Mar 16 18:51:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 47896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6977BB7DA5 for ; Wed, 17 Mar 2010 06:07:37 +1100 (EST) Received: from localhost ([127.0.0.1]:43012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nrc74-0002xl-Jd for incoming@patchwork.ozlabs.org; Tue, 16 Mar 2010 15:07:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nrbrk-0002Mj-4d for qemu-devel@nongnu.org; Tue, 16 Mar 2010 14:51:44 -0400 Received: from [199.232.76.173] (port=42505 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nrbrj-0002LS-24 for qemu-devel@nongnu.org; Tue, 16 Mar 2010 14:51:43 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nrbrd-0000BM-S8 for qemu-devel@nongnu.org; Tue, 16 Mar 2010 14:51:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47384) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nrbrc-0000Ah-1n for qemu-devel@nongnu.org; Tue, 16 Mar 2010 14:51:37 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2GIpWWx007915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Mar 2010 14:51:32 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2GIpPvB023231; Tue, 16 Mar 2010 14:51:31 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 16 Mar 2010 19:51:20 +0100 Message-Id: <3514a89848cd2a07ac988d819210c245ddea1094.1268765204.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 4/9] virtio: Teach virtio-net about DO_UPCAST X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- hw/virtio-net.c | 21 ++++++++------------- 1 files changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 5c0093e..c0537c8 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -61,14 +61,9 @@ typedef struct VirtIONet * - we could suppress RX interrupt if we were so inclined. */ -static VirtIONet *to_virtio_net(VirtIODevice *vdev) -{ - return (VirtIONet *)vdev; -} - static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); struct virtio_net_config netcfg; netcfg.status = n->status; @@ -78,7 +73,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); struct virtio_net_config netcfg; memcpy(&netcfg, config, sizeof(netcfg)); @@ -105,7 +100,7 @@ static void virtio_net_set_link_status(VLANClientState *nc) static void virtio_net_reset(VirtIODevice *vdev) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); /* Reset back to compatibility mode */ n->promisc = 1; @@ -149,7 +144,7 @@ static int peer_has_ufo(VirtIONet *n) static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); features |= (1 << VIRTIO_NET_F_MAC); @@ -192,7 +187,7 @@ static uint32_t virtio_net_bad_features(VirtIODevice *vdev) static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF)); @@ -315,7 +310,7 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd, static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); struct virtio_net_ctrl_hdr ctrl; virtio_net_ctrl_ack status = VIRTIO_NET_ERR; VirtQueueElement elem; @@ -353,7 +348,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); qemu_flush_queued_packets(&n->nic->nc); @@ -665,7 +660,7 @@ static void virtio_net_flush_tx(VirtIONet *n, VirtQueue *vq) static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) { - VirtIONet *n = to_virtio_net(vdev); + VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev); if (n->tx_timer_active) { virtio_queue_set_notification(vq, 1);