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

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   (0ULL << 0)
#define PKT_RX_OVERSIZE   (0ULL << 0)
#define PKT_RX_HBUF_OVERFLOW   (0ULL << 0)
#define PKT_RX_RECIP_ERR   (0ULL << 0)
#define PKT_RX_MAC_ERR   (0ULL << 0)
#define PKT_RX_IPV4_HDR   (1ULL << 5)
#define PKT_RX_IPV4_HDR_EXT   (1ULL << 6)
#define PKT_RX_IPV6_HDR   (1ULL << 7)
#define PKT_RX_IPV6_HDR_EXT   (1ULL << 8)
#define PKT_RX_IEEE1588_PTP   (1ULL << 9)
#define PKT_RX_IEEE1588_TMST   (1ULL << 10)
#define PKT_RX_TUNNEL_IPV4_HDR   (1ULL << 11)
#define PKT_RX_TUNNEL_IPV6_HDR   (1ULL << 12)
#define PKT_RX_FDIR_ID   (1ULL << 13)
#define PKT_RX_FDIR_FLX   (1ULL << 14)
#define PKT_TX_TCP_SEG   (1ULL << 49)
#define PKT_TX_UDP_TUNNEL_PKT   (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_CSUM   PKT_TX_IP_CKSUM
#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 CTRL_MBUF_FLAG   (1ULL << 63)
#define RTE_MBUF_FROM_BADDR(ba)   (((struct rte_mbuf *)(ba)) - 1)
#define RTE_MBUF_TO_BADDR(mb)   (((struct rte_mbuf *)(mb)) + 1)
#define RTE_MBUF_INDIRECT(mb)   (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb))
#define RTE_MBUF_DIRECT(mb)   (RTE_MBUF_FROM_BADDR((mb)->buf_addr) == (mb))
#define __rte_mbuf_sanity_check(m, is_h)   do { } while (0)
#define __rte_mbuf_sanity_check_raw(m, is_h)   do { } while (0)
#define RTE_MBUF_ASSERT(exp)   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(m, t)   ((t)((char *)(m)->buf_addr + (m)->data_off))
#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 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)
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)
static void rte_pktmbuf_reset (struct rte_mbuf *m)
static struct rte_mbufrte_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_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)
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

Macro Definition Documentation

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

check mbuf type in debug mode

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

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

#define CTRL_MBUF_FLAG   (1ULL << 63)

Mbuf contains control data

#define PKT_RX_EIP_CKSUM_BAD   (0ULL << 0)

External IP header checksum error.

#define PKT_RX_FDIR   (1ULL << 2)

RX packet with FDIR match indicate.

#define PKT_RX_FDIR_FLX   (1ULL << 14)

Flexible bytes reported if FDIR match.

#define PKT_RX_FDIR_ID   (1ULL << 13)

FD id reported if FDIR match.

#define PKT_RX_HBUF_OVERFLOW   (0ULL << 0)

Header buffer overflow.

#define PKT_RX_IEEE1588_PTP   (1ULL << 9)

RX IEEE1588 L2 Ethernet PT Packet.

#define PKT_RX_IEEE1588_TMST   (1ULL << 10)

RX IEEE1588 L2/L4 timestamped packet.

#define PKT_RX_IP_CKSUM_BAD   (1ULL << 4)

IP cksum of RX pkt. is not OK.

#define PKT_RX_IPV4_HDR   (1ULL << 5)

RX packet with IPv4 header.

#define PKT_RX_IPV4_HDR_EXT   (1ULL << 6)

RX packet with extended IPv4 header.

#define PKT_RX_IPV6_HDR   (1ULL << 7)

RX packet with IPv6 header.

#define PKT_RX_IPV6_HDR_EXT   (1ULL << 8)

RX packet with extended IPv6 header.

#define PKT_RX_L4_CKSUM_BAD   (1ULL << 3)

L4 cksum of RX pkt. is not OK.

#define PKT_RX_MAC_ERR   (0ULL << 0)

MAC error.

#define PKT_RX_OVERSIZE   (0ULL << 0)

Num of desc of an RX pkt oversize.

#define PKT_RX_RECIP_ERR   (0ULL << 0)

Hardware processing error.

#define PKT_RX_RSS_HASH   (1ULL << 1)

RX packet with RSS hash result.

#define PKT_RX_TUNNEL_IPV4_HDR   (1ULL << 11)

