1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains message handling functionality for DU cell management */
20 #include "common_def.h"
27 #include "du_app_mac_inf.h"
28 #include "du_app_rlc_inf.h"
32 #include "du_cell_mgr.h"
36 #include "AlarmInterface.h"
37 #include "ConfigInterface.h"
41 /*******************************************************************
43 * @brief Processes cells to be activated
47 * Function : duProcCellsToBeActivated
50 * - Processes cells to be activated list received in F1SetupRsp
53 * @return ROK - success
56 * ****************************************************************/
57 uint8_t duProcCellsToBeActivated(uint8_t *plmnStr, uint16_t nci, uint16_t nRPci)
60 DuCellCb *cellCb = NULLP;
61 uint8_t cfgIdx, tmpPlmn[4];
63 for(cfgIdx=0; cfgIdx<duCb.numCfgCells; cfgIdx++)
65 memset(tmpPlmn, 0, 4);
66 buildPlmnId(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.plmn, tmpPlmn);
67 if(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.cellId == nci &&
68 (strcmp((const char*)tmpPlmn, (const char*)plmnStr) == 0))
70 cellCb = duCb.cfgCellLst[cfgIdx];
75 DU_LOG("\nERROR --> DU APP : No Cell found for NCI %d", nci);
80 cellCb->cellStatus = ACTIVATION_IN_PROGRESS;
81 cellCb->cellInfo.nrPci = nRPci;
83 duCb.actvCellLst[duCb.numActvCells++] = cellCb;
85 if(duBuildAndSendMacCellCfg(cellCb->cellId) != ROK)
87 DU_LOG("\nERROR --> DU APP : macCellCfg build and send failed");
88 /* Delete cell from actvCellList */
89 duCb.actvCellLst[--(duCb.numActvCells)] = NULLP;
95 /*******************************************************************
97 * @brief Handles DU F1Setup Rsp received in F1AP
101 * Function : duProcF1SetupRsp
104 * - Handles DU F1Setup Rsp received in F1AP
106 * @params[in] Pointer to F1SetupRsp
109 ******************************************************************/
110 void duProcF1SetupRsp()
112 DU_LOG("\nINFO --> DU_APP : F1 Setup Response received");
113 duCb.f1Status = TRUE; //Set F1 status as true
116 /*******************************************************************
118 * @brief Handles GNB DU Cfg Update Ack received in F1AP
122 * Function : duProcGnbDuCfgUpdAckMsg
125 * - Handles GNB DU Cfg Update Ack received in F1AP
127 * @params[in] Pointer to F1GnbDuCfgUpdAck
130 ******************************************************************/
131 void duProcGnbDuCfgUpdAckMsg()
133 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
135 /*******************************************************************
137 * @brief Returns cellCb based on cell ID
141 * Function : duGetCellCb
143 * Functionality: Returns DU APP CellCb based on cell ID
145 * @params[in] F1AP_PDU_t ASN decoded F1AP message
146 * @return ROK - success
149 * ****************************************************************/
150 uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb)
153 for(cellIdx=0; cellIdx<duCb.numActvCells; cellIdx++)
155 if(duCb.actvCellLst[cellIdx]->cellId == cellId)
156 *cellCb = duCb.actvCellLst[cellIdx];
162 DU_LOG("\nERROR --> DU APP : Cell Id %d not found in DU APP", cellId);
169 /*******************************************************************
171 * @brief Handles cell up indication from MAC
175 * Function : duHandleCellUpInd
178 * Handles cell up indication from MAC
180 * @params[in] Post structure pointer
182 * @return ROK - success
185 * ****************************************************************/
186 uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId)
188 DuCellCb *cellCb = NULLP;
190 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
192 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleCellUpInd()", cellId->cellId);
196 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
199 if((cellCb != NULL) && (cellCb->cellStatus == ACTIVATION_IN_PROGRESS))
201 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is UP", cellId->cellId);
202 cellCb->cellStatus = ACTIVATED;
203 gCellStatus = CELL_UP;
206 DU_LOG("\nINFO --> DU APP : Raise cell UP alarm for cell id=%d", cellId->cellId);
207 raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId);
208 setCellOpState(cellId->cellId, ENABLED, ACTIVE);
212 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
213 DU_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
217 /**********************************************************************
219 **********************************************************************/