qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 17/22] xilinx_ethlite: use qdev properties for configuration.
Date: Wed, 21 Oct 2009 15:25:38 +0200	[thread overview]
Message-ID: <1256131543-28416-18-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/xilinx.h         |    2 +-
 hw/xilinx_ethlite.c |   16 ++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/hw/xilinx.h b/hw/xilinx.h
index 5e6aeea..705ff5b 100644
--- a/hw/xilinx.h
+++ b/hw/xilinx.h
@@ -40,7 +40,7 @@ xilinx_ethlite_create(NICInfo *nd, target_phys_addr_t base, qemu_irq irq,
     qemu_check_nic_model(nd, "xilinx-ethlite");
 
     dev = qdev_create(NULL, "xilinx,ethlite");
-    dev->nd = nd;
+    qdev_set_nic_properties(dev, nd);
     qdev_prop_set_uint32(dev, "txpingpong", txpingpong);
     qdev_prop_set_uint32(dev, "rxpingpong", rxpingpong);
     qdev_init_nofail(dev);
diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c
index 9b0074c..994e0e2 100644
--- a/hw/xilinx_ethlite.c
+++ b/hw/xilinx_ethlite.c
@@ -52,13 +52,13 @@ struct xlx_ethlite
     SysBusDevice busdev;
     qemu_irq irq;
     VLANClientState *vc;
+    NICConf conf;
 
     uint32_t c_tx_pingpong;
     uint32_t c_rx_pingpong;
     unsigned int txbuf;
     unsigned int rxbuf;
 
-    uint8_t macaddr[6];
     uint32_t regs[R_MAX];
 };
 
@@ -125,7 +125,7 @@ eth_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
                 if (s->regs[base + R_TX_CTRL0] & CTRL_I)
                     eth_pulse_irq(s);
             } else if ((value & (CTRL_P | CTRL_S)) == (CTRL_P | CTRL_S)) {
-                memcpy(&s->macaddr[0], &s->regs[base], 6);
+                memcpy(&s->conf.macaddr.a[0], &s->regs[base], 6);
                 if (s->regs[base + R_TX_CTRL0] & CTRL_I)
                     eth_pulse_irq(s);
             }
@@ -175,7 +175,7 @@ static ssize_t eth_rx(VLANClientState *vc, const uint8_t *buf, size_t size)
     int i;
 
     /* DA filter.  */
-    if (!(buf[0] & 0x80) && memcmp(&s->macaddr[0], buf, 6))
+    if (!(buf[0] & 0x80) && memcmp(&s->conf.macaddr.a[0], buf, 6))
         return size;
 
     if (s->regs[rxbase + R_RX_CTRL0] & CTRL_S) {
@@ -204,7 +204,8 @@ static ssize_t eth_rx(VLANClientState *vc, const uint8_t *buf, size_t size)
 static void eth_cleanup(VLANClientState *vc)
 {
     struct xlx_ethlite *s = vc->opaque;
-    qemu_free(s);
+
+    s->vc = NULL;
 }
 
 static int xilinx_ethlite_init(SysBusDevice *dev)
@@ -218,9 +219,11 @@ static int xilinx_ethlite_init(SysBusDevice *dev)
     regs = cpu_register_io_memory(eth_read, eth_write, s);
     sysbus_init_mmio(dev, R_MAX * 4, regs);
 
-    qdev_get_macaddr(&dev->qdev, s->macaddr);
-    s->vc = qdev_get_vlan_client(&dev->qdev,
+    qemu_macaddr_default_if_unset(&s->conf.macaddr);
+    s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer,
+                                 dev->qdev.info->name, dev->qdev.id,
                                  eth_can_rx, eth_rx, NULL, eth_cleanup, s);
+    qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
     return 0;
 }
 
@@ -231,6 +234,7 @@ static SysBusDeviceInfo xilinx_ethlite_info = {
     .qdev.props = (Property[]) {
         DEFINE_PROP_UINT32("txpingpong", struct xlx_ethlite, c_tx_pingpong, 1),
         DEFINE_PROP_UINT32("rxpingpong", struct xlx_ethlite, c_rx_pingpong, 1),
+        DEFINE_NIC_PROPERTIES(struct xlx_ethlite, conf),
         DEFINE_PROP_END_OF_LIST(),
     }
 };
-- 
1.6.2.5

  parent reply	other threads:[~2009-10-21 13:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 01/22] net: add macaddr type Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 03/22] qdev: add netdev property Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 04/22] qdev: add vlan property Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists() Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 10/22] e1000: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 11/22] pcnet: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code) Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
2009-10-28 14:07   ` [Qemu-devel] [PATCH] virtio-net: fix macaddr config regression Mark McLoughlin
2009-10-21 13:25 ` [Qemu-devel] [PATCH 15/22] eepro100: use qdev properties for configuration Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 16/22] smc91c111: " Gerd Hoffmann
2009-10-21 13:25 ` Gerd Hoffmann [this message]
2009-10-21 13:25 ` [Qemu-devel] [PATCH 18/22] stellaris_enet: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 19/22] musicpal: " Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 20/22] zap DeviceState->nd Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 21/22] kill dead nic unplug code Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 22/22] pc.c: only load e1000 rom Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1256131543-28416-18-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).