morpheus_network::dma::region

Struct DmaRegion

Source
pub struct DmaRegion {
    pub cpu_ptr: *mut u8,
    pub bus_addr: u64,
    pub size: usize,
}
Expand description

DMA-capable memory region.

Contains both the CPU-accessible pointer and the device-visible bus address.

Fields§

§cpu_ptr: *mut u8

CPU-accessible pointer to the region.

§bus_addr: u64

Device-visible bus address.

§size: usize

Total size of the region in bytes.

Implementations§

Source§

impl DmaRegion

Source

pub const MIN_SIZE: usize = 2_097_152usize

Minimum region size (2MB).

Source

pub const DEFAULT_QUEUE_SIZE: usize = 32usize

Default queue size (number of descriptors).

Source

pub const DEFAULT_BUFFER_SIZE: usize = 2_048usize

Default buffer size (2KB each).

Source

pub const RX_DESC_OFFSET: usize = 0usize

RX descriptor table offset.

Source

pub const RX_AVAIL_OFFSET: usize = 512usize

RX available ring offset.

Source

pub const RX_USED_OFFSET: usize = 1_024usize

RX used ring offset.

Source

pub const TX_DESC_OFFSET: usize = 2_048usize

TX descriptor table offset.

Source

pub const TX_AVAIL_OFFSET: usize = 2_560usize

TX available ring offset.

Source

pub const TX_USED_OFFSET: usize = 3_072usize

TX used ring offset.

Source

pub const RX_BUFFERS_OFFSET: usize = 4_096usize

RX buffers offset.

Source

pub const TX_BUFFERS_OFFSET: usize = 69_632usize

TX buffers offset.

Source

pub unsafe fn new(cpu_ptr: *mut u8, bus_addr: u64, size: usize) -> Self

Create a new DMA region.

§Safety
  • cpu_ptr must point to valid DMA-capable memory
  • bus_addr must be the corresponding device-visible address
  • Region must be properly aligned (page-aligned preferred)
Source

pub fn cpu_base(&self) -> *mut u8

Get CPU base pointer.

Source

pub fn bus_base(&self) -> u64

Get bus base address.

Source

pub fn size(&self) -> usize

Get total size.

Source

pub fn rx_desc_cpu(&self) -> *mut u8

Get CPU pointer for RX descriptor table.

Source

pub fn rx_desc_bus(&self) -> u64

Get bus address for RX descriptor table.

Source

pub fn rx_avail_cpu(&self) -> *mut u8

Get CPU pointer for RX available ring.

Source

pub fn rx_avail_bus(&self) -> u64

Get bus address for RX available ring.

Source

pub fn rx_used_cpu(&self) -> *mut u8

Get CPU pointer for RX used ring.

Source

pub fn rx_used_bus(&self) -> u64

Get bus address for RX used ring.

Source

pub fn tx_desc_cpu(&self) -> *mut u8

Get CPU pointer for TX descriptor table.

Source

pub fn tx_desc_bus(&self) -> u64

Get bus address for TX descriptor table.

Source

pub fn tx_avail_cpu(&self) -> *mut u8

Get CPU pointer for TX available ring.

Source

pub fn tx_avail_bus(&self) -> u64

Get bus address for TX available ring.

Source

pub fn tx_used_cpu(&self) -> *mut u8

Get CPU pointer for TX used ring.

Source

pub fn tx_used_bus(&self) -> u64

Get bus address for TX used ring.

Source

pub fn rx_buffers_cpu(&self) -> *mut u8

Get CPU pointer for RX buffers.

Source

pub fn rx_buffers_bus(&self) -> u64

Get bus address for RX buffers.

Source

pub fn tx_buffers_cpu(&self) -> *mut u8

Get CPU pointer for TX buffers.

Source

pub fn tx_buffers_bus(&self) -> u64

Get bus address for TX buffers.

Source

pub fn buffer_cpu( &self, offset: usize, index: usize, buffer_size: usize, ) -> *mut u8

Calculate buffer address by index.

Source

pub fn buffer_bus(&self, offset: usize, index: usize, buffer_size: usize) -> u64

Calculate buffer bus address by index.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.