* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / nr5g_fapi.c
1 /******************************************************************************
2 *
3 *   Copyright (c) 2021 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18 #include <pthread.h>
19
20 #include "nr5g_fapi_std.h"
21 #include "nr5g_fapi_common_types.h"
22 #include "nr5g_fapi_args.h"
23 #include "nr5g_fapi_config_loader.h"
24 #include "nr5g_fapi_dpdk.h"
25 #include "nr5g_fapi_framework.h"
26 #include "nr5g_fapi_cmd.h"
27
28 int main(
29     int argc,
30     char **argv)
31 {
32     const char *config_file = NULL;
33     p_nr5g_fapi_cfg_t config = NULL;
34
35     if (NULL == (config_file = nr5g_fapi_parse_args(argc, argv))) {
36         NR5G_FAPI_LOG(ERROR_LOG, ("Config file parsing error"));
37         exit(1);
38     }
39
40     if (NULL == (config = nr5g_fapi_config_loader(argv[0], config_file))) {
41         NR5G_FAPI_LOG(ERROR_LOG, ("Config file loading error"));
42         exit(1);
43     }
44
45     nr5g_fapi_dpdk_init(config);
46
47     if (FAILURE == nr5g_fapi_framework_init(config)) {
48         NR5G_FAPI_LOG(ERROR_LOG, ("ORAN_5G_FAPI init failed"));
49         exit(1);
50     }
51     NR5G_FAPI_LOG(INFO_LOG, ("ORAN_5G_FAPI init successful"));
52
53     nr5g_fapi_cmgr((void *)config);
54     nr5g_fapi_dpdk_wait(config);
55     pthread_attr_destroy(&config->phy2mac_thread_params.thread_info.thread_attr);
56     pthread_attr_destroy(&config->mac2phy_thread_params.thread_info.thread_attr);
57     if (config->is_urllc_enabled)
58     {
59         pthread_attr_destroy(&config->urllc_phy2mac_thread_params.thread_info.thread_attr);
60         pthread_attr_destroy(&config->urllc_mac2phy_thread_params.thread_info.thread_attr);
61     }
62
63     free(config);
64     return 0;
65 }