NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_erasure_coding.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES, ALL RIGHTS RESERVED.
3  *
4  * This software product is a proprietary product of NVIDIA CORPORATION &
5  * AFFILIATES (the "Company") and all right, title, and interest in and to the
6  * software product, including all associated intellectual property rights, are
7  * and shall remain exclusively with the Company.
8  *
9  * This software product is governed by the End User License Agreement
10  * provided with the software product.
11  *
12  */
13 
22 #ifndef DOCA_ERASURE_CODING_H_
23 #define DOCA_ERASURE_CODING_H_
24 
25 #include <inttypes.h>
26 
27 #include <doca_compat.h>
28 #include <doca_error.h>
29 #include <doca_types.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /**********************************************************************************************************************
36  * DOCA core opaque types
37  *********************************************************************************************************************/
38 
39 struct doca_buf;
40 struct doca_ctx;
41 struct doca_dev;
42 struct doca_devinfo;
43 
47 struct doca_ec;
48 
52 struct doca_ec_matrix;
53 
54 /*********************************************************************************************************************
55  * DOCA EC TASKS
56  *********************************************************************************************************************/
57 
58 /*****************************************
59  * DOCA EC TASK - Galois multiplication *
60  *****************************************/
64 struct doca_ec_task_galois_mul;
65 
92 typedef void (*doca_ec_task_galois_mul_completion_cb_t)(struct doca_ec_task_galois_mul *task,
93  union doca_data task_user_data,
94  union doca_data ctx_user_data);
95 
109 doca_error_t doca_ec_cap_task_galois_mul_is_supported(const struct doca_devinfo *devinfo);
110 
130  doca_ec_task_galois_mul_completion_cb_t successful_task_completion_cb,
131  doca_ec_task_galois_mul_completion_cb_t error_task_completion_cb,
132  uint32_t num_tasks);
133 
170  const struct doca_ec_matrix *coding_matrix,
171  const struct doca_buf *src_buf,
172  struct doca_buf *dst_buf,
173  union doca_data user_data,
174  struct doca_ec_task_galois_mul **task);
175 
186 struct doca_task *doca_ec_task_galois_mul_as_task(struct doca_ec_task_galois_mul *task);
187 
198 void doca_ec_task_galois_mul_set_coding_matrix(struct doca_ec_task_galois_mul *task,
199  const struct doca_ec_matrix *coding_matrix);
200 
211 const struct doca_ec_matrix *doca_ec_task_galois_mul_get_coding_matrix(const struct doca_ec_task_galois_mul *task);
212 
231 void doca_ec_task_galois_mul_set_src_buf(struct doca_ec_task_galois_mul *task, const struct doca_buf *src_buf);
232 
243 const struct doca_buf *doca_ec_task_galois_mul_get_src_buf(const struct doca_ec_task_galois_mul *task);
244 
264 void doca_ec_task_galois_mul_set_dst_buf(struct doca_ec_task_galois_mul *task, struct doca_buf *dst_buf);
265 
276 struct doca_buf *doca_ec_task_galois_mul_get_dst_buf(const struct doca_ec_task_galois_mul *task);
277 
278 /*****************************************
279  * DOCA EC TASK - Create *
280  *****************************************/
284 struct doca_ec_task_create;
285 
311 typedef void (*doca_ec_task_create_completion_cb_t)(struct doca_ec_task_create *task,
312  union doca_data task_user_data,
313  union doca_data ctx_user_data);
314 
328 doca_error_t doca_ec_cap_task_create_is_supported(const struct doca_devinfo *devinfo);
329 
349  doca_ec_task_create_completion_cb_t successful_task_completion_cb,
350  doca_ec_task_create_completion_cb_t error_task_completion_cb,
351  uint32_t num_tasks);
352 
389  const struct doca_ec_matrix *coding_matrix,
390  const struct doca_buf *original_data_blocks,
391  struct doca_buf *rdnc_blocks,
392  union doca_data user_data,
393  struct doca_ec_task_create **task);
394 
405 struct doca_task *doca_ec_task_create_as_task(struct doca_ec_task_create *task);
406 
417 void doca_ec_task_create_set_coding_matrix(struct doca_ec_task_create *task,
418  const struct doca_ec_matrix *coding_matrix);
419 
430 const struct doca_ec_matrix *doca_ec_task_create_get_coding_matrix(const struct doca_ec_task_create *task);
431 
450 void doca_ec_task_create_set_original_data_blocks(struct doca_ec_task_create *task,
451  const struct doca_buf *original_data_blocks);
452 
465 const struct doca_buf *doca_ec_task_create_get_original_data_blocks(const struct doca_ec_task_create *task);
466 
486 void doca_ec_task_create_set_rdnc_blocks(struct doca_ec_task_create *task, struct doca_buf *rdnc_blocks);
487 
501 struct doca_buf *doca_ec_task_create_get_rdnc_blocks(const struct doca_ec_task_create *task);
502 
503 /*****************************************
504  * DOCA EC TASK - Update *
505  *****************************************/
511 struct doca_ec_task_update;
512 
538 typedef void (*doca_ec_task_update_completion_cb_t)(struct doca_ec_task_update *task,
539  union doca_data task_user_data,
540  union doca_data ctx_user_data);
541 
555 doca_error_t doca_ec_cap_task_update_is_supported(const struct doca_devinfo *devinfo);
556 
576  doca_ec_task_update_completion_cb_t successful_task_completion_cb,
577  doca_ec_task_update_completion_cb_t error_task_completion_cb,
578  uint32_t num_tasks);
579 
619  const struct doca_ec_matrix *update_matrix,
620  const struct doca_buf *original_updated_and_rdnc_blocks,
621  struct doca_buf *updated_rdnc_blocks,
622  union doca_data user_data,
623  struct doca_ec_task_update **task);
624 
635 struct doca_task *doca_ec_task_update_as_task(struct doca_ec_task_update *task);
636 
647 void doca_ec_task_update_set_update_matrix(struct doca_ec_task_update *task,
648  const struct doca_ec_matrix *update_matrix);
649 
660 const struct doca_ec_matrix *doca_ec_task_update_get_update_matrix(const struct doca_ec_task_update *task);
661 
683 void doca_ec_task_update_set_original_updated_and_rdnc_blocks(struct doca_ec_task_update *task,
684  const struct doca_buf *original_updated_and_rdnc_blocks);
685 
700 const struct doca_buf *doca_ec_task_update_get_original_updated_and_rdnc_blocks(const struct doca_ec_task_update *task);
701 
721 void doca_ec_task_update_set_updated_rdnc_blocks(struct doca_ec_task_update *task,
722  struct doca_buf *updated_rdnc_blocks);
723 
737 struct doca_buf *doca_ec_task_update_get_updated_rdnc_blocks(const struct doca_ec_task_update *task);
738 
739 /*****************************************
740  * DOCA EC TASK - Recover *
741  *****************************************/
745 struct doca_ec_task_recover;
746 
772 typedef void (*doca_ec_task_recover_completion_cb_t)(struct doca_ec_task_recover *task,
773  union doca_data task_user_data,
774  union doca_data ctx_user_data);
775 
789 doca_error_t doca_ec_cap_task_recover_is_supported(const struct doca_devinfo *devinfo);
790 
810  doca_ec_task_recover_completion_cb_t successful_task_completion_cb,
811  doca_ec_task_recover_completion_cb_t error_task_completion_cb,
812  uint32_t num_tasks);
813 
855  const struct doca_ec_matrix *recover_matrix,
856  const struct doca_buf *available_blocks,
857  struct doca_buf *recovered_data_blocks,
858  union doca_data user_data,
859  struct doca_ec_task_recover **task);
860 
871 struct doca_task *doca_ec_task_recover_as_task(struct doca_ec_task_recover *task);
872 
883 void doca_ec_task_recover_set_recover_matrix(struct doca_ec_task_recover *task,
884  const struct doca_ec_matrix *recover_matrix);
885 
896 const struct doca_ec_matrix *doca_ec_task_recover_get_recover_matrix(const struct doca_ec_task_recover *task);
897 
920 void doca_ec_task_recover_set_available_blocks(struct doca_ec_task_recover *task,
921  const struct doca_buf *available_blocks);
922 
936 const struct doca_buf *doca_ec_task_recover_get_available_blocks(const struct doca_ec_task_recover *task);
937 
959 void doca_ec_task_recover_set_recovered_data_blocks(struct doca_ec_task_recover *task,
960  struct doca_buf *recovered_data_blocks);
961 
975 struct doca_buf *doca_ec_task_recover_get_recovered_data(const struct doca_ec_task_recover *task);
976 
977 /*********************************************************************************************************************
978  * DOCA EC Context
979  *********************************************************************************************************************/
980 
996 doca_error_t doca_ec_create(struct doca_dev *dev, struct doca_ec **ec);
997 
1010 doca_error_t doca_ec_destroy(struct doca_ec *ec);
1011 
1023 struct doca_ctx *doca_ec_as_ctx(struct doca_ec *ec);
1024 
1041 doca_error_t doca_ec_cap_get_max_block_size(const struct doca_devinfo *devinfo, uint64_t *max_block_size);
1042 
1058 doca_error_t doca_ec_cap_get_max_buf_list_len(const struct doca_devinfo *devinfo, uint32_t *max_buf_list_len);
1059 
1060 /*********************************************************************************************************************
1061  * DOCA EC Matrix Gen
1062  *********************************************************************************************************************/
1063 
1094 };
1095 
1118  size_t data_block_count,
1119  size_t rdnc_block_count,
1120  struct doca_ec_matrix **matrix);
1121 
1144  uint8_t *data,
1145  size_t data_block_count,
1146  size_t rdnc_block_count,
1147  struct doca_ec_matrix **matrix);
1148 
1172  const struct doca_ec_matrix *coding_matrix,
1173  uint32_t update_indices[],
1174  size_t n_updates,
1175  struct doca_ec_matrix **matrix);
1199  const struct doca_ec_matrix *coding_matrix,
1200  uint32_t missing_indices[],
1201  size_t n_missing,
1202  struct doca_ec_matrix **matrix);
1203 
1215 doca_error_t doca_ec_matrix_destroy(struct doca_ec_matrix *matrix);
1216 
1217 #ifdef __cplusplus
1218 } /* extern "C" */
1219 #endif
1220 
1221 #endif /* DOCA_EC_H_ */
1222 
#define DOCA_EXPERIMENTAL
To set a Symbol (or specifically a function) as experimental.
Definition: doca_compat.h:103
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_task_create_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_update_allocate_init(struct doca_ec *ec, const struct doca_ec_matrix *update_matrix, const struct doca_buf *original_updated_and_rdnc_blocks, struct doca_buf *updated_rdnc_blocks, union doca_data user_data, struct doca_ec_task_update **task)
This method allocates and initializes an update task.
DOCA_EXPERIMENTAL void doca_ec_task_recover_set_available_blocks(struct doca_ec_task_recover *task, const struct doca_buf *available_blocks)
This method sets the available_blocks buffer of a recover task.
DOCA_EXPERIMENTAL void doca_ec_task_galois_mul_set_dst_buf(struct doca_ec_task_galois_mul *task, struct doca_buf *dst_buf)
This method sets the destination buffer of a Galois multiplication task.
DOCA_EXPERIMENTAL struct doca_buf * doca_ec_task_update_get_updated_rdnc_blocks(const struct doca_ec_task_update *task)
This method gets the updated_rdnc_blocks buffer of an update task. The rdnc_blocks buffer is a destin...
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_task_update_is_supported(const struct doca_devinfo *devinfo)
void(* doca_ec_task_recover_completion_cb_t)(struct doca_ec_task_recover *task, union doca_data task_user_data, union doca_data ctx_user_data)
Function to execute on completion of a recover task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_create_set_conf(struct doca_ec *ec, doca_ec_task_create_completion_cb_t successful_task_completion_cb, doca_ec_task_create_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the create tasks configuration.
DOCA_EXPERIMENTAL const struct doca_ec_matrix * doca_ec_task_update_get_update_matrix(const struct doca_ec_task_update *task)
This method gets the update_matrix of an update task.
DOCA_EXPERIMENTAL const struct doca_buf * doca_ec_task_recover_get_available_blocks(const struct doca_ec_task_recover *task)
This method gets the available_blocks buffer of a recover task. The available_blocks buffer is a sour...
DOCA_EXPERIMENTAL struct doca_buf * doca_ec_task_recover_get_recovered_data(const struct doca_ec_task_recover *task)
This method gets the recovered_data buffer of a recover task. The recovered_data buffer is a destinat...
void(* doca_ec_task_create_completion_cb_t)(struct doca_ec_task_create *task, union doca_data task_user_data, union doca_data ctx_user_data)
Function to execute on completion of a create task.
DOCA_EXPERIMENTAL struct doca_buf * doca_ec_task_galois_mul_get_dst_buf(const struct doca_ec_task_galois_mul *task)
This method gets the destination buffer of a Galois multiplication task.
DOCA_EXPERIMENTAL void doca_ec_task_galois_mul_set_coding_matrix(struct doca_ec_task_galois_mul *task, const struct doca_ec_matrix *coding_matrix)
This method sets the coding_matrix of a Galois multiplication task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_destroy(struct doca_ec *ec)
Destroy a DOCA EC instance.
doca_ec_matrix_type
Types of coding matrix used for erasure codes.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_create_allocate_init(struct doca_ec *ec, const struct doca_ec_matrix *coding_matrix, const struct doca_buf *original_data_blocks, struct doca_buf *rdnc_blocks, union doca_data user_data, struct doca_ec_task_create **task)
This method allocates and initializes a create task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_galois_mul_set_conf(struct doca_ec *ec, doca_ec_task_galois_mul_completion_cb_t successful_task_completion_cb, doca_ec_task_galois_mul_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the Galois multiplication tasks configuration.
DOCA_EXPERIMENTAL doca_error_t doca_ec_matrix_create_from_raw(struct doca_ec *ec, uint8_t *data, size_t data_block_count, size_t rdnc_block_count, struct doca_ec_matrix **matrix)
Create coding matrix for Erasure Code encode i.e. most basic encode matrix from char array....
DOCA_EXPERIMENTAL void doca_ec_task_create_set_coding_matrix(struct doca_ec_task_create *task, const struct doca_ec_matrix *coding_matrix)
This method sets the coding_matrix of a create task.
DOCA_EXPERIMENTAL void doca_ec_task_update_set_original_updated_and_rdnc_blocks(struct doca_ec_task_update *task, const struct doca_buf *original_updated_and_rdnc_blocks)
This method sets the original_updated_and_rdnc_blocks buffer of an update task.
DOCA_EXPERIMENTAL const struct doca_buf * doca_ec_task_update_get_original_updated_and_rdnc_blocks(const struct doca_ec_task_update *task)
This method gets the original_updated_and_rdnc_blocks buffer of an update task. The original_data_blo...
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_get_max_buf_list_len(const struct doca_devinfo *devinfo, uint32_t *max_buf_list_len)
Get the maximum supported number of elements in DOCA linked-list buffer used for EC tasks.
DOCA_EXPERIMENTAL doca_error_t doca_ec_create(struct doca_dev *dev, struct doca_ec **ec)
Create a DOCA EC instance.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_recover_allocate_init(struct doca_ec *ec, const struct doca_ec_matrix *recover_matrix, const struct doca_buf *available_blocks, struct doca_buf *recovered_data_blocks, union doca_data user_data, struct doca_ec_task_recover **task)
This method allocates and initializes a recover task.
DOCA_EXPERIMENTAL void doca_ec_task_create_set_rdnc_blocks(struct doca_ec_task_create *task, struct doca_buf *rdnc_blocks)
This method sets the rdnc_blocks buffer of a create task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_galois_mul_allocate_init(struct doca_ec *ec, const struct doca_ec_matrix *coding_matrix, const struct doca_buf *src_buf, struct doca_buf *dst_buf, union doca_data user_data, struct doca_ec_task_galois_mul **task)
This method allocates and initializes a Galois multiplication task.
DOCA_EXPERIMENTAL const struct doca_buf * doca_ec_task_create_get_original_data_blocks(const struct doca_ec_task_create *task)
This method gets the original_data_blocks buffer of a create task. The original_data_blocks buffer is...
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_update_set_conf(struct doca_ec *ec, doca_ec_task_update_completion_cb_t successful_task_completion_cb, doca_ec_task_update_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the update tasks configuration.
DOCA_EXPERIMENTAL void doca_ec_task_create_set_original_data_blocks(struct doca_ec_task_create *task, const struct doca_buf *original_data_blocks)
This method sets the original_data_blocks buffer of a create task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_matrix_create_update(struct doca_ec *ec, const struct doca_ec_matrix *coding_matrix, uint32_t update_indices[], size_t n_updates, struct doca_ec_matrix **matrix)
Generate coding matrix for Erasure Code update. To use this function must call doca_ec_matrix_create(...
DOCA_EXPERIMENTAL doca_error_t doca_ec_matrix_destroy(struct doca_ec_matrix *matrix)
Destroy coding matrix.
DOCA_EXPERIMENTAL const struct doca_ec_matrix * doca_ec_task_create_get_coding_matrix(const struct doca_ec_task_create *task)
This method gets the coding matrix of a create task.
DOCA_EXPERIMENTAL void doca_ec_task_recover_set_recover_matrix(struct doca_ec_task_recover *task, const struct doca_ec_matrix *recover_matrix)
This method sets the recover_matrix of a recover task.
DOCA_EXPERIMENTAL void doca_ec_task_galois_mul_set_src_buf(struct doca_ec_task_galois_mul *task, const struct doca_buf *src_buf)
This method sets the source buffer of a Galois multiplication task.
DOCA_EXPERIMENTAL struct doca_task * doca_ec_task_recover_as_task(struct doca_ec_task_recover *task)
This method converts an EC recover task to a doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_task_recover_set_conf(struct doca_ec *ec, doca_ec_task_recover_completion_cb_t successful_task_completion_cb, doca_ec_task_recover_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the recover tasks configuration.
DOCA_EXPERIMENTAL struct doca_task * doca_ec_task_galois_mul_as_task(struct doca_ec_task_galois_mul *task)
This method converts an EC Galois multiplication task to a doca_task.
void(* doca_ec_task_update_completion_cb_t)(struct doca_ec_task_update *task, union doca_data task_user_data, union doca_data ctx_user_data)
Function to execute on completion of an update task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_get_max_block_size(const struct doca_devinfo *devinfo, uint64_t *max_block_size)
Get maximum block size supported for DOCA EC tasks.
void(* doca_ec_task_galois_mul_completion_cb_t)(struct doca_ec_task_galois_mul *task, union doca_data task_user_data, union doca_data ctx_user_data)
Function to execute on completion of a Galois multiplication task.
DOCA_EXPERIMENTAL struct doca_task * doca_ec_task_update_as_task(struct doca_ec_task_update *task)
This method converts an EC update task to a doca_task.
DOCA_EXPERIMENTAL struct doca_buf * doca_ec_task_create_get_rdnc_blocks(const struct doca_ec_task_create *task)
This method gets the rdnc_blocks buffer of a create task. The rdnc_blocks buffer is a destination buf...
DOCA_EXPERIMENTAL struct doca_task * doca_ec_task_create_as_task(struct doca_ec_task_create *task)
This method converts an EC create task to a doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_task_galois_mul_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL doca_error_t doca_ec_matrix_create_recover(struct doca_ec *ec, const struct doca_ec_matrix *coding_matrix, uint32_t missing_indices[], size_t n_missing, struct doca_ec_matrix **matrix)
Generate coding matrix for Erasure Code recovery from failure. To use this function must call doca_ec...
DOCA_EXPERIMENTAL doca_error_t doca_ec_matrix_create(struct doca_ec *ec, enum doca_ec_matrix_type type, size_t data_block_count, size_t rdnc_block_count, struct doca_ec_matrix **matrix)
Generate coding matrix for Erasure Code encode i.e. most basic encode matrix. This is necessary for e...
DOCA_EXPERIMENTAL void doca_ec_task_recover_set_recovered_data_blocks(struct doca_ec_task_recover *task, struct doca_buf *recovered_data_blocks)
This method sets the recovered_data_blocks buffer of a recover task.
DOCA_EXPERIMENTAL struct doca_ctx * doca_ec_as_ctx(struct doca_ec *ec)
Convert EC instance into context.
DOCA_EXPERIMENTAL void doca_ec_task_update_set_updated_rdnc_blocks(struct doca_ec_task_update *task, struct doca_buf *updated_rdnc_blocks)
This method sets the updated_rdnc_blocks buffer of an update task.
DOCA_EXPERIMENTAL void doca_ec_task_update_set_update_matrix(struct doca_ec_task_update *task, const struct doca_ec_matrix *update_matrix)
This method sets the update_matrix of an update task.
DOCA_EXPERIMENTAL const struct doca_buf * doca_ec_task_galois_mul_get_src_buf(const struct doca_ec_task_galois_mul *task)
This method gets the source buffer of a Galois multiplication task.
DOCA_EXPERIMENTAL const struct doca_ec_matrix * doca_ec_task_recover_get_recover_matrix(const struct doca_ec_task_recover *task)
This method gets the recover_matrix of a recover task.
DOCA_EXPERIMENTAL doca_error_t doca_ec_cap_task_recover_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL const struct doca_ec_matrix * doca_ec_task_galois_mul_get_coding_matrix(const struct doca_ec_task_galois_mul *task)
This method gets the coding matrix of a Galois multiplication task.
@ DOCA_EC_MATRIX_TYPE_VANDERMONDE
@ DOCA_EC_MATRIX_TYPE_CAUCHY
enum doca_error doca_error_t
DOCA API return codes.
uint8_t type
Definition: packets.h:0
Convenience type for representing opaque data.
Definition: doca_types.h:56