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 /*As per Spec ORAN WG8 AAD, lcId for DL RRC range from 1...3*/
393 if((f1DlRrcMsg->srbId < SRB1_LCID) || (f1DlRrcMsg->srbId > SRB3_LCID))
395 DU_LOG("\nERROR --> DU APP : Received SRBID for this Dl RRC Msg is not valid");
399 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
403 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
404 duBuildAndSendDlRrcMsgToRlc");
405 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
409 /* Filling up the RRC msg info */
410 dlRrcMsgInfo->cellId = cellId;
411 dlRrcMsgInfo->ueId = ueCfg.ueId;
412 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
414 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
416 dlRrcMsgInfo->lcId = f1DlRrcMsg->srbId;
420 if(lcIdx == (MAX_NUM_LC + 1))
422 DU_LOG("\nERROR --> DU APP : (duBuildAndSendDlRrcMsgToRlc) SRB for this DL_RRC msg is not configured.");
423 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
427 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
428 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
429 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
430 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
432 /* Filling post structure and sending msg */
433 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
434 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
435 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
438 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
439 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
448 /******************************************************************
450 * @brief Process DL RRC Msg recevied from F1AP
454 * Function : duProcDlRrcMsg
456 * Functionality: Process DL RRC Msg recevied from F1AP
458 * @params[in] dlCcchMsg - uint8_t*
459 * @return ROK - success
462 * ****************************************************************/
464 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
467 uint16_t crnti, cellId, cellIdx;
468 bool ueCcchCtxtFound = false;
469 bool ueFound = false;
473 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
475 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
477 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
479 ueCcchCtxtFound = true;
480 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
481 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
488 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
491 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
495 if(duCb.actvCellLst[cellId-1] == NULLP)
497 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
500 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
502 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
505 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
506 duCb.ueCcchCtxt[ueIdx].cellId);
511 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
518 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
520 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
522 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
523 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
526 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
527 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
530 DU_LOG("\nERROR --> DU_APP: duBuildAndSendDlRrcMsgToRlc() Failed for UE ID:%d", dlRrcMsg->gnbDuUeF1apId);
541 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
548 /******************************************************************
550 * @brief Processes UL CCCH Ind recvd from MAC
554 * Function : duProcUlCcchInd
556 * Functionality: Processes UL CCCH Ind recvd from MAC
558 * @params[in] UlCcchIndInfo *ulCcchIndInfo
559 * @return ROK - success
562 * ****************************************************************/
563 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
567 int32_t gnbDuUeF1apId = 0;
569 if(ulCcchIndInfo->crnti)
571 GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
575 DU_LOG("\nERROR --> DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
579 /* Store Ue mapping */
580 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
581 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
582 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
586 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
587 ulCcchIndInfo->ulCcchMsg));
590 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
593 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
594 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
600 /******************************************************************
602 * @brief Fills Default UL LC Cfg
606 * Function : fillDefaultUlLcCfg
608 * Functionality: Fills Default UL LC Cfg
610 * @params[in] UlLcCfg *ulLcCfg
612 *****************************************************************/
613 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
615 ulLcCfg->priority = LC_PRIORITY_1;
616 ulLcCfg->lcGroup = 0;
617 ulLcCfg->schReqId = 0;
618 ulLcCfg->pbr = PBR_KBPS_INFINITY;
619 ulLcCfg->bsd = BSD_MS_1000;
622 /******************************************************************
624 * @brief Fills Initial DL Bandwidth Part
628 * Function : fillDefaultInitDlBwp
630 * Functionality: Fills Initial DL Bandwidth Part
632 * @params[in] InitialDlBwp *initDlBwp
633 * @return ROK - success
636 *****************************************************************/
637 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
640 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
641 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
645 /* Filling PDCCH Config */
646 initDlBwp->pdcchPresent = TRUE;
647 if(initDlBwp->pdcchPresent)
649 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
650 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
651 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
653 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
654 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
655 coreset0EndPrb = CORESET0_END_PRB;
656 coreset1StartPrb = coreset0EndPrb +6;
657 coreset1NumPrb = CORESET1_NUM_PRB;
658 /* calculate the PRBs */
659 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
660 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
662 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
663 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
664 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
665 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
667 initDlBwp->pdcchCfg.numCRsetToRel = 0;
669 /* Filling Serach Space */
670 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
671 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
672 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
674 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
675 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
676 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
677 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
678 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
680 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
682 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
683 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
684 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
687 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
690 /* Filling PDSCH Config */
691 initDlBwp->pdschPresent = TRUE;
692 if(initDlBwp->pdschPresent)
694 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
695 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
697 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
700 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
701 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
702 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
703 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
706 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
707 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
709 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
712 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
713 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
714 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
715 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
716 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
717 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
719 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
720 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
721 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
722 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
729 /******************************************************************
731 * @brief Fills Initial UL Bandwidth Part
735 * Function : fillDefaultInitUlBwp
737 * Functionality: Fills Initial UL Bandwidth Part
739 * @params[in] InitialUlBwp *initUlBwp
742 *****************************************************************/
743 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
748 initUlBwp->pucchPresent = FALSE;
750 /*Filling PUSCH Config */
751 initUlBwp->puschPresent = TRUE;
752 if(initUlBwp->puschPresent)
754 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
755 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
756 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
757 scramblingId0 = SCRAMBLING_ID;
758 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
759 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
761 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
763 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
764 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
766 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
767 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
768 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
769 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
772 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
773 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
774 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
775 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
776 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
777 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
779 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
784 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
788 /******************************************************************
790 * @brief Fills SpCell Group Info
794 * Function : fillDefaultSpCellGrpInfo
796 * Functionality: Fills Sp Cell Group Info
798 * @params[in] DuMacUeCfg *macUeCfg
799 * @return ROK - Success
802 *****************************************************************/
803 uint8_t fillDefaultSpCellGrpInfo(DuMacUeCfg *macUeCfg)
805 SpCellRecfg *spCell = NULL;
808 spCell = &macUeCfg->spCellCfg;
812 macUeCfg->spCellCfgPres = true;
814 spCell->servCellIdx = SERV_CELL_IDX;
815 /* Filling Initial Dl Bwp */
816 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
818 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
822 spCell->servCellCfg.numDlBwpToAddOrMod = 0;
823 spCell->servCellCfg.numDlBwpToRel = 0;
824 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
825 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
826 spCell->servCellCfg.bwpInactivityTmr = NULLP;
827 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
828 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
829 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
830 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
831 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
833 /* Filling Initial UL Bwp*/
834 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
835 spCell->servCellCfg.numUlBwpToAddOrMod = 0;
836 spCell->servCellCfg.numUlBwpToRel = 0;
837 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
841 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
847 /******************************************************************
849 * @brief Fills Physical Cell Group Info
853 * Function : fillDefaultPhyCellGrpInfo
855 * Functionality: Fills Physical Cell Group Info
857 * @params[in] DuMacUeCfg *macUeCfg
860 *****************************************************************/
861 void fillDefaultPhyCellGrpInfo(DuMacUeCfg *macUeCfg)
863 PhyCellGrpCfg *cellGrp = NULL;
866 cellGrp = &macUeCfg->phyCellGrpCfg;
870 macUeCfg->phyCellGrpCfgPres = true;
871 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
872 cellGrp->pNrFr1 = P_NR_FR1;
876 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
880 /******************************************************************
882 * @brief Fills Mac Cell Group Info
886 * Function : fillDefaultMacCellGrpInfo
888 * Functionality: Fills Mac Cell Group Info
890 * @params[in] DuMacUeCfg *macUeCfg
893 *****************************************************************/
894 void fillDefaultMacCellGrpInfo(DuMacUeCfg *macUeCfg)
897 MacCellGrpCfg *cellGrp = NULL;
900 cellGrp = &macUeCfg->macCellGrpCfg;
904 macUeCfg->macCellGrpCfgPres = true;
906 /* Filling Scheduling Request Config */
907 cellGrp->schReqCfg.addModListCount = 1;
908 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
910 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
912 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
913 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
914 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
917 cellGrp->schReqCfg.relListCount = 0;
919 /* Filling Tag config */
920 cellGrp->tagCfg.addModListCount = 1;
921 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
923 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
925 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
926 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
929 cellGrp->tagCfg.relListCount = 0;
931 /* Filling BSR config */
932 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
933 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
934 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
936 /* Filling PHR config */
937 cellGrp->phrCfgSetupPres = true;
938 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
939 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
940 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
941 cellGrp->phrCfg.multiplePHR = false;
942 cellGrp->phrCfg.dummy = false;
943 cellGrp->phrCfg.phrType2OtherCell = false;
944 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
946 /* Filling Drx Config */
948 cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = DRX_ONDURATION_TIMER_VALUE_PRESENT_IN_MS;
949 if(!cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
950 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
951 DRX_ONDURATION_TIMER_VALUE_IN_SUBMS;
953 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
954 DRX_ONDURATION_TIMER_VALUE_IN_MS;
955 cellGrp->drxCfg.drxInactivityTimer = DRX_INACTIVITY_TIMER;
956 cellGrp->drxCfg.drxHarqRttTimerDl = DRX_HARQ_RTT_TIMER_DL;
957 cellGrp->drxCfg.drxHarqRttTimerUl = DRX_HARQ_RTT_TIMER_UL;
958 cellGrp->drxCfg.drxRetransmissionTimerDl = DRX_RETRANSMISSION_TIMER_DL;
959 cellGrp->drxCfg.drxRetransmissionTimerUl = DRX_RETRANSMISSION_TIMER_UL;
960 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = DRX_LONG_CYCLE_START_OFFSET_VAL;
961 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = DRX_LONG_CYCLE_START_OFFSET_CHOICE;
962 cellGrp->drxCfg.shortDrxPres = DRX_SHORT_CYCLE_PRESENT;
963 if(cellGrp->drxCfg.shortDrxPres)
965 cellGrp->drxCfg.shortDrx.drxShortCycle = DRX_SHORT_CYCLE;
966 cellGrp->drxCfg.shortDrx.drxShortCycleTimer = DRX_SHORT_CYCLE_TIMER;
968 cellGrp->drxCfg.drxSlotOffset = DRX_SLOT_OFFSET;
974 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
978 /*******************************************************************
980 * @brief Fills default modulation info for a UE
984 * Function : fillDefaultModulation
986 * Functionality: Fills default modulation info for a UE
988 * @params[in] Pointer to MAC UE configuration
989 * @return ROK - success
992 * ****************************************************************/
993 void fillDefaultModulation(DuMacUeCfg *ueCfg)
995 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
996 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
997 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
999 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
1000 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
1001 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1004 /******************************************************************
1006 * @brief Function to fill Mac Lc Cfg for SRB1
1010 * Function : fillMacSrb1LcCfg
1012 * Functionality: Function to fill Mac Lc cfg for SRB1
1014 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1016 *****************************************************************/
1018 void fillMacSrb1LcCfg(DuLcCfg *macLcCfg)
1020 macLcCfg->lcConfig.lcId = SRB1_LCID;
1021 macLcCfg->configType = CONFIG_ADD;
1022 macLcCfg->lcConfig.drbQos = NULLP;
1023 macLcCfg->lcConfig.snssai = NULLP;
1024 macLcCfg->lcConfig.ulLcCfgPres = true;
1025 fillDefaultUlLcCfg(&macLcCfg->lcConfig.ulLcCfg);
1028 /******************************************************************
1030 * @brief Function to fill the Lc cfg from ueSetupReqDb
1034 * Function : fillMacLcCfgToAddMod
1036 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1038 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1039 * @return ROK/RFAILED
1041 *****************************************************************/
1043 uint8_t fillMacLcCfgToAddMod(DuLcCfg *macLcCfgToSend, DuLcCfg *ueLcCfgDb, DuLcCfg *oldLcCfg, Bool toUpdate)
1049 macLcCfgToSend->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1050 macLcCfgToSend->configType = ueLcCfgDb->configType;
1052 if(ueLcCfgDb->lcConfig.drbQos)
1053 macLcCfgToSend->lcConfig.drbQos = ueLcCfgDb->lcConfig.drbQos;
1055 macLcCfgToSend->lcConfig.drbQos = oldLcCfg->lcConfig.drbQos;
1057 macLcCfgToSend->lcConfig.drbQos = NULL;
1059 if(ueLcCfgDb->lcConfig.snssai)
1060 macLcCfgToSend->lcConfig.snssai = ueLcCfgDb->lcConfig.snssai;
1062 macLcCfgToSend->lcConfig.snssai = oldLcCfg->lcConfig.snssai;
1064 macLcCfgToSend->lcConfig.snssai = NULL;
1066 macLcCfgToSend->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1067 memcpy(&macLcCfgToSend->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1068 memcpy(&macLcCfgToSend->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1073 oldLcCfg->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1074 oldLcCfg->configType = ueLcCfgDb->configType;
1076 if(ueLcCfgDb->lcConfig.drbQos)
1078 if(oldLcCfg->lcConfig.drbQos)
1079 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1081 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1082 if(oldLcCfg->lcConfig.drbQos == NULL)
1084 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1087 memcpy(oldLcCfg->lcConfig.drbQos, ueLcCfgDb->lcConfig.drbQos, sizeof(DrbQosInfo));
1090 if(ueLcCfgDb->lcConfig.snssai)
1092 if(oldLcCfg->lcConfig.snssai)
1093 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1095 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1096 if(oldLcCfg->lcConfig.snssai == NULL)
1098 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1099 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1102 memcpy(oldLcCfg->lcConfig.snssai, ueLcCfgDb->lcConfig.snssai, sizeof(Snssai));
1105 oldLcCfg->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1106 memcpy(&oldLcCfg->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1107 memcpy(&oldLcCfg->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1112 /******************************************************************
1114 * @brief Function to copy the Bit rate from ueSetupReqDb
1118 * Function : fillAmbr
1120 * Functionality: Function to copy bit Rate from ueSetupReqDb
1122 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1123 * @return ROK/RFAILED
1125 *****************************************************************/
1127 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1133 *macAmbrCfgToSend = ueDbAmbr;
1135 else if(oldMacAmbrCfg)
1136 *macAmbrCfgToSend = *oldMacAmbrCfg;
1146 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1148 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1149 if(*oldMacAmbrCfg == NULLP)
1151 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1154 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1155 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1163 /******************************************************************
1165 * @brief Builds and Send UE ReConfig Request to MAC
1169 * Function : sendUeRecfgReqToMac
1171 * Functionality: Builds and Send UE ReConfig Request to MAC
1173 * @Params[in] MacUeRecfg pointer
1174 * @return ROK - success
1177 * ****************************************************************/
1179 uint8_t sendUeRecfgReqToMac(MacUeRecfg *macUeRecfg)
1185 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1189 /* Processing one Ue at a time to MAC */
1190 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1191 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeRecfg);
1194 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeRecfgReqToMac()");
1195 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeRecfg, sizeof(MacUeRecfg));
1200 DU_LOG("\nERROR --> DU_APP: Received macUeRecfg is NULLP at sendUeRecfgReqToMac()");
1208 /******************************************************************
1210 * @brief update DuMacUeCfg structure
1214 * Function : updateDuMacUeCfg
1216 * Functionality: Fills DuMacUeCfg
1218 * @params[in] cellId, ueId, crnti,
1220 * DuMacUeCfg pointer
1221 * @return ROK/RFAILED
1223 *****************************************************************/
1224 uint8_t updateDuMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1226 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1227 bool lcIdFound = false;
1228 DuMacUeCfg *duMacDb = NULLP;
1230 duMacUeCfg->cellId = cellId;
1231 duMacUeCfg->ueId = gnbDuUef1apId;
1232 duMacUeCfg->crnti = crnti;
1236 fillDefaultMacCellGrpInfo(duMacUeCfg);
1237 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1239 if((fillDefaultSpCellGrpInfo(duMacUeCfg)) != ROK)
1241 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1245 duMacUeCfg->ambrCfg = NULLP;
1246 fillDefaultModulation(duMacUeCfg);
1247 fillMacSrb1LcCfg(&duMacUeCfg->lcCfgList[0]);
1248 duMacUeCfg->numLcs++;
1252 if(ueCfgDb->dataTransmissionAction == STOP_TRANSMISSION)
1254 duMacUeCfg->transmissionAction = ueCfgDb->dataTransmissionAction;
1258 GET_CELL_IDX(cellId, cellIdx);
1259 if(duCb.actvCellLst[cellIdx])
1260 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[duMacUeCfg->ueId-1].duMacUeCfg;
1263 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1266 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1268 if(ueCfgDb->cellGrpCfg)
1270 ret = procUeRecfgCellInfo(duMacUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1273 if(duMacUeCfg->spCellCfgPres == true)
1275 if(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1277 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1278 &duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1280 if(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1282 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1283 NULL, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1288 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1290 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1292 duFillModulationDetails(duMacUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1297 fillDefaultMacCellGrpInfo(duMacUeCfg);
1298 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1299 fillDefaultSpCellGrpInfo(duMacUeCfg);
1300 fillDefaultModulation(duMacUeCfg);
1301 duMacUeCfg->ambrCfg = NULLP;
1306 duMacUeCfg->drxConfigIndicatorRelease = ueCfgDb->drxConfigIndicatorRelease;
1308 if(ueCfgDb->drxCyclePres)
1310 duMacUeCfg->macCellGrpCfg.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = ueCfgDb->drxCycle.drxLongCycleLength;
1311 if(ueCfgDb->drxCycle.shortDrxCyclePres)
1313 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = true;
1314 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycle = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycle;
1315 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycleTimer;
1319 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = false;
1324 /* Filling LC Context */
1325 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1327 if(!ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres)
1329 /* Filling default UL LC config in MAC if not present */
1330 ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres = true;
1331 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfg);
1336 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1338 if(ueCfgDb->macLcCfg[dbIdx].lcConfig.lcId == duMacDb->lcCfgList[lcIdx].lcConfig.lcId)
1341 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1342 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1344 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1345 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1346 &duMacDb->lcCfgList[lcIdx], FALSE);
1356 /* ADD/DEL CONFIG */
1357 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1361 duMacUeCfg->numLcs++;
1365 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in updateDuMacUeCfg()", dbIdx);
1368 }/*End of Outer FOR loop */
1369 memcpy(&ueCfgDb->copyOfmacUeCfg, duMacUeCfg, sizeof(DuMacUeCfg));
1374 /******************************************************************
1376 * @brief Fills Rlc AM Information
1380 * Function : fillDefaultAmInfo
1382 * Functionality: Fills Rlc AM Information
1384 * @params[in] AmBearerCfg *amCfg
1387 *****************************************************************/
1388 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1391 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1392 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1393 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1394 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1395 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1398 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1399 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1400 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1403 /******************************************************************
1405 * @brief Fills RLC UM Bi Directional Information
1409 * Function : fillDefaultUmBiInfo
1411 * Functionality: Fills RLC UM Bi Directional Information
1413 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1416 *****************************************************************/
1417 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1419 /* UL UM BI DIR INFO */
1420 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1421 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1423 /* DL UM BI DIR INFO */
1424 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1427 /******************************************************************
1429 * @brief Fills RLC UM Uni Directional UL Information
1433 * Function : fillDefaultUmUlInfo
1435 * Functionality: Fills RLC UM Uni Directional Info
1437 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1440 *****************************************************************/
1441 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1443 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1444 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1447 /******************************************************************
1449 * @brief Fills RLC UM Uni Directional DL Information
1453 * Function : fillDefaultUmDlInfo
1455 * Functionality: Fills RLC UM Uni Directional DL Info
1457 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1460 *****************************************************************/
1461 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1463 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1466 /******************************************************************
1468 * @brief Builds Rlc Mode Default Configuration
1472 * Function : fillDefaultRlcModeCfg
1474 * Functionality: Builds Rlc Mode Default Configuration
1476 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1477 * @return ROK/RFAILED
1479 *****************************************************************/
1481 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1491 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1493 fillDefaultAmInfo(lcCfg->u.amCfg);
1496 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1502 case RLC_UM_BI_DIRECTIONAL :
1504 if(!lcCfg->u.umBiDirCfg)
1506 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1507 if(lcCfg->u.umBiDirCfg)
1508 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1511 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1517 case RLC_UM_UNI_DIRECTIONAL_UL :
1519 if(!lcCfg->u.umUniDirUlCfg)
1521 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1522 if(lcCfg->u.umUniDirUlCfg)
1523 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1526 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1532 case RLC_UM_UNI_DIRECTIONAL_DL :
1534 if(!lcCfg->u.umUniDirDlCfg)
1536 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1537 if(lcCfg->u.umUniDirDlCfg)
1538 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1541 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1548 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1555 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1561 /*******************************************************************
1563 * @brief Function to fill Rlc Lc Cfg for SRB1
1567 * Function : fillRlcSrb1LcCfg
1570 * Function to fill Rlc Lc Cfg for SRB1
1572 * @params[in] Pointer to RlcBearerCfg
1573 * @return ROK/RFAILED
1575 *****************************************************************/
1577 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1581 rlcLcCfg->rbId = SRB1_LCID;
1582 rlcLcCfg->rbType = RB_TYPE_SRB;
1583 rlcLcCfg->lcId = SRB1_LCID;
1584 rlcLcCfg->lcType = LCH_DCCH;
1585 rlcLcCfg->rlcMode = RLC_AM;
1586 rlcLcCfg->configType = CONFIG_ADD;
1587 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1588 rlcLcCfg->isLcAddModRspSent = true;
1592 /*******************************************************************
1594 * @brief Processes UE ReConfig Req to RLC UL
1598 * Function : sendUeRecfgReqToRlc
1601 * Processes UE Reconfig Req to RLC UL
1603 * @params[in] Pointer to RlcUeCfg
1604 * @return ROK - success
1607 *****************************************************************/
1609 uint8_t sendUeRecfgReqToRlc(RlcUeCfg *rlcUeCfg)
1614 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1617 /* Processing one Ue at a time to RLC */
1618 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1619 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1622 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeRecfgReqToRlc()");
1623 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1628 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeRecfgReqToRlc()");
1634 /******************************************************************
1636 * @brief Fills Snssai information
1640 * Function : fillSnssaiInfo
1642 * Functionality: Fills Snssai information
1644 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1646 * @return ROK - success
1649 *****************************************************************/
1650 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1655 snssaiTobeSend = snssaiDb;
1657 snssaiTobeSend = *oldSnssai;
1659 snssaiTobeSend = NULL;
1666 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1668 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1669 if(*oldSnssai == NULL)
1671 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1674 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1679 /******************************************************************
1681 * @brief Fills RlcBearerCfg structure
1685 * Function : fillRlcUeCfg
1687 * Functionality: Fills Rlc Bearer Cfg
1690 *****************************************************************/
1691 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t duUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1693 uint8_t ret, dbIdx, lcIdx, cellIdx;
1694 bool lcIdFound = false;
1695 RlcUeCfg *duRlcDb = NULLP;
1698 rlcUeCfg->cellId = cellId;
1699 rlcUeCfg->ueId = duUeF1apId;
1703 /* Initial RB being Added */
1704 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1708 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1712 /* Fetch RlcDb from DuUeCb */
1713 GET_CELL_IDX(cellId, cellIdx);
1714 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[rlcUeCfg->ueId-1].rlcUeCfg;
1715 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1717 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1719 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1722 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1723 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1729 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1730 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1732 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1735 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1736 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1739 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1740 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1741 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1742 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1752 /* ADD/ DEL Config Type */
1753 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1754 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1762 /******************************************************************
1764 * @brief creates UE context
1768 * Function : duCreateUeCb
1770 * Functionality: Creates UE Conetxt
1772 * @params[in] UeCcchCtxt Pointer
1775 * @return ROK - success
1777 * ****************************************************************/
1778 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1780 uint8_t cellIdx = 0;
1782 uint8_t ueId = 0, ueIdx = 0;
1784 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1786 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1788 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1789 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1792 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1793 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1794 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1795 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1796 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1797 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1799 /* Filling Mac Ue Config */
1800 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg, 0, sizeof(DuMacUeCfg));
1801 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1802 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg);
1804 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1806 /* Filling Rlc Ue Config */
1807 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1808 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, NULL,
1809 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1811 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1813 duCb.actvCellLst[cellIdx]->numActvUes++;
1814 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1821 /**********************************************************************************
1823 * @brief Fills Ue Cfg from DU DB to MacUeCfg
1827 * Function : fillMacUeCfg
1829 * Functionality: fills ue Cfg to be sent to MAC
1831 * @params[in] DuMacUeCfg Pointer
1834 * @return ROK - success
1836 * *******************************************************************************/
1837 void fillMacUeCfg(DuMacUeCfg *duMacUeCfg, MacUeCfg *macUeCfg)
1841 macUeCfg->cellId = duMacUeCfg->cellId;
1842 macUeCfg->ueId = duMacUeCfg->ueId;
1843 macUeCfg->crnti = duMacUeCfg->crnti;
1844 macUeCfg->macCellGrpCfgPres = duMacUeCfg->macCellGrpCfgPres;
1845 if(macUeCfg->macCellGrpCfgPres)
1847 memcpy(&macUeCfg->macCellGrpCfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
1849 macUeCfg->phyCellGrpCfgPres = duMacUeCfg->phyCellGrpCfgPres;
1850 if(macUeCfg->phyCellGrpCfgPres)
1852 memcpy(&macUeCfg->phyCellGrpCfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
1854 macUeCfg->spCellCfgPres = duMacUeCfg->spCellCfgPres;
1855 if(macUeCfg->spCellCfgPres)
1857 macUeCfg->spCellCfg.servCellIdx = duMacUeCfg->spCellCfg.servCellIdx;
1858 macUeCfg->spCellCfg.servCellCfg.initDlBwp = duMacUeCfg->spCellCfg.servCellCfg.initDlBwp;
1859 macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numDlBwpToAddOrMod;
1860 if(macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd > 0)
1862 memcpy(macUeCfg->spCellCfg.servCellCfg.dlBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.dlBwpToAddOrModList, \
1863 (sizeof(DlBwpInfo) * MAX_NUM_BWP));
1865 macUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId;
1866 macUeCfg->spCellCfg.servCellCfg.defaultDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.defaultDlBwpId;
1867 macUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr = duMacUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr;
1868 memcpy(&macUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, &duMacUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, sizeof(PdschServCellCfg));
1869 memcpy(&macUeCfg->spCellCfg.servCellCfg.initUlBwp, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp, sizeof(InitialUlBwp));
1870 macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numUlBwpToAddOrMod;
1871 if(macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd > 0)
1873 memcpy(macUeCfg->spCellCfg.servCellCfg.ulBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.ulBwpToAddOrModList,\
1874 (sizeof(UlBwpInfo) * MAX_NUM_BWP));
1876 macUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId;
1878 if(duMacUeCfg->ambrCfg != NULLP)
1880 memcpy(macUeCfg->ambrCfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
1882 memcpy(&macUeCfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
1883 memcpy(&macUeCfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
1884 if(duMacUeCfg->numLcs > 0)
1886 macUeCfg->numLcs = 0;
1887 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
1889 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1891 //VS: To thoroughly check
1892 memcpy(&macUeCfg->lcCfgList[macUeCfg->numLcs], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
1899 /******************************************************************
1901 * @brief Builds and Send UE Create Request to MAC
1905 * Function : duBuildAndSendUeCreateReqToMac
1907 * Functionality: Builds and Send UE Create Request to MAC
1909 * @Params[in] cellId,
1912 * UE config extracted from F1AP msg
1913 * MAC UE config struct to be filled
1914 * @return ROK - success
1917 * ****************************************************************/
1919 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1922 MacUeCfg *macUeCfg = NULLP;
1924 memset(&pst, 0, sizeof(Pst));
1927 ret = updateDuMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1930 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1935 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1937 /* Copying ueCb to a sharable buffer */
1938 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1941 memset(macUeCfg, 0, sizeof(MacUeCfg));
1942 fillMacUeCfg(duMacUeCfg, macUeCfg);
1943 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1945 /* Processing one Ue at a time to MAC */
1946 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1949 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1950 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1955 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1961 /*******************************************************************
1963 * @brief Build and send RACH Resource request to MAC
1967 * Function : duBuildAndSendRachRsrcReqToMac
1969 * Build and send RACH Resource request to MAC
1971 * @params[in] Cell Id
1973 * @return ROK - success
1976 * ****************************************************************/
1977 uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
1979 uint16_t cellIdx = 0, ssbIdx = 0;
1981 MacRachRsrcReq *rachRsrcReq = NULLP;
1983 GET_CELL_IDX(cellId, cellIdx);
1984 if(duCb.actvCellLst[cellIdx] == NULLP)
1986 DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
1990 DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
1993 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
1994 duBuildAndSendRachRsrcReqToMac()");
1998 rachRsrcReq->cellId = cellId;
1999 rachRsrcReq->ueId = ueId;
2000 rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
2001 for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
2003 rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
2007 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
2009 if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
2011 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
2012 duBuildAndSendRachRsrcReqToMac()");
2013 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
2020 /*******************************************************************
2022 * @brief Process RACH resource response from MAC
2026 * Function : DuProcMacRachRsrcRsp
2028 * Process RACH resource response from MAC
2030 * @params[in] Post structure
2031 * RACH resource response
2032 * @return ROK - success
2035 * ****************************************************************/
2036 uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
2038 uint8_t ret = RFAILED;
2039 uint16_t cellIdx = 0;
2040 DuCellCb *cellCb = NULLP;
2041 DuUeCb *ueCb = NULLP;
2043 DU_LOG("\nINFO --> DU APP : Received RACH Resource Response from MAC. Cell ID [%d] UE ID [%d]",
2044 rachRsrcRsp->cellId, rachRsrcRsp->ueId);
2046 if(rachRsrcRsp->result == MAC_DU_APP_RSP_OK)
2048 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
2051 GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
2052 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
2054 cellCb = duCb.actvCellLst[cellIdx];
2057 if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
2059 ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
2061 /* Store CRNTI alloted to this UE by MAC */
2062 ueCb->crnti = rachRsrcRsp->newCrnti;
2064 /* Store the assigned CF-RA resources */
2065 memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
2067 /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
2068 * along with the result of UE Context setup requested by CU */
2069 if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
2070 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2073 DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
2076 DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
2079 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
2081 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
2085 /*******************************************************************
2087 * @brief To update DuUeCb Mac Cfg
2091 * Function : duUpdateMacCfg
2092 * Functionality: update DuUeCb MAC Cfg
2094 * @params[in] DuUeCb Pointer
2095 * F1UeContextSetupDb pointer
2096 * @return ROK - success
2099 * ****************************************************************/
2100 uint8_t duUpdateMacCfg(DuMacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
2102 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
2103 DuMacUeCfg *oldMacUeCfg;
2106 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
2107 if(duCb.actvCellLst[cellIdx] == NULLP)
2109 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
2112 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].duMacUeCfg;
2114 /*Filling Cell Group Cfg*/
2115 ret = procUeRecfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
2117 memcpy(&macUeCfg->macCellGrpCfg.drxCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg.macCellGrpCfg.drxCfg, sizeof(DrxCfg));
2121 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
2123 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
2124 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
2126 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
2128 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
2129 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
2131 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
2132 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
2135 /* Filling LC Context */
2136 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
2138 numLcs = macUeCfg->numLcs;
2139 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2141 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcConfig.lcId == macUeCfg->lcCfgList[lcIdx].lcConfig.lcId)
2143 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
2145 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
2147 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
2149 /* Free memory at matched lcIdx index */
2150 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx].lcConfig);
2152 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
2154 /* moving all elements one index ahead */
2155 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
2156 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1].lcConfig);
2159 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
2166 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
2168 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
2171 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
2181 /******************************************************************
2183 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
2187 * Function : fillRlcCfgToAddMod
2189 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
2192 *****************************************************************/
2194 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
2196 lcCfg->configType = f1UeDbLcCfg->configType;
2197 lcCfg->rbId = f1UeDbLcCfg->rbId;
2198 lcCfg->rbType = f1UeDbLcCfg->rbType;
2199 lcCfg->lcId = f1UeDbLcCfg->lcId;
2200 lcCfg->lcType = f1UeDbLcCfg->lcType;
2201 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
2203 switch(lcCfg->rlcMode)
2209 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
2214 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
2215 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
2216 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
2217 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
2218 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
2221 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
2222 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
2223 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
2226 case RLC_UM_BI_DIRECTIONAL :
2228 if(!lcCfg->u.umBiDirCfg)
2230 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2231 if(!lcCfg->u.umBiDirCfg)
2234 /* UL UM BI DIR INFO */
2235 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
2236 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
2237 /* DL UM BI DIR INFO */
2238 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
2241 case RLC_UM_UNI_DIRECTIONAL_UL :
2243 if(!lcCfg->u.umUniDirUlCfg)
2245 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2246 if(!lcCfg->u.umUniDirUlCfg)
2249 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
2250 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2254 case RLC_UM_UNI_DIRECTIONAL_DL :
2256 if(!lcCfg->u.umUniDirDlCfg)
2258 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2259 if(!lcCfg->u.umUniDirDlCfg)
2262 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2266 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
2272 /*******************************************************************
2274 * @brief To update DuUeCb Rlc Lc Cfg
2278 * Function : duUpdateRlcLcCfg
2279 * Functionality: update DuUeCb Rlc Lc Cfg
2281 * @params[in] DuUeCb Pointer
2282 * F1UeContextSetupDb pointer
2283 * @return ROK - success
2286 * ****************************************************************/
2288 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2290 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2293 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2295 numLcs = rlcUeCfg->numLcs;
2296 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2298 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2300 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2302 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2305 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2308 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2310 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2312 /* Free memory at matched lcIdx index */
2313 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2315 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2317 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2318 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2320 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2323 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2330 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2332 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2335 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2344 /*******************************************************************
2346 * @brief Function to fill Tunnel Config to Add/Mod
2351 * Function : fillTnlCfgToAddMod
2353 * Functionality: Function to fill tunnel Config to Add/Mod
2355 * @params[in] Pointer to tnlCfgDb,
2356 * pointer to f1TnlCfg
2357 * @return ROK - success
2360 * ****************************************************************/
2361 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2365 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2366 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2369 if(*ueCbTnlCfg == NULLP)
2371 /* copying to DuCb Tnl Cfg */
2372 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2373 if(*ueCbTnlCfg == NULLP)
2375 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2379 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2380 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2381 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2382 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2383 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2384 if(f1TnlCfg->tnlCfg1)
2386 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2388 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2389 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2391 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2395 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2396 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2397 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2398 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2403 /*******************************************************************
2405 * @brief Processing the tunnel Request to EGTP
2409 * Function : duProcEgtpTunnelCfg
2411 * Functionality: Processing the tunnel Request to EGTP
2413 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2414 * @return ROK - success
2417 * ****************************************************************/
2419 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2421 uint8_t ret = RFAILED, delIdx;
2423 if(f1TnlCfg->tnlCfg1 == NULLP)
2425 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2429 if(f1TnlCfg->configType == CONFIG_ADD)
2431 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2433 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2440 else if(f1TnlCfg->configType == CONFIG_MOD)
2442 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2444 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2450 else if(f1TnlCfg->configType == CONFIG_DEL)
2452 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2454 /* Free memory at drbIdx */
2456 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2458 /* moving all elements one index ahead */
2459 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2465 if(duCb.upTnlCfg[delIdx])
2467 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2468 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2475 /***********************************************************************
2477 * @brief Function to fill Tunnel Config
2478 * and sends tunnel Req to EGTP
2483 * Function : duUpdateTunnelCfgDb
2485 * Functionality: Function to fill tunnel Config
2486 * and sends tunnel Cfg Req to EGTP
2488 * @params[in] ueId, cellId, DuUeCfg
2489 * @return ROK - success
2492 * ****************************************************************/
2494 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2496 uint8_t ret = ROK, drbIdx, teIdx;
2497 bool drbFound = false;
2499 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2500 /*then update drbId and tunnel Info in duCb */
2501 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2503 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2504 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2505 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2507 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2508 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2510 drbFound = true; /* existing DRB */
2511 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2513 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2514 duUeCfg->upTnlInfo[drbIdx].drbId);
2523 if(!drbFound && ret == ROK)/* new DRB to Add */
2525 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2527 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2528 duUeCfg->upTnlInfo[drbIdx].drbId);
2537 /*******************************************************************
2539 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2544 * Function : duUpdateDuUeCbCfg
2546 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2548 * @params[in] ueId, cellIdx
2549 * @return ROK - success
2552 * ****************************************************************/
2554 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2556 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2557 DuUeCb *ueCb = NULLP;
2559 GET_CELL_IDX(cellId, cellIdx);
2560 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2562 /*Filling RLC Ue Cfg */
2563 ueCb->rlcUeCfg.cellId = cellId;
2564 ueCb->rlcUeCfg.ueId = ueId;
2565 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2568 /*Filling MAC Ue Cfg */
2569 GET_CRNTI(crnti, ueId);
2570 ueCb->duMacUeCfg.cellId = cellId;
2571 ueCb->duMacUeCfg.ueId = ueId;
2572 ueCb->duMacUeCfg.crnti = crnti;
2573 ret = duUpdateMacCfg(&ueCb->duMacUeCfg, ueCb->f1UeDb);
2575 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2578 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2580 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2586 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2590 /*******************************************************************
2592 * @brief Handle UE config response from MAC
2596 * Function : DuProcMacUeCfgRsp
2598 * Functionality: Handle UE Config response from MAC
2600 * @params[in] Pointer to MacUeCfgRsp and Pst
2601 * @return ROK - success
2604 * ****************************************************************/
2605 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2612 GET_CELL_IDX(cfgRsp->cellId, cellIdx);
2613 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2615 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2617 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2619 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2621 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2623 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2624 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2625 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2627 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2629 /* If UE is in handover, RACH resource needs to be requested
2630 * from MAC for CFRA */
2631 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2633 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2634 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2640 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2641 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2650 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
2653 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2657 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2663 /*******************************************************************
2665 * @brief Handle UE Reconfig response from MAC
2669 * Function : DuProcMacUeRecfgRsp
2671 * Functionality: Handle UE ReConfig response from MAC
2673 * @params[in] Pointer to MacUeRecfgRsp and Pst
2674 * @return ROK - success
2677 * ****************************************************************/
2678 uint8_t DuProcMacUeRecfgRsp(Pst *pst, MacUeRecfgRsp *reCfgRsp)
2685 GET_CELL_IDX(reCfgRsp->cellId, cellIdx);
2686 if(reCfgRsp->result == MAC_DU_APP_RSP_OK)
2688 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2690 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", reCfgRsp->ueId);
2691 if(duCb.actvCellLst[cellIdx] &&
2692 (duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].gnbDuUeF1apId == reCfgRsp->ueId))
2694 duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2695 if((duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2696 (duCb.actvCellLst[reCfgRsp->cellId -1]->ueCb[reCfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2698 if((ret = duUpdateDuUeCbCfg(reCfgRsp->ueId, reCfgRsp->cellId)) == ROK)
2700 if((BuildAndSendUeCtxtRsp(reCfgRsp->cellId, reCfgRsp->ueId)) != ROK)
2702 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2703 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2709 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2710 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2719 DU_LOG("\nERROR --> DU APP : MAC UE RECFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, reCfgRsp->ueId);
2720 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2722 //TODO: Send the failure case in Ue Context Setup Response
2726 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2730 DU_LOG("\nERROR --> DU APP : Received MAC Ue ReConfig Response is NULL at DuProcMacUeRecfgRsp()");
2736 /*******************************************************************
2738 * @brief Processes UE create Req to RLC UL
2742 * Function : duBuildAndSendUeCreateReqToRlc
2745 * Processes UE create Req to RLC UL
2747 * @params[in] cellId,
2749 * Pointer to RlcUeCfg
2750 * @return ROK - success
2753 *****************************************************************/
2755 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *duRlcUeCfg)
2758 RlcUeCfg *rlcUeCfg = NULLP;
2761 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
2764 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2768 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2769 /* Copying ueCfg to a sharable buffer */
2770 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2773 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2774 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2775 /* Processing one Ue at a time to RLC */
2776 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2777 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2780 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2781 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2787 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2793 /*******************************************************************
2795 * @brief Processes UE create Rsp received from RLC UL
2800 * Function : DuProcRlcUeCfgRsp
2803 * Processes UE create Rsp received from RLC UL
2805 * @params[in] Post structure
2806 * Pointer to RlcCfgCfm
2807 * @return ROK - success
2810 *****************************************************************/
2811 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2817 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2819 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2821 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2822 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2824 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2825 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2826 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2828 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2830 /* If UE is in handover, RACH resource needs to be requested
2831 * from MAC for CFRA */
2832 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2834 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2835 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2836 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2842 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2843 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2848 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2850 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2852 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2853 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2854 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2856 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2858 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2860 DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
2861 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2867 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2868 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2876 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2877 pst->event, cfgRsp->ueId, cfgRsp->reason);
2878 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2880 //TODO: update failure case in ue Context setup Response
2884 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2888 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2894 /*******************************************************************
2896 * @brief Builds and Send Ue Reconfig Req to RLC
2900 * Function : duBuildAndSendUeRecfgReqToRLC
2902 * Functionality: Builds and Send Ue Reconfig Req to RLC
2904 * @params[in] cellId, crnti
2906 * RlcUeCfg *rlcUeCfg
2907 * @return ROK - success
2910 * ****************************************************************/
2912 uint8_t duBuildAndSendUeRecfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2915 RlcUeCfg *rlcUeCfg = NULLP;
2917 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2920 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2921 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, rlcUeCfg);
2923 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeRecfgReqToRlc()");
2925 ret = sendUeRecfgReqToRlc(rlcUeCfg);
2929 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeRecfgReqToRlc()");
2935 /**********************************************************************************
2937 * @brief Fills Ue ReCfg from DU DB to MacUeRecfg
2941 * Function : fillMacUeRecfg
2943 * Functionality: fills ue ReCfg to be sent to MAC
2945 * @params[in] DuMacUeCfg Pointer
2946 * MacUeRecfg Pointer
2949 * *******************************************************************************/
2950 void fillMacUeRecfg(DuMacUeCfg *duMacUeCfg, MacUeRecfg *macUeRecfg)
2954 macUeRecfg->cellId = duMacUeCfg->cellId;
2955 macUeRecfg->ueId = duMacUeCfg->ueId;
2956 macUeRecfg->crnti = duMacUeCfg->crnti;
2957 macUeRecfg->macCellGrpRecfgPres = duMacUeCfg->macCellGrpCfgPres;
2958 if(macUeRecfg->macCellGrpRecfgPres)
2960 memcpy(&macUeRecfg->macCellGrpRecfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
2962 macUeRecfg->phyCellGrpRecfgPres = duMacUeCfg->phyCellGrpCfgPres;
2963 if(macUeRecfg->phyCellGrpRecfgPres)
2965 memcpy(&macUeRecfg->phyCellGrpRecfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
2967 macUeRecfg->spCellRecfgPres = duMacUeCfg->spCellCfgPres;
2968 if(macUeRecfg->spCellRecfgPres)
2970 memcpy(&macUeRecfg->spCellRecfg, &duMacUeCfg->spCellCfg, sizeof(SpCellRecfg));
2972 if(duMacUeCfg->ambrCfg != NULLP)
2974 DU_ALLOC_SHRABL_BUF(macUeRecfg->ambrRecfg, sizeof(AmbrCfg));
2975 memcpy(macUeRecfg->ambrRecfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
2977 memcpy(&macUeRecfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
2978 memcpy(&macUeRecfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
2979 if(duMacUeCfg->numLcs > 0)
2981 macUeRecfg->numLcsToAdd = 0;
2982 macUeRecfg->numLcsToDel = 0;
2983 macUeRecfg->numLcsToMod = 0;
2985 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
2987 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
2989 /*VS: To thoroughly check*/
2990 memcpy(&macUeRecfg->lcCfgAdd[macUeRecfg->numLcsToAdd], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
2991 macUeRecfg->numLcsToAdd++;
2993 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
2995 /*VS: To thoroughly check*/
2996 macUeRecfg->lcIdToDel[macUeRecfg->numLcsToDel] = duMacUeCfg->lcCfgList[lcIdx].lcConfig.lcId;
2997 macUeRecfg->numLcsToDel++;
2999 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
3001 /*VS: To thoroughly check*/
3002 memcpy(&macUeRecfg->lcCfgMod[macUeRecfg->numLcsToMod], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
3003 macUeRecfg->numLcsToMod++;
3007 macUeRecfg->transmissionAction = duMacUeCfg->transmissionAction;
3009 macUeRecfg->drxConfigIndicatorRelease = duMacUeCfg->drxConfigIndicatorRelease;
3013 /*******************************************************************
3015 * @brief Builds and Send Ue Reconfig Req to MAC
3019 * Function : duBuildAndSendUeRecfgReqToMac
3021 * Functionality: Builds and Send Ue Reconfig Req to MAC
3023 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
3025 * @return ROK - success
3028 * ****************************************************************/
3030 uint8_t duBuildAndSendUeRecfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
3033 DuMacUeCfg *duMacUeCfg = NULLP;
3034 MacUeRecfg *macUeRecfg = NULLP;
3036 DU_ALLOC(duMacUeCfg, sizeof(DuMacUeCfg));
3037 DU_ALLOC_SHRABL_BUF(macUeRecfg, sizeof(MacUeRecfg));
3038 if(macUeRecfg && duMacUeCfg)
3040 memset(duMacUeCfg, 0, sizeof(DuMacUeCfg));
3041 memset(macUeRecfg, 0, sizeof(MacUeRecfg));
3042 ret = updateDuMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, duMacUeCfg);
3043 fillMacUeRecfg(duMacUeCfg, macUeRecfg);
3045 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeRecfgReqToMac()");
3047 ret = sendUeRecfgReqToMac(macUeRecfg);
3051 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeRecfgReqToMac()");
3054 DU_FREE(duMacUeCfg, sizeof(DuMacUeCfg));
3059 /*******************************************************************
3061 * @brief Build and Send Ue context setup request
3066 * Function : duBuildAndSendUeContextSetupReq
3069 * Build and Send Ue context setup request
3071 * @params[in] cellId, crnti, DuUeCfg pointer
3072 * @return ROK - success
3075 *****************************************************************/
3077 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
3081 DuUeCfg *duUeCfg = NULLP;
3083 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
3087 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
3091 crnti = ueCb->crnti;
3092 duUeCfg = &ueCb->f1UeDb->duUeCfg;
3094 /* If UE is being handed-in to this DU, UE context setup request will create
3095 * new UE context at MAC/SCH and RLC.
3096 * If UE is in active state, UE contex setup request will lead to
3097 * reconfiguration of UE at MAC/SCH and RLC
3099 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
3101 /* Filling MAC UE Config */
3102 memset(&ueCb->duMacUeCfg, 0, sizeof(DuMacUeCfg));
3104 /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
3105 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->duMacUeCfg);
3107 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
3109 ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->rlcUeCfg);
3111 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
3116 /* Filling RLC UE Reconfig */
3117 ret = duBuildAndSendUeRecfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3119 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
3121 /* Filling MAC UE Reconfig */
3122 ret = duBuildAndSendUeRecfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3124 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
3130 /*******************************************************************
3132 * @brief Processes DL Rsp received from RLC DL
3137 * Function : DuProcRlcDlRrcMsgRsp
3140 * Processes UE Rsp received from RLC DL
3142 * @params[in] Post structure
3143 * Pointer to RlcCfgCfm
3144 * @return ROK - success
3147 *****************************************************************/
3148 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
3150 uint8_t ret = ROK, ueId = 0;
3151 uint16_t cellId, crnti;
3152 DuUeCb *ueCb = NULLP;
3155 state = dlRrcMsg->state;
3156 cellId = dlRrcMsg->cellId;
3157 crnti = dlRrcMsg->crnti;
3158 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
3160 if(state == TRANSMISSION_COMPLETE)
3162 GET_UE_ID(crnti, ueId);
3163 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
3165 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
3167 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3169 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3171 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
3174 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3176 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
3178 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
3181 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
3183 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
3186 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
3192 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
3196 /*******************************************************************
3198 * @brief Process UE context setup request from CU
3202 * Function : duProcUeContextSetupRequest
3204 * Functionality: Process UE context setup request from CU
3206 * @params[in] F1AP message
3207 * @return ROK - success
3210 * ****************************************************************/
3212 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
3214 uint8_t ret, cellId;
3219 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3221 /* Send DL RRC msg for security Mode */
3222 if(ueCb->f1UeDb->dlRrcMsg)
3224 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3226 /* Sending DL RRC Message to RLC */
3227 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3230 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
3231 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3232 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3233 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3237 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3239 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3242 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
3248 //TODO: To send the failure cause in UeContextSetupRsp
3249 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
3254 /*******************************************************************
3256 * @brief Build and Send Ue context mod request
3261 * Function : duBuildAndSendUeContextModReq
3264 * Build and Send Ue context mod request
3266 * @params[in] cellId, crnti, DuUeCfg pointer
3267 * @return ROK - success
3270 *****************************************************************/
3272 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
3276 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
3277 /* Filling RLC Ue Reconfig */
3278 ret = duBuildAndSendUeRecfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3280 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
3282 /* Filling MAC Ue Reconfig */
3283 ret = duBuildAndSendUeRecfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3285 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
3289 /*******************************************************************
3291 * @brief Processing Ue context mod request
3296 * Function : duProcUeContextModReq
3299 * Processing Ue context mod request
3301 * @params[in] DuUeCb *ueCb
3302 * @return ROK - success
3305 *****************************************************************/
3307 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
3309 uint8_t ret, cellId;
3314 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3315 /* Send DL RRC msg for security Mode */
3316 if(ueCb->f1UeDb->dlRrcMsg)
3318 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3320 /* Sending DL RRC Message to RLC */
3321 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3324 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
3325 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3326 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3327 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3331 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3333 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
3336 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
3340 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
3342 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
3344 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
3351 //TODO: To send the failure cause in UeContextModRsp
3353 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
3359 /*******************************************************************
3361 * @brief Build and send dedicated RACH resource release request to MAC
3365 * Function : duBuildAndSendRachRsrcRelToMac
3367 * Functionality: Function to Build and send dedicated RACH resource
3368 * release request to MAC
3370 * @params[in] Cell ID
3372 * @return ROK - Success
3375 * ****************************************************************/
3376 uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb)
3379 MacRachRsrcRel *rachRsrcRel = NULLP;
3381 DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel));
3384 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \
3385 duBuildAndSendRachRsrcRelToMac()");
3389 rachRsrcRel->cellId = cellId;
3390 rachRsrcRel->ueId = ueCb->gnbDuUeF1apId;
3391 rachRsrcRel->crnti = ueCb->crnti;
3394 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL);
3396 if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK)
3398 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \
3399 duBuildAndSendRachRsrcRelToMac()");
3400 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel));
3407 /*******************************************************************
3409 * @brief delete DuMacUeCfg from duCb
3413 * Function : deleteMacUeCfg
3415 * Functionality: delete DuMacUeCfg from duCb
3417 * @params[in] Pointer to DuMacUeCfg
3418 * @return ROK - success
3421 *******************************************************************/
3423 void deleteMacUeCfg(DuMacUeCfg *ueCfg)
3427 if(ueCfg->spCellCfgPres)
3429 freeUeRecfgCellGrpInfo(ueCfg);
3433 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
3435 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
3437 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx].lcConfig);
3439 memset(ueCfg, 0, sizeof(DuMacUeCfg));
3442 /*******************************************************************
3444 * @brief delete UE Configuration of a particular UE
3448 * Function : deleteUeCfg
3450 * Functionality: delete UE Configuration of a particular UE
3452 * @params[in] uint16_t cellIdx, uint8_t ueId
3453 * @return ROK - success
3456 * ****************************************************************/
3457 uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
3460 uint16_t cellIdx = 0;
3461 DuUeCb *ueCb = NULLP;
3463 GET_CELL_IDX(cellId, cellIdx);
3464 if(duCb.actvCellLst[cellIdx] != NULLP)
3466 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duMacUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3467 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3469 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3470 deleteMacUeCfg(&ueCb->duMacUeCfg);
3471 deleteRlcUeCfg(&ueCb->rlcUeCfg);
3472 if(ueCb->f1UeDb !=NULLP)
3474 freeF1UeDb(ueCb->f1UeDb);
3476 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3478 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3480 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3481 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3486 unsetBitInUeBitMap(cellId, ueId-1);
3487 duCb.actvCellLst[cellIdx]->numActvUes--;
3488 memset(ueCb, 0, sizeof(DuUeCb));
3497 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3504 /*******************************************************************
3506 * @brief Handle UE delete response from MAC
3510 * Function : DuProcMacUeDeleteRsp
3512 * Functionality: Handle UE delete response from MAC
3514 * @params[in] Pointer to MacUeDeleteRsp and Pst
3515 * @return ROK - success
3518 * ****************************************************************/
3520 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3522 uint8_t ret =ROK,ueId=0;
3524 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3528 if(deleteRsp->result == DEL_SUCCESSFUL)
3530 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3531 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3532 if(duCb.actvCellLst[cellIdx])
3534 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3535 ueId = deleteRsp->ueId;
3536 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3537 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3538 if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
3540 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3543 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3551 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3555 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3559 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3565 /*******************************************************************
3567 * @brief Processes UE Delete Rsp received from RLC
3571 * Function : DuProcRlcUeDeleteRsp
3574 * Processes UE Delete Rsp received from RLC
3576 * @params[in] Post structure
3577 * Pointer to RlcUeDeleteRsp
3578 * @return ROK - success
3581 * *****************************************************************/
3583 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3585 uint8_t ueId = 0, ret = ROK;
3586 uint16_t cellIdx = 0,crnti=0;
3590 ueId = delRsp->ueId;
3591 GET_CELL_IDX(delRsp->cellId, cellIdx);
3593 if(delRsp->result == SUCCESSFUL)
3595 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3596 if(duCb.actvCellLst[cellIdx]!=NULLP)
3598 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3599 GET_CRNTI(crnti, ueId);
3600 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3602 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3610 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3613 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3619 /*******************************************************************
3621 * @brief Sending UE Delete Req To Mac
3625 * Function : sendUeDeleteReqToMac
3628 * sending UE Delete Req To Mac
3630 * @params[in] cellId, ueId, crnti
3631 * @return ROK - success
3634 *****************************************************************/
3636 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3640 MacUeDelete *ueDelete = NULLP;
3642 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3645 ueDelete->cellId = cellId;
3646 ueDelete->ueId = ueId;
3647 ueDelete->crnti = crnti;
3648 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3650 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3651 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3654 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3655 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3660 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3666 /*******************************************************************
3668 * @brief Sending UE Delete Req To Rlc
3672 * Function : sendUeDeleteReqToRlc
3675 * Sending UE Delete Req To Rlc
3677 * @params[in] cellId, ueId
3678 * @return ROK - success
3681 *****************************************************************/
3683 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3687 RlcUeDelete *ueDelete;
3689 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3690 if(ueDelete !=NULLP)
3692 ueDelete->cellId = cellId;
3693 ueDelete->ueId = ueId;
3694 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3696 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3699 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3700 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3705 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3711 /*******************************************************************
3713 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3717 * Function : duBuildAndSendUeDeleteReq
3719 * Functionality: DU processes UE delete req from CU and sends to MAC
3722 * @params[in] cellId, crnti
3723 * @return ROK - success
3726 * ****************************************************************/
3728 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3731 uint16_t cellIdx = 0;
3733 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3734 GET_CELL_IDX(cellId, cellIdx);
3735 GET_UE_ID(crnti, ueId);
3737 if(duCb.actvCellLst[cellIdx] != NULLP)
3739 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3741 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3745 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3746 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3748 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3754 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3761 /*******************************************************************
3763 * @brief delete RlcUeCfg from duCb
3767 * Function : deleteRlcUeCfg
3770 * delete RlcUeCfg from duCb
3772 * @params[in] RlcUeCfg *ueCfg
3774 * @return ROK - success
3777 *****************************************************************/
3779 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3782 RlcBearerCfg *lcCfg= NULLP;
3785 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3787 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3788 switch(lcCfg->rlcMode)
3792 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3795 case RLC_UM_BI_DIRECTIONAL :
3797 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3800 case RLC_UM_UNI_DIRECTIONAL_UL :
3802 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3805 case RLC_UM_UNI_DIRECTIONAL_DL :
3807 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3811 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3813 memset(ueCfg, 0, sizeof(RlcUeCfg));
3817 /*******************************************************************
3819 * @brief Du process Ue Context Release Command
3823 * Function : duProcUeContextReleaseCommand
3825 * Functionality: Du process Ue Context Release Command
3827 * @params[in] DuUeCb *duUeCb
3828 * @return ROK - success
3831 * ****************************************************************/
3832 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3834 uint8_t ret =ROK, ueId=0;
3839 crnti = duUeCb->crnti;
3840 GET_UE_ID(crnti, ueId);
3844 /* Send DL RRC msg for RRC release */
3845 if(duUeCb->f1UeDb->dlRrcMsg)
3847 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3849 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3850 duUeCb->f1UeDb->dlRrcMsg);
3853 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3854 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3855 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3856 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3863 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3866 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3873 /**********************************************************************
3875 ***********************************************************************/