aboutsummaryrefslogtreecommitdiff
path: root/net/queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/queue.c')
-rw-r--r--net/queue.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/net/queue.c b/net/queue.c
index 1ab5247a32..e8030aafe4 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -23,6 +23,7 @@
#include "net/queue.h"
#include "qemu-queue.h"
+#include "net.h"
/* The delivery handler may only return zero if it will call
* qemu_net_queue_flush() when it determines that it is once again able
@@ -40,7 +41,7 @@
struct NetPacket {
QTAILQ_ENTRY(NetPacket) entry;
- VLANClientState *sender;
+ NetClientState *sender;
unsigned flags;
int size;
NetPacketSent *sent_cb;
@@ -48,8 +49,6 @@ struct NetPacket {
};
struct NetQueue {
- NetPacketDeliver *deliver;
- NetPacketDeliverIOV *deliver_iov;
void *opaque;
QTAILQ_HEAD(packets, NetPacket) packets;
@@ -57,16 +56,12 @@ struct NetQueue {
unsigned delivering : 1;
};
-NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver,
- NetPacketDeliverIOV *deliver_iov,
- void *opaque)
+NetQueue *qemu_new_net_queue(void *opaque)
{
NetQueue *queue;
queue = g_malloc0(sizeof(NetQueue));
- queue->deliver = deliver;
- queue->deliver_iov = deliver_iov;
queue->opaque = opaque;
QTAILQ_INIT(&queue->packets);
@@ -89,7 +84,7 @@ void qemu_del_net_queue(NetQueue *queue)
}
static ssize_t qemu_net_queue_append(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const uint8_t *buf,
size_t size,
@@ -110,7 +105,7 @@ static ssize_t qemu_net_queue_append(NetQueue *queue,
}
static ssize_t qemu_net_queue_append_iov(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const struct iovec *iov,
int iovcnt,
@@ -143,7 +138,7 @@ static ssize_t qemu_net_queue_append_iov(NetQueue *queue,
}
static ssize_t qemu_net_queue_deliver(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const uint8_t *data,
size_t size)
@@ -151,14 +146,14 @@ static ssize_t qemu_net_queue_deliver(NetQueue *queue,
ssize_t ret = -1;
queue->delivering = 1;
- ret = queue->deliver(sender, flags, data, size, queue->opaque);
+ ret = qemu_deliver_packet(sender, flags, data, size, queue->opaque);
queue->delivering = 0;
return ret;
}
static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const struct iovec *iov,
int iovcnt)
@@ -166,14 +161,14 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue,
ssize_t ret = -1;
queue->delivering = 1;
- ret = queue->deliver_iov(sender, flags, iov, iovcnt, queue->opaque);
+ ret = qemu_deliver_packet_iov(sender, flags, iov, iovcnt, queue->opaque);
queue->delivering = 0;
return ret;
}
ssize_t qemu_net_queue_send(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const uint8_t *data,
size_t size,
@@ -181,8 +176,8 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
{
ssize_t ret;
- if (queue->delivering) {
- return qemu_net_queue_append(queue, sender, flags, data, size, NULL);
+ if (queue->delivering || !qemu_can_send_packet(sender)) {
+ return qemu_net_queue_append(queue, sender, flags, data, size, sent_cb);
}
ret = qemu_net_queue_deliver(queue, sender, flags, data, size);
@@ -197,7 +192,7 @@ ssize_t qemu_net_queue_send(NetQueue *queue,
}
ssize_t qemu_net_queue_send_iov(NetQueue *queue,
- VLANClientState *sender,
+ NetClientState *sender,
unsigned flags,
const struct iovec *iov,
int iovcnt,
@@ -205,8 +200,9 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
{
ssize_t ret;
- if (queue->delivering) {
- return qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, NULL);
+ if (queue->delivering || !qemu_can_send_packet(sender)) {
+ return qemu_net_queue_append_iov(queue, sender, flags,
+ iov, iovcnt, sent_cb);
}
ret = qemu_net_queue_deliver_iov(queue, sender, flags, iov, iovcnt);
@@ -220,7 +216,7 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue,
return ret;
}
-void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from)
+void qemu_net_queue_purge(NetQueue *queue, NetClientState *from)
{
NetPacket *packet, *next;