iPXE
|
Hyper-V network virtual service client. More...
#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. More... | |
static int | netvsc_completed (struct netvsc_device *netvsc __unused, const void *data __unused, size_t len __unused) |
Handle generic completion. More... | |
static int | netvsc_initialise (struct netvsc_device *netvsc) |
Initialise communication. More... | |
static int | netvsc_initialised (struct netvsc_device *netvsc, const void *data, size_t len) |
Handle initialisation completion. More... | |
static int | netvsc_ndis_version (struct netvsc_device *netvsc) |
Set NDIS version. More... | |
static int | netvsc_establish_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
Establish data buffer. More... | |
static int | netvsc_rx_established_buffer (struct netvsc_device *netvsc, const void *data, size_t len) |
Handle establish receive data buffer completion. More... | |
static int | netvsc_revoke_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
Revoke data buffer. More... | |
static int | netvsc_recv_control (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
Handle received control packet. More... | |
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. More... | |
static int | netvsc_recv_completion (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
Handle received completion packet. More... | |
static int | netvsc_recv_cancellation (struct vmbus_device *vmdev, uint64_t xid) |
Handle received cancellation packet. More... | |
static void | netvsc_poll (struct rndis_device *rndis) |
Poll for completed and received packets. More... | |
static int | netvsc_transmit (struct rndis_device *rndis, struct io_buffer *iobuf) |
Transmit packet. More... | |
static void | netvsc_cancel_transmit (struct netvsc_device *netvsc, struct io_buffer *iobuf, unsigned int tx_id) |
Cancel transmission. More... | |
static int | netvsc_create_ring (struct netvsc_device *netvsc __unused, struct netvsc_ring *ring) |
Create descriptor ring. More... | |
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. More... | |
static int | netvsc_buffer_copy (struct vmbus_xfer_pages *pages, void *data, size_t offset, size_t len) |
Copy data from data buffer. More... | |
static int | netvsc_create_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
Create data buffer. More... | |
static void | netvsc_destroy_buffer (struct netvsc_device *netvsc, struct netvsc_buffer *buffer) |
Destroy data buffer. More... | |
static int | netvsc_open (struct rndis_device *rndis) |
Open device. More... | |
static void | netvsc_close (struct rndis_device *rndis) |
Close device. More... | |
static int | netvsc_probe (struct vmbus_device *vmdev) |
Probe device. More... | |
static int | netvsc_reset (struct vmbus_device *vmdev) |
Reset device. More... | |
static void | netvsc_remove (struct vmbus_device *vmdev) |
Remove device. More... | |
Variables | |
static struct vmbus_channel_operations | netvsc_channel_operations |
VMBus channel operations. More... | |
static struct vmbus_xfer_pages_operations | netvsc_xfer_pages_operations |
Transfer page set operations. More... | |
static struct rndis_operations | netvsc_operations |
RNDIS operations. More... | |
struct vmbus_driver netvsc_driver | __vmbus_driver |
NetVSC driver. More... | |
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.
netvsc | NetVSC device |
xrid | Relative transaction ID |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 52 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 |
Handle generic completion.
netvsc | NetVSC device |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 96 of file netvsc.c.
Referenced by netvsc_recv_completion().
|
static |
Initialise communication.
netvsc | NetVSC device |
rc | Return status code |
Definition at line 107 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.
netvsc | NetVSC device |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 137 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 168 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 196 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.
netvsc | NetVSC device |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 226 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 257 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.
vmdev | VMBus device |
xid | Transaction ID |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 296 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.
vmdev | VMBus device |
xid | Transaction ID |
data | Data |
len | Length of data |
list | List of I/O buffers |
rc | Return status code |
Definition at line 317 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.
vmdev | VMBus device |
xid | Transaction ID |
data | Data |
len | Length of data |
rc | Return status code |
Definition at line 375 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 434 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 457 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 476 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 537 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 561 of file netvsc.c.
References 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 583 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 615 of file netvsc.c.
References buffer, container_of, copy_from_user(), data, ERANGE, len, offset, and netvsc_buffer::pages.
|
static |
Create data buffer.
netvsc | NetVSC device |
buffer | Data buffer |
rc | Return status code |
Definition at line 642 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 691 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 721 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 771 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 801 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 849 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 877 of file netvsc.c.
References free_rndis(), unregister_rndis(), and vmbus_get_drvdata().
|
static |
VMBus channel operations.
Definition at line 445 of file netvsc.c.
Referenced by netvsc_open().
|
static |
Transfer page set operations.
Definition at line 631 of file netvsc.c.
Referenced by netvsc_probe().
|
static |
RNDIS operations.
Definition at line 788 of file netvsc.c.
Referenced by netvsc_probe().
struct vmbus_driver netvsc_driver __vmbus_driver |
NetVSC driver.