pub struct Port { /* private fields */ }Expand description
A DPDK Ethernet port
Implementations§
Source§impl Port
impl Port
Sourcepub fn count_available() -> u16
pub fn count_available() -> u16
Get the number of available DPDK ports
Sourcepub fn init(
port_id: u16,
config: PortConfig,
mempool: &Mempool,
) -> DpdkResult<Self>
pub fn init( port_id: u16, config: PortConfig, mempool: &Mempool, ) -> DpdkResult<Self>
Initialize a port with the given configuration
This will:
- Validate the port ID
- Get device info to check capabilities
- Configure the port
- Set up RX and TX queues
Sourcepub fn new(port_id: u16) -> DpdkResult<Self>
pub fn new(port_id: u16) -> DpdkResult<Self>
Create a port handle without full initialization (for testing)
Sourcepub fn capabilities(&self) -> &DeviceCapabilities
pub fn capabilities(&self) -> &DeviceCapabilities
Get the device capabilities
Sourcepub fn numa_node(&self) -> i32
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.
Sourcepub fn active_rx_offload(&self) -> u64
pub fn active_rx_offload(&self) -> u64
Get the active RX offload flags
Sourcepub fn active_tx_offload(&self) -> u64
pub fn active_tx_offload(&self) -> u64
Get the active TX offload flags
Sourcepub fn is_rx_offload_active(&self, offload: u64) -> bool
pub fn is_rx_offload_active(&self, offload: u64) -> bool
Check if a specific RX offload is active
Sourcepub fn is_tx_offload_active(&self, offload: u64) -> bool
pub fn is_tx_offload_active(&self, offload: u64) -> bool
Check if a specific TX offload is active
Sourcepub fn mac_address(&self) -> MacAddress
pub fn mac_address(&self) -> MacAddress
Get the MAC address of this port
Sourcepub fn config(&self) -> &PortConfig
pub fn config(&self) -> &PortConfig
Get the port configuration
Sourcepub fn is_started(&self) -> bool
pub fn is_started(&self) -> bool
Check if the port is started
Sourcepub fn start(&mut self) -> DpdkResult<()>
pub fn start(&mut self) -> DpdkResult<()>
Start the port
Sourcepub fn stop(&mut self) -> DpdkResult<()>
pub fn stop(&mut self) -> DpdkResult<()>
Stop the port
Sourcepub fn link_status(&self) -> LinkStatus
pub fn link_status(&self) -> LinkStatus
Get link status
Sourcepub fn stats(&self) -> DpdkResult<PortStats>
pub fn stats(&self) -> DpdkResult<PortStats>
Get port statistics
Sourcepub fn reset_stats(&self) -> DpdkResult<()>
pub fn reset_stats(&self) -> DpdkResult<()>
Reset port statistics
Sourcepub fn rx_burst(&self, queue_id: u16, max_packets: u16) -> DpdkResult<Vec<Mbuf>>
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.
Sourcepub fn tx_burst(
&self,
queue_id: u16,
packets: &mut Vec<Mbuf>,
) -> DpdkResult<u16>
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.
Sourcepub fn set_promiscuous(&mut self, enable: bool) -> DpdkResult<()>
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.
Sourcepub fn is_promiscuous(&self) -> bool
pub fn is_promiscuous(&self) -> bool
Check if promiscuous mode is enabled
Sourcepub fn set_allmulticast(&self, enable: bool) -> DpdkResult<()>
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.
Sourcepub fn is_allmulticast(&self) -> bool
pub fn is_allmulticast(&self) -> bool
Check if all-multicast mode is enabled
Sourcepub fn set_multicast_addrs(&self, addrs: &[MacAddress]) -> DpdkResult<()>
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.