NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
erasure_coding_recover_sample.c File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <doca_buf.h>
#include <doca_buf_inventory.h>
#include <doca_ctx.h>
#include <doca_erasure_coding.h>
#include <doca_error.h>
#include <doca_log.h>
#include <doca_mmap.h>
#include <doca_pe.h>
#include <utils.h>
#include "common.h"
Include dependency graph for erasure_coding_recover_sample.c:

Go to the source code of this file.

Data Structures

struct  ec_sample_objects
 
struct  create_task_data
 
struct  recover_task_data
 

Macros

#define SLEEP_IN_NANOS   (10 * 1000) /* sample the task every 10 microseconds */
 
#define SAMPLE_ASSERT(condition, result, state, error...)
 
#define CB_ASSERT(condition, result, cb_result, error...)
 
#define ASSERT_DOCA_ERR(result, state, error)    SAMPLE_ASSERT((result) == DOCA_SUCCESS, (result), state, (error ": %s"), doca_error_get_descr(result))
 
#define NUM_EC_TASKS   (8) /* EC tasks number */
 
#define USER_MAX_PATH_NAME   255 /* Max file name length */
 
#define MAX_PATH_NAME   (USER_MAX_PATH_NAME + 1) /* Max file name string length */
 
#define MAX_DATA_SIZE   (MAX_PATH_NAME + 100) /* Max data file length - path + max int string size */
 
#define RECOVERED_FILE_NAME   "_recovered" /* Recovered file extension (if file name not given) */
 
#define DATA_INFO_FILE_NAME   "data_info" /* Data information file name - i.e. size & name of original file */
 
#define DATA_BLOCK_FILE_NAME   "data_block_" /* Data blocks file name (attached index at the end) */
 
#define RDNC_BLOCK_FILE_NAME   "rdnc_block_" /* Redundancy blocks file name (attached index at the end) */
 

Functions

 DOCA_LOG_REGISTER (EC_RECOVER)
 
static void ec_cleanup (struct ec_sample_objects *state)
 
static void ec_state_changed_callback (const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
 
static doca_error_t ec_core_init (struct ec_sample_objects *state, const char *pci_addr, tasks_check is_support_func, uint32_t src_size, uint32_t dst_size, int num_src_buf, int num_dst_buf, uint64_t *max_block_size)
 
static void ec_task_error (struct doca_task *task, doca_error_t *task_status, doca_error_t *cb_result)
 
static void ec_create_error_callback (struct doca_ec_task_create *create_task, union doca_data task_user_data, union doca_data ctx_user_data)
 
static void ec_create_completed_callback (struct doca_ec_task_create *create_task, union doca_data task_user_data, union doca_data ctx_user_data)
 
doca_error_t ec_encode (const char *pci_addr, const char *file_path, enum doca_ec_matrix_type matrix_type, const char *output_dir_path, uint32_t data_block_count, uint32_t rdnc_block_count, int num_src_buf, int num_dst_buf)
 
static void ec_recover_error_callback (struct doca_ec_task_recover *recover_task, union doca_data task_user_data, union doca_data ctx_user_data)
 
static void ec_recover_completed_callback (struct doca_ec_task_recover *recover_task, union doca_data task_user_data, union doca_data ctx_user_data)
 
doca_error_t ec_decode (const char *pci_addr, enum doca_ec_matrix_type matrix_type, const char *user_output_file_path, const char *dir_path, uint32_t data_block_count, uint32_t rdnc_block_count, int num_src_buf, int num_dst_buf)
 
doca_error_t ec_delete_data (const char *output_path, uint32_t *missing_indices, size_t n_missing)
 
doca_error_t ec_recover (const char *pci_addr, const char *input_path, const char *output_path, bool do_both, enum doca_ec_matrix_type matrix_type, uint32_t data_block_count, uint32_t rdnc_block_count, uint32_t *missing_indices, size_t n_missing, int num_src_buf, int num_dst_buf)
 

Macro Definition Documentation

◆ ASSERT_DOCA_ERR

#define ASSERT_DOCA_ERR (   result,
  state,
  error 
)     SAMPLE_ASSERT((result) == DOCA_SUCCESS, (result), state, (error ": %s"), doca_error_get_descr(result))

Definition at line 70 of file erasure_coding_recover_sample.c.

◆ CB_ASSERT

#define CB_ASSERT (   condition,
  result,
  cb_result,
  error... 
)
Value:
do { \
if (!(condition)) { \
DOCA_LOG_ERR(error); \
*(cb_result) = (result); \
goto free_task; \
} \
} while (0)
int32_t result

Definition at line 61 of file erasure_coding_recover_sample.c.

◆ DATA_BLOCK_FILE_NAME

#define DATA_BLOCK_FILE_NAME   "data_block_" /* Data blocks file name (attached index at the end) */

Definition at line 79 of file erasure_coding_recover_sample.c.

◆ DATA_INFO_FILE_NAME

#define DATA_INFO_FILE_NAME   "data_info" /* Data information file name - i.e. size & name of original file */

Definition at line 78 of file erasure_coding_recover_sample.c.

◆ MAX_DATA_SIZE

#define MAX_DATA_SIZE   (MAX_PATH_NAME + 100) /* Max data file length - path + max int string size */

Definition at line 76 of file erasure_coding_recover_sample.c.

◆ MAX_PATH_NAME

#define MAX_PATH_NAME   (USER_MAX_PATH_NAME + 1) /* Max file name string length */

Definition at line 75 of file erasure_coding_recover_sample.c.

◆ NUM_EC_TASKS

#define NUM_EC_TASKS   (8) /* EC tasks number */

Definition at line 73 of file erasure_coding_recover_sample.c.

◆ RDNC_BLOCK_FILE_NAME

#define RDNC_BLOCK_FILE_NAME   "rdnc_block_" /* Redundancy blocks file name (attached index at the end) */

Definition at line 80 of file erasure_coding_recover_sample.c.

◆ RECOVERED_FILE_NAME

#define RECOVERED_FILE_NAME   "_recovered" /* Recovered file extension (if file name not given) */

Definition at line 77 of file erasure_coding_recover_sample.c.

◆ SAMPLE_ASSERT

#define SAMPLE_ASSERT (   condition,
  result,
  state,
  error... 
)
Value:
do { \
if (!(condition)) { \
DOCA_LOG_ERR(error); \
ec_cleanup(state); \
return result; \
} \
} while (0)

Definition at line 52 of file erasure_coding_recover_sample.c.

◆ SLEEP_IN_NANOS

#define SLEEP_IN_NANOS   (10 * 1000) /* sample the task every 10 microseconds */

Definition at line 50 of file erasure_coding_recover_sample.c.

◆ USER_MAX_PATH_NAME

#define USER_MAX_PATH_NAME   255 /* Max file name length */

Definition at line 74 of file erasure_coding_recover_sample.c.

Function Documentation

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( EC_RECOVER  )

◆ ec_cleanup()

static void ec_cleanup ( struct ec_sample_objects state)
static

Definition at line 105 of file erasure_coding_recover_sample.c.

◆ ec_core_init()

static doca_error_t ec_core_init ( struct ec_sample_objects state,
const char *  pci_addr,
tasks_check  is_support_func,
uint32_t  src_size,
uint32_t  dst_size,
int  num_src_buf,
int  num_dst_buf,
uint64_t *  max_block_size 
)
static

Init ec core objects.

@state [in]: The DOCA EC sample state @pci_addr [in]: The PCI address of a doca device @is_support_func [in]: Function that pci device should support @src_size [in]: The source data size (to create the buffer) @dst_size [in]: The destination data size (to create the buffer) @num_src_buf [in]: Number of doca_buf for source buffer @num_dst_buf [in]: Number of doca_buf for destination buffer @max_block_size [out]: The maximum block size supported for ec operations

Returns
: DOCA_SUCCESS if the core init successfully and DOCA_ERROR otherwise.

Definition at line 226 of file erasure_coding_recover_sample.c.

◆ ec_create_completed_callback()

static void ec_create_completed_callback ( struct doca_ec_task_create *  create_task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Definition at line 370 of file erasure_coding_recover_sample.c.

◆ ec_create_error_callback()

static void ec_create_error_callback ( struct doca_ec_task_create *  create_task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Definition at line 353 of file erasure_coding_recover_sample.c.

◆ ec_decode()

doca_error_t ec_decode ( const char *  pci_addr,
enum doca_ec_matrix_type  matrix_type,
const char *  user_output_file_path,
const char *  dir_path,
uint32_t  data_block_count,
uint32_t  rdnc_block_count,
int  num_src_buf,
int  num_dst_buf 
)

Definition at line 740 of file erasure_coding_recover_sample.c.

◆ ec_delete_data()

doca_error_t ec_delete_data ( const char *  output_path,
uint32_t *  missing_indices,
size_t  n_missing 
)

Definition at line 984 of file erasure_coding_recover_sample.c.

◆ ec_encode()

doca_error_t ec_encode ( const char *  pci_addr,
const char *  file_path,
enum doca_ec_matrix_type  matrix_type,
const char *  output_dir_path,
uint32_t  data_block_count,
uint32_t  rdnc_block_count,
int  num_src_buf,
int  num_dst_buf 
)

Definition at line 439 of file erasure_coding_recover_sample.c.

◆ ec_recover()

doca_error_t ec_recover ( const char *  pci_addr,
const char *  input_path,
const char *  output_path,
bool  do_both,
enum doca_ec_matrix_type  matrix_type,
uint32_t  data_block_count,
uint32_t  rdnc_block_count,
uint32_t *  missing_indices,
size_t  n_missing,
int  num_src_buf,
int  num_dst_buf 
)

Definition at line 1021 of file erasure_coding_recover_sample.c.

◆ ec_recover_completed_callback()

static void ec_recover_completed_callback ( struct doca_ec_task_recover *  recover_task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Definition at line 649 of file erasure_coding_recover_sample.c.

◆ ec_recover_error_callback()

static void ec_recover_error_callback ( struct doca_ec_task_recover *  recover_task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Definition at line 632 of file erasure_coding_recover_sample.c.

◆ ec_state_changed_callback()

static void ec_state_changed_callback ( const union doca_data  user_data,
struct doca_ctx *  ctx,
enum doca_ctx_states  prev_state,
enum doca_ctx_states  next_state 
)
static

Callback triggered whenever Erasure Coding context state changes

@user_data [in]: User data associated with the Erasure Coding context. Will hold struct ec_sample_objects * @ctx [in]: The Erasure Coding context that had a state change @prev_state [in]: Previous context state @next_state [in]: Next context state (context is already in this state when the callback is called)

The context is in starting state, this is unexpected for Erasure Coding.

doca_ctx_stop() has been called. In this sample, this happens either due to a failure encountered, in which case doca_pe_progress() will cause any inflight task to be flushed, or due to the successful compilation of the sample flow. In both cases, in this sample, doca_pe_progress() will eventually transition the context to idle state.

Definition at line 173 of file erasure_coding_recover_sample.c.

◆ ec_task_error()

static void ec_task_error ( struct doca_task *  task,
doca_error_t task_status,
doca_error_t cb_result 
)
static

Definition at line 319 of file erasure_coding_recover_sample.c.