Lines Matching refs:queue
65 NetQueue *queue; in qemu_new_net_queue() local
67 queue = g_new0(NetQueue, 1); in qemu_new_net_queue()
69 queue->opaque = opaque; in qemu_new_net_queue()
70 queue->nq_maxlen = 10000; in qemu_new_net_queue()
71 queue->nq_count = 0; in qemu_new_net_queue()
72 queue->deliver = deliver; in qemu_new_net_queue()
74 QTAILQ_INIT(&queue->packets); in qemu_new_net_queue()
76 queue->delivering = 0; in qemu_new_net_queue()
78 return queue; in qemu_new_net_queue()
81 void qemu_del_net_queue(NetQueue *queue) in qemu_del_net_queue() argument
85 QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) { in qemu_del_net_queue()
86 QTAILQ_REMOVE(&queue->packets, packet, entry); in qemu_del_net_queue()
90 g_free(queue); in qemu_del_net_queue()
93 static void qemu_net_queue_append(NetQueue *queue, in qemu_net_queue_append() argument
102 if (queue->nq_count >= queue->nq_maxlen && !sent_cb) { in qemu_net_queue_append()
112 queue->nq_count++; in qemu_net_queue_append()
113 QTAILQ_INSERT_TAIL(&queue->packets, packet, entry); in qemu_net_queue_append()
116 void qemu_net_queue_append_iov(NetQueue *queue, in qemu_net_queue_append_iov() argument
127 if (queue->nq_count >= queue->nq_maxlen && !sent_cb) { in qemu_net_queue_append_iov()
147 queue->nq_count++; in qemu_net_queue_append_iov()
148 QTAILQ_INSERT_TAIL(&queue->packets, packet, entry); in qemu_net_queue_append_iov()
151 static ssize_t qemu_net_queue_deliver(NetQueue *queue, in qemu_net_queue_deliver() argument
163 queue->delivering = 1; in qemu_net_queue_deliver()
164 ret = queue->deliver(sender, flags, &iov, 1, queue->opaque); in qemu_net_queue_deliver()
165 queue->delivering = 0; in qemu_net_queue_deliver()
170 static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, in qemu_net_queue_deliver_iov() argument
178 queue->delivering = 1; in qemu_net_queue_deliver_iov()
179 ret = queue->deliver(sender, flags, iov, iovcnt, queue->opaque); in qemu_net_queue_deliver_iov()
180 queue->delivering = 0; in qemu_net_queue_deliver_iov()
185 ssize_t qemu_net_queue_receive(NetQueue *queue, in qemu_net_queue_receive() argument
189 if (queue->delivering) { in qemu_net_queue_receive()
193 return qemu_net_queue_deliver(queue, NULL, 0, data, size); in qemu_net_queue_receive()
196 ssize_t qemu_net_queue_receive_iov(NetQueue *queue, in qemu_net_queue_receive_iov() argument
200 if (queue->delivering) { in qemu_net_queue_receive_iov()
204 return qemu_net_queue_deliver_iov(queue, NULL, 0, iov, iovcnt); in qemu_net_queue_receive_iov()
207 ssize_t qemu_net_queue_send(NetQueue *queue, in qemu_net_queue_send() argument
216 if (queue->delivering || !qemu_can_send_packet(sender)) { in qemu_net_queue_send()
217 qemu_net_queue_append(queue, sender, flags, data, size, sent_cb); in qemu_net_queue_send()
221 ret = qemu_net_queue_deliver(queue, sender, flags, data, size); in qemu_net_queue_send()
223 qemu_net_queue_append(queue, sender, flags, data, size, sent_cb); in qemu_net_queue_send()
227 qemu_net_queue_flush(queue); in qemu_net_queue_send()
232 ssize_t qemu_net_queue_send_iov(NetQueue *queue, in qemu_net_queue_send_iov() argument
241 if (queue->delivering || !qemu_can_send_packet(sender)) { in qemu_net_queue_send_iov()
242 qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb); in qemu_net_queue_send_iov()
246 ret = qemu_net_queue_deliver_iov(queue, sender, flags, iov, iovcnt); in qemu_net_queue_send_iov()
248 qemu_net_queue_append_iov(queue, sender, flags, iov, iovcnt, sent_cb); in qemu_net_queue_send_iov()
252 qemu_net_queue_flush(queue); in qemu_net_queue_send_iov()
257 void qemu_net_queue_purge(NetQueue *queue, NetClientState *from) in qemu_net_queue_purge() argument
261 QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) { in qemu_net_queue_purge()
263 QTAILQ_REMOVE(&queue->packets, packet, entry); in qemu_net_queue_purge()
264 queue->nq_count--; in qemu_net_queue_purge()
273 bool qemu_net_queue_flush(NetQueue *queue) in qemu_net_queue_flush() argument
275 if (queue->delivering) in qemu_net_queue_flush()
278 while (!QTAILQ_EMPTY(&queue->packets)) { in qemu_net_queue_flush()
282 packet = QTAILQ_FIRST(&queue->packets); in qemu_net_queue_flush()
283 QTAILQ_REMOVE(&queue->packets, packet, entry); in qemu_net_queue_flush()
284 queue->nq_count--; in qemu_net_queue_flush()
286 ret = qemu_net_queue_deliver(queue, in qemu_net_queue_flush()
292 queue->nq_count++; in qemu_net_queue_flush()
293 QTAILQ_INSERT_HEAD(&queue->packets, packet, entry); in qemu_net_queue_flush()