iPXE
|
Hyper-V virtual machine bus. More...
#include <byteswap.h>
#include <ipxe/uuid.h>
#include <ipxe/device.h>
#include <ipxe/tables.h>
#include <ipxe/uaccess.h>
#include <ipxe/iobuf.h>
#include <ipxe/hyperv.h>
Go to the source code of this file.
Data Structures | |
union | vmbus_version |
VMBus version number. More... | |
struct | vmbus_gpa_range |
Guest physical address range descriptor. More... | |
struct | vmbus_message_header |
VMBus message header. More... | |
struct | vmbus_offer_channel |
VMBus "offer channel" message. More... | |
struct | vmbus_open_channel |
VMBus "open channel" message. More... | |
struct | vmbus_open_channel_result |
VMBus "open channel result" message. More... | |
struct | vmbus_close_channel |
VMBus "close channel" message. More... | |
struct | vmbus_gpadl_header |
VMBus "GPADL header" message. More... | |
struct | vmbus_gpadl_created |
VMBus "GPADL created" message. More... | |
struct | vmbus_gpadl_teardown |
VMBus "GPADL teardown" message. More... | |
struct | vmbus_gpadl_torndown |
VMBus "GPADL torndown" message. More... | |
struct | vmbus_initiate_contact |
VMBus "initiate contact" message. More... | |
struct | vmbus_version_response |
VMBus "version response" message. More... | |
union | vmbus_message |
VMBus message. More... | |
struct | vmbus_packet_header |
VMBus packet header. More... | |
struct | vmbus_gpa_direct_header |
VMBus GPA direct header. More... | |
struct | vmbus_xfer_page_range |
VMBus transfer page range. More... | |
struct | vmbus_xfer_page_header |
VMBus transfer page header. More... | |
union | vmbus_packet_header_max |
VMBus maximum-sized packet header. More... | |
struct | vmbus_packet_footer |
VMBus packet footer. More... | |
struct | vmbus_ring |
VMBus ring buffer. More... | |
struct | vmbus_interrupt |
VMBus interrupt page. More... | |
struct | vmbus |
A virtual machine bus. More... | |
struct | vmbus_channel_operations |
VMBus channel operations. More... | |
struct | vmbus_xfer_pages_operations |
VMBus transfer page set operations. More... | |
struct | vmbus_xfer_pages |
VMBus transfer page set. More... | |
struct | vmbus_device |
A VMBus device. More... | |
struct | vmbus_driver |
A VMBus device driver. More... | |
Macros | |
#define | VMBUS_MESSAGE_ID 1 |
VMBus message connection ID. More... | |
#define | VMBUS_EVENT_ID 2 |
VMBus event connection ID. More... | |
#define | VMBUS_MESSAGE_TYPE 1 |
VMBus message type. More... | |
#define | VMBUS_MESSAGE_SINT 2 |
VMBus message synthetic interrupt. More... | |
#define | VMBUS_PACKET_MAX_HEADER_LEN 64 |
Maximum expected size of VMBus packet header. More... | |
#define | VMBUS_DRIVERS __table ( struct vmbus_driver, "vmbus_drivers" ) |
VMBus device driver table. More... | |
#define | __vmbus_driver __table_entry ( VMBUS_DRIVERS, 01 ) |
Declare a VMBus device driver. More... | |
#define | VMBUS_TYPE(a, b, c, d, e0, e1, e2, e3, e4, e5) |
Construct VMBus type. More... | |
Enumerations | |
enum | vmbus_raw_version { VMBUS_VERSION_WS2008 = ( ( 0 << 16 ) | ( 13 << 0 ) ), VMBUS_VERSION_WIN7 = ( ( 1 << 16 ) | ( 1 << 0 ) ), VMBUS_VERSION_WIN8 = ( ( 2 << 16 ) | ( 4 << 0 ) ), VMBUS_VERSION_WIN8_1 = ( ( 3 << 16 ) | ( 0 << 0 ) ) } |
Known VMBus protocol versions. More... | |
enum | vmbus_message_type { VMBUS_OFFER_CHANNEL = 1, VMBUS_REQUEST_OFFERS = 3, VMBUS_ALL_OFFERS_DELIVERED = 4, VMBUS_OPEN_CHANNEL = 5, VMBUS_OPEN_CHANNEL_RESULT = 6, VMBUS_CLOSE_CHANNEL = 7, VMBUS_GPADL_HEADER = 8, VMBUS_GPADL_CREATED = 10, VMBUS_GPADL_TEARDOWN = 11, VMBUS_GPADL_TORNDOWN = 12, VMBUS_INITIATE_CONTACT = 14, VMBUS_VERSION_RESPONSE = 15, VMBUS_UNLOAD = 16, VMBUS_UNLOAD_RESPONSE = 17 } |
VMBus message types. More... | |
enum | vmbus_packet_type { VMBUS_DATA_INBAND = 6, VMBUS_DATA_XFER_PAGES = 7, VMBUS_DATA_GPA_DIRECT = 9, VMBUS_CANCELLATION = 10, VMBUS_COMPLETION = 11 } |
VMBus packet types. More... | |
enum | vmbus_packet_flags { VMBUS_COMPLETION_REQUESTED = 0x0001 } |
VMBus packet flags. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static void | vmbus_set_drvdata (struct vmbus_device *vmdev, void *priv) |
Set VMBus device driver-private data. More... | |
static void * | vmbus_get_drvdata (struct vmbus_device *vmdev) |
Get VMBus device driver-private data. More... | |
static int | vmbus_has_data (struct vmbus_device *vmdev) |
Check if data is present in ring buffer. More... | |
static int | vmbus_register_pages (struct vmbus_device *vmdev, struct vmbus_xfer_pages *pages) |
Register transfer page set. More... | |
static void | vmbus_unregister_pages (struct vmbus_device *vmdev, struct vmbus_xfer_pages *pages) |
Unregister transfer page set. More... | |
static int | vmbus_gpadl_is_obsolete (unsigned int gpadl) |
Check if GPADL is obsolete. More... | |
int | vmbus_establish_gpadl (struct vmbus_device *vmdev, userptr_t data, size_t len) |
Establish GPA descriptor list. More... | |
int | vmbus_gpadl_teardown (struct vmbus_device *vmdev, unsigned int gpadl) |
Tear down GPA descriptor list. More... | |
int | vmbus_open (struct vmbus_device *vmdev, struct vmbus_channel_operations *op, size_t out_len, size_t in_len, size_t mtu) |
Open VMBus channel. More... | |
void | vmbus_close (struct vmbus_device *vmdev) |
Close VMBus channel. More... | |
int | vmbus_send_control (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
Send control packet via ring buffer. More... | |
int | vmbus_send_data (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len, struct io_buffer *iobuf) |
Send data packet via ring buffer. More... | |
int | vmbus_send_completion (struct vmbus_device *vmdev, uint64_t xid, const void *data, size_t len) |
Send completion packet via ring buffer. More... | |
int | vmbus_send_cancellation (struct vmbus_device *vmdev, uint64_t xid) |
Send cancellation packet via ring buffer. More... | |
int | vmbus_poll (struct vmbus_device *vmdev) |
Poll ring buffer. More... | |
void | vmbus_dump_channel (struct vmbus_device *vmdev) |
Dump channel status (for debugging) More... | |
int | vmbus_probe (struct hv_hypervisor *hv, struct device *parent) |
Probe Hyper-V virtual machine bus. More... | |
int | vmbus_reset (struct hv_hypervisor *hv, struct device *parent) |
Reset Hyper-V virtual machine bus. More... | |
void | vmbus_remove (struct hv_hypervisor *hv, struct device *parent) |
Remove Hyper-V virtual machine bus. More... | |
Variables | |
unsigned int | vmbus_obsolete_gpadl |
Obsolete GPADL ID threshold. More... | |
Hyper-V virtual machine bus.
Definition in file vmbus.h.
#define VMBUS_MESSAGE_SINT 2 |
#define VMBUS_PACKET_MAX_HEADER_LEN 64 |
#define VMBUS_DRIVERS __table ( struct vmbus_driver, "vmbus_drivers" ) |
#define __vmbus_driver __table_entry ( VMBUS_DRIVERS, 01 ) |
#define VMBUS_TYPE | ( | a, | |
b, | |||
c, | |||
d, | |||
e0, | |||
e1, | |||
e2, | |||
e3, | |||
e4, | |||
e5 | |||
) |
Construct VMBus type.
enum vmbus_raw_version |
enum vmbus_message_type |
VMBus message types.
Definition at line 80 of file vmbus.h.
enum vmbus_packet_type |
VMBus packet types.
Enumerator | |
---|---|
VMBUS_DATA_INBAND | |
VMBUS_DATA_XFER_PAGES | |
VMBUS_DATA_GPA_DIRECT | |
VMBUS_CANCELLATION | |
VMBUS_COMPLETION |
Definition at line 284 of file vmbus.h.
enum vmbus_packet_flags |
VMBus packet flags.
Enumerator | |
---|---|
VMBUS_COMPLETION_REQUESTED |
Definition at line 293 of file vmbus.h.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
inlinestatic |
Set VMBus device driver-private data.
vmdev | VMBus device |
priv | Private data |
Definition at line 557 of file vmbus.h.
References priv, and vmbus_device::priv.
Referenced by netvsc_probe().
|
inlinestatic |
Get VMBus device driver-private data.
vmdev | VMBus device |
priv | Private data |
Definition at line 567 of file vmbus.h.
References vmbus_device::priv.
Referenced by netvsc_recv_cancellation(), netvsc_recv_completion(), netvsc_recv_control(), netvsc_recv_data(), netvsc_remove(), and netvsc_reset().
|
inlinestatic |
Check if data is present in ring buffer.
vmdev | VMBus device |
has_data | Data is present |
Definition at line 586 of file vmbus.h.
References vmbus_ring::cons, vmbus_device::in, and vmbus_ring::prod.
Referenced by netvsc_poll(), and vmbus_poll().
|
inlinestatic |
Register transfer page set.
vmdev | VMBus device |
pages | Transfer page set |
rc | Return status code |
Definition at line 599 of file vmbus.h.
References list_add, and vmbus_device::pages.
Referenced by netvsc_create_buffer().
|
inlinestatic |
Unregister transfer page set.
vmdev | VMBus device |
pages | Transfer page set |
Definition at line 613 of file vmbus.h.
References list_check_contains_entry, list_del, and vmbus_device::pages.
Referenced by netvsc_create_buffer(), and netvsc_destroy_buffer().
|
inlinestatic |
Check if GPADL is obsolete.
gpadl | GPADL ID |
is_obsolete | GPADL ID is obsolete |
Check if GPADL is obsolete (i.e. was created before the most recent Hyper-V reset).
Definition at line 632 of file vmbus.h.
References gpadl, and vmbus_obsolete_gpadl.
Referenced by vmbus_gpadl_teardown().
int vmbus_establish_gpadl | ( | struct vmbus_device * | vmdev, |
userptr_t | data, | ||
size_t | len | ||
) |
Establish GPA descriptor list.
vmdev | VMBus device |
data | Data buffer |
len | Length of data buffer |
gpadl | GPADL ID, or negative error |
Definition at line 276 of file vmbus.c.
References __attribute__, addr, vmbus_gpadl_created::channel, vmbus_device::channel, cpu_to_le16, cpu_to_le32, vmbus_message::created, data, DBGC, vmbus_device::dev, EPROTO, gpadl, vmbus_gpadl_created::gpadl, vmbus_device::hv, hv_pfn_count(), le32_to_cpu, len, memset(), vmbus::message, device::name, PAGE_SIZE, vmbus_gpa_range::pfn, range, rc, vmbus_gpadl_created::status, user_to_phys(), hv_hypervisor::vmbus, vmbus_gpadl, VMBUS_GPADL_CREATED, VMBUS_GPADL_HEADER, vmbus_post_message(), and vmbus_wait_for_message().
Referenced by netvsc_create_buffer(), and vmbus_open().
int vmbus_gpadl_teardown | ( | struct vmbus_device * | vmdev, |
unsigned int | gpadl | ||
) |
Tear down GPA descriptor list.
vmdev | VMBus device |
gpadl | GPADL ID |
rc | Return status code |
Definition at line 347 of file vmbus.c.
References vmbus_gpadl_teardown::channel, vmbus_device::channel, cpu_to_le32, DBGC, vmbus_device::dev, EPROTO, gpadl, vmbus_gpadl_teardown::gpadl, vmbus_gpadl_torndown::gpadl, vmbus_gpadl_teardown::header, vmbus_device::hv, le32_to_cpu, memset(), vmbus::message, device::name, rc, vmbus_message::torndown, vmbus_message_header::type, hv_hypervisor::vmbus, vmbus_gpadl_is_obsolete(), VMBUS_GPADL_TEARDOWN, VMBUS_GPADL_TORNDOWN, vmbus_post_message(), and vmbus_wait_for_message().
Referenced by netvsc_create_buffer(), and vmbus_open().
int vmbus_open | ( | struct vmbus_device * | vmdev, |
struct vmbus_channel_operations * | op, | ||
size_t | out_len, | ||
size_t | in_len, | ||
size_t | mtu | ||
) |
Open VMBus channel.
vmdev | VMBus device |
op | Channel operations |
out_len | Outbound ring buffer length |
in_len | Inbound ring buffer length |
mtu | Maximum expected data packet length (including headers) |
rc | Return status code |
Both outbound and inbound ring buffer lengths must be a power of two and a multiple of PAGE_SIZE. The requirement to be a power of two is a policy decision taken to simplify the ring buffer indexing logic.
Definition at line 403 of file vmbus.c.
References assert(), vmbus_open_channel_result::channel, vmbus_device::channel, cpu_to_le32, DBGC, vmbus_device::dev, ENOMEM, EPROTO, free, free_phys(), gpadl, vmbus_device::gpadl, vmbus_device::hv, vmbus_open_channel_result::id, vmbus_device::in, vmbus_device::in_len, le32_to_cpu, len, malloc(), malloc_phys(), memset(), vmbus::message, mtu, vmbus_device::mtu, device::name, op, vmbus_device::op, open(), vmbus_message::opened, vmbus_device::out, vmbus_device::out_len, vmbus_device::packet, PAGE_SIZE, random(), rc, vmbus_open_channel_result::status, virt_to_phys(), virt_to_user(), hv_hypervisor::vmbus, vmbus_establish_gpadl(), vmbus_gpadl_teardown(), VMBUS_OPEN_CHANNEL, VMBUS_OPEN_CHANNEL_RESULT, vmbus_post_message(), and vmbus_wait_for_message().
Referenced by netvsc_open().
void vmbus_close | ( | struct vmbus_device * | vmdev | ) |
Close VMBus channel.
vmdev | VMBus device |
Definition at line 524 of file vmbus.c.
References vmbus_device::channel, close, cpu_to_le32, DBGC, vmbus_device::dev, free, free_phys(), vmbus_device::gpadl, vmbus_device::hv, vmbus_device::in, vmbus_device::in_len, len, memset(), device::name, NULL, vmbus_device::out, vmbus_device::out_len, vmbus_device::packet, rc, strerror(), VMBUS_CLOSE_CHANNEL, and vmbus_post_message().
Referenced by netvsc_close(), and netvsc_open().
int vmbus_send_control | ( | struct vmbus_device * | vmdev, |
uint64_t | xid, | ||
const void * | data, | ||
size_t | len | ||
) |
Send control packet via ring buffer.
vmdev | VMBus device |
xid | Transaction ID (or zero to not request completion) |
data | Data |
len | Length of data |
rc | Return status code |
Send data using a VMBUS_DATA_INBAND packet.
Definition at line 765 of file vmbus.c.
References assert(), cpu_to_le16, data, ena_aq_header::flags, header, len, NULL, vmbus_device::packet, VMBUS_COMPLETION_REQUESTED, VMBUS_DATA_INBAND, vmbus_send(), and vmbus_packet_header::xid.
Referenced by netvsc_control().
int vmbus_send_data | ( | struct vmbus_device * | vmdev, |
uint64_t | xid, | ||
const void * | data, | ||
size_t | len, | ||
struct io_buffer * | iobuf | ||
) |
Send data packet via ring buffer.
vmdev | VMBus device |
xid | Transaction ID |
data | Data |
len | Length of data |
iobuf | I/O buffer |
rc | Return status code |
Send data using a VMBUS_DATA_GPA_DIRECT packet. The caller is responsible for ensuring that the I/O buffer remains untouched until the corresponding completion has been received.
Definition at line 794 of file vmbus.c.
References __attribute__, addr, assert(), cpu_to_le16, cpu_to_le32, data, io_buffer::data, ena_aq_header::flags, header, hv_pfn_count(), iob_len(), len, vmbus_device::mtu, NULL, vmbus_device::packet, PAGE_SIZE, vmbus_gpa_range::pfn, range, virt_to_phys(), VMBUS_COMPLETION_REQUESTED, VMBUS_DATA_GPA_DIRECT, and vmbus_send().
Referenced by netvsc_transmit().
int vmbus_send_completion | ( | struct vmbus_device * | vmdev, |
uint64_t | xid, | ||
const void * | data, | ||
size_t | len | ||
) |
Send completion packet via ring buffer.
vmdev | VMBus device |
xid | Transaction ID |
data | Data |
len | Length of data |
rc | Return status code |
Send data using a VMBUS_COMPLETION packet.
Definition at line 834 of file vmbus.c.
References assert(), cpu_to_le16, data, ena_aq_header::flags, header, len, NULL, vmbus_device::packet, VMBUS_COMPLETION, vmbus_send(), and vmbus_packet_header::xid.
Referenced by netvsc_recv_data().
int vmbus_send_cancellation | ( | struct vmbus_device * | vmdev, |
uint64_t | xid | ||
) |
Send cancellation packet via ring buffer.
vmdev | VMBus device |
xid | Transaction ID |
rc | Return status code |
Send data using a VMBUS_CANCELLATION packet.
Definition at line 857 of file vmbus.c.
References assert(), cpu_to_le16, ena_aq_header::flags, header, NULL, vmbus_device::packet, VMBUS_CANCELLATION, vmbus_send(), and vmbus_packet_header::xid.
Referenced by netvsc_cancel_transmit().
int vmbus_poll | ( | struct vmbus_device * | vmdev | ) |
Poll ring buffer.
vmdev | VMBus device |
rc | Return status code |
Definition at line 972 of file vmbus.c.
References assert(), cons, vmbus_ring::cons, cpu_to_le16, cpu_to_le32, data, DBGC, DBGC2, DBGC2_HDA, vmbus_device::dev, EINVAL, ENOTSUP, ERANGE, header, vmbus_device::in, vmbus_device::in_len, INIT_LIST_HEAD, le16_to_cpu, le32_to_cpu, le64_to_cpu, len, vmbus_device::mtu, device::name, NULL, vmbus_device::op, vmbus_device::packet, rc, vmbus_channel_operations::recv_cancellation, vmbus_channel_operations::recv_completion, vmbus_channel_operations::recv_control, vmbus_channel_operations::recv_data, rmb, strerror(), VMBUS_CANCELLATION, VMBUS_COMPLETION, vmbus_consume(), VMBUS_DATA_INBAND, VMBUS_DATA_XFER_PAGES, vmbus_has_data(), and vmbus_xfer_page_iobufs().
Referenced by netvsc_control(), and netvsc_poll().
void vmbus_dump_channel | ( | struct vmbus_device * | vmdev | ) |
Dump channel status (for debugging)
vmdev | VMBus device |
Definition at line 1089 of file vmbus.c.
References vmbus_ring::cons, vmbus_ring::data, DBGC, DBGC_HDA, vmbus_device::dev, first, vmbus_device::in, vmbus_device::in_len, vmbus_ring::intr_mask, le32_to_cpu, device::name, vmbus_device::out, vmbus_ring::prod, and second.
Referenced by netvsc_control().
int vmbus_probe | ( | struct hv_hypervisor * | hv, |
struct device * | parent | ||
) |
Probe Hyper-V virtual machine bus.
hv | Hyper-V hypervisor |
parent | Parent device |
rc | Return status code |
Definition at line 1365 of file vmbus.c.
References assert(), hv_message::data, ENOMEM, free, hv_alloc_pages(), hv_disable_sint(), hv_enable_sint(), hv_free_pages(), vmbus::intr, hv_hypervisor::message, vmbus::message, vmbus::monitor_in, vmbus::monitor_out, NULL, rc, hv_message_buffer::received, hv_hypervisor::vmbus, VMBUS_MESSAGE_SINT, vmbus_negotiate_version(), vmbus_probe_channels(), vmbus_remove_channels(), vmbus_unload(), and zalloc().
Referenced by hv_probe().
int vmbus_reset | ( | struct hv_hypervisor * | hv, |
struct device * | parent | ||
) |
Reset Hyper-V virtual machine bus.
hv | Hyper-V hypervisor |
parent | Parent device |
rc | Return status code |
Definition at line 1426 of file vmbus.c.
References hv_enable_sint(), vmbus::intr, memset(), vmbus::monitor_in, vmbus::monitor_out, PAGE_SIZE, rc, hv_hypervisor::vmbus, vmbus_gpadl, VMBUS_MESSAGE_SINT, vmbus_negotiate_version(), vmbus_obsolete_gpadl, and vmbus_reset_channels().
Referenced by hv_unquiesce().
void vmbus_remove | ( | struct hv_hypervisor * | hv, |
struct device * | parent | ||
) |
Remove Hyper-V virtual machine bus.
hv | Hyper-V hypervisor |
parent | Parent device |
Definition at line 1458 of file vmbus.c.
References free, hv_disable_sint(), hv_free_pages(), vmbus::intr, vmbus::monitor_in, vmbus::monitor_out, NULL, hv_hypervisor::vmbus, VMBUS_MESSAGE_SINT, vmbus_remove_channels(), and vmbus_unload().
Referenced by hv_probe(), and hv_remove().
unsigned int vmbus_obsolete_gpadl |
Obsolete GPADL ID threshold.
When the Hyper-V connection is reset, any previous GPADLs are automatically rendered obsolete.
Definition at line 61 of file vmbus.c.
Referenced by vmbus_gpadl_is_obsolete(), and vmbus_reset().