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 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
100 packDuMacUeDeleteReq, /* Loose coupling */
101 MacProcUeDeleteReq, /* TIght coupling */
102 packDuMacUeDeleteReq /* Light weight-loose coupling */
105 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
107 packDuRlcUeDeleteReq, /* Loose coupling */
108 RlcProcUeDeleteReq, /* TIght coupling */
109 packDuRlcUeDeleteReq /* Light weight-loose coupling */
112 /******************************************************************
114 * @brief Function to return Drb LcId
118 * Function : getDrbLcId
120 * Functionality: Function to return Drb LcId
122 * @params[in] drbBitMap
124 * Returns: lcId - SUCCESS
126 *****************************************************************/
128 uint8_t getDrbLcId(uint32_t *drbBitMap)
130 uint8_t bitMask = 1, bitPos = 0;
131 bitPos = MIN_DRB_LCID;
133 while(bitPos <= MAX_DRB_LCID)
135 if((*drbBitMap & (bitMask << bitPos)) == 0)
137 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
145 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
149 /*******************************************************************
151 * @brief Function to fillDlUserDataInfo
155 * Function : fillDlUserDataInfo
158 * Function to fillDlUserDataInfo
163 * @return ROK - success
166 * ****************************************************************/
168 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
172 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
173 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
175 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
177 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
179 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
180 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
181 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
189 /*******************************************************************
191 * @brief Build and Send DL Data Message transfer to RLC
195 * Function : duBuildAndSendDlUserDataToRlc
198 * Build and Send DL Data Message transfer to RLC
200 * @params[in] Cell ID
202 * Logical Channgel ID
205 * @return ROK - success
208 * ****************************************************************/
210 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
212 uint8_t ret = RFAILED;
214 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
216 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
219 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
222 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
223 dlDataMsgInfo->dlMsg = egtpMsg->msg;
224 dlDataMsgInfo->msgLen = msgLen;
226 /* Filling DL DATA Msg Info */
227 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
229 /* Filling post structure and sending msg */
230 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
231 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
232 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
233 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
237 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
238 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
239 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
244 /*******************************************************************
246 * @brief Handles EGTP data from CU
250 * Function : duHdlEgtpData
253 * Processes EGTP header and sends data to RLC
255 * @params[in] Pointer to EGTP Message
256 * @return ROK - success
259 * ****************************************************************/
260 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
264 #ifdef CALL_FLOW_DEBUG_LOG
265 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
268 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
272 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
275 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
276 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
278 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
284 /******************************************************************
286 * @brief Builds and Sends DL CCCH Ind to MAC
290 * Function : duBuildAndSendDlCcchInd
292 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
294 * @params[in] dlCcchMsg - uint8_t*
295 * @return ROK - success
298 * ****************************************************************/
299 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
300 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
304 DlCcchIndInfo *dlCcchIndInfo = NULLP;
307 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
309 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
313 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
317 dlCcchIndInfo->cellId = *cellId;
318 dlCcchIndInfo->crnti = *crnti;
319 dlCcchIndInfo->msgType = msgType;
320 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
322 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
323 if(!dlCcchIndInfo->dlCcchMsg)
325 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
326 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
329 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
331 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
333 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
336 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
337 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
340 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
341 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
342 dlCcchIndInfo->dlCcchMsgLen);
343 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
344 sizeof(DlCcchIndInfo));
352 /*******************************************************************
354 * @brief Build and Send DL RRC Message transfer to RLC
358 * Function : duBuildAndSendDlRrcMsgToRlc
361 * Build and Send DL RRC Message transfer to RLC
363 * @params[in] Cell ID
365 * Logical Channgel ID
368 * @return ROK - success
371 * ****************************************************************/
372 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
377 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
381 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
385 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
388 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
389 duBuildAndSendDlRrcMsgToRlc");
390 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
394 /* Filling up the RRC msg info */
395 dlRrcMsgInfo->cellId = cellId;
396 dlRrcMsgInfo->ueId = ueCfg.ueId;
397 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
399 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
401 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
402 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
403 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
404 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
408 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
409 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
410 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
411 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
413 /* Filling post structure and sending msg */
414 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
415 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
416 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
419 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
420 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
429 /******************************************************************
431 * @brief Process DL RRC Msg recevied from F1AP
435 * Function : duProcDlRrcMsg
437 * Functionality: Process DL RRC Msg recevied from F1AP
439 * @params[in] dlCcchMsg - uint8_t*
440 * @return ROK - success
443 * ****************************************************************/
445 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
448 uint16_t crnti, cellId, cellIdx;
449 bool ueCcchCtxtFound = false;
450 bool ueFound = false;
454 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
456 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
458 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
460 ueCcchCtxtFound = true;
461 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
462 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
469 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
472 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
476 if(duCb.actvCellLst[cellId-1] == NULLP)
478 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
481 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
483 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
486 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
487 duCb.ueCcchCtxt[ueIdx].cellId);
492 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
499 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
501 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
503 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
504 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
507 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
508 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
517 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
524 /******************************************************************
526 * @brief Processes UL CCCH Ind recvd from MAC
530 * Function : duProcUlCcchInd
532 * Functionality: Processes UL CCCH Ind recvd from MAC
534 * @params[in] UlCcchIndInfo *ulCcchIndInfo
535 * @return ROK - success
538 * ****************************************************************/
539 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
543 int32_t gnbDuUeF1apId = 0;
545 if(ulCcchIndInfo->crnti)
547 GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
551 DU_LOG("\nERROR --> DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
555 /* Store Ue mapping */
556 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
557 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
558 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
562 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
563 ulCcchIndInfo->ulCcchMsg));
566 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
569 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
570 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
576 /******************************************************************
578 * @brief Fills Default UL LC Cfg
582 * Function : fillDefaultUlLcCfg
584 * Functionality: Fills Default UL LC Cfg
586 * @params[in] UlLcCfg *ulLcCfg
588 *****************************************************************/
589 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
591 ulLcCfg->priority = LC_PRIORITY_1;
592 ulLcCfg->lcGroup = 0;
593 ulLcCfg->schReqId = 0;
594 ulLcCfg->pbr = PBR_KBPS_INFINITY;
595 ulLcCfg->bsd = BSD_MS_1000;
598 /******************************************************************
600 * @brief Fills Initial DL Bandwidth Part
604 * Function : fillDefaultInitDlBwp
606 * Functionality: Fills Initial DL Bandwidth Part
608 * @params[in] InitialDlBwp *initDlBwp
609 * @return ROK - success
612 *****************************************************************/
613 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
616 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
617 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
621 /* Filling PDCCH Config */
622 initDlBwp->pdcchPresent = TRUE;
623 if(initDlBwp->pdcchPresent)
625 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
626 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
627 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
629 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
630 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
631 coreset0EndPrb = CORESET0_END_PRB;
632 coreset1StartPrb = coreset0EndPrb +6;
633 coreset1NumPrb = CORESET1_NUM_PRB;
634 /* calculate the PRBs */
635 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
636 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
638 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
639 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
640 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
641 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
643 initDlBwp->pdcchCfg.numCRsetToRel = 0;
645 /* Filling Serach Space */
646 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
647 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
648 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
650 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
651 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
652 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
653 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
654 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
655 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
656 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
657 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
658 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
659 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
660 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
661 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
663 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
666 /* Filling PDSCH Config */
667 initDlBwp->pdschPresent = TRUE;
668 if(initDlBwp->pdschPresent)
670 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
671 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
673 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
676 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
677 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
678 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
679 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
682 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
683 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
685 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
688 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
689 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
690 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
691 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
692 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
693 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
695 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
696 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
697 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
698 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
705 /******************************************************************
707 * @brief Fills Initial UL Bandwidth Part
711 * Function : fillDefaultInitUlBwp
713 * Functionality: Fills Initial UL Bandwidth Part
715 * @params[in] InitialUlBwp *initUlBwp
718 *****************************************************************/
719 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
724 initUlBwp->pucchPresent = FALSE;
726 /*Filling PUSCH Config */
727 initUlBwp->puschPresent = TRUE;
728 if(initUlBwp->puschPresent)
730 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
731 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
732 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
733 scramblingId0 = SCRAMBLING_ID;
734 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
735 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
737 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
739 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
740 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
742 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
743 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
744 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
745 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
748 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
749 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
750 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
751 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
752 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
753 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
755 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
760 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
764 /******************************************************************
766 * @brief Fills SpCell Group Info
770 * Function : fillDefaultSpCellGrpInfo
772 * Functionality: Fills Sp Cell Group Info
774 * @params[in] MacUeCfg *macUeCfg
775 * @return ROK - Success
778 *****************************************************************/
779 uint8_t fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
781 SpCellCfg *spCell = NULL;
784 spCell = &macUeCfg->spCellCfg;
788 macUeCfg->spCellCfgPres = true;
790 spCell->servCellIdx = SERV_CELL_IDX;
791 /* Filling Initial Dl Bwp */
792 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
794 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
798 spCell->servCellCfg.numDlBwpToAdd = 0;
799 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
800 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
801 spCell->servCellCfg.bwpInactivityTmr = NULLP;
802 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
803 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
804 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
805 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
806 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
808 /* Filling Initial UL Bwp*/
809 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
810 spCell->servCellCfg.numUlBwpToAdd = 0;
811 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
815 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
821 /******************************************************************
823 * @brief Fills Physical Cell Group Info
827 * Function : fillDefaultPhyCellGrpInfo
829 * Functionality: Fills Physical Cell Group Info
831 * @params[in] MacUeCfg *macUeCfg
834 *****************************************************************/
835 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
837 PhyCellGrpCfg *cellGrp = NULL;
840 cellGrp = &macUeCfg->phyCellGrpCfg;
844 macUeCfg->phyCellGrpCfgPres = true;
845 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
846 cellGrp->pNrFr1 = P_NR_FR1;
850 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
854 /******************************************************************
856 * @brief Fills Mac Cell Group Info
860 * Function : fillDefaultMacCellGrpInfo
862 * Functionality: Fills Mac Cell Group Info
864 * @params[in] MacUeCfg *macUeCfg
867 *****************************************************************/
868 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
871 MacCellGrpCfg *cellGrp = NULL;
874 cellGrp = &macUeCfg->macCellGrpCfg;
878 macUeCfg->macCellGrpCfgPres = true;
880 /* Filling Scheduling Request Config */
881 cellGrp->schReqCfg.addModListCount = 1;
882 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
884 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
886 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
887 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
888 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
891 cellGrp->schReqCfg.relListCount = 0;
893 /* Filling Tag config */
894 cellGrp->tagCfg.addModListCount = 1;
895 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
897 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
899 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
900 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
903 cellGrp->tagCfg.relListCount = 0;
905 /* Filling BSR config */
906 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
907 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
908 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
910 /* Filling PHR config */
911 cellGrp->phrCfgSetupPres = true;
912 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
913 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
914 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
915 cellGrp->phrCfg.multiplePHR = false;
916 cellGrp->phrCfg.dummy = false;
917 cellGrp->phrCfg.phrType2OtherCell = false;
918 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
923 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
927 /*******************************************************************
929 * @brief Fills default modulation info for a UE
933 * Function : fillDefaultModulation
935 * Functionality: Fills default modulation info for a UE
937 * @params[in] Pointer to MAC UE configuration
938 * @return ROK - success
941 * ****************************************************************/
942 void fillDefaultModulation(MacUeCfg *ueCfg)
944 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
945 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
946 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
948 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
949 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
950 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
953 /******************************************************************
955 * @brief Function to fill Mac Lc Cfg for SRB1
959 * Function : fillMacSrb1LcCfg
961 * Functionality: Function to fill Mac Lc cfg for SRB1
963 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
965 *****************************************************************/
967 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
969 macLcCfg->lcId = SRB1_LCID;
970 macLcCfg->configType = CONFIG_ADD;
971 macLcCfg->drbQos = NULLP;
972 macLcCfg->snssai = NULLP;
973 macLcCfg->ulLcCfgPres = true;
974 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
977 /******************************************************************
979 * @brief Function to fill the Lc cfg from ueSetupReqDb
983 * Function : fillMacLcCfgToAddMod
985 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
987 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
988 * @return ROK/RFAILED
990 *****************************************************************/
992 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
998 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
999 macLcCfgToSend->configType = ueLcCfgDb->configType;
1001 if(ueLcCfgDb->drbQos)
1002 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1004 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1006 macLcCfgToSend->drbQos = NULL;
1008 if(ueLcCfgDb->snssai)
1009 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1011 macLcCfgToSend->snssai = oldLcCfg->snssai;
1013 macLcCfgToSend->snssai = NULL;
1015 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1016 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1017 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1022 oldLcCfg->lcId = ueLcCfgDb->lcId;
1023 oldLcCfg->configType = ueLcCfgDb->configType;
1025 if(ueLcCfgDb->drbQos)
1027 if(oldLcCfg->drbQos)
1028 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1030 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1031 if(oldLcCfg->drbQos == NULL)
1033 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1036 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1039 if(ueLcCfgDb->snssai)
1041 if(oldLcCfg->snssai)
1042 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1044 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1045 if(oldLcCfg->snssai == NULL)
1047 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1048 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1051 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1054 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1055 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1056 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1061 /******************************************************************
1063 * @brief Function to copy the Bit rate from ueSetupReqDb
1067 * Function : fillAmbr
1069 * Functionality: Function to copy bit Rate from ueSetupReqDb
1071 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1072 * @return ROK/RFAILED
1074 *****************************************************************/
1076 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1082 *macAmbrCfgToSend = ueDbAmbr;
1084 else if(oldMacAmbrCfg)
1085 *macAmbrCfgToSend = *oldMacAmbrCfg;
1095 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1097 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1098 if(*oldMacAmbrCfg == NULLP)
1100 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1103 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1104 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1112 /******************************************************************
1114 * @brief Builds and Send UE ReConfig Request to MAC
1118 * Function : sendUeReCfgReqToMac
1120 * Functionality: Builds and Send UE ReConfig Request to MAC
1122 * @Params[in] MacUeCfg pointer
1123 * @return ROK - success
1126 * ****************************************************************/
1128 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1134 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1138 /* Processing one Ue at a time to MAC */
1139 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1140 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1143 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1144 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1149 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1157 /******************************************************************
1159 * @brief Fills MacUeCfg structure
1163 * Function : fillMacUeCfg
1165 * Functionality: Fills MacUeCfg
1167 * @params[in] cellId, ueId, crnti,
1170 * @return ROK/RFAILED
1172 *****************************************************************/
1173 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1175 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1176 bool lcIdFound = false;
1177 MacUeCfg *duMacDb = NULLP;
1179 macUeCfg->cellId = cellId;
1180 macUeCfg->ueId = gnbDuUef1apId;
1181 macUeCfg->crnti = crnti;
1185 fillDefaultMacCellGrpInfo(macUeCfg);
1186 fillDefaultPhyCellGrpInfo(macUeCfg);
1188 if((fillDefaultSpCellGrpInfo(macUeCfg)) != ROK)
1190 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1194 macUeCfg->ambrCfg = NULLP;
1195 fillDefaultModulation(macUeCfg);
1196 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1201 if(ueCfgDb->dataTransmissionAction == STOP_TRANSMISSION)
1203 macUeCfg->transmissionAction = ueCfgDb->dataTransmissionAction;
1207 GET_CELL_IDX(cellId, cellIdx);
1208 if(duCb.actvCellLst[cellIdx])
1209 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1212 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1215 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1217 if(ueCfgDb->cellGrpCfg)
1219 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1222 if(macUeCfg->spCellCfgPres == true)
1224 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1226 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1227 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1229 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1231 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1232 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1237 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1239 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1241 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1246 fillDefaultMacCellGrpInfo(macUeCfg);
1247 fillDefaultPhyCellGrpInfo(macUeCfg);
1248 fillDefaultSpCellGrpInfo(macUeCfg);
1249 fillDefaultModulation(macUeCfg);
1252 /* Filling LC Context */
1253 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1255 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1257 /* Filling default UL LC config in MAC if not present */
1258 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1259 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1264 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1266 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1269 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1270 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1272 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1273 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1274 &duMacDb->lcCfgList[lcIdx], FALSE);
1284 /* ADD/DEL CONFIG */
1285 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1293 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1296 }/*End of Outer FOR loop */
1297 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1302 /******************************************************************
1304 * @brief Fills Rlc AM Information
1308 * Function : fillDefaultAmInfo
1310 * Functionality: Fills Rlc AM Information
1312 * @params[in] AmBearerCfg *amCfg
1315 *****************************************************************/
1316 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1319 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1320 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1321 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1322 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1323 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1326 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1327 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1328 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1331 /******************************************************************
1333 * @brief Fills RLC UM Bi Directional Information
1337 * Function : fillDefaultUmBiInfo
1339 * Functionality: Fills RLC UM Bi Directional Information
1341 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1344 *****************************************************************/
1345 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1347 /* UL UM BI DIR INFO */
1348 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1349 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1351 /* DL UM BI DIR INFO */
1352 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1355 /******************************************************************
1357 * @brief Fills RLC UM Uni Directional UL Information
1361 * Function : fillDefaultUmUlInfo
1363 * Functionality: Fills RLC UM Uni Directional Info
1365 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1368 *****************************************************************/
1369 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1371 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1372 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1375 /******************************************************************
1377 * @brief Fills RLC UM Uni Directional DL Information
1381 * Function : fillDefaultUmDlInfo
1383 * Functionality: Fills RLC UM Uni Directional DL Info
1385 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1388 *****************************************************************/
1389 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1391 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1394 /******************************************************************
1396 * @brief Builds Rlc Mode Default Configuration
1400 * Function : fillDefaultRlcModeCfg
1402 * Functionality: Builds Rlc Mode Default Configuration
1404 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1405 * @return ROK/RFAILED
1407 *****************************************************************/
1409 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1419 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1421 fillDefaultAmInfo(lcCfg->u.amCfg);
1424 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1430 case RLC_UM_BI_DIRECTIONAL :
1432 if(!lcCfg->u.umBiDirCfg)
1434 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1435 if(lcCfg->u.umBiDirCfg)
1436 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1439 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1445 case RLC_UM_UNI_DIRECTIONAL_UL :
1447 if(!lcCfg->u.umUniDirUlCfg)
1449 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1450 if(lcCfg->u.umUniDirUlCfg)
1451 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1454 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1460 case RLC_UM_UNI_DIRECTIONAL_DL :
1462 if(!lcCfg->u.umUniDirDlCfg)
1464 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1465 if(lcCfg->u.umUniDirDlCfg)
1466 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1469 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1476 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1483 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1489 /*******************************************************************
1491 * @brief Function to fill Rlc Lc Cfg for SRB1
1495 * Function : fillRlcSrb1LcCfg
1498 * Function to fill Rlc Lc Cfg for SRB1
1500 * @params[in] Pointer to RlcBearerCfg
1501 * @return ROK/RFAILED
1503 *****************************************************************/
1505 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1509 rlcLcCfg->rbId = SRB1_LCID;
1510 rlcLcCfg->rbType = RB_TYPE_SRB;
1511 rlcLcCfg->lcId = SRB1_LCID;
1512 rlcLcCfg->lcType = LCH_DCCH;
1513 rlcLcCfg->rlcMode = RLC_AM;
1514 rlcLcCfg->configType = CONFIG_ADD;
1515 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1516 rlcLcCfg->isLcAddModRspSent = true;
1520 /*******************************************************************
1522 * @brief Processes UE ReConfig Req to RLC UL
1526 * Function : sendUeReCfgReqToRlc
1529 * Processes UE Reconfig Req to RLC UL
1531 * @params[in] Pointer to RlcUeCfg
1532 * @return ROK - success
1535 *****************************************************************/
1537 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1542 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1545 /* Processing one Ue at a time to RLC */
1546 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1547 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1550 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1551 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1556 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1562 /******************************************************************
1564 * @brief Fills Snssai information
1568 * Function : fillSnssaiInfo
1570 * Functionality: Fills Snssai information
1572 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1574 * @return ROK - success
1577 *****************************************************************/
1578 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1583 snssaiTobeSend = snssaiDb;
1585 snssaiTobeSend = *oldSnssai;
1587 snssaiTobeSend = NULL;
1594 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1596 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1597 if(*oldSnssai == NULL)
1599 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1602 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1607 /******************************************************************
1609 * @brief Fills RlcBearerCfg structure
1613 * Function : fillRlcUeCfg
1615 * Functionality: Fills Rlc Bearer Cfg
1618 *****************************************************************/
1619 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t duUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1621 uint8_t ret, dbIdx, lcIdx, cellIdx;
1622 bool lcIdFound = false;
1623 RlcUeCfg *duRlcDb = NULLP;
1626 rlcUeCfg->cellId = cellId;
1627 rlcUeCfg->ueId = duUeF1apId;
1631 /* Initial RB being Added */
1632 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1636 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1640 /* Fetch RlcDb from DuUeCb */
1641 GET_CELL_IDX(cellId, cellIdx);
1642 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[rlcUeCfg->ueId-1].rlcUeCfg;
1643 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1645 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1647 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1650 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1651 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1657 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1658 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1660 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1663 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1664 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1667 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1668 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1669 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1670 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1680 /* ADD/ DEL Config Type */
1681 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1682 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1690 /******************************************************************
1692 * @brief creates UE context
1696 * Function : duCreateUeCb
1698 * Functionality: Creates UE Conetxt
1700 * @params[in] UeCcchCtxt Pointer
1703 * @return ROK - success
1705 * ****************************************************************/
1706 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1708 uint8_t cellIdx = 0;
1710 uint8_t ueId = 0, ueIdx = 0;
1712 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1714 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1716 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1717 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1720 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1721 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1722 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1723 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1724 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1725 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1727 /* Filling Mac Ue Config */
1728 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
1729 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1730 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
1732 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1734 /* Filling Rlc Ue Config */
1735 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1736 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, NULL,
1737 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1739 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1741 duCb.actvCellLst[cellIdx]->numActvUes++;
1742 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1749 /******************************************************************
1751 * @brief Builds and Send UE Create Request to MAC
1755 * Function : duBuildAndSendUeCreateReqToMac
1757 * Functionality: Builds and Send UE Create Request to MAC
1759 * @Params[in] cellId,
1762 * UE config extracted from F1AP msg
1763 * MAC UE config struct to be filled
1764 * @return ROK - success
1767 * ****************************************************************/
1769 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *duMacUeCfg)
1772 MacUeCfg *macUeCfg = NULLP;
1774 memset(&pst, 0, sizeof(Pst));
1777 ret = fillMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1780 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1785 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1787 /* Copying ueCb to a sharable buffer */
1788 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1791 memset(macUeCfg, 0, sizeof(MacUeCfg));
1792 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1793 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1795 /* Processing one Ue at a time to MAC */
1796 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1799 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1800 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1805 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1811 /*******************************************************************
1813 * @brief Build and send RACH Resource request to MAC
1817 * Function : duBuildAndSendRachRsrcReqToMac
1819 * Build and send RACH Resource request to MAC
1821 * @params[in] Cell Id
1823 * @return ROK - success
1826 * ****************************************************************/
1827 uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
1829 uint16_t cellIdx = 0, ssbIdx = 0;
1831 MacRachRsrcReq *rachRsrcReq = NULLP;
1833 GET_CELL_IDX(cellId, cellIdx);
1834 if(duCb.actvCellLst[cellIdx] == NULLP)
1836 DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
1840 DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
1843 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
1844 duBuildAndSendRachRsrcReqToMac()");
1848 rachRsrcReq->cellId = cellId;
1849 rachRsrcReq->ueId = ueId;
1850 rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
1851 for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
1853 rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
1857 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
1859 if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
1861 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
1862 duBuildAndSendRachRsrcReqToMac()");
1863 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
1870 /*******************************************************************
1872 * @brief Process RACH resource response from MAC
1876 * Function : DuProcMacRachRsrcRsp
1878 * Process RACH resource response from MAC
1880 * @params[in] Post structure
1881 * RACH resource response
1882 * @return ROK - success
1885 * ****************************************************************/
1886 uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
1888 uint8_t ret = RFAILED;
1889 uint16_t cellIdx = 0;
1890 DuCellCb *cellCb = NULLP;
1891 DuUeCb *ueCb = NULLP;
1893 DU_LOG("\nINFO --> DU APP : Received RACH Resource Response from MAC. Cell ID [%d] UE ID [%d]",
1894 rachRsrcRsp->cellId, rachRsrcRsp->ueId);
1896 if(rachRsrcRsp->result == MAC_DU_APP_RSP_OK)
1898 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
1901 GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
1902 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
1904 cellCb = duCb.actvCellLst[cellIdx];
1907 if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
1909 ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
1911 /* Store CRNTI alloted to this UE by MAC */
1912 ueCb->crnti = rachRsrcRsp->newCrnti;
1914 /* Store the assigned CF-RA resources */
1915 memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
1917 /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
1918 * along with the result of UE Context setup requested by CU */
1919 if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
1920 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
1923 DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
1926 DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
1929 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
1931 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
1935 /*******************************************************************
1937 * @brief To update DuUeCb Mac Cfg
1941 * Function : duUpdateMacCfg
1942 * Functionality: update DuUeCb MAC Cfg
1944 * @params[in] DuUeCb Pointer
1945 * F1UeContextSetupDb pointer
1946 * @return ROK - success
1949 * ****************************************************************/
1950 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1952 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1953 MacUeCfg *oldMacUeCfg;
1956 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1957 if(duCb.actvCellLst[cellIdx] == NULLP)
1959 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
1962 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1964 /*Filling Cell Group Cfg*/
1965 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1968 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1970 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1971 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1973 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1975 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1976 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1978 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1979 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1982 /* Filling LC Context */
1983 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1985 numLcs = macUeCfg->numLcs;
1986 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1988 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1990 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1992 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1994 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1996 /* Free memory at matched lcIdx index */
1997 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1999 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
2001 /* moving all elements one index ahead */
2002 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
2003 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
2006 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
2013 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
2015 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
2018 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
2028 /******************************************************************
2030 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
2034 * Function : fillRlcCfgToAddMod
2036 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
2039 *****************************************************************/
2041 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
2043 lcCfg->configType = f1UeDbLcCfg->configType;
2044 lcCfg->rbId = f1UeDbLcCfg->rbId;
2045 lcCfg->rbType = f1UeDbLcCfg->rbType;
2046 lcCfg->lcId = f1UeDbLcCfg->lcId;
2047 lcCfg->lcType = f1UeDbLcCfg->lcType;
2048 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
2050 switch(lcCfg->rlcMode)
2056 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
2061 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
2062 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
2063 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
2064 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
2065 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
2068 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
2069 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
2070 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
2073 case RLC_UM_BI_DIRECTIONAL :
2075 if(!lcCfg->u.umBiDirCfg)
2077 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2078 if(!lcCfg->u.umBiDirCfg)
2081 /* UL UM BI DIR INFO */
2082 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
2083 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
2084 /* DL UM BI DIR INFO */
2085 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
2088 case RLC_UM_UNI_DIRECTIONAL_UL :
2090 if(!lcCfg->u.umUniDirUlCfg)
2092 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2093 if(!lcCfg->u.umUniDirUlCfg)
2096 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
2097 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2101 case RLC_UM_UNI_DIRECTIONAL_DL :
2103 if(!lcCfg->u.umUniDirDlCfg)
2105 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2106 if(!lcCfg->u.umUniDirDlCfg)
2109 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2113 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
2119 /*******************************************************************
2121 * @brief To update DuUeCb Rlc Lc Cfg
2125 * Function : duUpdateRlcLcCfg
2126 * Functionality: update DuUeCb Rlc Lc Cfg
2128 * @params[in] DuUeCb Pointer
2129 * F1UeContextSetupDb pointer
2130 * @return ROK - success
2133 * ****************************************************************/
2135 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2137 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2140 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2142 numLcs = rlcUeCfg->numLcs;
2143 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2145 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2147 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2149 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2152 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2155 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2157 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2159 /* Free memory at matched lcIdx index */
2160 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2162 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2164 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2165 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2167 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2170 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2177 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2179 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2182 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2191 /*******************************************************************
2193 * @brief Function to fill Tunnel Config to Add/Mod
2198 * Function : fillTnlCfgToAddMod
2200 * Functionality: Function to fill tunnel Config to Add/Mod
2202 * @params[in] Pointer to tnlCfgDb,
2203 * pointer to f1TnlCfg
2204 * @return ROK - success
2207 * ****************************************************************/
2208 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2212 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2213 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2216 if(*ueCbTnlCfg == NULLP)
2218 /* copying to DuCb Tnl Cfg */
2219 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2220 if(*ueCbTnlCfg == NULLP)
2222 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2226 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2227 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2228 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2229 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2230 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2231 if(f1TnlCfg->tnlCfg1)
2233 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2235 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2236 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2238 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2242 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2243 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2244 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2245 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2250 /*******************************************************************
2252 * @brief Processing the tunnel Request to EGTP
2256 * Function : duProcEgtpTunnelCfg
2258 * Functionality: Processing the tunnel Request to EGTP
2260 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2261 * @return ROK - success
2264 * ****************************************************************/
2266 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2268 uint8_t ret = RFAILED, delIdx;
2270 if(f1TnlCfg->tnlCfg1 == NULLP)
2272 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2276 if(f1TnlCfg->configType == CONFIG_ADD)
2278 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2280 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2287 else if(f1TnlCfg->configType == CONFIG_MOD)
2289 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2291 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2297 else if(f1TnlCfg->configType == CONFIG_DEL)
2299 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2301 /* Free memory at drbIdx */
2303 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2305 /* moving all elements one index ahead */
2306 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2312 if(duCb.upTnlCfg[delIdx])
2314 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2315 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2322 /***********************************************************************
2324 * @brief Function to fill Tunnel Config
2325 * and sends tunnel Req to EGTP
2330 * Function : duUpdateTunnelCfgDb
2332 * Functionality: Function to fill tunnel Config
2333 * and sends tunnel Cfg Req to EGTP
2335 * @params[in] ueId, cellId, DuUeCfg
2336 * @return ROK - success
2339 * ****************************************************************/
2341 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2343 uint8_t ret = ROK, drbIdx, teIdx;
2344 bool drbFound = false;
2346 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2347 /*then update drbId and tunnel Info in duCb */
2348 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2350 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2351 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2352 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2354 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2355 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2357 drbFound = true; /* existing DRB */
2358 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2360 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2361 duUeCfg->upTnlInfo[drbIdx].drbId);
2370 if(!drbFound && ret == ROK)/* new DRB to Add */
2372 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2374 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2375 duUeCfg->upTnlInfo[drbIdx].drbId);
2386 /*******************************************************************
2388 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2393 * Function : duUpdateDuUeCbCfg
2395 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2397 * @params[in] ueId, cellIdx
2398 * @return ROK - success
2401 * ****************************************************************/
2403 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2405 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2406 DuUeCb *ueCb = NULLP;
2408 GET_CELL_IDX(cellId, cellIdx);
2409 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2411 /*Filling RLC Ue Cfg */
2412 ueCb->rlcUeCfg.cellId = cellId;
2413 ueCb->rlcUeCfg.ueId = ueId;
2414 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2417 /*Filling MAC Ue Cfg */
2418 GET_CRNTI(crnti, ueId);
2419 ueCb->macUeCfg.cellId = cellId;
2420 ueCb->macUeCfg.ueId = ueId;
2421 ueCb->macUeCfg.crnti = crnti;
2422 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2424 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2427 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2429 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2435 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2439 /*******************************************************************
2441 * @brief Handle UE config response from MAC
2445 * Function : DuProcMacUeCfgRsp
2447 * Functionality: Handle UE Config response from MAC
2449 * @params[in] Pointer to MacUeCfgRsp and Pst
2450 * @return ROK - success
2453 * ****************************************************************/
2454 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2461 GET_CELL_IDX(cfgRsp->cellId, cellIdx);
2462 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2464 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2466 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2468 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2470 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2472 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2473 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2474 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2476 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2478 /* If UE is in handover, RACH resource needs to be requested
2479 * from MAC for CFRA */
2480 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2482 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2483 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2489 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2490 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2496 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2498 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2499 if(duCb.actvCellLst[cellIdx] &&
2500 (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2502 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2503 if((duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2504 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2506 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2508 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2510 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2511 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2517 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2518 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2527 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
2528 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2530 //TODO: Send the failure case in Ue Context Setup Response
2534 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2538 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2545 /*******************************************************************
2547 * @brief Processes UE create Req to RLC UL
2551 * Function : duBuildAndSendUeCreateReqToRlc
2554 * Processes UE create Req to RLC UL
2556 * @params[in] cellId,
2558 * Pointer to RlcUeCfg
2559 * @return ROK - success
2562 *****************************************************************/
2564 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, RlcUeCfg *duRlcUeCfg)
2567 RlcUeCfg *rlcUeCfg = NULLP;
2570 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
2573 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2577 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2578 /* Copying ueCfg to a sharable buffer */
2579 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2582 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2583 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2584 /* Processing one Ue at a time to RLC */
2585 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2586 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2589 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2590 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2596 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2602 /*******************************************************************
2604 * @brief Processes UE create Rsp received from RLC UL
2609 * Function : DuProcRlcUeCfgRsp
2612 * Processes UE create Rsp received from RLC UL
2614 * @params[in] Post structure
2615 * Pointer to RlcCfgCfm
2616 * @return ROK - success
2619 *****************************************************************/
2620 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2626 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2628 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2630 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2631 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2633 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2634 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2635 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2637 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2639 /* If UE is in handover, RACH resource needs to be requested
2640 * from MAC for CFRA */
2641 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2643 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2644 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2645 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2651 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2652 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2657 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2659 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2661 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2662 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2663 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2665 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2667 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2669 DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
2670 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2676 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2677 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2685 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2686 pst->event, cfgRsp->ueId, cfgRsp->reason);
2687 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2689 //TODO: update failure case in ue Context setup Response
2693 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2697 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2703 /*******************************************************************
2705 * @brief Builds and Send Ue Reconfig Req to RLC
2709 * Function : duBuildAndSendUeReCfgReqToRLC
2711 * Functionality: Builds and Send Ue Reconfig Req to RLC
2713 * @params[in] cellId, crnti
2715 * RlcUeCfg *rlcUeCfg
2716 * @return ROK - success
2719 * ****************************************************************/
2721 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2724 RlcUeCfg *rlcUeCfg = NULLP;
2726 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2729 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2730 ret = fillRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, rlcUeCfg);
2732 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2734 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2738 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2744 /*******************************************************************
2746 * @brief Builds and Send Ue Reconfig Req to MAC
2750 * Function : duBuildAndSendUeReCfgReqToMac
2752 * Functionality: Builds and Send Ue Reconfig Req to MAC
2754 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2756 * MacUeCfg *macUeCfg
2757 * @return ROK - success
2760 * ****************************************************************/
2762 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
2765 MacUeCfg *macUeCfg = NULLP;
2767 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2770 memset(macUeCfg, 0, sizeof(MacUeCfg));
2771 ret = fillMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, macUeCfg);
2773 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2775 ret = sendUeReCfgReqToMac(macUeCfg);
2779 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2785 /*******************************************************************
2787 * @brief Build and Send Ue context setup request
2792 * Function : duBuildAndSendUeContextSetupReq
2795 * Build and Send Ue context setup request
2797 * @params[in] cellId, crnti, DuUeCfg pointer
2798 * @return ROK - success
2801 *****************************************************************/
2803 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
2807 DuUeCfg *duUeCfg = NULLP;
2809 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2813 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
2817 crnti = ueCb->crnti;
2818 duUeCfg = &ueCb->f1UeDb->duUeCfg;
2820 /* If UE is being handed-in to this DU, UE context setup request will create
2821 * new UE context at MAC/SCH and RLC.
2822 * If UE is in active state, UE contex setup request will lead to
2823 * reconfiguration of UE at MAC/SCH and RLC
2825 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
2827 /* Filling MAC UE Config */
2828 memset(&ueCb->macUeCfg, 0, sizeof(MacUeCfg));
2830 /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
2831 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->macUeCfg);
2833 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
2835 ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->rlcUeCfg);
2837 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
2842 /* Filling RLC UE Reconfig */
2843 ret = duBuildAndSendUeReCfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
2845 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2847 /* Filling MAC UE Reconfig */
2848 ret = duBuildAndSendUeReCfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
2850 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2856 /*******************************************************************
2858 * @brief Processes DL Rsp received from RLC DL
2863 * Function : DuProcRlcDlRrcMsgRsp
2866 * Processes UE Rsp received from RLC DL
2868 * @params[in] Post structure
2869 * Pointer to RlcCfgCfm
2870 * @return ROK - success
2873 *****************************************************************/
2874 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2876 uint8_t ret = ROK, ueId = 0;
2877 uint16_t cellId, crnti;
2878 DuUeCb *ueCb = NULLP;
2881 state = dlRrcMsg->state;
2882 cellId = dlRrcMsg->cellId;
2883 crnti = dlRrcMsg->crnti;
2884 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2886 if(state == TRANSMISSION_COMPLETE)
2888 GET_UE_ID(crnti, ueId);
2889 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
2891 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2893 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2895 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
2897 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2900 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2902 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
2904 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2907 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2909 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2912 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2918 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2922 /*******************************************************************
2924 * @brief Process UE context setup request from CU
2928 * Function : duProcUeContextSetupRequest
2930 * Functionality: Process UE context setup request from CU
2932 * @params[in] F1AP message
2933 * @return ROK - success
2936 * ****************************************************************/
2938 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2940 uint8_t ret, cellId;
2945 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2947 /* Send DL RRC msg for security Mode */
2948 if(ueCb->f1UeDb->dlRrcMsg)
2950 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2952 /* Sending DL RRC Message to RLC */
2953 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2956 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2957 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2958 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2959 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2963 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2965 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
2968 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2974 //TODO: To send the failure cause in UeContextSetupRsp
2975 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2980 /*******************************************************************
2982 * @brief Build and Send Ue context mod request
2987 * Function : duBuildAndSendUeContextModReq
2990 * Build and Send Ue context mod request
2992 * @params[in] cellId, crnti, DuUeCfg pointer
2993 * @return ROK - success
2996 *****************************************************************/
2998 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
3002 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
3003 /* Filling RLC Ue Reconfig */
3004 ret = duBuildAndSendUeReCfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3006 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
3008 /* Filling MAC Ue Reconfig */
3009 ret = duBuildAndSendUeReCfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3011 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
3015 /*******************************************************************
3017 * @brief Processing Ue context mod request
3022 * Function : duProcUeContextModReq
3025 * Processing Ue context mod request
3027 * @params[in] DuUeCb *ueCb
3028 * @return ROK - success
3031 *****************************************************************/
3033 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
3035 uint8_t ret, cellId;
3040 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3041 /* Send DL RRC msg for security Mode */
3042 if(ueCb->f1UeDb->dlRrcMsg)
3044 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3046 /* Sending DL RRC Message to RLC */
3047 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3050 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
3051 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3052 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3053 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3057 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3059 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
3062 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
3066 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
3068 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
3070 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
3077 //TODO: To send the failure cause in UeContextModRsp
3079 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
3085 /*******************************************************************
3087 * @brief Function to delete Pdsch ServCellCfg
3091 * Function : deletePdschServCellCfg
3093 * Functionality: Function to delete Pdsch ServCellCfg
3095 * @params[in] PdschServCellCfg *pdschServCellCfg
3098 * ****************************************************************/
3100 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
3102 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
3103 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
3104 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
3105 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
3108 /*******************************************************************
3110 * @brief delete MacUeCfg from duCb
3114 * Function : deleteMacUeCfg
3116 * Functionality: delete MacUeCfg from duCb
3118 * @params[in] Pointer to MacUeCfg
3119 * @return ROK - success
3122 *******************************************************************/
3124 void deleteMacUeCfg(MacUeCfg *ueCfg)
3128 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
3129 if(ueCfg->spCellCfgPres)
3131 freeUeReCfgCellGrpInfo(ueCfg);
3133 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
3135 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
3137 memset(ueCfg, 0, sizeof(MacUeCfg));
3140 /*******************************************************************
3142 * @brief delete UE Configuration of a particular UE
3146 * Function : deleteUeCfg
3148 * Functionality: delete UE Configuration of a particular UE
3150 * @params[in] uint16_t cellIdx, uint8_t ueId
3151 * @return ROK - success
3154 * ****************************************************************/
3155 uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
3158 uint16_t cellIdx = 0;
3159 DuUeCb *ueCb = NULLP;
3161 GET_CELL_IDX(cellId, cellIdx);
3162 if(duCb.actvCellLst[cellIdx] != NULLP)
3164 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3165 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3167 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3168 deleteMacUeCfg(&ueCb->macUeCfg);
3169 deleteRlcUeCfg(&ueCb->rlcUeCfg);
3170 if(ueCb->f1UeDb !=NULLP)
3172 freeF1UeDb(ueCb->f1UeDb);
3174 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3176 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3178 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3179 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3184 unsetBitInUeBitMap(cellId, ueId-1);
3185 duCb.actvCellLst[cellIdx]->numActvUes--;
3186 memset(ueCb, 0, sizeof(DuUeCb));
3195 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3202 /*******************************************************************
3204 * @brief Handle UE delete response from MAC
3208 * Function : DuProcMacUeDeleteRsp
3210 * Functionality: Handle UE delete response from MAC
3212 * @params[in] Pointer to MacUeDeleteRsp and Pst
3213 * @return ROK - success
3216 * ****************************************************************/
3218 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3220 uint8_t ret =ROK,ueId=0;
3222 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3226 if(deleteRsp->result == SUCCESS)
3228 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3229 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3230 if(duCb.actvCellLst[cellIdx])
3232 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3233 ueId = deleteRsp->ueId;
3234 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3235 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3236 if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
3238 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3241 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3249 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3253 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3257 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3263 /*******************************************************************
3265 * @brief Processes UE Delete Rsp received from RLC
3269 * Function : DuProcRlcUeDeleteRsp
3272 * Processes UE Delete Rsp received from RLC
3274 * @params[in] Post structure
3275 * Pointer to RlcUeDeleteRsp
3276 * @return ROK - success
3279 * *****************************************************************/
3281 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3283 uint8_t ueId = 0, ret = ROK;
3284 uint16_t cellIdx = 0,crnti=0;
3288 ueId = delRsp->ueId;
3289 GET_CELL_IDX(delRsp->cellId, cellIdx);
3291 if(delRsp->result == SUCCESSFUL)
3293 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3294 if(duCb.actvCellLst[cellIdx]!=NULLP)
3296 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3297 GET_CRNTI(crnti, ueId);
3298 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3300 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3308 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3311 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3317 /*******************************************************************
3319 * @brief Sending UE Delete Req To Mac
3323 * Function : sendUeDeleteReqToMac
3326 * sending UE Delete Req To Mac
3328 * @params[in] cellId, ueId, crnti
3329 * @return ROK - success
3332 *****************************************************************/
3334 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3338 MacUeDelete *ueDelete = NULLP;
3340 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3343 ueDelete->cellId = cellId;
3344 ueDelete->ueId = ueId;
3345 ueDelete->crnti = crnti;
3346 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3348 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3349 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3352 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3353 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3358 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3364 /*******************************************************************
3366 * @brief Sending UE Delete Req To Rlc
3370 * Function : sendUeDeleteReqToRlc
3373 * Sending UE Delete Req To Rlc
3375 * @params[in] cellId, ueId
3376 * @return ROK - success
3379 *****************************************************************/
3381 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3385 RlcUeDelete *ueDelete;
3387 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3388 if(ueDelete !=NULLP)
3390 ueDelete->cellId = cellId;
3391 ueDelete->ueId = ueId;
3392 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3394 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3397 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3398 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3403 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3409 /*******************************************************************
3411 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3415 * Function : duBuildAndSendUeDeleteReq
3417 * Functionality: DU processes UE delete req from CU and sends to MAC
3420 * @params[in] cellId, crnti
3421 * @return ROK - success
3424 * ****************************************************************/
3426 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3429 uint16_t cellIdx = 0;
3431 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3432 GET_CELL_IDX(cellId, cellIdx);
3433 GET_UE_ID(crnti, ueId);
3435 if(duCb.actvCellLst[cellIdx] != NULLP)
3437 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3439 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3443 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3444 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3446 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3452 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3459 /*******************************************************************
3461 * @brief delete RlcUeCfg from duCb
3465 * Function : deleteRlcUeCfg
3468 * delete RlcUeCfg from duCb
3470 * @params[in] RlcUeCfg *ueCfg
3472 * @return ROK - success
3475 *****************************************************************/
3477 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3480 RlcBearerCfg *lcCfg= NULLP;
3483 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3485 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3486 switch(lcCfg->rlcMode)
3490 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3493 case RLC_UM_BI_DIRECTIONAL :
3495 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3498 case RLC_UM_UNI_DIRECTIONAL_UL :
3500 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3503 case RLC_UM_UNI_DIRECTIONAL_DL :
3505 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3509 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3511 memset(ueCfg, 0, sizeof(RlcUeCfg));
3515 /*******************************************************************
3517 * @brief Du process Ue Context Release Command
3521 * Function : duProcUeContextReleaseCommand
3523 * Functionality: Du process Ue Context Release Command
3525 * @params[in] DuUeCb *duUeCb
3526 * @return ROK - success
3529 * ****************************************************************/
3530 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3532 uint8_t ret =ROK, ueId=0;
3537 crnti = duUeCb->crnti;
3538 GET_UE_ID(crnti, ueId);
3542 /* Send DL RRC msg for RRC release */
3543 if(duUeCb->f1UeDb->dlRrcMsg)
3545 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3547 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3548 duUeCb->f1UeDb->dlRrcMsg);
3551 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3552 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3553 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3554 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3561 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3564 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3571 /**********************************************************************
3573 ***********************************************************************/