NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
doca_sha.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2025 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_SHA_H_
23 #define DOCA_SHA_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 
44 /**********************************************************************************************************************
45  * DOCA SHA context
46  *********************************************************************************************************************/
47 
49 struct doca_sha;
50 
70 doca_error_t doca_sha_create(struct doca_dev *dev, struct doca_sha **sha);
71 
85 doca_error_t doca_sha_destroy(struct doca_sha *sha);
86 
99 struct doca_ctx *doca_sha_as_ctx(struct doca_sha *sha);
100 
101 /*********************************************************************************************************************
102  * DOCA SHA Algorithms
103  *********************************************************************************************************************/
104 
112 };
113 
114 /**********************************************************************************************************************
115  * DOCA SHA support and capabilities
116  *********************************************************************************************************************/
117 
135 doca_error_t doca_sha_cap_task_hash_get_supported(struct doca_devinfo const *devinfo,
136  enum doca_sha_algorithm algorithm);
137 
156  enum doca_sha_algorithm algorithm);
157 
175 doca_error_t doca_sha_cap_get_max_list_buf_num_elem(struct doca_devinfo const *devinfo,
176  uint32_t *max_list_buf_num_elem);
177 
194 doca_error_t doca_sha_cap_get_max_src_buf_size(struct doca_devinfo const *devinfo, uint64_t *max_src_buf_size);
195 
218 doca_error_t doca_sha_cap_get_min_dst_buf_size(struct doca_devinfo const *devinfo,
219  enum doca_sha_algorithm algorithm,
220  uint32_t *min_dst_buf_size);
221 
242 doca_error_t doca_sha_cap_get_partial_hash_block_size(struct doca_devinfo const *devinfo,
243  enum doca_sha_algorithm algorithm,
244  uint32_t *partial_block_size);
245 
262 doca_error_t doca_sha_cap_get_max_num_tasks(struct doca_sha *sha, uint32_t *max_num_tasks);
263 
264 /**********************************************************************************************************************
265  * DOCA SHA hash task
266  *********************************************************************************************************************/
267 
269 struct doca_sha_task_hash;
270 
283 typedef void (*doca_sha_task_hash_completion_cb_t)(struct doca_sha_task_hash *task,
284  union doca_data task_user_data,
285  union doca_data ctx_user_data);
286 
309  uint8_t log_num_tasks);
310 
340  enum doca_sha_algorithm algorithm,
341  struct doca_buf const *src_buf,
342  struct doca_buf *dst_buf,
343  union doca_data user_data,
344  struct doca_sha_task_hash **task);
345 
360 doca_error_t doca_sha_task_hash_set_src(struct doca_sha_task_hash *task, struct doca_buf const *src_buf);
361 
375 struct doca_buf const *doca_sha_task_hash_get_src(struct doca_sha_task_hash const *task);
376 
391 doca_error_t doca_sha_task_hash_set_dst(struct doca_sha_task_hash *task, struct doca_buf *dst_buf);
392 
406 struct doca_buf const *doca_sha_task_hash_get_dst(struct doca_sha_task_hash const *task);
407 
422 doca_error_t doca_sha_task_hash_set_algorithm(struct doca_sha_task_hash *task, enum doca_sha_algorithm algorithm);
423 
437 enum doca_sha_algorithm doca_sha_task_hash_get_algorithm(struct doca_sha_task_hash const *task);
438 
451 struct doca_task *doca_sha_task_hash_as_task(struct doca_sha_task_hash *task);
452 
453 /**********************************************************************************************************************
454  * DOCA SHA partial hash task
455  *********************************************************************************************************************/
456 
482 struct doca_sha_task_partial_hash;
483 
496 typedef void (*doca_sha_task_partial_hash_completion_cb_t)(struct doca_sha_task_partial_hash *task,
497  union doca_data task_user_data,
498  union doca_data ctx_user_data);
499 
522  uint8_t log_num_tasks);
523 
554  enum doca_sha_algorithm algorithm,
555  struct doca_buf const *src_buf,
556  struct doca_buf *dst_buf,
557  union doca_data user_data,
558  struct doca_sha_task_partial_hash **task);
559 
573 doca_error_t doca_sha_task_partial_hash_reset(struct doca_sha_task_partial_hash *task);
574 
593 doca_error_t doca_sha_task_partial_hash_set_src(struct doca_sha_task_partial_hash *task,
594  struct doca_buf const *src_buf);
595 
609 struct doca_buf const *doca_sha_task_partial_hash_get_src(struct doca_sha_task_partial_hash const *task);
610 
627 doca_error_t doca_sha_task_partial_hash_set_dst(struct doca_sha_task_partial_hash *task, struct doca_buf *dst_buf);
628 
642 struct doca_buf const *doca_sha_task_partial_hash_get_dst(struct doca_sha_task_partial_hash const *task);
643 
660 doca_error_t doca_sha_task_partial_hash_set_algorithm(struct doca_sha_task_partial_hash *task,
661  enum doca_sha_algorithm algorithm);
662 
676 enum doca_sha_algorithm doca_sha_task_partial_hash_get_algorithm(struct doca_sha_task_partial_hash const *task);
677 
695 doca_error_t doca_sha_task_partial_hash_set_is_final_buf(struct doca_sha_task_partial_hash *task);
696 
710 uint8_t doca_sha_task_partial_hash_get_is_final(struct doca_sha_task_partial_hash const *task);
711 
722 uint8_t doca_sha_task_partial_hash_get_has_result(struct doca_sha_task_partial_hash const *task);
723 
736 struct doca_task *doca_sha_task_partial_hash_as_task(struct doca_sha_task_partial_hash *task);
737 
738 #ifdef __cplusplus
739 } /* extern "C" */
740 #endif
741 
744 #endif /* DOCA_SHA_H_ */
static void task_error_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: common_common.c:65
static void task_completion_cb(struct doca_task *se_task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: common_common.c:48
#define DOCA_EXPERIMENTAL
To set a Symbol (or specifically a function) as experimental.
Definition: doca_compat.h:103
enum doca_error doca_error_t
DOCA API return codes.
DOCA_EXPERIMENTAL struct doca_buf const * doca_sha_task_hash_get_dst(struct doca_sha_task_hash const *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_get_partial_hash_block_size(struct doca_devinfo const *devinfo, enum doca_sha_algorithm algorithm, uint32_t *partial_block_size)
DOCA_EXPERIMENTAL struct doca_task * doca_sha_task_partial_hash_as_task(struct doca_sha_task_partial_hash *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_set_dst(struct doca_sha_task_partial_hash *task, struct doca_buf *dst_buf)
void(* doca_sha_task_hash_completion_cb_t)(struct doca_sha_task_hash *task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: doca_sha.h:283
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_get_max_list_buf_num_elem(struct doca_devinfo const *devinfo, uint32_t *max_list_buf_num_elem)
DOCA_EXPERIMENTAL doca_error_t doca_sha_create(struct doca_dev *dev, struct doca_sha **sha)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_get_min_dst_buf_size(struct doca_devinfo const *devinfo, enum doca_sha_algorithm algorithm, uint32_t *min_dst_buf_size)
DOCA_EXPERIMENTAL struct doca_buf const * doca_sha_task_partial_hash_get_dst(struct doca_sha_task_partial_hash const *task)
DOCA_EXPERIMENTAL struct doca_task * doca_sha_task_hash_as_task(struct doca_sha_task_hash *task)
DOCA_EXPERIMENTAL enum doca_sha_algorithm doca_sha_task_hash_get_algorithm(struct doca_sha_task_hash const *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_set_is_final_buf(struct doca_sha_task_partial_hash *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_alloc_init(struct doca_sha *sha, enum doca_sha_algorithm algorithm, struct doca_buf const *src_buf, struct doca_buf *dst_buf, union doca_data user_data, struct doca_sha_task_partial_hash **task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_task_partial_hash_get_supported(struct doca_devinfo const *devinfo, enum doca_sha_algorithm algorithm)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_hash_set_algorithm(struct doca_sha_task_hash *task, enum doca_sha_algorithm algorithm)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_set_conf(struct doca_sha *sha, doca_sha_task_partial_hash_completion_cb_t task_completion_cb, doca_sha_task_partial_hash_completion_cb_t task_error_cb, uint8_t log_num_tasks)
This method sets the doca_sha partial hash task pool configuration.
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_set_algorithm(struct doca_sha_task_partial_hash *task, enum doca_sha_algorithm algorithm)
DOCA_EXPERIMENTAL struct doca_buf const * doca_sha_task_hash_get_src(struct doca_sha_task_hash const *task)
DOCA_EXPERIMENTAL struct doca_buf const * doca_sha_task_partial_hash_get_src(struct doca_sha_task_partial_hash const *task)
void(* doca_sha_task_partial_hash_completion_cb_t)(struct doca_sha_task_partial_hash *task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: doca_sha.h:496
DOCA_EXPERIMENTAL enum doca_sha_algorithm doca_sha_task_partial_hash_get_algorithm(struct doca_sha_task_partial_hash const *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_task_hash_get_supported(struct doca_devinfo const *devinfo, enum doca_sha_algorithm algorithm)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_set_src(struct doca_sha_task_partial_hash *task, struct doca_buf const *src_buf)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_get_max_num_tasks(struct doca_sha *sha, uint32_t *max_num_tasks)
DOCA_EXPERIMENTAL uint8_t doca_sha_task_partial_hash_get_has_result(struct doca_sha_task_partial_hash const *task)
DOCA_EXPERIMENTAL uint8_t doca_sha_task_partial_hash_get_is_final(struct doca_sha_task_partial_hash const *task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_hash_set_conf(struct doca_sha *sha, doca_sha_task_hash_completion_cb_t task_completion_cb, doca_sha_task_hash_completion_cb_t task_error_cb, uint8_t log_num_tasks)
This method sets the doca_sha hash task pool configuration.
doca_sha_algorithm
Definition: doca_sha.h:108
DOCA_EXPERIMENTAL doca_error_t doca_sha_destroy(struct doca_sha *sha)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_hash_alloc_init(struct doca_sha *sha, enum doca_sha_algorithm algorithm, struct doca_buf const *src_buf, struct doca_buf *dst_buf, union doca_data user_data, struct doca_sha_task_hash **task)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_hash_set_src(struct doca_sha_task_hash *task, struct doca_buf const *src_buf)
DOCA_EXPERIMENTAL doca_error_t doca_sha_cap_get_max_src_buf_size(struct doca_devinfo const *devinfo, uint64_t *max_src_buf_size)
DOCA_EXPERIMENTAL struct doca_ctx * doca_sha_as_ctx(struct doca_sha *sha)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_hash_set_dst(struct doca_sha_task_hash *task, struct doca_buf *dst_buf)
DOCA_EXPERIMENTAL doca_error_t doca_sha_task_partial_hash_reset(struct doca_sha_task_partial_hash *task)
@ DOCA_SHA_ALGORITHM_SHA512
Definition: doca_sha.h:111
@ DOCA_SHA_ALGORITHM_SHA1
Definition: doca_sha.h:109
@ DOCA_SHA_ALGORITHM_SHA256
Definition: doca_sha.h:110
Convenience type for representing opaque data.
Definition: doca_types.h:56