diff --git a/src/drivers/virtio/virtqueue/mod.rs b/src/drivers/virtio/virtqueue/mod.rs index 2bbe62193c..b90100d72b 100644 --- a/src/drivers/virtio/virtqueue/mod.rs +++ b/src/drivers/virtio/virtqueue/mod.rs @@ -129,7 +129,6 @@ pub trait Virtq: VirtqPrivate { /// /// * `TransferTokens` which hold an `await_queue` will be placed into /// these queues. - /// * All finished `TransferTokens` will have a state of `TransferState::Finished`. fn poll(&self); /// Dispatches a batch of transfer token. The buffers of the respective transfers are provided to the queue in @@ -280,7 +279,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Single { desc_lst: vec![desc].into_boxed_slice(), @@ -320,7 +318,6 @@ pub trait Virtq: VirtqPrivate { } Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Multiple { desc_lst: desc_lst.into_boxed_slice(), @@ -364,7 +361,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Indirect { desc_lst: desc_lst.into_boxed_slice(), @@ -400,7 +396,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: None, recv_buff: Some(Buffer::Single { @@ -440,7 +435,6 @@ pub trait Virtq: VirtqPrivate { } Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: None, recv_buff: Some(Buffer::Multiple { @@ -484,7 +478,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: None, recv_buff: Some(Buffer::Indirect { @@ -533,7 +526,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Single { desc_lst: vec![send_desc].into_boxed_slice(), @@ -591,7 +583,6 @@ pub trait Virtq: VirtqPrivate { } Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Single { desc_lst: vec![send_desc].into_boxed_slice(), @@ -659,7 +650,6 @@ pub trait Virtq: VirtqPrivate { } Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Multiple { desc_lst: send_desc_lst.into_boxed_slice(), @@ -717,7 +707,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { send_buff: Some(Buffer::Multiple { desc_lst: send_desc_lst.into_boxed_slice(), @@ -790,7 +779,6 @@ pub trait Virtq: VirtqPrivate { }; Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(BufferToken { recv_buff: Some(Buffer::Indirect { desc_lst: recv_desc_lst.into_boxed_slice(), @@ -1478,21 +1466,9 @@ pub trait AsSliceU8 { } } -/// Enum indicates the current state of a transfer. -#[derive(PartialEq, Copy, Clone, Debug)] -enum TransferState { - /// Queue finished transfer - Finished, - /// Transfer is ongoing and still processed by queue - Processing, - /// Transfer is ready to be sended - Ready, -} - /// The struct represents buffers which are ready to be send via the /// virtqueue. Buffers can no longer be written or retrieved. pub struct TransferToken { - state: TransferState, /// Must be some in order to prevent drop /// upon reuse. buff_tkn: Option, @@ -1538,8 +1514,7 @@ impl TransferToken { /// Dispatches the provided TransferToken to the respectuve queue and does /// return when, the queue finished the transfer. /// - /// The resultaing [TransferState] in this case is of course - /// finished and the returned [BufferToken] can be reused, copied from + /// The returned [BufferToken] can be reused, copied from /// or return the underlying buffers. /// /// **INFO:** @@ -2223,7 +2198,6 @@ impl BufferToken { } Ok(TransferToken { - state: TransferState::Ready, buff_tkn: Some(self), await_queue: None, }) @@ -2286,7 +2260,6 @@ impl BufferToken { /// After this call, the buffers are no longer writable. pub fn provide(self) -> TransferToken { TransferToken { - state: TransferState::Ready, buff_tkn: Some(self), await_queue: None, } diff --git a/src/drivers/virtio/virtqueue/packed.rs b/src/drivers/virtio/virtqueue/packed.rs index 884a2d3a5f..b82a17571a 100644 --- a/src/drivers/virtio/virtqueue/packed.rs +++ b/src/drivers/virtio/virtqueue/packed.rs @@ -20,8 +20,8 @@ use super::super::transport::mmio::{ComCfg, NotifCfg, NotifCtrl}; use super::super::transport::pci::{ComCfg, NotifCfg, NotifCtrl}; use super::error::VirtqError; use super::{ - BuffSpec, Buffer, BufferToken, Bytes, DescrFlags, MemDescr, MemPool, TransferState, - TransferToken, Virtq, VirtqPrivate, VqIndex, VqSize, + BuffSpec, Buffer, BufferToken, Bytes, DescrFlags, MemDescr, MemPool, TransferToken, Virtq, + VirtqPrivate, VqIndex, VqSize, }; use crate::arch::mm::paging::{BasePageSize, PageSize}; use crate::arch::mm::{paging, VirtAddr}; @@ -136,7 +136,6 @@ impl DescriptorRing { let mut ctrl = self.get_read_ctrler(); if let Some(mut tkn) = ctrl.poll_next() { - tkn.state = TransferState::Finished; if let Some(queue) = tkn.await_queue.take() { // Place the TransferToken in a Transfer, which will hold ownership of the token queue @@ -154,7 +153,7 @@ impl DescriptorRing { let mut first_ctrl_settings: (usize, u16, WrapCount) = (0, 0, WrapCount::new()); let mut first_buffer = None; - for (i, mut tkn) in tkn_lst.into_iter().enumerate() { + for (i, tkn) in tkn_lst.into_iter().enumerate() { // Check length and if its fits. This should always be true due to the restriction of // the memory pool, but to be sure. assert!(tkn.buff_tkn.as_ref().unwrap().num_consuming_descr() <= self.capacity); @@ -264,8 +263,6 @@ impl DescriptorRing { (None, None) => unreachable!("Empty Transfers are not allowed!"), // This should already be caught at creation of BufferToken } - tkn.state = TransferState::Processing; - if i == 0 { first_ctrl_settings = (ctrl.start, ctrl.buff_id, ctrl.wrap_at_init); first_buffer = Some(Box::new(tkn)); @@ -288,7 +285,7 @@ impl DescriptorRing { (first_ctrl_settings.0, first_ctrl_settings.2 .0 as u8) } - fn push(&mut self, mut tkn: TransferToken) -> (usize, u8) { + fn push(&mut self, tkn: TransferToken) -> (usize, u8) { // Check length and if its fits. This should always be true due to the restriction of // the memory pool, but to be sure. assert!(tkn.buff_tkn.as_ref().unwrap().num_consuming_descr() <= self.capacity); @@ -391,10 +388,6 @@ impl DescriptorRing { (None, None) => unreachable!("Empty Transfers are not allowed!"), // This should already be caught at creation of BufferToken } - fence(Ordering::SeqCst); - // Update the state of the actual Token - tkn.state = TransferState::Processing; - fence(Ordering::SeqCst); // Update flags of the first descriptor and set new write_index ctrl.make_avail(Box::new(tkn)); diff --git a/src/drivers/virtio/virtqueue/split.rs b/src/drivers/virtio/virtqueue/split.rs index e9699c801e..cf7825c44a 100644 --- a/src/drivers/virtio/virtqueue/split.rs +++ b/src/drivers/virtio/virtqueue/split.rs @@ -21,8 +21,8 @@ use super::super::transport::mmio::{ComCfg, NotifCfg, NotifCtrl}; use super::super::transport::pci::{ComCfg, NotifCfg, NotifCtrl}; use super::error::VirtqError; use super::{ - BuffSpec, BufferToken, Bytes, DescrFlags, MemDescr, MemPool, TransferState, TransferToken, - Virtq, VirtqPrivate, VqIndex, VqSize, + BuffSpec, BufferToken, Bytes, DescrFlags, MemDescr, MemPool, TransferToken, Virtq, + VirtqPrivate, VqIndex, VqSize, }; use crate::arch::memory_barrier; use crate::arch::mm::{paging, VirtAddr}; @@ -304,7 +304,6 @@ impl DescrRing { .restr_size(None, Some(used_elem.len.get() as usize)) .unwrap(); } - tkn.state = TransferState::Finished; if let Some(queue) = tkn.await_queue.take() { queue .borrow_mut()