NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
pe_common.h File Reference
#include <doca_ctx.h>
#include <doca_dma.h>
Include dependency graph for pe_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pe_sample_state_base
 

Functions

doca_error_t process_completed_dma_memcpy_task (struct doca_dma_task_memcpy *dma_task, uint8_t expected_value)
 
doca_error_t free_dma_memcpy_task_buffers (struct doca_dma_task_memcpy *dma_task)
 
doca_error_t dma_task_free (struct doca_dma_task_memcpy *dma_task)
 
doca_error_t allocate_buffer (struct pe_sample_state_base *state)
 
doca_error_t allocate_dma_tasks (struct pe_sample_state_base *state, struct doca_dma *dma, uint32_t num_tasks, size_t dma_buffer_size, struct doca_dma_task_memcpy **tasks)
 
doca_error_t submit_dma_tasks (uint32_t num_tasks, struct doca_dma_task_memcpy **tasks)
 
doca_error_t open_device (struct pe_sample_state_base *state)
 
doca_error_t create_pe (struct pe_sample_state_base *state)
 
doca_error_t create_mmap (struct pe_sample_state_base *state)
 
doca_error_t create_buf_inventory (struct pe_sample_state_base *state)
 
doca_error_t poll_for_completion (struct pe_sample_state_base *state, uint32_t num_tasks)
 
void pe_sample_base_cleanup (struct pe_sample_state_base *state)
 

Function Documentation

◆ allocate_buffer()

doca_error_t allocate_buffer ( struct pe_sample_state_base state)

Allocates a buffer that will be used for the source and destination buffers.

@state [in]: sample state

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 131 of file pe_common.c.

◆ allocate_dma_tasks()

doca_error_t allocate_dma_tasks ( struct pe_sample_state_base state,
struct doca_dma *  dma,
uint32_t  num_tasks,
size_t  dma_buffer_size,
struct doca_dma_task_memcpy **  tasks 
)

This method allocate the DMA tasks but does not submit them. This is a sample choice. A task can be submitted immediately after it is allocated.

@state [in]: sample state @dma [in]: DMA context to allocate the tasks from @num_tasks [in]: Number of tasks per group @dma_buffer_size [in]: Size of DMA buffer @tasks [in]: tasks to allocate

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

This method allocate the DMA tasks but does not submit them. This is a sample choice. A task can be submitted immediately after it is allocated.

@state [in]: sample state @dma [in] DMA context to allocate the tasks from. @num_tasks [in]: Number of tasks per group @dma_buffer_size [in]: Size of DMA buffer @tasks [in]: tasks to allocate

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Using doca_buf_inventory_buf_get_by_addr leaves the buffer head uninitialized. The DMA context will set the head and length at the task completion.

Definition at line 155 of file pe_common.c.

◆ create_buf_inventory()

doca_error_t create_buf_inventory ( struct pe_sample_state_base state)

Create buffer inventory, initialize and start it.

@state [in]: sample state

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 294 of file pe_common.c.

◆ create_mmap()

doca_error_t create_mmap ( struct pe_sample_state_base state)

Create MMAP, initialize and start it.

@state [in]: sample state

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 275 of file pe_common.c.

◆ create_pe()

doca_error_t create_pe ( struct pe_sample_state_base state)

Creates a progress engine

@state [in]: sample state

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 260 of file pe_common.c.

◆ dma_task_free()

doca_error_t dma_task_free ( struct doca_dma_task_memcpy *  dma_task)

A DOCA task should be freed once it is no longer used. It can be freed during a completion or error callback, during the progress one loop (e.g. if the program stores it in the state), at the end of the program, etc., as long as it is not required anymore. The sample also releases the buffers during this call, but only for simplicity. Buffers don't have to be released when a task is released.

Definition at line 108 of file pe_common.c.

◆ free_dma_memcpy_task_buffers()

doca_error_t free_dma_memcpy_task_buffers ( struct doca_dma_task_memcpy *  dma_task)

Removing the const is fine in this case because the sample owns the buffer and the task is about to be freed. However, in other cases this action may not be valid.

Definition at line 93 of file pe_common.c.

◆ open_device()

doca_error_t open_device ( struct pe_sample_state_base state)

Opens a device that supports SHA and DMA

@state [in]: sample state

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 245 of file pe_common.c.

◆ pe_sample_base_cleanup()

void pe_sample_base_cleanup ( struct pe_sample_state_base state)

This method cleans up the sample resources in reverse order of their creation. This method does not check for destroy return values for simplify. Real code should check the return value and act accordingly (e.g. if doca_ctx_stop failed with DOCA_ERROR_IN_PROGRESS it means that some contexts are still added or even that there are still in flight tasks in the progress engine).

@state [in]: sample state

Definition at line 311 of file pe_common.c.

◆ poll_for_completion()

doca_error_t poll_for_completion ( struct pe_sample_state_base state,
uint32_t  num_tasks 
)

Poll the PE until all tasks are completed.

@state [in]: sample state @num_tasks [in]: number of expected tasks

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Poll the PE until all tasks are completed.

@state [in]: sample state @num_tasks [in] number of expected tasks

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

doca_pe_progress shall return 1 if a task was completed and 0 if not. In this case the sample does not have anything to do with the return value because it is a polling sample.

Definition at line 340 of file pe_common.c.

◆ process_completed_dma_memcpy_task()

doca_error_t process_completed_dma_memcpy_task ( struct doca_dma_task_memcpy *  dma_task,
uint8_t  expected_value 
)

Definition at line 66 of file pe_common.c.

◆ submit_dma_tasks()

doca_error_t submit_dma_tasks ( uint32_t  num_tasks,
struct doca_dma_task_memcpy **  tasks 
)

This method submits all the tasks (

See also
allocate_dma_tasks).

@num_tasks [in]: Number of tasks per group @tasks [in]: tasks to submit

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

This method submits all the tasks (

See also
allocate_dma_tasks).

@num_tasks [in]: Number of tasks per group @dma_buffer_size [in]: Size of DMA buffer @tasks [in]: tasks to submit

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 211 of file pe_common.c.