VMXNET3 paravirtual NIC device implementation
Subsystems (2)
v9 cover VMXNET3 paravirtual NIC device implementation
This set of patches implements VMWare VMXNET3 paravirtual NIC device. The device supports of all the device features including offload capabilties, VLANs and etc.
The device is tested on different OSes:
Fedora 15
Ubuntu 10.4
Centos 6.2
Windows 2008R2
Windows 2008 64bit
Windows 2008 32bit
Windows 2003 64bit
Windows 2003 32bitChanges in V9:
Issues reported by Stefan Hajnoczi fixed.
Changes in V8:
Issues reported by Stefan Hajnoczi reviewed and mostly fixed:
Review
Quoted 5 lines
(quoted diff) +5
-0+ } + curr_src_off += src[i].iov_len; + } + return j; +}
The existing iov_copy() function provides equivalent functionality. I don't think iov_rebuild() is needed.
[DF] Done. Thanks, missed it.
Review
Quoted 6 lines
(quoted diff) +6
-0+ size -= len; + } + iovec_off += iov[i].iov_len; + } + return res; +}
Rename this net_checksum_add_iov() and place it in net/checksum.c, then the new dependency on net from block can be dropped.
[DF] Done.
Quoted 5 lines
+vmw_shmem_read(hwaddr addr, void *buf, int len)
{ VMW_SHPRN("SHMEM r: %" PRIx64 ", len: %d to %p", addr, len, buf); cpu_physical_memory_read(addr, buf, len);}
All changes to this file should be squashed with the previous patch.
[DF] Done
Review
Quoted 13 lines
(quoted diff) +9
-0+#ifdef VMXNET_DEBUG_SHMEM_ACCESS +#define VMW_SHPRN(fmt, ...) \ + do { \ + printf("[%s][SH][%s]: " fmt "\n", VMXNET_DEVICE_NAME, __func__, \ + ## __VA_ARGS__); \ + } while (0) +#else +#define VMW_SHPRN(fmt, ...) do {} while (0) +#endif
Please use QEMU tracing. It eliminates all this boilerplate and conditional compilation. Tracing can be enabled/disabled at runtime and works with SystemTap/DTrace. See docs/tracing.txt.
[DF] We'd like to stick with compile time logic in this case becase of 2 reasons:
[DF] 1. These printouts are intended for reverse engineering/development only and there is
[DF] no need to enable them at run time
[DF] 2. There is a big number of printouts, all driver-device communication is traced,
[DF] they hit performance even on strongest x86 in case of run-time logic
Review
Quoted 5 lines
(quoted diff) +5
-0+struct eth_header { + uint8_t h_dest[ETH_ALEN]; /* destination eth addr */ + uint8_t h_source[ETH_ALEN]; /* source ether addr */ + uint16_t h_proto; /* packet type ID field */ +};
Looks like it's copy-pasted stuff from /usr/include/linux/if_*.h, /usr/include/netinet/*.h, and friends. If the system-wide headers are included names will collide for some of the macros at least.
Did you check if the slirp/ definitions can be reused?
[DF] Yes, you are right. This is copy-pasted from different places. [DF] Slips definishing do not fully cover our needs.
I'd rather we import network header definitions once in a generic place into the source tree. That way vmxnet and other components don't need to redefine these structs.
[DF] Exaclty! Our intention is to create generic header with network definitions and make everyone use it. [DF] We can move our header to some shared place if you want, however I'd do it in parallel with cleanup [DF] of similar definitions in existing code and this is a big change that os out of scope of these patches.
Quoted 2 lines
+ *===========================================================================*/
Is this huge comment box a sign that the code should be split into a foo_tx.c and an foo_rx.c file?
[DF] As for me this file is not that big to be splitted (<800 lines), however I'll do this if you insist :)
Quoted 1 line
+size_t
vmxnet_tx_pkt_send(VmxnetTxPktH pkt, NetClientState *vc)
'vc' is an old name that was used for VLANClientState. The struct has since been renamed to NetClientState and the rest of QEMU uses 'nc' instead of 'vc'.
[DF] Fixed. Thanks.
Review
Quoted 2 lines
(quoted diff) +2
-0+/* tx module context handle */ +typedef void *VmxnetTxPktH;
Forward-declaring the struct is nicer:
typedef struct VmxnetTxPkt VmxnetTxPkt;
The definition of VmxnetTxPkt is still hidden from the caller but you avoid the void* and casting. In vmxnet_pkt.c define using:
struct VmxnetTxPkt {
...
};[DF] Agree, fixed. Thanks.
hw/vmxnet_utils.h
Quoted 4 lines
hw/vmxnet_utils.h +0
-0
Please squash these fixes into the previous patch.
[DF] Oops, my bad. Fixed.
hw/vmxnet_utils.h
Quoted 3 lines
hw/vmxnet_utils.h +3
-0+uint8_t msix_used; +/* Whether MSI support was installed successfully */ +uint8_t msi_used;
These two fields should be bool.
hw/vmxnet_utils.h
Quoted 2 lines
hw/vmxnet_utils.h +2
-0+/* Whether automatic interrupts masking enabled */ +uint8_t auto_int_masking;
bool
[DF] Done.
hw/vmxnet_utils.h
Quoted 9 lines
hw/vmxnet_utils.h +9
-0+static inline void vmxnet3_flush_shmem_changes (void ) +{ +/* +* Flush shared memory changes +* Needed before sending interrupt to guest to ensure +* it gets consistent memory state +*/ +smp_wmb (); +}
It's useful to document why a memory barrier is being used in each instance. Therefore hiding smp_wmb() inside a wrapper function isn't great.
[DF] Fixed.
Also, it's suspicious that smb_wmb() is used but no other barriers are used. What about a read memory barrier when accessing shared memory written by the guest?
[DF] VMWARE interface build a in safe way - you always read out data buffer (packet descriptor) with memcopy, [DF] and then check its last byte to see whether it was fully filled by driver.
[DF] In this case device doesn't need read barriers. Drivers need write barriers of course to secure [DF] proper order of writes.
Changes in V7:
Issues reported by Michael S. Tsirkin reviewed and mostly fixed:
File vmware_utils.h:
...
hw/vmxnet_utils.h
Quoted 7 lines
hw/vmxnet_utils.h +7
-0+static inline void +vmw_shmem_st64 (target_phys_addr_t addr,uint64_t value) +{ +VMW_SHPRN ("SHMEM store64: %" PRIx64" (value %" PRIx64")" , addr, value); +stq_le_phys (addr, value); +} +
Pls remove these wrappers. These are just memory stores. Our codebase is too large as it is without every driver wrapping all standard calls.
[DF] Idea behind this macros is to have printout in each of them [DF] Printouts are really needed when reverse-engineering windows guest drivers [DF] Since there is no windows drivers code this is the only way to understand [DF] sequences they use
Quoted 1 line
+/* MACROS for simplification of operations on array-style registers */
UPPERCASE ABUSE
[DF] Fixed
hw/vmxnet_utils.h
Quoted 2 lines
hw/vmxnet_utils.h +2
-0+#define IS_MULTIREG_ADDR (addr, base, cnt, regsize) \ + (((addr + 1) > (base)) && ((addr) < (base) + (cnt) * (regsize)))
Same as range_covers_byte(base, cnt * regsize, addr)?
[DF] Fixed, thanks
hw/vmxnet_utils.h
Quoted 4 lines
hw/vmxnet_utils.h +4
-0+ +#define MULTIREG_IDX_BY_ADDR (addr, base, regsize) \ + (((addr) - (base)) / (regsize)) +
Above two macros is all that's left. No objection but it does not say what they do - want to add minimal documentation?
And please prefix with VMWARE_ or something.
[DF] Prefix added, macros documented
File vmxnet_utils.h (and related with the same problems):
...
hw/vmxnet_utils.h
Quoted 6 lines
+ * See the COPYING file in the top-level directory.
+ *
+ */hw/vmxnet_utils.h +3
-0+ +#ifndef _VMXNET_UTILS_H_ +#define _VMXNET_UTILS_H_
Please do not start identifiers with _ followed by an uppercase lattters.
[DF] Fixed
...
hw/vmxnet_utils.h
Quoted 7 lines
hw/vmxnet_utils.h +7
-0+ +struct eth_header { +uint8_t h_dest[ETH_ALEN ];/* destination eth addr */ +uint8_t h_source[ETH_ALEN ];/* source ether addr */ +uint16_t h_proto;/* packet type ID field */ +}; +
And fix struct definitions to
1. follow qemu coding style
[DF] It's not clear what's wrong with the coding style. Please, elaborate.
2. start with vmxnet
[DF] Since this is generic network definitions with no device specifics
[DF] I'm not sure it makes sense to add vmxnet prefix.
[DF] I'd say it makes sense to put them into some generic header files under "net" directory instead [DF] and clean up other devices that have their local definitions of the same structures. [DF] Please, advise.
I also don't really understand why are these functions split out - vmxnet is the only user, no?
[DF] Currently vmxnet3 is the only user, hovewer we have vmxnet2 implementation as well (not submitted yet) [DF] and it uses the same header
File vmxnet_pkt.h:
...
hw/vmxnet_utils.h
Quoted 3 lines
hw/vmxnet_utils.h +3
-0+ +/* tx module context handle */ +typedef void *VmxnetTxPktH ;
This gets you zero type safety and makes debugging impossible. Just use pointers like everyone does.
[DF] Handle type is added to hide VmxnetTxPkt structure into .c header [DF] for better encapsulation.
[DF] Should we drop it anyway?
Files vmxnet3.*:
...
hw/vmxnet_utils.h
Quoted 3 lines
hw/vmxnet_utils.h +3
-0+ +if (zero_region) { +vmw_shmem_set (pa,0 , size*cell_size);
spaces around *
[DF] Fixed
...
Quoted 7 lines
+#define
vmxnet3_ring_dump(macro, ring_name, ridx, r)\
+ macro("%s#%d: base %" PRIx64 " size %lucell_size%lu gen %d next %lu",
\
+ (ring_name), (ridx),
\
+ (r)->pa, (r)->size, (r)->cell_size, (r)->gen, (r)->next)
make macros upper case
[DF] Fixed
...
hw/vmxnet_utils.h
Quoted 5 lines
hw/vmxnet_utils.h +5
-0+static inline void vmxnet3_flush_shmem_changes (void ) +{ +/* +* Flush shared memory changes +* Needed before transferring control to guest
what does 'transferring control to guest' mean?
[DF] Changed to
[DF] /*
[DF] * Flush shared memory changes [DF] * Needed before sending interrupt to guest to ensure [DF] * it gets consistent memory state [DF] */
...
hw/vmxnet_utils.h
Quoted 3 lines
hw/vmxnet_utils.h +3
-0+*/ +smp_wmb (); +}
Don't use wrappers like this. They just hide bugs. For example it's not helpful before an interrupt in the function below.
[DF] I guess you are talking about vmxnet3_complete_packet() [DF] Strictly speaking barrier is a must because we change shared memory in [DF] vmxnet3_complete_packet()
[DF] And the wrapper is a good thing because its name explains its effect [DF] in a formal way as opposed to comments
...
hw/vmxnet_utils.h
Quoted 2 lines
hw/vmxnet_utils.h +2
-0+switch (status) { +case VMXNET3_PKT_STATUS_OK : {
don't put {} around cases: they align incorrectly
if it's too big move to a function.
[DF] Fixed
...
hw/vmxnet_utils.h
Quoted 5 lines
hw/vmxnet_utils.h +5
-0+static bool +vmxnet3_send_packet (VMXNET3State *s,uint32_t qidx) +{ +size_t bytes_sent =0 ; +bool res = true;
why = true? don't initialize just because.
[DF] Fixed
...
Quoted 6 lines
+/*
+ * VMWARE headers we got from Linux kernel do not fully comply QEMU coding
+ * standards in sense of types and defines used.
+ * Since we didn't want to change VMWARE code, following set of typedefs
+ * and defines needed to compile these headers with QEMU introduced.
+ */
No need for this now.
You can export headers and put them under linux-headers.
[DF] Not sure it is possible because the header as-is is not stand-alone and won't compile [DF] without changes. We extracted definitions we use from their header and dropped unused [DF] and kernel-specific stuff.
[DF} Please, advise.
...
Quoted 1 line
+ if (
VMXNET3_OM_TSO==s->offload_mode) {
Don't do Yoda style like this
[DF] "Yoda" style removed everywhere
Changes in V6:
Fixed most of problems pointed out by Michael S. Tsirkin
The only issue still open is creation of shared place
with generic network structures and functions. Currently
all generic network code introduced by VMXNET3 resides in vmxnet_utils.c/h files. It could be moved to some shared location however we believe it is a matter of separate refactoring as there are a lot of copy-pasted definitions in almost every device and code cleanup efforts requred in order to create truly shared codebase.
Implemented suggestions by Anthony Liguori
Fixed incorrect checksum caclulation for some packets in SW offloads mode
Changes in V5:
MSI-X save/load implemented in the device instead of pci bus as suggested by Michael S. Tsirkin
Patches regrouped as suggested by Paolo Bonzini
Changes in V4:
Fixed a few problems uncovered by NETIO test suit Assertion on failure to initialize MSI/MSI-X replaced with warning message and fallback to Legacy/MSI respectively
Various coding style adjustments and patch split-up as suggested by Anthony
Liguori
Live migration support added
Changes in V3:
Fixed crash when net device that is used as network fronted has no virtio HDR support.
Task offloads emulation for cases when net device that is used as network fronted has no virtio HDR support.
Changes in V2:
License text changed accoring to community suggestions Standard license header from GPLv2+ - licensed QEMU files used
Dmitry Fleytman (5):
Adding utility function net_checksum_add_cont() that allows checksum
calculation of scattered data with odd chunk sizes
Adding utility function net_checksum_add_iov() for iovec checksum
calculation
Adding common definitions for VMWARE devices
Adding packet abstraction for VMWARE network devices Adding VMXNET3 device implementation
default-configs/pci.mak | 1 + hw/Makefile.objs | 1 + hw/pci.h | 1 + hw/vmware_utils.h | 143 +++ hw/vmxnet3.c | 2437 +++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet3.h | 762 +++++++++++++++ hw/vmxnet_debug.h | 121 +++ hw/vmxnet_pkt.c | 758 +++++++++++++++ hw/vmxnet_pkt.h | 309 ++++++ hw/vmxnet_utils.c | 219 +++++ hw/vmxnet_utils.h | 340 +++++++ iov.h | 5 + net/checksum.c | 41 +- net/checksum.h | 22 +- 14 files changed, 5153 insertions(+), 7 deletions(-) create mode 100644 hw/vmware_utils.h create mode 100644 hw/vmxnet3.c create mode 100644 hw/vmxnet3.h create mode 100644 hw/vmxnet_debug.h create mode 100644 hw/vmxnet_pkt.c create mode 100644 hw/vmxnet_pkt.h create mode 100644 hw/vmxnet_utils.c create mode 100644 hw/vmxnet_utils.h
Signature · 1 line
1.7.11.7
PATCH v9 1/5 Adding utility function net_checksum_add_cont() that allows checksum calculation of scattered data with odd chunk sizes
Adding utility function net_raw_checksum() that calculates checksum of buffer given
--- include/net/checksum.h | 14 +++++++++++++- net/checksum.c | 13 +++++++------ 2 files changed, 20 insertions(+), 7 deletions(-)
include/net/checksum.h +13 -1
@@ -20,10 +20,22 @@#include <stdint.h> -uint32_t net_checksum_add (int len,uint8_t *buf); +uint32_t net_checksum_add_cont (int len,uint8_t *buf,int seq);uint16_t net_checksum_finish (uint32_t sum);uint16_t net_checksum_tcpudp (uint16_t length,uint16_t proto,uint8_t *addrs,uint8_t *buf);void net_checksum_calculate (uint8_t *data,int length); +static inline uint32_t +net_checksum_add (int len,uint8_t *buf) +{ +return net_checksum_add_cont (len, buf,0 ); +} + +static inline uint16_t +net_raw_checksum (uint8_t *data,int length) +{ +return net_checksum_finish (net_checksum_add (length, data)); +} +#endif /* QEMU_NET_CHECKSUM_H */
net/checksum.c +7 -6
@@ -20,16 +20,17 @@#define PROTO_TCP 6#define PROTO_UDP 17 -uint32_t net_checksum_add (int len,uint8_t *buf) +uint32_t net_checksum_add_cont (int len,uint8_t *buf,int seq) {uint32_t sum =0 ;int i; -for (i =0 ; i < len; i++) { -if (i &1 ) - sum += (uint32_t )buf[i]; -else - sum += (uint32_t )buf[i] <<8 ; +for (i = seq; i < seq + len; i++) { +if (i &1 ) { + sum += (uint32_t )buf[i - seq]; + }else { + sum += (uint32_t )buf[i - seq] <<8 ; + } }return sum; }
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH v9 1/5] Adding utility function net_checksum_add_cont() that allows checksum calculation of scattered data with odd chunk sizes
include/net/checksum.h line 39
Quoted 11 lines · Dmitry Fleytman
include/net/checksum.h +11
-0+static inline uint32_t +net_checksum_add (int len,uint8_t *buf) +{ +return net_checksum_add_cont (len, buf,0 ); +} + +static inline uint16_t +net_raw_checksum (uint8_t *data,int length) +{ +return net_checksum_finish (net_checksum_add (length, data)); +}
4-space indentation. Don't bother resending because of this, it can be fixed when merging the patch.
Stefan
Re: [Qemu-devel] [PATCH v9 1/5] Adding utility function net_checksum_add_cont() that allows checksum calculation of scattered data with odd chunk sizes
Fixed. Thanks.
Quoted 18 lines · Stefan Hajnoczi
include/net/checksum.h line 39
Quoted 11 lines · Dmitry Fleytman
include/net/checksum.h +11
-0+static inline uint32_t +net_checksum_add (int len,uint8_t *buf) +{ +return net_checksum_add_cont (len, buf,0 ); +} + +static inline uint16_t +net_raw_checksum (uint8_t *data,int length) +{ +return net_checksum_finish (net_checksum_add (length, data)); +}4-space indentation. Don't bother resending because of this, it can be fixed when merging the patch.
Stefan
Signature · 7 lines
Dmitry Fleytman Technology Expert and Consultant, Daynix Computing Ltd. Cell: +972-54-2819481 Skype: dmitry.fleytman
Re: [Qemu-devel] [PATCH v9 1/5] Adding utility function net_checksum_add_cont() that allows checksum calculation of scattered data with odd chunk sizes
In reply to Dmitry FleytmanQuoted 2 lines · Dmitry Fleytman
Adding utility function
net_raw_checksum()that calculates checksum of buffer given
Your subject is excessively long. Please stick to the standard commit message format:
subsystem: summary phrase (no more than 75 chars, please)
Zero or more paragraphs of description. Wrap long lines, please (75 chars tops).
PATCH v9 2/5 Adding utility function net_checksum_add_iov() for iovec checksum calculation
In reply to Dmitry Fleytman--- include/net/checksum.h | 8 ++++++++ net/checksum.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/net/checksum.h +8 -0
@@ -19,6 +19,7 @@#define QEMU_NET_CHECKSUM_H #include <stdint.h> +#include "qemu-common.h" uint32_t net_checksum_add_cont (int len,uint8_t *buf,int seq);uint16_t net_checksum_finish (uint32_t sum);
@@ -38,4 +39,11 @@ net_raw_checksum(uint8_t *data, int length) return net_checksum_finish(net_checksum_add(length, data)); } +/** +* Checksum calculation for scatter-gather vector +*/ +uint32_t net_checksum_add_iov (const struct iovec *iov, +const unsigned int iov_cnt, +uint32_t iov_off,uint32_t size); +#endif /* QEMU_NET_CHECKSUM_H */
net/checksum.c +28 -0
@@ -84,3 +84,31 @@ void net_checksum_calculate(uint8_t *data, int length) data[14 +hlen+csum_offset] = csum >>8 ; data[14 +hlen+csum_offset+1 ] = csum &0xff ; } + +uint32_t +net_checksum_add_iov (const struct iovec *iov,const unsigned int iov_cnt, +uint32_t iov_off,uint32_t size) +{ +size_t iovec_off, buf_off; +unsigned int i; +uint32_t res =0 ; +uint32_t seq =0 ; + + iovec_off =0 ; + buf_off =0 ; +for (i =0 ; i < iov_cnt && size; i++) { +if (iov_off < (iovec_off + iov[i].iov_len)) { +size_t len =MIN ((iovec_off + iov[i].iov_len) - iov_off , size); +void *chunk_buf = iov[i].iov_base + (iov_off - iovec_off); + + res +=net_checksum_add_cont (len, chunk_buf, seq); + seq += len; + + buf_off += len; + iov_off += len; + size -= len; + } + iovec_off += iov[i].iov_len; + } +return res; +}
Signature · 1 line
1.7.11.7
PATCH v9 3/5 Adding common definitions for VMWARE devices
In reply to Dmitry Fleytman--- Makefile.objs | 1 + eth.c | 219 ++++++++++++++++++++++++++++++++++ hw/vmware_utils.h | 143 +++++++++++++++++++++++ hw/vmxnet_debug.h | 115 ++++++++++++++++++ include/qemu/eth.h | 338 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 816 insertions(+) create mode 100644 eth.c create mode 100644 hw/vmware_utils.h create mode 100644 hw/vmxnet_debug.h create mode 100644 include/qemu/eth.h
Makefile.objs +1 -0
@@ -92,6 +92,7 @@ common-obj-y += qemu-char.o #aio.o common-obj-y += block-migration.o iohandler.o common-obj-y += bitmap.o bitops.o common-obj-y += page_cache.o +common-obj-y += eth.o common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o common-obj-$(CONFIG_WIN32) += version.o
eth.c new file +219 -0
219 lines not on this page · raw message
hw/vmware_utils.h new file +143 -0
143 lines not on this page · raw message
hw/vmxnet_debug.h new file +115 -0
115 lines not on this page · raw message
include/qemu/eth.h new file +338 -0
338 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH v9 3/5] Adding common definitions for VMWARE devices
Quoted 14 lines · Dmitry Fleytman
eth.c new file +8
-0@@ -0,0 +1,219 @@ +/* +* QEMU network structures definitions and helper functions +* +* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com) +* +* Authors:
eth.c line 18
Quoted 10 lines
eth.c new file +10
-0+* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +//#include "hw.h"
Please remove this commented-out line.
Quoted 12 lines
include/qemu/eth.h new file +6
-0@@ -0,0 +1,338 @@ +/* +* QEMU network structures definitions and helper functions +* +* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com)
include/qemu/eth.h line 16
Quoted 10 lines
include/qemu/eth.h new file +10
-0+* +* Authors: +* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/
Please indicate where these header definitions come from and how they are licensed.
Re: [Qemu-devel] [PATCH v9 3/5] Adding common definitions for VMWARE devices
Hello Stefan
I've checked origin of headers, some of them are self-made, other came from following places:
1. file rtl8139.c from QEMU codebase
2. /usr/include/netinet/ip6.h from glibc
3. /usr/include/netinet/in.h from glibc
How should we indicate this? Should we add something like:
Portions developed by Free Software Foundation, Inc Copyright (C) 1991-1997, 2001, 2003, 2006 Free Software Foundation, Inc.
Portions developed by Igor Kovalenko
Copyright (c) 2006 Igor Kovalenko
Is it enough?
Thanks for advice,
Dmitry.
Quoted 56 lines · Stefan Hajnoczi
Quoted 9 lines · Dmitry Fleytman
eth.c new file +3
-0@@ -0,0 +1,219 @@ +/* +* QEMU network structures definitions and helper functions +* eth.c line 13
Quoted 10 lines
eth.c new file +10
-0+* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com) +* +* Authors: +* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
eth.c line 18
Quoted 5 lines
eth.c new file +5
-0+* See the COPYING file in the top-level directory. +* +*/ + +//#include "hw.h" Please remove this commented-out line.
Quoted 9 lines
include/qemu/eth.h new file +3
-0@@ -0,0 +1,338 @@ +/* +* QEMU network structures definitions and helper functions +* include/qemu/eth.h line 13
Quoted 10 lines
include/qemu/eth.h new file +10
-0+* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com) +* +* Authors: +* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later.
include/qemu/eth.h line 16
Quoted 3 lines
include/qemu/eth.h new file +3
-0+* See the COPYING file in the top-level directory. +* +*/ Please indicate where these header definitions come from and how they are licensed.
Signature · 7 lines
Dmitry Fleytman Technology Expert and Consultant, Daynix Computing Ltd. Cell: +972-54-2819481 Skype: dmitry.fleytman
PATCH v9 4/5 Adding packet abstraction for VMWARE network devices
In reply to Dmitry Fleytman--- hw/vmxnet_rx_pkt.c | 187 ++++++++++++++++++ hw/vmxnet_rx_pkt.h | 173 ++++++++++++++++ hw/vmxnet_tx_pkt.c | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet_tx_pkt.h | 148 ++++++++++++++ 4 files changed, 1075 insertions(+) create mode 100644 hw/vmxnet_rx_pkt.c create mode 100644 hw/vmxnet_rx_pkt.h create mode 100644 hw/vmxnet_tx_pkt.c create mode 100644 hw/vmxnet_tx_pkt.h
hw/vmxnet_rx_pkt.c new file +187 -0
@@ -0,0 +1,187 @@ +/* +* QEMU VMWARE VMXNET* paravirtual NICs - RX packets abstractions +* +* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com) +* +* Authors: +* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "vmxnet_rx_pkt.h" +#include "qemu/eth.h" +#include "qemu-common.h" +#include "qemu/iov.h" +#include "net/checksum.h" +#include "net/tap.h" + +/* +* RX packet may contain up to 2 fragments - rebuilt eth header +* in case of VLAN tag stripping +* and payload received from QEMU - in any case +*/ +#define VMXNET_MAX_RX_PACKET_FRAGMENTS (2) + +struct VmxnetRxPkt { +struct virtio_net_hdr virt_hdr; +uint8_t ehdr_buf[ETH_MAX_L2_HDR_LEN ]; +struct iovec vec[VMXNET_MAX_RX_PACKET_FRAGMENTS ]; +uint16_t vec_len; +uint32_t tot_len; +uint16_t tci; +bool vlan_stripped; +bool has_virt_hdr; +eth_pkt_types_e packet_type; + +/* Analysis results */ +bool isip4; +bool isip6; +bool isudp; +bool istcp; +}; + +void vmxnet_rx_pkt_init (struct VmxnetRxPkt **pkt,bool has_virt_hdr) +{ +struct VmxnetRxPkt *p =g_malloc0 (sizeof *p); + p->has_virt_hdr = has_virt_hdr; + *pkt = p; +} + +void vmxnet_rx_pkt_uninit (struct VmxnetRxPkt *pkt) +{ +g_free (pkt); +} + +struct virtio_net_hdr *vmxnet_rx_pkt_get_vhdr (struct VmxnetRxPkt *pkt) +{ +assert (pkt); +return &pkt->virt_hdr; +} + +void vmxnet_rx_pkt_attach_data (struct VmxnetRxPkt *pkt,const void *data, +size_t len,bool strip_vlan) +{ +uint16_t tci =0 ; +uint16_t ploff; +assert (pkt); + pkt->vlan_stripped = false; + +if (strip_vlan) { + pkt->vlan_stripped =eth_strip_vlan (data, pkt->ehdr_buf, &ploff, &tci); + } + +if (pkt->vlan_stripped) { + pkt->vec[0 ].iov_base = pkt->ehdr_buf; + pkt->vec[0 ].iov_len = ploff -sizeof (struct vlan_header ); + pkt->vec[1 ].iov_base = (uint8_t *) data + ploff; + pkt->vec[1 ].iov_len = len - ploff; + pkt->vec_len =2 ; + pkt->tot_len = len - ploff +sizeof (struct eth_header ); + }else { + pkt->vec[0 ].iov_base = (void *)data; + pkt->vec[0 ].iov_len = len; + pkt->vec_len =1 ; + pkt->tot_len = len; + } + + pkt->tci = tci; + +eth_get_protocols (data, len, &pkt->isip4, &pkt->isip6, + &pkt->isudp, &pkt->istcp); +} + +void vmxnet_rx_pkt_dump (struct VmxnetRxPkt *pkt) +{ +#ifdef VMXNET_RX_PKT_DEBUG +VmxnetRxPkt *pkt = (VmxnetRxPkt *)pkt; +assert (pkt); + +printf ("RX PKT: tot_len: %d, vlan_stripped: %d, vlan_tag: %d\n" , + pkt->tot_len, pkt->vlan_stripped, pkt->tci); +#endif +} + +void vmxnet_rx_pkt_set_packet_type (struct VmxnetRxPkt *pkt, +eth_pkt_types_e packet_type) +{ +assert (pkt); + + pkt->packet_type = packet_type; + +} + +eth_pkt_types_e vmxnet_rx_pkt_get_packet_type (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->packet_type; +} + +size_t vmxnet_rx_pkt_get_total_len (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->tot_len; +} + +void vmxnet_rx_pkt_get_protocols (struct VmxnetRxPkt *pkt, +bool *isip4,bool *isip6, +bool *isudp,bool *istcp) +{ +assert (pkt); + + *isip4 = pkt->isip4; + *isip6 = pkt->isip6; + *isudp = pkt->isudp; + *istcp = pkt->istcp; +} + +struct iovec *vmxnet_rx_pkt_get_iovec (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->vec; +} + +void vmxnet_rx_pkt_set_vhdr (struct VmxnetRxPkt *pkt, +struct virtio_net_hdr *vhdr) +{ +assert (pkt); + +memcpy (&pkt->virt_hdr, vhdr,sizeof pkt->virt_hdr); +} + +bool vmxnet_rx_pkt_is_vlan_stripped (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->vlan_stripped; +} + +bool vmxnet_rx_pkt_has_virt_hdr (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->has_virt_hdr; +} + +uint16_t vmxnet_rx_pkt_get_num_frags (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->vec_len; +} + +uint16_t vmxnet_rx_pkt_get_vlan_tag (struct VmxnetRxPkt *pkt) +{ +assert (pkt); + +return pkt->tci; +}
hw/vmxnet_rx_pkt.h new file +173 -0
173 lines not on this page · raw message
hw/vmxnet_tx_pkt.c new file +567 -0
567 lines not on this page · raw message
hw/vmxnet_tx_pkt.h new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH v9 4/5] Adding packet abstraction for VMWARE network devices
Quoted 10 lines · Dmitry Fleytman
--- hw/vmxnet_rx_pkt.c | 187 ++++++++++++++++++ hw/vmxnet_rx_pkt.h | 173 ++++++++++++++++ hw/vmxnet_tx_pkt.c | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet_tx_pkt.h | 148 ++++++++++++++ 4 files changed, 1075 insertions(+) create mode 100644 hw/vmxnet_rx_pkt.c create mode 100644 hw/vmxnet_rx_pkt.h create mode 100644 hw/vmxnet_tx_pkt.c create mode 100644 hw/vmxnet_tx_pkt.h
There are other VMware-specific hw/ files. Please create hw/vmware/ and put source files in there without the prefix. Check hw/pci/ or other subdirectories for how to setup Makefile.objs, it's pretty simple.
Quoted 55 lines
hw/vmxnet_rx_pkt.c new file +49
-0@@ -0,0 +1,187 @@ +/* +* QEMU VMWARE VMXNET* paravirtual NICs - RX packets abstractions +* +* Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com) +* +* Developed by Daynix Computing LTD (http://www.daynix.com) +* +* Authors: +* Dmitry Fleytman <[email protected]> +* Tamir Shomer <[email protected]> +* Yan Vugenfirer <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "vmxnet_rx_pkt.h" +#include "qemu/eth.h" +#include "qemu-common.h" +#include "qemu/iov.h" +#include "net/checksum.h" +#include "net/tap.h" + +/* +* RX packet may contain up to 2 fragments - rebuilt eth header +* in case of VLAN tag stripping +* and payload received from QEMU - in any case +*/ +#define VMXNET_MAX_RX_PACKET_FRAGMENTS (2) + +struct VmxnetRxPkt { +struct virtio_net_hdr virt_hdr; +uint8_t ehdr_buf[ETH_MAX_L2_HDR_LEN ]; +struct iovec vec[VMXNET_MAX_RX_PACKET_FRAGMENTS ]; +uint16_t vec_len; +uint32_t tot_len; +uint16_t tci; +bool vlan_stripped; +bool has_virt_hdr; +eth_pkt_types_e packet_type; + +/* Analysis results */ +bool isip4; +bool isip6; +bool isudp; +bool istcp; +}; +
hw/vmxnet_rx_pkt.c line 59
Quoted 10 lines
hw/vmxnet_rx_pkt.c new file +10
-0+void vmxnet_rx_pkt_init (struct VmxnetRxPkt **pkt,bool has_virt_hdr) +{ +struct VmxnetRxPkt *p =g_malloc0 (sizeof *p); + p->has_virt_hdr = has_virt_hdr; + *pkt = p; +} + +void vmxnet_rx_pkt_uninit (struct VmxnetRxPkt *pkt) +{ +g_free (pkt);
4-space indentation please.
Re: [Qemu-devel] [PATCH v9 4/5] Adding packet abstraction for VMWARE network devices
Il 16/01/2013 15:48, Stefan Hajnoczi ha scritto:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
hw/vmxnet_rx_pkt.c | 187 ++++++++++++++++++ hw/vmxnet_rx_pkt.h | 173 ++++++++++++++++ hw/vmxnet_tx_pkt.c | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet_tx_pkt.h | 148 ++++++++++++++ 4 files changed, 1075 insertions(+) create mode 100644 hw/vmxnet_rx_pkt.c create mode 100644 hw/vmxnet_rx_pkt.h create mode 100644 hw/vmxnet_tx_pkt.c create mode 100644 hw/vmxnet_tx_pkt.h
Quoted 3 lines
There are other VMware-specific hw/ files. Please create hw/vmware/ and put source files in there without the prefix. Check hw/pci/ or other subdirectories for how to setup Makefile.objs, it's pretty simple.
I don't think we have enough plans for hw/ structure to create directories yet. What we have so far is basically hw/<arch> and hw/<bus>, so the logic would be to have hw/net (also mimicking Linux's drivers/net directory). It's premature to create hw/vmware, we risk getting a spaghetti directory structure.
eth.c/eth.h sound more interesting. Could they be used by host-side code (e.g. SLIRP or a TAP backend)? If so, they belong in net/ and include/net. If not, they belong in hw/ (waiting for hw/net to be created).
Paolo
Re: [Qemu-devel] [PATCH v9 4/5] Adding packet abstraction for VMWARE network devices
Quoted 14 lines · Paolo Bonzini
Il 16/01/2013 15:48, Stefan Hajnoczi ha scritto:
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
hw/vmxnet_rx_pkt.c | 187 ++++++++++++++++++ hw/vmxnet_rx_pkt.h | 173 ++++++++++++++++ hw/vmxnet_tx_pkt.c | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet_tx_pkt.h | 148 ++++++++++++++ 4 files changed, 1075 insertions(+) create mode 100644 hw/vmxnet_rx_pkt.c create mode 100644 hw/vmxnet_rx_pkt.h create mode 100644 hw/vmxnet_tx_pkt.c create mode 100644 hw/vmxnet_tx_pkt.hQuoted 3 lines
There are other VMware-specific hw/ files. Please create hw/vmware/ and put source files in there without the prefix. Check hw/pci/ or other subdirectories for how to setup Makefile.objs, it's pretty simple.
Quoted 5 lines
I don't think we have enough plans for hw/ structure to create directories yet. What we have so far is basically hw/<arch> and hw/<bus>, so the logic would be to have hw/net (also mimicking Linux's
drivers/netdirectory). It's premature to create hw/vmware, we risk getting a spaghetti directory structure.
Okay, let's leave the hw/ sub-directory for a future hw/-wide cleanup series that moves all device emulation code.
Quoted 3 lines
eth.c/eth.hsound more interesting. Could they be used by host-side code (e.g. SLIRP or a TAP backend)? If so, they belong innet/andinclude/net. If not, they belong in hw/ (waiting for hw/net to be created).
Yes, they can be used by host (backend) code.
Stefan
Re: [Qemu-devel] [PATCH v9 4/5] Adding packet abstraction for VMWARE network devices
Quoted 26 lines · Stefan Hajnoczi
Quoted 4 lines · Paolo Bonzini
Il 16/01/2013 15:48, Stefan Hajnoczi ha scritto:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
hw/vmxnet_rx_pkt.c | 187 ++++++++++++++++++ hw/vmxnet_rx_pkt.h | 173 ++++++++++++++++ hw/vmxnet_tx_pkt.c | 567+++++++++++++++++++++++++++++++++++++++++++++++++++++
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
hw/vmxnet_tx_pkt.h | 148 ++++++++++++++ 4 files changed, 1075 insertions(+) create mode 100644 hw/vmxnet_rx_pkt.c create mode 100644 hw/vmxnet_rx_pkt.h create mode 100644 hw/vmxnet_tx_pkt.c create mode 100644 hw/vmxnet_tx_pkt.hThere are other VMware-specific hw/ files. Please create hw/vmware/
and
Quoted 8 lines
Quoted 2 lines
put source files in there without the prefix. Check hw/pci/ or other subdirectories for how to setup Makefile.objs, it's pretty simple.
I don't think we have enough plans for hw/ structure to create directories yet. What we have so far is basically hw/<arch> and hw/<bus>, so the logic would be to have hw/net (also mimicking Linux's
drivers/netdirectory). It's premature to create hw/vmware, we risk getting a spaghetti directory structure.Okay, let's leave the hw/ sub-directory for a future hw/-wide cleanup series that moves all device emulation code.
Quoted 9 lines
Quoted 3 lines
eth.c/eth.hsound more interesting. Could they be used by host-side code (e.g. SLIRP or a TAP backend)? If so, they belong innet/andinclude/net. If not, they belong in hw/ (waiting for hw/net to becreated).
Yes, they can be used by host (backend) code.
Stefan
eth.* moved to "include/net" and "net"
Signature · 7 lines
Dmitry Fleytman Technology Expert and Consultant, Daynix Computing Ltd. Cell: +972-54-2819481 Skype: dmitry.fleytman
PATCH v9 5/5 Adding VMXNET3 device implementation
In reply to Dmitry Fleytman--- default-configs/pci.mak | 1 + hw/Makefile.objs | 2 + hw/pci/pci.h | 1 + hw/vmxnet3.c | 2420 +++++++++++++++++++++++++++++++++++++++++++++++ hw/vmxnet3.h | 760 +++++++++++++++ 5 files changed, 3184 insertions(+) create mode 100644 hw/vmxnet3.c create mode 100644 hw/vmxnet3.h
default-configs/pci.mak +1 -0
@@ -13,6 +13,7 @@ CONFIG_LSI_SCSI_PCI=y CONFIG_MEGASAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y +CONFIG_VMXNET3_PCI=y CONFIG_IDE_CORE=y CONFIG_IDE_QDEV=y CONFIG_IDE_PCI=y
hw/Makefile.objs +2 -0
@@ -113,6 +113,8 @@ common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o common-obj-$(CONFIG_E1000_PCI) += e1000.o common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet_tx_pkt.o vmxnet_rx_pkt.o common-obj-$(CONFIG_SMC91C111) += smc91c111.o common-obj-$(CONFIG_LAN9118) += lan9118.o
hw/pci/pci.h +1 -0
@@ -60,6 +60,7 @@#define PCI_DEVICE_ID_VMWARE_NET 0x0720#define PCI_DEVICE_ID_VMWARE_SCSI 0x0730#define PCI_DEVICE_ID_VMWARE_IDE 0x1729 +#define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07B0/* Intel (0x8086) */ #define PCI_DEVICE_ID_INTEL_82551IT 0x1209
hw/vmxnet3.c new file +2420 -0
2,420 lines not on this page · raw message
hw/vmxnet3.h new file +760 -0
558 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.11.7
Part of the diff is not shown here. View the raw message.
Re: [Qemu-devel] [PATCH v9 5/5] Adding VMXNET3 device implementation
hw/Makefile.objs common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o · line 117
Quoted 6 lines · Dmitry Fleytman
hw/Makefile.objs +2
-0@@ -113,6 +113,8 @@ common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o common-obj-$(CONFIG_E1000_PCI) += e1000.o common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet_tx_pkt.o vmxnet_rx_pkt.o
The objects can already be built in the earlier patch so clean compilation can be tested. Please move this to the patch that introduces these .c files.
hw/vmxnet3.c line 1114
Quoted 7 lines
hw/vmxnet3.c new file +7
-0+static void vmxnet3_reset (VMXNET3State *s) +{ +VMW_CBPRN ("Resetting vmxnet3..." ); + +vmxnet_tx_pkt_reset (s->tx_pkt); + s->tx_sop = true; + s->skip_current_tx_pkt = false;
Not much is reset here?
Clear rx mac filtering and reset MAC address?
Reset drv_shmem?
Quoted 9 lines
hw/vmxnet3.c new file +9
-0+static void vmxnet3_net_init (VMXNET3State *s) +{ +VMW_CBPRN ("vmxnet3_net_init called..." ); + +qemu_macaddr_default_if_unset (&s->conf.macaddr); + +/* Windows guest will query the address that was set on init */ +memcpy (&s->perm_mac.a, &s->conf.macaddr.a,sizeof (s->perm_mac.a)); +
hw/vmxnet3.c line 1880
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+ s->mcast_list =NULL ; + s->mcast_list_len =0 ; + + s->link_status_and_speed =VMXNET3_LINK_SPEED |VMXNET3_LINK_STATUS_UP ; + +VMW_CFPRN ("Permanent MAC: " MAC_FMT ,MAC_ARG (s->perm_mac.a)); + + s->nic =qemu_new_nic (&net_vmxnet3_info, &s->conf, +object_get_typename (OBJECT (s)), + s->dev.qdev.id, s);
Missing qemu_del_net_client() to free s->nic in this file.
Quoted 4 lines
hw/vmxnet3.c new file +4
-0+static void vmxnet3_get_tx_stats_from_file (QEMUFile *f, +struct UPT1_TxStats *tx_stat) +{ + tx_stat->TSOPktsTxOK =qemu_get_be64 (f);
hw/vmxnet3.c line 2160
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+ tx_stat->TSOBytesTxOK =qemu_get_be64 (f); + tx_stat->ucastPktsTxOK =qemu_get_be64 (f); + tx_stat->ucastBytesTxOK =qemu_get_be64 (f); + tx_stat->mcastPktsTxOK =qemu_get_be64 (f); + tx_stat->mcastBytesTxOK =qemu_get_be64 (f); + tx_stat->bcastPktsTxOK =qemu_get_be64 (f); + tx_stat->bcastBytesTxOK =qemu_get_be64 (f); + tx_stat->pktsTxError =qemu_get_be64 (f); + tx_stat->pktsTxDiscard =qemu_get_be64 (f); +}
4-space indentation.
Quoted 5 lines
hw/vmxnet3.c new file +5
-0+ +static void vmxnet3_put_tx_stats_to_file (QEMUFile *f, +struct UPT1_TxStats *tx_stat) +{ +qemu_put_be64 (f, tx_stat->TSOPktsTxOK);
hw/vmxnet3.c line 2175
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+qemu_put_be64 (f, tx_stat->TSOBytesTxOK); +qemu_put_be64 (f, tx_stat->ucastPktsTxOK); +qemu_put_be64 (f, tx_stat->ucastBytesTxOK); +qemu_put_be64 (f, tx_stat->mcastPktsTxOK); +qemu_put_be64 (f, tx_stat->mcastBytesTxOK); +qemu_put_be64 (f, tx_stat->bcastPktsTxOK); +qemu_put_be64 (f, tx_stat->bcastBytesTxOK); +qemu_put_be64 (f, tx_stat->pktsTxError); +qemu_put_be64 (f, tx_stat->pktsTxDiscard); +}
4-space indentation.
hw/vmxnet3.c line 2220
Quoted 13 lines
hw/vmxnet3.c new file +13
-0+static void vmxnet3_get_rx_stats_from_file (QEMUFile *f, +struct UPT1_RxStats *rx_stat) +{ + rx_stat->LROPktsRxOK =qemu_get_be64 (f); + rx_stat->LROBytesRxOK =qemu_get_be64 (f); + rx_stat->ucastPktsRxOK =qemu_get_be64 (f); + rx_stat->ucastBytesRxOK =qemu_get_be64 (f); + rx_stat->mcastPktsRxOK =qemu_get_be64 (f); + rx_stat->mcastBytesRxOK =qemu_get_be64 (f); + rx_stat->bcastPktsRxOK =qemu_get_be64 (f); + rx_stat->bcastBytesRxOK =qemu_get_be64 (f); + rx_stat->pktsRxOutOfBuf =qemu_get_be64 (f); + rx_stat->pktsRxError =qemu_get_be64 (f);
4-space indentation.
Quoted 5 lines
hw/vmxnet3.c new file +5
-0+} + +static void vmxnet3_put_rx_stats_to_file (QEMUFile *f, +struct UPT1_RxStats *rx_stat) +{
hw/vmxnet3.c line 2235
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+qemu_put_be64 (f, rx_stat->LROPktsRxOK); +qemu_put_be64 (f, rx_stat->LROBytesRxOK); +qemu_put_be64 (f, rx_stat->ucastPktsRxOK); +qemu_put_be64 (f, rx_stat->ucastBytesRxOK); +qemu_put_be64 (f, rx_stat->mcastPktsRxOK); +qemu_put_be64 (f, rx_stat->mcastBytesRxOK); +qemu_put_be64 (f, rx_stat->bcastPktsRxOK); +qemu_put_be64 (f, rx_stat->bcastBytesRxOK); +qemu_put_be64 (f, rx_stat->pktsRxOutOfBuf); +qemu_put_be64 (f, rx_stat->pktsRxError);
4-space indentation.
Re: [Qemu-devel] [PATCH v9 5/5] Adding VMXNET3 device implementation
Quoted 12 lines · Stefan Hajnoczi
hw/Makefile.objs common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o · line 117
Quoted 6 lines · Dmitry Fleytman
hw/Makefile.objs +2
-0@@ -113,6 +113,8 @@ common-obj-$(CONFIG_PCNET_PCI) += pcnet-pci.o common-obj-$(CONFIG_PCNET_COMMON) += pcnet.o common-obj-$(CONFIG_E1000_PCI) += e1000.o common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o +common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet_tx_pkt.o vmxnet_rx_pkt.oThe objects can already be built in the earlier patch so clean compilation can be tested. Please move this to the patch that introduces these .c files.
Done.
Quoted 11 lines
hw/vmxnet3.c line 1114
Quoted 8 lines
hw/vmxnet3.c new file +7
-0+static void vmxnet3_reset (VMXNET3State *s) +{ +VMW_CBPRN ("Resetting vmxnet3..." ); + +vmxnet_tx_pkt_reset (s->tx_pkt); + s->tx_sop = true; + s->skip_current_tx_pkt = false;Not much is reset here?
Quoted 5 lines
Clear rx mac filtering and reset MAC address?
Reset
drv_shmem?
Reset drv_shmem, MAC address and a number of other fields added. Also state machine switched to "inactive" state on reset.
All context fields that being filled "atomically" with device activation left as-is to avoid code/logic duplication.
Quoted 14 lines
+static void
vmxnet3_net_init(VMXNET3State *s)hw/vmxnet3.c
Quoted 12 lines
hw/vmxnet3.c new file +12
-0+{ +VMW_CBPRN ("vmxnet3_net_init called..." ); + +qemu_macaddr_default_if_unset (&s->conf.macaddr); + +/* Windows guest will query the address that was set on init */ +memcpy (&s->perm_mac.a, &s->conf.macaddr.a,sizeof (s->perm_mac.a)); + + s->mcast_list =NULL ; + s->mcast_list_len =0 ; + + s->link_status_and_speed = VMXNET3_LINK_SPEED |
VMXNET3_LINK_STATUS_UP;
Quoted 10 lines
hw/vmxnet3.c line 1880
Quoted 6 lines
hw/vmxnet3.c new file +6
-0+ +VMW_CFPRN ("Permanent MAC: " MAC_FMT ,MAC_ARG (s->perm_mac.a)); + + s->nic =qemu_new_nic (&net_vmxnet3_info, &s->conf, +object_get_typename (OBJECT (s)), + s->dev.qdev.id, s);Missing
qemu_del_net_client()to frees->nicin this file.
Un-init sequence amended. Thanks for pointing out.
Quoted 60 lines
Quoted 4 lines
hw/vmxnet3.c new file +4
-0+static void vmxnet3_get_tx_stats_from_file (QEMUFile *f, +struct UPT1_TxStats *tx_stat) +{ + tx_stat->TSOPktsTxOK =qemu_get_be64 (f);hw/vmxnet3.c line 2160
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+ tx_stat->TSOBytesTxOK =qemu_get_be64 (f); + tx_stat->ucastPktsTxOK =qemu_get_be64 (f); + tx_stat->ucastBytesTxOK =qemu_get_be64 (f); + tx_stat->mcastPktsTxOK =qemu_get_be64 (f); + tx_stat->mcastBytesTxOK =qemu_get_be64 (f); + tx_stat->bcastPktsTxOK =qemu_get_be64 (f); + tx_stat->bcastBytesTxOK =qemu_get_be64 (f); + tx_stat->pktsTxError =qemu_get_be64 (f); + tx_stat->pktsTxDiscard =qemu_get_be64 (f); +}4-space indentation.
Quoted 5 lines
hw/vmxnet3.c new file +5
-0+ +static void vmxnet3_put_tx_stats_to_file (QEMUFile *f, +struct UPT1_TxStats *tx_stat) +{ +qemu_put_be64 (f, tx_stat->TSOPktsTxOK);hw/vmxnet3.c line 2175
Quoted 10 lines
hw/vmxnet3.c new file +10
-0+qemu_put_be64 (f, tx_stat->TSOBytesTxOK); +qemu_put_be64 (f, tx_stat->ucastPktsTxOK); +qemu_put_be64 (f, tx_stat->ucastBytesTxOK); +qemu_put_be64 (f, tx_stat->mcastPktsTxOK); +qemu_put_be64 (f, tx_stat->mcastBytesTxOK); +qemu_put_be64 (f, tx_stat->bcastPktsTxOK); +qemu_put_be64 (f, tx_stat->bcastBytesTxOK); +qemu_put_be64 (f, tx_stat->pktsTxError); +qemu_put_be64 (f, tx_stat->pktsTxDiscard); +}4-space indentation.
hw/vmxnet3.c line 2220
Quoted 13 lines
hw/vmxnet3.c new file +13
-0+static void vmxnet3_get_rx_stats_from_file (QEMUFile *f, +struct UPT1_RxStats *rx_stat) +{ + rx_stat->LROPktsRxOK =qemu_get_be64 (f); + rx_stat->LROBytesRxOK =qemu_get_be64 (f); + rx_stat->ucastPktsRxOK =qemu_get_be64 (f); + rx_stat->ucastBytesRxOK =qemu_get_be64 (f); + rx_stat->mcastPktsRxOK =qemu_get_be64 (f); + rx_stat->mcastBytesRxOK =qemu_get_be64 (f); + rx_stat->bcastPktsRxOK =qemu_get_be64 (f); + rx_stat->bcastBytesRxOK =qemu_get_be64 (f); + rx_stat->pktsRxOutOfBuf =qemu_get_be64 (f); + rx_stat->pktsRxError =qemu_get_be64 (f);4-space indentation.
Quoted 9 lines
hw/vmxnet3.c new file +9
-0+} + +static void vmxnet3_put_rx_stats_to_file (QEMUFile *f, +struct UPT1_RxStats *rx_stat) +{ +qemu_put_be64 (f, rx_stat->LROPktsRxOK); +qemu_put_be64 (f, rx_stat->LROBytesRxOK); +qemu_put_be64 (f, rx_stat->ucastPktsRxOK); +qemu_put_be64 (f, rx_stat->ucastBytesRxOK);
Quoted 9 lines
hw/vmxnet3.c line 2235
Quoted 6 lines
hw/vmxnet3.c new file +6
-0+qemu_put_be64 (f, rx_stat->mcastPktsRxOK); +qemu_put_be64 (f, rx_stat->mcastBytesRxOK); +qemu_put_be64 (f, rx_stat->bcastPktsRxOK); +qemu_put_be64 (f, rx_stat->bcastBytesRxOK); +qemu_put_be64 (f, rx_stat->pktsRxOutOfBuf); +qemu_put_be64 (f, rx_stat->pktsRxError);4-space indentation.
Indentation verified and fixed everywhere.
Signature · 7 lines
Dmitry Fleytman Technology Expert and Consultant, Daynix Computing Ltd. Cell: +972-54-2819481 Skype: dmitry.fleytman