From: Alex Williamson <alex.williamson@hp.com>
To: anthony@codemonkey.ws, qemu-devel@nongnu.org
Cc: markmc@redhat.com, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH v2 3/8] qemu:virtio-net: Define ETH_ALEN for use when manipulating MAC addresses
Date: Tue, 03 Feb 2009 12:29:48 -0700 [thread overview]
Message-ID: <20090203192948.19598.42228.stgit@kvm.aw> (raw)
In-Reply-To: <20090203192932.19598.50925.stgit@kvm.aw>
Makes it much easier to search too.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Acked-by: Mark McLoughlin <markmc@redhat.com>
---
hw/virtio-net.c | 14 +++++++-------
hw/virtio-net.h | 2 ++
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 105daa9..073f23a 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -21,7 +21,7 @@
typedef struct VirtIONet
{
VirtIODevice vdev;
- uint8_t mac[6];
+ uint8_t mac[ETH_ALEN];
uint16_t status;
VirtQueue *rx_vq;
VirtQueue *tx_vq;
@@ -46,7 +46,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
struct virtio_net_config netcfg;
netcfg.status = n->status;
- memcpy(netcfg.mac, n->mac, 6);
+ memcpy(netcfg.mac, n->mac, ETH_ALEN);
memcpy(config, &netcfg, sizeof(netcfg));
}
@@ -57,8 +57,8 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
memcpy(&netcfg, config, sizeof(netcfg));
- if (memcmp(netcfg.mac, n->mac, 6)) {
- memcpy(n->mac, netcfg.mac, 6);
+ if (memcmp(netcfg.mac, n->mac, ETH_ALEN)) {
+ memcpy(n->mac, netcfg.mac, ETH_ALEN);
qemu_format_nic_info_str(n->vc, n->mac);
}
}
@@ -304,7 +304,7 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
virtio_save(&n->vdev, f);
- qemu_put_buffer(f, n->mac, 6);
+ qemu_put_buffer(f, n->mac, ETH_ALEN);
qemu_put_be32(f, n->tx_timer_active);
qemu_put_be32(f, n->mergeable_rx_bufs);
qemu_put_be16(f, n->status);
@@ -319,7 +319,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
virtio_load(&n->vdev, f);
- qemu_get_buffer(f, n->mac, 6);
+ qemu_get_buffer(f, n->mac, ETH_ALEN);
n->tx_timer_active = qemu_get_be32(f);
n->mergeable_rx_bufs = qemu_get_be32(f);
@@ -356,7 +356,7 @@ void virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn)
n->vdev.set_features = virtio_net_set_features;
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);
- memcpy(n->mac, nd->macaddr, 6);
+ memcpy(n->mac, nd->macaddr, ETH_ALEN);
n->status = VIRTIO_NET_S_LINK_UP;
n->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
virtio_net_receive, virtio_net_can_receive, n);
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 148ec47..9dce663 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -18,6 +18,8 @@
#include "net.h"
#include "pci.h"
+#define ETH_ALEN 6
+
/* from Linux's virtio_net.h */
/* The ID for virtio_net */
next prev parent reply other threads:[~2009-02-03 19:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-03 19:29 [Qemu-devel] [PATCH v2 0/8] qemu:virtio-net: Add MAC and VLAN filtering Alex Williamson
2009-02-03 19:29 ` [Qemu-devel] [PATCH v2 1/8] qemu:virtio-net: Save status and add some save infrastructure Alex Williamson
2009-02-03 19:29 ` [Qemu-devel] [PATCH v2 2/8] qemu:virtio-net: Allow setting the MAC address via set_config Alex Williamson
2009-02-03 19:29 ` Alex Williamson [this message]
2009-02-03 19:29 ` [Qemu-devel] [PATCH v2 4/8] qemu:virtio-net: Add a virtqueue for control commands from the guest Alex Williamson
2009-02-03 20:56 ` [Qemu-devel] " Anthony Liguori
2009-02-04 22:59 ` Alex Williamson
2009-02-04 23:09 ` malc
2009-02-04 23:34 ` Alex Williamson
2009-02-04 23:14 ` Anthony Liguori
2009-02-03 19:29 ` [Qemu-devel] [PATCH v2 5/8] qemu:virtio-net: Add promiscuous and all-multicast mode bits Alex Williamson
2009-02-03 19:30 ` [Qemu-devel] [PATCH v2 6/8] qemu:virtio-net: Enable filtering based on MAC, promisc, broadcast and allmulti Alex Williamson
2009-02-03 20:06 ` Blue Swirl
2009-02-03 20:53 ` Anthony Liguori
2009-02-03 23:35 ` Paul Brook
2009-02-04 0:18 ` malc
2009-02-03 19:30 ` [Qemu-devel] [PATCH v2 7/8] qemu:virtio-net: Add additional MACs via a filter table Alex Williamson
2009-02-03 19:30 ` [Qemu-devel] [PATCH v2 8/8] qemu:virtio-net: Add VLAN filtering Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090203192948.19598.42228.stgit@kvm.aw \
--to=alex.williamson@hp.com \
--cc=anthony@codemonkey.ws \
--cc=kvm@vger.kernel.org \
--cc=markmc@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).