0% found this document useful (0 votes)
762 views

Intel DPDK API Reference

Data Plane DEpelovment Api Kit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
762 views

Intel DPDK API Reference

Data Plane DEpelovment Api Kit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 262

Intel Data Plane Development Kit

(Intel DPDK)
API Reference
November 2012

Reference Number: 326004-001

Intel DPDK -

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
INTELS 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 INTELS 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-5484725, 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.
This document contains information on products in the design phase of development.
Intel processor numbers are not a measure of performance. Processor numbers differentiate features within each processor family, not across different
processor families. See http://www.intel.com/products/processor_number for details.
Intel and Intel logo are trademarks of Intel Corporation in the U.S. and other countries.
*Other names and brands may be claimed as the property of others.
Copyright 2012, Intel Corporation. All Rights Reserved.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
2

November 2012
Reference Number: 326004-001

CONTENTS- Intel DPDK

Contents
1 Deprecated List

2 Data Structure Documentation

2.1 rte_ring::cons Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.2 eth_dev_ops Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.3 eth_driver Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

2.4 ether_addr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

13

2.5 ether_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

14

2.6 ipv4_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

2.7 ipv6_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16

2.8 rte_ring::prod Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

2.9 rte_atomic16_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

18

2.10 rte_atomic32_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19

2.11 rte_atomic64_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19

2.12 rte_config Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

19

2.13 rte_ctrlmbuf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

2.14 rte_dummy Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

21

2.15 rte_eth_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22

2.16 rte_eth_dev Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

23

2.17 rte_eth_dev_data Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

24

2.18 rte_eth_dev_info Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

26

2.19 rte_eth_fc_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

28

2.20 rte_eth_fdir Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29

2.21 rte_eth_link Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

30

2.22 rte_eth_rss_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

31

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
3

Intel DPDK - CONTENTS

2.23 rte_eth_rxconf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

31

2.24 rte_eth_rxmode Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

32

2.25 rte_eth_stats Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

33

2.26 rte_eth_thresh Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35

2.27 rte_eth_txconf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

35

2.28 rte_eth_txmode Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

36

2.29 rte_eth_vmdq_dcb_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

36

2.30 rte_fbk_hash_entry Union Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

37

2.31 rte_fbk_hash_params Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

38

2.32 rte_fbk_hash_table Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

39

2.33 rte_fdir_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

41

2.34 rte_fdir_filter Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

42

2.35 rte_fdir_masks Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

43

2.36 rte_hash Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

45

2.37 rte_hash_parameters Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

47

2.38 rte_intr_conf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

48

2.39 rte_logs Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

49

2.40 rte_lpm Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

49

2.41 rte_lpm_rule Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

50

2.42 rte_lpm_tbl24_entry Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51

2.43 rte_lpm_tbl8_entry Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

51

2.44 rte_mbuf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

52

2.45 rte_mem_config Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

54

2.46 rte_mempool Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

55

2.47 rte_mempool_cache Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

57

2.48 rte_memseg Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

57

2.49 rte_memzone Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

58

2.50 rte_pci_addr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

60

2.51 rte_pci_device Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

60

2.52 rte_pci_driver Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

61

2.53 rte_pci_id Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

62

2.54 rte_pci_resource Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

63

2.55 rte_pktmbuf Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

64

2.56 rte_pktmbuf_pool_private Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . .

65

Intel Data Plane Development Kit (Intel DPDK)


API Reference
4

November 2012
Reference Number: 326004-001

CONTENTS - Intel DPDK

2.57 rte_ring Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

66

2.58 rte_rwlock_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

67

2.59 rte_spinlock_recursive_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

67

2.60 rte_spinlock_t Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

68

2.61 rte_tailq_head Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

68

2.62 rte_timer Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

69

2.63 rte_timer_status Union Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

70

2.64 sctp_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

71

2.65 tcp_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

72

2.66 udp_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

73

2.67 vlan_hdr Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

74

3 File Documentation

75

3.1 rte_alarm.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

75

3.2 rte_atomic.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

76

3.3 rte_branch_prediction.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

90

3.4 rte_byteorder.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

90

3.5 rte_common.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

92

3.6 rte_cpuflags.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

97

3.7 rte_cycles.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100


3.8 rte_debug.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
3.9 rte_eal.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
3.10 rte_errno.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3.11 rte_ethdev.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.12 rte_ether.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
3.13 rte_fbk_hash.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
3.14 rte_hash.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
3.15 rte_hash_crc.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
3.16 rte_interrupts.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
3.17 rte_ip.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
3.18 rte_jhash.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.19 rte_launch.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.20 rte_lcore.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
3.21 rte_log.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
5

Intel DPDK - CONTENTS

3.22 rte_lpm.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185


3.23 rte_malloc.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.24 rte_mbuf.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
3.25 rte_memcpy.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
3.26 rte_memory.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
3.27 rte_mempool.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
3.28 rte_memzone.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
3.29 rte_pci.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
3.30 rte_pci_dev_ids.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
3.31 rte_per_lcore.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
3.32 rte_prefetch.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
3.33 rte_random.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
3.34 rte_ring.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
3.35 rte_rwlock.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
3.36 rte_sctp.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
3.37 rte_spinlock.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
3.38 rte_string_fns.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
3.39 rte_tailq.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
3.40 rte_tcp.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
3.41 rte_timer.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
3.42 rte_udp.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
3.43 rte_version.h File Reference

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

3.44 rte_warnings.h File Reference

Intel Data Plane Development Kit (Intel DPDK)


API Reference
6

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

November 2012
Reference Number: 326004-001

Deprecated List- Intel DPDK

Chapter 1

Deprecated List
Global rte_82576_pmd_init (void)
rte_82576_pmd_init() is deprecated and will be removed from future versions of Intel(R) DPDK. It has
been replaced by rte_igb_pmd_init().
Global rte_82599_pmd_init (void)
rte_82599_pmd_init() is deprecated and will be removed from future versions of Intel(R) DPDK. It has
been replaced by rte_ixgbe_pmd_init().
Global RTE_LIBRTE_82576_PMD
The config file option CONFIG_RTE_LIBRTE_82576_PMD and resulting preprocessor define RTE_LIBRTE_82576_PMD are deprecated. CONFIG_RTE_LIBRTE_IGB_PMD must be set in the config file
to use Intel(R) DPDK supported Gigabit Ethernet Controllers, and RTE_LIBRTE_IGB_PMD should be
used in code.
Global RTE_LIBRTE_82599_PMD
The config file option CONFIG_RTE_LIBRTE_82599_PMD and resulting preprocessor define RTE_LIBRTE_82599_PMD are deprecated. CONFIG_RTE_LIBRTE_IXGBE_PMD must be set in the config file
to use Intel(R) DPDK supported Gigabit Ethernet Controllers, and RTE_LIBRTE_IXGBE_PMD should
be used in code.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
7

Intel DPDK- Data Structure Documentation

Chapter 2

Data Structure Documentation


2.1

rte ring::cons Struct Reference

Data Fields

volatile uint32_t bulk_default


uint32_t sc_dequeue
uint32_t size
uint32_t mask
volatile uint32_t head
volatile uint32_t tail

2.1.1

Detailed Description

Ring consumer status.

2.1.2

Field Documentation

2.1.2.1

volatile uint32 t rte_ring::cons::bulk_default

Default bulk count.


2.1.2.2

uint32 t rte_ring::cons::sc_dequeue

True, if single consumer.


2.1.2.3

uint32 t rte_ring::cons::size

Size of the ring.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
8

November 2012
Reference Number: 326004-001

eth_dev_ops Struct Reference - Intel DPDK

2.1.2.4

uint32 t rte_ring::cons::mask

Mask (size-1) of ring.


2.1.2.5

volatile uint32 t rte_ring::cons::head

Consumer head.
2.1.2.6

volatile uint32 t rte_ring::cons::tail

Consumer tail.

2.2

eth dev ops Struct Reference

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_dev_infos_get_t dev_infos_get
vlan_filter_set_t vlan_filter_set
eth_rx_queue_setup_t rx_queue_setup
eth_tx_queue_setup_t tx_queue_setup
eth_dev_led_on_t dev_led_on
eth_dev_led_off_t dev_led_off
flow_ctrl_set_t flow_ctrl_set
eth_mac_addr_remove_t mac_addr_remove
eth_mac_addr_add_t mac_addr_add
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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
9

Intel DPDK - eth_dev_ops Struct Reference

2.2.1

Detailed Description

A structure containing the functions exported by an Ethernet driver.

2.2.2

Field Documentation

2.2.2.1

eth_dev_configure_t eth_dev_ops::dev_configure

Configure device.

2.2.2.2

eth_dev_start_t eth_dev_ops::dev_start

Start device.

2.2.2.3

eth_dev_stop_t eth_dev_ops::dev_stop

Stop device.

2.2.2.4

eth_dev_close_t eth_dev_ops::dev_close

Close device.

2.2.2.5

eth_promiscuous_enable_t eth_dev_ops::promiscuous_enable

Promiscuous ON.

2.2.2.6

eth_promiscuous_disable_t eth_dev_ops::promiscuous_disable

Promiscuous OFF.

2.2.2.7

eth_allmulticast_enable_t eth_dev_ops::allmulticast_enable

RX multicast ON.

2.2.2.8

eth_allmulticast_disable_t eth_dev_ops::allmulticast_disable

RX multicast OF.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
10

November 2012
Reference Number: 326004-001

eth_dev_ops Struct Reference - Intel DPDK

2.2.2.9 eth_link_update_t eth_dev_ops::link_update


Get device link state.

2.2.2.10 eth_stats_get_t eth_dev_ops::stats_get


Get device statistics.

2.2.2.11 eth_stats_reset_t eth_dev_ops::stats_reset


Reset device statistics.

2.2.2.12 eth_dev_infos_get_t eth_dev_ops::dev_infos_get


Get device info.

2.2.2.13 vlan_filter_set_t eth_dev_ops::vlan_filter_set


Filter VLAN on/off.

2.2.2.14 eth_rx_queue_setup_t eth_dev_ops::rx_queue_setup


Set up device RX queue.

2.2.2.15 eth_tx_queue_setup_t eth_dev_ops::tx_queue_setup


Set up device TX queue.

2.2.2.16 eth_dev_led_on_t eth_dev_ops::dev_led_on


Turn on LED.

2.2.2.17 eth_dev_led_off_t eth_dev_ops::dev_led_off


Turn off LED.

2.2.2.18 flow_ctrl_set_t eth_dev_ops::flow_ctrl_set


Setup flow control.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
11

Intel DPDK - eth_dev_ops Struct Reference

2.2.2.19 eth_mac_addr_remove_t eth_dev_ops::mac_addr_remove


Remove MAC address

2.2.2.20 eth_mac_addr_add_t eth_dev_ops::mac_addr_add


Add a MAC address

2.2.2.21 fdir_add_signature_filter_t eth_dev_ops::fdir_add_signature_filter


Add a signature filter.

2.2.2.22 fdir_update_signature_filter_t eth_dev_ops::fdir_update_signature_filter


Update a signature filter.

2.2.2.23 fdir_remove_signature_filter_t eth_dev_ops::fdir_remove_signature_filter


Remove a signature filter.

2.2.2.24 fdir_infos_get_t eth_dev_ops::fdir_infos_get


Get information about FDIR status.

2.2.2.25 fdir_add_perfect_filter_t eth_dev_ops::fdir_add_perfect_filter


Add a perfect filter.

2.2.2.26 fdir_update_perfect_filter_t eth_dev_ops::fdir_update_perfect_filter


Update a perfect filter.

2.2.2.27 fdir_remove_perfect_filter_t eth_dev_ops::fdir_remove_perfect_filter


Remove a perfect filter.

2.2.2.28 fdir_set_masks_t eth_dev_ops::fdir_set_masks


Setup masks for FDIR filtering.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
12

November 2012
Reference Number: 326004-001

eth_driver Struct Reference - Intel DPDK

2.3

eth driver Struct Reference

Data Fields
struct rte_pci_driver pci_drv
eth_dev_init_t eth_dev_init
unsigned int dev_private_size

2.3.1

Detailed Description

The structure associated with a PMD Ethernet driver.


Each Ethernet driver acts as a PCI driver and is represented by a generic eth_driver structure that holds:
An rte_pci_driver structure (which must be the first field).
The eth_dev_init function invoked for each matching PCI device.
The size of the private data to allocate for each matching device.

2.3.2

Field Documentation

2.3.2.1

struct rte_pci_driver eth_driver::pci_drv

The PMD is also a PCI driver.

2.3.2.2 eth_dev_init_t eth_driver::eth_dev_init


Device init function.

2.3.2.3

unsigned int eth_driver::dev_private_size

Size of device private data.

2.4

ether addr Struct Reference

Data Fields
uint8_t addr_bytes [ETHER_ADDR_LEN]

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
13

Intel DPDK - ether_hdr Struct Reference

2.4.1

Detailed Description

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

2.4.2

Field Documentation

2.4.2.1

uint8 t ether_addr::addr_bytes[ETHER ADDR LEN]

Address bytes in transmission order

2.5

ether hdr Struct Reference

Data Fields
struct ether_addr d_addr
struct ether_addr s_addr
uint16_t ether_type

2.5.1

Detailed Description

Ethernet header: Contains the destination address, source address and frame type.

2.5.2

Field Documentation

2.5.2.1

struct ether_addr ether_hdr::d_addr

Destination address.

2.5.2.2

struct ether_addr ether_hdr::s_addr

Source address.

2.5.2.3

uint16 t ether_hdr::ether_type

Frame type.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
14

November 2012
Reference Number: 326004-001

ipv4_hdr Struct Reference - Intel DPDK

2.6

ipv4 hdr Struct Reference

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

2.6.1

Detailed Description

IPv4 Header

2.6.2

Field Documentation

2.6.2.1

uint8 t ipv4_hdr::version_ihl

version and header length

2.6.2.2

uint8 t ipv4_hdr::type_of_service

type of service

2.6.2.3

uint16 t ipv4_hdr::total_length

length of packet

2.6.2.4

uint16 t ipv4_hdr::packet_id

packet ID

2.6.2.5

uint16 t ipv4_hdr::fragment_offset

fragmentation offset

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
15

Intel DPDK - ipv6_hdr Struct Reference

2.6.2.6

uint8 t ipv4_hdr::time_to_live

time to live

2.6.2.7

uint8 t ipv4_hdr::next_proto_id

protocol ID

2.6.2.8

uint16 t ipv4_hdr::hdr_checksum

header checksum

2.6.2.9

uint32 t ipv4_hdr::src_addr

source address

2.6.2.10

uint32 t ipv4_hdr::dst_addr

destination address

2.7

ipv6 hdr Struct Reference

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]

2.7.1

Detailed Description

IPv6 Header

2.7.2

Field Documentation

2.7.2.1

uint32 t ipv6_hdr::vtc_flow

IP version, traffic class & flow label.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
16

November 2012
Reference Number: 326004-001

rte_ring::prod Struct Reference - Intel DPDK

2.7.2.2

uint16 t ipv6_hdr::payload_len

IP packet length - includes sizeof(ip_header).


2.7.2.3

uint8 t ipv6_hdr::proto

Protocol, next header.


2.7.2.4

uint8 t ipv6_hdr::hop_limits

Hop limits.
2.7.2.5

uint8 t ipv6_hdr::src_addr[16]

IP address of source host.


2.7.2.6

uint8 t ipv6_hdr::dst_addr[16]

IP address of destination host(s).

2.8

rte ring::prod Struct Reference

Data Fields

volatile uint32_t bulk_default


uint32_t watermark
uint32_t sp_enqueue
uint32_t size
uint32_t mask
volatile uint32_t head
volatile uint32_t tail

2.8.1

Detailed Description

Ring producer status.

2.8.2

Field Documentation

2.8.2.1

volatile uint32 t rte_ring::prod::bulk_default

Default bulk count.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
17

Intel DPDK - rte_atomic16_t Struct Reference

2.8.2.2

uint32 t rte_ring::prod::watermark

Maximum items before EDQUOT.

2.8.2.3

uint32 t rte_ring::prod::sp_enqueue

True, if single producer.

2.8.2.4

uint32 t rte_ring::prod::size

Size of ring.

2.8.2.5

uint32 t rte_ring::prod::mask

Mask (size-1) of ring.

2.8.2.6

volatile uint32 t rte_ring::prod::head

Producer head.

2.8.2.7

volatile uint32 t rte_ring::prod::tail

Producer tail.

2.9

rte atomic16 t Struct Reference

Data Fields
volatile int16_t cnt

2.9.1

Detailed Description

The atomic counter structure.

2.9.2

Field Documentation

2.9.2.1

volatile int16 t rte_atomic16_t::cnt

An internal counter value.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
18

November 2012
Reference Number: 326004-001

rte_atomic32_t Struct Reference - Intel DPDK

2.10

rte atomic32 t Struct Reference

Data Fields
volatile int32_t cnt

2.10.1

Detailed Description

The atomic counter structure.

2.10.2

Field Documentation

2.10.2.1

volatile int32 t rte_atomic32_t::cnt

An internal counter value.

2.11

rte atomic64 t Struct Reference

Data Fields
volatile int64_t cnt

2.11.1

Detailed Description

The atomic counter structure.

2.11.2

Field Documentation

2.11.2.1

volatile int64 t rte_atomic64_t::cnt

Internal counter value.

2.12

rte config Struct Reference

Data Fields
uint32_t version
uint32_t magic
uint32_t master_lcore

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
19

Intel DPDK - rte_config Struct Reference

uint32_t lcore_count
enum rte_lcore_role_t lcore_role [32,]
enum rte_proc_type_t process_type
struct rte_mem_config mem_config

2.12.1

Detailed Description

The global RTE configuration structure.

2.12.2

Field Documentation

2.12.2.1

uint32 t rte_config::version

Configuration [structure] version.

2.12.2.2

uint32 t rte_config::magic

Magic number - Sanity check.

2.12.2.3

uint32 t rte_config::master_lcore

Id of the master lcore

2.12.2.4

uint32 t rte_config::lcore_count

Number of available logical cores.

2.12.2.5

enum rte_lcore_role_t rte_config::lcore_role[32,]

State of cores.

2.12.2.6

enum rte_proc_type_t rte_config::process_type

Primary or secondary configuration

2.12.2.7

struct rte_mem_config rte_config::mem_config

Pointer to memory configuration, which may be shared across multiple Intel DPDK instances

Intel Data Plane Development Kit (Intel DPDK)


API Reference
20

November 2012
Reference Number: 326004-001

rte_ctrlmbuf Struct Reference - Intel DPDK

2.13

rte ctrlmbuf Struct Reference

Data Fields
void data
uint32_t data_len

2.13.1

Detailed Description

A control message buffer.

2.13.2

Field Documentation

2.13.2.1

void rte_ctrlmbuf::data

Pointer to data.

2.13.2.2

uint32 t rte_ctrlmbuf::data_len

Length of data.

2.14

rte dummy Struct Reference

Data Fields
TAILQ_ENTRY next

2.14.1

Detailed Description

dummy structure type used by the rte_tailq APIs

2.14.2

Field Documentation

2.14.2.1

TAILQ ENTRY rte_dummy::next

Pointer entries for a tailq list

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
21

Intel DPDK - rte_eth_conf Struct Reference

2.15

rte eth conf Struct Reference

Data Fields

uint16_t link_speed
uint16_t link_duplex
struct rte_eth_rxmode rxmode
struct rte_eth_txmode txmode
union {
struct rte_eth_rss_conf rss_conf
struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf
} rx_adv_conf

struct rte_fdir_conf fdir_conf


struct rte_intr_conf intr_conf

2.15.1

Detailed Description

A structure used to configure an Ethernet port. Depending upon the RX multi-queue mode, extra advanced
configuration settings may be needed.

2.15.2

Field Documentation

2.15.2.1

uint16 t rte_eth_conf::link_speed

ETH_LINK_SPEED_10[0|00|000], or 0 for autonegotation

2.15.2.2

uint16 t rte_eth_conf::link_duplex

ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation

2.15.2.3

struct rte_eth_rxmode rte_eth_conf::rxmode

Port RX configuration.

2.15.2.4

struct rte_eth_txmode rte_eth_conf::txmode

Port TX configuration.

2.15.2.5

struct rte_eth_rss_conf rte_eth_conf::rss_conf

Port RSS configuration

Intel Data Plane Development Kit (Intel DPDK)


API Reference
22

November 2012
Reference Number: 326004-001

rte_eth_dev Struct Reference - Intel DPDK

2.15.2.6

struct rte_eth_vmdq_dcb_conf rte_eth_conf::vmdq_dcb_conf

Port vmdq+dcb configuration.

2.15.2.7

union { ... } rte_eth_conf::rx_adv_conf

Port RX filtering configuration (union).

2.15.2.8

struct rte_fdir_conf rte_eth_conf::fdir_conf

FDIR configuration.

2.15.2.9

struct rte_intr_conf rte_eth_conf::intr_conf

Interrupt mode configuration.

2.16

rte eth dev Struct Reference

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

2.16.1

Detailed Description

The generic data structure associated with each ethernet device.


Pointers to burst-oriented packet receive and transmit functions are located at the beginning of the structure,
along with the pointer to where all the data elements for the particular device are stored in shared memory.
This split allows the function pointer and driver data to be per- process, while the actual configuration data
for the device is shared.

2.16.2

Field Documentation

2.16.2.1 eth_rx_burst_t rte_eth_dev::rx_pkt_burst


Pointer to PMD receive function.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
23

Intel DPDK - rte_eth_dev_data Struct Reference

2.16.2.2 eth_tx_burst_t rte_eth_dev::tx_pkt_burst


Pointer to PMD transmit function.

2.16.2.3

struct rte_eth_dev_data rte_eth_dev::data

Pointer to device data

2.16.2.4

struct eth_driver rte_eth_dev::driver

Driver for this device

2.16.2.5

struct eth_dev_ops rte_eth_dev::dev_ops

Functions exported by PMD

2.16.2.6

struct rte_pci_device rte_eth_dev::pci_dev

PCI info. supplied by probing

2.16.2.7

struct rte eth dev cb list rte_eth_dev::callbacks

User application callbacks

2.17

rte eth dev data Struct Reference

Data Fields

struct igb_rx_queue rx_queues


struct igb_tx_queue tx_queues
uint16_t nb_rx_queues
uint16_t nb_tx_queues
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
uint8_t port_id
uint8_t promiscuous: 1
uint8_t scattered_rx: 1

Intel Data Plane Development Kit (Intel DPDK)


API Reference
24

November 2012
Reference Number: 326004-001

rte_eth_dev_data Struct Reference - Intel DPDK

uint8_t all_multicast: 1
uint8_t dev_started: 1

2.17.1

Detailed Description

The data part, with no function pointers, associated with each ethernet device.
This structure is safe to place in shared memory to be common among different processes in a multi-process
configuration.

2.17.2

Field Documentation

2.17.2.1

struct igb rx queue rte_eth_dev_data::rx_queues

Array of pointers to RX queues.

2.17.2.2

struct igb tx queue rte_eth_dev_data::tx_queues

Array of pointers to TX queues.

2.17.2.3

uint16 t rte_eth_dev_data::nb_rx_queues

Number of RX queues.

2.17.2.4

uint16 t rte_eth_dev_data::nb_tx_queues

Number of TX queues.

2.17.2.5

void rte_eth_dev_data::dev_private

PMD-specific private data

2.17.2.6

struct rte_eth_link rte_eth_dev_data::dev_link

Link-level information & status

2.17.2.7

struct rte_eth_conf rte_eth_dev_data::dev_conf

Configuration applied to device.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
25

Intel DPDK - rte_eth_dev_info Struct Reference

2.17.2.8

uint16 t rte_eth_dev_data::max_frame_size

Default is ETHER_MAX_LEN (1518).

2.17.2.9

uint64 t rte_eth_dev_data::rx_mbuf_alloc_failed

RX ring mbuf allocation failures.

2.17.2.10

struct ether_addr rte_eth_dev_data::mac_addrs

Device Ethernet Link address.

2.17.2.11

uint8 t rte_eth_dev_data::port_id

Device [external] port identifier.

2.17.2.12

uint8 t rte_eth_dev_data::promiscuous

RX promiscuous mode ON(1) / OFF(0).

2.17.2.13

uint8 t rte_eth_dev_data::scattered_rx

RX of scattered packets is ON(1) / OFF(0)

2.17.2.14

uint8 t rte_eth_dev_data::all_multicast

RX all multicast mode ON(1) / OFF(0).

2.17.2.15

uint8 t rte_eth_dev_data::dev_started

Device state: STARTED(1) / STOPPED(0).

2.18

rte eth dev info Struct Reference

Data Fields

struct rte_pci_device pci_dev


const char driver_name
uint32_t min_rx_bufsize
uint32_t max_rx_pktlen

Intel Data Plane Development Kit (Intel DPDK)


API Reference
26

November 2012
Reference Number: 326004-001

rte_eth_dev_info Struct Reference - Intel DPDK

uint16_t max_rx_queues
uint16_t max_tx_queues
uint32_t max_mac_addrs

2.18.1

Detailed Description

A structure used to retrieve the contextual information of an Ethernet device, such as the controlling driver
of the device, its PCI context, etc...

2.18.2

Field Documentation

2.18.2.1

struct rte_pci_device rte_eth_dev_info::pci_dev

Device PCI information.

2.18.2.2

const char rte_eth_dev_info::driver_name

Device Driver name.

2.18.2.3

uint32 t rte_eth_dev_info::min_rx_bufsize

Minimum size of RX buffer.

2.18.2.4

uint32 t rte_eth_dev_info::max_rx_pktlen

Maximum configurable length of RX pkt.

2.18.2.5

uint16 t rte_eth_dev_info::max_rx_queues

Maximum number of RX queues.

2.18.2.6

uint16 t rte_eth_dev_info::max_tx_queues

Maximum number of TX queues.

2.18.2.7

uint32 t rte_eth_dev_info::max_mac_addrs

Maximum number of MAC addresses.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
27

Intel DPDK - rte_eth_fc_conf Struct Reference

2.19

rte eth fc conf Struct Reference

Data Fields
uint32_t high_water
uint32_t low_water
uint16_t pause_time
uint16_t send_xon
enum rte_eth_fc_mode mode

2.19.1

Detailed Description

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.

2.19.2

Field Documentation

2.19.2.1

uint32 t rte_eth_fc_conf::high_water

High threshold value to trigger XOFF

2.19.2.2

uint32 t rte_eth_fc_conf::low_water

Low threshold value to trigger XON

2.19.2.3

uint16 t rte_eth_fc_conf::pause_time

Pause quota in the Pause frame

2.19.2.4

uint16 t rte_eth_fc_conf::send_xon

Is XON frame need be sent

2.19.2.5

enum rte_eth_fc_mode rte_eth_fc_conf::mode

Link flow control mode

Intel Data Plane Development Kit (Intel DPDK)


API Reference
28

November 2012
Reference Number: 326004-001

rte_eth_fdir Struct Reference - Intel DPDK

2.20

rte eth fdir Struct Reference

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

2.20.1

Detailed Description

A structure used to report the status of the flow director filters in use.

2.20.2

Field Documentation

2.20.2.1

uint16 t rte_eth_fdir::collision

Number of filters with collision indication.

2.20.2.2

uint16 t rte_eth_fdir::free

Number of free (non programmed) filters.

2.20.2.3

uint16 t rte_eth_fdir::maxhash

The Lookup hash value of the added filter that updated the value of the MAXLEN field

