NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
dpa_common.c File Reference
#include "dpa_common.h"
#include "doca_dpa.h"
#include "libflexio/flexio_ver.h"
#include "libflexio/flexio.h"
Include dependency graph for dpa_common.c:

Go to the source code of this file.

Macros

#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MAJOR_VERSION   (25)
 
#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MINOR_VERSION   (4)
 
#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_PATCH_VERSION   (0)
 
#define FLEXIO_VER_USED
 
#define DPA_THREADS_MAX   256
 

Functions

 DOCA_LOG_REGISTER (DPA_COMMON)
 
static doca_error_t pf_device_name_param_callback (void *param, void *config)
 
static doca_error_t dpa_resources_file_param_callback (void *param, void *config)
 
static doca_error_t dpa_app_key_param_callback (void *param, void *config)
 
doca_error_t register_dpa_params (void)
 Register the command line parameters for the sample. More...
 
static doca_error_t open_dpa_device (const char *pf_device_name, const char *rdma_device_name, struct doca_dev **pf_doca_device, struct doca_dev **rdma_doca_device)
 
doca_error_t create_doca_dpa_wait_sync_event (struct doca_dpa *doca_dpa, struct doca_dev *doca_device, struct doca_sync_event **wait_event)
 Create DOCA sync event to be published by the CPU and subscribed by the DPA. More...
 
doca_error_t create_doca_dpa_completion_sync_event (struct doca_dpa *doca_dpa, struct doca_dev *doca_device, struct doca_sync_event **comp_event, doca_dpa_dev_sync_event_t *handle)
 Create DOCA sync event to be published by the DPA and subscribed by the CPU. More...
 
doca_error_t create_doca_dpa_kernel_sync_event (struct doca_dpa *doca_dpa, struct doca_sync_event **kernel_event)
 Create DOCA sync event to be published and subscribed by the DPA. More...
 
doca_error_t create_doca_remote_net_sync_event (struct doca_dev *doca_device, struct doca_sync_event **remote_net_event)
 Create DOCA sync event to be published by a remote net and subscribed by the CPU. More...
 
doca_error_t export_doca_remote_net_sync_event_to_dpa (struct doca_dev *doca_device, struct doca_dpa *doca_dpa, struct doca_sync_event *remote_net_event, struct doca_sync_event_remote_net **remote_net_exported_event, doca_dpa_dev_sync_event_remote_net_t *remote_net_event_dpa_handle)
 Create DOCA sync event to be published by a remote net and subscribed by the CPU. More...
 
static doca_error_t get_file_size (const char *path, size_t *file_size)
 Get the size of a file. More...
 
static doca_error_t read_file_into_buffer (const char *path, char *buffer, size_t *bytes_read)
 Read file content into a pre-allocated buffer. More...
 
static doca_error_t get_eu_ids_from_resources_file (struct dpa_config *cfg, uint32_t *threads_list, uint32_t *threads_num)
 Get execution unit IDs from FlexIO resources. More...
 
doca_error_t allocate_dpa_resources (struct dpa_config *cfg, struct dpa_resources *resources)
 Allocate DOCA DPA resources. More...
 
doca_error_t destroy_dpa_resources (struct dpa_resources *resources)
 Destroy DOCA DPA resources. More...
 
doca_error_t dpa_thread_obj_init (struct dpa_thread_obj *dpa_thread_obj)
 Initialize DPA thread. More...
 
doca_error_t dpa_thread_obj_destroy (struct dpa_thread_obj *dpa_thread_obj)
 Destroy DPA thread. More...
 
doca_error_t dpa_completion_obj_init (struct dpa_completion_obj *dpa_completion_obj)
 Initialize DPA completion. More...
 
doca_error_t dpa_completion_obj_destroy (struct dpa_completion_obj *dpa_completion_obj)
 Destroy DPA completion. More...
 
doca_error_t dpa_notification_completion_obj_init (struct dpa_notification_completion_obj *notification_completion_obj)
 Initialize DPA notification completion. More...
 
doca_error_t dpa_notification_completion_obj_destroy (struct dpa_notification_completion_obj *notification_completion_obj)
 Destroy DPA notification completion. More...
 
doca_error_t dpa_rdma_obj_init (struct dpa_rdma_obj *dpa_rdma_obj)
 Initialize DPA RDMA without starting it. More...
 
doca_error_t dpa_rdma_obj_start (struct dpa_rdma_obj *dpa_rdma_obj)
 Start DPA RDMA. More...
 
doca_error_t dpa_rdma_obj_destroy (struct dpa_rdma_obj *dpa_rdma_obj)
 Destroy DPA RDMA. More...
 
doca_error_t doca_mmap_obj_init (struct doca_mmap_obj *doca_mmap_obj)
 Initialize DOCA Mmap. More...
 
doca_error_t doca_mmap_obj_destroy (struct doca_mmap_obj *doca_mmap_obj)
 Destroy DOCA Mmap. More...
 

Variables

struct doca_dpa_app * dpa_sample_app
 

Macro Definition Documentation

