NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
urom_rdmo.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 <stdint.h>
27 #include <stdlib.h>
28 
29 #include <doca_argp.h>
30 
31 #include "urom_rdmo_core.h"
32 
33 DOCA_LOG_REGISTER(UROM::RDMO);
34 
35 /*
36  * UROM RDMO application main function
37  *
38  * @argc [in]: command line arguments size
39  * @argv [in]: array of command line arguments
40  * @return: EXIT_SUCCESS on success and EXIT_FAILURE otherwise
41  */
42 int main(int argc, char **argv)
43 {
45  struct rdmo_cfg rdmo_cfg = {0};
46  struct doca_log_backend *sdk_log;
47  int exit_status = EXIT_FAILURE;
48 
49  /* Register a logger backend */
51  if (result != DOCA_SUCCESS)
52  goto app_exit;
53 
54  /* Register a logger backend for internal SDK errors and warnings */
56  if (result != DOCA_SUCCESS)
57  goto app_exit;
58 
60  if (result != DOCA_SUCCESS)
61  goto app_exit;
62 
64  if (result != DOCA_SUCCESS) {
65  DOCA_LOG_ERR("Failed to init ARGP resources: %s", doca_error_get_descr(result));
66  goto app_exit;
67  }
68 
70  if (result != DOCA_SUCCESS) {
71  DOCA_LOG_ERR("Failed to register RDMO parameters: %s", doca_error_get_descr(result));
72  goto destroy_argp;
73  }
74 
75  result = doca_argp_start(argc, argv);
76  if (result != DOCA_SUCCESS) {
77  DOCA_LOG_ERR("Failed to parse application input: %s", doca_error_get_descr(result));
78  goto destroy_argp;
79  }
80 
83  else if (rdmo_cfg.mode == RDMO_MODE_CLIENT)
85  else
87 
88  if (result != DOCA_SUCCESS) {
89  DOCA_LOG_ERR("Failed to start RDMO operations flow");
90  goto destroy_argp;
91  }
92 
93  exit_status = EXIT_SUCCESS;
94 
95 destroy_argp:
97 app_exit:
98  return exit_status;
99 }
#define NULL
Definition: __stddef_null.h:26
int32_t result
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_ERROR_BAD_STATE
Definition: doca_error.h:56
@ 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
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
enum rdmo_mode mode
struct urom_common_cfg common
char server_name[HOST_NAME_MAX]
char device_name[DOCA_DEVINFO_IBDEV_NAME_SIZE]
Definition: urom_common.h:41
int main(int argc, char **argv)
Definition: urom_rdmo.c:42
DOCA_LOG_REGISTER(UROM::RDMO)
doca_error_t register_urom_rdmo_params(void)
doca_error_t rdmo_client(char *server_name)
doca_error_t rdmo_server(char *device_name)
@ RDMO_MODE_CLIENT
@ RDMO_MODE_SERVER