Skip to main content

Port

Struct Port 

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

A DPDK Ethernet port

Implementations§

Source§

impl Port

Source

pub fn count_available() -> u16

Get the number of available DPDK ports

Source

pub fn is_valid(port_id: u16) -> bool

Check if a port ID is valid

Source

pub fn init( port_id: u16, config: PortConfig, mempool: &Mempool, ) -> DpdkResult<Self>

Initialize a port with the given configuration

This will:

  1. Validate the port ID
  2. Get device info to check capabilities
  3. Configure the port
  4. Set up RX and TX queues
Source

pub fn new(port_id: u16) -> DpdkResult<Self>

Create a port handle without full initialization (for testing)

Source

pub fn capabilities(&self) -> &DeviceCapabilities

Get the device capabilities

Source

pub fn numa_node(&self) -> i32

Get the NUMA node of this NIC port.

Returns the NUMA socket ID where the NIC is attached. Use this to allocate mempools and pin lcores on the same NUMA node for optimal memory access latency.

Source

pub fn active_rx_offload(&self) -> u64

Get the active RX offload flags

Source

pub fn active_tx_offload(&self) -> u64

Get the active TX offload flags

Source

pub fn is_rx_offload_active(&self, offload: u64) -> bool

Check if a specific RX offload is active

Source

pub fn is_tx_offload_active(&self, offload: u64) -> bool

Check if a specific TX offload is active

Source

pub fn port_id(&self) -> u16

Get the port ID

Source

pub fn mac_address(&self) -> MacAddress

Get the MAC address of this port

Source

pub fn config(&self) -> &PortConfig

Get the port configuration

Source

pub fn is_started(&self) -> bool

Check if the port is started

Source

pub fn start(&mut self) -> DpdkResult<()>

Start the port

Source

pub fn stop(&mut self) -> DpdkResult<()>

Stop the port

Get link status

Source

pub fn stats(&self) -> DpdkResult<PortStats>

Get port statistics

Source

pub fn reset_stats(&self) -> DpdkResult<()>

Reset port statistics

Source

pub fn rx_burst(&self, queue_id: u16, max_packets: u16) -> DpdkResult<Vec<Mbuf>>

Receive a burst of packets from the specified queue

Returns a vector of received Mbufs. The maximum number of packets returned is limited by max_packets.

Source

pub fn tx_burst( &self, queue_id: u16, packets: &mut Vec<Mbuf>, ) -> DpdkResult<u16>

Transmit a burst of packets on the specified queue

Returns the number of packets successfully transmitted. Packets that are sent are consumed (freed) by the driver.

Source

pub fn set_promiscuous(&mut self, enable: bool) -> DpdkResult<()>

Enable promiscuous mode on the port

In promiscuous mode, the port receives all packets regardless of destination MAC address.

Source

pub fn is_promiscuous(&self) -> bool

Check if promiscuous mode is enabled

Source

pub fn set_allmulticast(&self, enable: bool) -> DpdkResult<()>

Enable all-multicast mode on the port

In all-multicast mode, the port receives all multicast packets regardless of whether they match configured multicast addresses.

Source

pub fn is_allmulticast(&self) -> bool

Check if all-multicast mode is enabled

Source

pub fn set_multicast_addrs(&self, addrs: &[MacAddress]) -> DpdkResult<()>

Set the list of multicast MAC addresses to receive

This configures the hardware multicast filter. Pass an empty slice to clear all multicast addresses.

Trait Implementations§

Source§

impl Drop for Port

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Port

§

impl RefUnwindSafe for Port

§

impl Send for Port

§

impl Sync for Port

§

impl Unpin for Port

§

impl UnsafeUnpin for Port

§

impl UnwindSafe for Port

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.