summaryrefslogtreecommitdiff
path: root/net.h
AgeCommit message (Collapse)AuthorFilesLines
2009-10-27really fix net.hAnthony Liguori1-1/+1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Fix signature of new_vlan_clientAnthony Liguori1-1/+2
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27Enable UFO on virtio-net and tap devicesSridhar Samudrala1-1/+2
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-27net: add tap_set_offload()Mark McLoughlin1-0/+1
This API allows virtio-net to enable various offload features on a tap interface - e.g. to tell the host kernel it can pass up partial checksums to userspace. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27net: add receive_raw parameter to qemu_new_vlan_client()Mark McLoughlin1-0/+1
Trivial patch to allow supplying a receive_raw function. A future cleanup should combine this function pointer parameters into a table. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27net: add an API for 'raw' packetsMark McLoughlin1-0/+2
In the case where a NIC and backend agree on a packet header format, this API allows injecting packets which lack the agreed upon header. We need this for sending our gratuitous ARP. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27net: add tap_has_vnet_hdr() and tap_using_vnet_hdr() APIsMark McLoughlin1-0/+3
These lamely named functions allow virtio-net to query whether IFF_VNET_HDR is enabled on a tap interface and inform the tap code that virtio-net will supply packets with a vnet header. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27net: add a client type codeMark McLoughlin1-0/+11
This is so as to allow APIs which operate on specific client types without having to add a function table entry which is only implemented by a single client type. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27zap DeviceState->ndGerd Hoffmann1-7/+0
No users left. Also cleanup obsolete helper functions. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27qdev/net: common nic property bitsGerd Hoffmann1-0/+14
Add a new type for properties common to all nics. Add helper functions and macros to deal with it. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27qdev: add netdev propertyGerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27net: add macaddr type.Gerd Hoffmann1-0/+5
Add new type for mac addresses. Add function which sets the qemu default mac address if it finds the mac address uninitialized (i.e. all zeros). Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: add queue for peer-to-peer packet forwardingMark McLoughlin1-0/+1
Now that we have re-factored the packet queue code, we can re-use it for peer-to-peer also. Patchworks-ID: 35520 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: refactor packet queueing codeMark McLoughlin1-16/+2
The packet queue code is fairly standalone, has some complex details and easily reusable. It makes sense to split it out on its own. This patch doesn't contain any functional changes. Patchworks-ID: 35511 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: allow NICs to be connected to netdevsMark McLoughlin1-0/+2
Introduce a 'peer' member to VLANClientState as an alternative to a vlan. The idea being that packets are transfered directly from peer clients rather than going through a vlan. Patchworks-ID: 35516 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: add -net nic,netdev= optionMark McLoughlin1-0/+1
Patchworks-ID: 35515 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: handle -netdevice optionsMark McLoughlin1-1/+1
Same as for -net except for: - only tap, user, vde and socket types are supported - the vlan parameter is not allowed - the name parameter is not allowed but the id parameter is required Patchworks-ID: 35517 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: add QemuOptsList arg to net_client_parse()Mark McLoughlin1-1/+1
Patchworks-ID: 35505 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: use qtailq for vlan and client listsMark McLoughlin1-3/+3
Patchworks-ID: 35507 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: remove id field from NICInfoMark McLoughlin1-1/+0
Just use the name field instead since we now use the id paramater as the name, if supplied. Only implication with this change is that if id is not supplied, the value of the name paramater is used as an id. Patchworks-ID: 35512 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-15net: remove unused qemu_handler_true()Mark McLoughlin1-1/+0
Patchworks-ID: 35504 Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Final net cleanup after conversion to QemuOptsMark McLoughlin1-3/+2
Now that net_client_init() has no users, kill it off and rename net_client_init_from_opts(). There is no further need for the old code in net_client_parse() either. We use qemu_opts_parse() 'firstname' facitity for that. Instead, move the special handling of the 'vmchannel' type there. Simplify the vl.c code into merely call net_client_parse() for each -net command line option and then calling net_init_clients() later to iterate over the options and create the clients. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Port usb net to QemuOptsMark McLoughlin1-0/+2
We need net_client_init_from_opts() exported for this Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Don't exit() in config_error()Markus Armbruster1-2/+2
Propagating errors up the call chain is tedious. In startup code, we can take a shortcut: terminate the program. This is wrong elsewhere, the monitor in particular. config_error() tries to cater for both customers: it terminates the program unless its mon parameter tells it it's working for the monitor. Its users need to return status anyway (unless passing a null mon argument, which none do), which their users need to check. So this automatic exit buys us exactly nothing useful. Only the dangerous delusion that we can get away without returning status. Some of its users fell for that. Their callers continue executing after failure when working for the monitor. This bites monitor command host_net_add in two places: * net_slirp_init() continues after slirp_hostfwd(), slirp_guestfwd(), or slirp_smb() failed, and may end up reporting success. This happens for "host_net_add user guestfwd=foo": it complains about the invalid guest forwarding rule, then happily creates the user network without guest forwarding. * net_client_init() can't detect slirp_guestfwd() failure, and gets fooled by net_slirp_init() lying about success. Suppresses its "Could not initialize device" message. Add the missing error reporting, make sure errors are checked, and drop the exit() from config_error(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-06Make NICInfo string fields non-constMark McLoughlin1-4/+4
We now only assign strdup()ed strings to these fields, never static strings. aliguori: fix build for ppc_prep and mips_jazz Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Fix pci_add nic not to exit on bad modelMarkus Armbruster1-2/+3
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() to create the NIC. When MODEL is unknown or "?", this prints to stderr and terminates the program. Change pci_nic_init() not to treat "?" specially, and to return NULL on failure. Switch uses during startup to new convenience wrapper pci_nic_init_nofail(), which behaves just like pci_nic_init() used to do. Bonus bug fix: we now check for qdev_init() failing there. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Make it obvious that pci_nic_init() can't failMarkus Armbruster1-2/+2
Before this patch, pci_nic_init() returns NULL when it can't find the model in pci_nic_models[]. Except this can't happen, because qemu_check_nic_model_list() just searched for model in pci_nic_models[], and terminated the program on failure. Repeating the search here is pointless. Instead, change qemu_check_nic_model_list() to return the model's array index. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-3/+3
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-04monitor: Port handler_3 to use QDictLuiz Capitulino1-4/+2
This commit ports command handlers that receive three arguments to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04monitor: Port handler_2 to use QDictLuiz Capitulino1-3/+4
This commit ports command handlers that receive two arguments to use the new monitor's dictionary. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-04net: Fix send queue orderingJan Kiszka1-2/+3
Ensure that packets enqueued for delayed delivery are dequeued in FIFO order. At least one simplistic guest TCP/IP stack became unhappy due to sporadically reordered packet streams. At this chance, switch the send queue implementation to TAILQ. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-10net: Fix do_set_link() return typeLuiz Capitulino1-1/+1
do_set_link() returns int, but Monitor handler functions should always return void. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
2009-07-16qdev: add id= support for pci nics.Gerd Hoffmann1-0/+1
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09Don't leak VLANClientState on PCI hot removeMark McLoughlin1-0/+1
destroy_nic() requires that NICInfo::private by a PCIDevice pointer, but then goes on to require that the same pointer matches VLANClientState::opaque. That is no longer the case for virtio-net since qdev and wasn't previously the case for rtl8139, ne2k_pci or eepro100. Make the situation a lot more clear by maintaining a VLANClientState pointer in NICInfo. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Make hostfwd_add/remove multi-instance-awareJan Kiszka1-2/+4
Extend the syntax of hostfwd_add/remove to optionally take a tuple of VLAN ID and slirp stack name. If those are omitted, the commands will continue to work on the first registered slirp stack. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29net: Provide VLAN client lookup helperJan Kiszka1-1/+1
Introduce qemu_find_vlan_client_by_name for VLANClientState lookup based on VLAN ID and client name. This is useful for monitor commands. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Kill slirp_is_initedJan Kiszka1-1/+0
Avoid the need for slirp_is_inited by refactoring the protected slirp_select_* functions. This also avoids the clearing of all fd sets on select errors. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Add info usernet for dumping connection statesJan Kiszka1-0/+2
Break out sockstats from the slirp statistics and present them under the new info category "usernet". This patch also improves the current output /wrt proper reporting connection source and destination. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Bind support for host forwarding rulesJan Kiszka1-1/+1
Extend the hostfwd rule format so that the user can specify on which host interface qemu should listen for incoming connections. If omitted, binding will takes place against all interfaces. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Rework monitor commands for host forwardingJan Kiszka1-1/+3
Improve the monitor interface for adding and removing host forwarding rules by splitting it up in two commands and rename them to hostfwd_add and hostfwd_remove. Also split up the paths taken for legacy -redir support and the monitor add command as the latter will be extended later on. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-29slirp: Move smb, redir, tftp and bootp parameters and -net channelJan Kiszka1-0/+3
So far a couple of slirp-related parameters were expressed via stand-alone command line options. This it inconsistent and unintuitive. Moreover, it prevents both dynamically reconfigured (host_net_add/ delete) and multi-instance slirp. This patch refactors the configuration by turning -smb, -redir, -tftp and -bootp as well as -net channel into options of "-net user". The old stand-alone command line options are still processed, but no longer advertised. This allows smooth migration of management applications to to the new syntax and also the extension of that syntax later in this series. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.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-0/+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-22net: add packet length to NetPacketSent callbackMark McLoughlin1-1/+1
virtio-net needs this - for the same purpose that it currently uses the return value from qemu_sendv_packet(). Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22net: add qemu_purge_queued_packets()Mark McLoughlin1-0/+1
If net client sends packets asynchronously, it needs to purge its queued packets in cleanup() so as to prevent sent callbacks being invoked with a freed client. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22Support addr=... in option argument of -net nicMarkus Armbruster1-0/+1
Make net_client_init() accept addr=, put the value into struct NICinfo. Use it in pci_nic_init(), and remove arguments bus and devfn. Don't support addr= in third argument of monitor command pci_add, because that clashes with its first argument. Admittedly unelegant. Machines "malta" and "r2d" have a default NIC with a well-known PCI address. Deal with that the same way as the NIC model: make pci_nic_init() take an optional default to be used when the user doesn't specify one. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-22Make nic option rom loading less painful.Glauber Costa1-0/+2
The code how it is today, is totally painful to read and keep. To begin with, the code is duplicated with the option rom loading code that linux_boot and vga are already using. This patch introduces a "bootable" state in NICInfo structure, that we can use to keep track of whether or not a given nic should be bootable, avoiding the introduction of yet another global state. With that in hands, we move the code in vl.c to hw/pc.c, and use the already existing infra structure to load those option roms. Error checking code suggested by Mark McLoughlin Signed-off-by: Glauber Costa <glommer@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-09net: add qemu_send_packet_async()Mark McLoughlin1-0/+8
Add a qemu_send_packet() variant which will queue up the packet if it cannot be sent when all client queues are full. It later invokes the supplied callback when the packet has been sent. If qemu_send_packet_async() returns zero, the caller is expected to not send any more packets until the queued packet has been sent. Packets are queued iff a receive() handler returns zero (indicating queue full) and the caller has provided a sent notification callback (indicating it will stop and start its own queue). We need the packet sending API to support queueing because: - a sending client should process all available packets in one go (e.g. virtio-net emptying its tx ring) - a receiving client may not be able to handle the packet (e.g. -EAGAIN from write() to tapfd) - the sending client could detect this condition in advance (e.g. by select() for writable on tapfd) - that's too much overhead (e.g. a select() call per packet) - therefore the sending client must handle the condition by dropping the packet or queueing it - dropping packets is poor form; we should queue. However, we don't want queueing to be completely transparent. We want the sending client to stop sending packets as soon as a packet is queued. This allows the sending client to be throttled by the receiver. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-09net: add return value to packet receive handlerMark McLoughlin1-1/+1
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-3/+3
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-11/+12
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>