API Reference Manual  1.45.0
ODP BUFFER

API Description

Buffer event metadata and operations.

Macros

#define ODP_BUFFER_INVALID   ((odp_buffer_t)0)
 Invalid buffer.
 

Typedefs

typedef _odp_abi_buffer_todp_buffer_t
 ODP buffer.
 

Functions

odp_buffer_t odp_buffer_from_event (odp_event_t ev)
 Get buffer handle from event. More...
 
void odp_buffer_from_event_multi (odp_buffer_t buf[], const odp_event_t ev[], int num)
 Convert multiple buffer events to buffer handles. More...
 
odp_event_t odp_buffer_to_event (odp_buffer_t buf)
 Convert buffer handle to event. More...
 
void odp_buffer_to_event_multi (const odp_buffer_t buf[], odp_event_t ev[], int num)
 Convert multiple buffer handles to events. More...
 
void * odp_buffer_addr (odp_buffer_t buf)
 Buffer start address. More...
 
uint32_t odp_buffer_size (odp_buffer_t buf)
 Buffer maximum data size. More...
 
void * odp_buffer_user_area (odp_buffer_t buf)
 Buffer user area. More...
 
int odp_buffer_is_valid (odp_buffer_t buf)
 Check that buffer is valid. More...
 
odp_pool_t odp_buffer_pool (odp_buffer_t buf)
 Buffer pool of the buffer. More...
 
odp_buffer_t odp_buffer_alloc (odp_pool_t pool)
 Buffer alloc. More...
 
int odp_buffer_alloc_multi (odp_pool_t pool, odp_buffer_t buf[], int num)
 Allocate multiple buffers. More...
 
void odp_buffer_free (odp_buffer_t buf)
 Buffer free. More...
 
void odp_buffer_free_multi (const odp_buffer_t buf[], int num)
 Free multiple buffers. More...
 
void odp_buffer_print (odp_buffer_t buf)
 Print buffer metadata to STDOUT. More...
 
uint64_t odp_buffer_to_u64 (odp_buffer_t hdl)
 Get printable value for an odp_buffer_t. More...
 

Function Documentation

◆ odp_buffer_from_event()

odp_buffer_t odp_buffer_from_event ( odp_event_t  ev)

Get buffer handle from event.

Converts an ODP_EVENT_BUFFER type event to a buffer.

Parameters
evEvent handle
Returns
Buffer handle
See also
odp_event_type()
Examples
odp_bench_buffer.c, odp_sched_latency.c, and odp_sched_perf.c.

◆ odp_buffer_from_event_multi()

void odp_buffer_from_event_multi ( odp_buffer_t  buf[],
const odp_event_t  ev[],
int  num 
)

Convert multiple buffer events to buffer handles.

All events must be of type ODP_EVENT_BUFFER.

Parameters
[out]bufBuffer handle array for output
evArray of event handles to convert
numNumber of buffers and events
Examples
odp_bench_buffer.c.

◆ odp_buffer_to_event()

odp_event_t odp_buffer_to_event ( odp_buffer_t  buf)

Convert buffer handle to event.

Parameters
bufBuffer handle
Returns
Event handle
Examples
odp_bench_buffer.c, odp_queue_perf.c, odp_sched_latency.c, and odp_sched_perf.c.

◆ odp_buffer_to_event_multi()

void odp_buffer_to_event_multi ( const odp_buffer_t  buf[],
odp_event_t  ev[],
int  num 
)

Convert multiple buffer handles to events.

Parameters
bufArray of buffer handles to convert
[out]evEvent handle array for output
numNumber of buffers and events
Examples
odp_bench_buffer.c.

◆ odp_buffer_addr()

void* odp_buffer_addr ( odp_buffer_t  buf)

Buffer start address.

Parameters
bufBuffer handle
Returns
Buffer start address
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_buffer.c, odp_dmafwd.c, odp_sched_latency.c, and odp_sched_perf.c.

◆ odp_buffer_size()