2.20.2.4

uint8 t rte_eth_fdir::maxlen

Longest linked list of filters in the table.

2.20.2.5

uint64 t rte_eth_fdir::add

Number of added filters.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
29

Intel DPDK - rte_eth_link Struct Reference

2.20.2.6

uint64 t rte_eth_fdir::remove

Number of removed filters.

2.20.2.7

uint64 t rte_eth_fdir::f_add

Number of failed added filters (no more space in device).

2.20.2.8

uint64 t rte_eth_fdir::f_remove

Number of failed removed filters.

2.21

rte eth link Struct Reference

Data Fields
uint16_t link_speed
uint16_t link_duplex
uint8_t link_status: 1

2.21.1

Detailed Description

A structure used to retrieve link-level information of an Ethernet port. aligned for atomic64 read/write

2.21.2

Field Documentation

2.21.2.1

uint16 t rte_eth_link::link_speed

ETH_LINK_SPEED_[10, 100, 1000, 10000]

2.21.2.2

uint16 t rte_eth_link::link_duplex

ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX]

2.21.2.3

uint8 t rte_eth_link::link_status

1 -> link up, 0 -> link down

Intel Data Plane Development Kit (Intel DPDK)


API Reference
30

November 2012
Reference Number: 326004-001

rte_eth_rss_conf Struct Reference - Intel DPDK

2.22

rte eth rss conf Struct Reference

Data Fields
uint8_t rss_key
uint16_t rss_hf

2.22.1

Detailed Description

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.

2.22.2

Field Documentation

2.22.2.1

uint8 t rte_eth_rss_conf::rss_key

If not NULL, 40-byte hash key.

2.22.2.2

uint16 t rte_eth_rss_conf::rss_hf

Hash functions to apply - see below.

2.23

rte eth rxconf Struct Reference

Data Fields
struct rte_eth_thresh rx_thresh
uint16_t rx_free_thresh

2.23.1

Detailed Description

A structure used to configure an RX ring of an Ethernet port.

2.23.2

Field Documentation

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
31

Intel DPDK - rte_eth_rxmode Struct Reference

2.23.2.1

struct rte_eth_thresh rte_eth_rxconf::rx_thresh

RX ring threshold registers.

2.23.2.2

uint16 t rte_eth_rxconf::rx_free_thresh

Drives the freeing of RX descriptors.

2.24

rte eth rxmode Struct Reference

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 jumbo_frame: 1
uint8_t hw_strip_crc: 1

2.24.1

Detailed Description

A structure used to configure the RX features of an Ethernet port.

2.24.2

Field Documentation

2.24.2.1

enum rte_eth_rx_mq_mode rte_eth_rxmode::mq_mode

The multi-queue packet distribution mode to be used, e.g. RSS.

2.24.2.2

uint32 t rte_eth_rxmode::max_rx_pkt_len

Only used if jumbo_frame enabled.

2.24.2.3

uint16 t rte_eth_rxmode::split_hdr_size

hdr buf size (header_split enabled).

Intel Data Plane Development Kit (Intel DPDK)


API Reference
32

November 2012
Reference Number: 326004-001

rte_eth_stats Struct Reference - Intel DPDK

2.24.2.4

uint8 t rte_eth_rxmode::header_split

Header Split enable.

2.24.2.5

uint8 t rte_eth_rxmode::hw_ip_checksum

IP/UDP/TCP checksum offload enable.

2.24.2.6

uint8 t rte_eth_rxmode::hw_vlan_filter

VLAN filter enable.

2.24.2.7

uint8 t rte_eth_rxmode::jumbo_frame

Jumbo Frame Receipt enable.

2.24.2.8

uint8 t rte_eth_rxmode::hw_strip_crc

Enable CRC stripping by hardware.

2.25

rte eth stats Struct Reference

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

2.25.1

Detailed Description

A structure used to retrieve statistics for an Ethernet port.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
33

Intel DPDK - rte_eth_stats Struct Reference

2.25.2

Field Documentation

2.25.2.1

uint64 t rte_eth_stats::ipackets

Total number of successfully received packets.


2.25.2.2

uint64 t rte_eth_stats::opackets

Total number of successfully transmitted packets.


2.25.2.3

uint64 t rte_eth_stats::ibytes

Total number of successfully received bytes.


2.25.2.4

uint64 t rte_eth_stats::obytes

Total number of successfully transmitted bytes.


2.25.2.5

uint64 t rte_eth_stats::ierrors

Total number of erroneous received packets.


2.25.2.6

uint64 t rte_eth_stats::oerrors

Total number of failed transmitted packets.


2.25.2.7

uint64 t rte_eth_stats::imcasts

Total number of multicast received packets.


2.25.2.8

uint64 t rte_eth_stats::rx_nombuf

Total number of RX mbuf allocation failures.


2.25.2.9

uint64 t rte_eth_stats::fdirmatch

Total number of RX packets matching a filter.


2.25.2.10

uint64 t rte_eth_stats::fdirmiss

Total number of RX packets not matching any filter.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
34

November 2012
Reference Number: 326004-001

rte_eth_thresh Struct Reference - Intel DPDK

2.26

rte eth thresh Struct Reference

Data Fields
uint8_t pthresh
uint8_t hthresh
uint8_t wthresh

2.26.1

Detailed Description

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

2.26.2

Field Documentation

2.26.2.1

uint8 t rte_eth_thresh::pthresh

Ring prefetch threshold.

2.26.2.2

uint8 t rte_eth_thresh::hthresh

Ring host threshold.

2.26.2.3

uint8 t rte_eth_thresh::wthresh

Ring writeback threshold.

2.27

rte eth txconf Struct Reference

Data Fields
struct rte_eth_thresh tx_thresh
uint16_t tx_rs_thresh
uint16_t tx_free_thresh

2.27.1

Detailed Description

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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
35

Intel DPDK - rte_eth_txmode Struct Reference

2.27.2

Field Documentation

2.27.2.1

struct rte_eth_thresh rte_eth_txconf::tx_thresh

TX ring threshold registers.


2.27.2.2

uint16 t rte_eth_txconf::tx_rs_thresh

Drives the setting of RS bit on TXDs.


2.27.2.3

uint16 t rte_eth_txconf::tx_free_thresh

Drives the freeing of TX buffers.

2.28

rte eth txmode Struct Reference

2.28.1

Detailed Description

A structure used to configure the TX features of an Ethernet port. For future extensions.

rte eth vmdq dcb conf Struct Reference

2.29

Data Fields

enum rte_eth_nb_pools nb_queue_pools


uint8_t enable_default_pool
uint8_t default_pool
uint8_t nb_pool_maps
struct {
uint16_t vlan_id
uint64_t pools
} pool_map [ETH_VMDQ_MAX_VLAN_FILTERS]

uint8_t dcb_queue [ETH_DCB_NUM_USER_PRIORITIES]

2.29.1

Detailed Description

A structure used to configure the VMDQ+DCB feature of an Ethernet port.


Using this feature, packets are routed to a pool of queues, based on the vlan id in the vlan tag, and then to
a specific queue within that pool, using the user priority vlan tag field.
A default pool may be used, if desired, to route all traffic which does not match the vlan filter rules.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
36

November 2012
Reference Number: 326004-001

rte_fbk_hash_entry Union Reference - Intel DPDK

2.29.2

Field Documentation

2.29.2.1

enum rte_eth_nb_pools rte_eth_vmdq_dcb_conf::nb_queue_pools

With DCB, 16 or 32 pools

2.29.2.2

uint8 t rte_eth_vmdq_dcb_conf::enable_default_pool

If non-zero, use a default pool

2.29.2.3

uint8 t rte_eth_vmdq_dcb_conf::default_pool

The default pool, if applicable

2.29.2.4

uint8 t rte_eth_vmdq_dcb_conf::nb_pool_maps

We can have up to 64 filters/mappings

2.29.2.5

uint16 t rte_eth_vmdq_dcb_conf::vlan_id

The vlan id of the received frame

2.29.2.6

uint64 t rte_eth_vmdq_dcb_conf::pools

Bitmask of pools for packet rx

2.29.2.7

struct { ... } rte_eth_vmdq_dcb_conf::pool_map[ETH VMDQ MAX VLAN FILTERS]

VMDq vlan pool maps.

2.29.2.8

uint8 t rte_eth_vmdq_dcb_conf::dcb_queue[ETH DCB NUM USER PRIORITIES]

Selects a queue in a pool

2.30

rte fbk hash entry Union Reference

Data Fields
uint64_t whole_entry

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
37

Intel DPDK - rte_fbk_hash_params Struct Reference

struct {
uint16_t is_entry
uint16_t value
uint32_t key
} entry

2.30.1

Detailed Description

Individual entry in the four-byte key hash table.

2.30.2

Field Documentation

2.30.2.1

uint64 t rte_fbk_hash_entry::whole_entry

For accessing entire entry.

2.30.2.2

uint16 t rte_fbk_hash_entry::is_entry

Non-zero if entry is active.

2.30.2.3

uint16 t rte_fbk_hash_entry::value

Value returned by lookup.

2.30.2.4

uint32 t rte_fbk_hash_entry::key

Key used to find value.

2.30.2.5

struct { ... } rte_fbk_hash_entry::entry

For accessing each entry part.

2.31

rte fbk hash params Struct Reference

Data Fields
const char name
uint32_t entries
uint32_t entries_per_bucket

Intel Data Plane Development Kit (Intel DPDK)


API Reference
38

November 2012
Reference Number: 326004-001

rte_fbk_hash_table Struct Reference - Intel DPDK

int socket_id
rte_fbk_hash_fn hash_func
uint32_t init_val

2.31.1

Detailed Description

Parameters used when creating four-byte key hash table.

2.31.2

Field Documentation

2.31.2.1

const char rte_fbk_hash_params::name

Name of the hash table.

2.31.2.2

uint32 t rte_fbk_hash_params::entries

Total number of entries.

2.31.2.3

uint32 t rte_fbk_hash_params::entries_per_bucket

Number of entries in a bucket.

2.31.2.4

int rte_fbk_hash_params::socket_id

Socket to allocate memory on.

2.31.2.5 rte_fbk_hash_fn rte_fbk_hash_params::hash_func


The hash function.

2.31.2.6

uint32 t rte_fbk_hash_params::init_val

For initialising hash function.

2.32

rte fbk hash table Struct Reference

Data Fields
TAILQ_ENTRY next

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
39

Intel DPDK - rte_fbk_hash_table Struct Reference

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]

2.32.1

Detailed Description

The four-byte key hash table structure.

2.32.2

Field Documentation

2.32.2.1

TAILQ ENTRY rte_fbk_hash_table::next

Linked list.

2.32.2.2

char rte_fbk_hash_table::name[RTE FBK HASH NAMESIZE]

Name of the hash.

2.32.2.3

uint32 t rte_fbk_hash_table::entries

Total number of entries.

2.32.2.4

uint32 t rte_fbk_hash_table::entries_per_bucket

Number of entries in a bucket.

2.32.2.5

uint32 t rte_fbk_hash_table::used_entries

How many entries are used.

2.32.2.6

uint32 t rte_fbk_hash_table::bucket_mask

To find which bucket the key is in.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
40

November 2012
Reference Number: 326004-001

rte_fdir_conf Struct Reference - Intel DPDK

2.32.2.7

uint32 t rte_fbk_hash_table::bucket_shift

Convert bucket to table offset.

2.32.2.8 rte_fbk_hash_fn rte_fbk_hash_table::hash_func


The hash function.

2.32.2.9

uint32 t rte_fbk_hash_table::init_val

For initialising hash function.

2.32.2.10

union rte_fbk_hash_entry rte_fbk_hash_table::t[0]

A flat table of all buckets.

2.33

rte fdir conf Struct Reference

Data Fields
enum rte_fdir_mode mode
enum rte_fdir_pballoc_type pballoc
enum rte_fdir_status_mode status

2.33.1

Detailed Description

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.

2.33.2

Field Documentation

2.33.2.1

enum rte_fdir_mode rte_fdir_conf::mode

Flow Director mode.

2.33.2.2

enum rte_fdir_pballoc_type rte_fdir_conf::pballoc

Space for FDIR filters.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
41

Intel DPDK - rte_fdir_filter Struct Reference

2.33.2.3

enum rte_fdir_status_mode rte_fdir_conf::status

How to report FDIR hash.

2.34

rte fdir filter Struct Reference

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
enum rte_l4type l4type
enum rte_iptype iptype

2.34.1

Detailed Description

A structure used to define a FDIR packet filter.

2.34.2

Field Documentation

2.34.2.1

uint16 t rte_fdir_filter::flex_bytes

Flex bytes value to match.

2.34.2.2

uint16 t rte_fdir_filter::vlan_id

VLAN ID value to match, 0 otherwise.

2.34.2.3

uint16 t rte_fdir_filter::port_src

Source port to match, 0 otherwise.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
42

November 2012
Reference Number: 326004-001

rte_fdir_masks Struct Reference - Intel DPDK

2.34.2.4

uint16 t rte_fdir_filter::port_dst

Destination port to match, 0 otherwise.

2.34.2.5

uint32 t rte_fdir_filter::ipv4_addr

IPv4 source address to match.


IPv4 destination address to match.

2.34.2.6

uint32 t rte_fdir_filter::ipv6_addr[4]

IPv6 source address to match.


IPv6 destination address to match

2.34.2.7

union { ... } rte_fdir_filter::ip_src

IPv4/IPv6 source address to match (union of above).

2.34.2.8

union { ... } rte_fdir_filter::ip_dst

IPv4/IPv6 destination address to match (union of above).

2.34.2.9

enum rte_l4type rte_fdir_filter::l4type

l4type to match: NONE/UDP/TCP/SCTP.

2.34.2.10

enum rte_iptype rte_fdir_filter::iptype

IP packet type to match: IPv4 or IPv6.

2.35

rte fdir masks Struct Reference

Data Fields

uint8_t only_ip_flow
uint8_t vlan_id
uint8_t vlan_prio
uint8_t flexbytes
uint32_t dst_ipv4_mask
uint32_t src_ipv4_mask

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
43

Intel DPDK - rte_fdir_masks Struct Reference

uint16_t src_ipv6_mask
uint16_t src_port_mask
uint16_t dst_port_mask

2.35.1

Detailed Description

A structure used to configure FDIR masks that are used by the device to match the various fields of RX
packet headers.

2.35.2

Field Documentation

2.35.2.1

uint8 t rte_fdir_masks::only_ip_flow

When set to 1, packet l4type is not relevant in filters, and source and destination port masks must be set to
zero.

2.35.2.2

uint8 t rte_fdir_masks::vlan_id

If set to 1, vlan_id is relevant in filters.

2.35.2.3

uint8 t rte_fdir_masks::vlan_prio

If set to 1, vlan_prio is relevant in filters.

2.35.2.4

uint8 t rte_fdir_masks::flexbytes

If set to 1, flexbytes is relevant in filters.

2.35.2.5

uint32 t rte_fdir_masks::dst_ipv4_mask

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.

2.35.2.6

uint32 t rte_fdir_masks::src_ipv4_mask

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
44

November 2012
Reference Number: 326004-001

rte_hash Struct Reference - Intel DPDK

2.35.2.7

uint16 t rte_fdir_masks::src_ipv6_mask

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.
2.35.2.8

uint16 t rte_fdir_masks::src_port_mask

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.
2.35.2.9

uint16 t rte_fdir_masks::dst_port_mask

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.

2.36

rte hash Struct Reference

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

2.36.1

Detailed Description

A hash table structure.

2.36.2

Field Documentation

2.36.2.1

TAILQ ENTRY rte_hash::next

Next in list.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
45

Intel DPDK - rte_hash Struct Reference

2.36.2.2

char rte_hash::name[RTE HASH NAMESIZE]

Name of the hash.

2.36.2.3

uint32 t rte_hash::entries

Total table entries.

2.36.2.4

uint32 t rte_hash::bucket_entries

Bucket entries.

2.36.2.5

uint32 t rte_hash::key_len

Length of hash key.

2.36.2.6 rte_hash_function rte_hash::hash_func


Function used to calculate hash.

2.36.2.7

uint32 t rte_hash::hash_func_init_val

Init value used by hash_func.

2.36.2.8

uint32 t rte_hash::num_buckets

Number of buckets in table.

2.36.2.9

uint32 t rte_hash::bucket_bitmask

Bitmask for getting bucket index from hash signature.

2.36.2.10 hash_sig_t rte_hash::sig_msb


MSB is always set in valid signatures.

2.36.2.11

uint8 t rte_hash::sig_tbl

Flat array of hash signature buckets.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
46

November 2012
Reference Number: 326004-001

rte_hash_parameters Struct Reference - Intel DPDK

2.36.2.12

uint32 t rte_hash::sig_tbl_bucket_size

Signature buckets may be padded for alignment reasons, and this is the bucket size used by sig_tbl.

2.36.2.13

uint8 t rte_hash::key_tbl

Flat array of key value buckets.

2.36.2.14

uint32 t rte_hash::key_tbl_key_size

Keys may be padded for alignment reasons, and this is the key size used by key_tbl.

2.37

rte hash parameters Struct Reference

Data Fields

const char name


uint32_t entries
uint32_t bucket_entries
uint32_t key_len
rte_hash_function hash_func
uint32_t hash_func_init_val
int socket_id

2.37.1

Detailed Description

Parameters used when creating the hash table. The total table entries and bucket entries must be a power
of 2.

2.37.2

Field Documentation

2.37.2.1

const char rte_hash_parameters::name

Name of the hash.

2.37.2.2

uint32 t rte_hash_parameters::entries

Total hash table entries.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
47

Intel DPDK - rte_intr_conf Struct Reference

2.37.2.3

uint32 t rte_hash_parameters::bucket_entries

Bucket entries.

2.37.2.4

uint32 t rte_hash_parameters::key_len

Length of hash key.

2.37.2.5 rte_hash_function rte_hash_parameters::hash_func


Function used to calculate hash.

2.37.2.6

uint32 t rte_hash_parameters::hash_func_init_val

Init value used by hash_func.

2.37.2.7

int rte_hash_parameters::socket_id

NUMA Socket ID for memory.

2.38

rte intr conf Struct Reference

Data Fields
uint16_t lsc

2.38.1

Detailed Description

A structure used to enable/disable specific device interrupts.

2.38.2

Field Documentation

2.38.2.1

uint16 t rte_intr_conf::lsc

enable/disable lsc interrupt. 0 (default) - disable, 1 enable

Intel Data Plane Development Kit (Intel DPDK)


API Reference
48

November 2012
Reference Number: 326004-001

rte_logs Struct Reference - Intel DPDK

2.39

rte logs Struct Reference

Data Fields
uint32_t type
uint32_t level
FILE file

2.39.1

Detailed Description

The rte_log structure.

2.39.2

Field Documentation

2.39.2.1

uint32 t rte_logs::type

Bitfield with enabled logs.


2.39.2.2

uint32 t rte_logs::level

Log level.
2.39.2.3

FILE rte_logs::file

Pointer to current FILE for logs.

rte lpm Struct Reference

2.40

Data Fields

TAILQ_ENTRY next
char name [RTE_LPM_NAMESIZE]
int mem_location
uint32_t max_rules_per_depth
uint32_t used_rules_at_depth [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]

2.40.1

Detailed Description

LPM structure.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
49

Intel DPDK - rte_lpm_rule Struct Reference

2.40.2

Field Documentation

2.40.2.1

TAILQ ENTRY rte_lpm::next

Next in list.

2.40.2.2

char rte_lpm::name[RTE LPM NAMESIZE]

Name of the lpm.

2.40.2.3

int rte_lpm::mem_location

Location of memory to be allocated.

2.40.2.4

uint32 t rte_lpm::max_rules_per_depth

Max. balanced rules per lpm.

2.40.2.5

uint32 t rte_lpm::used_rules_at_depth[RTE LPM MAX DEPTH]

Rules / depth.

2.40.2.6

struct rte_lpm_tbl24_entry struct rte_lpm_tbl8_entry rte_lpm::tbl8[RTE LPM TBL8 NUM ENTRIES]

LPM tbl24 table.

2.40.2.7

struct rte_lpm_tbl24_entry struct rte_lpm_tbl8_entry struct rte_lpm_rule rte_lpm::rules_tbl[0]

LPM tbl8 table.

2.41

rte lpm rule Struct Reference

Data Fields
uint32_t ip
uint8_t next_hop

2.41.1

Detailed Description

Rule structure.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
50

November 2012
Reference Number: 326004-001

rte_lpm_tbl24_entry Struct Reference - Intel DPDK

2.41.2

Field Documentation

2.41.2.1

uint32 t rte_lpm_rule::ip

Rule IP address.

2.41.2.2

uint8 t rte_lpm_rule::next_hop

Rule next hop.

2.42

rte lpm tbl24 entry Struct Reference

Data Fields
uint8_t valid:1
uint8_t ext_entry:1
uint8_t depth:6

2.42.1

Detailed Description

Tbl24 entry structure.

2.42.2

Field Documentation

2.42.2.1

uint8 t rte_lpm_tbl24_entry::valid

Validation flag.

2.42.2.2

uint8 t rte_lpm_tbl24_entry::ext_entry

External entry.

2.42.2.3

uint8 t rte_lpm_tbl24_entry::depth

Rule depth.

2.43

rte lpm tbl8 entry Struct Reference

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
51

Intel DPDK - rte_mbuf Struct Reference

Data Fields

uint8_t valid:1
uint8_t valid_group:1
uint8_t depth:6
uint8_t next_hop

2.43.1

Detailed Description

Tbl8 entry structure.

2.43.2

Field Documentation

2.43.2.1

uint8 t rte_lpm_tbl8_entry::valid

Validation flag.
2.43.2.2

uint8 t rte_lpm_tbl8_entry::valid_group

Group validation flag.


2.43.2.3

uint8 t rte_lpm_tbl8_entry::depth

Rule depth.
2.43.2.4

uint8 t rte_lpm_tbl8_entry::next_hop

next hop.

2.44

rte mbuf Struct Reference

Data Fields

struct rte_mempool pool


void buf_addr
phys_addr_t buf_physaddr
uint16_t buf_len
union {
rte_atomic16_t refcnt_atomic
uint16_t refcnt
};

Intel Data Plane Development Kit (Intel DPDK)


API Reference
52

November 2012
Reference Number: 326004-001

rte_mbuf Struct Reference - Intel DPDK

uint8_t type
uint8_t reserved
uint16_t ol_flags

2.44.1

Detailed Description

The generic rte_mbuf, containing a packet mbuf or a control mbuf.

2.44.2

Field Documentation

2.44.2.1

struct rte_mempool rte_mbuf::pool

Pool from which mbuf was allocated.

2.44.2.2

void rte_mbuf::buf_addr

Virtual address of segment buffer.

2.44.2.3 phys_addr_t rte_mbuf::buf_physaddr


Physical address of segment buffer.

2.44.2.4

uint16 t rte_mbuf::buf_len

Length of segment buffer.

2.44.2.5 rte_atomic16_t rte_mbuf::refcnt_atomic


Atomically accessed refcnt

2.44.2.6

uint16 t rte_mbuf::refcnt

Non-atomically accessed refcnt

2.44.2.7

union { ... }

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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
53

Intel DPDK - rte_mem_config Struct Reference

2.44.2.8

uint8 t rte_mbuf::type

Type of mbuf.

2.44.2.9

uint8 t rte_mbuf::reserved

Unused field. Required for padding.

2.44.2.10

uint16 t rte_mbuf::ol_flags

Offload features.

2.45

rte mem config Struct Reference

Data Fields

uint32_t nchannel
uint32_t nrank
struct rte_memseg memseg [32,]
struct rte_memzone memzone [512,]
struct rte_tailq_head tailq_head [32,]

2.45.1

Detailed Description

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

2.45.2

Field Documentation

2.45.2.1

uint32 t rte_mem_config::nchannel

Number of channels (0 if unknown).

2.45.2.2

uint32 t rte_mem_config::nrank

Number of ranks (0 if unknown).

2.45.2.3

struct rte_memseg rte_mem_config::memseg[32,]

Physmem descriptors.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
54

November 2012
Reference Number: 326004-001

rte_mempool Struct Reference - Intel DPDK

2.45.2.4

struct rte_memzone rte_mem_config::memzone[512,]

Memzone descriptors.

2.45.2.5

struct rte_tailq_head rte_mem_config::tailq_head[32,]

Tailqs for objects

rte mempool Struct Reference

2.46

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 bulk_default
uint32_t cache_size
uint32_t elt_size
uint32_t header_size
uint32_t trailer_size
unsigned private_data_size
struct rte_mempool_cache local_cache [32,]

2.46.1

Detailed Description

The RTE mempool structure.

2.46.2

Field Documentation

2.46.2.1

TAILQ ENTRY rte_mempool::next

Next in list.

2.46.2.2

char rte_mempool::name[RTE MEMPOOL NAMESIZE]

Name of mempool.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
55

Intel DPDK - rte_mempool Struct Reference

2.46.2.3

struct rte_ring rte_mempool::ring

Ring to store objects.

2.46.2.4 phys_addr_t rte_mempool::phys_addr


Phys. addr. of mempool struct.

2.46.2.5

int rte_mempool::flags

Flags of the mempool.

2.46.2.6

uint32 t rte_mempool::size

Size of the mempool.

2.46.2.7

uint32 t rte_mempool::bulk_default

Default bulk count.

2.46.2.8

uint32 t rte_mempool::cache_size

Size of per-lcore local cache.

2.46.2.9

uint32 t rte_mempool::elt_size

Size of an element.

2.46.2.10

uint32 t rte_mempool::header_size

Size of header (before elt).

2.46.2.11

uint32 t rte_mempool::trailer_size

Size of trailer (after elt).

2.46.2.12

unsigned rte_mempool::private_data_size

Size of private data.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
56

November 2012
Reference Number: 326004-001

rte_mempool_cache Struct Reference - Intel DPDK

2.46.2.13

struct rte_mempool_cache rte_mempool::local_cache[32,]

Per-lcore local cache.

2.47

rte mempool cache Struct Reference

Data Fields
unsigned len
void objs [512,]

2.47.1

Detailed Description

A structure that stores a per-core object cache.

2.47.2

Field Documentation

2.47.2.1

unsigned rte_mempool_cache::len

Cache len
2.47.2.2

void rte_mempool_cache::objs[512,]

Cache objects

2.48

rte memseg Struct Reference

Data Fields

phys_addr_t phys_addr
uint64_t len
uint64_t hugepage_sz
int32_t socket_id
uint32_t nchannel
uint32_t nrank
void addr
uint64_t addr_64

2.48.1

Detailed Description

Physical memory segment descriptor.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
57

Intel DPDK - rte_memzone Struct Reference

2.48.2

Field Documentation

2.48.2.1 phys_addr_t rte_memseg::phys_addr


Start physical address.

2.48.2.2

void rte_memseg::addr

Start virtual address.

2.48.2.3

uint64 t rte_memseg::addr_64

Makes sure addr is always 64 bits

2.48.2.4

uint64 t rte_memseg::len

Length of the segment.

2.48.2.5

uint64 t rte_memseg::hugepage_sz

The pagesize of underlying memory

2.48.2.6

int32 t rte_memseg::socket_id

NUMA socket ID.

2.48.2.7

uint32 t rte_memseg::nchannel

Number of channels.

2.48.2.8

uint32 t rte_memseg::nrank

Number of ranks.

2.49

rte memzone Struct Reference

