From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDNHF-0006Un-QO for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:11:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDNHB-0006SI-1D for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:11:45 -0500 Received: from [199.232.76.173] (port=51860 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDNHA-0006S1-Gy for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:11:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40989) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDNH9-0002Pk-RS for qemu-devel@nongnu.org; Wed, 25 Nov 2009 14:11:40 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAPIqPNq031868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Nov 2009 13:52:25 -0500 From: Mark McLoughlin Date: Wed, 25 Nov 2009 18:49:23 +0000 Message-Id: <1259174977-26212-31-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> Subject: [Qemu-devel] [PATCH 30/44] net: convert smc91c111 to NICState List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin Signed-off-by: Mark McLoughlin --- hw/smc91c111.c | 35 ++++++++++++++++++++--------------- 1 files changed, 20 insertions(+), 15 deletions(-) diff --git a/hw/smc91c111.c b/hw/smc91c111.c index b7398c9..c1a88c9 100644 --- a/hw/smc91c111.c +++ b/hw/smc91c111.c @@ -18,7 +18,7 @@ typedef struct { SysBusDevice busdev; - VLANClientState *vc; + NICState *nic; NICConf conf; uint16_t tcr; uint16_t rcr; @@ -207,7 +207,7 @@ static void smc91c111_do_tx(smc91c111_state *s) smc91c111_release_packet(s, packetnum); else if (s->tx_fifo_done_len < NUM_PACKETS) s->tx_fifo_done[s->tx_fifo_done_len++] = packetnum; - qemu_send_packet(s->vc, p, len); + qemu_send_packet(&s->nic->nc, p, len); } s->tx_fifo_len = 0; smc91c111_update(s); @@ -591,9 +591,9 @@ static uint32_t smc91c111_readl(void *opaque, target_phys_addr_t offset) return val; } -static int smc91c111_can_receive(VLANClientState *vc) +static int smc91c111_can_receive(VLANClientState *nc) { - smc91c111_state *s = vc->opaque; + smc91c111_state *s = DO_UPCAST(NICState, nc, nc)->opaque; if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST)) return 1; @@ -602,9 +602,9 @@ static int smc91c111_can_receive(VLANClientState *vc) return 1; } -static ssize_t smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t smc91c111_receive(VLANClientState *nc, const uint8_t *buf, size_t size) { - smc91c111_state *s = vc->opaque; + smc91c111_state *s = DO_UPCAST(NICState, nc, nc)->opaque; int status; int packetsize; uint32_t crc; @@ -692,13 +692,21 @@ static CPUWriteMemoryFunc * const smc91c111_writefn[] = { smc91c111_writel }; -static void smc91c111_cleanup(VLANClientState *vc) +static void smc91c111_cleanup(VLANClientState *nc) { - smc91c111_state *s = vc->opaque; + smc91c111_state *s = DO_UPCAST(NICState, nc, nc)->opaque; - s->vc = NULL; + s->nic = NULL; } +static NetClientInfo net_smc91c111_info = { + .type = NET_CLIENT_TYPE_NIC, + .size = sizeof(NICState), + .can_receive = smc91c111_can_receive, + .receive = smc91c111_receive, + .cleanup = smc91c111_cleanup, +}; + static int smc91c111_init1(SysBusDevice *dev) { smc91c111_state *s = FROM_SYSBUS(smc91c111_state, dev); @@ -711,12 +719,9 @@ static int smc91c111_init1(SysBusDevice *dev) smc91c111_reset(s); - s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, - s->conf.vlan, s->conf.peer, - dev->qdev.info->name, dev->qdev.id, - smc91c111_can_receive, smc91c111_receive, NULL, - NULL, smc91c111_cleanup, s); - qemu_format_nic_info_str(s->vc, s->conf.macaddr.a); + s->nic = qemu_new_nic(&net_smc91c111_info, &s->conf, + dev->qdev.info->name, dev->qdev.id, s); + qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); /* ??? Save/restore. */ return 0; } -- 1.6.5.2