56 DOCA_LOG_ERR(
"Got external interrupt, the program will terminate shortly, please wait");
72 unsigned int total_num_eus,
74 unsigned int *available_eus_size)
76 struct doca_dpa_eu_affinity *affinity =
NULL;
85 for (
unsigned int eu_id = 1; eu_id < total_num_eus; ++eu_id) {
93 struct doca_dpa_thread *thread =
NULL;
119 FILE *orig_stderr = stderr;
120 stderr = fopen(
"/dev/null",
"w");
127 available_eus[eu_id] =
true;
128 *available_eus_size = *available_eus_size + 1;
133 stderr = orig_stderr;
157 static size_t get_num_used_eus(
bool *available_eus,
bool *excluded_eus,
unsigned int total_num_eus)
160 for (
unsigned int eu_id = 1; eu_id < total_num_eus; eu_id++) {
161 if ((available_eus[eu_id] ==
true) && (excluded_eus[eu_id] ==
false)) {
195 char *device_name = (
char *)param;
218 unsigned long err = strtoul((
char *)param,
NULL, 10);
220 DOCA_LOG_ERR(
"Failed to convert ARGP param duration seconds to unsigned long");
239 DOCA_LOG_ERR(
"Failed to convert ARGP param user factor to float");
256 char *
input = (
char *)param;
261 DOCA_LOG_ERR(
"Entered excluded EUs exceeding the maximum size of %d",
266 char *token = strtok(
input,
",");
267 while (token !=
NULL) {
268 unsigned int eu_id = (
unsigned int)strtoul(token,
NULL, 0);
273 token = strtok(
NULL,
",");
287 struct doca_argp_param *dev_name, *test_duration_sec, *user_factor, *excluded_eus;
335 "user factor from type float (optional). If not provided then 0.75f be chosen.");
354 "excluded eus list, devided by ',' with no spaced (optional). If not provided then no eu will be excluded.");
380 unsigned int size_used_eus = 0;
382 unsigned int size_unused_eus = 0;
385 unsigned int size_unreachable_eus =
output->total_num_eus - 1;
386 for (
unsigned int eu_id = 1; eu_id <
output->total_num_eus; ++eu_id)
387 unreachable_eus[eu_id] =
true;
389 strcat(stream,
"{\"data\": {\n");
390 snprintf(stream + strlen(stream),
392 "\t\"device\": \"%s\",\n",
394 snprintf(stream + strlen(stream),
396 "\t\"total_harts\": %d,\n",
399 strcat(stream,
"\t\"available_harts\": [");
400 for (
unsigned int eu_id = 1; eu_id <
output->total_num_eus; ++eu_id) {
401 if (
output->available_eus[eu_id] ==
true) {
402 output->available_eus_size--;
403 unreachable_eus[eu_id] =
false;
404 size_unreachable_eus--;
406 if (
output->available_eus_size > 0) {
410 used_eus[eu_id] =
true;
413 unused_eus[eu_id] =
true;
418 strcat(stream,
"],\n");
420 strcat(stream,
"\t\"unreachable_harts\": [");
421 for (
unsigned int eu_id = 1; eu_id <
output->total_num_eus; ++eu_id) {
422 if (unreachable_eus[eu_id] ==
true) {
423 size_unreachable_eus--;
425 if (size_unreachable_eus > 0) {
430 strcat(stream,
"],\n");
432 strcat(stream,
"\t\"used_harts\": [");
433 for (
unsigned int eu_id = 1; eu_id <
output->total_num_eus; ++eu_id) {
434 if (used_eus[eu_id] ==
true) {
437 if (size_used_eus > 0) {
442 strcat(stream,
"],\n");
444 strcat(stream,
"\t\"unused_harts\": [");
445 for (
unsigned int eu_id = 1; eu_id <
output->total_num_eus; ++eu_id) {
446 if (unused_eus[eu_id] ==
true) {
449 if (size_unused_eus > 0) {
454 strcat(stream,
"],\n");
456 snprintf(stream + strlen(stream),
458 "\t\"total_dpa_run_time\": \"%ld [sec]\"\n}}\n",
459 output->total_dpa_run_time_sec);
476 float float_user_factor;
477 memcpy(&float_user_factor, &nvqual_argp_cfg->
user_factor,
sizeof(float_user_factor));
481 if (float_user_factor != (
float)0) {
517 sigemptyset(&sa.sa_mask);
520 if (sigaction(SIGINT, &sa,
NULL) == -1) {
525 uint32_t num_devs = 0;
536 for (uint32_t i = 0; i < num_devs; i++) {
625 if (num_used_eus == 0) {
626 DOCA_LOG_ERR(
"Failed to find any available DPA EUs with the current excluded EUs configuration");
659 for (
unsigned int eu_id = 1; eu_id < nvq->
total_num_eus; eu_id++) {
662 DOCA_LOG_WARN(
"Skipping unavailable HART #%d, you may use dpaeumgmt tool to enable it", eu_id);
680 struct doca_dpa_thread *thread =
NULL;
698 DOCA_LOG_ERR(
"Failed to alloc src buffer of size %lu : %s",
708 DOCA_LOG_ERR(
"Failed to alloc dst buffer of size %lu : %s",
737 nvq->
tlss[eu_id] = htls;
758 struct doca_dpa_notification_completion *notify_comp =
NULL;
776 DOCA_LOG_ERR(
"Failed to get notification completion device handle: %s",
785 (
void *)(&dev_notify_comp),
886 while (time_left > 0) {
895 DOCA_LOG_INFO(
"Estimated time left: %02d:%02d:%02d", h, m, s);
901 struct timeval start;
902 gettimeofday(&start,
NULL);
911 DOCA_LOG_ERR(
"Failed to run RPC for waking up all threads: %s",
923 struct timeval current;
924 gettimeofday(¤t,
NULL);
928 long long elapsed = current_time - start_time;
930 time_left -= elapsed;
936 (
void *)(thread_rets_host),
945 for (
unsigned int thread_idx = 0; thread_idx < nvq->num_threads; thread_idx++)
982 DOCA_LOG_ERR(
"Failed to set logging backend log level for SDK messages: %s",
990 DOCA_LOG_ERR(
"Failed to set logging backend log level for SDK messages: %s",
996 doca_err =
setup(nvqual_argp_cfg, nvq);
1005 "DPA context member hasn't been initialized during the setup phase. Please initialize it in the setup method.");
struct doca_dpa_app * dpa_sample_app
#define DPA_NVQUAL_DPA_FREQ
#define DPA_NVQUAL_MAX_EUS
#define DPA_NVQUAL_SEC_IN_HOUR
#define DPA_NVQUAL_SEC_IN_MINUTE
#define DPA_NVQUAL_ALLOCATED_DPA_HEAP_SIZE
#define DPA_NVQUAL_COPY_BYTE_LATENCY_USEC
#define DPA_NVQUAL_SEC_TO_USEC
#define DPA_NVQUAL_WATCHDOG_TIME_SEC
#define DPA_NVQUAL_MAX_INPUT_EXCLUDED_EUS_SIZE
#define DPA_NVQUAL_PRINT_BUFFER_SIZE
#define DPA_NVQUAL_ITERATION_DURATION_SEC
#define DPA_NVQUAL_SYNC_EVENT_MASK
static doca_error_t user_factor_param_callback(void *param, void *config)
ARGP Callback - Handle user factor parameter.
static void sigint_handler(int signum)
Signal interrupt handler.
static size_t get_num_used_eus(bool *available_eus, bool *excluded_eus, unsigned int total_num_eus)
Get number of used EUs.
DOCA_LOG_REGISTER(DPA_NVQUAL)
doca_dpa_func_t dpa_nvqual_entry_point
static doca_error_t iteration_complete_cb(struct dpa_nvqual *nvq, uint64_t ret_val)
Iteration complete updates.
static doca_error_t get_available_eus(struct doca_dpa *dpa, unsigned int total_num_eus, bool *available_eus, unsigned int *available_eus_size)
Get available EUs.
struct doca_log_backend * stdout_logger
static doca_error_t setup(struct dpa_nvqual_config *nvqual_argp_cfg, struct dpa_nvqual *nvq)
Setup sample's configuration.
static doca_error_t test_duration_sec_param_callback(void *param, void *config)
ARGP Callback - Handle duration seconds parameter.
doca_dpa_func_t dpa_nvqual_kernel
static doca_error_t dev_name_param_callback(void *param, void *config)
ARGP Callback - Handle device name parameter.
doca_error_t dpa_nvqual(struct dpa_nvqual_config *nvqual_argp_cfg)
Run DPA nvqual sample.
static doca_error_t run_flow(struct dpa_nvqual *nvq)
Run sample's flow.
static doca_error_t excluded_eus_param_callback(void *param, void *config)
ARGP Callback - Handle excluded eus parameter.
doca_error_t dpa_nvqual_register_params(void)
Register DPA nvqual parameters.
static doca_error_t tear_down(struct dpa_nvqual *nvq)
Tear down sample's configuration.
static doca_error_t print_sample_data(struct dpa_nvqual_run_output *output, struct dpa_nvqual_flow_config *flow_cfg)
Print sample's data.
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_arguments(struct doca_argp_param *param, const char *arguments)
Set the description of the expected arguments of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_mandatory(struct doca_argp_param *param)
Mark the program param as mandatory.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
DOCA_STABLE doca_error_t doca_devinfo_get_ibdev_name(const struct doca_devinfo *devinfo, char *ibdev_name, uint32_t size)
Get the name of the IB device represented by a DOCA devinfo.
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_notification_completion_start(struct doca_dpa_notification_completion *notify_comp)
Start DPA notification completion context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_stop(struct doca_dpa *dpa)
Stop a DPA context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_run(struct doca_dpa_thread *dpa_thread)
Run DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_create(struct doca_dpa *dpa, struct doca_dpa_thread **dpa_thread)
Create DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_create(struct doca_dev *dev, struct doca_dpa **dpa)
Create a DOCA DPA Context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_notification_completion_destroy(struct doca_dpa_notification_completion *notify_comp)
Destroy DPA notification completion context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_notification_completion_create(struct doca_dpa *dpa, struct doca_dpa_thread *dpa_thread, struct doca_dpa_notification_completion **notify_comp)
Create DPA notification completion context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_mem_alloc(struct doca_dpa *dpa, size_t size, doca_dpa_dev_uintptr_t *dev_ptr)
Allocate DPA heap memory.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_mem_free(struct doca_dpa *dpa, doca_dpa_dev_uintptr_t dev_ptr)
Free the previously allocated DPA memory.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_destroy(struct doca_dpa *dpa)
Destroy a DOCA DPA context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_rpc(struct doca_dpa *dpa, doca_dpa_func_t *func, uint64_t *retval,...)
RPC to run DPA kernel.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_set_local_storage(struct doca_dpa_thread *dpa_thread, doca_dpa_dev_uintptr_t dev_ptr)
Set DPA thread local storage.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_notification_completion_get_dpa_handle(struct doca_dpa_notification_completion *notify_comp, doca_dpa_dev_notification_completion_t *handle)
Get DPA notification completion context handle.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_eu_affinity_create(struct doca_dpa *dpa, struct doca_dpa_eu_affinity **affinity)
Create DPA EU affinity.
void() doca_dpa_func_t(void)
Generic function pointer type.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_notification_completion_stop(struct doca_dpa_notification_completion *notify_comp)
Stop DPA notification completion context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_start(struct doca_dpa *dpa)
Start a DPA context.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_set_func_arg(struct doca_dpa_thread *dpa_thread, doca_dpa_func_t *func, uint64_t arg)
Set DPA thread entry point and its argument.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_d2h_memcpy(struct doca_dpa *dpa, void *dst_ptr, doca_dpa_dev_uintptr_t src_ptr, size_t size)
Copy from DPA Heap to host memory.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_h2d_memcpy(struct doca_dpa *dpa, doca_dpa_dev_uintptr_t dst_ptr, void *src_ptr, size_t size)
Copy from host memory to DPA Heap.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_cap_is_supported(const struct doca_devinfo *devinfo)
Get whether the DOCA device supports DPA.
uint64_t doca_dpa_dev_uintptr_t
DPA pointer type definition.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_set_affinity(struct doca_dpa_thread *dpa_thread, const struct doca_dpa_eu_affinity *affinity)
Set DPA thread affinity.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_eu_affinity_destroy(struct doca_dpa_eu_affinity *affinity)
Destroy DPA EU affinity.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_get_total_num_eus_available(struct doca_dpa *dpa, unsigned int *total_num_eus)
Retrieve the total number of EUs available to the application.
uint64_t doca_dpa_dev_notification_completion_t
DPA notification completion handle type definition.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_start(struct doca_dpa_thread *dpa_thread)
Start DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_stop(struct doca_dpa_thread *dpa_thread)
Stop DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_eu_affinity_set(struct doca_dpa_eu_affinity *affinity, unsigned int eu_id)
Set EU ID in DPA EU affinity.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_thread_destroy(struct doca_dpa_thread *dpa_thread)
Destroy DPA thread.
DOCA_EXPERIMENTAL doca_error_t doca_dpa_set_app(struct doca_dpa *dpa, struct doca_dpa_app *app)
Set program app for DPA context.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_name(doca_error_t error)
Returns the string representation of an error code name.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
@ DOCA_ERROR_OPERATING_SYSTEM
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_with_file_sdk(FILE *fptr, struct doca_log_backend **backend)
Create a logging backend with a FILE* stream for SDK messages.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_set_sdk_level(struct doca_log_backend *backend, uint32_t level)
Set the log level limit for SDK logging backends.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_start(struct doca_sync_event *event)
Start a Sync Event to be operate as stand-alone DOCA Core object only.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_create(struct doca_sync_event **event)
Create a Sync Event handle.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_add_subscriber_location_dpa(struct doca_sync_event *event, struct doca_dpa *dpa)
Associate a DOCA DPA context as the Sync Event subscriber.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_update_set(struct doca_sync_event *event, uint64_t value)
Set the value of a Sync Event to some value synchronously.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_wait_gt(struct doca_sync_event *event, uint64_t value, uint64_t mask)
Wait for the value of a Sync Event to be grater than some threshold value synchronously in a polling ...
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_stop(struct doca_sync_event *event)
Stop a Sync Event which has been previously started with 'doca_sync_event_start'.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_get_dpa_handle(struct doca_sync_event *event, struct doca_dpa *dpa, doca_dpa_dev_sync_event_t *dpa_dev_se_handle)
Export Sync Event to be shared with the DPA.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_destroy(struct doca_sync_event *event)
Destroy a Sync Event instance.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_add_publisher_location_cpu(struct doca_sync_event *event, struct doca_dev *dev)
Associate a CPU device context as the Sync Event publisher.
unsigned int excluded_eus_size
char dev_name[DPA_NVQUAL_DOCA_DEVINFO_IBDEV_NAME_SIZE]
bool excluded_eus[DPA_NVQUAL_MAX_EUS]
uint64_t test_duration_sec
uint64_t allocated_dpa_heap_size
uint64_t iteration_duration_sec
uint64_t test_duration_sec
bool excluded_eus[DPA_NVQUAL_MAX_EUS]
unsigned int excluded_eus_size
unsigned int available_eus_size
uint64_t total_dpa_run_time_sec
bool available_eus[DPA_NVQUAL_MAX_EUS]
unsigned int total_num_eus
doca_dpa_dev_uintptr_t dst_buf
doca_dpa_dev_uintptr_t src_buf
doca_dpa_dev_sync_event_t dev_se
doca_dpa_dev_uintptr_t thread_ret
struct doca_dpa_thread * threads[DPA_NVQUAL_MAX_EUS]
struct doca_dpa_eu_affinity * affinity
doca_dpa_dev_uintptr_t thread_rets
doca_dpa_dev_uintptr_t dev_tlss[DPA_NVQUAL_MAX_EUS]
uint32_t avg_latency_single_op
unsigned int total_num_eus
doca_dpa_dev_uintptr_t dev_notification_completions
bool available_eus[DPA_NVQUAL_MAX_EUS]
struct doca_dpa_notification_completion * notification_completions[DPA_NVQUAL_MAX_EUS]
struct doca_sync_event * se
struct doca_devinfo ** dev_list
unsigned int available_eus_size
struct dpa_nvqual_flow_config flow_cfg
doca_dpa_dev_sync_event_t dev_se
struct dpa_nvqual_tls tlss[DPA_NVQUAL_MAX_EUS]
uint64_t total_dpa_run_time_usec