summaryrefslogtreecommitdiff
path: root/hw/virtio-net.c
AgeCommit message (Collapse)AuthorFilesLines
2010-04-28iov: Introduce a new file for helpers around iovs, add iov_from_buf()Amit Shah1-17/+3
The virtio-net code uses iov_fill() which fills an iov from a linear buffer. The virtio-serial-bus code does something similar in an open-coded function. Create a new iov.c file that has iov_from_buf(). Convert virtio-net and virtio-serial-bus over to use this functionality. virtio-net used ints to hold sizes, the new function is going to use size_t types. Later commits will add the opposite functionality -- going from an iov to a linear buffer. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-13vhost: fix features ackDavid L Stevens1-0/+8
vhost driver in qemu didn't ack features, and this happens to work because we don't really require any features. However, it's better not to rely on this. This patch passes features to vhost as guest acks them. Signed-off-by: David L Stevens <dlstevens@us.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-01virtio-net: vhost net supportMichael S. Tsirkin1-2/+69
This connects virtio-net to vhost net backend. The code is structured in a way analogous to what we have with vnet header capability in tap. We start/stop backend on driver start/stop as well as on save and vm start (for migration). Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-16error: Replace qemu_error() by error_report()Markus Armbruster1-2/+2
error_report() terminates the message with a newline. Strip it it from its arguments. This fixes a few error messages lacking a newline: net_handle_fd_param()'s "No file descriptor named %s found", and tap_open()'s "vnet_hdr=1 requested, but no kernel support for IFF_VNET_HDR available" (all three versions). There's one place that passes arguments without newlines intentionally: load_vmstate(). Fix it up.
2010-03-16error: Move qemu_error & friends into their own headerMarkus Armbruster1-0/+1
2010-02-10virtio-net: fix network stall under loadTom Lendacky1-1/+9
Fix a race condition where qemu finds that there are not enough virtio ring buffers available and the guest make more buffers available before qemu can enable notifications. Signed-off-by: Tom Lendacky <toml@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-13virtio: net: remove dead assignmentAmit Shah1-1/+1
clang-analyzer points out value assigned to 'len' is not used. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-12virtio-net: mac property is mandatoryMichael S. Tsirkin1-0/+2
Mac feature bit isn't going to work as all network cards already have a 'mac' property to set the mac address. Remove it from mask and add in get_features. Reported-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-11virtio: add features as qdev propertiesMichael S. Tsirkin1-23/+16
Add feature bits as properties to virtio. This makes it possible to e.g. define machine without indirect buffer support, which is required for 0.10 compatibility, or without hardware checksum support, which is required for 0.11 compatibility. Since default values for optional features are now set by qdev, get_features callback has been modified: it sets non-optional bits, and clears bits not supported by host. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-11virtio: rename features -> guest_featuresMichael S. Tsirkin1-5/+5
Rename features->guest_features. This is what they are, avoid confusion with host features which we also need to keep around. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03net: remove VLANClientState members now in NetClientInfoMark McLoughlin1-1/+1
Add a NetClientInfo pointer to VLANClientState and use that for the typecode and function pointers. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03net: convert virtio to NICStateMark McLoughlin1-34/+39
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09whitelist host virtio networking featuresDustin Kirkland1-4/+4
This patch is a followup to 8eca6b1bc770982595db2f7207c65051572436cb, fixing crashes when guests with 2.6.25 virtio drivers have saturated virtio network connections. https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/458521 That patch should have been whitelisting *_HOST_* rather than the the *_GUEST_* features. I tested this by running an Ubuntu 8.04 Hardy guest (2.6.24 kernel + 2.6.25-virtio driver). I saturated both the incoming, and outgoing network connection with nc, seeing sustained 6MB/s up and 6MB/s down bitrates for ~20 minutes. Previously, this crashed immediately. Now, the guest does not crash and maintains network connectivity throughout the test. Signed-off-by: Dustin Kirkland <kirkland@canonical.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09virtio-net: split the has_buffers() logic from can_receive()Mark McLoughlin1-9/+12
We should only return zero from receive() for a condition which we'll get notification of when it changes. Currently, we're returning zero if the guest driver is not ready, but we won't ever flush our queue when that status changes. Also, don't check buffer space in can_receive(), but instead just allow receive() to return zero when this condition occurs and have the caller handle queueing the packet. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30virtio-net: fix macaddr config regressionMark McLoughlin1-0/+1
This commit: commit 97b15621 virtio: use qdev properties for configuration. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> makes a guest using virtio-net see an empty macaddr because we never copy the macaddr into the location that virtio_net_get_config() uses. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30net: move more stuff into net/tap-win32.c, add net/tap.hMark McLoughlin1-0/+1
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30net: move net-checksum.c under net/Mark McLoughlin1-0/+1
Also add a new net/checksum.h header Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27virtio-net: add tap_has_ufo flag to saved stateMark McLoughlin1-2/+21
If we tell the guest we support UFO and then migrate to host which doesn't support it, we will find ourselves in grave difficulties. Prevent this scenario by adding a flag to virtio-net's savevm format which indicates whether the device requires host UFO support. [v2: - add has_ufo uint8_t field for ease of vmstate conversion - use qemu_error() ] Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Enable UFO on virtio-net and tap devicesSridhar Samudrala1-2/+9
Enable UFO on the host tap device if supported and allow setting UFO on virtio-net in the guest. Signed-off-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Work around dhclient brokennessAnthony Liguori1-0/+29
With the latest GSO/csum offload patches, any guest using an unpatched version of dhclient (any Ubuntu guest, for instance), will no longer be able to get a DHCP address. dhclient is actually at fault here. It uses AF_PACKET to receive DHCP responses but does not check auxdata to see if the packet has a valid csum. This causes it to throw out the DHCP responses it gets from the virtio interface as there is not a valid checksum. Fedora has carried a patch to fix their dhclient (it's needed for Xen too) but this patch has not made it into a release of dhclient. AFAIK, the patch is in the dhclient CVS but I cannot confirm since their CVS is not public. This patch, suggested by Rusty, looks for UDP packets (of a normal MTU) and explicitly adds a checksum to them if they are missing one. This allows unpatched dhclients to continue to work without needing to update the guest kernels. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27virtio-net: enable tap offload if guest supports itMark McLoughlin1-0/+18
We query the guest's feature set to see if it supports offload and, if so, we enable those features on the tap interface. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27virtio-net: add vnet_hdr supportMark McLoughlin1-7/+44
With '-netdev tap,id=foo -nic model=virtio,netdev=foo' virtio-net can detect that its peer (i.e. the tap backend) supports vnet headers and advertise to the guest that it can send packets with partial checksums and/or TSO packets. One complication is that if we're migrating and the source host supports IFF_VNET_HDR but the destination host doesn't, we can't then stop the guest from using those features. In this scenario, we just fail the migration. [v2: - add has_vnet_hdr uint32_t field for ease of vmstate conversion - use qemu_error() ] Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27virtio: use qdev properties for configuration.Gerd Hoffmann1-20/+25
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-22notify io_thread at the end of rx handlingGlauber Costa1-0/+4
This is a backport from qemu-kvm. Just instead of using kvm's specific notification mechanism, we use qemu_notify_event() Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-24qemu/net: flag to control the number of vectors a nic hasMichael S. Tsirkin1-1/+4
Add an option to specify the number of MSI-X vectors for PCI NIC cards. This can also be used to disable MSI-X, for compatibility with old qemu. This option currently only affects virtio cards. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-24qemu/net: request 3 vectors in virtio-netMichael S. Tsirkin1-0/+1
Request up to 3 vectors in virtio-net. Actual bindings might supply less. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22virtio-net: implement async packet sendingMark McLoughlin1-2/+37
Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22virtio-net: enable mergeable receive buffersMark McLoughlin1-0/+1
When virtio-net was merged in from qemu-kvm.git, the VNET_HDR related features were dropped from the code. However, VIRTIO_NET_F_MRG_RXBUF appears to have accidentally been dropped too. Re-instate that now. Reported-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-09virtio-net: Increase filter and control limitsAlex Williamson1-2/+2
Increase the size of the perfect filter table and control queue depth. This should give us more headroom in the MAC filter and is known to be needed by at least one guest user. Increasing the control queue depth allows a guest to feed several commands back to back if they so desire rather than using the send and wait approach Linux uses. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: Add new RX filter controlsAlex Williamson1-4/+36
Add a few new RX modes to better control the receive_filter. These are all fairly obvious features that hardware could provide. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: MAC filter optimizationAlex Williamson1-4/+25
The MAC filter table is received from the guest as two separate buffers, one with unicast entries, the other with multicast entries. If we track the index dividing the two sets, we can avoid searching the part of the table with the wrong type of entries. We could store this index as part of the save image, but its trivially easy to discover it on load. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: Fix MAC filter overflow handlingAlex Williamson1-8/+23
Overloading the promisc and allmulti flags for indicating filter table overflow makes it difficult to track the actual requested operating mode. Split these out into separate flags. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: reorganize receive_filter()Alex Williamson1-8/+11
Reorganize receive_filter to better handle the split between unicast and multicast filtering. This allows us to skip the broadcast check on unicast packets and leads to more opportunities for optimization. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: Use a byte to store RX mode flagsAlex Williamson1-7/+12
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>
2009-06-09virtio-net: Add version_id 7 placeholder for vnet header supportAlex Williamson1-1/+8
Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09virtio-net: implement rx packet queueingMark McLoughlin1-1/+4
If we don't have room to receive a packet, we return zero from virtio_net_receive() and call qemu_flush_queued_packets() as soon as space becomes available. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add return value to packet receive handlerMark McLoughlin1-4/+6
This allows us to handle queue full conditions rather than dropping the packet on the floor. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: pass VLANClientState* as first arg to receive handlersMark McLoughlin1-4/+4
Give static type checking a chance to catch errors. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: re-name vc->fd_read() to vc->receive()Mark McLoughlin1-1/+1
VLANClientState's fd_read() handler doesn't read from file descriptors, it adds a buffer to the client's receive queue. Re-name the handlers to make things a little less confusing. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add fd_readv() handler to qemu_new_vlan_client() argsMark McLoughlin1-1/+1
This, apparently, is the style we prefer - all VLANClientState should be an argument to qemu_new_vlan_client(). Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-05-18Separate virtio PCI codePaul Brook1-16/+7
Split the PCI host bindings from the VRing transport implementation. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-14Virtio-net qdev conversionPaul Brook1-9/+12
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-04-17Introduce VLANClientState::cleanup() (Mark McLoughlin)aliguori1-1/+18
We're currently leaking memory and file descriptors on device hot-unplug. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17Remove stray GSO code from virtio_net (Mark McLoughlin)aliguori1-5/+0
Obviously merged from kvm-userspace accidentally. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7142 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-13Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'blueswir11-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-05Fix oops on 2.6.25 guest (Rusty Russell)aliguori1-0/+16
I believe this is behind the following: https://bugs.edge.launchpad.net/ubuntu/jaunty/+source/linux/+bug/331128 virtio_pci in 2.6.25 didn't do feature negotiation correctly: it acked every bit. Fortunately, we can detect this. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6975 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-13qemu:virtio-net: Check return size on the correct sg list (Alex Williamson)aliguori1-1/+1
When checking that the size of the control virtqueue return field is sufficient, use the correct sg list. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6845 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-16virtio: Remove malloc failure checks (Jan Kiszka)aliguori1-4/+0
No need to check for failing qemu_malloc anymore. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6626 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-11qemu: return PCIDevice on net device init and record devfn (Marcelo Tosatti)aliguori1-4/+5
Change the PCI network drivers init functions to return the PCIDev, to inform which slot has been hot-plugged. Also record PCIDevice structure on NICInfo to locate for release on hot-removal. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6593 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-05qemu:virtio-net: Add VLAN filtering (Alex Williamson)aliguori1-3/+49
Use the control virtqueue to allow the guest to enable and manipulate a VLAN filter table. This allows us to drop more packets the guest doesn't want to see. We define a new VLAN class for the control virtqueue with commands ADD and DEL with usage defined in virtio-net.h. Signed-off-by: Alex Williamson <alex.williamson@hp.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6540 c046a42c-6fe2-441c-8c8c-71466251a162