pub fn add_used(
        &mut self,
        mem: &GuestMemoryMmap,
        desc_index: u16,
        len: u32,
    ) -> Result<(), QueueError> {
        if desc_index >= self.actual_size() {
            error!(
                "attempted to add out of bounds descriptor to used ring: {}",
                desc_index
            );
            return Err(QueueError::DescIndexOutOfBounds(desc_index));
        }

        let used_ring = self.used_ring;
        let next_used = u64::from(self.next_used.0 % self.actual_size());
        let used_elem = used_ring.unchecked_add(4 + next_used * 8);

        mem.write_obj(u32::from(desc_index), used_elem)
            .map_err(QueueError::UsedRing)?;

        let len_addr = used_elem.unchecked_add(4);
        mem.write_obj(len as u32, len_addr)
            .map_err(QueueError::UsedRing)?;

        self.num_added += Wrapping(1);
        self.next_used += Wrapping(1);

        // This fence ensures all descriptor writes are visible before the index update is.
        fence(Ordering::Release);

        let next_used_addr = used_ring.unchecked_add(2);
        mem.write_obj(self.next_used.0 as u16, next_used_addr)
            .map_err(QueueError::UsedRing)
    }
/// Puts an available descriptor head into the used ring for use by the guest.
Puts an available descriptor head into the used ring for use by the guest.
Puts an available descriptor head into the used ring for use by the guest .
pub fn add_used(
        &mut self,
        mem: &GuestMemoryMmap,
        desc_index: u16,
        len: u32,
    ) -> Result<(), QueueError> {
        if desc_index >= self.actual_size() {
            error!(
                "attempted to add out of bounds descriptor to used ring: {}",
                desc_index
            );
            return Err(QueueError::DescIndexOutOfBounds(desc_index));
        }
        let used_ring = self.used_ring;
        let next_used = u64::from(self.next_used.0 % self.actual_size());
        let used_elem = used_ring.unchecked_add(4 + next_used * 8);
        mem.write_obj(u32::from(desc_index), used_elem)
            .map_err(QueueError::UsedRing)?;
        let len_addr = used_elem.unchecked_add(4);
        mem.write_obj(len as u32, len_addr)
            .map_err(QueueError::UsedRing)?;
        self.num_added += Wrapping(1);
        self.next_used += Wrapping(1);
        // This fence ensures all descriptor writes are visible before the index update is.
        fence(Ordering::Release);
        let next_used_addr = used_ring.unchecked_add(2);
        mem.write_obj(self.next_used.0 as u16, next_used_addr)
            .map_err(QueueError::UsedRing)
    }
pub fn add_used ( & mut self , mem : & GuestMemoryMmap , desc_index : u16 , len : u32 , ) -> Result < ( ) , QueueError > { if desc_index >= self . actual_size ( ) { error ! ( " " desc_index ) ; return Err ( QueueError :: DescIndexOutOfBounds ( desc_index ) ) ; } let used_ring = self . used_ring ; let next_used = u64 :: from ( self . next_used . 0 % self . actual_size ( ) ) ; let used_elem = used_ring . unchecked_add ( 4 + next_used * 8 ) ; mem . write_obj ( u32 :: from ( desc_index ) , used_elem ) . map_err ( QueueError :: UsedRing ) ? ; let len_addr = used_elem . unchecked_add ( 4 ) ; mem . write_obj ( len as u32 , len_addr ) . map_err ( QueueError :: UsedRing ) ? ; self . num_added += Wrapping ( 1 ) ; self . next_used += Wrapping ( 1 ) ; // This fence ensures all descriptor writes are visible before the index update is. fence ( Ordering :: Release ) ; let next_used_addr = used_ring . unchecked_add ( 2 ) ; mem . write_obj ( self . next_used . 0 as u16 , next_used_addr ) . map_err ( QueueError :: UsedRing ) }
Puts an available descriptor head into the used ring for use by the guest.
Puts an available descriptor head into the used ring for use by the guest .
&mut self
mem
&GuestMemoryMmap
desc_index
u16
len
u32
&mut self
mem
&GuestMemoryMmap
desc_index
u16
len
u32