1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
38 #include "AlarmInterface.h"
39 #include "CmInterface.h"
42 DuMacDlCcchInd packMacDlCcchIndOpts[] =
44 packMacDlCcchInd, /* Loose coupling */
45 MacProcDlCcchInd, /* TIght coupling */
46 packMacDlCcchInd /* Light weight-loose coupling */
49 DuMacUeCreateReq packMacUeCreateReqOpts[] =
51 packDuMacUeCreateReq, /* Loose coupling */
52 MacProcUeCreateReq, /* TIght coupling */
53 packDuMacUeCreateReq /* Light weight-loose coupling */
56 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
58 packDuRlcUeCreateReq, /* Loose coupling */
59 RlcProcUeCreateReq, /* TIght coupling */
60 packDuRlcUeCreateReq /* Light weight-loose coupling */
63 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
65 packDlRrcMsgToRlc, /* Loose coupling */
66 RlcProcDlRrcMsgTransfer, /* Tight coupling */
67 packDlRrcMsgToRlc /* Light weight-loose coupling */
70 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
72 packDuRlcUeReconfigReq, /* Loose coupling */
73 RlcProcUeReconfigReq, /* TIght coupling */
74 packDuRlcUeReconfigReq /* Light weight-loose coupling */
77 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
79 packDuMacUeReconfigReq, /* Loose coupling */
80 MacProcUeReconfigReq, /* TIght coupling */
81 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 DuMacRachRsrcReq packMacRachRsrcReqOpts[] =
86 packDuMacRachRsrcReq, /* Loose coupling */
87 MacProcRachRsrcReq, /* Tight coupling */
88 packDuMacRachRsrcReq /* Light weight-loose coupling */
91 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
93 packRlcDlUserDataToRlc, /* Loose coupling */
94 RlcProcDlUserDataTransfer, /* Tight coupling */
95 packRlcDlUserDataToRlc /* Light weight-loose coupling */
98 DuMacRachRsrcRel packMacRachRsrcRelOpts[] =
100 packDuMacRachRsrcRel, /* Loose coupling */
101 MacProcRachRsrcRel, /* Tight coupling */
102 packDuMacRachRsrcRel /* Light weight-loose coupling */
105 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
107 packDuMacUeDeleteReq, /* Loose coupling */
108 MacProcUeDeleteReq, /* TIght coupling */
109 packDuMacUeDeleteReq /* Light weight-loose coupling */
112 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
114 packDuRlcUeDeleteReq, /* Loose coupling */
115 RlcProcUeDeleteReq, /* TIght coupling */
116 packDuRlcUeDeleteReq /* Light weight-loose coupling */
119 /******************************************************************
121 * @brief Function to return Drb LcId
125 * Function : getDrbLcId
127 * Functionality: Function to return Drb LcId
129 * @params[in] drbBitMap
131 * Returns: lcId - SUCCESS
133 *****************************************************************/
135 uint8_t getDrbLcId(uint32_t *drbBitMap)
137 uint8_t bitMask = 1, bitPos = 0;
138 bitPos = MIN_DRB_LCID;
140 while(bitPos <= MAX_DRB_LCID)
142 if((*drbBitMap & (bitMask << bitPos)) == 0)
144 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
152 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
156 /*******************************************************************
158 * @brief Function to fillDlUserDataInfo
162 * Function : fillDlUserDataInfo
165 * Function to fillDlUserDataInfo
170 * @return ROK - success
173 * ****************************************************************/
175 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
179 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
180 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
182 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
184 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
186 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
187 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
188 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
196 /*******************************************************************
198 * @brief Build and Send DL Data Message transfer to RLC
202 * Function : duBuildAndSendDlUserDataToRlc
205 * Build and Send DL Data Message transfer to RLC
207 * @params[in] Cell ID
209 * Logical Channgel ID
212 * @return ROK - success
215 * ****************************************************************/
217 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
219 uint8_t ret = RFAILED;
221 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
223 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
226 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
229 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
230 dlDataMsgInfo->dlMsg = egtpMsg->msg;
231 dlDataMsgInfo->msgLen = msgLen;
233 /* Filling DL DATA Msg Info */
234 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
236 /* Filling post structure and sending msg */
237 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
238 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
239 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
240 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
244 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
245 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
246 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
251 /*******************************************************************
253 * @brief Handles EGTP data from CU
257 * Function : duHdlEgtpData
260 * Processes EGTP header and sends data to RLC
262 * @params[in] Pointer to EGTP Message
263 * @return ROK - success
266 * ****************************************************************/
267 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
271 #ifdef CALL_FLOW_DEBUG_LOG
272 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
275 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
279 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
282 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
283 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
285 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
291 /******************************************************************
293 * @brief Builds and Sends DL CCCH Ind to MAC
297 * Function : duBuildAndSendDlCcchInd
299 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
301 * @params[in] dlCcchMsg - uint8_t*
302 * @return ROK - success
305 * ****************************************************************/
306 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
307 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
311 DlCcchIndInfo *dlCcchIndInfo = NULLP;
314 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
316 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
320 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
324 dlCcchIndInfo->cellId = *cellId;
325 dlCcchIndInfo->crnti = *crnti;
326 dlCcchIndInfo->msgType = msgType;
327 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
329 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
330 if(!dlCcchIndInfo->dlCcchMsg)
332 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
333 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
336 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
338 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
340 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
343 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
344 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
347 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
348 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
349 dlCcchIndInfo->dlCcchMsgLen);
350 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
351 sizeof(DlCcchIndInfo));
359 /*******************************************************************
361 * @brief Build and Send DL RRC Message transfer to RLC
365 * Function : duBuildAndSendDlRrcMsgToRlc
368 * Build and Send DL RRC Message transfer to RLC
370 * @params[in] Cell ID
372 * Logical Channgel ID
375 * @return ROK - success
378 * ****************************************************************/
379 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, DuRlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
384 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
388 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
392 /*As per Spec ORAN WG8 AAD, lcId for DL RRC range from 1...3*/
393 if((f1DlRrcMsg->srbId < SRB1_LCID) || (f1DlRrcMsg->srbId > SRB3_LCID))
395 DU_LOG("\nERROR --> DU APP : Received SRBID for this Dl RRC Msg is not valid");
399 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
403 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
404 duBuildAndSendDlRrcMsgToRlc");
405 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
409 /* Filling up the RRC msg info */
410 dlRrcMsgInfo->cellId = cellId;
411 dlRrcMsgInfo->ueId = ueCfg.ueId;
412 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
414 if(ueCfg.rlcLcCfg[lcIdx].rlcBearerCfg.lcId == f1DlRrcMsg->srbId)
416 dlRrcMsgInfo->lcId = f1DlRrcMsg->srbId;
420 if(lcIdx == (MAX_NUM_LC + 1))
422 DU_LOG("\nERROR --> DU APP : (duBuildAndSendDlRrcMsgToRlc) SRB for this DL_RRC msg is not configured.");
423 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
427 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
428 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
429 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
430 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
432 /* Filling post structure and sending msg */
433 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
434 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
435 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
438 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
439 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
448 /******************************************************************
450 * @brief Process DL RRC Msg recevied from F1AP
454 * Function : duProcDlRrcMsg
456 * Functionality: Process DL RRC Msg recevied from F1AP
458 * @params[in] dlCcchMsg - uint8_t*
459 * @return ROK - success
462 * ****************************************************************/
464 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
467 uint16_t crnti, cellId, cellIdx;
468 bool ueCcchCtxtFound = false;
469 bool ueFound = false;
473 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
475 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
477 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
479 ueCcchCtxtFound = true;
480 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
481 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
488 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
491 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
495 if(duCb.actvCellLst[cellId-1] == NULLP)
497 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
500 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
502 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
505 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
506 duCb.ueCcchCtxt[ueIdx].cellId);
511 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
518 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
520 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
522 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
523 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
526 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
527 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg, dlRrcMsg);
530 DU_LOG("\nERROR --> DU_APP: duBuildAndSendDlRrcMsgToRlc() Failed for UE ID:%d", dlRrcMsg->gnbDuUeF1apId);
541 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
548 /******************************************************************
550 * @brief Processes UL CCCH Ind recvd from MAC
554 * Function : duProcUlCcchInd
556 * Functionality: Processes UL CCCH Ind recvd from MAC
558 * @params[in] UlCcchIndInfo *ulCcchIndInfo
559 * @return ROK - success
562 * ****************************************************************/
563 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
567 int32_t gnbDuUeF1apId = 0;
569 if(ulCcchIndInfo->crnti)
571 GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
575 DU_LOG("\nERROR --> DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
579 /* Store Ue mapping */
580 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
581 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
582 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
586 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
587 ulCcchIndInfo->ulCcchMsg));
590 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
593 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
594 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
600 /******************************************************************
602 * @brief Fills Default UL LC Cfg
606 * Function : fillDefaultUlLcCfg
608 * Functionality: Fills Default UL LC Cfg
610 * @params[in] UlLcCfg *ulLcCfg
612 *****************************************************************/
613 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
615 ulLcCfg->priority = LC_PRIORITY_1;
616 ulLcCfg->lcGroup = 0;
617 ulLcCfg->schReqId = 0;
618 ulLcCfg->pbr = PBR_KBPS_INFINITY;
619 ulLcCfg->bsd = BSD_MS_1000;
622 /******************************************************************
624 * @brief Fills Initial DL Bandwidth Part
628 * Function : fillDefaultInitDlBwp
630 * Functionality: Fills Initial DL Bandwidth Part
632 * @params[in] InitialDlBwp *initDlBwp
633 * @return ROK - success
636 *****************************************************************/
637 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
640 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
641 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
645 /* Filling PDCCH Config */
646 initDlBwp->pdcchPresent = TRUE;
647 if(initDlBwp->pdcchPresent)
649 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
650 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
651 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
653 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
654 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
655 coreset0EndPrb = CORESET0_END_PRB;
656 coreset1StartPrb = coreset0EndPrb +6;
657 coreset1NumPrb = CORESET1_NUM_PRB;
658 /* calculate the PRBs */
659 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
660 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
662 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
663 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
664 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
665 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
667 initDlBwp->pdcchCfg.numCRsetToRel = 0;
669 /* Filling Serach Space */
670 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
671 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
672 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
674 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
675 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
676 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
677 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
678 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
680 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
682 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
683 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
684 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
687 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
690 /* Filling PDSCH Config */
691 initDlBwp->pdschPresent = TRUE;
692 if(initDlBwp->pdschPresent)
694 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
695 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
697 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
700 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
701 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
702 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
703 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
706 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
707 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
709 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
712 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
714 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
716 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
717 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
718 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
719 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
721 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
722 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
723 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
724 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
731 /******************************************************************
733 * @brief Fills Initial UL Bandwidth Part
737 * Function : fillDefaultInitUlBwp
739 * Functionality: Fills Initial UL Bandwidth Part
741 * @params[in] InitialUlBwp *initUlBwp
744 *****************************************************************/
745 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
750 initUlBwp->pucchPresent = FALSE;
752 /*Filling PUSCH Config */
753 initUlBwp->puschPresent = TRUE;
754 if(initUlBwp->puschPresent)
756 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
757 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
758 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
759 scramblingId0 = SCRAMBLING_ID;
760 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
761 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
763 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
765 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
766 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
768 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
769 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
770 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
771 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
774 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
775 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
776 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
777 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
778 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
779 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
781 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
786 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
790 /******************************************************************
792 * @brief Fills SpCell Group Info
796 * Function : fillDefaultSpCellGrpInfo
798 * Functionality: Fills Sp Cell Group Info
800 * @params[in] DuMacUeCfg *macUeCfg
801 * @return ROK - Success
804 *****************************************************************/
805 uint8_t fillDefaultSpCellGrpInfo(DuMacUeCfg *macUeCfg)
807 SpCellRecfg *spCell = NULL;
810 spCell = &macUeCfg->spCellCfg;
814 macUeCfg->spCellCfgPres = true;
816 spCell->servCellIdx = SERV_CELL_IDX;
817 /* Filling Initial Dl Bwp */
818 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
820 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
824 spCell->servCellCfg.numDlBwpToAddOrMod = 0;
825 spCell->servCellCfg.numDlBwpToRel = 0;
826 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
827 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
828 spCell->servCellCfg.bwpInactivityTmr = NULLP;
829 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
830 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
831 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
832 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
833 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
835 /* Filling Initial UL Bwp*/
836 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
837 spCell->servCellCfg.numUlBwpToAddOrMod = 0;
838 spCell->servCellCfg.numUlBwpToRel = 0;
839 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
843 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
849 /******************************************************************
851 * @brief Fills Physical Cell Group Info
855 * Function : fillDefaultPhyCellGrpInfo
857 * Functionality: Fills Physical Cell Group Info
859 * @params[in] DuMacUeCfg *macUeCfg
862 *****************************************************************/
863 void fillDefaultPhyCellGrpInfo(DuMacUeCfg *macUeCfg)
865 PhyCellGrpCfg *cellGrp = NULL;
868 cellGrp = &macUeCfg->phyCellGrpCfg;
872 macUeCfg->phyCellGrpCfgPres = true;
873 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
874 cellGrp->pNrFr1 = P_NR_FR1;
878 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
882 /******************************************************************
884 * @brief Fills Mac Cell Group Info
888 * Function : fillDefaultMacCellGrpInfo
890 * Functionality: Fills Mac Cell Group Info
892 * @params[in] DuMacUeCfg *macUeCfg
895 *****************************************************************/
896 void fillDefaultMacCellGrpInfo(DuMacUeCfg *macUeCfg)
899 MacCellGrpCfg *cellGrp = NULL;
902 cellGrp = &macUeCfg->macCellGrpCfg;
906 macUeCfg->macCellGrpCfgPres = true;
908 /* Filling Scheduling Request Config */
909 cellGrp->schReqCfg.addModListCount = 1;
910 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
912 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
914 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
915 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
916 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
919 cellGrp->schReqCfg.relListCount = 0;
921 /* Filling Tag config */
922 cellGrp->tagCfg.addModListCount = 1;
923 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
925 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
927 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
928 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
931 cellGrp->tagCfg.relListCount = 0;
933 /* Filling BSR config */
934 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
935 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
936 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
938 /* Filling PHR config */
939 cellGrp->phrCfgSetupPres = true;
940 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
941 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
942 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
943 cellGrp->phrCfg.multiplePHR = false;
944 cellGrp->phrCfg.dummy = false;
945 cellGrp->phrCfg.phrType2OtherCell = false;
946 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
948 /* Filling Drx Config */
950 cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = DRX_ONDURATION_TIMER_VALUE_PRESENT_IN_MS;
951 if(!cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
952 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
953 DRX_ONDURATION_TIMER_VALUE_IN_SUBMS;
955 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
956 DRX_ONDURATION_TIMER_VALUE_IN_MS;
957 cellGrp->drxCfg.drxInactivityTimer = DRX_INACTIVITY_TIMER;
958 cellGrp->drxCfg.drxHarqRttTimerDl = DRX_HARQ_RTT_TIMER_DL;
959 cellGrp->drxCfg.drxHarqRttTimerUl = DRX_HARQ_RTT_TIMER_UL;
960 cellGrp->drxCfg.drxRetransmissionTimerDl = DRX_RETRANSMISSION_TIMER_DL;
961 cellGrp->drxCfg.drxRetransmissionTimerUl = DRX_RETRANSMISSION_TIMER_UL;
962 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = DRX_LONG_CYCLE_START_OFFSET_VAL;
963 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = DRX_LONG_CYCLE_START_OFFSET_CHOICE;
964 cellGrp->drxCfg.shortDrxPres = DRX_SHORT_CYCLE_PRESENT;
965 if(cellGrp->drxCfg.shortDrxPres)
967 cellGrp->drxCfg.shortDrx.drxShortCycle = DRX_SHORT_CYCLE;
968 cellGrp->drxCfg.shortDrx.drxShortCycleTimer = DRX_SHORT_CYCLE_TIMER;
970 cellGrp->drxCfg.drxSlotOffset = DRX_SLOT_OFFSET;
976 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
980 /*******************************************************************
982 * @brief Fills default modulation info for a UE
986 * Function : fillDefaultModulation
988 * Functionality: Fills default modulation info for a UE
990 * @params[in] Pointer to MAC UE configuration
991 * @return ROK - success
994 * ****************************************************************/
995 void fillDefaultModulation(DuMacUeCfg *ueCfg)
997 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
998 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
999 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1001 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
1002 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
1003 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1006 /******************************************************************
1008 * @brief Function to fill Mac Lc Cfg for SRB1
1012 * Function : fillMacSrb1LcCfg
1014 * Functionality: Function to fill Mac Lc cfg for SRB1
1016 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1018 *****************************************************************/
1020 void fillMacSrb1LcCfg(DuLcCfg *macLcCfg)
1022 macLcCfg->lcConfig.lcId = SRB1_LCID;
1023 macLcCfg->configType = CONFIG_ADD;
1024 macLcCfg->lcConfig.drbQos = NULLP;
1025 macLcCfg->lcConfig.snssai = NULLP;
1026 macLcCfg->lcConfig.ulLcCfgPres = true;
1027 fillDefaultUlLcCfg(&macLcCfg->lcConfig.ulLcCfg);
1030 /******************************************************************
1032 * @brief Function to fill the Lc cfg from ueSetupReqDb
1036 * Function : fillMacLcCfgToAddMod
1038 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1040 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1041 * @return ROK/RFAILED
1043 *****************************************************************/
1045 uint8_t fillMacLcCfgToAddMod(DuLcCfg *macLcCfgToSend, DuLcCfg *ueLcCfgDb, DuLcCfg *oldLcCfg, Bool toUpdate)
1051 macLcCfgToSend->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1052 macLcCfgToSend->configType = ueLcCfgDb->configType;
1054 if(ueLcCfgDb->lcConfig.drbQos)
1055 macLcCfgToSend->lcConfig.drbQos = ueLcCfgDb->lcConfig.drbQos;
1057 macLcCfgToSend->lcConfig.drbQos = oldLcCfg->lcConfig.drbQos;
1059 macLcCfgToSend->lcConfig.drbQos = NULL;
1061 if(ueLcCfgDb->lcConfig.snssai)
1062 macLcCfgToSend->lcConfig.snssai = ueLcCfgDb->lcConfig.snssai;
1064 macLcCfgToSend->lcConfig.snssai = oldLcCfg->lcConfig.snssai;
1066 macLcCfgToSend->lcConfig.snssai = NULL;
1068 macLcCfgToSend->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1069 memcpy(&macLcCfgToSend->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1070 memcpy(&macLcCfgToSend->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1075 oldLcCfg->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1076 oldLcCfg->configType = ueLcCfgDb->configType;
1078 if(ueLcCfgDb->lcConfig.drbQos)
1080 if(oldLcCfg->lcConfig.drbQos)
1081 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1083 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1084 if(oldLcCfg->lcConfig.drbQos == NULL)
1086 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1089 memcpy(oldLcCfg->lcConfig.drbQos, ueLcCfgDb->lcConfig.drbQos, sizeof(DrbQosInfo));
1092 if(ueLcCfgDb->lcConfig.snssai)
1094 if(oldLcCfg->lcConfig.snssai)
1095 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1097 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1098 if(oldLcCfg->lcConfig.snssai == NULL)
1100 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1101 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1104 memcpy(oldLcCfg->lcConfig.snssai, ueLcCfgDb->lcConfig.snssai, sizeof(Snssai));
1107 oldLcCfg->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1108 memcpy(&oldLcCfg->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1109 memcpy(&oldLcCfg->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1114 /******************************************************************
1116 * @brief Function to copy the Bit rate from ueSetupReqDb
1120 * Function : fillAmbr
1122 * Functionality: Function to copy bit Rate from ueSetupReqDb
1124 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1125 * @return ROK/RFAILED
1127 *****************************************************************/
1129 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1135 *macAmbrCfgToSend = ueDbAmbr;
1137 else if(oldMacAmbrCfg)
1138 *macAmbrCfgToSend = *oldMacAmbrCfg;
1148 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1150 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1151 if(*oldMacAmbrCfg == NULLP)
1153 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1156 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1157 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1165 /******************************************************************
1167 * @brief Builds and Send UE ReConfig Request to MAC
1171 * Function : sendUeRecfgReqToMac
1173 * Functionality: Builds and Send UE ReConfig Request to MAC
1175 * @Params[in] MacUeRecfg pointer
1176 * @return ROK - success
1179 * ****************************************************************/
1181 uint8_t sendUeRecfgReqToMac(MacUeRecfg *macUeRecfg)
1187 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1191 /* Processing one Ue at a time to MAC */
1192 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1193 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeRecfg);
1196 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeRecfgReqToMac()");
1197 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeRecfg, sizeof(MacUeRecfg));
1202 DU_LOG("\nERROR --> DU_APP: Received macUeRecfg is NULLP at sendUeRecfgReqToMac()");
1210 /******************************************************************
1212 * @brief update DuMacUeCfg structure
1216 * Function : updateDuMacUeCfg
1218 * Functionality: Fills DuMacUeCfg
1220 * @params[in] cellId, ueId, crnti,
1222 * DuMacUeCfg pointer
1223 * @return ROK/RFAILED
1225 *****************************************************************/
1226 uint8_t updateDuMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1228 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1229 bool lcIdFound = false;
1230 DuMacUeCfg *duMacDb = NULLP;
1232 duMacUeCfg->cellId = cellId;
1233 duMacUeCfg->ueId = gnbDuUef1apId;
1234 duMacUeCfg->crnti = crnti;
1238 fillDefaultMacCellGrpInfo(duMacUeCfg);
1239 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1241 if((fillDefaultSpCellGrpInfo(duMacUeCfg)) != ROK)
1243 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1247 duMacUeCfg->ambrCfg = NULLP;
1248 fillDefaultModulation(duMacUeCfg);
1249 fillMacSrb1LcCfg(&duMacUeCfg->lcCfgList[0]);
1250 duMacUeCfg->numLcs++;
1254 if(ueCfgDb->dataTransmissionAction == STOP_TRANSMISSION)
1256 duMacUeCfg->transmissionAction = ueCfgDb->dataTransmissionAction;
1260 GET_CELL_IDX(cellId, cellIdx);
1261 if(duCb.actvCellLst[cellIdx])
1262 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[duMacUeCfg->ueId-1].duMacUeCfg;
1265 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1268 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1270 if(ueCfgDb->cellGrpCfg)
1272 ret = procUeRecfgCellInfo(duMacUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1275 if(duMacUeCfg->spCellCfgPres == true)
1277 if(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1279 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1280 &duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1282 if(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1284 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1285 NULL, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1290 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1292 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1294 duFillModulationDetails(duMacUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1299 fillDefaultMacCellGrpInfo(duMacUeCfg);
1300 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1301 fillDefaultSpCellGrpInfo(duMacUeCfg);
1302 fillDefaultModulation(duMacUeCfg);
1303 duMacUeCfg->ambrCfg = NULLP;
1308 duMacUeCfg->drxConfigIndicatorRelease = ueCfgDb->drxConfigIndicatorRelease;
1310 if(ueCfgDb->drxCyclePres)
1312 duMacUeCfg->macCellGrpCfg.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = ueCfgDb->drxCycle.drxLongCycleLength;
1313 if(ueCfgDb->drxCycle.shortDrxCyclePres)
1315 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = true;
1316 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycle = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycle;
1317 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycleTimer;
1321 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = false;
1326 /* Filling LC Context */
1327 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1329 if(!ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres)
1331 /* Filling default UL LC config in MAC if not present */
1332 ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres = true;
1333 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfg);
1338 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1340 if(ueCfgDb->macLcCfg[dbIdx].lcConfig.lcId == duMacDb->lcCfgList[lcIdx].lcConfig.lcId)
1343 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1344 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1346 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1347 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1348 &duMacDb->lcCfgList[lcIdx], FALSE);
1358 /* ADD/DEL CONFIG */
1359 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1363 duMacUeCfg->numLcs++;
1367 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in updateDuMacUeCfg()", dbIdx);
1370 }/*End of Outer FOR loop */
1371 memcpy(&ueCfgDb->copyOfmacUeCfg, duMacUeCfg, sizeof(DuMacUeCfg));
1376 /******************************************************************
1378 * @brief Fills Rlc AM Information
1382 * Function : fillDefaultAmInfo
1384 * Functionality: Fills Rlc AM Information
1386 * @params[in] AmBearerCfg *amCfg
1389 *****************************************************************/
1390 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1393 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1394 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1395 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1396 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1397 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1400 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1401 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1402 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1405 /******************************************************************
1407 * @brief Fills RLC UM Bi Directional Information
1411 * Function : fillDefaultUmBiInfo
1413 * Functionality: Fills RLC UM Bi Directional Information
1415 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1418 *****************************************************************/
1419 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1421 /* UL UM BI DIR INFO */
1422 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1423 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1425 /* DL UM BI DIR INFO */
1426 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1429 /******************************************************************
1431 * @brief Fills RLC UM Uni Directional UL Information
1435 * Function : fillDefaultUmUlInfo
1437 * Functionality: Fills RLC UM Uni Directional Info
1439 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1442 *****************************************************************/
1443 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1445 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1446 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1449 /******************************************************************
1451 * @brief Fills RLC UM Uni Directional DL Information
1455 * Function : fillDefaultUmDlInfo
1457 * Functionality: Fills RLC UM Uni Directional DL Info
1459 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1462 *****************************************************************/
1463 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1465 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1468 /******************************************************************
1470 * @brief Builds Rlc Mode Default Configuration
1474 * Function : fillDefaultRlcModeCfg
1476 * Functionality: Builds Rlc Mode Default Configuration
1478 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1479 * @return ROK/RFAILED
1481 *****************************************************************/
1483 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1493 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1495 fillDefaultAmInfo(lcCfg->u.amCfg);
1498 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1504 case RLC_UM_BI_DIRECTIONAL :
1506 if(!lcCfg->u.umBiDirCfg)
1508 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1509 if(lcCfg->u.umBiDirCfg)
1510 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1513 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1519 case RLC_UM_UNI_DIRECTIONAL_UL :
1521 if(!lcCfg->u.umUniDirUlCfg)
1523 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1524 if(lcCfg->u.umUniDirUlCfg)
1525 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1528 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1534 case RLC_UM_UNI_DIRECTIONAL_DL :
1536 if(!lcCfg->u.umUniDirDlCfg)
1538 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1539 if(lcCfg->u.umUniDirDlCfg)
1540 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1543 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1550 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1557 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1563 /*******************************************************************
1565 * @brief Function to fill Rlc Lc Cfg for SRB1
1569 * Function : fillRlcSrb1LcCfg
1572 * Function to fill Rlc Lc Cfg for SRB1
1574 * @params[in] Pointer to RlcBearerCfg
1575 * @return ROK/RFAILED
1577 *****************************************************************/
1579 uint8_t fillRlcSrb1LcCfg(DuRlcBearerCfg *rlcLcCfg)
1583 rlcLcCfg->rlcBearerCfg.rbId = SRB1_LCID;
1584 rlcLcCfg->rlcBearerCfg.rbType = RB_TYPE_SRB;
1585 rlcLcCfg->rlcBearerCfg.lcId = SRB1_LCID;
1586 rlcLcCfg->rlcBearerCfg.lcType = LCH_DCCH;
1587 rlcLcCfg->rlcBearerCfg.rlcMode = RLC_AM;
1588 rlcLcCfg->configType = CONFIG_ADD;
1589 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcBearerCfg.rlcMode, &rlcLcCfg->rlcBearerCfg);
1590 rlcLcCfg->rlcBearerCfg.isLcAddModRspSent = true;
1594 /*******************************************************************
1596 * @brief Processes UE ReConfig Req to RLC UL
1600 * Function : sendUeRecfgReqToRlc
1603 * Processes UE Reconfig Req to RLC UL
1605 * @params[in] Pointer to RlcUeCfg
1606 * @return ROK - success
1609 *****************************************************************/
1611 uint8_t sendUeRecfgReqToRlc(RlcUeRecfg *rlcUeRecfg)
1616 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1619 /* Processing one Ue at a time to RLC */
1620 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1621 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeRecfg);
1624 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeRecfgReqToRlc()");
1625 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeRecfg, sizeof(RlcUeRecfg));
1630 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeRecfgReqToRlc()");
1636 /******************************************************************
1638 * @brief Fills Snssai information
1642 * Function : fillSnssaiInfo
1644 * Functionality: Fills Snssai information
1646 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1648 * @return ROK - success
1651 *****************************************************************/
1652 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1657 snssaiTobeSend = snssaiDb;
1659 snssaiTobeSend = *oldSnssai;
1661 snssaiTobeSend = NULL;
1668 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1670 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1671 if(*oldSnssai == NULL)
1673 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1676 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1681 /******************************************************************
1683 * @brief Fills RlcBearerCfg structure
1687 * Function : updateRlcUeCfg
1689 * Functionality: Fills Rlc Bearer Cfg
1692 *****************************************************************/
1693 uint8_t updateRlcUeCfg(uint16_t cellId, uint8_t duUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *rlcUeCfg)
1695 uint8_t ret, dbIdx, lcIdx, cellIdx;
1696 bool lcIdFound = false;
1697 DuRlcUeCfg *duRlcDb = NULLP;
1700 rlcUeCfg->cellId = cellId;
1701 rlcUeCfg->ueId = duUeF1apId;
1705 /* Initial RB being Added */
1706 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1710 memset(rlcUeCfg, 0, sizeof(DuRlcUeCfg));
1714 /* Fetch RlcDb from DuUeCb */
1715 GET_CELL_IDX(cellId, cellIdx);
1716 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[rlcUeCfg->ueId-1].duRlcUeCfg;
1717 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1719 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1721 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.rlcMode, &ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg);
1724 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1725 memset(rlcUeCfg, 0, sizeof(DuRlcUeCfg));
1731 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1732 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1734 if(ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.lcId == duRlcDb->rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
1737 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1738 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1741 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1742 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(DuRlcBearerCfg));
1743 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
1744 &duRlcDb->rlcLcCfg[lcIdx].rlcBearerCfg.snssai,false);
1754 /* ADD/ DEL Config Type */
1755 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(DuRlcBearerCfg));
1756 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, NULL, false);
1764 /******************************************************************
1766 * @brief creates UE context
1770 * Function : duCreateUeCb
1772 * Functionality: Creates UE Conetxt
1774 * @params[in] UeCcchCtxt Pointer
1777 * @return ROK - success
1779 * ****************************************************************/
1780 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1782 uint8_t cellIdx = 0;
1784 uint8_t ueId = 0, ueIdx = 0;
1786 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1788 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1790 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1791 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1794 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1795 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1796 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1797 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1798 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1799 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1801 /* Filling Mac Ue Config */
1802 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg, 0, sizeof(DuMacUeCfg));
1803 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1804 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg);
1806 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1808 /* Filling Rlc Ue Config */
1809 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg, 0, sizeof(DuRlcUeCfg));
1810 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, NULL,
1811 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg);
1813 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1815 duCb.actvCellLst[cellIdx]->numActvUes++;
1816 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1823 /**********************************************************************************
1825 * @brief Fills Ue Cfg from DU DB to MacUeCfg
1829 * Function : fillMacUeCfg
1831 * Functionality: fills ue Cfg to be sent to MAC
1833 * @params[in] DuMacUeCfg Pointer
1836 * @return ROK - success
1838 * *******************************************************************************/
1839 void fillMacUeCfg(DuMacUeCfg *duMacUeCfg, MacUeCfg *macUeCfg)
1843 macUeCfg->cellId = duMacUeCfg->cellId;
1844 macUeCfg->ueId = duMacUeCfg->ueId;
1845 macUeCfg->crnti = duMacUeCfg->crnti;
1846 macUeCfg->macCellGrpCfgPres = duMacUeCfg->macCellGrpCfgPres;
1847 if(macUeCfg->macCellGrpCfgPres)
1849 memcpy(&macUeCfg->macCellGrpCfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
1851 macUeCfg->phyCellGrpCfgPres = duMacUeCfg->phyCellGrpCfgPres;
1852 if(macUeCfg->phyCellGrpCfgPres)
1854 memcpy(&macUeCfg->phyCellGrpCfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
1856 macUeCfg->spCellCfgPres = duMacUeCfg->spCellCfgPres;
1857 if(macUeCfg->spCellCfgPres)
1859 macUeCfg->spCellCfg.servCellIdx = duMacUeCfg->spCellCfg.servCellIdx;
1860 macUeCfg->spCellCfg.servCellCfg.initDlBwp = duMacUeCfg->spCellCfg.servCellCfg.initDlBwp;
1861 macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numDlBwpToAddOrMod;
1862 if(macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd > 0)
1864 memcpy(macUeCfg->spCellCfg.servCellCfg.dlBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.dlBwpToAddOrModList, \
1865 (sizeof(DlBwpInfo) * MAX_NUM_BWP));
1867 macUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId;
1868 macUeCfg->spCellCfg.servCellCfg.defaultDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.defaultDlBwpId;
1869 macUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr = duMacUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr;
1870 memcpy(&macUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, &duMacUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, sizeof(PdschServCellCfg));
1871 memcpy(&macUeCfg->spCellCfg.servCellCfg.initUlBwp, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp, sizeof(InitialUlBwp));
1872 macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numUlBwpToAddOrMod;
1873 if(macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd > 0)
1875 memcpy(macUeCfg->spCellCfg.servCellCfg.ulBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.ulBwpToAddOrModList,\
1876 (sizeof(UlBwpInfo) * MAX_NUM_BWP));
1878 macUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId;
1880 if(duMacUeCfg->ambrCfg != NULLP)
1882 memcpy(macUeCfg->ambrCfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
1884 memcpy(&macUeCfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
1885 memcpy(&macUeCfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
1886 if(duMacUeCfg->numLcs > 0)
1888 macUeCfg->numLcs = 0;
1889 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
1891 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1893 //VS: To thoroughly check
1894 memcpy(&macUeCfg->lcCfgList[macUeCfg->numLcs], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
1901 /**********************************************************************************
1903 * @brief Fills Ue Cfg from DU DB to RLCUeCfg
1907 * Function : fillRlcUeCfg
1909 * Functionality: fills ue Cfg to be sent to RLC
1911 * @params[in] DuRlcUeCfg Pointer
1914 * @return ROK - success
1916 * *******************************************************************************/
1917 void fillRlcUeCfg(DuRlcUeCfg *duRlcUeCfg, RlcUeCfg *rlcUeCfg)
1921 rlcUeCfg->cellId = duRlcUeCfg->cellId;
1922 rlcUeCfg->ueId = duRlcUeCfg->ueId;
1924 rlcUeCfg->numLcsToAdd = 0;
1925 for(lcIdx = 0; lcIdx < duRlcUeCfg->numLcs; lcIdx++)
1927 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_ADD)
1929 memcpy(&rlcUeCfg->rlcLcCfgAdd[rlcUeCfg->numLcsToAdd], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
1930 rlcUeCfg->numLcsToAdd++;
1936 /******************************************************************
1938 * @brief Builds and Send UE Create Request to MAC
1942 * Function : duBuildAndSendUeCreateReqToMac
1944 * Functionality: Builds and Send UE Create Request to MAC
1946 * @Params[in] cellId,
1949 * UE config extracted from F1AP msg
1950 * MAC UE config struct to be filled
1951 * @return ROK - success
1954 * ****************************************************************/
1956 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1959 MacUeCfg *macUeCfg = NULLP;
1961 memset(&pst, 0, sizeof(Pst));
1964 ret = updateDuMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1967 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1972 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1974 /* Copying ueCb to a sharable buffer */
1975 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1978 memset(macUeCfg, 0, sizeof(MacUeCfg));
1979 fillMacUeCfg(duMacUeCfg, macUeCfg);
1980 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1982 /* Processing one Ue at a time to MAC */
1983 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1986 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1987 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1992 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1998 /*******************************************************************
2000 * @brief Build and send RACH Resource request to MAC
2004 * Function : duBuildAndSendRachRsrcReqToMac
2006 * Build and send RACH Resource request to MAC
2008 * @params[in] Cell Id
2010 * @return ROK - success
2013 * ****************************************************************/
2014 uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
2016 uint16_t cellIdx = 0, ssbIdx = 0;
2018 MacRachRsrcReq *rachRsrcReq = NULLP;
2020 GET_CELL_IDX(cellId, cellIdx);
2021 if(duCb.actvCellLst[cellIdx] == NULLP)
2023 DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
2027 DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
2030 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
2031 duBuildAndSendRachRsrcReqToMac()");
2035 rachRsrcReq->cellId = cellId;
2036 rachRsrcReq->ueId = ueId;
2037 rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
2038 for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
2040 rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
2044 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
2046 if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
2048 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
2049 duBuildAndSendRachRsrcReqToMac()");
2050 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
2057 /*******************************************************************
2059 * @brief Process RACH resource response from MAC
2063 * Function : DuProcMacRachRsrcRsp
2065 * Process RACH resource response from MAC
2067 * @params[in] Post structure
2068 * RACH resource response
2069 * @return ROK - success
2072 * ****************************************************************/
2073 uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
2075 uint8_t ret = RFAILED;
2076 uint16_t cellIdx = 0;
2077 DuCellCb *cellCb = NULLP;
2078 DuUeCb *ueCb = NULLP;
2080 DU_LOG("\nINFO --> DU APP : Received RACH Resource Response from MAC. Cell ID [%d] UE ID [%d]",
2081 rachRsrcRsp->cellId, rachRsrcRsp->ueId);
2083 if(rachRsrcRsp->result == MAC_DU_APP_RSP_OK)
2085 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
2088 GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
2089 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
2091 cellCb = duCb.actvCellLst[cellIdx];
2094 if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
2096 ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
2098 /* Store CRNTI alloted to this UE by MAC */
2099 ueCb->crnti = rachRsrcRsp->newCrnti;
2101 /* Store the assigned CF-RA resources */
2102 memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
2104 /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
2105 * along with the result of UE Context setup requested by CU */
2106 if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
2107 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2110 DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
2113 DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
2116 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
2118 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
2122 /*******************************************************************
2124 * @brief fill k0 value in duCb
2128 * Function : fillK0Values
2129 * Functionality: update k0 value in duCb
2131 * @params[in] PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg
2132 * @return ROK - success
2135 * ****************************************************************/
2137 uint8_t fillK0Values(PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg)
2139 uint8_t numTimeDomRsrcAlloc, rsrcIdx;
2143 if(storePdschCfg->numTimeDomRsrcAlloc)
2145 numTimeDomRsrcAlloc = cuPdschCfg->numTimeDomRsrcAlloc;
2146 for(rsrcIdx =0 ; rsrcIdx<numTimeDomRsrcAlloc; rsrcIdx++)
2148 if(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2150 if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2152 *(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = *(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
2153 if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0 != cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2154 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0, sizeof(uint8_t));
2158 (storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = (cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
2167 /*******************************************************************
2169 * @brief To update DuUeCb Mac Cfg
2173 * Function : duUpdateMacCfg
2174 * Functionality: update DuUeCb MAC Cfg
2176 * @params[in] DuUeCb Pointer
2177 * F1UeContextSetupDb pointer
2178 * @return ROK - success
2181 * ****************************************************************/
2182 uint8_t duUpdateMacCfg(DuMacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
2184 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
2185 DuMacUeCfg *oldMacUeCfg;
2188 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
2189 if(duCb.actvCellLst[cellIdx] == NULLP)
2191 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
2194 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].duMacUeCfg;
2196 /*Filling Cell Group Cfg*/
2197 ret = procUeRecfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
2199 memcpy(&macUeCfg->macCellGrpCfg.drxCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg.macCellGrpCfg.drxCfg, sizeof(DrxCfg));
2203 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
2205 /* update k0 values */
2206 fillK0Values(&f1UeDb->duUeCfg.copyOfmacUeCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg, &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg);
2207 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
2208 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
2210 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
2212 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
2213 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
2215 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
2216 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
2219 /* Filling LC Context */
2220 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
2222 numLcs = macUeCfg->numLcs;
2223 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2225 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcConfig.lcId == macUeCfg->lcCfgList[lcIdx].lcConfig.lcId)
2227 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
2229 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
2231 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
2233 /* Free memory at matched lcIdx index */
2234 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx].lcConfig);
2236 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
2238 /* moving all elements one index ahead */
2239 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
2240 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1].lcConfig);
2243 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
2250 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
2252 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
2255 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
2265 /******************************************************************
2267 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
2271 * Function : fillRlcCfgToAddMod
2273 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
2276 *****************************************************************/
2278 uint8_t fillRlcCfgToAddMod(DuRlcBearerCfg *lcCfg, DuRlcBearerCfg *f1UeDbLcCfg)
2280 lcCfg->configType = f1UeDbLcCfg->configType;
2281 lcCfg->rlcBearerCfg.rbId = f1UeDbLcCfg->rlcBearerCfg.rbId;
2282 lcCfg->rlcBearerCfg.rbType = f1UeDbLcCfg->rlcBearerCfg.rbType;
2283 lcCfg->rlcBearerCfg.lcId = f1UeDbLcCfg->rlcBearerCfg.lcId;
2284 lcCfg->rlcBearerCfg.lcType = f1UeDbLcCfg->rlcBearerCfg.lcType;
2285 lcCfg->rlcBearerCfg.rlcMode = f1UeDbLcCfg->rlcBearerCfg.rlcMode;
2287 switch(lcCfg->rlcBearerCfg.rlcMode)
2291 if(!lcCfg->rlcBearerCfg.u.amCfg)
2293 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.amCfg, sizeof(AmBearerCfg));
2294 if(!lcCfg->rlcBearerCfg.u.amCfg)
2298 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl;
2299 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr;
2300 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu;
2301 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte;
2302 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh;
2305 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl;
2306 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr;
2307 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr;
2310 case RLC_UM_BI_DIRECTIONAL :
2312 if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
2314 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2315 if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
2318 /* UL UM BI DIR INFO */
2319 lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm;
2320 lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr;
2321 /* DL UM BI DIR INFO */
2322 lcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm;
2325 case RLC_UM_UNI_DIRECTIONAL_UL :
2327 if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
2329 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2330 if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
2333 lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
2334 lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2338 case RLC_UM_UNI_DIRECTIONAL_DL :
2340 if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
2342 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2343 if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
2346 lcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2350 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcBearerCfg.rlcMode);
2356 /*******************************************************************
2358 * @brief To update DuUeCb Rlc Lc Cfg
2362 * Function : duUpdateRlcLcCfg
2363 * Functionality: update DuUeCb Rlc Lc Cfg
2365 * @params[in] DuUeCb Pointer
2366 * F1UeContextSetupDb pointer
2367 * @return ROK - success
2370 * ****************************************************************/
2372 uint8_t duUpdateRlcLcCfg(DuRlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2374 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2377 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2379 numLcs = rlcUeCfg->numLcs;
2380 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2382 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.lcId == rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
2384 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2386 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2389 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2392 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
2393 &rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.snssai, true);
2395 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2397 /* Free memory at matched lcIdx index */
2398 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg);
2400 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2402 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2403 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg.snssai,\
2404 &rlcUeCfg->rlcLcCfg[lcDelIdx].rlcBearerCfg.snssai, true);
2405 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg);
2408 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2415 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2417 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2420 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
2421 &rlcUeCfg->rlcLcCfg[rlcUeCfg->numLcs].rlcBearerCfg.snssai, true);
2429 /*******************************************************************
2431 * @brief Function to fill Tunnel Config to Add/Mod
2436 * Function : fillTnlCfgToAddMod
2438 * Functionality: Function to fill tunnel Config to Add/Mod
2440 * @params[in] Pointer to tnlCfgDb,
2441 * pointer to f1TnlCfg
2442 * @return ROK - success
2445 * ****************************************************************/
2446 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2450 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2451 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2454 if(*ueCbTnlCfg == NULLP)
2456 /* copying to DuCb Tnl Cfg */
2457 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2458 if(*ueCbTnlCfg == NULLP)
2460 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2464 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2465 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2466 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2467 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2468 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2469 if(f1TnlCfg->tnlCfg1)
2471 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2473 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2474 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2476 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2480 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2481 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2482 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2483 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2488 /*******************************************************************
2490 * @brief Processing the tunnel Request to EGTP
2494 * Function : duProcEgtpTunnelCfg
2496 * Functionality: Processing the tunnel Request to EGTP
2498 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2499 * @return ROK - success
2502 * ****************************************************************/
2504 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2506 uint8_t ret = RFAILED, delIdx;
2508 if(f1TnlCfg->tnlCfg1 == NULLP)
2510 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2514 if(f1TnlCfg->configType == CONFIG_ADD)
2516 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2518 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2525 else if(f1TnlCfg->configType == CONFIG_MOD)
2527 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2529 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2535 else if(f1TnlCfg->configType == CONFIG_DEL)
2537 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2539 /* Free memory at drbIdx */
2541 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2543 /* moving all elements one index ahead */
2544 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2550 if(duCb.upTnlCfg[delIdx])
2552 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2553 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2560 /***********************************************************************
2562 * @brief Function to fill Tunnel Config
2563 * and sends tunnel Req to EGTP
2568 * Function : duUpdateTunnelCfgDb
2570 * Functionality: Function to fill tunnel Config
2571 * and sends tunnel Cfg Req to EGTP
2573 * @params[in] ueId, cellId, DuUeCfg
2574 * @return ROK - success
2577 * ****************************************************************/
2579 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2581 uint8_t ret = ROK, drbIdx, teIdx;
2582 bool drbFound = false;
2584 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2585 /*then update drbId and tunnel Info in duCb */
2586 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2588 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2589 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2590 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2592 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2593 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2595 drbFound = true; /* existing DRB */
2596 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2598 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2599 duUeCfg->upTnlInfo[drbIdx].drbId);
2608 if(!drbFound && ret == ROK)/* new DRB to Add */
2610 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2612 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2613 duUeCfg->upTnlInfo[drbIdx].drbId);
2622 /*******************************************************************
2624 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2629 * Function : duUpdateDuUeCbCfg
2631 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2633 * @params[in] ueId, cellIdx
2634 * @return ROK - success
2637 * ****************************************************************/
2639 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2641 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2642 DuUeCb *ueCb = NULLP;
2644 GET_CELL_IDX(cellId, cellIdx);
2645 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2647 /*Filling RLC Ue Cfg */
2648 ueCb->duRlcUeCfg.cellId = cellId;
2649 ueCb->duRlcUeCfg.ueId = ueId;
2650 ret = duUpdateRlcLcCfg(&ueCb->duRlcUeCfg, ueCb->f1UeDb);
2653 /*Filling MAC Ue Cfg */
2654 GET_CRNTI(crnti, ueId);
2655 ueCb->duMacUeCfg.cellId = cellId;
2656 ueCb->duMacUeCfg.ueId = ueId;
2657 ueCb->duMacUeCfg.crnti = crnti;
2658 ret = duUpdateMacCfg(&ueCb->duMacUeCfg, ueCb->f1UeDb);
2660 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2663 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2665 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2671 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2675 /*******************************************************************
2677 * @brief Handle UE config response from MAC
2681 * Function : DuProcMacUeCfgRsp
2683 * Functionality: Handle UE Config response from MAC
2685 * @params[in] Pointer to MacUeCfgRsp and Pst
2686 * @return ROK - success
2689 * ****************************************************************/
2690 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2697 GET_CELL_IDX(cfgRsp->cellId, cellIdx);
2698 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2700 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2702 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2704 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2706 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2708 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2709 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2710 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2712 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2714 /* If UE is in handover, RACH resource needs to be requested
2715 * from MAC for CFRA */
2716 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2718 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2719 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2725 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2726 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2735 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
2738 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2742 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2748 /*******************************************************************
2750 * @brief Handle UE Reconfig response from MAC
2754 * Function : DuProcMacUeRecfgRsp
2756 * Functionality: Handle UE ReConfig response from MAC
2758 * @params[in] Pointer to MacUeRecfgRsp and Pst
2759 * @return ROK - success
2762 * ****************************************************************/
2763 uint8_t DuProcMacUeRecfgRsp(Pst *pst, MacUeRecfgRsp *reCfgRsp)
2770 GET_CELL_IDX(reCfgRsp->cellId, cellIdx);
2771 if(reCfgRsp->result == MAC_DU_APP_RSP_OK)
2773 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2775 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", reCfgRsp->ueId);
2776 if(duCb.actvCellLst[cellIdx] &&
2777 (duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].gnbDuUeF1apId == reCfgRsp->ueId))
2779 duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2780 if((duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2781 (duCb.actvCellLst[reCfgRsp->cellId -1]->ueCb[reCfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2783 if((ret = duUpdateDuUeCbCfg(reCfgRsp->ueId, reCfgRsp->cellId)) == ROK)
2785 if((BuildAndSendUeCtxtRsp(reCfgRsp->cellId, reCfgRsp->ueId)) != ROK)
2787 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2788 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2794 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2795 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2804 DU_LOG("\nERROR --> DU APP : MAC UE RECFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, reCfgRsp->ueId);
2805 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2807 //TODO: Send the failure case in Ue Context Setup Response
2811 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2815 DU_LOG("\nERROR --> DU APP : Received MAC Ue ReConfig Response is NULL at DuProcMacUeRecfgRsp()");
2821 /*******************************************************************
2823 * @brief Processes UE create Req to RLC UL
2827 * Function : duBuildAndSendUeCreateReqToRlc
2830 * Processes UE create Req to RLC UL
2832 * @params[in] cellId,
2834 * Pointer to RlcUeCfg
2835 * @return ROK - success
2838 *****************************************************************/
2840 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *duRlcUeCfg)
2843 RlcUeCfg *rlcUeCfg = NULLP;
2846 ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
2849 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2853 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2854 /* Copying ueCfg to a sharable buffer */
2855 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2858 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2859 fillRlcUeCfg(duRlcUeCfg, rlcUeCfg);
2861 /* Processing one Ue at a time to RLC */
2862 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2863 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2866 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2867 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2873 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2879 /*******************************************************************
2881 * @brief Processes UE create Rsp received from RLC UL
2886 * Function : DuProcRlcUeCfgRsp
2889 * Processes UE create Rsp received from RLC UL
2891 * @params[in] Post structure
2892 * Pointer to RlcCfgCfm
2893 * @return ROK - success
2896 *****************************************************************/
2897 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2903 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2905 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2907 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2908 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2910 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2911 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2912 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2914 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2916 /* If UE is in handover, RACH resource needs to be requested
2917 * from MAC for CFRA */
2918 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2920 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2921 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2922 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2928 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2929 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2934 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2936 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2938 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2939 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2940 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2942 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2944 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2946 DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
2947 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2953 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2954 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2962 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2963 pst->event, cfgRsp->ueId, cfgRsp->reason);
2964 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2966 //TODO: update failure case in ue Context setup Response
2970 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2974 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2980 /**********************************************************************************
2982 * @brief Fills Ue ReCfg from DU DB to RlcUeRecfg
2986 * Function : fillRlcUeRecfg
2988 * Functionality: fills ue ReCfg to be sent to RLC
2990 * @params[in] DuRlcUeCfg Pointer
2991 * RlcUeRecfg Pointer
2994 * *******************************************************************************/
2995 void fillRlcUeRecfg(DuRlcUeCfg *duRlcUeCfg, RlcUeRecfg *rlcUeRecfg)
2999 rlcUeRecfg->cellId = duRlcUeCfg->cellId;
3000 rlcUeRecfg->ueId = duRlcUeCfg->ueId;
3003 if(duRlcUeCfg->numLcs > 0)
3005 rlcUeRecfg->numLcsToAdd = 0;
3006 rlcUeRecfg->numLcsToMod = 0;
3007 rlcUeRecfg->numLcsToRel = 0;
3009 for(lcIdx = 0; lcIdx < duRlcUeCfg->numLcs; lcIdx++)
3011 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_ADD)
3013 memcpy(&rlcUeRecfg->rlcLcCfgAdd[rlcUeRecfg->numLcsToAdd], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3014 rlcUeRecfg->numLcsToAdd++;
3016 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_MOD)
3018 memcpy(&rlcUeRecfg->rlcLcCfgMod[rlcUeRecfg->numLcsToMod], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3019 rlcUeRecfg->numLcsToMod++;
3021 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_DEL)
3023 memcpy(&rlcUeRecfg->rlcLcCfgRel[rlcUeRecfg->numLcsToRel], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3024 rlcUeRecfg->numLcsToRel++;
3031 /*******************************************************************
3033 * @brief Builds and Send Ue Reconfig Req to RLC
3037 * Function : duBuildAndSendUeRecfgReqToRLC
3039 * Functionality: Builds and Send Ue Reconfig Req to RLC
3041 * @params[in] cellId, crnti
3043 * RlcUeCfg *rlcUeCfg
3044 * @return ROK - success
3047 * ****************************************************************/
3049 uint8_t duBuildAndSendUeRecfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
3052 DuRlcUeCfg *duRlcUeCfg = NULLP;
3053 RlcUeRecfg *rlcUeRecfg = NULLP;
3055 DU_ALLOC(duRlcUeCfg, sizeof(DuRlcUeCfg));
3056 DU_ALLOC_SHRABL_BUF(rlcUeRecfg, sizeof(RlcUeRecfg));
3057 if(duRlcUeCfg && rlcUeRecfg)
3059 memset(duRlcUeCfg, 0, sizeof(DuRlcUeCfg));
3060 memset(rlcUeRecfg, 0, sizeof(RlcUeRecfg));
3062 ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
3065 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeRecfgReqToRlc()");
3068 fillRlcUeRecfg(duRlcUeCfg, rlcUeRecfg);
3069 ret = sendUeRecfgReqToRlc(rlcUeRecfg);
3074 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeRecfgReqToRlc()");
3077 DU_FREE(duRlcUeCfg, sizeof(DuRlcUeCfg));
3081 /**********************************************************************************
3083 * @brief Fills Ue ReCfg from DU DB to MacUeRecfg
3087 * Function : fillMacUeRecfg
3089 * Functionality: fills ue ReCfg to be sent to MAC
3091 * @params[in] DuMacUeCfg Pointer
3092 * MacUeRecfg Pointer
3095 * *******************************************************************************/
3096 void fillMacUeRecfg(DuMacUeCfg *duMacUeCfg, MacUeRecfg *macUeRecfg)
3100 macUeRecfg->cellId = duMacUeCfg->cellId;
3101 macUeRecfg->ueId = duMacUeCfg->ueId;
3102 macUeRecfg->crnti = duMacUeCfg->crnti;
3103 macUeRecfg->macCellGrpRecfgPres = duMacUeCfg->macCellGrpCfgPres;
3104 if(macUeRecfg->macCellGrpRecfgPres)
3106 memcpy(&macUeRecfg->macCellGrpRecfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
3108 macUeRecfg->phyCellGrpRecfgPres = duMacUeCfg->phyCellGrpCfgPres;
3109 if(macUeRecfg->phyCellGrpRecfgPres)
3111 memcpy(&macUeRecfg->phyCellGrpRecfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
3113 macUeRecfg->spCellRecfgPres = duMacUeCfg->spCellCfgPres;
3114 if(macUeRecfg->spCellRecfgPres)
3116 memcpy(&macUeRecfg->spCellRecfg, &duMacUeCfg->spCellCfg, sizeof(SpCellRecfg));
3118 if(duMacUeCfg->ambrCfg != NULLP)
3120 DU_ALLOC_SHRABL_BUF(macUeRecfg->ambrRecfg, sizeof(AmbrCfg));
3121 memcpy(macUeRecfg->ambrRecfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
3123 memcpy(&macUeRecfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
3124 memcpy(&macUeRecfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
3125 if(duMacUeCfg->numLcs > 0)
3127 macUeRecfg->numLcsToAdd = 0;
3128 macUeRecfg->numLcsToDel = 0;
3129 macUeRecfg->numLcsToMod = 0;
3131 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
3133 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
3135 /*VS: To thoroughly check*/
3136 memcpy(&macUeRecfg->lcCfgAdd[macUeRecfg->numLcsToAdd], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
3137 macUeRecfg->numLcsToAdd++;
3139 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
3141 /*VS: To thoroughly check*/
3142 macUeRecfg->lcIdToDel[macUeRecfg->numLcsToDel] = duMacUeCfg->lcCfgList[lcIdx].lcConfig.lcId;
3143 macUeRecfg->numLcsToDel++;
3145 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
3147 /*VS: To thoroughly check*/
3148 memcpy(&macUeRecfg->lcCfgMod[macUeRecfg->numLcsToMod], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
3149 macUeRecfg->numLcsToMod++;
3153 macUeRecfg->transmissionAction = duMacUeCfg->transmissionAction;
3155 macUeRecfg->drxConfigIndicatorRelease = duMacUeCfg->drxConfigIndicatorRelease;
3159 /*******************************************************************
3161 * @brief Builds and Send Ue Reconfig Req to MAC
3165 * Function : duBuildAndSendUeRecfgReqToMac
3167 * Functionality: Builds and Send Ue Reconfig Req to MAC
3169 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
3171 * @return ROK - success
3174 * ****************************************************************/
3176 uint8_t duBuildAndSendUeRecfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
3179 DuMacUeCfg *duMacUeCfg = NULLP;
3180 MacUeRecfg *macUeRecfg = NULLP;
3182 DU_ALLOC(duMacUeCfg, sizeof(DuMacUeCfg));
3183 DU_ALLOC_SHRABL_BUF(macUeRecfg, sizeof(MacUeRecfg));
3184 if(macUeRecfg && duMacUeCfg)
3186 memset(duMacUeCfg, 0, sizeof(DuMacUeCfg));
3187 memset(macUeRecfg, 0, sizeof(MacUeRecfg));
3189 ret = updateDuMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, duMacUeCfg);
3191 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeRecfgReqToMac()");
3194 fillMacUeRecfg(duMacUeCfg, macUeRecfg);
3195 ret = sendUeRecfgReqToMac(macUeRecfg);
3200 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeRecfgReqToMac()");
3203 DU_FREE(duMacUeCfg, sizeof(DuMacUeCfg));
3208 /*******************************************************************
3210 * @brief Build and Send Ue context setup request
3215 * Function : duBuildAndSendUeContextSetupReq
3218 * Build and Send Ue context setup request
3220 * @params[in] cellId, crnti, DuUeCfg pointer
3221 * @return ROK - success
3224 *****************************************************************/
3226 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
3230 DuUeCfg *duUeCfg = NULLP;
3232 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
3236 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
3240 crnti = ueCb->crnti;
3241 duUeCfg = &ueCb->f1UeDb->duUeCfg;
3243 /* If UE is being handed-in to this DU, UE context setup request will create
3244 * new UE context at MAC/SCH and RLC.
3245 * If UE is in active state, UE contex setup request will lead to
3246 * reconfiguration of UE at MAC/SCH and RLC
3248 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
3250 /* Filling MAC UE Config */
3251 memset(&ueCb->duMacUeCfg, 0, sizeof(DuMacUeCfg));
3253 /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
3254 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->duMacUeCfg);
3256 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
3258 ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->duRlcUeCfg);
3260 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
3265 /* Filling RLC UE Reconfig */
3266 ret = duBuildAndSendUeRecfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3268 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
3270 /* Filling MAC UE Reconfig */
3271 ret = duBuildAndSendUeRecfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3273 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
3279 /*******************************************************************
3281 * @brief Processes DL Rsp received from RLC DL
3286 * Function : DuProcRlcDlRrcMsgRsp
3289 * Processes UE Rsp received from RLC DL
3291 * @params[in] Post structure
3292 * Pointer to RlcCfgCfm
3293 * @return ROK - success
3296 *****************************************************************/
3297 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
3299 uint8_t ret = ROK, ueId = 0;
3300 uint16_t cellId, crnti;
3301 DuUeCb *ueCb = NULLP;
3304 state = dlRrcMsg->state;
3305 cellId = dlRrcMsg->cellId;
3306 crnti = dlRrcMsg->crnti;
3307 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
3309 if(state == TRANSMISSION_COMPLETE)
3311 GET_UE_ID(crnti, ueId);
3312 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
3314 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
3316 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3318 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3320 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
3323 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3325 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
3327 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
3330 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
3332 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
3335 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
3341 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
3345 /*******************************************************************
3347 * @brief Process UE context setup request from CU
3351 * Function : duProcUeContextSetupRequest
3353 * Functionality: Process UE context setup request from CU
3355 * @params[in] F1AP message
3356 * @return ROK - success
3359 * ****************************************************************/
3361 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
3363 uint8_t ret, cellId;
3368 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3370 /* Send DL RRC msg for security Mode */
3371 if(ueCb->f1UeDb->dlRrcMsg)
3373 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3375 /* Sending DL RRC Message to RLC */
3376 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3379 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
3380 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3381 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3382 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3386 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3388 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3391 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
3397 //TODO: To send the failure cause in UeContextSetupRsp
3398 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
3403 /*******************************************************************
3405 * @brief Build and Send Ue context mod request
3410 * Function : duBuildAndSendUeContextModReq
3413 * Build and Send Ue context mod request
3415 * @params[in] cellId, crnti, DuUeCfg pointer
3416 * @return ROK - success
3419 *****************************************************************/
3421 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
3425 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
3426 /* Filling RLC Ue Reconfig */
3427 ret = duBuildAndSendUeRecfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3429 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
3431 /* Filling MAC Ue Reconfig */
3432 ret = duBuildAndSendUeRecfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3434 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
3438 /*******************************************************************
3440 * @brief Processing Ue context mod request
3445 * Function : duProcUeContextModReq
3448 * Processing Ue context mod request
3450 * @params[in] DuUeCb *ueCb
3451 * @return ROK - success
3454 *****************************************************************/
3456 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
3458 uint8_t ret, cellId;
3463 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3464 /* Send DL RRC msg for security Mode */
3465 if(ueCb->f1UeDb->dlRrcMsg)
3467 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3469 /* Sending DL RRC Message to RLC */
3470 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3473 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
3474 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3475 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3476 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3480 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3482 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
3485 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
3489 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
3491 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
3493 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
3500 //TODO: To send the failure cause in UeContextModRsp
3502 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
3508 /*******************************************************************
3510 * @brief Build and send dedicated RACH resource release request to MAC
3514 * Function : duBuildAndSendRachRsrcRelToMac
3516 * Functionality: Function to Build and send dedicated RACH resource
3517 * release request to MAC
3519 * @params[in] Cell ID
3521 * @return ROK - Success
3524 * ****************************************************************/
3525 uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb)
3528 MacRachRsrcRel *rachRsrcRel = NULLP;
3530 DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel));
3533 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \
3534 duBuildAndSendRachRsrcRelToMac()");
3538 rachRsrcRel->cellId = cellId;
3539 rachRsrcRel->ueId = ueCb->gnbDuUeF1apId;
3540 rachRsrcRel->crnti = ueCb->crnti;
3543 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL);
3545 if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK)
3547 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \
3548 duBuildAndSendRachRsrcRelToMac()");
3549 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel));
3556 /*******************************************************************
3558 * @brief delete DuMacUeCfg from duCb
3562 * Function : deleteMacUeCfg
3564 * Functionality: delete DuMacUeCfg from duCb
3566 * @params[in] Pointer to DuMacUeCfg
3567 * @return ROK - success
3570 *******************************************************************/
3572 void deleteMacUeCfg(DuMacUeCfg *ueCfg)
3576 if(ueCfg->spCellCfgPres)
3578 freeUeRecfgCellGrpInfo(ueCfg);
3582 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
3584 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
3586 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx].lcConfig);
3588 memset(ueCfg, 0, sizeof(DuMacUeCfg));
3591 /*******************************************************************
3593 * @brief delete UE Configuration of a particular UE
3597 * Function : deleteUeCfg
3599 * Functionality: delete UE Configuration of a particular UE
3601 * @params[in] uint16_t cellIdx, uint8_t ueId
3602 * @return ROK - success
3605 * ****************************************************************/
3606 uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
3609 uint16_t cellIdx = 0;
3610 DuUeCb *ueCb = NULLP;
3612 GET_CELL_IDX(cellId, cellIdx);
3613 if(duCb.actvCellLst[cellIdx] != NULLP)
3615 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duMacUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3616 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3618 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3619 deleteMacUeCfg(&ueCb->duMacUeCfg);
3620 deleteRlcUeCfg(&ueCb->duRlcUeCfg);
3621 if(ueCb->f1UeDb !=NULLP)
3623 freeF1UeDb(ueCb->f1UeDb);
3625 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3627 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3629 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3630 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3635 unsetBitInUeBitMap(cellId, ueId-1);
3636 duCb.actvCellLst[cellIdx]->numActvUes--;
3637 memset(ueCb, 0, sizeof(DuUeCb));
3646 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3653 /*******************************************************************
3655 * @brief Handle UE delete response from MAC
3659 * Function : DuProcMacUeDeleteRsp
3661 * Functionality: Handle UE delete response from MAC
3663 * @params[in] Pointer to MacUeDeleteRsp and Pst
3664 * @return ROK - success
3667 * ****************************************************************/
3669 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3671 uint8_t ret =ROK,ueId=0;
3673 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3677 if(deleteRsp->result == DEL_SUCCESSFUL)
3679 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3680 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3681 if(duCb.actvCellLst[cellIdx])
3683 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3684 ueId = deleteRsp->ueId;
3685 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3686 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3687 if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
3689 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3692 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3700 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3704 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3708 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3714 /*******************************************************************
3716 * @brief Processes UE Delete Rsp received from RLC
3720 * Function : DuProcRlcUeDeleteRsp
3723 * Processes UE Delete Rsp received from RLC
3725 * @params[in] Post structure
3726 * Pointer to RlcUeDeleteRsp
3727 * @return ROK - success
3730 * *****************************************************************/
3732 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3734 uint8_t ueId = 0, ret = ROK;
3735 uint16_t cellIdx = 0,crnti=0;
3739 ueId = delRsp->ueId;
3740 GET_CELL_IDX(delRsp->cellId, cellIdx);
3742 if(delRsp->result == SUCCESSFUL)
3744 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3745 if(duCb.actvCellLst[cellIdx]!=NULLP)
3747 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3748 GET_CRNTI(crnti, ueId);
3749 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3751 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3759 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3762 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3768 /*******************************************************************
3770 * @brief Sending UE Delete Req To Mac
3774 * Function : sendUeDeleteReqToMac
3777 * sending UE Delete Req To Mac
3779 * @params[in] cellId, ueId, crnti
3780 * @return ROK - success
3783 *****************************************************************/
3785 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3789 MacUeDelete *ueDelete = NULLP;
3791 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3794 ueDelete->cellId = cellId;
3795 ueDelete->ueId = ueId;
3796 ueDelete->crnti = crnti;
3797 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3799 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3800 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3803 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3804 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3809 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3815 /*******************************************************************
3817 * @brief Sending UE Delete Req To Rlc
3821 * Function : sendUeDeleteReqToRlc
3824 * Sending UE Delete Req To Rlc
3826 * @params[in] cellId, ueId
3827 * @return ROK - success
3830 *****************************************************************/
3832 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3836 RlcUeDelete *ueDelete;
3838 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3839 if(ueDelete !=NULLP)
3841 ueDelete->cellId = cellId;
3842 ueDelete->ueId = ueId;
3843 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3845 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3848 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3849 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3854 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3860 /*******************************************************************
3862 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3866 * Function : duBuildAndSendUeDeleteReq
3868 * Functionality: DU processes UE delete req from CU and sends to MAC
3871 * @params[in] cellId, crnti
3872 * @return ROK - success
3875 * ****************************************************************/
3877 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3880 uint16_t cellIdx = 0;
3882 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3883 GET_CELL_IDX(cellId, cellIdx);
3884 GET_UE_ID(crnti, ueId);
3886 if(duCb.actvCellLst[cellIdx] != NULLP)
3888 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3890 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3894 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3895 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3897 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3903 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3910 /*******************************************************************
3912 * @brief delete RlcUeCfg from duCb
3916 * Function : deleteRlcUeCfg
3919 * delete RlcUeCfg from duCb
3921 * @params[in] RlcUeCfg *ueCfg
3923 * @return ROK - success
3926 *****************************************************************/
3928 void deleteRlcUeCfg(DuRlcUeCfg *ueCfg)
3931 RlcBearerCfg *lcCfg= NULLP;
3934 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3936 lcCfg = &ueCfg->rlcLcCfg[lcIdx].rlcBearerCfg;
3937 switch(lcCfg->rlcMode)
3941 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3944 case RLC_UM_BI_DIRECTIONAL :
3946 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3949 case RLC_UM_UNI_DIRECTIONAL_UL :
3951 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3954 case RLC_UM_UNI_DIRECTIONAL_DL :
3956 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3960 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3962 memset(ueCfg, 0, sizeof(RlcUeCfg));
3966 /*******************************************************************
3968 * @brief Du process Ue Context Release Command
3972 * Function : duProcUeContextReleaseCommand
3974 * Functionality: Du process Ue Context Release Command
3976 * @params[in] DuUeCb *duUeCb
3977 * @return ROK - success
3980 * ****************************************************************/
3981 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3983 uint8_t ret =ROK, ueId=0;
3988 crnti = duUeCb->crnti;
3989 GET_UE_ID(crnti, ueId);
3993 /* Send DL RRC msg for RRC release */
3994 if(duUeCb->f1UeDb->dlRrcMsg)
3996 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3998 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].duRlcUeCfg,\
3999 duUeCb->f1UeDb->dlRrcMsg);
4002 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
4003 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
4004 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
4005 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
4012 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
4015 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
4022 /**********************************************************************
4024 ***********************************************************************/