ethdev

package
v0.1.1-r1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package ethdev wraps RTE Ethernet Device API.

Please refer to DPDK Programmer's Guide for reference and caveats.

Index

Constants

View Source
const (
	// Disable flow control.
	FcNone uint32 = C.RTE_ETH_FC_NONE
	// RX pause frame, enable flowctrl on TX side.
	FcRxPause uint32 = C.RTE_ETH_FC_RX_PAUSE
	// TX pause frame, enable flowctrl on RX side.
	FcTxPause uint32 = C.RTE_ETH_FC_TX_PAUSE
	// Enable flow control on both side.
	FcFull uint32 = C.RTE_ETH_FC_FULL
)

This enum indicates the flow control mode.

Variables

This section is empty.

Functions

func CountAvail

func CountAvail() int

CountAvail gets the number of ports which are usable for the application.

These devices must be iterated by using the macro RTE_ETH_FOREACH_DEV or RTE_ETH_FOREACH_DEV_OWNED_BY to deal with non-contiguous ranges of devices.

func CountTotal

func CountTotal() int

CountTotal gets the total number of ports which are allocated.

Some devices may not be available for the application.

func RegisterTelemetryLSC

func RegisterTelemetryLSC(name string)

RegisterTelemetryLSC registers telemetry handlers for accessing LSC counters.

func TxBufferSize

func TxBufferSize(mbufCnt int) uintptr

TxBufferSize is the occupied memory for TxBuffer of length mbufCnt.

Types

type DevFlags

type DevFlags uint32

DevFlags represent the value of dev_flags member of rte_eth_dev_info struct.

func (DevFlags) IsIntrLSC

func (f DevFlags) IsIntrLSC() bool

IsIntrLSC tells if the device supports link status change interrupt.

type DevInfo

type DevInfo C.struct_rte_eth_dev_info

DevInfo is a structure used to retrieve the contextual information of an Ethernet device, such as the controlling driver of the device, etc...

func (*DevInfo) DevFlags

func (info *DevInfo) DevFlags() DevFlags

DevFlags acquires device capability flags from DevInfo.

func (*DevInfo) DriverName

func (info *DevInfo) DriverName() string

DriverName returns driver_name as a Go string.

func (*DevInfo) InterfaceName

func (info *DevInfo) InterfaceName() string

InterfaceName is the name of the interface in the system.

func (*DevInfo) MaxMTU

func (info *DevInfo) MaxMTU() uint16

MaxMTU returns maximum MTU allowed.

func (*DevInfo) MaxRxPktLen

func (info *DevInfo) MaxRxPktLen() uint32

MaxRxPktLen returns maximum configurable length of Rx pkt.

func (*DevInfo) MaxRxQueues

func (info *DevInfo) MaxRxQueues() uint16

MaxRxQueues returns maximum number of Rx queues.

func (*DevInfo) MaxTxQueues

func (info *DevInfo) MaxTxQueues() uint16

MaxTxQueues returns maximum number of Tx queues.

func (*DevInfo) MinMTU

func (info *DevInfo) MinMTU() uint16

MinMTU returns minimum MTU allowed.

func (*DevInfo) MinRxBufSize

func (info *DevInfo) MinRxBufSize() uint32

MinRxBufSize returns minimum Rx buffer size per descriptor supported by HW.

func (*DevInfo) NbRxQueues

func (info *DevInfo) NbRxQueues() uint16

NbRxQueues returns number of configured RX queues for the device.

func (*DevInfo) NbTxQueues

func (info *DevInfo) NbTxQueues() uint16

NbTxQueues returns number of configured TX queues for the device.

func (*DevInfo) RetaSize

func (info *DevInfo) RetaSize() uint16

RetaSize returns Device redirection table size, the total number of entries.

type EthLink C.struct_go_rte_eth_link

EthLink is a structure used to retrieve link-level information of an Ethernet port.

func (*EthLink) AutoNeg

func (link *EthLink) AutoNeg() bool

AutoNeg returns true if auto-negotiation is true.

func (*EthLink) Duplex

func (link *EthLink) Duplex() bool

Duplex returns true if the port is in full-duplex, otherwise it's in half-duplex.

func (*EthLink) Speed

func (link *EthLink) Speed() uint32

Speed returns speed in Mbps.

func (*EthLink) Status

func (link *EthLink) Status() bool

Status returns true if link is on, false otherwise.

type FcConf

FcConf is a structure used to configure Ethernet flow control parameter. These parameters will be configured into the register of the NIC. Please refer to the corresponding data sheet for proper value.

func (*FcConf) SetMode

func (conf *FcConf) SetMode(n uint32)

SetMode sets Flow Control mode.

type GoStats

type GoStats struct {
	Ipackets uint64 `metric:"ipackets" type:"counter"`
	Opackets uint64 `metric:"opackets" type:"counter"`
	Ibytes   uint64 `metric:"ibytes" type:"counter"`
	Obytes   uint64 `metric:"obytes" type:"counter"`
	Imissed  uint64 `metric:"imissed" type:"counter"`
	Ierrors  uint64 `metric:"ierrors" type:"counter"`
	Oerrors  uint64 `metric:"oerrors" type:"counter"`
	RxNoMbuf uint64 `metric:"rxnombuf" type:"counter"`
}

GoStats contains counters from rte_eth_stats.

type IntrConf

type IntrConf struct {
	LSC, RXQ, RMV bool
}

IntrConf is used to enable/disable interrupts.

type MACAddr

type MACAddr C.struct_rte_ether_addr

MACAddr is a universally administered address is uniquely assigned to a device by its manufacturer. The first three octets (in transmission order) contain the Organizationally Unique Identifier (OUI). The following three (MAC-48 and EUI-48) octets are assigned by that organization with the only constraint of uniqueness. A locally administered address is assigned to a device by a network administrator and does not contain OUIs.

func (*MACAddr) HardwareAddr

func (addr *MACAddr) HardwareAddr() net.HardwareAddr

HardwareAddr converts MACAddr into Go's native net.HardwareAddr.

func (*MACAddr) String

func (addr *MACAddr) String() string

type Option

type Option struct {
	// contains filtered or unexported fields
}

Option represents device option which is then used by DevConfigure to setup Ethernet device.

func OptIntrConf

func OptIntrConf(intr IntrConf) Option

OptIntrConf is used to specify interrupt configuration.

func OptLinkSpeeds

func OptLinkSpeeds(speeds uint) Option

OptLinkSpeeds sets allowed speeds for the device. LinkSpeedFixed disables link autonegotiation, and a unique speed shall be set. Otherwise, the bitmap defines the set of speeds to be advertised. If the special value LinkSpeedAutoneg is used, all speeds supported are advertised.

func OptLoopbackMode

func OptLoopbackMode(mode uint32) Option

OptLoopbackMode specifies loopback operation mode. By default the value is 0, meaning the loopback mode is disabled. Read the datasheet of given ethernet controller for details. The possible values of this field are defined in implementation of each driver.

func OptRss

func OptRss(conf RssConf) Option

OptRss specifies RSS configuration.

func OptRxMode

func OptRxMode(conf RxMode) Option

OptRxMode specifies port RX configuration.

func OptTxMode

func OptTxMode(conf TxMode) Option

OptTxMode specifies port TX configuration.

type Port

type Port uint16

Port is the number of the Ethernet device.

func GetPortByName

func GetPortByName(name string) (Port, error)

GetPortByName gets the port ID from device name. The device name should be specified as below:

  • PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
  • SoC device name, for example- fsl-gmac0
  • vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]

(0) if successful. (-ENODEV or -EINVAL) in case of failure.

func ValidPorts

func ValidPorts() []Port

ValidPorts returns list of devices valid in EAL.

func (Port) Close

func (pid Port) Close()

Close a stopped Ethernet device. The device cannot be restarted! The function frees all port resources if the driver supports the flag RTE_ETH_DEV_CLOSE_REMOVE.

func (Port) DevConfigure

func (pid Port) DevConfigure(nrxq, ntxq uint16, opts ...Option) error

DevConfigure configures an Ethernet device. This function must be invoked first before any other function in the Ethernet API. This function can also be re-invoked when a device is in the stopped state.

nrxq and ntxq are the numbers of receive and transmit queues to set up for the Ethernet device, respectively.

Several Opt* options may be specified as well.

func (Port) EthLinkGet

func (pid Port) EthLinkGet() (EthLink, error)

EthLinkGet retrieves the link status (up/down), the duplex mode (half/full), the negotiation (auto/fixed), and if available, the speed (Mbps).

It might need to wait up to 9 seconds.

Returns:

(0) if successful.
(-ENOTSUP) if the function is not supported in PMD driver.
(-ENODEV) if port_id invalid.
(-EINVAL) if bad parameter.

func (Port) EthLinkGetNowait

func (pid Port) EthLinkGetNowait() (EthLink, error)

EthLinkGetNowait retrieves the link status (up/down), the duplex mode (half/full), the negotiation (auto/fixed), and if available, the speed (Mbps).

Returns:

(0) if successful.
(-ENOTSUP) if the function is not supported in PMD driver.
(-ENODEV) if port_id invalid.
(-EINVAL) if bad parameter.

func (Port) FlowCtrlGet

func (pid Port) FlowCtrlGet(conf *FcConf) error

FlowCtrlGet gets current status of the Ethernet link flow control for Ethernet device.

func (Port) FlowCtrlSet

func (pid Port) FlowCtrlSet(conf *FcConf) error

FlowCtrlSet configures the Ethernet link flow control for Ethernet device.

func (Port) GetMTU

func (pid Port) GetMTU() (uint16, error)

GetMTU retrieves the MTU of an Ethernet device.

func (Port) InfoGet

func (pid Port) InfoGet(info *DevInfo) error

InfoGet retrieves the contextual information of an Ethernet device.

As part of this function, a number of of fields in dev_info will be initialized as follows:

rx_desc_lim = lim tx_desc_lim = lim

Where lim is defined within the rte_eth_dev_info_get as

const struct rte_eth_desc_lim lim = { .nb_max = UINT16_MAX, .nb_min
= 0, .nb_align = 1, .nb_seg_max = UINT16_MAX, .nb_mtu_seg_max =
UINT16_MAX, };

device = dev->device min_mtu = RTE_ETHER_MIN_MTU max_mtu =
UINT16_MAX

The following fields will be populated if support for dev_infos_get() exists for the device and the rte_eth_dev 'dev' has been populated successfully with a call to it:

driver_name = dev->device->driver->name nb_rx_queues =
dev->data->nb_rx_queues nb_tx_queues = dev->data->nb_tx_queues
dev_flags = &dev->data->dev_flags

func (Port) IsValid

func (pid Port) IsValid() bool

IsValid checks if port_id of device is attached.

func (Port) MACAddrGet

func (pid Port) MACAddrGet(addr *MACAddr) error

MACAddrGet retrieves the Ethernet address of an Ethernet device.

func (Port) Name

func (pid Port) Name() (string, error)

Name get the device name from port id. The device name is specified as below:

  • PCIe address (Domain:Bus:Device.Function), for example- 0000:02:00.0
  • SoC device name, for example- fsl-gmac0
  • vdev dpdk name, for example- net_[pcap0|null0|tun0|tap0]

(0) if successful. (-ENODEV) if port_id is invalid. (-EINVAL) on failure.

func (Port) PromiscDisable

func (pid Port) PromiscDisable() error

PromiscDisable disables receipt in promiscuous mode for an Ethernet device.

func (Port) PromiscEnable

func (pid Port) PromiscEnable() error

PromiscEnable enables receipt in promiscuous mode for an Ethernet device.

func (Port) RegisterCallbackLSC

func (p Port) RegisterCallbackLSC() error

RegisterCallbackLSC installs a callback for RTE_ETH_EVENT_INTR_LSC event which counts all occurred events.

func (Port) Reset

func (pid Port) Reset() error

Reset a Ethernet device and keep its port id.

When a port has to be reset passively, the DPDK application can invoke this function. For example when a PF is reset, all its VFs should also be reset. Normally a DPDK application can invoke this function when RTE_ETH_EVENT_INTR_RESET event is detected, but can also use it to start a port reset in other circumstances.

When this function is called, it first stops the port and then calls the PMD specific dev_uninit( ) and dev_init( ) to return the port to initial state, in which no Tx and Rx queues are setup, as if the port has been reset and not started. The port keeps the port id it had before the function call.

After calling rte_eth_dev_reset( ), the application should use rte_eth_dev_configure( ), rte_eth_rx_queue_setup( ), rte_eth_tx_queue_setup( ), and rte_eth_dev_start( ) to reconfigure the device as appropriate.

Note: To avoid unexpected behavior, the application should stop calling Tx and Rx functions before calling rte_eth_dev_reset( ). For thread safety, all these controlling functions should be called from the same thread.