◆ DPA_BASIC_INITIATOR_TARGET_FLEXIO_MAJOR_VERSION

#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MAJOR_VERSION   (25)

Definition at line 30 of file dpa_common.c.

◆ DPA_BASIC_INITIATOR_TARGET_FLEXIO_MINOR_VERSION

#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MINOR_VERSION   (4)

Definition at line 31 of file dpa_common.c.

◆ DPA_BASIC_INITIATOR_TARGET_FLEXIO_PATCH_VERSION

#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_PATCH_VERSION   (0)

Definition at line 32 of file dpa_common.c.

◆ DPA_THREADS_MAX

#define DPA_THREADS_MAX   256

Definition at line 42 of file dpa_common.c.

◆ FLEXIO_VER_USED

#define FLEXIO_VER_USED
Value:
#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MAJOR_VERSION
Definition: dpa_common.c:30
#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_MINOR_VERSION
Definition: dpa_common.c:31
#define DPA_BASIC_INITIATOR_TARGET_FLEXIO_PATCH_VERSION
Definition: dpa_common.c:32

Definition at line 34 of file dpa_common.c.

Function Documentation

◆ allocate_dpa_resources()

doca_error_t allocate_dpa_resources ( struct dpa_config cfg,
struct dpa_resources resources 
)

Allocate DOCA DPA resources.

@cfg [in]: DOCA DPA configurations @resources [out]: DOCA DPA resources to allocate

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 660 of file dpa_common.c.

◆ create_doca_dpa_completion_sync_event()

doca_error_t create_doca_dpa_completion_sync_event ( struct doca_dpa *  doca_dpa,
struct doca_dev *  doca_device,
struct doca_sync_event **  comp_event,
doca_dpa_dev_sync_event_t handle 
)

Create DOCA sync event to be published by the DPA and subscribed by the CPU.

@doca_dpa [in]: DOCA DPA context @doca_device [in]: DOCA device @comp_event [out]: Created DOCA sync event that is published by the DPA and subscribed by the CPU @handle [out]: Created DOCA sync event handle

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 354 of file dpa_common.c.

◆ create_doca_dpa_kernel_sync_event()

doca_error_t create_doca_dpa_kernel_sync_event ( struct doca_dpa *  doca_dpa,
struct doca_sync_event **  kernel_event 
)

Create DOCA sync event to be published and subscribed by the DPA.

@doca_dpa [in]: DOCA DPA context @kernel_event [out]: Created DOCA sync event that is published and subscribed by the DPA

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 404 of file dpa_common.c.

◆ create_doca_dpa_wait_sync_event()

doca_error_t create_doca_dpa_wait_sync_event ( struct doca_dpa *  doca_dpa,
struct doca_dev *  doca_device,
struct doca_sync_event **  wait_event 
)

Create DOCA sync event to be published by the CPU and subscribed by the DPA.

@doca_dpa [in]: DOCA DPA context @doca_device [in]: DOCA device @wait_event [out]: Created DOCA sync event that is published by the CPU and subscribed by the DPA

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 313 of file dpa_common.c.

◆ create_doca_remote_net_sync_event()

doca_error_t create_doca_remote_net_sync_event ( struct doca_dev *  doca_device,
struct doca_sync_event **  remote_net_event 
)

Create DOCA sync event to be published by a remote net and subscribed by the CPU.

@doca_device [in]: DOCA device @remote_net_event [out]: Created DOCA sync event that is published by a remote net and subscribed by the CPU

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 443 of file dpa_common.c.

◆ destroy_dpa_resources()

doca_error_t destroy_dpa_resources ( struct dpa_resources resources)

Destroy DOCA DPA resources.

@resources [in]: DOCA DPA resources to destroy

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 769 of file dpa_common.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( DPA_COMMON  )

◆ doca_mmap_obj_destroy()

doca_error_t doca_mmap_obj_destroy ( struct doca_mmap_obj doca_mmap_obj)

Destroy DOCA Mmap.

@doca_mmap_obj [in]: DOCA Mmap object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1209 of file dpa_common.c.

◆ doca_mmap_obj_init()

doca_error_t doca_mmap_obj_init ( struct doca_mmap_obj doca_mmap_obj)

Initialize DOCA Mmap.

@doca_mmap_obj [in/out]: DOCA Mmap object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1126 of file dpa_common.c.

◆ dpa_app_key_param_callback()

static doca_error_t dpa_app_key_param_callback ( void *  param,
void *  config 
)
static

Definition at line 88 of file dpa_common.c.

◆ dpa_completion_obj_destroy()

doca_error_t dpa_completion_obj_destroy ( struct dpa_completion_obj dpa_completion_obj)

Destroy DPA completion.

@dpa_completion_obj [in]: DPA completion object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 916 of file dpa_common.c.

◆ dpa_completion_obj_init()

doca_error_t dpa_completion_obj_init ( struct dpa_completion_obj dpa_completion_obj)

Initialize DPA completion.

@dpa_completion_obj [in/out]: DPA completion object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 877 of file dpa_common.c.

