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 10/22] e1000: use qdev properties for configuration.
Date: Wed, 21 Oct 2009 15:25:31 +0200	[thread overview]
Message-ID: <1256131543-28416-11-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/e1000.c |   46 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index f123bda..301997b 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -25,6 +25,7 @@
 #include "hw.h"
 #include "pci.h"
 #include "net.h"
+#include "loader.h"
 
 #include "e1000_hw.h"
 
@@ -74,6 +75,7 @@ enum {
 typedef struct E1000State_st {
     PCIDevice dev;
     VLANClientState *vc;
+    NICConf conf;
     int mmio_index;
 
     uint32_t mac_reg[0x8000];
@@ -1056,7 +1058,7 @@ e1000_cleanup(VLANClientState *vc)
 {
     E1000State *d = vc->opaque;
 
-    unregister_savevm("e1000", d);
+    d->vc = NULL;
 }
 
 static int
@@ -1065,7 +1067,8 @@ pci_e1000_uninit(PCIDevice *dev)
     E1000State *d = DO_UPCAST(E1000State, dev, dev);
 
     cpu_unregister_io_memory(d->mmio_index);
-
+    qemu_del_vlan_client(d->vc);
+    unregister_savevm("e1000", d);
     return 0;
 }
 
@@ -1088,7 +1091,7 @@ static int pci_e1000_init(PCIDevice *pci_dev)
     uint16_t checksum = 0;
     static const char info_str[] = "e1000";
     int i;
-    uint8_t macaddr[6];
+    uint8_t *macaddr;
 
     pci_conf = d->dev.config;
 
@@ -1113,7 +1116,8 @@ static int pci_e1000_init(PCIDevice *pci_dev)
 
     memmove(d->eeprom_data, e1000_eeprom_template,
         sizeof e1000_eeprom_template);
-    qdev_get_macaddr(&d->dev.qdev, macaddr);
+    qemu_macaddr_default_if_unset(&d->conf.macaddr);
+    macaddr = d->conf.macaddr.a;
     for (i = 0; i < 3; i++)
         d->eeprom_data[i] = (macaddr[2*i+1]<<8) | macaddr[2*i];
     for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
@@ -1121,7 +1125,8 @@ static int pci_e1000_init(PCIDevice *pci_dev)
     checksum = (uint16_t) EEPROM_SUM - checksum;
     d->eeprom_data[EEPROM_CHECKSUM_REG] = checksum;
 
-    d->vc = qdev_get_vlan_client(&d->dev.qdev,
+    d->vc = qemu_new_vlan_client(d->conf.vlan, d->conf.peer,
+                                 d->dev.qdev.info->name, d->dev.qdev.id,
                                  e1000_can_receive, e1000_receive,
                                  NULL, e1000_cleanup, d);
     d->vc->link_status_changed = e1000_set_link_status;
@@ -1129,16 +1134,37 @@ static int pci_e1000_init(PCIDevice *pci_dev)
     qemu_format_nic_info_str(d->vc, macaddr);
 
     register_savevm(info_str, -1, 2, nic_save, nic_load, d);
-    qemu_register_reset(e1000_reset, d);
     e1000_reset(d);
+
+#if 0 /* rom bev support is broken -> can't load unconditionally */
+    if (!pci_dev->qdev.hotplugged) {
+        static int loaded = 0;
+        if (!loaded) {
+            rom_add_option("pxe-e1000.bin");
+            loaded = 1;
+        }
+    }
+#endif
     return 0;
 }
 
+static void qdev_e1000_reset(DeviceState *dev)
+{
+    E1000State *d = DO_UPCAST(E1000State, dev.qdev, dev);
+    e1000_reset(d);
+}
+
 static PCIDeviceInfo e1000_info = {
-    .qdev.name = "e1000",
-    .qdev.size = sizeof(E1000State),
-    .init      = pci_e1000_init,
-    .exit      = pci_e1000_uninit,
+    .qdev.name  = "e1000",
+    .qdev.desc  = "Intel Gigabit Ethernet",
+    .qdev.size  = sizeof(E1000State),
+    .qdev.reset = qdev_e1000_reset,
+    .init       = pci_e1000_init,
+    .exit       = pci_e1000_uninit,
+    .qdev.props = (Property[]) {
+        DEFINE_NIC_PROPERTIES(E1000State, conf),
+        DEFINE_PROP_END_OF_LIST(),
+    }
 };
 
 static void e1000_register_devices(void)
-- 
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 ` Gerd Hoffmann [this message]
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 ` [Qemu-devel] [PATCH 17/22] xilinx_ethlite: " Gerd Hoffmann
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-11-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).