[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/13] net: re-name vc->fd_read() to vc->receive()
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 06/13] net: re-name vc->fd_read() to vc->receive() |
Date: |
Tue, 19 May 2009 10:55:28 +0100 |
VLANClientState's fd_read() handler doesn't read from file
descriptors, it adds a buffer to the client's receive queue.
Re-name the handlers to make things a little less confusing.
Signed-off-by: Mark McLoughlin <address@hidden>
---
hw/dp8393x.c | 4 ++--
hw/e1000.c | 6 +++---
hw/eepro100.c | 2 +-
hw/etraxfs_eth.c | 2 +-
hw/mcf_fec.c | 2 +-
hw/mipsnet.c | 2 +-
hw/musicpal.c | 2 +-
hw/ne2000.c | 2 +-
hw/pcnet.c | 2 +-
hw/qdev.c | 10 +++++-----
hw/rtl8139.c | 2 +-
hw/smc91c111.c | 2 +-
hw/stellaris_enet.c | 2 +-
hw/usb-net.c | 2 +-
hw/virtio-net.c | 2 +-
hw/xen_nic.c | 6 +++---
net.c | 36 ++++++++++++++++++------------------
net.h | 23 ++++++++++++-----------
savevm.c | 2 +-
tap-win32.c | 2 +-
20 files changed, 57 insertions(+), 56 deletions(-)
diff --git a/hw/dp8393x.c b/hw/dp8393x.c
index c5efb3c..8327bfb 100644
--- a/hw/dp8393x.c
+++ b/hw/dp8393x.c
@@ -409,7 +409,7 @@ static void do_transmit_packets(dp8393xState *s)
s->regs[SONIC_TCR] |= SONIC_TCR_CRSL;
if (s->vc->fd_can_read(s)) {
s->loopback_packet = 1;
- s->vc->fd_read(s, s->tx_buffer, tx_len);
+ s->vc->receive(s, s->tx_buffer, tx_len);
}
} else {
/* Transmit packet */
@@ -725,7 +725,7 @@ static int receive_filter(dp8393xState *s, const uint8_t *
buf, int size)
return -1;
}
-static void nic_receive(void *opaque, const uint8_t * buf, int size)
+static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
{
uint16_t data[10];
dp8393xState *s = opaque;
diff --git a/hw/e1000.c b/hw/e1000.c
index fd13f64..f6f03fe 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -593,7 +593,7 @@ e1000_can_receive(void *opaque)
}
static void
-e1000_receive(void *opaque, const uint8_t *buf, int size)
+e1000_receive(void *opaque, const uint8_t *buf, size_t size)
{
E1000State *s = opaque;
struct e1000_rx_desc desc;
@@ -607,8 +607,8 @@ e1000_receive(void *opaque, const uint8_t *buf, int size)
return;
if (size > s->rxbuf_size) {
- DBGOUT(RX, "packet too large for buffers (%d > %d)\n", size,
- s->rxbuf_size);
+ DBGOUT(RX, "packet too large for buffers (%lu > %d)\n",
+ (unsigned long)size, s->rxbuf_size);
return;
}
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 571ab94..28af318 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1441,7 +1441,7 @@ static int nic_can_receive(void *opaque)
//~ return !eepro100_buffer_full(s);
}
-static void nic_receive(void *opaque, const uint8_t * buf, int size)
+static void nic_receive(void *opaque, const uint8_t * buf, size_t size)
{
/* TODO:
* - Magic packets should set bit 30 in power management driver register.
diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
index bb61284..2446f0d 100644
--- a/hw/etraxfs_eth.c
+++ b/hw/etraxfs_eth.c
@@ -501,7 +501,7 @@ static int eth_can_receive(void *opaque)
return 1;
}
-static void eth_receive(void *opaque, const uint8_t *buf, int size)
+static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
{
unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
struct fs_eth *eth = opaque;
diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c
index 86b3aaf..0b0f17a 100644
--- a/hw/mcf_fec.c
+++ b/hw/mcf_fec.c
@@ -353,7 +353,7 @@ static int mcf_fec_can_receive(void *opaque)
return s->rx_enabled;
}
-static void mcf_fec_receive(void *opaque, const uint8_t *buf, int size)
+static void mcf_fec_receive(void *opaque, const uint8_t *buf, size_t size)
{
mcf_fec_state *s = (mcf_fec_state *)opaque;
mcf_fec_bd bd;
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 82a8c93..a22f49a 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -75,7 +75,7 @@ static int mipsnet_can_receive(void *opaque)
return !mipsnet_buffer_full(s);
}
-static void mipsnet_receive(void *opaque, const uint8_t *buf, int size)
+static void mipsnet_receive(void *opaque, const uint8_t *buf, size_t size)
{
MIPSnetState *s = opaque;
diff --git a/hw/musicpal.c b/hw/musicpal.c
index f3c7f2c..14258ec 100644
--- a/hw/musicpal.c
+++ b/hw/musicpal.c
@@ -562,7 +562,7 @@ static int eth_can_receive(void *opaque)
return 1;
}
-static void eth_receive(void *opaque, const uint8_t *buf, int size)
+static void eth_receive(void *opaque, const uint8_t *buf, size_t size)
{
mv88w8618_eth_state *s = opaque;
uint32_t desc_addr;
diff --git a/hw/ne2000.c b/hw/ne2000.c
index aea66b7..502c8ae 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -224,7 +224,7 @@ static int ne2000_can_receive(void *opaque)
#define MIN_BUF_SIZE 60
-static void ne2000_receive(void *opaque, const uint8_t *buf, int size)
+static void ne2000_receive(void *opaque, const uint8_t *buf, size_t size)
{
NE2000State *s = opaque;
uint8_t *p;
diff --git a/hw/pcnet.c b/hw/pcnet.c
index 848d21b..ad4ee33 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1076,7 +1076,7 @@ static int pcnet_can_receive(void *opaque)
#define MIN_BUF_SIZE 60
-static void pcnet_receive(void *opaque, const uint8_t *buf, int size)
+static void pcnet_receive(void *opaque, const uint8_t *buf, size_t size)
{
PCNetState *s = opaque;
int is_padr = 0, is_bcast = 0, is_ladr = 0;
diff --git a/hw/qdev.c b/hw/qdev.c
index 923a08e..14b98f0 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -233,16 +233,16 @@ void qdev_connect_gpio_out(DeviceState * dev, int n,
qemu_irq pin)
}
VLANClientState *qdev_get_vlan_client(DeviceState *dev,
- IOCanRWHandler *fd_can_read,
- IOReadHandler *fd_read,
- IOReadvHandler *fd_readv,
+ NetCanReceive *can_receive,
+ NetReceive *receive,
+ NetReceiveIOV *receive_iov,
NetCleanup *cleanup,
void *opaque)
{
NICInfo *nd = dev->nd;
assert(nd);
- return qemu_new_vlan_client(nd->vlan, nd->model, nd->name, fd_can_read,
- fd_read, fd_readv, cleanup, opaque);
+ return qemu_new_vlan_client(nd->vlan, nd->model, nd->name, can_receive,
+ receive, receive_iov, cleanup, opaque);
}
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index ab68bda..14119d4 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -1158,7 +1158,7 @@ static void rtl8139_do_receive(void *opaque, const
uint8_t *buf, int size, int d
}
}
-static void rtl8139_receive(void *opaque, const uint8_t *buf, int size)
+static void rtl8139_receive(void *opaque, const uint8_t *buf, size_t size)
{
rtl8139_do_receive(opaque, buf, size, 1);
}
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index b20d535..6d1fbb3 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -602,7 +602,7 @@ static int smc91c111_can_receive(void *opaque)
return 1;
}
-static void smc91c111_receive(void *opaque, const uint8_t *buf, int size)
+static void smc91c111_receive(void *opaque, const uint8_t *buf, size_t size)
{
smc91c111_state *s = (smc91c111_state *)opaque;
int status;
diff --git a/hw/stellaris_enet.c b/hw/stellaris_enet.c
index 8b7df09..3ee9a88 100644
--- a/hw/stellaris_enet.c
+++ b/hw/stellaris_enet.c
@@ -78,7 +78,7 @@ static void stellaris_enet_update(stellaris_enet_state *s)
}
/* TODO: Implement MAC address filtering. */
-static void stellaris_enet_receive(void *opaque, const uint8_t *buf, int size)
+static void stellaris_enet_receive(void *opaque, const uint8_t *buf, size_t
size)
{
stellaris_enet_state *s = (stellaris_enet_state *)opaque;
int n;
diff --git a/hw/usb-net.c b/hw/usb-net.c
index fda0aa5..693e976 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1369,7 +1369,7 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket
*p)
return ret;
}
-static void usbnet_receive(void *opaque, const uint8_t *buf, int size)
+static void usbnet_receive(void *opaque, const uint8_t *buf, size_t size)
{
USBNetState *s = opaque;
struct rndis_packet_msg_type *msg;
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 5613308..3ca93f5 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -361,7 +361,7 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf,
int size)
return 0;
}
-static void virtio_net_receive(void *opaque, const uint8_t *buf, int size)
+static void virtio_net_receive(void *opaque, const uint8_t *buf, size_t size)
{
VirtIONet *n = opaque;
struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
diff --git a/hw/xen_nic.c b/hw/xen_nic.c
index 920b227..a33d163 100644
--- a/hw/xen_nic.c
+++ b/hw/xen_nic.c
@@ -245,7 +245,7 @@ static int net_rx_ok(void *opaque)
return 1;
}
-static void net_rx_packet(void *opaque, const uint8_t *buf, int size)
+static void net_rx_packet(void *opaque, const uint8_t *buf, size_t size)
{
struct XenNetDev *netdev = opaque;
netif_rx_request_t rxreq;
@@ -264,8 +264,8 @@ static void net_rx_packet(void *opaque, const uint8_t *buf,
int size)
return;
}
if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
- xen_be_printf(&netdev->xendev, 0, "packet too big (%d > %ld)",
- size, XC_PAGE_SIZE - NET_IP_ALIGN);
+ xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
+ (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
return;
}
diff --git a/net.c b/net.c
index 409205a..ce1bbbf 100644
--- a/net.c
+++ b/net.c
@@ -332,9 +332,9 @@ static char *assign_name(VLANClientState *vc1, const char
*model)
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
const char *model,
const char *name,
- IOCanRWHandler *fd_can_read,
- IOReadHandler *fd_read,
- IOReadvHandler *fd_readv,
+ NetCanReceive *can_receive,
+ NetReceive *receive,
+ NetReceiveIOV *receive_iov,
NetCleanup *cleanup,
void *opaque)
{
@@ -345,9 +345,9 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
vc->name = strdup(name);
else
vc->name = assign_name(vc, model);
- vc->fd_can_read = fd_can_read;
- vc->fd_read = fd_read;
- vc->fd_readv = fd_readv;
+ vc->can_receive = can_receive;
+ vc->receive = receive;
+ vc->receive_iov = receive_iov;
vc->cleanup = cleanup;
vc->opaque = opaque;
vc->vlan = vlan;
@@ -401,8 +401,8 @@ int qemu_can_send_packet(VLANClientState *sender)
continue;
}
- /* no fd_can_read() handler, they can always receive */
- if (!vc->fd_can_read || vc->fd_can_read(vc->opaque)) {
+ /* no can_receive() handler, they can always receive */
+ if (!vc->can_receive || vc->can_receive(vc->opaque)) {
return 1;
}
}
@@ -416,7 +416,7 @@ qemu_deliver_packet(VLANClientState *sender, const uint8_t
*buf, int size)
for (vc = sender->vlan->first_client; vc != NULL; vc = vc->next) {
if (vc != sender && !vc->link_down) {
- vc->fd_read(vc->opaque, buf, size);
+ vc->receive(vc->opaque, buf, size);
}
}
}
@@ -467,7 +467,7 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const
struct iovec *iov,
offset += len;
}
- vc->fd_read(vc->opaque, buffer, offset);
+ vc->receive(vc->opaque, buffer, offset);
return offset;
}
@@ -519,9 +519,9 @@ ssize_t qemu_sendv_packet(VLANClientState *sender, const
struct iovec *iov,
}
if (vc->link_down) {
len = calc_iov_length(iov, iovcnt);
- } else if (vc->fd_readv) {
- len = vc->fd_readv(vc->opaque, iov, iovcnt);
- } else if (vc->fd_read) {
+ } else if (vc->receive_iov) {
+ len = vc->receive_iov(vc->opaque, iov, iovcnt);
+ } else if (vc->receive) {
len = vc_sendv_compat(vc, iov, iovcnt);
}
max_len = MAX(max_len, len);
@@ -568,7 +568,7 @@ int slirp_is_inited(void)
return slirp_inited;
}
-static void slirp_receive(void *opaque, const uint8_t *buf, int size)
+static void slirp_receive(void *opaque, const uint8_t *buf, size_t size)
{
#ifdef DEBUG_SLIRP
printf("slirp input:\n");
@@ -800,7 +800,7 @@ static ssize_t tap_receive_iov(void *opaque, const struct
iovec *iov,
return len;
}
-static void tap_receive(void *opaque, const uint8_t *buf, int size)
+static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
{
TAPState *s = opaque;
int ret;
@@ -1227,7 +1227,7 @@ typedef struct NetSocketListenState {
} NetSocketListenState;
/* XXX: we consider we can send the whole packet without blocking */
-static void net_socket_receive(void *opaque, const uint8_t *buf, int size)
+static void net_socket_receive(void *opaque, const uint8_t *buf, size_t size)
{
NetSocketState *s = opaque;
uint32_t len;
@@ -1237,7 +1237,7 @@ static void net_socket_receive(void *opaque, const
uint8_t *buf, int size)
send_all(s->fd, buf, size);
}
-static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, int
size)
+static void net_socket_receive_dgram(void *opaque, const uint8_t *buf, size_t
size)
{
NetSocketState *s = opaque;
sendto(s->fd, buf, size, 0,
@@ -1678,7 +1678,7 @@ struct pcap_sf_pkthdr {
uint32_t len;
};
-static void dump_receive(void *opaque, const uint8_t *buf, int size)
+static void dump_receive(void *opaque, const uint8_t *buf, size_t size)
{
DumpState *s = opaque;
struct pcap_sf_pkthdr hdr;
diff --git a/net.h b/net.h
index a312ee5..d99dc39 100644
--- a/net.h
+++ b/net.h
@@ -5,19 +5,20 @@
/* VLANs support */
-typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
-
typedef struct VLANClientState VLANClientState;
+typedef int (NetCanReceive)(void *);
+typedef void (NetReceive)(void *, const uint8_t *, size_t);
+typedef ssize_t (NetReceiveIOV)(void *, const struct iovec *, int);
typedef void (NetCleanup) (VLANClientState *);
typedef void (LinkStatusChanged)(VLANClientState *);
struct VLANClientState {
- IOReadHandler *fd_read;
- IOReadvHandler *fd_readv;
+ NetReceive *receive;
+ NetReceiveIOV *receive_iov;
/* Packets may still be sent if this returns zero. It's used to
rate-limit the slirp code. */
- IOCanRWHandler *fd_can_read;
+ NetCanReceive *can_receive;
NetCleanup *cleanup;
LinkStatusChanged *link_status_changed;
int link_down;
@@ -51,9 +52,9 @@ VLANState *qemu_find_vlan(int id);
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
const char *model,
const char *name,
- IOCanRWHandler *fd_can_read,
- IOReadHandler *fd_read,
- IOReadvHandler *fd_readv,
+ NetCanReceive *can_receive,
+ NetReceive *receive,
+ NetReceiveIOV *receive_iov,
NetCleanup *cleanup,
void *opaque);
void qemu_del_vlan_client(VLANClientState *vc);
@@ -130,9 +131,9 @@ void net_host_device_remove(Monitor *mon, int vlan_id,
const char *device);
void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
VLANClientState *qdev_get_vlan_client(DeviceState *dev,
- IOCanRWHandler *fd_can_read,
- IOReadHandler *fd_read,
- IOReadvHandler *fd_readv,
+ NetCanReceive *can_receive,
+ NetReceive *receive,
+ NetReceiveIOV *receive_iov,
NetCleanup *cleanup,
void *opaque);
diff --git a/savevm.c b/savevm.c
index 8b7909a..f19aa60 100644
--- a/savevm.c
+++ b/savevm.c
@@ -129,7 +129,7 @@ void qemu_announce_self(void)
vlan = nd_table[i].vlan;
for(vc = vlan->first_client; vc != NULL; vc = vc->next) {
for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++)
- vc->fd_read(vc->opaque, buf, len);
+ vc->receive(vc->opaque, buf, len);
}
}
}
diff --git a/tap-win32.c b/tap-win32.c
index 008158d..ccf7e45 100644
--- a/tap-win32.c
+++ b/tap-win32.c
@@ -650,7 +650,7 @@ static void tap_cleanup(VLANClientState *vc)
qemu_free(s);
}
-static void tap_receive(void *opaque, const uint8_t *buf, int size)
+static void tap_receive(void *opaque, const uint8_t *buf, size_t size)
{
TAPState *s = opaque;
--
1.6.0.6
- [Qemu-devel] [PATCH 0/13] Add generic packet buffering API, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 01/13] net: factor tap_read_packet() out of tap_send(), Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 02/13] net: move the tap buffer into TAPState, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 03/13] net: vlan clients with no fd_can_read() can always receive, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 04/13] net: only read from tapfd when we can send, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 05/13] net: add fd_readv() handler to qemu_new_vlan_client() args, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 06/13] net: re-name vc->fd_read() to vc->receive(),
Mark McLoughlin <=
- [Qemu-devel] [PATCH 07/13] net: pass VLANClientState* as first arg to receive handlers, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 08/13] net: add return value to packet receive handler, Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 09/13] net: return status from qemu_deliver_packet(), Mark McLoughlin, 2009/05/19
- [Qemu-devel] [PATCH 10/13] net: split out packet queueing and flushing into separate functions, Mark McLoughlin, 2009/05/22
- [Qemu-devel] [PATCH 11/13] net: add qemu_send_packet_async(), Mark McLoughlin, 2009/05/22
- [Qemu-devel] [PATCH 12/13] net: make use of async packet sending API in tap client, Mark McLoughlin, 2009/05/22
- [Qemu-devel] [PATCH 13/13] virtio-net: implement rx packet queueing, Mark McLoughlin, 2009/05/22
Re: [Qemu-devel] [PATCH 0/13] Add generic packet buffering API, Avi Kivity, 2009/05/19