[−][src]Struct xsk_rs::Umem
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]
&self,
addr: &usize,
len: &usize
) -> Result<(), AccessError>
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]
&self,
addr: &usize,
len: &usize
) -> Result<&[u8], AccessError>
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]
&mut self,
frame_desc: &mut FrameDesc<'_>,
data: &[u8]
)
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]
&mut self,
frame_desc: &mut FrameDesc<'_>,
data: &[u8]
) -> Result<(), WriteError>
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]
&mut self,
addr: &usize,
len: &usize
) -> Result<&mut [u8], AccessError>
Checked version of umem_region_mut
. Ensures the requested
region lies within a single frame.
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,