Skip to main content

Mempool

Struct Mempool 

Source
pub struct Mempool { /* private fields */ }
Expand description

Memory pool for packet buffers

A mempool is a fixed-size pool of mbufs. All packet buffers in DPDK must be allocated from a mempool.

Implementations§

Source§

impl Mempool

Source

pub fn create( name: &str, n: u32, cache_size: u32, data_room_size: u16, socket_id: i32, ) -> DpdkResult<Self>

Create a new mempool for packet buffers

§Arguments
  • name - Unique name for this mempool (max 32 characters)
  • n - Number of elements in the pool
  • cache_size - Per-core cache size (0 to disable)
  • data_room_size - Size of data buffer in each mbuf
  • socket_id - NUMA socket ID (-1 for any)
§Errors

Returns an error if:

  • The name is empty or too long
  • The name contains null bytes
  • DPDK mempool creation fails (e.g., out of memory, invalid parameters)
Source

pub fn create_with_config( name: &str, config: &MempoolConfig, ) -> DpdkResult<Self>

Create a new mempool with configuration

§Arguments
  • name - Unique name for this mempool
  • config - Mempool configuration
Source

pub fn create_default(name: &str) -> DpdkResult<Self>

Create a mempool with default configuration

Source

pub fn name(&self) -> &str

Get the name of this mempool

Source

pub fn alloc(&self) -> DpdkResult<Mbuf>

Allocate an mbuf from this pool

Source

pub fn alloc_bulk(&self, count: usize) -> DpdkResult<Vec<Mbuf>>

Allocate multiple mbufs from this pool in a batch

This is more efficient than calling alloc() multiple times. Returns Ok with a vector of mbufs, or Err if allocation fails.

Source

pub fn available_count(&self) -> u32

Get the number of free elements in the pool

Source

pub fn in_use_count(&self) -> u32

Get the number of elements in use

Source

pub fn is_full(&self) -> bool

Check if the pool is full (all elements available)

Source

pub fn is_empty(&self) -> bool

Check if the pool is empty (no elements available)

Source

pub fn as_raw(&self) -> *mut rte_mempool

Get the raw pointer to the mempool

Trait Implementations§

Source§

impl Drop for Mempool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Mempool

Source§

impl Sync for Mempool

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.