◆ dpa_notification_completion_obj_destroy()

doca_error_t dpa_notification_completion_obj_destroy ( struct dpa_notification_completion_obj notification_completion_obj)

Destroy DPA notification completion.

@notification_completion_obj [in]: DPA notification completion object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 962 of file dpa_common.c.

◆ dpa_notification_completion_obj_init()

doca_error_t dpa_notification_completion_obj_init ( struct dpa_notification_completion_obj notification_completion_obj)

Initialize DPA notification completion.

@notification_completion_obj [in/out]: DPA notification completion object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 929 of file dpa_common.c.

◆ dpa_rdma_obj_destroy()

doca_error_t dpa_rdma_obj_destroy ( struct dpa_rdma_obj dpa_rdma_obj)

Destroy DPA RDMA.

@dpa_rdma_obj [in]: DPA RDMA object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1107 of file dpa_common.c.

◆ dpa_rdma_obj_init()

doca_error_t dpa_rdma_obj_init ( struct dpa_rdma_obj dpa_rdma_obj)

Initialize DPA RDMA without starting it.

This function creates DPA RDMA object. Please note that this function doesn't start the created DPA RDMA object, this need to be done using dpa_rdma_obj_start() API

@dpa_rdma_obj [in/out]: DPA RDMA object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 976 of file dpa_common.c.

◆ dpa_rdma_obj_start()

doca_error_t dpa_rdma_obj_start ( struct dpa_rdma_obj dpa_rdma_obj)

Start DPA RDMA.

@dpa_rdma_obj [in]: DPA RDMA object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1058 of file dpa_common.c.

◆ dpa_resources_file_param_callback()

static doca_error_t dpa_resources_file_param_callback ( void *  param,
void *  config 
)
static

Definition at line 72 of file dpa_common.c.

◆ dpa_thread_obj_destroy()

doca_error_t dpa_thread_obj_destroy ( struct dpa_thread_obj dpa_thread_obj)

Destroy DPA thread.

@dpa_thread_obj [in]: DPA thread object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 864 of file dpa_common.c.

◆ dpa_thread_obj_init()

doca_error_t dpa_thread_obj_init ( struct dpa_thread_obj dpa_thread_obj)

Initialize DPA thread.

@dpa_thread_obj [in/out]: DPA thread object

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 817 of file dpa_common.c.

◆ export_doca_remote_net_sync_event_to_dpa()

doca_error_t export_doca_remote_net_sync_event_to_dpa ( struct doca_dev *  doca_device,
struct doca_dpa *  doca_dpa,
struct doca_sync_event *  remote_net_event,
struct doca_sync_event_remote_net **  remote_net_exported_event,
doca_dpa_dev_sync_event_remote_net_t remote_net_event_dpa_handle 
)

Create DOCA sync event to be published by a remote net and subscribed by the CPU.

@doca_device [in]: DOCA device @doca_dpa [in]: DOCA DPA context @remote_net_event [in]: remote net DOCA sync event @remote_net_exported_event [out]: Created from export remote net DOCA sync event @remote_net_event_dpa_handle [out]: DPA handle of the created from export remote net DOCA sync event

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 483 of file dpa_common.c.

◆ get_eu_ids_from_resources_file()

static doca_error_t get_eu_ids_from_resources_file ( struct dpa_config cfg,
uint32_t *  threads_list,
uint32_t *  threads_num 
)
static

Get execution unit IDs from FlexIO resources.

This function reads the DPA resources file and extracts the execution unit IDs for the specified application key.

@cfg [in]: DPA configuration @threads_list [out]: List of execution unit IDs @threads_num [out]: Number of execution units

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 601 of file dpa_common.c.

◆ get_file_size()

static doca_error_t get_file_size ( const char *  path,
size_t file_size 
)
static

Get the size of a file.

Parameters
[in]path- Path to the file
[out]file_size- Size of the file in bytes
Returns
DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 536 of file dpa_common.c.

◆ open_dpa_device()

static doca_error_t open_dpa_device ( const char *  pf_device_name,
const char *  rdma_device_name,
struct doca_dev **  pf_doca_device,
struct doca_dev **  rdma_doca_device 
)
static

Definition at line 222 of file dpa_common.c.

◆ pf_device_name_param_callback()

static doca_error_t pf_device_name_param_callback ( void *  param,
void *  config 
)
static

Definition at line 57 of file dpa_common.c.

◆ read_file_into_buffer()

static doca_error_t read_file_into_buffer ( const char *  path,
char *  buffer,
size_t bytes_read 
)
static

Read file content into a pre-allocated buffer.

Parameters
[in]path- Path to the file
[out]buffer- Pre-allocated buffer to store file content
[out]bytes_read- Number of bytes read from the file
Returns
DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 571 of file dpa_common.c.

◆ register_dpa_params()

doca_error_t register_dpa_params ( void  )

Register the command line parameters for the sample.

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 126 of file dpa_common.c.

Variable Documentation

◆ dpa_sample_app

struct doca_dpa_app* dpa_sample_app
extern