[][src]Struct xsk_rs::Umem

pub struct Umem<'a> { /* fields omitted */ }

A region of virtual contiguous memory divided into equal-sized frames. It provides the underlying working memory for an AF_XDP socket.

Implementations

impl Umem<'_>[src]

pub fn builder(config: Config) -> UmemBuilder[src]

pub fn config(&self) -> &Config[src]

Config used for building the UMEM.

pub fn mtu(&self) -> usize[src]

The maximum transmission unit, this determines the largest packet that may be sent.

Equal to frame_size - (XDP_PACKET_HEADROOM + frame_headroom).

pub fn is_access_valid(
    &self,
    addr: &usize,
    len: &usize
) -> Result<(), AccessError>
[src]

Check if trying to access the UMEM region bound by [addr, addr + len] makes sense.

pub fn is_data_valid(&self, data: &[u8]) -> Result<(), DataError>[src]

Check if data is ok to write to the UMEM for transmission.

pub unsafe fn read_from_umem(&self, addr: &usize, len: &usize) -> &[u8][src]

Return a reference to the UMEM region starting at addr of length len.

This does not check that the region accessed makes sense and may cause undefined behaviour if used improperly. An example of potential misuse is referencing a region that extends beyond the end of the UMEM.

Apart from the memory considerations, this function is also unsafe as there is no guarantee the kernel isn't also reading from or writing to the same region.

pub unsafe fn read_from_umem_checked(
    &self,
    addr: &usize,
    len: &usize
) -> Result<&[u8], AccessError>
[src]

Checked version of umem_region_ref. Ensures that the referenced region is contained within a single frame of the UMEM.

pub unsafe fn write_to_umem(
    &mut self,
    frame_desc: &mut FrameDesc<'_>,
    data: &[u8]
)
[src]

Copy data to the region starting at frame_desc.addr, and set frame_desc.len when done.

This does no checking that the region written to makes sense and may cause undefined behaviour if used improperly. An example of potential misuse is writing beyond the end of the UMEM, or if data is large then potentially writing across frame boundaries.

Apart from the considerations around writing to memory, this function is also unsafe as there is no guarantee the kernel isn't also reading from or writing to the same region.

pub unsafe fn write_to_umem_checked(
    &mut self,
    frame_desc: &mut FrameDesc<'_>,
    data: &[u8]
) -> Result<(), WriteError>
[src]

Checked version of write_to_umem_frame. Ensures that a successful write is completely contained within a single frame of the UMEM.

pub unsafe fn umem_region_mut(&mut self, addr: &usize, len: &usize) -> &mut [u8][src]

Return a reference to the UMEM region starting at addr of length len.

This does not check that the region accessed makes sense and may cause undefined behaviour if used improperly. An example of potential misuse is referencing a region that extends beyond the end of the UMEM.

Apart from the memory considerations, this function is also unsafe as there is no guarantee the kernel isn't also reading from or writing to the same region.

If data is written to a frame, the length on the corresponding FrameDesc for addr must be updated before submitting to the TxQueue. This ensures the correct number of bytes are sent. Use write_to_umem or write_to_umem_checked to avoid the overhead of updating the frame descriptor.

pub unsafe fn umem_region_mut_checked(
    &mut self,
    addr: &usize,
    len: &usize
) -> Result<&mut [u8], AccessError>
[src]

Checked version of umem_region_mut. Ensures the requested region lies within a single frame.

Trait Implementations

impl Drop for Umem<'_>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Umem<'a>[src]

impl<'a> Send for Umem<'a>[src]

impl<'a> !Sync for Umem<'a>[src]

impl<'a> Unpin for Umem<'a>[src]

impl<'a> UnwindSafe for Umem<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.