2 * Virtio Network Device
4 * Copyright IBM, Corp. 2007
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef QEMU_VIRTIO_NET_H
15 #define QEMU_VIRTIO_NET_H
17 #include "qemu/units.h"
18 #include "standard-headers/linux/virtio_net.h"
19 #include "hw/virtio/virtio.h"
21 #define TYPE_VIRTIO_NET "virtio-net-device"
22 #define VIRTIO_NET(obj) \
23 OBJECT_CHECK(VirtIONet, (obj), TYPE_VIRTIO_NET)
25 #define TX_TIMER_INTERVAL 150000 /* 150 us */
27 /* Limit the number of packets that can be sent via a single flush
28 * of the TX queue. This gives us a guaranteed exit condition and
29 * ensures fairness in the io path. 256 conveniently matches the
30 * length of the TX queue and shows a good balance of performance
34 typedef struct virtio_net_conf
39 uint16_t rx_queue_size
;
40 uint16_t tx_queue_size
;
47 /* Maximum packet size we can receive from tap device: header + 64k */
48 #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 * KiB))
50 typedef struct VirtIONetQueue
{
57 VirtQueueElement
*elem
;
62 typedef struct VirtIONet
{
63 VirtIODevice parent_obj
;
64 uint8_t mac
[ETH_ALEN
];
71 uint32_t has_vnet_hdr
;
74 uint64_t host_features
;
76 uint32_t mergeable_rx_bufs
;
83 uint8_t vhost_started
;
87 uint8_t multi_overflow
;
92 virtio_net_conf net_conf
;
100 char *netclient_type
;
101 uint64_t curr_guest_offloads
;
102 QEMUTimer
*announce_timer
;
103 int announce_counter
;
104 bool needs_vnet_hdr_swap
;
105 bool mtu_bypass_backend
;
108 void virtio_net_set_netclient_name(VirtIONet
*n
, const char *name
,