pub struct Umem { /* private fields */ }
Expand description
A region of virtual contiguous memory divided into equal-sized
frames. It provides the underlying working memory for an AF_XDP
Socket
.
Implementations
sourceimpl Umem
impl Umem
sourcepub fn new(
config: UmemConfig,
frame_count: NonZeroU32,
use_huge_pages: bool
) -> Result<(Self, Vec<FrameDesc>), UmemCreateError>
pub fn new(
config: UmemConfig,
frame_count: NonZeroU32,
use_huge_pages: bool
) -> Result<(Self, Vec<FrameDesc>), UmemCreateError>
Create a new Umem
instance backed by an anonymous memory
mapped region.
Setting use_huge_pages
to true
will instructed mmap()
to
allocate the underlying memory using huge pages. If you are
getting errors as a result of this, check that the
HugePages_Total
setting is non-zero when you run cat /proc/meminfo
.
sourcepub unsafe fn frame(&self, desc: &FrameDesc) -> (Headroom<'_>, Data<'_>)
pub unsafe fn frame(&self, desc: &FrameDesc) -> (Headroom<'_>, Data<'_>)
The headroom and packet data segments of the Umem
frame
pointed at by desc
. Contents are read-only.
Safety
desc
must correspond to a frame belonging to this
Umem
. Passing the descriptor of another Umem
is very
likely to result in incorrect memory access, by either
straddling frames or accessing memory outside the underlying
Umem
area.
Furthermore, the memory region accessed must not be mutably
accessed anywhere else at the same time, either in userspace
or by the kernel. To ensure this, care should be taken not to
use the frame after submission to either the TxQueue
or
FillQueue
until received over the CompQueue
or
RxQueue
respectively.
sourcepub unsafe fn frame_mut<'a>(
&'a self,
desc: &'a mut FrameDesc
) -> (HeadroomMut<'a>, DataMut<'a>)
pub unsafe fn frame_mut<'a>(
&'a self,
desc: &'a mut FrameDesc
) -> (HeadroomMut<'a>, DataMut<'a>)
The headroom and packet data segments of the Umem
frame
pointed at by desc
. Contents are writeable.
Safety
desc
must correspond to a frame belonging to this
Umem
. Passing the descriptor of another Umem
is very
likely to result in incorrect memory access, by either
straddling frames or accessing memory outside the underlying
Umem
area.
Furthermore, the memory region accessed must not be mutably or
immutably accessed anywhere else at the same time, either in
userspace or by the kernel. To ensure this, care should be
taken not to use the frame after submission to either the
TxQueue
or FillQueue
until received over the
CompQueue
or RxQueue
respectively.
sourcepub unsafe fn headroom_mut<'a>(
&'a self,
desc: &'a mut FrameDesc
) -> HeadroomMut<'a>
pub unsafe fn headroom_mut<'a>(
&'a self,
desc: &'a mut FrameDesc
) -> HeadroomMut<'a>
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Umem
impl Send for Umem
impl Sync for Umem
impl Unpin for Umem
impl UnwindSafe for Umem
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more