« Previous | Next » 

Revision f3b6c7fc

IDf3b6c7fcf8fca857b3c3ba0aa5b3a06d7ce0ac37

Added by Mark McLoughlin almost 15 years ago

net: add qemu_send_packet_async()

Add a qemu_send_packet() variant which will queue up the packet
if it cannot be sent when all client queues are full. It later
invokes the supplied callback when the packet has been sent.

If qemu_send_packet_async() returns zero, the caller is expected
to not send any more packets until the queued packet has been
sent.

Packets are queued iff a receive() handler returns zero (indicating
queue full) and the caller has provided a sent notification callback
(indicating it will stop and start its own queue).

We need the packet sending API to support queueing because:

- a sending client should process all available packets in one go
(e.g. virtio-net emptying its tx ring)
- a receiving client may not be able to handle the packet
(e.g. -EAGAIN from write() to tapfd)
- the sending client could detect this condition in advance
(e.g. by select() for writable on tapfd)
- that's too much overhead (e.g. a select() call per packet)
- therefore the sending client must handle the condition by
dropping the packet or queueing it
- dropping packets is poor form; we should queue.

However, we don't want queueing to be completely transparent. We
want the sending client to stop sending packets as soon as a
packet is queued. This allows the sending client to be throttled
by the receiver.

Signed-off-by: Mark McLoughlin <>

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences