DPDK  16.07.2
Data Structures | Macros | Typedefs | Functions
rte_mbuf.h File Reference
#include <stdint.h>
#include <rte_common.h>
#include <rte_mempool.h>
#include <rte_memory.h>
#include <rte_atomic.h>
#include <rte_prefetch.h>
#include <rte_branch_prediction.h>

Go to the source code of this file.

Data Structures

struct  rte_mbuf
struct  rte_pktmbuf_pool_private

Macros

#define PKT_RX_VLAN_PKT   (1ULL << 0)
#define PKT_RX_RSS_HASH   (1ULL << 1)
#define PKT_RX_FDIR   (1ULL << 2)
#define PKT_RX_L4_CKSUM_BAD   (1ULL << 3)
#define PKT_RX_IP_CKSUM_BAD   (1ULL << 4)
#define PKT_RX_EIP_CKSUM_BAD   (1ULL << 5)
#define PKT_RX_VLAN_STRIPPED   (1ULL << 6)
#define PKT_RX_IEEE1588_PTP   (1ULL << 9)
#define PKT_RX_IEEE1588_TMST   (1ULL << 10)
#define PKT_RX_FDIR_ID   (1ULL << 13)
#define PKT_RX_FDIR_FLX   (1ULL << 14)
#define PKT_RX_QINQ_STRIPPED   (1ULL << 15)
#define PKT_RX_QINQ_PKT   PKT_RX_QINQ_STRIPPED
#define PKT_TX_QINQ_PKT   (1ULL << 49)
#define PKT_TX_TCP_SEG   (1ULL << 50)
#define PKT_TX_IEEE1588_TMST   (1ULL << 51)
#define PKT_TX_L4_NO_CKSUM   (0ULL << 52)
#define PKT_TX_TCP_CKSUM   (1ULL << 52)
#define PKT_TX_SCTP_CKSUM   (2ULL << 52)
#define PKT_TX_UDP_CKSUM   (3ULL << 52)
#define PKT_TX_L4_MASK   (3ULL << 52)
#define PKT_TX_IP_CKSUM   (1ULL << 54)
#define PKT_TX_IPV4   (1ULL << 55)
#define PKT_TX_IPV6   (1ULL << 56)
#define PKT_TX_VLAN_PKT   (1ULL << 57)
#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
#define PKT_TX_OUTER_IPV4   (1ULL << 59)
#define PKT_TX_OUTER_IPV6   (1ULL << 60)
#define __RESERVED   (1ULL << 61)
#define IND_ATTACHED_MBUF   (1ULL << 62)
#define CTRL_MBUF_FLAG   (1ULL << 63)
#define RTE_PTYPE_L2_ETHER   0x00000001
#define RTE_PTYPE_L2_ETHER_TIMESYNC   0x00000002
#define RTE_PTYPE_L2_ETHER_ARP   0x00000003
#define RTE_PTYPE_L2_ETHER_LLDP   0x00000004
#define RTE_PTYPE_L2_ETHER_NSH   0x00000005
#define RTE_PTYPE_L2_MASK   0x0000000f
#define RTE_PTYPE_L3_IPV4   0x00000010
#define RTE_PTYPE_L3_IPV4_EXT   0x00000030
#define RTE_PTYPE_L3_IPV6   0x00000040
#define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN   0x00000090
#define RTE_PTYPE_L3_IPV6_EXT   0x000000c0
#define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN   0x000000e0
#define RTE_PTYPE_L3_MASK   0x000000f0
#define RTE_PTYPE_L4_TCP   0x00000100
#define RTE_PTYPE_L4_UDP   0x00000200
#define RTE_PTYPE_L4_FRAG   0x00000300
#define RTE_PTYPE_L4_SCTP   0x00000400
#define RTE_PTYPE_L4_ICMP   0x00000500
#define RTE_PTYPE_L4_NONFRAG   0x00000600
#define RTE_PTYPE_L4_MASK   0x00000f00
#define RTE_PTYPE_TUNNEL_IP   0x00001000
#define RTE_PTYPE_TUNNEL_GRE   0x00002000
#define RTE_PTYPE_TUNNEL_VXLAN   0x00003000
#define RTE_PTYPE_TUNNEL_NVGRE   0x00004000
#define RTE_PTYPE_TUNNEL_GENEVE   0x00005000
#define RTE_PTYPE_TUNNEL_GRENAT   0x00006000
#define RTE_PTYPE_TUNNEL_MASK   0x0000f000
#define RTE_PTYPE_INNER_L2_ETHER   0x00010000
#define RTE_PTYPE_INNER_L2_ETHER_VLAN   0x00020000
#define RTE_PTYPE_INNER_L2_MASK   0x000f0000
#define RTE_PTYPE_INNER_L3_IPV4   0x00100000
#define RTE_PTYPE_INNER_L3_IPV4_EXT   0x00200000
#define RTE_PTYPE_INNER_L3_IPV6   0x00300000
#define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN   0x00400000
#define RTE_PTYPE_INNER_L3_IPV6_EXT   0x00500000
#define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN   0x00600000
#define RTE_PTYPE_INNER_L3_MASK   0x00f00000
#define RTE_PTYPE_INNER_L4_TCP   0x01000000
#define RTE_PTYPE_INNER_L4_UDP   0x02000000
#define RTE_PTYPE_INNER_L4_FRAG   0x03000000
#define RTE_PTYPE_INNER_L4_SCTP   0x04000000
#define RTE_PTYPE_INNER_L4_ICMP   0x05000000
#define RTE_PTYPE_INNER_L4_NONFRAG   0x06000000
#define RTE_PTYPE_INNER_L4_MASK   0x0f000000
#define RTE_ETH_IS_IPV4_HDR(ptype)   ((ptype) & RTE_PTYPE_L3_IPV4)
#define RTE_ETH_IS_IPV6_HDR(ptype)   ((ptype) & RTE_PTYPE_L3_IPV6)
#define RTE_MBUF_PRIV_ALIGN   8
#define RTE_MBUF_DEFAULT_DATAROOM   2048
#define RTE_MBUF_INDIRECT(mb)   ((mb)->ol_flags & IND_ATTACHED_MBUF)
#define RTE_MBUF_DIRECT(mb)   (!RTE_MBUF_INDIRECT(mb))
#define __rte_mbuf_sanity_check(m, is_h)   do { } while (0)
#define RTE_MBUF_PREFETCH_TO_FREE(m)
#define rte_ctrlmbuf_alloc(mp)   rte_pktmbuf_alloc(mp)
#define rte_ctrlmbuf_free(m)   rte_pktmbuf_free(m)
#define rte_ctrlmbuf_data(m)   ((char *)((m)->buf_addr) + (m)->data_off)
#define rte_ctrlmbuf_len(m)   rte_pktmbuf_data_len(m)
#define rte_pktmbuf_mtod_offset(m, t, o)   ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
#define rte_pktmbuf_mtod(m, t)   rte_pktmbuf_mtod_offset(m, t, 0)
#define rte_pktmbuf_mtophys_offset(m, o)   (phys_addr_t)((m)->buf_physaddr + (m)->data_off + (o))
#define rte_pktmbuf_mtophys(m)   rte_pktmbuf_mtophys_offset(m, 0)
#define rte_pktmbuf_pkt_len(m)   ((m)->pkt_len)
#define rte_pktmbuf_data_len(m)   ((m)->data_len)

Typedefs

typedef void * MARKER [0]
typedef uint8_t MARKER8 [0]
typedef uint64_t MARKER64 [0]

Functions

const char * rte_get_rx_ol_flag_name (uint64_t mask)
const char * rte_get_tx_ol_flag_name (uint64_t mask)
static void rte_mbuf_prefetch_part1 (struct rte_mbuf *m)
static void rte_mbuf_prefetch_part2 (struct rte_mbuf *m)
static uint16_t rte_pktmbuf_priv_size (struct rte_mempool *mp)
static phys_addr_t rte_mbuf_data_dma_addr (const struct rte_mbuf *mb)
static phys_addr_t rte_mbuf_data_dma_addr_default (const struct rte_mbuf *mb)
static struct rte_mbufrte_mbuf_from_indirect (struct rte_mbuf *mi)
static char * rte_mbuf_to_baddr (struct rte_mbuf *md)
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, int is_header)
static struct rte_mbufrte_mbuf_raw_alloc (struct rte_mempool *mp)
void rte_ctrlmbuf_init (struct rte_mempool *mp, void *opaque_arg, void *m, unsigned i)
static int rte_is_ctrlmbuf (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)
struct rte_mempoolrte_pktmbuf_pool_create (const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)
static uint16_t rte_pktmbuf_data_room_size (struct rte_mempool *mp)
static void rte_pktmbuf_reset (struct rte_mbuf *m)
static struct rte_mbufrte_pktmbuf_alloc (struct rte_mempool *mp)
static int rte_pktmbuf_alloc_bulk (struct rte_mempool *pool, struct rte_mbuf **mbufs, unsigned count)
static void rte_pktmbuf_attach (struct rte_mbuf *mi, struct rte_mbuf *m)
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_mbufrte_pktmbuf_clone (struct rte_mbuf *md, struct rte_mempool *mp)
static void rte_pktmbuf_refcnt_update (struct rte_mbuf *m, int16_t v)
static uint16_t rte_pktmbuf_headroom (const struct rte_mbuf *m)
static uint16_t rte_pktmbuf_tailroom (const struct rte_mbuf *m)
static struct rte_mbufrte_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)
static int rte_pktmbuf_chain (struct rte_mbuf *head, struct rte_mbuf *tail)
void rte_pktmbuf_dump (FILE *f, const struct rte_mbuf *m, unsigned dump_len)

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 packet mbufs, 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

Definition in file rte_mbuf.h.

Macro Definition Documentation

#define PKT_RX_VLAN_PKT   (1ULL << 0)

RX packet is a 802.1q VLAN packet. This flag was set by PMDs when the packet is recognized as a VLAN, but the behavior between PMDs was not the same. This flag is kept for some time to avoid breaking applications and should be replaced by PKT_RX_VLAN_STRIPPED.

Definition at line 89 of file rte_mbuf.h.

#define PKT_RX_RSS_HASH   (1ULL << 1)

RX packet with RSS hash result.

Definition at line 91 of file rte_mbuf.h.

#define PKT_RX_FDIR   (1ULL << 2)

RX packet with FDIR match indicate.

Definition at line 92 of file rte_mbuf.h.

#define PKT_RX_L4_CKSUM_BAD   (1ULL << 3)

L4 cksum of RX pkt. is not OK.

Examples:
tep_termination/vxlan_setup.c.

Definition at line 93 of file rte_mbuf.h.

#define PKT_RX_IP_CKSUM_BAD   (1ULL << 4)

IP cksum of RX pkt. is not OK.

Examples:
tep_termination/vxlan_setup.c.

Definition at line 94 of file rte_mbuf.h.

#define PKT_RX_EIP_CKSUM_BAD   (1ULL << 5)

External IP header checksum error.

Definition at line 95 of file rte_mbuf.h.

#define PKT_RX_VLAN_STRIPPED   (1ULL << 6)

A vlan has been stripped by the hardware and its tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping is enabled in the RX configuration of the PMD.

Definition at line 102 of file rte_mbuf.h.

#define PKT_RX_IEEE1588_PTP   (1ULL << 9)

RX IEEE1588 L2 Ethernet PT Packet.

Examples:
ptpclient/ptpclient.c.

Definition at line 106 of file rte_mbuf.h.

#define PKT_RX_IEEE1588_TMST   (1ULL << 10)

RX IEEE1588 L2/L4 timestamped packet.

Definition at line 107 of file rte_mbuf.h.

#define PKT_RX_FDIR_ID   (1ULL << 13)

FD id reported if FDIR match.

Definition at line 108 of file rte_mbuf.h.

#define PKT_RX_FDIR_FLX   (1ULL << 14)

Flexible bytes reported if FDIR match.

Definition at line 109 of file rte_mbuf.h.

#define PKT_RX_QINQ_STRIPPED   (1ULL << 15)

The 2 vlans have been stripped by the hardware and their tci are saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer). This can only happen if vlan stripping is enabled in the RX configuration of the PMD. If this flag is set, PKT_RX_VLAN_STRIPPED must also be set.

Definition at line 118 of file rte_mbuf.h.

#define PKT_RX_QINQ_PKT   PKT_RX_QINQ_STRIPPED

Deprecated. RX packet with double VLAN stripped. This flag is replaced by PKT_RX_QINQ_STRIPPED.

Definition at line 125 of file rte_mbuf.h.

#define PKT_TX_QINQ_PKT   (1ULL << 49)

Second VLAN insertion (QinQ) flag.TX packet with double VLAN inserted.

Definition at line 134 of file rte_mbuf.h.

#define PKT_TX_TCP_SEG   (1ULL << 50)

TCP segmentation offload. To enable this offload feature for a packet to be transmitted on hardware supporting TSO:

  • set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies PKT_TX_TCP_CKSUM)
  • set the flag PKT_TX_IPV4 or PKT_TX_IPV6
  • if it's IPv4, set the PKT_TX_IP_CKSUM flag and write the IP checksum to 0 in the packet
  • fill the mbuf offload information: l2_len, l3_len, l4_len, tso_segsz
  • calculate the pseudo header checksum without taking ip_len in account, and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and rte_ipv6_phdr_cksum() that can be used as helpers.
Examples:
tep_termination/vxlan.c, and vhost/main.c.

Definition at line 149 of file rte_mbuf.h.

#define PKT_TX_IEEE1588_TMST   (1ULL << 51)

TX IEEE1588 packet to timestamp.

Examples:
ptpclient/ptpclient.c.

Definition at line 151 of file rte_mbuf.h.

#define PKT_TX_L4_NO_CKSUM   (0ULL << 52)

Bits 52+53 used for L4 packet type with checksum enabled: 00: Reserved, 01: TCP checksum, 10: SCTP checksum, 11: UDP checksum. To use hardware L4 checksum offload, the user needs to:

  • fill l2_len and l3_len in mbuf
  • set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM
  • set the flag PKT_TX_IPV4 or PKT_TX_IPV6
  • calculate the pseudo header checksum and set it in the L4 header (only for TCP or UDP). See rte_ipv4_phdr_cksum() and rte_ipv6_phdr_cksum(). For SCTP, set the crc field to 0.Disable L4 cksum of TX pkt.

Definition at line 164 of file rte_mbuf.h.

#define PKT_TX_TCP_CKSUM   (1ULL << 52)

TCP cksum of TX pkt. computed by NIC.

Examples:
tep_termination/vxlan.c.

Definition at line 165 of file rte_mbuf.h.

#define PKT_TX_SCTP_CKSUM   (2ULL << 52)

SCTP cksum of TX pkt. computed by NIC.

Examples:
tep_termination/vxlan.c.

Definition at line 166 of file rte_mbuf.h.

#define PKT_TX_UDP_CKSUM   (3ULL << 52)

UDP cksum of TX pkt. computed by NIC.

Examples:
tep_termination/vxlan.c.

Definition at line 167 of file rte_mbuf.h.

#define PKT_TX_L4_MASK   (3ULL << 52)

Mask for L4 cksum offload request.

Definition at line 168 of file rte_mbuf.h.

#define PKT_TX_IP_CKSUM   (1ULL << 54)

Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should also be set by the application, although a PMD will only check PKT_TX_IP_CKSUM.

  • set the IP checksum field in the packet to 0
  • fill the mbuf offload information: l2_len, l3_len
Examples:
tep_termination/vxlan.c, and vhost/main.c.

Definition at line 177 of file rte_mbuf.h.

#define PKT_TX_IPV4   (1ULL << 55)

Packet is IPv4. This flag must be set when using any offload feature (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4 packet. If the packet is a tunneled packet, this flag is related to the inner headers.

Examples:
tep_termination/vxlan.c, and vhost/main.c.

Definition at line 185 of file rte_mbuf.h.

#define PKT_TX_IPV6   (1ULL << 56)

Packet is IPv6. This flag must be set when using an offload feature (TSO or L4 checksum) to tell the NIC that the packet is an IPv6 packet. If the packet is a tunneled packet, this flag is related to the inner headers.

Examples:
tep_termination/vxlan.c.

Definition at line 193 of file rte_mbuf.h.

#define PKT_TX_VLAN_PKT   (1ULL << 57)

TX packet is a 802.1q VLAN packet.

Examples:
vhost/main.c.

Definition at line 195 of file rte_mbuf.h.

#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)

Offload the IP checksum of an external header in the hardware. The flag PKT_TX_OUTER_IPV4 should also be set by the application, alto ugh a PMD will only check PKT_TX_IP_CKSUM. The IP checksum field in the packet must be set to 0.

  • set the outer IP checksum field in the packet to 0
  • fill the mbuf offload information: outer_l2_len, outer_l3_len
Examples:
tep_termination/vxlan.c.

Definition at line 205 of file rte_mbuf.h.

#define PKT_TX_OUTER_IPV4   (1ULL << 59)

Packet outer header is IPv4. This flag must be set when using any outer offload feature (L3 or L4 checksum) to tell the NIC that the outer header of the tunneled packet is an IPv4 packet.

Definition at line 212 of file rte_mbuf.h.

#define PKT_TX_OUTER_IPV6   (1ULL << 60)

Packet outer header is IPv6. This flag must be set when using any outer offload feature (L4 checksum) to tell the NIC that the outer header of the tunneled packet is an IPv6 packet.

Definition at line 219 of file rte_mbuf.h.

#define __RESERVED   (1ULL << 61)

reserved for future mbuf use

Definition at line 221 of file rte_mbuf.h.

#define IND_ATTACHED_MBUF   (1ULL << 62)

Indirect attached mbuf

Definition at line 223 of file rte_mbuf.h.

#define CTRL_MBUF_FLAG   (1ULL << 63)

Mbuf contains control data

Definition at line 226 of file rte_mbuf.h.

#define RTE_PTYPE_L2_ETHER   0x00000001

Ethernet packet type. It is used for outer packet for tunneling cases.

Packet format: <'ether type'=[0x0800|0x86DD]>

Definition at line 284 of file rte_mbuf.h.

#define RTE_PTYPE_L2_ETHER_TIMESYNC   0x00000002

Ethernet packet type for time sync.

Packet format: <'ether type'=0x88F7>

Definition at line 291 of file rte_mbuf.h.

#define RTE_PTYPE_L2_ETHER_ARP   0x00000003

ARP (Address Resolution Protocol) packet type.

Packet format: <'ether type'=0x0806>

Definition at line 298 of file rte_mbuf.h.

#define RTE_PTYPE_L2_ETHER_LLDP   0x00000004

LLDP (Link Layer Discovery Protocol) packet type.

Packet format: <'ether type'=0x88CC>

Definition at line 305 of file rte_mbuf.h.

#define RTE_PTYPE_L2_ETHER_NSH   0x00000005

NSH (Network Service Header) packet type.

Packet format: <'ether type'=0x894F>

Definition at line 312 of file rte_mbuf.h.

#define RTE_PTYPE_L2_MASK   0x0000000f

Mask of layer 2 packet types. It is used for outer packet for tunneling cases.

Definition at line 317 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV4   0x00000010

IP (Internet Protocol) version 4 packet type. It is used for outer packet for tunneling cases, and does not contain any header option.

Packet format: <'ether type'=0x0800 | 'version'=4, 'ihl'=5>

Examples:
performance-thread/l3fwd-thread/main.c.

Definition at line 327 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV4_EXT   0x00000030

IP (Internet Protocol) version 4 packet type. It is used for outer packet for tunneling cases, and contains header options.

Packet format: <'ether type'=0x0800 | 'version'=4, 'ihl'=[6-15], 'options'>

Definition at line 337 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV6   0x00000040

IP (Internet Protocol) version 6 packet type. It is used for outer packet for tunneling cases, and does not contain any extension header.

Packet format: <'ether type'=0x86DD | 'version'=6, 'next header'=0x3B>

Examples:
performance-thread/l3fwd-thread/main.c.

Definition at line 347 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV4_EXT_UNKNOWN   0x00000090

IP (Internet Protocol) version 4 packet type. It is used for outer packet for tunneling cases, and may or maynot contain header options.

Packet format: <'ether type'=0x0800 | 'version'=4, 'ihl'=[5-15], <'options'>>

Definition at line 357 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV6_EXT   0x000000c0

IP (Internet Protocol) version 6 packet type. It is used for outer packet for tunneling cases, and contains extension headers.

Packet format: <'ether type'=0x86DD | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 'extension headers'>

Definition at line 368 of file rte_mbuf.h.

#define RTE_PTYPE_L3_IPV6_EXT_UNKNOWN   0x000000e0

IP (Internet Protocol) version 6 packet type. It is used for outer packet for tunneling cases, and may or maynot contain extension headers.

Packet format: <'ether type'=0x86DD | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], <'extension headers'>>

Definition at line 379 of file rte_mbuf.h.

#define RTE_PTYPE_L3_MASK   0x000000f0

Mask of layer 3 packet types. It is used for outer packet for tunneling cases.

Definition at line 384 of file rte_mbuf.h.

#define RTE_PTYPE_L4_TCP   0x00000100

TCP (Transmission Control Protocol) packet type. It is used for outer packet for tunneling cases.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=6, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=6>

Definition at line 396 of file rte_mbuf.h.

#define RTE_PTYPE_L4_UDP   0x00000200

UDP (User Datagram Protocol) packet type. It is used for outer packet for tunneling cases.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=17, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=17>

Definition at line 408 of file rte_mbuf.h.

#define RTE_PTYPE_L4_FRAG   0x00000300

Fragmented IP (Internet Protocol) packet type. It is used for outer packet for tunneling cases.

It refers to those packets of any IP types, which can be recognized as fragmented. A fragmented packet cannot be recognized as any other L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP, RTE_PTYPE_L4_NONFRAG).

Packet format: <'ether type'=0x0800 | 'version'=4, 'MF'=1> or, <'ether type'=0x86DD | 'version'=6, 'next header'=44>

Definition at line 425 of file rte_mbuf.h.

#define RTE_PTYPE_L4_SCTP   0x00000400

SCTP (Stream Control Transmission Protocol) packet type. It is used for outer packet for tunneling cases.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=132, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=132>

Definition at line 437 of file rte_mbuf.h.

#define RTE_PTYPE_L4_ICMP   0x00000500

ICMP (Internet Control Message Protocol) packet type. It is used for outer packet for tunneling cases.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=1, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=1>

Definition at line 449 of file rte_mbuf.h.

#define RTE_PTYPE_L4_NONFRAG   0x00000600

Non-fragmented IP (Internet Protocol) packet type. It is used for outer packet for tunneling cases.

It refers to those packets of any IP types, while cannot be recognized as any of above L4 types (RTE_PTYPE_L4_TCP, RTE_PTYPE_L4_UDP, RTE_PTYPE_L4_FRAG, RTE_PTYPE_L4_SCTP, RTE_PTYPE_L4_ICMP).

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'!=[6|17|44|132|1]>

Definition at line 465 of file rte_mbuf.h.

#define RTE_PTYPE_L4_MASK   0x00000f00

Mask of layer 4 packet types. It is used for outer packet for tunneling cases.

Definition at line 470 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_IP   0x00001000

IP (Internet Protocol) in IP (Internet Protocol) tunneling packet type.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=[4|41]> or, <'ether type'=0x86DD | 'version'=6, 'next header'=[4|41]>

Definition at line 481 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_GRE   0x00002000

GRE (Generic Routing Encapsulation) tunneling packet type.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=47> or, <'ether type'=0x86DD | 'version'=6, 'next header'=47>

Definition at line 492 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_VXLAN   0x00003000

VXLAN (Virtual eXtensible Local Area Network) tunneling packet type.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=17 | 'destination port'=4798> or, <'ether type'=0x86DD | 'version'=6, 'next header'=17 | 'destination port'=4798>

Definition at line 505 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_NVGRE   0x00004000

NVGRE (Network Virtualization using Generic Routing Encapsulation) tunneling packet type.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=47 | 'protocol type'=0x6558> or, <'ether type'=0x86DD | 'version'=6, 'next header'=47 | 'protocol type'=0x6558'>

Definition at line 519 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_GENEVE   0x00005000

GENEVE (Generic Network Virtualization Encapsulation) tunneling packet type.

Packet format: <'ether type'=0x0800 | 'version'=4, 'protocol'=17 | 'destination port'=6081> or, <'ether type'=0x86DD | 'version'=6, 'next header'=17 | 'destination port'=6081>

Definition at line 532 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_GRENAT   0x00006000

Tunneling packet type of Teredo, VXLAN (Virtual eXtensible Local Area Network) or GRE (Generic Routing Encapsulation) could be recognized as this packet type, if they can not be recognized independently as of hardware capability.

Definition at line 539 of file rte_mbuf.h.

#define RTE_PTYPE_TUNNEL_MASK   0x0000f000

Mask of tunneling packet types.

Examples:
tep_termination/vxlan.c.

Definition at line 543 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L2_ETHER   0x00010000

Ethernet packet type. It is used for inner packet type only.

Packet format (inner only): <'ether type'=[0x800|0x86DD]>

Definition at line 551 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L2_ETHER_VLAN   0x00020000

Ethernet packet type with VLAN (Virtual Local Area Network) tag.

Packet format (inner only): <'ether type'=[0x800|0x86DD], vlan=[1-4095]>

Definition at line 558 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L2_MASK   0x000f0000

Mask of inner layer 2 packet types.

Definition at line 562 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV4   0x00100000

IP (Internet Protocol) version 4 packet type. It is used for inner packet only, and does not contain any header option.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'ihl'=5>

Definition at line 571 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV4_EXT   0x00200000

IP (Internet Protocol) version 4 packet type. It is used for inner packet only, and contains header options.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'ihl'=[6-15], 'options'>

Definition at line 580 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV6   0x00300000

IP (Internet Protocol) version 6 packet type. It is used for inner packet only, and does not contain any extension header.

Packet format (inner only): <'ether type'=0x86DD | 'version'=6, 'next header'=0x3B>

Definition at line 589 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN   0x00400000

IP (Internet Protocol) version 4 packet type. It is used for inner packet only, and may or maynot contain header options.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'ihl'=[5-15], <'options'>>

Definition at line 598 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV6_EXT   0x00500000

IP (Internet Protocol) version 6 packet type. It is used for inner packet only, and contains extension headers.

Packet format (inner only): <'ether type'=0x86DD | 'version'=6, 'next header'=[0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], 'extension headers'>

Definition at line 608 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN   0x00600000

IP (Internet Protocol) version 6 packet type. It is used for inner packet only, and may or maynot contain extension headers.

Packet format (inner only): <'ether type'=0x86DD | 'version'=6, 'next header'=[0x3B|0x0|0x2B|0x2C|0x32|0x33|0x3C|0x87], <'extension headers'>>

Definition at line 619 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L3_MASK   0x00f00000

Mask of inner layer 3 packet types.

Definition at line 623 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_TCP   0x01000000

TCP (Transmission Control Protocol) packet type. It is used for inner packet only.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'protocol'=6, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=6>

Definition at line 635 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_UDP   0x02000000

UDP (User Datagram Protocol) packet type. It is used for inner packet only.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'protocol'=17, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=17>

Definition at line 647 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_FRAG   0x03000000

Fragmented IP (Internet Protocol) packet type. It is used for inner packet only, and may or maynot have layer 4 packet.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'MF'=1> or, <'ether type'=0x86DD | 'version'=6, 'next header'=44>

Definition at line 659 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_SCTP   0x04000000

SCTP (Stream Control Transmission Protocol) packet type. It is used for inner packet only.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'protocol'=132, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=132>

Definition at line 671 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_ICMP   0x05000000

ICMP (Internet Control Message Protocol) packet type. It is used for inner packet only.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'protocol'=1, 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'=1>

Definition at line 683 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_NONFRAG   0x06000000

Non-fragmented IP (Internet Protocol) packet type. It is used for inner packet only, and may or maynot have other unknown layer 4 packet types.

Packet format (inner only): <'ether type'=0x0800 | 'version'=4, 'protocol'!=[6|17|132|1], 'MF'=0> or, <'ether type'=0x86DD | 'version'=6, 'next header'!=[6|17|44|132|1]>

Definition at line 696 of file rte_mbuf.h.

#define RTE_PTYPE_INNER_L4_MASK   0x0f000000

Mask of inner layer 4 packet types.

Definition at line 700 of file rte_mbuf.h.

#define RTE_ETH_IS_IPV4_HDR (   ptype)    ((ptype) & RTE_PTYPE_L3_IPV4)

Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by one, bit 4 is selected to be used for IPv4 only. Then checking bit 4 can determine if it is an IPV4 packet.

Examples:
ip_fragmentation/main.c, ip_reassembly/main.c, l3fwd-acl/main.c, l3fwd-power/main.c, and performance-thread/l3fwd-thread/main.c.

Definition at line 707 of file rte_mbuf.h.

#define RTE_ETH_IS_IPV6_HDR (   ptype)    ((ptype) & RTE_PTYPE_L3_IPV6)

Check if the (outer) L3 header is IPv4. To avoid comparing IPv4 types one by one, bit 6 is selected to be used for IPv4 only. Then checking bit 6 can determine if it is an IPV4 packet.

Examples:
ip_fragmentation/main.c, ip_reassembly/main.c, l3fwd-acl/main.c, l3fwd-power/main.c, and performance-thread/l3fwd-thread/main.c.

Definition at line 714 of file rte_mbuf.h.

#define RTE_MBUF_PRIV_ALIGN   8

Alignment constraint of mbuf private area.

Definition at line 723 of file rte_mbuf.h.

#define RTE_MBUF_DEFAULT_DATAROOM   2048

Some NICs need at least 2KB buffer to RX standard Ethernet frame without splitting it into multiple segments. So, for mbufs that planned to be involved into RX/TX, the recommended minimal buffer length is 2KB + RTE_PKTMBUF_HEADROOM.

Definition at line 753 of file rte_mbuf.h.

#define RTE_MBUF_INDIRECT (   mb)    ((mb)->ol_flags & IND_ATTACHED_MBUF)

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

Definition at line 992 of file rte_mbuf.h.

#define RTE_MBUF_DIRECT (   mb)    (!RTE_MBUF_INDIRECT(mb))

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

Definition at line 997 of file rte_mbuf.h.

#define __rte_mbuf_sanity_check (   m,
  is_h 
)    do { } while (0)

check mbuf type in debug mode

Examples:
ipv4_multicast/main.c.

Definition at line 1018 of file rte_mbuf.h.

#define RTE_MBUF_PREFETCH_TO_FREE (   m)
Value:
do { \
if ((m) != NULL) \
rte_prefetch0(m); \
} while (0)

