NVIDIA DOCA SDK
Data Center on a Chip Framework Documentation
pe_single_task_comp_cb_main.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 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 <stdlib.h>
27
28
#include <
doca_error.h
>
29
#include <
doca_log.h
>
30
31
DOCA_LOG_REGISTER
(PE_SINGLE_TASK_COMP_CB::MAIN);
32
33
/* Sample's Logic */
34
doca_error_t
run_pe_single_task_comp_cb_sample
(
void
);
35
36
/*
37
* Sample main function
38
*
39
* @argc [in]: command line arguments size
40
* @argv [in]: array of command line arguments
41
* @return: EXIT_SUCCESS on success and EXIT_FAILURE otherwise
42
*/
43
int
main
(
int
argc,
char
*argv[])
44
{
45
(void)(argc);
46
(void)(argv);
47
48
doca_error_t
result
;
49
struct
doca_log_backend *sdk_log;
50
int
exit_status = EXIT_FAILURE;
51
52
/* Register a logger backend */
53
result
=
doca_log_backend_create_standard
();
54
if
(
result
!=
DOCA_SUCCESS
)
55
return
EXIT_FAILURE;
56
57
/* Register a logger backend for internal SDK errors and warnings */
58
result
=
doca_log_backend_create_with_file_sdk
(stderr, &sdk_log);
59
if
(
result
!=
DOCA_SUCCESS
)
60
goto
sample_exit;
61
result
=
doca_log_backend_set_sdk_level
(sdk_log,
DOCA_LOG_LEVEL_WARNING
);
62
if
(
result
!=
DOCA_SUCCESS
)
63
goto
sample_exit;
64
65
DOCA_LOG_INFO
(
"Starting the sample"
);
66
67
/* Run the sample's core function */
68
result
=
run_pe_single_task_comp_cb_sample
();
69
if
(
result
!=
DOCA_SUCCESS
) {
70
DOCA_LOG_ERR
(
"run_pe_single_task_comp_cb_sample() encountered an error: %s"
,
71
doca_error_get_descr
(
result
));
72
goto
sample_exit;
73
}
74
75
exit_status = EXIT_SUCCESS;
76
77
sample_exit:
78
if
(exit_status == EXIT_SUCCESS)
79
DOCA_LOG_INFO
(
"Sample finished successfully"
);
80
else
81
DOCA_LOG_INFO
(
"Sample finished with errors"
);
82
return
exit_status;
83
}
result
int32_t result
Definition:
app_shield_agent_core.h:3
doca_error.h
doca_log.h
doca_error_t
enum doca_error doca_error_t
DOCA API return codes.
doca_error_get_descr
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
DOCA_SUCCESS
@ DOCA_SUCCESS
Definition:
doca_error.h:38
doca_log_backend_create_standard
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_standard(void)
Create default, non configurable backend for application messages.
DOCA_LOG_ERR
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
Definition:
doca_log.h:466
DOCA_LOG_INFO
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
Definition:
doca_log.h:486
doca_log_backend_create_with_file_sdk
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_log_backend_set_sdk_level
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
@ DOCA_LOG_LEVEL_WARNING
Definition:
doca_log.h:47
main
int main(int argc, char *argv[])
Definition:
pe_single_task_comp_cb_main.c:43
DOCA_LOG_REGISTER
DOCA_LOG_REGISTER(PE_SINGLE_TASK_COMP_CB::MAIN)
run_pe_single_task_comp_cb_sample
doca_error_t run_pe_single_task_comp_cb_sample(void)
Definition:
pe_single_task_comp_cb_sample.c:208
samples
doca_common
pe_single_task_comp_cb
pe_single_task_comp_cb_main.c
Generated on Wed Aug 13 2025 09:23:36 for NVIDIA DOCA SDK by
1.9.1