NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
sha_partial_create_sample.c File Reference
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <doca_buf.h>
#include <doca_buf_inventory.h>
#include <doca_ctx.h>
#include <doca_mmap.h>
#include <doca_pe.h>
#include <doca_error.h>
#include <doca_log.h>
#include <doca_sha.h>
#include "common.h"
Include dependency graph for sha_partial_create_sample.c:

Go to the source code of this file.

Data Structures

struct  sha_resources
 

Macros

#define SLEEP_IN_NANOS   (10 * 1000) /* Sample the task every 10 microseconds */
 
#define LOG_NUM_PARTIAL_SHA_TASKS   (0) /* Log of SHA tasks number */
 
#define SHA_SAMPLE_ALGORITHM   (DOCA_SHA_ALGORITHM_SHA256) /* doca_sha_algorithm for the sample */
 

Functions

 DOCA_LOG_REGISTER (SHA_PARTIAL_CREATE)
 
void free_cb (void *addr, size_t len, void *opaque)
 
static doca_error_t sha_cleanup (struct sha_resources *resources)
 
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)
 
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 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 sha_partial_hash_is_supported (struct doca_devinfo *devinfo)
 
static doca_error_t perform_partial_sha_hash_task (struct sha_resources *resources, struct doca_buf **dst_doca_buf)
 
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)
 
doca_error_t sha_partial_create (char *src_buffer)
 

Macro Definition Documentation

◆ LOG_NUM_PARTIAL_SHA_TASKS

#define LOG_NUM_PARTIAL_SHA_TASKS   (0) /* Log of SHA tasks number */

Definition at line 46 of file sha_partial_create_sample.c.

◆ SHA_SAMPLE_ALGORITHM

#define SHA_SAMPLE_ALGORITHM   (DOCA_SHA_ALGORITHM_SHA256) /* doca_sha_algorithm for the sample */

Definition at line 47 of file sha_partial_create_sample.c.

◆ SLEEP_IN_NANOS

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

Definition at line 45 of file sha_partial_create_sample.c.

Function Documentation

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( SHA_PARTIAL_CREATE  )

◆ free_cb()

void free_cb ( void *  addr,
size_t  len,
void *  opaque 
)

Definition at line 67 of file sha_partial_create_sample.c.

◆ perform_partial_sha_hash_task()

static doca_error_t perform_partial_sha_hash_task ( struct sha_resources resources,
struct doca_buf **  dst_doca_buf 
)
static

Definition at line 247 of file sha_partial_create_sample.c.

◆ prepare_and_submit_partial_sha_hash_task()

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 
)
static

Definition at line 120 of file sha_partial_create_sample.c.

◆ sha_cleanup()

static doca_error_t sha_cleanup ( struct sha_resources resources)
static

Definition at line 81 of file sha_partial_create_sample.c.

◆ sha_partial_create()

doca_error_t sha_partial_create ( char *  src_buffer)

Definition at line 368 of file sha_partial_create_sample.c.

◆ sha_partial_hash_completed_callback()

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

Definition at line 178 of file sha_partial_create_sample.c.

◆ sha_partial_hash_error_callback()

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

Definition at line 209 of file sha_partial_create_sample.c.

◆ sha_partial_hash_is_supported()

static doca_error_t sha_partial_hash_is_supported ( struct doca_devinfo *  devinfo)
static

Definition at line 234 of file sha_partial_create_sample.c.

◆ sha_state_changed_callback()

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

Callback triggered whenever SHA context state changes

@user_data [in]: User data associated with the SHA context. Will hold struct sha_resources * @ctx [in]: The SHA 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 SHA.

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 322 of file sha_partial_create_sample.c.