RX tunnel packet with IPv4 header.

#define PKT_RX_TUNNEL_IPV6_HDR   (1ULL << 12)

RX tunnel packet with IPv6 header.

#define PKT_RX_VLAN_PKT   (1ULL << 0)

RX packet is a 802.1q VLAN packet.

#define PKT_TX_IEEE1588_TMST   (1ULL << 51)

TX IEEE1588 packet to timestamp.

#define PKT_TX_IP_CKSUM   (1ULL << 54)

IP cksum of TX pkt. computed by NIC.

#define PKT_TX_IPV4   (1ULL << 55)

Packet is IPv4 without requiring IP checksum offload.

#define PKT_TX_IPV4_CSUM   PKT_TX_IP_CKSUM

Alias of PKT_TX_IP_CKSUM.

#define PKT_TX_IPV6   (1ULL << 56)

Tell the NIC it's an IPv6 packet.

#define PKT_TX_L4_MASK   (3ULL << 52)

Mask for L4 cksum offload request.

#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.
#define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)

Outer IP checksum of TX packet, computed by NIC for tunneling packet. The tunnel type must also be specified, ex: PKT_TX_UDP_TUNNEL_PKT.

#define PKT_TX_OUTER_IPV4   (1ULL << 59)

Packet is outer IPv4 without requiring IP checksum offload for tunneling packet.

#define PKT_TX_OUTER_IPV6   (1ULL << 60)

Tell the NIC it's an outer IPv6 packet for tunneling packet

#define PKT_TX_SCTP_CKSUM   (2ULL << 52)

SCTP cksum of TX pkt. computed by NIC.

#define PKT_TX_TCP_CKSUM   (1ULL << 52)

TCP cksum of TX pkt. computed by NIC.

#define PKT_TX_TCP_SEG   (1ULL << 49)

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.
#define PKT_TX_UDP_CKSUM   (3ULL << 52)

UDP cksum of TX pkt. computed by NIC.

#define PKT_TX_UDP_TUNNEL_PKT   (1ULL << 50)

TX packet is an UDP tunneled packet. It must be specified when using outer checksum offload (PKT_TX_OUTER_IP_CKSUM) TX packet is an UDP tunneled packet

#define PKT_TX_VLAN_PKT   (1ULL << 57)

TX packet is a 802.1q VLAN packet.

#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.
#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.
#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.
#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.
#define RTE_MBUF_ASSERT (   exp)    do { } while (0)

MBUF asserts in debug mode

#define RTE_MBUF_DIRECT (   mb)    (RTE_MBUF_FROM_BADDR((mb)->buf_addr) == (mb))

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

#define RTE_MBUF_FROM_BADDR (   ba)    (((struct rte_mbuf *)(ba)) - 1)

Given the buf_addr returns the pointer to corresponding mbuf.

#define RTE_MBUF_INDIRECT (   mb)    (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb))

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

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

Mbuf prefetch

#define RTE_MBUF_TO_BADDR (   mb)    (((struct rte_mbuf *)(mb)) + 1)

Given the pointer to mbuf returns an address where it's buf_addr should point to.

#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.
#define rte_pktmbuf_mtod (   m,
 
)    ((t)((char *)(m)->buf_addr + (m)->data_off))

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
mThe packet mbuf.
tThe type to cast the result into.
#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.

Typedef Documentation

typedef void* MARKER[0]

generic marker for a point in a structure

typedef uint64_t MARKER64[0]

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

typedef uint8_t MARKER8[0]

generic marker with 1B alignment

Function Documentation

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.
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 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
static uint16_t rte_mbuf_refcnt_read ( const struct rte_mbuf m)
inlinestatic

Reads the value of an mbuf's refcnt.

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

Sets an mbuf's refcnt to the defined value.

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.

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 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.
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.
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
static void rte_pktmbuf_attach ( struct rte_mbuf mi,
struct rte_mbuf md 
)
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'. Right now, not supported:

  • attachment to indirect mbuf (e.g. - md has to be direct).
  • 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.
mdThe direct packet mbuf.
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.
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. All other fields of the given packet mbuf will be left intact.
Parameters
mThe indirect attached packet mbuf.
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.
static void rte_pktmbuf_free ( struct rte_mbuf m)
inlinestatic

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
mThe packet mbuf to be freed.
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.
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.
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.
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.
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.
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().
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
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.
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.
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.
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.