2 * Virtio Network Device
4 * Copyright IBM, Corp. 2007
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 "standard-headers/linux/virtio_net.h"
18 #include "hw/virtio/virtio.h"
20 #define TYPE_VIRTIO_NET "virtio-net-device"
21 #define VIRTIO_NET(obj) \
22 OBJECT_CHECK(VirtIONet, (obj), TYPE_VIRTIO_NET)
24 #define TX_TIMER_INTERVAL 150000 /* 150 us */
26 /* Limit the number of packets that can be sent via a single flush
27 * of the TX queue. This gives us a guaranteed exit condition and
28 * ensures fairness in the io path. 256 conveniently matches the
29 * length of the TX queue and shows a good balance of performance
33 typedef struct virtio_net_conf
38 uint16_t rx_queue_size;
39 uint16_t tx_queue_size;
46 /* Maximum packet size we can receive from tap device: header + 64k */
47 #define VIRTIO_NET_MAX_BUFSIZE (sizeof(struct virtio_net_hdr) + (64 << 10))
49 typedef struct VirtIONetQueue {
56 VirtQueueElement *elem;
61 typedef struct VirtIONet {
62 VirtIODevice parent_obj;
63 uint8_t mac[ETH_ALEN];
70 uint32_t has_vnet_hdr;
73 uint64_t host_features;
75 uint32_t mergeable_rx_bufs;
82 uint8_t vhost_started;
86 uint8_t multi_overflow;
91 virtio_net_conf net_conf;
100 uint64_t curr_guest_offloads;
101 QEMUTimer *announce_timer;
102 int announce_counter;
103 bool needs_vnet_hdr_swap;
104 bool mtu_bypass_backend;
107 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,