From patchwork Wed Oct 21 13:25:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 36590 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 D7182B7B86 for ; Thu, 22 Oct 2009 01:33:55 +1100 (EST) Received: from localhost ([127.0.0.1]:49931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0cG8-0002ld-5e for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 10:33:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0bCf-000892-96 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0bCZ-00081y-WC for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:12 -0400 Received: from [199.232.76.173] (port=55741 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0bCZ-00081S-I5 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43118) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0bCZ-0007T4-45 for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:07 -0400 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 n9LDQ6Qp004252 for ; Wed, 21 Oct 2009 09:26:06 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-113.ams2.redhat.com [10.36.9.113]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9LDPxAA027267; Wed, 21 Oct 2009 09:26:01 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 1C36870118; Wed, 21 Oct 2009 15:25:44 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2009 15:25:39 +0200 Message-Id: <1256131543-28416-19-git-send-email-kraxel@redhat.com> In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com> References: <1256131543-28416-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 18/22] stellaris_enet: use qdev properties for configuration. 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: Gerd Hoffmann --- hw/stellaris.c | 2 +- hw/stellaris_enet.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/hw/stellaris.c b/hw/stellaris.c index 1628914..44c9eee 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -1383,7 +1383,7 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model, qemu_check_nic_model(&nd_table[0], "stellaris"); enet = qdev_create(NULL, "stellaris_enet"); - enet->nd = &nd_table[0]; + qdev_set_nic_properties(enet, &nd_table[0]); qdev_init_nofail(enet); sysbus_mmio_map(sysbus_from_qdev(enet), 0, 0x40048000); sysbus_connect_irq(sysbus_from_qdev(enet), 0, pic[42]); diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c index 4596a69..fe2cffe 100644 --- a/hw/stellaris_enet.c +++ b/hw/stellaris_enet.c @@ -67,8 +67,8 @@ typedef struct { int rx_fifo_len; int next_packet; VLANClientState *vc; + NICConf conf; qemu_irq irq; - uint8_t macaddr[6]; int mmio_index; } stellaris_enet_state; @@ -169,10 +169,10 @@ static uint32_t stellaris_enet_read(void *opaque, target_phys_addr_t offset) } return val; case 0x14: /* IA0 */ - return s->macaddr[0] | (s->macaddr[1] << 8) - | (s->macaddr[2] << 16) | (s->macaddr[3] << 24); + return s->conf.macaddr.a[0] | (s->conf.macaddr.a[1] << 8) + | (s->conf.macaddr.a[2] << 16) | (s->conf.macaddr.a[3] << 24); case 0x18: /* IA1 */ - return s->macaddr[4] | (s->macaddr[5] << 8); + return s->conf.macaddr.a[4] | (s->conf.macaddr.a[5] << 8); case 0x1c: /* THR */ return s->thr; case 0x20: /* MCTL */ @@ -267,14 +267,14 @@ static void stellaris_enet_write(void *opaque, target_phys_addr_t offset, } break; case 0x14: /* IA0 */ - s->macaddr[0] = value; - s->macaddr[1] = value >> 8; - s->macaddr[2] = value >> 16; - s->macaddr[3] = value >> 24; + s->conf.macaddr.a[0] = value; + s->conf.macaddr.a[1] = value >> 8; + s->conf.macaddr.a[2] = value >> 16; + s->conf.macaddr.a[3] = value >> 24; break; case 0x18: /* IA1 */ - s->macaddr[4] = value; - s->macaddr[5] = value >> 8; + s->conf.macaddr.a[4] = value; + s->conf.macaddr.a[5] = value >> 8; break; case 0x1c: /* THR */ s->thr = value; @@ -404,13 +404,14 @@ static int stellaris_enet_init(SysBusDevice *dev) stellaris_enet_writefn, s); sysbus_init_mmio(dev, 0x1000, s->mmio_index); sysbus_init_irq(dev, &s->irq); - qdev_get_macaddr(&dev->qdev, s->macaddr); + qemu_macaddr_default_if_unset(&s->conf.macaddr); - s->vc = qdev_get_vlan_client(&dev->qdev, + s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer, + dev->qdev.info->name, dev->qdev.id, stellaris_enet_can_receive, stellaris_enet_receive, NULL, stellaris_enet_cleanup, s); - qemu_format_nic_info_str(s->vc, s->macaddr); + qemu_format_nic_info_str(s->vc, s->conf.macaddr.a); stellaris_enet_reset(s); register_savevm("stellaris_enet", -1, 1, @@ -418,10 +419,19 @@ static int stellaris_enet_init(SysBusDevice *dev) return 0; } +static SysBusDeviceInfo stellaris_enet_info = { + .init = stellaris_enet_init, + .qdev.name = "stellaris_enet", + .qdev.size = sizeof(stellaris_enet_state), + .qdev.props = (Property[]) { + DEFINE_NIC_PROPERTIES(stellaris_enet_state, conf), + DEFINE_PROP_END_OF_LIST(), + } +}; + static void stellaris_enet_register_devices(void) { - sysbus_register_dev("stellaris_enet", sizeof(stellaris_enet_state), - stellaris_enet_init); + sysbus_register_withprop(&stellaris_enet_info); } device_init(stellaris_enet_register_devices)