Intel DPDK Api Reference PDF
Intel DPDK Api Reference PDF
Intel DPDK Api Reference PDF
(Intel® DPDK)
API Reference
January 2014
INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY
ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN
INTEL’S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS
ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES
RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER
INTELLECTUAL PROPERTY RIGHT.
A "Mission Critical Application" is any application in which failure of the Intel Product could result, directly or indirectly, in personal injury or death.
SHOULD YOU PURCHASE OR USE INTEL’S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION, YOU SHALL INDEMNIFY AND
HOLD INTEL AND ITS SUBSIDIARIES, SUBCONTRACTORS AND AFFILIATES, AND THE DIRECTORS, OFFICERS, AND EMPLOYEES OF EACH,
HARMLESS AGAINST ALL CLAIMS COSTS, DAMAGES, AND EXPENSES AND REASONABLE ATTORNEYS’ FEES ARISING OUT OF, DIRECTLY
OR INDIRECTLY, ANY CLAIM OF PRODUCT LIABILITY, PERSONAL INJURY, OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL
APPLICATION, WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN, MANUFACTURE, OR WARNING OF THE
INTEL PRODUCT OR ANY OF ITS PARTS.
Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics
of any features or instructions marked "reserved" or "undefined". Intel reserves these for future definition and shall have no responsibility whatsoever for
conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with
this information.
The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published
specifications. Current characterized errata are available on request.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.
Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-
4725, or go to: http://www.intel.com/design/literature.htm
Any software source code reprinted in this document is furnished under a software license and may only be used or copied in accordance with the terms
of that license.
Any software source code reprinted in this document is furnished for informational purposes only and may only be used or copied and no license, express
or implied, by estoppel or otherwise, to any of the reprinted source code is granted by this document.
Code Names are only for use by Intel to identify products, platforms, programs, services, etc. (.products.) in development by Intel that have not been
made commercially available to the public, i.e., announced, launched or shipped. They are never to be used as "commercial" names for products. Also,
they are not intended to function as trademarks.
Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
*Other names and brands may be claimed as the property of others.
Contents
1 Deprecated List 8
Chapter 1
Deprecated List
Global rte_lpm::mem_location
Global RTE_LPM_HEAP
Possible location to allocate memory. This was for last parameter of rte_lpm_create(), but is now redun-
dant. The LPM table is always allocated in memory using librte_malloc which uses a memzone.
Global RTE_LPM_MEMZONE
Possible location to allocate memory. This was for last parameter of rte_lpm_create(), but is now redun-
dant. The LPM table is always allocated in memory using librte_malloc which uses a memzone.
Chapter 2
Data Fields
• uint32_t sc_dequeue
• uint32_t size
• uint32_t mask
• volatile uint32_t head
• volatile uint32_t tail
Consumer head.
Consumer tail.
Data Fields
• eth_dev_configure_t dev_configure
• eth_dev_start_t dev_start
• eth_dev_stop_t dev_stop
• eth_dev_close_t dev_close
• eth_promiscuous_enable_t promiscuous_enable
• eth_promiscuous_disable_t promiscuous_disable
• eth_allmulticast_enable_t allmulticast_enable
• eth_allmulticast_disable_t allmulticast_disable
• eth_link_update_t link_update
• eth_stats_get_t stats_get
• eth_stats_reset_t stats_reset
• eth_queue_stats_mapping_set_t queue_stats_mapping_set
• eth_dev_infos_get_t dev_infos_get
• vlan_filter_set_t vlan_filter_set
• vlan_tpid_set_t vlan_tpid_set
• vlan_strip_queue_set_t vlan_strip_queue_set
• vlan_offload_set_t vlan_offload_set
• eth_rx_queue_setup_t rx_queue_setup
• eth_queue_release_t rx_queue_release
• eth_rx_queue_count_t rx_queue_count
• eth_rx_descriptor_done_t rx_descriptor_done
• eth_tx_queue_setup_t tx_queue_setup
• eth_queue_release_t tx_queue_release
• eth_dev_led_on_t dev_led_on
• eth_dev_led_off_t dev_led_off
• flow_ctrl_set_t flow_ctrl_set
• priority_flow_ctrl_set_t priority_flow_ctrl_set
• eth_mac_addr_remove_t mac_addr_remove
• eth_mac_addr_add_t mac_addr_add
• eth_uc_hash_table_set_t uc_hash_table_set
• eth_uc_all_hash_table_set_t uc_all_hash_table_set
• eth_mirror_rule_set_t mirror_rule_set
• eth_mirror_rule_reset_t mirror_rule_reset
• eth_set_vf_rx_mode_t set_vf_rx_mode
• eth_set_vf_rx_t set_vf_rx
• eth_set_vf_tx_t set_vf_tx
• eth_set_vf_vlan_filter_t set_vf_vlan_filter
• fdir_add_signature_filter_t fdir_add_signature_filter
• fdir_update_signature_filter_t fdir_update_signature_filter
• fdir_remove_signature_filter_t fdir_remove_signature_filter
• fdir_infos_get_t fdir_infos_get
• fdir_add_perfect_filter_t fdir_add_perfect_filter
• fdir_update_perfect_filter_t fdir_update_perfect_filter
• fdir_remove_perfect_filter_t fdir_remove_perfect_filter
• fdir_set_masks_t fdir_set_masks
• reta_update_t reta_update
• reta_query_t reta_query
Configure device.
Start device.
Stop device.
Close device.
Promiscuous ON.
Promiscuous OFF.
RX multicast ON.
RX multicast OF.
Release RX queue.
Release TX queue.
Turn on LED.
Set VF RX mode
enable/disable a VF receive
enable/disable a VF transmit
Data Fields
Data Fields
Ethernet address: 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. See http://standards.ieee.org/regauth/groupmac/tutorial.html
Data Fields
• struct ether_addr d_addr
• struct ether_addr s_addr
• uint16_t ether_type
Ethernet header: Contains the destination address, source address and frame type.
Destination address.
Source address.
Frame type.
Data Fields
• uint8_t version_ihl
• uint8_t type_of_service
• uint16_t total_length
• uint16_t packet_id
• uint16_t fragment_offset
• uint8_t time_to_live
• uint8_t next_proto_id
• uint16_t hdr_checksum
• uint32_t src_addr
• uint32_t dst_addr
IPv4 Header
type of service
length of packet
packet ID
fragmentation offset
time to live
protocol ID
header checksum
source address
destination address
Data Fields
• uint32_t vtc_flow
• uint16_t payload_len
• uint8_t proto
• uint8_t hop_limits
• uint8_t src_addr [16]
• uint8_t dst_addr [16]
IPv6 Header
Hop limits.
Data Fields
• uint32_t watermark
• uint32_t sp_enqueue
• uint32_t size
• uint32_t mask
• volatile uint32_t head
• volatile uint32_t tail
Size of ring.
Producer head.
Producer tail.
Data Fields
Data Fields
Data Fields
Data Fields
• uint32_t version
• uint32_t magic
• uint32_t master_lcore
• uint32_t lcore_count
• enum rte_lcore_role_t lcore_role [32,]
• enum rte_proc_type_t process_type
• unsigned flags
• struct rte_mem_config ∗ mem_config
State of cores.
Pointer to memory configuration, which may be shared across multiple Intel DPDK instances
Data Fields
• void ∗ data
• uint32_t data_len
Pointer to data.
Length of data.
Data Fields
• TAILQ_ENTRY next
Data Fields
• uint16_t link_speed
• uint16_t link_duplex
• struct rte_eth_rxmode rxmode
• struct rte_eth_txmode txmode
• uint32_t lpbk_mode
• union {
struct rte_eth_rss_conf rss_conf
struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf
struct rte_eth_dcb_rx_conf dcb_rx_conf
struct rte_eth_vmdq_rx_conf vmdq_rx_conf
} rx_adv_conf
• union {
struct rte_eth_vmdq_dcb_tx_conf vmdq_dcb_tx_conf
struct rte_eth_dcb_tx_conf dcb_tx_conf
struct rte_eth_vmdq_tx_conf vmdq_tx_conf
} tx_adv_conf
• uint32_t dcb_capability_en
• struct rte_fdir_conf fdir_conf
• struct rte_intr_conf intr_conf
A structure used to configure an Ethernet port. Depending upon the RX multi-queue mode, extra advanced
configuration settings may be needed.
Port RX configuration.
Port TX configuration.
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.
Currently,Priority Flow Control(PFC) are supported,if DCB with PFC is needed,and the variable must be set
ETH_DCB_PFC_SUPPORT.
FDIR configuration.
Data Fields
• enum rte_eth_nb_tcs nb_tcs
• uint8_t dcb_queue [ETH_DCB_NUM_USER_PRIORITIES]
Data Fields
• enum rte_eth_nb_tcs nb_tcs
• uint8_t dcb_queue [ETH_DCB_NUM_USER_PRIORITIES]
Data Fields
• eth_rx_burst_t rx_pkt_burst
• eth_tx_burst_t tx_pkt_burst
• struct rte_eth_dev_data ∗ data
• struct eth_driver ∗ driver
• struct eth_dev_ops ∗ dev_ops
• struct rte_pci_device ∗ pci_dev
• struct rte_eth_dev_cb_list callbacks
Data Fields
• void ∗∗ rx_queues
• void ∗∗ tx_queues
• uint16_t nb_rx_queues
• uint16_t nb_tx_queues
• struct rte_eth_dev_sriov sriov
• void ∗ dev_private
• struct rte_eth_link dev_link
• struct rte_eth_conf dev_conf
• uint16_t max_frame_size
• uint64_t rx_mbuf_alloc_failed
• struct ether_addr ∗ mac_addrs
• struct ether_addr ∗ hash_mac_addrs
• uint8_t port_id
• uint8_t promiscuous: 1
• uint8_t scattered_rx: 1
• uint8_t all_multicast: 1
• uint8_t dev_started: 1
Number of RX queues.
Number of TX queues.
SRIOV data
Device Ethernet MAC addresses of hash filtering. Device [external] port identifier.
Data Fields
A structure used to retrieve the contextual information of an Ethernet device, such as the controlling driver
of the device, its PCI context, etc...
Maximum number of hash MAC addresses for MTA and UTA. Maximum number of VFs.
Data Fields
• uint8_t active
• uint8_t nb_q_per_pool
• uint16_t def_vmdq_idx
• uint16_t def_pool_q_idx
Data Fields
• uint32_t high_water
• uint32_t low_water
• uint16_t pause_time
• uint16_t send_xon
• enum rte_eth_fc_mode mode
• uint8_t mac_ctrl_frame_fwd
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.
Data Fields
• uint16_t collision
• uint16_t free
• uint16_t maxhash
• uint8_t maxlen
• uint64_t add
• uint64_t remove
• uint64_t f_add
• uint64_t f_remove
A structure used to report the status of the flow director filters in use.
The Lookup hash value of the added filter that updated the value of the MAXLEN field
Data Fields
• uint16_t link_speed
• uint16_t link_duplex
• uint8_t link_status: 1
A structure used to retrieve link-level information of an Ethernet port. aligned for atomic64 read/write
ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX]
Data Fields
• struct rte_eth_fc_conf fc
• uint8_t priority
A structure used to configure Ethernet priority flow control parameter. These parameters will be configured
into the register of the NIC. Please refer to the corresponding data sheet for proper value.
Data Fields
• uint8_t ∗ rss_key
• uint16_t rss_hf
A structure used to configure the Receive Side Scaling (RSS) feature of an Ethernet port. If not NULL, the
∗rss_key∗ pointer of the ∗rss_conf∗ structure points to an array of 40 bytes 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.
The ∗rss_hf∗ field of the ∗rss_conf∗ structure 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.
Data Fields
• uint64_t mask_lo
• uint64_t mask_hi
• uint8_t reta [ETH_RSS_RETA_NUM_ENTRIES]
A structure used to configure Redirection Table of the Receive Side Scaling (RSS) feature of an Ethernet
port.
Data Fields
Data Fields
• enum rte_eth_rx_mq_mode mq_mode
• uint32_t max_rx_pkt_len
• uint16_t split_hdr_size
• uint8_t header_split: 1
• uint8_t hw_ip_checksum: 1
• uint8_t hw_vlan_filter: 1
• uint8_t hw_vlan_strip: 1
• uint8_t hw_vlan_extend: 1
• uint8_t jumbo_frame: 1
• uint8_t hw_strip_crc: 1
Data Fields
• uint64_t ipackets
• uint64_t opackets
• uint64_t ibytes
• uint64_t obytes
• uint64_t ierrors
• uint64_t oerrors
• uint64_t imcasts
• uint64_t rx_nombuf
• uint64_t fdirmatch
• uint64_t fdirmiss
• uint64_t q_ipackets [RTE_ETHDEV_QUEUE_STAT_CNTRS]
• uint64_t q_opackets [RTE_ETHDEV_QUEUE_STAT_CNTRS]
• uint64_t q_ibytes [RTE_ETHDEV_QUEUE_STAT_CNTRS]
• uint64_t q_obytes [RTE_ETHDEV_QUEUE_STAT_CNTRS]
• uint64_t q_errors [RTE_ETHDEV_QUEUE_STAT_CNTRS]
• uint64_t ilbpackets
• uint64_t olbpackets
• uint64_t ilbbytes
• uint64_t olbbytes
Data Fields
• uint8_t pthresh
• uint8_t hthresh
• uint8_t wthresh
A structure used to configure the ring threshold registers of an RX/TX queue for an Ethernet port.
Data Fields
• struct rte_eth_thresh tx_thresh
• uint16_t tx_rs_thresh
• uint16_t tx_free_thresh
• uint32_t txq_flags
Data Fields
• enum rte_eth_tx_mq_mode mq_mode
TX multi-queues mode.
Data Fields
• uint64_t vlan_mask
Data Fields
Data Fields
Data Fields
• uint8_t rule_type_mask
• uint8_t dst_pool
• uint64_t pool_mask
• struct rte_eth_vlan_mirror vlan
Data Fields
Data Fields
Data Fields
• uint64_t whole_entry
• struct {
uint16_t is_entry
uint16_t value
uint32_t key
} entry
Data Fields
Data Fields
• TAILQ_ENTRY next
• char name [RTE_FBK_HASH_NAMESIZE]
• uint32_t entries
• uint32_t entries_per_bucket
• uint32_t used_entries
• uint32_t bucket_mask
• uint32_t bucket_shift
• rte_fbk_hash_fn hash_func
• uint32_t init_val
• union rte_fbk_hash_entry t [0]
Linked list.
Data Fields
• enum rte_fdir_mode mode
• enum rte_fdir_pballoc_type pballoc
• enum rte_fdir_status_mode status
• uint8_t flexbytes_offset
• uint8_t drop_queue
A structure used to configure the Flow Director (FDIR) feature of an Ethernet port.
If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
Data Fields
• uint16_t flex_bytes
• uint16_t vlan_id
• uint16_t port_src
• uint16_t port_dst
• union {
uint32_t ipv4_addr
uint32_t ipv6_addr [4]
} ip_src
• union {
uint32_t ipv4_addr
uint32_t ipv6_addr [4]
} ip_dst
Data Fields
• uint8_t only_ip_flow
• uint8_t vlan_id
• uint8_t vlan_prio
• uint8_t flexbytes
• uint8_t set_ipv6_mask
• uint8_t comp_ipv6_dst
• uint32_t dst_ipv4_mask
• uint32_t src_ipv4_mask
• uint16_t dst_ipv6_mask
• uint16_t src_ipv6_mask
• uint16_t src_port_mask
• uint16_t dst_port_mask
A structure used to configure FDIR masks that are used by the device to match the various fields of RX
packet headers.
Note
The only_ip_flow field has the opposite meaning compared to other masks!
When set to 1, packet l4type is NOT relevant in filters, and source and destination port masks must be set
to zero.
If set to 1, set the IPv6 masks. Otherwise set the IPv4 masks.
When set to 1, comparison of destination IPv6 address with IP6AT registers is meaningful.
Mask of Destination IPv4 Address. All bits set to 1 define the relevant bits to use in the destination address
of an IPv4 packet when matching it against FDIR filters.
Mask of Source IPv4 Address. All bits set to 1 define the relevant bits to use in the source address of an
IPv4 packet when matching it against FDIR filters.
Mask of Source IPv6 Address. All bits set to 1 define the relevant BYTES to use in the source address of
an IPv6 packet when matching it against FDIR filters.
Mask of Destination IPv6 Address. All bits set to 1 define the relevant BYTES to use in the destination
address of an IPv6 packet when matching it against FDIR filters.
Mask of Source Port. All bits set to 1 define the relevant bits to use in the source port of an IP packets when
matching it against FDIR filters.
Mask of Destination Port. All bits set to 1 define the relevant bits to use in the destination port of an IP
packet when matching it against FDIR filters.
Data Fields
• TAILQ_ENTRY next
• char name [RTE_HASH_NAMESIZE]
• uint32_t entries
• uint32_t bucket_entries
• uint32_t key_len
• rte_hash_function hash_func
• uint32_t hash_func_init_val
• uint32_t num_buckets
• uint32_t bucket_bitmask
• hash_sig_t sig_msb
• uint8_t ∗ sig_tbl
• uint32_t sig_tbl_bucket_size
• uint8_t ∗ key_tbl
• uint32_t key_tbl_key_size
Next in list.
Bucket entries.
Signature buckets may be padded for alignment reasons, and this is the bucket size used by sig_tbl.
Keys may be padded for alignment reasons, and this is the key size used by key_tbl.
Data Fields
Parameters used when creating the hash table. The total table entries and bucket entries must be a power
of 2.
Bucket entries.
Data Fields
• uint16_t lsc
Data Fields
• int magic_number
• char name [IVSHMEM_NAME_LEN]
• struct rte_ivshmem_metadata_entry entry [RTE_LIBRTE_IVSHMEM_MAX_ENTRIES]
magic number
metadata entries
Data Fields
• struct rte_memzone mz
• uint64_t offset
shared memzone
Data Fields
• uint32_t type
• uint32_t level
• FILE ∗ file
Log level.
Data Fields
• TAILQ_ENTRY next
• char name [RTE_LPM_NAMESIZE]
• int mem_location
• uint32_t max_rules
• struct rte_lpm_rule_info rule_info [RTE_LPM_MAX_DEPTH]
• struct rte_lpm_tbl24_entry struct rte_lpm_tbl8_entry tbl8 [RTE_LPM_TBL8_NUM_ENTRIES]
• struct rte_lpm_tbl24_entry struct rte_lpm_tbl8_entry struct rte_lpm_rule rules_tbl [0]
Next in list.
Deprecated
See also
RTE_LPM_HEAP and RTE_LPM_MEMZONE.
2.55.1.6 struct rte_lpm_tbl24_entry struct rte_lpm_tbl8_entry rte_lpm::tbl8[RTE LPM TBL8 NUM ENTRIES]
Data Fields
• uint32_t max_rules
• uint32_t number_tbl8s
• int flags
Data Fields
• uint32_t ip
• uint8_t next_hop
Rule IP address.
Data Fields
• uint32_t used_rules
• uint32_t first_rule
Data Fields
• uint8_t valid:1
• uint8_t ext_entry:1
• uint8_t depth:6
Validation flag.
External entry.
Rule depth.
Data Fields
• uint8_t next_hop
• uint8_t valid:1
• uint8_t valid_group:1
• uint8_t depth:6
next hop.
Validation flag.
Rule depth.
Data Fields
• size_t heap_totalsz_bytes
• size_t heap_freesz_bytes
• size_t greatest_free_size
• unsigned free_count
• unsigned alloc_count
• size_t heap_allocsz_bytes
Data Fields
• uint8_t type
• uint8_t reserved
• uint16_t ol_flags
16-bit Reference counter. It should only be accessed using the following functions: rte_mbuf_refcnt_-
update(), rte_mbuf_refcnt_read(), and rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC config option.
Type of mbuf.
Offload features.
Data Fields
the structure for the memory configuration for the RTE. Used by the rte_config structure. It is separated out,
as for multi-process support, the memory details should be shared across instances
• qlock->mlock (ring/hash/lpm)
• mplock->qlock->mlock (mempool) Notice: ∗ALWAYS∗ obtain qlock first if having to obtain both qlock
and mlock only used by memzone LIB for thread-safe.
Index of memzone
Physmem descriptors.
Memzone descriptors.
Data Fields
• TAILQ_ENTRY next
• char name [RTE_MEMPOOL_NAMESIZE]
• struct rte_ring ∗ ring
• phys_addr_t phys_addr
• int flags
• uint32_t size
• uint32_t cache_size
• uint32_t cache_flushthresh
• uint32_t elt_size
• uint32_t header_size
• uint32_t trailer_size
• unsigned private_data_size
• struct rte_mempool_cache local_cache [32,]
• uint32_t pg_num
• uint32_t uint32_t pg_shift
• uintptr_t pg_mask
• uintptr_t elt_va_start
• uintptr_t elt_va_end
• phys_addr_t elt_pa [MEMPOOL_PG_NUM_DEFAULT]
Next in list.
Name of mempool.
Size of an element.
Data Fields
• unsigned len
• void ∗ objs [512,∗3]
Cache len
Cache objects
Data Fields
• uint32_t elt_size
• uint32_t header_size
• uint32_t trailer_size
• uint32_t total_size
Size of an element.
Data Fields
• phys_addr_t phys_addr
• size_t len
• size_t hugepage_sz
• int32_t socket_id
• uint32_t nchannel
• uint32_t nrank
• void ∗ addr
• uint64_t addr_64
Number of channels.
Number of ranks.
Data Fields
A structure describing a memzone, which is a contiguous portion of physical memory identified by a name.
Data Fields
• uint64_t cir
• uint64_t cbs
• uint64_t ebs
srTCM parameters per metered traffic flow. The CIR, CBS and EBS parameters only count bytes of IP
packets and do not include link specific headers. At least one of the CBS or EBS parameters has to be
greater than zero.
Data Fields
• uint64_t cir
• uint64_t pir
• uint64_t cbs
• uint64_t pbs
trTCM parameters per metered traffic flow. The CIR, PIR, CBS and PBS parameters only count bytes of IP
packets and do not include link specific headers. PIR has to be greater than or equal to CIR. Both CBS or
EBS have to be greater than zero.
Data Fields
• uint16_t domain
• uint8_t bus
• uint8_t devid
• uint8_t function
Device domain
Device bus
Device ID
Device function.
Data Fields
• TAILQ_ENTRY next
• struct rte_pci_addr addr
• struct rte_pci_id id
• struct rte_pci_resource mem_resource [PCI_MAX_RESOURCE]
• struct rte_intr_handle intr_handle
PCI location.
PCI ID.
Interrupt handle
Associated driver
Device is blacklisted
Data Fields
• TAILQ_ENTRY next
• const char ∗ name
• pci_devinit_t ∗ devinit
• struct rte_pci_id ∗ id_table
• uint32_t drv_flags
Next in list.
Driver name.
Data Fields
• uint16_t vendor_id
• uint16_t device_id
• uint16_t subsystem_vendor_id
• uint16_t subsystem_device_id
A structure describing an ID for a PCI driver. Each driver provides a table of these IDs for each device that
it supports.
Vendor ID or PCI_ANY_ID.
Device ID or PCI_ANY_ID.
Data Fields
• uint64_t phys_addr
• uint64_t len
• void ∗ addr
Data Fields
Number of segments.
Input port.
Hierarchical scheduler
hash information
Data Fields
• uint16_t mbuf_data_room_size
Data Fields
• uint32_t avg
• uint32_t count
• uint64_t q_time
Data Fields
• uint32_t min_th
• uint32_t max_th
• uint32_t pa_const
• uint8_t maxp_inv
• uint8_t wq_log2
maxp_inv
wq_log2
Data Fields
• uint16_t min_th
• uint16_t max_th
• uint16_t maxp_inv
• uint16_t wq_log2
Data Structures
• struct cons
• struct prod
Data Fields
• TAILQ_ENTRY next
• char name [RTE_RING_NAMESIZE]
• int flags
Next in list.
Data Fields
Data Fields
• uint32_t tb_rate
• uint32_t tb_size
• uint32_t tc_rate [RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
• uint32_t tc_period
• uint8_t wrr_weights [RTE_SCHED_QUEUES_PER_PIPE]
Pipe configuration parameters. The period and credits_per_period parameters are measured in bytes, with
one byte meaning the time duration associated with the transmission of one byte on the physical medium of
the output port, with pipe or pipe traffic class rate (measured as percentage of output port rate) determined
as credits_per_period divided by period. One credit represents one byte.
Data Fields
• uint32_t queue:2
• uint32_t traffic_class:2
• uint32_t pipe:20
• uint32_t subport:6
• uint32_t color:2
Path through the scheduler hierarchy used by the scheduler enqueue operation to identify the destination
queue for the current packet. Stored in the field pkt.hash.sched of struct rte_mbuf of each packet, typically
written by the classification stage and read by scheduler enqueue.
Queue ID (0 .. 3)
Traffic class ID (0 .. 3)
Pipe ID
Subport ID
Color
Data Fields
CPU socket ID where the memory for port scheduler should be allocated
Maximum Ethernet frame size (measured in bytes). Should not include the framing overhead.
Packet queue size for each traffic class. All queues within the same pipe traffic class have the same size.
Queues from different pipes serving the same traffic class have the same size.
Pipe profile table defined for current port scheduler instance. Every pipe of the current port scheduler is
configured using one of the profiles from this table.
Data Fields
• uint32_t n_pkts
• uint32_t n_pkts_dropped
• uint32_t n_bytes
• uint32_t n_bytes_dropped
Queue statistics
Data Fields
• uint32_t tb_rate
• uint32_t tb_size
• uint32_t tc_rate [RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]
• uint32_t tc_period
Subport configuration parameters. The period and credits_per_period parameters are measured in bytes,
with one byte meaning the time duration associated with the transmission of one byte on the physical medium
of the output port, with pipe or pipe traffic class rate (measured as percentage of output port rate) determined
as credits_per_period divided by period. One credit represents one byte.
Data Fields
Subport statistics
Number of packets successfully written to current subport for each traffic class
Number of packets dropped by the current subport for each traffic class due to subport queues being full or
congested
Number of bytes successfully written to current subport for each traffic class
Number of bytes dropped by the current subport for each traffic class due to subport queues being full or
congested
Data Fields
• rte_spinlock_t sl
• volatile int user
• volatile int count
Data Fields
Data Fields
The structure defining a tailq header entry for storing in the rte_config structure in shared memory. Each tailq
is identified by name. Any library storing a set of objects e.g. rings, mempools, hash-tables, is recommended
to use an entry here, so as to make it easy for a multi-process app to find already-created elements in shared
memory.
Data Fields
• uint64_t expire
• union rte_timer_status status
• uint64_t period
• rte_timer_cb_t ∗ f
• void ∗ arg
Status of timer.
Callback function.
Data Fields
• uint32_t u32
• uint16_t state
• int16_t owner
Timer status: A union of the state (stopped, pending, running, config) and an owner (the id of the lcore that
owns the timer).
Offload features
Data Fields
• uint16_t src_port
• uint16_t dst_port
• uint32_t tag
• uint32_t cksum
SCTP Header
Source port.
Destin port.
Validation tag.
Checksum.
Data Fields
• uint16_t src_port
• uint16_t dst_port
• uint32_t sent_seq
• uint32_t recv_ack
• uint8_t data_off
• uint8_t tcp_flags
• uint16_t rx_win
• uint16_t cksum
• uint16_t tcp_urp
TCP Header
Data offset.
TCP flags
TCP checksum.
Data Fields
• uint16_t src_port
• uint16_t dst_port
• uint16_t dgram_len
• uint16_t dgram_cksum
UDP Header
Data Fields
• uint16_t vlan_tci
• uint16_t eth_proto
Ethernet VLAN Header. Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type of the
encapsulated frame.
Chapter 3
File Documentation
Typedefs
Functions
Alarm functions
Simple alarm-clock functionality supplied by eal. Does not require hpet support.
3.1.3.1 int rte eal alarm set ( uint64 t us, rte_eal_alarm_callback cb, void ∗ cb arg )
Function to set a callback to be triggered when us microseconds have expired. Accuracy of timing to the
microsecond is not guaranteed. The alarm function will not be called ∗before∗ the requested time, but may
be called a short period of time afterwards. The alarm handler will be called only once. There is no need to
call "rte_eal_alarm_cancel" from within the callback function.
Parameters
us The time in microseconds before the callback is called
cb The function to be called when the alarm expires
cb_arg Pointer parameter to be passed to the callback function
Returns
On success, zero. On failure, a negative error number
3.1.3.2 int rte eal alarm cancel ( rte_eal_alarm_callback cb fn, void ∗ cb arg )
Parameters
cb_fn alarm callback
cb_arg Pointer parameter to be passed to the callback function. To remove all copies of a given
callback function, irrespective of parameter, (void ∗)-1 can be used here.
Returns
• The number of callbacks removed
Data Structures
• struct rte_atomic16_t
• struct rte_atomic32_t
• struct rte_atomic64_t
Defines
• #define MPLOCKED
• #define rte_mb()
• #define rte_wmb()
• #define rte_rmb()
• #define rte_compiler_barrier()
• #define RTE_ATOMIC16_INIT(val)
• #define RTE_ATOMIC32_INIT(val)
• #define RTE_ATOMIC64_INIT(val)
Functions
• static int rte_atomic16_cmpset (volatile uint16_t ∗dst, uint16_t exp, uint16_t src)
• static void rte_atomic16_init (rte_atomic16_t ∗v)
• static int16_t rte_atomic16_read (const rte_atomic16_t ∗v)
• static void rte_atomic16_set (rte_atomic16_t ∗v, int16_t new_value)
• static void rte_atomic16_add (rte_atomic16_t ∗v, int16_t inc)
• static void rte_atomic16_sub (rte_atomic16_t ∗v, int16_t dec)
• static void rte_atomic16_inc (rte_atomic16_t ∗v)
• static void rte_atomic16_dec (rte_atomic16_t ∗v)
• static int16_t rte_atomic16_add_return (rte_atomic16_t ∗v, int16_t inc)
• static int16_t rte_atomic16_sub_return (rte_atomic16_t ∗v, int16_t dec)
• static int rte_atomic16_inc_and_test (rte_atomic16_t ∗v)
• static int rte_atomic16_dec_and_test (rte_atomic16_t ∗v)
• static int rte_atomic16_test_and_set (rte_atomic16_t ∗v)
• static void rte_atomic16_clear (rte_atomic16_t ∗v)
• static int rte_atomic32_cmpset (volatile uint32_t ∗dst, uint32_t exp, uint32_t src)
• static void rte_atomic32_init (rte_atomic32_t ∗v)
• static int32_t rte_atomic32_read (const rte_atomic32_t ∗v)
• static void rte_atomic32_set (rte_atomic32_t ∗v, int32_t new_value)
• static void rte_atomic32_add (rte_atomic32_t ∗v, int32_t inc)
• static void rte_atomic32_sub (rte_atomic32_t ∗v, int32_t dec)
• static void rte_atomic32_inc (rte_atomic32_t ∗v)
• static void rte_atomic32_dec (rte_atomic32_t ∗v)
• static int32_t rte_atomic32_add_return (rte_atomic32_t ∗v, int32_t inc)
• static int32_t rte_atomic32_sub_return (rte_atomic32_t ∗v, int32_t dec)
• static int rte_atomic32_inc_and_test (rte_atomic32_t ∗v)
• static int rte_atomic32_dec_and_test (rte_atomic32_t ∗v)
• static int rte_atomic32_test_and_set (rte_atomic32_t ∗v)
• static void rte_atomic32_clear (rte_atomic32_t ∗v)
• static int rte_atomic64_cmpset (volatile uint64_t ∗dst, uint64_t exp, uint64_t src)
• static void rte_atomic64_init (rte_atomic64_t ∗v)
• static int64_t rte_atomic64_read (rte_atomic64_t ∗v)
• static void rte_atomic64_set (rte_atomic64_t ∗v, int64_t new_value)
• static void rte_atomic64_add (rte_atomic64_t ∗v, int64_t inc)
• static void rte_atomic64_sub (rte_atomic64_t ∗v, int64_t dec)
• static void rte_atomic64_inc (rte_atomic64_t ∗v)
• static void rte_atomic64_dec (rte_atomic64_t ∗v)
• static int64_t rte_atomic64_add_return (rte_atomic64_t ∗v, int64_t inc)
Atomic Operations
This file defines a generic API for atomic operations. The implementation is architecture-specific.
See lib/librte_eal/common/include/i686/arch/rte_atomic.h See lib/librte_eal/common/include/x86_64/arch/rte-
_atomic.h
Atomic Operations on x86_64
Compiler barrier.
Guarantees that operation reordering does not occur at compile time for operations directly before and after
the barrier.
3.2.3.1 static int rte atomic16 cmpset ( volatile uint16 t ∗ dst, uint16 t exp, uint16 t src ) [static]
Parameters
dst The destination location into which the value will be written.
exp The expected value.
src The new value.
Returns
Non-zero on success; 0 on failure.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
Returns
The value of the counter.
3.2.3.4 static void rte atomic16 set ( rte_atomic16_t ∗ v, int16 t new value ) [static]
Parameters
v A pointer to the atomic counter.
new_value The new value for the counter.
3.2.3.5 static void rte atomic16 add ( rte_atomic16_t ∗ v, int16 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
3.2.3.6 static void rte atomic16 sub ( rte_atomic16_t ∗ v, int16 t dec ) [static]
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
3.2.3.9 static int16 t rte atomic16 add return ( rte_atomic16_t ∗ v, int16 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
Returns
The value of v after the addition.
3.2.3.10 static int16 t rte atomic16 sub return ( rte_atomic16_t ∗ v, int16 t dec ) [static]
Atomically subtract a 16-bit value from a counter and return the result.
Atomically subtracts the 16-bit value (inc) from the atomic counter (v) and returns the value of v after the
subtraction.
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Returns
The value of v after the subtraction.
3.2.3.11 static int rte atomic16 inc and test ( rte_atomic16_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after the increment operation is 0; false otherwise.
3.2.3.12 static int rte atomic16 dec and test ( rte_atomic16_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after the decrement operation is 0; false otherwise.
3.2.3.13 static int rte atomic16 test and set ( rte_atomic16_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
0 if failed; else 1, success.
Parameters
v A pointer to the atomic counter.
3.2.3.15 static int rte atomic32 cmpset ( volatile uint32 t ∗ dst, uint32 t exp, uint32 t src ) [static]
Parameters
dst The destination location into which the value will be written.
exp The expected value.
src The new value.
Returns
Non-zero on success; 0 on failure.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
Returns
The value of the counter.
3.2.3.18 static void rte atomic32 set ( rte_atomic32_t ∗ v, int32 t new value ) [static]
Parameters
v A pointer to the atomic counter.
new_value The new value for the counter.
3.2.3.19 static void rte atomic32 add ( rte_atomic32_t ∗ v, int32 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
3.2.3.20 static void rte atomic32 sub ( rte_atomic32_t ∗ v, int32 t dec ) [static]
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
3.2.3.23 static int32 t rte atomic32 add return ( rte_atomic32_t ∗ v, int32 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
Returns
The value of v after the addition.
3.2.3.24 static int32 t rte atomic32 sub return ( rte_atomic32_t ∗ v, int32 t dec ) [static]
Atomically subtract a 32-bit value from a counter and return the result.
Atomically subtracts the 32-bit value (inc) from the atomic counter (v) and returns the value of v after the
subtraction.
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Returns
The value of v after the subtraction.
3.2.3.25 static int rte atomic32 inc and test ( rte_atomic32_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after the increment operation is 0; false otherwise.
3.2.3.26 static int rte atomic32 dec and test ( rte_atomic32_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after the decrement operation is 0; false otherwise.
3.2.3.27 static int rte atomic32 test and set ( rte_atomic32_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
0 if failed; else 1, success.
Parameters
v A pointer to the atomic counter.
3.2.3.29 static int rte atomic64 cmpset ( volatile uint64 t ∗ dst, uint64 t exp, uint64 t src ) [static]
An atomic compare and set function used by the mutex functions. (atomic) equivalent to: if (∗dst == exp)
∗dst = src (all 64-bit words)
Parameters
dst The destination into which the value will be written.
exp The expected value.
src The new value.
Returns
Non-zero on success; 0 on failure.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
Returns
The value of the counter.
3.2.3.32 static void rte atomic64 set ( rte_atomic64_t ∗ v, int64 t new value ) [static]
Parameters
v A pointer to the atomic counter.
new_value The new value of the counter.
3.2.3.33 static void rte atomic64 add ( rte_atomic64_t ∗ v, int64 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
3.2.3.34 static void rte atomic64 sub ( rte_atomic64_t ∗ v, int64 t dec ) [static]
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Parameters
v A pointer to the atomic counter.
Parameters
v A pointer to the atomic counter.
3.2.3.37 static int64 t rte atomic64 add return ( rte_atomic64_t ∗ v, int64 t inc ) [static]
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.
Returns
The value of v after the addition.
3.2.3.38 static int64 t rte atomic64 sub return ( rte_atomic64_t ∗ v, int64 t dec ) [static]
Subtract a 64-bit value from an atomic counter and return the result.
Atomically subtracts the 64-bit value (dec) from the atomic counter (v) and returns the value of v after the
subtraction.
Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.
Returns
The value of v after the subtraction.
3.2.3.39 static int rte atomic64 inc and test ( rte_atomic64_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after the addition is 0; false otherwise.
3.2.3.40 static int rte atomic64 dec and test ( rte_atomic64_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
True if the result after subtraction is 0; false otherwise.
3.2.3.41 static int rte atomic64 test and set ( rte_atomic64_t ∗ v ) [static]
Parameters
v A pointer to the atomic counter.
Returns
0 if failed; else 1, success.
Parameters
v A pointer to the atomic counter.
Defines
• #define likely(x)
• #define unlikely(x)
This compiler builtin allows the developer to indicate if a branch is likely to be taken. Example:
if (likely(x > 1)) do_stuff();
Defines
• #define rte_bswap16(x)
• #define rte_bswap32(x)
• #define rte_bswap64(x)
• #define rte_cpu_to_le_16(x)
• #define rte_cpu_to_le_32(x)
• #define rte_cpu_to_le_64(x)
• #define rte_cpu_to_be_16(x)
• #define rte_cpu_to_be_32(x)
• #define rte_cpu_to_be_64(x)
• #define rte_le_to_cpu_16(x)
• #define rte_le_to_cpu_32(x)
• #define rte_le_to_cpu_64(x)
• #define rte_be_to_cpu_16(x)
• #define rte_be_to_cpu_32(x)
• #define rte_be_to_cpu_64(x)
Defines
• #define __rte_unused
• #define RTE_SET_USED(x)
• #define RTE_PTR_ADD(ptr, x)
• #define RTE_PTR_SUB(ptr, x)
• #define RTE_PTR_DIFF(ptr1, ptr2)
• #define RTE_PTR_ALIGN_FLOOR(ptr, align)
• #define RTE_ALIGN_FLOOR(val, align)
• #define RTE_PTR_ALIGN_CEIL(ptr, align)
• #define RTE_ALIGN_CEIL(val, align)
• #define RTE_PTR_ALIGN(ptr, align)
• #define RTE_ALIGN(val, align)
• #define RTE_BUILD_BUG_ON(condition)
• #define RTE_MIN(a, b)
• #define RTE_MAX(a, b)
• #define offsetof(TYPE, MEMBER)
• #define RTE_STR(x)
• #define RTE_LEN2MASK(ln, tp)
• #define RTE_DIM(a)
Functions
Generic, commonly-used macro and inline function definitions for Intel DPDK.
get the difference between two pointer values, i.e. how far apart in bytes are the locations they point two. It
is assumed that ptr1 is greater than ptr2.
Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as
the first parameter, and point to an address no higher than the first parameter. Second parameter must be
a power-of-two value.
Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first
parameter, and will be no bigger than the first parameter. Second parameter must be a power-of-two value.
Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as
the first parameter, and point to an address no lower than the first parameter. Second parameter must be a
power-of-two value.
Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first
parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value.
Macro to align a pointer to a given power-of-two. The resultant pointer will be a pointer of the same type as
the first parameter, and point to an address no lower than the first parameter. Second parameter must be a
power-of-two value. This function is the same as RTE_PTR_ALIGN_CEIL
Macro to align a value to a given power-of-two. The resultant value will be of the same type as the first
parameter, and will be no lower than the first parameter. Second parameter must be a power-of-two value.
This function is the same as RTE_ALIGN_CEIL
Mask value of type <tp> for the first <ln> bit set.
3.5.3.1 static uintptr t rte align floor int ( uintptr t ptr, uintptr t align ) [static]
Function which rounds an unsigned int down to a given power-of-two value. Takes uintptr_t types as
parameters, as this type of operation is most commonly done for pointer alignment. (See also RTE_AL-
IGN_FLOOR, RTE_ALIGN_CEIL, RTE_ALIGN, RTE_PTR_ALIGN_FLOOR, RTE_PTR_ALIGN_CEL, RT-
E_PTR_ALIGN macros)
Parameters
ptr The value to be rounded down
align The power-of-two of which the result must be a multiple.
Returns
Function returns a properly aligned value where align is a power-of-two. If align is not a power-of-two,
result will be incorrect.
3.5.3.2 static int rte is aligned ( void ∗ ptr, unsigned align ) [static]
Parameters
ptr The pointer whose alignment is to be checked
align The power-of-two value to which the ptr should be aligned
Returns
True(1) where the pointer is correctly aligned, false(0) otherwise
Parameters
n Number to check
Returns
1 if true, 0 otherwise
Parameters
x The integer value to algin
Returns
Input parameter aligned to the next power of 2
Parameters
x The 64b value to algin
Returns
Input parameter aligned to the next power of 2
Searches the input parameter for the least significant set bit (starting from zero). If a least significant 1 bit
is found, its bit index is returned. If the content of the input parameter is zero, then the content of the return
value is undefined.
Parameters
v input parameter, should not be zero.
Returns
least significant set bit in the input parameter.
3.5.3.7 static uint64 t rte str to size ( const char ∗ str ) [static]
Converts a numeric string to the equivalent uint64_t value. As well as straight number conversion, also
recognises the suffixes k, m and g for kilobytes, megabytes and gigabytes respectively.
If a negative number is passed in i.e. a string with the first non-black character being "-", zero is returned.
Zero is also returned in the case of an error with the strtoull call in the function.
Parameters
str String containing number to convert.
Returns
Number.
3.5.3.8 void rte exit ( int exit code, const char ∗ format, ... )
Function to terminate the application immediately, printing an error message and returning the exit_code
back to the shell.
This function never returns
Parameters
exit_code The exit code to be returned by the application
format The format string to be used for printing the message. This can include printf format
characters which will be expanded using any further parameters to the function.
Enumerations
• enum rte_cpu_flag_t { RTE_CPUFLAG_SSE3, RTE_CPUFLAG_PCLMULQDQ, RTE_CPUFLAG_D-
TES64, RTE_CPUFLAG_MONITOR, RTE_CPUFLAG_DS_CPL, RTE_CPUFLAG_VMX, RTE_CPU-
FLAG_SMX, RTE_CPUFLAG_EIST, RTE_CPUFLAG_TM2, RTE_CPUFLAG_SSSE3, RTE_CPUF-
LAG_CNXT_ID, RTE_CPUFLAG_FMA, RTE_CPUFLAG_CMPXCHG16B, RTE_CPUFLAG_XTPR,
RTE_CPUFLAG_PDCM, RTE_CPUFLAG_PCID, RTE_CPUFLAG_DCA, RTE_CPUFLAG_SSE4_-
1, RTE_CPUFLAG_SSE4_2, RTE_CPUFLAG_X2APIC, RTE_CPUFLAG_MOVBE, RTE_CPUFLA-
G_POPCNT, RTE_CPUFLAG_TSC_DEADLINE, RTE_CPUFLAG_AES, RTE_CPUFLAG_XSAVE,
RTE_CPUFLAG_OSXSAVE, RTE_CPUFLAG_AVX, RTE_CPUFLAG_F16C, RTE_CPUFLAG_RD-
RAND, RTE_CPUFLAG_FPU, RTE_CPUFLAG_VME, RTE_CPUFLAG_DE, RTE_CPUFLAG_PSE,
RTE_CPUFLAG_TSC, RTE_CPUFLAG_MSR, RTE_CPUFLAG_PAE, RTE_CPUFLAG_MCE, RTE-
_CPUFLAG_CX8, RTE_CPUFLAG_APIC, RTE_CPUFLAG_SEP, RTE_CPUFLAG_MTRR, RTE_C-
PUFLAG_PGE, RTE_CPUFLAG_MCA, RTE_CPUFLAG_CMOV, RTE_CPUFLAG_PAT, RTE_CPU-
FLAG_PSE36, RTE_CPUFLAG_PSN, RTE_CPUFLAG_CLFSH, RTE_CPUFLAG_DS, RTE_CPUF-
LAG_ACPI, RTE_CPUFLAG_MMX, RTE_CPUFLAG_FXSR, RTE_CPUFLAG_SSE, RTE_CPUFLA-
G_SSE2, RTE_CPUFLAG_SS, RTE_CPUFLAG_HTT, RTE_CPUFLAG_TM, RTE_CPUFLAG_PBE,
RTE_CPUFLAG_DIGTEMP, RTE_CPUFLAG_TRBOBST, RTE_CPUFLAG_ARAT, RTE_CPUFLA-
G_PLN, RTE_CPUFLAG_ECMD, RTE_CPUFLAG_PTM, RTE_CPUFLAG_MPERF_APERF_MSR,
RTE_CPUFLAG_ACNT2, RTE_CPUFLAG_ENERGY_EFF, RTE_CPUFLAG_FSGSBASE, RTE_C-
PUFLAG_BMI1, RTE_CPUFLAG_HLE, RTE_CPUFLAG_AVX2, RTE_CPUFLAG_SMEP, RTE_CP-
UFLAG_BMI2, RTE_CPUFLAG_ERMS, RTE_CPUFLAG_INVPCID, RTE_CPUFLAG_RTM, RTE_C-
PUFLAG_LAHF_SAHF, RTE_CPUFLAG_LZCNT, RTE_CPUFLAG_SYSCALL, RTE_CPUFLAG_XD,
RTE_CPUFLAG_1GB_PG, RTE_CPUFLAG_RDTSCP, RTE_CPUFLAG_EM64T, RTE_CPUFLAG-
_INVTSC, RTE_CPUFLAG_NUMFLAGS }
Functions
• int rte_cpu_get_flag_enabled (enum rte_cpu_flag_t flag)
• void rte_cpu_check_supported (void)
Enumerator:
RTE_CPUFLAG_SSE3 SSE3
RTE_CPUFLAG_PCLMULQDQ PCLMULQDQ
RTE_CPUFLAG_DTES64 DTES64
RTE_CPUFLAG_MONITOR MONITOR
RTE_CPUFLAG_DS_CPL DS_CPL
RTE_CPUFLAG_VMX VMX
RTE_CPUFLAG_SMX SMX
RTE_CPUFLAG_EIST EIST
RTE_CPUFLAG_TM2 TM2
RTE_CPUFLAG_SSSE3 SSSE3
RTE_CPUFLAG_CNXT_ID CNXT_ID
RTE_CPUFLAG_FMA FMA
RTE_CPUFLAG_CMPXCHG16B CMPXCHG16B
RTE_CPUFLAG_XTPR XTPR
RTE_CPUFLAG_PDCM PDCM
RTE_CPUFLAG_PCID PCID
RTE_CPUFLAG_DCA DCA
RTE_CPUFLAG_SSE4_1 SSE4_1
RTE_CPUFLAG_SSE4_2 SSE4_2
RTE_CPUFLAG_X2APIC X2APIC
RTE_CPUFLAG_MOVBE MOVBE
RTE_CPUFLAG_POPCNT POPCNT
RTE_CPUFLAG_TSC_DEADLINE TSC_DEADLINE
RTE_CPUFLAG_AES AES
RTE_CPUFLAG_XSAVE XSAVE
RTE_CPUFLAG_OSXSAVE OSXSAVE
RTE_CPUFLAG_AVX AVX
RTE_CPUFLAG_F16C F16C
RTE_CPUFLAG_RDRAND RDRAND
RTE_CPUFLAG_FPU FPU
RTE_CPUFLAG_VME VME
RTE_CPUFLAG_DE DE
RTE_CPUFLAG_PSE PSE
RTE_CPUFLAG_TSC TSC
RTE_CPUFLAG_MSR MSR
RTE_CPUFLAG_PAE PAE
RTE_CPUFLAG_MCE MCE
RTE_CPUFLAG_CX8 CX8
RTE_CPUFLAG_APIC APIC
RTE_CPUFLAG_SEP SEP
RTE_CPUFLAG_MTRR MTRR
RTE_CPUFLAG_PGE PGE
RTE_CPUFLAG_MCA MCA
RTE_CPUFLAG_CMOV CMOV
RTE_CPUFLAG_PAT PAT
RTE_CPUFLAG_PSE36 PSE36
RTE_CPUFLAG_PSN PSN
RTE_CPUFLAG_CLFSH CLFSH
RTE_CPUFLAG_DS DS
RTE_CPUFLAG_ACPI ACPI
RTE_CPUFLAG_MMX MMX
RTE_CPUFLAG_FXSR FXSR
RTE_CPUFLAG_SSE SSE
RTE_CPUFLAG_SSE2 SSE2
RTE_CPUFLAG_SS SS
RTE_CPUFLAG_HTT HTT
RTE_CPUFLAG_TM TM
RTE_CPUFLAG_PBE PBE
RTE_CPUFLAG_DIGTEMP DIGTEMP
RTE_CPUFLAG_TRBOBST TRBOBST
RTE_CPUFLAG_ARAT ARAT
RTE_CPUFLAG_PLN PLN
RTE_CPUFLAG_ECMD ECMD
RTE_CPUFLAG_PTM PTM
RTE_CPUFLAG_MPERF_APERF_MSR MPERF_APERF_MSR
RTE_CPUFLAG_ACNT2 ACNT2
RTE_CPUFLAG_ENERGY_EFF ENERGY_EFF
RTE_CPUFLAG_FSGSBASE FSGSBASE
RTE_CPUFLAG_BMI1 BMI1
RTE_CPUFLAG_HLE Hardware Lock elision
RTE_CPUFLAG_AVX2 AVX2
RTE_CPUFLAG_SMEP SMEP
RTE_CPUFLAG_BMI2 BMI2
RTE_CPUFLAG_ERMS ERMS
RTE_CPUFLAG_INVPCID INVPCID
RTE_CPUFLAG_RTM Transactional memory
RTE_CPUFLAG_LAHF_SAHF LAHF_SAHF
RTE_CPUFLAG_LZCNT LZCNT
RTE_CPUFLAG_SYSCALL SYSCALL
RTE_CPUFLAG_XD XD
RTE_CPUFLAG_1GB_PG 1GB_PG
RTE_CPUFLAG_RDTSCP RDTSCP
RTE_CPUFLAG_EM64T EM64T
RTE_CPUFLAG_INVTSC INVTSC
RTE_CPUFLAG_NUMFLAGS This should always be the last!
3.6.3.1 int rte cpu get flag enabled ( enum rte_cpu_flag_t flag )
Parameters
flag CPU flag to query CPU for
Returns
1 if flag is available 0 if flag is not available -ENOENT if flag is invalid
This function checks that the currently used CPU supports the CPU features that were specified at compile
time. It is called automatically within the EAL, so does not need to be used by applications.
Functions
Returns
The TSC for this lcore.
Returns
The TSC frequency for this lcore
Returns
the number of cycles
Returns
the number of cycles
Returns
The number of cycles in one second.
Initialise the HPET for use. This must be called before the rte_get_hpet_hz and rte_get_hpet_cycles APIs
are called. If this function does not succeed, then the HPET functions are unavailable and should not be
called.
Parameters
make_default If set, the hpet timer becomes the default timer whose values are returned by the rte_-
get_timer_hz/cycles API calls
Returns
0 on success, -1 on error, and the make_default parameter is ignored.
Get the number of cycles since boot from the default timer.
Returns
The number of cycles
Get the number of cycles in one second for the default timer.
Returns
The number of cycles in one second.
Parameters
Parameters
ms The number of milliseconds to wait.
Defines
• #define rte_panic_(func, format,...)
Functions
• void rte_dump_stack (void)
• void rte_dump_registers (void)
Parameters
format The format string
args The variable list of arguments.
Data Structures
• struct rte_config
Defines
• #define RTE_VERSION
• #define RTE_MAGIC
• #define EAL_FLG_HIGH_IOPL
• #define RTE_EAL_TAILQ_RWLOCK
• #define RTE_EAL_MEMPOOL_RWLOCK
• #define RTE_EAL_TAILQ_INSERT_TAIL(idx, type, elm)
• #define RTE_EAL_TAILQ_REMOVE(idx, type, elm)
• #define RTE_EAL_TAILQ_EXIST_CHECK(idx)
Typedefs
Enumerations
• enum rte_lcore_role_t
• enum rte_proc_type_t
Functions
• struct rte_config ∗ rte_eal_get_configuration (void)
• enum rte_lcore_role_t rte_eal_lcore_role (unsigned lcore_id)
• enum rte_proc_type_t rte_eal_process_type (void)
• int rte_eal_init (int argc, char ∗∗argv)
• rte_usage_hook_t rte_set_application_usage_hook (rte_usage_hook_t usage_func)
3.9.2.6 #define RTE EAL TAILQ INSERT TAIL( idx, type, elm )
Parameters
idx a kind of tailq define in enum rte_tailq_t
type type of list(tailq head)
elm The element will be added into the list
Parameters
idx a kind of tailq define in enum rte_tailq_t
type type of list(tailq head)
elm The element will be remove from the list
Parameters
idx a kind of tailq define in enum rte_tailq_t
Returns
A pointer to the global configuration structure.
Parameters
lcore_id The identifier of the lcore.
Returns
The role of the lcore.
Returns
The process type
Parameters
argc The argc argument that was given to the main() function.
argv The argv argument that was given to the main() function.
Returns
• On success, the number of parsed arguments, which is greater or equal to zero. After the call to
rte_eal_init(), all arguments argv[x] with x < ret may be modified and should not be accessed by
the application.
• On failure, a negative error value.
3.9.5.5 rte_usage_hook_t rte set application usage hook ( rte_usage_hook_t usage func )
Parameters
func The func argument is a function pointer to the application usage routine. Called function
is defined using rte_usage_hook_t typedef, which is of the form void rte_usage_-
func(const char ∗ prgname).
Calling this routine with a NULL value will reset the usage hook routine and return the current value, which
could be NULL.
Returns
• Returns the current value of the rte_application_usage pointer to allow the caller to daisy chain the
usage routines if needing more then one.
Defines
• #define rte_errno
• #define __ELASTERROR
Enumerations
• enum { RTE_MIN_ERRNO, E_RTE_SECONDARY, E_RTE_NO_CONFIG, E_RTE_NO_TAILQ, R-
TE_MAX_ERRNO }
Functions
• RTE_DECLARE_PER_LCORE (int, _rte_errno)
Error number value, stored per-thread, which can be queried after calls to certain functions to determine
why those functions failed.
Uses standard values from errno.h wherever possible, with a small number of additional possible values for
RTE-specific conditions.
Check if we have a defined value for the max system-defined errno values. if no max defined, start from
1000 to prevent overlap with standard values
Error types
Enumerator:
RTE_MIN_ERRNO Start numbering above std errno vals
E_RTE_SECONDARY Operation not allowed in secondary processes
E_RTE_NO_CONFIG Missing rte_config
E_RTE_NO_TAILQ Uninitialised TAILQ
RTE_MAX_ERRNO Max RTE error number
Function which returns a printable string describing a particular error code. For non-RTE-specific error
codes, this function returns the value from the libc strerror function.
Parameters
errnum The error number to be looked up - generally the value of rte_errno
Returns
A pointer to a thread-local string containing the text describing the error.
Data Structures
• struct rte_eth_stats
• struct rte_eth_link
• struct rte_eth_thresh
• struct rte_eth_rxmode
• struct rte_eth_rss_conf
• struct rte_eth_vlan_mirror
• struct rte_eth_vmdq_mirror_conf
• struct rte_eth_rss_reta
• struct rte_eth_dcb_rx_conf
• struct rte_eth_vmdq_dcb_tx_conf
• struct rte_eth_dcb_tx_conf
• struct rte_eth_vmdq_tx_conf
• struct rte_eth_vmdq_dcb_conf
• struct rte_eth_vmdq_rx_conf
• struct rte_eth_txmode
• struct rte_eth_rxconf
• struct rte_eth_txconf
• struct rte_eth_fc_conf
• struct rte_eth_pfc_conf
• struct rte_fdir_conf
• struct rte_fdir_filter
• struct rte_fdir_masks
• struct rte_eth_fdir
• struct rte_intr_conf
• struct rte_eth_conf
• struct rte_eth_dev_info
• struct eth_dev_ops
• struct rte_eth_dev
• struct rte_eth_dev_sriov
• struct rte_eth_dev_data
• struct eth_driver
Defines
• #define ETH_LINK_SPEED_AUTONEG
• #define ETH_LINK_SPEED_10
• #define ETH_LINK_SPEED_100
• #define ETH_LINK_SPEED_1000
• #define ETH_LINK_SPEED_10000
• #define ETH_LINK_AUTONEG_DUPLEX
• #define ETH_LINK_HALF_DUPLEX
• #define ETH_LINK_FULL_DUPLEX
• #define ETH_RSS
• #define ETH_DCB_NONE
• #define ETH_RSS_IPV4
• #define ETH_RSS_IPV4_TCP
• #define ETH_RSS_IPV6
• #define ETH_RSS_IPV6_EX
• #define ETH_RSS_IPV6_TCP
• #define ETH_RSS_IPV6_TCP_EX
• #define ETH_RSS_IPV4_UDP
• #define ETH_RSS_IPV6_UDP
• #define ETH_RSS_IPV6_UDP_EX
• #define ETH_VMDQ_MAX_VLAN_FILTERS
• #define ETH_DCB_NUM_USER_PRIORITIES
• #define ETH_VMDQ_DCB_NUM_QUEUES
• #define ETH_DCB_NUM_QUEUES
• #define ETH_DCB_PG_SUPPORT
• #define ETH_DCB_PFC_SUPPORT
• #define ETH_VLAN_STRIP_OFFLOAD
• #define ETH_VLAN_FILTER_OFFLOAD
• #define ETH_VLAN_EXTEND_OFFLOAD
• #define ETH_VLAN_STRIP_MASK
• #define ETH_VLAN_FILTER_MASK
• #define ETH_VLAN_EXTEND_MASK
• #define ETH_VLAN_ID_MAX
• #define ETH_NUM_RECEIVE_MAC_ADDR
• #define ETH_VMDQ_NUM_UC_HASH_ARRAY
• #define ETH_VMDQ_ACCEPT_UNTAG
• #define ETH_VMDQ_ACCEPT_HASH_MC
• #define ETH_VMDQ_ACCEPT_HASH_UC
• #define ETH_VMDQ_ACCEPT_BROADCAST
• #define ETH_VMDQ_ACCEPT_MULTICAST
• #define ETH_VMDQ_NUM_MIRROR_RULE
• #define ETH_VMDQ_POOL_MIRROR
• #define ETH_VMDQ_UPLINK_MIRROR
• #define ETH_VMDQ_DOWNLIN_MIRROR
• #define ETH_VMDQ_VLAN_MIRROR
• #define ETH_TXQ_FLAGS_NOMULTSEGS
• #define ETH_TXQ_FLAGS_NOREFCOUNT
• #define ETH_TXQ_FLAGS_NOMULTMEMP
• #define ETH_TXQ_FLAGS_NOVLANOFFL
• #define ETH_TXQ_FLAGS_NOXSUMSCTP
• #define ETH_TXQ_FLAGS_NOXSUMUDP
• #define ETH_TXQ_FLAGS_NOXSUMTCP
Typedefs
• typedef uint32_t(∗ eth_rx_queue_count_t )(struct rte_eth_dev ∗dev, uint16_t rx_queue_id)
• typedef int(∗ eth_rx_descriptor_done_t )(void ∗rxq, uint16_t offset)
• typedef void(∗ rte_eth_dev_cb_fn )(uint8_t port_id, enum rte_eth_event_type event, void ∗cb_arg)
Enumerations
• enum rte_eth_rx_mq_mode { ETH_MQ_RX_NONE, ETH_MQ_RX_RSS, ETH_MQ_RX_DCB, ETH-
_MQ_RX_DCB_RSS, ETH_MQ_RX_VMDQ_ONLY, ETH_MQ_RX_VMDQ_RSS, ETH_MQ_RX_V-
MDQ_DCB, ETH_MQ_RX_VMDQ_DCB_RSS }
• enum rte_eth_tx_mq_mode { ETH_MQ_TX_NONE, ETH_MQ_TX_DCB, ETH_MQ_TX_VMDQ_DCB,
ETH_MQ_TX_VMDQ_ONLY }
• enum rte_eth_nb_tcs { ETH_4_TCS, ETH_8_TCS }
• enum rte_eth_nb_pools { ETH_8_POOLS, ETH_16_POOLS, ETH_32_POOLS, ETH_64_POOLS }
• enum rte_eth_fc_mode { RTE_FC_NONE, RTE_FC_RX_PAUSE, RTE_FC_TX_PAUSE, RTE_FC_-
FULL }
• enum rte_fdir_mode { RTE_FDIR_MODE_NONE, RTE_FDIR_MODE_SIGNATURE, RTE_FDIR_M-
ODE_PERFECT }
• enum rte_fdir_pballoc_type { RTE_FDIR_PBALLOC_64K, RTE_FDIR_PBALLOC_128K, RTE_FDIR-
_PBALLOC_256K }
• enum rte_fdir_status_mode { RTE_FDIR_NO_REPORT_STATUS, RTE_FDIR_REPORT_STATUS,
RTE_FDIR_REPORT_STATUS_ALWAYS }
• enum rte_l4type { RTE_FDIR_L4TYPE_NONE, RTE_FDIR_L4TYPE_UDP, RTE_FDIR_L4TYPE_T-
CP, RTE_FDIR_L4TYPE_SCTP }
• enum rte_iptype { RTE_FDIR_IPTYPE_IPV4, RTE_FDIR_IPTYPE_IPV6 }
• enum rte_eth_event_type { RTE_ETH_EVENT_UNKNOWN, RTE_ETH_EVENT_INTR_LSC, RTE_-
ETH_EVENT_MAX }
Functions
• uint8_t rte_eth_dev_count (void)
• struct rte_eth_dev ∗ rte_eth_dev_allocate (void)
• int rte_igb_pmd_init (void)
• int rte_em_pmd_init (void)
• int rte_igbvf_pmd_init (void)
• int rte_ixgbe_pmd_init (void)
• The application-oriented Ethernet API that includes functions to setup an Ethernet device (configure
it, setup its RX and TX queues and start it), to get its MAC address, the speed and the status of its
physical link, to receive and to transmit packets, and so on.
• The driver-oriented Ethernet API that exports a function allowing an Ethernet Poll Mode Driver (PMD)
to simultaneously register itself as an Ethernet device driver and as a PCI driver for a set of matching
PCI [Ethernet] devices classes.
By default, all the functions of the Ethernet Device API exported by a PMD are lock-free functions which
assume to not be invoked in parallel on different logical cores to work on the same target object. For
instance, the receive function of a PMD cannot be invoked in parallel on two logical cores to poll the same
RX queue [of the same port]. Of course, this function can be invoked in parallel by different logical cores on
different RX queues. It is the responsibility of the upper level application to enforce this rule.
If needed, parallel accesses by multiple logical cores to shared queues shall be explicitly protected by
dedicated inline lock-aware functions built on top of their corresponding lock-free functions of the PMD API.
In all functions of the Ethernet API, the Ethernet device is designated by an integer >= 0 named the device
port identifier.
At the Ethernet driver level, Ethernet devices are represented by a generic data structure of type ∗rte_eth_-
dev∗.
Ethernet devices are dynamically registered during the PCI probing phase performed at EAL initialization
time. When an Ethernet device is being probed, an ∗rte_eth_dev∗ structure and a new port identifier are
allocated for that device. Then, the eth_dev_init() function supplied by the Ethernet driver matching the
probed PCI device is invoked to properly initialize the device.
The role of the device init function consists of resetting the hardware, checking access to Non-volatile -
Memory (NVM), reading the MAC address from NVM etc.
If the device init operation is successful, the correspondence between the port identifier assigned to the new
device and its associated ∗rte_eth_dev∗ structure is effectively registered. Otherwise, both the ∗rte_eth_-
dev∗ structure and the port identifier are freed.
The functions exported by the application Ethernet API to setup a device designated by its port identifier
must be invoked in the following order:
• rte_eth_dev_configure()
• rte_eth_tx_queue_setup()
• rte_eth_rx_queue_setup()
• rte_eth_dev_start()
Then, the network application can invoke, in any order, the functions exported by the Ethernet API to get the
MAC address of a given device, to get the speed and the status of a device physical link, to receive/transmit
[burst of] packets, and so on.
If the application wants to change the configuration (i.e. call rte_eth_dev_configure(), rte_eth_tx_queue_-
setup(), or rte_eth_rx_queue_setup()), it must call rte_eth_dev_stop() first to stop the device and then do
the reconfiguration before calling rte_eth_dev_start() again. The tramsit and receive functions should not be
invoked when the device is stopped.
Please note that some configuration is not stored between calls to rte_eth_dev_stop()/rte_eth_dev_start().
The following configuration will be retained:
• receive mode configuration (promiscuous mode, hardware checksum mode, RSS/VMDQ settings etc.)
• VLAN filtering configuration
• MAC addresses supplied to MAC address array
• flow director filtering mode (but not filtering rules)
• NIC queue statistics mappings
Any other configuration will not be stored and will need to be re-entered after a call to rte_eth_dev_start().
Finally, a network application can close an Ethernet device by invoking the rte_eth_dev_close() function.
Each function of the application Ethernet API invokes a specific function of the PMD that controls the target
device designated by its port identifier. For this purpose, all device-specific functions of an Ethernet driver
are supplied through a set of pointers contained in a generic structure of type ∗eth_dev_ops∗. The address
of the ∗eth_dev_ops∗ structure is stored in the ∗rte_eth_dev∗ structure by the device init function of the
Ethernet driver, which is invoked during the PCI probing phase, as explained earlier.
In other words, each function of the Ethernet API simply retrieves the ∗rte_eth_dev∗ structure associated
with the device port identifier and performs an indirect invocation of the corresponding driver function
supplied in the ∗eth_dev_ops∗ structure of the ∗rte_eth_dev∗ structure.
For performance reasons, the address of the burst-oriented RX and TX functions of the Ethernet driver
are not contained in the ∗eth_dev_ops∗ structure. Instead, they are directly stored at the beginning of the
∗rte_eth_dev∗ structure to avoid an extra indirect memory access during their invocation.
RTE ethernet device drivers do not use interrupts for transmitting or receiving. Instead, Ethernet drivers
export Poll-Mode receive and transmit functions to applications. Both receive and transmit functions are
packet-burst oriented to minimize their cost per packet through the following optimizations:
• Sharing among multiple packets the incompressible cost of the invocation of receive/transmit functions.
• Enabling receive/transmit functions to take advantage of burst-oriented hardware features (L1 cache,
prefetch instructions, NIC head/tail registers) to minimize the number of CPU cycles per packet, for
instance, by avoiding useless read memory accesses to ring descriptors, or by systematically using
arrays of pointers that exactly fit L1 cache line boundaries and sizes.
The burst-oriented receive function does not provide any error notification, to avoid the corresponding
overhead. As a hint, the upper-level application might check the status of the device link once being
systematically returned a 0 value by the receive function of the driver for a given number of tries.
10 megabits/second.
100 megabits/second.
1 gigabits/second.
10 gigabits/second.
Auto-negotiate duplex.
Half-duplex connection.
Full-duplex connection.
IPv4 packet.
IPv4/TCP packet.
IPv6 packet.
IPv6/TCP packet.
IPv4/UDP packet.
IPv6/UDP packet.
multicast promiscuous.
VLAN Mirroring.
3.11.3.1 typedef uint32 t(∗ eth_rx_queue_count_t)(struct rte_eth_dev ∗dev, uint16 t rx queue id)
3.11.3.3 typedef void(∗ rte_eth_dev_cb_fn)(uint8 t port id, enum rte_eth_event_type event, void ∗cb arg)
A set of values to identify what method is to be used to route packets to multiple queues.
Enumerator:
ETH_MQ_RX_NONE None of DCB,RSS or VMDQ mode
ETH_MQ_RX_RSS For RX side, only RSS is on
ETH_MQ_RX_DCB For RX side,only DCB is on.
ETH_MQ_RX_DCB_RSS Both DCB and RSS enable
ETH_MQ_RX_VMDQ_ONLY Only VMDQ, no RSS nor DCB
ETH_MQ_RX_VMDQ_RSS RSS mode with VMDQ
ETH_MQ_RX_VMDQ_DCB Use VMDQ+DCB to route traffic to queues
ETH_MQ_RX_VMDQ_DCB_RSS Enable both VMDQ and DCB in VMDq
A set of values to identify what method is to be used to transmit packets using multi-TCs.
Enumerator:
ETH_MQ_TX_NONE It is in neither DCB nor VT mode.
ETH_MQ_TX_DCB For TX side,only DCB is on.
ETH_MQ_TX_VMDQ_DCB For TX side,both DCB and VT is on.
ETH_MQ_TX_VMDQ_ONLY Only VT on, no DCB
This enum indicates the possible number of traffic classes in DCB configratioins
Enumerator:
ETH_4_TCS 4 TCs with DCB.
ETH_8_TCS 8 TCs with DCB.
This enum indicates the possible number of queue pools in VMDQ configurations.
Enumerator:
ETH_8_POOLS 8 VMDq pools.
ETH_16_POOLS 16 VMDq pools.
ETH_32_POOLS 32 VMDq pools.
ETH_64_POOLS 64 VMDq pools.
Enumerator:
RTE_FC_NONE Disable flow control.
RTE_FC_RX_PAUSE RX pause frame, enable flowctrl on TX side.
RTE_FC_TX_PAUSE TX pause frame, enable flowctrl on RX side.
RTE_FC_FULL Enable flow control on both side.
Enumerator:
RTE_FDIR_MODE_NONE Disable FDIR support.
RTE_FDIR_MODE_SIGNATURE Enable FDIR signature filter mode.
RTE_FDIR_MODE_PERFECT Enable FDIR perfect filter mode.
Memory space that can be configured to store Flow Director filters in the board memory.
Enumerator:
RTE_FDIR_PBALLOC_64K 64k.
RTE_FDIR_PBALLOC_128K 128k.
RTE_FDIR_PBALLOC_256K 256k.
Enumerator:
RTE_FDIR_NO_REPORT_STATUS Never report FDIR hash.
RTE_FDIR_REPORT_STATUS Only report FDIR hash for matching pkts.
RTE_FDIR_REPORT_STATUS_ALWAYS Always report FDIR hash.
Enumerator:
RTE_FDIR_L4TYPE_NONE None.
RTE_FDIR_L4TYPE_UDP UDP.
RTE_FDIR_L4TYPE_TCP TCP.
RTE_FDIR_L4TYPE_SCTP SCTP.
Enumerator:
RTE_FDIR_IPTYPE_IPV4 IPv4.
RTE_FDIR_IPTYPE_IPV6 IPv6.
The eth device event type for interrupt, and maybe others in the future.
Enumerator:
RTE_ETH_EVENT_UNKNOWN unknown event type
RTE_ETH_EVENT_INTR_LSC lsc interrupt event
RTE_ETH_EVENT_MAX max value of this enum
Get the total number of Ethernet devices that have been successfully initialized by the [matching] Ethernet
driver during the PCI probing phase. All devices whose port identifier is in the range [0, rte_eth_dev_count()
- 1] can be operated on by network applications.
Returns
• The total number of usable Ethernet devices.
Function for internal use by dummy drivers primarily, e.g. ring-based driver. Allocates a new ethdev slot for
an ethernet device and returns the pointer to that slot for the driver to use.
Returns
• Slot in the rte_dev_devices array for a new device;
The initialization function of the driver for Intel(r) IGB Gigabit Ethernet Controller devices. This function is
invoked once at EAL start time.
Returns
0 on success
The initialization function of the driver for Intel(r) EM Gigabit Ethernet Controller devices. This function is
invoked once at EAL start time.
Returns
0 on success
The initialization function of the driver for 1Gbps Intel IGB_VF Ethernet devices. Invoked once at EAL start
time.
Returns
0 on success
The initialization function of the driver for 10Gbps Intel IXGBE Ethernet devices. Invoked once at EAL start
time.
Returns
0 on success
The initialization function of the driver for 10Gbps Intel IXGBE_VF Ethernet devices. Invoked once at EAL
start time.
Returns
0 on success
The initialization function of the driver for Qumranet virtio-net Ethernet devices. Invoked once at EAL start
time.
Returns
0 on success
The initialization function of the driver for VMware VMXNET3 Ethernet devices. Invoked once at EAL start
time.
Returns
0 on success
The initialization function of ∗all∗ supported and enabled drivers. Right now, the following PMDs are
supported:
• igb
• igbvf
• em
• ixgbe
• ixgbevf
• virtio
3.11.5.11 int rte eth dev configure ( uint8 t port id, uint16 t nb rx queue, uint16 t nb tx queue, const struct
rte_eth_conf ∗ eth conf )
Configure 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.
Parameters
port_id The port identifier of the Ethernet device to configure.
nb_rx_queue The number of receive queues to set up for the Ethernet device.
nb_tx_queue The number of transmit queues to set up for the Ethernet device.
eth_conf The pointer to the configuration data to be used for the Ethernet device. The ∗rte_eth_-
conf∗ structure includes:
• the hardware offload features to activate, with dedicated fields for each statically
configurable offload hardware feature provided by Ethernet devices, such as IP
checksum or VLAN tag stripping for example.
• the Receive Side Scaling (RSS) configuration when using multiple RX queues per
port.
Embedding all configuration information in a single data structure is the more flexible method that allows the
addition of new features without changing the syntax of the API.
Returns
• 0: Success, device configured.
• <0: Error code returned by the driver configuration function.
3.11.5.12 int rte eth rx queue setup ( uint8 t port id, uint16 t rx queue id, uint16 t nb rx desc, unsigned int
socket id, const struct rte_eth_rxconf ∗ rx conf, struct rte_mempool ∗ mb pool )
Parameters
port_id The port identifier of the Ethernet device.
rx_queue_id 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().
nb_rx_desc The number of receive descriptors to allocate for the receive ring.
socket_id The ∗socket_id∗ 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 descriptors of the ring.
rx_conf The pointer to 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.
mb_pool The pointer to the memory pool from which to allocate ∗rte_mbuf∗ network memory
buffers to populate each descriptor of the receive ring.
Returns
• 0: Success, receive queue correctly set up.
• -EINVAL: The size of network buffers which can be allocated from the 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.
3.11.5.13 int rte eth tx queue setup ( uint8 t port id, uint16 t tx queue id, uint16 t nb tx desc, unsigned int
socket id, const struct rte_eth_txconf ∗ tx conf )
Parameters
port_id The port identifier of the Ethernet device.
tx_queue_id 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().
nb_tx_desc The number of transmit descriptors to allocate for the transmit ring.
socket_id The ∗socket_id∗ argument is 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.
tx_conf The pointer to the configuration data to be used for the transmit queue. 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 ∗txq_flags∗ member contains flags to pass to the TX queue setup function
to configure the behavior of the TX queue. This should be set to 0 if no special
configuration is required.
Note that setting ∗tx_free_thresh∗ or ∗tx_rs_thresh∗ value to 0 forces the transmit function to use default
values.
Returns
• 0: Success, the transmit queue is correctly set up.
• -ENOMEM: Unable to allocate the transmit ring descriptors.
Parameters
port_id The port identifier of the Ethernet device.
Returns
• 0: Success, Ethernet device started.
• <0: Error code of the driver device start function.
Stop an Ethernet device. The device can be restarted with a call to rte_eth_dev_start()
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Returns
• (1) if promiscuous is enabled
• (0) if promiscuous is disabled.
• (-1) on error
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Returns
• (1) if allmulticast is enabled
• (0) if allmulticast is disabled.
• (-1) on error
3.11.5.23 void rte eth link get ( uint8 t port id, struct rte_eth_link ∗ link )
Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX or FULL-DUPLEX) of the
physical link of an Ethernet device. It might need to wait up to 9 seconds in it.
Parameters
port_id The port identifier of the Ethernet device.
link A pointer to an ∗rte_eth_link∗ structure to be filled with the status, the speed and the
mode of the Ethernet device link.
3.11.5.24 void rte eth link get nowait ( uint8 t port id, struct rte_eth_link ∗ link )
Retrieve the status (ON/OFF), the speed (in Mbps) and the mode (HALF-DUPLEX or FULL-DUPLEX) of the
physical link of an Ethernet device. It is a no-wait version of rte_eth_link_get().
Parameters
port_id The port identifier of the Ethernet device.
link A pointer to an ∗rte_eth_link∗ structure to be filled with the status, the speed and the
mode of the Ethernet device link.
3.11.5.25 void rte eth stats get ( uint8 t port id, struct rte_eth_stats ∗ stats )
Parameters
port_id The port identifier of the Ethernet device.
stats A pointer to a structure of type ∗rte_eth_stats∗ to be filled with the values of device
counters for the following set of statistics:
• ∗ipackets∗ with the total of successfully received packets.
• ∗opackets∗ with the total of successfully transmitted packets.
• ∗ibytes∗ with the total of successfully received bytes.
• ∗obytes∗ with the total of successfully transmitted bytes.
• ∗ierrors∗ with the total of erroneous received packets.
• ∗oerrors∗ with the total of failed transmitted packets.
Parameters
port_id The port identifier of the Ethernet device.
3.11.5.27 int rte eth dev set tx queue stats mapping ( uint8 t port id, uint16 t tx queue id, uint8 t stat idx )
Set a mapping for the specified transmit queue to the specified per-queue statistics counter.
Parameters
port_id The port identifier of the Ethernet device.
tx_queue_id The index of the transmit queue for which a queue stats mapping is required. The
value must be in the range [0, nb_tx_queue - 1] previously supplied to rte_eth_dev_-
configure().
stat_idx The per-queue packet statistics functionality number that the transmit queue is to be
assigned. The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS-
_MAPS - 1].
Returns
Zero if successful. Non-zero otherwise.
3.11.5.28 int rte eth dev set rx queue stats mapping ( uint8 t port id, uint16 t rx queue id, uint8 t stat idx )
Set a mapping for the specified receive queue to the specified per-queue statistics counter.
Parameters
port_id The port identifier of the Ethernet device.
rx_queue_id The index of the receive queue for which a queue stats mapping is required. The
value must be in the range [0, nb_rx_queue - 1] previously supplied to rte_eth_dev_-
configure().
stat_idx The per-queue packet statistics functionality number that the receive queue is to be
assigned. The value must be in the range [0, RTE_MAX_ETHPORT_QUEUE_STATS-
_MAPS - 1].
Returns
Zero if successful. Non-zero otherwise.
3.11.5.29 void rte eth macaddr get ( uint8 t port id, struct ether_addr ∗ mac addr )
Parameters
port_id The port identifier of the Ethernet device.
mac_addr A pointer to a structure of type ∗ether_addr∗ to be filled with the Ethernet address of the
Ethernet device.
3.11.5.30 void rte eth dev info get ( uint8 t port id, struct rte_eth_dev_info ∗ dev info )
Parameters
port_id The port identifier of the Ethernet device.
dev_info A pointer to a structure of type ∗rte_eth_dev_info∗ to be filled with the contextual
information of the Ethernet device.
3.11.5.31 int rte eth dev vlan filter ( uint8 t port id, uint16 t vlan id, int on )
Enable/Disable hardware filtering by an Ethernet device of received VLAN packets tagged with a given VLAN
Tag Identifier.
Parameters
port_id The port identifier of the Ethernet device.
vlan_id The VLAN Tag Identifier whose filtering must be enabled or disabled.
on If > 0, enable VLAN filtering of VLAN packets tagged with ∗vlan_id∗. Otherwise, disable
VLAN filtering of VLAN packets tagged with ∗vlan_id∗.
Returns
• (0) if successful.
• (-ENOSUP) if hardware-assisted VLAN filtering not configured.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if VLAN filtering on ∗port_id∗ disabled.
• (-EINVAL) if ∗vlan_id∗ > 4095.
3.11.5.32 int rte eth dev set vlan strip on queue ( uint8 t port id, uint16 t rx queue id, int on )
Enable/Disable hardware VLAN Strip by a rx queue of an Ethernet device. 82599/X540 can support VLAN
stripping at the rx queue level
Parameters
port_id The port identifier of the Ethernet device.
rx_queue_id The index of the receive queue for which a queue stats mapping is required. The
value must be in the range [0, nb_rx_queue - 1] previously supplied to rte_eth_dev_-
configure().
on If 1, Enable VLAN Stripping of the receive queue of the Ethernet port. If 0, Disable VLAN
Stripping of the receive queue of the Ethernet port.
Returns
• (0) if successful.
• (-ENOSUP) if hardware-assisted VLAN stripping not configured.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if ∗rx_queue_id∗ invalid.
3.11.5.33 int rte eth dev set vlan ether type ( uint8 t port id, uint16 t tag type )
Set the Outer VLAN Ether Type by an Ethernet device, it can be inserted to the VLAN Header. This is a
register setup available on some Intel NIC, not but all, please check the data sheet for availability.
Parameters
port_id The port identifier of the Ethernet device.
tag_type The Tag Protocol ID
Returns
• (0) if successful.
• (-ENOSUP) if hardware-assisted VLAN TPID setup is not supported.
• (-ENODEV) if ∗port_id∗ invalid.
3.11.5.34 int rte eth dev set vlan offload ( uint8 t port id, int offload mask )
Set VLAN offload configuration on an Ethernet device Enable/Disable Extended VLAN by an Ethernet
device, This is a register setup available on some Intel NIC, not but all, please check the data sheet for
availability. Enable/Disable VLAN Strip can be done on rx queue for certain NIC, but here the configuration
is applied on the port level.
Parameters
port_id The port identifier of the Ethernet device.
offload_mask The VLAN Offload bit mask can be mixed use with "OR" ETH_VLAN_STRIP_OFFLOAD
ETH_VLAN_FILTER_OFFLOAD ETH_VLAN_EXTEND_OFFLOAD
Returns
• (0) if successful.
• (-ENOSUP) if hardware-assisted VLAN filtering not configured.
• (-ENODEV) if ∗port_id∗ invalid.
3.11.5.35 int rte eth dev get vlan offload ( uint8 t port id )
Parameters
port_id The port identifier of the Ethernet device.
Returns
• (>0) if successful. Bit mask to indicate ETH_VLAN_STRIP_OFFLOAD ETH_VLAN_FILTER_OF-
FLOAD ETH_VLAN_EXTEND_OFFLOAD
• (-ENODEV) if ∗port_id∗ invalid.
3.11.5.36 static uint16 t rte eth rx burst ( uint8 t port id, uint16 t queue id, struct rte_mbuf ∗∗ rx pkts, uint16 t
nb pkts ) [static]
Retrieve a burst of input packets from a receive queue of an Ethernet device. The retrieved packets are
stored in ∗rte_mbuf∗ structures whose pointers are supplied in the ∗rx_pkts∗ array.
The rte_eth_rx_burst() function loops, parsing the RX ring of the receive queue, up to ∗nb_pkts∗ packets,
and for each completed RX descriptor in the ring, it performs the following operations:
• Initialize the ∗rte_mbuf∗ data structure associated with the RX descriptor according to the information
provided by the NIC into that RX descriptor.
• Store the ∗rte_mbuf∗ data structure into the next entry of the ∗rx_pkts∗ array.
• Replenish the RX descriptor with a new ∗rte_mbuf∗ buffer allocated from the memory pool associated
with the receive queue at initialization time.
When retrieving an input packet that was scattered by the controller into multiple receive descriptors, the
rte_eth_rx_burst() function appends the associated ∗rte_mbuf∗ buffers to the first buffer of the packet.
The rte_eth_rx_burst() function returns the number of packets actually retrieved, which is the number of
∗rte_mbuf∗ data structures effectively supplied into the ∗rx_pkts∗ array. A return value equal to ∗nb_-
pkts∗ indicates that the RX queue contained at least ∗rx_pkts∗ packets, and this is likely to signify that
other received packets remain in the input queue. Applications implementing a "retrieve as much received
packets as possible" policy can check this specific case and keep invoking the rte_eth_rx_burst() function
until a value less than ∗nb_pkts∗ is returned.
This receive method has the following advantages:
• It allows a run-to-completion network stack engine to retrieve and to immediately process received
packets in a fast burst-oriented approach, avoiding the overhead of unnecessary intermediate packet
queue/dequeue operations.
• It allows the rte_eth_rx_burst() function of the driver to take advantage of burst-oriented hardware
features (CPU cache, prefetch instructions, and so on) to minimize the number of CPU cycles per
packet.
To summarize, the proposed receive API enables many burst-oriented optimizations in both synchronous
and asynchronous packet processing environments with no overhead in both cases.
The rte_eth_rx_burst() function does not provide any error notification to avoid the corresponding overhead.
As a hint, the upper-level application might check the status of the device link once being systematically
returned a 0 value for a given number of tries.
Parameters
port_id The port identifier of the Ethernet device.
queue_id The index of the receive queue from which to retrieve input packets. The value must be
in the range [0, nb_rx_queue - 1] previously supplied to rte_eth_dev_configure().
rx_pkts The address of an array of pointers to ∗rte_mbuf∗ structures that must be large enough
to store ∗nb_pkts∗ pointers in it.
nb_pkts The maximum number of packets to retrieve.
Returns
The number of packets actually retrieved, which is the number of pointers to ∗rte_mbuf∗ structures
effectively supplied to the ∗rx_pkts∗ array.
3.11.5.37 static uint32 t rte eth rx queue count ( uint8 t port id, uint16 t queue id ) [static]
Parameters
port_id The port identifier of the Ethernet device.
queue_id The queue id on the specific port.
Returns
The number of used descriptors in the specific queue.
3.11.5.38 static int rte eth rx descriptor done ( uint8 t port id, uint16 t queue id, uint16 t offset ) [static]
Check if the DD bit of the specific RX descriptor in the queue has been set
Parameters
port_id The port identifier of the Ethernet device.
queue_id The queue id on the specific port. The offset of the descriptor ID from tail.
Returns
• (1) if the specific DD bit is set.
• (0) if the specific DD bit is not set.
• (-ENODEV) if ∗port_id∗ invalid.
3.11.5.39 static uint16 t rte eth tx burst ( uint8 t port id, uint16 t queue id, struct rte_mbuf ∗∗ tx pkts, uint16 t
nb pkts ) [static]
• Free the network buffer previously sent with that descriptor, if any.
• Initialize the transmit descriptor with the information provided in the ∗rte_mbuf data structure.
In the case of a segmented packet composed of a list of ∗rte_mbuf∗ buffers, the rte_eth_tx_burst() function
uses several transmit descriptors of the ring.
The rte_eth_tx_burst() function returns the number of packets it actually sent. A return value equal to ∗nb-
_pkts∗ means that all packets have been sent, and this is likely to signify that other output packets could
be immediately transmitted again. Applications that implement a "send as many packets to transmit as
possible" policy can check this specific case and keep invoking the rte_eth_tx_burst() function until a value
less than ∗nb_pkts∗ is returned.
It is the responsibility of the rte_eth_tx_burst() function to transparently free the memory buffers of packets
previously sent. This feature is driven by the ∗tx_free_thresh∗ value supplied to the rte_eth_dev_configure()
function at device configuration time. When the number of previously sent packets reached the "minimum
transmit packets to free" threshold, the rte_eth_tx_burst() function must [attempt to] free the ∗rte_mbuf∗
buffers of those packets whose transmission was effectively completed.
Parameters
Returns
The number of output packets actually stored in transmit descriptors of the transmit ring. The return
value can be less than the value of the ∗tx_pkts∗ parameter when the transmit ring is full or has been
filled up.
3.11.5.40 int rte eth dev fdir add signature filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir filter, uint8 t rx queue
)
Parameters
port_id The port identifier of the Ethernet device.
fdir_filter The pointer to the fdir filter structure describing the signature filter rule. The ∗rte_-
fdir_filter∗ structure includes the values of the different fields to match: source and
destination IP addresses, vlan id, flexbytes, source and destination ports, and so on.
rx_queue The index of the RX queue where to store RX packets matching the added signature
filter defined in fdir_filter.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the FDIR mode is not configured in signature mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.41 int rte eth dev fdir update signature filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir ftr, uint8 t rx queue
)
Update a signature filter rule on an Ethernet device. If the rule doesn’t exits, it is created.
Parameters
port_id The port identifier of the Ethernet device.
fdir_ftr The pointer to the structure describing the signature filter rule. The ∗rte_fdir_filter∗
structure includes the values of the different fields to match: source and destination
IP addresses, vlan id, flexbytes, source and destination ports, and so on.
rx_queue The index of the RX queue where to store RX packets matching the added signature
filter defined in fdir_ftr.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in signature mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.42 int rte eth dev fdir remove signature filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir ftr )
Parameters
port_id The port identifier of the Ethernet device.
fdir_ftr The pointer to the structure describing the signature filter rule. The ∗rte_fdir_filter∗
structure includes the values of the different fields to match: source and destination
IP addresses, vlan id, flexbytes, source and destination ports, and so on.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in signature mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.43 int rte eth dev fdir get infos ( uint8 t port id, struct rte_eth_fdir ∗ fdir )
Parameters
port_id The port identifier of the Ethernet device.
fdir A pointer to a structure of type ∗rte_eth_dev_fdir∗ to be filled with the flow director
information of the Ethernet device.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured on ∗port_id∗.
3.11.5.44 int rte eth dev fdir add perfect filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir filter, uint16 t soft id,
uint8 t rx queue, uint8 t drop )
Parameters
port_id The port identifier of the Ethernet device.
fdir_filter The pointer to the structure describing the perfect filter rule. The ∗rte_fdir_filter∗
structure includes the values of the different fields to match: source and destination
IP addresses, vlan id, flexbytes, source and destination ports, and so on. IPv6 are not
supported.
soft_id The 16-bit value supplied in the field hash.fdir.id of mbuf for RX packets matching the
perfect filter.
rx_queue The index of the RX queue where to store RX packets matching the added perfect filter
defined in fdir_filter.
drop If drop is set to 1, matching RX packets are stored into the RX drop queue defined in
the rte_fdir_conf.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in perfect mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.45 int rte eth dev fdir update perfect filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir filter, uint16 t soft id,
uint8 t rx queue, uint8 t drop )
Update a perfect filter rule on an Ethernet device. If the rule doesn’t exits, it is created.
Parameters
port_id The port identifier of the Ethernet device.
fdir_filter The pointer to the structure describing the perfect filter rule. The ∗rte_fdir_filter∗
structure includes the values of the different fields to match: source and destination
IP addresses, vlan id, flexbytes, source and destination ports, and so on. IPv6 are not
supported.
soft_id The 16-bit value supplied in the field hash.fdir.id of mbuf for RX packets matching the
perfect filter.
rx_queue The index of the RX queue where to store RX packets matching the added perfect filter
defined in fdir_filter.
drop If drop is set to 1, matching RX packets are stored into the RX drop queue defined in
the rte_fdir_conf.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in perfect mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.46 int rte eth dev fdir remove perfect filter ( uint8 t port id, struct rte_fdir_filter ∗ fdir filter, uint16 t soft id
)
Parameters
port_id The port identifier of the Ethernet device.
fdir_filter The pointer to the structure describing the perfect filter rule. The ∗rte_fdir_filter∗
structure includes the values of the different fields to match: source and destination
IP addresses, vlan id, flexbytes, source and destination ports, and so on. IPv6 are not
supported.
soft_id The soft_id value provided when adding/updating the removed filter.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in perfect mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct.
3.11.5.47 int rte eth dev fdir set masks ( uint8 t port id, struct rte_fdir_masks ∗ fdir mask )
Configure globally the masks for flow director mode for an Ethernet device. For example, the device can
match packets with only the first 24 bits of the IPv4 source address.
The following fields can be masked: IPv4 addresses and L4 port numbers. The following fields can be either
enabled or disabled completely for the matching functionality: VLAN ID tag; VLAN Priority + CFI bit; Flexible
2-byte tuple. IPv6 masks are not supported.
All filters must comply with the masks previously configured. For example, with a mask equal to 255.255.-
255.0 for the source IPv4 address, all IPv4 filters must be created with a source IPv4 address that fits the
"X.X.X.0" format.
This function flushes all filters that have been previously added in the device.
Parameters
port_id The port identifier of the Ethernet device.
fdir_mask The pointer to the fdir mask structure describing relevant headers fields and relevant
bits to use when matching packets addresses and ports. IPv6 masks are not supported.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow director mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOSYS) if the flow director mode is not configured in perfect mode on ∗port_id∗.
• (-EINVAL) if the fdir_filter information is not correct
3.11.5.48 int rte eth dev callback register ( uint8 t port id, enum rte_eth_event_type event,
rte_eth_dev_cb_fn cb fn, void ∗ cb arg )
Parameters
port_id Port id.
event Event interested.
cb_fn User supplied callback function to be called.
cb_arg Pointer to the parameters for the registered callback.
Returns
• On success, zero.
• On failure, a negative value.
3.11.5.49 int rte eth dev callback unregister ( uint8 t port id, enum rte_eth_event_type event,
rte_eth_dev_cb_fn cb fn, void ∗ cb arg )
Parameters
port_id Port id.
event Event interested.
cb_fn User supplied callback function to be called.
cb_arg Pointer to the parameters for the registered callback. -1 means to remove all for the
same callback address and same event.
Returns
• On success, zero.
• On failure, a negative value.
Turn on the LED on the Ethernet device. This function turns on the LED on the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Returns
• (0) if successful.
• (-ENOTSUP) if underlying hardware OR driver doesn’t support that operation.
• (-ENODEV) if ∗port_id∗ invalid.
Turn off the LED on the Ethernet device. This function turns off the LED on the Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
Returns
• (0) if successful.
• (-ENOTSUP) if underlying hardware OR driver doesn’t support that operation.
• (-ENODEV) if ∗port_id∗ invalid.
3.11.5.52 int rte eth dev flow ctrl set ( uint8 t port id, struct rte_eth_fc_conf ∗ fc conf )
Parameters
port_id The port identifier of the Ethernet device.
fc_conf The pointer to the structure of the flow control parameters.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support flow control mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if bad parameter
• (-EIO) if flow control setup failure
3.11.5.53 int rte eth dev priority flow ctrl set ( uint8 t port id, struct rte_eth_pfc_conf ∗ pfc conf )
Configure the Ethernet priority flow control under DCB environment for Ethernet device.
Parameters
port_id The port identifier of the Ethernet device.
pfc_conf The pointer to the structure of the priority flow control parameters.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support priority flow control mode.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if bad parameter
• (-EIO) if flow control setup failure
3.11.5.54 int rte eth dev mac addr add ( uint8 t port, struct ether_addr ∗ mac addr, uint32 t pool )
Add a MAC address to an internal array of addresses used to enable whitelist filtering to accept packets
only if the destination MAC address matches.
Parameters
port The port identifier of the Ethernet device.
mac_addr The MAC address to add.
pool VMDq pool index to associate address with (if VMDq is enabled). If VMDq is not enabled,
this should be set to 0.
Returns
• (0) if successfully added or ∗mac_addr" was already added.
• (-ENOTSUP) if hardware doesn’t support this feature.
• (-ENODEV) if ∗port∗ is invalid.
• (-ENOSPC) if no more MAC addresses can be added.
• (-EINVAL) if MAC address is invalid.
3.11.5.55 int rte eth dev mac addr remove ( uint8 t port, struct ether_addr ∗ mac addr )
Parameters
port The port identifier of the Ethernet device.
mac_addr MAC address to remove.
Returns
• (0) if successful, or ∗mac_addr∗ didn’t exist.
• (-ENOTSUP) if hardware doesn’t support.
• (-ENODEV) if ∗port∗ invalid.
• (-EADDRINUSE) if attempting to remove the default MAC address
3.11.5.56 int rte eth dev rss reta update ( uint8 t port, struct rte_eth_rss_reta ∗ reta conf )
Parameters
port The port identifier of the Ethernet device.
reta_conf RETA to update.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.57 int rte eth dev rss reta query ( uint8 t port, struct rte_eth_rss_reta ∗ reta conf )
Parameters
port The port identifier of the Ethernet device.
reta_conf RETA to query.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.58 int rte eth dev uc hash table set ( uint8 t port, struct ether_addr ∗ addr, uint8 t on )
Updates unicast hash table for receiving packet with the given destination MAC address, and the packet is
routed to all VFs for which the RX mode is accept packets that match the unicast hash table.
Parameters
port The port identifier of the Ethernet device.
addr Unicast MAC address.
on 1 - Set an unicast hash bit for receiving packets with the MAC address. 0 - Clear an
unicast hash bit.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
3.11.5.59 int rte eth dev uc all hash table set ( uint8 t port, uint8 t on )
Updates all unicast hash bitmaps for receiving packet with any Unicast Ethernet MAC addresses,the packet
is routed to all VFs for which the RX mode is accept packets that match the unicast hash table.
Parameters
port The port identifier of the Ethernet device.
on 1 - Set all unicast hash bitmaps for receiving all the Ethernet MAC addresses 0 - Clear
all unicast hash bitmaps
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
3.11.5.60 int rte eth dev set vf rxmode ( uint8 t port, uint16 t vf, uint16 t rx mode, uint8 t on )
Parameters
port The port identifier of the Ethernet device.
vf VF id.
rx_mode The RX mode mask, which is one or more of accepting Untagged Packets, packets
that match the PFUTA table, Broadcast and Multicast Promiscuous. ETH_VMDQ_AC-
CEPT_UNTAG,ETH_VMDQ_ACCEPT_HASH_UC, ETH_VMDQ_ACCEPT_BROADC-
AST and ETH_VMDQ_ACCEPT_MULTICAST will be used in rx_mode.
on 1 - Enable a VF RX mode. 0 - Disable a VF RX mode.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.61 int rte eth dev set vf tx ( uint8 t port, uint16 t vf, uint8 t on )
Parameters
port The port identifier of the Ethernet device.
vf VF id.
on 1 - Enable a VF traffic transmit. 0 - Disable a VF traffic transmit.
Returns
• (0) if successful.
• (-ENODEV) if ∗port_id∗ invalid.
• (-ENOTSUP) if hardware doesn’t support.
3.11.5.62 int rte eth dev set vf rx ( uint8 t port, uint16 t vf, uint8 t on )
Parameters
port The port identifier of the Ethernet device.
vf VF id.
on 1 - Enable a VF traffic receive. 0 - Disable a VF traffic receive.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if bad parameter.
3.11.5.63 int rte eth dev set vf vlan filter ( uint8 t port, uint16 t vlan id, uint64 t vf mask, uint8 t vlan on )
Enable/Disable hardware VF VLAN filtering by an Ethernet device of received VLAN packets tagged with a
given VLAN Tag Identifier.
Parameters
port id The port identifier of the Ethernet device.
vlan_id The VLAN Tag Identifier whose filtering must be enabled or disabled.
vf_mask Bitmap listing which VFs participate in the VLAN filtering.
vlan_on 1 - Enable VFs VLAN filtering. 0 - Disable VFs VLAN filtering.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if bad parameter.
3.11.5.64 int rte eth mirror rule set ( uint8 t port id, struct rte_eth_vmdq_mirror_conf ∗ mirror conf, uint8 t
rule id, uint8 t on )
Parameters
port_id The port identifier of the Ethernet device.
mirror_conf The pointer to the traffic mirroring structure describing the mirroring rule. The ∗rte_eth-
_vm_mirror_conf∗ structure includes the type of mirroring rule, destination pool and the
value of rule if enable vlan or pool mirroring.
rule_id The index of traffic mirroring rule, we support four separated rules.
on 1 - Enable a mirroring rule. 0 - Disable a mirroring rule.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support this feature.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if the mr_conf information is not correct.
3.11.5.65 int rte eth mirror rule reset ( uint8 t port id, uint8 t rule id )
Parameters
port_id The port identifier of the Ethernet device.
rule_id The index of traffic mirroring rule, we support four separated rules.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support this feature.
• (-ENODEV) if ∗port_id∗ invalid.
• (-EINVAL) if bad parameter.
Initialize bypass logic. This function needs to be called before executing any other bypass API.
Parameters
port The port identifier of the Ethernet device.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
3.11.5.67 int rte eth dev bypass state show ( uint8 t port, uint32 t ∗ state )
Parameters
port The port identifier of the Ethernet device.
state The return bypass state.
• (1) Normal mode
• (2) Bypass mode
• (3) Isolate mode
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.68 int rte eth dev bypass state set ( uint8 t port, uint32 t ∗ new state )
Parameters
port The port identifier of the Ethernet device.
state The current bypass state.
• (1) Normal mode
• (2) Bypass mode
• (3) Isolate mode
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.69 int rte eth dev bypass event show ( uint8 t port, uint32 t event, uint32 t ∗ state )
Parameters
port The port identifier of the Ethernet device.
event The bypass event
• (1) Main power on (power button is pushed)
• (2) Auxiliary power on (power supply is being plugged)
• (3) Main power off (system shutdown and power supply is left plugged in)
• (4) Auxiliary power off (power supply is being unplugged)
• (5) Display or set the watchdog timer
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.70 int rte eth dev bypass event store ( uint8 t port, uint32 t event, uint32 t state )
Parameters
port The port identifier of the Ethernet device.
event The bypass event
• (1) Main power on (power button is pushed)
• (2) Auxiliary power on (power supply is being plugged)
• (3) Main power off (system shutdown and power supply is left plugged in)
• (4) Auxiliary power off (power supply is being unplugged)
• (5) Display or set the watchdog timer
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.71 int rte eth dev wd timeout store ( uint8 t port, uint32 t timeout )
Parameters
port The port identifier of the Ethernet device.
state The timeout to be set.
• (0) 0 seconds (timer is off)
• (1) 1.5 seconds
• (2) 2 seconds
• (3) 3 seconds
• (4) 4 seconds
• (5) 8 seconds
• (6) 16 seconds
• (7) 32 seconds
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.72 int rte eth dev bypass ver show ( uint8 t port, uint32 t ∗ ver )
Parameters
port The port identifier of the Ethernet device.
ver The firmware version
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
3.11.5.73 int rte eth dev bypass wd timeout show ( uint8 t port, uint32 t ∗ wd timeout )
Parameters
port The port identifier of the Ethernet device.
wd_timeout The return watchdog timeout. "0" represents timer expired
• (0) 0 seconds (timer is off)
• (1) 1.5 seconds
• (2) 2 seconds
• (3) 3 seconds
• (4) 4 seconds
• (5) 8 seconds
• (6) 16 seconds
• (7) 32 seconds
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
Parameters
port The port identifier of the Ethernet device.
Returns
• (0) if successful.
• (-ENOTSUP) if hardware doesn’t support.
• (-EINVAL) if bad parameter.
Data Structures
• struct ether_addr
• struct ether_hdr
• struct vlan_hdr
Defines
• #define ETHER_ADDR_LEN
• #define ETHER_TYPE_LEN
• #define ETHER_CRC_LEN
• #define ETHER_HDR_LEN
• #define ETHER_MIN_LEN
• #define ETHER_MAX_LEN
• #define ETHER_MTU
• #define ETHER_MAX_VLAN_FRAME_LEN
• #define ETHER_MAX_JUMBO_FRAME_LEN
• #define ETHER_MAX_VLAN_ID
• #define ETHER_LOCAL_ADMIN_ADDR
• #define ETHER_GROUP_ADDR
• #define ETHER_TYPE_IPv4
• #define ETHER_TYPE_IPv6
• #define ETHER_TYPE_ARP
• #define ETHER_TYPE_RARP
• #define ETHER_TYPE_VLAN
• #define ETHER_TYPE_1588
Functions
• static int is_zero_ether_addr (const struct ether_addr ∗ea)
• static int is_unicast_ether_addr (const struct ether_addr ∗ea)
• static int is_multicast_ether_addr (const struct ether_addr ∗ea)
• static int is_broadcast_ether_addr (const struct ether_addr ∗ea)
• static int is_universal_ether_addr (const struct ether_addr ∗ea)
• static int is_local_admin_ether_addr (const struct ether_addr ∗ea)
• static int is_valid_assigned_ether_addr (const struct ether_addr ∗ea)
• static void eth_random_addr (uint8_t ∗addr)
• static void ether_addr_copy (const struct ether_addr ∗ea_from, struct ether_addr ∗ea_to)
Ethernet MTU.
IPv4 Protocol.
IPv6 Protocol.
Arp Protocol.
3.12.3.1 static int is zero ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is filled with zeros; false (0) otherwise.
3.12.3.2 static int is unicast ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a unicast address; false (0) otherwise.
3.12.3.3 static int is multicast ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a multicast address; false (0) otherwise.
3.12.3.4 static int is broadcast ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a broadcast address; false (0) otherwise.
3.12.3.5 static int is universal ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a universally assigned address; false (0) otherwise.
3.12.3.6 static int is local admin ether addr ( const struct ether_addr ∗ ea ) [static]
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is a locally assigned address; false (0) otherwise.
3.12.3.7 static int is valid assigned ether addr ( const struct ether_addr ∗ ea ) [static]
Check if an Ethernet address is a valid address. Checks that the address is a unicast address and is not
filled with zeros.
Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.
Returns
True (1) if the given ethernet address is valid; false (0) otherwise.
Generate a random Ethernet address that is locally administered and not multicast.
Parameters
addr A pointer to Ethernet address.
3.12.3.9 static void ether addr copy ( const struct ether_addr ∗ ea from, struct ether_addr ∗ ea to ) [static]
Parameters
ea_from A pointer to a ether_addr structure holding the Ethernet address to copy.
ea_to A pointer to a ether_addr structure where to copy the Ethernet address.
Data Structures
• struct rte_fbk_hash_params
• union rte_fbk_hash_entry
• struct rte_fbk_hash_table
Defines
• #define RTE_FBK_HASH_INIT_VAL_DEFAULT
• #define RTE_FBK_HASH_ENTRIES_MAX
• #define RTE_FBK_HASH_ENTRIES_PER_BUCKET_MAX
• #define RTE_FBK_HASH_NAMESIZE
Typedefs
• typedef uint32_t(∗ rte_fbk_hash_fn )(uint32_t key, uint32_t init_val)
Functions
• static uint32_t rte_fbk_hash_get_bucket (const struct rte_fbk_hash_table ∗ht, uint32_t key)
• static int rte_fbk_hash_add_key_with_bucket (struct rte_fbk_hash_table ∗ht, uint32_t key, uint16_-
t value, uint32_t bucket)
• static int rte_fbk_hash_add_key (struct rte_fbk_hash_table ∗ht, uint32_t key, uint16_t value)
• static int rte_fbk_hash_delete_key_with_bucket (struct rte_fbk_hash_table ∗ht, uint32_t key, uint32_t
bucket)
• static int rte_fbk_hash_delete_key (struct rte_fbk_hash_table ∗ht, uint32_t key)
• static int rte_fbk_hash_lookup_with_bucket (const struct rte_fbk_hash_table ∗ht, uint32_t key, uint32_t
bucket)
Type of function that can be used for calculating the hash value.
3.13.4.1 static uint32 t rte fbk hash get bucket ( const struct rte_fbk_hash_table ∗ ht, uint32 t key )
[static]
Find the offset into hash table of the bucket containing a particular key.
Parameters
ht Pointer to hash table.
key Key to calculate bucket for.
Returns
Offset into hash table.
3.13.4.2 static int rte fbk hash add key with bucket ( struct rte_fbk_hash_table ∗ ht, uint32 t key, uint16 t value,
uint32 t bucket ) [static]
Add a key to an existing hash table with bucket id. This operation is not multi-thread safe and should only
be called from one thread.
Parameters
ht Hash table to add the key to.
key Key to add to the hash table.
value Value to associate with key.
bucket Bucket to associate with key.
Returns
0 if ok, or negative value on error.
3.13.4.3 static int rte fbk hash add key ( struct rte_fbk_hash_table ∗ ht, uint32 t key, uint16 t value )
[static]
Add a key to an existing hash table. This operation is not multi-thread safe and should only be called from
one thread.
Parameters
ht Hash table to add the key to.
key Key to add to the hash table.
value Value to associate with key.
Returns
0 if ok, or negative value on error.
3.13.4.4 static int rte fbk hash delete key with bucket ( struct rte_fbk_hash_table ∗ ht, uint32 t key, uint32 t
bucket ) [static]
Remove a key with a given bucket id from an existing hash table. This operation is not multi-thread safe and
should only be called from one thread.
Parameters
ht Hash table to remove the key from.
key Key to remove from the hash table.
bucket Bucket id associate with key.
Returns
0 if ok, or negative value on error.
3.13.4.5 static int rte fbk hash delete key ( struct rte_fbk_hash_table ∗ ht, uint32 t key ) [static]
Remove a key from an existing hash table. This operation is not multi-thread safe and should only be called
from one thread.
Parameters
ht Hash table to remove the key from.
key Key to remove from the hash table.
Returns
0 if ok, or negative value on error.
3.13.4.6 static int rte fbk hash lookup with bucket ( const struct rte_fbk_hash_table ∗ ht, uint32 t key, uint32 t
bucket ) [static]
Find a key in the hash table with a given bucketid. This operation is multi-thread safe.
Parameters
ht Hash table to look in.
key Key to find.
bucket Bucket associate to the key.
Returns
The value that was associated with the key, or negative value on error.
3.13.4.7 static int rte fbk hash lookup ( const struct rte_fbk_hash_table ∗ ht, uint32 t key ) [static]
Parameters
ht Hash table to look in.
key Key to find.
Returns
The value that was associated with the key, or negative value on error.
3.13.4.8 static void rte fbk hash clear all ( struct rte_fbk_hash_table ∗ ht ) [static]
Delete all entries in a hash table. This operation is not multi-thread safe and should only be called from one
thread.
Parameters
ht Hash table to delete entries in.
3.13.4.9 static double rte fbk hash get load factor ( struct rte_fbk_hash_table ∗ ht ) [static]
Parameters
ht Hash table to find how many entries are being used in.
Returns
Load factor of the hash table, or negative value on error.
3.13.4.10 struct rte_fbk_hash_table∗ rte fbk hash find existing ( const char ∗ name ) [read]
Performs a lookup for an existing hash table, and returns a pointer to the table if found.
Parameters
name Name of the hash table to find
Returns
pointer to hash table structure or NULL on error with rte_errno set appropriately. Possible rte_errno
values include:
• ENOENT - required entry not available to return.
3.13.4.11 struct rte_fbk_hash_table∗ rte fbk hash create ( const struct rte_fbk_hash_params ∗ params )
[read]
Create a new hash table for use with four byte keys.
Parameters
params Parameters used in creation of hash table.
Returns
Pointer to hash table structure that is used in future hash table operations, or NULL on error with rte_-
errno set appropriately. Possible rte_errno error values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the fbk hash table list
• EINVAL - invalid parameter value passed to function
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
Free all memory used by a hash table. Has no effect on hash tables allocated in memory zones
Parameters
ht Hash table to deallocate.
Data Structures
• struct rte_hash_parameters
• struct rte_hash
Defines
• #define RTE_HASH_ENTRIES_MAX
• #define RTE_HASH_BUCKET_ENTRIES_MAX
• #define RTE_HASH_KEY_LENGTH_MAX
• #define RTE_HASH_LOOKUP_BULK_MAX
• #define RTE_HASH_NAMESIZE
Typedefs
Functions
3.14.3.2 typedef uint32 t(∗ rte_hash_function)(const void ∗key, uint32 t key len, uint32 t init val)
Type of function that can be used for calculating the hash value.
3.14.4.1 struct rte_hash∗ rte hash create ( const struct rte_hash_parameters ∗ params ) [read]
Parameters
params Parameters used to create and initialise the hash table.
Returns
Pointer to hash table structure that is used in future hash table operations, or NULL on error, with error
code set in rte_errno. Possible rte_errno errors include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the hash table list
• ENOENT - missing entry
• EINVAL - invalid parameter passed to function
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
3.14.4.2 struct rte_hash∗ rte hash find existing ( const char ∗ name ) [read]
Parameters
name Name of the hash table as passed to rte_hash_create()
Returns
Pointer to hash table or NULL if object not found with rte_errno set appropriately. Possible rte_errno
values include:
• ENOENT - value not available for return
Parameters
h Hash table to free
3.14.4.4 int32 t rte hash add key ( const struct rte_hash ∗ h, const void ∗ key )
Add a key to an existing hash table. This operation is not multi-thread safe and should only be called from
one thread.
Parameters
h Hash table to add the key to.
key Key to add to the hash table.
Returns
• -EINVAL if the parameters are invalid.
• -ENOSPC if there is no space in the hash for this key.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key.
3.14.4.5 int32 t rte hash add key with hash ( const struct rte_hash ∗ h, const void ∗ key, hash_sig_t sig )
Add a key to an existing hash table. This operation is not multi-thread safe and should only be called from
one thread.
Parameters
h Hash table to add the key to.
key Key to add to the hash table.
sig Hash value to add to the hash table.
Returns
• -EINVAL if the parameters are invalid.
• -ENOSPC if there is no space in the hash for this key.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key.
3.14.4.6 int32 t rte hash del key ( const struct rte_hash ∗ h, const void ∗ key )
Remove a key from an existing hash table. This operation is not multi-thread safe and should only be called
from one thread.
Parameters
h Hash table to remove the key from.
key Key to remove from the hash table.
Returns
• -EINVAL if the parameters are invalid.
• -ENOENT if the key is not found.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key, and is the same value that was returned when the key was added.
3.14.4.7 int32 t rte hash del key with hash ( const struct rte_hash ∗ h, const void ∗ key, hash_sig_t sig )
Remove a key from an existing hash table. This operation is not multi-thread safe and should only be called
from one thread.
Parameters
h Hash table to remove the key from.
key Key to remove from the hash table.
sig Hash value to remove from the hash table.
Returns
• -EINVAL if the parameters are invalid.
• -ENOENT if the key is not found.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key, and is the same value that was returned when the key was added.
3.14.4.8 int32 t rte hash lookup ( const struct rte_hash ∗ h, const void ∗ key )
Parameters
h Hash table to look in.
key Key to find.
Returns
• -EINVAL if the parameters are invalid.
• -ENOENT if the key is not found.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key, and is the same value that was returned when the key was added.
3.14.4.9 int32 t rte hash lookup with hash ( const struct rte_hash ∗ h, const void ∗ key, hash_sig_t sig )
Parameters
h Hash table to look in.
key Key to find.
sig Hash value to find.
Returns
• -EINVAL if the parameters are invalid.
• -ENOENT if the key is not found.
• A positive value that can be used by the caller as an offset into an array of user data. This value is
unique for this key, and is the same value that was returned when the key was added.
3.14.4.10 static hash_sig_t rte hash hash ( const struct rte_hash ∗ h, const void ∗ key ) [static]
Parameters
h Hash table to look in.
key Key to find.
Returns
• hash value
3.14.4.11 int rte hash lookup bulk ( const struct rte_hash ∗ h, const void ∗∗ keys, uint32 t num keys, int32 t ∗
positions )
Find multiple keys in the hash table. This operation is multi-thread safe.
Parameters
h Hash table to look in.
keys A pointer to a list of keys to look for.
num_keys How many keys are in the keys list (less than RTE_HASH_LOOKUP_BULK_MAX).
positions Output containing a list of values, corresponding to the list of keys that can be used by
the caller as an offset into an array of user data. These values are unique for each key,
and are the same values that were returned when each key was added. If a key in the
list was not found, then -ENOENT will be the value.
Returns
-EINVAL if there’s an error, otherwise 0.
Functions
3.15.2.1 static uint32 t rte hash crc 4byte ( uint32 t data, uint32 t init val ) [static]
Parameters
data Data to perform hash on.
init_val Value to initialise hash generator.
Returns
32bit calculated hash value.
3.15.2.2 static uint32 t rte hash crc ( const void ∗ data, uint32 t data len, uint32 t init val ) [static]
Parameters
data Data to perform hash on.
data_len How many bytes to use to calculate hash value.
init_val Value to initialise hash generator.
Returns
32bit calculated hash value.
Functions
• void rte_hexdump (const char ∗title, const void ∗buf, unsigned int len)
• void rte_memdump (const char ∗title, const void ∗buf, unsigned int len)
3.16.2.1 void rte hexdump ( const char ∗ title, const void ∗ buf, unsigned int len )
Parameters
title If not NULL this string is printed as a header to the output.
buf This is the buffer address to print out.
len The number of bytes to dump out
Returns
None.
3.16.2.2 void rte memdump ( const char ∗ title, const void ∗ buf, unsigned int len )
Parameters
title If not NULL this string is printed as a header to the output.
buf This is the buffer address to print out.
len The number of bytes to dump out
Returns
None.
Typedefs
Functions
The RTE interrupt interface provides functions to register/unregister callbacks for a specific interrupt.
3.17.2.1 typedef void(∗ rte_intr_callback_fn)(struct rte intr handle ∗intr handle, void ∗cb arg)
3.17.3.1 int rte intr callback register ( struct rte intr handle ∗ intr handle, rte_intr_callback_fn cb, void ∗ cb arg )
It registers the callback for the specific interrupt. Multiple callbacks cal be registered at the same time.
Parameters
intr_handle Pointer to the interrupt handle.
cb callback address.
cb_arg address of parameter for callback.
Returns
• On success, zero.
• On failure, a negative value.
3.17.3.2 int rte intr callback unregister ( struct rte intr handle ∗ intr handle, rte_intr_callback_fn cb, void ∗
cb arg )
Parameters
intr_handle pointer to the interrupt handle.
cb callback address.
cb_arg address of parameter for callback, (void ∗)-1 means to remove all registered which has
the same callback address.
Returns
• On success, return the number of callback entities removed.
• On failure, a negative value.
3.17.3.3 int rte intr enable ( struct rte intr handle ∗ intr handle )
Parameters
intr_handle pointer to the interrupt handle.
Returns
• On success, zero.
• On failure, a negative value.
3.17.3.4 int rte intr disable ( struct rte intr handle ∗ intr handle )
Parameters
intr_handle pointer to the interrupt handle.
Returns
• On success, zero.
• On failure, a negative value.
Data Structures
• struct ipv4_hdr
• struct ipv6_hdr
Defines
• #define IPv4(a, b, c, d)
• #define IPPROTO_IP
• #define IPPROTO_HOPOPTS
• #define IPPROTO_ICMP
• #define IPPROTO_IGMP
• #define IPPROTO_GGP
• #define IPPROTO_IPV4
• #define IPPROTO_TCP
• #define IPPROTO_ST
• #define IPPROTO_EGP
• #define IPPROTO_PIGP
• #define IPPROTO_RCCMON
• #define IPPROTO_NVPII
• #define IPPROTO_PUP
• #define IPPROTO_ARGUS
• #define IPPROTO_EMCON
• #define IPPROTO_XNET
• #define IPPROTO_CHAOS
• #define IPPROTO_UDP
• #define IPPROTO_MUX
• #define IPPROTO_MEAS
• #define IPPROTO_HMP
• #define IPPROTO_PRM
• #define IPPROTO_IDP
• #define IPPROTO_TRUNK1
• #define IPPROTO_TRUNK2
• #define IPPROTO_LEAF1
• #define IPPROTO_LEAF2
• #define IPPROTO_RDP
• #define IPPROTO_IRTP
• #define IPPROTO_TP
• #define IPPROTO_BLT
• #define IPPROTO_NSP
• #define IPPROTO_INP
• #define IPPROTO_SEP
• #define IPPROTO_3PC
• #define IPPROTO_IDPR
• #define IPPROTO_XTP
• #define IPPROTO_DDP
• #define IPPROTO_CMTP
• #define IPPROTO_TPXX
• #define IPPROTO_IL
• #define IPPROTO_IPV6
• #define IPPROTO_SDRP
• #define IPPROTO_ROUTING
• #define IPPROTO_FRAGMENT
• #define IPPROTO_IDRP
• #define IPPROTO_RSVP
• #define IPPROTO_GRE
• #define IPPROTO_MHRP
• #define IPPROTO_BHA
• #define IPPROTO_ESP
• #define IPPROTO_AH
• #define IPPROTO_INLSP
• #define IPPROTO_SWIPE
• #define IPPROTO_NHRP
• #define IPPROTO_ICMPV6
• #define IPPROTO_NONE
• #define IPPROTO_DSTOPTS
• #define IPPROTO_AHIP
• #define IPPROTO_CFTP
• #define IPPROTO_HELLO
• #define IPPROTO_SATEXPAK
• #define IPPROTO_KRYPTOLAN
• #define IPPROTO_RVD
• #define IPPROTO_IPPC
• #define IPPROTO_ADFS
• #define IPPROTO_SATMON
• #define IPPROTO_VISA
• #define IPPROTO_IPCV
• #define IPPROTO_CPNX
• #define IPPROTO_CPHB
• #define IPPROTO_WSN
• #define IPPROTO_PVP
• #define IPPROTO_BRSATMON
• #define IPPROTO_ND
• #define IPPROTO_WBMON
• #define IPPROTO_WBEXPAK
• #define IPPROTO_EON
• #define IPPROTO_VMTP
• #define IPPROTO_SVMTP
• #define IPPROTO_VINES
• #define IPPROTO_TTP
• #define IPPROTO_IGP
• #define IPPROTO_DGP
• #define IPPROTO_TCF
• #define IPPROTO_IGRP
• #define IPPROTO_OSPFIGP
• #define IPPROTO_SRPC
• #define IPPROTO_LARP
• #define IPPROTO_MTP
• #define IPPROTO_AX25
• #define IPPROTO_IPEIP
• #define IPPROTO_MICP
• #define IPPROTO_SCCSP
• #define IPPROTO_ETHERIP
• #define IPPROTO_ENCAP
• #define IPPROTO_APES
• #define IPPROTO_GMTP
• #define IPPROTO_IPCOMP
• #define IPPROTO_PIM
• #define IPPROTO_PGM
• #define IPPROTO_SCTP
• #define IPPROTO_DIVERT
• #define IPPROTO_RAW
• #define IPPROTO_MAX
• #define IPV4_ANY
• #define IPV4_LOOPBACK
• #define IPV4_BROADCAST
• #define IPV4_ALLHOSTS_GROUP
• #define IPV4_ALLRTRS_GROUP
• #define IPV4_MAX_LOCAL_GROUP
• #define IPV4_MIN_MCAST
• #define IPV4_MAX_MCAST
• #define IS_IPV4_MCAST(x)
IP-related defines
dummy for IP
gateway∧ 2 (deprecated)
IPv4 encapsulation
tcp
Stream protocol II
pup
Argus
EMCON
Chaos
Multiplexing
Host Monitoring
xns idp
Trunk-1
Trunk-2
Leaf-1
Leaf-2
Reliable Data
Reliable Transaction
Network Services
Merit Internodal
Sequential Exchange
XTP
Datagram Delivery
TP++ Transport
IL transport protocol
IP6 header
InterDomain Routing
resource reservation
BHA
IP with encryption
ICMP6
CFTP
SATNET/Backroom EXPAK
Kryptolan
Any distributed FS
Satnet Monitoring
VISA Protocol
WIDEBAND Monitoring
WIDEBAND EXPAK
ISO cnlp
VMTP
Secure VMTP
Banyon VINES
TTP
NSFNET-IGP
TCF
Cisco/GXS IGRP
OSPFIGP
Multicast Transport
AX.25 Frames
IP encapsulated in IP
Ethernet IP encapsulation
encapsulation header
GMTP
PGM
divert pseudo-protocol
raw IP packet
0.0.0.0
127.0.0.1
224.0.0.0
224.0.0.1
224.0.0.2
224.0.0.255
Data Structures
• struct rte_ivshmem_metadata_entry
• struct rte_ivshmem_metadata
Functions
• int rte_ivshmem_metadata_create (const char ∗name)
• int rte_ivshmem_metadata_add_memzone (const struct rte_memzone ∗mz, const char ∗md_name)
• int rte_ivshmem_metadata_add_ring (const struct rte_ring ∗r, const char ∗md_name)
• int rte_ivshmem_metadata_add_mempool (const struct rte_mempool ∗mp, const char ∗md_name)
• int rte_ivshmem_metadata_cmdline_generate (char ∗buffer, unsigned size, const char ∗name)
Dump all metadata entries from a given metadata file to the console.
Name of the metadata file to be dumped to console.
The RTE IVSHMEM interface provides functions to create metadata files describing memory segments to
be shared via QEMU IVSHMEM.
Parameters
name Name of metadata file to be created
Returns
• On success, zero
• On failure, a negative value
3.19.2.2 int rte ivshmem metadata add memzone ( const struct rte_memzone ∗ mz, const char ∗ md name )
Parameters
mz Memzone to be added
md_name Name of metadata file for the memzone to be added to
Returns
• On success, zero
• On failure, a negative value
3.19.2.3 int rte ivshmem metadata add ring ( const struct rte_ring ∗ r, const char ∗ md name )
Parameters
r Ring descriptor to be added
md_name Name of metadata file for the ring to be added to
Returns
• On success, zero
• On failure, a negative value
3.19.2.4 int rte ivshmem metadata add mempool ( const struct rte_mempool ∗ mp, const char ∗ md name )
Parameters
mp Mempool to be added
md_name Name of metadata file for the mempool to be added to
Returns
• On success, zero
• On failure, a negative value
3.19.2.5 int rte ivshmem metadata cmdline generate ( char ∗ buffer, unsigned size, const char ∗ name )
Generates the QEMU command-line for IVSHMEM device for a given metadata file. This function is to be
called after all the objects were added.
Parameters
buffer Buffer to be filled with the command line arguments.
size Size of the buffer.
name Name of metadata file to generate QEMU command-line parameters for
Returns
• On success, zero
• On failure, a negative value
Defines
• #define RTE_JHASH_GOLDEN_RATIO
Functions
• static uint32_t rte_jhash (const void ∗key, uint32_t length, uint32_t initval)
• static uint32_t rte_jhash2 (uint32_t ∗k, uint32_t length, uint32_t initval)
• static uint32_t rte_jhash_3words (uint32_t a, uint32_t b, uint32_t c, uint32_t initval)
• static uint32_t rte_jhash_2words (uint32_t a, uint32_t b, uint32_t initval)
• static uint32_t rte_jhash_1word (uint32_t a, uint32_t initval)
jhash functions.
3.20.3.1 static uint32 t rte jhash ( const void ∗ key, uint32 t length, uint32 t initval ) [static]
The most generic version, hashes an arbitrary sequence of bytes. No alignment or length assumptions are
made about the input key.
Parameters
key Key to calculate hash of.
length Length of key in bytes.
initval Initialising value of hash.
Returns
Calculated hash value.
3.20.3.2 static uint32 t rte jhash2 ( uint32 t ∗ k, uint32 t length, uint32 t initval ) [static]
A special optimized version that handles 1 or more of uint32_ts. The length parameter here is the number
of uint32_ts in the key.
Parameters
k Key to calculate hash of.
length Length of key in units of 4 bytes.
initval Initialising value of hash.
Returns
Calculated hash value.
3.20.3.3 static uint32 t rte jhash 3words ( uint32 t a, uint32 t b, uint32 t c, uint32 t initval ) [static]
Parameters
a First word to calcuate hash of.
b Second word to calcuate hash of.
c Third word to calcuate hash of.
initval Initialising value of hash.
Returns
Calculated hash value.
3.20.3.4 static uint32 t rte jhash 2words ( uint32 t a, uint32 t b, uint32 t initval ) [static]
Parameters
a First word to calcuate hash of.
b Second word to calcuate hash of.
initval Initialising value of hash.
Returns
Calculated hash value.
3.20.3.5 static uint32 t rte jhash 1word ( uint32 t a, uint32 t initval ) [static]
Parameters
a Word to calcuate hash of.
initval Initialising value of hash.
Returns
Calculated hash value.
Data Structures
• struct rte_kni_ops
• struct rte_kni_conf
Functions
• struct rte_kni ∗ rte_kni_alloc (struct rte_mempool ∗pktmbuf_pool, const struct rte_kni_conf ∗conf,
struct rte_kni_ops ∗ops)
• struct rte_kni ∗ rte_kni_create (uint8_t port_id, unsigned mbuf_size, struct rte_mempool ∗pktmbuf_-
pool, struct rte_kni_ops ∗ops)
• int rte_kni_release (struct rte_kni ∗kni)
• int rte_kni_handle_request (struct rte_kni ∗kni)
• unsigned rte_kni_rx_burst (struct rte_kni ∗kni, struct rte_mbuf ∗∗mbufs, unsigned num)
• unsigned rte_kni_tx_burst (struct rte_kni ∗kni, struct rte_mbuf ∗∗mbufs, unsigned num)
• uint8_t rte_kni_get_port_id (struct rte_kni ∗kni)
• struct rte_kni ∗ rte_kni_get (const char ∗name)
• struct rte_kni ∗ rte_kni_info_get (uint8_t port_id)
• int rte_kni_register_handlers (struct rte_kni ∗kni, struct rte_kni_ops ∗ops)
RTE KNI
The KNI library provides the ability to create and destroy kernel NIC interfaces that may be used by the RTE
application to receive/transmit packets from/to Linux kernel net interfaces.
This library provide two APIs to burst receive packets from KNI interfaces, and burst transmit packets to KNI
interfaces.
3.21.2.1 struct rte kni∗ rte kni alloc ( struct rte_mempool ∗ pktmbuf pool, const struct rte_kni_conf ∗ conf,
struct rte_kni_ops ∗ ops ) [read]
Allocate KNI interface according to the port id, mbuf size, mbuf pool, configurations and callbacks for kernel
requests.The KNI interface created in the kernel space is the net interface the traditional Linux application
talking to.
Parameters
pktmbuf_pool The mempool for allocting mbufs for packets.
conf The pointer to the configurations of the KNI device.
ops The pointer to the callbacks for the KNI kernel requests.
Returns
• The pointer to the context of a KNI interface.
• NULL indicate error.
3.21.2.2 struct rte kni∗ rte kni create ( uint8 t port id, unsigned mbuf size, struct rte_mempool ∗ pktmbuf pool,
struct rte_kni_ops ∗ ops ) [read]
Parameters
port_id Port ID.
mbuf_size mbuf size.
pktmbuf_pool The mempool for allocting mbufs for packets.
ops The pointer to the callbacks for the KNI kernel requests.
Returns
• The pointer to the context of a KNI interface.
• NULL indicate error.
Release KNI interface according to the context. It will also release the paired KNI interface in kernel space.
All processing on the specific KNI context need to be stopped before calling this interface.
Parameters
kni The pointer to the context of an existant KNI interface.
Returns
• 0 indicates success.
• negative value indicates failure.
3.21.2.4 int rte kni handle request ( struct rte kni ∗ kni )
It is used to handle the request mbufs sent from kernel space. Then analyzes it and calls the specific actions
for the specific requests. Finally constructs the response mbuf and puts it back to the resp_q.
Parameters
kni The pointer to the context of an existant KNI interface.
Returns
• 0
• negative value indicates failure.
3.21.2.5 unsigned rte kni rx burst ( struct rte kni ∗ kni, struct rte_mbuf ∗∗ mbufs, unsigned num )
Retrieve a burst of packets from a KNI interface. The retrieved packets are stored in rte_mbuf structures
whose pointers are supplied in the array of mbufs, and the maximum number is indicated by num. It handles
the freeing of the mbufs in the free queue of KNI interface.
Parameters
kni The KNI interface context.
mbufs The array to store the pointers of mbufs.
num The maximum number per burst.
Returns
The actual number of packets retrieved.
3.21.2.6 unsigned rte kni tx burst ( struct rte kni ∗ kni, struct rte_mbuf ∗∗ mbufs, unsigned num )
Send a burst of packets to a KNI interface. The packets to be sent out are stored in rte_mbuf structures
whose pointers are supplied in the array of mbufs, and the maximum number is indicated by num. It handles
allocating the mbufs for KNI interface alloc queue.
Parameters
kni The KNI interface context.
mbufs The array to store the pointers of mbufs.
num The maximum number per burst.
Returns
The actual number of packets sent.
3.21.2.7 uint8 t rte kni get port id ( struct rte kni ∗ kni )
Parameters
kni The KNI interface context.
Returns
On success: The port id. On failure: ∼0x0
3.21.2.8 struct rte kni∗ rte kni get ( const char ∗ name ) [read]
Parameters
name pointer to the KNI device name.
Returns
On success: Pointer to KNI interface. On failure: NULL.
3.21.2.9 struct rte kni∗ rte kni info get ( uint8 t port id ) [read]
Parameters
port_id the port id.
Returns
On success: Pointer to KNI interface. On failure: NULL
3.21.2.10 int rte kni register handlers ( struct rte kni ∗ kni, struct rte_kni_ops ∗ ops )
Register KNI request handling for a specified port,and it can be called by master process or slave process.
Parameters
kni pointer to struct rte_kni.
ops ponter to struct rte_kni_ops.
Returns
On success: 0 On failure: -1
3.21.2.11 int rte kni unregister handlers ( struct rte kni ∗ kni )
Parameters
kni pointer to struct rte_kni.
Returns
On success: 0 On failure: -1
Parameters
void
Returns
void
Typedefs
Enumerations
Functions
State of an lcore.
Enumerator:
WAIT waiting a new command
RUNNING executing command
FINISHED command executed
This enum indicates whether the master core must execute the handler launched on all logical cores.
Enumerator:
SKIP_MASTER lcore handler not executed by master core.
CALL_MASTER lcore handler executed by master core.
3.22.4.1 int rte eal remote launch ( lcore_function_t ∗ f, void ∗ arg, unsigned slave id )
Parameters
f The function to be called.
arg The argument for the function.
slave_id The identifier of the lcore on which the function should be executed.
Returns
• 0: Success. Execution of function f started on the remote lcore.
• (-EBUSY): The remote lcore is not in a WAIT state.
3.22.4.2 int rte eal mp remote launch ( lcore_function_t ∗ f, void ∗ arg, enum rte_rmt_call_master_t
call master )
Parameters
f The function to be called.
arg The argument for the function.
call_master If call_master set to SKIP_MASTER, the MASTER lcore does not call the function. -
If call_master is set to CALL_MASTER, the function is also called on master before
returning. In any case, the master lcore returns as soon as it finished its job and knows
nothing about the completion of f on the other lcores.
Returns
• 0: Success. Execution of function f started on all remote lcores.
• (-EBUSY): At least one remote lcore is not in a WAIT state. In this case, no message is sent to
any of the lcores.
3.22.4.3 enum rte_lcore_state_t rte eal get lcore state ( unsigned slave id )
Parameters
slave_id The identifier of the lcore.
Returns
The state of the lcore.
If the slave lcore identified by the slave_id is in a FINISHED state, switch to the WAIT state. If the lcore is in
RUNNING state, wait until the lcore finishes its job and moves to the FINISHED state.
Parameters
slave_id The identifier of the lcore.
Returns
• 0: If the lcore identified by the slave_id is in a WAIT state.
• The value that was returned by the previous remote launch function call if the lcore identified by
the slave_id was in a FINISHED or RUNNING state. In this case, it changes the state of the lcore
to WAIT.
Defines
• #define LCORE_ID_ANY
• #define RTE_LCORE_FOREACH(i)
• #define RTE_LCORE_FOREACH_SLAVE(i)
Functions
• RTE_DECLARE_PER_LCORE (unsigned, _lcore_id)
• static unsigned rte_lcore_id (void)
• static unsigned rte_get_master_lcore (void)
• static unsigned rte_lcore_count (void)
• static unsigned rte_socket_id (void)
• static unsigned rte_lcore_to_socket_id (unsigned lcore_id)
• static int rte_lcore_is_enabled (unsigned lcore_id)
• static unsigned rte_get_next_lcore (unsigned i, int skip_master, int wrap)
API for lcore and Socket Manipulation. Parts of this are execution environment specific.
Any lcore.
Returns
Logical core ID
Returns
the id of the master lcore
Returns
the number of execution units (lcores) on the system.
Return the ID of the physical socket of the logical core we are running on.
Returns
the ID of current lcoreid’s physical socket
Parameters
lcore_id the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
Returns
the ID of lcoreid’s physical socket
Parameters
lcore_id The identifier of the lcore, which MUST be between 0 and RTE_MAX_LCORE-1.
Returns
True if the given lcore is enabled; false otherwise.
3.23.3.8 static unsigned rte get next lcore ( unsigned i, int skip master, int wrap ) [static]
Parameters
i The current lcore (reference).
skip_master If true, do not return the ID of the master lcore.
wrap If true, go back to 0 when RTE_MAX_LCORE is reached; otherwise, return RTE_MAX-
_LCORE.
Returns
The next lcore_id or RTE_MAX_LCORE if not found.
Data Structures
• struct rte_logs
Defines
• #define RTE_LOGTYPE_EAL
• #define RTE_LOGTYPE_MALLOC
• #define RTE_LOGTYPE_RING
• #define RTE_LOGTYPE_MEMPOOL
• #define RTE_LOGTYPE_TIMER
• #define RTE_LOGTYPE_PMD
• #define RTE_LOGTYPE_HASH
• #define RTE_LOGTYPE_LPM
• #define RTE_LOGTYPE_KNI
• #define RTE_LOGTYPE_ACL
• #define RTE_LOGTYPE_POWER
• #define RTE_LOGTYPE_METER
• #define RTE_LOGTYPE_SCHED
• #define RTE_LOGTYPE_USER1
• #define RTE_LOGTYPE_USER2
• #define RTE_LOGTYPE_USER3
• #define RTE_LOGTYPE_USER4
• #define RTE_LOGTYPE_USER5
• #define RTE_LOGTYPE_USER6
• #define RTE_LOGTYPE_USER7
• #define RTE_LOGTYPE_USER8
• #define RTE_LOG_EMERG
• #define RTE_LOG_ALERT
• #define RTE_LOG_CRIT
• #define RTE_LOG_ERR
• #define RTE_LOG_WARNING
• #define RTE_LOG_NOTICE
• #define RTE_LOG_INFO
• #define RTE_LOG_DEBUG
• #define RTE_LOG(l, t,...)
Functions
Variables
System is unusable.
Critical conditions.
Error conditions.
Warning conditions.
Informational.
Debug-level messages.
• RTE_LOG() can be used to remove debug logs at compilation time, depending on RTE_LOG_LEVEL
configuration option, and compilation optimization level. If optimization is enabled, the tests involving
constants only are pre-computed. If compilation is done with -O0, these tests will be done at run time.
• The log level and log type names are smaller, for example: RTE_LOG(INFO, EAL, "this is a %s", "log");
Parameters
l Log level. A value between EMERG (1) and DEBUG (8). The short name is expanded
by the macro, so it cannot be an integer value.
t The log type, for example, EAL. The short name is expanded by the macro, so it cannot
be an integer value.
fmt The fmt string, as in printf(3), followed by the variable arguments required by the format.
args The variable list of arguments according to the format string.
Returns
• 0: Success.
• Negative on error.
Parameters
f Pointer to the stream.
Returns
• 0 on success.
• Negative on error.
Parameters
level Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
3.24.3.3 void rte set log type ( uint32 t type, int enable )
Parameters
type Log type, for example, RTE_LOGTYPE_EAL.
enable True for enable; false for disable.
Returns
The loglevel of the message being processed.
Returns
The logtype of the message being processed.
Parameters
enable true to enable, or 0 to disable history.
3.24.3.8 int rte log add in history ( const char ∗ buf, size t size )
Parameters
buf A data buffer containing the message to be saved in the history.
size The length of the data buffer.
Returns
• 0: Success.
• (-ENOBUFS) if there is no room to store the message.
3.24.3.9 int rte log ( uint32 t level, uint32 t logtype, const char ∗ format, ... )
Parameters
level Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
logtype The log type, for example, RTE_LOGTYPE_EAL.
format The format string, as in printf(3), followed by the variable arguments required by the
format.
Returns
• 0: Success.
• Negative on error.
3.24.3.10 int rte vlog ( uint32 t level, uint32 t logtype, const char ∗ format, va list ap )
Parameters
level Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).
logtype The log type, for example, RTE_LOGTYPE_EAL.
format The format string, as in printf(3), followed by the variable arguments required by the
format.
ap The va_list of the variable arguments required by the format.
Returns
• 0: Success.
• Negative on error.
Data Structures
• struct rte_lpm_tbl24_entry
• struct rte_lpm_tbl8_entry
• struct rte_lpm_rule
• struct rte_lpm_rule_info
• struct rte_lpm
Defines
• #define RTE_LPM_NAMESIZE
• #define RTE_LPM_HEAP
• #define RTE_LPM_MEMZONE
• #define RTE_LPM_MAX_DEPTH
• #define RTE_LPM_LOOKUP_SUCCESS
• #define rte_lpm_lookup_bulk(lpm, ips, next_hops, n)
Functions
• struct rte_lpm ∗ rte_lpm_create (const char ∗name, int socket_id, int max_rules, int flags)
• struct rte_lpm ∗ rte_lpm_find_existing (const char ∗name)
• void rte_lpm_free (struct rte_lpm ∗lpm)
• int rte_lpm_add (struct rte_lpm ∗lpm, uint32_t ip, uint8_t depth, uint8_t next_hop)
• int rte_lpm_delete (struct rte_lpm ∗lpm, uint32_t ip, uint8_t depth)
• void rte_lpm_delete_all (struct rte_lpm ∗lpm)
• static int rte_lpm_lookup (struct rte_lpm ∗lpm, uint32_t ip, uint8_t ∗next_hop)
Deprecated Possible location to allocate memory. This was for last parameter of rte_lpm_create(), but is
now redundant. The LPM table is always allocated in memory using librte_malloc which uses
a memzone.
Deprecated Possible location to allocate memory. This was for last parameter of rte_lpm_create(), but is
now redundant. The LPM table is always allocated in memory using librte_malloc which uses
a memzone.
3.25.2.6 #define rte lpm lookup bulk( lpm, ips, next hops, n )
Lookup multiple IP addresses in an LPM table. This may be implemented as a macro, so the address of the
function should not be used.
Parameters
lpm LPM object handle
ips Array of IPs to be looked up in the LPM table
next_hops Next hop of the most specific rule found for IP (valid on lookup hit only). This is an array
of two byte values. The most significant byte in each value says whether the lookup was
successful (bitmask RTE_LPM_LOOKUP_SUCCESS is set). The least significant byte
is the actual next hop.
n Number of elements in ips (and next_hops) array to lookup. This should be a compile
time constant, and divisible by 8 for best performance.
Returns
-EINVAL for incorrect arguments, otherwise 0
3.25.3.1 struct rte_lpm∗ rte lpm create ( const char ∗ name, int socket id, int max rules, int flags ) [read]
Parameters
name LPM object name
socket_id NUMA socket ID for LPM table memory allocation
max_rules Maximum number of LPM rules that can be added
flags This parameter is currently unused
Returns
Handle to LPM object on success, NULL otherwise with rte_errno set to an appropriate values. Possible
rte_errno values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the lpm object list
• EINVAL - invalid parameter passed to function
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
3.25.3.2 struct rte_lpm∗ rte lpm find existing ( const char ∗ name ) [read]
Parameters
name Name of the lpm object as passed to rte_lpm_create()
Returns
Pointer to lpm object or NULL if object not found with rte_errno set appropriately. Possible rte_errno
values include:
• ENOENT - required entry not available to return.
Parameters
lpm LPM object handle
Returns
None
3.25.3.4 int rte lpm add ( struct rte_lpm ∗ lpm, uint32 t ip, uint8 t depth, uint8 t next hop )
Parameters
lpm LPM object handle
ip IP of the rule to be added to the LPM table
depth Depth of the rule to be added to the LPM table
next_hop Next hop of the rule to be added to the LPM table
Returns
0 on success, negative value otherwise
3.25.3.5 int rte lpm delete ( struct rte_lpm ∗ lpm, uint32 t ip, uint8 t depth )
Parameters
lpm LPM object handle
ip IP of the rule to be deleted from the LPM table
depth Depth of the rule to be deleted from the LPM table
Returns
0 on success, negative value otherwise
Parameters
lpm LPM object handle
3.25.3.7 static int rte lpm lookup ( struct rte_lpm ∗ lpm, uint32 t ip, uint8 t ∗ next hop ) [static]
Parameters
lpm LPM object handle
ip IP to be looked up in the LPM table
next_hop Next hop of the most specific rule found for IP (valid on lookup hit only)
Returns
-EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
Data Structures
• struct rte_lpm6_config
Defines
• #define RTE_LPM6_NAMESIZE
Functions
• struct rte_lpm6 ∗ rte_lpm6_create (const char ∗name, int socket_id, const struct rte_lpm6_config
∗config)
• struct rte_lpm6 ∗ rte_lpm6_find_existing (const char ∗name)
• void rte_lpm6_free (struct rte_lpm6 ∗lpm)
• int rte_lpm6_add (struct rte_lpm6 ∗lpm, uint8_t ∗ip, uint8_t depth, uint8_t next_hop)
• int rte_lpm6_delete (struct rte_lpm6 ∗lpm, uint8_t ∗ip, uint8_t depth)
• int rte_lpm6_delete_bulk_func (struct rte_lpm6 ∗lpm, uint8_t ips[ ][RTE_LPM6_IPV6_ADDR_SIZE],
uint8_t ∗depths, unsigned n)
• void rte_lpm6_delete_all (struct rte_lpm6 ∗lpm)
• int rte_lpm6_lookup (const struct rte_lpm6 ∗lpm, uint8_t ∗ip, uint8_t ∗next_hop)
• int rte_lpm6_lookup_bulk_func (const struct rte_lpm6 ∗lpm, uint8_t ips[ ][RTE_LPM6_IPV6_ADDR_S-
IZE], int16_t ∗next_hops, unsigned n)
3.26.3.1 struct rte lpm6∗ rte lpm6 create ( const char ∗ name, int socket id, const struct rte_lpm6_config ∗ config
) [read]
Parameters
name LPM object name
socket_id NUMA socket ID for LPM table memory allocation
config Structure containing the configuration
Returns
Handle to LPM object on success, NULL otherwise with rte_errno set to an appropriate values. Possible
rte_errno values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the lpm object list
• EINVAL - invalid parameter passed to function
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
3.26.3.2 struct rte lpm6∗ rte lpm6 find existing ( const char ∗ name ) [read]
Parameters
name Name of the lpm object as passed to rte_lpm6_create()
Returns
Pointer to lpm object or NULL if object not found with rte_errno set appropriately. Possible rte_errno
values include:
• ENOENT - required entry not available to return.
Parameters
lpm LPM object handle
Returns
None
3.26.3.4 int rte lpm6 add ( struct rte lpm6 ∗ lpm, uint8 t ∗ ip, uint8 t depth, uint8 t next hop )
Parameters
lpm LPM object handle
ip IP of the rule to be added to the LPM table
depth Depth of the rule to be added to the LPM table
next_hop Next hop of the rule to be added to the LPM table
Returns
0 on success, negative value otherwise
3.26.3.5 int rte lpm6 delete ( struct rte lpm6 ∗ lpm, uint8 t ∗ ip, uint8 t depth )
Parameters
lpm LPM object handle
ip IP of the rule to be deleted from the LPM table
depth Depth of the rule to be deleted from the LPM table
Returns
0 on success, negative value otherwise
3.26.3.6 int rte lpm6 delete bulk func ( struct rte lpm6 ∗ lpm, uint8 t ips[ ][RTE LPM6 IPV6 ADDR SIZE], uint8 t ∗
depths, unsigned n )
Parameters
lpm LPM object handle
ips Array of IPs to be deleted from the LPM table
depths Array of depths of the rules to be deleted from the LPM table
n Number of rules to be deleted from the LPM table
Returns
0 on success, negative value otherwise.
3.26.3.7 void rte lpm6 delete all ( struct rte lpm6 ∗ lpm )
Parameters
lpm LPM object handle
3.26.3.8 int rte lpm6 lookup ( const struct rte lpm6 ∗ lpm, uint8 t ∗ ip, uint8 t ∗ next hop )
Parameters
lpm LPM object handle
ip IP to be looked up in the LPM table
next_hop Next hop of the most specific rule found for IP (valid on lookup hit only)
Returns
-EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
3.26.3.9 int rte lpm6 lookup bulk func ( const struct rte lpm6 ∗ lpm, uint8 t ips[ ][RTE LPM6 IPV6 ADDR SIZE],
int16 t ∗ next hops, unsigned n )
Parameters
lpm LPM object handle
ips Array of IPs to be looked up in the LPM table
next_hops Next hop of the most specific rule found for IP (valid on lookup hit only). This is an array
of two byte values. The next hop will be stored on each position on success; otherwise
the position will be set to -1.
n Number of elements in ips (and next_hops) array to lookup.
Returns
-EINVAL for incorrect arguments, otherwise 0
Data Structures
• struct rte_malloc_socket_stats
Functions
• void ∗ rte_malloc_socket (const char ∗type, size_t size, unsigned align, int socket)
• void ∗ rte_zmalloc_socket (const char ∗type, size_t size, unsigned align, int socket)
• void ∗ rte_calloc_socket (const char ∗type, size_t num, size_t size, unsigned align, int socket)
• void rte_free (void ∗ptr)
• int rte_malloc_validate (void ∗ptr, size_t ∗size)
• int rte_malloc_get_socket_stats (int socket, struct rte_malloc_socket_stats ∗socket_stats)
• void rte_malloc_dump_stats (const char ∗type)
• int rte_malloc_set_limit (const char ∗type, size_t max)
RTE Malloc. This library provides methods for dynamically allocating memory from hugepages.
3.27.2.1 void∗ rte malloc ( const char ∗ type, size t size, unsigned align )
This function allocates memory from the huge-page area of memory. The memory is not cleared. In NUMA
systems, the memory allocated resides on the same NUMA socket as the core that calls this function.
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
size Size (in bytes) to be allocated.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. -
In this case, it must be a power of two. (Minimum alignment is the cacheline size, i.e.
64-bytes)
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
3.27.2.2 void∗ rte zmalloc ( const char ∗ type, size t size, unsigned align )
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
size Size (in bytes) to be allocated.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. In
this case, it must obviously be a power of two. (Minimum alignment is the cacheline size,
i.e. 64-bytes)
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
3.27.2.3 void∗ rte calloc ( const char ∗ type, size t num, size t size, unsigned align )
Replacement function for calloc(), using huge-page memory. Memory area is initialised with zeros. In NUMA
systems, the memory allocated resides on the same NUMA socket as the core that calls this function.
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
num Number of elements to be allocated.
size Size (in bytes) of a single element.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. In
this case, it must obviously be a power of two. (Minimum alignment is the cacheline size,
i.e. 64-bytes)
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
3.27.2.4 void∗ rte realloc ( void ∗ ptr, size t size, unsigned align )
Replacement function for realloc(), using huge-page memory. Reserved area memory is resized, preserving
contents. In NUMA systems, the new area resides on the same NUMA socket as the old area.
Parameters
ptr Pointer to already allocated memory
size Size (in bytes) of new area. If this is 0, memory is freed.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. In
this case, it must obviously be a power of two. (Minimum alignment is the cacheline size,
i.e. 64-bytes)
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the reallocated memory.
3.27.2.5 void∗ rte malloc socket ( const char ∗ type, size t size, unsigned align, int socket )
This function allocates memory from the huge-page area of memory. The memory is not cleared.
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
size Size (in bytes) to be allocated.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. -
In this case, it must be a power of two. (Minimum alignment is the cacheline size, i.e.
64-bytes)
socket NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this function will
behave the same as rte_malloc().
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
3.27.2.6 void∗ rte zmalloc socket ( const char ∗ type, size t size, unsigned align, int socket )
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
size Size (in bytes) to be allocated.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. In
this case, it must obviously be a power of two. (Minimum alignment is the cacheline size,
i.e. 64-bytes)
socket NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this function will
behave the same as rte_zmalloc().
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
3.27.2.7 void∗ rte calloc socket ( const char ∗ type, size t num, size t size, unsigned align, int socket )
Replacement function for calloc(), using huge-page memory. Memory area is initialised with zeros.
Parameters
type A string identifying the type of allocated objects (useful for debug purposes, such as
identifying the cause of a memory leak). Can be NULL.
num Number of elements to be allocated.
size Size (in bytes) of a single element.
align If 0, the return is a pointer that is suitably aligned for any kind of variable (in the same
manner as malloc()). Otherwise, the return is a pointer that is a multiple of ∗align∗. In
this case, it must obviously be a power of two. (Minimum alignment is the cacheline size,
i.e. 64-bytes)
socket NUMA socket to allocate memory on. If SOCKET_ID_ANY is used, this function will
behave the same as rte_calloc().
Returns
• NULL on error. Not enough memory, or invalid arguments (size is 0, align is not a power of two).
• Otherwise, the pointer to the allocated object.
Parameters
ptr The pointer to memory to be freed.
If malloc debug is enabled, check a memory block for header and trailer markers to indicate that all is well
with the block. If size is non-null, also return the size of the block.
Parameters
ptr pointer to the start of a data block, must have been returned by a previous call to rte_-
malloc(), rte_zmalloc(), rte_calloc() or rte_realloc()
size if non-null, and memory block pointer is valid, returns the size of the memory block
Returns
-1 on error, invalid pointer passed or header and trailer markers are missing or corrupted 0 on success
3.27.2.10 int rte malloc get socket stats ( int socket, struct rte_malloc_socket_stats ∗ socket stats )
Parameters
socket An unsigned integer specifying the socket to get heap statistics for
socket_stats A structure which provides memory to store statistics
Returns
Null on error Pointer to structure storing statistics on success
Dump statistics.
Dump for the specified type to the console. If the type argument is NULL, all memory types will be dumped.
Parameters
type A string identifying the type of objects to dump, or NULL to dump all objects.
3.27.2.12 int rte malloc set limit ( const char ∗ type, size t max )
Parameters
type A string identifying the type of allocated objects.
max The maximum amount of allocated bytes for this type.
Returns
• 0: Success.
• (-1): Error.
Data Structures
• struct rte_ctrlmbuf
• union rte_vlan_macip
• struct rte_pktmbuf
• struct rte_mbuf
• struct rte_pktmbuf_pool_private
Defines
• #define PKT_RX_VLAN_PKT
• #define PKT_RX_RSS_HASH
• #define PKT_RX_FDIR
• #define PKT_RX_L4_CKSUM_BAD
• #define PKT_RX_IP_CKSUM_BAD
• #define PKT_RX_IPV4_HDR
• #define PKT_RX_IPV4_HDR_EXT
• #define PKT_RX_IPV6_HDR
• #define PKT_RX_IPV6_HDR_EXT
• #define PKT_RX_IEEE1588_PTP
• #define PKT_RX_IEEE1588_TMST
• #define PKT_TX_VLAN_PKT
• #define PKT_TX_IP_CKSUM
• #define PKT_TX_L4_MASK
• #define PKT_TX_L4_NO_CKSUM
• #define PKT_TX_TCP_CKSUM
• #define PKT_TX_SCTP_CKSUM
• #define PKT_TX_UDP_CKSUM
• #define PKT_TX_IEEE1588_TMST
• #define PKT_TX_OFFLOAD_MASK
• #define TX_VLAN_CMP_MASK
• #define TX_MAC_LEN_CMP_MASK
• #define TX_IP_LEN_CMP_MASK
• #define RTE_MBUF_FROM_BADDR(ba)
• #define RTE_MBUF_TO_BADDR(mb)
• #define RTE_MBUF_INDIRECT(mb)
• #define RTE_MBUF_DIRECT(mb)
• #define __rte_mbuf_sanity_check(m, t, is_h)
• #define __rte_mbuf_sanity_check_raw(m, t, is_h)
• #define RTE_MBUF_ASSERT(exp)
• #define RTE_MBUF_PREFETCH_TO_FREE(m)
• #define rte_ctrlmbuf_data(m)
• #define rte_ctrlmbuf_len(m)
• #define rte_pktmbuf_mtod(m, t)
• #define rte_pktmbuf_pkt_len(m)
• #define rte_pktmbuf_data_len(m)
Enumerations
• enum rte_mbuf_type { RTE_MBUF_CTRL, RTE_MBUF_PKT }
Functions
• static uint16_t rte_mbuf_refcnt_update (struct rte_mbuf ∗m, int16_t value)
• static uint16_t rte_mbuf_refcnt_read (const struct rte_mbuf ∗m)
• static void rte_mbuf_refcnt_set (struct rte_mbuf ∗m, uint16_t new_value)
• void rte_mbuf_sanity_check (const struct rte_mbuf ∗m, enum rte_mbuf_type t, int is_header)
• void rte_ctrlmbuf_init (struct rte_mempool ∗mp, void ∗opaque_arg, void ∗m, unsigned i)
• static struct rte_mbuf ∗ rte_ctrlmbuf_alloc (struct rte_mempool ∗mp)
• static void rte_ctrlmbuf_free (struct rte_mbuf ∗m)
• void rte_pktmbuf_init (struct rte_mempool ∗mp, void ∗opaque_arg, void ∗m, unsigned i)
• void rte_pktmbuf_pool_init (struct rte_mempool ∗mp, void ∗opaque_arg)
• static void rte_pktmbuf_reset (struct rte_mbuf ∗m)
• static struct rte_mbuf ∗ rte_pktmbuf_alloc (struct rte_mempool ∗mp)
• static void rte_pktmbuf_attach (struct rte_mbuf ∗mi, struct rte_mbuf ∗md)
• static void rte_pktmbuf_detach (struct rte_mbuf ∗m)
• static void rte_pktmbuf_free_seg (struct rte_mbuf ∗m)
• static void rte_pktmbuf_free (struct rte_mbuf ∗m)
• static struct rte_mbuf ∗ rte_pktmbuf_clone (struct rte_mbuf ∗md, struct rte_mempool ∗mp)
• static void rte_pktmbuf_refcnt_update (struct rte_mbuf ∗m, int16_t v)
• static uint16_t rte_pktmbuf_headroom (const struct rte_mbuf ∗m)
• static uint16_t rte_pktmbuf_tailroom (const struct rte_mbuf ∗m)
• static struct rte_mbuf ∗ rte_pktmbuf_lastseg (struct rte_mbuf ∗m)
• static char ∗ rte_pktmbuf_prepend (struct rte_mbuf ∗m, uint16_t len)
• static char ∗ rte_pktmbuf_append (struct rte_mbuf ∗m, uint16_t len)
• static char ∗ rte_pktmbuf_adj (struct rte_mbuf ∗m, uint16_t len)
• static int rte_pktmbuf_trim (struct rte_mbuf ∗m, uint16_t len)
• static int rte_pktmbuf_is_contiguous (const struct rte_mbuf ∗m)
• void rte_pktmbuf_dump (const struct rte_mbuf ∗m, unsigned dump_len)
RTE Mbuf
The mbuf library provides the ability to create and destroy buffers that may be used by the RTE application
to store message buffers. The message buffers are stored in a mempool, using the RTE mempool library.
This library provide an API to allocate/free mbufs, manipulate control message buffer (ctrlmbuf), which are
generic message buffers, and packet buffers (pktmbuf), which are used to carry network packets.
To understand the concepts of packet buffers or mbufs, you should read "TCP/IP Illustrated, Volume 2:
The Implementation, Addison-Wesley, 1995, ISBN 0-201-63354-X from Richard Stevens" http://www.-
kohala.com/start/tcpipiv2.html
The main modification of this implementation is the use of mbuf for transports other than packets. mbufs
can have other types.
Given the pointer to mbuf returns an address where it’s buf_addr should point to.
Mbuf prefetch
Parameters
m The control mbuf.
Parameters
m The control mbuf.
Parameters
m The packet mbuf.
t The type to cast the result into.
Parameters
m The packet mbuf.
Parameters
m The packet mbuf.
Enumerator:
RTE_MBUF_CTRL Control mbuf.
RTE_MBUF_PKT Packet mbuf.
3.28.4.1 static uint16 t rte mbuf refcnt update ( struct rte_mbuf ∗ m, int16 t value ) [static]
Adds given value to an mbuf’s refcnt and returns its new value.
Parameters
m Mbuf to update
value Value to add/subtract
Returns
Updated value
3.28.4.2 static uint16 t rte mbuf refcnt read ( const struct rte_mbuf ∗ m ) [static]
Parameters
m Mbuf to read
Returns
Reference count number.
3.28.4.3 static void rte mbuf refcnt set ( struct rte_mbuf ∗ m, uint16 t new value ) [static]
Parameters
m Mbuf to update
new_value Value set
3.28.4.4 void rte mbuf sanity check ( const struct rte_mbuf ∗ m, enum rte_mbuf_type t, int is header )
Parameters
m The mbuf to be checked.
t The expected type of the mbuf.
is_header True if the mbuf is a packet header, false if it is a sub-segment of a packet (in this case,
some fields like nb_segs are not checked)
3.28.4.5 void rte ctrlmbuf init ( struct rte_mempool ∗ mp, void ∗ opaque arg, void ∗ m, unsigned i )
Parameters
mp The mempool from which the mbuf is allocated.
opaque_arg A pointer that can be used by the user to retrieve useful information for mbuf initialization.
This pointer comes from the “init_arg“ parameter of rte_mempool_create().
m The mbuf to initialize.
i The index of the mbuf in the pool table.
3.28.4.6 static struct rte_mbuf∗ rte ctrlmbuf alloc ( struct rte_mempool ∗ mp ) [static, read]
Parameters
mp The mempool from which the mbuf is allocated.
Returns
• The pointer to the new mbuf on success.
• NULL if allocation failed.
Parameters
m The control mbuf to be freed.
3.28.4.8 void rte pktmbuf init ( struct rte_mempool ∗ mp, void ∗ opaque arg, void ∗ m, unsigned i )
Parameters
mp The mempool from which mbufs originate.
opaque_arg A pointer that can be used by the user to retrieve useful information for mbuf initialization.
This pointer comes from the “init_arg“ parameter of rte_mempool_create().
m The mbuf to initialize.
i The index of the mbuf in the pool table.
3.28.4.9 void rte pktmbuf pool init ( struct rte_mempool ∗ mp, void ∗ opaque arg )
Parameters
mp The mempool from which mbufs originate.
opaque_arg A pointer that can be used by the user to retrieve useful information for mbuf initialization.
This pointer comes from the “init_arg“ parameter of rte_mempool_create().
Parameters
m The packet mbuf to be resetted.
3.28.4.11 static struct rte_mbuf∗ rte pktmbuf alloc ( struct rte_mempool ∗ mp ) [static, read]
Parameters
mp The mempool from which the mbuf is allocated.
Returns
• The pointer to the new mbuf on success.
• NULL if allocation failed.
3.28.4.12 static void rte pktmbuf attach ( struct rte_mbuf ∗ mi, struct rte_mbuf ∗ md ) [static]
Attach packet mbuf to another packet mbuf. After attachment we refer the mbuf we attached as ’indirect’,
while mbuf we attached to as ’direct’. Right now, not supported:
Parameters
mi The indirect packet mbuf.
md The direct packet mbuf.
Parameters
m The indirect attached packet mbuf.
3.28.4.14 static void rte pktmbuf free seg ( struct rte_mbuf ∗ m ) [static]
Parameters
m The packet mbuf segment to be freed.
Parameters
m The packet mbuf to be freed.
3.28.4.16 static struct rte_mbuf∗ rte pktmbuf clone ( struct rte_mbuf ∗ md, struct rte_mempool ∗ mp )
[static, read]
Parameters
md The packet mbuf to be cloned.
mp The mempool from which the "clone" mbufs are allocated.
Returns
• The pointer to the new "clone" mbuf on success.
• NULL if allocation fails.
3.28.4.17 static void rte pktmbuf refcnt update ( struct rte_mbuf ∗ m, int16 t v ) [static]
Parameters
m The packet mbuf whose refcnt to be updated.
v The value to add to the mbuf’s segments refcnt.
3.28.4.18 static uint16 t rte pktmbuf headroom ( const struct rte_mbuf ∗ m ) [static]
Parameters
m The packet mbuf.
Returns
The length of the headroom.
3.28.4.19 static uint16 t rte pktmbuf tailroom ( const struct rte_mbuf ∗ m ) [static]
Parameters
m The packet mbuf.
Returns
The length of the tailroom.
3.28.4.20 static struct rte_mbuf∗ rte pktmbuf lastseg ( struct rte_mbuf ∗ m ) [static, read]
Parameters
m The packet mbuf.
Returns
The last segment of the given mbuf.
3.28.4.21 static char∗ rte pktmbuf prepend ( struct rte_mbuf ∗ m, uint16 t len ) [static]
Parameters
m The pkt mbuf.
len The amount of data to prepend (in bytes).
Returns
A pointer to the start of the newly prepended data, or NULL if there is not enough headroom space in
the first segment
3.28.4.22 static char∗ rte pktmbuf append ( struct rte_mbuf ∗ m, uint16 t len ) [static]
Parameters
m The packet mbuf.
len The amount of data to append (in bytes).
Returns
A pointer to the start of the newly appended data, or NULL if there is not enough tailroom space in the
last segment
3.28.4.23 static char∗ rte pktmbuf adj ( struct rte_mbuf ∗ m, uint16 t len ) [static]
Parameters
m The packet mbuf.
len The amount of data to remove (in bytes).
Returns
A pointer to the new start of the data.
3.28.4.24 static int rte pktmbuf trim ( struct rte_mbuf ∗ m, uint16 t len ) [static]
Parameters
m The packet mbuf.
len The amount of data to remove (in bytes).
Returns
• 0: On success.
• -1: On error.
3.28.4.25 static int rte pktmbuf is contiguous ( const struct rte_mbuf ∗ m ) [static]
Parameters
m The packet mbuf.
Returns
• 1, if all data is contiguous (one segment).
• 0, if there is several segments.
3.28.4.26 void rte pktmbuf dump ( const struct rte_mbuf ∗ m, unsigned dump len )
Parameters
m The packet mbuf.
dump_len If dump_len != 0, also dump the "dump_len" first data bytes of the packet.
Defines
• #define rte_memcpy(dst, src, n)
Functions
• static void rte_mov16 (uint8_t ∗dst, const uint8_t ∗src)
• static void rte_mov32 (uint8_t ∗dst, const uint8_t ∗src)
• static void rte_mov48 (uint8_t ∗dst, const uint8_t ∗src)
• static void rte_mov64 (uint8_t ∗dst, const uint8_t ∗src)
• static void rte_mov128 (uint8_t ∗dst, const uint8_t ∗src)
• static void rte_mov256 (uint8_t ∗dst, const uint8_t ∗src)
Copy bytes from one location to another. The locations must not overlap.
Note
This is implemented as a macro, so it’s address should not be taken and care is needed as parameter
expressions may be evaluated multiple times.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
n Number of bytes to copy.
Returns
Pointer to the destination data.
3.29.3.1 static void rte mov16 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 16 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
3.29.3.2 static void rte mov32 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 32 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
3.29.3.3 static void rte mov48 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 48 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
3.29.3.4 static void rte mov64 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 64 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
3.29.3.5 static void rte mov128 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 128 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
3.29.3.6 static void rte mov256 ( uint8 t ∗ dst, const uint8 t ∗ src ) [static]
Copy 256 bytes from one location to another using optimised SSE instructions. The locations should not
overlap.
Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.
Data Structures
• struct rte_memseg
Defines
• #define SOCKET_ID_ANY
• #define CACHE_LINE_SIZE
• #define CACHE_LINE_MASK
• #define CACHE_LINE_ROUNDUP(size)
• #define __rte_cache_aligned
Typedefs
Functions
3.30.4.1 struct rte_memseg∗ rte eal get physmem layout ( void ) [read]
Returns
• On success, return a pointer to a read-only table of struct rte_physmem_desc elements, containing
the layout of all addressable physical memory. The last element of the table contains a NULL
address.
• On error, return NULL. This should not happen since it is a fatal error that will probably cause the
entire system to panic.
Returns
The total amount of available physical memory in bytes.
Returns
The number of memory channels on the system. The value is 0 if unknown or not the same on all
devices.
Returns
The number of memory ranks on the system. The value is 0 if unknown or not the same on all devices.
Data Structures
• struct rte_mempool_cache
• struct rte_mempool_objsz
• struct rte_mempool
Defines
• #define RTE_MEMPOOL_HEADER_COOKIE1
• #define RTE_MEMPOOL_HEADER_COOKIE2
• #define RTE_MEMPOOL_TRAILER_COOKIE
• #define RTE_MEMPOOL_NAMESIZE
• #define MEMPOOL_PG_NUM_DEFAULT
• #define MEMPOOL_F_NO_SPREAD
• #define MEMPOOL_F_NO_CACHE_ALIGN
• #define MEMPOOL_F_SP_PUT
• #define MEMPOOL_F_SC_GET
• #define MEMPOOL_HEADER_SIZE(mp, pgn)
• #define MEMPOOL_IS_CONTIG(mp)
Typedefs
Functions
RTE Mempool.
A memory pool is an allocator of fixed-size object. It is identified by its name, and uses a ring to store free
objects. It provides some other optional services, like a per-core object cache, and an alignment helper to
ensure that objects are padded to spread them equally on all RAM channels, ranks, and so on.
Objects owned by a mempool should never be added in another mempool. When an object is freed using
rte_mempool_put() or equivalent, the object data is not modified; the user can save some meta-data in the
object data and retrieve them when allocating a new object.
Note: the mempool implementation is not preemptable. A lcore must not be interrupted by another task
that uses the same mempool (because it uses a ring which is not preemptable). Also, mempool functions
must not be used outside the DPDK environment: for example, in linuxapp environment, a thread that is
not created by the EAL must not use mempools. This is due to the per-lcore cache that won’t work as
rte_lcore_id() will not return a correct value.
Header cookie.
Header cookie.
Trailer cookie.
Parameters
mp Pointer to the memory pool.
pgn Number of page used to store mempool objects.
3.31.4.1 static struct rte_mempool∗ rte mempool from obj ( void ∗ obj ) [static, read]
Parameters
obj An object that is owned by a pool. If this is not the case, the behavior is undefined.
Returns
A pointer to the mempool structure.
3.31.4.2 struct rte_mempool∗ rte mempool create ( const char ∗ name, unsigned n, unsigned elt size,
unsigned cache size, unsigned private data size, rte_mempool_ctor_t ∗ mp init, void ∗ mp init arg,
rte_mempool_obj_ctor_t ∗ obj init, void ∗ obj init arg, int socket id, unsigned flags ) [read]
Parameters
name The name of the mempool.
n The number of elements in the mempool. The optimum size (in terms of memory usage)
for a mempool is when n is a power of two minus one: n = (2∧ q - 1).
elt_size The size of each element.
cache_size If cache_size is non-zero, the rte_mempool library will try to limit the accesses to the
common lockless pool, by maintaining a per-lcore object cache. This argument must
be lower or equal to CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE. It is advised to
choose cache_size to have "n modulo cache_size == 0": if this is not the case, some
elements will always stay in the pool and will never be used. The access to the per-
lcore table is of course faster than the multi-producer/consumer pool. The cache can be
disabled if the cache_size argument is set to 0; it can be useful to avoid loosing objects
in cache. Note that even if not used, the memory space for cache is always reserved in
a mempool structure, except if CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE is set
to 0.
private_data_- The size of the private data appended after the mempool structure. This is useful for
size storing some private data after the mempool structure, as is done for rte_mbuf_pool for
example.
mp_init A function pointer that is called for initialization of the pool, before object initialization.
The user can initialize the private data in this function if needed. This parameter can be
NULL if not needed.
mp_init_arg An opaque pointer to data that can be used in the mempool constructor function.
obj_init A function pointer that is called for each object at initialization of the pool. The user can
set some meta data in objects if needed. This parameter can be NULL if not needed.
The obj_init() function takes the mempool pointer, the init_arg, the object pointer and the
object number as parameters.
obj_init_arg An opaque pointer to data that can be used as an argument for each call to the object
constructor function.
socket_id The ∗socket_id∗ argument is the socket identifier in the case of NUMA. The value can
be ∗SOCKET_ID_ANY∗ if there is no NUMA constraint for the reserved zone.
flags The ∗flags∗ arguments is an OR of following flags:
• MEMPOOL_F_NO_SPREAD: By default, objects addresses are spread between
channels in RAM: the pool allocator will add padding between objects depending
on the hardware configuration. See Memory alignment constraints for details. If
this flag is set, the allocator will just align them to a cache line.
• MEMPOOL_F_NO_CACHE_ALIGN: By default, the returned objects are cache-
aligned. This flag removes this constraint, and no padding will be present between
objects. This flag implies MEMPOOL_F_NO_SPREAD.
• MEMPOOL_F_SP_PUT: If this flag is set, the default behavior when using rte_-
mempool_put() or rte_mempool_put_bulk() is "single-producer". Otherwise, it is
"multi-producers".
• MEMPOOL_F_SC_GET: If this flag is set, the default behavior when using rte_-
mempool_get() or rte_mempool_get_bulk() is "single-consumer". Otherwise, it is
"multi-consumers".
Returns
The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately.
Possible rte_errno values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the ring or mempool list
• EINVAL - cache size provided is too large
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
3.31.4.3 struct rte_mempool∗ rte mempool xmem create ( const char ∗ name, unsigned n, unsigned elt size,
unsigned cache size, unsigned private data size, rte_mempool_ctor_t ∗ mp init, void ∗ mp init arg,
rte_mempool_obj_ctor_t ∗ obj init, void ∗ obj init arg, int socket id, unsigned flags, void ∗ vaddr,
const phys_addr_t paddr[ ], uint32 t pg num, uint32 t pg shift ) [read]
This function uses “memzone_reserve()“ to allocate memory. The pool contains n elements of elt_size. Its
size is set to n. Depending on the input parameters, mempool elements can be either allocated together
with the mempool header, or an externally provided memory buffer could be used to store mempool objects.
In later case, that external memory buffer can consist of set of disjoint phyiscal pages.
Parameters
name The name of the mempool.
n The number of elements in the mempool. The optimum size (in terms of memory usage)
for a mempool is when n is a power of two minus one: n = (2∧ q - 1).
elt_size The size of each element.
cache_size If cache_size is non-zero, the rte_mempool library will try to limit the accesses to the
common lockless pool, by maintaining a per-lcore object cache. This argument must
be lower or equal to CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE. It is advised to
choose cache_size to have "n modulo cache_size == 0": if this is not the case, some
elements will always stay in the pool and will never be used. The access to the per-
lcore table is of course faster than the multi-producer/consumer pool. The cache can be
disabled if the cache_size argument is set to 0; it can be useful to avoid loosing objects
in cache. Note that even if not used, the memory space for cache is always reserved in
a mempool structure, except if CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE is set
to 0.
private_data_- The size of the private data appended after the mempool structure. This is useful for
size storing some private data after the mempool structure, as is done for rte_mbuf_pool for
example.
mp_init A function pointer that is called for initialization of the pool, before object initialization.
The user can initialize the private data in this function if needed. This parameter can be
NULL if not needed.
mp_init_arg An opaque pointer to data that can be used in the mempool constructor function.
obj_init A function pointer that is called for each object at initialization of the pool. The user can
set some meta data in objects if needed. This parameter can be NULL if not needed.
The obj_init() function takes the mempool pointer, the init_arg, the object pointer and the
object number as parameters.
obj_init_arg An opaque pointer to data that can be used as an argument for each call to the object
constructor function.
socket_id The ∗socket_id∗ argument is the socket identifier in the case of NUMA. The value can
be ∗SOCKET_ID_ANY∗ if there is no NUMA constraint for the reserved zone.
vaddr Virtual address of the externally allocated memory buffer. Will be used to store mempool
objects.
paddr Array of phyiscall addresses of the pages that comprises given memory buffer.
pg_num Number of elements in the paddr array.
pg_shift LOG2 of the physical pages size.
Returns
The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately.
Possible rte_errno values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the ring or mempool list
• EINVAL - cache size provided is too large
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
Parameters
mp A pointer to the mempool structure.
3.31.4.5 static void rte mempool mp put bulk ( struct rte_mempool ∗ mp, void ∗const ∗ obj table, unsigned n )
[static]
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the mempool from the obj_table.
3.31.4.6 static void rte mempool sp put bulk ( struct rte_mempool ∗ mp, void ∗const ∗ obj table, unsigned n )
[static]
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the mempool from obj_table.
3.31.4.7 static void rte mempool put bulk ( struct rte_mempool ∗ mp, void ∗const ∗ obj table, unsigned n )
[static]
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the mempool from obj_table.
3.31.4.8 static void rte mempool mp put ( struct rte_mempool ∗ mp, void ∗ obj ) [static]
Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.
3.31.4.9 static void rte mempool sp put ( struct rte_mempool ∗ mp, void ∗ obj ) [static]
Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.
3.31.4.10 static void rte mempool put ( struct rte_mempool ∗ mp, void ∗ obj ) [static]
Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.
3.31.4.11 static int rte mempool mc get bulk ( struct rte_mempool ∗ mp, void ∗∗ obj table, unsigned n )
[static]
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to get from mempool to obj_table.
Returns
• 0: Success; objects taken.
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
3.31.4.12 static int rte mempool sc get bulk ( struct rte_mempool ∗ mp, void ∗∗ obj table, unsigned n )
[static]
If cache is enabled, objects will be retrieved first from cache, subsequently from the common pool. Note that
it can return -ENOENT when the local cache and common pool are empty, even if cache from other lcores
are full.
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to get from the mempool to obj_table.
Returns
• 0: Success; objects taken.
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
3.31.4.13 static int rte mempool get bulk ( struct rte_mempool ∗ mp, void ∗∗ obj table, unsigned n ) [static]
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to get from the mempool to obj_table.
Returns
• 0: Success; objects taken
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
3.31.4.14 static int rte mempool mc get ( struct rte_mempool ∗ mp, void ∗∗ obj p ) [static]
Parameters
mp A pointer to the mempool structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success; objects taken.
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
3.31.4.15 static int rte mempool sc get ( struct rte_mempool ∗ mp, void ∗∗ obj p ) [static]
Parameters
mp A pointer to the mempool structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success; objects taken.
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
3.31.4.16 static int rte mempool get ( struct rte_mempool ∗ mp, void ∗∗ obj p ) [static]
Parameters
mp A pointer to the mempool structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success; objects taken.
• -ENOENT: Not enough entries in the mempool; no object is retrieved.
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a
data path, but only for debug purposes.
Parameters
mp A pointer to the mempool structure.
Returns
The number of entries in the mempool.
3.31.4.18 static unsigned rte mempool free count ( const struct rte_mempool ∗ mp ) [static]
Return the number of free entries in the mempool ring. i.e. how many entries can be freed back to the
mempool.
NOTE: This corresponds to the number of elements ∗allocated∗ from the memory pool, not the number of
elements in the pool itself. To count the number elements currently available in the pool, use "rte_mempool-
_count"
When cache is enabled, this function has to browse the length of all lcores, so it should not be used in a
data path, but only for debug purposes.
Parameters
mp A pointer to the mempool structure.
Returns
The number of free entries in the mempool.
3.31.4.19 static int rte mempool full ( const struct rte_mempool ∗ mp ) [static]
Parameters
mp A pointer to the mempool structure.
Returns
• 1: The mempool is full.
• 0: The mempool is not full.
3.31.4.20 static int rte mempool empty ( const struct rte_mempool ∗ mp ) [static]
Parameters
mp A pointer to the mempool structure.
Returns
• 1: The mempool is empty.
• 0: The mempool is not empty.
3.31.4.21 static phys_addr_t rte mempool virt2phy ( const struct rte_mempool ∗ mp, const void ∗ elt )
[static]
Return the physical address of elt, which is an element of the pool mp.
Parameters
mp A pointer to the mempool structure.
elt A pointer (virtual address) to the element of the pool.
Returns
The physical address of the elt element.
Parameters
mp A pointer to the mempool structure.
3.31.4.23 static void∗ rte mempool get priv ( struct rte_mempool ∗ mp ) [static]
Parameters
mp A pointer to the mempool structure.
Returns
A pointer to the private data.
3.31.4.25 struct rte_mempool∗ rte mempool lookup ( const char ∗ name ) [read]
Parameters
name The name of the mempool.
Returns
The pointer to the mempool matching the name, or NULL if not found. NULL on error with rte_errno set
appropriately. Possible rte_errno values include:
• ENOENT - required entry not available to return.
3.31.4.26 uint32 t rte mempool calc obj size ( uint32 t elt size, uint32 t flags, struct rte_mempool_objsz ∗ sz )
Given a desired size of the mempool element and mempool flags, caluclates header, trailer, body and total
sizes of the mempool object.
Parameters
elt_size The size of each element.
flags The flags used for the mempool creation. Consult rte_mempool_create() for more
information about possible values. The size of each element.
Returns
Total size of the mempool object.
3.31.4.27 size t rte mempool xmem size ( uint32 t elt num, size t elt sz, uint32 t pg shift )
Calculate maximum amount of memory required to store given number of objects. Assumes that the memory
buffer will be alligned at page boundary. Note, that if object size is bigger then page size, then it assumes
that we have a subsets of physically continuous pages big enough to store at least one object.
Parameters
elt_num Number of elements.
elt_sz The size of each element.
pg_shift LOG2 of the physical pages size.
Returns
Required memory size aligned at page boundary.
3.31.4.28 ssize t rte mempool xmem usage ( void ∗ vaddr, uint32 t elt num, size t elt sz, const phys_addr_t
paddr[ ], uint32 t pg num, uint32 t pg shift )
Calculate how much memory would be actually required with the given memory footprint to store required
number of objects.
Parameters
vaddr Virtual address of the externally allocated memory buffer. Will be used to store mempool
objects.
elt_num Number of elements.
elt_sz The size of each element.
paddr Array of phyiscall addresses of the pages that comprises given memory buffer.
pg_num Number of elements in the paddr array.
pg_shift LOG2 of the physical pages size.
Returns
Number of bytes needed to store given number of objects, aligned to the given page size. If provided
memory buffer is not big enough: (-1) ∗ actual number of elemnts that can be stored in that buffer.
Data Structures
• struct rte_memzone
Defines
• #define RTE_MEMZONE_2MB
• #define RTE_MEMZONE_1GB
• #define RTE_MEMZONE_SIZE_HINT_ONLY
• #define RTE_MEMZONE_NAMESIZE
Functions
• struct rte_memzone ∗ rte_memzone_reserve (const char ∗name, size_t len, int socket_id, unsigned
flags)
• struct rte_memzone ∗ rte_memzone_reserve_aligned (const char ∗name, size_t len, int socket_id,
unsigned flags, unsigned align)
• struct rte_memzone ∗ rte_memzone_reserve_bounded (const char ∗name, size_t len, int socket_id,
unsigned flags, unsigned align, unsigned bound)
• struct rte_memzone ∗ rte_memzone_lookup (const char ∗name)
• void rte_memzone_dump (void)
RTE Memzone
The goal of the memzone allocator is to reserve contiguous portions of physical memory. These zones are
identified by a name.
The memzone descriptors are shared by all partitions and are located in a known place of physical memory.
This zone is accessed using rte_eal_get_configuration(). The lookup (by name) of a memory zone can be
done in any partition and returns the same physical address.
A reserved memory zone cannot be unreserved. The reservation shall be done at initialization time only.
3.32.3.1 struct rte_memzone∗ rte memzone reserve ( const char ∗ name, size t len, int socket id, unsigned flags
) [read]
Parameters
name The name of the memzone. If it already exists, the function will fail and return NULL.
len The size of the memory to be reserved. If it is 0, the biggest contiguous zone will be
reserved.
socket_id The socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there
is no NUMA constraint for the reserved zone.
flags The flags parameter is used to request memzones to be taken from 1GB or 2MB
hugepages.
• RTE_MEMZONE_2MB - Reserve from 2MB pages
• RTE_MEMZONE_1GB - Reserve from 1GB pages
• RTE_MEMZONE_SIZE_HINT_ONLY - Allow alternative page size to be used if
the requested page size is unavailable. If this flag is not set, the function will return
error on an unavailable size request.
Returns
A pointer to a correctly-filled read-only memzone descriptor, or NULL on error. On error case, rte_errno
will be set appropriately:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
• EINVAL - invalid parameters
3.32.3.2 struct rte_memzone∗ rte memzone reserve aligned ( const char ∗ name, size t len, int socket id,
unsigned flags, unsigned align ) [read]
Parameters
name The name of the memzone. If it already exists, the function will fail and return NULL.
len The size of the memory to be reserved. If it is 0, the biggest contiguous zone will be
reserved.
socket_id The socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there
is no NUMA constraint for the reserved zone.
flags The flags parameter is used to request memzones to be taken from 1GB or 2MB
hugepages.
• RTE_MEMZONE_2MB - Reserve from 2MB pages
• RTE_MEMZONE_1GB - Reserve from 1GB pages
• RTE_MEMZONE_SIZE_HINT_ONLY - Allow alternative page size to be used if
the requested page size is unavailable. If this flag is not set, the function will return
error on an unavailable size request.
Returns
A pointer to a correctly-filled read-only memzone descriptor, or NULL on error. On error case, rte_errno
will be set appropriately:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
• EINVAL - invalid parameters
3.32.3.3 struct rte_memzone∗ rte memzone reserve bounded ( const char ∗ name, size t len, int socket id,
unsigned flags, unsigned align, unsigned bound ) [read]
Parameters
name The name of the memzone. If it already exists, the function will fail and return NULL.
len The size of the memory to be reserved. If it is 0, the biggest contiguous zone will be
reserved.
socket_id The socket identifier in the case of NUMA. The value can be SOCKET_ID_ANY if there
is no NUMA constraint for the reserved zone.
flags The flags parameter is used to request memzones to be taken from 1GB or 2MB
hugepages.
• RTE_MEMZONE_2MB - Reserve from 2MB pages
• RTE_MEMZONE_1GB - Reserve from 1GB pages
• RTE_MEMZONE_SIZE_HINT_ONLY - Allow alternative page size to be used if
the requested page size is unavailable. If this flag is not set, the function will return
error on an unavailable size request.
Returns
A pointer to a correctly-filled read-only memzone descriptor, or NULL on error. On error case, rte_errno
will be set appropriately:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• ENOSPC - the maximum number of memzones has already been allocated
• EEXIST - a memzone with the same name already exists
• ENOMEM - no appropriate memory area found in which to create memzone
• EINVAL - invalid parameters
3.32.3.4 struct rte_memzone∗ rte memzone lookup ( const char ∗ name ) [read]
Parameters
name The name of the memzone.
Returns
A pointer to a read-only memzone descriptor.
Data Structures
• struct rte_meter_srtcm_params
• struct rte_meter_trtcm_params
• struct rte_meter_srtcm
• struct rte_meter_trtcm
Enumerations
• enum rte_meter_color { e_RTE_METER_GREEN, e_RTE_METER_YELLOW, e_RTE_METER_RE-
D, e_RTE_METER_COLORS }
Functions
• int rte_meter_srtcm_config (struct rte_meter_srtcm ∗m, struct rte_meter_srtcm_params ∗params)
• int rte_meter_trtcm_config (struct rte_meter_trtcm ∗m, struct rte_meter_trtcm_params ∗params)
• static enum rte_meter_color rte_meter_srtcm_color_blind_check (struct rte_meter_srtcm ∗m, uint64_t
time, uint32_t pkt_len)
• static enum rte_meter_color rte_meter_srtcm_color_aware_check (struct rte_meter_srtcm ∗m, uint64-
_t time, uint32_t pkt_len, enum rte_meter_color pkt_color)
• static enum rte_meter_color rte_meter_trtcm_color_blind_check (struct rte_meter_trtcm ∗m, uint64_t
time, uint32_t pkt_len)
• static enum rte_meter_color rte_meter_trtcm_color_aware_check (struct rte_meter_trtcm ∗m, uint64-
_t time, uint32_t pkt_len, enum rte_meter_color pkt_color)
Enumerator:
e_RTE_METER_GREEN Green
e_RTE_METER_YELLOW Yellow
e_RTE_METER_RED Red
e_RTE_METER_COLORS Number of available colors
3.33.3.1 int rte meter srtcm config ( struct rte_meter_srtcm ∗ m, struct rte_meter_srtcm_params ∗ params )
Parameters
m Pointer to pre-allocated srTCM data structure
params User parameters per srTCM metered traffic flow
Returns
0 upon success, error code otherwise
3.33.3.2 int rte meter trtcm config ( struct rte_meter_trtcm ∗ m, struct rte_meter_trtcm_params ∗ params )
Parameters
m Pointer to pre-allocated trTCM data structure
params User parameters per trTCM metered traffic flow
Returns
0 upon success, error code otherwise
3.33.3.3 static enum rte_meter_color rte meter srtcm color blind check ( struct rte_meter_srtcm ∗ m, uint64 t
time, uint32 t pkt len ) [static]
Parameters
m Handle to srTCM instance
time Current CPU time stamp (measured in CPU cycles)
pkt_length Length of the current IP packet (measured in bytes)
Returns
Color assigned to the current IP packet
3.33.3.4 static enum rte_meter_color rte meter srtcm color aware check ( struct rte_meter_srtcm ∗ m, uint64 t
time, uint32 t pkt len, enum rte_meter_color pkt color ) [static]
Parameters
m Handle to srTCM instance
time Current CPU time stamp (measured in CPU cycles)
pkt_length Length of the current IP packet (measured in bytes)
pkt_color Input color of the current IP packet
Returns
Color assigned to the current IP packet
3.33.3.5 static enum rte_meter_color rte meter trtcm color blind check ( struct rte_meter_trtcm ∗ m, uint64 t
time, uint32 t pkt len ) [static]
Parameters
m Handle to trTCM instance
time Current CPU time stamp (measured in CPU cycles)
pkt_length Length of the current IP packet (measured in bytes)
Returns
Color assigned to the current IP packet
3.33.3.6 static enum rte_meter_color rte meter trtcm color aware check ( struct rte_meter_trtcm ∗ m, uint64 t
time, uint32 t pkt len, enum rte_meter_color pkt color ) [static]
Parameters
m Handle to trTCM instance
time Current CPU time stamp (measured in CPU cycles)
pkt_length Length of the current IP packet (measured in bytes)
pkt_color Input color of the current IP packet
Returns
Color assigned to the current IP packet
Data Structures
• struct rte_pci_resource
• struct rte_pci_id
• struct rte_pci_addr
• struct rte_pci_device
• struct rte_pci_driver
Defines
• #define SYSFS_PCI_DEVICES
• #define PCI_PRI_FMT
• #define PCI_SHORT_PRI_FMT
• #define PCI_FMT_NVAL
• #define PCI_RESOURCE_FMT_NVAL
• #define PCI_MAX_RESOURCE
• #define PCI_ANY_ID
• #define RTE_PCI_DEVICE(vend, dev)
• #define RTE_PCI_DRV_MULTIPLE
Typedefs
Functions
Variables
Short formatting string, without domain, for PCI device: Ex: 00:01.0
Device driver must be registered several times until failure Internal use only - Macro used by pci addr parsing
functions
3.34.4.3 static int eal parse pci BDF ( const char ∗ input, struct rte_pci_addr ∗ dev addr ) [static]
Utility function to produce a PCI Bus-Device-Function value given a string representation. Assumes that the
BDF is provided without a domain prefix (i.e. domain returned is always 0)
Parameters
input The input string to be parsed. Should have the format XX:XX.X
dev_addr The PCI Bus-Device-Function address to be returned. Domain will always be returned
as 0
Returns
0 on success, negative on error.
3.34.4.4 static int eal parse pci DomBDF ( const char ∗ input, struct rte_pci_addr ∗ dev addr ) [static]
Utility function to produce a PCI Bus-Device-Function value given a string representation. Assumes that the
BDF is provided including a domain prefix.
Parameters
input The input string to be parsed. Should have the format XXXX:XX:XX.X
dev_addr The PCI Bus-Device-Function address to be returned
Returns
0 on success, negative on error.
Returns
• 0 on success.
• Negative on error.
Parameters
driver A pointer to a rte_pci_driver structure describing the driver to be registered.
Parameters
driver A pointer to a rte_pci_driver structure describing the driver to be unregistered.
3.34.4.9 void rte eal pci set blacklist ( struct rte_pci_addr ∗ blacklist, unsigned size )
Register a list of PCI locations that will be blacklisted (not used by DPDK).
Parameters
blacklist List of PCI device addresses that will not be used by DPDK.
size Number of items in the list.
Defines
• #define PCI_VENDOR_ID_INTEL
• #define PCI_VENDOR_ID_QUMRANET
• #define PCI_VENDOR_ID_VMWARE
This file contains a list of the PCI device IDs recognised by DPDK, which can be used to fill out an array of
structures describing the devices.
Currently four families of devices are recognised: those supported by the IGB driver, by EM driver, those
supported by the IXGBE driver, and by virtio driver which is a para virtualization driver running in guest
virtual machine. The inclusion of these in an array built using this file depends on the definition of RTE_-
PCI_DEV_ID_DECL_EM RTE_PCI_DEV_ID_DECL_IGB RTE_PCI_DEV_ID_DECL_IGBVF RTE_PCI_D-
EV_ID_DECL_IXGBE RTE_PCI_DEV_ID_DECL_IXGBEVF RTE_PCI_DEV_ID_DECL_VIRTIO at the time
when this file is included.
In order to populate an array, the user of this file must define this macro: RTE_PCI_DEV_ID_DECL_IXGB-
E(vendorID, deviceID). For example:
struct device {
int vend;
int dev;
};
Note that this file can be included multiple times within the same file.
Defines
Macro to define a per lcore variable "var" of type "type", don’t use keywords like "static" or "volatile" in type,
just prefix the whole macro.
Functions
Initialize power management for a specific lcore. It will check and set the governor to userspace for the lcore,
get the available frequencies, and prepare to set new lcore frequency.
Parameters
lcore_id lcore id.
Returns
• 0 on success.
• Negative on error.
Exit power management on a specific lcore. It will set the governor to which is before initialized.
Parameters
lcore_id lcore id.
Returns
• 0 on success.
• Negative on error.
3.37.2.3 uint32 t rte power freqs ( unsigned lcore id, uint32 t ∗ freqs, uint32 t num )
Get the available frequencies of a specific lcore. The return value will be the minimal one of the total number
of available frequencies and the number of buffer. The index of available frequencies used in other interfaces
should be in the range of 0 to this return value. It should be protected outside of this function for threadsafe.
Parameters
lcore_id lcore id.
freqs The buffer array to save the frequencies.
num The number of frequencies to get.
Returns
The number of available frequencies.
Return the current index of available frequencies of a specific lcore. It will return ’RTE_POWER_INVALID-
_FREQ_INDEX = (∼0)’ if error. It should be protected outside of this function for threadsafe.
Parameters
lcore_id lcore id.
Returns
The current index of available frequencies.
3.37.2.5 int rte power set freq ( unsigned lcore id, uint32 t index )
Set the new frequency for a specific lcore by indicating the index of available frequencies. It should be
protected outside of this function for threadsafe.
Parameters
lcore_id lcore id.
index The index of available frequencies.
Returns
• 1 on success with frequency changed.
• 0 on success without frequency chnaged.
• Negative on error.
Scale up the frequency of a specific lcore according to the available frequencies. It should be protected
outside of this function for threadsafe.
Parameters
lcore_id lcore id.
Returns
• 1 on success with frequency changed.
• 0 on success without frequency chnaged.
• Negative on error.
Scale down the frequency of a specific lcore according to the available frequencies. It should be protected
outside of this function for threadsafe.
Parameters
lcore_id lcore id.
Returns
• 1 on success with frequency changed.
• 0 on success without frequency chnaged.
• Negative on error.
Scale up the frequency of a specific lcore to the highest according to the available frequencies. It should be
protected outside of this function for threadsafe.
Parameters
lcore_id lcore id.
Returns
• 1 on success with frequency changed.
• 0 on success without frequency chnaged.
• Negative on error.
Scale down the frequency of a specific lcore to the lowest according to the available frequencies. It should
be protected outside of this function for threadsafe.
Parameters
lcore_id lcore id.
Returns
• 1 on success with frequency changed.
• 0 on success without frequency chnaged.
• Negative on error.
Functions
• static void rte_prefetch0 (volatile void ∗p)
• static void rte_prefetch1 (volatile void ∗p)
• static void rte_prefetch2 (volatile void ∗p)
Prefetch operations.
This file defines an API for prefetch macros / inline-functions, which are architecture-dependent. Prefetching
occurs when a processor requests an instruction or data from memory to cache before it is actually needed,
potentially speeding up the execution of the program.
Parameters
p Address to prefetch
Prefetch a cache line into all cache levels except the 0th cache level.
Parameters
p Address to prefetch
Prefetch a cache line into all cache levels except the 0th and 1th cache levels.
Parameters
p Address to prefetch
Functions
• static void rte_srand (uint64_t seedval)
• static uint64_t rte_rand (void)
Parameters
seedval The value of the seed.
Returns
A pseudo-random value between 0 and (1<<64)-1.
Data Structures
• struct rte_red_params
• struct rte_red_config
• struct rte_red
Defines
• #define RTE_RED_SCALING
• #define RTE_RED_S
• #define RTE_RED_MAX_TH_MAX
• #define RTE_RED_WQ_LOG2_MIN
• #define RTE_RED_WQ_LOG2_MAX
• #define RTE_RED_MAXP_INV_MIN
• #define RTE_RED_MAXP_INV_MAX
• #define RTE_RED_2POW16
Functions
• int rte_red_rt_data_init (struct rte_red ∗red)
• int rte_red_config_init (struct rte_red_config ∗red_cfg, const uint16_t wq_log2, const uint16_t min_th,
const uint16_t max_th, const uint16_t maxp_inv)
• static uint32_t rte_fast_rand (void)
• static uint16_t __rte_red_calc_qempty_factor (uint8_t wq_log2, uint16_t m)
• static int rte_red_enqueue_empty (const struct rte_red_config ∗red_cfg, struct rte_red ∗red, const
uint64_t time)
• static int __rte_red_drop (const struct rte_red_config ∗red_cfg, struct rte_red ∗red)
• static int rte_red_enqueue_nonempty (const struct rte_red_config ∗red_cfg, struct rte_red ∗red, const
unsigned q)
• static int rte_red_enqueue (const struct rte_red_config ∗red_cfg, struct rte_red ∗red, const unsigned
q, const uint64_t time)
• static void rte_red_mark_queue_empty (struct rte_red ∗red, const uint64_t time)
Variables
• uint32_t rte_red_rand_val
2 power 16
Parameters
in,out data pointer to RED runtime data
Returns
Operation status
Return values
0 success
!0 error
3.40.3.2 int rte red config init ( struct rte_red_config ∗ red cfg, const uint16 t wq log2, const uint16 t min th,
const uint16 t max th, const uint16 t maxp inv )
Parameters
in,out config pointer to a RED configuration parameter structure
in wq_log2 log2 of the filter weight, valid range is: RTE_RED_WQ_LOG2_MIN <=
wq_log2 <= RTE_RED_WQ_LOG2_MAX
in min_th queue minimum threshold in number of packets
in max_th queue maximum threshold in number of packets
in maxp_inv inverse maximum mark probability
Returns
Operation status
Return values
0 success
!0 error
Returns
Random number between 0 and (2∧ 22 - 1)
3.40.3.4 static uint16 t rte red calc qempty factor ( uint8 t wq log2, uint16 t m ) [static]
calculate factor to scale average queue size when queue becomes empty
Parameters
in wq_log2,where EWMA filter weight wq = 1/(2 ∧ wq_log2)
in m exponent in the computed value (1 - wq) ∧ m
Returns
computed value
Return values
((1 - wq) ∧ m) scaled in fixed-point format
3.40.3.5 static int rte red enqueue empty ( const struct rte_red_config ∗ red cfg, struct rte_red ∗ red, const
uint64 t time ) [static]
Parameters
in config pointer to a RED configuration parameter structure
in,out data pointer to RED runtime data
in time current time stamp
Returns
Operation status
Return values
0 enqueue the packet
1 drop the packet based on max threshold criterion
2 drop the packet based on mark probability criterion
We compute avg but we don’t compare avg against min_th or max_th, nor calculate drop probability
m is the number of packets that might have arrived while the queue was empty. In this case we have time
stamps provided by scheduler in byte units (bytes transmitted on network port). Such time stamp translates
into time units as port speed is fixed but such approach simplifies the code.
Check that m will fit into 16-bit unsigned integer
3.40.3.6 static int rte red drop ( const struct rte_red_config ∗ red cfg, struct rte_red ∗ red ) [static]
Parameters
in config pointer to structure defining RED parameters
in,out data pointer to RED runtime data
Returns
operation status
Return values
0 enqueue the packet
1 drop the packet
3.40.3.7 static int rte red enqueue nonempty ( const struct rte_red_config ∗ red cfg, struct rte_red ∗ red, const
unsigned q ) [static]
Parameters
in config pointer to a RED configuration parameter structure
in,out data pointer to RED runtime data
in q current queue size (measured in packets)
Returns
Operation status
Return values
0 enqueue the packet
1 drop the packet based on max threshold criterion
2 drop the packet based on mark probability criterion
EWMA filter (Sally Floyd and Van Jacobson): avg = (1 - wq) ∗ avg + wq ∗ q avg = avg + q ∗ wq - avg ∗ wq
We select: wq = 2∧ (-n). Let scaled version of avg be: avg_s = avg ∗ 2∧ (N+n). We get: avg_s = avg_s + q ∗
2∧ N - avg_s ∗ 2∧ (-n)
By using shift left/right operations, we get: avg_s = avg_s + (q << N) - (avg_s >> n) avg_s += (q << N) -
(avg_s >> n)
3.40.3.8 static int rte red enqueue ( const struct rte_red_config ∗ red cfg, struct rte_red ∗ red, const unsigned q,
const uint64 t time ) [static]
Decides if new packet should be enqeued or dropped Updates run time data based on new queue size
value. Based on new queue average and RED configuration parameters gives verdict whether to enqueue
or drop the packet.
Parameters
in config pointer to a RED configuration parameter structure
in,out data pointer to RED runtime data
in q updated queue size in packets
in time current time stamp
Returns
Operation status
Return values
0 enqueue the packet
1 drop the packet based on max threshold criteria
2 drop the packet based on mark probability criteria
3.40.3.9 static void rte red mark queue empty ( struct rte_red ∗ red, const uint64 t time ) [static]
Parameters
in,out data pointer to RED runtime data
in time current time stamp
Externs
Data Structures
• struct rte_ring
• struct rte_ring::prod
• struct rte_ring::cons
Defines
• #define RTE_RING_NAMESIZE
• #define RING_F_SP_ENQ
• #define RING_F_SC_DEQ
• #define RTE_RING_QUOT_EXCEED
• #define RTE_RING_SZ_MASK
Functions
• struct rte_ring ∗ rte_ring_create (const char ∗name, unsigned count, int socket_id, unsigned flags)
• int rte_ring_set_water_mark (struct rte_ring ∗r, unsigned count)
• void rte_ring_dump (const struct rte_ring ∗r)
• static int rte_ring_mp_enqueue_bulk (struct rte_ring ∗r, void ∗const ∗obj_table, unsigned n)
• static int rte_ring_sp_enqueue_bulk (struct rte_ring ∗r, void ∗const ∗obj_table, unsigned n)
• static int rte_ring_enqueue_bulk (struct rte_ring ∗r, void ∗const ∗obj_table, unsigned n)
• static int rte_ring_mp_enqueue (struct rte_ring ∗r, void ∗obj)
• static int rte_ring_sp_enqueue (struct rte_ring ∗r, void ∗obj)
• static int rte_ring_enqueue (struct rte_ring ∗r, void ∗obj)
• static int rte_ring_mc_dequeue_bulk (struct rte_ring ∗r, void ∗∗obj_table, unsigned n)
• static int rte_ring_sc_dequeue_bulk (struct rte_ring ∗r, void ∗∗obj_table, unsigned n)
• static int rte_ring_dequeue_bulk (struct rte_ring ∗r, void ∗∗obj_table, unsigned n)
• static int rte_ring_mc_dequeue (struct rte_ring ∗r, void ∗∗obj_p)
• static int rte_ring_sc_dequeue (struct rte_ring ∗r, void ∗∗obj_p)
RTE Ring
The Ring Manager is a fixed-size queue, implemented as a table of pointers. Head and tail pointers are
modified atomically, allowing concurrent access to it. It has the following features:
• Lockless implementation.
• Bulk dequeue.
• Bulk enqueue.
Note: the ring implementation is not preemptable. A lcore must not be interrupted by another task that uses
the same ring.
3.41.3.1 struct rte_ring∗ rte ring create ( const char ∗ name, unsigned count, int socket id, unsigned flags )
[read]
Parameters
name The name of the ring.
count The size of the ring (must be a power of 2).
socket_id The ∗socket_id∗ argument is the socket identifier in case of NUMA. The value can be
∗SOCKET_ID_ANY∗ if there is no NUMA constraint for the reserved zone.
flags An OR of the following:
• RING_F_SP_ENQ: If this flag is set, the default behavior when using “rte_ring-
_enqueue()“ or “rte_ring_enqueue_bulk()“ is "single-producer". Otherwise, it is
"multi-producers".
• RING_F_SC_DEQ: If this flag is set, the default behavior when using “rte_ring-
_dequeue()“ or “rte_ring_dequeue_bulk()“ is "single-consumer". Otherwise, it is
"multi-consumers".
Returns
On success, the pointer to the new allocated ring. NULL on error with rte_errno set appropriately.
Possible errno values include:
• E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
• E_RTE_SECONDARY - function was called from a secondary process instance
• E_RTE_NO_TAILQ - no tailq list could be got for the ring list
3.41.3.2 int rte ring set water mark ( struct rte_ring ∗ r, unsigned count )
Parameters
r A pointer to the ring structure.
count The new water mark value.
Returns
• 0: Success; water mark changed.
• -EINVAL: Invalid water mark value.
Parameters
r A pointer to the ring structure.
3.41.3.4 static int rte ring mp enqueue bulk ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• 0: Success; objects enqueue.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue, no object is enqueued.
3.41.3.5 static int rte ring sp enqueue bulk ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• 0: Success; objects enqueued.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
3.41.3.6 static int rte ring enqueue bulk ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• 0: Success; objects enqueued.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
3.41.3.7 static int rte ring mp enqueue ( struct rte_ring ∗ r, void ∗ obj ) [static]
Parameters
r A pointer to the ring structure.
obj A pointer to the object to be added.
Returns
• 0: Success; objects enqueued.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
3.41.3.8 static int rte ring sp enqueue ( struct rte_ring ∗ r, void ∗ obj ) [static]
Parameters
r A pointer to the ring structure.
obj A pointer to the object to be added.
Returns
• 0: Success; objects enqueued.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
3.41.3.9 static int rte ring enqueue ( struct rte_ring ∗ r, void ∗ obj ) [static]
Parameters
r A pointer to the ring structure.
obj A pointer to the object to be added.
Returns
• 0: Success; objects enqueued.
• -EDQUOT: Quota exceeded. The objects have been enqueued, but the high water mark is
exceeded.
• -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
3.41.3.10 static int rte ring mc dequeue bulk ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table.
Returns
• 0: Success; objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue; no object is dequeued.
3.41.3.11 static int rte ring sc dequeue bulk ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table, must be strictly positive.
Returns
• 0: Success; objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue; no object is dequeued.
3.41.3.12 static int rte ring dequeue bulk ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table.
Returns
• 0: Success; objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue, no object is dequeued.
3.41.3.13 static int rte ring mc dequeue ( struct rte_ring ∗ r, void ∗∗ obj p ) [static]
Parameters
r A pointer to the ring structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success; objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue; no object is dequeued.
3.41.3.14 static int rte ring sc dequeue ( struct rte_ring ∗ r, void ∗∗ obj p ) [static]
Parameters
r A pointer to the ring structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success; objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue, no object is dequeued.
3.41.3.15 static int rte ring dequeue ( struct rte_ring ∗ r, void ∗∗ obj p ) [static]
This function calls the multi-consumers or the single-consumer version depending on the default behaviour
that was specified at ring creation time (see flags).
Parameters
r A pointer to the ring structure.
obj_p A pointer to a void ∗ pointer (object) that will be filled.
Returns
• 0: Success, objects dequeued.
• -ENOENT: Not enough entries in the ring to dequeue, no object is dequeued.
3.41.3.16 static int rte ring full ( const struct rte_ring ∗ r ) [static]
Parameters
r A pointer to the ring structure.
Returns
• 1: The ring is full.
• 0: The ring is not full.
3.41.3.17 static int rte ring empty ( const struct rte_ring ∗ r ) [static]
Parameters
r A pointer to the ring structure.
Returns
• 1: The ring is empty.
• 0: The ring is not empty.
3.41.3.18 static unsigned rte ring count ( const struct rte_ring ∗ r ) [static]
Parameters
r A pointer to the ring structure.
Returns
The number of entries in the ring.
3.41.3.19 static unsigned rte ring free count ( const struct rte_ring ∗ r ) [static]
Parameters
r A pointer to the ring structure.
Returns
The number of free entries in the ring.
3.41.3.21 struct rte_ring∗ rte ring lookup ( const char ∗ name ) [read]
Parameters
name The name of the ring.
Returns
The pointer to the ring matching the name, or NULL if not found, with rte_errno set appropriately. -
Possible rte_errno values include:
• ENOENT - required entry not available to return.
3.41.3.22 static int rte ring mp enqueue burst ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n )
[static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• n: Actual number of objects enqueued.
3.41.3.23 static int rte ring sp enqueue burst ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n )
[static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• n: Actual number of objects enqueued.
3.41.3.24 static int rte ring enqueue burst ( struct rte_ring ∗ r, void ∗const ∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects).
n The number of objects to add in the ring from the obj_table.
Returns
• n: Actual number of objects enqueued.
3.41.3.25 static int rte ring mc dequeue burst ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Dequeue several objects from a ring (multi-consumers safe). When the request objects are more than the
available objects, only dequeue the actual number of objects
This function uses a "compare and set" instruction to move the consumer index atomically.
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table.
Returns
• n: Actual number of objects dequeued, 0 if ring is empty
3.41.3.26 static int rte ring sc dequeue burst ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Dequeue several objects from a ring (NOT multi-consumers safe).When the request objects are more than
the available objects, only dequeue the actual number of objects
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table.
Returns
• n: Actual number of objects dequeued, 0 if ring is empty
3.41.3.27 static int rte ring dequeue burst ( struct rte_ring ∗ r, void ∗∗ obj table, unsigned n ) [static]
Parameters
r A pointer to the ring structure.
obj_table A pointer to a table of void ∗ pointers (objects) that will be filled.
n The number of objects to dequeue from the ring to the obj_table.
Returns
• Number of objects dequeued, or a negative error code on error
Data Structures
• struct rte_rwlock_t
Defines
• #define RTE_RWLOCK_INITIALIZER
Functions
Parameters
rwl A pointer to the rwlock structure.
3.42.3.2 static void rte rwlock read lock ( rte_rwlock_t ∗ rwl ) [static]
Parameters
rwl A pointer to a rwlock structure.
3.42.3.3 static void rte rwlock read unlock ( rte_rwlock_t ∗ rwl ) [static]
Parameters
rwl A pointer to the rwlock structure.
3.42.3.4 static void rte rwlock write lock ( rte_rwlock_t ∗ rwl ) [static]
Parameters
rwl A pointer to a rwlock structure.
3.42.3.5 static void rte rwlock write unlock ( rte_rwlock_t ∗ rwl ) [static]
Parameters
rwl A pointer to a rwlock structure.
Data Structures
• struct rte_sched_subport_params
• struct rte_sched_subport_stats
• struct rte_sched_pipe_params
• struct rte_sched_queue_stats
• struct rte_sched_port_params
• struct rte_sched_port_hierarchy
Defines
• #define RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE
• #define RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS
• #define RTE_SCHED_QUEUES_PER_PIPE
• #define RTE_SCHED_PIPE_PROFILES_PER_PORT
• #define RTE_SCHED_FRAME_OVERHEAD_DEFAULT
Functions
• struct rte_sched_port ∗ rte_sched_port_config (struct rte_sched_port_params ∗params)
• void rte_sched_port_free (struct rte_sched_port ∗port)
• int rte_sched_subport_config (struct rte_sched_port ∗port, uint32_t subport_id, struct rte_sched_-
subport_params ∗params)
• int rte_sched_pipe_config (struct rte_sched_port ∗port, uint32_t subport_id, uint32_t pipe_id, int32_t
pipe_profile)
• uint32_t rte_sched_port_get_memory_footprint (struct rte_sched_port_params ∗params)
• int rte_sched_subport_read_stats (struct rte_sched_port ∗port, uint32_t subport_id, struct rte_sched-
_subport_stats ∗stats, uint32_t ∗tc_ov)
• int rte_sched_queue_read_stats (struct rte_sched_port ∗port, uint32_t queue_id, struct rte_sched_-
queue_stats ∗stats, uint16_t ∗qlen)
• static void rte_sched_port_pkt_write (struct rte_mbuf ∗pkt, uint32_t subport, uint32_t pipe, uint32_t
traffic_class, uint32_t queue, enum rte_meter_color color)
• static void rte_sched_port_pkt_read_tree_path (struct rte_mbuf ∗pkt, uint32_t ∗subport, uint32_-
t ∗pipe, uint32_t ∗traffic_class, uint32_t ∗queue)
• int rte_sched_port_enqueue (struct rte_sched_port ∗port, struct rte_mbuf ∗∗pkts, uint32_t n_pkts)
• int rte_sched_port_dequeue (struct rte_sched_port ∗port, struct rte_mbuf ∗∗pkts, uint32_t n_pkts)
• Traffic shaping using the token bucket algorithm (one bucket per subport);
• Lower priority traffic classes able to reuse subport bandwidth currently unused by higher priority traffic
classes of the same subport;
• When any subport traffic class is oversubscribed (configuration time event), the usage of subport
member pipes with high demand for that traffic class pipes is truncated to a dynamically adjusted
value with no impact to low demand pipes; 3. Pipe:
• Traffic shaping using the token bucket algorithm (one bucket per pipe); 4. Traffic class:
• Lower priority traffic classes able to reuse pipe bandwidth currently unused by higher priority traffic
classes of the same pipe; 5. Queue:
• Typical usage: queue hosting packets from one or multiple connections of same traffic class belonging
to the same user;
• Weighted Round Robin (WRR) is used to service the queues within same pipe traffic class.
Random Early Detection (RED) Number of traffic classes per pipe (as well as subport). Cannot be changed.
Maximum number of pipe profiles that can be defined per port. Compile-time configurable.
Ethernet framing overhead. Overhead fields per Ethernet frame: 1. Preamble: 7 bytes; 2. Start of Frame
Delimiter (SFD): 1 byte; 3. Frame Check Sequence (FCS): 4 bytes; 4. Inter Frame Gap (IFG): 12 bytes. The
FCS is considered overhead only if not included in the packet length (field pkt.pkt_len of struct rte_mbuf).
3.43.3.1 struct rte sched port∗ rte sched port config ( struct rte_sched_port_params ∗ params ) [read]
Parameters
params Port scheduler configuration parameter structure
Returns
Handle to port scheduler instance upon success or NULL otherwise.
3.43.3.2 void rte sched port free ( struct rte sched port ∗ port )
Parameters
port Handle to port scheduler instance
3.43.3.3 int rte sched subport config ( struct rte sched port ∗ port, uint32 t subport id, struct
rte_sched_subport_params ∗ params )
Parameters
port Handle to port scheduler instance
subport_id Subport ID
params Subport configuration parameters
Returns
0 upon success, error code otherwise
3.43.3.4 int rte sched pipe config ( struct rte sched port ∗ port, uint32 t subport id, uint32 t pipe id, int32 t
pipe profile )
Parameters
port Handle to port scheduler instance
subport_id Subport ID
pipe_id Pipe ID within subport
pipe_profile ID of port-level pre-configured pipe profile
Returns
0 upon success, error code otherwise
3.43.3.5 uint32 t rte sched port get memory footprint ( struct rte_sched_port_params ∗ params )
Parameters
params Port scheduler configuration parameter structure
Returns
Memory footprint size in bytes upon success, 0 otherwise
3.43.3.6 int rte sched subport read stats ( struct rte sched port ∗ port, uint32 t subport id, struct
rte_sched_subport_stats ∗ stats, uint32 t ∗ tc ov )
Parameters
port Handle to port scheduler instance
subport_id Subport ID
stats Pointer to pre-allocated subport statistics structure where the statistics counters should
be stored
tc_ov Pointer to pre-allocated 4-entry array where the oversubscription status for each of the
4 subport traffic classes should be stored.
Returns
0 upon success, error code otherwise
3.43.3.7 int rte sched queue read stats ( struct rte sched port ∗ port, uint32 t queue id, struct
rte_sched_queue_stats ∗ stats, uint16 t ∗ qlen )
Parameters
port Handle to port scheduler instance
queue_id Queue ID within port scheduler
stats Pointer to pre-allocated subport statistics structure where the statistics counters should
be stored
qlen Pointer to pre-allocated variable where the current queue length should be stored.
Returns
0 upon success, error code otherwise
3.43.3.8 static void rte sched port pkt write ( struct rte_mbuf ∗ pkt, uint32 t subport, uint32 t pipe, uint32 t
traffic class, uint32 t queue, enum rte_meter_color color ) [static]
Scheduler hierarchy path write to packet descriptor. Typically called by the packet classification stage.
Parameters
pkt Packet descriptor handle
subport Subport ID
pipe Pipe ID within subport
traffic_class Traffic class ID within pipe (0 .. 3)
queue Queue ID within pipe traffic class (0 .. 3)
3.43.3.9 static void rte sched port pkt read tree path ( struct rte_mbuf ∗ pkt, uint32 t ∗ subport, uint32 t ∗ pipe,
uint32 t ∗ traffic class, uint32 t ∗ queue ) [static]
Scheduler hierarchy path read from packet descriptor (struct rte_mbuf). Typically called as part of the
hierarchical scheduler enqueue operation. The subport, pipe, traffic class and queue parameters need to
be pre-allocated by the caller.
Parameters
pkt Packet descriptor handle
subport Subport ID
pipe Pipe ID within subport
traffic_class Traffic class ID within pipe (0 .. 3)
queue Queue ID within pipe traffic class (0 .. 3)
3.43.3.10 int rte sched port enqueue ( struct rte sched port ∗ port, struct rte_mbuf ∗∗ pkts, uint32 t n pkts )
Hierarchical scheduler port enqueue. Writes up to n_pkts to port scheduler and returns the number of
packets actually written. For each packet, the port scheduler queue to write the packet to is identified by
reading the hierarchy path from the packet descriptor; if the queue is full or congested and the packet is not
written to the queue, then the packet is automatically dropped without any action required from the caller.
Parameters
port Handle to port scheduler instance
pkts Array storing the packet descriptor handles
n_pkts Number of packets to enqueue from the pkts array into the port scheduler
Returns
Number of packets successfully enqueued
3.43.3.11 int rte sched port dequeue ( struct rte sched port ∗ port, struct rte_mbuf ∗∗ pkts, uint32 t n pkts )
Hierarchical scheduler port dequeue. Reads up to n_pkts from the port scheduler and stores them in the
pkts array and returns the number of packets actually read. The pkts array needs to be pre-allocated by the
caller with at least n_pkts entries.
Parameters
port Handle to port scheduler instance
pkts Pre-allocated packet descriptor array where the packets dequeued from the port
scheduler should be stored
n_pkts Number of packets to dequeue from the port scheduler
Returns
Number of packets successfully dequeued and placed in the pkts array
Data Structures
• struct sctp_hdr
SCTP-related defines
Data Structures
• struct rte_spinlock_t
• struct rte_spinlock_recursive_t
Defines
• #define RTE_SPINLOCK_INITIALIZER
• #define RTE_SPINLOCK_RECURSIVE_INITIALIZER
Functions
RTE Spinlocks
This file defines an API for read-write locks, which are implemented in an architecture-specific way. This
kind of lock simply waits in a loop repeatedly checking until the lock becomes available.
All locks must be initialised before use, and only initialised once.
Parameters
sl A pointer to the spinlock.
Parameters
sl A pointer to the spinlock.
Parameters
sl A pointer to the spinlock.
Parameters
sl A pointer to the spinlock.
Returns
1 if the lock is successfully taken; 0 otherwise.
Parameters
sl A pointer to the spinlock.
Returns
1 if the lock is currently taken; 0 otherwise.
3.45.3.6 static void rte spinlock recursive init ( rte_spinlock_recursive_t ∗ slr ) [static]
Parameters
slr A pointer to the recursive spinlock.
3.45.3.7 static void rte spinlock recursive lock ( rte_spinlock_recursive_t ∗ slr ) [static]
Parameters
slr A pointer to the recursive spinlock.
3.45.3.8 static void rte spinlock recursive unlock ( rte_spinlock_recursive_t ∗ slr ) [static]
Parameters
slr A pointer to the recursive spinlock.
3.45.3.9 static int rte spinlock recursive trylock ( rte_spinlock_recursive_t ∗ slr ) [static]
Parameters
slr A pointer to the recursive spinlock.
Returns
1 if the lock is successfully taken; 0 otherwise.
Functions
• static int rte_snprintf (char ∗buffer, int buflen, const char ∗format,...)
• static int rte_strsplit (char ∗string, int stringlen, char ∗∗tokens, int maxtokens, char delim)
3.46.2.1 static int rte snprintf ( char ∗ buffer, int buflen, const char ∗ format, ... ) [static]
Safer version of snprintf that writes up to buflen characters to the output buffer and ensures that the resultant
string is null-terminated, that is, it writes at most buflen-1 actual string characters to buffer. The return value
is the number of characters which should be written to the buffer, so string truncation can be detected by
the caller by checking if the return value is greater than or equal to the buflen.
Parameters
buffer The buffer into which the output is to be written
buflen The size of the output buffer
format The format string to be printed to the buffer
Returns
The number of characters written to the buffer, or if the string has been truncated, the number of
characters which would have been written had the buffer been sufficiently big.
3.46.2.2 static int rte strsplit ( char ∗ string, int stringlen, char ∗∗ tokens, int maxtokens, char delim ) [static]
Takes string "string" parameter and splits it at character "delim" up to maxtokens-1 times - to give
"maxtokens" resulting tokens. Like strtok or strsep functions, this modifies its input string, by replacing
instances of "delim" with ’\0’. All resultant tokens are returned in the "tokens" array which must have enough
entries to hold "maxtokens".
Parameters
stringThe input string to be split into tokens
stringlen The max length of the input buffer
tokens The array to hold the pointers to the tokens in the string
maxtokens The number of elements in the tokens array. At most, maxtokens-1 splits of the string
will be done.
delim The character on which the split of the data will be done
Returns
The number of tokens in the tokens array.
Data Structures
• struct rte_dummy
• struct rte_tailq_head
Defines
• #define RTE_TAILQ_RESERVE(name, struct_name)
• #define RTE_TAILQ_RESERVE_BY_IDX(idx, struct_name)
• #define RTE_TAILQ_LOOKUP(name, struct_name)
• #define RTE_TAILQ_LOOKUP_BY_IDX(idx, struct_name)
Functions
• TAILQ_HEAD (rte_dummy_head, rte_dummy)
• struct rte_tailq_head ∗ rte_eal_tailq_reserve (const char ∗name)
• struct rte_tailq_head ∗ rte_eal_tailq_reserve_by_idx (const unsigned idx)
• void rte_dump_tailq (void)
• struct rte_tailq_head ∗ rte_eal_tailq_lookup (const char ∗name)
• struct rte_tailq_head ∗ rte_eal_tailq_lookup_by_idx (const unsigned idx)
Parameters
name The name to be given to the tailq - used by lookup to find it later
struct_name The name of the list type we are using. (Generally this is the same as the first parameter
passed to TAILQ_HEAD macro)
Returns
The return value from rte_eal_tailq_reserve, typecast to the appropriate structure pointer type. NULL
on error, since the tailq_head is the first element in the rte_tailq_head structure.
Parameters
idx The tailq idx defined in rte_tail_t to be given to the tail queue.
• used by lookup to find it later
struct_name The name of the list type we are using. (Generally this is the same as the first parameter
passed to TAILQ_HEAD macro)
Returns
The return value from rte_eal_tailq_reserve, typecast to the appropriate structure pointer type. NULL
on error, since the tailq_head is the first element in the rte_tailq_head structure.
Parameters
name The name of tailq
struct_name The name of the list type we are using. (Generally this is the same as the first parameter
passed to TAILQ_HEAD macro)
Returns
The return value from rte_eal_tailq_lookup, typecast to the appropriate structure pointer type. NULL on
error, since the tailq_head is the first element in the rte_tailq_head structure.
Parameters
idx The tailq idx defined in rte_tail_t to be given to the tail queue.
struct_name The name of the list type we are using. (Generally this is the same as the first parameter
passed to TAILQ_HEAD macro)
Returns
The return value from rte_eal_tailq_lookup, typecast to the appropriate structure pointer type. NULL on
error, since the tailq_head is the first element in the rte_tailq_head structure.
dummy
3.47.3.2 struct rte_tailq_head∗ rte eal tailq reserve ( const char ∗ name ) [read]
Reserve a slot in the tailq list for a particular tailq header Note: this function, along with rte_tailq_lookup, is
not multi-thread safe, and both these functions should only be called from a single thread at a time
Parameters
name The name to be given to the tail queue.
Returns
A pointer to the newly reserved tailq entry
3.47.3.3 struct rte_tailq_head∗ rte eal tailq reserve by idx ( const unsigned idx ) [read]
Reserve a slot in the tailq list for a particular tailq header Note: this function, along with rte_tailq_lookup, is
not multi-thread safe, and both these functions should only be called from a single thread at a time
Parameters
idx The tailq idx defined in rte_tail_t to be given to the tail queue.
Returns
A pointer to the newly reserved tailq entry
3.47.3.5 struct rte_tailq_head∗ rte eal tailq lookup ( const char ∗ name ) [read]
Get a pointer to a tail queue header of an already reserved tail queue identified by the name given as an
argument. Note: this function, along with rte_tailq_reserve, is not multi-thread safe, and both these functions
should only be called from a single thread at a time
Parameters
name The name of the queue.
Returns
A pointer to the tail queue head structure.
3.47.3.6 struct rte_tailq_head∗ rte eal tailq lookup by idx ( const unsigned idx ) [read]
Parameters
idx The tailq idx defined in rte_tail_t to be given to the tail queue.
Returns
A pointer to the tail queue head structure.
This file contains the type of the tailq elem recognised by DPDK, which can be used to fill out an array of
structures describing the tailq.
In order to populate an array, the user of this file must define this macro: rte_tailq_elem(idx, name). For
example:
enum rte_tailq_t {
#define rte_tailq_elem(idx, name) idx,
#define rte_tailq_end(idx) idx
#include <rte_tailq_elem.h>
};
Note that this file can be included multiple times within the same file.
Data Structures
• struct tcp_hdr
TCP-related defines
Data Structures
• union rte_timer_status
• struct rte_timer
Defines
• #define RTE_TIMER_STOP
• #define RTE_TIMER_PENDING
• #define RTE_TIMER_RUNNING
• #define RTE_TIMER_CONFIG
• #define RTE_TIMER_NO_OWNER
• #define RTE_TIMER_INITIALIZER
Typedefs
Enumerations
• enum rte_timer_type
Functions
RTE Timer
This library provides a timer service to RTE Data Plane execution units that allows the execution of callback
functions asynchronously.
• The timers can be loaded from one core and executed on another. This has to be specified in the call
to rte_timer_reset().
• High precision is possible. NOTE: this depends on the call frequency to rte_timer_manage() that check
the timer expiration for the local core.
• If not used in an application, for improved performance, it can be disabled at compilation time by not
calling the rte_timer_manage() to improve performance.
The timer library uses the rte_get_hpet_cycles() function that uses the HPET, when available, to provide a
reliable time reference. [HPET routines are provided by EAL, which falls back to using the chip TSC (time-
stamp counter) as fallback when HPET is not available]
This library provides an interface to add, delete and restart a timer. The API is based on the BSD callout(9)
API with a few differences.
See the RTE architecture documentation for more information about the design of this library.
Parameters
tim The timer to initialize.
3.50.5.3 int rte timer reset ( struct rte_timer ∗ tim, uint64 t ticks, enum rte_timer_type type, unsigned tim lcore,
rte_timer_cb_t fct, void ∗ arg )
Reset and start the timer associated with the timer handle.
The rte_timer_reset() function resets and starts the timer associated with the timer handle ∗tim∗. When the
timer expires after ∗ticks∗ HPET cycles, the function specified by ∗fct∗ will be called with the argument ∗arg∗
on core ∗tim_lcore∗.
If the timer associated with the timer handle is already running (in the RUNNING state), the function will
fail. The user has to check the return value of the function to see if there is a chance that the timer is in the
RUNNING state.
If the timer is being configured on another core (the CONFIG state), it will also fail.
If the timer is pending or stopped, it will be rescheduled with the new parameters.
Parameters
tim The timer handle.
ticks The number of cycles (see rte_get_hpet_hz()) before the callback function is called.
type The type can be either:
• PERIODICAL: The timer is automatically reloaded after execution (returns to the
PENDING state)
• SINGLE: The timer is one-shot, that is, the timer goes to a STOPPED state after
execution.
tim_lcore The ID of the lcore where the timer callback function has to be executed. If tim_lcore is
LCORE_ID_ANY, the timer library will launch it on a different core for each call (round-
robin).
fct The callback function of the timer.
arg The user argument of the callback function.
Returns
• 0: Success; the timer is scheduled.
• (-1): Timer is in the RUNNING or CONFIG state.
3.50.5.4 void rte timer reset sync ( struct rte_timer ∗ tim, uint64 t ticks, enum rte_timer_type type, unsigned
tim lcore, rte_timer_cb_t fct, void ∗ arg )
Parameters
tim The timer handle.
ticks The number of cycles (see rte_get_hpet_hz()) before the callback function is called.
type The type can be either:
• PERIODICAL: The timer is automatically reloaded after execution (returns to the
PENDING state)
• SINGLE: The timer is one-shot, that is, the timer goes to a STOPPED state after
execution.
tim_lcore The ID of the lcore where the timer callback function has to be executed. If tim_lcore is
LCORE_ID_ANY, the timer library will launch it on a different core for each call (round-
robin).
fct The callback function of the timer.
arg The user argument of the callback function.
Stop a timer.
The rte_timer_stop() function stops the timer associated with the timer handle ∗tim∗. It may fail if the timer
is currently running or being configured.
If the timer is pending or stopped (for instance, already expired), the function will succeed. The timer handle
tim must have been initialized using rte_timer_init(), otherwise, undefined behavior will occur.
This function can be called safely from a timer callback. If it succeeds, the timer is not referenced anymore
by the timer library and the timer structure can be freed (even in the callback function).
Parameters
tim The timer handle.
Returns
• 0: Success; the timer is stopped.
• (-1): The timer is in the RUNNING or CONFIG state.
Parameters
tim The timer handle.
Parameters
tim The timer handle.
Returns
• 0: The timer is not pending.
• 1: The timer is pending.
Data Structures
• struct udp_hdr
UDP-related defines
Defines
• #define RTE_VER_PREFIX
• #define RTE_VER_MAJOR
• #define RTE_VER_MINOR
• #define RTE_VER_PATCH_LEVEL
• #define RTE_VER_SUFFIX
Functions
Extra string to be appended to version number, for example: pre1, EAR, final etc.
Returns
string