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 "CmInterface.h"
41 DuMacCellDeleteReq packMacCellDeleteReqOpts[] =
43 packDuMacCellDeleteReq, /* Loose coupling */
44 MacProcCellDeleteReq, /* TIght coupling */
45 packDuMacCellDeleteReq /* Light weight-loose coupling */
48 /*******************************************************************
50 * @brief Processes cells to be activated
54 * Function : duProcCellsToBeActivated
57 * - Processes cells to be activated list received in F1SetupRsp
60 * @return ROK - success
63 * ****************************************************************/
64 uint8_t duProcCellsToBeActivated(uint8_t *plmnStr, uint16_t nci, uint16_t nRPci)
67 DuCellCb *cellCb = NULLP;
68 uint8_t cfgIdx, tmpPlmn[4];
70 for(cfgIdx=0; cfgIdx<duCb.numCfgCells; cfgIdx++)
72 memset(tmpPlmn, 0, 4);
73 buildPlmnId(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.plmn, tmpPlmn);
74 if(duCb.cfgCellLst[cfgIdx]->cellInfo.nrEcgi.cellId == nci &&
75 (strcmp((const char*)tmpPlmn, (const char*)plmnStr) == 0))
77 cellCb = duCb.cfgCellLst[cfgIdx];
82 DU_LOG("\nERROR --> DU APP : No Cell found for NCI %d", nci);
87 cellCb->cellStatus = ACTIVATION_IN_PROGRESS;
88 cellCb->cellInfo.nrPci = nRPci;
90 duCb.actvCellLst[cellCb->cellId -1] = cellCb;
93 if(duBuildAndSendMacCellCfg(cellCb->cellId) != ROK)
95 DU_LOG("\nERROR --> DU APP : macCellCfg build and send failed");
96 /* Delete cell from actvCellList */
97 duCb.actvCellLst[cellCb->cellId -1] = NULLP;
98 --(duCb.numActvCells);
104 /*******************************************************************
106 * @brief Handles DU F1Setup Rsp received in F1AP
110 * Function : duProcF1SetupRsp
113 * - Handles DU F1Setup Rsp received in F1AP
115 * @params[in] Pointer to F1SetupRsp
118 ******************************************************************/
119 void duProcF1SetupRsp()
121 DU_LOG("\nINFO --> DU_APP : F1 Setup Response received");
122 duCb.f1Status = TRUE; //Set F1 status as true
125 /*******************************************************************
127 * @brief Returns cellCb based on cell ID
131 * Function : duGetCellCb
133 * Functionality: Returns DU APP CellCb based on cell ID
135 * @params[in] F1AP_PDU_t ASN decoded F1AP message
136 * @return ROK - success
139 * ****************************************************************/
140 uint8_t duGetCellCb(uint16_t cellId, DuCellCb **cellCb)
143 for(cellIdx=0; cellIdx < MAX_NUM_CELL; cellIdx++)
145 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == cellId))
147 *cellCb = duCb.actvCellLst[cellIdx];
154 DU_LOG("\nERROR --> DU APP : Cell Id %d not found in DU APP", cellId);
161 /*****************************************************************
162 * @brief Handles slot indication from MAC
166 * Function : duHandleSlotInd
169 * Handles slot indication from MAC
171 * @params[in] Post structure pointer
172 * SlotTimingInfo *slotIndInfo
173 * @return ROK - success
177 *****************************************************************/
178 uint8_t duHandleSlotInd(Pst *pst, SlotTimingInfo *slotIndInfo)
180 uint8_t cellIdx = 0, ret = ROK;
185 GET_CELL_IDX(slotIndInfo->cellId, cellIdx);
186 duCellCb = duCb.actvCellLst[cellIdx];
190 duCellCb->currSlotInfo.sfn = slotIndInfo->sfn;
191 duCellCb->currSlotInfo.slot = slotIndInfo->slot;
195 DU_LOG("\nERROR --> DU APP : CellId[%d] doesnot exist", slotIndInfo->cellId);
198 DU_FREE_SHRABL_BUF(pst->region, pst->pool, slotIndInfo, sizeof(SlotTimingInfo));
202 DU_LOG("\nERROR --> DU APP : Recevied null pointer from MAC");
207 /*******************************************************************
209 * @brief Handles cell up indication from MAC
213 * Function : duHandleCellUpInd
216 * Handles cell up indication from MAC
218 * @params[in] Post structure pointer
220 * @return ROK - success
223 * ****************************************************************/
224 uint8_t duHandleCellUpInd(Pst *pst, OduCellId *cellId)
226 DuCellCb *cellCb = NULLP;
230 /*Note: Static Configuration, when O1 is not configuring the RRM policy*/
231 RrmPolicy *rrmPolicy;
232 DU_ALLOC(rrmPolicy, sizeof(RrmPolicy));
233 rrmPolicy->rsrcType = RSRC_PRB;
234 rrmPolicy->numMemberList = 1;
235 DU_ALLOC(rrmPolicy->memberList, sizeof(PolicyMemberList *));
236 DU_ALLOC(rrmPolicy->memberList[0], sizeof(PolicyMemberList));
238 memset(&rrmPolicy->memberList[0]->plmn, 0, sizeof(Plmn));
239 rrmPolicy->memberList[0]->snssai.sst = 1;
240 rrmPolicy->memberList[0]->snssai.sd[0] = 2;
241 rrmPolicy->memberList[0]->snssai.sd[1] = 3;
242 rrmPolicy->memberList[0]->snssai.sd[2] = 4;
243 rrmPolicy->policyMinRatio = 30;
244 rrmPolicy->policyMaxRatio = 90;
245 rrmPolicy->policyDedicatedRatio = 10;
248 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
250 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleCellUpInd()", cellId->cellId);
254 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
257 if((cellCb != NULL) && (cellCb->cellStatus == ACTIVATION_IN_PROGRESS))
259 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is UP", cellId->cellId);
260 cellCb->cellStatus = ACTIVATED;
261 gCellStatus = CELL_UP;
264 if(duCfgParam.tempSliceCfg.rrmPolicy)
265 BuildAndSendSliceConfigReq(duCfgParam.tempSliceCfg.rrmPolicy, duCfgParam.tempSliceCfg.totalRrmPolicy, duCfgParam.tempSliceCfg.totalSliceCount);
266 DU_LOG("\nINFO --> DU APP : Raise cell UP alarm for cell id=%d", cellId->cellId);
267 raiseCellAlrm(CELL_UP_ALARM_ID, cellId->cellId);
268 setCellOpState(cellId->cellId, ENABLED, ACTIVE);
270 BuildAndSendSliceConfigReq(&rrmPolicy,1, rrmPolicy->numMemberList);
275 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
276 DU_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
280 /*******************************************************************
282 * @brief Handle Cell delete response from MAC
286 * Function : DuProcMacCellDeleteRsp
288 * Functionality: Handle Cell delete response from MAC
290 * @params[in] Pointer to MacCellDeleteRsp and Pst
291 * @return ROK - success
294 * ****************************************************************/
296 uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *deleteRsp)
303 if(deleteRsp->result == SUCCESSFUL_RSP)
305 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
306 DU_LOG("\nINFO --> DU APP : MAC CELL Delete Response : SUCCESS [CELL IDX : %d]", deleteRsp->cellId);
307 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == deleteRsp->cellId))
309 memset(duCb.actvCellLst[cellIdx], 0, sizeof(DuCellCb));
310 gCellStatus = CELL_DOWN;
313 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", deleteRsp->cellId);
314 raiseCellAlrm(CELL_DOWN_ALARM_ID, deleteRsp->cellId);
315 setCellOpState(deleteRsp->cellId, DISABLED, INACTIVE);
320 DU_FREE(duCb.actvCellLst[cellIdx], sizeof(DuCellCb));
325 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): CellId [%d] doesnot exist", deleteRsp->cellId);
331 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): MAC CELL Delete Response : FAILED\
332 [CELL IDX : %d]", deleteRsp->cellId);
335 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacCellDeleteRsp));
339 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): Received MAC cell delete response is NULL");
345 /*******************************************************************
347 * @brief Sending Cell Delete Req To Mac
351 * Function : sendCellDeleteReqToMac
354 * sending Cell Delete Req To Mac
356 * @params[in] uint16_t cellId
357 * @return ROK - success
361 *****************************************************************/
363 uint8_t sendCellDeleteReqToMac(uint16_t cellId)
367 MacCellDelete *cellDelete = NULLP;
369 DU_ALLOC_SHRABL_BUF(cellDelete, sizeof(MacCellDelete));
372 cellDelete->cellId = cellId;
373 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_DELETE_REQ);
375 DU_LOG("\nINFO --> DU APP : Sending Cell Delete Request to MAC");
376 /* Processing one Cell at a time to MAC */
377 ret = (*packMacCellDeleteReqOpts[pst.selector])(&pst, cellDelete);
380 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to send Cell delete Req to MAC");
381 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDelete));
386 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to allocate memory");
392 /*******************************************************************
394 * @brief DU preocess Cell Delete Req to MAC
398 * Function : duSendCellDeletReq
400 * Functionality: DU process Cell Delete Req to MAC
402 * @params[in] uint16_t cellId
403 * @return ROK - success
406 * ****************************************************************/
408 uint8_t duSendCellDeletReq(uint16_t cellId)
410 uint16_t cellIdx = 0;
411 DU_LOG("\nINFO --> DU APP : Processing Cell Delete Request ");
412 GET_CELL_IDX(cellId, cellIdx);
414 if(duCb.actvCellLst[cellIdx] == NULLP)
416 DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellId[%d] is not found", cellId);
420 if(duCb.actvCellLst[cellIdx]->cellId != cellId)
422 DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellId[%d] is not found", cellId);
427 if(duCb.actvCellLst[cellIdx]->cellStatus != DELETION_IN_PROGRESS)
429 DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): CellStatus[%d] of cellId[%d] is not correct.\
430 Expected CellStatus is DELETION_IN_PROGRESS",duCb.actvCellLst[cellIdx]->cellStatus, cellId);
434 if(duBuildAndSendMacCellStop(cellId) == RFAILED)
436 DU_LOG("\nERROR --> DU APP : duSendCellDeletReq(): Failed to build and send cell stop request to MAC for\
444 /**********************************************************************
446 **********************************************************************/