First round of documentation cleanup for oran_e_maintenance_release_v1.0
[o-du/phy.git] / fapi_5g / source / api / fapi2mac / p7 / nr5g_fapi_proc_add_remove_core_msg.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
19 #include "fapi_vendor_extension.h"
20 #include "gnb_l1_l2_api.h"
21 #include "nr5g_fapi_common_types.h"
22 #include "nr5g_fapi_fapi2phy_api.h"
23 #include "nr5g_fapi_log.h"
24
25 /**
26  * @file
27  * This file consist of implementation of FAPI VENDOR ADD_REMOVE_CORE message.
28  *
29  **/
30
31 /** @ingroup group_source_api_p5_fapi2phy_proc
32  *
33  *  @param[in]  p_fapi_req Pointer to FAPI VENDOR ADD_REMOVE_CORE message structure.
34  *  @return     Returns ::SUCCESS and ::FAILURE.
35  *
36  *  @description
37  *  This is a timer mode specific message used to set options on bbupool cores.
38  *
39  */
40 #ifdef DEBUG_MODE
41 uint8_t nr5g_fapi_add_remove_core_message(
42     bool is_urllc,
43     fapi_vendor_ext_add_remove_core_msg_t * p_fapi_req)
44 {
45     uint32_t i, k;
46     PMAC2PHY_QUEUE_EL p_list_elem;
47     PADD_REMOVE_BBU_CORES p_add_remove_bbu_cores;
48
49     /* Below print is for better logging on console in debug mode. */
50     NR5G_FAPI_LOG(INFO_LOG, (""));
51
52     if (NULL == p_fapi_req) {
53         NR5G_FAPI_LOG(ERROR_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE] Invalid fapi message"));
54         return FAILURE;
55     }
56
57     p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem(
58         (uint8_t)MSG_TYPE_PHY_ADD_REMOVE_CORE, 1, (uint32_t) sizeof(ADD_REMOVE_BBU_CORES));
59
60     if (!p_list_elem) {
61         NR5G_FAPI_LOG(ERROR_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE] Unable to create "
62                 "list element. Out of memory!!!"));
63         return FAILURE;
64     }
65
66     p_add_remove_bbu_cores = (PADD_REMOVE_BBU_CORES) (p_list_elem + 1);
67     p_add_remove_bbu_cores->sMsgHdr.nMessageType = MSG_TYPE_PHY_ADD_REMOVE_CORE;
68     p_add_remove_bbu_cores->sMsgHdr.nMessageLen = sizeof(ADD_REMOVE_BBU_CORES);
69
70     for (i = 0; i < FAPI_MAX_NUM_SET_CORE_MASK; ++i)
71     {
72         for (k = 0; k < FAPI_MAX_MASK_OPTIONS; ++k)
73         {
74             p_add_remove_bbu_cores->nCoreMask[k][i] = p_fapi_req->add_remove_core_info.nCoreMask[k][i];
75         }
76     }
77     for (i = 0; i < FAPI_NUM_SPLIT_OPTIONS; ++i)
78     {
79         p_add_remove_bbu_cores->nMacOptions[i] = p_fapi_req->add_remove_core_info.nMacOptions[i];
80     }
81     p_add_remove_bbu_cores->eOption = (BBUPOOL_CORE_OPERATION)p_fapi_req->add_remove_core_info.eOption;
82
83     nr5g_fapi_fapi2phy_add_to_api_list(is_urllc, p_list_elem);
84
85     NR5G_FAPI_LOG(INFO_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE.message]"));
86
87     return SUCCESS;
88 }
89 #endif