Skip to content

Commit

Permalink
Merge pull request #140 from rcore-os/indirect_desc
Browse files Browse the repository at this point in the history
Support indirect descriptors in all drivers.
  • Loading branch information
qwandor authored Jun 12, 2024
2 parents 7c18b36 + 4349025 commit 3030297
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/device/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use core::ptr::NonNull;
const QUEUE_RECEIVEQ_PORT_0: u16 = 0;
const QUEUE_TRANSMITQ_PORT_0: u16 = 1;
const QUEUE_SIZE: usize = 2;
const SUPPORTED_FEATURES: Features = Features::RING_EVENT_IDX;
const SUPPORTED_FEATURES: Features = Features::RING_EVENT_IDX.union(Features::RING_INDIRECT_DESC);

/// Driver for a VirtIO console device.
///
Expand Down Expand Up @@ -82,13 +82,13 @@ impl<H: Hal, T: Transport> VirtIOConsole<H, T> {
let receiveq = VirtQueue::new(
&mut transport,
QUEUE_RECEIVEQ_PORT_0,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;
let transmitq = VirtQueue::new(
&mut transport,
QUEUE_TRANSMITQ_PORT_0,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;

Expand Down
6 changes: 3 additions & 3 deletions src/device/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::info;
use zerocopy::{AsBytes, FromBytes, FromZeroes};

const QUEUE_SIZE: u16 = 2;
const SUPPORTED_FEATURES: Features = Features::RING_EVENT_IDX;
const SUPPORTED_FEATURES: Features = Features::RING_EVENT_IDX.union(Features::RING_INDIRECT_DESC);

/// A virtio based graphics adapter.
///
Expand Down Expand Up @@ -56,13 +56,13 @@ impl<H: Hal, T: Transport> VirtIOGpu<H, T> {
let control_queue = VirtQueue::new(
&mut transport,
QUEUE_TRANSMIT,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;
let cursor_queue = VirtQueue::new(
&mut transport,
QUEUE_CURSOR,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;

Expand Down
6 changes: 3 additions & 3 deletions src/device/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ impl<H: Hal, T: Transport> VirtIOInput<H, T> {
let mut event_queue = VirtQueue::new(
&mut transport,
QUEUE_EVENT,
false,
negotiated_features.contains(Feature::RING_INDIRECT_DESC),
negotiated_features.contains(Feature::RING_EVENT_IDX),
)?;
let status_queue = VirtQueue::new(
&mut transport,
QUEUE_STATUS,
false,
negotiated_features.contains(Feature::RING_INDIRECT_DESC),
negotiated_features.contains(Feature::RING_EVENT_IDX),
)?;
for (i, event) in event_buf.as_mut().iter_mut().enumerate() {
Expand Down Expand Up @@ -209,7 +209,7 @@ pub struct InputEvent {

const QUEUE_EVENT: u16 = 0;
const QUEUE_STATUS: u16 = 1;
const SUPPORTED_FEATURES: Feature = Feature::RING_EVENT_IDX;
const SUPPORTED_FEATURES: Feature = Feature::RING_EVENT_IDX.union(Feature::RING_INDIRECT_DESC);

// a parameter that can change
const QUEUE_SIZE: usize = 32;
4 changes: 2 additions & 2 deletions src/device/net/dev_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONetRaw<H, T, QUEUE_SIZ
let send_queue = VirtQueue::new(
&mut transport,
QUEUE_TRANSMIT,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;
let recv_queue = VirtQueue::new(
&mut transport,
QUEUE_RECEIVE,
false,
negotiated_features.contains(Features::RING_INDIRECT_DESC),
negotiated_features.contains(Features::RING_EVENT_IDX),
)?;

Expand Down
3 changes: 2 additions & 1 deletion src/device/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,5 @@ const QUEUE_RECEIVE: u16 = 0;
const QUEUE_TRANSMIT: u16 = 1;
const SUPPORTED_FEATURES: Features = Features::MAC
.union(Features::STATUS)
.union(Features::RING_EVENT_IDX);
.union(Features::RING_EVENT_IDX)
.union(Features::RING_INDIRECT_DESC);
8 changes: 4 additions & 4 deletions src/device/socket/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) const TX_QUEUE_IDX: u16 = 1;
const EVENT_QUEUE_IDX: u16 = 2;

pub(crate) const QUEUE_SIZE: usize = 8;
const SUPPORTED_FEATURES: Feature = Feature::RING_EVENT_IDX;
const SUPPORTED_FEATURES: Feature = Feature::RING_EVENT_IDX.union(Feature::RING_INDIRECT_DESC);

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ConnectionInfo {
Expand Down Expand Up @@ -275,19 +275,19 @@ impl<H: Hal, T: Transport, const RX_BUFFER_SIZE: usize> VirtIOSocket<H, T, RX_BU
let mut rx = VirtQueue::new(
&mut transport,
RX_QUEUE_IDX,
false,
negotiated_features.contains(Feature::RING_INDIRECT_DESC),
negotiated_features.contains(Feature::RING_EVENT_IDX),
)?;
let tx = VirtQueue::new(
&mut transport,
TX_QUEUE_IDX,
false,
negotiated_features.contains(Feature::RING_INDIRECT_DESC),
negotiated_features.contains(Feature::RING_EVENT_IDX),
)?;
let event = VirtQueue::new(
&mut transport,
EVENT_QUEUE_IDX,
false,
negotiated_features.contains(Feature::RING_INDIRECT_DESC),
negotiated_features.contains(Feature::RING_EVENT_IDX),
)?;

Expand Down

0 comments on commit 3030297

Please sign in to comment.