Mbuf prefetch

Definition at line 1110 of file rte_mbuf.h.

#define rte_ctrlmbuf_alloc (   mp)    rte_pktmbuf_alloc(mp)

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
mpThe mempool from which the mbuf is allocated.
Returns
  • The pointer to the new mbuf on success.
  • NULL if allocation failed.

Definition at line 1218 of file rte_mbuf.h.

#define rte_ctrlmbuf_free (   m)    rte_pktmbuf_free(m)

Free a control mbuf back into its original mempool.

Parameters
mThe control mbuf to be freed.

Definition at line 1226 of file rte_mbuf.h.

#define rte_ctrlmbuf_data (   m)    ((char *)((m)->buf_addr) + (m)->data_off)

A macro that returns the pointer to the carried data.

The value that can be read or assigned.

Parameters
mThe control mbuf.

Definition at line 1236 of file rte_mbuf.h.

#define rte_ctrlmbuf_len (   m)    rte_pktmbuf_data_len(m)

A macro that returns the length of the carried data.

The value that can be read or assigned.

Parameters
mThe control mbuf.

Definition at line 1246 of file rte_mbuf.h.

#define rte_pktmbuf_mtod_offset (   m,
  t,
 
)    ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))

A macro that points to an offset into the data in the mbuf.

The returned pointer is cast to type t. Before using this function, the user must ensure that the first segment is large enough to accommodate its data.

Parameters
mThe packet mbuf.
oThe offset into the mbuf data.
tThe type to cast the result into.
Examples:
dpdk_qat/crypto.c, dpdk_qat/main.c, l3fwd-acl/main.c, l3fwd-power/main.c, l3fwd-vf/main.c, load_balancer/runtime.c, performance-thread/l3fwd-thread/main.c, and vhost_xen/main.c.

Definition at line 1769 of file rte_mbuf.h.

#define rte_pktmbuf_mtod (   m,
 
)    rte_pktmbuf_mtod_offset(m, t, 0)
#define rte_pktmbuf_mtophys_offset (   m,
 
)    (phys_addr_t)((m)->buf_physaddr + (m)->data_off + (o))

A macro that returns the physical address that points to an offset of the start of the data in the mbuf

Parameters
mThe packet mbuf.
oThe offset into the data to calculate address from.
Examples:
l2fwd-crypto/main.c.

Definition at line 1795 of file rte_mbuf.h.

#define rte_pktmbuf_mtophys (   m)    rte_pktmbuf_mtophys_offset(m, 0)

A macro that returns the physical address that points to the start of the data in the mbuf

Parameters
mThe packet mbuf.

Definition at line 1805 of file rte_mbuf.h.

#define rte_pktmbuf_pkt_len (   m)    ((m)->pkt_len)

A macro that returns the length of the packet.

The value can be read or assigned.

Parameters
mThe packet mbuf.
Examples:
l2fwd-crypto/main.c, and qos_meter/main.c.

Definition at line 1815 of file rte_mbuf.h.

#define rte_pktmbuf_data_len (   m)    ((m)->data_len)

A macro that returns the length of the segment.

The value can be read or assigned.

Parameters
mThe packet mbuf.
Examples:
exception_path/main.c, l2fwd-crypto/main.c, netmap_compat/lib/compat_netmap.c, and vhost_xen/main.c.

Definition at line 1825 of file rte_mbuf.h.

Typedef Documentation

typedef void* MARKER[0]

generic marker for a point in a structure

Definition at line 759 of file rte_mbuf.h.

typedef uint8_t MARKER8[0]

generic marker with 1B alignment

Definition at line 760 of file rte_mbuf.h.

typedef uint64_t MARKER64[0]

marker that allows us to overwrite 8 bytes with a single assignment

Definition at line 761 of file rte_mbuf.h.

Function Documentation

const char* rte_get_rx_ol_flag_name ( uint64_t  mask)

Get the name of a RX offload flag

Parameters
maskThe mask describing the flag.
Returns
The name of this flag, or NULL if it's not a valid RX flag.
const char* rte_get_tx_ol_flag_name ( uint64_t  mask)

Get the name of a TX offload flag

Parameters
maskThe mask describing the flag. Usually only one bit must be set. Several bits can be given if they belong to the same mask. Ex: PKT_TX_L4_MASK.
Returns
The name of this flag, or NULL if it's not a valid TX flag.
static void rte_mbuf_prefetch_part1 ( struct rte_mbuf m)
inlinestatic

Prefetch the first part of the mbuf

The first 64 bytes of the mbuf corresponds to fields that are used early in the receive path. If the cache line of the architecture is higher than 64B, the second part will also be prefetched.

Parameters
mThe pointer to the mbuf.

Definition at line 898 of file rte_mbuf.h.

static void rte_mbuf_prefetch_part2 ( struct rte_mbuf m)
inlinestatic

Prefetch the second part of the mbuf

The next 64 bytes of the mbuf corresponds to fields that are used in the transmit path. If the cache line of the architecture is higher than 64B, this function does nothing as it is expected that the full mbuf is already in cache.

Parameters
mThe pointer to the mbuf.

Definition at line 915 of file rte_mbuf.h.

static uint16_t rte_pktmbuf_priv_size ( struct rte_mempool mp)
inlinestatic

Get the application private size of mbufs stored in a pktmbuf_pool

The private size of mbuf is a zone located between the rte_mbuf structure and the data buffer where an application can store data associated to a packet.

Parameters
mpThe packet mbuf pool.
Returns
The private size of mbufs stored in this mempool.

Definition at line 1379 of file rte_mbuf.h.

static phys_addr_t rte_mbuf_data_dma_addr ( const struct rte_mbuf mb)
inlinestatic

Return the DMA address of the beginning of the mbuf data

Parameters
mbThe pointer to the mbuf.
Returns
The physical address of the beginning of the mbuf data

Definition at line 936 of file rte_mbuf.h.

static phys_addr_t rte_mbuf_data_dma_addr_default ( const struct rte_mbuf mb)
inlinestatic

Return the default DMA address of the beginning of the mbuf data

This function is used by drivers in their receive function, as it returns the location where data should be written by the NIC, taking the default headroom in account.

Parameters
mbThe pointer to the mbuf.
Returns
The physical address of the beginning of the mbuf data

Definition at line 954 of file rte_mbuf.h.

