|
iPXE
|
Hyper-V network virtual service client. More...
#include <string.h>#include <errno.h>#include <unistd.h>#include <byteswap.h>#include <ipxe/umalloc.h>#include <ipxe/rndis.h>#include <ipxe/vmbus.h>#include "netvsc.h"Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| static int | netvsc_control (struct netvsc_device *netvsc, unsigned int xrid, const void *data, size_t len) |
| Send control message and wait for completion. | |
| static int | netvsc_completed (struct netvsc_device *netvsc __unused, const void *data __unused, size_t len __unused) |
| Handle generic completion. | |
| static int | netvsc_initialise (struct netvsc_device *netvsc) |
| Initialise communication. | |
| static int | netvsc_initialised (struct netvsc_device *netvsc, const void *data, size_t len) |
| Handle initialisation completion. | |
| static int | netvsc_ndis_version (struct netvsc_device *netvsc) |
| Set NDIS version. | |
| static int | netvsc_establish_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
| Establish data buffer. | |
| static int | netvsc_rx_established_buffer (struct netvsc_device *netvsc, const void *data, size_t len) |
| Handle establish receive data buffer completion. | |
| static int | netvsc_revoke_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
| Revoke data buffer. | |
| static int | netvsc_recv_control (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
| Handle received control packet. | |
| static int | netvsc_recv_data (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len, struct list_head *list) |
| Handle received data packet. | |
| static int | netvsc_recv_completion (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
| Handle received completion packet. | |
| static int | netvsc_recv_cancellation (struct vmbus_device *vmdev, uint64_t xid) |
| Handle received cancellation packet. | |
| static void | netvsc_poll (struct rndis_device *rndis) |
| Poll for completed and received packets. | |
| static int | netvsc_transmit (struct rndis_device *rndis, struct io_buffer *iobuf) |
| Transmit packet. | |
| static void | netvsc_cancel_transmit (struct netvsc_device *netvsc, struct io_buffer *iobuf, unsigned int tx_id) |
| Cancel transmission. | |
| static int | netvsc_create_ring (struct netvsc_device *netvsc __unused, struct netvsc_ring *ring) |
| Create descriptor ring. | |
| static void | netvsc_destroy_ring (struct netvsc_device *netvsc, struct netvsc_ring *ring, void(*discard)(struct netvsc_device *, struct io_buffer *, unsigned int)) |
| Destroy descriptor ring. | |
| static int | netvsc_buffer_copy (struct vmbus_xfer_pages *pages, void *data, size_t offset, size_t len) |
| Copy data from data buffer. | |
| static int | netvsc_create_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
| Create data buffer. | |
| static void | netvsc_destroy_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
| Destroy data buffer. | |
| static int | netvsc_open (struct rndis_device *rndis) |
| Open device. | |
| static void | netvsc_close (struct rndis_device *rndis) |
| Close device. | |
| static int | netvsc_probe (struct vmbus_device *vmdev) |
| Probe device. | |
| static int | netvsc_reset (struct vmbus_device *vmdev) |
| Reset device. | |
| static void | netvsc_remove (struct vmbus_device *vmdev) |
| Remove device. | |
| VMBUS_ROM ("netvsc", "Hyper-V NetVSC RNDIS virtual NIC") | |
Variables | |
| static struct vmbus_channel_operations | netvsc_channel_operations |
| VMBus channel operations. | |
| static struct vmbus_xfer_pages_operations | netvsc_xfer_pages_operations |
| Transfer page set operations. | |
| static struct rndis_operations | netvsc_operations |
| RNDIS operations. | |
| struct vmbus_driver netvsc_driver | __vmbus_driver |
| NetVSC driver. | |
Hyper-V network virtual service client.
The network virtual service client (NetVSC) connects to the network virtual service provider (NetVSP) via the Hyper-V virtual machine bus (VMBus). It provides a transport layer for RNDIS packets.
Definition in file netvsc.c.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Send control message and wait for completion.
| rc | Return status code |
Definition at line 53 of file netvsc.c.
References data, DBGC, ETIMEDOUT, len, mdelay(), netvsc_device::name, NETVSC_BASE_XID, NETVSC_MAX_WAIT_MS, rc, strerror(), vmbus_dump_channel(), vmbus_poll(), vmbus_send_control(), netvsc_device::vmdev, netvsc_device::wait_rc, and netvsc_device::wait_xrid.
Referenced by netvsc_establish_buffer(), netvsc_initialise(), netvsc_ndis_version(), and netvsc_revoke_buffer().
|
static |
|
static |
Initialise communication.
| netvsc | NetVSC device |
| rc | Return status code |
Definition at line 108 of file netvsc.c.
References cpu_to_le32, DBGC, memset(), msg(), netvsc_device::name, netvsc_control(), NETVSC_INIT_MSG, NETVSC_INIT_XRID, NETVSC_VERSION_1, rc, and strerror().
Referenced by netvsc_open().
|
static |
Handle initialisation completion.
| rc | Return status code |
Definition at line 138 of file netvsc.c.
References cpu_to_le32, data, DBGC, EINVAL, EPROTO, netvsc_init_completion::header, le32_to_cpu, len, netvsc_device::name, NETVSC_INIT_CMPLT, NETVSC_OK, netvsc_init_completion::status, and netvsc_header::type.
Referenced by netvsc_recv_completion().
|
static |
Set NDIS version.
| netvsc | NetVSC device |
| rc | Return status code |
Definition at line 170 of file netvsc.c.
References cpu_to_le32, DBGC, memset(), msg(), netvsc_device::name, netvsc_control(), NETVSC_NDIS_MAJOR, NETVSC_NDIS_MINOR, NETVSC_NDIS_VERSION_MSG, NETVSC_NDIS_VERSION_XRID, rc, and strerror().
Referenced by netvsc_open().
|
static |
Establish data buffer.
| netvsc | NetVSC device |
| buffer | Data buffer |
| rc | Return status code |
Definition at line 198 of file netvsc.c.
References buffer, cpu_to_le32, DBGC, memset(), msg(), netvsc_device::name, netvsc_control(), rc, and strerror().
Referenced by netvsc_open().
|
static |
Handle establish receive data buffer completion.
| rc | Return status code |
Definition at line 228 of file netvsc.c.
References cpu_to_le32, data, DBGC, EINVAL, EPROTO, netvsc_rx_establish_buffer_completion::header, le32_to_cpu, len, netvsc_device::name, NETVSC_OK, NETVSC_RX_ESTABLISH_CMPLT, netvsc_rx_establish_buffer_completion::status, and netvsc_header::type.
Referenced by netvsc_recv_completion().
|
static |
Revoke data buffer.
| netvsc | NetVSC device |
| buffer | Data buffer |
| rc | Return status code |
Definition at line 260 of file netvsc.c.
References buffer, cpu_to_le32, DBGC, memset(), msg(), netvsc_device::name, netvsc_control(), rc, and strerror().
Referenced by netvsc_close(), and netvsc_open().
|
static |
Handle received control packet.
| rc | Return status code |
Definition at line 299 of file netvsc.c.
References data, DBGC, DBGC_HDA, ENOTSUP, len, netvsc_device::name, rndis_device::priv, netvsc_device::rndis, and vmbus_get_drvdata().
|
static |
Handle received data packet.
| rc | Return status code |
Definition at line 320 of file netvsc.c.
References cpu_to_le32, data, DBGC, EINVAL, free_iob(), iob_disown, le32_to_cpu, len, io_buffer::list, list_del, list_for_each_entry_safe, msg(), netvsc_device::name, NETVSC_RNDIS_MSG, NULL, rndis_device::priv, rc, netvsc_device::rndis, rndis_rx(), strerror(), tmp, vmbus_get_drvdata(), and vmbus_send_completion().
|
static |
Handle received completion packet.
| rc | Return status code |
Definition at line 379 of file netvsc.c.
References completion, netvsc_ring::count, data, DBGC, EPIPE, netvsc_ring::id_cons, netvsc_ring::ids, netvsc_ring::iobufs, len, netvsc_device::name, NETVSC_BASE_XID, netvsc_completed(), NETVSC_INIT_XRID, netvsc_initialised(), NETVSC_RX_ESTABLISH_XRID, netvsc_rx_established_buffer(), NETVSC_TX_BASE_XRID, NETVSC_TX_NUM_DESC, NULL, rndis_device::priv, rc, netvsc_device::rndis, rndis_tx_complete(), netvsc_device::tx, vmbus_get_drvdata(), netvsc_device::wait_rc, and netvsc_device::wait_xrid.
|
static |
Handle received cancellation packet.
| vmdev | VMBus device |
| xid | Transaction ID |
| rc | Return status code |
Definition at line 438 of file netvsc.c.
References DBGC, ENOTSUP, netvsc_device::name, rndis_device::priv, netvsc_device::rndis, and vmbus_get_drvdata().
|
static |
Poll for completed and received packets.
| rndis | RNDIS device |
Definition at line 461 of file netvsc.c.
References rndis_device::priv, netvsc_device::rndis, vmbus_has_data(), vmbus_poll(), and netvsc_device::vmdev.
|
static |
Transmit packet.
| rndis | RNDIS device |
| iobuf | I/O buffer |
| rc | Return status code |
If this method returns success then the RNDIS device must eventually report completion via rndis_tx_complete().
Definition at line 480 of file netvsc.c.
References assert, netvsc_ring::count, cpu_to_le32, io_buffer::data, DBGC, EPIPE, header, netvsc_ring::id_prod, netvsc_ring::ids, iob_len(), netvsc_ring::iobufs, le32_to_cpu, memset(), msg(), netvsc_device::name, NETVSC_BASE_XID, NETVSC_RNDIS_CONTROL, NETVSC_RNDIS_DATA, NETVSC_RNDIS_MSG, NETVSC_RNDIS_NO_BUFFER, NETVSC_TX_BASE_XRID, NULL, rndis_device::priv, rc, netvsc_device::rndis, RNDIS_PACKET_MSG, rndis_tx_defer(), strerror(), netvsc_device::tx, vmbus_send_data(), and netvsc_device::vmdev.
|
static |
Cancel transmission.
| netvsc | NetVSC device |
| iobuf | I/O buffer |
| tx_id | Transmission ID |
Definition at line 541 of file netvsc.c.
References DBGC, ECANCELED, netvsc_device::name, NETVSC_BASE_XID, NETVSC_TX_BASE_XRID, netvsc_device::rndis, rndis_tx_complete_err(), vmbus_send_cancellation(), and netvsc_device::vmdev.
Referenced by netvsc_close().
|
static |
Create descriptor ring.
| netvsc | NetVSC device |
| ring | Descriptor ring |
| rc | Return status code |
Definition at line 565 of file netvsc.c.
References __unused, assert, netvsc_ring::count, netvsc_ring::id_cons, netvsc_ring::id_prod, netvsc_ring::ids, netvsc_ring::iobufs, and NULL.
Referenced by netvsc_open().
|
static |
Destroy descriptor ring.
| netvsc | NetVSC device |
| ring | Descriptor ring |
| discard | Method used to discard outstanding buffer, or NULL |
Definition at line 587 of file netvsc.c.
References assert, netvsc_ring::count, netvsc_ring::id_cons, netvsc_ring::ids, netvsc_ring::iobufs, and NULL.
Referenced by netvsc_close(), and netvsc_open().
|
static |
Copy data from data buffer.
| pages | Transfer page set |
| data | Data buffer |
| offset | Offset within page set |
| len | Length within page set |
| rc | Return status code |
Definition at line 619 of file netvsc.c.
References buffer, container_of, data, ERANGE, len, memcpy(), offset, and netvsc_buffer::pages.
|
static |
Create data buffer.
| netvsc | NetVSC device |
| buffer | Data buffer |
| rc | Return status code |
Definition at line 646 of file netvsc.c.
References buffer, DBGC, ENOMEM, gpadl, netvsc_device::name, rc, strerror(), ufree(), umalloc(), vmbus_establish_gpadl(), vmbus_gpadl_teardown(), vmbus_register_pages(), vmbus_unregister_pages(), and netvsc_device::vmdev.
Referenced by netvsc_open().
|
static |
Destroy data buffer.
| netvsc | NetVSC device |
| buffer | Data buffer |
Definition at line 695 of file netvsc.c.
References buffer, DBGC, netvsc_device::name, rc, strerror(), ufree(), vmbus_unregister_pages(), and netvsc_device::vmdev.
Referenced by netvsc_close(), and netvsc_open().
|
static |
Open device.
| rndis | RNDIS device |
| rc | Return status code |
Definition at line 725 of file netvsc.c.
References DBGC, netvsc_device::name, netvsc_channel_operations, netvsc_create_buffer(), netvsc_create_ring(), netvsc_destroy_buffer(), netvsc_destroy_ring(), netvsc_establish_buffer(), netvsc_initialise(), NETVSC_MTU, netvsc_ndis_version(), netvsc_revoke_buffer(), NULL, PAGE_SIZE, rndis_device::priv, rc, netvsc_device::rndis, netvsc_device::rx, strerror(), netvsc_device::tx, vmbus_close(), vmbus_open(), and netvsc_device::vmdev.
|
static |
Close device.
| rndis | RNDIS device |
Definition at line 775 of file netvsc.c.
References netvsc_cancel_transmit(), netvsc_destroy_buffer(), netvsc_destroy_ring(), netvsc_revoke_buffer(), rndis_device::priv, netvsc_device::rndis, netvsc_device::rx, netvsc_device::tx, vmbus_close(), and netvsc_device::vmdev.
|
static |
Probe device.
| vmdev | VMBus device |
| rc | Return status code |
Definition at line 805 of file netvsc.c.
References alloc_rndis(), DBGC, net_device::dev, vmbus_device::dev, ENOMEM, free_rndis(), device::name, netvsc_device::name, rndis_device::netdev, netvsc_operations, NETVSC_RX_BUF_LEN, NETVSC_RX_BUF_PAGESET, NETVSC_RX_ESTABLISH_MSG, NETVSC_RX_ESTABLISH_XRID, NETVSC_RX_REVOKE_MSG, NETVSC_RX_REVOKE_XRID, NETVSC_TX_NUM_DESC, netvsc_xfer_pages_operations, rndis_device::priv, rc, register_rndis(), netvsc_device::rndis, rndis_init(), netvsc_device::rx, strerror(), netvsc_device::tx, netvsc_device::tx_ids, netvsc_device::tx_iobufs, unregister_rndis(), vmbus_set_drvdata(), and netvsc_device::vmdev.
|
static |
Reset device.
| vmdev | VMBus device |
| rc | Return status code |
Definition at line 853 of file netvsc.c.
References DBGC, netvsc_device::name, netdev, rndis_device::netdev, netdev_close(), netdev_is_open(), netdev_open(), rndis_device::priv, rc, netvsc_device::rndis, strerror(), and vmbus_get_drvdata().
|
static |
Remove device.
| vmdev | VMBus device |
Definition at line 881 of file netvsc.c.
References free_rndis(), unregister_rndis(), and vmbus_get_drvdata().
| VMBUS_ROM | ( | "netvsc" | , |
| "Hyper-V NetVSC RNDIS virtual NIC" | ) |
|
static |
VMBus channel operations.
Definition at line 449 of file netvsc.c.
Referenced by netvsc_open().
|
static |
Transfer page set operations.
Definition at line 635 of file netvsc.c.
Referenced by netvsc_probe().
|
static |
RNDIS operations.
Definition at line 792 of file netvsc.c.
Referenced by netvsc_probe().
| struct vmbus_driver netvsc_driver __vmbus_driver |
NetVSC driver.
Definition at line 892 of file netvsc.c.