1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
38 #include "AlarmInterface.h"
39 #include "CmInterface.h"
42 DuMacDlCcchInd packMacDlCcchIndOpts[] =
44 packMacDlCcchInd, /* Loose coupling */
45 MacProcDlCcchInd, /* TIght coupling */
46 packMacDlCcchInd /* Light weight-loose coupling */
49 DuMacUeCreateReq packMacUeCreateReqOpts[] =
51 packDuMacUeCreateReq, /* Loose coupling */
52 MacProcUeCreateReq, /* TIght coupling */
53 packDuMacUeCreateReq /* Light weight-loose coupling */
56 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
58 packDuRlcUeCreateReq, /* Loose coupling */
59 RlcProcUeCreateReq, /* TIght coupling */
60 packDuRlcUeCreateReq /* Light weight-loose coupling */
63 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
65 packDlRrcMsgToRlc, /* Loose coupling */
66 RlcProcDlRrcMsgTransfer, /* Tight coupling */
67 packDlRrcMsgToRlc /* Light weight-loose coupling */
70 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
72 packDuRlcUeReconfigReq, /* Loose coupling */
73 RlcProcUeReconfigReq, /* TIght coupling */
74 packDuRlcUeReconfigReq /* Light weight-loose coupling */
77 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
79 packDuMacUeReconfigReq, /* Loose coupling */
80 MacProcUeReconfigReq, /* TIght coupling */
81 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
86 packRlcDlUserDataToRlc, /* Loose coupling */
87 RlcProcDlUserDataTransfer, /* Tight coupling */
88 packRlcDlUserDataToRlc /* Light weight-loose coupling */
91 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
93 packDuMacUeDeleteReq, /* Loose coupling */
94 MacProcUeDeleteReq, /* TIght coupling */
95 packDuMacUeDeleteReq /* Light weight-loose coupling */
98 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
100 packDuRlcUeDeleteReq, /* Loose coupling */
101 RlcProcUeDeleteReq, /* TIght coupling */
102 packDuRlcUeDeleteReq /* Light weight-loose coupling */
105 /******************************************************************
107 * @brief Function to return Drb LcId
111 * Function : getDrbLcId
113 * Functionality: Function to return Drb LcId
115 * @params[in] drbBitMap
117 * Returns: lcId - SUCCESS
119 *****************************************************************/
121 uint8_t getDrbLcId(uint32_t *drbBitMap)
123 uint8_t bitMask = 1, bitPos = 0;
124 bitPos = MIN_DRB_LCID;
126 while(bitPos <= MAX_DRB_LCID)
128 if((*drbBitMap & (bitMask << bitPos)) == 0)
130 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
138 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
142 /*******************************************************************
144 * @brief Function to fillDlUserDataInfo
148 * Function : fillDlUserDataInfo
151 * Function to fillDlUserDataInfo
156 * @return ROK - success
159 * ****************************************************************/
161 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
165 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
166 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
168 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
170 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
172 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
173 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
174 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
182 /*******************************************************************
184 * @brief Build and Send DL Data Message transfer to RLC
188 * Function : duBuildAndSendDlUserDataToRlc
191 * Build and Send DL Data Message transfer to RLC
193 * @params[in] Cell ID
195 * Logical Channgel ID
198 * @return ROK - success
201 * ****************************************************************/
203 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
205 uint8_t ret = RFAILED;
207 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
209 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
212 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
215 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
216 dlDataMsgInfo->dlMsg = egtpMsg->msg;
217 dlDataMsgInfo->msgLen = msgLen;
219 /* Filling DL DATA Msg Info */
220 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
222 /* Filling post structure and sending msg */
223 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
224 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
225 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
226 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
230 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
231 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
232 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
237 /*******************************************************************
239 * @brief Handles EGTP data from CU
243 * Function : duHdlEgtpData
246 * Processes EGTP header and sends data to RLC
248 * @params[in] Pointer to EGTP Message
249 * @return ROK - success
252 * ****************************************************************/
253 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
257 #ifdef CALL_FLOW_DEBUG_LOG
258 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
261 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
265 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
268 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
269 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
271 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
277 /******************************************************************
279 * @brief Builds and Sends DL CCCH Ind to MAC
283 * Function : duBuildAndSendDlCcchInd
285 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
287 * @params[in] dlCcchMsg - uint8_t*
288 * @return ROK - success
291 * ****************************************************************/
292 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
293 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
297 DlCcchIndInfo *dlCcchIndInfo = NULLP;
300 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
302 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
306 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
310 dlCcchIndInfo->cellId = *cellId;
311 dlCcchIndInfo->crnti = *crnti;
312 dlCcchIndInfo->msgType = msgType;
313 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
315 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
316 if(!dlCcchIndInfo->dlCcchMsg)
318 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
319 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
322 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
324 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
326 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
329 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
330 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
333 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
334 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
335 dlCcchIndInfo->dlCcchMsgLen);
336 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
337 sizeof(DlCcchIndInfo));
345 /*******************************************************************
347 * @brief Build and Send DL RRC Message transfer to RLC
351 * Function : duBuildAndSendDlRrcMsgToRlc
354 * Build and Send DL RRC Message transfer to RLC
356 * @params[in] Cell ID
358 * Logical Channgel ID
361 * @return ROK - success
364 * ****************************************************************/
365 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
370 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
374 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
378 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
381 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
382 duBuildAndSendDlRrcMsgToRlc");
383 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
387 /* Filling up the RRC msg info */
388 dlRrcMsgInfo->cellId = cellId;
389 dlRrcMsgInfo->ueId = ueCfg.ueId;
390 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
392 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
394 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
395 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
396 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
397 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
401 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
402 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
403 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
404 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
406 /* Filling post structure and sending msg */
407 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
408 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
409 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
412 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
413 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
422 /******************************************************************
424 * @brief Process DL RRC Msg recevied from F1AP
428 * Function : duProcDlRrcMsg
430 * Functionality: Process DL RRC Msg recevied from F1AP
432 * @params[in] dlCcchMsg - uint8_t*
433 * @return ROK - success
436 * ****************************************************************/
438 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
441 uint16_t crnti, cellId, cellIdx;
442 bool ueCcchCtxtFound = false;
443 bool ueFound = false;
447 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
449 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
451 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
453 ueCcchCtxtFound = true;
454 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
455 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
462 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
465 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
469 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
471 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
474 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
475 duCb.ueCcchCtxt[ueIdx].cellId);
480 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
487 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
489 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
491 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
492 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
495 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
496 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
509 /******************************************************************
511 * @brief Generates GNB DU Ue F1AP ID
515 * Function : genGnbDuUeF1apId
517 * Functionality: Generates GNB DU Ue F1AP ID
520 * @return gnbDuF1apId
522 * ****************************************************************/
523 int32_t genGnbDuUeF1apId(uint8_t cellId)
527 GET_CELL_IDX(cellId, cellIdx);
528 if(duCb.actvCellLst[cellIdx])
530 return ++duCb.gnbDuUeF1apIdGenerator;
534 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
539 /******************************************************************
541 * @brief Processes UL CCCH Ind recvd from MAC
545 * Function : duProcUlCcchInd
547 * Functionality: Processes UL CCCH Ind recvd from MAC
549 * @params[in] UlCcchIndInfo *ulCcchIndInfo
550 * @return ROK - success
553 * ****************************************************************/
554 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
558 int32_t gnbDuUeF1apId = 0;
560 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
562 if(gnbDuUeF1apId == -1)
564 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
568 /* Store Ue mapping */
569 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
570 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
571 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
575 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
576 ulCcchIndInfo->ulCcchMsg));
579 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
582 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
583 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
589 /******************************************************************
591 * @brief Fills Default UL LC Cfg
595 * Function : fillDefaultUlLcCfg
597 * Functionality: Fills Default UL LC Cfg
599 * @params[in] UlLcCfg *ulLcCfg
601 *****************************************************************/
602 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
604 ulLcCfg->priority = LC_PRIORITY_1;
605 ulLcCfg->lcGroup = 0;
606 ulLcCfg->schReqId = 0;
607 ulLcCfg->pbr = PBR_KBPS_INFINITY;
608 ulLcCfg->bsd = BSD_MS_1000;
611 /******************************************************************
613 * @brief Fills Initial DL Bandwidth Part
617 * Function : fillDefaultInitDlBwp
619 * Functionality: Fills Initial DL Bandwidth Part
621 * @params[in] InitialDlBwp *initDlBwp
624 *****************************************************************/
625 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
628 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
629 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
634 /* Filling PDCCH Config */
635 initDlBwp->pdcchPresent = TRUE;
636 if(initDlBwp->pdcchPresent)
638 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
639 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
640 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
642 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
643 PDCCH_CTRL_RSRC_SET_ONE_ID;
644 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
646 coreset0EndPrb = CORESET0_END_PRB;
647 coreset1StartPrb = coreset0EndPrb +6;
648 coreset1NumPrb = CORESET1_NUM_PRB;
649 /* calculate the PRBs */
650 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
651 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
654 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
655 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
656 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
657 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
658 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
660 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
663 initDlBwp->pdcchCfg.numCRsetToRel = 0;
664 /* Filling Serach Space */
665 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
666 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
667 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
669 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
670 PDCCH_SRCH_SPC_TWO_ID;
671 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
672 PDCCH_CTRL_RSRC_SET_ONE_ID;
673 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
674 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
675 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
676 MONITORING_SYMB_WITHIN_SLOT_SIZE);
677 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
678 PDCCH_SYMBOL_WITHIN_SLOT;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
683 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
687 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
689 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
690 SEARCHSPACETYPE_PR_UE_SPECIFIC;
691 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
692 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
694 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
698 /* Filling PDSCH Config */
699 initDlBwp->pdschPresent = TRUE;
700 if(initDlBwp->pdschPresent)
702 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
703 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
704 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
705 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
707 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
708 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
709 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
710 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
711 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
712 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
713 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
714 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
720 /******************************************************************
722 * @brief Fills Initial UL Bandwidth Part
726 * Function : fillDefaultInitUlBwp
728 * Functionality: Fills Initial UL Bandwidth Part
730 * @params[in] InitialUlBwp *initUlBwp
733 *****************************************************************/
734 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
739 initUlBwp->pucchPresent = FALSE;
741 /*Filling PUSCH Config */
742 initUlBwp->puschPresent = TRUE;
743 if(initUlBwp->puschPresent)
745 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
746 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
747 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
748 scramblingId0 = SCRAMBLING_ID;
749 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
750 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
752 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
754 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
755 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
757 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
758 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
759 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
760 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
763 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
764 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
765 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
766 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
767 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
768 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
770 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
775 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
779 /******************************************************************
781 * @brief Fills SpCell Group Info
785 * Function : fillDefaultSpCellGrpInfo
787 * Functionality: Fills Sp Cell Group Info
789 * @params[in] MacUeCfg *macUeCfg
792 *****************************************************************/
793 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
795 SpCellCfg *spCell = NULL;
798 spCell = &macUeCfg->spCellCfg;
802 macUeCfg->spCellCfgPres = true;
804 spCell->servCellIdx = SERV_CELL_IDX;
805 /* Filling Initial Dl Bwp */
806 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
808 spCell->servCellCfg.numDlBwpToAdd = 0;
809 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
810 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
811 spCell->servCellCfg.bwpInactivityTmr = NULLP;
812 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
813 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
814 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
815 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
816 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
817 NUM_HARQ_PROC_FOR_PDSCH_N_16;
818 /* Filling Initial UL Bwp*/
819 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
820 spCell->servCellCfg.numUlBwpToAdd = 0;
821 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
825 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
829 /******************************************************************
831 * @brief Fills Physical Cell Group Info
835 * Function : fillDefaultPhyCellGrpInfo
837 * Functionality: Fills Physical Cell Group Info
839 * @params[in] MacUeCfg *macUeCfg
842 *****************************************************************/
843 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
845 PhyCellGrpCfg *cellGrp = NULL;
848 cellGrp = &macUeCfg->phyCellGrpCfg;
852 macUeCfg->phyCellGrpCfgPres = true;
853 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
854 cellGrp->pNrFr1 = P_NR_FR1;
858 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
862 /******************************************************************
864 * @brief Fills Mac Cell Group Info
868 * Function : fillDefaultMacCellGrpInfo
870 * Functionality: Fills Mac Cell Group Info
872 * @params[in] MacUeCfg *macUeCfg
875 *****************************************************************/
876 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
879 MacCellGrpCfg *cellGrp = NULL;
882 cellGrp = &macUeCfg->macCellGrpCfg;
886 macUeCfg->macCellGrpCfgPres = true;
888 /* Filling Scheduling Request Config */
889 cellGrp->schReqCfg.addModListCount = 1;
890 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
892 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
894 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
895 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
896 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
899 cellGrp->schReqCfg.relListCount = 0;
901 /* Filling Tag config */
902 cellGrp->tagCfg.addModListCount = 1;
903 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
905 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
907 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
908 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
911 cellGrp->tagCfg.relListCount = 0;
913 /* Filling BSR config */
914 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
915 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
916 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
918 /* Filling PHR config */
919 cellGrp->phrCfgSetupPres = true;
920 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
921 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
922 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
923 cellGrp->phrCfg.multiplePHR = false;
924 cellGrp->phrCfg.dummy = false;
925 cellGrp->phrCfg.phrType2OtherCell = false;
926 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
931 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
935 /*******************************************************************
937 * @brief Fills default modulation info for a UE
941 * Function : fillDefaultModulation
943 * Functionality: Fills default modulation info for a UE
945 * @params[in] Pointer to MAC UE configuration
946 * @return ROK - success
949 * ****************************************************************/
950 void fillDefaultModulation(MacUeCfg *ueCfg)
952 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
953 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
954 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
956 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
957 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
958 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
961 /******************************************************************
963 * @brief Function to fill Mac Lc Cfg for SRB1
967 * Function : fillMacSrb1LcCfg
969 * Functionality: Function to fill Mac Lc cfg for SRB1
971 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
973 *****************************************************************/
975 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
977 macLcCfg->lcId = SRB1_LCID;
978 macLcCfg->configType = CONFIG_ADD;
979 macLcCfg->drbQos = NULLP;
980 macLcCfg->snssai = NULLP;
981 macLcCfg->ulLcCfgPres = true;
982 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
985 /******************************************************************
987 * @brief Function to fill the Lc cfg from ueSetupReqDb
991 * Function : fillMacLcCfgToAddMod
993 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
995 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
996 * @return ROK/RFAILED
998 *****************************************************************/
1000 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1006 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1007 macLcCfgToSend->configType = ueLcCfgDb->configType;
1009 if(ueLcCfgDb->drbQos)
1010 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1012 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1014 macLcCfgToSend->drbQos = NULL;
1016 if(ueLcCfgDb->snssai)
1017 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1019 macLcCfgToSend->snssai = oldLcCfg->snssai;
1021 macLcCfgToSend->snssai = NULL;
1023 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1024 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1025 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1030 oldLcCfg->lcId = ueLcCfgDb->lcId;
1031 oldLcCfg->configType = ueLcCfgDb->configType;
1033 if(ueLcCfgDb->drbQos)
1035 if(oldLcCfg->drbQos)
1036 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1038 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1039 if(oldLcCfg->drbQos == NULL)
1041 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1044 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1047 if(ueLcCfgDb->snssai)
1049 if(oldLcCfg->snssai)
1050 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1052 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1053 if(oldLcCfg->snssai == NULL)
1055 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1056 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1059 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1062 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1063 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1064 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1069 /******************************************************************
1071 * @brief Function to copy the Bit rate from ueSetupReqDb
1075 * Function : fillAmbr
1077 * Functionality: Function to copy bit Rate from ueSetupReqDb
1079 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1080 * @return ROK/RFAILED
1082 *****************************************************************/
1084 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1090 *macAmbrCfgToSend = ueDbAmbr;
1093 *macAmbrCfgToSend = *oldMacAmbrCfg;
1101 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1103 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1104 if(*oldMacAmbrCfg == NULLP)
1106 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1109 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1110 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1117 /******************************************************************
1119 * @brief Builds and Send UE ReConfig Request to MAC
1123 * Function : sendUeReCfgReqToMac
1125 * Functionality: Builds and Send UE ReConfig Request to MAC
1127 * @Params[in] MacUeCfg pointer
1128 * @return ROK - success
1131 * ****************************************************************/
1133 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1139 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1143 /* Processing one Ue at a time to MAC */
1144 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1145 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1148 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1149 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1154 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1162 /******************************************************************
1164 * @brief Fills MacUeCfg structure
1168 * Function : fillMacUeCfg
1170 * Functionality: Fills MacUeCfg
1172 * @params[in] cellId, ueId, crnti,
1175 * @return ROK/RFAILED
1177 *****************************************************************/
1178 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1180 uint8_t ret, dbIdx, lcIdx, cellIdx;
1181 bool lcIdFound = false;
1182 MacUeCfg *duMacDb = NULLP;
1188 macUeCfg->cellId = cellId;
1189 macUeCfg->ueId = ueId;
1190 macUeCfg->crnti = crnti;
1192 fillDefaultMacCellGrpInfo(macUeCfg);
1193 fillDefaultPhyCellGrpInfo(macUeCfg);
1194 fillDefaultSpCellGrpInfo(macUeCfg);
1195 macUeCfg->ambrCfg = NULLP;
1196 fillDefaultModulation(macUeCfg);
1197 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1202 /* Fetching MacDb from DuUeCb */
1203 GET_CELL_IDX(cellId, cellIdx);
1204 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg;
1205 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1206 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1207 macUeCfg->cellId = cellId;
1208 macUeCfg->ueId = ueId;
1209 macUeCfg->crnti = crnti;
1210 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1213 if(macUeCfg->spCellCfgPres == true)
1215 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1217 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1218 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1220 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1222 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1223 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1226 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1227 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1230 /* Filling LC Context */
1231 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1233 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1235 /* Filling default UL LC config in MAC if not present */
1236 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1237 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1239 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1241 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1244 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1245 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1247 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1248 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1249 &duMacDb->lcCfgList[lcIdx], FALSE);
1257 /* ADD/DEL CONFIG */
1258 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1266 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1269 }/*End of Outer FOR loop */
1270 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1275 /******************************************************************
1277 * @brief Fills Rlc AM Information
1281 * Function : fillDefaultAmInfo
1283 * Functionality: Fills Rlc AM Information
1285 * @params[in] AmBearerCfg *amCfg
1288 *****************************************************************/
1289 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1292 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1293 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1294 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1295 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1296 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1299 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1300 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1301 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1304 /******************************************************************
1306 * @brief Fills RLC UM Bi Directional Information
1310 * Function : fillDefaultUmBiInfo
1312 * Functionality: Fills RLC UM Bi Directional Information
1314 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1317 *****************************************************************/
1318 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1320 /* UL UM BI DIR INFO */
1321 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1322 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1324 /* DL UM BI DIR INFO */
1325 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1328 /******************************************************************
1330 * @brief Fills RLC UM Uni Directional UL Information
1334 * Function : fillDefaultUmUlInfo
1336 * Functionality: Fills RLC UM Uni Directional Info
1338 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1341 *****************************************************************/
1342 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1344 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1345 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1348 /******************************************************************
1350 * @brief Fills RLC UM Uni Directional DL Information
1354 * Function : fillDefaultUmDlInfo
1356 * Functionality: Fills RLC UM Uni Directional DL Info
1358 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1361 *****************************************************************/
1362 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1364 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1367 /******************************************************************
1369 * @brief Builds Rlc Mode Default Configuration
1373 * Function : fillDefaultRlcModeCfg
1375 * Functionality: Builds Rlc Mode Default Configuration
1377 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1378 * @return ROK/RFAILED
1380 *****************************************************************/
1382 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1392 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1394 fillDefaultAmInfo(lcCfg->u.amCfg);
1397 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1403 case RLC_UM_BI_DIRECTIONAL :
1405 if(!lcCfg->u.umBiDirCfg)
1407 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1408 if(lcCfg->u.umBiDirCfg)
1409 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1412 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1418 case RLC_UM_UNI_DIRECTIONAL_UL :
1420 if(!lcCfg->u.umUniDirUlCfg)
1422 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1423 if(lcCfg->u.umUniDirUlCfg)
1424 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1427 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1433 case RLC_UM_UNI_DIRECTIONAL_DL :
1435 if(!lcCfg->u.umUniDirDlCfg)
1437 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1438 if(lcCfg->u.umUniDirDlCfg)
1439 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1442 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1449 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1456 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1462 /*******************************************************************
1464 * @brief Function to fill Rlc Lc Cfg for SRB1
1468 * Function : fillRlcSrb1LcCfg
1471 * Function to fill Rlc Lc Cfg for SRB1
1473 * @params[in] Pointer to RlcBearerCfg
1474 * @return ROK/RFAILED
1476 *****************************************************************/
1478 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1482 rlcLcCfg->rbId = SRB1_LCID;
1483 rlcLcCfg->rbType = RB_TYPE_SRB;
1484 rlcLcCfg->lcId = SRB1_LCID;
1485 rlcLcCfg->lcType = LCH_DCCH;
1486 rlcLcCfg->rlcMode = RLC_AM;
1487 rlcLcCfg->configType = CONFIG_ADD;
1488 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1492 /*******************************************************************
1494 * @brief Processes UE ReConfig Req to RLC UL
1498 * Function : sendUeReCfgReqToRlc
1501 * Processes UE Reconfig Req to RLC UL
1503 * @params[in] Pointer to RlcUeCfg
1504 * @return ROK - success
1507 *****************************************************************/
1509 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1514 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1517 /* Processing one Ue at a time to RLC */
1518 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1519 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1522 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1523 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1528 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1534 /******************************************************************
1536 * @brief Fills Snssai information
1540 * Function : fillSnssaiInfo
1542 * Functionality: Fills Snssai information
1544 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1546 * @return ROK - success
1549 *****************************************************************/
1550 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1555 snssaiTobeSend = snssaiDb;
1557 snssaiTobeSend = *oldSnssai;
1559 snssaiTobeSend = NULL;
1566 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1568 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1569 if(*oldSnssai == NULL)
1571 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1574 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1579 /******************************************************************
1581 * @brief Fills RlcBearerCfg structure
1585 * Function : fillRlcUeCfg
1587 * Functionality: Fills Rlc Bearer Cfg
1590 *****************************************************************/
1591 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1593 uint8_t ret, dbIdx, lcIdx, cellIdx;
1594 bool lcIdFound = false;
1595 RlcUeCfg *duRlcDb = NULLP;
1600 /* Initial RB being Added */
1601 rlcUeCfg->cellId = cellId;
1602 rlcUeCfg->ueId = ueId;
1603 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1607 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1611 /* Fetch RlcDb from DuUeCb */
1612 GET_CELL_IDX(cellId, cellIdx);
1613 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg;
1614 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1615 /*Filling RlcUeCfg */
1616 rlcUeCfg->cellId = cellId;
1617 rlcUeCfg->ueId = ueId;
1618 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1620 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1623 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1624 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1627 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1628 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1630 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1633 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1634 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1637 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1638 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1639 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1640 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1648 /* ADD/ DEL Config Type */
1649 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1650 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1658 /******************************************************************
1660 * @brief creates UE context
1664 * Function : duCreateUeCb
1666 * Functionality: Creates UE Conetxt
1668 * @params[in] UeCcchCtxt Pointer
1671 * @return ROK - success
1673 * ****************************************************************/
1674 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1676 uint8_t cellIdx = 0;
1678 uint8_t ueId = 0, ueIdx = 0;
1680 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1682 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1684 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1685 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1688 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1689 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1690 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1691 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1692 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1693 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1695 /* Filling Mac Ue Config */
1696 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
1697 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueId, ueCcchCtxt->crnti,\
1698 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
1700 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1702 /* Filling Rlc Ue Config */
1703 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1704 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueId, \
1705 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1707 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1709 duCb.actvCellLst[cellIdx]->numActvUes++;
1710 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1717 /******************************************************************
1719 * @brief Builds and Send UE Create Request to MAC
1723 * Function : duBuildAndSendUeCreateReqToMac
1725 * Functionality: Builds and Send UE Create Request to MAC
1727 * @Params[in] cellId,
1731 * @return ROK - success
1734 * ****************************************************************/
1736 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti, MacUeCfg *duMacUeCfg)
1739 MacUeCfg *macUeCfg = NULLP;
1741 memset(&pst, 0, sizeof(Pst));
1744 ret = fillMacUeCfg(cellId, ueId, crnti, NULL, duMacUeCfg);
1747 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1751 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1753 /* Copying ueCb to a sharable buffer */
1754 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1757 memset(macUeCfg, 0, sizeof(MacUeCfg));
1758 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1759 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1761 /* Processing one Ue at a time to MAC */
1762 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1765 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1766 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1771 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1777 /*******************************************************************
1779 * @brief To update DuUeCb Mac Cfg
1783 * Function : duUpdateMacCfg
1784 * Functionality: update DuUeCb MAC Cfg
1786 * @params[in] DuUeCb Pointer
1787 * F1UeContextSetupDb pointer
1788 * @return ROK - success
1791 * ****************************************************************/
1792 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1794 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1795 MacUeCfg *oldMacUeCfg;
1798 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1799 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1801 /*Filling Cell Group Cfg*/
1802 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1805 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1807 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1808 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1810 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1812 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1813 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1815 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1816 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1819 /* Filling LC Context */
1820 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1822 numLcs = macUeCfg->numLcs;
1823 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1825 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1827 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1829 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1831 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1833 /* Free memory at matched lcIdx index */
1834 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1836 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1838 /* moving all elements one index ahead */
1839 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1840 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1843 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1850 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1852 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1855 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1865 /******************************************************************
1867 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1871 * Function : fillRlcCfgToAddMod
1873 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1876 *****************************************************************/
1878 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1880 lcCfg->configType = f1UeDbLcCfg->configType;
1881 lcCfg->rbId = f1UeDbLcCfg->rbId;
1882 lcCfg->rbType = f1UeDbLcCfg->rbType;
1883 lcCfg->lcId = f1UeDbLcCfg->lcId;
1884 lcCfg->lcType = f1UeDbLcCfg->lcType;
1885 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1887 switch(lcCfg->rlcMode)
1893 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1898 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1899 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1900 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1901 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1902 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1905 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1906 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1907 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1910 case RLC_UM_BI_DIRECTIONAL :
1912 if(!lcCfg->u.umBiDirCfg)
1914 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1915 if(!lcCfg->u.umBiDirCfg)
1918 /* UL UM BI DIR INFO */
1919 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1920 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1921 /* DL UM BI DIR INFO */
1922 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1925 case RLC_UM_UNI_DIRECTIONAL_UL :
1927 if(!lcCfg->u.umUniDirUlCfg)
1929 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1930 if(!lcCfg->u.umUniDirUlCfg)
1933 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1934 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1938 case RLC_UM_UNI_DIRECTIONAL_DL :
1940 if(!lcCfg->u.umUniDirDlCfg)
1942 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1943 if(!lcCfg->u.umUniDirDlCfg)
1946 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1950 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1956 /*******************************************************************
1958 * @brief To update DuUeCb Rlc Lc Cfg
1962 * Function : duUpdateRlcLcCfg
1963 * Functionality: update DuUeCb Rlc Lc Cfg
1965 * @params[in] DuUeCb Pointer
1966 * F1UeContextSetupDb pointer
1967 * @return ROK - success
1970 * ****************************************************************/
1972 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1974 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1977 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1979 numLcs = rlcUeCfg->numLcs;
1980 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1982 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1984 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1986 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1989 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1992 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
1994 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1996 /* Free memory at matched lcIdx index */
1997 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1999 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2001 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2002 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2004 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2007 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2014 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2016 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2019 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2028 /*******************************************************************
2030 * @brief Function to fill Tunnel Config to Add/Mod
2035 * Function : fillTnlCfgToAddMod
2037 * Functionality: Function to fill tunnel Config to Add/Mod
2039 * @params[in] Pointer to tnlCfgDb,
2040 * pointer to f1TnlCfg
2041 * @return ROK - success
2044 * ****************************************************************/
2045 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2049 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2050 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2053 if(*ueCbTnlCfg == NULLP)
2055 /* copying to DuCb Tnl Cfg */
2056 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2057 if(*ueCbTnlCfg == NULLP)
2059 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2063 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2064 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2065 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2066 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2067 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2068 if(f1TnlCfg->tnlCfg1)
2070 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2072 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2073 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2075 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2079 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2080 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2081 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2082 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2087 /*******************************************************************
2089 * @brief Processing the tunnel Request to EGTP
2093 * Function : duProcEgtpTunnelCfg
2095 * Functionality: Processing the tunnel Request to EGTP
2097 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2098 * @return ROK - success
2101 * ****************************************************************/
2103 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2105 uint8_t ret = RFAILED, delIdx;
2107 if(f1TnlCfg->tnlCfg1 == NULLP)
2109 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2113 if(f1TnlCfg->configType == CONFIG_ADD)
2115 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2117 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2124 else if(f1TnlCfg->configType == CONFIG_MOD)
2126 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2128 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2134 else if(f1TnlCfg->configType == CONFIG_DEL)
2136 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2138 /* Free memory at drbIdx */
2140 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2142 /* moving all elements one index ahead */
2143 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2149 if(duCb.upTnlCfg[delIdx])
2151 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2152 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2159 /***********************************************************************
2161 * @brief Function to fill Tunnel Config
2162 * and sends tunnel Req to EGTP
2167 * Function : duUpdateTunnelCfgDb
2169 * Functionality: Function to fill tunnel Config
2170 * and sends tunnel Cfg Req to EGTP
2172 * @params[in] ueId, cellId, DuUeCfg
2173 * @return ROK - success
2176 * ****************************************************************/
2178 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2180 uint8_t ret = ROK, drbIdx, teIdx;
2181 bool drbFound = false;
2183 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2184 /*then update drbId and tunnel Info in duCb */
2185 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2187 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2188 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2189 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2191 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2192 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2194 drbFound = true; /* existing DRB */
2195 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2197 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2198 duUeCfg->upTnlInfo[drbIdx].drbId);
2207 if(!drbFound && ret == ROK)/* new DRB to Add */
2209 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2211 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2212 duUeCfg->upTnlInfo[drbIdx].drbId);
2223 /*******************************************************************
2225 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2230 * Function : duUpdateDuUeCbCfg
2232 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2234 * @params[in] ueId, cellIdx
2235 * @return ROK - success
2238 * ****************************************************************/
2240 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2242 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2243 DuUeCb *ueCb = NULLP;
2245 GET_CELL_IDX(cellId, cellIdx);
2247 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg. \
2248 macUeCfgState == UE_RECFG_COMPLETE) &&
2249 (duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg. \
2250 rlcUeCfgState == UE_RECFG_COMPLETE))
2252 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2254 /*Filling RLC Ue Cfg */
2255 ueCb->rlcUeCfg.cellId = cellId;
2256 ueCb->rlcUeCfg.ueId = ueId;
2257 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2260 /*Filling MAC Ue Cfg */
2261 GET_CRNTI(crnti, ueId);
2262 ueCb->macUeCfg.cellId = cellId;
2263 ueCb->macUeCfg.ueId = ueId;
2264 ueCb->macUeCfg.crnti = crnti;
2265 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2267 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2270 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2272 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2278 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2285 /*******************************************************************
2287 * @brief Handle UE config response from MAC
2291 * Function : DuProcMacUeCfgRsp
2293 * Functionality: Handle UE Config response from MAC
2295 * @params[in] Pointer to MacUeCfgRsp and Pst
2296 * @return ROK - success
2299 * ****************************************************************/
2300 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2306 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2308 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2310 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueId);
2311 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2312 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2314 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2316 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueId);
2317 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2318 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2320 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2326 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueId);
2327 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2329 //TODO: Send the failure case in Ue Context Setup Response
2333 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2337 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2344 /*******************************************************************
2346 * @brief Processes UE create Req to RLC UL
2350 * Function : duBuildAndSendUeCreateReqToRlc
2353 * Processes UE create Req to RLC UL
2355 * @params[in] cellId,
2357 * Pointer to RlcUeCfg
2358 * @return ROK - success
2361 *****************************************************************/
2363 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueId, RlcUeCfg *duRlcUeCfg)
2366 RlcUeCfg *rlcUeCfg = NULLP;
2369 ret = fillRlcUeCfg(cellId, ueId, NULL, duRlcUeCfg);
2372 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2376 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2377 /* Copying ueCfg to a sharable buffer */
2378 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2381 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2382 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2383 /* Processing one Ue at a time to RLC */
2384 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2385 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2388 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2389 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2395 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2401 /*******************************************************************
2403 * @brief Processes UE create Rsp received from RLC UL
2408 * Function : DuProcRlcUeCfgRsp
2411 * Processes UE create Rsp received from RLC UL
2413 * @params[in] Post structure
2414 * Pointer to RlcCfgCfm
2415 * @return ROK - success
2418 *****************************************************************/
2419 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2425 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2427 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2429 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2430 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2431 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2433 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2435 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2436 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2437 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2438 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2440 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2446 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2447 pst->event, cfgRsp->ueId, cfgRsp->reason);
2448 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2450 //TODO: update failure case in ue Context setup Response
2454 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2458 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2464 /*******************************************************************
2466 * @brief Builds and Send Ue Reconfig Req to RLC
2470 * Function : duBuildAndSendUeReCfgReqToRLC
2472 * Functionality: Builds and Send Ue Reconfig Req to RLC
2474 * @params[in] cellId, crnti
2476 * RlcUeCfg *rlcUeCfg
2477 * @return ROK - success
2480 * ****************************************************************/
2482 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2484 uint8_t ret = ROK, ueId = 0;
2485 RlcUeCfg *rlcUeCfg = NULLP;
2487 GET_UE_ID(crnti, ueId);
2488 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2491 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2492 ret = fillRlcUeCfg(cellId, ueId, ueCfgDb, rlcUeCfg);
2494 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2496 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2500 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2506 /*******************************************************************
2508 * @brief Builds and Send Ue Reconfig Req to MAC
2512 * Function : duBuildAndSendUeReCfgReqToMac
2514 * Functionality: Builds and Send Ue Reconfig Req to MAC
2516 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2518 * MacUeCfg *macUeCfg
2519 * @return ROK - success
2522 * ****************************************************************/
2524 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2526 uint8_t ret, ueId = 0;
2527 MacUeCfg *macUeCfg = NULLP;
2530 GET_UE_ID(crnti, ueId);
2532 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2535 memset(macUeCfg, 0, sizeof(MacUeCfg));
2536 ret = fillMacUeCfg(cellId, ueId, crnti, ueCfgDb, macUeCfg);
2538 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2540 ret = sendUeReCfgReqToMac(macUeCfg);
2544 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2550 /*******************************************************************
2552 * @brief Build and Send Ue context setup request
2557 * Function : duBuildAndSendUeContextSetupReq
2560 * Build and Send Ue context setup request
2562 * @params[in] cellId, crnti, DuUeCfg pointer
2563 * @return ROK - success
2566 *****************************************************************/
2568 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2572 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2573 /* Filling RLC Ue Reconfig */
2574 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2576 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2578 /* Filling MAC Ue Reconfig */
2579 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2581 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2586 /*******************************************************************
2588 * @brief Processes DL Rsp received from RLC DL
2593 * Function : DuProcRlcDlRrcMsgRsp
2596 * Processes UE Rsp received from RLC DL
2598 * @params[in] Post structure
2599 * Pointer to RlcCfgCfm
2600 * @return ROK - success
2603 *****************************************************************/
2604 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2606 uint8_t ret = ROK, ueId = 0;
2607 uint16_t cellId, crnti;
2608 DuUeCb *ueCb = NULLP;
2611 state = dlRrcMsg->state;
2612 cellId = dlRrcMsg->cellId;
2613 crnti = dlRrcMsg->crnti;
2614 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2616 if(state == TRANSMISSION_COMPLETE)
2618 GET_UE_ID(crnti, ueId);
2619 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
2621 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2623 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2625 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2627 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2630 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2632 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2634 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2637 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2639 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2642 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2648 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2652 /*******************************************************************
2654 * @brief Process UE context setup request from CU
2658 * Function : duProcUeContextSetupRequest
2660 * Functionality: Process UE context setup request from CU
2662 * @params[in] F1AP message
2663 * @return ROK - success
2666 * ****************************************************************/
2668 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2670 uint8_t ret, cellId;
2675 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2676 /* Send DL RRC msg for security Mode */
2677 if(ueCb->f1UeDb->dlRrcMsg)
2679 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2681 /* Sending DL RRC Message to RLC */
2682 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2685 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2686 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2687 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2688 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2692 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2694 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2697 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2703 //TODO: To send the failure cause in UeContextSetupRsp
2704 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2709 /*******************************************************************
2711 * @brief Build and Send Ue context mod request
2716 * Function : duBuildAndSendUeContextModReq
2719 * Build and Send Ue context mod request
2721 * @params[in] cellId, crnti, DuUeCfg pointer
2722 * @return ROK - success
2725 *****************************************************************/
2727 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2731 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2732 /* Filling RLC Ue Reconfig */
2733 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2735 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2737 /* Filling MAC Ue Reconfig */
2738 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2740 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2744 /*******************************************************************
2746 * @brief Processing Ue context mod request
2751 * Function : duProcUeContextModReq
2754 * Processing Ue context mod request
2756 * @params[in] DuUeCb *ueCb
2757 * @return ROK - success
2760 *****************************************************************/
2762 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2764 uint8_t ret, cellId;
2769 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2770 /* Send DL RRC msg for security Mode */
2771 if(ueCb->f1UeDb->dlRrcMsg)
2773 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2775 /* Sending DL RRC Message to RLC */
2776 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2779 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2780 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2781 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2782 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2786 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2788 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2791 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2795 else if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
2797 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
2799 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
2806 //TODO: To send the failure cause in UeContextModRsp
2808 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2814 /*******************************************************************
2816 * @brief Function to delete Pdsch ServCellCfg
2820 * Function : deletePdschServCellCfg
2822 * Functionality: Function to delete Pdsch ServCellCfg
2824 * @params[in] PdschServCellCfg *pdschServCellCfg
2827 * ****************************************************************/
2829 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2831 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2832 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2833 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2834 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2837 /*******************************************************************
2839 * @brief delete MacUeCfg from duCb
2843 * Function : deleteMacUeCfg
2845 * Functionality: delete MacUeCfg from duCb
2847 * @params[in] Pointer to MacUeCfg
2848 * @return ROK - success
2851 *******************************************************************/
2853 void deleteMacUeCfg(MacUeCfg *ueCfg)
2857 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2858 if(ueCfg->spCellCfgPres)
2860 freeUeReCfgCellGrpInfo(ueCfg);
2862 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2864 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2866 memset(ueCfg, 0, sizeof(MacUeCfg));
2869 /*******************************************************************
2871 * @brief delete UE Configuration of a particular UE
2875 * Function : deleteUeCfg
2877 * Functionality: delete UE Configuration of a particular UE
2879 * @params[in] uint16_t cellIdx, uint8_t ueId
2880 * @return ROK - success
2883 * ****************************************************************/
2884 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueId)
2887 DuUeCb *ueCb = NULLP;
2889 if(duCb.actvCellLst[cellIdx] != NULLP)
2891 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2892 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2894 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2895 deleteMacUeCfg(&ueCb->macUeCfg);
2896 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2897 if(ueCb->f1UeDb !=NULLP)
2899 freeF1UeDb(ueCb->f1UeDb);
2901 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
2903 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
2905 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2906 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2911 duCb.actvCellLst[cellIdx]->numActvUes--;
2912 memset(ueCb, 0, sizeof(DuUeCb));
2921 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2928 /*******************************************************************
2930 * @brief Handle UE delete response from MAC
2934 * Function : DuProcMacUeDeleteRsp
2936 * Functionality: Handle UE delete response from MAC
2938 * @params[in] Pointer to MacUeDeleteRsp and Pst
2939 * @return ROK - success
2942 * ****************************************************************/
2944 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2946 uint8_t ret =ROK,ueId=0;
2948 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2952 if(deleteRsp->result == SUCCESS)
2954 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2955 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2956 if(duCb.actvCellLst[cellIdx])
2958 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2959 ueId = deleteRsp->ueId;
2960 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2961 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2962 if(deleteUeCfg(cellIdx, ueId) == ROK)
2964 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2967 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2975 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2979 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2983 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2989 /*******************************************************************
2991 * @brief Processes UE Delete Rsp received from RLC
2995 * Function : DuProcRlcUeDeleteRsp
2998 * Processes UE Delete Rsp received from RLC
3000 * @params[in] Post structure
3001 * Pointer to RlcUeDeleteRsp
3002 * @return ROK - success
3005 * *****************************************************************/
3007 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3009 uint8_t ueId = 0, ret = ROK;
3010 uint16_t cellIdx = 0,crnti=0;
3014 ueId = delRsp->ueId;
3015 GET_CELL_IDX(delRsp->cellId, cellIdx);
3017 if(delRsp->result == SUCCESSFUL)
3019 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3020 if(duCb.actvCellLst[cellIdx]!=NULLP)
3022 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3023 GET_CRNTI(crnti, ueId);
3024 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3026 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3034 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3037 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3043 /*******************************************************************
3045 * @brief Sending UE Delete Req To Mac
3049 * Function : sendUeDeleteReqToMac
3052 * sending UE Delete Req To Mac
3054 * @params[in] cellId, ueId, crnti
3055 * @return ROK - success
3058 *****************************************************************/
3060 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3064 MacUeDelete *ueDelete = NULLP;
3066 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3069 ueDelete->cellId = cellId;
3070 ueDelete->ueId = ueId;
3071 ueDelete->crnti = crnti;
3072 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3074 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3075 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3078 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3079 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3084 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3090 /*******************************************************************
3092 * @brief Sending UE Delete Req To Rlc
3096 * Function : sendUeDeleteReqToRlc
3099 * Sending UE Delete Req To Rlc
3101 * @params[in] cellId, ueId
3102 * @return ROK - success
3105 *****************************************************************/
3107 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3111 RlcUeDelete *ueDelete;
3113 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3114 if(ueDelete !=NULLP)
3116 ueDelete->cellId = cellId;
3117 ueDelete->ueId = ueId;
3118 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3120 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3123 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3124 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3129 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3135 /*******************************************************************
3137 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3141 * Function : duBuildAndSendUeDeleteReq
3143 * Functionality: DU processes UE delete req from CU and sends to MAC
3146 * @params[in] cellId, crnti
3147 * @return ROK - success
3150 * ****************************************************************/
3152 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3155 uint16_t cellIdx = 0;
3157 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3158 GET_CELL_IDX(cellId, cellIdx);
3159 GET_UE_ID(crnti, ueId);
3161 if(duCb.actvCellLst[cellIdx] != NULLP)
3163 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3165 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3169 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3170 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3172 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3178 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3185 /*******************************************************************
3187 * @brief delete RlcUeCfg from duCb
3191 * Function : deleteRlcUeCfg
3194 * delete RlcUeCfg from duCb
3196 * @params[in] RlcUeCfg *ueCfg
3198 * @return ROK - success
3201 *****************************************************************/
3203 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3206 RlcBearerCfg *lcCfg= NULLP;
3209 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3211 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3212 switch(lcCfg->rlcMode)
3216 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3219 case RLC_UM_BI_DIRECTIONAL :
3221 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3224 case RLC_UM_UNI_DIRECTIONAL_UL :
3226 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3229 case RLC_UM_UNI_DIRECTIONAL_DL :
3231 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3235 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3237 memset(ueCfg, 0, sizeof(RlcUeCfg));
3241 /*******************************************************************
3243 * @brief Du process Ue Context Release Command
3247 * Function : duProcUeContextReleaseCommand
3249 * Functionality: Du process Ue Context Release Command
3251 * @params[in] DuUeCb *duUeCb
3252 * @return ROK - success
3255 * ****************************************************************/
3256 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3258 uint8_t ret =ROK, ueId=0;
3259 uint16_t cellId=0,crnti =0;
3262 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3265 if(duUeCb->f1UeDb == NULLP)
3267 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3271 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3272 crnti = duUeCb->crnti;
3273 GET_UE_ID(crnti, ueId);
3275 /* Send DL RRC msg for RRC release */
3276 if(duUeCb->f1UeDb->dlRrcMsg)
3278 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3280 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3281 duUeCb->f1UeDb->dlRrcMsg);
3284 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3285 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3286 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3287 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3293 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3296 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3303 /**********************************************************************
3305 ***********************************************************************/