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 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
167 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
169 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
171 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
172 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
173 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
181 /*******************************************************************
183 * @brief Build and Send DL Data Message transfer to RLC
187 * Function : duBuildAndSendDlUserDataToRlc
190 * Build and Send DL Data Message transfer to RLC
192 * @params[in] Cell ID
194 * Logical Channgel ID
197 * @return ROK - success
200 * ****************************************************************/
202 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
204 uint8_t ret = RFAILED;
206 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
208 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
211 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
214 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
215 dlDataMsgInfo->dlMsg = egtpMsg->msg;
216 dlDataMsgInfo->msgLen = msgLen;
218 /* Filling DL DATA Msg Info */
219 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
221 /* Filling post structure and sending msg */
222 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
223 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
224 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
225 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
229 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
230 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
231 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
236 /*******************************************************************
238 * @brief Handles EGTP data from CU
242 * Function : duHdlEgtpData
245 * Processes EGTP header and sends data to RLC
247 * @params[in] Pointer to EGTP Message
248 * @return ROK - success
251 * ****************************************************************/
252 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
256 #ifdef CALL_FLOW_DEBUG_LOG
257 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
260 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
264 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
267 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
268 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
270 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
271 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
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->ueIdx = ueCfg.ueIdx;
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]->numActvUes < MAX_NUM_UE)
471 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
474 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
475 duCb.ueCcchCtxt[ueIdx].cellId);
480 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
487 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
489 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
491 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
492 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
495 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
496 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
509 /******************************************************************
511 * @brief Generates GNB DU Ue F1AP ID
515 * Function : genGnbDuUeF1apId
517 * Functionality: Generates GNB DU Ue F1AP ID
520 * @return gnbDuF1apId
522 * ****************************************************************/
523 int32_t genGnbDuUeF1apId(uint8_t cellId)
527 GET_CELL_IDX(cellId, cellIdx);
528 if(duCb.actvCellLst[cellIdx])
530 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
534 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
539 /******************************************************************
541 * @brief Processes UL CCCH Ind recvd from MAC
545 * Function : duProcUlCcchInd
547 * Functionality: Processes UL CCCH Ind recvd from MAC
549 * @params[in] UlCcchIndInfo *ulCcchIndInfo
550 * @return ROK - success
553 * ****************************************************************/
554 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
558 int32_t gnbDuUeF1apId = 0;
560 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
562 if(gnbDuUeF1apId == -1)
564 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
568 /* Store Ue mapping */
569 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
570 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
571 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
575 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
576 ulCcchIndInfo->ulCcchMsg));
579 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
582 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
583 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
589 /******************************************************************
591 * @brief Fills Default UL LC Cfg
595 * Function : fillDefaultUlLcCfg
597 * Functionality: Fills Default UL LC Cfg
599 * @params[in] UlLcCfg *ulLcCfg
601 *****************************************************************/
602 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
604 ulLcCfg->priority = LC_PRIORITY_1;
605 ulLcCfg->lcGroup = 0;
606 ulLcCfg->schReqId = 0;
607 ulLcCfg->pbr = PBR_KBPS_INFINITY;
608 ulLcCfg->bsd = BSD_MS_1000;
611 /******************************************************************
613 * @brief Fills Initial DL Bandwidth Part
617 * Function : fillDefaultInitDlBwp
619 * Functionality: Fills Initial DL Bandwidth Part
621 * @params[in] InitialDlBwp *initDlBwp
624 *****************************************************************/
625 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
628 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
629 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
634 /* Filling PDCCH Config */
635 initDlBwp->pdcchPresent = TRUE;
636 if(initDlBwp->pdcchPresent)
638 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
639 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
640 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
642 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
643 PDCCH_CTRL_RSRC_SET_ONE_ID;
644 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
646 coreset0EndPrb = CORESET0_END_PRB;
647 coreset1StartPrb = coreset0EndPrb +6;
648 coreset1NumPrb = CORESET1_NUM_PRB;
649 /* calculate the PRBs */
650 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
651 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
654 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
655 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
656 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
657 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
658 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
660 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
663 initDlBwp->pdcchCfg.numCRsetToRel = 0;
664 /* Filling Serach Space */
665 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
666 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
667 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
669 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
670 PDCCH_SRCH_SPC_TWO_ID;
671 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
672 PDCCH_CTRL_RSRC_SET_ONE_ID;
673 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
674 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
675 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
676 MONITORING_SYMB_WITHIN_SLOT_SIZE);
677 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
678 PDCCH_SYMBOL_WITHIN_SLOT;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
683 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
687 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
689 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
690 SEARCHSPACETYPE_PR_UE_SPECIFIC;
691 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
692 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
694 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
698 /* Filling PDSCH Config */
699 initDlBwp->pdschPresent = TRUE;
700 if(initDlBwp->pdschPresent)
702 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
703 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
704 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
705 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
707 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
708 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
709 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
710 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
711 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
712 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
713 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
714 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
720 /******************************************************************
722 * @brief Fills Initial UL Bandwidth Part
726 * Function : fillDefaultInitUlBwp
728 * Functionality: Fills Initial UL Bandwidth Part
730 * @params[in] InitialUlBwp *initUlBwp
733 *****************************************************************/
734 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
739 initUlBwp->pucchPresent = FALSE;
741 /*Filling PUSCH Config */
742 initUlBwp->puschPresent = TRUE;
743 if(initUlBwp->puschPresent)
745 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
746 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
747 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
748 scramblingId0 = SCRAMBLING_ID;
749 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
750 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
752 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
754 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
755 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
757 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
758 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
759 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
760 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
763 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
764 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
765 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
766 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
767 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
768 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
770 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
775 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
779 /******************************************************************
781 * @brief Fills SpCell Group Info
785 * Function : fillDefaultSpCellGrpInfo
787 * Functionality: Fills Sp Cell Group Info
789 * @params[in] MacUeCfg *macUeCfg
792 *****************************************************************/
793 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
795 SpCellCfg *spCell = NULL;
798 spCell = &macUeCfg->spCellCfg;
802 macUeCfg->spCellCfgPres = true;
804 spCell->servCellIdx = SERV_CELL_IDX;
805 /* Filling Initial Dl Bwp */
806 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
808 spCell->servCellCfg.numDlBwpToAdd = 0;
809 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
810 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
811 spCell->servCellCfg.bwpInactivityTmr = NULLP;
812 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
813 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
814 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
815 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
816 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
817 NUM_HARQ_PROC_FOR_PDSCH_N_16;
818 /* Filling Initial UL Bwp*/
819 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
820 spCell->servCellCfg.numUlBwpToAdd = 0;
821 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
825 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
829 /******************************************************************
831 * @brief Fills Physical Cell Group Info
835 * Function : fillDefaultPhyCellGrpInfo
837 * Functionality: Fills Physical Cell Group Info
839 * @params[in] MacUeCfg *macUeCfg
842 *****************************************************************/
843 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
845 PhyCellGrpCfg *cellGrp = NULL;
848 cellGrp = &macUeCfg->phyCellGrpCfg;
852 macUeCfg->phyCellGrpCfgPres = true;
853 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
854 cellGrp->pNrFr1 = P_NR_FR1;
858 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
862 /******************************************************************
864 * @brief Fills Mac Cell Group Info
868 * Function : fillDefaultMacCellGrpInfo
870 * Functionality: Fills Mac Cell Group Info
872 * @params[in] MacUeCfg *macUeCfg
875 *****************************************************************/
876 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
879 MacCellGrpCfg *cellGrp = NULL;
882 cellGrp = &macUeCfg->macCellGrpCfg;
886 macUeCfg->macCellGrpCfgPres = true;
888 /* Filling Scheduling Request Config */
889 cellGrp->schReqCfg.addModListCount = 1;
890 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
892 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
894 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
895 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
896 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
899 cellGrp->schReqCfg.relListCount = 0;
901 /* Filling Tag config */
902 cellGrp->tagCfg.addModListCount = 1;
903 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
905 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
907 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
908 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
911 cellGrp->tagCfg.relListCount = 0;
913 /* Filling BSR config */
914 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
915 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
916 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
918 /* Filling PHR config */
919 cellGrp->phrCfgSetupPres = true;
920 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
921 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
922 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
923 cellGrp->phrCfg.multiplePHR = false;
924 cellGrp->phrCfg.dummy = false;
925 cellGrp->phrCfg.phrType2OtherCell = false;
926 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
931 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
935 /*******************************************************************
937 * @brief Fills default modulation info for a UE
941 * Function : fillDefaultModulation
943 * Functionality: Fills default modulation info for a UE
945 * @params[in] Pointer to MAC UE configuration
946 * @return ROK - success
949 * ****************************************************************/
950 void fillDefaultModulation(MacUeCfg *ueCfg)
952 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
953 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
954 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
956 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
957 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
958 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
961 /******************************************************************
963 * @brief Function to fill Mac Lc Cfg for SRB1
967 * Function : fillMacSrb1LcCfg
969 * Functionality: Function to fill Mac Lc cfg for SRB1
971 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
973 *****************************************************************/
975 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
977 macLcCfg->lcId = SRB1_LCID;
978 macLcCfg->configType = CONFIG_ADD;
979 macLcCfg->drbQos = NULLP;
980 macLcCfg->snssai = NULLP;
981 macLcCfg->ulLcCfgPres = true;
982 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
985 /******************************************************************
987 * @brief Function to fill the Lc cfg from ueSetupReqDb
991 * Function : fillMacLcCfgToAddMod
993 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
995 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
996 * @return ROK/RFAILED
998 *****************************************************************/
1000 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1006 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1007 macLcCfgToSend->configType = ueLcCfgDb->configType;
1009 if(ueLcCfgDb->drbQos)
1010 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1012 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1014 macLcCfgToSend->drbQos = NULL;
1016 if(ueLcCfgDb->snssai)
1017 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1019 macLcCfgToSend->snssai = oldLcCfg->snssai;
1021 macLcCfgToSend->snssai = NULL;
1023 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1024 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1025 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1030 oldLcCfg->lcId = ueLcCfgDb->lcId;
1031 oldLcCfg->configType = ueLcCfgDb->configType;
1033 if(ueLcCfgDb->drbQos)
1035 if(oldLcCfg->drbQos)
1036 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1038 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1039 if(oldLcCfg->drbQos == NULL)
1041 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1044 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1047 if(ueLcCfgDb->snssai)
1049 if(oldLcCfg->snssai)
1050 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1052 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1053 if(oldLcCfg->snssai == NULL)
1055 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1056 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1059 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1062 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1063 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1064 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1069 /******************************************************************
1071 * @brief Function to copy the Bit rate from ueSetupReqDb
1075 * Function : fillAmbr
1077 * Functionality: Function to copy bit Rate from ueSetupReqDb
1079 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1080 * @return ROK/RFAILED
1082 *****************************************************************/
1084 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1090 *macAmbrCfgToSend = ueDbAmbr;
1093 *macAmbrCfgToSend = *oldMacAmbrCfg;
1101 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1103 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1104 if(*oldMacAmbrCfg == NULLP)
1106 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1109 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1110 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1117 /******************************************************************
1119 * @brief Builds and Send UE ReConfig Request to MAC
1123 * Function : sendUeReCfgReqToMac
1125 * Functionality: Builds and Send UE ReConfig Request to MAC
1127 * @Params[in] MacUeCfg pointer
1128 * @return ROK - success
1131 * ****************************************************************/
1133 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1139 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1143 /* Processing one Ue at a time to MAC */
1144 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1145 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1148 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1149 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1154 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1162 /******************************************************************
1164 * @brief Fills MacUeCfg structure
1168 * Function : fillMacUeCfg
1170 * Functionality: Fills MacUeCfg
1172 * @params[in] cellId, ueIdx, crnti,
1175 * @return ROK/RFAILED
1177 *****************************************************************/
1178 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1179 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1181 uint8_t ret, dbIdx, lcIdx, cellIdx;
1182 bool lcIdFound = false;
1183 MacUeCfg *duMacDb = NULLP;
1189 macUeCfg->cellId = cellId;
1190 macUeCfg->ueIdx = ueIdx;
1191 macUeCfg->crnti = crnti;
1193 fillDefaultMacCellGrpInfo(macUeCfg);
1194 fillDefaultPhyCellGrpInfo(macUeCfg);
1195 fillDefaultSpCellGrpInfo(macUeCfg);
1196 macUeCfg->ambrCfg = NULLP;
1197 fillDefaultModulation(macUeCfg);
1198 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1203 /* Fetching MacDb from DuUeCb */
1204 GET_CELL_IDX(cellId, cellIdx);
1205 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1206 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1207 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1208 macUeCfg->cellId = cellId;
1209 macUeCfg->ueIdx = ueIdx;
1210 macUeCfg->crnti = crnti;
1211 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1214 if(macUeCfg->spCellCfgPres == true)
1216 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1218 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1219 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1221 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1223 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1224 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1227 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1228 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1231 /* Filling LC Context */
1232 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1234 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1236 /* Filling default UL LC config in MAC if not present */
1237 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1238 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1240 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1242 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1245 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1246 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1248 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1249 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1250 &duMacDb->lcCfgList[lcIdx], FALSE);
1258 /* ADD/DEL CONFIG */
1259 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1267 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1270 }/*End of Outer FOR loop */
1271 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1276 /******************************************************************
1278 * @brief Fills Rlc AM Information
1282 * Function : fillDefaultAmInfo
1284 * Functionality: Fills Rlc AM Information
1286 * @params[in] AmBearerCfg *amCfg
1289 *****************************************************************/
1290 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1293 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1294 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1295 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1296 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1297 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1300 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1301 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1302 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1305 /******************************************************************
1307 * @brief Fills RLC UM Bi Directional Information
1311 * Function : fillDefaultUmBiInfo
1313 * Functionality: Fills RLC UM Bi Directional Information
1315 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1318 *****************************************************************/
1319 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1321 /* UL UM BI DIR INFO */
1322 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1323 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1325 /* DL UM BI DIR INFO */
1326 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1329 /******************************************************************
1331 * @brief Fills RLC UM Uni Directional UL Information
1335 * Function : fillDefaultUmUlInfo
1337 * Functionality: Fills RLC UM Uni Directional Info
1339 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1342 *****************************************************************/
1343 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1345 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1346 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1349 /******************************************************************
1351 * @brief Fills RLC UM Uni Directional DL Information
1355 * Function : fillDefaultUmDlInfo
1357 * Functionality: Fills RLC UM Uni Directional DL Info
1359 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1362 *****************************************************************/
1363 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1365 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1368 /******************************************************************
1370 * @brief Builds Rlc Mode Default Configuration
1374 * Function : fillDefaultRlcModeCfg
1376 * Functionality: Builds Rlc Mode Default Configuration
1378 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1379 * @return ROK/RFAILED
1381 *****************************************************************/
1383 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1393 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1395 fillDefaultAmInfo(lcCfg->u.amCfg);
1398 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1404 case RLC_UM_BI_DIRECTIONAL :
1406 if(!lcCfg->u.umBiDirCfg)
1408 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1409 if(lcCfg->u.umBiDirCfg)
1410 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1413 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1419 case RLC_UM_UNI_DIRECTIONAL_UL :
1421 if(!lcCfg->u.umUniDirUlCfg)
1423 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1424 if(lcCfg->u.umUniDirUlCfg)
1425 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1428 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1434 case RLC_UM_UNI_DIRECTIONAL_DL :
1436 if(!lcCfg->u.umUniDirDlCfg)
1438 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1439 if(lcCfg->u.umUniDirDlCfg)
1440 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1443 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1450 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1457 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1463 /*******************************************************************
1465 * @brief Function to fill Rlc Lc Cfg for SRB1
1469 * Function : fillRlcSrb1LcCfg
1472 * Function to fill Rlc Lc Cfg for SRB1
1474 * @params[in] Pointer to RlcBearerCfg
1475 * @return ROK/RFAILED
1477 *****************************************************************/
1479 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1483 rlcLcCfg->rbId = SRB1_LCID;
1484 rlcLcCfg->rbType = RB_TYPE_SRB;
1485 rlcLcCfg->lcId = SRB1_LCID;
1486 rlcLcCfg->lcType = LCH_DCCH;
1487 rlcLcCfg->rlcMode = RLC_AM;
1488 rlcLcCfg->configType = CONFIG_ADD;
1489 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1493 /*******************************************************************
1495 * @brief Processes UE ReConfig Req to RLC UL
1499 * Function : sendUeReCfgReqToRlc
1502 * Processes UE Reconfig Req to RLC UL
1504 * @params[in] Pointer to RlcUeCfg
1505 * @return ROK - success
1508 *****************************************************************/
1510 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1515 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1518 /* Processing one Ue at a time to RLC */
1519 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1520 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1523 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1524 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1529 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1535 /******************************************************************
1537 * @brief Fills Snssai information
1541 * Function : fillSnssaiInfo
1543 * Functionality: Fills Snssai information
1545 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1547 * @return ROK - success
1550 *****************************************************************/
1551 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1556 snssaiTobeSend = snssaiDb;
1558 snssaiTobeSend = *oldSnssai;
1560 snssaiTobeSend = NULL;
1567 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1569 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1570 if(*oldSnssai == NULL)
1572 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1575 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1580 /******************************************************************
1582 * @brief Fills RlcBearerCfg structure
1586 * Function : fillRlcUeCfg
1588 * Functionality: Fills Rlc Bearer Cfg
1591 *****************************************************************/
1592 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1593 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1595 uint8_t ret, dbIdx, lcIdx, cellIdx;
1596 bool lcIdFound = false;
1597 RlcUeCfg *duRlcDb = NULLP;
1602 /* Initial RB being Added */
1603 rlcUeCfg->cellId = cellId;
1604 rlcUeCfg->ueIdx = ueIdx;
1605 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1609 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1613 /* Fetch RlcDb from DuUeCb */
1614 GET_CELL_IDX(cellId, cellIdx);
1615 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1616 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1617 /*Filling RlcUeCfg */
1618 rlcUeCfg->cellId = cellId;
1619 rlcUeCfg->ueIdx = ueIdx;
1620 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1622 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1625 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1626 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1629 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1630 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1632 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1635 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1636 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1639 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1640 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1641 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1642 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1650 /* ADD/ DEL Config Type */
1651 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1652 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1660 /******************************************************************
1662 * @brief creates UE context
1666 * Function : duCreateUeCb
1668 * Functionality: Creates UE Conetxt
1670 * @params[in] UeCcchCtxt Pointer
1673 * @return ROK - success
1675 * ****************************************************************/
1676 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1678 uint8_t cellIdx = 0;
1682 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1684 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1686 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1687 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1689 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1690 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1691 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1692 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1693 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1694 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1696 /* Filling Mac Ue Config */
1697 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1698 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1699 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1701 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1703 /* Filling Rlc Ue Config */
1704 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1705 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1706 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1708 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1710 duCb.actvCellLst[cellIdx]->numActvUes++;
1711 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1718 /******************************************************************
1720 * @brief Builds and Send UE Create Request to MAC
1724 * Function : duBuildAndSendUeCreateReqToMac
1726 * Functionality: Builds and Send UE Create Request to MAC
1728 * @Params[in] cellId,
1730 * @return ROK - success
1733 * ****************************************************************/
1735 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1736 uint16_t crnti, MacUeCfg *duMacUeCfg)
1739 MacUeCfg *macUeCfg = NULLP;
1741 memset(&pst, 0, sizeof(Pst));
1744 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1747 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1751 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1753 /* Copying ueCb to a sharable buffer */
1754 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1757 memset(macUeCfg, 0, sizeof(MacUeCfg));
1758 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1759 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1761 /* Processing one Ue at a time to MAC */
1762 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1765 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1766 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1771 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1777 /*******************************************************************
1779 * @brief To update DuUeCb Mac Cfg
1783 * Function : duUpdateMacCfg
1784 * Functionality: update DuUeCb MAC Cfg
1786 * @params[in] DuUeCb Pointer
1787 * F1UeContextSetupDb pointer
1788 * @return ROK - success
1791 * ****************************************************************/
1792 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1794 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1795 MacUeCfg *oldMacUeCfg;
1798 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1799 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1801 /*Filling Cell Group Cfg*/
1802 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1805 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1807 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1808 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1810 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1812 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1813 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1815 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1816 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1819 /* Filling LC Context */
1820 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1822 numLcs = macUeCfg->numLcs;
1823 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1825 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1827 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1829 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1831 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1833 /* Free memory at matched lcIdx index */
1834 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1836 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1838 /* moving all elements one index ahead */
1839 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1840 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1843 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1850 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1852 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1855 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1865 /******************************************************************
1867 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1871 * Function : fillRlcCfgToAddMod
1873 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1876 *****************************************************************/
1878 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1880 lcCfg->configType = f1UeDbLcCfg->configType;
1881 lcCfg->rbId = f1UeDbLcCfg->rbId;
1882 lcCfg->rbType = f1UeDbLcCfg->rbType;
1883 lcCfg->lcId = f1UeDbLcCfg->lcId;
1884 lcCfg->lcType = f1UeDbLcCfg->lcType;
1885 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1887 switch(lcCfg->rlcMode)
1893 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1898 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1899 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1900 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1901 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1902 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1905 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1906 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1907 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1910 case RLC_UM_BI_DIRECTIONAL :
1912 if(!lcCfg->u.umBiDirCfg)
1914 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1915 if(!lcCfg->u.umBiDirCfg)
1918 /* UL UM BI DIR INFO */
1919 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1920 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1921 /* DL UM BI DIR INFO */
1922 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1925 case RLC_UM_UNI_DIRECTIONAL_UL :
1927 if(!lcCfg->u.umUniDirUlCfg)
1929 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1930 if(!lcCfg->u.umUniDirUlCfg)
1933 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1934 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1938 case RLC_UM_UNI_DIRECTIONAL_DL :
1940 if(!lcCfg->u.umUniDirDlCfg)
1942 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1943 if(!lcCfg->u.umUniDirDlCfg)
1946 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1950 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1956 /*******************************************************************
1958 * @brief To update DuUeCb Rlc Lc Cfg
1962 * Function : duUpdateRlcLcCfg
1963 * Functionality: update DuUeCb Rlc Lc Cfg
1965 * @params[in] DuUeCb Pointer
1966 * F1UeContextSetupDb pointer
1967 * @return ROK - success
1970 * ****************************************************************/
1972 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1974 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1977 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1979 numLcs = rlcUeCfg->numLcs;
1980 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1982 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1984 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1986 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1989 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1992 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
1994 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1996 /* Free memory at matched lcIdx index */
1997 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1999 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2001 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2002 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2004 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2007 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2014 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2016 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2019 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2028 /*******************************************************************
2030 * @brief Function to fill Tunnel Config to Add/Mod
2035 * Function : fillTnlCfgToAddMod
2037 * Functionality: Function to fill tunnel Config to Add/Mod
2039 * @params[in] Pointer to tnlCfgDb,
2040 * pointer to f1TnlCfg
2041 * @return ROK - success
2044 * ****************************************************************/
2045 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2049 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2050 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2053 if(*ueCbTnlCfg == NULLP)
2055 /* copying to DuCb Tnl Cfg */
2056 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2057 if(*ueCbTnlCfg == NULLP)
2059 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2063 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2064 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2065 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2066 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2067 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2068 if(f1TnlCfg->tnlCfg1)
2070 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2072 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2073 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2075 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2079 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2080 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2081 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2082 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2087 /*******************************************************************
2089 * @brief Processing the tunnel Request to EGTP
2093 * Function : duProcEgtpTunnelCfg
2095 * Functionality: Processing the tunnel Request to EGTP
2097 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2098 * @return ROK - success
2101 * ****************************************************************/
2103 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2105 uint8_t ret = RFAILED, delIdx;
2107 if(f1TnlCfg->tnlCfg1 == NULLP)
2109 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2113 if(f1TnlCfg->configType == CONFIG_ADD)
2115 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2117 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2124 else if(f1TnlCfg->configType == CONFIG_MOD)
2126 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2128 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2134 else if(f1TnlCfg->configType == CONFIG_DEL)
2136 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2138 /* Free memory at drbIdx */
2140 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2142 /* moving all elements one index ahead */
2143 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2149 if(duCb.upTnlCfg[delIdx])
2151 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2152 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2159 /***********************************************************************
2161 * @brief Function to fill Tunnel Config
2162 * and sends tunnel Req to EGTP
2167 * Function : duUpdateTunnelCfgDb
2169 * Functionality: Function to fill tunnel Config
2170 * and sends tunnel Cfg Req to EGTP
2172 * @params[in] ueIdx, cellId, DuUeCfg
2173 * @return ROK - success
2176 * ****************************************************************/
2178 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2180 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2181 bool drbFound = false;
2183 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2184 /*then update drbId and tunnel Info in duCb */
2185 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2187 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2188 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2189 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2191 if((duCb.upTnlCfg[duCbDrbIdx]->ueIdx == duUeCfg->upTnlInfo[drbIdx].ueIdx) && \
2192 (duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2194 drbFound = true; /* existing DRB */
2195 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2197 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2198 duUeCfg->upTnlInfo[drbIdx].drbId);
2207 if(!drbFound && ret == ROK)/* new DRB to Add */
2209 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2211 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2212 duUeCfg->upTnlInfo[drbIdx].drbId);
2223 /*******************************************************************
2225 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2230 * Function : duUpdateDuUeCbCfg
2232 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2234 * @params[in] ueIdx, cellIdx
2235 * @return ROK - success
2238 * ****************************************************************/
2240 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2242 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2243 DuUeCb *ueCb = NULLP;
2245 GET_CELL_IDX(cellId, cellIdx);
2247 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2248 macUeCfgState == UE_RECFG_COMPLETE) &&
2249 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2250 rlcUeCfgState == UE_RECFG_COMPLETE))
2252 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2254 /*Filling RLC Ue Cfg */
2255 ueCb->rlcUeCfg.cellId = cellId;
2256 ueCb->rlcUeCfg.ueIdx = ueIdx;
2257 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2260 /*Filling MAC Ue Cfg */
2261 GET_CRNTI(crnti, ueIdx);
2262 ueCb->macUeCfg.cellId = cellId;
2263 ueCb->macUeCfg.ueIdx = ueIdx;
2264 ueCb->macUeCfg.crnti = crnti;
2265 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2267 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2270 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2272 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2278 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2285 /*******************************************************************
2287 * @brief Handle UE config response from MAC
2291 * Function : DuProcMacUeCfgRsp
2293 * Functionality: Handle UE Config response from MAC
2295 * @params[in] Pointer to MacUeCfgRsp and Pst
2296 * @return ROK - success
2299 * ****************************************************************/
2300 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2306 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2308 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2310 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2311 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2312 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2314 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2316 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2317 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2318 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2319 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2321 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2327 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2328 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2330 //TODO: Send the failure case in Ue Context Setup Response
2334 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2338 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2345 /*******************************************************************
2347 * @brief Processes UE create Req to RLC UL
2351 * Function : duBuildAndSendUeCreateReqToRlc
2354 * Processes UE create Req to RLC UL
2356 * @params[in] cellId,
2358 * Pointer to RlcUeCfg
2359 * @return ROK - success
2362 *****************************************************************/
2364 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2365 RlcUeCfg *duRlcUeCfg)
2368 RlcUeCfg *rlcUeCfg = NULLP;
2371 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2374 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2378 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2379 /* Copying ueCfg to a sharable buffer */
2380 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2383 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2384 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2385 /* Processing one Ue at a time to RLC */
2386 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2387 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2390 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2391 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2397 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2403 /*******************************************************************
2405 * @brief Processes UE create Rsp received from RLC UL
2410 * Function : DuProcRlcUeCfgRsp
2413 * Processes UE create Rsp received from RLC UL
2415 * @params[in] Post structure
2416 * Pointer to RlcCfgCfm
2417 * @return ROK - success
2420 *****************************************************************/
2421 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2427 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2429 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2431 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2432 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2433 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2435 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2437 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2438 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2439 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2440 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2442 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2448 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2449 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2450 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2452 //TODO: update failure case in ue Context setup Response
2456 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2460 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2466 /*******************************************************************
2468 * @brief Builds and Send Ue Reconfig Req to RLC
2472 * Function : duBuildAndSendUeReCfgReqToRLC
2474 * Functionality: Builds and Send Ue Reconfig Req to RLC
2476 * @params[in] cellId, crnti
2478 * RlcUeCfg *rlcUeCfg
2479 * @return ROK - success
2482 * ****************************************************************/
2484 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2486 uint8_t ret = ROK, ueIdx = 0;
2487 RlcUeCfg *rlcUeCfg = NULLP;
2489 GET_UE_IDX(crnti, ueIdx);
2490 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2493 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2494 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2496 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2498 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2502 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2508 /*******************************************************************
2510 * @brief Builds and Send Ue Reconfig Req to MAC
2514 * Function : duBuildAndSendUeReCfgReqToMac
2516 * Functionality: Builds and Send Ue Reconfig Req to MAC
2518 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2520 * MacUeCfg *macUeCfg
2521 * @return ROK - success
2524 * ****************************************************************/
2526 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2528 uint8_t ret, ueIdx = 0;
2529 MacUeCfg *macUeCfg = NULLP;
2532 GET_UE_IDX(crnti, ueIdx);
2534 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2537 memset(macUeCfg, 0, sizeof(MacUeCfg));
2538 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2540 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2542 ret = sendUeReCfgReqToMac(macUeCfg);
2546 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2552 /*******************************************************************
2554 * @brief Build and Send Ue context setup request
2559 * Function : duBuildAndSendUeContextSetupReq
2562 * Build and Send Ue context setup request
2564 * @params[in] cellId, crnti, DuUeCfg pointer
2565 * @return ROK - success
2568 *****************************************************************/
2570 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2574 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2575 /* Filling RLC Ue Reconfig */
2576 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2578 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2580 /* Filling MAC Ue Reconfig */
2581 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2583 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2588 /*******************************************************************
2590 * @brief Processes DL Rsp received from RLC DL
2595 * Function : DuProcRlcDlRrcMsgRsp
2598 * Processes UE Rsp received from RLC DL
2600 * @params[in] Post structure
2601 * Pointer to RlcCfgCfm
2602 * @return ROK - success
2605 *****************************************************************/
2606 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2608 uint8_t ret = ROK, ueIdx = 0;
2609 uint16_t cellId, crnti;
2610 DuUeCb *ueCb = NULLP;
2613 state = dlRrcMsg->state;
2614 cellId = dlRrcMsg->cellId;
2615 crnti = dlRrcMsg->crnti;
2616 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2618 if(state == TRANSMISSION_COMPLETE)
2620 GET_UE_IDX(crnti, ueIdx);
2621 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2623 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2625 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2627 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2629 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2632 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2634 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2636 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2639 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2641 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2644 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2650 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2654 /*******************************************************************
2656 * @brief Process UE context setup request from CU
2660 * Function : duProcUeContextSetupRequest
2662 * Functionality: Process UE context setup request from CU
2664 * @params[in] F1AP message
2665 * @return ROK - success
2668 * ****************************************************************/
2670 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2672 uint8_t ret, cellId;
2677 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2678 /* Send DL RRC msg for security Mode */
2679 if(ueCb->f1UeDb->dlRrcMsg)
2681 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2683 /* Sending DL RRC Message to RLC */
2684 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2687 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2688 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2689 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2690 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2694 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2696 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2699 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2705 //TODO: To send the failure cause in UeContextSetupRsp
2706 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2711 /*******************************************************************
2713 * @brief Build and Send Ue context mod request
2718 * Function : duBuildAndSendUeContextModReq
2721 * Build and Send Ue context mod request
2723 * @params[in] cellId, crnti, DuUeCfg pointer
2724 * @return ROK - success
2727 *****************************************************************/
2729 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2733 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2734 /* Filling RLC Ue Reconfig */
2735 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2737 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2739 /* Filling MAC Ue Reconfig */
2740 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2742 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2746 /*******************************************************************
2748 * @brief Processing Ue context mod request
2753 * Function : duProcUeContextModReq
2756 * Processing Ue context mod request
2758 * @params[in] DuUeCb *ueCb
2759 * @return ROK - success
2762 *****************************************************************/
2764 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2766 uint8_t ret, cellId;
2771 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2772 /* Send DL RRC msg for security Mode */
2773 if(ueCb->f1UeDb->dlRrcMsg)
2775 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2777 /* Sending DL RRC Message to RLC */
2778 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2781 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2782 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2783 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2784 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2790 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2793 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2799 //TODO: To send the failure cause in UeContextModRsp
2800 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2805 /*******************************************************************
2807 * @brief Function to delete Pdsch ServCellCfg
2811 * Function : deletePdschServCellCfg
2813 * Functionality: Function to delete Pdsch ServCellCfg
2815 * @params[in] PdschServCellCfg *pdschServCellCfg
2818 * ****************************************************************/
2820 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2822 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2823 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2824 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2825 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2828 /*******************************************************************
2830 * @brief delete MacUeCfg from duCb
2834 * Function : deleteMacUeCfg
2836 * Functionality: delete MacUeCfg from duCb
2838 * @params[in] Pointer to MacUeCfg
2839 * @return ROK - success
2842 *******************************************************************/
2844 void deleteMacUeCfg(MacUeCfg *ueCfg)
2848 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2849 if(ueCfg->spCellCfgPres)
2851 freeUeReCfgCellGrpInfo(ueCfg);
2853 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2855 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2857 memset(ueCfg, 0, sizeof(MacUeCfg));
2860 /*******************************************************************
2862 * @brief delete UE Configuration of a particular UE
2866 * Function : deleteUeCfg
2868 * Functionality: delete UE Configuration of a particular UE
2870 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2871 * @return ROK - success
2874 * ****************************************************************/
2875 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2878 DuUeCb *ueCb = NULLP;
2880 if(duCb.actvCellLst[cellIdx] != NULLP)
2882 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2883 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2885 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2886 deleteMacUeCfg(&ueCb->macUeCfg);
2887 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2888 if(ueCb->f1UeDb !=NULLP)
2890 freeF1UeDb(ueCb->f1UeDb);
2892 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2894 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2896 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2897 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2902 duCb.actvCellLst[cellIdx]->numActvUes--;
2903 memset(ueCb, 0, sizeof(DuUeCb));
2912 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2919 /*******************************************************************
2921 * @brief Handle UE delete response from MAC
2925 * Function : DuProcMacUeDeleteRsp
2927 * Functionality: Handle UE delete response from MAC
2929 * @params[in] Pointer to MacUeDeleteRsp and Pst
2930 * @return ROK - success
2933 * ****************************************************************/
2935 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2937 uint8_t ret =ROK,ueId=0;
2939 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2943 if(deleteRsp->result == SUCCESS)
2945 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2946 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2947 if(duCb.actvCellLst[cellIdx])
2949 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2950 ueId = deleteRsp->ueId;
2951 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2952 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2953 if(deleteUeCfg(cellIdx, ueId) == ROK)
2955 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2958 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2966 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2970 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2974 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2980 /*******************************************************************
2982 * @brief Processes UE Delete Rsp received from RLC
2986 * Function : DuProcRlcUeDeleteRsp
2989 * Processes UE Delete Rsp received from RLC
2991 * @params[in] Post structure
2992 * Pointer to RlcUeDeleteRsp
2993 * @return ROK - success
2996 * *****************************************************************/
2998 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3000 uint8_t ueId = 0, ret = ROK;
3001 uint16_t cellIdx = 0,crnti=0;
3005 ueId = delRsp->ueId;
3006 GET_CELL_IDX(delRsp->cellId, cellIdx);
3008 if(delRsp->result == SUCCESSFUL)
3010 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3011 if(duCb.actvCellLst[cellIdx]!=NULLP)
3013 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3014 GET_CRNTI(crnti, ueId);
3015 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3017 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3025 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3028 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3034 /*******************************************************************
3036 * @brief Sending UE Delete Req To Mac
3040 * Function : sendUeDeleteReqToMac
3043 * sending UE Delete Req To Mac
3045 * @params[in] cellId, ueId, crnti
3046 * @return ROK - success
3049 *****************************************************************/
3051 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3055 MacUeDelete *ueDelete = NULLP;
3057 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3060 ueDelete->cellId = cellId;
3061 ueDelete->ueId = ueId;
3062 ueDelete->crnti = crnti;
3063 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3065 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3066 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3069 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3070 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3075 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3081 /*******************************************************************
3083 * @brief Sending UE Delete Req To Rlc
3087 * Function : sendUeDeleteReqToRlc
3090 * Sending UE Delete Req To Rlc
3092 * @params[in] cellId, ueId
3093 * @return ROK - success
3096 *****************************************************************/
3098 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3102 RlcUeDelete *ueDelete;
3104 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3105 if(ueDelete !=NULLP)
3107 ueDelete->cellId = cellId;
3108 ueDelete->ueId = ueId;
3109 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3111 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3114 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3115 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3120 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3126 /*******************************************************************
3128 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3132 * Function : duBuildAndSendUeDeleteReq
3134 * Functionality: DU processes UE delete req from CU and sends to MAC
3137 * @params[in] cellId, crnti
3138 * @return ROK - success
3141 * ****************************************************************/
3143 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3146 uint16_t cellIdx = 0;
3148 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3149 GET_CELL_IDX(cellId, cellIdx);
3150 GET_UE_IDX(crnti, ueId);
3152 if(duCb.actvCellLst[cellIdx] != NULLP)
3154 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3156 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3160 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3161 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3163 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3169 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3176 /*******************************************************************
3178 * @brief delete RlcUeCfg from duCb
3182 * Function : deleteRlcUeCfg
3185 * delete RlcUeCfg from duCb
3187 * @params[in] RlcUeCfg *ueCfg
3189 * @return ROK - success
3192 *****************************************************************/
3194 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3197 RlcBearerCfg *lcCfg= NULLP;
3200 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3202 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3203 switch(lcCfg->rlcMode)
3207 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3210 case RLC_UM_BI_DIRECTIONAL :
3212 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3215 case RLC_UM_UNI_DIRECTIONAL_UL :
3217 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3220 case RLC_UM_UNI_DIRECTIONAL_DL :
3222 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3226 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3228 memset(ueCfg, 0, sizeof(RlcUeCfg));
3232 /*******************************************************************
3234 * @brief Du process Ue Context Release Command
3238 * Function : duProcUeContextReleaseCommand
3240 * Functionality: Du process Ue Context Release Command
3242 * @params[in] DuUeCb *duUeCb
3243 * @return ROK - success
3246 * ****************************************************************/
3247 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3249 uint8_t ret =ROK, ueIdx=0;
3250 uint16_t cellId=0,crnti =0;
3253 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3256 if(duUeCb->f1UeDb == NULLP)
3258 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3262 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3263 crnti = duUeCb->crnti;
3264 GET_UE_IDX(crnti, ueIdx);
3266 /* Send DL RRC msg for RRC release */
3267 if(duUeCb->f1UeDb->dlRrcMsg)
3269 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3271 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx-1].rlcUeCfg,\
3272 duUeCb->f1UeDb->dlRrcMsg);
3275 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3276 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3277 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3278 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3284 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3287 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3294 /**********************************************************************
3296 ***********************************************************************/