uint32_t odp_buffer_size ( odp_buffer_t  buf)

Buffer maximum data size.

Parameters
bufBuffer handle
Returns
Buffer maximum data size
Examples
odp_bench_buffer.c, and odp_sched_perf.c.

◆ odp_buffer_user_area()

void* odp_buffer_user_area ( odp_buffer_t  buf)

Buffer user area.

Returns pointer to the user area associated with the buffer. Size of the area is fixed and defined in buffer pool parameters.

Parameters
bufBuffer handle
Returns
Pointer to the user area of the buffer
Return values
NULLThe buffer does not have user area
Examples
odp_bench_buffer.c, and odp_pool_latency.c.

◆ odp_buffer_is_valid()

int odp_buffer_is_valid ( odp_buffer_t  buf)

Check that buffer is valid.

This function can be used for debugging purposes to check if a buffer handle represents a valid buffer. The level of error checks depends on the implementation. The call should not crash if the buffer handle is corrupted.

Parameters
bufBuffer handle
Return values
1Buffer handle represents a valid buffer.
0Buffer handle does not represent a valid buffer.
Examples
odp_bench_buffer.c, and odp_sched_latency.c.

◆ odp_buffer_pool()

odp_pool_t odp_buffer_pool ( odp_buffer_t  buf)

Buffer pool of the buffer.

Parameters
bufBuffer handle
Returns
Handle of buffer pool buffer belongs to
Examples
odp_bench_buffer.c.

◆ odp_buffer_alloc()

odp_buffer_t odp_buffer_alloc ( odp_pool_t  pool)

Buffer alloc.

Allocates a buffer from the pool. Returns ODP_BUFFER_INVALID when a buffer can not be allocated.

Parameters
poolPool handle
Returns
Handle of allocated buffer
Return values
ODP_BUFFER_INVALIDBuffer could not be allocated
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_buffer.c, odp_debug.c, odp_dmafwd.c, odp_queue_perf.c, odp_sched_latency.c, and odp_sched_perf.c.

◆ odp_buffer_alloc_multi()

int odp_buffer_alloc_multi ( odp_pool_t  pool,
odp_buffer_t  buf[],
int  num 
)

Allocate multiple buffers.

Otherwise like odp_buffer_alloc(), but allocates multiple buffers from a pool.

Parameters
poolPool handle
[out]bufArray of buffer handles for output
numMaximum number of buffers to allocate
Returns
Number of buffers actually allocated (0 ... num)
Return values
<0on failure
Examples
odp_bench_buffer.c, odp_pool_latency.c, odp_pool_perf.c, and odp_sched_latency.c.

◆ odp_buffer_free()

void odp_buffer_free ( odp_buffer_t  buf)

Buffer free.

Parameters
bufBuffer handle
Examples
ipsec_api/odp_ipsec.c, ipsec_crypto/odp_ipsec.c, odp_bench_buffer.c, odp_debug.c, and odp_dmafwd.c.

◆ odp_buffer_free_multi()

void odp_buffer_free_multi ( const odp_buffer_t  buf[],
int  num 
)

Free multiple buffers.

Otherwise like odp_buffer_free(), but frees multiple buffers to their originating pools.

Parameters
bufArray of buffer handles
numNumber of buffer handles to free
Examples
odp_bench_buffer.c, odp_pool_latency.c, odp_pool_perf.c, and odp_sched_latency.c.

◆ odp_buffer_print()

void odp_buffer_print ( odp_buffer_t  buf)

Print buffer metadata to STDOUT.

Parameters
bufBuffer handle
Examples
odp_debug.c.

◆ odp_buffer_to_u64()

uint64_t odp_buffer_to_u64 ( odp_buffer_t  hdl)

Get printable value for an odp_buffer_t.

Parameters
hdlodp_buffer_t handle to be printed
Returns
uint64_t value that can be used to print/display this handle
Note
This routine is intended to be used for diagnostic purposes to enable applications to generate a printable value that represents an odp_buffer_t handle.