API Reference Manual
1.46.0
|
DMA offload.
Data Structures | |
struct | odp_dma_pool_capability_t |
DMA completion event pool capabilities. More... | |
struct | odp_dma_pool_param_t |
DMA completion event pool parameters. More... | |
struct | odp_dma_capability_t |
DMA capabilities. More... | |
struct | odp_dma_param_t |
DMA session parameters. More... | |
struct | odp_dma_seg_t |
DMA segment. More... | |
struct | odp_dma_transfer_param_t |
DMA transfer parameters. More... | |
struct | odp_dma_compl_param_t |
DMA transfer completion parameters. More... | |
struct | odp_dma_result_t |
DMA transfer results. More... | |
Macros | |
#define | ODP_DMA_INVALID ((odp_dma_t)0) |
Invalid DMA session. | |
#define | ODP_DMA_COMPL_INVALID ((odp_dma_compl_t)0) |
Invalid DMA completion event. | |
#define | ODP_DMA_TRANSFER_ID_INVALID ((odp_dma_transfer_id_t)0) |
Invalid DMA transfer identifier. | |
#define | ODP_DMA_NAME_LEN 32 |
Maximum DMA name length, including the null character. | |
#define | ODP_DMA_MAIN_TO_MAIN 0x1u |
DMA transfer within the main memory. | |
#define | ODP_DMA_TYPE_COPY 0x1u |
Copy data. More... | |
#define | ODP_DMA_COMPL_NONE 0x1u |
No completion indication. More... | |
#define | ODP_DMA_COMPL_SYNC 0x2u |
Synchronous transfer. More... | |
#define | ODP_DMA_COMPL_EVENT 0x4u |
Asynchronous transfer with completion event. More... | |
#define | ODP_DMA_COMPL_POLL 0x8u |
Asynchronous transfer with completion polling. More... | |
Typedefs | |
typedef _odp_abi_dma_t * | odp_dma_t |
DMA session. | |
typedef _odp_abi_dma_t * | odp_dma_compl_t |
DMA completion event. | |
typedef uint64_t | odp_dma_transfer_id_t |
DMA transfer identifier. | |
typedef struct odp_dma_pool_capability_t | odp_dma_pool_capability_t |
DMA completion event pool capabilities. More... | |
typedef struct odp_dma_pool_param_t | odp_dma_pool_param_t |
DMA completion event pool parameters. | |
typedef uint32_t | odp_dma_direction_t |
DMA transfer direction. More... | |
typedef uint32_t | odp_dma_transfer_type_t |
DMA transfer type. More... | |
typedef uint32_t | odp_dma_compl_mode_t |
DMA transfer completion mode. More... | |
typedef struct odp_dma_capability_t | odp_dma_capability_t |
DMA capabilities. | |
typedef struct odp_dma_param_t | odp_dma_param_t |
DMA session parameters. | |
typedef struct odp_dma_seg_t | odp_dma_seg_t |
DMA segment. | |
typedef struct odp_dma_transfer_param_t | odp_dma_transfer_param_t |
DMA transfer parameters. More... | |
typedef struct odp_dma_compl_param_t | odp_dma_compl_param_t |
DMA transfer completion parameters. | |
typedef struct odp_dma_result_t | odp_dma_result_t |
DMA transfer results. | |
Enumerations | |
enum | odp_dma_data_format_t { ODP_DMA_FORMAT_ADDR = 0 , ODP_DMA_FORMAT_PACKET } |
DMA transfer data format. More... | |
enum | odp_dma_transfer_order_t { ODP_DMA_ORDER_NONE = 0 , ODP_DMA_ORDER_COMPL , ODP_DMA_ORDER_ALL } |
DMA transfer ordering. More... | |
enum | odp_dma_mt_mode_t { ODP_DMA_MT_SAFE = 0 , ODP_DMA_MT_SERIAL } |
DMA transfer multi-thread safeness. More... | |
Functions | |
int | odp_dma_capability (odp_dma_capability_t *capa) |
Query DMA capabilities. More... | |
void | odp_dma_param_init (odp_dma_param_t *param) |
Initialize DMA session parameters. More... | |
odp_dma_t | odp_dma_create (const char *name, const odp_dma_param_t *param) |
Create DMA session. More... | |
int | odp_dma_destroy (odp_dma_t dma) |
Destroy DMA session. More... | |
odp_dma_t | odp_dma_lookup (const char *name) |
Find DMA session by name. More... | |
void | odp_dma_transfer_param_init (odp_dma_transfer_param_t *trs_param) |
Initialize DMA transfer parameters. More... | |
void | odp_dma_compl_param_init (odp_dma_compl_param_t *compl_param) |
Initialize DMA transfer completion parameters. More... | |
int | odp_dma_transfer (odp_dma_t dma, const odp_dma_transfer_param_t *trs_param, odp_dma_result_t *result) |
Perform DMA transfer. More... | |
int | odp_dma_transfer_multi (odp_dma_t dma, const odp_dma_transfer_param_t *trs_param[], odp_dma_result_t *result[], int num) |
Perform multiple DMA transfers. More... | |
int | odp_dma_transfer_start (odp_dma_t dma, const odp_dma_transfer_param_t *trs_param, const odp_dma_compl_param_t *compl_param) |
Start DMA transfer. More... | |
int | odp_dma_transfer_start_multi (odp_dma_t dma, const odp_dma_transfer_param_t *trs_param[], const odp_dma_compl_param_t *compl_param[], int num) |
Start multiple DMA transfers. More... | |
int | odp_dma_transfer_done (odp_dma_t dma, odp_dma_transfer_id_t transfer_id, odp_dma_result_t *result) |
Check if DMA transfer has completed. More... | |
odp_dma_transfer_id_t | odp_dma_transfer_id_alloc (odp_dma_t dma) |
Allocate DMA transfer identifier. More... | |
void | odp_dma_transfer_id_free (odp_dma_t dma, odp_dma_transfer_id_t transfer_id) |
Free DMA transfer identifier. More... | |
uint64_t | odp_dma_transfer_id_to_u64 (odp_dma_transfer_id_t transfer_id) |
Get printable value for DMA transfer identifier handle. More... | |
uint64_t | odp_dma_to_u64 (odp_dma_t dma) |
Get printable value for DMA session handle. More... | |
void | odp_dma_print (odp_dma_t dma) |
Print debug info about DMA session. More... | |
int | odp_dma_compl_result (odp_dma_compl_t dma_compl, odp_dma_result_t *result) |
Check DMA completion event. More... | |
odp_dma_compl_t | odp_dma_compl_from_event (odp_event_t ev) |
Convert event to DMA completion event. More... | |
odp_event_t | odp_dma_compl_to_event (odp_dma_compl_t dma_compl) |
Convert DMA completion event to event. More... | |
uint64_t | odp_dma_compl_to_u64 (odp_dma_compl_t dma_compl) |
Get printable value for DMA completion event handle. More... | |
void * | odp_dma_compl_user_area (odp_dma_compl_t dma_compl) |
DMA completion event user area. More... | |
odp_dma_compl_t | odp_dma_compl_alloc (odp_pool_t pool) |
Allocate DMA completion event. More... | |
void | odp_dma_compl_free (odp_dma_compl_t dma_compl) |
Free DMA completion event. More... | |
void | odp_dma_compl_print (odp_dma_compl_t dma_compl) |
Print DMA completion event debug information. More... | |
void | odp_dma_pool_param_init (odp_dma_pool_param_t *pool_param) |
Initialize DMA completion event pool parameters. More... | |
odp_pool_t | odp_dma_pool_create (const char *name, const odp_dma_pool_param_t *pool_param) |
Create DMA completion event pool. More... | |
#define ODP_DMA_TYPE_COPY 0x1u |
Copy data.
Copy all data from source segment(s) to destination segment(s). There may be different number of source and destination segments in a transfer, but total length of all source segments must be equal to total length of all destination segments. Segments must not point to overlapping memory addresses. There are no alignment requirements for segment addresses or lengths. Data transfer from source to destination may happen in any segment and byte order.
Definition at line 168 of file api/spec/dma_types.h.
#define ODP_DMA_COMPL_NONE 0x1u |
No completion indication.
Application uses odp_dma_transfer_start() call to start a DMA transfer, but does not request a completion notification for it. This can be useful for example when application starts a burst of transfers, but requests a completion event only on the last one (none on others).
Definition at line 190 of file api/spec/dma_types.h.
#define ODP_DMA_COMPL_SYNC 0x2u |
Synchronous transfer.
Application uses odp_dma_transfer() call for DMA transfers. Each call performs the requested transfer and returns when the transfer is complete.
Definition at line 197 of file api/spec/dma_types.h.
#define ODP_DMA_COMPL_EVENT 0x4u |
Asynchronous transfer with completion event.
Application uses odp_dma_transfer_start() call to start a DMA transfer. The transfer is complete when application receives the completion event.
Definition at line 204 of file api/spec/dma_types.h.
#define ODP_DMA_COMPL_POLL 0x8u |
Asynchronous transfer with completion polling.
Application uses odp_dma_transfer_start() call to start a DMA transfer and uses odp_dma_transfer_done() call to check if the transfer has completed.
Definition at line 211 of file api/spec/dma_types.h.
typedef struct odp_dma_pool_capability_t odp_dma_pool_capability_t |
DMA completion event pool capabilities.
Pool statistics are not supported with DMA completion event pools.
typedef uint32_t odp_dma_direction_t |
DMA transfer direction.
Transfer direction defines source and destination memory type of DMA transfers. API specification defines only one option (ODP_DMA_MAIN_TO_MAIN) for the transfer direction. It is used for transfers within the main memory. Some implementations may extend this enumeration with implementation specific directions and memory types (e.g. from main memory to a device, etc.).
Definition at line 145 of file api/spec/dma_types.h.
typedef uint32_t odp_dma_transfer_type_t |
DMA transfer type.
Transfer type defines how DMA transfers operate data. Currently, only one transfer type is defined (ODP_DMA_TYPE_COPY).
Definition at line 157 of file api/spec/dma_types.h.
typedef uint32_t odp_dma_compl_mode_t |
DMA transfer completion mode.
Transfer completion mode defines how transfer completion is reported to the application. Completion modes are: ODP_DMA_COMPL_NONE, ODP_DMA_COMPL_SYNC, ODP_DMA_COMPL_EVENT, and ODP_DMA_COMPL_POLL
If not otherwise specified, a DMA transfer is complete when memory reads and writes are complete for all its segments, and writes are visible to all memory observers (threads and HW accelerators).
Definition at line 181 of file api/spec/dma_types.h.
typedef struct odp_dma_transfer_param_t odp_dma_transfer_param_t |
DMA transfer parameters.
These parameters define data sources and destinations for a DMA transfer. Capabilities specify the maximum number of segments and the maximum segment length that are supported.
The selected data format specifies how segment structure fields are used. When data format is ODP_DMA_FORMAT_ADDR, set segment start address (odp_dma_seg_t::addr) and length (odp_dma_seg_t::len). When data format is ODP_DMA_FORMAT_PACKET, set packet handle (odp_dma_seg_t::packet), segment start offset (odp_dma_seg_t::offset) and length. If a DMA segment spans over multiple packet segments, it is considered as equally many DMA segments. So, take packet segmentation into account when making sure that the maximum number of DMA segments capabilities are not exceeded.
DMA transfer data format.
Enumerator | |
---|---|
ODP_DMA_FORMAT_ADDR | Data format is raw memory address. |
ODP_DMA_FORMAT_PACKET | Data format is odp_packet_t. |
Definition at line 216 of file api/spec/dma_types.h.
DMA transfer ordering.
These options specify ordering of consecutive DMA transfers within a session. Transfer order is defined by the order of consecutive transfer (start) calls and the order of transfers within each multi-transfer call. Note that ordering option matters also when using odp_dma_transfer_multi() call, as ODP_DMA_ORDER_NONE allows implementation to perform transfers in parallel.
These options do not apply to data (segment or byte) processing order within a transfer. If two transfers read/write overlapping memory areas, an appropriate transfer ordering option (e.g. ODP_DMA_ORDER_ALL) needs to be used for correct operation.
Definition at line 238 of file api/spec/dma_types.h.
enum odp_dma_mt_mode_t |
DMA transfer multi-thread safeness.
Definition at line 264 of file api/spec/dma_types.h.
int odp_dma_capability | ( | odp_dma_capability_t * | capa | ) |
Query DMA capabilities.
Outputs DMA capabilities on success.
[out] | capa | Pointer to a capability structure for output |
0 | on success |
<0 | on failure |
void odp_dma_param_init | ( | odp_dma_param_t * | param | ) |
Initialize DMA session parameters.
Initialize an odp_dma_param_t to its default values.
[out] | param | Parameter structure to be initialized |
odp_dma_t odp_dma_create | ( | const char * | name, |
const odp_dma_param_t * | param | ||
) |
Create DMA session.
Create a DMA session according to the parameters. The use of session name is optional. Unique names are not required. However, odp_dma_lookup() returns only a single matching named session. Use odp_dma_param_init() to initialize parameters into their default values.
name | DMA session name or NULL. Maximum string length is ODP_DMA_NAME_LEN, including the null character. |
param | DMA session parameters |
ODP_DMA_INVALID | on failure |
int odp_dma_destroy | ( | odp_dma_t | dma | ) |
Destroy DMA session.
A DMA session may be destroyed only when there are no active transfers in the session (all previously started transfers have completed).
dma | DMA session to be destroyed |
0 | on success |
<0 | on failure |
odp_dma_t odp_dma_lookup | ( | const char * | name | ) |
Find DMA session by name.
name | DMA session name |
ODP_DMA_INVALID | DMA session could not be found |
void odp_dma_transfer_param_init | ( | odp_dma_transfer_param_t * | trs_param | ) |
Initialize DMA transfer parameters.
Initialize an odp_dma_transfer_param_t to its default values.
[out] | trs_param | Parameter structure to be initialized |
void odp_dma_compl_param_init | ( | odp_dma_compl_param_t * | compl_param | ) |
Initialize DMA transfer completion parameters.
Initialize an odp_dma_compl_param_t to its default values.
[out] | compl_param | Parameter structure to be initialized |
int odp_dma_transfer | ( | odp_dma_t | dma, |
const odp_dma_transfer_param_t * | trs_param, | ||
odp_dma_result_t * | result | ||
) |
Perform DMA transfer.
Performs DMA transfer according to the session and transfer parameters. Returns 1 when the transfer was completed successfully. Returns 0 when the transfer was not performed due to resources being temporarily busy. In this case, the same transfer is likely to succeed after enough resources are available. Returns <0 on failure.
The call outputs optionally transfer results on a non-zero return value. Use NULL as 'result' pointer if results are not required.
dma | DMA session | |
trs_param | Transfer parameters | |
[out] | result | Pointer to transfer result structure for output, or NULL when not used |
1 | when transfer completed successfully |
0 | when resources are busy and transfer was not performed |
<0 | on failure |
int odp_dma_transfer_multi | ( | odp_dma_t | dma, |
const odp_dma_transfer_param_t * | trs_param[], | ||
odp_dma_result_t * | result[], | ||
int | num | ||
) |
Perform multiple DMA transfers.
Like odp_dma_transfer(), but performs 'num' transfers.
dma | DMA session | |
trs_param | Array of transfer parameter pointers | |
[out] | result | Array of transfer result pointers for output, or NULL when not used |
num | Number of transfers to perform. Both arrays have this many elements. |
0 | when resources are busy and no transfers were performed |
<0 | on failure |
int odp_dma_transfer_start | ( | odp_dma_t | dma, |
const odp_dma_transfer_param_t * | trs_param, | ||
const odp_dma_compl_param_t * | compl_param | ||
) |
Start DMA transfer.
Starts asynchronous DMA transfer according to the session and transfer parameters. Completion parameters specify how transfer completion is reported. Returns 1 when the transfer was started successfully. Returns 0 when the transfer was not started due to resources being temporarily busy. In this case, the same transfer is likely to start successfully after enough resources are available. Returns <0 on failure.
dma | DMA session |
trs_param | Transfer parameters |
compl_param | Transfer completion parameters |
1 | when transfer started successfully |
0 | when resources are busy and transfer was not started |
<0 | on failure |
int odp_dma_transfer_start_multi | ( | odp_dma_t | dma, |
const odp_dma_transfer_param_t * | trs_param[], | ||
const odp_dma_compl_param_t * | compl_param[], | ||
int | num | ||
) |
Start multiple DMA transfers.
Like odp_dma_transfer_start(), but starts 'num' transfers.
dma | DMA session |
trs_param | Array of transfer parameter pointers |
compl_param | Array of transfer completion parameter pointers |
num | Number of transfers to start. Both parameter arrays have this many elements. |
0 | when resources are busy and no transfers were started |
<0 | on failure |
int odp_dma_transfer_done | ( | odp_dma_t | dma, |
odp_dma_transfer_id_t | transfer_id, | ||
odp_dma_result_t * | result | ||
) |
Check if DMA transfer has completed.
Application must call this function for every transfer that was started in ODP_DMA_COMPL_POLL mode until a non-zero value is returned. The transfer identifier from completion parameters of the transfer start call is used. When a non-zero value is returned, the transfer is complete and the identifier may be freed or reused for another transfer.
The call outputs optionally transfer results on a non-zero return value. Use NULL as 'result' pointer if results are not required.
dma | DMA session | |
transfer_id | Transfer identifier | |
[out] | result | Pointer to transfer result structure for output, or NULL when not used. |
0 | transfer has not finished |
>0 | transfer has finished successfully |
<0 | on failure |
odp_dma_transfer_id_t odp_dma_transfer_id_alloc | ( | odp_dma_t | dma | ) |
Allocate DMA transfer identifier.
Transfer identifiers are used in ODP_DMA_COMPL_POLL mode. It identifies a previously started transfer for an odp_dma_transfer_done() call. The maximum number of transfer identifiers is implementation specific, but there are at least odp_dma_capability_t::max_transfers identifiers per session.
dma | DMA session |
ODP_DMA_TRANSFER_ID_INVALID | Transfer identifier could not be allocated |
void odp_dma_transfer_id_free | ( | odp_dma_t | dma, |
odp_dma_transfer_id_t | transfer_id | ||
) |
Free DMA transfer identifier.
dma | DMA session |
transfer_id | DMA transfer identifier to be freed |
uint64_t odp_dma_transfer_id_to_u64 | ( | odp_dma_transfer_id_t | transfer_id | ) |
Get printable value for DMA transfer identifier handle.
transfer_id | Handle to be converted for debugging |
uint64_t odp_dma_to_u64 | ( | odp_dma_t | dma | ) |
Get printable value for DMA session handle.
dma | Handle to be converted for debugging |
void odp_dma_print | ( | odp_dma_t | dma | ) |
Print debug info about DMA session.
Print implementation defined information about DMA session to the ODP log. The information is intended to be used for debugging.
dma | DMA session handle |
int odp_dma_compl_result | ( | odp_dma_compl_t | dma_compl, |
odp_dma_result_t * | result | ||
) |
Check DMA completion event.
Reads DMA completion event (ODP_EVENT_DMA_COMPL), and returns if the transfer succeeded or failed. The call outputs optionally transfer results. Use NULL as 'result' pointer if results are not required.
dma_compl | DMA completion event | |
[out] | result | Pointer to transfer result structure for output, or NULL when not used. |
0 | Transfer was successful |
<0 | Transfer failed |
odp_dma_compl_t odp_dma_compl_from_event | ( | odp_event_t | ev | ) |
Convert event to DMA completion event.
Converts an ODP_EVENT_DMA_COMPL type event to a DMA completion event.
ev | Event handle |
odp_event_t odp_dma_compl_to_event | ( | odp_dma_compl_t | dma_compl | ) |
Convert DMA completion event to event.
dma_compl | DMA completion event handle |
uint64_t odp_dma_compl_to_u64 | ( | odp_dma_compl_t | dma_compl | ) |
Get printable value for DMA completion event handle.
dma_compl | Handle to be converted for debugging |
void* odp_dma_compl_user_area | ( | odp_dma_compl_t | dma_compl | ) |
DMA completion event user area.
Returns pointer to the user area associated with the completion event. Size of the area is fixed and defined in completion event pool parameters.
dma_compl | DMA completion event handle |
NULL | The completion event does not have user area |
odp_dma_compl_t odp_dma_compl_alloc | ( | odp_pool_t | pool | ) |
Allocate DMA completion event.
Allocates a DMA completion event from a pool. The pool must have been created with odp_dma_pool_create() call. All completion event metadata are set to their default values.
pool | Pool handle |
ODP_DMA_COMPL_INVALID | Completion event could not be allocated |
void odp_dma_compl_free | ( | odp_dma_compl_t | dma_compl | ) |
Free DMA completion event.
Frees a DMA completion event into the pool it was allocated from.
dma_compl | DMA completion event handle |
void odp_dma_compl_print | ( | odp_dma_compl_t | dma_compl | ) |
Print DMA completion event debug information.
Prints implementation specific debug information about the completion event to the ODP log.
dma_compl | DMA completion event handle |
void odp_dma_pool_param_init | ( | odp_dma_pool_param_t * | pool_param | ) |
Initialize DMA completion event pool parameters.
Initialize an odp_dma_pool_param_t to its default values.
[out] | pool_param | Parameter structure to be initialized |
odp_pool_t odp_dma_pool_create | ( | const char * | name, |
const odp_dma_pool_param_t * | pool_param | ||
) |
Create DMA completion event pool.
Creates a pool of DMA completion events (ODP_EVENT_DMA_COMPL). Pool type is ODP_POOL_DMA_COMPL. The use of pool name is optional. Unique names are not required. However, odp_pool_lookup() returns only a single matching pool. Use odp_dma_pool_param_init() to initialize pool parameters into their default values. Parameters values must not exceed pool capabilities (odp_dma_pool_capability_t).
name | Name of the pool or NULL. Maximum string length is ODP_POOL_NAME_LEN, including the null character. |
pool_param | Pool parameters |
ODP_POOL_INVALID | Pool could not be created |