NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
dpa_nvqual_main.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2025 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #include <dpa_common.h>
27 #include <dpa_nvqual_common_defs.h>
28 
29 DOCA_LOG_REGISTER(DPA_NVQUAL_TEST);
30 
34 doca_error_t dpa_nvqual(struct dpa_nvqual_config *nvqual_argp_cfg);
39 
47 int main(int argc, char **argv)
48 {
49  struct dpa_nvqual_config nvqual_argp_cfg;
51  struct doca_log_backend *sdk_log = NULL;
52  int exit_status = EXIT_FAILURE;
53 
54  strcpy(nvqual_argp_cfg.dev_name, "");
55  for (int i = 0; i < DPA_NVQUAL_MAX_EUS; i++) {
56  nvqual_argp_cfg.excluded_eus[i] = false;
57  }
58  nvqual_argp_cfg.excluded_eus_size = 0;
59  nvqual_argp_cfg.test_duration_sec = 0;
60  nvqual_argp_cfg.user_factor = 0;
61 
63  if (err != DOCA_SUCCESS)
64  goto sample_exit;
65 
66  err = doca_log_backend_create_with_file_sdk(stderr, &sdk_log);
67  if (err != DOCA_SUCCESS)
68  goto sample_exit;
70  if (err != DOCA_SUCCESS)
71  goto sample_exit;
72 
73  DOCA_LOG_INFO("Starting the sample");
74 
75  err = doca_argp_init(NULL, &nvqual_argp_cfg);
76  if (err != DOCA_SUCCESS) {
77  DOCA_LOG_ERR("Failed to init ARGP resources: %s", doca_error_get_descr(err));
78  goto sample_exit;
79  }
80 
82  if (err != DOCA_SUCCESS) {
83  DOCA_LOG_ERR("Failed to register sample parameters: %s", doca_error_get_descr(err));
84  goto argp_cleanup;
85  }
86 
87  err = doca_argp_start(argc, argv);
88  if (err != DOCA_SUCCESS) {
89  DOCA_LOG_ERR("Failed to parse sample input: %s", doca_error_get_descr(err));
90  goto argp_cleanup;
91  }
92 
93  err = dpa_nvqual(&nvqual_argp_cfg);
94  if (err != DOCA_SUCCESS) {
95  DOCA_LOG_ERR("dpa_nvqual() encountered an error: %s", doca_error_get_descr(err));
96  goto argp_cleanup;
97  }
98 
99  exit_status = EXIT_SUCCESS;
100 
101 argp_cleanup:
103 
104 sample_exit:
105  if (exit_status == EXIT_SUCCESS)
106  DOCA_LOG_INFO("Sample finished successfully");
107  else
108  DOCA_LOG_INFO("Sample finished with errors");
109  return exit_status;
110 }
#define NULL
Definition: __stddef_null.h:26
#define DPA_NVQUAL_MAX_EUS
int main(int argc, char **argv)
Sample's main function.
DOCA_LOG_REGISTER(DPA_NVQUAL_TEST)
doca_error_t dpa_nvqual(struct dpa_nvqual_config *nvqual_argp_cfg)
Run DPA nvqual sample.
doca_error_t dpa_nvqual_register_params(void)
Register DPA nvqual parameters.
DOCA_EXPERIMENTAL doca_error_t doca_argp_start(int argc, char **argv)
Parse incoming arguments (cmd line/json).
DOCA_EXPERIMENTAL doca_error_t doca_argp_init(const char *program_name, void *program_config)
Initialize the parser interface.
DOCA_EXPERIMENTAL doca_error_t doca_argp_destroy(void)
ARG Parser destroy.
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_SUCCESS
Definition: doca_error.h:38
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_standard(void)
Create default, non configurable backend for application messages.
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition: doca_log.h:466
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition: doca_log.h:486
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_LOG_LEVEL_WARNING
Definition: doca_log.h:47
char dev_name[DPA_NVQUAL_DOCA_DEVINFO_IBDEV_NAME_SIZE]
bool excluded_eus[DPA_NVQUAL_MAX_EUS]