aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-net.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2009-06-10 18:05:55 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-10 18:08:35 -0500
commitf8e76fbf5190575c0f927fe3c5b0ec6934c6c3fc (patch)
treec67bf81b0bfa6b897f4fb7a236962a85819e15f7 /hw/usb-net.c
parentb319820d4099ec6b98c9c260e06d519fc41d544c (diff)
parent4ffb17f5c3244e405198ae285ffbb20a62e0d4b3 (diff)
Merge branch 'net-queue'
* net-queue: (28 commits) virtio-net: Increase filter and control limits virtio-net: Add new RX filter controls virtio-net: MAC filter optimization virtio-net: Fix MAC filter overflow handling virtio-net: reorganize receive_filter() virtio-net: Use a byte to store RX mode flags virtio-net: Add version_id 7 placeholder for vnet header support virtio-net: implement rx packet queueing net: make use of async packet sending API in tap client net: add qemu_send_packet_async() net: split out packet queueing and flushing into separate functions net: return status from qemu_deliver_packet() net: add return value to packet receive handler net: pass VLANClientState* as first arg to receive handlers net: re-name vc->fd_read() to vc->receive() net: add fd_readv() handler to qemu_new_vlan_client() args net: only read from tapfd when we can send net: vlan clients with no fd_can_read() can always receive net: move the tap buffer into TAPState net: factor tap_read_packet() out of tap_send() ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/usb-net.c')
-rw-r--r--hw/usb-net.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 9e6442506f..0e80ca6923 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1369,17 +1369,17 @@ 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 ssize_t usbnet_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
- USBNetState *s = opaque;
+ USBNetState *s = vc->opaque;
struct rndis_packet_msg_type *msg;
if (s->rndis) {
msg = (struct rndis_packet_msg_type *) s->in_buf;
if (!s->rndis_state == RNDIS_DATA_INITIALIZED)
- return;
+ return -1;
if (size + sizeof(struct rndis_packet_msg_type) > sizeof(s->in_buf))
- return;
+ return -1;
memset(msg, 0, sizeof(struct rndis_packet_msg_type));
msg->MessageType = cpu_to_le32(RNDIS_PACKET_MSG);
@@ -1398,16 +1398,17 @@ static void usbnet_receive(void *opaque, const uint8_t *buf, int size)
s->in_len = size + sizeof(struct rndis_packet_msg_type);
} else {
if (size > sizeof(s->in_buf))
- return;
+ return -1;
memcpy(s->in_buf, buf, size);
s->in_len = size;
}
s->in_ptr = 0;
+ return size;
}
-static int usbnet_can_receive(void *opaque)
+static int usbnet_can_receive(VLANClientState *vc)
{
- USBNetState *s = opaque;
+ USBNetState *s = vc->opaque;
if (s->rndis && !s->rndis_state == RNDIS_DATA_INITIALIZED)
return 1;
@@ -1458,8 +1459,9 @@ USBDevice *usb_net_init(NICInfo *nd)
pstrcpy(s->dev.devname, sizeof(s->dev.devname),
"QEMU USB Network Interface");
s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
- usbnet_receive,
usbnet_can_receive,
+ usbnet_receive,
+ NULL,
usbnet_cleanup, s);
qemu_format_nic_info_str(s->vc, s->mac);