STRUCT VIRTIO_MAP_OPS(9)
π NAME π
okay bestie, welcome to struct virtio_map_ops(9) from the Kernel API Manual β itβs literally the operations for mapping a buffer for a virtio device. No cap, this is the plug. β¨
β¨ SYNOPSIS β¨
hereβs the whole struct, exactly as printed β do not come for me, Iβm just the messenger π«Ά
struct virtio_map_ops {
dma_addr_t (*map_page)(union virtio_map map, struct page *page,
unsigned long offset, size_t size, enum dma_data_direction dir, unsigned
long attrs);
void (*unmap_page)(union virtio_map map, dma_addr_t map_handle,
size_t size, enum dma_data_direction dir, unsigned long attrs);
void (*sync_single_for_cpu)(union virtio_map map, dma_addr_t
map_handle, size_t size, enum dma_data_direction dir);
void (*sync_single_for_device)(union virtio_map map, dma_addr_t
map_handle, size_t size, enum dma_data_direction dir);
void *(*alloc)(union virtio_map map, size_t size, dma_addr_t
*map_handle, gfp_t gfp);
void (*free)(union virtio_map map, size_t size, void *vaddr,
dma_addr_t map_handle, unsigned long attrs);
bool (*need_sync)(union virtio_map map, dma_addr_t map_handle);
int (*mapping_error)(union virtio_map map, dma_addr_t map_handle);
size_t (*max_mapping_size)(union virtio_map map);
};
π«Ά Members π«Ά
map_pageβ maps a buffer to the device.map= metadata for performing mapping;page= the page that will be mapped by the device;offset= the offset in the page for a buffer;size= the buffer size;dir= mapping direction;attrs= mapping attributes. Returns the mapped address. slay πunmap_pageβ unmaps a buffer from the device.map= device specific mapping map;map_handle= the mapped address;size= the buffer size;dir= mapping direction;attrs= unmapping attributes. bye-bye buffer πsync_single_for_cpuβ syncs a single buffer from device to cpu.map= metadata for performing mapping;map_handle= the mapping address to sync;size= the size of the buffer;dir= synchronization direction. keep it fresh β¨sync_single_for_deviceβ syncs a single buffer from cpu to device.map= metadata for performing mapping;map_handle= the mapping address to sync;size= the size of the buffer;dir= synchronization direction. sending it back π«‘allocβ allocs a coherent buffer mapping.map= metadata for performing mapping;size= the size of the buffer;map_handle= the mapping address to sync;gfp= allocation flag (GFP_XXX). Returns virtual address of the allocated buffer. iconic allocation moment πfreeβ frees a coherent buffer mapping.map= metadata for performing mapping;size= the size of the buffer;vaddr= virtual address of the buffer;map_handle= the mapping address that needs to be freed;attrs= unmapping attributes. release her πneed_syncβ if the buffer needs synchronization.map= metadata for performing mapping;map_handle= the mapped address. Returns whether the buffer needs synchronization. vibe check π¦mapping_errorβ if the mapping address is error.map= metadata for performing mapping;map_handle= the mapped address. not the error era πmax_mapping_sizeβ gets the maximum buffer size that can be mapped.map= metadata for performing mapping. Returns the maximum buffer size that can be mapped. big energy, but make it bounded π
π Note π
bestie, listen: for a transport that has its own mapping logic, it must implement all of the operations. all of them. no skipping, no picking favorites. periodt. π
π SEE ALSO π
- Kernel file
./include/linux/virtio_config.h struct virtqueue_info(9)struct virtio_config_ops(9)__virtio_test_bit(9)__virtio_set_bit(9)__virtio_clear_bit(9)virtio_has_feature(9)virtio_has_dma_quirk(9)virtio_synchronize_cbs(9)virtio_device_ready(9)virtqueue_set_affinity(9)
xoxo, your kernel bestie π source/version: ./include/linux, date: October 2026, page: struct virtio_map_ops(9) β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms