Net patches
The following changes since commit 187f35512106501fe9a11057f4d8705431e0026d:
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-251019-3' into staging (2019-10-26 10:13:48 +0100)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to 5af982a47cf6b6cd9beb872e5a9b940e43df5bf9:
COLO-compare: Fix incorrect if logic (2019-10-28 14:28:31 +0800)
----------------------------------------------------------------
----------------------------------------------------------------
Fan Yang (1):
COLO-compare: Fix incorrect if logic
Michael S. Tsirkin (1):
virtio: new post_load hook
Mikhail Sennikovsky (1):
virtio-net: prevent offloads reset on migration
Sven Schnelle (1):
net: add tulip (dec21143) driver
MAINTAINERS | 6 + hw/net/Kconfig | 5 + hw/net/Makefile.objs | 1 + hw/net/trace-events | 14 + hw/net/tulip.c | 1029 ++++++++++++++++++++++++++++++++++++++++ hw/net/tulip.h | 267 +++++++++++ hw/net/virtio-net.c | 27 +- hw/virtio/virtio.c | 7 + include/hw/pci/pci_ids.h | 1 + include/hw/virtio/virtio-net.h | 2 + include/hw/virtio/virtio.h | 6 + net/colo-compare.c | 6 +- 12 files changed, 1365 insertions(+), 6 deletions(-) create mode 100644 hw/net/tulip.c create mode 100644 hw/net/tulip.h
[PULL 2/4] virtio: new post_load hook
From: "Michael S. Tsirkin" <[email protected]>
Post load hook in virtio vmsd is called early while device is processed, and when VirtIODevice core isn't fully initialized. Most device specific code isn't ready to deal with a device in such state, and behaves weirdly.
Add a new post_load hook in a device class instead. Devices should use this unless they specifically want to verify the migration stream as it's processed, e.g. for bounds checking.
--- hw/virtio/virtio.c | 7 +++++++ include/hw/virtio/virtio.h | 6 ++++++ 2 files changed, 13 insertions(+)
hw/virtio/virtio.c +7 -0
@@ -2291,6 +2291,13 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id) }rcu_read_unlock (); +if (vdc->post_load) { + ret = vdc->post_load (vdev); +if (ret) { +return ret; + } + } +return 0 ; }
include/hw/virtio/virtio.h +6 -0
@@ -158,6 +158,12 @@ typedef struct VirtioDeviceClass {*/ void (*save)(VirtIODevice *vdev,QEMUFile *f);int (*load)(VirtIODevice *vdev,QEMUFile *f,int version_id); +/* Post load hook in vmsd is called early while device is processed, and +* when VirtIODevice isn't fully initialized. Devices should use this instead, +* unless they specifically want to verify the migration stream as it's +* processed, e.g. for bounds checking. +*/ +int (*post_load)(VirtIODevice *vdev);const VMStateDescription *vmsd; } VirtioDeviceClass;
Signature · 1 line
2.5.0
[PULL 1/4] net: add tulip (dec21143) driver
In reply to Jason WangFrom: Sven Schnelle <[email protected]>
This adds the basic functionality to emulate a Tulip NIC.
Implemented are:
- RX and TX functionality
- Perfect Frame Filtering
- Big/Little Endian descriptor support
- 93C46 EEPROM support
- LXT970 PHY
Not implemented, mostly because i had no OS using these functions:
- Imperfect frame filtering
- General Purpose Timer
- Transmit automatic polling
- Boot ROM support
- SIA interface
- Big/Little Endian data buffer conversion
Successfully tested with the following Operating Systems:
- MSDOS with Microsoft Network Client 3.0 and DEC ODI drivers
- HPPA Linux
- Windows XP
- HP-UX
Message-Id: <[email protected]>
--- MAINTAINERS | 6 + hw/net/Kconfig | 5 + hw/net/Makefile.objs | 1 + hw/net/trace-events | 14 + hw/net/tulip.c | 1029 ++++++++++++++++++++++++++++++++++++++++++++++ hw/net/tulip.h | 267 ++++++++++++ include/hw/pci/pci_ids.h | 1 + 7 files changed, 1323 insertions(+) create mode 100644 hw/net/tulip.c create mode 100644 hw/net/tulip.h
MAINTAINERS +6 -0
@@ -1643,6 +1643,12 @@ M: Stefan Weil <[email protected]> S: Maintained F: hw/net/eepro100.c +tulip +M: Sven Schnelle <[email protected]> +S: Maintained +F: hw/net/tulip.c +F: hw/net/tulip.h + Generic Loader M: Alistair Francis <[email protected]> S: Maintained
hw/net/Kconfig +5 -0
@@ -24,6 +24,11 @@ config PCNET_PCI config PCNET_COMMON bool +config TULIP + bool + default y if PCI_DEVICES + depends on PCI + config E1000_PCI bool default y if PCI_DEVICES
hw/net/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ common-obj-$(CONFIG_E1000E_PCI_EXPRESS) += e1000e.o e1000e_core.o e1000x_common. common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o common-obj-$(CONFIG_VMXNET3_PCI) += net_tx_pkt.o net_rx_pkt.o common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o +common-obj-$(CONFIG_TULIP) += tulip.o common-obj-$(CONFIG_SMC91C111) += smc91c111.o common-obj-$(CONFIG_LAN9118) += lan9118.o
hw/net/trace-events +14 -0
@@ -367,3 +367,17 @@ virtio_net_announce_notify(void) "" virtio_net_announce_timer(int round) "%d" virtio_net_handle_announce(int round) "%d" virtio_net_post_load_device(void) + +# tulip.c +tulip_reg_write(uint64_t addr, const char *name, int size, uint64_t val) "addr 0x%02"PRIx64" (%s) size %d value 0x%08"PRIx64 +tulip_reg_read(uint64_t addr, const char *name, int size, uint64_t val) "addr 0x%02"PRIx64" (%s) size %d value 0x%08"PRIx64 +tulip_receive(const uint8_t *buf, size_t len) "buf %p size %zu" +tulip_descriptor(const char *prefix, uint32_t addr, uint32_t status, uint32_t control, uint32_t len1, uint32_t len2, uint32_t buf1, uint32_t buf2) "%s 0x%08x: status 0x%08x control 0x%03x len1 %4d len2 %4d buf1 0x%08x buf2 0x%08x" +tulip_rx_state(const char *state) "RX %s" +tulip_tx_state(const char *state) "TX %s" +tulip_irq(uint32_t mask, uint32_t en, const char *state) "mask 0x%08x ie 0x%08x %s" +tulip_mii_write(int phy, int reg, uint16_t data) "phy 0x%x reg 0x%x data 0x%04x" +tulip_mii_read(int phy, int reg, uint16_t data) "phy 0x%x, reg 0x%x data 0x%04x" +tulip_reset(void) "" +tulip_setup_frame(void) "" +tulip_setup_filter(int n, uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f) "%d: %02x:%02x:%02x:%02x:%02x:%02x"
hw/net/tulip.c new file +1029 -0
1,029 lines not on this page · raw message
hw/net/tulip.h new file +267 -0
267 lines not on this page · raw message
include/hw/pci/pci_ids.h +1 -0
@@ -164,6 +164,7 @@#define PCI_DEVICE_ID_LSI_SAS0079 0x0079#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_21143 0x0019#define PCI_DEVICE_ID_DEC_21154 0x0026#define PCI_VENDOR_ID_CIRRUS 0x1013
Signature · 1 line
2.5.0
[PULL 3/4] virtio-net: prevent offloads reset on migration
In reply to Jason WangFrom: Mikhail Sennikovsky <[email protected]>
Currently offloads disabled by guest via the VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET command are not preserved on VM migration.
Instead all offloads reported by guest features (via VIRTIO_PCI_GUEST_FEATURES) get enabled.
What happens is: first the VirtIONet::curr_guest_offloads gets restored and offloads are getting set correctly:
#0 qemu_set_offload (nc=0x555556a11400, csum=1, tso4=0, tso6=0, ecn=0, ufo=0) at net/net.c:474
#1 virtio_net_apply_guest_offloads (n=0x555557701ca0) at hw/net/virtio-net.c:720
#2 virtio_net_post_load_device (opaque=0x555557701ca0, version_id=11) at hw/net/virtio-net.c:2334
#3 vmstate_load_state (f=0x5555569dc010, vmsd=0x555556577c80 <vmstate_virtio_net_device>, opaque=0x555557701ca0, version_id=11)
at migration/vmstate.c:168
#4 virtio_load (vdev=0x555557701ca0, f=0x5555569dc010, version_id=11) at hw/virtio/virtio.c:2197
#5 virtio_device_get (f=0x5555569dc010, opaque=0x555557701ca0, size=0, field=0x55555668cd00 <__compound_literal.5>) at hw/virtio/virtio.c:2036
#6 vmstate_load_state (f=0x5555569dc010, vmsd=0x555556577ce0 <vmstate_virtio_net>, opaque=0x555557701ca0, version_id=11) at migration/vmstate.c:143
#7 vmstate_load (f=0x5555569dc010, se=0x5555578189e0) at migration/savevm.c:829
#8 qemu_loadvm_section_start_full (f=0x5555569dc010, mis=0x5555569eee20) at migration/savevm.c:2211
#9 qemu_loadvm_state_main (f=0x5555569dc010, mis=0x5555569eee20) at migration/savevm.c:2395
#10 qemu_loadvm_state (f=0x5555569dc010) at migration/savevm.c:2467
#11 process_incoming_migration_co (opaque=0x0) at migration/migration.c:449However later on the features are getting restored, and offloads get reset to everything supported by features:
#0 qemu_set_offload (nc=0x555556a11400, csum=1, tso4=1, tso6=1, ecn=0, ufo=0) at net/net.c:474 #1 virtio_net_apply_guest_offloads (n=0x555557701ca0) at hw/net/virtio-net.c:720 #2 virtio_net_set_features (vdev=0x555557701ca0, features=5104441767) at hw/net/virtio-net.c:773 #3 virtio_set_features_nocheck (vdev=0x555557701ca0, val=5104441767) at hw/virtio/virtio.c:2052 #4 virtio_load (vdev=0x555557701ca0, f=0x5555569dc010, version_id=11) at hw/virtio/virtio.c:2220 #5 virtio_device_get (f=0x5555569dc010, opaque=0x555557701ca0, size=0, field=0x55555668cd00 <__compound_literal.5>) at hw/virtio/virtio.c:2036 #6 vmstate_load_state (f=0x5555569dc010, vmsd=0x555556577ce0 <vmstate_virtio_net>, opaque=0x555557701ca0, version_id=11) at migration/vmstate.c:143 #7 vmstate_load (f=0x5555569dc010, se=0x5555578189e0) at migration/savevm.c:829 #8 qemu_loadvm_section_start_full (f=0x5555569dc010, mis=0x5555569eee20) at migration/savevm.c:2211 #9 qemu_loadvm_state_main (f=0x5555569dc010, mis=0x5555569eee20) at migration/savevm.c:2395
#10 qemu_loadvm_state (f=0x5555569dc010) at migration/savevm.c:2467 #11 process_incoming_migration_co (opaque=0x0) at migration/migration.c:449
Fix this by preserving the state in saved_guest_offloads field and pushing out offload initialization to the new post load hook.
--- hw/net/virtio-net.c | 27 ++++++++++++++++++++++++--- include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-)
hw/net/virtio-net.c +24 -3
@@ -2333,9 +2333,13 @@ static int virtio_net_post_load_device(void *opaque, int version_id) n->curr_guest_offloads =virtio_net_supported_guest_offloads (n); } -if (peer_has_vnet_hdr (n)) { -virtio_net_apply_guest_offloads (n); - } +/* +* curr_guest_offloads will be later overwritten by the +* virtio_set_features_nocheck call done from the virtio_load. +* Here we make sure it is preserved and restored accordingly +* in the virtio_net_post_load_virtio callback. +*/ + n->saved_guest_offloads = n->curr_guest_offloads;virtio_net_set_queues (n);
@@ -2370,6 +2374,22 @@ static int virtio_net_post_load_device(void *opaque, int version_id)return 0 ; } +static int virtio_net_post_load_virtio (VirtIODevice *vdev) +{ +VirtIONet *n =VIRTIO_NET (vdev); +/* +* The actual needed state is now in saved_guest_offloads, +* see virtio_net_post_load_device for detail. +* Restore it back and apply the desired offloads. +*/ + n->curr_guest_offloads = n->saved_guest_offloads; +if (peer_has_vnet_hdr (n)) { +virtio_net_apply_guest_offloads (n); + } + +return 0 ; +} +/* tx_waiting field of a VirtIONetQueue */ static const VMStateDescription vmstate_virtio_net_queue_tx_waiting = { .name ="virtio-net-queue-tx_waiting" ,
@@ -2912,6 +2932,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_mask = virtio_net_guest_notifier_mask; vdc->guest_notifier_pending = virtio_net_guest_notifier_pending; vdc->legacy_features |= (0x1 <<VIRTIO_NET_F_GSO ); + vdc->post_load = virtio_net_post_load_virtio; vdc->vmsd = &vmstate_virtio_net_device; }
include/hw/virtio/virtio-net.h +2 -0
@@ -182,6 +182,8 @@ struct VirtIONet {char *netclient_name;char *netclient_type;uint64_t curr_guest_offloads; +/* used on saved state restore phase to preserve the curr_guest_offloads */ +uint64_t saved_guest_offloads;AnnounceTimer announce_timer;bool needs_vnet_hdr_swap;bool mtu_bypass_backend;
Signature · 1 line
2.5.0
[PULL 4/4] COLO-compare: Fix incorrect `if` logic
In reply to Jason WangFrom: Fan Yang <[email protected]>
'colo_mark_tcp_pkt' should return 'true' when packets are the same, and 'false' otherwise. However, it returns 'true' when 'colo_compare_packet_payload' returns non-zero while 'colo_compare_packet_payload' is just a 'memcmp'. The result is that COLO-compare reports inconsistent TCP packets when they are actually the same.
--- net/colo-compare.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/colo-compare.c +3 -3
@@ -319,7 +319,7 @@ static bool colo_mark_tcp_pkt(Packet *ppkt, Packet *spkt, *mark =0 ;if (ppkt->tcp_seq == spkt->tcp_seq && ppkt->seq_end == spkt->seq_end) { -if (colo_compare_packet_payload (ppkt, spkt, +if (!colo_compare_packet_payload (ppkt, spkt, ppkt->header_size, spkt->header_size, ppkt->payload_size)) { *mark =COLO_COMPARE_FREE_SECONDARY |COLO_COMPARE_FREE_PRIMARY ;
@@ -329,7 +329,7 @@ static bool colo_mark_tcp_pkt(Packet *ppkt, Packet *spkt,/* one part of secondary packet payload still need to be compared */ if (!after (ppkt->seq_end, spkt->seq_end)) { -if (colo_compare_packet_payload (ppkt, spkt, +if (!colo_compare_packet_payload (ppkt, spkt, ppkt->header_size + ppkt->offset, spkt->header_size + spkt->offset, ppkt->payload_size - ppkt->offset)) {
@@ -348,7 +348,7 @@ static bool colo_mark_tcp_pkt(Packet *ppkt, Packet *spkt,/* primary packet is longer than secondary packet, compare * the same part and mark the primary packet offset */ -if (colo_compare_packet_payload (ppkt, spkt, +if (!colo_compare_packet_payload (ppkt, spkt, ppkt->header_size + ppkt->offset, spkt->header_size + spkt->offset, spkt->payload_size - spkt->offset)) {
Signature · 1 line
2.5.0
Quoted 9 lines · Jason Wang
The following changes since commit
187f35512106501fe9a11057f4d8705431e0026d:Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-251019-3' into staging (2019-10-26 10:13:48 +0100)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
Quoted 7 lines
for you to fetch changes up to
5af982a47cf6b6cd9beb872e5a9b940e43df5bf9:COLO-compare: Fix incorrect
iflogic (2019-10-28 14:28:31 +0800)----------------------------------------------------------------
----------------------------------------------------------------
Hi -- I get this compile failure on some hosts (s390, aarch64, aarch32, ppc):
/home/pm215/qemu/hw/net/tulip.c: In function ‘tulip_idblock_crc’:/home/pm215/qemu/hw/net/tulip.c:859:9: error: comparison is always true due to limited range of data type [-Werror=type-limits]
for (bit = 15; bit >= 0; bit--) {
^'bit' here is of type char, which can be either signed or unsigned depending on the host. If it's unsigned (as is the case on the above architectures), then the loop will never terminate because "bit >= 0" is always true. Plain old 'int' is probably a better choice anyway.
thanks
-- PMM
Quoted 22 lines · Peter Maydell
Quoted 8 lines · Jason Wang
The following changes since commit
187f35512106501fe9a11057f4d8705431e0026d:Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-251019-3' into staging (2019-10-26 10:13:48 +0100)are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
Quoted 7 lines
for you to fetch changes up to
5af982a47cf6b6cd9beb872e5a9b940e43df5bf9:COLO-compare: Fix incorrect `if` logic (2019-10-28 14:28:31 +0800)----------------------------------------------------------------
----------------------------------------------------------------
Hi -- I get this compile failure on some hosts (s390, aarch64, aarch32, ppc):
/home/pm215/qemu/hw/net/tulip.c: In function ‘tulip_idblock_crc’:/home/pm215/qemu/hw/net/tulip.c:859:9: error: comparison is always true due to limited range of data type [-Werror=type-limits]
Quoted 8 lines
for (bit = 15; bit >= 0; bit--) { ^'bit' here is of type char, which can be either signed or unsigned depending on the host. If it's unsigned (as is the case on the above architectures), then the loop will never terminate because "bit >= 0" is always true. Plain old 'int' is probably a better choice anyway.
Yes, will fix and post V2.
Thanks
Quoted 4 lines
thanks
-- PMM