Return codes:

  • (0) if successful.

  • (-EINVAL) if port identifier is invalid.

  • (-ENOTSUP) if hardware doesn't support this function.

  • (-EPERM) if not ran from the primary process.

  • (-EIO) if re-initialisation failed or device is removed.

  • (-ENOMEM) if the reset failed due to OOM.

  • (-EAGAIN) if the reset temporarily failed and should be retried later.

func (Port) RssHashConfGet

func (pid Port) RssHashConfGet(conf *RssConf) error

RssHashConfGet retrieves current configuration of Receive Side Scaling hash computation of Ethernet device.

func (Port) RssHashUpdate

func (pid Port) RssHashUpdate(conf *RssConf) error

RssHashUpdate updates configuration of Receive Side Scaling hash computation of Ethernet device.

func (Port) RssRetaQuery

func (pid Port) RssRetaQuery(conf []RssRetaEntry64, retaSize uint16) error

RssRetaQuery queries Redirection Table(RETA) of Receive Side Scaling of Ethernet device.

conf is a RETA to query. For each requested reta entry, corresponding bit in mask must be set. retaSize is a redirection table size. The table size can be queried by rte_eth_dev_info_get().

Returns:

(0) if successful.
(-ENODEV) if port_id is invalid.
(-ENOTSUP) if hardware doesn't support.
(-EINVAL) if bad parameter.
(-EIO) if device is removed.

func (Port) RssRetaUpdate

func (pid Port) RssRetaUpdate(conf []RssRetaEntry64, retaSize uint16) error

RssRetaUpdate updates Redirection Table(RETA) of Receive Side Scaling of Ethernet device.

conf is a RETA to update. retaSize is redirection table size. The table size can be queried by rte_eth_dev_info_get().

Returns:

(0) if successful.
(-ENODEV) if port_id is invalid.
(-ENOTSUP) if hardware doesn't support.
(-EINVAL) if bad parameter.
(-EIO) if device is removed.

func (Port) RxBurst

func (pid Port) RxBurst(qid uint16, pkts []*mbuf.Mbuf) uint16

RxBurst receives packets for port pid and queue qid. Returns number of packets retrieved into pkts.

func (Port) RxqSetup

func (pid Port) RxqSetup(qid, nDesc uint16, mp *mempool.Mempool, opts ...QueueOption) error

RxqSetup allocates and sets up a receive queue for an Ethernet device.

The function allocates a contiguous block of memory for nDesc receive descriptors from a memory zone associated with *socket_id* and initializes each receive descriptor with a network buffer allocated from the memory pool *mb_pool*.

qid is the index of the receive queue to set up. The value must be in the range [0, nb_rx_queue - 1] previously supplied to rte_eth_dev_configure().

nDesc is the number of receive descriptors to allocate for the receive ring.

mp is the pointer to the memory pool from which to allocate *rte_mbuf* network memory buffers to populate each descriptor of the receive ring.

opts specifies the configuration data to be used for the receive queue. The *rx_conf* structure contains an *rx_thresh* structure with the values of the Prefetch, Host, and Write-Back threshold registers of the receive ring. In addition it contains the hardware offloads features to activate using the DEV_RX_OFFLOAD_* flags. If an offloading set in rx_conf->offloads hasn't been set in the input argument eth_conf->rxmode.offloads to rte_eth_dev_configure(), it is a new added offloading, it must be per-queue type and it is enabled for the queue. No need to repeat any bit in rx_conf->offloads which has already been enabled in rte_eth_dev_configure() at port level. An offloading enabled at port level can't be disabled at queue level.

Return codes:

- 0: Success, receive queue correctly set up.

- -EIO: if device is removed.

  • -EINVAL: The memory pool pointer is null or the size of network buffers which can be allocated from this memory pool does not fit the various buffer sizes allowed by the device controller.

  • -ENOMEM: Unable to allocate the receive ring descriptors or to allocate network memory buffers from the memory pool when initializing receive descriptors.

func (Port) SetLinkDown

func (pid Port) SetLinkDown() error

SetLinkDown set link status to 'down' an Ethernet device. The device rx/tx functionality will be disabled if success, and it can be re-enabled with a call to rte_eth_dev_set_link_up().

Return codes:

  • 0: Success, Ethernet device linked down.

  • <0: Error code of the driver device link down function.

func (Port) SetLinkUp

func (pid Port) SetLinkUp() error

SetLinkUp set link status to 'up' an Ethernet device.

Set device link up will re-enable the device rx/tx functionality after it is previously set device linked down.

Return codes:

  • 0: Success, Ethernet device linked up.

  • <0: Error code of the driver device link up function.

func (Port) SetMTU

func (pid Port) SetMTU(mtu uint16) error

SetMTU changes the MTU of an Ethernet device.

func (Port) SocketID

func (pid Port) SocketID() int

SocketID returns the NUMA socket to which an Ethernet device is connected. The function may return a default of zero if the socket could not be determined. -1 is returned if the port_id value is out of range.

func (Port) Start

func (pid Port) Start() error

Start an Ethernet device.

The device start step is the last one and consists of setting the configured offload features and in starting the transmit and the receive units of the device.

Device RTE_ETH_DEV_NOLIVE_MAC_ADDR flag causes MAC address to be set before PMD port start callback function is invoked.

On success, all basic functions exported by the Ethernet API (link status, receive/transmit, and so on) can be invoked.

Return codes:

- 0: Success, Ethernet device started.

- <0: Error code of the driver device start function.

func (Port) StatsGet

func (pid Port) StatsGet(stats *Stats) error

StatsGet retrieves statistics from ethernet device.

func (Port) StatsReset

func (pid Port) StatsReset() error

StatsReset resets stats counters.

func (Port) Stop

func (pid Port) Stop()

Stop an Ethernet device. The device can be restarted with a call to rte_eth_dev_start().

func (Port) TxBuffer

func (pid Port) TxBuffer(qid uint16, buf *TxBuffer, m *mbuf.Mbuf) uint16

TxBuffer buffers a single packet for future transmission on a port and queue.

This function takes a single mbuf/packet and buffers it for later transmission on the particular port and queue specified. Once the buffer is full of packets, an attempt will be made to transmit all the buffered packets. In case of error, where not all packets can be transmitted, a callback is called with the unsent packets as a parameter. If no callback is explicitly set up, the unsent packets are just freed back to the owning mempool. The function returns the number of packets actually sent i.e. 0 if no buffer flush occurred, otherwise the number of packets successfully flushed

func (Port) TxBufferFlush

func (pid Port) TxBufferFlush(qid uint16, buf *TxBuffer) uint16

TxBufferFlush Send any packets queued up for transmission on a port and HW queue.

This causes an explicit flush of packets previously buffered via the rte_eth_tx_buffer() function. It returns the number of packets successfully sent to the NIC, and calls the error callback for any unsent packets. Unless explicitly set up otherwise, the default callback simply frees the unsent packets back to the owning mempool.

func (Port) TxBurst

func (pid Port) TxBurst(qid uint16, pkts []*mbuf.Mbuf) uint16

TxBurst sends packets over port pid and queue qid. Returns number of packets sent from pkts.

func (Port) TxqSetup

func (pid Port) TxqSetup(qid, nDesc uint16, opts ...QueueOption) error

TxqSetup allocates and set up a transmit queue for an Ethernet device.

qid is the index of the transmit queue to set up. The value must be in the range [0, nb_tx_queue - 1] previously supplied to rte_eth_dev_configure().

nDesc is the number of transmit descriptors to allocate for the transmit ring.

OptSocket specifies the socket identifier in case of NUMA. Its value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the DMA memory allocated for the transmit descriptors of the ring.

OptTxqConf specifies configuration data to be used for the transmit queue. NULL value is allowed, in which case default TX configuration will be used.

The *tx_conf* structure contains the following data:

- The *tx_thresh* structure with the values of the Prefetch, Host, and Write-Back threshold registers of the transmit ring. When setting Write-Back threshold to the value greater then zero, *tx_rs_thresh* value should be explicitly set to one.

- The *tx_free_thresh* value indicates the [minimum] number of network buffers that must be pending in the transmit ring to trigger their [implicit] freeing by the driver transmit function.

- The *tx_rs_thresh* value indicates the [minimum] number of transmit descriptors that must be pending in the transmit ring before setting the RS bit on a descriptor by the driver transmit function. The *tx_rs_thresh* value should be less or equal then *tx_free_thresh* value, and both of them should be less then *nb_tx_desc* - 3.

- The *offloads* member contains Tx offloads to be enabled. If an offloading set in tx_conf->offloads hasn't been set in the input argument eth_conf->txmode.offloads to rte_eth_dev_configure(), it is a new added offloading, it must be per-queue type and it is enabled for the queue. No need to repeat any bit in tx_conf->offloads which has already been enabled in rte_eth_dev_configure() at port level. An offloading enabled at port level can't be disabled at queue level.

