Commit f10c592e8d35e59a11cf7af1484ab1051acc3ef6

Authored by Alex Williamson
Committed by Mark McLoughlin
1 parent 6c042c16

virtio-net: Use a byte to store RX mode flags

There's no need to save 4 bytes for promisc and allmulti.
Use one byte each just to avoid the overhead of a bitmap.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Showing 1 changed file with 12 additions and 7 deletions
hw/virtio-net.c
... ... @@ -16,7 +16,7 @@
16 16 #include "qemu-timer.h"
17 17 #include "virtio-net.h"
18 18  
19   -#define VIRTIO_NET_VM_VERSION 7
  19 +#define VIRTIO_NET_VM_VERSION 8
20 20  
21 21 #define MAC_TABLE_ENTRIES 32
22 22 #define MAX_VLAN (1 << 12) /* Per 802.1Q definition */
... ... @@ -33,8 +33,8 @@ typedef struct VirtIONet
33 33 QEMUTimer *tx_timer;
34 34 int tx_timer_active;
35 35 int mergeable_rx_bufs;
36   - int promisc;
37   - int allmulti;
  36 + uint8_t promisc;
  37 + uint8_t allmulti;
38 38 struct {
39 39 int in_use;
40 40 uint8_t *macs;
... ... @@ -523,8 +523,8 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
523 523 qemu_put_be32(f, n->tx_timer_active);
524 524 qemu_put_be32(f, n->mergeable_rx_bufs);
525 525 qemu_put_be16(f, n->status);
526   - qemu_put_be32(f, n->promisc);
527   - qemu_put_be32(f, n->allmulti);
  526 + qemu_put_byte(f, n->promisc);
  527 + qemu_put_byte(f, n->allmulti);
528 528 qemu_put_be32(f, n->mac_table.in_use);
529 529 qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
530 530 qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3);
... ... @@ -548,8 +548,13 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
548 548 n->status = qemu_get_be16(f);
549 549  
550 550 if (version_id >= 4) {
551   - n->promisc = qemu_get_be32(f);
552   - n->allmulti = qemu_get_be32(f);
  551 + if (version_id < 8) {
  552 + n->promisc = qemu_get_be32(f);
  553 + n->allmulti = qemu_get_be32(f);
  554 + } else {
  555 + n->promisc = qemu_get_byte(f);
  556 + n->allmulti = qemu_get_byte(f);
  557 + }
553 558 }
554 559  
555 560 if (version_id >= 5) {
... ...