提交 bb9d17f8 编写于 作者: C Cornelia Huck 提交者: Michael S. Tsirkin

virtio-net: support longer header

virtio-1 devices always use num_buffers in the header, even if
mergeable rx buffers have not been negotiated.
Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
上级 b6a3cddb
...@@ -367,15 +367,21 @@ static int peer_has_ufo(VirtIONet *n) ...@@ -367,15 +367,21 @@ static int peer_has_ufo(VirtIONet *n)
return n->has_ufo; return n->has_ufo;
} }
static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs) static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs,
int version_1)
{ {
int i; int i;
NetClientState *nc; NetClientState *nc;
n->mergeable_rx_bufs = mergeable_rx_bufs; n->mergeable_rx_bufs = mergeable_rx_bufs;
if (version_1) {
n->guest_hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
} else {
n->guest_hdr_len = n->mergeable_rx_bufs ? n->guest_hdr_len = n->mergeable_rx_bufs ?
sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr); sizeof(struct virtio_net_hdr_mrg_rxbuf) :
sizeof(struct virtio_net_hdr);
}
for (i = 0; i < n->max_queues; i++) { for (i = 0; i < n->max_queues; i++) {
nc = qemu_get_subqueue(n->nic, i); nc = qemu_get_subqueue(n->nic, i);
...@@ -522,7 +528,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) ...@@ -522,7 +528,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
virtio_net_set_mrg_rx_bufs(n, virtio_net_set_mrg_rx_bufs(n,
__virtio_has_feature(features, __virtio_has_feature(features,
VIRTIO_NET_F_MRG_RXBUF)); VIRTIO_NET_F_MRG_RXBUF),
__virtio_has_feature(features,
VIRTIO_F_VERSION_1));
if (n->has_vnet_hdr) { if (n->has_vnet_hdr) {
n->curr_guest_offloads = n->curr_guest_offloads =
...@@ -1375,7 +1383,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f, ...@@ -1375,7 +1383,8 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
qemu_get_buffer(f, n->mac, ETH_ALEN); qemu_get_buffer(f, n->mac, ETH_ALEN);
n->vqs[0].tx_waiting = qemu_get_be32(f); n->vqs[0].tx_waiting = qemu_get_be32(f);
virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f)); virtio_net_set_mrg_rx_bufs(n, qemu_get_be32(f),
virtio_has_feature(vdev, VIRTIO_F_VERSION_1));
if (version_id >= 3) if (version_id >= 3)
n->status = qemu_get_be16(f); n->status = qemu_get_be16(f);
...@@ -1627,7 +1636,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) ...@@ -1627,7 +1636,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
n->vqs[0].tx_waiting = 0; n->vqs[0].tx_waiting = 0;
n->tx_burst = n->net_conf.txburst; n->tx_burst = n->net_conf.txburst;
virtio_net_set_mrg_rx_bufs(n, 0); virtio_net_set_mrg_rx_bufs(n, 0, 0);
n->promisc = 1; /* for compatibility */ n->promisc = 1; /* for compatibility */
n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册