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 DuMacRachRsrcReq packMacRachRsrcReqOpts[] =
86 packDuMacRachRsrcReq, /* Loose coupling */
87 MacProcRachRsrcReq, /* Tight coupling */
88 packDuMacRachRsrcReq /* Light weight-loose coupling */
91 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
93 packRlcDlUserDataToRlc, /* Loose coupling */
94 RlcProcDlUserDataTransfer, /* Tight coupling */
95 packRlcDlUserDataToRlc /* Light weight-loose coupling */
98 DuMacRachRsrcRel packMacRachRsrcRelOpts[] =
100 packDuMacRachRsrcRel, /* Loose coupling */
101 MacProcRachRsrcRel, /* Tight coupling */
102 packDuMacRachRsrcRel /* Light weight-loose coupling */
105 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
107 packDuMacUeDeleteReq, /* Loose coupling */
108 MacProcUeDeleteReq, /* TIght coupling */
109 packDuMacUeDeleteReq /* Light weight-loose coupling */
112 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
114 packDuRlcUeDeleteReq, /* Loose coupling */
115 RlcProcUeDeleteReq, /* TIght coupling */
116 packDuRlcUeDeleteReq /* Light weight-loose coupling */
119 /******************************************************************
121 * @brief Function to return Drb LcId
125 * Function : getDrbLcId
127 * Functionality: Function to return Drb LcId
129 * @params[in] drbBitMap
131 * Returns: lcId - SUCCESS
133 *****************************************************************/
135 uint8_t getDrbLcId(uint32_t *drbBitMap)
137 uint8_t bitMask = 1, bitPos = 0;
138 bitPos = MIN_DRB_LCID;
140 while(bitPos <= MAX_DRB_LCID)
142 if((*drbBitMap & (bitMask << bitPos)) == 0)
144 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
152 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
156 /*******************************************************************
158 * @brief Function to fillDlUserDataInfo
162 * Function : fillDlUserDataInfo
165 * Function to fillDlUserDataInfo
170 * @return ROK - success
173 * ****************************************************************/
175 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
179 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
180 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
182 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
184 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
186 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
187 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
188 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
196 /*******************************************************************
198 * @brief Build and Send DL Data Message transfer to RLC
202 * Function : duBuildAndSendDlUserDataToRlc
205 * Build and Send DL Data Message transfer to RLC
207 * @params[in] Cell ID
209 * Logical Channgel ID
212 * @return ROK - success
215 * ****************************************************************/
217 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
219 uint8_t ret = RFAILED;
221 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
223 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
226 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
229 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
230 dlDataMsgInfo->dlMsg = egtpMsg->msg;
231 dlDataMsgInfo->msgLen = msgLen;
233 /* Filling DL DATA Msg Info */
234 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
236 /* Filling post structure and sending msg */
237 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
238 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
239 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
240 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
244 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
245 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
246 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
251 /*******************************************************************
253 * @brief Handles EGTP data from CU
257 * Function : duHdlEgtpData
260 * Processes EGTP header and sends data to RLC
262 * @params[in] Pointer to EGTP Message
263 * @return ROK - success
266 * ****************************************************************/
267 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
271 #ifdef CALL_FLOW_DEBUG_LOG
272 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
275 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
279 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
282 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
283 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
285 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
291 /******************************************************************
293 * @brief Builds and Sends DL CCCH Ind to MAC
297 * Function : duBuildAndSendDlCcchInd
299 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
301 * @params[in] dlCcchMsg - uint8_t*
302 * @return ROK - success
305 * ****************************************************************/
306 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
307 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
311 DlCcchIndInfo *dlCcchIndInfo = NULLP;
314 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
316 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
320 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
324 dlCcchIndInfo->cellId = *cellId;
325 dlCcchIndInfo->crnti = *crnti;
326 dlCcchIndInfo->msgType = msgType;
327 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
329 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
330 if(!dlCcchIndInfo->dlCcchMsg)
332 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
333 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
336 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
338 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
340 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
343 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
344 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
347 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
348 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
349 dlCcchIndInfo->dlCcchMsgLen);
350 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
351 sizeof(DlCcchIndInfo));
359 /*******************************************************************
361 * @brief Build and Send DL RRC Message transfer to RLC
365 * Function : duBuildAndSendDlRrcMsgToRlc
368 * Build and Send DL RRC Message transfer to RLC
370 * @params[in] Cell ID
372 * Logical Channgel ID
375 * @return ROK - success
378 * ****************************************************************/
379 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
384 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
388 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
392 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
395 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
396 duBuildAndSendDlRrcMsgToRlc");
397 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
401 /* Filling up the RRC msg info */
402 dlRrcMsgInfo->cellId = cellId;
403 dlRrcMsgInfo->ueId = ueCfg.ueId;
404 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
406 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
408 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
409 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
410 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
411 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
415 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
416 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
417 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
418 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
420 /* Filling post structure and sending msg */
421 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
422 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
423 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
426 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
427 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
436 /******************************************************************
438 * @brief Process DL RRC Msg recevied from F1AP
442 * Function : duProcDlRrcMsg
444 * Functionality: Process DL RRC Msg recevied from F1AP
446 * @params[in] dlCcchMsg - uint8_t*
447 * @return ROK - success
450 * ****************************************************************/
452 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
455 uint16_t crnti, cellId, cellIdx;
456 bool ueCcchCtxtFound = false;
457 bool ueFound = false;
461 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
463 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
465 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
467 ueCcchCtxtFound = true;
468 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
469 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
476 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
479 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
483 if(duCb.actvCellLst[cellId-1] == NULLP)
485 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
488 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
490 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
493 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
494 duCb.ueCcchCtxt[ueIdx].cellId);
499 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
506 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
508 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
510 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
511 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
514 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
515 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
524 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
531 /******************************************************************
533 * @brief Processes UL CCCH Ind recvd from MAC
537 * Function : duProcUlCcchInd
539 * Functionality: Processes UL CCCH Ind recvd from MAC
541 * @params[in] UlCcchIndInfo *ulCcchIndInfo
542 * @return ROK - success
545 * ****************************************************************/
546 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
550 int32_t gnbDuUeF1apId = 0;
552 if(ulCcchIndInfo->crnti)
554 GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
558 DU_LOG("\nERROR --> DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
562 /* Store Ue mapping */
563 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
564 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
565 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
569 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
570 ulCcchIndInfo->ulCcchMsg));
573 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
576 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
577 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
583 /******************************************************************
585 * @brief Fills Default UL LC Cfg
589 * Function : fillDefaultUlLcCfg
591 * Functionality: Fills Default UL LC Cfg
593 * @params[in] UlLcCfg *ulLcCfg
595 *****************************************************************/
596 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
598 ulLcCfg->priority = LC_PRIORITY_1;
599 ulLcCfg->lcGroup = 0;
600 ulLcCfg->schReqId = 0;
601 ulLcCfg->pbr = PBR_KBPS_INFINITY;
602 ulLcCfg->bsd = BSD_MS_1000;
605 /******************************************************************
607 * @brief Fills Initial DL Bandwidth Part
611 * Function : fillDefaultInitDlBwp
613 * Functionality: Fills Initial DL Bandwidth Part
615 * @params[in] InitialDlBwp *initDlBwp
616 * @return ROK - success
619 *****************************************************************/
620 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
623 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
624 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
628 /* Filling PDCCH Config */
629 initDlBwp->pdcchPresent = TRUE;
630 if(initDlBwp->pdcchPresent)
632 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
633 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
634 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
636 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
637 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
638 coreset0EndPrb = CORESET0_END_PRB;
639 coreset1StartPrb = coreset0EndPrb +6;
640 coreset1NumPrb = CORESET1_NUM_PRB;
641 /* calculate the PRBs */
642 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
643 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
645 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
646 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
647 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
648 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
650 initDlBwp->pdcchCfg.numCRsetToRel = 0;
652 /* Filling Serach Space */
653 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
654 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
655 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
657 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
658 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
659 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
660 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
661 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
662 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
663 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
664 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
665 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
666 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
667 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
668 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
670 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
673 /* Filling PDSCH Config */
674 initDlBwp->pdschPresent = TRUE;
675 if(initDlBwp->pdschPresent)
677 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
678 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
680 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
683 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
684 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
685 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
686 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
689 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
690 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
692 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
695 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
696 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
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);
702 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
703 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
704 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
705 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
712 /******************************************************************
714 * @brief Fills Initial UL Bandwidth Part
718 * Function : fillDefaultInitUlBwp
720 * Functionality: Fills Initial UL Bandwidth Part
722 * @params[in] InitialUlBwp *initUlBwp
725 *****************************************************************/
726 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
731 initUlBwp->pucchPresent = FALSE;
733 /*Filling PUSCH Config */
734 initUlBwp->puschPresent = TRUE;
735 if(initUlBwp->puschPresent)
737 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
738 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
739 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
740 scramblingId0 = SCRAMBLING_ID;
741 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
742 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
744 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
746 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
747 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
749 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
750 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
751 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
752 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
755 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
756 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
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);
762 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
767 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
771 /******************************************************************
773 * @brief Fills SpCell Group Info
777 * Function : fillDefaultSpCellGrpInfo
779 * Functionality: Fills Sp Cell Group Info
781 * @params[in] MacUeCfg *macUeCfg
782 * @return ROK - Success
785 *****************************************************************/
786 uint8_t fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
788 SpCellCfg *spCell = NULL;
791 spCell = &macUeCfg->spCellCfg;
795 macUeCfg->spCellCfgPres = true;
797 spCell->servCellIdx = SERV_CELL_IDX;
798 /* Filling Initial Dl Bwp */
799 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
801 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
805 spCell->servCellCfg.numDlBwpToAdd = 0;
806 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
807 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
808 spCell->servCellCfg.bwpInactivityTmr = NULLP;
809 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
810 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
811 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
812 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
813 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
815 /* Filling Initial UL Bwp*/
816 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
817 spCell->servCellCfg.numUlBwpToAdd = 0;
818 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
822 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
828 /******************************************************************
830 * @brief Fills Physical Cell Group Info
834 * Function : fillDefaultPhyCellGrpInfo
836 * Functionality: Fills Physical Cell Group Info
838 * @params[in] MacUeCfg *macUeCfg
841 *****************************************************************/
842 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
844 PhyCellGrpCfg *cellGrp = NULL;
847 cellGrp = &macUeCfg->phyCellGrpCfg;
851 macUeCfg->phyCellGrpCfgPres = true;
852 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
853 cellGrp->pNrFr1 = P_NR_FR1;
857 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
861 /******************************************************************
863 * @brief Fills Mac Cell Group Info
867 * Function : fillDefaultMacCellGrpInfo
869 * Functionality: Fills Mac Cell Group Info
871 * @params[in] MacUeCfg *macUeCfg
874 *****************************************************************/
875 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
878 MacCellGrpCfg *cellGrp = NULL;
881 cellGrp = &macUeCfg->macCellGrpCfg;
885 macUeCfg->macCellGrpCfgPres = true;
887 /* Filling Scheduling Request Config */
888 cellGrp->schReqCfg.addModListCount = 1;
889 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
891 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
893 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
894 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
895 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
898 cellGrp->schReqCfg.relListCount = 0;
900 /* Filling Tag config */
901 cellGrp->tagCfg.addModListCount = 1;
902 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
904 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
906 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
907 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
910 cellGrp->tagCfg.relListCount = 0;
912 /* Filling BSR config */
913 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
914 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
915 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
917 /* Filling PHR config */
918 cellGrp->phrCfgSetupPres = true;
919 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
920 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
921 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
922 cellGrp->phrCfg.multiplePHR = false;
923 cellGrp->phrCfg.dummy = false;
924 cellGrp->phrCfg.phrType2OtherCell = false;
925 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
927 /* Filling Drx Config */
929 cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = DRX_ONDURATION_TIMER_VALUE_PRESENT_IN_MS;
930 if(!cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
931 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
932 DRX_ONDURATION_TIMER_VALUE_IN_SUBMS;
934 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
935 DRX_ONDURATION_TIMER_VALUE_IN_MS;
936 cellGrp->drxCfg.drxInactivityTimer = DRX_INACTIVITY_TIMER;
937 cellGrp->drxCfg.drxHarqRttTimerDl = DRX_HARQ_RTT_TIMER_DL;
938 cellGrp->drxCfg.drxHarqRttTimerUl = DRX_HARQ_RTT_TIMER_UL;
939 cellGrp->drxCfg.drxRetransmissionTimerDl = DRX_RETRANSMISSION_TIMER_DL;
940 cellGrp->drxCfg.drxRetransmissionTimerUl = DRX_RETRANSMISSION_TIMER_UL;
941 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = DRX_LONG_CYCLE_START_OFFSET_VAL;
942 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = DRX_LONG_CYCLE_START_OFFSET_CHOICE;
943 cellGrp->drxCfg.shortDrxPres = DRX_SHORT_CYCLE_PRESENT;
944 if(cellGrp->drxCfg.shortDrxPres)
946 cellGrp->drxCfg.shortDrx.drxShortCycle = DRX_SHORT_CYCLE;
947 cellGrp->drxCfg.shortDrx.drxShortCycleTimer = DRX_SHORT_CYCLE_TIMER;
949 cellGrp->drxCfg.drxSlotOffset = DRX_SLOT_OFFSET;
955 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
959 /*******************************************************************
961 * @brief Fills default modulation info for a UE
965 * Function : fillDefaultModulation
967 * Functionality: Fills default modulation info for a UE
969 * @params[in] Pointer to MAC UE configuration
970 * @return ROK - success
973 * ****************************************************************/
974 void fillDefaultModulation(MacUeCfg *ueCfg)
976 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
977 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
978 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
980 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
981 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
982 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
985 /******************************************************************
987 * @brief Function to fill Mac Lc Cfg for SRB1
991 * Function : fillMacSrb1LcCfg
993 * Functionality: Function to fill Mac Lc cfg for SRB1
995 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
997 *****************************************************************/
999 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
1001 macLcCfg->lcId = SRB1_LCID;
1002 macLcCfg->configType = CONFIG_ADD;
1003 macLcCfg->drbQos = NULLP;
1004 macLcCfg->snssai = NULLP;
1005 macLcCfg->ulLcCfgPres = true;
1006 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
1009 /******************************************************************
1011 * @brief Function to fill the Lc cfg from ueSetupReqDb
1015 * Function : fillMacLcCfgToAddMod
1017 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1019 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1020 * @return ROK/RFAILED
1022 *****************************************************************/
1024 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1030 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1031 macLcCfgToSend->configType = ueLcCfgDb->configType;
1033 if(ueLcCfgDb->drbQos)
1034 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1036 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1038 macLcCfgToSend->drbQos = NULL;
1040 if(ueLcCfgDb->snssai)
1041 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1043 macLcCfgToSend->snssai = oldLcCfg->snssai;
1045 macLcCfgToSend->snssai = NULL;
1047 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1048 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1049 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1054 oldLcCfg->lcId = ueLcCfgDb->lcId;
1055 oldLcCfg->configType = ueLcCfgDb->configType;
1057 if(ueLcCfgDb->drbQos)
1059 if(oldLcCfg->drbQos)
1060 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1062 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1063 if(oldLcCfg->drbQos == NULL)
1065 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1068 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1071 if(ueLcCfgDb->snssai)
1073 if(oldLcCfg->snssai)
1074 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1076 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1077 if(oldLcCfg->snssai == NULL)
1079 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1080 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1083 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1086 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1087 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1088 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1093 /******************************************************************
1095 * @brief Function to copy the Bit rate from ueSetupReqDb
1099 * Function : fillAmbr
1101 * Functionality: Function to copy bit Rate from ueSetupReqDb
1103 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1104 * @return ROK/RFAILED
1106 *****************************************************************/
1108 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1114 *macAmbrCfgToSend = ueDbAmbr;
1116 else if(oldMacAmbrCfg)
1117 *macAmbrCfgToSend = *oldMacAmbrCfg;
1127 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1129 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1130 if(*oldMacAmbrCfg == NULLP)
1132 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1135 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1136 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1144 /******************************************************************
1146 * @brief Builds and Send UE ReConfig Request to MAC
1150 * Function : sendUeReCfgReqToMac
1152 * Functionality: Builds and Send UE ReConfig Request to MAC
1154 * @Params[in] MacUeCfg pointer
1155 * @return ROK - success
1158 * ****************************************************************/
1160 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1166 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1170 /* Processing one Ue at a time to MAC */
1171 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1172 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1175 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1176 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1181 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1189 /******************************************************************
1191 * @brief Fills MacUeCfg structure
1195 * Function : fillMacUeCfg
1197 * Functionality: Fills MacUeCfg
1199 * @params[in] cellId, ueId, crnti,
1202 * @return ROK/RFAILED
1204 *****************************************************************/
1205 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1207 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1208 bool lcIdFound = false;
1209 MacUeCfg *duMacDb = NULLP;
1211 macUeCfg->cellId = cellId;
1212 macUeCfg->ueId = gnbDuUef1apId;
1213 macUeCfg->crnti = crnti;
1217 fillDefaultMacCellGrpInfo(macUeCfg);
1218 fillDefaultPhyCellGrpInfo(macUeCfg);
1220 if((fillDefaultSpCellGrpInfo(macUeCfg)) != ROK)
1222 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1226 macUeCfg->ambrCfg = NULLP;
1227 fillDefaultModulation(macUeCfg);
1228 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1233 if(ueCfgDb->dataTransmissionAction == STOP_TRANSMISSION)
1235 macUeCfg->transmissionAction = ueCfgDb->dataTransmissionAction;
1239 GET_CELL_IDX(cellId, cellIdx);
1240 if(duCb.actvCellLst[cellIdx])
1241 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1244 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1247 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1249 if(ueCfgDb->cellGrpCfg)
1251 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1254 if(macUeCfg->spCellCfgPres == true)
1256 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1258 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1259 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1261 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1263 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1264 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1269 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1271 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1273 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1278 fillDefaultMacCellGrpInfo(macUeCfg);
1279 fillDefaultPhyCellGrpInfo(macUeCfg);
1280 fillDefaultSpCellGrpInfo(macUeCfg);
1281 fillDefaultModulation(macUeCfg);
1282 macUeCfg->ambrCfg = NULLP;
1286 if(ueCfgDb->drxCyclePres)
1288 macUeCfg->macCellGrpCfg.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = ueCfgDb->drxCycle.drxLongCycleLength;
1289 if(ueCfgDb->drxCycle.shortDrxCyclePres)
1291 macUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = true;
1292 macUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycle = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycle;
1293 macUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycleTimer;
1297 macUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = false;
1302 /* Filling LC Context */
1303 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1305 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1307 /* Filling default UL LC config in MAC if not present */
1308 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1309 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1314 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1316 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1319 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1320 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1322 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1323 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1324 &duMacDb->lcCfgList[lcIdx], FALSE);
1334 /* ADD/DEL CONFIG */
1335 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1343 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1346 }/*End of Outer FOR loop */
1347 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1352 /******************************************************************
1354 * @brief Fills Rlc AM Information
1358 * Function : fillDefaultAmInfo
1360 * Functionality: Fills Rlc AM Information
1362 * @params[in] AmBearerCfg *amCfg
1365 *****************************************************************/
1366 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1369 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1370 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1371 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1372 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1373 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1376 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1377 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1378 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1381 /******************************************************************
1383 * @brief Fills RLC UM Bi Directional Information
1387 * Function : fillDefaultUmBiInfo
1389 * Functionality: Fills RLC UM Bi Directional Information
1391 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1394 *****************************************************************/
1395 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1397 /* UL UM BI DIR INFO */
1398 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1399 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1401 /* DL UM BI DIR INFO */
1402 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1405 /******************************************************************
1407 * @brief Fills RLC UM Uni Directional UL Information
1411 * Function : fillDefaultUmUlInfo
1413 * Functionality: Fills RLC UM Uni Directional Info
1415 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1418 *****************************************************************/
1419 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1421 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1422 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1425 /******************************************************************
1427 * @brief Fills RLC UM Uni Directional DL Information
1431 * Function : fillDefaultUmDlInfo
1433 * Functionality: Fills RLC UM Uni Directional DL Info
1435 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1438 *****************************************************************/
1439 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1441 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1444 /******************************************************************
1446 * @brief Builds Rlc Mode Default Configuration
1450 * Function : fillDefaultRlcModeCfg
1452 * Functionality: Builds Rlc Mode Default Configuration
1454 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1455 * @return ROK/RFAILED
1457 *****************************************************************/
1459 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1469 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1471 fillDefaultAmInfo(lcCfg->u.amCfg);
1474 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1480 case RLC_UM_BI_DIRECTIONAL :
1482 if(!lcCfg->u.umBiDirCfg)
1484 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1485 if(lcCfg->u.umBiDirCfg)
1486 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1489 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1495 case RLC_UM_UNI_DIRECTIONAL_UL :
1497 if(!lcCfg->u.umUniDirUlCfg)
1499 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1500 if(lcCfg->u.umUniDirUlCfg)
1501 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1504 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1510 case RLC_UM_UNI_DIRECTIONAL_DL :
1512 if(!lcCfg->u.umUniDirDlCfg)
1514 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1515 if(lcCfg->u.umUniDirDlCfg)
1516 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1519 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1526 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1533 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1539 /*******************************************************************
1541 * @brief Function to fill Rlc Lc Cfg for SRB1
1545 * Function : fillRlcSrb1LcCfg
1548 * Function to fill Rlc Lc Cfg for SRB1
1550 * @params[in] Pointer to RlcBearerCfg
1551 * @return ROK/RFAILED
1553 *****************************************************************/
1555 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1559 rlcLcCfg->rbId = SRB1_LCID;
1560 rlcLcCfg->rbType = RB_TYPE_SRB;
1561 rlcLcCfg->lcId = SRB1_LCID;
1562 rlcLcCfg->lcType = LCH_DCCH;
1563 rlcLcCfg->rlcMode = RLC_AM;
1564 rlcLcCfg->configType = CONFIG_ADD;
1565 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1566 rlcLcCfg->isLcAddModRspSent = true;
1570 /*******************************************************************
1572 * @brief Processes UE ReConfig Req to RLC UL
1576 * Function : sendUeReCfgReqToRlc
1579 * Processes UE Reconfig Req to RLC UL
1581 * @params[in] Pointer to RlcUeCfg
1582 * @return ROK - success
1585 *****************************************************************/
1587 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1592 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1595 /* Processing one Ue at a time to RLC */
1596 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1597 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1600 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1601 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1606 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1612 /******************************************************************
1614 * @brief Fills Snssai information
1618 * Function : fillSnssaiInfo
1620 * Functionality: Fills Snssai information
1622 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1624 * @return ROK - success
1627 *****************************************************************/
1628 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1633 snssaiTobeSend = snssaiDb;
1635 snssaiTobeSend = *oldSnssai;
1637 snssaiTobeSend = NULL;
1644 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1646 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1647 if(*oldSnssai == NULL)
1649 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1652 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1657 /******************************************************************
1659 * @brief Fills RlcBearerCfg structure
1663 * Function : fillRlcUeCfg
1665 * Functionality: Fills Rlc Bearer Cfg
1668 *****************************************************************/
1669 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t duUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1671 uint8_t ret, dbIdx, lcIdx, cellIdx;
1672 bool lcIdFound = false;
1673 RlcUeCfg *duRlcDb = NULLP;
1676 rlcUeCfg->cellId = cellId;
1677 rlcUeCfg->ueId = duUeF1apId;
1681 /* Initial RB being Added */
1682 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1686 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1690 /* Fetch RlcDb from DuUeCb */
1691 GET_CELL_IDX(cellId, cellIdx);
1692 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[rlcUeCfg->ueId-1].rlcUeCfg;
1693 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1695 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1697 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1700 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1701 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1707 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1708 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1710 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1713 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1714 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1717 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1718 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1719 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1720 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1730 /* ADD/ DEL Config Type */
1731 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1732 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1740 /******************************************************************
1742 * @brief creates UE context
1746 * Function : duCreateUeCb
1748 * Functionality: Creates UE Conetxt
1750 * @params[in] UeCcchCtxt Pointer
1753 * @return ROK - success
1755 * ****************************************************************/
1756 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1758 uint8_t cellIdx = 0;
1760 uint8_t ueId = 0, ueIdx = 0;
1762 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1764 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1766 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1767 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1770 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1771 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1772 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1773 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1774 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1775 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1777 /* Filling Mac Ue Config */
1778 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
1779 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1780 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
1782 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1784 /* Filling Rlc Ue Config */
1785 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1786 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, NULL,
1787 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1789 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1791 duCb.actvCellLst[cellIdx]->numActvUes++;
1792 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1799 /******************************************************************
1801 * @brief Builds and Send UE Create Request to MAC
1805 * Function : duBuildAndSendUeCreateReqToMac
1807 * Functionality: Builds and Send UE Create Request to MAC
1809 * @Params[in] cellId,
1812 * UE config extracted from F1AP msg
1813 * MAC UE config struct to be filled
1814 * @return ROK - success
1817 * ****************************************************************/
1819 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *duMacUeCfg)
1822 MacUeCfg *macUeCfg = NULLP;
1824 memset(&pst, 0, sizeof(Pst));
1827 ret = fillMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1830 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1835 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1837 /* Copying ueCb to a sharable buffer */
1838 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1841 memset(macUeCfg, 0, sizeof(MacUeCfg));
1842 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1843 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1845 /* Processing one Ue at a time to MAC */
1846 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1849 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1850 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1855 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1861 /*******************************************************************
1863 * @brief Build and send RACH Resource request to MAC
1867 * Function : duBuildAndSendRachRsrcReqToMac
1869 * Build and send RACH Resource request to MAC
1871 * @params[in] Cell Id
1873 * @return ROK - success
1876 * ****************************************************************/
1877 uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
1879 uint16_t cellIdx = 0, ssbIdx = 0;
1881 MacRachRsrcReq *rachRsrcReq = NULLP;
1883 GET_CELL_IDX(cellId, cellIdx);
1884 if(duCb.actvCellLst[cellIdx] == NULLP)
1886 DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
1890 DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
1893 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
1894 duBuildAndSendRachRsrcReqToMac()");
1898 rachRsrcReq->cellId = cellId;
1899 rachRsrcReq->ueId = ueId;
1900 rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
1901 for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
1903 rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
1907 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
1909 if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
1911 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
1912 duBuildAndSendRachRsrcReqToMac()");
1913 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
1920 /*******************************************************************
1922 * @brief Process RACH resource response from MAC
1926 * Function : DuProcMacRachRsrcRsp
1928 * Process RACH resource response from MAC
1930 * @params[in] Post structure
1931 * RACH resource response
1932 * @return ROK - success
1935 * ****************************************************************/
1936 uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
1938 uint8_t ret = RFAILED;
1939 uint16_t cellIdx = 0;
1940 DuCellCb *cellCb = NULLP;
1941 DuUeCb *ueCb = NULLP;
1943 DU_LOG("\nINFO --> DU APP : Received RACH Resource Response from MAC. Cell ID [%d] UE ID [%d]",
1944 rachRsrcRsp->cellId, rachRsrcRsp->ueId);
1946 if(rachRsrcRsp->result == MAC_DU_APP_RSP_OK)
1948 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
1951 GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
1952 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
1954 cellCb = duCb.actvCellLst[cellIdx];
1957 if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
1959 ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
1961 /* Store CRNTI alloted to this UE by MAC */
1962 ueCb->crnti = rachRsrcRsp->newCrnti;
1964 /* Store the assigned CF-RA resources */
1965 memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
1967 /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
1968 * along with the result of UE Context setup requested by CU */
1969 if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
1970 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
1973 DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
1976 DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
1979 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
1981 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
1985 /*******************************************************************
1987 * @brief To update DuUeCb Mac Cfg
1991 * Function : duUpdateMacCfg
1992 * Functionality: update DuUeCb MAC Cfg
1994 * @params[in] DuUeCb Pointer
1995 * F1UeContextSetupDb pointer
1996 * @return ROK - success
1999 * ****************************************************************/
2000 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
2002 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
2003 MacUeCfg *oldMacUeCfg;
2006 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
2007 if(duCb.actvCellLst[cellIdx] == NULLP)
2009 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
2012 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
2014 /*Filling Cell Group Cfg*/
2015 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
2017 memcpy(&macUeCfg->macCellGrpCfg.drxCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg.macCellGrpCfg.drxCfg, sizeof(DrxCfg));
2021 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
2023 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
2024 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
2026 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
2028 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
2029 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
2031 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
2032 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
2035 /* Filling LC Context */
2036 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
2038 numLcs = macUeCfg->numLcs;
2039 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2041 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
2043 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
2045 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
2047 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
2049 /* Free memory at matched lcIdx index */
2050 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
2052 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
2054 /* moving all elements one index ahead */
2055 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
2056 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
2059 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
2066 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
2068 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
2071 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
2081 /******************************************************************
2083 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
2087 * Function : fillRlcCfgToAddMod
2089 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
2092 *****************************************************************/
2094 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
2096 lcCfg->configType = f1UeDbLcCfg->configType;
2097 lcCfg->rbId = f1UeDbLcCfg->rbId;
2098 lcCfg->rbType = f1UeDbLcCfg->rbType;
2099 lcCfg->lcId = f1UeDbLcCfg->lcId;
2100 lcCfg->lcType = f1UeDbLcCfg->lcType;
2101 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
2103 switch(lcCfg->rlcMode)
2109 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
2114 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
2115 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
2116 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
2117 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
2118 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
2121 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
2122 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
2123 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
2126 case RLC_UM_BI_DIRECTIONAL :
2128 if(!lcCfg->u.umBiDirCfg)
2130 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2131 if(!lcCfg->u.umBiDirCfg)
2134 /* UL UM BI DIR INFO */
2135 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
2136 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
2137 /* DL UM BI DIR INFO */
2138 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
2141 case RLC_UM_UNI_DIRECTIONAL_UL :
2143 if(!lcCfg->u.umUniDirUlCfg)
2145 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2146 if(!lcCfg->u.umUniDirUlCfg)
2149 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
2150 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2154 case RLC_UM_UNI_DIRECTIONAL_DL :
2156 if(!lcCfg->u.umUniDirDlCfg)
2158 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2159 if(!lcCfg->u.umUniDirDlCfg)
2162 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2166 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
2172 /*******************************************************************
2174 * @brief To update DuUeCb Rlc Lc Cfg
2178 * Function : duUpdateRlcLcCfg
2179 * Functionality: update DuUeCb Rlc Lc Cfg
2181 * @params[in] DuUeCb Pointer
2182 * F1UeContextSetupDb pointer
2183 * @return ROK - success
2186 * ****************************************************************/
2188 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2190 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2193 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2195 numLcs = rlcUeCfg->numLcs;
2196 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2198 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2200 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2202 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2205 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2208 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2210 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2212 /* Free memory at matched lcIdx index */
2213 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2215 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2217 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2218 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2220 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2223 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2230 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2232 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2235 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2244 /*******************************************************************
2246 * @brief Function to fill Tunnel Config to Add/Mod
2251 * Function : fillTnlCfgToAddMod
2253 * Functionality: Function to fill tunnel Config to Add/Mod
2255 * @params[in] Pointer to tnlCfgDb,
2256 * pointer to f1TnlCfg
2257 * @return ROK - success
2260 * ****************************************************************/
2261 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2265 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2266 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2269 if(*ueCbTnlCfg == NULLP)
2271 /* copying to DuCb Tnl Cfg */
2272 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2273 if(*ueCbTnlCfg == NULLP)
2275 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2279 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2280 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2281 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2282 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2283 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2284 if(f1TnlCfg->tnlCfg1)
2286 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2288 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2289 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2291 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2295 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2296 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2297 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2298 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2303 /*******************************************************************
2305 * @brief Processing the tunnel Request to EGTP
2309 * Function : duProcEgtpTunnelCfg
2311 * Functionality: Processing the tunnel Request to EGTP
2313 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2314 * @return ROK - success
2317 * ****************************************************************/
2319 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2321 uint8_t ret = RFAILED, delIdx;
2323 if(f1TnlCfg->tnlCfg1 == NULLP)
2325 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2329 if(f1TnlCfg->configType == CONFIG_ADD)
2331 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2333 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2340 else if(f1TnlCfg->configType == CONFIG_MOD)
2342 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2344 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2350 else if(f1TnlCfg->configType == CONFIG_DEL)
2352 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2354 /* Free memory at drbIdx */
2356 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2358 /* moving all elements one index ahead */
2359 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2365 if(duCb.upTnlCfg[delIdx])
2367 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2368 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2375 /***********************************************************************
2377 * @brief Function to fill Tunnel Config
2378 * and sends tunnel Req to EGTP
2383 * Function : duUpdateTunnelCfgDb
2385 * Functionality: Function to fill tunnel Config
2386 * and sends tunnel Cfg Req to EGTP
2388 * @params[in] ueId, cellId, DuUeCfg
2389 * @return ROK - success
2392 * ****************************************************************/
2394 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2396 uint8_t ret = ROK, drbIdx, teIdx;
2397 bool drbFound = false;
2399 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2400 /*then update drbId and tunnel Info in duCb */
2401 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2403 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2404 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2405 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2407 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2408 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2410 drbFound = true; /* existing DRB */
2411 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2413 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2414 duUeCfg->upTnlInfo[drbIdx].drbId);
2423 if(!drbFound && ret == ROK)/* new DRB to Add */
2425 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2427 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2428 duUeCfg->upTnlInfo[drbIdx].drbId);
2439 /*******************************************************************
2441 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2446 * Function : duUpdateDuUeCbCfg
2448 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2450 * @params[in] ueId, cellIdx
2451 * @return ROK - success
2454 * ****************************************************************/
2456 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2458 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2459 DuUeCb *ueCb = NULLP;
2461 GET_CELL_IDX(cellId, cellIdx);
2462 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2464 /*Filling RLC Ue Cfg */
2465 ueCb->rlcUeCfg.cellId = cellId;
2466 ueCb->rlcUeCfg.ueId = ueId;
2467 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2470 /*Filling MAC Ue Cfg */
2471 GET_CRNTI(crnti, ueId);
2472 ueCb->macUeCfg.cellId = cellId;
2473 ueCb->macUeCfg.ueId = ueId;
2474 ueCb->macUeCfg.crnti = crnti;
2475 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2477 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2480 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2482 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2488 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2492 /*******************************************************************
2494 * @brief Handle UE config response from MAC
2498 * Function : DuProcMacUeCfgRsp
2500 * Functionality: Handle UE Config response from MAC
2502 * @params[in] Pointer to MacUeCfgRsp and Pst
2503 * @return ROK - success
2506 * ****************************************************************/
2507 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2514 GET_CELL_IDX(cfgRsp->cellId, cellIdx);
2515 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2517 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2519 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2521 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2523 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2525 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2526 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2527 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2529 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2531 /* If UE is in handover, RACH resource needs to be requested
2532 * from MAC for CFRA */
2533 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2535 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2536 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2542 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2543 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2549 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2551 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2552 if(duCb.actvCellLst[cellIdx] &&
2553 (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2555 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2556 if((duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2557 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2559 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2561 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2563 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2564 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2570 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2571 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2580 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
2581 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2583 //TODO: Send the failure case in Ue Context Setup Response
2587 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2591 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2598 /*******************************************************************
2600 * @brief Processes UE create Req to RLC UL
2604 * Function : duBuildAndSendUeCreateReqToRlc
2607 * Processes UE create Req to RLC UL
2609 * @params[in] cellId,
2611 * Pointer to RlcUeCfg
2612 * @return ROK - success
2615 *****************************************************************/
2617 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *duRlcUeCfg)
2620 RlcUeCfg *rlcUeCfg = NULLP;
2623 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
2626 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2630 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2631 /* Copying ueCfg to a sharable buffer */
2632 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2635 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2636 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2637 /* Processing one Ue at a time to RLC */
2638 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2639 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2642 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2643 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2649 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2655 /*******************************************************************
2657 * @brief Processes UE create Rsp received from RLC UL
2662 * Function : DuProcRlcUeCfgRsp
2665 * Processes UE create Rsp received from RLC UL
2667 * @params[in] Post structure
2668 * Pointer to RlcCfgCfm
2669 * @return ROK - success
2672 *****************************************************************/
2673 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2679 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2681 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2683 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2684 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2686 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2687 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2688 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2690 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2692 /* If UE is in handover, RACH resource needs to be requested
2693 * from MAC for CFRA */
2694 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2696 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2697 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2698 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2704 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2705 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2710 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2712 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2714 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2715 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2716 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2718 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2720 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2722 DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
2723 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2729 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2730 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2738 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2739 pst->event, cfgRsp->ueId, cfgRsp->reason);
2740 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2742 //TODO: update failure case in ue Context setup Response
2746 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2750 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2756 /*******************************************************************
2758 * @brief Builds and Send Ue Reconfig Req to RLC
2762 * Function : duBuildAndSendUeReCfgReqToRLC
2764 * Functionality: Builds and Send Ue Reconfig Req to RLC
2766 * @params[in] cellId, crnti
2768 * RlcUeCfg *rlcUeCfg
2769 * @return ROK - success
2772 * ****************************************************************/
2774 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2777 RlcUeCfg *rlcUeCfg = NULLP;
2779 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2782 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2783 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, rlcUeCfg);
2785 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2787 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2791 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2797 /*******************************************************************
2799 * @brief Builds and Send Ue Reconfig Req to MAC
2803 * Function : duBuildAndSendUeReCfgReqToMac
2805 * Functionality: Builds and Send Ue Reconfig Req to MAC
2807 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2809 * MacUeCfg *macUeCfg
2810 * @return ROK - success
2813 * ****************************************************************/
2815 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2818 MacUeCfg *macUeCfg = NULLP;
2820 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2823 memset(macUeCfg, 0, sizeof(MacUeCfg));
2824 ret = fillMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, macUeCfg);
2826 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2828 ret = sendUeReCfgReqToMac(macUeCfg);
2832 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2838 /*******************************************************************
2840 * @brief Build and Send Ue context setup request
2845 * Function : duBuildAndSendUeContextSetupReq
2848 * Build and Send Ue context setup request
2850 * @params[in] cellId, crnti, DuUeCfg pointer
2851 * @return ROK - success
2854 *****************************************************************/
2856 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
2860 DuUeCfg *duUeCfg = NULLP;
2862 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2866 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
2870 crnti = ueCb->crnti;
2871 duUeCfg = &ueCb->f1UeDb->duUeCfg;
2873 /* If UE is being handed-in to this DU, UE context setup request will create
2874 * new UE context at MAC/SCH and RLC.
2875 * If UE is in active state, UE contex setup request will lead to
2876 * reconfiguration of UE at MAC/SCH and RLC
2878 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
2880 /* Filling MAC UE Config */
2881 memset(&ueCb->macUeCfg, 0, sizeof(MacUeCfg));
2883 /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
2884 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->macUeCfg);
2886 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
2888 ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->rlcUeCfg);
2890 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
2895 /* Filling RLC UE Reconfig */
2896 ret = duBuildAndSendUeReCfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
2898 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2900 /* Filling MAC UE Reconfig */
2901 ret = duBuildAndSendUeReCfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
2903 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2909 /*******************************************************************
2911 * @brief Processes DL Rsp received from RLC DL
2916 * Function : DuProcRlcDlRrcMsgRsp
2919 * Processes UE Rsp received from RLC DL
2921 * @params[in] Post structure
2922 * Pointer to RlcCfgCfm
2923 * @return ROK - success
2926 *****************************************************************/
2927 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2929 uint8_t ret = ROK, ueId = 0;
2930 uint16_t cellId, crnti;
2931 DuUeCb *ueCb = NULLP;
2934 state = dlRrcMsg->state;
2935 cellId = dlRrcMsg->cellId;
2936 crnti = dlRrcMsg->crnti;
2937 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2939 if(state == TRANSMISSION_COMPLETE)
2941 GET_UE_ID(crnti, ueId);
2942 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
2944 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2946 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2948 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
2950 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2953 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2955 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
2957 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2960 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2962 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2965 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2971 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2975 /*******************************************************************
2977 * @brief Process UE context setup request from CU
2981 * Function : duProcUeContextSetupRequest
2983 * Functionality: Process UE context setup request from CU
2985 * @params[in] F1AP message
2986 * @return ROK - success
2989 * ****************************************************************/
2991 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2993 uint8_t ret, cellId;
2998 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3000 /* Send DL RRC msg for security Mode */
3001 if(ueCb->f1UeDb->dlRrcMsg)
3003 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3005 /* Sending DL RRC Message to RLC */
3006 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3009 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
3010 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3011 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3012 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3016 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3018 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3021 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
3027 //TODO: To send the failure cause in UeContextSetupRsp
3028 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
3033 /*******************************************************************
3035 * @brief Build and Send Ue context mod request
3040 * Function : duBuildAndSendUeContextModReq
3043 * Build and Send Ue context mod request
3045 * @params[in] cellId, crnti, DuUeCfg pointer
3046 * @return ROK - success
3049 *****************************************************************/
3051 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
3055 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
3056 /* Filling RLC Ue Reconfig */
3057 ret = duBuildAndSendUeReCfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3059 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
3061 /* Filling MAC Ue Reconfig */
3062 ret = duBuildAndSendUeReCfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3064 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
3068 /*******************************************************************
3070 * @brief Processing Ue context mod request
3075 * Function : duProcUeContextModReq
3078 * Processing Ue context mod request
3080 * @params[in] DuUeCb *ueCb
3081 * @return ROK - success
3084 *****************************************************************/
3086 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
3088 uint8_t ret, cellId;
3093 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3094 /* Send DL RRC msg for security Mode */
3095 if(ueCb->f1UeDb->dlRrcMsg)
3097 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3099 /* Sending DL RRC Message to RLC */
3100 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3103 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
3104 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3105 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3106 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3110 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3112 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
3115 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
3119 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
3121 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
3123 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
3130 //TODO: To send the failure cause in UeContextModRsp
3132 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
3138 /*******************************************************************
3140 * @brief Build and send dedicated RACH resource release request to MAC
3144 * Function : duBuildAndSendRachRsrcRelToMac
3146 * Functionality: Function to Build and send dedicated RACH resource
3147 * release request to MAC
3149 * @params[in] Cell ID
3151 * @return ROK - Success
3154 * ****************************************************************/
3155 uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb)
3158 MacRachRsrcRel *rachRsrcRel = NULLP;
3160 DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel));
3163 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \
3164 duBuildAndSendRachRsrcRelToMac()");
3168 rachRsrcRel->cellId = cellId;
3169 rachRsrcRel->ueId = ueCb->gnbDuUeF1apId;
3170 rachRsrcRel->crnti = ueCb->crnti;
3173 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL);
3175 if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK)
3177 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \
3178 duBuildAndSendRachRsrcRelToMac()");
3179 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel));
3186 /*******************************************************************
3188 * @brief delete MacUeCfg from duCb
3192 * Function : deleteMacUeCfg
3194 * Functionality: delete MacUeCfg from duCb
3196 * @params[in] Pointer to MacUeCfg
3197 * @return ROK - success
3200 *******************************************************************/
3202 void deleteMacUeCfg(MacUeCfg *ueCfg)
3206 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
3207 if(ueCfg->spCellCfgPres)
3209 freeUeReCfgCellGrpInfo(ueCfg);
3211 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
3213 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
3215 memset(ueCfg, 0, sizeof(MacUeCfg));
3218 /*******************************************************************
3220 * @brief delete UE Configuration of a particular UE
3224 * Function : deleteUeCfg
3226 * Functionality: delete UE Configuration of a particular UE
3228 * @params[in] uint16_t cellIdx, uint8_t ueId
3229 * @return ROK - success
3232 * ****************************************************************/
3233 uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
3236 uint16_t cellIdx = 0;
3237 DuUeCb *ueCb = NULLP;
3239 GET_CELL_IDX(cellId, cellIdx);
3240 if(duCb.actvCellLst[cellIdx] != NULLP)
3242 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3243 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3245 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3246 deleteMacUeCfg(&ueCb->macUeCfg);
3247 deleteRlcUeCfg(&ueCb->rlcUeCfg);
3248 if(ueCb->f1UeDb !=NULLP)
3250 freeF1UeDb(ueCb->f1UeDb);
3252 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3254 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3256 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3257 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3262 unsetBitInUeBitMap(cellId, ueId-1);
3263 duCb.actvCellLst[cellIdx]->numActvUes--;
3264 memset(ueCb, 0, sizeof(DuUeCb));
3273 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3280 /*******************************************************************
3282 * @brief Handle UE delete response from MAC
3286 * Function : DuProcMacUeDeleteRsp
3288 * Functionality: Handle UE delete response from MAC
3290 * @params[in] Pointer to MacUeDeleteRsp and Pst
3291 * @return ROK - success
3294 * ****************************************************************/
3296 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3298 uint8_t ret =ROK,ueId=0;
3300 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3304 if(deleteRsp->result == DEL_SUCCESSFUL)
3306 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3307 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3308 if(duCb.actvCellLst[cellIdx])
3310 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3311 ueId = deleteRsp->ueId;
3312 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3313 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3314 if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
3316 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3319 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3327 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3331 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3335 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3341 /*******************************************************************
3343 * @brief Processes UE Delete Rsp received from RLC
3347 * Function : DuProcRlcUeDeleteRsp
3350 * Processes UE Delete Rsp received from RLC
3352 * @params[in] Post structure
3353 * Pointer to RlcUeDeleteRsp
3354 * @return ROK - success
3357 * *****************************************************************/
3359 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3361 uint8_t ueId = 0, ret = ROK;
3362 uint16_t cellIdx = 0,crnti=0;
3366 ueId = delRsp->ueId;
3367 GET_CELL_IDX(delRsp->cellId, cellIdx);
3369 if(delRsp->result == SUCCESSFUL)
3371 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3372 if(duCb.actvCellLst[cellIdx]!=NULLP)
3374 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3375 GET_CRNTI(crnti, ueId);
3376 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3378 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3386 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3389 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3395 /*******************************************************************
3397 * @brief Sending UE Delete Req To Mac
3401 * Function : sendUeDeleteReqToMac
3404 * sending UE Delete Req To Mac
3406 * @params[in] cellId, ueId, crnti
3407 * @return ROK - success
3410 *****************************************************************/
3412 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3416 MacUeDelete *ueDelete = NULLP;
3418 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3421 ueDelete->cellId = cellId;
3422 ueDelete->ueId = ueId;
3423 ueDelete->crnti = crnti;
3424 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3426 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3427 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3430 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3431 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3436 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3442 /*******************************************************************
3444 * @brief Sending UE Delete Req To Rlc
3448 * Function : sendUeDeleteReqToRlc
3451 * Sending UE Delete Req To Rlc
3453 * @params[in] cellId, ueId
3454 * @return ROK - success
3457 *****************************************************************/
3459 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3463 RlcUeDelete *ueDelete;
3465 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3466 if(ueDelete !=NULLP)
3468 ueDelete->cellId = cellId;
3469 ueDelete->ueId = ueId;
3470 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3472 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3475 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3476 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3481 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3487 /*******************************************************************
3489 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3493 * Function : duBuildAndSendUeDeleteReq
3495 * Functionality: DU processes UE delete req from CU and sends to MAC
3498 * @params[in] cellId, crnti
3499 * @return ROK - success
3502 * ****************************************************************/
3504 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3507 uint16_t cellIdx = 0;
3509 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3510 GET_CELL_IDX(cellId, cellIdx);
3511 GET_UE_ID(crnti, ueId);
3513 if(duCb.actvCellLst[cellIdx] != NULLP)
3515 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3517 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3521 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3522 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3524 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3530 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3537 /*******************************************************************
3539 * @brief delete RlcUeCfg from duCb
3543 * Function : deleteRlcUeCfg
3546 * delete RlcUeCfg from duCb
3548 * @params[in] RlcUeCfg *ueCfg
3550 * @return ROK - success
3553 *****************************************************************/
3555 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3558 RlcBearerCfg *lcCfg= NULLP;
3561 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3563 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3564 switch(lcCfg->rlcMode)
3568 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3571 case RLC_UM_BI_DIRECTIONAL :
3573 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3576 case RLC_UM_UNI_DIRECTIONAL_UL :
3578 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3581 case RLC_UM_UNI_DIRECTIONAL_DL :
3583 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3587 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3589 memset(ueCfg, 0, sizeof(RlcUeCfg));
3593 /*******************************************************************
3595 * @brief Du process Ue Context Release Command
3599 * Function : duProcUeContextReleaseCommand
3601 * Functionality: Du process Ue Context Release Command
3603 * @params[in] DuUeCb *duUeCb
3604 * @return ROK - success
3607 * ****************************************************************/
3608 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3610 uint8_t ret =ROK, ueId=0;
3615 crnti = duUeCb->crnti;
3616 GET_UE_ID(crnti, ueId);
3620 /* Send DL RRC msg for RRC release */
3621 if(duUeCb->f1UeDb->dlRrcMsg)
3623 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3625 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3626 duUeCb->f1UeDb->dlRrcMsg);
3629 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3630 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3631 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3632 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3639 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3642 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3649 /**********************************************************************
3651 ***********************************************************************/