static struct rte_mbuf* rte_mbuf_from_indirect ( struct rte_mbuf mi)
staticread

Return the mbuf owning the data buffer address of an indirect mbuf.

Parameters
miThe pointer to the indirect mbuf.
Returns
The address of the direct mbuf corresponding to buffer_addr.

Definition at line 968 of file rte_mbuf.h.

static char* rte_mbuf_to_baddr ( struct rte_mbuf md)
inlinestatic

Return the buffer address embedded in the given mbuf.

Parameters
mdThe pointer to the mbuf.
Returns
The address of the data buffer owned by the mbuf.

Definition at line 982 of file rte_mbuf.h.

static uint16_t rte_mbuf_refcnt_update ( struct rte_mbuf m,
int16_t  value 
)
inlinestatic

Adds given value to an mbuf's refcnt and returns its new value.

Definition at line 1083 of file rte_mbuf.h.

static uint16_t rte_mbuf_refcnt_read ( const struct rte_mbuf m)
inlinestatic

Reads the value of an mbuf's refcnt.

Definition at line 1093 of file rte_mbuf.h.

static void rte_mbuf_refcnt_set ( struct rte_mbuf m,
uint16_t  new_value 
)
inlinestatic

Sets an mbuf's refcnt to the defined value.

Definition at line 1102 of file rte_mbuf.h.

void rte_mbuf_sanity_check ( const struct rte_mbuf m,
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
mThe mbuf to be checked.
is_headerTrue 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)
static struct rte_mbuf* rte_mbuf_raw_alloc ( struct rte_mempool mp)
staticread

Allocate an unitialized mbuf from mempool mp.

This function can be used by PMDs (especially in RX functions) to allocate an unitialized mbuf. The driver is responsible of initializing all the required fields. See rte_pktmbuf_reset(). For standard needs, prefer rte_pktmbuf_alloc().

Parameters
mpThe mempool from which mbuf is allocated.
Returns
  • The pointer to the new mbuf on success.
  • NULL if allocation failed.

Definition at line 1145 of file rte_mbuf.h.

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.

Parameters
mpThe mempool from which the mbuf is allocated.
opaque_argA 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().
mThe mbuf to initialize.
iThe index of the mbuf in the pool table.
static int rte_is_ctrlmbuf ( struct rte_mbuf m)
inlinestatic

Tests if an mbuf is a control mbuf

Parameters
mThe mbuf to be tested
Returns
  • True (1) if the mbuf is a control mbuf
  • False(0) otherwise

Definition at line 1258 of file rte_mbuf.h.

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 (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
mpThe mempool from which mbufs originate.
opaque_argA 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().
mThe mbuf to initialize.
iThe index of the mbuf in the pool table.
Examples:
ip_pipeline/init.c, ip_reassembly/main.c, multi_process/l2fwd_fork/main.c, and tep_termination/main.c.
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
mpThe mempool from which mbufs originate.
opaque_argA 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().
Examples:
ip_pipeline/init.c, ip_reassembly/main.c, multi_process/l2fwd_fork/main.c, and tep_termination/main.c.
struct rte_mempool* rte_pktmbuf_pool_create ( const char *  name,
unsigned  n,
unsigned  cache_size,
uint16_t  priv_size,
uint16_t  data_room_size,
int  socket_id 
)
read

Create a mbuf pool.

This function creates and initializes a packet mbuf pool. It is a wrapper to rte_mempool_create() with the proper packet constructor and mempool constructor.

Parameters
nameThe name of the mbuf pool.
nThe number of elements in the mbuf pool. 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).
cache_sizeSize of the per-core object cache. See rte_mempool_create() for details.
priv_sizeSize of application private are between the rte_mbuf structure and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN.
data_room_sizeSize of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM.
socket_idThe socket identifier where the memory should be allocated. The value can be SOCKET_ID_ANY if there is no NUMA constraint for the reserved zone.
Returns
The pointer to the new allocated mempool, on success. NULL on error with rte_errno set appropriately. Possible rte_errno values include:
  • E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
  • E_RTE_SECONDARY - function was called from a secondary process instance
  • EINVAL - cache size provided is too large, or priv_size is not aligned.
  • 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
Examples:
bond/main.c, distributor/main.c, dpdk_qat/main.c, ethtool/ethtool-app/main.c, exception_path/main.c, ip_fragmentation/main.c, ipv4_multicast/main.c, kni/main.c, l2fwd-crypto/main.c, l2fwd-ivshmem/host/host.c, l2fwd-jobstats/main.c, l2fwd-keepalive/main.c, l2fwd/main.c, l3fwd-acl/main.c, l3fwd-power/main.c, l3fwd-vf/main.c, l3fwd/main.c, link_status_interrupt/main.c, load_balancer/init.c, multi_process/client_server_mp/mp_server/init.c, multi_process/symmetric_mp/main.c, netmap_compat/bridge/bridge.c, packet_ordering/main.c, performance-thread/l3fwd-thread/main.c, ptpclient/ptpclient.c, qos_meter/main.c, qos_sched/init.c, quota_watermark/qw/main.c, rxtx_callbacks/main.c, skeleton/basicfwd.c, vhost/main.c, vhost_xen/main.c, vmdq/main.c, and vmdq_dcb/main.c.
static uint16_t rte_pktmbuf_data_room_size ( struct rte_mempool mp)
inlinestatic

Get the data room size of mbufs stored in a pktmbuf_pool

The data room size is the amount of data that can be stored in a mbuf including the headroom (RTE_PKTMBUF_HEADROOM).

Parameters
mpThe packet mbuf pool.
Returns
The data room size of mbufs stored in this mempool.

Definition at line 1358 of file rte_mbuf.h.

static void rte_pktmbuf_reset ( struct rte_mbuf m)
inlinestatic

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

The given mbuf must have only one segment.

Parameters
mThe packet mbuf to be resetted.
Examples:
netmap_compat/lib/compat_netmap.c.

Definition at line 1395 of file rte_mbuf.h.

static struct rte_mbuf* rte_pktmbuf_alloc ( struct rte_mempool mp)
staticread

Allocate a new mbuf 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
mpThe mempool from which the mbuf is allocated.
Returns
  • The pointer to the new mbuf on success.
  • NULL if allocation failed.
