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

        let used_ring = self.used_ring;
        let next_used = (self.next_used.0 % self.actual_size()) as u64;
        let used_elem = used_ring.unchecked_add(4 + next_used * 8);
        let (_region, used_ring) = mem.to_region_addr(used_ring).unwrap();
        let (region, used_elem) = mem.to_region_addr(used_elem).unwrap();

        // These writes can't fail as we are guaranteed to be within the descriptor ring.
        region.write_obj(desc_index as u32, used_elem).unwrap();
        region.write_obj(len, used_elem.unchecked_add(4)).unwrap();

        self.next_used += Wrapping(1);

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

        region
            .write_obj(self.next_used.0, used_ring.unchecked_add(2))
            .unwrap();

        self.next_used.0
    }
/// 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) -> u16 {
        if desc_index >= self.actual_size() {
            panic!(
                "attempted to add out of bounds descriptor to used ring: {}",
                desc_index
            );
        }
        let used_ring = self.used_ring;
        let next_used = (self.next_used.0 % self.actual_size()) as u64;
        let used_elem = used_ring.unchecked_add(4 + next_used * 8);
        let (_region, used_ring) = mem.to_region_addr(used_ring).unwrap();
        let (region, used_elem) = mem.to_region_addr(used_elem).unwrap();
        // These writes can't fail as we are guaranteed to be within the descriptor ring.
        region.write_obj(desc_index as u32, used_elem).unwrap();
        region.write_obj(len, used_elem.unchecked_add(4)).unwrap();
        self.next_used += Wrapping(1);
        // This fence ensures all descriptor writes are visible before the index update is.
        fence(Ordering::Release);
        region
            .write_obj(self.next_used.0, used_ring.unchecked_add(2))
            .unwrap();
        self.next_used.0
    }
pub fn add_used ( & mut self , mem : & GuestMemoryMmap , desc_index : u16 , len : u32 ) -> u16 { if desc_index >= self . actual_size ( ) { panic ! ( " " desc_index ) ; } let used_ring = self . used_ring ; let next_used = ( self . next_used . 0 % self . actual_size ( ) ) as u64 ; let used_elem = used_ring . unchecked_add ( 4 + next_used * 8 ) ; let ( _region , used_ring ) = mem . to_region_addr ( used_ring ) . unwrap ( ) ; let ( region , used_elem ) = mem . to_region_addr ( used_elem ) . unwrap ( ) ; // These writes can't fail as we are guaranteed to be within the descriptor ring. region . write_obj ( desc_index as u32 , used_elem ) . unwrap ( ) ; region . write_obj ( len , used_elem . unchecked_add ( 4 ) ) . unwrap ( ) ; self . next_used += Wrapping ( 1 ) ; // This fence ensures all descriptor writes are visible before the index update is. fence ( Ordering :: Release ) ; region . write_obj ( self . next_used . 0 , used_ring . unchecked_add ( 2 ) ) . unwrap ( ) ; self . next_used . 0 }
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