Data Fields
char name [RTE_MEMZONE_NAMESIZE]
phys_addr_t phys_addr

Intel Data Plane Development Kit (Intel DPDK)


API Reference
58

November 2012
Reference Number: 326004-001

rte_memzone Struct Reference - Intel DPDK

uint64_t len
uint64_t hugepage_sz
int32_t socket_id
uint32_t flags
void addr
uint64_t addr_64

2.49.1

Detailed Description

A structure describing a memzone, which is a contiguous portion of physical memory identified by a name.

2.49.2

Field Documentation

2.49.2.1

char rte_memzone::name[RTE MEMZONE NAMESIZE]

Name of the memory zone.

2.49.2.2 phys_addr_t rte_memzone::phys_addr


Start physical address.

2.49.2.3

void rte_memzone::addr

Start virtual address.

2.49.2.4

uint64 t rte_memzone::addr_64

Makes sure addr is always 64-bits

2.49.2.5

uint64 t rte_memzone::len

Length of the memzone.

2.49.2.6

uint64 t rte_memzone::hugepage_sz

The page size of underlying memory

2.49.2.7

int32 t rte_memzone::socket_id

NUMA socket ID.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
59

Intel DPDK - rte_pci_addr Struct Reference

2.49.2.8

uint32 t rte_memzone::flags

Characteristics of this memzone.

2.50

rte pci addr Struct Reference

Data Fields

uint16_t domain
uint8_t bus
uint8_t devid
uint8_t function

2.50.1

Detailed Description

A structure describing the location of a PCI device.

2.50.2

Field Documentation

2.50.2.1

uint16 t rte_pci_addr::domain

Device domain
2.50.2.2

uint8 t rte_pci_addr::bus

Device bus
2.50.2.3

uint8 t rte_pci_addr::devid

Device ID
2.50.2.4

uint8 t rte_pci_addr::function

Device function.

2.51

rte pci device Struct Reference

Data Fields
TAILQ_ENTRY next

Intel Data Plane Development Kit (Intel DPDK)


API Reference
60

November 2012
Reference Number: 326004-001

rte_pci_driver Struct Reference - Intel DPDK

struct rte_pci_addr addr


struct rte_pci_id id
struct rte_pci_resource mem_resource
struct rte_intr_handle intr_handle

2.51.1

Detailed Description

A structure describing a PCI device.

2.51.2

Field Documentation

2.51.2.1

TAILQ ENTRY rte_pci_device::next

Next probed PCI device.

2.51.2.2

struct rte_pci_addr rte_pci_device::addr

PCI location.

2.51.2.3

struct rte_pci_id rte_pci_device::id

PCI ID.

2.51.2.4

struct rte_pci_resource rte_pci_device::mem_resource

PCI Memory Resource

2.51.2.5

struct rte intr handle rte_pci_device::intr_handle

Interrupt handle

2.52

rte pci driver Struct Reference

Data Fields

TAILQ_ENTRY next
const char name
pci_devinit_t devinit
struct rte_pci_id id_table
uint32_t drv_flags

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
61

Intel DPDK - rte_pci_id Struct Reference

2.52.1

Detailed Description

A structure describing a PCI driver. Device needs igb_uio kernel module

2.52.2

Field Documentation

2.52.2.1

TAILQ ENTRY rte_pci_driver::next

Next in list.

2.52.2.2

const char rte_pci_driver::name

Driver name.

2.52.2.3 pci_devinit_t rte_pci_driver::devinit


Device init. function.

2.52.2.4

struct rte_pci_id rte_pci_driver::id_table

ID table, NULL terminated.

2.52.2.5

uint32 t rte_pci_driver::drv_flags

Flags contolling handling of device.

rte pci id Struct Reference

2.53

Data Fields

uint16_t vendor_id
uint16_t device_id
uint16_t subsystem_vendor_id
uint16_t subsystem_device_id

2.53.1

Detailed Description

A structure describing an ID for a PCI driver. Each driver provides a table of these IDs for each device that
it supports.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
62

November 2012
Reference Number: 326004-001

rte_pci_resource Struct Reference - Intel DPDK

2.53.2

Field Documentation

2.53.2.1

uint16 t rte_pci_id::vendor_id

Vendor ID or PCI_ANY_ID.

2.53.2.2

uint16 t rte_pci_id::device_id

Device ID or PCI_ANY_ID.

2.53.2.3

uint16 t rte_pci_id::subsystem_vendor_id

Subsystem vendor ID or PCI_ANY_ID.

2.53.2.4

uint16 t rte_pci_id::subsystem_device_id

Subsystem device ID or PCI_ANY_ID.

2.54

rte pci resource Struct Reference

Data Fields
uint64_t phys_addr
uint64_t len
void addr

2.54.1

Detailed Description

A structure describing a PCI resource.

2.54.2

Field Documentation

2.54.2.1

uint64 t rte_pci_resource::phys_addr

Physical address, 0 if no resource.

2.54.2.2

uint64 t rte_pci_resource::len

Length of the resource.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
63

Intel DPDK - rte_pktmbuf Struct Reference

2.54.2.3

void rte_pci_resource::addr

Virtual address, NULL when not mapped.

2.55

rte pktmbuf Struct Reference

Data Fields

struct rte_mbuf next


void data
uint16_t data_len
uint8_t nb_segs
uint8_t in_port
uint32_t pkt_len
uint16_t vlan_tci
uint16_t l2_len:7
uint16_t l3_len:9
union {
uint32_t rss
struct {
} fdir
} hash

2.55.1

Detailed Description

A packet message buffer.

2.55.2

Field Documentation

2.55.2.1

struct rte_mbuf rte_pktmbuf::next

Next segment of scattered packet.

2.55.2.2

void rte_pktmbuf::data

Start address of data in segment buffer.

2.55.2.3

uint16 t rte_pktmbuf::data_len

Amount of data in segment buffer.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
64

November 2012
Reference Number: 326004-001

rte_pktmbuf_pool_private Struct Reference - Intel DPDK

2.55.2.4

uint8 t rte_pktmbuf::nb_segs

Number of segments.

2.55.2.5

uint8 t rte_pktmbuf::in_port

Input port.

2.55.2.6

uint32 t rte_pktmbuf::pkt_len

Total pkt len: sum of all segment data_len.

2.55.2.7

uint16 t rte_pktmbuf::vlan_tci

VLAN Tag Control Identifier (CPU order).

2.55.2.8

uint16 t rte_pktmbuf::l2_len

L2 (MAC) Header Length.

2.55.2.9

uint16 t rte_pktmbuf::l3_len

L3 (IP) Header Length.

2.55.2.10

uint32 t rte_pktmbuf::rss

RSS hash result if RSS enabled

2.55.2.11

struct { ... } rte_pktmbuf::fdir

Filter identifier if FDIR enabled

2.55.2.12

union { ... } rte pktmbuf::hash

hash information

2.56

rte pktmbuf pool private Struct Reference

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
65

Intel DPDK - rte_ring Struct Reference

Data Fields
uint16_t mbuf_data_room_size

2.56.1

Detailed Description

Private data in case of pktmbuf pool.


A structure that contains some pktmbuf_pool-specific data that are appended after the mempool structure
(in private data).

2.56.2

Field Documentation

2.56.2.1

uint16 t rte_pktmbuf_pool_private::mbuf_data_room_size

Size of data space in each mbuf.

2.57

rte ring Struct Reference

Data Structures
struct cons
struct prod

Data Fields
TAILQ_ENTRY next
char name [RTE_RING_NAMESIZE]
int flags

2.57.1

Detailed Description

An RTE ring structure.


The producer and the consumer have a head and a tail index. The particularity of these index is that they
are not between 0 and size(ring). These indexes are between 0 and 2 32, and we mask their value when
we access the ring[] field. Thanks to this assumption, we can do subtractions between 2 index values in a
modulo-32bit base: thats why the overflow of the indexes is not a problem.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
66

November 2012
Reference Number: 326004-001

rte_rwlock_t Struct Reference - Intel DPDK

2.57.2

Field Documentation

2.57.2.1

TAILQ ENTRY rte_ring::next

Next in list.

2.57.2.2

char rte_ring::name[RTE RING NAMESIZE]

Name of the ring.

2.57.2.3

int rte_ring::flags

Flags supplied at creation.

2.58

rte rwlock t Struct Reference

Data Fields
volatile int32_t cnt

2.58.1

Detailed Description

The rte_rwlock_t type.


cnt is -1 when write lock is held, and > 0 when read locks are held.

2.58.2

Field Documentation

2.58.2.1

volatile int32 t rte_rwlock_t::cnt

-1 when W lock held, > 0 when R locks held.

2.59

rte spinlock recursive t Struct Reference

Data Fields
rte_spinlock_t sl
volatile int user
volatile int count

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
67

Intel DPDK - rte_spinlock_t Struct Reference

2.59.1

Detailed Description

The rte_spinlock_recursive_t type.

2.59.2

Field Documentation

2.59.2.1 rte_spinlock_t rte_spinlock_recursive_t::sl


the actual spinlock
2.59.2.2

volatile int rte_spinlock_recursive_t::user

core id using lock, -1 for unused


2.59.2.3

volatile int rte_spinlock_recursive_t::count

count of time this lock has been called

2.60

rte spinlock t Struct Reference

Data Fields
volatile int locked

2.60.1

Detailed Description

The rte_spinlock_t type.

2.60.2

Field Documentation

2.60.2.1

volatile int rte_spinlock_t::locked

lock status 0 = unlocked, 1 = locked

2.61

rte tailq head Struct Reference

Data Fields
struct rte_dummy_head tailq_head
char qname [RTE_TAILQ_NAMESIZE]

Intel Data Plane Development Kit (Intel DPDK)


API Reference
68

November 2012
Reference Number: 326004-001

rte_timer Struct Reference - Intel DPDK

2.61.1

Detailed Description

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.

2.61.2

Field Documentation

2.61.2.1

struct rte dummy head rte_tailq_head::tailq_head

NOTE: must be first element

2.61.2.2

char rte_tailq_head::qname[RTE TAILQ NAMESIZE]

Queue name

2.62

rte timer Struct Reference

Public Member Functions


LIST_ENTRY (rte_timer) next

Data Fields

union rte_timer_status status


uint64_t period
uint64_t expire
rte_timer_cb_t f
void arg

2.62.1

Detailed Description

A structure describing a timer in RTE.

2.62.2

Member Function Documentation

2.62.2.1

rte timer::LIST ENTRY ( rte_timer )

Next and prev in list.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
69

Intel DPDK - rte_timer_status Union Reference

2.62.3

Field Documentation

2.62.3.1

union rte_timer_status rte_timer::status

Status of timer.

2.62.3.2

uint64 t rte_timer::period

Period of timer (0 if not periodic).

2.62.3.3

uint64 t rte_timer::expire

Time when timer expire.

2.62.3.4 rte_timer_cb_t rte_timer::f


Callback function.

2.62.3.5

void rte_timer::arg

Argument to callback function.

2.63

rte timer status Union Reference

Data Fields
uint32_t u32
uint16_t state
int16_t owner

2.63.1

Detailed Description

Timer status: A union of the state (stopped, pending, running, config) and an owner (the id of the lcore that
owns the timer).

2.63.2

Field Documentation

2.63.2.1

uint16 t rte_timer_status::state

Stop, pending, running, config.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
70

November 2012
Reference Number: 326004-001

sctp_hdr Struct Reference - Intel DPDK

2.63.2.2

int16 t rte_timer_status::owner

The lcore that owns the timer.

2.63.2.3

uint32 t rte_timer_status::u32

To atomic-set status + owner.

2.64

sctp hdr Struct Reference

Data Fields

uint16_t src_port
uint16_t dst_port
uint32_t tag
uint32_t cksum

2.64.1

Detailed Description

SCTP Header

2.64.2

Field Documentation

2.64.2.1

uint16 t sctp_hdr::src_port

Source port.

2.64.2.2

uint16 t sctp_hdr::dst_port

Destin port.

2.64.2.3

uint32 t sctp_hdr::tag

Validation tag.

2.64.2.4

uint32 t sctp_hdr::cksum

Checksum.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
71

Intel DPDK - tcp_hdr Struct Reference

2.65

tcp hdr Struct Reference

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

2.65.1

Detailed Description

TCP Header

2.65.2

Field Documentation

2.65.2.1

uint16 t tcp_hdr::src_port

TCP source port.

2.65.2.2

uint16 t tcp_hdr::dst_port

TCP destination port.

2.65.2.3

uint32 t tcp_hdr::sent_seq

TX data sequence number.

2.65.2.4

uint32 t tcp_hdr::recv_ack

RX data acknowledgement sequence number.

2.65.2.5

uint8 t tcp_hdr::data_off

Data offset.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
72

November 2012
Reference Number: 326004-001

udp_hdr Struct Reference - Intel DPDK

2.65.2.6

uint8 t tcp_hdr::tcp_flags

TCP flags

2.65.2.7

uint16 t tcp_hdr::rx_win

RX flow control window.

2.65.2.8

uint16 t tcp_hdr::cksum

TCP checksum.

2.65.2.9

uint16 t tcp_hdr::tcp_urp

TCP urgent pointer, if any.

udp hdr Struct Reference

2.66

Data Fields

uint16_t src_port
uint16_t dst_port
uint16_t dgram_len
uint16_t dgram_cksum

2.66.1

Detailed Description

UDP Header

2.66.2

Field Documentation

2.66.2.1

uint16 t udp_hdr::src_port

UDP source port.

2.66.2.2

uint16 t udp_hdr::dst_port

UDP destination port.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
73

Intel DPDK - vlan_hdr Struct Reference

2.66.2.3

uint16 t udp_hdr::dgram_len

UDP datagram length

2.66.2.4

uint16 t udp_hdr::dgram_cksum

UDP datagram checksum

2.67

vlan hdr Struct Reference

Data Fields
uint16_t vlan_tci
uint16_t eth_proto

2.67.1

Detailed Description

Ethernet VLAN Header. Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type of the
encapsulated frame.

2.67.2

Field Documentation

2.67.2.1

uint16 t vlan_hdr::vlan_tci

Priority (3) + CFI (1) + Identifier Code (12)

2.67.2.2

uint16 t vlan_hdr::eth_proto

Ethernet type of encapsulated frame.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
74

November 2012
Reference Number: 326004-001

File Documentation- Intel DPDK

Chapter 3

File Documentation
3.1

rte alarm.h File Reference

Typedefs
typedef void( rte_eal_alarm_callback )(void arg)

Functions
int rte_eal_alarm_set (uint64_t us, rte_eal_alarm_callback cb, void cb_arg)
int rte_eal_alarm_cancel (rte_eal_alarm_callback cb_fn, void cb_arg)

3.1.1

Detailed Description

Alarm functions
Simple alarm-clock functionality supplied by eal. Does not require hpet support.

3.1.2

Typedef Documentation

3.1.2.1

typedef void( rte_eal_alarm_callback)(void arg)

Signature of callback back function called when an alarm goes off.

3.1.3

Function Documentation

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
75

Intel DPDK - rte_atomic.h File Reference

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 )

Function to cancel an alarm callback which has been registered before.


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

3.2

rte atomic.h File Reference

Data Structures
struct rte_atomic16_t
struct rte_atomic32_t
struct rte_atomic64_t

Defines
#define rte_mb()
#define rte_wmb()
#define rte_rmb()

Intel Data Plane Development Kit (Intel DPDK)


API Reference
76

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

#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)
static int64_t rte_atomic64_sub_return (rte_atomic64_t v, int64_t dec)
static int rte_atomic64_inc_and_test (rte_atomic64_t v)
static int rte_atomic64_dec_and_test (rte_atomic64_t v)
static int rte_atomic64_test_and_set (rte_atomic64_t v)
static void rte_atomic64_clear (rte_atomic64_t v)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
77

Intel DPDK - rte_atomic.h File Reference

3.2.1

Detailed Description

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

3.2.2

Define Documentation

3.2.2.1

#define rte mb( )

General memory barrier.


Guarantees that the LOAD and STORE operations generated before the barrier occur before the LOAD and
STORE operations generated after.

3.2.2.2

#define rte wmb( )

Write memory barrier.


Guarantees that the STORE operations generated before the barrier occur before the STORE operations
generated after.

3.2.2.3

#define rte rmb( )

Read memory barrier.


Guarantees that the LOAD operations generated before the barrier occur before the LOAD operations
generated after.

3.2.2.4

#define RTE ATOMIC16 INIT( val )

Static initializer for an atomic counter.

3.2.2.5

#define RTE ATOMIC32 INIT( val )

Static initializer for an atomic counter.

3.2.2.6

#define RTE ATOMIC64 INIT( val )

Static initializer for an atomic counter.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
78

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

3.2.3

Function Documentation

3.2.3.1

static int rte atomic16 cmpset ( volatile uint16 t dst, uint16 t exp, uint16 t src ) [static]

Atomic compare and set.


(atomic) equivalent to: if (dst == exp) dst = src (all 16-bit words)
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.

static void rte atomic16 init ( rte_atomic16_t v ) [static]

3.2.3.2

Initialize an atomic counter.


Parameters
v A pointer to the atomic counter.

static int16 t rte atomic16 read ( const rte_atomic16_t v ) [static]

3.2.3.3

Atomically read a 16-bit value from a 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]

Atomically set a counter to a 16-bit value.


Parameters
v A pointer to the atomic counter.
new_value The new value for the counter.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
79

Intel DPDK - rte_atomic.h File Reference

3.2.3.5

static void rte atomic16 add ( rte_atomic16_t v, int16 t inc ) [static]

Atomically add a 16-bit value to an atomic counter.


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]

Atomically subtract a 16-bit value from an atomic counter.


Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.

3.2.3.7

static void rte atomic16 inc ( rte_atomic16_t v ) [static]

Atomically increment a counter by one.


Parameters
v A pointer to the atomic counter.

3.2.3.8

static void rte atomic16 dec ( rte_atomic16_t v ) [static]

Atomically decrement a counter by one.


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]

Atomically add a 16-bit value to a counter and return the result.


Atomically adds the 16-bits value (inc) to the atomic counter (v) and returns the value of v after addition.
Parameters
v A pointer to the atomic counter.
inc The value to be added to the counter.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
80

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

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]

Atomically increment a 16-bit counter by one and test.


Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.
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]

Atomically decrement a 16-bit counter by one and test.


Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.
Parameters
v A pointer to the atomic counter.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
81

Intel DPDK - rte_atomic.h File Reference

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]

Atomically test and set a 16-bit atomic counter.


If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1
(success).
Parameters
v A pointer to the atomic counter.

Returns
0 if failed; else 1, success.

3.2.3.14

static void rte atomic16 clear ( rte_atomic16_t v ) [static]

Atomically set a 16-bit counter to 0.


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]

Atomic compare and set.


(atomic) equivalent to: if (dst == exp) dst = src (all 32-bit words)
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
82

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

3.2.3.16

static void rte atomic32 init ( rte_atomic32_t v ) [static]

Initialize an atomic counter.


Parameters
v A pointer to the atomic counter.

3.2.3.17

static int32 t rte atomic32 read ( const rte_atomic32_t v ) [static]

Atomically read a 32-bit value from a 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]

Atomically set a counter to a 32-bit value.


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]

Atomically add a 32-bit value to an atomic counter.


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]

Atomically subtract a 32-bit value from an atomic counter.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
83

Intel DPDK - rte_atomic.h File Reference

Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.

3.2.3.21

static void rte atomic32 inc ( rte_atomic32_t v ) [static]

Atomically increment a counter by one.


Parameters
v A pointer to the atomic counter.

3.2.3.22

static void rte atomic32 dec ( rte_atomic32_t v ) [static]

Atomically decrement a counter by one.


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]

Atomically add a 32-bit value to a counter and return the result.


Atomically adds the 32-bits value (inc) to the atomic counter (v) and returns the value of v after addition.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
84

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

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]

Atomically increment a 32-bit counter by one and test.


Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.
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]

Atomically decrement a 32-bit counter by one and test.


Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.
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]

Atomically test and set a 32-bit atomic counter.


If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1
(success).

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
85

Intel DPDK - rte_atomic.h File Reference

Parameters
v A pointer to the atomic counter.

Returns
0 if failed; else 1, success.

3.2.3.28

static void rte atomic32 clear ( rte_atomic32_t v ) [static]

Atomically set a 32-bit counter to 0.


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.

3.2.3.30

static void rte atomic64 init ( rte_atomic64_t v ) [static]

Initialize the atomic counter.


Parameters
v A pointer to the atomic counter.

3.2.3.31

static int64 t rte atomic64 read ( rte_atomic64_t v ) [static]

Atomically read a 64-bit counter.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
86

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

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]

Atomically set a 64-bit counter.


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]

Atomically add a 64-bit value to a counter.


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]

Atomically subtract a 64-bit value from a counter.


Parameters
v A pointer to the atomic counter.
dec The value to be subtracted from the counter.

3.2.3.35

static void rte atomic64 inc ( rte_atomic64_t v ) [static]

Atomically increment a 64-bit counter by one and test.


Parameters
v A pointer to the atomic counter.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
87

Intel DPDK - rte_atomic.h File Reference

3.2.3.36

static void rte atomic64 dec ( rte_atomic64_t v ) [static]

Atomically decrement a 64-bit counter by one and test.


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]

Add a 64-bit value to an atomic counter and return the result.


Atomically adds the 64-bit value (inc) to the atomic counter (v) and returns the value of v after the addition.
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]

Atomically increment a 64-bit counter by one and test.


Atomically increments the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
88

November 2012
Reference Number: 326004-001

rte_atomic.h File Reference - Intel DPDK

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]

Atomically decrement a 64-bit counter by one and test.


Atomically decrements the atomic counter (v) by one and returns true if the result is 0, or false in all other
cases.
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]

Atomically test and set a 64-bit atomic counter.


If the counter value is already set, return 0 (failed). Otherwise, set the counter value to 1 and return 1
(success).
Parameters
v A pointer to the atomic counter.

Returns
0 if failed; else 1, success.

3.2.3.42

static void rte atomic64 clear ( rte_atomic64_t v ) [static]

Atomically set a 64-bit counter to 0.


Parameters
v A pointer to the atomic counter.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
89

Intel DPDK - rte_branch_prediction.h File Reference

3.3

rte branch prediction.h File Reference

Defines
#define likely(x)
#define unlikely(x)

3.3.1

Detailed Description

Branch Prediction Helpers in RTE

3.3.2

Define Documentation

3.3.2.1

#define likely( x )

Check if a branch is likely to be taken.


This compiler builtin allows the developer to indicate if a branch is likely to be taken. Example:
if (likely(x > 1)) do_stuff();

3.3.2.2

#define unlikely( x )

Check if a branch is unlikely to be taken.


This compiler builtin allows the developer to indicate if a branch is unlikely to be taken. Example:
if (unlikely(x < 1)) do_stuff();

rte byteorder.h File Reference

3.4

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)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
90

November 2012
Reference Number: 326004-001

rte_byteorder.h File Reference - Intel DPDK

#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)

3.4.1

Detailed Description

Byte Swap Operations


This file defines a generic API for byte swap operations. Part of the implementation is architecture-specific.

3.4.2

Define Documentation

3.4.2.1

#define rte bswap16( x )

Swap bytes in a 16-bit value.

3.4.2.2

#define rte bswap32( x )

Swap bytes in a 32-bit value.

3.4.2.3

#define rte bswap64( x )

Swap bytes in a 64-bit value.

3.4.2.4

#define rte cpu to le 16( x )

Convert a 16-bit value from CPU order to little endian.

3.4.2.5

#define rte cpu to le 32( x )

Convert a 32-bit value from CPU order to little endian.

3.4.2.6

#define rte cpu to le 64( x )

Convert a 64-bit value from CPU order to little endian.

3.4.2.7

#define rte cpu to be 16( x )

Convert a 16-bit value from CPU order to big endian.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
91

Intel DPDK - rte_common.h File Reference

3.4.2.8

#define rte cpu to be 32( x )

Convert a 32-bit value from CPU order to big endian.

3.4.2.9

#define rte cpu to be 64( x )

Convert a 64-bit value from CPU order to big endian.

3.4.2.10

#define rte le to cpu 16( x )

Convert a 16-bit value from little endian to CPU order.

3.4.2.11

#define rte le to cpu 32( x )

Convert a 32-bit value from little endian to CPU order.

#define rte le to cpu 64( x )

3.4.2.12

Convert a 64-bit value from little endian to CPU order.

3.4.2.13

#define rte be to cpu 16( x )

Convert a 16-bit value from big endian to CPU order.

3.4.2.14

#define rte be to cpu 32( x )

Convert a 32-bit value from big endian to CPU order.

3.4.2.15

#define rte be to cpu 64( x )

Convert a 64-bit value from big endian to CPU order.

3.5

rte common.h File Reference

Defines

#define __rte_unused
#define RTE_SET_USED(x)
#define RTE_PTR_ADD(ptr, x)
#define RTE_PTR_SUB(ptr, x)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
92

November 2012
Reference Number: 326004-001

rte_common.h File Reference - Intel DPDK

#define RTE_PTR_DIFF(ptr1, ptr2)


#define RTE_ALIGN_FLOOR(ptr, align)
#define RTE_ALIGN_CEIL(ptr, align)
#define RTE_ALIGN(ptr, 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)

Functions

static uintptr_t rte_align_floor_int (uintptr_t ptr, uintptr_t align)


static int rte_is_aligned (void ptr, unsigned align)
static int rte_is_power_of_2 (uint32_t n)
static uint32_t rte_align32pow2 (uint32_t x)
static void rte_pause (void)
static uint64_t rte_str_to_size (const char str)
void rte_exit (int exit_code, const char format,...)

3.5.1

Detailed Description

Generic, commonly-used macro and inline function definitions for Intel DPDK.

3.5.2

Define Documentation

3.5.2.1

#define rte unused

short definition to mark a function parameter unused

3.5.2.2

#define RTE SET USED( x )

definition to mark a variable or function parameter as used so as to avoid a compiler warning

3.5.2.3

#define RTE PTR ADD( ptr, x )

add a byte-value offset from a pointer

3.5.2.4

#define RTE PTR SUB( ptr, x )

subtract a byte-value offset from a pointer

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
93

Intel DPDK - rte_common.h File Reference

3.5.2.5

#define RTE PTR DIFF( ptr1, ptr2 )

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.
3.5.2.6

#define RTE ALIGN FLOOR( ptr, align )

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.
3.5.2.7

#define RTE ALIGN CEIL( ptr, align )

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.
3.5.2.8

#define RTE ALIGN( ptr, align )

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_ALIGN_CEIL
3.5.2.9

#define RTE BUILD BUG ON( condition )

Triggers an error at compilation time if the condition is true.


3.5.2.10

#define RTE MIN( a, b )

Macro to return the minimum of two numbers


3.5.2.11

#define RTE MAX( a, b )

Macro to return the maximum of two numbers


3.5.2.12

#define offsetof( TYPE, MEMBER )

Return the offset of a field in a structure.


3.5.2.13

#define RTE STR( x )

Take a macro value and get a string version of it

Intel Data Plane Development Kit (Intel DPDK)


API Reference
94

November 2012
Reference Number: 326004-001

rte_common.h File Reference - Intel DPDK

3.5.3

Function Documentation

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_ALIGN_FLOOR, RTE_ALIGN_CEIL, RTE_ALIGN, RTE_PTR_ALIGN_FLOOR, RTE_PTR_ALIGN_CEL, RTE_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]