Note that setting *tx_free_thresh* or *tx_rs_thresh* value to 0 forces the transmit function to use default values. Return codes:

- 0: Success, the transmit queue is correctly set up.

- -ENOMEM: Unable to allocate the transmit ring descriptors.

func (Port) UnregisterCallbackLSC

func (p Port) UnregisterCallbackLSC() error

UnregisterCallbackLSC removes callback for RTE_ETH_EVENT_INTR_LSC event which counts all occurred events.

func (Port) XstatGetByID

func (pid Port) XstatGetByID(ids, values []uint64) (int, error)

XstatGetByID retrieves extended statistics of an Ethernet device.

ids is the IDs array given by app to retrieve specific statistics. May be nil to retrieve all available statistics or, if values is nil as well, just the number of available statistics.

values is the array to be filled in with requested device statistics. Must not be nil if ids are specified (not nil).

Returns:

A positive value lower or equal to len(values): success. The return value is the number of entries filled in the stats table.

A positive value higher than len(values): success: The given statistics table is too small. The return value corresponds to the size that should be given to succeed. The entries in the table are not valid and shall not be used by the caller.

Otherwise, error is returned.

func (Port) XstatNameIDs

func (pid Port) XstatNameIDs() (map[uint64]string, error)

XstatNameIDs returns names of extended statistics mapped by their ID and an error. This is supposed to be called to cache counter ids and not used in hot path.

func (Port) XstatNames

func (pid Port) XstatNames() ([]XstatName, error)

XstatNames returns list of names for custom eth dev stats.

func (Port) XstatsGet

func (pid Port) XstatsGet(out []Xstat) (int, error)

XstatsGet retrieves xstat from eth dev. Returns number of retrieved statistics and possible error. If returned number is greater than len(out) extend the slice and try again.

func (Port) XstatsReset

func (pid Port) XstatsReset() error

XstatsReset resets xstats counters.

type QueueOption

type QueueOption struct {
	// contains filtered or unexported fields
}

QueueOption represents an option which is used to setup RX/TX queue on Ethernet device.

func OptRxqConf

func OptRxqConf(conf RxqConf) QueueOption

OptRxqConf specifies the configuration an RX ring of an Ethernet port.

func OptSocket

func OptSocket(socket int) QueueOption

OptSocket specifies the NUMA socket id for RX/TX queue. The socket argument is the socket identifier in case of NUMA. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the DMA memory allocated for the receive/transmit descriptors of the ring.

func OptTxqConf

func OptTxqConf(conf TxqConf) QueueOption

OptTxqConf specifies the configuration an TX ring of an Ethernet port.

type RssConf

type RssConf struct {
	/**< If not NULL, 40-byte hash key. */
	Key []byte
	/**< Hash functions to apply. */
	Hf uint64
}

RssConf is a structure used to configure the Receive Side Scaling (RSS) feature of an Ethernet port. If not nil, the Key points to an array holding the RSS key to use for hashing specific header fields of received packets. Otherwise, a default random hash key is used by the device driver.

To maintain compatibility the Key should be 40 bytes long. To be compatible, this length will be checked in i40e only. Others assume 40 bytes to be used as before.

The Hf field indicates the different types of IPv4/IPv6 packets to which the RSS hashing must be applied. Supplying an *rss_hf* equal to zero disables the RSS feature.

type RssRetaEntry64

type RssRetaEntry64 C.struct_rte_eth_rss_reta_entry64

RssRetaEntry64 is a structure used to configure 64 entries of Redirection Table of the Receive Side Scaling (RSS) feature of an Ethernet port. To configure more than 64 entries supported by hardware, an array of this structure is needed.

func (*RssRetaEntry64) Mask

func (conf *RssRetaEntry64) Mask() *uint64

Mask returns bits indicating which entries need to be updated/queried.

func (*RssRetaEntry64) Reta

func (conf *RssRetaEntry64) Reta() (reta []uint16)

Reta returns group of 64 redirection table entries. You may set elements of returned slice but no appends are allowed.

type RxMode

type RxMode struct {
	// The multi-queue packet distribution mode to be used, e.g. RSS.
	// See MqRx* constants.
	MqMode uint
	// Requested MTU or MaxRxPktLen if JUMBO_FRAME enabled (for releases older than 21.11).
	MTU uint32
	// hdr buf size (header_split enabled).
	SplitHdrSize uint16
	// Per-port Rx offloads to be set using RxOffload* flags. Only
	// offloads set on rx_offload_capa field on rte_eth_dev_info
	// structure are allowed to be set.
	Offloads uint64
}

