src/virtio/queue.bend checks
raw source on the hub · import 0x2740e30df705f4fb9b9db637023eca00/src/virtio/queue.bend as Queue
5 imports
import Base import ../lib/u64.bend as U import ../lib/bytes.bend as B import ../vmm/abi.bend as V import ./mmio.bend as M
Types
type Desc source · line 18 · raw
Data
Desc@addr:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @len:U32 -> @flags:U32 -> @next:U32 -> Desc
type Chain source · line 23 · raw
Data
A descriptor chain: its head index, then the device-readable descriptors and the device-writable ones, each in chain order.
Chain@head:U32 -> @readable:List<&2, Desc> -> @writable:List<&2, Desc> -> Chain
type Vq source · line 28 · raw
Data
A queue as the device sees it: size, the three areas, and the next ring positions (both modulo 65536).
Vq@num:U32 -> @desc:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @driver:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @device:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @next_avail:U32 -> @next_used:U32 -> Vq
Definitions
def Chain.head source · line 31 · raw
@c:Chain -> U32
def Desc.is_eq source · line 36 · raw
@a:Desc -> @b:Desc -> Bool
def Desc.list_eq source · line 41 · raw
@xs:List<&2, Desc> -> @ys:List<&2, Desc> -> Bool
def Chain.is_eq source · line 50 · raw
@a:Chain -> @b:Chain -> Bool
def Chain.is_eq_maybe source · line 55 · raw
@a:Maybe<&2, Chain> -> @b:Maybe<&2, Chain> -> Bool
def Vq.is_eq source · line 64 · raw
@a:Vq -> @b:Vq -> Bool
def Vq.from_cfg source · line 72 · raw
@cfg:0x2740e30df705f4fb9b9db637023eca00/src/virtio/mmio.QueueCfg -> Vq
The queue of a transport's config; num is clamped to num_max (the transport already drops a larger QueueNum).
def Desc.parse source · line 78 · raw
@bs:List<&2, U32> -> Desc
Parses one 16-byte descriptor.
def Desc.f_next source · line 87 · raw
U32
Flag bits.
def Desc.f_write source · line 90 · raw
U32
def Desc.is_write source · line 93 · raw
@d:Desc -> Bool
def Vq.index source · line 99 · raw
@+i:U32 -> @num:U32 -> Maybe<&2, U32>
The index i, when it names a slot of a table of num descriptors.
def Desc.follow source · line 103 · raw
@d:Desc -> @num:U32 -> Maybe<&2, U32>
The descriptor the chain continues with, if d has NEXT and it is in range.
def Desc.add_readable source · line 109 · raw
@+d:Desc -> @+rd:List<&2, Desc> -> List<&2, Desc>
Prepends d to the readable list (reversed) unless it is device-writable.
def Desc.add_writable source · line 113 · raw
@+d:Desc -> @+wr:List<&2, Desc> -> List<&2, Desc>
Prepends d to the writable list (reversed) when it is device-writable.
def Vq.wrap source · line 117 · raw
@n:U32 -> U32
Index n modulo 65536, the width of the ring idx fields.
def Vq.walk source · line 122 · raw
@fuel:Nat -> @-R:Type -> @+num:U32 -> @+desc:0x2740e30df705f4fb9b9db637023eca00/src/lib/u64.U64 -> @cur:Maybe<&2, U32> -> @rd:List<&2, Desc> -> @wr:List<&2, Desc> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Pair(List<&2, Desc>, List<&2, Desc>)>
Walks a chain from descriptor cur, at most fuel descriptors; rd and wr
collect the readable and writable descriptors in reverse.
def Vq.pop.fin source · line 139 · raw
@q:Vq -> @head:U32 -> @ds:Pair(List<&2, Desc>, List<&2, Desc>) -> Pair(Vq, Maybe<&2, Chain>)
def Vq.pop.take source · line 145 · raw
@-R:Type -> @q:Vq -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Pair(Vq, Maybe<&2, Chain>)>
Reads the head of the chain at ring slot next_avail and walks it.
def Vq.pop.go source · line 155 · raw
@-R:Type -> @empty:Bool -> @q:Vq -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Pair(Vq, Maybe<&2, Chain>)>
def Vq.pop.avail source · line 162 · raw
@-R:Type -> @q:Vq -> @avail:U32 -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Pair(Vq, Maybe<&2, Chain>)>
def Vq.pop source · line 169 · raw
@-R:Type -> @q:Vq -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Pair(Vq, Maybe<&2, Chain>)>
Takes the next available chain, if the driver has published one.
def Vq.push.write source · line 177 · raw
@-R:Type -> @q:Vq -> @+head:U32 -> @+len:U32 -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Vq>
Writes the used element at ring slot next_used, then publishes the new idx.
def Vq.push.go source · line 188 · raw
@-R:Type -> @empty:Bool -> @q:Vq -> @head:U32 -> @len:U32 -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Vq>
def Vq.push source · line 196 · raw
@-R:Type -> @q:Vq -> @head:U32 -> @len:U32 -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, Vq>
Returns chain head to the driver as used, with len bytes written.
def Vq.read_desc source · line 201 · raw
@-R:Type -> @d:Desc -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>>
def Vq.cat source · line 206 · raw
@-R:Type -> @a:0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>> -> @b:0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>>
def Vq.gather.go source · line 214 · raw
@fuel:Nat -> @-R:Type -> @+n:Nat -> @ds:List<&2, Desc> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>>
Builds the reads of n descriptors: halves are independent, so they are built in parallel. fuel bounds the depth (n descriptors need at most n).
def Vq.gather source · line 231 · raw
@-R:Type -> @c:Chain -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>>
Gathers the bytes of every readable descriptor of a chain, in order.
def Vq.scatter.go source · line 239 · raw
@-R:Type -> @ds:List<&2, Desc> -> @bytes:List<&2, U32> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, U32>
Writes the head of bytes that fits d, then the rest over ds; answers the count written.
def Vq.scatter source · line 259 · raw
@-R:Type -> @c:Chain -> @bytes:List<&2, U32> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, U32>
Scatters bytes over the writable descriptors of a chain, in order, and answers how many bytes fit.
def Iov.add source · line 264 · raw
@+s:0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Iov -> @+ss:List<&2, 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Iov> -> List<&2, 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Iov>
def Vq.segs source · line 271 · raw
@ds:List<&2, Desc> -> @+skip:U32 -> @+max:U32 -> List<&2, 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Iov>
The memory of ds after its first skip bytes, at most max bytes of it, in chain order (empty pieces left out).
def Vq.read_segs source · line 282 · raw
@-R:Type -> @ss:List<&2, 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Iov> -> 0x2740e30df705f4fb9b9db637023eca00/src/vmm/abi.Op<R, List<&2, U32>>
Reads the pieces of guest memory, in order.