Checks if a pointer is aligned to a given power-of-two value


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

3.5.3.3

static int rte is power of 2 ( uint32 t n ) [static]

Returns true if n is a power of 2


Parameters
n Number to check

Returns
1 if true, 0 otherwise

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
95

Intel DPDK - rte_common.h File Reference

3.5.3.4

static uint32 t rte align32pow2 ( uint32 t x ) [static]

Aligns input parameter to the next power of 2


Parameters
x The integer value to algin

Returns
Input parameter aligned to the next power of 2

3.5.3.5

static void rte pause ( void ) [static]

PAUSE instruction for tight loops (avoid busy waiting)

3.5.3.6

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.7

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
96

November 2012
Reference Number: 326004-001

rte_cpuflags.h File Reference - Intel DPDK

3.6

rte cpuflags.h File Reference

Enumerations
enum rte_cpu_flag_t { RTE_CPUFLAG_SSE3, RTE_CPUFLAG_PCLMULQDQ, RTE_CPUFLAG_DTES64, RTE_CPUFLAG_MONITOR, RTE_CPUFLAG_DS_CPL, RTE_CPUFLAG_VMX, RTE_CPUFLAG_SMX, RTE_CPUFLAG_EIST, RTE_CPUFLAG_TM2, RTE_CPUFLAG_SSSE3, RTE_CPUFLAG_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_CPUFLAG_POPCNT, RTE_CPUFLAG_TSC_DEADLINE, RTE_CPUFLAG_AES, RTE_CPUFLAG_XSAVE,
RTE_CPUFLAG_OSXSAVE, RTE_CPUFLAG_AVX, RTE_CPUFLAG_F16C, RTE_CPUFLAG_RDRAND, 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_CPUFLAG_PGE, RTE_CPUFLAG_MCA, RTE_CPUFLAG_CMOV, RTE_CPUFLAG_PAT, RTE_CPUFLAG_PSE36, RTE_CPUFLAG_PSN, RTE_CPUFLAG_CLFSH, RTE_CPUFLAG_DS, RTE_CPUFLAG_ACPI, RTE_CPUFLAG_MMX, RTE_CPUFLAG_FXSR, RTE_CPUFLAG_SSE, RTE_CPUFLAG_SSE2, RTE_CPUFLAG_SS, RTE_CPUFLAG_HTT, RTE_CPUFLAG_TM, RTE_CPUFLAG_PBE,
RTE_CPUFLAG_DIGTEMP, RTE_CPUFLAG_TRBOBST, RTE_CPUFLAG_ARAT, RTE_CPUFLAG_PLN, RTE_CPUFLAG_ECMD, RTE_CPUFLAG_PTM, RTE_CPUFLAG_MPERF_APERF_MSR,
RTE_CPUFLAG_ACNT2, RTE_CPUFLAG_ENERGY_EFF, RTE_CPUFLAG_FSGSBASE, RTE_CPUFLAG_BMI1, RTE_CPUFLAG_AVX2, RTE_CPUFLAG_SMEP, RTE_CPUFLAG_BMI2, RTE_CPUFLAG_ERMS, RTE_CPUFLAG_INVPCID, RTE_CPUFLAG_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)

3.6.1

Detailed Description

Simple API to determine available CPU features at runtime.

3.6.2

Enumeration Type Documentation

3.6.2.1

enum rte_cpu_flag_t

Enumeration of all CPU features supported


Enumerator:
RTE_CPUFLAG_SSE3 SSE3
RTE_CPUFLAG_PCLMULQDQ PCLMULQDQ

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
97

Intel DPDK - rte_cpuflags.h File Reference

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

Intel Data Plane Development Kit (Intel DPDK)


API Reference
98

November 2012
Reference Number: 326004-001

rte_cpuflags.h File Reference - Intel DPDK

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_AVX2 AVX2
RTE_CPUFLAG_SMEP SMEP
RTE_CPUFLAG_BMI2 BMI2
RTE_CPUFLAG_ERMS ERMS
RTE_CPUFLAG_INVPCID INVPCID
RTE_CPUFLAG_LAHF_SAHF LAHF_SAHF
RTE_CPUFLAG_LZCNT LZCNT
RTE_CPUFLAG_SYSCALL SYSCALL
RTE_CPUFLAG_XD XD

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
99

Intel DPDK - rte_cycles.h File Reference

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

Function Documentation

3.6.3.1

int rte cpu get flag enabled ( enum rte_cpu_flag_t flag )

Function for checking a CPU flag availability


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

3.7

rte cycles.h File Reference

Functions

static uint64_t rte_rdtsc (void)


uint64_t rte_get_hpet_cycles (void)
uint64_t rte_get_hpet_hz (void)
void rte_delay_us (unsigned us)
static void rte_delay_ms (unsigned ms)

3.7.1

Detailed Description

Simple Time Reference Functions (Cycles and HPET).

3.7.2

Function Documentation

3.7.2.1

static uint64 t rte rdtsc ( void ) [static]

Read the TSC register.


Returns
The TSC for this lcore.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
100

November 2012
Reference Number: 326004-001

rte_debug.h File Reference - Intel DPDK

3.7.2.2

uint64 t rte get hpet cycles ( void )

Return the number of HPET cycles since boot


This counter is global for all execution units. The number of cycles in one second can be retrived using
rte_get_hpet_hz().
Returns
the number of cycles

3.7.2.3

uint64 t rte get hpet hz ( void )

Get the number of cycles in one second.


Returns
The number of cycles in one second.

3.7.2.4

void rte delay us ( unsigned us )

Wait at least us microseconds.


Parameters
us The number of microseconds to wait.

3.7.2.5

static void rte delay ms ( unsigned ms ) [static]

Wait at least ms milliseconds.


Parameters
ms The number of milliseconds to wait.

3.8

rte debug.h File Reference

Defines
#define rte_panic(format, args...)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
101

Intel DPDK - rte_eal.h File Reference

Functions
void rte_dump_stack (void)
void rte_dump_registers (void)

3.8.1

Detailed Description

Debug Functions in RTE


This file defines a generic API for debug operations. Part of the implementation is architecture-specific.

3.8.2

Define Documentation

3.8.2.1

#define rte panic( format, args... )

Provide notification of a critical non-recoverable error and terminate execution abnormally.


Display the format string and its expanded arguments (printf-like).
In a linuxapp environment, this function dumps the stack and calls abort() resulting in a core dump if enabled.
The function never returns.
Parameters
format The format string
args The variable list of arguments.

3.8.3

Function Documentation

3.8.3.1

void rte dump stack ( void )

Dump the stack of the calling core to the console.

3.8.3.2

void rte dump registers ( void )

Dump the registers of the calling core to the console.


Note: Not implemented in a userapp environment; use gdb instead.

3.9

rte eal.h File Reference

Data Structures
struct rte_mem_config

Intel Data Plane Development Kit (Intel DPDK)


API Reference
102

November 2012
Reference Number: 326004-001

rte_eal.h File Reference - Intel DPDK

struct rte_config

Defines
#define RTE_VERSION
#define RTE_MAGIC

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)

3.9.1

Detailed Description

EAL Configuration API

3.9.2

Define Documentation

3.9.2.1

#define RTE VERSION

The version of the RTE configuration structure.

3.9.2.2

#define RTE MAGIC

Magic number written by the main partition when ready.

3.9.3

Enumeration Type Documentation

3.9.3.1

enum rte_lcore_role_t

The lcore role (used in RTE or not).

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
103

Intel DPDK - rte_eal.h File Reference

3.9.3.2

enum rte_proc_type_t

The type of process in a linuxapp, multi-process setup

3.9.4

Function Documentation

3.9.4.1

struct rte_config rte eal get configuration ( void ) [read]

Get the global configuration structure.


Returns
A pointer to the global configuration structure.

3.9.4.2

enum rte_lcore_role_t rte eal lcore role ( unsigned lcore id )

Get a lcores role.


Parameters
lcore_id The identifier of the lcore.
Returns
The role of the lcore.

3.9.4.3

enum rte_proc_type_t rte eal process type ( void )

Get the process type in a multi-process setup


Returns
The process type

3.9.4.4

int rte eal init ( int argc, char argv )

Initialize the Environment Abstraction Layer (EAL).


This function is to be executed on the MASTER lcore only, as soon as possible in the applications main()
function.
The function finishes the initialization process that was started during boot (in case of baremetal) or before
main() is called (in case of linuxapp). It puts the SLAVE lcores in the WAIT state.
When the multi-partition feature is supported, depending on the configuration (if CONFIG_RTE_EAL_MAIN_PARTITION is disabled), this function waits to ensure that the magic number is set before returning. See
also the rte_eal_get_configuration() function. Note: This behavior may change in the future.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
104

November 2012
Reference Number: 326004-001

rte_errno.h File Reference - Intel DPDK

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.10

rte errno.h File Reference

Defines
#define rte_errno
#define __ELASTERROR

Enumerations
enum { RTE_MIN_ERRNO, E_RTE_SECONDARY, E_RTE_NO_CONFIG, E_RTE_NO_TAILQ, RTE_MAX_ERRNO }

Functions
RTE_DECLARE_PER_LCORE (int, _rte_errno)
const char rte_strerror (int errnum)

3.10.1

Detailed Description

API for error cause tracking

3.10.2

Define Documentation

3.10.2.1

#define 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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
105

Intel DPDK - rte_ethdev.h File Reference

3.10.2.2

#define ELASTERROR

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

3.10.3

Enumeration Type Documentation

3.10.3.1

anonymous enum

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

3.10.4

Function Documentation

3.10.4.1

RTE DECLARE PER LCORE ( int , rte errno )

Per core error number.

3.10.4.2

const char rte strerror ( int errnum )

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.

3.11

rte ethdev.h File Reference

Data Structures
struct rte_eth_stats

Intel Data Plane Development Kit (Intel DPDK)


API Reference
106

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

struct rte_eth_link
struct rte_eth_thresh
struct rte_eth_rxmode
struct rte_eth_rss_conf
struct rte_eth_vmdq_dcb_conf
struct rte_eth_txmode
struct rte_eth_rxconf
struct rte_eth_txconf
struct rte_eth_fc_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_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_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 RTE_LIBRTE_82576_PMD
#define RTE_LIBRTE_82599_PMD

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
107

Intel DPDK - rte_ethdev.h File Reference

Typedefs

typedef int( eth_dev_configure_t )(struct rte_eth_dev dev, uint16_t nb_rx_q, uint16_t nb_tx_q)
typedef int( eth_dev_start_t )(struct rte_eth_dev dev)
typedef void( eth_dev_stop_t )(struct rte_eth_dev dev)
typedef void( eth_dev_close_t )(struct rte_eth_dev dev)
typedef void( eth_promiscuous_enable_t )(struct rte_eth_dev dev)
typedef void( eth_promiscuous_disable_t )(struct rte_eth_dev dev)
typedef void( eth_allmulticast_enable_t )(struct rte_eth_dev dev)
typedef void( eth_allmulticast_disable_t )(struct rte_eth_dev dev)
typedef int( eth_link_update_t )(struct rte_eth_dev dev, int wait_to_complete)
typedef void( eth_stats_get_t )(struct rte_eth_dev dev, struct rte_eth_stats igb_stats)
typedef void( eth_stats_reset_t )(struct rte_eth_dev dev)
typedef void( eth_dev_infos_get_t )(struct rte_eth_dev dev, struct rte_eth_dev_info dev_info)
typedef int( eth_rx_queue_setup_t )(struct rte_eth_dev dev, 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)
typedef int( eth_tx_queue_setup_t )(struct rte_eth_dev dev, uint16_t tx_queue_id, uint16_t nb_tx_desc, unsigned int socket_id, const struct rte_eth_txconf tx_conf)
typedef void( vlan_filter_set_t )(struct rte_eth_dev dev, uint16_t vlan_id, int on)
typedef uint16_t( eth_rx_burst_t )(struct igb_rx_queue rxq, struct rte_mbuf rx_pkts, uint16_t nb_pkts)
typedef uint16_t( eth_tx_burst_t )(struct igb_tx_queue txq, struct rte_mbuf tx_pkts, uint16_t nb_pkts)
typedef int( fdir_add_signature_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr, uint8_t
rx_queue)
typedef int( fdir_update_signature_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr,
uint8_t rx_queue)
typedef int( fdir_remove_signature_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr)
typedef void( fdir_infos_get_t )(struct rte_eth_dev dev, struct rte_eth_fdir fdir)
typedef int( fdir_add_perfect_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr, uint16_t
soft_id, uint8_t rx_queue, uint8_t drop)
typedef int( fdir_update_perfect_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr, uint16_t soft_id, uint8_t rx_queue, uint8_t drop)
typedef int( fdir_remove_perfect_filter_t )(struct rte_eth_dev dev, struct rte_fdir_filter fdir_ftr, uint16_t soft_id)
typedef int( fdir_set_masks_t )(struct rte_eth_dev dev, struct rte_fdir_masks fdir_masks)
typedef int( flow_ctrl_set_t )(struct rte_eth_dev dev, struct rte_eth_fc_conf fc_conf)
typedef int( eth_dev_led_on_t )(struct rte_eth_dev dev)
typedef int( eth_dev_led_off_t )(struct rte_eth_dev dev)
typedef void( eth_mac_addr_remove_t )(struct rte_eth_dev dev, uint32_t index)
typedef void( eth_mac_addr_add_t )(struct rte_eth_dev dev, struct ether_addr mac_addr, uint32_t
index, uint32_t vmdq)
typedef int( eth_dev_init_t )(struct eth_driver eth_drv, struct rte_eth_dev eth_dev)
typedef void( rte_eth_dev_cb_fn )(uint8_t port_id, enum rte_eth_event_type event, void cb_arg)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
108

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

Enumerations
enum rte_eth_rx_mq_mode { ETH_RSS, ETH_VMDQ_DCB }
enum rte_eth_nb_pools { ETH_16_POOLS, ETH_32_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_MODE_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_TCP, 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

TAILQ_HEAD (rte_eth_dev_cb_list, rte_eth_dev_callback)


uint8_t rte_eth_dev_count (void)
void rte_eth_driver_register (struct eth_driver eth_drv)
int rte_igb_pmd_init (void)
int rte_ixgbe_pmd_init (void)
int rte_ixgbevf_pmd_init (void)
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)
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)
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)
int rte_eth_dev_start (uint8_t port_id)
void rte_eth_dev_stop (uint8_t port_id)
void rte_eth_dev_close (uint8_t port_id)
void rte_eth_promiscuous_enable (uint8_t port_id)
void rte_eth_promiscuous_disable (uint8_t port_id)
int rte_eth_promiscuous_get (uint8_t port_id)
void rte_eth_allmulticast_enable (uint8_t port_id)
void rte_eth_allmulticast_disable (uint8_t port_id)
int rte_eth_allmulticast_get (uint8_t port_id)
void rte_eth_link_get (uint8_t port_id, struct rte_eth_link link)
void rte_eth_link_get_nowait (uint8_t port_id, struct rte_eth_link link)
void rte_eth_stats_get (uint8_t port_id, struct rte_eth_stats stats)
void rte_eth_stats_reset (uint8_t port_id)
void rte_eth_macaddr_get (uint8_t port_id, struct ether_addr mac_addr)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
109

Intel DPDK - rte_ethdev.h File Reference

void rte_eth_dev_info_get (uint8_t port_id, struct rte_eth_dev_info dev_info)


int rte_eth_dev_vlan_filter (uint8_t port_id, uint16_t vlan_id, int on)
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 uint16_t rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id, struct rte_mbuf tx_pkts, uint16_t
nb_pkts)
int rte_eth_dev_fdir_add_signature_filter (uint8_t port_id, struct rte_fdir_filter fdir_filter, uint8_t rx_queue)
int rte_eth_dev_fdir_update_signature_filter (uint8_t port_id, struct rte_fdir_filter fdir_ftr, uint8_t rx_queue)
int rte_eth_dev_fdir_remove_signature_filter (uint8_t port_id, struct rte_fdir_filter fdir_ftr)
int rte_eth_dev_fdir_get_infos (uint8_t port_id, struct rte_eth_fdir fdir)
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)
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)
int rte_eth_dev_fdir_remove_perfect_filter (uint8_t port_id, struct rte_fdir_filter fdir_filter, uint16_t soft_id)
int rte_eth_dev_fdir_set_masks (uint8_t port_id, struct rte_fdir_masks fdir_mask)
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)
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)
void _rte_eth_dev_callback_process (struct rte_eth_dev dev, enum rte_eth_event_type event)
int rte_eth_led_on (uint8_t port_id)
int rte_eth_led_off (uint8_t port_id)
int rte_eth_dev_flow_ctrl_set (uint8_t port_id, struct rte_eth_fc_conf fc_conf)
int rte_eth_dev_mac_addr_add (uint8_t port, struct ether_addr mac_addr, uint32_t pool)
int rte_eth_dev_mac_addr_remove (uint8_t port, struct ether_addr mac_addr)
static int rte_82576_pmd_init (void)
static int rte_82599_pmd_init (void)

Variables
struct rte_eth_dev rte_eth_devices [ ]

3.11.1

Detailed Description

RTE Ethernet Device API


The Ethernet Device API is composed of two parts:
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
110

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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:
flow control settings

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
111

Intel DPDK - rte_ethdev.h File Reference

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)
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.

3.11.2

Define Documentation

3.11.2.1

#define ETH LINK SPEED AUTONEG

Auto-negotiate link speed.

3.11.2.2

#define ETH LINK SPEED 10

10 megabits/second.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
112

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.2.3

#define ETH LINK SPEED 100

100 megabits/second.

3.11.2.4

#define ETH LINK SPEED 1000

1 gigabits/second.

3.11.2.5

#define ETH LINK SPEED 10000

10 gigabits/second.

3.11.2.6

#define ETH LINK AUTONEG DUPLEX

Auto-negotiate duplex.

3.11.2.7

#define ETH LINK HALF DUPLEX

Half-duplex connection.

3.11.2.8

#define ETH LINK FULL DUPLEX

Full-duplex connection.

3.11.2.9

#define ETH RSS IPV4

IPv4 packet.

3.11.2.10

#define ETH RSS IPV4 TCP

IPv4/TCP packet.

3.11.2.11

#define ETH RSS IPV6

IPv6 packet.

3.11.2.12

#define ETH RSS IPV6 EX

IPv6 packet with extension headers.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
113

Intel DPDK - rte_ethdev.h File Reference

3.11.2.13

#define ETH RSS IPV6 TCP

IPv6/TCP packet.

3.11.2.14

#define ETH RSS IPV6 TCP EX

IPv6/TCP with extension headers.

3.11.2.15

#define ETH RSS IPV4 UDP

IPv4/UDP packet.

3.11.2.16

#define ETH RSS IPV6 UDP

IPv6/UDP packet.

3.11.2.17

#define ETH RSS IPV6 UDP EX

IPv6/UDP with extension headers.

3.11.2.18

#define ETH VMDQ MAX VLAN FILTERS

Maximum nb. of VMDQ vlan filters.

3.11.2.19

#define ETH DCB NUM USER PRIORITIES

Maximum nb. of DCB priorities.

3.11.2.20

#define ETH VMDQ DCB NUM QUEUES

Maximum nb. of VMDQ DCB queues.

3.11.2.21

#define RTE LIBRTE 82576 PMD

Deprecated The config file option CONFIG_RTE_LIBRTE_82576_PMD and resulting preprocessor define
RTE_LIBRTE_82576_PMD are deprecated. CONFIG_RTE_LIBRTE_IGB_PMD must be set
in the config file to use Intel(R) DPDK supported Gigabit Ethernet Controllers, and RTE_LIBRTE_IGB_PMD should be used in code.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
114

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.2.22

#define RTE LIBRTE 82599 PMD

Deprecated The config file option CONFIG_RTE_LIBRTE_82599_PMD and resulting preprocessor define
RTE_LIBRTE_82599_PMD are deprecated. CONFIG_RTE_LIBRTE_IXGBE_PMD must be
set in the config file to use Intel(R) DPDK supported Gigabit Ethernet Controllers, and RTE_LIBRTE_IXGBE_PMD should be used in code.

3.11.3

Typedef Documentation

3.11.3.1

typedef int( eth_dev_configure_t)(struct rte_eth_dev dev, uint16 t nb rx q, uint16 t nb tx q)

Ethernet device configuration.

3.11.3.2

typedef int( eth_dev_start_t)(struct rte_eth_dev dev)

Function used to start a configured Ethernet device.

3.11.3.3

typedef void( eth_dev_stop_t)(struct rte_eth_dev dev)

Function used to stop a configured Ethernet device.

3.11.3.4

typedef void( eth_dev_close_t)(struct rte_eth_dev dev)

Function used to close a configured Ethernet device.

3.11.3.5

typedef void( eth_promiscuous_enable_t)(struct rte_eth_dev dev)

Function used to enable the RX promiscuous mode of an Ethernet device.

3.11.3.6

typedef void( eth_promiscuous_disable_t)(struct rte_eth_dev dev)

Function used to disable the RX promiscuous mode of an Ethernet device.

3.11.3.7

typedef void( eth_allmulticast_enable_t)(struct rte_eth_dev dev)

Enable the receipt of all multicast packets by an Ethernet device.

3.11.3.8

typedef void( eth_allmulticast_disable_t)(struct rte_eth_dev dev)

Disable the receipt of all multicast packets by an Ethernet device.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
115

Intel DPDK - rte_ethdev.h File Reference

3.11.3.9

typedef int( eth_link_update_t)(struct rte_eth_dev dev, int wait to complete)

Get link speed, duplex mode and state (up/down) of an Ethernet device.

3.11.3.10

typedef void( eth_stats_get_t)(struct rte_eth_dev dev, struct rte_eth_stats igb stats)

Get global I/O statistics of an Ethernet device.

3.11.3.11

typedef void( eth_stats_reset_t)(struct rte_eth_dev dev)

Reset global I/O statistics of an Ethernet device to 0.

3.11.3.12

typedef void( eth_dev_infos_get_t)(struct rte_eth_dev dev, struct rte_eth_dev_info dev info)

Get specific informations of an Ethernet device.

3.11.3.13

typedef int( eth_rx_queue_setup_t)(struct rte_eth_dev dev, 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)

Set up a receive queue of an Ethernet device.

3.11.3.14

typedef int( eth_tx_queue_setup_t)(struct rte_eth_dev dev, uint16 t tx queue id, uint16 t


nb tx desc, unsigned int socket id, const struct rte_eth_txconf tx conf)

Setup a transmit queue of an Ethernet device.

3.11.3.15

typedef void( vlan_filter_set_t)(struct rte_eth_dev dev, uint16 t vlan id, int on)

Enable/Disable filtering of a VLAN Tag Identifier by an Ethernet device.

3.11.3.16

typedef uint16 t( eth_rx_burst_t)(struct igb rx queue rxq, struct rte_mbuf rx pkts, uint16 t nb pkts)

Retrieve input packets from a receive queue of an Ethernet device.

3.11.3.17

typedef uint16 t( eth_tx_burst_t)(struct igb tx queue txq, struct rte_mbuf tx pkts, uint16 t nb pkts)

Send output packets on a transmit queue of an Ethernet device.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
116

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.3.18

typedef int( fdir_add_signature_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter fdir ftr,


uint8 t rx queue)

Setup a new signature filter rule on an Ethernet device

3.11.3.19

typedef int( fdir_update_signature_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter fdir ftr,


uint8 t rx queue)

Update a signature filter rule on an Ethernet device

3.11.3.20

typedef int( fdir_remove_signature_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter


fdir ftr)

Remove a signature filter rule on an Ethernet device

3.11.3.21

typedef void( fdir_infos_get_t)(struct rte_eth_dev dev, struct rte_eth_fdir fdir)

Get information about fdir status

3.11.3.22

typedef int( fdir_add_perfect_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter fdir ftr,


uint16 t soft id, uint8 t rx queue, uint8 t drop)

Setup a new perfect filter rule on an Ethernet device

3.11.3.23

typedef int( fdir_update_perfect_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter fdir ftr,


uint16 t soft id, uint8 t rx queue, uint8 t drop)

Update a perfect filter rule on an Ethernet device

3.11.3.24

typedef int( fdir_remove_perfect_filter_t)(struct rte_eth_dev dev, struct rte_fdir_filter fdir ftr,


uint16 t soft id)

Remove a perfect filter rule on an Ethernet device

3.11.3.25

typedef int( fdir_set_masks_t)(struct rte_eth_dev dev, struct rte_fdir_masks fdir masks)

Setup flow director masks on an Ethernet device

3.11.3.26

typedef int( flow_ctrl_set_t)(struct rte_eth_dev dev, struct rte_eth_fc_conf fc conf)

Setup flow control parameter on an Ethernet device

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
117

Intel DPDK - rte_ethdev.h File Reference

3.11.3.27

typedef int( eth_dev_led_on_t)(struct rte_eth_dev dev)

Turn on SW controllable LED on an Ethernet device

3.11.3.28

typedef int( eth_dev_led_off_t)(struct rte_eth_dev dev)

Turn off SW controllable LED on an Ethernet device

3.11.3.29

typedef void( eth_mac_addr_remove_t)(struct rte_eth_dev dev, uint32 t index)

Remove MAC address from receive address register

3.11.3.30

typedef void( eth_mac_addr_add_t)(struct rte_eth_dev dev, struct ether_addr mac addr, uint32 t
index, uint32 t vmdq)

Set a MAC address into Receive Address Address Register

3.11.3.31

typedef int( eth_dev_init_t)(struct eth_driver eth drv, struct rte_eth_dev eth dev)

Initialization function of an Ethernet driver invoked for each matching Ethernet PCI device detected during
the PCI probing phase.
Parameters
eth_drv The pointer to the [matching] Ethernet driver structure supplied by the PMD when it
registered itself.
eth_dev The eth_dev pointer is the address of the rte_eth_dev structure associated with
the matching device and which have been [automatically] allocated in the rte_eth_devices array. The eth_dev structure is supplied to the driver initialization function
with the following fields already initialized:
pci_dev: Holds the pointers to the rte_pci_device structure which contains the generic PCI
information of the matching device.
dev_private: Holds a pointer to the device private data structure.
max_frame_size: Contains the default Ethernet maximum frame length (1518).
port_id: Contains the port index of the device (actually the index of the eth_dev structure in the
rte_eth_devices array).

Intel Data Plane Development Kit (Intel DPDK)


API Reference
118

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

Returns
0: Success, the device is properly initialized by the driver. In particular, the driver MUST have set
up the dev_ops pointer of the eth_dev structure.
<0: Error code of the device initialization failure.

3.11.3.32

typedef void( rte_eth_dev_cb_fn)(uint8 t port id, enum rte_eth_event_type event, void cb arg)

user application callback to be registered for interrupts

3.11.4

Enumeration Type Documentation

3.11.4.1

enum rte_eth_rx_mq_mode

A set of values to identify what method is to be used to route packets to multiple queues.
Enumerator:
ETH_RSS Default to RSS mode
ETH_VMDQ_DCB Use VMDQ+DCB to route traffic to queues

3.11.4.2

enum rte_eth_nb_pools

This enum indicates the possible number of queue pools in VMDQ+DCB configurations.
Enumerator:
ETH_16_POOLS 16 pools with DCB.
ETH_32_POOLS 32 pools with DCB.

3.11.4.3

enum rte_eth_fc_mode