Examples:
bond/main.c, exception_path/main.c, ipv4_multicast/main.c, netmap_compat/lib/compat_netmap.c, ptpclient/ptpclient.c, quota_watermark/qw/main.c, and vhost_xen/main.c.

Definition at line 1427 of file rte_mbuf.h.

static int rte_pktmbuf_alloc_bulk ( struct rte_mempool pool,
struct rte_mbuf **  mbufs,
unsigned  count 
)
inlinestatic

Allocate a bulk of mbufs, initialize refcnt and reset the fields to default values.

Parameters
poolThe mempool from which mbufs are allocated.
mbufsArray of pointers to mbufs
countArray size
Returns
  • 0: Success

Definition at line 1448 of file rte_mbuf.h.

static void rte_pktmbuf_attach ( struct rte_mbuf mi,
struct rte_mbuf m 
)
inlinestatic

Attach packet mbuf to another packet mbuf.

After attachment we refer the mbuf we attached as 'indirect', while mbuf we attached to as 'direct'. The direct mbuf's reference counter is incremented.

Right now, not supported:

  • 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. it's reference counter is greater then 1.
Parameters
miThe indirect packet mbuf.
mThe packet mbuf we're attaching to.

Definition at line 1507 of file rte_mbuf.h.

static void rte_pktmbuf_detach ( struct rte_mbuf m)
inlinestatic

Detach an indirect packet mbuf.

  • restore original mbuf address and length values.
  • reset pktmbuf data and data_len to their default values.
  • decrement the direct mbuf's reference counter. When the reference counter becomes 0, the direct mbuf is freed.

All other fields of the given packet mbuf will be left intact.

Parameters
mThe indirect attached packet mbuf.

Definition at line 1558 of file rte_mbuf.h.

static void rte_pktmbuf_free_seg ( struct rte_mbuf m)
inlinestatic

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

Free an mbuf, without parsing other segments in case of chained buffers.

Parameters
mThe packet mbuf segment to be freed.
Examples:
vhost_xen/main.c.

Definition at line 1604 of file rte_mbuf.h.

static void rte_pktmbuf_free ( struct rte_mbuf m)
inlinestatic
static struct rte_mbuf* rte_pktmbuf_clone ( struct rte_mbuf md,
struct rte_mempool mp 
)
staticread

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
mdThe packet mbuf to be cloned.
mpThe mempool from which the "clone" mbufs are allocated.
Returns
  • The pointer to the new "clone" mbuf on success.
  • NULL if allocation fails.
Examples:
ipv4_multicast/main.c.

Definition at line 1651 of file rte_mbuf.h.

static void rte_pktmbuf_refcnt_update ( struct rte_mbuf m,
int16_t  v 
)
inlinestatic

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
mThe packet mbuf whose refcnt to be updated.
vThe value to add to the mbuf's segments refcnt.
Examples:
ipv4_multicast/main.c.

Definition at line 1699 of file rte_mbuf.h.

static uint16_t rte_pktmbuf_headroom ( const struct rte_mbuf m)
inlinestatic

Get the headroom in a packet mbuf.

Parameters
mThe packet mbuf.
Returns
The length of the headroom.

Definition at line 1716 of file rte_mbuf.h.

static uint16_t rte_pktmbuf_tailroom ( const struct rte_mbuf m)
inlinestatic

Get the tailroom of a packet mbuf.

Parameters
mThe packet mbuf.
Returns
The length of the tailroom.
Examples:
vhost/main.c.

Definition at line 1730 of file rte_mbuf.h.

static struct rte_mbuf* rte_pktmbuf_lastseg ( struct rte_mbuf m)
staticread

Get the last segment of the packet.

Parameters
mThe packet mbuf.
Returns
The last segment of the given mbuf.

Definition at line 1745 of file rte_mbuf.h.

static char* rte_pktmbuf_prepend ( struct rte_mbuf m,
uint16_t  len 
)
inlinestatic

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
mThe pkt mbuf.
lenThe 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
Examples:
ip_fragmentation/main.c, ipv4_multicast/main.c, and tep_termination/vxlan.c.

Definition at line 1842 of file rte_mbuf.h.

static char* rte_pktmbuf_append ( struct rte_mbuf m,
uint16_t  len 
)
inlinestatic

Append len bytes to an mbuf.

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
mThe packet mbuf.
lenThe 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
Examples:
l2fwd-crypto/main.c, and netmap_compat/lib/compat_netmap.c.

Definition at line 1872 of file rte_mbuf.h.

static char* rte_pktmbuf_adj ( struct rte_mbuf m,
uint16_t  len 
)
inlinestatic

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
mThe packet mbuf.
lenThe amount of data to remove (in bytes).
Returns
A pointer to the new start of the data.
Examples:
ip_fragmentation/main.c, ipv4_multicast/main.c, and tep_termination/vxlan.c.

Definition at line 1903 of file rte_mbuf.h.

static int rte_pktmbuf_trim ( struct rte_mbuf m,
uint16_t  len 
)
inlinestatic

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
mThe packet mbuf.
lenThe amount of data to remove (in bytes).
Returns
  • 0: On success.
  • -1: On error.

Definition at line 1930 of file rte_mbuf.h.

static int rte_pktmbuf_is_contiguous ( const struct rte_mbuf m)
inlinestatic

Test if mbuf data is contiguous.

Parameters
mThe packet mbuf.
Returns
  • 1, if all data is contiguous (one segment).
  • 0, if there is several segments.

Definition at line 1954 of file rte_mbuf.h.

static int rte_pktmbuf_chain ( struct rte_mbuf head,
struct rte_mbuf tail 
)
inlinestatic

Chain an mbuf to another, thereby creating a segmented packet.

Note: The implementation will do a linear walk over the segments to find the tail entry. For cases when there are many segments, it's better to chain the entries manually.

Parameters
headThe head of the mbuf chain (the first packet)
tailThe mbuf to put last in the chain
Returns
  • 0, on success.
  • -EOVERFLOW, if the chain is full (256 entries)

Definition at line 1976 of file rte_mbuf.h.

void rte_pktmbuf_dump ( FILE *  f,
const struct rte_mbuf m,
unsigned  dump_len 
)

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
fA pointer to a file for output
mThe packet mbuf.
dump_lenIf dump_len != 0, also dump the "dump_len" first data bytes of the packet.