drivers/misc/vmw_vmci/vmci_queue_pair.c
Source file repositories/reference/linux-study-clean/drivers/misc/vmw_vmci/vmci_queue_pair.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/vmw_vmci/vmci_queue_pair.c- Extension
.c- Size
- 91972 bytes
- Lines
- 3147
- Domain
- Driver Families
- Bucket
- drivers/misc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/vmw_vmci_defs.hlinux/vmw_vmci_api.hlinux/highmem.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/mutex.hlinux/pagemap.hlinux/pci.hlinux/sched.hlinux/slab.hlinux/uio.hlinux/wait.hlinux/vmalloc.hlinux/skbuff.hvmci_handle_array.hvmci_queue_pair.hvmci_datagram.hvmci_resource.hvmci_context.hvmci_driver.hvmci_event.hvmci_route.h
Detected Declarations
struct vmci_queue_kern_ifstruct vmci_qpstruct qp_entrystruct qp_broker_entrystruct qp_guest_endpointstruct qp_listenum qp_broker_statefunction DIV_ROUND_UPfunction kmap_local_pagefunction kmap_local_pagefunction queuesfunction qp_free_ppn_setfunction qp_populate_ppn_setfunction queuefunction qp_init_queue_mutexfunction qp_cleanup_queue_mutexfunction qp_acquire_queue_mutexfunction qp_release_queue_mutexfunction qp_release_pagesfunction qp_host_get_user_memoryfunction qp_host_register_user_memoryfunction qp_host_unregister_user_memoryfunction qp_host_map_queuesfunction qp_host_unmap_queuesfunction list_for_each_entryfunction qp_guest_handle_to_entryfunction qp_broker_handle_to_entryfunction qp_notify_peer_localfunction ridfunction qp_guest_endpoint_destroyfunction qp_alloc_hypercallfunction qp_detatch_hypercallfunction qp_list_add_entryfunction qp_list_remove_entryfunction qp_detatch_guest_workfunction qp_alloc_guest_workfunction idfunction qp_broker_createfunction qp_notify_peerfunction qp_broker_attachfunction qp_broker_allocfunction qp_alloc_host_workfunction vmci_qp_allocfunction qp_detatch_host_workfunction qp_detatchfunction vmci_qp_broker_exitfunction vmci_qp_broker_allocfunction vmci_qp_broker_set_page_store
Annotated Snippet
struct vmci_queue_kern_if {
struct mutex __mutex; /* Protects the queue. */
struct mutex *mutex; /* Shared by producer and consumer queues. */
size_t num_pages; /* Number of pages incl. header. */
bool host; /* Host or guest? */
union {
struct {
dma_addr_t *pas;
void **vas;
} g; /* Used by the guest. */
struct {
struct page **page;
struct page **header_page;
} h; /* Used by the host. */
} u;
};
/*
* This structure is opaque to the clients.
*/
struct vmci_qp {
struct vmci_handle handle;
struct vmci_queue *produce_q;
struct vmci_queue *consume_q;
u64 produce_q_size;
u64 consume_q_size;
u32 peer;
u32 flags;
u32 priv_flags;
bool guest_endpoint;
unsigned int blocked;
unsigned int generation;
wait_queue_head_t event;
};
enum qp_broker_state {
VMCIQPB_NEW,
VMCIQPB_CREATED_NO_MEM,
VMCIQPB_CREATED_MEM,
VMCIQPB_ATTACHED_NO_MEM,
VMCIQPB_ATTACHED_MEM,
VMCIQPB_SHUTDOWN_NO_MEM,
VMCIQPB_SHUTDOWN_MEM,
VMCIQPB_GONE
};
#define QPBROKERSTATE_HAS_MEM(_qpb) (_qpb->state == VMCIQPB_CREATED_MEM || \
_qpb->state == VMCIQPB_ATTACHED_MEM || \
_qpb->state == VMCIQPB_SHUTDOWN_MEM)
/*
* In the queue pair broker, we always use the guest point of view for
* the produce and consume queue values and references, e.g., the
* produce queue size stored is the guests produce queue size. The
* host endpoint will need to swap these around. The only exception is
* the local queue pairs on the host, in which case the host endpoint
* that creates the queue pair will have the right orientation, and
* the attaching host endpoint will need to swap.
*/
struct qp_entry {
struct list_head list_item;
struct vmci_handle handle;
u32 peer;
u32 flags;
u64 produce_size;
u64 consume_size;
u32 ref_count;
};
struct qp_broker_entry {
struct vmci_resource resource;
struct qp_entry qp;
u32 create_id;
u32 attach_id;
enum qp_broker_state state;
bool require_trusted_attach;
bool created_by_trusted;
bool vmci_page_files; /* Created by VMX using VMCI page files */
struct vmci_queue *produce_q;
struct vmci_queue *consume_q;
struct vmci_queue_header saved_produce_q;
struct vmci_queue_header saved_consume_q;
vmci_event_release_cb wakeup_cb;
void *client_data;
void *local_mem; /* Kernel memory for local queue pair */
};
struct qp_guest_endpoint {
struct vmci_resource resource;
struct qp_entry qp;
Annotation
- Immediate include surface: `linux/vmw_vmci_defs.h`, `linux/vmw_vmci_api.h`, `linux/highmem.h`, `linux/kernel.h`, `linux/mm.h`, `linux/module.h`, `linux/mutex.h`, `linux/pagemap.h`.
- Detected declarations: `struct vmci_queue_kern_if`, `struct vmci_qp`, `struct qp_entry`, `struct qp_broker_entry`, `struct qp_guest_endpoint`, `struct qp_list`, `enum qp_broker_state`, `function DIV_ROUND_UP`, `function kmap_local_page`, `function kmap_local_page`.
- Atlas domain: Driver Families / drivers/misc.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.