This enum indicates the flow control mode


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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
119

Intel DPDK - rte_ethdev.h File Reference

3.11.4.4

enum rte_fdir_mode

Flow Director setting modes: none (default), signature or perfect.


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.

3.11.4.5

enum rte_fdir_pballoc_type

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.

3.11.4.6

enum rte_fdir_status_mode

Select report mode of FDIR hash information in RX descriptors.


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.

3.11.4.7

enum rte_l4type

Possible l4type of FDIR filters.


Enumerator:
RTE_FDIR_L4TYPE_NONE Nnoe.
RTE_FDIR_L4TYPE_UDP UDP.
RTE_FDIR_L4TYPE_TCP TCP.
RTE_FDIR_L4TYPE_SCTP SCTP.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
120

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.4.8

enum rte_iptype

Select IPv4 or IPv6 FDIR filters.


Enumerator:
RTE_FDIR_IPTYPE_IPV4 IPv4.
RTE_FDIR_IPTYPE_IPV6 IPv6.

3.11.4.9

enum rte_eth_event_type

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

3.11.5

Function Documentation

3.11.5.1

TAILQ HEAD ( rte eth dev cb list , rte eth dev callback )

Structure to keep track of registered callbacks

3.11.5.2

uint8 t rte eth dev count ( void )

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.

3.11.5.3

void rte eth driver register ( struct eth_driver eth drv )

A function invoked by the initialization function of an Ethernet driver to simultaneously register itself as a PCI
driver and as an Ethernet Poll Mode Driver (PMD).
Parameters
eth_drv The pointer to the eth_driver structure associated with the Ethernet driver.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
121

Intel DPDK - rte_ethdev.h File Reference

3.11.5.4

int rte igb pmd init ( void )

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

3.11.5.5

int rte ixgbe pmd init ( void )

The initialization function of the driver for 10Gbps Intel IXGBE Ethernet devices. Invoked once at EAL start
time.
Returns
0 on success

3.11.5.6

int rte ixgbevf pmd init ( void )

The initialization function of the driver for 10Gbps Intel IXGBE_VF Ethernet devices. Invoked once at EAL
start time.
Returns
0 on success

3.11.5.7

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
nb_rx_queue
nb_tx_queue
eth_conf

The port identifier of the Ethernet device to configure.


The number of receive queues to set up for the Ethernet device.
The number of transmit queues to set up for the Ethernet device.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
122

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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.8

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 )

Allocate and set up a receive queue for an Ethernet device.


The function allocates a contiguous block of memory for nb_rx_desc receive descriptors from a memory
zone associated with socket_id and initializes each receive descriptor with a network buffer allocated from
the memory pool mb_pool.
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.9

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 )

Allocate and set up a transmit queue for an Ethernet device.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
123

Intel DPDK - rte_ethdev.h File Reference

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.

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.

3.11.5.10

int rte eth dev start ( uint8 t port id )

Start an Ethernet device.


The device start step is the last one and consists of setting the configured offload features and in starting
the transmit and the receive units of the device. On success, all basic functions exported by the Ethernet
API (link status, receive/transmit, and so on) can be invoked.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
124

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.5.11

void rte eth dev stop ( uint8 t port id )

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.

3.11.5.12

void rte eth dev close ( uint8 t port id )

Close an Ethernet device. The device cannot be restarted!


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.13

void rte eth promiscuous enable ( uint8 t port id )

Enable receipt in promiscuous mode for an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.14

void rte eth promiscuous disable ( uint8 t port id )

Disable receipt in promiscuous mode for an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.15

int rte eth promiscuous get ( uint8 t port id )

Return the value of promiscuous mode for an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.
Returns
(1) if promiscuous is enabled
(0) if promiscuous is disabled.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
125

Intel DPDK - rte_ethdev.h File Reference

(-1) on error

3.11.5.16

void rte eth allmulticast enable ( uint8 t port id )

Enable the receipt of any multicast frame by an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.17

void rte eth allmulticast disable ( uint8 t port id )

Disable the receipt of all multicast frames by an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.18

int rte eth allmulticast get ( uint8 t port id )

Return the value of allmulticast mode for an 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.19

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
126

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

3.11.5.20

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.21

void rte eth stats get ( uint8 t port id, struct rte_eth_stats stats )

Retrieve the general I/O statistics of an Ethernet device.


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.

3.11.5.22

void rte eth stats reset ( uint8 t port id )

Reset the general I/O statistics of an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

3.11.5.23

void rte eth macaddr get ( uint8 t port id, struct ether_addr mac addr )

Retrieve the Ethernet address of an Ethernet device.


Parameters
port_id The port identifier of the Ethernet device.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
127

Intel DPDK - rte_ethdev.h File Reference

mac_addr A pointer to a structure of type ether_addr to be filled with the Ethernet address of the
Ethernet device.

void rte eth dev info get ( uint8 t port id, struct rte_eth_dev_info dev info )

3.11.5.24

Retrieve the contextual information of an Ethernet device.


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.25

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

3.11.5.26

(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.

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
128

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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.
Conversely, it also allows an asynchronous-oriented processing method to retrieve bursts of received
packets and to immediately queue them for further parallel processing by another logical core, for
instance. However, instead of having received packets being individually queued by the driver, this
approach allows the invoker of the rte_eth_rx_burst() function to queue a burst of retrieved packets at
a time and therefore dramatically reduce the cost of enqueue/dequeue operations per packet.
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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
129

Intel DPDK - rte_ethdev.h File Reference

Returns
The number of packets actually retrieved, which is the number of pointers to rte_mbuf structures
effectively supplied to the rx_pkts array.

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]

3.11.5.27

Send a burst of output packets on a transmit queue of an Ethernet device.


The rte_eth_tx_burst() function is invoked to transmit output packets on the output queue queue_id of the
Ethernet device designated by its port_id. The nb_pkts parameter is the number of packets to send
which are supplied in the tx_pkts array of rte_mbuf structures. The rte_eth_tx_burst() function loops,
sending nb_pkts packets, up to the number of transmit descriptors available in the TX ring of the transmit
queue. For each packet to send, the rte_eth_tx_burst() function performs the following operations:
Pick up the next available descriptor in the transmit ring.
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
port_id The port identifier of the Ethernet device.
queue_id The index of the transmit queue through which output packets must be sent. The
value must be in the range [0, nb_tx_queue - 1] previously supplied to rte_eth_dev_configure().
tx_pkts The address of an array of nb_pkts pointers to rte_mbuf structures which contain
the output packets.
nb_pkts The maximum number of packets to transmit.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
130

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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.

int rte eth dev fdir add signature filter ( uint8 t port id, struct rte_fdir_filter fdir filter, uint8 t rx queue
)

3.11.5.28

Setup a new signature filter rule on an Ethernet device


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 doesnt 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.

int rte eth dev fdir update signature filter ( uint8 t port id, struct rte_fdir_filter fdir ftr, uint8 t rx queue
)

3.11.5.29

Update a signature filter rule on an Ethernet device. If the rule doesnt 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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
131

Intel DPDK - rte_ethdev.h File Reference

(-ENOTSUP) if hardware doesnt 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.30

int rte eth dev fdir remove signature filter ( uint8 t port id, struct rte_fdir_filter fdir ftr )

Remove a signature filter rule on an Ethernet device.


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 doesnt 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.31

int rte eth dev fdir get infos ( uint8 t port id, struct rte_eth_fdir fdir )

Retrieve the flow director information of an Ethernet device.


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 doesnt support flow director mode.
(-ENODEV) if port_id invalid.
(-ENOSYS) if the flow director mode is not configured on port_id.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
132

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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 )

3.11.5.32

Add a new perfect filter rule on an Ethernet device.


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 doesnt 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.

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 )

3.11.5.33

Update a perfect filter rule on an Ethernet device. If the rule doesnt 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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
133

Intel DPDK - rte_ethdev.h File Reference

Returns
(0) if successful.
(-ENOTSUP) if hardware doesnt 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.

int rte eth dev fdir remove perfect filter ( uint8 t port id, struct rte_fdir_filter fdir filter, uint16 t soft id
)

3.11.5.34

Remove a perfect filter rule on an Ethernet device.


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 doesnt 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.35

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
134

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

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 doesnt 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.36

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 )

Register a callback function for specific port id.


Parameters
port_id
event
cb_fn
cb_arg

Port id.
Event interested.
User supplied callback function to be called.
Pointer to the parameters for the registered callback.

Returns
On success, zero.
On failure, a negative value.

3.11.5.37

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 )

Unregister a callback function for specific port id.


Parameters
port_id
event
cb_fn
cb_arg

Port id.
Event interested.
User supplied callback function to be called.
Pointer to the parameters for the registered callback. -1 means to remove all for the
same callback address and same event.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
135

Intel DPDK - rte_ethdev.h File Reference

Returns
On success, zero.
On failure, a negative value.

3.11.5.38

void rte eth dev callback process ( struct rte_eth_dev dev, enum rte_eth_event_type event )

Executes all the user application registered callbacks for the specific device. It is for DPDK internal user
only. User application should not call it directly.
Parameters
dev Pointer to struct rte_eth_dev.
event Eth device interrupt event type.

Returns
void

3.11.5.39

int rte eth led on ( uint8 t port id )

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 doesnt support that operation.
(-ENODEV) if port_id invalid.

3.11.5.40

int rte eth led off ( uint8 t port id )

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
136

November 2012
Reference Number: 326004-001

rte_ethdev.h File Reference - Intel DPDK

(-ENOTSUP) if underlying hardware OR driver doesnt support that operation.


(-ENODEV) if port_id invalid.

3.11.5.41

int rte eth dev flow ctrl set ( uint8 t port id, struct rte_eth_fc_conf fc conf )

Configure the Ethernet link flow control for Ethernet device


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 doesnt support flow director mode.
(-ENODEV) if port_id invalid.
(-EINVAL) if bad parameter
(-EIO) if flow control setup failure

3.11.5.42

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 doesnt support this feature.
(-ENODEV) if port is invalid.
(-ENOSPC) if no more MAC addresses can be added.
(-EINVAL) if MAC address is invalid.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
137

Intel DPDK - rte_ethdev.h File Reference

int rte eth dev mac addr remove ( uint8 t port, struct ether_addr mac addr )

3.11.5.43

Remove a MAC address from the internal array of addresses.


Parameters
port The port identifier of the Ethernet device.
mac_addr MAC address to remove.

Returns
(0) if successful, or mac_addr didnt exist.
(-ENOTSUP) if hardware doesnt support.
(-ENODEV) if port invalid.
(-EADDRINUSE) if attempting to remove the default MAC address

3.11.5.44

static int rte 82576 pmd init ( void ) [static]

Deprecated rte_82576_pmd_init() is deprecated and will be removed from future versions of Intel(R) DPDK. It has been replaced by rte_igb_pmd_init().

Returns
0 on success

3.11.5.45

static int rte 82599 pmd init ( void ) [static]

Deprecated rte_82599_pmd_init() is deprecated and will be removed from future versions of Intel(R) DPDK. It has been replaced by rte_ixgbe_pmd_init().

Returns
0 on success

3.11.6

Variable Documentation

3.11.6.1

struct rte_eth_dev rte_eth_devices[ ]

The pool of rte_eth_dev structures. The size of the pool is configured at compile-time in the <rte_ethdev.c> file.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
138

November 2012
Reference Number: 326004-001

rte_ether.h File Reference - Intel DPDK

3.12

rte ether.h File Reference

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_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 ether_addr_copy (const struct ether_addr ea_from, struct ether_addr ea_to)

3.12.1

Detailed Description

Ethernet Helpers in RTE

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
139

Intel DPDK - rte_ether.h File Reference

3.12.2

Define Documentation

3.12.2.1

#define ETHER ADDR LEN

Length of Ethernet address.


3.12.2.2

#define ETHER TYPE LEN

Length of Ethernet type field.


3.12.2.3

#define ETHER CRC LEN

Length of Ethernet CRC.


3.12.2.4

#define ETHER HDR LEN

Length of Ethernet header.


3.12.2.5

#define ETHER MIN LEN

Minimum frame len, including CRC.


3.12.2.6

#define ETHER MAX LEN

Maximum frame len, including CRC.


3.12.2.7

#define ETHER MTU

Ethernet MTU.
3.12.2.8

#define ETHER MAX VLAN FRAME LEN

Maximum VLAN frame length, including CRC.


3.12.2.9

#define ETHER MAX JUMBO FRAME LEN

Maximum Jumbo frame length, including CRC.


3.12.2.10

#define ETHER LOCAL ADMIN ADDR

Locally assigned Eth. address.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
140

November 2012
Reference Number: 326004-001

rte_ether.h File Reference - Intel DPDK

3.12.2.11

#define ETHER GROUP ADDR

Multicast or broadcast Eth. address.

3.12.2.12

#define ETHER TYPE IPv4

IPv4 Protocol.

3.12.2.13

#define ETHER TYPE IPv6

IPv6 Protocol.

#define ETHER TYPE ARP

3.12.2.14

Arp Protocol.

3.12.2.15

#define ETHER TYPE RARP

Reverse Arp Protocol.

3.12.2.16

#define ETHER TYPE VLAN

IEEE 802.1Q VLAN tagging.

3.12.2.17

#define ETHER TYPE 1588

IEEE 802.1AS 1588 Precise Time Protocol.

3.12.3

Function Documentation

3.12.3.1

static int is zero ether addr ( const struct ether_addr ea ) [static]

Check if an Ethernet address is 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 filled with zeros; false (0) otherwise.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
141

Intel DPDK - rte_ether.h File Reference

3.12.3.2

static int is unicast ether addr ( const struct ether_addr ea ) [static]

Check if an Ethernet address is a unicast address.


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]

Check if an Ethernet address is a multicast address.


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]

Check if an Ethernet address is a broadcast address.


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]

Check if an Ethernet address is a universally assigned address.


Parameters
ea A pointer to a ether_addr structure containing the ethernet address to check.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
142

November 2012
Reference Number: 326004-001

rte_fbk_hash.h File Reference - Intel DPDK

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]

Check if an Ethernet address is a locally assigned address.


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.

3.12.3.8

static void ether addr copy ( const struct ether_addr ea from, struct ether_addr ea to ) [static]

Fast copy an Ethernet address.


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.

3.13

rte fbk hash.h File Reference

Data Structures
struct rte_fbk_hash_params

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
143

Intel DPDK - rte_fbk_hash.h File Reference

union rte_fbk_hash_entry
struct rte_fbk_hash_table

Defines

#define RTE_FBK_HASH_FUNC_DEFAULT
#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 (struct rte_fbk_hash_table ht, uint32_t key, uint16_t value)
static int rte_fbk_hash_delete_key (struct rte_fbk_hash_table ht, uint32_t key)
static int rte_fbk_hash_lookup (const struct rte_fbk_hash_table ht, uint32_t key)
static void rte_fbk_hash_clear_all (struct rte_fbk_hash_table ht)
static double rte_fbk_hash_get_load_factor (struct rte_fbk_hash_table ht)
struct rte_fbk_hash_table rte_fbk_hash_find_existing (const char name)
struct rte_fbk_hash_table rte_fbk_hash_create (const struct rte_fbk_hash_params params)
void rte_fbk_hash_free (struct rte_fbk_hash_table ht)

3.13.1

Detailed Description

This is a hash table implementation for four byte keys (fbk).


Note that the return value of the add function should always be checked as, if a bucket is full, the key is not
added even if there is space in other buckets. This keeps the lookup function very simple and therefore fast.

3.13.2

Define Documentation

3.13.2.1

#define RTE FBK HASH FUNC DEFAULT

Default four-byte key hash function if none is specified.

3.13.2.2

#define RTE FBK HASH INIT VAL DEFAULT

Initialising value used when calculating hash.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
144

November 2012
Reference Number: 326004-001

rte_fbk_hash.h File Reference - Intel DPDK

3.13.2.3

#define RTE FBK HASH ENTRIES MAX

The maximum number of entries in the hash table that is supported.

3.13.2.4

#define RTE FBK HASH ENTRIES PER BUCKET MAX

The maximum number of entries in each bucket that is supported.

3.13.2.5

#define RTE FBK HASH NAMESIZE

Maximum size of string for naming the hash.

3.13.3

Typedef Documentation

3.13.3.1

typedef uint32 t( rte_fbk_hash_fn)(uint32 t key, uint32 t init val)

Type of function that can be used for calculating the hash value.

3.13.4

Function Documentation

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 ( 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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
145

Intel DPDK - rte_fbk_hash.h File Reference

Returns
0 if ok, or negative value on error.

3.13.4.3

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.4

static int rte fbk hash lookup ( const struct rte_fbk_hash_table ht, uint32 t key ) [static]

Find a key in the hash table. This operation is multi-thread safe.


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.5

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.6

static double rte fbk hash get load factor ( struct rte_fbk_hash_table ht ) [static]

Find what fraction of entries are being used.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
146

November 2012
Reference Number: 326004-001

rte_fbk_hash.h File Reference - Intel DPDK

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.7

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.8

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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
147

Intel DPDK - rte_hash.h File Reference

3.13.4.9

void rte fbk hash free ( struct rte_fbk_hash_table ht )

Free all memory used by a hash table. Has no effect on hash tables allocated in memory zones
Parameters
ht Hash table to deallocate.

3.14

rte hash.h File Reference

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_MULTI_MAX
#define RTE_HASH_NAMESIZE

Typedefs
typedef uint32_t hash_sig_t
typedef uint32_t( rte_hash_function )(const void key, uint32_t key_len, uint32_t init_val)

Functions

struct rte_hash rte_hash_create (const struct rte_hash_parameters params)


struct rte_hash rte_hash_find_existing (const char name)
void rte_hash_free (struct rte_hash h)
int32_t rte_hash_add_key (const struct rte_hash h, const void key)
int32_t rte_hash_del_key (const struct rte_hash h, const void key)
int32_t rte_hash_lookup (const struct rte_hash h, const void key)
int rte_hash_lookup_multi (const struct rte_hash h, const void keys, uint32_t num_keys, int32_t
positions)

3.14.1

Detailed Description

RTE Hash Table

Intel Data Plane Development Kit (Intel DPDK)


API Reference
148

November 2012
Reference Number: 326004-001

rte_hash.h File Reference - Intel DPDK

3.14.2

Define Documentation

3.14.2.1

#define RTE HASH ENTRIES MAX

Maximum size of hash table that can be created.

3.14.2.2

#define RTE HASH BUCKET ENTRIES MAX

Maximum bucket size that can be created.

3.14.2.3

#define RTE HASH KEY LENGTH MAX

Maximum length of key that can be used.

3.14.2.4

#define RTE HASH LOOKUP MULTI MAX

Max number of keys that can be searched for using rte_hash_lookup_multi.

3.14.2.5

#define RTE HASH NAMESIZE

Max number of characters in hash name.

3.14.3

Typedef Documentation

3.14.3.1

typedef uint32 t hash_sig_t

Signature of key that is stored internally.

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

Function Documentation

3.14.4.1

struct rte_hash rte hash create ( const struct rte_hash_parameters params ) [read]

Create a new hash table. If RTE_LIBRTE_HASH_USE_MEMZONE is defined, then the hash table is
allocated in a memzone on a specific NUMA socket ID, otherwise it is allocated in the heap.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
149

Intel DPDK - rte_hash.h File Reference

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]

Find an existing hash table object and return a pointer to it.


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

3.14.4.3

void rte hash free ( struct rte_hash h )

De-allocate all memory used by hash table. If RTE_LIBRTE_HASH_USE_MEMZONE is defined, then this
has no effect.
Parameters
h Hash table to free

Intel Data Plane Development Kit (Intel DPDK)


API Reference
150

November 2012
Reference Number: 326004-001

rte_hash.h File Reference - Intel DPDK

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 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.6

int32 t rte hash lookup ( const struct rte_hash h, const void key )

Find a key in the hash table. This operation is multi-thread safe.


Parameters
h Hash table to look in.
key Key to find.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
151

Intel DPDK - rte_hash_crc.h File Reference

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

int rte hash lookup multi ( 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
keys
num_keys
positions

Hash table to look in.


A pointer to a list of keys to look for.
How many keys are in the keys list (less than RTE_HASH_LOOKUP_MULTI_MAX).
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 theres an error, otherwise 0.

3.15

rte hash crc.h File Reference

Functions
static uint32_t rte_hash_crc_4byte (uint32_t data, uint32_t init_val)
static uint32_t rte_hash_crc (const void data, uint32_t data_len, uint32_t init_val)

3.15.1

Detailed Description

RTE CRC Hash

3.15.2

Function Documentation

3.15.2.1

static uint32 t rte hash crc 4byte ( uint32 t data, uint32 t init val ) [static]

Use single crc32 instruction to perform a hash on a 4 byte value.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
152

November 2012
Reference Number: 326004-001

rte_interrupts.h File Reference - Intel DPDK

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]

Use crc32 instruction to perform a hash.


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.

3.16

rte interrupts.h File Reference

Typedefs
typedef void( rte_intr_callback_fn )(struct rte_intr_handle intr_handle, void cb_arg)

Functions
int rte_intr_callback_register (struct rte_intr_handle intr_handle, rte_intr_callback_fn cb, void cb_arg)
int rte_intr_callback_unregister (struct rte_intr_handle intr_handle, rte_intr_callback_fn cb, void cb_arg)
int rte_intr_enable (struct rte_intr_handle intr_handle)
int rte_intr_disable (struct rte_intr_handle intr_handle)

3.16.1

Detailed Description

The RTE interrupt interface provides functions to register/unregister callbacks for a specific interrupt.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
153

Intel DPDK - rte_interrupts.h File Reference

3.16.2

Typedef Documentation

3.16.2.1

typedef void( rte_intr_callback_fn)(struct rte intr handle intr handle, void cb arg)

Function to be registered for the specific interrupt

3.16.3

Function Documentation

3.16.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.16.3.2

int rte intr callback unregister ( struct rte intr handle intr handle, rte_intr_callback_fn cb, void
cb arg )

It unregisters the callback according to the specified interrupt handle.


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.16.3.3

int rte intr enable ( struct rte intr handle intr handle )

It enables the interrupt for the specified handle.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
154

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

Parameters
intr_handle pointer to the interrupt handle.

Returns
On success, zero.
On failure, a negative value.

int rte intr disable ( struct rte intr handle intr handle )

3.16.3.4

It disables the interrupt for the specified handle.


Parameters
intr_handle pointer to the interrupt handle.

Returns
On success, zero.
On failure, a negative value.

3.17

rte ip.h File Reference

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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
155

Intel DPDK - rte_ip.h File Reference

#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

Intel Data Plane Development Kit (Intel DPDK)


API Reference
156

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

#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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
157

Intel DPDK - rte_ip.h File Reference

#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)

3.17.1

Detailed Description

IP-related defines

3.17.2

Define Documentation

3.17.2.1

#define IPv4( a, b, c, d )

Create IPv4 address

3.17.2.2

#define IPPROTO IP

dummy for IP

3.17.2.3

#define IPPROTO HOPOPTS

IP6 hop-by-hop options

3.17.2.4

#define IPPROTO ICMP

control message protocol

3.17.2.5

#define IPPROTO IGMP

group mgmt protocol

3.17.2.6

#define IPPROTO GGP

gateway 2 (deprecated)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
158

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

3.17.2.7

#define IPPROTO IPV4

IPv4 encapsulation

3.17.2.8

#define IPPROTO TCP

tcp

3.17.2.9

#define IPPROTO ST

Stream protocol II

3.17.2.10

#define IPPROTO EGP

exterior gateway protocol

3.17.2.11

#define IPPROTO PIGP

private interior gateway

3.17.2.12

#define IPPROTO RCCMON

BBN RCC Monitoring

3.17.2.13

#define IPPROTO NVPII

network voice protocol

3.17.2.14

#define IPPROTO PUP

pup

3.17.2.15

#define IPPROTO ARGUS

Argus

3.17.2.16

#define IPPROTO EMCON

EMCON

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
159

Intel DPDK - rte_ip.h File Reference

3.17.2.17

#define IPPROTO XNET

Cross Net Debugger

3.17.2.18

#define IPPROTO CHAOS

Chaos

3.17.2.19

#define IPPROTO UDP

user datagram protocol

3.17.2.20

#define IPPROTO MUX

Multiplexing

3.17.2.21

#define IPPROTO MEAS

DCN Measurement Subsystems

3.17.2.22

#define IPPROTO HMP

Host Monitoring

3.17.2.23

#define IPPROTO PRM

Packet Radio Measurement

3.17.2.24

#define IPPROTO IDP

xns idp

3.17.2.25

#define IPPROTO TRUNK1

Trunk-1

3.17.2.26

#define IPPROTO TRUNK2

Trunk-2

Intel Data Plane Development Kit (Intel DPDK)


API Reference
160

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

3.17.2.27

#define IPPROTO LEAF1

Leaf-1

3.17.2.28

#define IPPROTO LEAF2

Leaf-2

3.17.2.29

#define IPPROTO RDP

Reliable Data

3.17.2.30

#define IPPROTO IRTP

Reliable Transaction

3.17.2.31

#define IPPROTO TP

tp-4 w/ class negotiation

3.17.2.32

#define IPPROTO BLT

Bulk Data Transfer

3.17.2.33

#define IPPROTO NSP

Network Services

3.17.2.34

#define IPPROTO INP

Merit Internodal

3.17.2.35

#define IPPROTO SEP

Sequential Exchange

3.17.2.36

#define IPPROTO 3PC

Third Party Connect

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
161

Intel DPDK - rte_ip.h File Reference

3.17.2.37

#define IPPROTO IDPR

InterDomain Policy Routing

3.17.2.38

#define IPPROTO XTP

XTP

3.17.2.39

#define IPPROTO DDP

Datagram Delivery

3.17.2.40

#define IPPROTO CMTP

Control Message Transport

3.17.2.41

#define IPPROTO TPXX

TP++ Transport

3.17.2.42

#define IPPROTO IL

IL transport protocol

3.17.2.43

#define IPPROTO IPV6

IP6 header

3.17.2.44

#define IPPROTO SDRP

Source Demand Routing

3.17.2.45

#define IPPROTO ROUTING

IP6 routing header

3.17.2.46

#define IPPROTO FRAGMENT

IP6 fragmentation header

Intel Data Plane Development Kit (Intel DPDK)


API Reference
162

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

3.17.2.47

#define IPPROTO IDRP

InterDomain Routing

3.17.2.48

#define IPPROTO RSVP

resource reservation

3.17.2.49

#define IPPROTO GRE

General Routing Encap.

3.17.2.50

#define IPPROTO MHRP

Mobile Host Routing

3.17.2.51

#define IPPROTO BHA

BHA

3.17.2.52

#define IPPROTO ESP

IP6 Encap Sec. Payload

3.17.2.53

#define IPPROTO AH

IP6 Auth Header

3.17.2.54

#define IPPROTO INLSP

Integ. Net Layer Security

3.17.2.55

#define IPPROTO SWIPE

IP with encryption

3.17.2.56

#define IPPROTO NHRP

Next Hop Resolution

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
163

Intel DPDK - rte_ip.h File Reference

3.17.2.57

#define IPPROTO ICMPV6

ICMP6

3.17.2.58

#define IPPROTO NONE

IP6 no next header

3.17.2.59

#define IPPROTO DSTOPTS

IP6 destination option

3.17.2.60

#define IPPROTO AHIP

any host internal protocol

3.17.2.61

#define IPPROTO CFTP

CFTP

3.17.2.62

#define IPPROTO HELLO

"hello" routing protocol

3.17.2.63

#define IPPROTO SATEXPAK

SATNET/Backroom EXPAK

3.17.2.64

#define IPPROTO KRYPTOLAN

Kryptolan

3.17.2.65

#define IPPROTO RVD

Remote Virtual Disk

3.17.2.66

#define IPPROTO IPPC

Pluribus Packet Core

Intel Data Plane Development Kit (Intel DPDK)


API Reference
164

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

3.17.2.67

#define IPPROTO ADFS

Any distributed FS

3.17.2.68

#define IPPROTO SATMON

Satnet Monitoring

3.17.2.69

#define IPPROTO VISA

VISA Protocol

3.17.2.70

#define IPPROTO IPCV

Packet Core Utility

3.17.2.71

#define IPPROTO CPNX

Comp. Prot. Net. Executive

3.17.2.72

#define IPPROTO CPHB

Comp. Prot. HeartBeat

3.17.2.73

#define IPPROTO WSN

Wang Span Network

3.17.2.74

#define IPPROTO PVP

Packet Video Protocol

3.17.2.75

#define IPPROTO BRSATMON

BackRoom SATNET Monitoring

3.17.2.76

#define IPPROTO ND

Sun net disk proto (temp.)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
165

Intel DPDK - rte_ip.h File Reference

3.17.2.77

#define IPPROTO WBMON

WIDEBAND Monitoring

3.17.2.78

#define IPPROTO WBEXPAK

WIDEBAND EXPAK

3.17.2.79

#define IPPROTO EON

ISO cnlp

3.17.2.80

#define IPPROTO VMTP

VMTP

3.17.2.81

#define IPPROTO SVMTP

Secure VMTP

3.17.2.82

#define IPPROTO VINES

Banyon VINES

3.17.2.83

#define IPPROTO TTP

TTP

3.17.2.84

#define IPPROTO IGP

NSFNET-IGP

3.17.2.85

#define IPPROTO DGP

dissimilar gateway prot.

3.17.2.86

#define IPPROTO TCF

TCF

Intel Data Plane Development Kit (Intel DPDK)


API Reference
166

November 2012
Reference Number: 326004-001

rte_ip.h File Reference - Intel DPDK

3.17.2.87

#define IPPROTO IGRP

Cisco/GXS IGRP

3.17.2.88

#define IPPROTO OSPFIGP

OSPFIGP

3.17.2.89

#define IPPROTO SRPC

Strite RPC protocol

3.17.2.90

#define IPPROTO LARP

Locus Address Resoloution

3.17.2.91

#define IPPROTO MTP

Multicast Transport

3.17.2.92

#define IPPROTO AX25

AX.25 Frames

3.17.2.93

#define IPPROTO IPEIP

IP encapsulated in IP

3.17.2.94

#define IPPROTO MICP

Mobile Int.ing control

3.17.2.95

#define IPPROTO SCCSP

Semaphore Comm. security

3.17.2.96

#define IPPROTO ETHERIP

Ethernet IP encapsulation

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
167

Intel DPDK - rte_ip.h File Reference

3.17.2.97

#define IPPROTO ENCAP

encapsulation header

3.17.2.98

#define IPPROTO APES

any private encr. scheme

3.17.2.99

#define IPPROTO GMTP

GMTP

3.17.2.100

#define IPPROTO IPCOMP

payload compression (IPComp)

3.17.2.101

#define IPPROTO PIM

Protocol Independent Mcast

3.17.2.102

#define IPPROTO PGM

PGM

3.17.2.103

#define IPPROTO SCTP

Stream Control Transport Protocol

3.17.2.104

#define IPPROTO DIVERT

divert pseudo-protocol

3.17.2.105

#define IPPROTO RAW

raw IP packet

3.17.2.106

#define IPPROTO MAX

maximum protocol number

Intel Data Plane Development Kit (Intel DPDK)


API Reference
168

November 2012
Reference Number: 326004-001

rte_jhash.h File Reference - Intel DPDK

3.17.2.107

#define IPV4 ANY

0.0.0.0

3.17.2.108

#define IPV4 LOOPBACK

127.0.0.1

3.17.2.109

#define IPV4 BROADCAST

224.0.0.0

3.17.2.110

#define IPV4 ALLHOSTS GROUP

224.0.0.1

3.17.2.111

#define IPV4 ALLRTRS GROUP

224.0.0.2

3.17.2.112

#define IPV4 MAX LOCAL GROUP

224.0.0.255

3.17.2.113

#define IPV4 MIN MCAST

Minimal IPv4-multicast address

3.17.2.114

#define IPV4 MAX MCAST

Maximum IPv4 multicast address

3.17.2.115

#define IS IPV4 MCAST( x )

check if IPv4 address is multicast

3.18

rte jhash.h File Reference

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
169

Intel DPDK - rte_jhash.h File Reference

Defines
#define __rte_jhash_mix(a, b, c)
#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)

3.18.1

Detailed Description

jhash functions.

3.18.2

Define Documentation

3.18.2.1

#define rte jhash mix( a, b, c )

Internal function. NOTE: Arguments are modified.

3.18.2.2

#define RTE JHASH GOLDEN RATIO

The golden ratio: an arbitrary value.

3.18.3

Function Documentation

3.18.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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
170

November 2012
Reference Number: 326004-001

rte_jhash.h File Reference - Intel DPDK

3.18.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.18.3.3

static uint32 t rte jhash 3words ( uint32 t a, uint32 t b, uint32 t c, uint32 t initval ) [static]

A special ultra-optimized versions that knows it is hashing exactly 3 words.


Parameters
a
b
c
initval

First word to calcuate hash of.


Second word to calcuate hash of.
Third word to calcuate hash of.
Initialising value of hash.

Returns
Calculated hash value.

3.18.3.4

static uint32 t rte jhash 2words ( uint32 t a, uint32 t b, uint32 t initval ) [static]

A special ultra-optimized versions that knows it is hashing exactly 2 words.


NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally done at the end is not done here.
Parameters
a First word to calcuate hash of.
b Second word to calcuate hash of.
initval Initialising value of hash.

Returns
Calculated hash value.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
171

Intel DPDK - rte_launch.h File Reference

3.18.3.5

static uint32 t rte jhash 1word ( uint32 t a, uint32 t initval ) [static]

A special ultra-optimized versions that knows it is hashing exactly 1 word.


NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally done at the end is not done here.
Parameters
a Word to calcuate hash of.
initval Initialising value of hash.
Returns
Calculated hash value.

3.19

rte launch.h File Reference

Typedefs
typedef int( lcore_function_t )(void )

Enumerations
enum rte_lcore_state_t { WAIT, RUNNING, FINISHED }
enum rte_rmt_call_master_t { SKIP_MASTER, CALL_MASTER }

Functions
int rte_eal_remote_launch (lcore_function_t f, void arg, unsigned slave_id)
int rte_eal_mp_remote_launch (lcore_function_t f, void arg, enum rte_rmt_call_master_t call_master)
enum rte_lcore_state_t rte_eal_get_lcore_state (unsigned slave_id)
int rte_eal_wait_lcore (unsigned slave_id)
void rte_eal_mp_wait_lcore (void)

3.19.1

Detailed Description

Launch tasks on other lcores

3.19.2

Typedef Documentation

3.19.2.1

typedef int( lcore_function_t)(void )

Definition of a remote launch function.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
172

November 2012
Reference Number: 326004-001

rte_launch.h File Reference - Intel DPDK

3.19.3

Enumeration Type Documentation

3.19.3.1

enum rte_lcore_state_t

State of an lcore.
Enumerator:
WAIT waiting a new command
RUNNING executing command
FINISHED command executed

3.19.3.2

enum rte_rmt_call_master_t

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.19.4

Function Documentation

3.19.4.1

int rte eal remote launch ( lcore_function_t f, void arg, unsigned slave id )

Launch a function on another lcore.


To be executed on the MASTER lcore only.
Sends a message to a slave lcore (identified by the slave_id) that is in the WAIT state (this is true after the
first call to rte_eal_init()). This can be checked by first calling rte_eal_wait_lcore(slave_id).
When the remote lcore receives the message, it switches to the RUNNING state, then calls the function f
with argument arg. Once the execution is done, the remote lcore switches to a FINISHED state and the
return value of f is stored in a local variable to be read using rte_eal_wait_lcore().
The MASTER lcore returns as soon as the message is sent and knows nothing about the completion of f.
Note: This function is not designed to offer optimum performance. It is just a practical way to launch a
function on another lcore at initialization time.
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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
173

Intel DPDK - rte_launch.h File Reference

Returns
0: Success. Execution of function f started on the remote lcore.
(-EBUSY): The remote lcore is not in a WAIT state.

3.19.4.2

int rte eal mp remote launch ( lcore_function_t f, void arg, enum rte_rmt_call_master_t
call master )

Launch a function on all lcores.


Check that each SLAVE lcore is in a WAIT state, then call rte_eal_remote_launch() for each lcore.
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.19.4.3

enum rte_lcore_state_t rte eal get lcore state ( unsigned slave id )

Get the state of the lcore identified by slave_id.


To be executed on the MASTER lcore only.
Parameters
slave_id The identifier of the lcore.

Returns
The state of the lcore.

3.19.4.4

int rte eal wait lcore ( unsigned slave id )

Wait until an lcore finishes its job.


To be executed on the MASTER lcore only.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
174

November 2012
Reference Number: 326004-001

rte_lcore.h File Reference - Intel DPDK

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.

3.19.4.5

void rte eal mp wait lcore ( void )

Wait until all lcores finish their jobs.


To be executed on the MASTER lcore only. Issue an rte_eal_wait_lcore() for every lcore. The return values
are ignored.
After a call to rte_eal_mp_wait_lcores(), the caller can assume that all slave lcores are in a WAIT state.

rte lcore.h File Reference

3.20
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)

3.20.1

Detailed Description

API for lcore and Socket Manipulation. Parts of this are execution environment specific.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
175

Intel DPDK - rte_lcore.h File Reference

3.20.2

Define Documentation

3.20.2.1

#define LCORE ID ANY

Any lcore.
3.20.2.2

#define RTE LCORE FOREACH( i )

Macro to browse all running lcores.


3.20.2.3

#define RTE LCORE FOREACH SLAVE( i )

Macro to browse all running lcores except the master lcore.

3.20.3

Function Documentation

3.20.3.1

RTE DECLARE PER LCORE ( unsigned , lcore id )

Per core "core id".


3.20.3.2

static unsigned rte lcore id ( void ) [static]

Return the ID of the execution unit we are running on.


Returns
Logical core ID

3.20.3.3

static unsigned rte get master lcore ( void ) [static]

Get the id of the master lcore


Returns
the id of the master lcore

3.20.3.4

static unsigned rte lcore count ( void ) [static]

Return the number of execution units (lcores) on the system.


Returns
the number of execution units (lcores) on the system.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
176

November 2012
Reference Number: 326004-001

rte_lcore.h File Reference - Intel DPDK

3.20.3.5

static unsigned rte socket id ( void ) [static]

Return the ID of the physical socket of the logical core we are running on.
Returns
Socket ID

3.20.3.6

static unsigned rte lcore to socket id ( unsigned lcore id ) [static]

Get the ID of the physical socket of the specified lcore


Parameters
lcore_id the targeted lcore, which MUST be between 0 and RTE_MAX_LCORE-1.

Returns
the ID of lcoreids physical socket

3.20.3.7

static int rte lcore is enabled ( unsigned lcore id ) [static]

Test if an lcore is enabled.


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.20.3.8

static unsigned rte get next lcore ( unsigned i, int skip master, int wrap ) [static]

Get the next enabled lcore ID.


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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
177

Intel DPDK - rte_log.h File Reference

Returns
The next lcore_id or RTE_MAX_LCORE if not found.

3.21

rte log.h File Reference

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_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, fmt, args...)

Functions

int rte_openlog_stream (FILE f)


void rte_set_log_level (uint32_t level)
void rte_set_log_type (uint32_t type, int enable)
int rte_log_cur_msg_loglevel (void)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
178

November 2012
Reference Number: 326004-001

rte_log.h File Reference - Intel DPDK

int rte_log_cur_msg_logtype (void)


void rte_log_set_history (int enable)
void rte_log_dump_history (void)
int rte_log_add_in_history (const char buf, size_t size)
int rte_log (uint32_t level, uint32_t logtype, const char format,...)
int rte_vlog (uint32_t level, uint32_t logtype, const char format, va_list ap)

Variables
struct rte_logs rte_logs
FILE eal_default_log_stream

3.21.1

Detailed Description

RTE Logs API


This file provides a log API to RTE applications.

3.21.2

Define Documentation

3.21.2.1

#define RTE LOGTYPE EAL

Log related to eal.

3.21.2.2

#define RTE LOGTYPE MALLOC

Log related to malloc.

3.21.2.3

#define RTE LOGTYPE RING

Log related to ring.

3.21.2.4

#define RTE LOGTYPE MEMPOOL

Log related to mempool.

3.21.2.5

#define RTE LOGTYPE TIMER

Log related to timers.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
179

Intel DPDK - rte_log.h File Reference

3.21.2.6

#define RTE LOGTYPE PMD

Log related to poll mode driver.

3.21.2.7

#define RTE LOGTYPE HASH

Log related to hash table.

3.21.2.8

#define RTE LOGTYPE LPM

Log related to LPM.

3.21.2.9

#define RTE LOGTYPE USER1

User-defined log type 1.

3.21.2.10

#define RTE LOGTYPE USER2

User-defined log type 2.

3.21.2.11

#define RTE LOGTYPE USER3

User-defined log type 3.

3.21.2.12

#define RTE LOGTYPE USER4

User-defined log type 4.

3.21.2.13

#define RTE LOGTYPE USER5

User-defined log type 5.

3.21.2.14

#define RTE LOGTYPE USER6

User-defined log type 6.

3.21.2.15

#define RTE LOGTYPE USER7

User-defined log type 7.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
180

November 2012
Reference Number: 326004-001

rte_log.h File Reference - Intel DPDK

3.21.2.16

#define RTE LOGTYPE USER8

User-defined log type 8.

3.21.2.17

#define RTE LOG EMERG

System is unusable.

3.21.2.18

#define RTE LOG ALERT

Action must be taken immediately.

3.21.2.19

#define RTE LOG CRIT

Critical conditions.

3.21.2.20

#define RTE LOG ERR

Error conditions.

3.21.2.21

#define RTE LOG WARNING

Warning conditions.

3.21.2.22

#define RTE LOG NOTICE

Normal but significant condition.

3.21.2.23

#define RTE LOG INFO

Informational.

3.21.2.24

#define RTE LOG DEBUG

Debug-level messages.

3.21.2.25

#define RTE LOG( l, t, fmt, args... )

Generates a log message.


The RTE_LOG() is equivalent to rte_log() with two differences:

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
181

Intel DPDK - rte_log.h File Reference

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.

3.21.3

Function Documentation

3.21.3.1

int rte openlog stream ( FILE f )

Change the stream that will be used by the logging system.


This can be done at any time. The f argument represents the stream to be used to send the logs. If f is
NULL, the default output is used, which is the serial line in case of bare metal, or directly sent to syslog in
case of linux application.
Parameters
f Pointer to the stream.

Returns
0 on success.
Negative on error.

3.21.3.2

void rte set log level ( uint32 t level )

Set the global log level.


After this call, all logs that are lower or equal than level and lower or equal than the RTE_LOG_LEVEL
configuration option will be displayed.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
182

November 2012
Reference Number: 326004-001

rte_log.h File Reference - Intel DPDK

Parameters
level Log level. A value between RTE_LOG_EMERG (1) and RTE_LOG_DEBUG (8).

3.21.3.3

void rte set log type ( uint32 t type, int enable )

Enable or disable the log type.


Parameters
type Log type, for example, RTE_LOGTYPE_EAL.
enable True for enable; false for disable.

3.21.3.4

int rte log cur msg loglevel ( void )

Get the current loglevel for the message being processed.


Before calling the user-defined stream for logging, the log subsystem sets a per-lcore variable containing
the loglevel and the logtype of the message being processed. This information can be accessed by the
user-defined log output function through this function.
Returns
The loglevel of the message being processed.

3.21.3.5

int rte log cur msg logtype ( void )

Get the current logtype for the message being processed.


Before calling the user-defined stream for logging, the log subsystem sets a per-lcore variable containing
the loglevel and the logtype of the message being processed. This information can be accessed by the
user-defined log output function through this function.
Returns
The logtype of the message being processed.

3.21.3.6

void rte log set history ( int enable )

Enable or disable the history (enabled by default)


Parameters
enable true to enable, or 0 to disable history.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
183

Intel DPDK - rte_log.h File Reference

3.21.3.7

void rte log dump history ( void )

Dump the log history to the console.

3.21.3.8

int rte log add in history ( const char buf, size t size )

Add a log message to the history.


This function can be called from a user-defined log stream. It adds the given message in the history that
can be dumped using rte_log_dump_history().
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.21.3.9

int rte log ( uint32 t level, uint32 t logtype, const char format, ... )

Generates a log message.


The message will be sent in the stream defined by the previous call to rte_openlog_stream().
The level argument determines if the log should be displayed or not, depending on the global rte_logs
variable.
The preferred alternative is the RTE_LOG() function because debug logs may be removed at compilation
time if optimization is enabled. Moreover, logs are automatically prefixed by type when using the macro.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
184

November 2012
Reference Number: 326004-001

rte_lpm.h File Reference - Intel DPDK

int rte vlog ( uint32 t level, uint32 t logtype, const char format, va list ap )

3.21.3.10

Generates a log message.


The message will be sent in the stream defined by the previous call to rte_openlog_stream().
The level argument determines if the log should be displayed or not, depending on the global rte_logs
variable. A trailing newline may be added if needed.
The preferred alternative is the RTE_LOG() because debug logs may be removed at compilation time.
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.

3.21.4

Variable Documentation

3.21.4.1

struct rte_logs rte_logs

Global log informations

3.21.4.2

FILE eal_default_log_stream

The default log stream.

3.22

rte lpm.h File Reference

Data Structures
struct rte_lpm_tbl24_entry
struct rte_lpm_tbl8_entry
struct rte_lpm_rule
struct rte_lpm

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
185

Intel DPDK - rte_lpm.h File Reference

Defines

#define RTE_LPM_NAMESIZE
#define RTE_LPM_HEAP
#define RTE_LPM_MEMZONE
#define RTE_LPM_MAX_DEPTH
#define RTE_LPM_TBL24_NUM_ENTRIES
#define RTE_LPM_TBL8_GROUP_NUM_ENTRIES
#define RTE_LPM_TBL8_NUM_GROUPS
#define RTE_LPM_TBL8_NUM_ENTRIES
#define RTE_LPM_RETURN_IF_TRUE(cond, retval)

Functions

struct rte_lpm rte_lpm_create (const char name, int socket_id, int max_rules, int mem_location)
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)

3.22.1

Detailed Description

RTE Longest Prefix Match (LPM)

3.22.2

Define Documentation

3.22.2.1

#define RTE LPM NAMESIZE

Max number of characters in LPM name.


3.22.2.2

#define RTE LPM HEAP

Possible location to allocate memory.


3.22.2.3

#define RTE LPM MEMZONE

Possible location to allocate memory.


3.22.2.4

#define RTE LPM MAX DEPTH

Maximum depth value possible for IPv4 LPM.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
186

November 2012
Reference Number: 326004-001

rte_lpm.h File Reference - Intel DPDK

3.22.2.5

#define RTE LPM TBL24 NUM ENTRIES

Total number of tbl24 entries.

3.22.2.6

#define RTE LPM TBL8 GROUP NUM ENTRIES

Number of entries in a tbl8 group.

3.22.2.7

#define RTE LPM TBL8 NUM GROUPS

Total number of tbl8 groups in the tbl8.

3.22.2.8

#define RTE LPM TBL8 NUM ENTRIES

Total number of tbl8 entries.

3.22.2.9

#define RTE LPM RETURN IF TRUE( cond, retval )

Macro to enable/disable run-time checks.

3.22.3

Function Documentation

3.22.3.1

struct rte_lpm rte lpm create ( const char name, int socket id, int max rules, int mem location )
[read]

Create an LPM object.


Parameters
name
socket_id
max_rules
mem_location

LPM object name


NUMA socket ID for LPM table memory allocation
Maximum number of LPM rules that can be added
Location of memory to be allocated. Can only be RTE_LPM_HEAP or RTE_LPM_MEMZONE

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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
187

Intel DPDK - rte_lpm.h File Reference

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.22.3.2

struct rte_lpm rte lpm find existing ( const char name ) [read]

Find an existing LPM object and return a pointer to it.


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.

3.22.3.3

void rte lpm free ( struct rte_lpm lpm )

Free an LPM object.


Parameters
lpm LPM object handle

Returns
None

3.22.3.4

int rte lpm add ( struct rte_lpm lpm, uint32 t ip, uint8 t depth, uint8 t next hop )

Add a rule to the LPM table.


Parameters
lpm
ip
depth
next_hop

LPM object handle


IP of the rule to be added to the LPM table
Depth of the rule to be added to the LPM table
Next hop of the rule to be added to the LPM table

Intel Data Plane Development Kit (Intel DPDK)


API Reference
188

November 2012
Reference Number: 326004-001

rte_malloc.h File Reference - Intel DPDK

Returns
0 on success, negative value otherwise

3.22.3.5

int rte lpm delete ( struct rte_lpm lpm, uint32 t ip, uint8 t depth )

Delete a rule from the LPM table.


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.22.3.6

void rte lpm delete all ( struct rte_lpm lpm )

Delete all rules from the LPM table.


Parameters
lpm LPM object handle

3.22.3.7

static int rte lpm lookup ( struct rte_lpm lpm, uint32 t ip, uint8 t next hop ) [static]

Lookup an IP into the LPM table.


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.23

rte malloc.h File Reference

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
189

Intel DPDK - rte_malloc.h File Reference

Functions

void rte_malloc (const char type, size_t size, unsigned align)


void rte_zmalloc (const char type, size_t size, unsigned align)
void rte_calloc (const char type, size_t num, size_t size, unsigned align)
void rte_realloc (void ptr, size_t size, unsigned align)
void rte_free (void ptr)
int rte_malloc_validate (void ptr, size_t size)
void rte_malloc_dump_stats (const char type)
int rte_malloc_set_limit (const char type, size_t max)

3.23.1

Detailed Description

RTE Malloc. This library provides methods for dynamically allocating memory from hugepages.

3.23.2

Function Documentation

3.23.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.
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.23.2.2

void rte zmalloc ( const char type, size t size, unsigned align )

Allocate zeroed memory from the heap.


Equivalent to rte_malloc() except that the memory zone is initialised with zeros.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
190

November 2012
Reference Number: 326004-001

rte_malloc.h File Reference - Intel DPDK

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.23.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.
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.23.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.
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)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
191

Intel DPDK - rte_malloc.h File Reference

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.23.2.5

void rte free ( void ptr )

Frees the memory space pointed to by the provided pointer.


This pointer must have been returned by a previous call to rte_malloc(), rte_zmalloc(), rte_calloc() or rte_realloc(). The behaviour of rte_free() is undefined if the pointer does not match this requirement.
If the pointer is NULL, the function does nothing.
Parameters
ptr The pointer to memory to be freed.

3.23.2.6

int rte malloc validate ( void ptr, size t size )

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.23.2.7

void rte malloc dump stats ( const char type )

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
192

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

int rte malloc set limit ( const char type, size t max )

3.23.2.8

Set the maximum amount of allocated memory for this type.


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.

rte mbuf.h File Reference

3.24

Data Structures

struct rte_ctrlmbuf
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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
193

Intel DPDK - rte_mbuf.h File Reference

#define PKT_TX_OFFLOAD_MASK
#define TX_VLAN_CMP_MASK
#define TX_MAC_LEN_CMP_MASK
#define TX_IP_LEN_CMP_MASK
#define TX_MACIP_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)
static struct rte_mbuf __rte_mbuf_raw_alloc (struct rte_mempool mp)
static void __rte_mbuf_raw_free (struct rte_mbuf m)
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)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
194

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

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)

3.24.1

Detailed Description

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.

3.24.2

Define Documentation

3.24.2.1

#define PKT RX VLAN PKT

RX packet is a 802.1q VLAN packet.

3.24.2.2

#define PKT RX RSS HASH

RX packet with RSS hash result.

3.24.2.3

#define PKT RX FDIR

RX packet with FDIR infos.

3.24.2.4

#define PKT RX L4 CKSUM BAD

L4 cksum of RX pkt. is not OK.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
195

Intel DPDK - rte_mbuf.h File Reference

3.24.2.5

#define PKT RX IP CKSUM BAD

IP cksum of RX pkt. is not OK.

3.24.2.6

#define PKT RX IPV4 HDR

RX packet with IPv4 header.

3.24.2.7

#define PKT RX IPV4 HDR EXT

RX packet with extended IPv4 header.

3.24.2.8

#define PKT RX IPV6 HDR

RX packet with IPv6 header.

3.24.2.9

#define PKT RX IPV6 HDR EXT

RX packet with extended IPv6 header.

3.24.2.10

#define PKT RX IEEE1588 PTP

RX IEEE1588 L2 Ethernet PT Packet.

3.24.2.11

#define PKT RX IEEE1588 TMST

RX IEEE1588 L2/L4 timestamped packet.

3.24.2.12

#define PKT TX VLAN PKT

TX packet is a 802.1q VLAN packet.

3.24.2.13

#define PKT TX IP CKSUM

IP cksum of TX pkt. computed by NIC.

3.24.2.14

#define PKT TX L4 MASK

Mask bits for L4 checksum offload request.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
196

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

3.24.2.15

#define PKT TX L4 NO CKSUM

Disable L4 cksum of TX pkt.

3.24.2.16

#define PKT TX TCP CKSUM

TCP cksum of TX pkt. computed by NIC.

3.24.2.17

#define PKT TX SCTP CKSUM

SCTP cksum of TX pkt. computed by NIC.

3.24.2.18

#define PKT TX UDP CKSUM

UDP cksum of TX pkt. computed by NIC.

3.24.2.19

#define PKT TX IEEE1588 TMST

TX IEEE1588 packet to timestamp.

3.24.2.20

#define PKT TX OFFLOAD MASK

Bit Mask to indicate what bits required for building TX context

3.24.2.21

#define TX VLAN CMP MASK

VLAN length - 16-bits.

3.24.2.22

#define TX MAC LEN CMP MASK

MAC length - 7-bits.

3.24.2.23

#define TX IP LEN CMP MASK

IP length - 9-bits.

3.24.2.24

#define TX MACIP LEN CMP MASK

MAC+IP length.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
197

Intel DPDK - rte_mbuf.h File Reference

3.24.2.25

#define RTE MBUF FROM BADDR( ba )

Given the buf_addr returns the pointer to corresponding mbuf.

3.24.2.26

#define RTE MBUF TO BADDR( mb )

Given the pointer to mbuf returns an address where its buf_addr should point to.

3.24.2.27

#define RTE MBUF INDIRECT( mb )

Returns TRUE if given mbuf is indirect, or FALSE otherwise.

3.24.2.28

#define RTE MBUF DIRECT( mb )

Returns TRUE if given mbuf is direct, or FALSE otherwise.

3.24.2.29

#define rte mbuf sanity check( m, t, is h )