RxMode is used to configure Ethernet device through OptRxMode option.

type RxqConf

type RxqConf struct {
	Thresh
	// Drives the freeing of RX descriptors.
	FreeThresh uint16
	// Drop packets if no descriptors are available.
	DropEn uint8
	// Do not start queue with rte_eth_dev_start().
	DeferredStart uint8
	// Per-queue Rx offloads to be set using RxOffload* flags.
	// Only offloads set on rx_queue_offload_capa or rx_offload_capa
	// fields on rte_eth_dev_info structure are allowed to be set.
	Offloads uint64
}

RxqConf is a s tructure used to configure an RX ring of an Ethernet port.

type Stats

type Stats C.struct_rte_eth_stats

Stats represents basic statistics counters C struct.

func (*Stats) Cast

func (s *Stats) Cast() *GoStats

Cast transforms Stats pointer to GoStats.

func (*Stats) Diff

func (s *Stats) Diff(old, delta *Stats)

Diff computes delta between s and old.

type Thresh

type Thresh struct {
	// Ring prefetch threshold.
	PThresh uint8
	// Ring host threshold.
	HThresh uint8
	// Ring writeback threshold.
	WThresh uint8
}

Thresh is a structure used to configure the ring threshold registers of an RX/TX queue for an Ethernet port.

type TxBuffer

TxBuffer is a structure used to buffer packets for future TX Used by APIs rte_eth_tx_buffer and rte_eth_tx_buffer_flush.

func NewTxBuffer

func NewTxBuffer(cnt int) *TxBuffer

NewTxBuffer creates new TxBuffer with cnt mbufs.

func (*TxBuffer) Init

func (buf *TxBuffer) Init(cnt int)

Init initializes pre-allocated TxBuffer which must have enough memory to contain cnt mbufs.

func (*TxBuffer) Mbufs

func (buf *TxBuffer) Mbufs() []*mbuf.Mbuf

Mbufs returns a slice of packets contained in TxBuffer.

type TxMode

type TxMode struct {
	// TX multi-queues mode.
	MqMode uint
	// Per-port Tx offloads to be set using DevTxOffload*
	// flags. Only offloads set on tx_offload_capa field on
	// rte_eth_dev_info structure are allowed to be set.
	Offloads uint64
	// For i40e specifically.
	Pvid uint16
	// If set, reject sending out tagged pkts.
	HwVlanRejectTagged bool
	// If set, reject sending out untagged pkts
	HwVlanRejectUntagged bool
	// If set, enable port based VLAN insertion
	HwVlanInsertPvid bool
}

TxMode is used to configure Ethernet device through OptTxMode option.

type TxqConf

type TxqConf struct {
	Thresh
	// Drives the setting of RS bit on TXDs.
	RsThresh uint16
	// Start freeing TX buffers if there are less free descriptors
	// than this value.
	FreeThresh uint16
	// Do not start queue with rte_eth_dev_start().
	DeferredStart uint8
	// Per-queue Tx offloads to be set using DevTxOffload* flags. Only
	// offloads set on tx_queue_offload_capa or tx_offload_capa fields
	// on rte_eth_dev_info structure are allowed to be set.
	Offloads uint64
}

TxqConf is a structure used to configure a TX ring of an Ethernet port.

type Xstat

type Xstat struct {
	// Index of an element in XstatsNames array.
	Index uint64

	// Value of stats.
	Value uint64
}

Xstat reflect C rte_eth_xstats struct.

func XstatDiff

func XstatDiff(incoming, old, delta []Xstat) (newOld, newDelta []Xstat)

XstatDiff computes delta from incoming stats array (incoming) and old stats array (old) with the result placed in delta.

If old contains zero-value Xstat the resulting delta is zero to filter out outliers.

If old doesn't contain Xstat contained in incoming new Xstat is appended to old.

If delta doesn't contain new Xstat it is appended.

The resulting "old" (now updated) and delta are returned.

type XstatName

type XstatName C.struct_rte_eth_xstat_name

XstatName reflect C rte_eth_xstats_name struct.

func (*XstatName) String

func (x *XstatName) String() string

String returns name of the stat.

Directories

Path Synopsis
Package flow encaps RTE generic flow API.
Package flow encaps RTE generic flow API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL