* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / source / api / fapi2phy / p5 / 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 "nr5g_mac_phy_api.h"
20 #include "fapi_vendor_extension.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_NR5G p_add_remove_bbu_cores_nr5g;
48     PADD_REMOVE_BBU_CORES p_add_remove_bbu_cores;
49
50     /* Below print is for better logging on console in debug mode. */
51     NR5G_FAPI_LOG(INFO_LOG, (""));
52
53     if (NULL == p_fapi_req) {
54         NR5G_FAPI_LOG(ERROR_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE] Invalid fapi message"));
55         return FAILURE;
56     }
57
58     p_list_elem = nr5g_fapi_fapi2phy_create_api_list_elem(
59         (uint8_t)MSG_TYPE_PHY_ADD_REMOVE_CORE, 1, (uint32_t) sizeof(ADD_REMOVE_BBU_CORES_NR5G));
60
61     if (!p_list_elem) {
62         NR5G_FAPI_LOG(ERROR_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE] Unable to create "
63                 "list element. Out of memory!!!"));
64         return FAILURE;
65     }
66
67     p_add_remove_bbu_cores_nr5g = (PADD_REMOVE_BBU_CORES_NR5G) (p_list_elem + 1);
68     p_add_remove_bbu_cores_nr5g->sMsgHdr.nMessageType = MSG_TYPE_PHY_ADD_REMOVE_CORE;
69     p_add_remove_bbu_cores_nr5g->sMsgHdr.nMessageLen = sizeof(ADD_REMOVE_BBU_CORES_NR5G);
70
71     p_add_remove_bbu_cores = &p_add_remove_bbu_cores_nr5g->sAddRemoveBbuCores;
72     for (i = 0; i < FAPI_MAX_NUM_SET_CORE_MASK; ++i)
73     {
74         for (k = 0; k < FAPI_MAX_MASK_OPTIONS; ++k)
75         {
76             p_add_remove_bbu_cores->nCoreMask[k][i] = p_fapi_req->add_remove_core_info.nCoreMask[k][i];
77         }
78     }
79     for (i = 0; i < FAPI_NUM_SPLIT_OPTIONS; ++i)
80     {
81         p_add_remove_bbu_cores->nMacOptions[i] = p_fapi_req->add_remove_core_info.nMacOptions[i];
82     }
83     for(k = 0; k < FAPI_MAX_NUM_CELLS; ++k) {
84         for(i = 0; i < FAPI_MAX_GROUP_NUM; ++i) {
85             p_add_remove_bbu_cores->nPuschInterOptions[k][i] = p_fapi_req->add_remove_core_info.nPuschInterOptions[k][i];
86         }
87     }
88     p_add_remove_bbu_cores->eOption = (BBUPOOL_CORE_OPERATION)p_fapi_req->add_remove_core_info.eOption;
89
90     nr5g_fapi_fapi2phy_add_to_api_list(is_urllc, p_list_elem);
91
92     NR5G_FAPI_LOG(INFO_LOG, ("[FAPI_VENDOR_EXT_ADD_REMOVE_CORE.message]"));
93
94     return SUCCESS;
95 }
96 #endif