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 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
38 #include "AlarmInterface.h"
39 #include "CmInterface.h"
42 DuMacDlCcchInd packMacDlCcchIndOpts[] =
44 packMacDlCcchInd, /* Loose coupling */
45 MacProcDlCcchInd, /* TIght coupling */
46 packMacDlCcchInd /* Light weight-loose coupling */
49 DuMacUeCreateReq packMacUeCreateReqOpts[] =
51 packDuMacUeCreateReq, /* Loose coupling */
52 MacProcUeCreateReq, /* TIght coupling */
53 packDuMacUeCreateReq /* Light weight-loose coupling */
56 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
58 packDuRlcUeCreateReq, /* Loose coupling */
59 RlcProcUeCreateReq, /* TIght coupling */
60 packDuRlcUeCreateReq /* Light weight-loose coupling */
63 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
65 packDlRrcMsgToRlc, /* Loose coupling */
66 RlcProcDlRrcMsgTransfer, /* Tight coupling */
67 packDlRrcMsgToRlc /* Light weight-loose coupling */
70 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
72 packDuRlcUeReconfigReq, /* Loose coupling */
73 RlcProcUeReconfigReq, /* TIght coupling */
74 packDuRlcUeReconfigReq /* Light weight-loose coupling */
77 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
79 packDuMacUeReconfigReq, /* Loose coupling */
80 MacProcUeReconfigReq, /* TIght coupling */
81 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
86 packRlcDlUserDataToRlc, /* Loose coupling */
87 RlcProcDlUserDataTransfer, /* Tight coupling */
88 packRlcDlUserDataToRlc /* Light weight-loose coupling */
91 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
93 packDuMacUeDeleteReq, /* Loose coupling */
94 MacProcUeDeleteReq, /* TIght coupling */
95 packDuMacUeDeleteReq /* Light weight-loose coupling */
98 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
100 packDuRlcUeDeleteReq, /* Loose coupling */
101 RlcProcUeDeleteReq, /* TIght coupling */
102 packDuRlcUeDeleteReq /* Light weight-loose coupling */
105 /******************************************************************
107 * @brief Function to return Drb LcId
111 * Function : getDrbLcId
113 * Functionality: Function to return Drb LcId
115 * @params[in] drbBitMap
117 * Returns: lcId - SUCCESS
119 *****************************************************************/
121 uint8_t getDrbLcId(uint32_t *drbBitMap)
123 uint8_t bitMask = 1, bitPos = 0;
124 bitPos = MIN_DRB_LCID;
126 while(bitPos <= MAX_DRB_LCID)
128 if((*drbBitMap & (bitMask << bitPos)) == 0)
130 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
138 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
142 /*******************************************************************
144 * @brief Function to fillDlUserDataInfo
148 * Function : fillDlUserDataInfo
151 * Function to fillDlUserDataInfo
156 * @return ROK - success
159 * ****************************************************************/
161 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
165 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
166 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
168 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
170 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
172 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
173 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
174 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
182 /*******************************************************************
184 * @brief Build and Send DL Data Message transfer to RLC
188 * Function : duBuildAndSendDlUserDataToRlc
191 * Build and Send DL Data Message transfer to RLC
193 * @params[in] Cell ID
195 * Logical Channgel ID
198 * @return ROK - success
201 * ****************************************************************/
203 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
205 uint8_t ret = RFAILED;
207 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
209 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
212 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
215 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
216 dlDataMsgInfo->dlMsg = egtpMsg->msg;
217 dlDataMsgInfo->msgLen = msgLen;
219 /* Filling DL DATA Msg Info */
220 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
222 /* Filling post structure and sending msg */
223 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
224 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
225 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
226 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
230 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
231 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
232 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
237 /*******************************************************************
239 * @brief Handles EGTP data from CU
243 * Function : duHdlEgtpData
246 * Processes EGTP header and sends data to RLC
248 * @params[in] Pointer to EGTP Message
249 * @return ROK - success
252 * ****************************************************************/
253 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
257 #ifdef CALL_FLOW_DEBUG_LOG
258 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
261 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
265 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
268 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
269 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
271 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
277 /******************************************************************
279 * @brief Builds and Sends DL CCCH Ind to MAC
283 * Function : duBuildAndSendDlCcchInd
285 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
287 * @params[in] dlCcchMsg - uint8_t*
288 * @return ROK - success
291 * ****************************************************************/
292 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
293 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
297 DlCcchIndInfo *dlCcchIndInfo = NULLP;
300 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
302 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
306 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
310 dlCcchIndInfo->cellId = *cellId;
311 dlCcchIndInfo->crnti = *crnti;
312 dlCcchIndInfo->msgType = msgType;
313 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
315 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
316 if(!dlCcchIndInfo->dlCcchMsg)
318 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
319 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
322 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
324 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
326 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
329 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
330 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
333 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
334 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
335 dlCcchIndInfo->dlCcchMsgLen);
336 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
337 sizeof(DlCcchIndInfo));
345 /*******************************************************************
347 * @brief Build and Send DL RRC Message transfer to RLC
351 * Function : duBuildAndSendDlRrcMsgToRlc
354 * Build and Send DL RRC Message transfer to RLC
356 * @params[in] Cell ID
358 * Logical Channgel ID
361 * @return ROK - success
364 * ****************************************************************/
365 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
370 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
374 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
378 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
381 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
382 duBuildAndSendDlRrcMsgToRlc");
383 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
387 /* Filling up the RRC msg info */
388 dlRrcMsgInfo->cellId = cellId;
389 dlRrcMsgInfo->ueId = ueCfg.ueId;
390 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
392 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
394 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
395 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
396 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
397 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
401 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
402 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
403 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
404 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
406 /* Filling post structure and sending msg */
407 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
408 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
409 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
412 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
413 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
422 /******************************************************************
424 * @brief Process DL RRC Msg recevied from F1AP
428 * Function : duProcDlRrcMsg
430 * Functionality: Process DL RRC Msg recevied from F1AP
432 * @params[in] dlCcchMsg - uint8_t*
433 * @return ROK - success
436 * ****************************************************************/
438 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
441 uint16_t crnti, cellId, cellIdx;
442 bool ueCcchCtxtFound = false;
443 bool ueFound = false;
447 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
449 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
451 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
453 ueCcchCtxtFound = true;
454 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
455 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
462 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
465 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
469 if(duCb.actvCellLst[cellId-1] == NULLP)
471 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
474 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
476 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
479 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
480 duCb.ueCcchCtxt[ueIdx].cellId);
485 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
492 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
494 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
496 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
497 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
500 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
501 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
510 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
517 /******************************************************************
519 * @brief Generates GNB DU Ue F1AP ID
523 * Function : genGnbDuUeF1apId
525 * Functionality: Generates GNB DU Ue F1AP ID
528 * @return gnbDuF1apId
530 * ****************************************************************/
531 int32_t genGnbDuUeF1apId(uint8_t cellId)
535 GET_CELL_IDX(cellId, cellIdx);
536 if(duCb.actvCellLst[cellIdx])
538 return ++duCb.gnbDuUeF1apIdGenerator;
542 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
547 /******************************************************************
549 * @brief Processes UL CCCH Ind recvd from MAC
553 * Function : duProcUlCcchInd
555 * Functionality: Processes UL CCCH Ind recvd from MAC
557 * @params[in] UlCcchIndInfo *ulCcchIndInfo
558 * @return ROK - success
561 * ****************************************************************/
562 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
566 int32_t gnbDuUeF1apId = 0;
568 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
570 if(gnbDuUeF1apId == -1)
572 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
576 /* Store Ue mapping */
577 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
578 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
579 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
583 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
584 ulCcchIndInfo->ulCcchMsg));
587 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
590 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
591 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
597 /******************************************************************
599 * @brief Fills Default UL LC Cfg
603 * Function : fillDefaultUlLcCfg
605 * Functionality: Fills Default UL LC Cfg
607 * @params[in] UlLcCfg *ulLcCfg
609 *****************************************************************/
610 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
612 ulLcCfg->priority = LC_PRIORITY_1;
613 ulLcCfg->lcGroup = 0;
614 ulLcCfg->schReqId = 0;
615 ulLcCfg->pbr = PBR_KBPS_INFINITY;
616 ulLcCfg->bsd = BSD_MS_1000;
619 /******************************************************************
621 * @brief Fills Initial DL Bandwidth Part
625 * Function : fillDefaultInitDlBwp
627 * Functionality: Fills Initial DL Bandwidth Part
629 * @params[in] InitialDlBwp *initDlBwp
630 * @return ROK - success
633 *****************************************************************/
634 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
637 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
638 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
642 /* Filling PDCCH Config */
643 initDlBwp->pdcchPresent = TRUE;
644 if(initDlBwp->pdcchPresent)
646 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
647 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
648 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
650 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
651 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
652 coreset0EndPrb = CORESET0_END_PRB;
653 coreset1StartPrb = coreset0EndPrb +6;
654 coreset1NumPrb = CORESET1_NUM_PRB;
655 /* calculate the PRBs */
656 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
657 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
659 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
660 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
661 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
662 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
664 initDlBwp->pdcchCfg.numCRsetToRel = 0;
666 /* Filling Serach Space */
667 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
668 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
669 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
671 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
672 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
673 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
674 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
675 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
676 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
677 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
678 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
680 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
682 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
684 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
687 /* Filling PDSCH Config */
688 initDlBwp->pdschPresent = TRUE;
689 if(initDlBwp->pdschPresent)
691 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
692 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
694 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
697 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
698 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
699 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
700 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
703 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
704 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
706 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
709 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
710 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
711 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
712 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
713 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
714 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
716 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
717 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
718 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
719 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
726 /******************************************************************
728 * @brief Fills Initial UL Bandwidth Part
732 * Function : fillDefaultInitUlBwp
734 * Functionality: Fills Initial UL Bandwidth Part
736 * @params[in] InitialUlBwp *initUlBwp
739 *****************************************************************/
740 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
745 initUlBwp->pucchPresent = FALSE;
747 /*Filling PUSCH Config */
748 initUlBwp->puschPresent = TRUE;
749 if(initUlBwp->puschPresent)
751 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
752 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
753 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
754 scramblingId0 = SCRAMBLING_ID;
755 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
756 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
758 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
760 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
761 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
763 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
764 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
765 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
766 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
769 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
770 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
771 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
772 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
773 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
774 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
776 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
781 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
785 /******************************************************************
787 * @brief Fills SpCell Group Info
791 * Function : fillDefaultSpCellGrpInfo
793 * Functionality: Fills Sp Cell Group Info
795 * @params[in] MacUeCfg *macUeCfg
796 * @return ROK - Success
799 *****************************************************************/
800 uint8_t fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
802 SpCellCfg *spCell = NULL;
805 spCell = &macUeCfg->spCellCfg;
809 macUeCfg->spCellCfgPres = true;
811 spCell->servCellIdx = SERV_CELL_IDX;
812 /* Filling Initial Dl Bwp */
813 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
815 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
819 spCell->servCellCfg.numDlBwpToAdd = 0;
820 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
821 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
822 spCell->servCellCfg.bwpInactivityTmr = NULLP;
823 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
824 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
825 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
826 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
827 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
829 /* Filling Initial UL Bwp*/
830 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
831 spCell->servCellCfg.numUlBwpToAdd = 0;
832 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
836 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
842 /******************************************************************
844 * @brief Fills Physical Cell Group Info
848 * Function : fillDefaultPhyCellGrpInfo
850 * Functionality: Fills Physical Cell Group Info
852 * @params[in] MacUeCfg *macUeCfg
855 *****************************************************************/
856 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
858 PhyCellGrpCfg *cellGrp = NULL;
861 cellGrp = &macUeCfg->phyCellGrpCfg;
865 macUeCfg->phyCellGrpCfgPres = true;
866 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
867 cellGrp->pNrFr1 = P_NR_FR1;
871 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
875 /******************************************************************
877 * @brief Fills Mac Cell Group Info
881 * Function : fillDefaultMacCellGrpInfo
883 * Functionality: Fills Mac Cell Group Info
885 * @params[in] MacUeCfg *macUeCfg
888 *****************************************************************/
889 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
892 MacCellGrpCfg *cellGrp = NULL;
895 cellGrp = &macUeCfg->macCellGrpCfg;
899 macUeCfg->macCellGrpCfgPres = true;
901 /* Filling Scheduling Request Config */
902 cellGrp->schReqCfg.addModListCount = 1;
903 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
905 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
907 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
908 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
909 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
912 cellGrp->schReqCfg.relListCount = 0;
914 /* Filling Tag config */
915 cellGrp->tagCfg.addModListCount = 1;
916 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
918 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
920 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
921 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
924 cellGrp->tagCfg.relListCount = 0;
926 /* Filling BSR config */
927 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
928 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
929 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
931 /* Filling PHR config */
932 cellGrp->phrCfgSetupPres = true;
933 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
934 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
935 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
936 cellGrp->phrCfg.multiplePHR = false;
937 cellGrp->phrCfg.dummy = false;
938 cellGrp->phrCfg.phrType2OtherCell = false;
939 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
944 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
948 /*******************************************************************
950 * @brief Fills default modulation info for a UE
954 * Function : fillDefaultModulation
956 * Functionality: Fills default modulation info for a UE
958 * @params[in] Pointer to MAC UE configuration
959 * @return ROK - success
962 * ****************************************************************/
963 void fillDefaultModulation(MacUeCfg *ueCfg)
965 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
966 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
967 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
969 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
970 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
971 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
974 /******************************************************************
976 * @brief Function to fill Mac Lc Cfg for SRB1
980 * Function : fillMacSrb1LcCfg
982 * Functionality: Function to fill Mac Lc cfg for SRB1
984 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
986 *****************************************************************/
988 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
990 macLcCfg->lcId = SRB1_LCID;
991 macLcCfg->configType = CONFIG_ADD;
992 macLcCfg->drbQos = NULLP;
993 macLcCfg->snssai = NULLP;
994 macLcCfg->ulLcCfgPres = true;
995 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
998 /******************************************************************
1000 * @brief Function to fill the Lc cfg from ueSetupReqDb
1004 * Function : fillMacLcCfgToAddMod
1006 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1008 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1009 * @return ROK/RFAILED
1011 *****************************************************************/
1013 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1019 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1020 macLcCfgToSend->configType = ueLcCfgDb->configType;
1022 if(ueLcCfgDb->drbQos)
1023 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1025 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1027 macLcCfgToSend->drbQos = NULL;
1029 if(ueLcCfgDb->snssai)
1030 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1032 macLcCfgToSend->snssai = oldLcCfg->snssai;
1034 macLcCfgToSend->snssai = NULL;
1036 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1037 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1038 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1043 oldLcCfg->lcId = ueLcCfgDb->lcId;
1044 oldLcCfg->configType = ueLcCfgDb->configType;
1046 if(ueLcCfgDb->drbQos)
1048 if(oldLcCfg->drbQos)
1049 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1051 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1052 if(oldLcCfg->drbQos == NULL)
1054 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1057 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1060 if(ueLcCfgDb->snssai)
1062 if(oldLcCfg->snssai)
1063 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1065 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1066 if(oldLcCfg->snssai == NULL)
1068 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1069 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1072 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1075 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1076 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1077 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1082 /******************************************************************
1084 * @brief Function to copy the Bit rate from ueSetupReqDb
1088 * Function : fillAmbr
1090 * Functionality: Function to copy bit Rate from ueSetupReqDb
1092 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1093 * @return ROK/RFAILED
1095 *****************************************************************/
1097 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1103 *macAmbrCfgToSend = ueDbAmbr;
1105 else if(oldMacAmbrCfg)
1106 *macAmbrCfgToSend = *oldMacAmbrCfg;
1116 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1118 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1119 if(*oldMacAmbrCfg == NULLP)
1121 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1124 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1125 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1133 /******************************************************************
1135 * @brief Builds and Send UE ReConfig Request to MAC
1139 * Function : sendUeReCfgReqToMac
1141 * Functionality: Builds and Send UE ReConfig Request to MAC
1143 * @Params[in] MacUeCfg pointer
1144 * @return ROK - success
1147 * ****************************************************************/
1149 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1155 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1159 /* Processing one Ue at a time to MAC */
1160 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1161 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1164 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1165 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1170 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1178 /******************************************************************
1180 * @brief Fills MacUeCfg structure
1184 * Function : fillMacUeCfg
1186 * Functionality: Fills MacUeCfg
1188 * @params[in] cellId, ueId, crnti,
1191 * @return ROK/RFAILED
1193 *****************************************************************/
1194 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1196 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1197 bool lcIdFound = false;
1198 MacUeCfg *duMacDb = NULLP;
1200 macUeCfg->cellId = cellId;
1203 GET_UE_ID(crnti, macUeCfg->ueId);
1204 macUeCfg->crnti = crnti;
1206 macUeCfg->duUeF1apId = gnbDuUef1apId;
1210 fillDefaultMacCellGrpInfo(macUeCfg);
1211 fillDefaultPhyCellGrpInfo(macUeCfg);
1213 if((fillDefaultSpCellGrpInfo(macUeCfg)) != ROK)
1215 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1219 macUeCfg->ambrCfg = NULLP;
1220 fillDefaultModulation(macUeCfg);
1221 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1226 /* Fetching MacDb from DuUeCb.
1227 * In case of UE hand-in, UE context is created before RRC setup. Hence
1228 * crnti is not known yet. Thus, passing crnti=0 to this function.
1229 * In such a case actvCellLst doesnt yet have any entry for this UE. So
1230 * duMacDb will be NULL.
1234 GET_CELL_IDX(cellId, cellIdx);
1235 if(duCb.actvCellLst[cellIdx])
1236 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1239 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1242 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1245 if(ueCfgDb->cellGrpCfg)
1247 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1250 if(macUeCfg->spCellCfgPres == true)
1252 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1254 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1255 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1257 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1259 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1260 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1265 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1267 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1269 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1274 fillDefaultMacCellGrpInfo(macUeCfg);
1275 fillDefaultPhyCellGrpInfo(macUeCfg);
1276 fillDefaultSpCellGrpInfo(macUeCfg);
1277 fillDefaultModulation(macUeCfg);
1280 /* Filling LC Context */
1281 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1283 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1285 /* Filling default UL LC config in MAC if not present */
1286 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1287 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1292 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1294 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1297 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1298 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1300 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1301 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1302 &duMacDb->lcCfgList[lcIdx], FALSE);
1312 /* ADD/DEL CONFIG */
1313 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1321 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1324 }/*End of Outer FOR loop */
1325 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1330 /******************************************************************
1332 * @brief Fills Rlc AM Information
1336 * Function : fillDefaultAmInfo
1338 * Functionality: Fills Rlc AM Information
1340 * @params[in] AmBearerCfg *amCfg
1343 *****************************************************************/
1344 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1347 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1348 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1349 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1350 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1351 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1354 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1355 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1356 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1359 /******************************************************************
1361 * @brief Fills RLC UM Bi Directional Information
1365 * Function : fillDefaultUmBiInfo
1367 * Functionality: Fills RLC UM Bi Directional Information
1369 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1372 *****************************************************************/
1373 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1375 /* UL UM BI DIR INFO */
1376 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1377 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1379 /* DL UM BI DIR INFO */
1380 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1383 /******************************************************************
1385 * @brief Fills RLC UM Uni Directional UL Information
1389 * Function : fillDefaultUmUlInfo
1391 * Functionality: Fills RLC UM Uni Directional Info
1393 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1396 *****************************************************************/
1397 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1399 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1400 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1403 /******************************************************************
1405 * @brief Fills RLC UM Uni Directional DL Information
1409 * Function : fillDefaultUmDlInfo
1411 * Functionality: Fills RLC UM Uni Directional DL Info
1413 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1416 *****************************************************************/
1417 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1419 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1422 /******************************************************************
1424 * @brief Builds Rlc Mode Default Configuration
1428 * Function : fillDefaultRlcModeCfg
1430 * Functionality: Builds Rlc Mode Default Configuration
1432 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1433 * @return ROK/RFAILED
1435 *****************************************************************/
1437 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1447 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1449 fillDefaultAmInfo(lcCfg->u.amCfg);
1452 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1458 case RLC_UM_BI_DIRECTIONAL :
1460 if(!lcCfg->u.umBiDirCfg)
1462 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1463 if(lcCfg->u.umBiDirCfg)
1464 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1467 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1473 case RLC_UM_UNI_DIRECTIONAL_UL :
1475 if(!lcCfg->u.umUniDirUlCfg)
1477 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1478 if(lcCfg->u.umUniDirUlCfg)
1479 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1482 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1488 case RLC_UM_UNI_DIRECTIONAL_DL :
1490 if(!lcCfg->u.umUniDirDlCfg)
1492 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1493 if(lcCfg->u.umUniDirDlCfg)
1494 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1497 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1504 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1511 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1517 /*******************************************************************
1519 * @brief Function to fill Rlc Lc Cfg for SRB1
1523 * Function : fillRlcSrb1LcCfg
1526 * Function to fill Rlc Lc Cfg for SRB1
1528 * @params[in] Pointer to RlcBearerCfg
1529 * @return ROK/RFAILED
1531 *****************************************************************/
1533 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1537 rlcLcCfg->rbId = SRB1_LCID;
1538 rlcLcCfg->rbType = RB_TYPE_SRB;
1539 rlcLcCfg->lcId = SRB1_LCID;
1540 rlcLcCfg->lcType = LCH_DCCH;
1541 rlcLcCfg->rlcMode = RLC_AM;
1542 rlcLcCfg->configType = CONFIG_ADD;
1543 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1544 rlcLcCfg->isLcAddModRspSent = true;
1548 /*******************************************************************
1550 * @brief Processes UE ReConfig Req to RLC UL
1554 * Function : sendUeReCfgReqToRlc
1557 * Processes UE Reconfig Req to RLC UL
1559 * @params[in] Pointer to RlcUeCfg
1560 * @return ROK - success
1563 *****************************************************************/
1565 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1570 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1573 /* Processing one Ue at a time to RLC */
1574 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1575 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1578 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1579 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1584 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1590 /******************************************************************
1592 * @brief Fills Snssai information
1596 * Function : fillSnssaiInfo
1598 * Functionality: Fills Snssai information
1600 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1602 * @return ROK - success
1605 *****************************************************************/
1606 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1611 snssaiTobeSend = snssaiDb;
1613 snssaiTobeSend = *oldSnssai;
1615 snssaiTobeSend = NULL;
1622 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1624 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1625 if(*oldSnssai == NULL)
1627 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1630 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1635 /******************************************************************
1637 * @brief Fills RlcBearerCfg structure
1641 * Function : fillRlcUeCfg
1643 * Functionality: Fills Rlc Bearer Cfg
1646 *****************************************************************/
1647 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1649 uint8_t ret, dbIdx, lcIdx, cellIdx;
1650 bool lcIdFound = false;
1651 RlcUeCfg *duRlcDb = NULLP;
1656 /* Initial RB being Added */
1657 rlcUeCfg->cellId = cellId;
1658 rlcUeCfg->ueId = ueId;
1659 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1663 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1667 /* Fetch RlcDb from DuUeCb */
1668 GET_CELL_IDX(cellId, cellIdx);
1669 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg;
1670 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1671 /*Filling RlcUeCfg */
1672 rlcUeCfg->cellId = cellId;
1673 rlcUeCfg->ueId = ueId;
1674 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1676 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1679 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1680 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1683 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1684 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1686 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1689 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1690 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1693 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1694 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1695 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1696 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1704 /* ADD/ DEL Config Type */
1705 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1706 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1714 /******************************************************************
1716 * @brief creates UE context
1720 * Function : duCreateUeCb
1722 * Functionality: Creates UE Conetxt
1724 * @params[in] UeCcchCtxt Pointer
1727 * @return ROK - success
1729 * ****************************************************************/
1730 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1732 uint8_t cellIdx = 0;
1734 uint8_t ueId = 0, ueIdx = 0;
1736 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1738 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1740 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1741 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1744 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1745 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1746 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1747 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1748 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1749 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1751 /* Filling Mac Ue Config */
1752 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
1753 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1754 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
1756 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1758 /* Filling Rlc Ue Config */
1759 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1760 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueId, \
1761 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1763 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1765 duCb.actvCellLst[cellIdx]->numActvUes++;
1766 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1773 /******************************************************************
1775 * @brief Builds and Send UE Create Request to MAC
1779 * Function : duBuildAndSendUeCreateReqToMac
1781 * Functionality: Builds and Send UE Create Request to MAC
1783 * @Params[in] cellId,
1786 * UE config extracted from F1AP msg
1787 * MAC UE config struct to be filled
1788 * @return ROK - success
1791 * ****************************************************************/
1793 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *duMacUeCfg)
1796 MacUeCfg *macUeCfg = NULLP;
1798 memset(&pst, 0, sizeof(Pst));
1801 ret = fillMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1804 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1809 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1811 /* Copying ueCb to a sharable buffer */
1812 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1815 memset(macUeCfg, 0, sizeof(MacUeCfg));
1816 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1817 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1819 /* Processing one Ue at a time to MAC */
1820 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1823 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1824 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1829 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1835 /*******************************************************************
1837 * @brief To update DuUeCb Mac Cfg
1841 * Function : duUpdateMacCfg
1842 * Functionality: update DuUeCb MAC Cfg
1844 * @params[in] DuUeCb Pointer
1845 * F1UeContextSetupDb pointer
1846 * @return ROK - success
1849 * ****************************************************************/
1850 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1852 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1853 MacUeCfg *oldMacUeCfg;
1856 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1857 if(duCb.actvCellLst[cellIdx] == NULLP)
1859 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
1862 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1864 /*Filling Cell Group Cfg*/
1865 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1868 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1870 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1871 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1873 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1875 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1876 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1878 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1879 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1882 /* Filling LC Context */
1883 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1885 numLcs = macUeCfg->numLcs;
1886 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1888 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1890 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1892 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1894 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1896 /* Free memory at matched lcIdx index */
1897 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1899 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1901 /* moving all elements one index ahead */
1902 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1903 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1906 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1913 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1915 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1918 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1928 /******************************************************************
1930 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1934 * Function : fillRlcCfgToAddMod
1936 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1939 *****************************************************************/
1941 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1943 lcCfg->configType = f1UeDbLcCfg->configType;
1944 lcCfg->rbId = f1UeDbLcCfg->rbId;
1945 lcCfg->rbType = f1UeDbLcCfg->rbType;
1946 lcCfg->lcId = f1UeDbLcCfg->lcId;
1947 lcCfg->lcType = f1UeDbLcCfg->lcType;
1948 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1950 switch(lcCfg->rlcMode)
1956 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1961 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1962 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1963 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1964 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1965 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1968 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1969 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1970 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1973 case RLC_UM_BI_DIRECTIONAL :
1975 if(!lcCfg->u.umBiDirCfg)
1977 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1978 if(!lcCfg->u.umBiDirCfg)
1981 /* UL UM BI DIR INFO */
1982 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1983 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1984 /* DL UM BI DIR INFO */
1985 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1988 case RLC_UM_UNI_DIRECTIONAL_UL :
1990 if(!lcCfg->u.umUniDirUlCfg)
1992 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1993 if(!lcCfg->u.umUniDirUlCfg)
1996 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1997 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2001 case RLC_UM_UNI_DIRECTIONAL_DL :
2003 if(!lcCfg->u.umUniDirDlCfg)
2005 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2006 if(!lcCfg->u.umUniDirDlCfg)
2009 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2013 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
2019 /*******************************************************************
2021 * @brief To update DuUeCb Rlc Lc Cfg
2025 * Function : duUpdateRlcLcCfg
2026 * Functionality: update DuUeCb Rlc Lc Cfg
2028 * @params[in] DuUeCb Pointer
2029 * F1UeContextSetupDb pointer
2030 * @return ROK - success
2033 * ****************************************************************/
2035 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2037 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2040 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2042 numLcs = rlcUeCfg->numLcs;
2043 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2045 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2047 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2049 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2052 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2055 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2057 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2059 /* Free memory at matched lcIdx index */
2060 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2062 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2064 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2065 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2067 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2070 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2077 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2079 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2082 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2091 /*******************************************************************
2093 * @brief Function to fill Tunnel Config to Add/Mod
2098 * Function : fillTnlCfgToAddMod
2100 * Functionality: Function to fill tunnel Config to Add/Mod
2102 * @params[in] Pointer to tnlCfgDb,
2103 * pointer to f1TnlCfg
2104 * @return ROK - success
2107 * ****************************************************************/
2108 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2112 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2113 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2116 if(*ueCbTnlCfg == NULLP)
2118 /* copying to DuCb Tnl Cfg */
2119 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2120 if(*ueCbTnlCfg == NULLP)
2122 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2126 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2127 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2128 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2129 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2130 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2131 if(f1TnlCfg->tnlCfg1)
2133 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2135 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2136 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2138 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2142 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2143 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2144 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2145 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2150 /*******************************************************************
2152 * @brief Processing the tunnel Request to EGTP
2156 * Function : duProcEgtpTunnelCfg
2158 * Functionality: Processing the tunnel Request to EGTP
2160 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2161 * @return ROK - success
2164 * ****************************************************************/
2166 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2168 uint8_t ret = RFAILED, delIdx;
2170 if(f1TnlCfg->tnlCfg1 == NULLP)
2172 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2176 if(f1TnlCfg->configType == CONFIG_ADD)
2178 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2180 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2187 else if(f1TnlCfg->configType == CONFIG_MOD)
2189 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2191 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2197 else if(f1TnlCfg->configType == CONFIG_DEL)
2199 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2201 /* Free memory at drbIdx */
2203 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2205 /* moving all elements one index ahead */
2206 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2212 if(duCb.upTnlCfg[delIdx])
2214 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2215 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2222 /***********************************************************************
2224 * @brief Function to fill Tunnel Config
2225 * and sends tunnel Req to EGTP
2230 * Function : duUpdateTunnelCfgDb
2232 * Functionality: Function to fill tunnel Config
2233 * and sends tunnel Cfg Req to EGTP
2235 * @params[in] ueId, cellId, DuUeCfg
2236 * @return ROK - success
2239 * ****************************************************************/
2241 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2243 uint8_t ret = ROK, drbIdx, teIdx;
2244 bool drbFound = false;
2246 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2247 /*then update drbId and tunnel Info in duCb */
2248 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2250 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2251 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2252 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2254 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2255 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2257 drbFound = true; /* existing DRB */
2258 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2260 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2261 duUeCfg->upTnlInfo[drbIdx].drbId);
2270 if(!drbFound && ret == ROK)/* new DRB to Add */
2272 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2274 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2275 duUeCfg->upTnlInfo[drbIdx].drbId);
2286 /*******************************************************************
2288 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2293 * Function : duUpdateDuUeCbCfg
2295 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2297 * @params[in] ueId, cellIdx
2298 * @return ROK - success
2301 * ****************************************************************/
2303 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2305 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2306 DuUeCb *ueCb = NULLP;
2308 GET_CELL_IDX(cellId, cellIdx);
2310 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2311 (duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2313 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2315 /*Filling RLC Ue Cfg */
2316 ueCb->rlcUeCfg.cellId = cellId;
2317 ueCb->rlcUeCfg.ueId = ueId;
2318 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2321 /*Filling MAC Ue Cfg */
2322 GET_CRNTI(crnti, ueId);
2323 ueCb->macUeCfg.cellId = cellId;
2324 ueCb->macUeCfg.ueId = ueId;
2325 ueCb->macUeCfg.crnti = crnti;
2326 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2328 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2331 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2333 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2339 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2346 /*******************************************************************
2348 * @brief Handle UE config response from MAC
2352 * Function : DuProcMacUeCfgRsp
2354 * Functionality: Handle UE Config response from MAC
2356 * @params[in] Pointer to MacUeCfgRsp and Pst
2357 * @return ROK - success
2360 * ****************************************************************/
2361 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2363 uint8_t ret = ROK, ueIdx = 0, ueId = 0;
2364 DuUeCb *ueCb = NULLP;
2368 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2370 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2372 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->duUeF1apId);
2374 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
2376 if(duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[ueIdx].gnbDuUeF1apId == cfgRsp->duUeF1apId)
2378 ueCb = &duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[ueIdx];
2379 ueCb->macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2385 if(duCb.actvCellLst[cfgRsp->cellId -1]->hoUeCb[cfgRsp->duUeF1apId-1].gnbDuUeF1apId == cfgRsp->duUeF1apId)
2387 ueCb = &duCb.actvCellLst[cfgRsp->cellId -1]->hoUeCb[cfgRsp->duUeF1apId-1];
2388 ueCb->macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2389 //TODO : in next gerrit
2390 //BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2395 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2397 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->duUeF1apId);
2398 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
2400 if(duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[ueIdx].gnbDuUeF1apId == cfgRsp->duUeF1apId)
2402 ueCb = &duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[ueIdx];
2403 ueCb->macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2410 GET_UE_ID(ueCb->crnti, ueId);
2411 if((ret = duUpdateDuUeCbCfg(ueId, cfgRsp->cellId)) == ROK)
2413 BuildAndSendUeCtxtRsp(cfgRsp->cellId, ueId);
2420 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->duUeF1apId);
2421 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2423 //TODO: Send the failure case in Ue Context Setup Response
2427 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2431 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2438 /*******************************************************************
2440 * @brief Processes UE create Req to RLC UL
2444 * Function : duBuildAndSendUeCreateReqToRlc
2447 * Processes UE create Req to RLC UL
2449 * @params[in] cellId,
2451 * Pointer to RlcUeCfg
2452 * @return ROK - success
2455 *****************************************************************/
2457 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueId, RlcUeCfg *duRlcUeCfg)
2460 RlcUeCfg *rlcUeCfg = NULLP;
2463 ret = fillRlcUeCfg(cellId, ueId, NULL, duRlcUeCfg);
2466 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2470 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2471 /* Copying ueCfg to a sharable buffer */
2472 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2475 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2476 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2477 /* Processing one Ue at a time to RLC */
2478 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2479 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2482 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2483 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2489 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2495 /*******************************************************************
2497 * @brief Processes UE create Rsp received from RLC UL
2502 * Function : DuProcRlcUeCfgRsp
2505 * Processes UE create Rsp received from RLC UL
2507 * @params[in] Post structure
2508 * Pointer to RlcCfgCfm
2509 * @return ROK - success
2512 *****************************************************************/
2513 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2519 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2521 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2523 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2524 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2525 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2527 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2529 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2530 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2531 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2532 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2534 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2540 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2541 pst->event, cfgRsp->ueId, cfgRsp->reason);
2542 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2544 //TODO: update failure case in ue Context setup Response
2548 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2552 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2558 /*******************************************************************
2560 * @brief Builds and Send Ue Reconfig Req to RLC
2564 * Function : duBuildAndSendUeReCfgReqToRLC
2566 * Functionality: Builds and Send Ue Reconfig Req to RLC
2568 * @params[in] cellId, crnti
2570 * RlcUeCfg *rlcUeCfg
2571 * @return ROK - success
2574 * ****************************************************************/
2576 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2578 uint8_t ret = ROK, ueId = 0;
2579 RlcUeCfg *rlcUeCfg = NULLP;
2581 GET_UE_ID(crnti, ueId);
2582 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2585 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2586 ret = fillRlcUeCfg(cellId, ueId, ueCfgDb, rlcUeCfg);
2588 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2590 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2594 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2600 /*******************************************************************
2602 * @brief Builds and Send Ue Reconfig Req to MAC
2606 * Function : duBuildAndSendUeReCfgReqToMac
2608 * Functionality: Builds and Send Ue Reconfig Req to MAC
2610 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2612 * MacUeCfg *macUeCfg
2613 * @return ROK - success
2616 * ****************************************************************/
2618 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2621 MacUeCfg *macUeCfg = NULLP;
2623 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2626 memset(macUeCfg, 0, sizeof(MacUeCfg));
2627 ret = fillMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, macUeCfg);
2629 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2631 ret = sendUeReCfgReqToMac(macUeCfg);
2635 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2641 /*******************************************************************
2643 * @brief Build and Send Ue context setup request
2648 * Function : duBuildAndSendUeContextSetupReq
2651 * Build and Send Ue context setup request
2653 * @params[in] cellId, crnti, DuUeCfg pointer
2654 * @return ROK - success
2657 *****************************************************************/
2659 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
2663 DuUeCfg *duUeCfg = NULLP;
2665 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2669 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
2673 crnti = ueCb->crnti;
2674 duUeCfg = &ueCb->f1UeDb->duUeCfg;
2676 /* If UE is being handed-in to this DU, UE context setup request will create
2677 * new UE context at MAC/SCH and RLC.
2678 * If UE is in active state, UE contex setup request will lead to
2679 * reconfiguration of UE at MAC/SCH and RLC
2681 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
2683 /* Filling MAC UE Config */
2684 memset(&ueCb->macUeCfg, 0, sizeof(MacUeCfg));
2686 /* Since UE attach has not yet happened, ueId and crnti is unknow. Hence
2688 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->macUeCfg);
2690 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
2694 /* Filling RLC UE Reconfig */
2695 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2697 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2699 /* Filling MAC UE Reconfig */
2700 ret = duBuildAndSendUeReCfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
2702 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2708 /*******************************************************************
2710 * @brief Processes DL Rsp received from RLC DL
2715 * Function : DuProcRlcDlRrcMsgRsp
2718 * Processes UE Rsp received from RLC DL
2720 * @params[in] Post structure
2721 * Pointer to RlcCfgCfm
2722 * @return ROK - success
2725 *****************************************************************/
2726 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2728 uint8_t ret = ROK, ueId = 0;
2729 uint16_t cellId, crnti;
2730 DuUeCb *ueCb = NULLP;
2733 state = dlRrcMsg->state;
2734 cellId = dlRrcMsg->cellId;
2735 crnti = dlRrcMsg->crnti;
2736 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2738 if(state == TRANSMISSION_COMPLETE)
2740 GET_UE_ID(crnti, ueId);
2741 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
2743 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2745 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2747 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
2749 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2752 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2754 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
2756 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2759 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2761 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2764 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2770 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2774 /*******************************************************************
2776 * @brief Process UE context setup request from CU
2780 * Function : duProcUeContextSetupRequest
2782 * Functionality: Process UE context setup request from CU
2784 * @params[in] F1AP message
2785 * @return ROK - success
2788 * ****************************************************************/
2790 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2792 uint8_t ret, cellId;
2797 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2799 /* Send DL RRC msg for security Mode */
2800 if(ueCb->f1UeDb->dlRrcMsg)
2802 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2804 /* Sending DL RRC Message to RLC */
2805 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2808 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2809 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2810 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2811 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2815 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2817 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
2820 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2826 //TODO: To send the failure cause in UeContextSetupRsp
2827 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2832 /*******************************************************************
2834 * @brief Build and Send Ue context mod request
2839 * Function : duBuildAndSendUeContextModReq
2842 * Build and Send Ue context mod request
2844 * @params[in] cellId, crnti, DuUeCfg pointer
2845 * @return ROK - success
2848 *****************************************************************/
2850 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
2854 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2855 /* Filling RLC Ue Reconfig */
2856 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2858 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2860 /* Filling MAC Ue Reconfig */
2861 ret = duBuildAndSendUeReCfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
2863 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2867 /*******************************************************************
2869 * @brief Processing Ue context mod request
2874 * Function : duProcUeContextModReq
2877 * Processing Ue context mod request
2879 * @params[in] DuUeCb *ueCb
2880 * @return ROK - success
2883 *****************************************************************/
2885 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2887 uint8_t ret, cellId;
2892 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2893 /* Send DL RRC msg for security Mode */
2894 if(ueCb->f1UeDb->dlRrcMsg)
2896 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2898 /* Sending DL RRC Message to RLC */
2899 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2902 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2903 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2904 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2905 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2909 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2911 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2914 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2918 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
2920 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
2922 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
2929 //TODO: To send the failure cause in UeContextModRsp
2931 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2937 /*******************************************************************
2939 * @brief Function to delete Pdsch ServCellCfg
2943 * Function : deletePdschServCellCfg
2945 * Functionality: Function to delete Pdsch ServCellCfg
2947 * @params[in] PdschServCellCfg *pdschServCellCfg
2950 * ****************************************************************/
2952 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2954 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2955 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2956 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2957 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2960 /*******************************************************************
2962 * @brief delete MacUeCfg from duCb
2966 * Function : deleteMacUeCfg
2968 * Functionality: delete MacUeCfg from duCb
2970 * @params[in] Pointer to MacUeCfg
2971 * @return ROK - success
2974 *******************************************************************/
2976 void deleteMacUeCfg(MacUeCfg *ueCfg)
2980 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2981 if(ueCfg->spCellCfgPres)
2983 freeUeReCfgCellGrpInfo(ueCfg);
2985 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2987 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2989 memset(ueCfg, 0, sizeof(MacUeCfg));
2992 /*******************************************************************
2994 * @brief delete UE Configuration of a particular UE
2998 * Function : deleteUeCfg
3000 * Functionality: delete UE Configuration of a particular UE
3002 * @params[in] uint16_t cellIdx, uint8_t ueId
3003 * @return ROK - success
3006 * ****************************************************************/
3007 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueId)
3010 DuUeCb *ueCb = NULLP;
3012 if(duCb.actvCellLst[cellIdx] != NULLP)
3014 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3015 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3017 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3018 deleteMacUeCfg(&ueCb->macUeCfg);
3019 deleteRlcUeCfg(&ueCb->rlcUeCfg);
3020 if(ueCb->f1UeDb !=NULLP)
3022 freeF1UeDb(ueCb->f1UeDb);
3024 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3026 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3028 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3029 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3034 duCb.actvCellLst[cellIdx]->numActvUes--;
3035 memset(ueCb, 0, sizeof(DuUeCb));
3044 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3051 /*******************************************************************
3053 * @brief Handle UE delete response from MAC
3057 * Function : DuProcMacUeDeleteRsp
3059 * Functionality: Handle UE delete response from MAC
3061 * @params[in] Pointer to MacUeDeleteRsp and Pst
3062 * @return ROK - success
3065 * ****************************************************************/
3067 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3069 uint8_t ret =ROK,ueId=0;
3071 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3075 if(deleteRsp->result == SUCCESS)
3077 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3078 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3079 if(duCb.actvCellLst[cellIdx])
3081 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3082 ueId = deleteRsp->ueId;
3083 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3084 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3085 if(deleteUeCfg(cellIdx, ueId) == ROK)
3087 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3090 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3098 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3102 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3106 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3112 /*******************************************************************
3114 * @brief Processes UE Delete Rsp received from RLC
3118 * Function : DuProcRlcUeDeleteRsp
3121 * Processes UE Delete Rsp received from RLC
3123 * @params[in] Post structure
3124 * Pointer to RlcUeDeleteRsp
3125 * @return ROK - success
3128 * *****************************************************************/
3130 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3132 uint8_t ueId = 0, ret = ROK;
3133 uint16_t cellIdx = 0,crnti=0;
3137 ueId = delRsp->ueId;
3138 GET_CELL_IDX(delRsp->cellId, cellIdx);
3140 if(delRsp->result == SUCCESSFUL)
3142 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3143 if(duCb.actvCellLst[cellIdx]!=NULLP)
3145 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3146 GET_CRNTI(crnti, ueId);
3147 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3149 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3157 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3160 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3166 /*******************************************************************
3168 * @brief Sending UE Delete Req To Mac
3172 * Function : sendUeDeleteReqToMac
3175 * sending UE Delete Req To Mac
3177 * @params[in] cellId, ueId, crnti
3178 * @return ROK - success
3181 *****************************************************************/
3183 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3187 MacUeDelete *ueDelete = NULLP;
3189 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3192 ueDelete->cellId = cellId;
3193 ueDelete->ueId = ueId;
3194 ueDelete->crnti = crnti;
3195 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3197 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3198 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3201 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3202 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3207 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3213 /*******************************************************************
3215 * @brief Sending UE Delete Req To Rlc
3219 * Function : sendUeDeleteReqToRlc
3222 * Sending UE Delete Req To Rlc
3224 * @params[in] cellId, ueId
3225 * @return ROK - success
3228 *****************************************************************/
3230 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3234 RlcUeDelete *ueDelete;
3236 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3237 if(ueDelete !=NULLP)
3239 ueDelete->cellId = cellId;
3240 ueDelete->ueId = ueId;
3241 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3243 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3246 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3247 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3252 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3258 /*******************************************************************
3260 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3264 * Function : duBuildAndSendUeDeleteReq
3266 * Functionality: DU processes UE delete req from CU and sends to MAC
3269 * @params[in] cellId, crnti
3270 * @return ROK - success
3273 * ****************************************************************/
3275 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3278 uint16_t cellIdx = 0;
3280 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3281 GET_CELL_IDX(cellId, cellIdx);
3282 GET_UE_ID(crnti, ueId);
3284 if(duCb.actvCellLst[cellIdx] != NULLP)
3286 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3288 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3292 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3293 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3295 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3301 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3308 /*******************************************************************
3310 * @brief delete RlcUeCfg from duCb
3314 * Function : deleteRlcUeCfg
3317 * delete RlcUeCfg from duCb
3319 * @params[in] RlcUeCfg *ueCfg
3321 * @return ROK - success
3324 *****************************************************************/
3326 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3329 RlcBearerCfg *lcCfg= NULLP;
3332 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3334 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3335 switch(lcCfg->rlcMode)
3339 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3342 case RLC_UM_BI_DIRECTIONAL :
3344 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3347 case RLC_UM_UNI_DIRECTIONAL_UL :
3349 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3352 case RLC_UM_UNI_DIRECTIONAL_DL :
3354 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3358 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3360 memset(ueCfg, 0, sizeof(RlcUeCfg));
3364 /*******************************************************************
3366 * @brief Du process Ue Context Release Command
3370 * Function : duProcUeContextReleaseCommand
3372 * Functionality: Du process Ue Context Release Command
3374 * @params[in] DuUeCb *duUeCb
3375 * @return ROK - success
3378 * ****************************************************************/
3379 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3381 uint8_t ret =ROK, ueId=0;
3386 crnti = duUeCb->crnti;
3387 GET_UE_ID(crnti, ueId);
3391 /* Send DL RRC msg for RRC release */
3392 if(duUeCb->f1UeDb->dlRrcMsg)
3394 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3396 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3397 duUeCb->f1UeDb->dlRrcMsg);
3400 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3401 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3402 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3403 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3410 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3413 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3420 /**********************************************************************
3422 ***********************************************************************/