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,7 +16,7 @@
16 #include "qemu-timer.h" 16 #include "qemu-timer.h"
17 #include "virtio-net.h" 17 #include "virtio-net.h"
18 18
19 -#define VIRTIO_NET_VM_VERSION 7 19 +#define VIRTIO_NET_VM_VERSION 8
20 20
21 #define MAC_TABLE_ENTRIES 32 21 #define MAC_TABLE_ENTRIES 32
22 #define MAX_VLAN (1 << 12) /* Per 802.1Q definition */ 22 #define MAX_VLAN (1 << 12) /* Per 802.1Q definition */
@@ -33,8 +33,8 @@ typedef struct VirtIONet @@ -33,8 +33,8 @@ typedef struct VirtIONet
33 QEMUTimer *tx_timer; 33 QEMUTimer *tx_timer;
34 int tx_timer_active; 34 int tx_timer_active;
35 int mergeable_rx_bufs; 35 int mergeable_rx_bufs;
36 - int promisc;  
37 - int allmulti; 36 + uint8_t promisc;
  37 + uint8_t allmulti;
38 struct { 38 struct {
39 int in_use; 39 int in_use;
40 uint8_t *macs; 40 uint8_t *macs;
@@ -523,8 +523,8 @@ static void virtio_net_save(QEMUFile *f, void *opaque) @@ -523,8 +523,8 @@ static void virtio_net_save(QEMUFile *f, void *opaque)
523 qemu_put_be32(f, n->tx_timer_active); 523 qemu_put_be32(f, n->tx_timer_active);
524 qemu_put_be32(f, n->mergeable_rx_bufs); 524 qemu_put_be32(f, n->mergeable_rx_bufs);
525 qemu_put_be16(f, n->status); 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 qemu_put_be32(f, n->mac_table.in_use); 528 qemu_put_be32(f, n->mac_table.in_use);
529 qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN); 529 qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN);
530 qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); 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,8 +548,13 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
548 n->status = qemu_get_be16(f); 548 n->status = qemu_get_be16(f);
549 549
550 if (version_id >= 4) { 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 if (version_id >= 5) { 560 if (version_id >= 5) {