check mbuf type in debug mode

3.24.2.30

#define rte mbuf sanity check raw( m, t, is h )

check mbuf type in debug mode if mbuf pointer is not null

3.24.2.31

#define RTE MBUF ASSERT( exp )

MBUF asserts in debug mode

3.24.2.32

#define RTE MBUF PREFETCH TO FREE( m )

Mbuf prefetch

3.24.2.33

#define rte ctrlmbuf data( m )

A macro that returns the pointer to the carried data.


The value that can be read or assigned.
Parameters
m The control mbuf.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
198

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

3.24.2.34

#define rte ctrlmbuf len( m )

A macro that returns the length of the carried data.


The value that can be read or assigned.
Parameters
m The control mbuf.

3.24.2.35

#define rte pktmbuf mtod( m, t )

A macro that points to the start of the data in the mbuf.


The returned pointer is cast to type t. Before using this function, the user must ensure that m_headlen(m) is
large enough to read its data.
Parameters
m The packet mbuf.
t The type to cast the result into.

3.24.2.36

#define rte pktmbuf pkt len( m )

A macro that returns the length of the packet.


The value can be read or assigned.
Parameters
m The packet mbuf.

3.24.2.37

#define rte pktmbuf data len( m )

A macro that returns the length of the segment.


The value can be read or assigned.
Parameters
m The packet mbuf.

3.24.3

Enumeration Type Documentation

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
199

Intel DPDK - rte_mbuf.h File Reference

3.24.3.1

enum rte_mbuf_type

This enum indicates the mbuf type.


Enumerator:
RTE_MBUF_CTRL Control mbuf.
RTE_MBUF_PKT Packet mbuf.

3.24.4

Function Documentation

3.24.4.1

static uint16 t rte mbuf refcnt update ( struct rte_mbuf m, int16 t value ) [static]

Adds given value to an mbufs refcnt and returns its new value.
Parameters
m Mbuf to update
value Value to add/subtract

Returns
Updated value

3.24.4.2

static uint16 t rte mbuf refcnt read ( const struct rte_mbuf m ) [static]

Reads the value of an mbufs refcnt.


Parameters
m Mbuf to read

Returns
Reference count number.

3.24.4.3

static void rte mbuf refcnt set ( struct rte_mbuf m, uint16 t new value ) [static]

Sets an mbufs refcnt to a defined value.


Parameters
m Mbuf to update
new_value Value set

Intel Data Plane Development Kit (Intel DPDK)


API Reference
200

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

3.24.4.4

void rte mbuf sanity check ( const struct rte_mbuf m, enum rte_mbuf_type t, int is header )

Sanity checks on an mbuf.


Check the consistency of the given mbuf. The function will cause a panic if corruption is detected.
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.24.4.5

static struct rte_mbuf rte mbuf raw alloc ( struct rte_mempool mp ) [static, read]

Allocate a new mbuf from mempool mp. The use of that function is reserved for RTE internal needs.
Please use either rte_ctrlmbuf_alloc() or rte_pktmbuf_alloc().
Parameters
mp The mempool from which mbuf is allocated.

Returns
The pointer to the new mbuf on success.
NULL if allocation failed.

3.24.4.6

static void rte mbuf raw free ( struct rte_mbuf m ) [static]

Put mbuf back into its original mempool. The use of that function is reserved for RTE internal needs. Please
use either rte_ctrlmbuf_free() or rte_pktmbuf_free().
Parameters
m The mbuf to be freed.

3.24.4.7

void rte ctrlmbuf init ( struct rte_mempool mp, void opaque arg, void m, unsigned i )

The control mbuf constructor.


This function initializes some fields in an mbuf structure that are not modified by the user once created
(mbuf type, origin pool, buffer start address, and so on). This function is given as a callback function to
rte_mempool_create() at pool creation time.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
201

Intel DPDK - rte_mbuf.h File Reference

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.

static struct rte_mbuf rte ctrlmbuf alloc ( struct rte_mempool mp ) [static, read]

3.24.4.8

Allocate a new mbuf (type is ctrl) from mempool mp.


This new mbuf is initialized with data pointing to the beginning of buffer, and with a length of zero.
Parameters
mp The mempool from which the mbuf is allocated.

Returns
The pointer to the new mbuf on success.
NULL if allocation failed.

3.24.4.9

static void rte ctrlmbuf free ( struct rte_mbuf m ) [static]

Free a control mbuf back into its original mempool.


Parameters
m The control mbuf to be freed.

3.24.4.10

void rte pktmbuf init ( struct rte_mempool mp, void opaque arg, void m, unsigned i )

The packet mbuf constructor.


This function initializes some fields in the mbuf structure that are not modified by the user once created
(mbuf type, origin pool, buffer start address, and so on). This function is given as a callback function to
rte_mempool_create() at pool creation time.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
202

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

3.24.4.11

void rte pktmbuf pool init ( struct rte_mempool mp, void opaque arg )

A packet mbuf pool constructor.


This function initializes the mempool private data in the case of a pktmbuf pool. This private data is needed
by the driver. The function is given as a callback function to rte_mempool_create() at pool creation. It can
be extended by the user, for example, to provide another packet size.
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().

3.24.4.12

static void rte pktmbuf reset ( struct rte_mbuf m ) [static]

Reset the fields of a packet mbuf to their default values.


The given mbuf must have only one segment.
Parameters
m The packet mbuf to be resetted.

3.24.4.13

static struct rte_mbuf rte pktmbuf alloc ( struct rte_mempool mp ) [static, read]

Allocate a new mbuf (type is pkt) from a mempool.


This new mbuf contains one segment, which has a length of 0. The pointer to data is initialized to have
some bytes of headroom in the buffer (if buffer size allows).
Parameters
mp The mempool from which the mbuf is allocated.

Returns
The pointer to the new mbuf on success.
NULL if allocation failed.

3.24.4.14

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:
attachment to indirect mbuf (e.g. - md has to be direct).

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
203

Intel DPDK - rte_mbuf.h File Reference

attachment for already indirect mbuf (e.g. - mi has to be direct).


mbuf we trying to attach (mi) is used by someone else e.g. its reference counter is greater then 1.
Parameters
mi The indirect packet mbuf.
md The direct packet mbuf.

3.24.4.15

static void rte pktmbuf detach ( struct rte_mbuf m ) [static]

Detach an indirect packet mbuf restore original mbuf address and length values.
reset pktmbuf data and data_len to their default values. All other fields of the given packet mbuf will be
left intact.
Parameters
m The indirect attached packet mbuf.

3.24.4.16

static void rte pktmbuf free seg ( struct rte_mbuf m ) [static]

Free a segment of a packet mbuf into its original mempool.


Free an mbuf, without parsing other segments in case of chained buffers.
Parameters
m The packet mbuf segment to be freed.

3.24.4.17

static void rte pktmbuf free ( struct rte_mbuf m ) [static]

Free a packet mbuf back into its original mempool.


Free an mbuf, and all its segments in case of chained buffers. Each segment is added back into its original
mempool.
Parameters
m The packet mbuf to be freed.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
204

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

3.24.4.18

static struct rte_mbuf rte pktmbuf clone ( struct rte_mbuf md, struct rte_mempool mp )
[static, read]

Creates a "clone" of the given packet mbuf.


Walks through all segments of the given packet mbuf, and for each of them:
Creates a new packet mbuf from the given pool.
Attaches newly created mbuf to the segment. Then updates pkt_len and nb_segs of the "clone" packet
mbuf to match values from the original packet mbuf.
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.24.4.19

static void rte pktmbuf refcnt update ( struct rte_mbuf m, int16 t v ) [static]

Adds given value to the refcnt of all packet mbuf segments.


Walks through all segments of given packet mbuf and for each of them invokes rte_mbuf_refcnt_update().
Parameters
m The packet mbuf whose refcnt to be updated.
v The value to add to the mbufs segments refcnt.

3.24.4.20

static uint16 t rte pktmbuf headroom ( const struct rte_mbuf m ) [static]

Get the headroom in a packet mbuf.


Parameters
m The packet mbuf.

Returns
The length of the headroom.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
205

Intel DPDK - rte_mbuf.h File Reference

3.24.4.21

static uint16 t rte pktmbuf tailroom ( const struct rte_mbuf m ) [static]

Get the tailroom of a packet mbuf.


Parameters
m The packet mbuf.

Returns
The length of the tailroom.

3.24.4.22

static struct rte_mbuf rte pktmbuf lastseg ( struct rte_mbuf m ) [static, read]

Get the last segment of the packet.


Parameters
m The packet mbuf.

Returns
The last segment of the given mbuf.

3.24.4.23

static char rte pktmbuf prepend ( struct rte_mbuf m, uint16 t len ) [static]

Prepend len bytes to an mbuf data area.


Returns a pointer to the new data start address. If there is not enough headroom in the first segment, the
function will return NULL, without modifying the mbuf.
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.24.4.24

static char rte pktmbuf append ( struct rte_mbuf m, uint16 t len ) [static]

Append len bytes to an mbuf.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
206

November 2012
Reference Number: 326004-001

rte_mbuf.h File Reference - Intel DPDK

Append len bytes to an mbuf and return a pointer to the start address of the added data. If there is not
enough tailroom in the last segment, the function will return NULL, without modifying the mbuf.
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.24.4.25

static char rte pktmbuf adj ( struct rte_mbuf m, uint16 t len ) [static]

Remove len bytes at the beginning of an mbuf.


Returns a pointer to the start address of the new data area. If the length is greater than the length of the
first segment, then the function will fail and return NULL, without modifying the mbuf.
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.24.4.26

static int rte pktmbuf trim ( struct rte_mbuf m, uint16 t len ) [static]

Remove len bytes of data at the end of the mbuf.


If the length is greater than the length of the last segment, the function will fail and return -1 without modifying
the mbuf.
Parameters
m The packet mbuf.
len The amount of data to remove (in bytes).

Returns
0: On success.
-1: On error.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
207

Intel DPDK - rte_memcpy.h File Reference

static int rte pktmbuf is contiguous ( const struct rte_mbuf m ) [static]

3.24.4.27

Test if mbuf data is contiguous.


Parameters
m The packet mbuf.

Returns
1, if all data is contiguous (one segment).
0, if there is several segments.

void rte pktmbuf dump ( const struct rte_mbuf m, unsigned dump len )

3.24.4.28

Dump an mbuf structure to the console.


Dump all fields for the given packet mbuf and all its associated segments (in the case of a chained buffer).
Parameters
m The packet mbuf.
dump_len If dump_len != 0, also dump the "dump_len" first data bytes of the packet.

3.25

rte memcpy.h File Reference

Defines
#define rte_memcpy

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)
static void rte_memcpy_func (void dst, const void src, size_t n)

3.25.1

Detailed Description

Functions for SSE implementation of memcpy().

Intel Data Plane Development Kit (Intel DPDK)


API Reference
208

November 2012
Reference Number: 326004-001

rte_memcpy.h File Reference - Intel DPDK

3.25.2

Define Documentation

3.25.2.1

#define rte memcpy

Always use DPDK implementation.

3.25.3

Function Documentation

3.25.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.25.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.25.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.25.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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
209

Intel DPDK - rte_memory.h File Reference

Parameters
dst Pointer to the destination of the data.
src Pointer to the source data.

3.25.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.25.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.

3.25.3.7

static void rte memcpy func ( void dst, const void src, size t n ) [static]

Copy bytes from one location to another. The locations must not overlap.
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.26

rte memory.h File Reference

Data Structures
struct rte_memseg

Intel Data Plane Development Kit (Intel DPDK)


API Reference
210

November 2012
Reference Number: 326004-001

rte_memory.h File Reference - Intel DPDK

Defines

#define SOCKET_ID_ANY
#define CACHE_LINE_SIZE
#define CACHE_LINE_MASK
#define CACHE_LINE_ROUNDUP(size)
#define __rte_cache_aligned

Typedefs
typedef uint64_t phys_addr_t

Functions

struct rte_memseg rte_eal_get_physmem_layout (void)


void rte_dump_physmem_layout (void)
uint64_t rte_eal_get_physmem_size (void)
unsigned rte_memory_get_nchannel (void)
unsigned rte_memory_get_nrank (void)

3.26.1

Detailed Description

Memory-related RTE API.

3.26.2

Define Documentation

3.26.2.1

#define SOCKET ID ANY

Any NUMA socket.

3.26.2.2

#define CACHE LINE SIZE

Cache line size.

3.26.2.3

#define CACHE LINE MASK

Cache line mask.

3.26.2.4

#define CACHE LINE ROUNDUP( size )

Return the first cache-aligned value greater or equal to size.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
211

Intel DPDK - rte_memory.h File Reference

3.26.2.5

#define rte cache aligned

Force alignment to cache line.

3.26.3

Typedef Documentation

3.26.3.1

typedef uint64 t phys_addr_t

Physical address definition.

3.26.4

Function Documentation

3.26.4.1

struct rte_memseg rte eal get physmem layout ( void ) [read]

Get the layout of the available physical memory.


It can be useful for an application to have the full physical memory layout to decide the size of a memory
zone to reserve. This table is stored in rte_config (see rte_eal_get_configuration()).
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.

3.26.4.2

void rte dump physmem layout ( void )

Dump the physical memory layout to the console.

3.26.4.3

uint64 t rte eal get physmem size ( void )

Get the total amount of available physical memory.


Returns
The total amount of available physical memory in bytes.

3.26.4.4

unsigned rte memory get nchannel ( void )

Get the number of memory channels.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
212

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

Returns
The number of memory channels on the system. The value is 0 if unknown or not the same on all
devices.

3.26.4.5

unsigned rte memory get nrank ( void )

Get the number of memory ranks.


Returns
The number of memory ranks on the system. The value is 0 if unknown or not the same on all devices.

3.27

rte mempool.h File Reference

Data Structures
struct rte_mempool_cache
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_F_NO_SPREAD
#define MEMPOOL_F_NO_CACHE_ALIGN
#define MEMPOOL_F_SP_PUT
#define MEMPOOL_F_SC_GET
#define __MEMPOOL_STAT_ADD(mp, name, n)
#define __mempool_check_cookies(mp, obj_table_const, n, free)

Typedefs
typedef void( rte_mempool_obj_ctor_t )(struct rte_mempool , void , void , unsigned)
typedef void( rte_mempool_ctor_t )(struct rte_mempool , void )

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
213

Intel DPDK - rte_mempool.h File Reference

Functions
static struct rte_mempool __mempool_from_obj (void obj)
static struct rte_mempool rte_mempool_from_obj (void obj)
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)
static int rte_mempool_set_bulk_count (struct rte_mempool mp, unsigned count)
static unsigned rte_mempool_get_bulk_count (struct rte_mempool mp)
void rte_mempool_dump (const struct rte_mempool mp)
static void __mempool_put_bulk (struct rte_mempool mp, void const obj_table, unsigned n, int
is_mp)
static void rte_mempool_mp_put_bulk (struct rte_mempool mp, void const obj_table, unsigned n)
static void rte_mempool_sp_put_bulk (struct rte_mempool mp, void const obj_table, unsigned n)
static void rte_mempool_put_bulk (struct rte_mempool mp, void const obj_table, unsigned n)
static void rte_mempool_mp_put (struct rte_mempool mp, void obj)
static void rte_mempool_sp_put (struct rte_mempool mp, void obj)
static void rte_mempool_put (struct rte_mempool mp, void obj)
static int __mempool_get_bulk (struct rte_mempool mp, void obj_table, unsigned n, int is_mc)
static int rte_mempool_mc_get_bulk (struct rte_mempool mp, void obj_table, unsigned n)
static int rte_mempool_sc_get_bulk (struct rte_mempool mp, void obj_table, unsigned n)
static int rte_mempool_get_bulk (struct rte_mempool mp, void obj_table, unsigned n)
static int rte_mempool_mc_get (struct rte_mempool mp, void obj_p)
static int rte_mempool_sc_get (struct rte_mempool mp, void obj_p)
static int rte_mempool_get (struct rte_mempool mp, void obj_p)
unsigned rte_mempool_count (const struct rte_mempool mp)
static unsigned rte_mempool_free_count (const struct rte_mempool mp)
static int rte_mempool_full (const struct rte_mempool mp)
static int rte_mempool_empty (const struct rte_mempool mp)
static phys_addr_t rte_mempool_virt2phy (const struct rte_mempool mp, const void elt)
void rte_mempool_audit (const struct rte_mempool mp)
static void rte_mempool_get_priv (struct rte_mempool mp)
void rte_mempool_list_dump (void)
struct rte_mempool rte_mempool_lookup (const char name)

3.27.1

Detailed Description

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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
214

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

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 wont work as
rte_lcore_id() will not return a correct value.

3.27.2

Define Documentation

3.27.2.1

#define RTE MEMPOOL HEADER COOKIE1

Header cookie.

3.27.2.2

#define RTE MEMPOOL HEADER COOKIE2

Header cookie.

3.27.2.3

#define RTE MEMPOOL TRAILER COOKIE

Trailer cookie.

3.27.2.4

#define RTE MEMPOOL NAMESIZE

Maximum length of a memory pool.

3.27.2.5

#define MEMPOOL F NO SPREAD

Do not spread in memory.

3.27.2.6

#define MEMPOOL F NO CACHE ALIGN

Do not align objs on cache lines.

3.27.2.7

#define MEMPOOL F SP PUT

Default put is "single-producer".

3.27.2.8

#define MEMPOOL F SC GET

Default get is "single-consumer".

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
215

Intel DPDK - rte_mempool.h File Reference

3.27.2.9

#define MEMPOOL STAT ADD( mp, name, n )

When debug is enabled, store some statistics.


Parameters
mp Pointer to the memory pool.
name Name of the statistics field to increment in the memory pool.
n Number to add to the object-oriented statistics.

3.27.2.10

#define mempool check cookies( mp, obj table const, n, free )

Check and update cookies or panic.


Parameters
mp Pointer to the memory pool.
obj_table_const Pointer to a table of void pointers (objects).
n Index of object in object table.
free
0: object is supposed to be allocated, mark it as free
1: object is supposed to be free, mark it as allocated
2: just check that cookie is valid (free or allocated)

3.27.3

Typedef Documentation

3.27.3.1

typedef void( rte_mempool_obj_ctor_t)(struct rte_mempool , void , void , unsigned)

An object constructor callback function for mempool.


Arguments are the mempool, the opaque pointer given by the user in rte_mempool_create(), the pointer to
the element and the index of the element in the pool.

3.27.3.2

typedef void( rte_mempool_ctor_t)(struct rte_mempool , void )

A mempool constructor callback function.


Arguments are the mempool and the opaque pointer given by the user in rte_mempool_create().

3.27.4

Function Documentation

Intel Data Plane Development Kit (Intel DPDK)


API Reference
216

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

3.27.4.1

static struct rte_mempool mempool from obj ( void obj ) [static, read]

Get a pointer to a mempool pointer in the object header.


Parameters
obj Pointer to object.

Returns
The pointer to the mempool from which the object was allocated.

3.27.4.2

static struct rte_mempool rte mempool from obj ( void obj ) [static, read]

Return a pointer to the mempool owning this object.


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.27.4.3

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]

Creates a new mempool named name in memory.


This function uses memzone_reserve() to allocate memory. The pool contains n elements of elt_size. Its
size is set to n. By default, bulk_default_count (the default number of elements to get/put in the pool) is set
to 1.
See also
rte_mempool_set_bulk_count() to modify this valule.

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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
217

Intel DPDK - rte_mempool.h File Reference

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 perlcore 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 cachealigned. 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

Intel Data Plane Development Kit (Intel DPDK)


API Reference
218

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

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.27.4.4

static int rte mempool set bulk count ( struct rte_mempool mp, unsigned count ) [static]

Set the default bulk count for put/get.


The count parameter is the default number of bulk elements to get/put when using rte_mempool__{en,de}queue_bulk(). It must be greater than 0 and less than half of the mempool size.
Parameters
mp A pointer to the mempool structure.
count A new water mark value.

Returns
0: Success; default_bulk_count changed.
-EINVAL: Invalid count value.

3.27.4.5

static unsigned rte mempool get bulk count ( struct rte_mempool mp ) [static]

Get the default bulk count for put/get.


Parameters
mp A pointer to the mempool structure.

Returns
The default bulk count for enqueue/dequeue.

3.27.4.6

void rte mempool dump ( const struct rte_mempool mp )

Dump the status of the mempool to the console.


Parameters
mp A pointer to the mempool structure.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
219

Intel DPDK - rte_mempool.h File Reference

3.27.4.7

static void mempool put bulk ( struct rte_mempool mp, void const obj table, unsigned n, int is mp
) [static]

Put several objects back in the mempool; used internally.


Parameters
mp
obj_table
n
is_mp

3.27.4.8

A pointer to the mempool structure.


A pointer to a table of void pointers (objects).
The number of objects to store back in the mempool, must be strictly positive.
Mono-producer (0) or multi-producers (1).

static void rte mempool mp put bulk ( struct rte_mempool mp, void const obj table, unsigned n )
[static]

Put several objects back in the mempool (multi-producers safe).


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.27.4.9

static void rte mempool sp put bulk ( struct rte_mempool mp, void const obj table, unsigned n )
[static]

Put several objects back in the mempool (NOT multi-producers safe).


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.

static void rte mempool put bulk ( struct rte_mempool mp, void const obj table, unsigned n )
[static]

3.27.4.10

Put several objects back in the mempool.


This function calls the multi-producer or the single-producer version depending on the default behavior that
was specified at mempool creation time (see flags).
Parameters
mp A pointer to the mempool structure.
obj_table A pointer to a table of void pointers (objects).

Intel Data Plane Development Kit (Intel DPDK)


API Reference
220

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

n The number of objects to add in the mempool from obj_table.

static void rte mempool mp put ( struct rte_mempool mp, void obj ) [static]

3.27.4.11

Put one object in the mempool (multi-producers safe).


Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.

static void rte mempool sp put ( struct rte_mempool mp, void obj ) [static]

3.27.4.12

Put one object back in the mempool (NOT multi-producers safe).


Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.

static void rte mempool put ( struct rte_mempool mp, void obj ) [static]

3.27.4.13

Put one object back in the mempool.


This function calls the multi-producer or the single-producer version depending on the default behavior that
was specified at mempool creation time (see flags).
Parameters
mp A pointer to the mempool structure.
obj A pointer to the object to be added.

static int mempool get bulk ( struct rte_mempool mp, void obj table, unsigned n, int is mc )
[static]

3.27.4.14

Get several objects from the mempool; used internally.


Parameters
mp
obj_table
n
is_mc

A pointer to the mempool structure.


A pointer to a table of void pointers (objects).
The number of objects to get, must be strictly positive.
Mono-consumer (0) or multi-consumers (1).

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
221

Intel DPDK - rte_mempool.h File Reference

Returns
>=0: Success; number of objects supplied.
<0: Error; code of ring dequeue function.

static int rte mempool mc get bulk ( struct rte_mempool mp, void obj table, unsigned n )
[static]

3.27.4.15

Get several objects from the mempool (multi-consumers safe).


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 mempool to obj_table.

Returns
0: Success; objects taken.
-ENOENT: Not enough entries in the mempool; no object is retrieved.

static int rte mempool sc get bulk ( struct rte_mempool mp, void obj table, unsigned n )
[static]

3.27.4.16

Get several objects from the mempool (NOT multi-consumers safe).


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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
222

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

static int rte mempool get bulk ( struct rte_mempool mp, void obj table, unsigned n ) [static]

3.27.4.17

Get several objects from the mempool.


This function calls the multi-consumers or the single-consumer version, depending on the default behaviour
that was specified at mempool creation time (see flags).
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.27.4.18

static int rte mempool mc get ( struct rte_mempool mp, void obj p ) [static]

Get one object from the mempool (multi-consumers safe).


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_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.27.4.19

static int rte mempool sc get ( struct rte_mempool mp, void obj p ) [static]

Get one object from the mempool (NOT multi-consumers safe).


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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
223

Intel DPDK - rte_mempool.h File Reference

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.27.4.20

static int rte mempool get ( struct rte_mempool mp, void obj p ) [static]

Get one object from the mempool.


This function calls the multi-consumers or the single-consumer version, depending on the default behavior
that was specified at mempool creation (see flags).
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_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.27.4.21

unsigned rte mempool count ( const struct rte_mempool mp )

Return the number of entries in the mempool.


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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
224

November 2012
Reference Number: 326004-001

rte_mempool.h File Reference - Intel DPDK

3.27.4.22

static unsigned rte mempool free count ( const struct rte_mempool mp ) [static]

Return the number of free entries in the mempool.


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.27.4.23

static int rte mempool full ( const struct rte_mempool mp ) [static]

Test if the mempool is full.


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
1: The mempool is full.
0: The mempool is not full.

3.27.4.24

static int rte mempool empty ( const struct rte_mempool mp ) [static]

Test if the mempool is empty.


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
1: The mempool is empty.
0: The mempool is not empty.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
225

Intel DPDK - rte_mempool.h File Reference

3.27.4.25

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.

3.27.4.26

void rte mempool audit ( const struct rte_mempool mp )

Check the consistency of mempool objects.


Verify the coherency of fields in the mempool structure. Also check that the cookies of mempool objects
(even the ones that are not present in pool) have a correct value. If not, a panic will occur.
Parameters
mp A pointer to the mempool structure.

3.27.4.27

static void rte mempool get priv ( struct rte_mempool mp ) [static]

Return a pointer to the private data in an mempool structure.


Parameters
mp A pointer to the mempool structure.

Returns
A pointer to the private data.

3.27.4.28

void rte mempool list dump ( void )

Dump the status of all mempools on the console

3.27.4.29

struct rte_mempool rte mempool lookup ( const char name ) [read]

Search a mempool from its name

Intel Data Plane Development Kit (Intel DPDK)


API Reference
226

November 2012
Reference Number: 326004-001

rte_memzone.h File Reference - Intel DPDK

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.

rte memzone.h File Reference

3.28

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, uint64_t len, int socket_id, unsigned
flags)
struct rte_memzone rte_memzone_reserve_aligned (const char name, uint64_t len, int socket_id,
unsigned flags, unsigned align)
struct rte_memzone rte_memzone_lookup (const char name)
void rte_memzone_dump (void)

3.28.1

Detailed Description

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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
227

Intel DPDK - rte_memzone.h File Reference

3.28.2

Define Documentation

3.28.2.1

#define RTE MEMZONE 2MB

Use 2MB pages.

3.28.2.2

#define RTE MEMZONE 1GB

Use 1GB pages.

3.28.2.3

#define RTE MEMZONE SIZE HINT ONLY

Use available page size

3.28.2.4

#define RTE MEMZONE NAMESIZE

Maximum length of memory zone name.

3.28.3

Function Documentation

3.28.3.1

struct rte_memzone rte memzone reserve ( const char name, uint64 t len, int socket id, unsigned
flags ) [read]

Reserve a portion of physical memory.


This function reserves some memory and returns a pointer to a correctly filled memzone descriptor. If the
allocation cannot be done, return NULL. Note: A reserved zone cannot be freed.
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
228

November 2012
Reference Number: 326004-001

rte_memzone.h File Reference - Intel DPDK

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.28.3.2

struct rte_memzone rte memzone reserve aligned ( const char name, uint64 t len, int socket id,
unsigned flags, unsigned align ) [read]

Reserve a portion of physical memory with alignment on a specified boundary.


