45 #define SLEEP_IN_NANOS (10 * 1000)
46 #define LOG_NUM_PARTIAL_SHA_TASKS (0)
47 #define SHA_SAMPLE_ALGORITHM (DOCA_SHA_ALGORITHM_SHA256)
121 struct doca_sha_task_partial_hash *sha_partial_hash_task)
123 struct doca_task *task;
146 if (src_len ==
resources->remaining_src_len) {
149 DOCA_LOG_ERR(
"Failed to set final buffer for SHA partial hash task: %s",
183 bool last_task_finished =
resources->remaining_src_len == 0;
185 (
void)task_user_data.
ptr;
192 if (!last_task_finished)
216 (void)task_user_data.
ptr;
250 struct doca_sha_task_partial_hash *sha_partial_hash_task =
NULL;
251 struct doca_task *task =
NULL;
253 struct timespec ts = {
266 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing source buffer: %s",
277 &sha_partial_hash_task);
323 struct doca_ctx *
ctx,
332 switch (next_state) {
342 DOCA_LOG_ERR(
"SHA context entered into starting state. Unexpected transition");
355 DOCA_LOG_INFO(
"SHA context entered into stopping state. Any inflight tasks will be flushed");
373 struct doca_buf *dst_doca_buf =
NULL;
374 uint8_t *dst_buffer =
NULL;
375 uint8_t *dst_buffer_data =
NULL;
376 char *sha_output =
NULL;
377 uint32_t max_bufs = 2;
378 uint32_t min_dst_sha_buffer_size, i;
384 resources.remaining_src_len = strlen(src_buffer);
394 &min_dst_sha_buffer_size);
396 DOCA_LOG_ERR(
"Failed to get minimum destination buffer size for DOCA SHA: %s",
406 DOCA_LOG_ERR(
"Failed to get the partial hash block size for DOCA SHA: %s",
413 DOCA_LOG_ERR(
"User data length %lu should be bigger than one partial hash block size %u",
459 dst_buffer = calloc(1, min_dst_sha_buffer_size);
460 if (dst_buffer ==
NULL) {
505 min_dst_sha_buffer_size,
508 DOCA_LOG_ERR(
"Unable to acquire DOCA buffer representing destination buffer: %s",
551 sha_output = calloc(1, (hash_length * 2) + 1);
552 if (sha_output ==
NULL) {
560 for (i = 0; i < hash_length; i++)
561 snprintf(sha_output + (2 * i), 3,
"%02x", dst_buffer_data[i]);
doca_error_t destroy_core_objects(struct program_core_objects *state)
doca_error_t create_core_objects(struct program_core_objects *state, uint32_t max_bufs)
doca_error_t open_doca_device_with_capabilities(tasks_check func, struct doca_dev **retval)
struct rdma_resources resources
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_get_data(const struct doca_buf *buf, void **data)
Get the buffer's data.
DOCA_STABLE doca_error_t doca_buf_get_data_len(const struct doca_buf *buf, size_t *data_len)
Get buffer's data length.
DOCA_STABLE doca_error_t doca_buf_set_data(struct doca_buf *buf, void *data, size_t data_len)
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
doca_ctx_states
This enum defines the states of a context.
@ DOCA_CTX_STATE_STARTING
@ DOCA_CTX_STATE_STOPPING
DOCA_STABLE struct doca_devinfo * doca_dev_as_devinfo(const struct doca_dev *dev)
Get local device info from device. This should be useful when wanting to query information about devi...
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE doca_error_t doca_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_set_free_cb(struct doca_mmap *mmap, doca_mmap_memrange_free_cb_t *free_cb, void *opaque)
Set callback that will free the memory range when destroying DOCA memory map.
DOCA_STABLE doca_error_t doca_task_get_status(const struct doca_task *task)
Get task status.
DOCA_STABLE doca_error_t doca_pe_connect_ctx(struct doca_pe *pe, struct doca_ctx *ctx)
This method connects a context to a progress engine.
DOCA_STABLE doca_error_t doca_task_submit(struct doca_task *task)
Submit a task to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
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_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 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_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_src(struct doca_sha_task_partial_hash *task, struct doca_buf const *src_buf)
DOCA_EXPERIMENTAL doca_error_t doca_sha_destroy(struct doca_sha *sha)
DOCA_EXPERIMENTAL struct doca_ctx * doca_sha_as_ctx(struct doca_sha *sha)
#define SHA_SAMPLE_ALGORITHM
#define LOG_NUM_PARTIAL_SHA_TASKS
doca_error_t sha_partial_create(char *src_buffer)
static doca_error_t sha_cleanup(struct sha_resources *resources)
static void sha_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 void sha_partial_hash_error_callback(struct doca_sha_task_partial_hash *sha_partial_hash_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t prepare_and_submit_partial_sha_hash_task(struct sha_resources *resources, struct doca_sha_task_partial_hash *sha_partial_hash_task)
DOCA_LOG_REGISTER(SHA_PARTIAL_CREATE)
static void sha_partial_hash_completed_callback(struct doca_sha_task_partial_hash *sha_partial_hash_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t sha_partial_hash_is_supported(struct doca_devinfo *devinfo)
void free_cb(void *addr, size_t len, void *opaque)
static doca_error_t perform_partial_sha_hash_task(struct sha_resources *resources, struct doca_buf **dst_doca_buf)
struct doca_mmap * src_mmap
struct doca_buf_inventory * buf_inv
struct doca_mmap * dst_mmap
struct doca_sha * sha_ctx
struct program_core_objects state
struct doca_buf * src_doca_buf
uint32_t partial_block_size
Convenience type for representing opaque data.
struct upf_accel_ctx * ctx