STRUCT VIRTIO_MAP_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 πŸ‘€


xoxo, your kernel bestie πŸ’– source/version: ./include/linux, date: October 2026, page: struct virtio_map_ops(9) ✨

πŸ“¦ where this page comes from