Merge "Documentation fixes"
[o-du/l2.git] / src / du_app / du_cell_mgr.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
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 /* This file contains message handling functionality for DU cell management */
20 #include "common_def.h"
21 #include "lrg.h"
22 #include "legtp.h"
23 #include "lrg.x"
24 #include "lkw.x"
25 #include "rgr.h"
26 #include "rgr.x"
27 #include "du_app_mac_inf.h"
28 #include "du_app_rlc_inf.h"
29 #include "du_cfg.h"
30 #include "du_mgr.h"
31 #include "du_cell_mgr.h"
32
33 /*******************************************************************
34  *
35  * @brief Processes cells to be activated
36  *
37  * @details
38  *
39  *    Function : duProcCellsToBeActivated
40  *
41  *    Functionality:
42  *      - Processes cells to be activated list received in F1SetupRsp
43  *
44  * @params[in] void
45  * @return ROK     - success
46  *         RFAILED - failure
47  *
48  * ****************************************************************/
49 uint8_t duProcCellsToBeActivated(uint8_t *plmnStr, uint16_t nci, uint16_t nRPci)
50 {
51    uint8_t ret = ROK;
52    DuCellCb *cellCb = NULLP;
53    uint8_t cfgIdx, tmpPlmn[4];
54
55    for(cfgIdx=0; cfgIdx<duCb.numCfgCells; cfgIdx++)
56    {
57       memset(tmpPlmn, 0, 4);
58       buildPlmnId(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.plmn, tmpPlmn);
59       if(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.cellId == nci &&
60             (strcmp((const char*)tmpPlmn, (const char*)plmnStr) == 0))
61       {
62          cellCb = duCb.cfgCellLst[cfgIdx];
63          break;
64       }
65       else
66       {
67          DU_LOG("\nDU APP : No Cell found for NCI %d", nci);
68          return RFAILED;
69       }
70    }
71
72    cellCb->cellStatus = ACTIVATION_IN_PROGRESS; 
73    cellCb->cellInfo.nrPci = nRPci;
74
75    duCb.actvCellLst[duCb.numActvCells++] = cellCb;
76
77    if(duBuildAndSendMacCellCfg(cellCb->cellId) != ROK)
78    {
79       DU_LOG("\nDU APP : macCellCfg build and send failed");
80       /* Delete cell from actvCellList */
81       duCb.actvCellLst[--(duCb.numActvCells)] = NULLP;
82       ret = RFAILED;
83    }
84    return ret;
85 }
86
87 /*******************************************************************
88  *
89  * @brief Handles DU F1Setup Rsp received in F1AP
90  *
91  * @details
92  *
93  *    Function : duProcF1SetupRsp
94  *
95  *    Functionality:
96  *      - Handles DU F1Setup Rsp received in F1AP
97  *
98  * @params[in] Pointer to F1SetupRsp 
99  * @return void
100  *
101  ******************************************************************/
102 void duProcF1SetupRsp()
103 {
104    DU_LOG("\nDU_APP : F1 Setup Response received");
105    duCb.f1Status = TRUE; //Set F1 status as true
106 }
107
108 /*******************************************************************
109  *
110  * @brief Handles GNB DU Cfg Update Ack received in F1AP
111  *
112  * @details
113  *
114  *    Function : duProcGnbDuCfgUpdAckMsg
115  *
116  *    Functionality:
117  *      - Handles GNB DU Cfg Update Ack received in F1AP
118  *
119  * @params[in] Pointer to F1GnbDuCfgUpdAck
120  * @return void
121  *  
122  ******************************************************************/
123 void duProcGnbDuCfgUpdAckMsg()
124 {
125    DU_LOG("\nDU APP: GNB-DU config update Ack received ");
126 }
127 /*******************************************************************
128 *
129 * @brief Returns cellCb based on cell ID
130 *
131 * @details
132 *
133 *    Function : duGetCellCb
134 *
135 *    Functionality: Returns DU APP CellCb based on cell ID
136 *
137 * @params[in] F1AP_PDU_t ASN decoded F1AP message
138 * @return ROK     - success
139 *         RFAILED - failure
140 *
141 * ****************************************************************/
142 uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb)
143 {
144    uint8_t cellIdx;
145    for(cellIdx=0; cellIdx<duCb.numActvCells; cellIdx++)
146    {
147       if(duCb.actvCellLst[cellIdx]->cellId == cellId)
148          *cellCb = duCb.actvCellLst[cellIdx];
149          break;
150    }
151
152    if(!*cellCb)
153    {
154       DU_LOG("\nDU APP : Cell Id %d not found in DU APP", cellId);
155       return RFAILED;
156    }
157
158    return ROK;
159 }
160
161 /**********************************************************************
162   End of file
163  **********************************************************************/