* [Qemu-devel] [PATCH 01/22] qdev-ify network cards
@ 2009-10-21 13:25 Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 01/22] net: add macaddr type Gerd Hoffmann
` (21 more replies)
0 siblings, 22 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Hi,
Now the first non-RfC version of this series. Changes compared to
last RfC patch:
* Added some common helper code so we have less code duplication
and the actual driver changes are smaller.
* All network drivers are converted now.
* Some final cleanups which zap dead code.
With the patches applied network cards can now be created using ...
-device ne2k_isa,mac=00:11:22:33:44:55,vlan=1,irq=3,id=foo
'info qtree' shows ...
[ ... ]
bus: isa.0
type ISA
dev: ne2k_isa, id "foo"
dev-prop: iobase = 0x300
dev-prop: irq = 3
dev-prop: mac = 00:11:22:33:44:55
dev-prop: vlan = 1
dev-prop: netdev = <null>
[ ... ]
'info network' shows:
[ ... ]
VLAN 1 devices:
foo: model=ne2k_isa,macaddr=00:11:22:33:44:55
The nic initialization code calls qemu_new_vlan_client() with the
vlan/netdev specified using the properties. Likewise the device
cleanup code should call qemu_del_vlan_client (which only makes sense
for hot-pluggable devices).
struct NICInfo is only involved when creating nics using the legacy
path (via -net nic,...).
This patch series is also available here:
http://repo.or.cz/w/qemu/kraxel.git?a=shortlog;h=refs/heads/nic.v4
cheers,
Gerd
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 01/22] net: add macaddr type.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups Gerd Hoffmann
` (20 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add new type for mac addresses.
Add function which sets the qemu default mac address if it finds the mac
address uninitialized (i.e. all zeros).
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
net.c | 15 +++++++++++++++
net.h | 5 +++++
qemu-common.h | 1 +
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/net.c b/net.c
index 4708080..3b69d3b 100644
--- a/net.c
+++ b/net.c
@@ -280,6 +280,21 @@ void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6])
macaddr[3], macaddr[4], macaddr[5]);
}
+void qemu_macaddr_default_if_unset(MACAddr *macaddr)
+{
+ static int index = 0;
+ static const MACAddr zero = { .a = { 0,0,0,0,0,0 } };
+
+ if (memcmp(macaddr, &zero, sizeof(zero)) != 0)
+ return;
+ macaddr->a[0] = 0x52;
+ macaddr->a[1] = 0x54;
+ macaddr->a[2] = 0x00;
+ macaddr->a[3] = 0x12;
+ macaddr->a[4] = 0x34;
+ macaddr->a[5] = 0x56 + index++;
+}
+
static char *assign_name(VLANClientState *vc1, const char *model)
{
VLANState *vlan;
diff --git a/net.h b/net.h
index 439de2a..605092a 100644
--- a/net.h
+++ b/net.h
@@ -7,6 +7,10 @@
#include "qemu-option.h"
#include "net-queue.h"
+struct MACAddr {
+ uint8_t a[6];
+};
+
/* VLANs support */
typedef int (NetCanReceive)(VLANClientState *);
@@ -65,6 +69,7 @@ ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
void qemu_purge_queued_packets(VLANClientState *vc);
void qemu_flush_queued_packets(VLANClientState *vc);
void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
+void qemu_macaddr_default_if_unset(MACAddr *macaddr);
int qemu_show_nic_models(const char *arg, const char *const *models);
void qemu_check_nic_model(NICInfo *nd, const char *model);
int qemu_find_nic_model(NICInfo *nd, const char * const *models,
diff --git a/qemu-common.h b/qemu-common.h
index 8551862..980f362 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -180,6 +180,7 @@ typedef struct PixelFormat PixelFormat;
typedef struct TextConsole TextConsole;
typedef TextConsole QEMUConsole;
typedef struct CharDriverState CharDriverState;
+typedef struct MACAddr MACAddr;
typedef struct VLANState VLANState;
typedef struct VLANClientState VLANClientState;
typedef struct QEMUFile QEMUFile;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups
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 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 03/22] qdev: add netdev property Gerd Hoffmann
` (19 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Make the mac property use the newly added type for the mac address.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev-properties.c | 31 +++++++++++++++++++++----------
hw/qdev.h | 3 ++-
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 5c627fa..1d68125 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1,4 +1,5 @@
#include "sysemu.h"
+#include "net.h"
#include "qdev.h"
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
@@ -274,7 +275,7 @@ PropertyInfo qdev_prop_ptr = {
*/
static int parse_mac(DeviceState *dev, Property *prop, const char *str)
{
- uint8_t *mac = qdev_get_prop_ptr(dev, prop);
+ MACAddr *mac = qdev_get_prop_ptr(dev, prop);
int i, pos;
char *p;
@@ -283,26 +284,31 @@ static int parse_mac(DeviceState *dev, Property *prop, const char *str)
return -1;
if (!qemu_isxdigit(str[pos+1]))
return -1;
- if (i == 5 && str[pos+2] != '\0')
- return -1;
- if (str[pos+2] != ':' && str[pos+2] != '-')
- return -1;
- mac[i] = strtol(str+pos, &p, 16);
+ if (i == 5) {
+ if (str[pos+2] != '\0')
+ return -1;
+ } else {
+ if (str[pos+2] != ':' && str[pos+2] != '-')
+ return -1;
+ }
+ mac->a[i] = strtol(str+pos, &p, 16);
}
return 0;
}
static int print_mac(DeviceState *dev, Property *prop, char *dest, size_t len)
{
- uint8_t *mac = qdev_get_prop_ptr(dev, prop);
+ MACAddr *mac = qdev_get_prop_ptr(dev, prop);
+
return snprintf(dest, len, "%02x:%02x:%02x:%02x:%02x:%02x",
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ mac->a[0], mac->a[1], mac->a[2],
+ mac->a[3], mac->a[4], mac->a[5]);
}
PropertyInfo qdev_prop_macaddr = {
- .name = "mac-addr",
+ .name = "macaddr",
.type = PROP_TYPE_MACADDR,
- .size = 6,
+ .size = sizeof(MACAddr),
.parse = parse_mac,
.print = print_mac,
};
@@ -454,6 +460,11 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *valu
qdev_prop_set(dev, name, &value, PROP_TYPE_CHR);
}
+void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
+{
+ qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
+}
+
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
{
qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
diff --git a/hw/qdev.h b/hw/qdev.h
index 8cd843e..118e886 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -230,7 +230,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_drive, DriveInfo*)
#define DEFINE_PROP_MACADDR(_n, _s, _f) \
- DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, uint8_t[6])
+ DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
#define DEFINE_PROP_END_OF_LIST() \
{}
@@ -246,6 +246,7 @@ void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
+void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
/* FIXME: Remove opaque pointer properties. */
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_set_defaults(DeviceState *dev, Property *props);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 03/22] qdev: add netdev property
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 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 04/22] qdev: add vlan property Gerd Hoffmann
` (18 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev-properties.c | 36 ++++++++++++++++++++++++++++++++++++
hw/qdev.h | 4 ++++
net.c | 2 +-
net.h | 1 +
4 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 1d68125..76925c8 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -251,6 +251,37 @@ PropertyInfo qdev_prop_chr = {
.print = print_chr,
};
+/* --- netdev device --- */
+
+static int parse_netdev(DeviceState *dev, Property *prop, const char *str)
+{
+ VLANClientState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ *ptr = qemu_find_netdev(str);
+ if (*ptr == NULL)
+ return -1;
+ return 0;
+}
+
+static int print_netdev(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ VLANClientState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (*ptr && (*ptr)->name) {
+ return snprintf(dest, len, "%s", (*ptr)->name);
+ } else {
+ return snprintf(dest, len, "<null>");
+ }
+}
+
+PropertyInfo qdev_prop_netdev = {
+ .name = "netdev",
+ .type = PROP_TYPE_NETDEV,
+ .size = sizeof(VLANClientState*),
+ .parse = parse_netdev,
+ .print = print_netdev,
+};
+
/* --- pointer --- */
static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -460,6 +491,11 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *valu
qdev_prop_set(dev, name, &value, PROP_TYPE_CHR);
}
+void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value)
+{
+ qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV);
+}
+
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
{
qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
diff --git a/hw/qdev.h b/hw/qdev.h
index 118e886..c0d59bc 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -79,6 +79,7 @@ enum PropertyType {
PROP_TYPE_MACADDR,
PROP_TYPE_DRIVE,
PROP_TYPE_CHR,
+ PROP_TYPE_NETDEV,
PROP_TYPE_PTR,
};
@@ -227,6 +228,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
#define DEFINE_PROP_CHR(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
+#define DEFINE_PROP_NETDEV(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_drive, DriveInfo*)
#define DEFINE_PROP_MACADDR(_n, _s, _f) \
@@ -245,6 +248,7 @@ void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
+void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
/* FIXME: Remove opaque pointer properties. */
diff --git a/net.c b/net.c
index 3b69d3b..75a01d2 100644
--- a/net.c
+++ b/net.c
@@ -2363,7 +2363,7 @@ VLANState *qemu_find_vlan(int id, int allocate)
return vlan;
}
-static VLANClientState *qemu_find_netdev(const char *id)
+VLANClientState *qemu_find_netdev(const char *id)
{
VLANClientState *vc;
diff --git a/net.h b/net.h
index 605092a..6a24f55 100644
--- a/net.h
+++ b/net.h
@@ -47,6 +47,7 @@ struct VLANState {
};
VLANState *qemu_find_vlan(int id, int allocate);
+VLANClientState *qemu_find_netdev(const char *id);
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
VLANClientState *peer,
const char *model,
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 04/22] qdev: add vlan property
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (2 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 03/22] qdev: add netdev property Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits Gerd Hoffmann
` (17 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev-properties.c | 39 +++++++++++++++++++++++++++++++++++++++
hw/qdev.h | 6 ++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 76925c8..c9843a2 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -282,6 +282,40 @@ PropertyInfo qdev_prop_netdev = {
.print = print_netdev,
};
+/* --- vlan --- */
+
+static int parse_vlan(DeviceState *dev, Property *prop, const char *str)
+{
+ VLANState **ptr = qdev_get_prop_ptr(dev, prop);
+ int id;
+
+ if (sscanf(str, "%d", &id) != 1)
+ return -1;
+ *ptr = qemu_find_vlan(id, 1);
+ if (*ptr == NULL)
+ return -1;
+ return 0;
+}
+
+static int print_vlan(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ VLANState **ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (*ptr) {
+ return snprintf(dest, len, "%d", (*ptr)->id);
+ } else {
+ return snprintf(dest, len, "<null>");
+ }
+}
+
+PropertyInfo qdev_prop_vlan = {
+ .name = "vlan",
+ .type = PROP_TYPE_VLAN,
+ .size = sizeof(VLANClientState*),
+ .parse = parse_vlan,
+ .print = print_vlan,
+};
+
/* --- pointer --- */
static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -496,6 +530,11 @@ void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *v
qdev_prop_set(dev, name, &value, PROP_TYPE_NETDEV);
}
+void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value)
+{
+ qdev_prop_set(dev, name, &value, PROP_TYPE_VLAN);
+}
+
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
{
qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
diff --git a/hw/qdev.h b/hw/qdev.h
index c0d59bc..c678ab2 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -80,6 +80,7 @@ enum PropertyType {
PROP_TYPE_DRIVE,
PROP_TYPE_CHR,
PROP_TYPE_NETDEV,
+ PROP_TYPE_VLAN,
PROP_TYPE_PTR,
};
@@ -191,6 +192,8 @@ extern PropertyInfo qdev_prop_chr;
extern PropertyInfo qdev_prop_ptr;
extern PropertyInfo qdev_prop_macaddr;
extern PropertyInfo qdev_prop_drive;
+extern PropertyInfo qdev_prop_netdev;
+extern PropertyInfo qdev_prop_vlan;
extern PropertyInfo qdev_prop_pci_devfn;
#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
@@ -230,6 +233,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
#define DEFINE_PROP_NETDEV(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
+#define DEFINE_PROP_VLAN(_n, _s, _f) \
+ DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
#define DEFINE_PROP_DRIVE(_n, _s, _f) \
DEFINE_PROP(_n, _s, _f, qdev_prop_drive, DriveInfo*)
#define DEFINE_PROP_MACADDR(_n, _s, _f) \
@@ -249,6 +254,7 @@ void qdev_prop_set_int32(DeviceState *dev, const char *name, int32_t value);
void qdev_prop_set_uint64(DeviceState *dev, const char *name, uint64_t value);
void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value);
void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value);
+void qdev_prop_set_vlan(DeviceState *dev, const char *name, VLANState *value);
void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value);
void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value);
/* FIXME: Remove opaque pointer properties. */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (3 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 04/22] qdev: add vlan property Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration Gerd Hoffmann
` (16 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Add a new type for properties common to all nics.
Add helper functions and macros to deal with it.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev.c | 9 +++++++++
net.h | 14 ++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 20f931c..b32dbfc 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -383,6 +383,15 @@ void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr)
memcpy(macaddr, dev->nd->macaddr, 6);
}
+void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
+{
+ qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
+ if (nd->vlan)
+ qdev_prop_set_vlan(dev, "vlan", nd->vlan);
+ if (nd->netdev)
+ qdev_prop_set_netdev(dev, "netdev", nd->netdev);
+}
+
static int next_block_unit[IF_COUNT];
/* Get a block device. This should only be used for single-drive devices
diff --git a/net.h b/net.h
index 6a24f55..f2d10f0 100644
--- a/net.h
+++ b/net.h
@@ -11,6 +11,19 @@ struct MACAddr {
uint8_t a[6];
};
+/* qdev nic properties */
+
+typedef struct NICConf {
+ MACAddr macaddr;
+ VLANState *vlan;
+ VLANClientState *peer;
+} NICConf;
+
+#define DEFINE_NIC_PROPERTIES(_state, _conf) \
+ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \
+ DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \
+ DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
+
/* VLANs support */
typedef int (NetCanReceive)(VLANClientState *);
@@ -158,5 +171,6 @@ VLANClientState *qdev_get_vlan_client(DeviceState *dev,
NetReceiveIOV *receive_iov,
NetCleanup *cleanup,
void *opaque);
+void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (4 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists() Gerd Hoffmann
` (15 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/ne2000-isa.c | 17 +++++++----------
hw/ne2000.c | 6 +++---
hw/ne2000.h | 2 +-
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index e346731..1da0d54 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -38,13 +38,8 @@ typedef struct ISANE2000State {
static void isa_ne2000_cleanup(VLANClientState *vc)
{
NE2000State *s = vc->opaque;
- ISANE2000State *isa = container_of(s, ISANE2000State, ne2000);
- unregister_savevm("ne2000", s);
-
- isa_unassign_ioport(isa->iobase, 16);
- isa_unassign_ioport(isa->iobase + 0x10, 2);
- isa_unassign_ioport(isa->iobase + 0x1f, 1);
+ s->vc = NULL;
}
static int isa_ne2000_initfn(ISADevice *dev)
@@ -65,13 +60,14 @@ static int isa_ne2000_initfn(ISADevice *dev)
isa_init_irq(dev, &s->irq, isa->isairq);
- qdev_get_macaddr(&dev->qdev, s->macaddr);
+ qemu_macaddr_default_if_unset(&s->c.macaddr);
ne2000_reset(s);
- s->vc = qdev_get_vlan_client(&dev->qdev,
+ s->vc = qemu_new_vlan_client(s->c.vlan, s->c.peer,
+ dev->qdev.info->name, dev->qdev.id,
ne2000_can_receive, ne2000_receive, NULL,
isa_ne2000_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s);
return 0;
@@ -84,9 +80,9 @@ void isa_ne2000_init(int base, int irq, NICInfo *nd)
qemu_check_nic_model(nd, "ne2k_isa");
dev = isa_create("ne2k_isa");
- dev->qdev.nd = nd; /* hack alert */
qdev_prop_set_uint32(&dev->qdev, "iobase", base);
qdev_prop_set_uint32(&dev->qdev, "irq", irq);
+ qdev_set_nic_properties(&dev->qdev, nd);
qdev_init_nofail(&dev->qdev);
}
@@ -97,6 +93,7 @@ static ISADeviceInfo ne2000_isa_info = {
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, 9),
+ DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 87f1e59..7ce56ff 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -126,7 +126,7 @@ void ne2000_reset(NE2000State *s)
int i;
s->isr = ENISR_RESET;
- memcpy(s->mem, s->macaddr, 6);
+ memcpy(s->mem, &s->c.macaddr, 6);
s->mem[14] = 0x57;
s->mem[15] = 0x57;
@@ -758,13 +758,13 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
PCI_ADDRESS_SPACE_IO, ne2000_map);
s = &d->ne2000;
s->irq = d->dev.irq[0];
- qdev_get_macaddr(&d->dev.qdev, s->macaddr);
+ qdev_get_macaddr(&d->dev.qdev, s->c.macaddr.a);
ne2000_reset(s);
s->vc = qdev_get_vlan_client(&d->dev.qdev,
ne2000_can_receive, ne2000_receive, NULL,
ne2000_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
register_savevm("ne2000", -1, 3, pci_ne2000_save, pci_ne2000_load, d);
return 0;
diff --git a/hw/ne2000.h b/hw/ne2000.h
index 92a2ddb..7842246 100644
--- a/hw/ne2000.h
+++ b/hw/ne2000.h
@@ -23,7 +23,7 @@ typedef struct NE2000State {
uint8_t mult[8]; /* multicast mask array */
qemu_irq irq;
VLANClientState *vc;
- uint8_t macaddr[6];
+ NICConf c;
uint8_t mem[NE2000_MEM_SIZE];
} NE2000State;
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists()
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (5 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration Gerd Hoffmann
` (14 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Function test whenever a driver has a specific property.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev-properties.c | 5 +++++
hw/qdev.h | 1 +
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index c9843a2..370f356 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -452,6 +452,11 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
return NULL;
}
+int qdev_prop_exists(DeviceState *dev, const char *name)
+{
+ return qdev_prop_find(dev, name) ? true : false;
+}
+
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
{
Property *prop;
diff --git a/hw/qdev.h b/hw/qdev.h
index c678ab2..5271a3c 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -245,6 +245,7 @@ extern PropertyInfo qdev_prop_pci_devfn;
/* Set properties between creation and init. */
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+int qdev_prop_exists(DeviceState *dev, const char *name);
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type);
void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (6 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists() Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration Gerd Hoffmann
` (13 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Initialization path will work with both converted and not-converted
drivers, so we can convert drivers one by one.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pci.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index abf07ca..fe2c4bd 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -859,10 +859,16 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
dev = &pci_dev->qdev;
if (nd->name)
dev->id = qemu_strdup(nd->name);
- dev->nd = nd;
+ if (qdev_prop_exists(dev, "mac")) {
+ /* qdev-ified */
+ qdev_set_nic_properties(dev, nd);
+ } else {
+ /* legacy */
+ dev->nd = nd;
+ nd->private = dev;
+ }
if (qdev_init(dev) < 0)
return NULL;
- nd->private = dev;
return pci_dev;
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (7 preceding siblings ...)
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 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 10/22] e1000: " Gerd Hoffmann
` (12 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/ne2000.c | 39 ++++++++++++++++++++++++++++++++-------
1 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 7ce56ff..41893b3 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -25,6 +25,7 @@
#include "pci.h"
#include "net.h"
#include "ne2000.h"
+#include "loader.h"
/* debug NE2000 card */
//#define DEBUG_NE2000
@@ -738,7 +739,7 @@ static void ne2000_cleanup(VLANClientState *vc)
{
NE2000State *s = vc->opaque;
- unregister_savevm("ne2000", s);
+ s->vc = NULL;
}
static int pci_ne2000_init(PCIDevice *pci_dev)
@@ -758,22 +759,46 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
PCI_ADDRESS_SPACE_IO, ne2000_map);
s = &d->ne2000;
s->irq = d->dev.irq[0];
- qdev_get_macaddr(&d->dev.qdev, s->c.macaddr.a);
+
+ qemu_macaddr_default_if_unset(&s->c.macaddr);
ne2000_reset(s);
- s->vc = qdev_get_vlan_client(&d->dev.qdev,
+ s->vc = qemu_new_vlan_client(s->c.vlan, s->c.peer,
+ pci_dev->qdev.info->name, pci_dev->qdev.id,
ne2000_can_receive, ne2000_receive, NULL,
ne2000_cleanup, s);
-
qemu_format_nic_info_str(s->vc, s->c.macaddr.a);
+ if (!pci_dev->qdev.hotplugged) {
+ static int loaded = 0;
+ if (!loaded) {
+ rom_add_option("pxe-ne2k_pci.bin");
+ loaded = 1;
+ }
+ }
+
register_savevm("ne2000", -1, 3, pci_ne2000_save, pci_ne2000_load, d);
return 0;
}
+static int pci_ne2000_exit(PCIDevice *pci_dev)
+{
+ PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
+ NE2000State *s = &d->ne2000;
+
+ unregister_savevm("ne2000", s);
+ qemu_del_vlan_client(s->vc);
+ return 0;
+}
+
static PCIDeviceInfo ne2000_info = {
- .qdev.name = "ne2k_pci",
- .qdev.size = sizeof(PCINE2000State),
- .init = pci_ne2000_init,
+ .qdev.name = "ne2k_pci",
+ .qdev.size = sizeof(PCINE2000State),
+ .init = pci_ne2000_init,
+ .exit = pci_ne2000_exit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(PCINE2000State, ne2000.c),
+ DEFINE_PROP_END_OF_LIST(),
+ }
};
static void ne2000_register_devices(void)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 10/22] e1000: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (8 preceding siblings ...)
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
2009-10-21 13:25 ` [Qemu-devel] [PATCH 11/22] pcnet: " Gerd Hoffmann
` (11 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 11/22] pcnet: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (9 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 10/22] e1000: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code) Gerd Hoffmann
` (10 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pcnet.c | 64 +++++++++++++++++++++++++++++++++++++++++++++---------------
hw/sun4m.c | 2 +-
2 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/hw/pcnet.c b/hw/pcnet.c
index fecbff7..45ca6f3 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -38,6 +38,7 @@
#include "sysbus.h"
#include "pci.h"
#include "net.h"
+#include "loader.h"
#include "qemu-timer.h"
#include "qemu_socket.h"
@@ -61,7 +62,7 @@ typedef struct PCNetState_st PCNetState;
struct PCNetState_st {
VLANClientState *vc;
- uint8_t macaddr[6];
+ NICConf conf;
QEMUTimer *poll_timer;
int rap, isr, lnkst;
uint32_t rdra, tdra;
@@ -1601,7 +1602,7 @@ static void pcnet_h_reset(void *opaque)
/* Initialize the PROM */
- memcpy(s->prom, s->macaddr, 6);
+ memcpy(s->prom, s->conf.macaddr.a, 6);
s->prom[12] = s->prom[13] = 0x00;
s->prom[14] = s->prom[15] = 0x57;
@@ -1953,22 +1954,20 @@ static int pci_pcnet_load(QEMUFile *f, void *opaque, int version_id)
static void pcnet_common_cleanup(PCNetState *d)
{
- unregister_savevm("pcnet", d);
-
- qemu_del_timer(d->poll_timer);
- qemu_free_timer(d->poll_timer);
+ d->vc = NULL;
}
static int pcnet_common_init(DeviceState *dev, PCNetState *s,
- NetCleanup *cleanup)
+ NetCleanup *cleanup)
{
s->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, s);
- qdev_get_macaddr(dev, s->macaddr);
- s->vc = qdev_get_vlan_client(dev,
+ qemu_macaddr_default_if_unset(&s->conf.macaddr);
+ s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer,
+ dev->info->name, dev->id,
pcnet_can_receive, pcnet_receive, NULL,
cleanup, s);
- qemu_register_reset(pcnet_h_reset, s);
+ qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
pcnet_h_reset(s);
return 0;
}
@@ -2023,7 +2022,10 @@ static int pci_pcnet_uninit(PCIDevice *dev)
PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev, dev);
cpu_unregister_io_memory(d->state.mmio_index);
-
+ unregister_savevm("pcnet", d);
+ qemu_del_timer(d->state.poll_timer);
+ qemu_free_timer(d->state.poll_timer);
+ qemu_del_vlan_client(d->state.vc);
return 0;
}
@@ -2071,9 +2073,25 @@ static int pci_pcnet_init(PCIDevice *pci_dev)
s->phys_mem_write = pci_physical_memory_write;
register_savevm("pcnet", -1, 3, pci_pcnet_save, pci_pcnet_load, d);
+
+ if (!pci_dev->qdev.hotplugged) {
+ static int loaded = 0;
+ if (!loaded) {
+ rom_add_option("pxe-pcnet.bin");
+ loaded = 1;
+ }
+ }
+
return pcnet_common_init(&pci_dev->qdev, s, pci_pcnet_cleanup);
}
+static void pci_reset(DeviceState *dev)
+{
+ PCIPCNetState *d = DO_UPCAST(PCIPCNetState, pci_dev.qdev, dev);
+
+ pcnet_h_reset(&d->state);
+}
+
/* SPARC32 interface */
#if defined (TARGET_SPARC) && !defined(TARGET_SPARC64) // Avoid compile failure
@@ -2151,12 +2169,21 @@ static int lance_init(SysBusDevice *dev)
return pcnet_common_init(&dev->qdev, s, lance_cleanup);
}
+static void lance_reset(DeviceState *dev)
+{
+ SysBusPCNetState *d = DO_UPCAST(SysBusPCNetState, busdev.qdev, dev);
+
+ pcnet_h_reset(&d->state);
+}
+
static SysBusDeviceInfo lance_info = {
- .init = lance_init,
+ .init = lance_init,
.qdev.name = "lance",
.qdev.size = sizeof(SysBusPCNetState),
+ .qdev.reset = lance_reset,
.qdev.props = (Property[]) {
DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque),
+ DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf),
DEFINE_PROP_END_OF_LIST(),
}
};
@@ -2164,10 +2191,15 @@ static SysBusDeviceInfo lance_info = {
#endif /* TARGET_SPARC */
static PCIDeviceInfo pcnet_info = {
- .qdev.name = "pcnet",
- .qdev.size = sizeof(PCIPCNetState),
- .init = pci_pcnet_init,
- .exit = pci_pcnet_uninit,
+ .qdev.name = "pcnet",
+ .qdev.size = sizeof(PCIPCNetState),
+ .qdev.reset = pci_reset,
+ .init = pci_pcnet_init,
+ .exit = pci_pcnet_uninit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(PCIPCNetState, state.conf),
+ DEFINE_PROP_END_OF_LIST(),
+ }
};
static void pcnet_register_devices(void)
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 21f609c..424cf6d 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -396,7 +396,7 @@ static void lance_init(NICInfo *nd, target_phys_addr_t leaddr,
qemu_check_nic_model(&nd_table[0], "lance");
dev = qdev_create(NULL, "lance");
- dev->nd = nd;
+ qdev_set_nic_properties(dev, nd);
qdev_prop_set_ptr(dev, "dma", dma_opaque);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code).
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (10 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 11/22] pcnet: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration Gerd Hoffmann
` (9 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
Makefile.target | 2 +-
hw/lance.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/pcnet.c | 154 +++---------------------------------------------------
hw/pcnet.h | 39 ++++++++++++++
4 files changed, 195 insertions(+), 146 deletions(-)
create mode 100644 hw/lance.c
create mode 100644 hw/pcnet.h
diff --git a/Makefile.target b/Makefile.target
index 8d146c5..1d6bad8 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -260,7 +260,7 @@ obj-sparc-y += vga.o vga-pci.o
obj-sparc-y += fdc.o mc146818rtc.o serial.o
obj-sparc-y += cirrus_vga.o parallel.o
else
-obj-sparc-y = sun4m.o tcx.o iommu.o slavio_intctl.o
+obj-sparc-y = sun4m.o lance.o tcx.o iommu.o slavio_intctl.o
obj-sparc-y += slavio_timer.o slavio_misc.o fdc.o sparc32_dma.o
obj-sparc-y += cs4231.o eccmemctl.o sbi.o sun4c_intctl.o
endif
diff --git a/hw/lance.c b/hw/lance.c
new file mode 100644
index 0000000..99c25a8
--- /dev/null
+++ b/hw/lance.c
@@ -0,0 +1,146 @@
+/*
+ * QEMU AMD PC-Net II (Am79C970A) emulation
+ *
+ * Copyright (c) 2004 Antony T Curtis
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/* This software was written to be compatible with the specification:
+ * AMD Am79C970A PCnet-PCI II Ethernet Controller Data-Sheet
+ * AMD Publication# 19436 Rev:E Amendment/0 Issue Date: June 2000
+ */
+
+/*
+ * On Sparc32, this is the Lance (Am7990) part of chip STP2000 (Master I/O), also
+ * produced as NCR89C100. See
+ * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C100.txt
+ * and
+ * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR92C990.txt
+ */
+
+#include "sysbus.h"
+#include "net.h"
+#include "qemu-timer.h"
+#include "qemu_socket.h"
+#include "sun4m.h"
+
+#include "pcnet.h"
+
+typedef struct {
+ SysBusDevice busdev;
+ PCNetState state;
+} SysBusPCNetState;
+
+static void parent_lance_reset(void *opaque, int irq, int level)
+{
+ SysBusPCNetState *d = opaque;
+ if (level)
+ pcnet_h_reset(&d->state);
+}
+
+static void lance_mem_writew(void *opaque, target_phys_addr_t addr,
+ uint32_t val)
+{
+ SysBusPCNetState *d = opaque;
+#ifdef PCNET_DEBUG_IO
+ printf("lance_mem_writew addr=" TARGET_FMT_plx " val=0x%04x\n", addr,
+ val & 0xffff);
+#endif
+ pcnet_ioport_writew(&d->state, addr, val & 0xffff);
+}
+
+static uint32_t lance_mem_readw(void *opaque, target_phys_addr_t addr)
+{
+ SysBusPCNetState *d = opaque;
+ uint32_t val;
+
+ val = pcnet_ioport_readw(&d->state, addr);
+#ifdef PCNET_DEBUG_IO
+ printf("lance_mem_readw addr=" TARGET_FMT_plx " val = 0x%04x\n", addr,
+ val & 0xffff);
+#endif
+
+ return val & 0xffff;
+}
+
+static CPUReadMemoryFunc * const lance_mem_read[3] = {
+ NULL,
+ lance_mem_readw,
+ NULL,
+};
+
+static CPUWriteMemoryFunc * const lance_mem_write[3] = {
+ NULL,
+ lance_mem_writew,
+ NULL,
+};
+
+static void lance_cleanup(VLANClientState *vc)
+{
+ PCNetState *d = vc->opaque;
+
+ pcnet_common_cleanup(d);
+}
+
+static int lance_init(SysBusDevice *dev)
+{
+ SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);
+ PCNetState *s = &d->state;
+
+ s->mmio_index =
+ cpu_register_io_memory(lance_mem_read, lance_mem_write, d);
+
+ qdev_init_gpio_in(&dev->qdev, parent_lance_reset, 1);
+
+ sysbus_init_mmio(dev, 4, s->mmio_index);
+
+ sysbus_init_irq(dev, &s->irq);
+
+ s->phys_mem_read = ledma_memory_read;
+ s->phys_mem_write = ledma_memory_write;
+
+ register_savevm("pcnet", -1, 3, pcnet_save, pcnet_load, s);
+ return pcnet_common_init(&dev->qdev, s, lance_cleanup);
+}
+
+static void lance_reset(DeviceState *dev)
+{
+ SysBusPCNetState *d = DO_UPCAST(SysBusPCNetState, busdev.qdev, dev);
+
+ pcnet_h_reset(&d->state);
+}
+
+static SysBusDeviceInfo lance_info = {
+ .init = lance_init,
+ .qdev.name = "lance",
+ .qdev.size = sizeof(SysBusPCNetState),
+ .qdev.reset = lance_reset,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque),
+ DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
+static void lance_register_devices(void)
+{
+ sysbus_register_withprop(&lance_info);
+}
+device_init(lance_register_devices)
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 45ca6f3..eb64d33 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -35,13 +35,14 @@
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR92C990.txt
*/
-#include "sysbus.h"
#include "pci.h"
#include "net.h"
#include "loader.h"
#include "qemu-timer.h"
#include "qemu_socket.h"
+#include "pcnet.h"
+
//#define PCNET_DEBUG
//#define PCNET_DEBUG_IO
//#define PCNET_DEBUG_BCR
@@ -51,47 +52,11 @@
//#define PCNET_DEBUG_MATCH
-#define PCNET_IOPORT_SIZE 0x20
-#define PCNET_PNPMMIO_SIZE 0x20
-
-#define PCNET_LOOPTEST_CRC 1
-#define PCNET_LOOPTEST_NOCRC 2
-
-
-typedef struct PCNetState_st PCNetState;
-
-struct PCNetState_st {
- VLANClientState *vc;
- NICConf conf;
- QEMUTimer *poll_timer;
- int rap, isr, lnkst;
- uint32_t rdra, tdra;
- uint8_t prom[16];
- uint16_t csr[128];
- uint16_t bcr[32];
- uint64_t timer;
- int mmio_index, xmit_pos;
- uint8_t buffer[4096];
- int tx_busy;
- qemu_irq irq;
- void (*phys_mem_read)(void *dma_opaque, target_phys_addr_t addr,
- uint8_t *buf, int len, int do_bswap);
- void (*phys_mem_write)(void *dma_opaque, target_phys_addr_t addr,
- uint8_t *buf, int len, int do_bswap);
- void *dma_opaque;
- int looptest;
-};
-
typedef struct {
PCIDevice pci_dev;
PCNetState state;
} PCIPCNetState;
-typedef struct {
- SysBusDevice busdev;
- PCNetState state;
-} SysBusPCNetState;
-
struct qemu_ether_header {
uint8_t ether_dhost[6];
uint8_t ether_shost[6];
@@ -1594,7 +1559,7 @@ static uint32_t pcnet_bcr_readw(PCNetState *s, uint32_t rap)
return val;
}
-static void pcnet_h_reset(void *opaque)
+void pcnet_h_reset(void *opaque)
{
PCNetState *s = opaque;
int i;
@@ -1650,7 +1615,7 @@ static uint32_t pcnet_aprom_readb(void *opaque, uint32_t addr)
return val;
}
-static void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
+void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
{
PCNetState *s = opaque;
pcnet_poll_timer(s);
@@ -1673,7 +1638,7 @@ static void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
pcnet_update_irq(s);
}
-static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr)
+uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr)
{
PCNetState *s = opaque;
uint32_t val = -1;
@@ -1880,7 +1845,7 @@ static uint32_t pcnet_mmio_readl(void *opaque, target_phys_addr_t addr)
}
-static void pcnet_save(QEMUFile *f, void *opaque)
+void pcnet_save(QEMUFile *f, void *opaque)
{
PCNetState *s = opaque;
unsigned int i;
@@ -1902,7 +1867,7 @@ static void pcnet_save(QEMUFile *f, void *opaque)
qemu_put_timer(f, s->poll_timer);
}
-static int pcnet_load(QEMUFile *f, void *opaque, int version_id)
+int pcnet_load(QEMUFile *f, void *opaque, int version_id)
{
PCNetState *s = opaque;
int i, dummy;
@@ -1952,12 +1917,12 @@ static int pci_pcnet_load(QEMUFile *f, void *opaque, int version_id)
return pcnet_load(f, &s->state, version_id);
}
-static void pcnet_common_cleanup(PCNetState *d)
+void pcnet_common_cleanup(PCNetState *d)
{
d->vc = NULL;
}
-static int pcnet_common_init(DeviceState *dev, PCNetState *s,
+int pcnet_common_init(DeviceState *dev, PCNetState *s,
NetCleanup *cleanup)
{
s->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, s);
@@ -2092,104 +2057,6 @@ static void pci_reset(DeviceState *dev)
pcnet_h_reset(&d->state);
}
-/* SPARC32 interface */
-
-#if defined (TARGET_SPARC) && !defined(TARGET_SPARC64) // Avoid compile failure
-#include "sun4m.h"
-
-static void parent_lance_reset(void *opaque, int irq, int level)
-{
- SysBusPCNetState *d = opaque;
- if (level)
- pcnet_h_reset(&d->state);
-}
-
-static void lance_mem_writew(void *opaque, target_phys_addr_t addr,
- uint32_t val)
-{
- SysBusPCNetState *d = opaque;
-#ifdef PCNET_DEBUG_IO
- printf("lance_mem_writew addr=" TARGET_FMT_plx " val=0x%04x\n", addr,
- val & 0xffff);
-#endif
- pcnet_ioport_writew(&d->state, addr, val & 0xffff);
-}
-
-static uint32_t lance_mem_readw(void *opaque, target_phys_addr_t addr)
-{
- SysBusPCNetState *d = opaque;
- uint32_t val;
-
- val = pcnet_ioport_readw(&d->state, addr);
-#ifdef PCNET_DEBUG_IO
- printf("lance_mem_readw addr=" TARGET_FMT_plx " val = 0x%04x\n", addr,
- val & 0xffff);
-#endif
-
- return val & 0xffff;
-}
-
-static CPUReadMemoryFunc * const lance_mem_read[3] = {
- NULL,
- lance_mem_readw,
- NULL,
-};
-
-static CPUWriteMemoryFunc * const lance_mem_write[3] = {
- NULL,
- lance_mem_writew,
- NULL,
-};
-
-static void lance_cleanup(VLANClientState *vc)
-{
- PCNetState *d = vc->opaque;
-
- pcnet_common_cleanup(d);
-}
-
-static int lance_init(SysBusDevice *dev)
-{
- SysBusPCNetState *d = FROM_SYSBUS(SysBusPCNetState, dev);
- PCNetState *s = &d->state;
-
- s->mmio_index =
- cpu_register_io_memory(lance_mem_read, lance_mem_write, d);
-
- qdev_init_gpio_in(&dev->qdev, parent_lance_reset, 1);
-
- sysbus_init_mmio(dev, 4, s->mmio_index);
-
- sysbus_init_irq(dev, &s->irq);
-
- s->phys_mem_read = ledma_memory_read;
- s->phys_mem_write = ledma_memory_write;
-
- register_savevm("pcnet", -1, 3, pcnet_save, pcnet_load, s);
- return pcnet_common_init(&dev->qdev, s, lance_cleanup);
-}
-
-static void lance_reset(DeviceState *dev)
-{
- SysBusPCNetState *d = DO_UPCAST(SysBusPCNetState, busdev.qdev, dev);
-
- pcnet_h_reset(&d->state);
-}
-
-static SysBusDeviceInfo lance_info = {
- .init = lance_init,
- .qdev.name = "lance",
- .qdev.size = sizeof(SysBusPCNetState),
- .qdev.reset = lance_reset,
- .qdev.props = (Property[]) {
- DEFINE_PROP_PTR("dma", SysBusPCNetState, state.dma_opaque),
- DEFINE_NIC_PROPERTIES(SysBusPCNetState, state.conf),
- DEFINE_PROP_END_OF_LIST(),
- }
-};
-
-#endif /* TARGET_SPARC */
-
static PCIDeviceInfo pcnet_info = {
.qdev.name = "pcnet",
.qdev.size = sizeof(PCIPCNetState),
@@ -2205,9 +2072,6 @@ static PCIDeviceInfo pcnet_info = {
static void pcnet_register_devices(void)
{
pci_qdev_register(&pcnet_info);
-#if defined (TARGET_SPARC) && !defined(TARGET_SPARC64)
- sysbus_register_withprop(&lance_info);
-#endif
}
device_init(pcnet_register_devices)
diff --git a/hw/pcnet.h b/hw/pcnet.h
new file mode 100644
index 0000000..a94b605
--- /dev/null
+++ b/hw/pcnet.h
@@ -0,0 +1,39 @@
+#define PCNET_IOPORT_SIZE 0x20
+#define PCNET_PNPMMIO_SIZE 0x20
+
+#define PCNET_LOOPTEST_CRC 1
+#define PCNET_LOOPTEST_NOCRC 2
+
+
+typedef struct PCNetState_st PCNetState;
+
+struct PCNetState_st {
+ VLANClientState *vc;
+ NICConf conf;
+ QEMUTimer *poll_timer;
+ int rap, isr, lnkst;
+ uint32_t rdra, tdra;
+ uint8_t prom[16];
+ uint16_t csr[128];
+ uint16_t bcr[32];
+ uint64_t timer;
+ int mmio_index, xmit_pos;
+ uint8_t buffer[4096];
+ int tx_busy;
+ qemu_irq irq;
+ void (*phys_mem_read)(void *dma_opaque, target_phys_addr_t addr,
+ uint8_t *buf, int len, int do_bswap);
+ void (*phys_mem_write)(void *dma_opaque, target_phys_addr_t addr,
+ uint8_t *buf, int len, int do_bswap);
+ void *dma_opaque;
+ int looptest;
+};
+
+void pcnet_h_reset(void *opaque);
+void pcnet_ioport_writew(void *opaque, uint32_t addr, uint32_t val);
+uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr);
+void pcnet_common_cleanup(PCNetState *d);
+int pcnet_common_init(DeviceState *dev, PCNetState *s,
+ NetCleanup *cleanup);
+void pcnet_save(QEMUFile *f, void *opaque);
+int pcnet_load(QEMUFile *f, void *opaque, int version_id);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (11 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code) Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
` (8 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/rtl8139.c | 54 +++++++++++++++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 10daeb2..de60246 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -47,6 +47,7 @@
#include "pci.h"
#include "qemu-timer.h"
#include "net.h"
+#include "loader.h"
/* debug RTL8139 card */
//#define DEBUG_RTL8139 1
@@ -465,7 +466,7 @@ typedef struct RTL8139State {
uint8_t TxThresh;
VLANClientState *vc;
- uint8_t macaddr[6];
+ NICConf conf;
int rtl8139_mmio_io_addr;
/* C ring mode */
@@ -1179,7 +1180,7 @@ static void rtl8139_reset(DeviceState *d)
int i;
/* restore MAC address */
- memcpy(s->phys, s->macaddr, 6);
+ memcpy(s->phys, s->conf.macaddr.a, 6);
/* reset interrupt mask */
s->IntrStatus = 0;
@@ -1195,9 +1196,9 @@ static void rtl8139_reset(DeviceState *d)
s->eeprom.contents[2] = PCI_DEVICE_ID_REALTEK_8139;
#endif
- s->eeprom.contents[7] = s->macaddr[0] | s->macaddr[1] << 8;
- s->eeprom.contents[8] = s->macaddr[2] | s->macaddr[3] << 8;
- s->eeprom.contents[9] = s->macaddr[4] | s->macaddr[5] << 8;
+ s->eeprom.contents[7] = s->conf.macaddr.a[0] | s->conf.macaddr.a[1] << 8;
+ s->eeprom.contents[8] = s->conf.macaddr.a[2] | s->conf.macaddr.a[3] << 8;
+ s->eeprom.contents[9] = s->conf.macaddr.a[4] | s->conf.macaddr.a[5] << 8;
/* mark all status registers as owned by host */
for (i = 0; i < 4; ++i)
@@ -3171,7 +3172,7 @@ static void rtl8139_save(QEMUFile* f,void* opaque)
i = 0;
qemu_put_be32s(f, &i); /* unused. */
- qemu_put_buffer(f, s->macaddr, 6);
+ qemu_put_buffer(f, s->conf.macaddr.a, 6);
qemu_put_be32(f, s->rtl8139_mmio_io_addr);
qemu_put_be32s(f, &s->currTxDesc);
@@ -3268,7 +3269,7 @@ static int rtl8139_load(QEMUFile* f,void* opaque,int version_id)
qemu_get_8s(f, &s->TxThresh);
qemu_get_be32s(f, &i); /* unused. */
- qemu_get_buffer(f, s->macaddr, 6);
+ qemu_get_buffer(f, s->conf.macaddr.a, 6);
s->rtl8139_mmio_io_addr=qemu_get_be32(f);
qemu_get_be32s(f, &s->currTxDesc);
@@ -3416,25 +3417,24 @@ static void rtl8139_cleanup(VLANClientState *vc)
{
RTL8139State *s = vc->opaque;
+ s->vc = NULL;
+}
+
+static int pci_rtl8139_uninit(PCIDevice *dev)
+{
+ RTL8139State *s = DO_UPCAST(RTL8139State, dev, dev);
+
+ cpu_unregister_io_memory(s->rtl8139_mmio_io_addr);
if (s->cplus_txbuffer) {
qemu_free(s->cplus_txbuffer);
s->cplus_txbuffer = NULL;
}
-
#ifdef RTL8139_ONBOARD_TIMER
qemu_del_timer(s->timer);
qemu_free_timer(s->timer);
#endif
-
unregister_savevm("rtl8139", s);
-}
-
-static int pci_rtl8139_uninit(PCIDevice *dev)
-{
- RTL8139State *s = DO_UPCAST(RTL8139State, dev, dev);
-
- cpu_unregister_io_memory(s->rtl8139_mmio_io_addr);
-
+ qemu_del_vlan_client(s->vc);
return 0;
}
@@ -3463,13 +3463,13 @@ static int pci_rtl8139_init(PCIDevice *dev)
pci_register_bar(&s->dev, 1, 0x100,
PCI_ADDRESS_SPACE_MEM, rtl8139_mmio_map);
- qdev_get_macaddr(&dev->qdev, s->macaddr);
+ qemu_macaddr_default_if_unset(&s->conf.macaddr);
rtl8139_reset(&s->dev.qdev);
- 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,
rtl8139_can_receive, rtl8139_receive, NULL,
rtl8139_cleanup, s);
-
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
s->cplus_txbuffer = NULL;
s->cplus_txbuffer_len = 0;
@@ -3483,6 +3483,14 @@ static int pci_rtl8139_init(PCIDevice *dev)
qemu_mod_timer(s->timer,
rtl8139_get_next_tctr_time(s,qemu_get_clock(vm_clock)));
#endif /* RTL8139_ONBOARD_TIMER */
+
+ if (!dev->qdev.hotplugged) {
+ static int loaded = 0;
+ if (!loaded) {
+ rom_add_option("pxe-rtl8139.bin");
+ loaded = 1;
+ }
+ }
return 0;
}
@@ -3492,6 +3500,10 @@ static PCIDeviceInfo rtl8139_info = {
.qdev.reset = rtl8139_reset,
.init = pci_rtl8139_init,
.exit = pci_rtl8139_uninit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(RTL8139State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ }
};
static void rtl8139_register_devices(void)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 14/22] virtio: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (12 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration Gerd Hoffmann
@ 2009-10-21 13:25 ` 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
` (7 subsequent siblings)
21 siblings, 1 reply; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev.c | 4 ++++
hw/syborg.c | 4 ++--
hw/syborg_virtio.c | 16 +++++++++++++---
hw/virtio-net.c | 43 ++++++++++++++++++++++++-------------------
hw/virtio-pci.c | 33 +++++++++++++++++++++++----------
hw/virtio.h | 5 ++++-
6 files changed, 70 insertions(+), 35 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index b32dbfc..e81d662 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -390,6 +390,10 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
qdev_prop_set_vlan(dev, "vlan", nd->vlan);
if (nd->netdev)
qdev_prop_set_netdev(dev, "netdev", nd->netdev);
+ if (nd->nvectors != NIC_NVECTORS_UNSPECIFIED &&
+ qdev_prop_exists(dev, "vectors")) {
+ qdev_prop_set_uint32(dev, "vectors", nd->nvectors);
+ }
}
static int next_block_unit[IF_COUNT];
diff --git a/hw/syborg.c b/hw/syborg.c
index 2aec769..2d08cb2 100644
--- a/hw/syborg.c
+++ b/hw/syborg.c
@@ -77,13 +77,13 @@ static void syborg_init(ram_addr_t ram_size,
sysbus_create_simple("syborg,serial", 0xC0008000, pic[7]);
sysbus_create_simple("syborg,serial", 0xC0009000, pic[8]);
- if (nd_table[0].vlan) {
+ if (nd_table[0].vlan || nd_table[0].netdev) {
DeviceState *dev;
SysBusDevice *s;
qemu_check_nic_model(&nd_table[0], "virtio");
dev = qdev_create(NULL, "syborg,virtio-net");
- dev->nd = &nd_table[0];
+ qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, 0xc000c000);
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index c1faf3d..6cf5a15 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -65,6 +65,7 @@ typedef struct {
qemu_irq irq;
uint32_t int_enable;
uint32_t id;
+ NICConf nic;
} SyborgVirtIOProxy;
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
@@ -273,14 +274,23 @@ static int syborg_virtio_net_init(SysBusDevice *dev)
VirtIODevice *vdev;
SyborgVirtIOProxy *proxy = FROM_SYSBUS(SyborgVirtIOProxy, dev);
- vdev = virtio_net_init(&dev->qdev);
+ vdev = virtio_net_init(&dev->qdev, &proxy->nic);
return syborg_virtio_init(proxy, vdev);
}
+static SysBusDeviceInfo syborg_virtio_net_info = {
+ .init = syborg_virtio_net_init,
+ .qdev.name = "syborg,virtio-net",
+ .qdev.size = sizeof(SyborgVirtIOProxy),
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(SyborgVirtIOProxy, nic),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
static void syborg_virtio_register_devices(void)
{
- sysbus_register_dev("syborg,virtio-net", sizeof(SyborgVirtIOProxy),
- syborg_virtio_net_init);
+ sysbus_register_withprop(&syborg_virtio_net_info);
}
device_init(syborg_virtio_register_devices)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 218f985..f187461 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -700,20 +700,10 @@ static void virtio_net_cleanup(VLANClientState *vc)
{
VirtIONet *n = vc->opaque;
- qemu_purge_queued_packets(vc);
-
- unregister_savevm("virtio-net", n);
-
- qemu_free(n->mac_table.macs);
- qemu_free(n->vlans);
-
- qemu_del_timer(n->tx_timer);
- qemu_free_timer(n->tx_timer);
-
- virtio_cleanup(&n->vdev);
+ n->vc = NULL;
}
-VirtIODevice *virtio_net_init(DeviceState *dev)
+VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
{
VirtIONet *n;
static int virtio_net_id;
@@ -731,15 +721,16 @@ VirtIODevice *virtio_net_init(DeviceState *dev)
n->rx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_rx);
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
n->ctrl_vq = virtio_add_queue(&n->vdev, 64, virtio_net_handle_ctrl);
- qdev_get_macaddr(dev, n->mac);
+ qemu_macaddr_default_if_unset(&conf->macaddr);
n->status = VIRTIO_NET_S_LINK_UP;
- n->vc = qdev_get_vlan_client(dev,
+ n->vc = qemu_new_vlan_client(conf->vlan, conf->peer,
+ dev->info->name, dev->id,
virtio_net_can_receive,
virtio_net_receive, NULL,
virtio_net_cleanup, n);
n->vc->link_status_changed = virtio_net_set_link_status;
- qemu_format_nic_info_str(n->vc, n->mac);
+ qemu_format_nic_info_str(n->vc, conf->macaddr.a);
n->tx_timer = qemu_new_timer(vm_clock, virtio_net_tx_timer, n);
n->tx_timer_active = 0;
@@ -749,13 +740,27 @@ VirtIODevice *virtio_net_init(DeviceState *dev)
n->mac_table.macs = qemu_mallocz(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = qemu_mallocz(MAX_VLAN >> 3);
- if (dev->nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
- n->vdev.nvectors = 3;
- else
- n->vdev.nvectors = dev->nd->nvectors;
register_savevm("virtio-net", virtio_net_id++, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
return &n->vdev;
}
+
+void virtio_net_exit(VirtIODevice *vdev)
+{
+ VirtIONet *n = DO_UPCAST(VirtIONet, vdev, vdev);
+
+ qemu_purge_queued_packets(n->vc);
+
+ unregister_savevm("virtio-net", n);
+
+ qemu_free(n->mac_table.macs);
+ qemu_free(n->vlans);
+
+ qemu_del_timer(n->tx_timer);
+ qemu_free_timer(n->tx_timer);
+
+ virtio_cleanup(&n->vdev);
+ qemu_del_vlan_client(n->vc);
+}
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index e07a2a7..1665b59 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -20,6 +20,7 @@
#include "sysemu.h"
#include "msix.h"
#include "net.h"
+#include "loader.h"
/* from Linux's linux/virtio_pci.h */
@@ -90,6 +91,7 @@ typedef struct {
uint32_t class_code;
uint32_t nvectors;
DriveInfo *dinfo;
+ NICConf nic;
} VirtIOPCIProxy;
/* virtio device */
@@ -493,14 +495,9 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
- vdev = virtio_net_init(&pci_dev->qdev);
-
- /* set nvectors from property, unless the user specified something
- * via -net nic,model=virtio,vectors=n command line option */
- if (pci_dev->qdev.nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
- if (proxy->nvectors != NIC_NVECTORS_UNSPECIFIED)
- vdev->nvectors = proxy->nvectors;
+ vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic);
+ vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev,
PCI_VENDOR_ID_REDHAT_QUMRANET,
PCI_DEVICE_ID_VIRTIO_NET,
@@ -509,9 +506,25 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
/* make the actual value visible */
proxy->nvectors = vdev->nvectors;
+
+ if (!pci_dev->qdev.hotplugged) {
+ static int loaded = 0;
+ if (!loaded) {
+ rom_add_option("pxe-virtio.bin");
+ loaded = 1;
+ }
+ }
return 0;
}
+static int virtio_net_exit_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+
+ virtio_net_exit(proxy->vdev);
+ return virtio_exit_pci(pci_dev);
+}
+
static int virtio_balloon_init_pci(PCIDevice *pci_dev)
{
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
@@ -543,10 +556,10 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.name = "virtio-net-pci",
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_net_init_pci,
- .exit = virtio_exit_pci,
+ .exit = virtio_net_exit_pci,
.qdev.props = (Property[]) {
- DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
- NIC_NVECTORS_UNSPECIFIED),
+ DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
+ DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio.h b/hw/virtio.h
index 0f9be7d..15ad910 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -15,6 +15,7 @@
#define _QEMU_VIRTIO_H
#include "hw.h"
+#include "net.h"
#include "qdev.h"
#include "sysemu.h"
@@ -163,8 +164,10 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
/* Base devices. */
VirtIODevice *virtio_blk_init(DeviceState *dev, DriveInfo *dinfo);
-VirtIODevice *virtio_net_init(DeviceState *dev);
+VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf);
VirtIODevice *virtio_console_init(DeviceState *dev);
VirtIODevice *virtio_balloon_init(DeviceState *dev);
+void virtio_net_exit(VirtIODevice *vdev);
+
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 15/22] eepro100: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (13 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 16/22] smc91c111: " Gerd Hoffmann
` (6 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/eepro100.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 62 insertions(+), 13 deletions(-)
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 62207da..277759f 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -194,11 +194,11 @@ typedef struct {
uint8_t mult[8]; /* multicast mask array */
int mmio_index;
VLANClientState *vc;
+ NICConf conf;
uint8_t scb_stat; /* SCB stat/ack byte */
uint8_t int_stat; /* PCI interrupt status */
/* region must not be saved by nic_save. */
uint32_t region[3]; /* PCI region addresses */
- uint8_t macaddr[6];
uint16_t mdimem[32];
eeprom_t *eeprom;
uint32_t device; /* device variant */
@@ -482,7 +482,7 @@ static void nic_selective_reset(EEPRO100State * s)
size_t i;
uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom);
//~ eeprom93xx_reset(s->eeprom);
- memcpy(eeprom_contents, s->macaddr, 6);
+ memcpy(eeprom_contents, s->conf.macaddr.a, 6);
eeprom_contents[0xa] = 0x4000;
if (s->device == i82557B || s->device == i82557C)
eeprom_contents[5] = 0x0100;
@@ -665,7 +665,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint8_t val)
/* Do nothing. */
break;
case CmdIASetup:
- cpu_physical_memory_read(cb_address + 8, &s->macaddr[0], 6);
+ cpu_physical_memory_read(cb_address + 8, &s->conf.macaddr.a[0], 6);
TRACE(OTHER, logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6)));
break;
case CmdConfigure:
@@ -1507,7 +1507,7 @@ static ssize_t nic_receive(VLANClientState *vc, const uint8_t * buf, size_t size
* Long frames are discarded. */
logout("%p received long frame (%zu byte), ignored\n", s, size);
return -1;
- } else if (memcmp(buf, s->macaddr, 6) == 0) { // !!!
+ } else if (memcmp(buf, s->conf.macaddr.a, 6) == 0) { // !!!
/* Frame matches individual address. */
/* TODO: check configuration byte 15/4 (ignore U/L). */
TRACE(RXTX, logout("%p received frame for me, len=%zu\n", s, size));
@@ -1616,7 +1616,7 @@ static int nic_load(QEMUFile * f, void *opaque, int version_id)
qemu_get_8s(f, &s->int_stat);
/* Skip unused entries. */
qemu_fseek(f, 3 * 4, SEEK_CUR);
- qemu_get_buffer(f, s->macaddr, 6);
+ qemu_get_buffer(f, s->conf.macaddr.a, 6);
/* Skip unused entries. */
qemu_fseek(f, 19 * 4, SEEK_CUR);
for (i = 0; i < 32; i++) {
@@ -1682,7 +1682,7 @@ static void nic_save(QEMUFile * f, void *opaque)
qemu_put_8s(f, &s->int_stat);
/* Skip unused entries. */
qemu_fseek(f, 3 * 4, SEEK_CUR);
- qemu_put_buffer(f, s->macaddr, 6);
+ qemu_put_buffer(f, s->conf.macaddr.a, 6);
/* Skip unused entries. */
qemu_fseek(f, 19 * 4, SEEK_CUR);
for (i = 0; i < 32; i++) {
@@ -1731,9 +1731,7 @@ static void nic_cleanup(VLANClientState *vc)
{
EEPRO100State *s = vc->opaque;
- unregister_savevm(vc->model, s);
-
- eeprom93xx_free(s->eeprom);
+ s->vc = NULL;
}
static int pci_nic_uninit(PCIDevice *pci_dev)
@@ -1741,7 +1739,9 @@ static int pci_nic_uninit(PCIDevice *pci_dev)
EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev);
cpu_unregister_io_memory(s->mmio_index);
-
+ unregister_savevm(s->vc->model, s);
+ eeprom93xx_free(s->eeprom);
+ qemu_del_vlan_client(s->vc);
return 0;
}
@@ -1771,17 +1771,18 @@ static int nic_init(PCIDevice *pci_dev, uint32_t device)
pci_register_bar(&s->dev, 2, PCI_FLASH_SIZE, PCI_ADDRESS_SPACE_MEM,
pci_mmio_map);
- qdev_get_macaddr(&s->dev.qdev, s->macaddr);
+ qemu_macaddr_default_if_unset(&s->conf.macaddr);
logout("macaddr: %s\n", nic_dump(&s->macaddr[0], 6));
assert(s->region[1] == 0);
nic_reset(s);
- s->vc = qdev_get_vlan_client(&s->dev.qdev,
+ s->vc = qemu_new_vlan_client(s->conf.vlan, s->conf.peer,
+ pci_dev->qdev.info->name, pci_dev->qdev.id,
nic_can_receive, nic_receive, NULL,
nic_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
TRACE(OTHER, logout("%s\n", s->vc->info_str));
qemu_register_reset(nic_reset, s);
@@ -1855,53 +1856,101 @@ static PCIDeviceInfo eepro100_info[] = {
.qdev.name = "i82550",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82550_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82551",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82551_init,
.exit = pci_nic_uninit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82557a",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82557a_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82557b",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82557b_init,
.exit = pci_nic_uninit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82557c",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82557c_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82558a",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82558a_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82558b",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82558b_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82559a",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82559a_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82559b",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82559b_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82559c",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82559c_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82559er",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82559er_init,
.exit = pci_nic_uninit,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
.qdev.name = "i82562",
.qdev.size = sizeof(EEPRO100State),
.init = pci_i82562_init,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(EEPRO100State, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
},{
/* end of list */
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 16/22] smc91c111: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (14 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 15/22] eepro100: use qdev properties for configuration Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 17/22] xilinx_ethlite: " Gerd Hoffmann
` (5 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/smc91c111.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index d58821a..4006035 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -19,6 +19,7 @@
typedef struct {
SysBusDevice busdev;
VLANClientState *vc;
+ NICConf conf;
uint16_t tcr;
uint16_t rcr;
uint16_t cr;
@@ -42,7 +43,6 @@ typedef struct {
uint8_t data[NUM_PACKETS][2048];
uint8_t int_level;
uint8_t int_mask;
- uint8_t macaddr[6];
int mmio_index;
} smc91c111_state;
@@ -474,7 +474,7 @@ static uint32_t smc91c111_readb(void *opaque, target_phys_addr_t offset)
/* Not implemented. */
return 0;
case 4: case 5: case 6: case 7: case 8: case 9: /* IA */
- return s->macaddr[offset - 4];
+ return s->conf.macaddr.a[offset - 4];
case 10: /* General Purpose */
return s->gpr & 0xff;
case 11:
@@ -696,8 +696,7 @@ static void smc91c111_cleanup(VLANClientState *vc)
{
smc91c111_state *s = vc->opaque;
- cpu_unregister_io_memory(s->mmio_index);
- qemu_free(s);
+ s->vc = NULL;
}
static int smc91c111_init1(SysBusDevice *dev)
@@ -708,21 +707,32 @@ static int smc91c111_init1(SysBusDevice *dev)
smc91c111_writefn, s);
sysbus_init_mmio(dev, 16, s->mmio_index);
sysbus_init_irq(dev, &s->irq);
- qdev_get_macaddr(&dev->qdev, s->macaddr);
+ qemu_macaddr_default_if_unset(&s->conf.macaddr);
smc91c111_reset(s);
- 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,
smc91c111_can_receive, smc91c111_receive, NULL,
smc91c111_cleanup, s);
- qemu_format_nic_info_str(s->vc, s->macaddr);
+ qemu_format_nic_info_str(s->vc, s->conf.macaddr.a);
/* ??? Save/restore. */
return 0;
}
+static SysBusDeviceInfo smc91c111_info = {
+ .init = smc91c111_init1,
+ .qdev.name = "smc91c111",
+ .qdev.size = sizeof(smc91c111_state),
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(smc91c111_state, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ }
+};
+
static void smc91c111_register_devices(void)
{
- sysbus_register_dev("smc91c111", sizeof(smc91c111_state), smc91c111_init1);
+ sysbus_register_withprop(&smc91c111_info);
}
/* Legacy helper function. Should go away when machine config files are
@@ -734,7 +744,7 @@ void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)
qemu_check_nic_model(nd, "smc91c111");
dev = qdev_create(NULL, "smc91c111");
- dev->nd = nd;
+ qdev_set_nic_properties(dev, nd);
qdev_init_nofail(dev);
s = sysbus_from_qdev(dev);
sysbus_mmio_map(s, 0, base);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 17/22] xilinx_ethlite: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (15 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 16/22] smc91c111: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 18/22] stellaris_enet: " Gerd Hoffmann
` (4 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
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
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 18/22] stellaris_enet: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (16 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 17/22] xilinx_ethlite: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 19/22] musicpal: " Gerd Hoffmann
` (3 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
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)
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 19/22] musicpal: use qdev properties for configuration.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (17 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 18/22] stellaris_enet: " Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 20/22] zap DeviceState->nd Gerd Hoffmann
` (2 subsequent siblings)
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/musicpal.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/hw/musicpal.c b/hw/musicpal.c
index 02d4c70..cb1ac6d 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -152,6 +152,7 @@ typedef struct mv88w8618_eth_state {
uint32_t frx_queue[4];
uint32_t cur_rx[4];
VLANClientState *vc;
+ NICConf conf;
} mv88w8618_eth_state;
static void eth_rx_desc_put(uint32_t addr, mv88w8618_rx_desc *desc)
@@ -368,9 +369,7 @@ static void eth_cleanup(VLANClientState *vc)
{
mv88w8618_eth_state *s = vc->opaque;
- cpu_unregister_io_memory(s->mmio_index);
-
- qemu_free(s);
+ s->vc = NULL;
}
static int mv88w8618_eth_init(SysBusDevice *dev)
@@ -378,7 +377,8 @@ 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 = 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,
eth_can_receive, eth_receive, NULL,
eth_cleanup, s);
s->mmio_index = cpu_register_io_memory(mv88w8618_eth_readfn,
@@ -410,6 +410,10 @@ static SysBusDeviceInfo mv88w8618_eth_info = {
.qdev.name = "mv88w8618_eth",
.qdev.size = sizeof(mv88w8618_eth_state),
.qdev.vmsd = &mv88w8618_eth_vmsd,
+ .qdev.props = (Property[]) {
+ DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
+ DEFINE_PROP_END_OF_LIST(),
+ },
};
/* LCD register offsets */
@@ -1550,7 +1554,7 @@ static void musicpal_init(ram_addr_t ram_size,
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth");
- dev->nd = &nd_table[0];
+ qdev_set_nic_properties(dev, &nd_table[0]);
qdev_init_nofail(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 20/22] zap DeviceState->nd
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (18 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 19/22] musicpal: " Gerd Hoffmann
@ 2009-10-21 13:25 ` 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
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
No users left.
Also cleanup obsolete helper functions.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pci.c | 9 +--------
hw/qdev.c | 22 ----------------------
hw/qdev.h | 1 -
net.h | 7 -------
4 files changed, 1 insertions(+), 38 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index fe2c4bd..553febb 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -859,14 +859,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
dev = &pci_dev->qdev;
if (nd->name)
dev->id = qemu_strdup(nd->name);
- if (qdev_prop_exists(dev, "mac")) {
- /* qdev-ified */
- qdev_set_nic_properties(dev, nd);
- } else {
- /* legacy */
- dev->nd = nd;
- nd->private = dev;
- }
+ qdev_set_nic_properties(dev, nd);
if (qdev_init(dev) < 0)
return NULL;
return pci_dev;
diff --git a/hw/qdev.c b/hw/qdev.c
index e81d662..373ddfc 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -361,28 +361,6 @@ void qdev_connect_gpio_out(DeviceState * dev, int n, qemu_irq pin)
dev->gpio_out[n] = pin;
}
-VLANClientState *qdev_get_vlan_client(DeviceState *dev,
- NetCanReceive *can_receive,
- NetReceive *receive,
- NetReceiveIOV *receive_iov,
- NetCleanup *cleanup,
- void *opaque)
-{
- NICInfo *nd = dev->nd;
- assert(nd);
- nd->vc = qemu_new_vlan_client(nd->vlan, nd->netdev,
- nd->model, nd->name,
- can_receive, receive, receive_iov,
- cleanup, opaque);
- return nd->vc;
-}
-
-
-void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr)
-{
- memcpy(macaddr, dev->nd->macaddr, 6);
-}
-
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
{
qdev_prop_set_macaddr(dev, "mac", nd->macaddr);
diff --git a/hw/qdev.h b/hw/qdev.h
index 5271a3c..d28978f 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -39,7 +39,6 @@ struct DeviceState {
qemu_irq *gpio_in;
QLIST_HEAD(, BusState) child_bus;
int num_child_bus;
- NICInfo *nd;
QLIST_ENTRY(DeviceState) sibling;
};
diff --git a/net.h b/net.h
index f2d10f0..c96f291 100644
--- a/net.h
+++ b/net.h
@@ -164,13 +164,6 @@ void net_host_device_remove(Monitor *mon, const QDict *qdict);
#define SMBD_COMMAND "/usr/sbin/smbd"
#endif
-void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
-VLANClientState *qdev_get_vlan_client(DeviceState *dev,
- NetCanReceive *can_receive,
- NetReceive *receive,
- NetReceiveIOV *receive_iov,
- NetCleanup *cleanup,
- void *opaque);
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
#endif
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 21/22] kill dead nic unplug code.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (19 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 20/22] zap DeviceState->nd Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
2009-10-21 13:25 ` [Qemu-devel] [PATCH 22/22] pc.c: only load e1000 rom Gerd Hoffmann
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Cleanup on unplug happens via qdev->exit() callback now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/acpi.c | 3 ---
hw/device-hotplug.c | 16 ----------------
hw/pci-hotplug.c | 25 -------------------------
sysemu.h | 4 ----
4 files changed, 0 insertions(+), 48 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index d73aee9..dcc2c86 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -702,9 +702,6 @@ static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
QLIST_FOREACH_SAFE(qdev, &bus->children, sibling, next) {
dev = DO_UPCAST(PCIDevice, qdev, qdev);
if (PCI_SLOT(dev->devfn) == slot) {
-#if defined (TARGET_I386)
- pci_device_hot_remove_success(dev);
-#endif
qdev_free(qdev);
}
}
diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c
index c0cfd31..9cc8376 100644
--- a/hw/device-hotplug.c
+++ b/hw/device-hotplug.c
@@ -46,19 +46,3 @@ DriveInfo *add_init_drive(const char *optstr)
return dinfo;
}
-
-void destroy_nic(dev_match_fn *match_fn, void *arg)
-{
- int i;
- NICInfo *nic;
-
- for (i = 0; i < MAX_NICS; i++) {
- nic = &nd_table[i];
- if (nic->used) {
- if (nic->private && match_fn(nic->private, arg)) {
- qemu_del_vlan_client(nic->vc);
- net_client_uninit(nic);
- }
- }
- }
-}
diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c
index 35fa290..4673b89 100644
--- a/hw/pci-hotplug.c
+++ b/hw/pci-hotplug.c
@@ -234,28 +234,3 @@ void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict)
{
pci_device_hot_remove(mon, qdict_get_str(qdict, "pci_addr"));
}
-
-static int pci_match_fn(void *dev_private, void *arg)
-{
- PCIDevice *dev = dev_private;
- PCIDevice *match = arg;
-
- return (dev == match);
-}
-
-/*
- * OS has executed _EJ0 method, we now can remove the device
- */
-void pci_device_hot_remove_success(PCIDevice *d)
-{
- int class_code;
-
- class_code = d->config_read(d, PCI_CLASS_DEVICE+1, 1);
-
- switch(class_code) {
- case PCI_BASE_CLASS_NETWORK:
- destroy_nic(pci_match_fn, d);
- break;
- }
-}
-
diff --git a/sysemu.h b/sysemu.h
index 763861d..cda5848 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -202,17 +202,13 @@ extern DriveInfo *drive_init(QemuOpts *arg, void *machine, int *fatal_error);
/* device-hotplug */
-typedef int (dev_match_fn)(void *dev_private, void *arg);
-
DriveInfo *add_init_drive(const char *opts);
-void destroy_nic(dev_match_fn *match_fn, void *arg);
/* pci-hotplug */
void pci_device_hot_add(Monitor *mon, const QDict *qdict);
void drive_hot_add(Monitor *mon, const QDict *qdict);
void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
-void pci_device_hot_remove_success(PCIDevice *dev);
/* serial ports */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH 22/22] pc.c: only load e1000 rom.
2009-10-21 13:25 [Qemu-devel] [PATCH 01/22] qdev-ify network cards Gerd Hoffmann
` (20 preceding siblings ...)
2009-10-21 13:25 ` [Qemu-devel] [PATCH 21/22] kill dead nic unplug code Gerd Hoffmann
@ 2009-10-21 13:25 ` Gerd Hoffmann
21 siblings, 0 replies; 24+ messages in thread
From: Gerd Hoffmann @ 2009-10-21 13:25 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
The other pxe roms are loaded by the drivers individual drivers now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/pc.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 408d6d6..4cd8ec6 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1163,6 +1163,11 @@ static void pc_init1(ram_addr_t ram_size,
rom_add_option(option_rom[i]);
}
+#if 1
+ /*
+ * Needed for the e1000 rom only. The rom doesn't do proper BEV
+ * and thus we can't load it unconditionally.
+ */
for (i = 0; i < nb_nics; i++) {
char nic_oprom[1024];
const char *model = nd_table[i].model;
@@ -1172,10 +1177,12 @@ static void pc_init1(ram_addr_t ram_size,
if (model == NULL)
model = "e1000";
+ if (strcmp(model,"e1000") != 0)
+ continue;
snprintf(nic_oprom, sizeof(nic_oprom), "pxe-%s.bin", model);
-
rom_add_option(nic_oprom);
}
+#endif
cpu_irq = qemu_allocate_irqs(pic_irq_request, NULL, 1);
i8259 = i8259_init(cpu_irq[0]);
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [Qemu-devel] [PATCH] virtio-net: fix macaddr config regression
2009-10-21 13:25 ` [Qemu-devel] [PATCH 14/22] virtio: " Gerd Hoffmann
@ 2009-10-28 14:07 ` Mark McLoughlin
0 siblings, 0 replies; 24+ messages in thread
From: Mark McLoughlin @ 2009-10-28 14:07 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
This commit:
commit 97b15621
virtio: use qdev properties for configuration.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
makes a guest using virtio-net see an empty macaddr because we never
copy the macaddr into the location that virtio_net_get_config() uses.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/virtio-net.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 93294af..4b09a93 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -837,6 +837,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf)
n->tx_vq = virtio_add_queue(&n->vdev, 256, virtio_net_handle_tx);
n->ctrl_vq = virtio_add_queue(&n->vdev, 64, virtio_net_handle_ctrl);
qemu_macaddr_default_if_unset(&conf->macaddr);
+ memcpy(&n->mac[0], &conf->macaddr, sizeof(n->mac));
n->status = VIRTIO_NET_S_LINK_UP;
n->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC, conf->vlan, conf->peer,
dev->info->name, dev->id,
--
1.6.2.5
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2009-10-28 14:09 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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
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).