used_element.go 673 B

123456789101112131415161718192021
  1. package virtqueue
  2. // usedElementSize is the number of bytes needed to store a [UsedElement] in
  3. // memory.
  4. const usedElementSize = 8
  5. // UsedElement is an element of the [UsedRing] and describes a descriptor chain
  6. // that was used by the device.
  7. type UsedElement struct {
  8. // DescriptorIndex is the index of the head of the used descriptor chain in
  9. // the [DescriptorTable].
  10. // The index is 32-bit here for padding reasons.
  11. DescriptorIndex uint32
  12. // Length is the number of bytes written into the device writable portion of
  13. // the buffer described by the descriptor chain.
  14. Length uint32
  15. }
  16. func (u *UsedElement) GetHead() uint16 {
  17. return uint16(u.DescriptorIndex)
  18. }