From patchwork Wed Nov 25 18:49:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 39457 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 4E704B6EE8 for ; Thu, 26 Nov 2009 07:34:38 +1100 (EST) Received: from localhost ([127.0.0.1]:52666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDOZP-0006Mg-5Q for incoming@patchwork.ozlabs.org; Wed, 25 Nov 2009 15:34:35 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDNkX-0003Bb-HT for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:42:01 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDNkR-00031Y-SH for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:42:00 -0500 Received: from [199.232.76.173] (port=54186 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDNkR-000312-N6 for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:41:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21885) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDNkQ-0005QP-Lk for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:41:55 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqPPO024066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Nov 2009 13:52:25 -0500 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqM6x014166; Wed, 25 Nov 2009 13:52:24 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 52FF5B0AB; Wed, 25 Nov 2009 18:49:42 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Wed, 25 Nov 2009 18:49:22 +0000 Message-Id: <1259174977-26212-30-git-send-email-markmc@redhat.com> In-Reply-To: <1259174977-26212-1-git-send-email-markmc@redhat.com> References: <1259174977-26212-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin Subject: [Qemu-devel] [PATCH 29/44] net: convert musicpal to NICState 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: Mark McLoughlin --- hw/musicpal.c | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hw/musicpal.c b/hw/musicpal.c index 264669f..4a33e28 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -151,7 +151,7 @@ typedef struct mv88w8618_eth_state { uint32_t rx_queue[4]; uint32_t frx_queue[4]; uint32_t cur_rx[4]; - VLANClientState *vc; + NICState *nic; NICConf conf; } mv88w8618_eth_state; @@ -175,14 +175,14 @@ static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc) le32_to_cpus(&desc->next); } -static int eth_can_receive(VLANClientState *vc) +static int eth_can_receive(VLANClientState *nc) { return 1; } -static ssize_t eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t eth_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { - mv88w8618_eth_state *s = vc->opaque; + mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque; uint32_t desc_addr; mv88w8618_rx_desc desc; int i; @@ -250,7 +250,7 @@ static void eth_send(mv88w8618_eth_state *s, int queue_index) len = desc.bytes; if (len < 2048) { cpu_physical_memory_read(desc.buffer, buf, len); - qemu_send_packet(s->vc, buf, len); + qemu_send_packet(&s->nic->nc, buf, len); } desc.cmdstat &= ~MP_ETH_TX_OWN; s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index); @@ -365,23 +365,28 @@ static CPUWriteMemoryFunc * const mv88w8618_eth_writefn[] = { mv88w8618_eth_write }; -static void eth_cleanup(VLANClientState *vc) +static void eth_cleanup(VLANClientState *nc) { - mv88w8618_eth_state *s = vc->opaque; + mv88w8618_eth_state *s = DO_UPCAST(NICState, nc, nc)->opaque; - s->vc = NULL; + s->nic = NULL; } +static NetClientInfo net_mv88w8618_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = eth_can_receive, + .receive = eth_receive, + .cleanup = eth_cleanup, +}; + static int mv88w8618_eth_init(SysBusDevice *dev) { mv88w8618_eth_state *s = FROM_SYSBUS(mv88w8618_eth_state, dev); sysbus_init_irq(dev, &s->irq); - s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - s->conf.vlan, s->conf.peer, - dev->qdev.info->name, dev->qdev.id, - eth_can_receive, eth_receive, NULL, - NULL, eth_cleanup, s); + s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf, + dev->qdev.info->name, dev->qdev.id, s); s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn, mv88w8618_eth_writefn, s); sysbus_init_mmio(dev, MP_ETH_SIZE, s->mmio_index);