From: Mark McLoughlin <markmc@redhat.com>
To: qemu-devel@nongnu.org
Cc: Mark McLoughlin <markmc@redhat.com>
Subject: [Qemu-devel] [PATCH 37/44] net: remove VLANClientState members now in NetClientInfo
Date: Wed, 25 Nov 2009 18:49:30 +0000 [thread overview]
Message-ID: <1259174977-26212-38-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1259174977-26212-1-git-send-email-markmc@redhat.com>
Add a NetClientInfo pointer to VLANClientState and use that
for the typecode and function pointers.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
hw/dp8393x.c | 4 ++--
hw/virtio-net.c | 2 +-
net.c | 45 ++++++++++++++++++++-------------------------
net.h | 10 +---------
net/tap.c | 6 +++---
5 files changed, 27 insertions(+), 40 deletions(-)
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index be9714d..e65e4d1 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -407,9 +407,9 @@ static void do_transmit_packets(dp8393xState *s)
if (s->regs[SONIC_RCR] & (SONIC_RCR_LB1 | SONIC_RCR_LB0)) {
/* Loopback */
s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
- if (s->nic->nc.can_receive(&s->nic->nc)) {
+ if (s->nic->nc.info->can_receive(&s->nic->nc)) {
s->loopback_packet = 1;
- s->nic->nc.receive(&s->nic->nc, s->tx_buffer, tx_len);
+ s->nic->nc.info->receive(&s->nic->nc, s->tx_buffer, tx_len);
}
} else {
/* Transmit packet */
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 4f8d89e..2f201ff 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -129,7 +129,7 @@ static int peer_has_vnet_hdr(VirtIONet *n)
if (!n->nic->nc.peer)
return 0;
- if (n->nic->nc.peer->type != NET_CLIENT_TYPE_TAP)
+ if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP)
return 0;
n->has_vnet_hdr = tap_has_vnet_hdr(n->nic->nc.peer);
diff --git a/net.c b/net.c
index d77320b..a1ec243 100644
--- a/net.c
+++ b/net.c
@@ -229,19 +229,13 @@ VLANClientState *qemu_new_net_client(NetClientInfo *info,
vc = qemu_mallocz(info->size);
- vc->type = info->type;
+ vc->info = info;
vc->model = qemu_strdup(model);
if (name) {
vc->name = qemu_strdup(name);
} else {
vc->name = assign_name(vc, model);
}
- vc->can_receive = info->can_receive;
- vc->receive = info->receive;
- vc->receive_raw = info->receive_raw;
- vc->receive_iov = info->receive_iov;
- vc->cleanup = info->cleanup;
- vc->link_status_changed = info->link_status_changed;
if (vlan) {
assert(!peer);
@@ -297,8 +291,8 @@ void qemu_del_vlan_client(VLANClientState *vc)
}
}
- if (vc->cleanup) {
- vc->cleanup(vc);
+ if (vc->info->cleanup) {
+ vc->info->cleanup(vc);
}
qemu_free(vc->name);
@@ -340,8 +334,8 @@ int qemu_can_send_packet(VLANClientState *sender)
if (sender->peer) {
if (sender->peer->receive_disabled) {
return 0;
- } else if (sender->peer->can_receive &&
- !sender->peer->can_receive(sender->peer)) {
+ } else if (sender->peer->info->can_receive &&
+ !sender->peer->info->can_receive(sender->peer)) {
return 0;
} else {
return 1;
@@ -358,7 +352,7 @@ int qemu_can_send_packet(VLANClientState *sender)
}
/* no can_receive() handler, they can always receive */
- if (!vc->can_receive || vc->can_receive(vc)) {
+ if (!vc->info->can_receive || vc->info->can_receive(vc)) {
return 1;
}
}
@@ -382,10 +376,10 @@ static ssize_t qemu_deliver_packet(VLANClientState *sender,
return 0;
}
- if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->receive_raw) {
- ret = vc->receive_raw(vc, data, size);
+ if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
+ ret = vc->info->receive_raw(vc, data, size);
} else {
- ret = vc->receive(vc, data, size);
+ ret = vc->info->receive(vc, data, size);
}
if (ret == 0) {
@@ -422,10 +416,10 @@ static ssize_t qemu_vlan_deliver_packet(VLANClientState *sender,
continue;
}
- if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->receive_raw) {
- len = vc->receive_raw(vc, buf, size);
+ if (flags & QEMU_NET_PACKET_FLAG_RAW && vc->info->receive_raw) {
+ len = vc->info->receive_raw(vc, buf, size);
} else {
- len = vc->receive(vc, buf, size);
+ len = vc->info->receive(vc, buf, size);
}
if (len == 0) {
@@ -530,7 +524,7 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov,
offset += len;
}
- return vc->receive(vc, buffer, offset);
+ return vc->info->receive(vc, buffer, offset);
}
static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt)
@@ -555,8 +549,8 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
return calc_iov_length(iov, iovcnt);
}
- if (vc->receive_iov) {
- return vc->receive_iov(vc, iov, iovcnt);
+ if (vc->info->receive_iov) {
+ return vc->info->receive_iov(vc, iov, iovcnt);
} else {
return vc_sendv_compat(vc, iov, iovcnt);
}
@@ -586,8 +580,8 @@ static ssize_t qemu_vlan_deliver_packet_iov(VLANClientState *sender,
assert(!(flags & QEMU_NET_PACKET_FLAG_RAW));
- if (vc->receive_iov) {
- len = vc->receive_iov(vc, iov, iovcnt);
+ if (vc->info->receive_iov) {
+ len = vc->info->receive_iov(vc, iov, iovcnt);
} else {
len = vc_sendv_compat(vc, iov, iovcnt);
}
@@ -1246,8 +1240,9 @@ done:
monitor_printf(mon, "invalid link status '%s'; only 'up' or 'down' "
"valid\n", up_or_down);
- if (vc->link_status_changed)
- vc->link_status_changed(vc);
+ if (vc->info->link_status_changed) {
+ vc->info->link_status_changed(vc);
+ }
}
void net_cleanup(void)
diff --git a/net.h b/net.h
index 9185bcf..497a737 100644
--- a/net.h
+++ b/net.h
@@ -54,15 +54,7 @@ typedef struct NetClientInfo {
} NetClientInfo;
struct VLANClientState {
- net_client_type type;
- NetReceive *receive;
- NetReceive *receive_raw;
- NetReceiveIOV *receive_iov;
- /* Packets may still be sent if this returns zero. It's used to
- rate-limit the slirp code. */
- NetCanReceive *can_receive;
- NetCleanup *cleanup;
- LinkStatusChanged *link_status_changed;
+ NetClientInfo *info;
int link_down;
QTAILQ_ENTRY(VLANClientState) next;
struct VLANState *vlan;
diff --git a/net/tap.c b/net/tap.c
index d34feec..a327a9a 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -214,7 +214,7 @@ int tap_has_ufo(VLANClientState *nc)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
- assert(nc->type == NET_CLIENT_TYPE_TAP);
+ assert(nc->info->type == NET_CLIENT_TYPE_TAP);
return s->has_ufo;
}
@@ -223,7 +223,7 @@ int tap_has_vnet_hdr(VLANClientState *nc)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
- assert(nc->type == NET_CLIENT_TYPE_TAP);
+ assert(nc->info->type == NET_CLIENT_TYPE_TAP);
return s->has_vnet_hdr;
}
@@ -234,7 +234,7 @@ void tap_using_vnet_hdr(VLANClientState *nc, int using_vnet_hdr)
using_vnet_hdr = using_vnet_hdr != 0;
- assert(nc->type == NET_CLIENT_TYPE_TAP);
+ assert(nc->info->type == NET_CLIENT_TYPE_TAP);
assert(s->has_vnet_hdr == using_vnet_hdr);
s->using_vnet_hdr = using_vnet_hdr;
--
1.6.5.2
next prev parent reply other threads:[~2009-11-25 18:52 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 18:48 [Qemu-devel] [PATCH 00/44] Fix announce_self(), misc net fixes and cleanups Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 01/44] net: move slirp code from net.c to net/slirp.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 02/44] net: move vde code from net.c to net/vde.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 03/44] net: move socket backend code from net.c to net/socket.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 04/44] net: move dump backend code from net.c to net/dump.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 05/44] net: clean up includes in net.c Mark McLoughlin
2009-11-25 18:48 ` [Qemu-devel] [PATCH 06/44] net: remove NICInfo::vc Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 07/44] net: remove NICInfo::private Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 08/44] net: introduce NetClientInfo Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 09/44] net: introduce qemu_new_net_client() Mark McLoughlin
2009-11-25 20:36 ` Blue Swirl
2009-11-26 18:06 ` Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 10/44] qdev: move DO_UPCAST() into osdep.h Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 11/44] net: convert tap to NetClientInfo Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 12/44] net: convert tap-win32 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 13/44] net: convert slirp " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 14/44] net: convert vde " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 15/44] net: convert socket " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 16/44] net: convert dump " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 17/44] net: introduce NICState and qemu_new_nic() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 18/44] net: convert virtio to NICState Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 19/44] net: convert e1000 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 20/44] net: convert rtl8139 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 21/44] net: convert ne2000 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 22/44] net: convert pcnet " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 23/44] net: convert eepro100 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 24/44] net: convert dp8393x " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 25/44] net: convert etrax " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 26/44] net: convert LAN9118 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 27/44] net: convert mcf_fec " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 28/44] net: convert mipsnet " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 29/44] net: convert musicpal " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 30/44] net: convert smc91c111 " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 31/44] net: convert stellaris " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 32/44] net: convert usb-net " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 33/44] net: convert xilinx_ethlite " Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 34/44] net: move parse_macaddr() to net/util.[ch] Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 35/44] net: convert xen to NICState Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 36/44] net: remove qemu_new_vlan_client() Mark McLoughlin
2009-11-25 18:49 ` Mark McLoughlin [this message]
2009-11-25 18:49 ` [Qemu-devel] [PATCH 38/44] net: add qemu_foreach_nic() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 39/44] net: fix qemu_announce_self() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 40/44] net: print correct error for '-netdev ""' Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 41/44] net: fix TAP networking on host kernels without IFF_VNET_HDR support Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 42/44] net: check for TUNSETOFFLOAD support before trying to enable offload features Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 43/44] net: initialize vnet_hdr in net_init_tap() Mark McLoughlin
2009-11-25 18:49 ` [Qemu-devel] [PATCH 44/44] net: fix vnet_hdr handling in solaris tap code Mark McLoughlin
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=1259174977-26212-38-git-send-email-markmc@redhat.com \
--to=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).