[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits |
Date: |
Wed, 21 Oct 2009 15:25:26 +0200 |
Add a new type for properties common to all nics.
Add helper functions and macros to deal with it.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
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
- [Qemu-devel] [PATCH 01/22] qdev-ify network cards, Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 04/22] qdev: add vlan property, Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 03/22] qdev: add netdev property, Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 01/22] net: add macaddr type., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 02/22] qdev: mac addr property fixups, Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 07/22] qdev: add qdev_prop_exists(), Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 08/22] prepare pci nic init path for qdev property configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 09/22] ne2k_pci: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 06/22] ne2k_isa: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 11/22] pcnet: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 10/22] e1000: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 13/22] rtl8139: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 14/22] virtio: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 12/22] pcnet: split away lance.c (sparc32 code)., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 21/22] kill dead nic unplug code., Gerd Hoffmann, 2009/10/21
- [Qemu-devel] [PATCH 19/22] musicpal: use qdev properties for configuration., Gerd Hoffmann, 2009/10/21