This function reserves some memory with alignment on a specified boundary, and returns a pointer to a
correctly filled memzone descriptor. If the allocation cannot be done or if the alignment is not a power of 2,
returns NULL. Note: A reserved zone cannot be freed.
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.
align Alignment for resulting memzone. Must be a power of 2.
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

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
229

Intel DPDK - rte_pci.h File Reference

ENOMEM - no appropriate memory area found in which to create memzone


EINVAL - invalid parameters

3.28.3.3

struct rte_memzone rte memzone lookup ( const char name ) [read]

Lookup for a memzone.


Get a pointer to a descriptor of an already reserved memory zone identified by the name given as an
argument.
Parameters
name The name of the memzone.

Returns
A pointer to a read-only memzone descriptor.

3.28.3.4

void rte memzone dump ( void )

Dump all reserved memzones to the console.

3.29

rte pci.h File Reference

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_FMT_NVAL
#define PCI_RESOURCE_FMT_NVAL
#define PCI_MAX_RESOURCE
#define PCI_ANY_ID
#define RTE_PCI_DEVICE(vend, dev)

Intel Data Plane Development Kit (Intel DPDK)


API Reference
230

November 2012
Reference Number: 326004-001

rte_pci.h File Reference - Intel DPDK

Typedefs
typedef int( pci_devinit_t )(struct rte_pci_driver , struct rte_pci_device )

Functions

TAILQ_HEAD (pci_device_list, rte_pci_device)


TAILQ_HEAD (pci_driver_list, rte_pci_driver)
int rte_eal_pci_probe (void)
void rte_eal_pci_dump (void)
void rte_eal_pci_register (struct rte_pci_driver driver)
void rte_eal_pci_set_blacklist (struct rte_pci_addr blacklist, unsigned size)

Variables
struct pci_driver_list driver_list
struct pci_device_list device_list

3.29.1

Detailed Description

RTE PCI Interface

3.29.2

Define Documentation

3.29.2.1

#define SYSFS PCI DEVICES

Pathname of PCI devices directory.

3.29.2.2

#define PCI PRI FMT

Formatting string for PCI device identifier: Ex: 0000:00:01.0

3.29.2.3

#define PCI FMT NVAL

Nb. of values in PCI device identifier format string.

3.29.2.4

#define PCI RESOURCE FMT NVAL

Nb. of values in PCI resource format.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
231

Intel DPDK - rte_pci.h File Reference

3.29.2.5

#define PCI MAX RESOURCE

Maximum number of PCI resources.

3.29.2.6

#define PCI ANY ID

Any PCI device identifier (vendor, device, ...)

3.29.2.7

#define RTE PCI DEVICE( vend, dev )

Macro used to help building up tables of device IDs

3.29.3

Typedef Documentation

3.29.3.1

typedef int( pci_devinit_t)(struct rte_pci_driver , struct rte_pci_device )

Initialisation function for the driver called during PCI probing.

3.29.4

Function Documentation

3.29.4.1

TAILQ HEAD ( pci device list , rte_pci_device )

PCI devices in D-linked Q.

3.29.4.2

TAILQ HEAD ( pci driver list , rte_pci_driver )

PCI drivers in D-linked Q.

3.29.4.3

int rte eal pci probe ( void )

Probe the PCI bus for registered drivers.


Scan the content of the PCI bus, and call the probe() function for all registered drivers that have a matching
entry in its id_table for discovered devices.
Returns
0 on success.
Negative on error.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
232

November 2012
Reference Number: 326004-001

rte_pci_dev_ids.h File Reference - Intel DPDK

3.29.4.4

void rte eal pci dump ( void )

Dump the content of the PCI bus.

3.29.4.5

void rte eal pci register ( struct rte_pci_driver driver )

Register a PCI driver.


Parameters
driver A pointer to a rte_pci_driver structure describing the driver to be registered.

3.29.4.6

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.

3.29.5

Variable Documentation

3.29.5.1

struct pci driver list driver_list

Global list of PCI drivers.

3.29.5.2

struct pci device list device_list

Global list of PCI devices.

3.30

rte pci dev ids.h File Reference

Defines
#define PCI_VENDOR_ID_INTEL

3.30.1

Detailed Description

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.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
233

Intel DPDK - rte_per_lcore.h File Reference

Currently two families of devices are recognised: those supported by the IGB driver, and those supported
by the IXGBE driver. The inclusion of these in an array built using this file depends on the definition of
RTE_LIBRTE_IGB_PMD and RTE_LIBRTE_IXGBE_PMD 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(vendorID, deviceID). For example:
struct device {
int vend;
int dev;
};
struct device devices[] = {
#define RTE_PCI_DEV_ID_DECL(vendorID, deviceID) {vend, dev},
#include <rte_pci_dev_ids.h>
};

Note that this file can be included multiple times within the same file.

3.30.2

Define Documentation

3.30.2.1

#define PCI VENDOR ID INTEL

Vendor ID used by Intel devices

3.31

rte per lcore.h File Reference

Defines
#define RTE_DEFINE_PER_LCORE(type, name)
#define RTE_DECLARE_PER_LCORE(type, name)
#define RTE_PER_LCORE(name)

3.31.1

Detailed Description

Per-lcore variables in RTE


This file defines an API for instantiating per-lcore "global variables" that are environment-specific. Note that
in all environments, a "shared variable" is the default when you use a global variable.
Parts of this are execution environment specific.

3.31.2

Define Documentation

Intel Data Plane Development Kit (Intel DPDK)


API Reference
234

November 2012
Reference Number: 326004-001

rte_prefetch.h File Reference - Intel DPDK

3.31.2.1

#define RTE DEFINE PER LCORE( type, name )

Macro to define a per lcore variable "var" of type "type", dont use keywords like "static" or "volatile" in type,
just prefix the whole macro.

3.31.2.2

#define RTE DECLARE PER LCORE( type, name )

Macro to declare an extern per lcore variable "var" of type "type"

3.31.2.3

#define RTE PER LCORE( name )

Read/write the per-lcore variable value

3.32

rte prefetch.h File Reference

Functions
static void rte_prefetch0 (volatile void p)
static void rte_prefetch1 (volatile void p)
static void rte_prefetch2 (volatile void p)

3.32.1

Detailed Description

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.

3.32.2

Function Documentation

3.32.2.1

static void rte prefetch0 ( volatile void p ) [static]

Prefetch a cache line into all cache levels.


Parameters
p Address to prefetch

3.32.2.2

static void rte prefetch1 ( volatile void p ) [static]

Prefetch a cache line into all cache levels except the 0th cache level.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
235

Intel DPDK - rte_random.h File Reference

Parameters
p Address to prefetch

3.32.2.3

static void rte prefetch2 ( volatile void p ) [static]

Prefetch a cache line into all cache levels except the 0th and 1th cache levels.
Parameters
p Address to prefetch

3.33

rte random.h File Reference

Functions
static void rte_srand (uint64_t seedval)
static uint64_t rte_rand (void)

3.33.1

Detailed Description

Pseudo-random Generators in RTE

3.33.2

Function Documentation

3.33.2.1

static void rte srand ( uint64 t seedval ) [static]

Seed the pseudo-random generator.


The generator is automatically seeded by the EAL init with a timer value. It may need to be re-seeded by
the user with a real random value.
Parameters
seedval The value of the seed.

3.33.2.2

static uint64 t rte rand ( void ) [static]

Get a pseudo-random value.


This function generates pseudo-random numbers using the linear congruential algorithm and 48-bit integer
arithmetic, called twice to generate a 64-bit value.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
236

November 2012
Reference Number: 326004-001

rte_ring.h File Reference - Intel DPDK

Returns
A pseudo-random value between 0 and (1<<64)-1.

3.34

rte ring.h File Reference

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 __RING_STAT_ADD(r, name, n)

Functions

struct rte_ring rte_ring_create (const char name, unsigned count, int socket_id, unsigned flags)
static int rte_ring_set_bulk_count (struct rte_ring r, unsigned count)
static unsigned rte_ring_get_bulk_count (struct rte_ring r)
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)
static int rte_ring_dequeue (struct rte_ring r, void obj_p)
static int rte_ring_full (const struct rte_ring r)
static int rte_ring_empty (const struct rte_ring r)
static unsigned rte_ring_count (const struct rte_ring r)
static unsigned rte_ring_free_count (const struct rte_ring r)
void rte_ring_list_dump (void)
struct rte_ring rte_ring_lookup (const char name)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
237

Intel DPDK - rte_ring.h File Reference

3.34.1

Detailed Description

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:
FIFO (First In First Out)
Maximum size is fixed; the pointers are stored in a table.
Lockless implementation.
Multi- or single-consumer dequeue.
Multi- or single-producer enqueue.
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.34.2

Define Documentation

3.34.2.1

#define RTE RING NAMESIZE

The maximum length of a ring name.

3.34.2.2

#define RING F SP ENQ

The default enqueue is "single-producer".

3.34.2.3

#define RING F SC DEQ

The default dequeue is "single-consumer".

3.34.2.4

#define RING STAT ADD( r, name, n )

When debug is enabled, store ring statistics.


Parameters
r A pointer to the ring.
name The name of the statistics field to increment in the ring.
n The number to add to the object-oriented statistics.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
238

November 2012
Reference Number: 326004-001

rte_ring.h File Reference - Intel DPDK

3.34.3

Function Documentation

3.34.3.1

struct rte_ring rte ring create ( const char name, unsigned count, int socket id, unsigned flags )
[read]

Create a new ring named name in memory.


This function uses memzone_reserve() to allocate memory. Its size is set to count, which must be a
power of two. Water marking is disabled by default. The default bulk count is initialized to 1. Note that the
real usable ring size is count-1 instead of count.
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
EINVAL - count provided is not a power of 2
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.34.3.2

static int rte ring set bulk count ( struct rte_ring r, unsigned count ) [static]

Set the default bulk count for enqueue/dequeue.


The parameter count is the default number of bulk elements to get/put when using rte_ring__{en,de}queue_bulk(). It must be greater than 0 and less than half of the ring size.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
239

Intel DPDK - rte_ring.h File Reference

Parameters
r A pointer to the ring structure.
count A new water mark value.

Returns
0: Success; default_bulk_count changed.
-EINVAL: Invalid count value.

3.34.3.3

static unsigned rte ring get bulk count ( struct rte_ring r ) [static]

Get the default bulk count for enqueue/dequeue.


Parameters
r A pointer to the ring structure.

Returns
The default bulk count for enqueue/dequeue.

3.34.3.4

int rte ring set water mark ( struct rte_ring r, unsigned count )

Change the high water mark.


If count is 0, water marking is disabled. Otherwise, it is set to the count value. The count value must
be greater than 0 and less than the ring size.
This function can be called at any time (not necessarilly at initialization).
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.

3.34.3.5

void rte ring dump ( const struct rte_ring r )

Dump the status of the ring to the console.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
240

November 2012
Reference Number: 326004-001

rte_ring.h File Reference - Intel DPDK

Parameters
r A pointer to the ring structure.

3.34.3.6

static int rte ring mp enqueue bulk ( struct rte_ring r, void const obj table, unsigned n ) [static]

Enqueue several objects on the ring (multi-producers safe).


This function uses a "compare and set" instruction to move the producer index atomically.
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. The value must be strictly
positive.

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.34.3.7

static int rte ring sp enqueue bulk ( struct rte_ring r, void const obj table, unsigned n ) [static]

Enqueue several objects on a ring (NOT multi-producers safe).


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. The value must be strictly
positive.
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.34.3.8

static int rte ring enqueue bulk ( struct rte_ring r, void const obj table, unsigned n ) [static]

Enqueue several objects on a ring.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
241

Intel DPDK - rte_ring.h File Reference

This function calls the multi-producer or the single-producer version depending on the default behavior that
was specified at ring creation time (see flags).
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.

static int rte ring mp enqueue ( struct rte_ring r, void obj ) [static]

3.34.3.9

Enqueue one object on a ring (multi-producers safe).


This function uses a "compare and set" instruction to move the producer index atomically.
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.34.3.10

static int rte ring sp enqueue ( struct rte_ring r, void obj ) [static]

Enqueue one object on a ring (NOT multi-producers safe).


Parameters
r A pointer to the ring structure.
obj A pointer to the object to be added.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
242

November 2012
Reference Number: 326004-001

rte_ring.h File Reference - Intel DPDK

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.

static int rte ring enqueue ( struct rte_ring r, void obj ) [static]

3.34.3.11

Enqueue one object on a ring.


This function calls the multi-producer or the single-producer version, depending on the default behaviour
that was specified at ring creation time (see flags).
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.

static int rte ring mc dequeue bulk ( struct rte_ring r, void obj table, unsigned n ) [static]

3.34.3.12

Dequeue several objects from a ring (multi-consumers safe).


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, must be strictly positive

Returns
0: Success; objects dequeued.
-ENOENT: Not enough entries in the ring to dequeue; no object is dequeued.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
243

Intel DPDK - rte_ring.h File Reference

static int rte ring sc dequeue bulk ( struct rte_ring r, void obj table, unsigned n ) [static]

3.34.3.13

Dequeue several objects from a ring (NOT multi-consumers safe).


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.

static int rte ring dequeue bulk ( struct rte_ring r, void obj table, unsigned n ) [static]

3.34.3.14

Dequeue several objects from a ring.


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_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.34.3.15

static int rte ring mc dequeue ( struct rte_ring r, void obj p ) [static]

Dequeue one object from a ring (multi-consumers safe).


This function uses a "compare and set" instruction to move the consumer index atomically.
Parameters
r A pointer to the ring structure.
obj_p A pointer to a void pointer (object) that will be filled.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
244

November 2012
Reference Number: 326004-001

rte_ring.h File Reference - Intel DPDK

Returns
0: Success; objects dequeued.
-ENOENT: Not enough entries in the ring to dequeue; no object is dequeued.

3.34.3.16

static int rte ring sc dequeue ( struct rte_ring r, void obj p ) [static]

Dequeue one object from a ring (NOT multi-consumers safe).


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.34.3.17

static int rte ring dequeue ( struct rte_ring r, void obj p ) [static]

Dequeue one object from a ring.


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.34.3.18

static int rte ring full ( const struct rte_ring r ) [static]

Test if a ring is full.


Parameters
r A pointer to the ring structure.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
245

Intel DPDK - rte_ring.h File Reference

Returns
1: The ring is full.
0: The ring is not full.

3.34.3.19

static int rte ring empty ( const struct rte_ring r ) [static]

Test if a ring is empty.


Parameters
r A pointer to the ring structure.

Returns
1: The ring is empty.
0: The ring is not empty.

3.34.3.20

static unsigned rte ring count ( const struct rte_ring r ) [static]

Return the number of entries in a ring.


Parameters
r A pointer to the ring structure.

Returns
The number of entries in the ring.

3.34.3.21

static unsigned rte ring free count ( const struct rte_ring r ) [static]

Return the number of free entries in a ring.


Parameters
r A pointer to the ring structure.

Returns
The number of free entries in the ring.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
246

November 2012
Reference Number: 326004-001

rte_rwlock.h File Reference - Intel DPDK

3.34.3.22

void rte ring list dump ( void )

Dump the status of all rings on the console

struct rte_ring rte ring lookup ( const char name ) [read]

3.34.3.23

Search a ring from its name


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.

rte rwlock.h File Reference

3.35

Data Structures
struct rte_rwlock_t

Defines
#define RTE_RWLOCK_INITIALIZER

Functions

static void rte_rwlock_init (rte_rwlock_t rwl)


static void rte_rwlock_read_lock (rte_rwlock_t rwl)
static void rte_rwlock_read_unlock (rte_rwlock_t rwl)
static void rte_rwlock_write_lock (rte_rwlock_t rwl)
static void rte_rwlock_write_unlock (rte_rwlock_t rwl)

3.35.1

Detailed Description

RTE Read-Write Locks


This file defines an API for read-write locks. The lock is used to protect data that allows multiple readers in
parallel, but only one writer. All readers are blocked until the writer is finished writing.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
247

Intel DPDK - rte_rwlock.h File Reference

3.35.2

Define Documentation

3.35.2.1

#define RTE RWLOCK INITIALIZER

A static rwlock initializer.

3.35.3

Function Documentation

3.35.3.1

static void rte rwlock init ( rte_rwlock_t rwl ) [static]

Initialize the rwlock to an unlocked state.


Parameters
rwl A pointer to the rwlock structure.

3.35.3.2

static void rte rwlock read lock ( rte_rwlock_t rwl ) [static]

Take a read lock. Loop until the lock is held.


Parameters
rwl A pointer to a rwlock structure.

3.35.3.3

static void rte rwlock read unlock ( rte_rwlock_t rwl ) [static]

Release a read lock.


Parameters
rwl A pointer to the rwlock structure.

3.35.3.4

static void rte rwlock write lock ( rte_rwlock_t rwl ) [static]

Take a write lock. Loop until the lock is held.


Parameters
rwl A pointer to a rwlock structure.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
248

November 2012
Reference Number: 326004-001

rte_sctp.h File Reference - Intel DPDK

3.35.3.5

static void rte rwlock write unlock ( rte_rwlock_t rwl ) [static]

Release a write lock.


Parameters
rwl A pointer to a rwlock structure.

3.36

rte sctp.h File Reference

Data Structures
struct sctp_hdr

3.36.1

Detailed Description

SCTP-related defines

rte spinlock.h File Reference

3.37

Data Structures
struct rte_spinlock_t
struct rte_spinlock_recursive_t

Defines
#define RTE_SPINLOCK_INITIALIZER
#define RTE_SPINLOCK_RECURSIVE_INITIALIZER

Functions

static void rte_spinlock_init (rte_spinlock_t sl)


static void rte_spinlock_lock (rte_spinlock_t sl)
static void rte_spinlock_unlock (rte_spinlock_t sl)
static int rte_spinlock_trylock (rte_spinlock_t sl)
static int rte_spinlock_is_locked (rte_spinlock_t sl)
static void rte_spinlock_recursive_init (rte_spinlock_recursive_t slr)
static void rte_spinlock_recursive_lock (rte_spinlock_recursive_t slr)
static void rte_spinlock_recursive_unlock (rte_spinlock_recursive_t slr)
static int rte_spinlock_recursive_trylock (rte_spinlock_recursive_t slr)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
249

Intel DPDK - rte_spinlock.h File Reference

3.37.1

Detailed Description

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.

3.37.2

Define Documentation

3.37.2.1

#define RTE SPINLOCK INITIALIZER

A static spinlock initializer.

3.37.2.2

#define RTE SPINLOCK RECURSIVE INITIALIZER

A static recursive spinlock initializer.

3.37.3

Function Documentation

3.37.3.1

static void rte spinlock init ( rte_spinlock_t sl ) [static]

Initialize the spinlock to an unlocked state.


Parameters
sl A pointer to the spinlock.

3.37.3.2

static void rte spinlock lock ( rte_spinlock_t sl ) [static]

Take the spinlock.


Parameters
sl A pointer to the spinlock.

3.37.3.3

static void rte spinlock unlock ( rte_spinlock_t sl ) [static]

Release the spinlock.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
250

November 2012
Reference Number: 326004-001

rte_spinlock.h File Reference - Intel DPDK

Parameters
sl A pointer to the spinlock.

3.37.3.4

static int rte spinlock trylock ( rte_spinlock_t sl ) [static]

Try to take the lock.


Parameters
sl A pointer to the spinlock.

Returns
1 if the lock is successfully taken; 0 otherwise.

3.37.3.5

static int rte spinlock is locked ( rte_spinlock_t sl ) [static]

Test if the lock is taken.


Parameters
sl A pointer to the spinlock.

Returns
1 if the lock is currently taken; 0 otherwise.

3.37.3.6

static void rte spinlock recursive init ( rte_spinlock_recursive_t slr ) [static]

Initialize the recursive spinlock to an unlocked state.


Parameters
slr A pointer to the recursive spinlock.

3.37.3.7

static void rte spinlock recursive lock ( rte_spinlock_recursive_t slr ) [static]

Take the recursive spinlock.


Parameters
slr A pointer to the recursive spinlock.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
251

Intel DPDK - rte_string_fns.h File Reference

3.37.3.8

static void rte spinlock recursive unlock ( rte_spinlock_recursive_t slr ) [static]

Release the recursive spinlock.


Parameters
slr A pointer to the recursive spinlock.

3.37.3.9

static int rte spinlock recursive trylock ( rte_spinlock_recursive_t slr ) [static]

Try to take the recursive lock.


Parameters
slr A pointer to the recursive spinlock.

Returns
1 if the lock is successfully taken; 0 otherwise.

3.38

rte string fns.h File Reference

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.38.1

Detailed Description

Definitions of warnings for use of various insecure functions

3.38.2

Function Documentation

3.38.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

Intel Data Plane Development Kit (Intel DPDK)


API Reference
252

November 2012
Reference Number: 326004-001

rte_tailq.h File Reference - Intel DPDK

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.38.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
string
stringlen
tokens
maxtokens

The input string to be split into tokens


The max length of the input buffer
The array to hold the pointers to the tokens in the string
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.

3.39

rte tailq.h File Reference

Data Structures
struct rte_dummy
struct rte_tailq_head

Defines
#define RTE_TAILQ_RESERVE(name, struct_name)
#define RTE_TAILQ_LOOKUP(name, 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_lookup (const char name)

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
253

Intel DPDK - rte_tailq.h File Reference

3.39.1

Detailed Description

3.39.2

Define Documentation

3.39.2.1

#define RTE TAILQ RESERVE( name, struct name )

Utility macro to make reserving a tailqueue for a particular struct easier.


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.

3.39.2.2

#define RTE TAILQ LOOKUP( name, struct name )

Utility macro to make looking up a tailqueue for a particular struct easier.


Parameters
name The name of the 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.

3.39.3

Function Documentation

3.39.3.1

TAILQ HEAD ( rte dummy head , rte_dummy )

dummy

3.39.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

Intel Data Plane Development Kit (Intel DPDK)


API Reference
254

November 2012
Reference Number: 326004-001

rte_tcp.h File Reference - Intel DPDK

Parameters
name The name to be given to the tail queue.

Returns
A pointer to the newly reserved tailq entry

3.39.3.3

struct rte_tailq_head rte eal tailq lookup ( const char name ) [read]

Lookup for a tail queue.


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.40

rte tcp.h File Reference

Data Structures
struct tcp_hdr

3.40.1

Detailed Description

TCP-related defines

3.41

rte timer.h File Reference

Data Structures
union rte_timer_status
struct rte_timer

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
255

Intel DPDK - rte_timer.h File Reference

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
typedef void( rte_timer_cb_t )(struct rte_timer , void )

Enumerations
enum rte_timer_type

Functions
void rte_timer_subsystem_init (void)
void rte_timer_init (struct rte_timer tim)
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)
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)
int rte_timer_stop (struct rte_timer tim)
void rte_timer_stop_sync (struct rte_timer tim)
int rte_timer_pending (struct rte_timer tim)
void rte_timer_manage (void)
void rte_timer_dump_stats (void)

3.41.1

Detailed Description

RTE Timer
This library provides a timer service to RTE Data Plane execution units that allows the execution of callback
functions asynchronously.
Timers can be periodic or single (one-shot).
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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
256

November 2012
Reference Number: 326004-001

rte_timer.h File Reference - Intel DPDK

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 (timestamp 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.

3.41.2

Define Documentation

3.41.2.1

#define RTE TIMER STOP

State: timer is stopped.

3.41.2.2

#define RTE TIMER PENDING

State: timer is scheduled.

3.41.2.3

#define RTE TIMER RUNNING

State: timer function is running.

3.41.2.4

#define RTE TIMER CONFIG

State: timer is being configured.

3.41.2.5

#define RTE TIMER NO OWNER

Timer has no owner.

3.41.2.6

#define RTE TIMER INITIALIZER

A static initializer for a timer structure.

3.41.3

Typedef Documentation

3.41.3.1

typedef void( rte_timer_cb_t)(struct rte_timer , void )

Callback function type for timer expiry.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
257

Intel DPDK - rte_timer.h File Reference

3.41.4

Enumeration Type Documentation

3.41.4.1

enum rte_timer_type

Timer type: Periodic or single (one-shot).

3.41.5

Function Documentation

3.41.5.1

void rte timer subsystem init ( void )

Initialize the timer library.


Initializes internal variables (list, locks and so on) for the RTE timer library.

3.41.5.2

void rte timer init ( struct rte_timer tim )

Initialize a timer handle.


The rte_timer_init() function initializes the timer handle tim for use. No operations can be performed on a
timer before it is initialized.
Parameters
tim The timer to initialize.

3.41.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.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
258

November 2012
Reference Number: 326004-001

rte_timer.h File Reference - Intel DPDK

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 (roundrobin).
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.41.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 )

Loop until rte_timer_reset() succeeds.


Reset and start the timer associated with the timer handle. Always succeed. See rte_timer_reset() for
details.
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 (roundrobin).
fct The callback function of the timer.
arg The user argument of the callback function.

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
259

Intel DPDK - rte_timer.h File Reference

3.41.5.5

int rte timer stop ( struct rte_timer tim )

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.

3.41.5.6

void rte timer stop sync ( struct rte_timer tim )

Loop until rte_timer_stop() succeeds.


After a call to this function, the timer identified by tim is stopped. See rte_timer_stop() for details.
Parameters
tim The timer handle.

3.41.5.7

int rte timer pending ( struct rte_timer tim )

Test if a timer is pending.


The rte_timer_pending() function tests the PENDING status of the timer handle tim. A PENDING timer is
one that has been scheduled and whose function has not yet been called.
Parameters
tim The timer handle.

Returns
0: The timer is not pending.
1: The timer is pending.

Intel Data Plane Development Kit (Intel DPDK)


API Reference
260

November 2012
Reference Number: 326004-001

rte_udp.h File Reference - Intel DPDK

3.41.5.8

void rte timer manage ( void )

Manage the timer list and execute callback functions.


This function must be called periodically from all cores main_loop(). It browses the list of pending timers
and runs all timers that are expired.
The precision of the timer depends on the call frequency of this function. However, the more often the
function is called, the more CPU resources it will use.

3.41.5.9

void rte timer dump stats ( void )

Dump statistics about timers.

3.42

rte udp.h File Reference

Data Structures
struct udp_hdr

3.42.1

Detailed Description

UDP-related defines

3.43

rte version.h File Reference

Defines
#define RTE_VER_MAJOR
#define RTE_VER_MINOR
#define RTE_VER_PATCH_LEVEL

Functions
static const char rte_version (void)

3.43.1

Detailed Description

Definitions of Intel(R) DPDK version numbers

November 2012
Reference Number: 326004-001

Intel Data Plane Development Kit (Intel DPDK)


API Reference
261

Intel DPDK - rte_warnings.h File Reference

3.43.2

Define Documentation

3.43.2.1

#define RTE VER MAJOR

Major version number i.e. the x in x.y.z

3.43.2.2

#define RTE VER MINOR

Minor version number i.e. the y in x.y.z

3.43.2.3

#define RTE VER PATCH LEVEL

Patch level number i.e. the z in x.y.z

3.43.3

Function Documentation

3.43.3.1

static const char rte version ( void ) [static]

Function returning string of version number: "RTE x.y.z"


Returns
string

3.44

rte warnings.h File Reference

3.44.1

Detailed Description

Definitions of warnings for use of various insecure functions

Intel Data Plane Development Kit (Intel DPDK)


API Reference
262

November 2012
Reference Number: 326004-001

You might also like