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] == NULLP)
471 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
475 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
477 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
480 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
481 duCb.ueCcchCtxt[ueIdx].cellId);
486 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
493 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
495 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
497 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
498 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
501 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
502 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
515 /******************************************************************
517 * @brief Generates GNB DU Ue F1AP ID
521 * Function : genGnbDuUeF1apId
523 * Functionality: Generates GNB DU Ue F1AP ID
526 * @return gnbDuF1apId
528 * ****************************************************************/
529 int32_t genGnbDuUeF1apId(uint8_t cellId)
533 GET_CELL_IDX(cellId, cellIdx);
534 if(duCb.actvCellLst[cellIdx])
536 return ++duCb.gnbDuUeF1apIdGenerator;
540 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
545 /******************************************************************
547 * @brief Processes UL CCCH Ind recvd from MAC
551 * Function : duProcUlCcchInd
553 * Functionality: Processes UL CCCH Ind recvd from MAC
555 * @params[in] UlCcchIndInfo *ulCcchIndInfo
556 * @return ROK - success
559 * ****************************************************************/
560 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
564 int32_t gnbDuUeF1apId = 0;
566 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
568 if(gnbDuUeF1apId == -1)
570 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
574 /* Store Ue mapping */
575 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
576 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
577 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
581 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
582 ulCcchIndInfo->ulCcchMsg));
585 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
588 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
589 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
595 /******************************************************************
597 * @brief Fills Default UL LC Cfg
601 * Function : fillDefaultUlLcCfg
603 * Functionality: Fills Default UL LC Cfg
605 * @params[in] UlLcCfg *ulLcCfg
607 *****************************************************************/
608 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
610 ulLcCfg->priority = LC_PRIORITY_1;
611 ulLcCfg->lcGroup = 0;
612 ulLcCfg->schReqId = 0;
613 ulLcCfg->pbr = PBR_KBPS_INFINITY;
614 ulLcCfg->bsd = BSD_MS_1000;
617 /******************************************************************
619 * @brief Fills Initial DL Bandwidth Part
623 * Function : fillDefaultInitDlBwp
625 * Functionality: Fills Initial DL Bandwidth Part
627 * @params[in] InitialDlBwp *initDlBwp
630 *****************************************************************/
631 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
634 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
635 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
640 /* Filling PDCCH Config */
641 initDlBwp->pdcchPresent = TRUE;
642 if(initDlBwp->pdcchPresent)
644 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
645 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
646 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
648 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
649 PDCCH_CTRL_RSRC_SET_ONE_ID;
650 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
652 coreset0EndPrb = CORESET0_END_PRB;
653 coreset1StartPrb = coreset0EndPrb +6;
654 coreset1NumPrb = CORESET1_NUM_PRB;
655 /* calculate the PRBs */
656 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
657 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
660 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
661 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
662 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
663 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
664 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
666 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
669 initDlBwp->pdcchCfg.numCRsetToRel = 0;
670 /* Filling Serach Space */
671 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
672 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
673 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
675 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
676 PDCCH_SRCH_SPC_TWO_ID;
677 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
678 PDCCH_CTRL_RSRC_SET_ONE_ID;
679 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
680 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
681 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
682 MONITORING_SYMB_WITHIN_SLOT_SIZE);
683 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
684 PDCCH_SYMBOL_WITHIN_SLOT;
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
687 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
689 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
691 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
693 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
695 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
696 SEARCHSPACETYPE_PR_UE_SPECIFIC;
697 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
698 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
700 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
704 /* Filling PDSCH Config */
705 initDlBwp->pdschPresent = TRUE;
706 if(initDlBwp->pdschPresent)
708 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
709 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
710 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
711 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
713 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
714 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
715 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
716 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
717 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
718 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
719 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
720 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
726 /******************************************************************
728 * @brief Fills Initial UL Bandwidth Part
732 * Function : fillDefaultInitUlBwp
734 * Functionality: Fills Initial UL Bandwidth Part
736 * @params[in] InitialUlBwp *initUlBwp
739 *****************************************************************/
740 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
745 initUlBwp->pucchPresent = FALSE;
747 /*Filling PUSCH Config */
748 initUlBwp->puschPresent = TRUE;
749 if(initUlBwp->puschPresent)
751 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
752 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
753 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
754 scramblingId0 = SCRAMBLING_ID;
755 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
756 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
758 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
760 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
761 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
763 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
764 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
765 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
766 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
769 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
770 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
771 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
772 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
773 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
774 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
776 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
781 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
785 /******************************************************************
787 * @brief Fills SpCell Group Info
791 * Function : fillDefaultSpCellGrpInfo
793 * Functionality: Fills Sp Cell Group Info
795 * @params[in] MacUeCfg *macUeCfg
798 *****************************************************************/
799 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
801 SpCellCfg *spCell = NULL;
804 spCell = &macUeCfg->spCellCfg;
808 macUeCfg->spCellCfgPres = true;
810 spCell->servCellIdx = SERV_CELL_IDX;
811 /* Filling Initial Dl Bwp */
812 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
814 spCell->servCellCfg.numDlBwpToAdd = 0;
815 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
816 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
817 spCell->servCellCfg.bwpInactivityTmr = NULLP;
818 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
819 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
820 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
821 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
822 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
823 NUM_HARQ_PROC_FOR_PDSCH_N_16;
824 /* Filling Initial UL Bwp*/
825 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
826 spCell->servCellCfg.numUlBwpToAdd = 0;
827 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
831 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
835 /******************************************************************
837 * @brief Fills Physical Cell Group Info
841 * Function : fillDefaultPhyCellGrpInfo
843 * Functionality: Fills Physical Cell Group Info
845 * @params[in] MacUeCfg *macUeCfg
848 *****************************************************************/
849 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
851 PhyCellGrpCfg *cellGrp = NULL;
854 cellGrp = &macUeCfg->phyCellGrpCfg;
858 macUeCfg->phyCellGrpCfgPres = true;
859 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
860 cellGrp->pNrFr1 = P_NR_FR1;
864 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
868 /******************************************************************
870 * @brief Fills Mac Cell Group Info
874 * Function : fillDefaultMacCellGrpInfo
876 * Functionality: Fills Mac Cell Group Info
878 * @params[in] MacUeCfg *macUeCfg
881 *****************************************************************/
882 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
885 MacCellGrpCfg *cellGrp = NULL;
888 cellGrp = &macUeCfg->macCellGrpCfg;
892 macUeCfg->macCellGrpCfgPres = true;
894 /* Filling Scheduling Request Config */
895 cellGrp->schReqCfg.addModListCount = 1;
896 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
898 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
900 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
901 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
902 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
905 cellGrp->schReqCfg.relListCount = 0;
907 /* Filling Tag config */
908 cellGrp->tagCfg.addModListCount = 1;
909 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
911 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
913 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
914 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
917 cellGrp->tagCfg.relListCount = 0;
919 /* Filling BSR config */
920 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
921 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
922 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
924 /* Filling PHR config */
925 cellGrp->phrCfgSetupPres = true;
926 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
927 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
928 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
929 cellGrp->phrCfg.multiplePHR = false;
930 cellGrp->phrCfg.dummy = false;
931 cellGrp->phrCfg.phrType2OtherCell = false;
932 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
937 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
941 /*******************************************************************
943 * @brief Fills default modulation info for a UE
947 * Function : fillDefaultModulation
949 * Functionality: Fills default modulation info for a UE
951 * @params[in] Pointer to MAC UE configuration
952 * @return ROK - success
955 * ****************************************************************/
956 void fillDefaultModulation(MacUeCfg *ueCfg)
958 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
959 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
960 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
962 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
963 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
964 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
967 /******************************************************************
969 * @brief Function to fill Mac Lc Cfg for SRB1
973 * Function : fillMacSrb1LcCfg
975 * Functionality: Function to fill Mac Lc cfg for SRB1
977 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
979 *****************************************************************/
981 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
983 macLcCfg->lcId = SRB1_LCID;
984 macLcCfg->configType = CONFIG_ADD;
985 macLcCfg->drbQos = NULLP;
986 macLcCfg->snssai = NULLP;
987 macLcCfg->ulLcCfgPres = true;
988 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
991 /******************************************************************
993 * @brief Function to fill the Lc cfg from ueSetupReqDb
997 * Function : fillMacLcCfgToAddMod
999 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1001 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1002 * @return ROK/RFAILED
1004 *****************************************************************/
1006 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1012 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1013 macLcCfgToSend->configType = ueLcCfgDb->configType;
1015 if(ueLcCfgDb->drbQos)
1016 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1018 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1020 macLcCfgToSend->drbQos = NULL;
1022 if(ueLcCfgDb->snssai)
1023 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1025 macLcCfgToSend->snssai = oldLcCfg->snssai;
1027 macLcCfgToSend->snssai = NULL;
1029 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1030 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1031 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1036 oldLcCfg->lcId = ueLcCfgDb->lcId;
1037 oldLcCfg->configType = ueLcCfgDb->configType;
1039 if(ueLcCfgDb->drbQos)
1041 if(oldLcCfg->drbQos)
1042 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1044 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1045 if(oldLcCfg->drbQos == NULL)
1047 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1050 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1053 if(ueLcCfgDb->snssai)
1055 if(oldLcCfg->snssai)
1056 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1058 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1059 if(oldLcCfg->snssai == NULL)
1061 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1062 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1065 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1068 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1069 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1070 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1075 /******************************************************************
1077 * @brief Function to copy the Bit rate from ueSetupReqDb
1081 * Function : fillAmbr
1083 * Functionality: Function to copy bit Rate from ueSetupReqDb
1085 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1086 * @return ROK/RFAILED
1088 *****************************************************************/
1090 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1096 *macAmbrCfgToSend = ueDbAmbr;
1099 *macAmbrCfgToSend = *oldMacAmbrCfg;
1107 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1109 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1110 if(*oldMacAmbrCfg == NULLP)
1112 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1115 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1116 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1123 /******************************************************************
1125 * @brief Builds and Send UE ReConfig Request to MAC
1129 * Function : sendUeReCfgReqToMac
1131 * Functionality: Builds and Send UE ReConfig Request to MAC
1133 * @Params[in] MacUeCfg pointer
1134 * @return ROK - success
1137 * ****************************************************************/
1139 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1145 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1149 /* Processing one Ue at a time to MAC */
1150 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1151 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1154 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1155 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1160 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1168 /******************************************************************
1170 * @brief Fills MacUeCfg structure
1174 * Function : fillMacUeCfg
1176 * Functionality: Fills MacUeCfg
1178 * @params[in] cellId, ueId, crnti,
1181 * @return ROK/RFAILED
1183 *****************************************************************/
1184 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueId, uint16_t crnti, DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1186 uint8_t ret, dbIdx, lcIdx, cellIdx;
1187 bool lcIdFound = false;
1188 MacUeCfg *duMacDb = NULLP;
1194 macUeCfg->cellId = cellId;
1195 macUeCfg->ueId = ueId;
1196 macUeCfg->crnti = crnti;
1198 fillDefaultMacCellGrpInfo(macUeCfg);
1199 fillDefaultPhyCellGrpInfo(macUeCfg);
1200 fillDefaultSpCellGrpInfo(macUeCfg);
1201 macUeCfg->ambrCfg = NULLP;
1202 fillDefaultModulation(macUeCfg);
1203 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1208 /* Fetching MacDb from DuUeCb */
1209 GET_CELL_IDX(cellId, cellIdx);
1210 if(duCb.actvCellLst[cellIdx])
1211 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg;
1214 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1217 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1218 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1219 macUeCfg->cellId = cellId;
1220 macUeCfg->ueId = ueId;
1221 macUeCfg->crnti = crnti;
1222 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1225 if(macUeCfg->spCellCfgPres == true)
1227 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1229 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1230 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1232 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1234 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1235 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1238 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1239 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1242 /* Filling LC Context */
1243 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1245 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1247 /* Filling default UL LC config in MAC if not present */
1248 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1249 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1251 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1253 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1256 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1257 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1259 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1260 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1261 &duMacDb->lcCfgList[lcIdx], FALSE);
1269 /* ADD/DEL CONFIG */
1270 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1278 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1281 }/*End of Outer FOR loop */
1282 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1287 /******************************************************************
1289 * @brief Fills Rlc AM Information
1293 * Function : fillDefaultAmInfo
1295 * Functionality: Fills Rlc AM Information
1297 * @params[in] AmBearerCfg *amCfg
1300 *****************************************************************/
1301 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1304 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1305 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1306 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1307 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1308 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1311 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1312 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1313 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1316 /******************************************************************
1318 * @brief Fills RLC UM Bi Directional Information
1322 * Function : fillDefaultUmBiInfo
1324 * Functionality: Fills RLC UM Bi Directional Information
1326 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1329 *****************************************************************/
1330 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1332 /* UL UM BI DIR INFO */
1333 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1334 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1336 /* DL UM BI DIR INFO */
1337 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1340 /******************************************************************
1342 * @brief Fills RLC UM Uni Directional UL Information
1346 * Function : fillDefaultUmUlInfo
1348 * Functionality: Fills RLC UM Uni Directional Info
1350 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1353 *****************************************************************/
1354 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1356 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1357 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1360 /******************************************************************
1362 * @brief Fills RLC UM Uni Directional DL Information
1366 * Function : fillDefaultUmDlInfo
1368 * Functionality: Fills RLC UM Uni Directional DL Info
1370 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1373 *****************************************************************/
1374 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1376 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1379 /******************************************************************
1381 * @brief Builds Rlc Mode Default Configuration
1385 * Function : fillDefaultRlcModeCfg
1387 * Functionality: Builds Rlc Mode Default Configuration
1389 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1390 * @return ROK/RFAILED
1392 *****************************************************************/
1394 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1404 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1406 fillDefaultAmInfo(lcCfg->u.amCfg);
1409 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1415 case RLC_UM_BI_DIRECTIONAL :
1417 if(!lcCfg->u.umBiDirCfg)
1419 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1420 if(lcCfg->u.umBiDirCfg)
1421 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1424 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1430 case RLC_UM_UNI_DIRECTIONAL_UL :
1432 if(!lcCfg->u.umUniDirUlCfg)
1434 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1435 if(lcCfg->u.umUniDirUlCfg)
1436 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1439 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1445 case RLC_UM_UNI_DIRECTIONAL_DL :
1447 if(!lcCfg->u.umUniDirDlCfg)
1449 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1450 if(lcCfg->u.umUniDirDlCfg)
1451 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1454 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1461 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1468 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1474 /*******************************************************************
1476 * @brief Function to fill Rlc Lc Cfg for SRB1
1480 * Function : fillRlcSrb1LcCfg
1483 * Function to fill Rlc Lc Cfg for SRB1
1485 * @params[in] Pointer to RlcBearerCfg
1486 * @return ROK/RFAILED
1488 *****************************************************************/
1490 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1494 rlcLcCfg->rbId = SRB1_LCID;
1495 rlcLcCfg->rbType = RB_TYPE_SRB;
1496 rlcLcCfg->lcId = SRB1_LCID;
1497 rlcLcCfg->lcType = LCH_DCCH;
1498 rlcLcCfg->rlcMode = RLC_AM;
1499 rlcLcCfg->configType = CONFIG_ADD;
1500 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1504 /*******************************************************************
1506 * @brief Processes UE ReConfig Req to RLC UL
1510 * Function : sendUeReCfgReqToRlc
1513 * Processes UE Reconfig Req to RLC UL
1515 * @params[in] Pointer to RlcUeCfg
1516 * @return ROK - success
1519 *****************************************************************/
1521 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1526 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1529 /* Processing one Ue at a time to RLC */
1530 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1531 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1534 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1535 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1540 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1546 /******************************************************************
1548 * @brief Fills Snssai information
1552 * Function : fillSnssaiInfo
1554 * Functionality: Fills Snssai information
1556 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1558 * @return ROK - success
1561 *****************************************************************/
1562 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1567 snssaiTobeSend = snssaiDb;
1569 snssaiTobeSend = *oldSnssai;
1571 snssaiTobeSend = NULL;
1578 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1580 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1581 if(*oldSnssai == NULL)
1583 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1586 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1591 /******************************************************************
1593 * @brief Fills RlcBearerCfg structure
1597 * Function : fillRlcUeCfg
1599 * Functionality: Fills Rlc Bearer Cfg
1602 *****************************************************************/
1603 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueId, DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1605 uint8_t ret, dbIdx, lcIdx, cellIdx;
1606 bool lcIdFound = false;
1607 RlcUeCfg *duRlcDb = NULLP;
1612 /* Initial RB being Added */
1613 rlcUeCfg->cellId = cellId;
1614 rlcUeCfg->ueId = ueId;
1615 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1619 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1623 /* Fetch RlcDb from DuUeCb */
1624 GET_CELL_IDX(cellId, cellIdx);
1625 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg;
1626 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1627 /*Filling RlcUeCfg */
1628 rlcUeCfg->cellId = cellId;
1629 rlcUeCfg->ueId = ueId;
1630 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1632 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1635 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1636 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1639 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1640 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1642 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1645 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1646 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1649 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1650 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1651 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1652 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1660 /* ADD/ DEL Config Type */
1661 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1662 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1670 /******************************************************************
1672 * @brief creates UE context
1676 * Function : duCreateUeCb
1678 * Functionality: Creates UE Conetxt
1680 * @params[in] UeCcchCtxt Pointer
1683 * @return ROK - success
1685 * ****************************************************************/
1686 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1688 uint8_t cellIdx = 0;
1690 uint8_t ueId = 0, ueIdx = 0;
1692 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1694 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1696 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1697 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1700 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1701 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1702 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1703 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1704 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1705 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1707 /* Filling Mac Ue Config */
1708 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
1709 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueId, ueCcchCtxt->crnti,\
1710 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
1712 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1714 /* Filling Rlc Ue Config */
1715 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
1716 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueId, \
1717 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
1719 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1721 duCb.actvCellLst[cellIdx]->numActvUes++;
1722 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1729 /******************************************************************
1731 * @brief Builds and Send UE Create Request to MAC
1735 * Function : duBuildAndSendUeCreateReqToMac
1737 * Functionality: Builds and Send UE Create Request to MAC
1739 * @Params[in] cellId,
1743 * @return ROK - success
1746 * ****************************************************************/
1748 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti, MacUeCfg *duMacUeCfg)
1751 MacUeCfg *macUeCfg = NULLP;
1753 memset(&pst, 0, sizeof(Pst));
1756 ret = fillMacUeCfg(cellId, ueId, crnti, NULL, duMacUeCfg);
1759 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1763 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1765 /* Copying ueCb to a sharable buffer */
1766 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1769 memset(macUeCfg, 0, sizeof(MacUeCfg));
1770 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1771 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1773 /* Processing one Ue at a time to MAC */
1774 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1777 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1778 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1783 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1789 /*******************************************************************
1791 * @brief To update DuUeCb Mac Cfg
1795 * Function : duUpdateMacCfg
1796 * Functionality: update DuUeCb MAC Cfg
1798 * @params[in] DuUeCb Pointer
1799 * F1UeContextSetupDb pointer
1800 * @return ROK - success
1803 * ****************************************************************/
1804 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1806 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1807 MacUeCfg *oldMacUeCfg;
1810 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1811 if(duCb.actvCellLst[cellIdx] == NULLP)
1813 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
1816 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].macUeCfg;
1818 /*Filling Cell Group Cfg*/
1819 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1822 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1824 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1825 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1827 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1829 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1830 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1832 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1833 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1836 /* Filling LC Context */
1837 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1839 numLcs = macUeCfg->numLcs;
1840 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1842 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1844 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1846 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1848 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1850 /* Free memory at matched lcIdx index */
1851 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1853 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1855 /* moving all elements one index ahead */
1856 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1857 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1860 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1867 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1869 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1872 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1882 /******************************************************************
1884 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1888 * Function : fillRlcCfgToAddMod
1890 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1893 *****************************************************************/
1895 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1897 lcCfg->configType = f1UeDbLcCfg->configType;
1898 lcCfg->rbId = f1UeDbLcCfg->rbId;
1899 lcCfg->rbType = f1UeDbLcCfg->rbType;
1900 lcCfg->lcId = f1UeDbLcCfg->lcId;
1901 lcCfg->lcType = f1UeDbLcCfg->lcType;
1902 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1904 switch(lcCfg->rlcMode)
1910 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1915 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1916 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1917 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1918 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1919 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1922 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1923 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1924 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1927 case RLC_UM_BI_DIRECTIONAL :
1929 if(!lcCfg->u.umBiDirCfg)
1931 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1932 if(!lcCfg->u.umBiDirCfg)
1935 /* UL UM BI DIR INFO */
1936 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1937 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1938 /* DL UM BI DIR INFO */
1939 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1942 case RLC_UM_UNI_DIRECTIONAL_UL :
1944 if(!lcCfg->u.umUniDirUlCfg)
1946 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1947 if(!lcCfg->u.umUniDirUlCfg)
1950 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1951 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1955 case RLC_UM_UNI_DIRECTIONAL_DL :
1957 if(!lcCfg->u.umUniDirDlCfg)
1959 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1960 if(!lcCfg->u.umUniDirDlCfg)
1963 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1967 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1973 /*******************************************************************
1975 * @brief To update DuUeCb Rlc Lc Cfg
1979 * Function : duUpdateRlcLcCfg
1980 * Functionality: update DuUeCb Rlc Lc Cfg
1982 * @params[in] DuUeCb Pointer
1983 * F1UeContextSetupDb pointer
1984 * @return ROK - success
1987 * ****************************************************************/
1989 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1991 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1994 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1996 numLcs = rlcUeCfg->numLcs;
1997 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1999 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2001 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2003 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2006 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2009 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2011 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2013 /* Free memory at matched lcIdx index */
2014 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2016 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2018 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2019 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2021 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2024 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2031 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2033 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2036 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2045 /*******************************************************************
2047 * @brief Function to fill Tunnel Config to Add/Mod
2052 * Function : fillTnlCfgToAddMod
2054 * Functionality: Function to fill tunnel Config to Add/Mod
2056 * @params[in] Pointer to tnlCfgDb,
2057 * pointer to f1TnlCfg
2058 * @return ROK - success
2061 * ****************************************************************/
2062 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2066 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2067 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2070 if(*ueCbTnlCfg == NULLP)
2072 /* copying to DuCb Tnl Cfg */
2073 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2074 if(*ueCbTnlCfg == NULLP)
2076 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2080 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2081 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2082 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2083 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2084 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2085 if(f1TnlCfg->tnlCfg1)
2087 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2089 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2090 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2092 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2096 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2097 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2098 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2099 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2104 /*******************************************************************
2106 * @brief Processing the tunnel Request to EGTP
2110 * Function : duProcEgtpTunnelCfg
2112 * Functionality: Processing the tunnel Request to EGTP
2114 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2115 * @return ROK - success
2118 * ****************************************************************/
2120 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2122 uint8_t ret = RFAILED, delIdx;
2124 if(f1TnlCfg->tnlCfg1 == NULLP)
2126 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2130 if(f1TnlCfg->configType == CONFIG_ADD)
2132 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2134 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2141 else if(f1TnlCfg->configType == CONFIG_MOD)
2143 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2145 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2151 else if(f1TnlCfg->configType == CONFIG_DEL)
2153 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2155 /* Free memory at drbIdx */
2157 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2159 /* moving all elements one index ahead */
2160 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2166 if(duCb.upTnlCfg[delIdx])
2168 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2169 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2176 /***********************************************************************
2178 * @brief Function to fill Tunnel Config
2179 * and sends tunnel Req to EGTP
2184 * Function : duUpdateTunnelCfgDb
2186 * Functionality: Function to fill tunnel Config
2187 * and sends tunnel Cfg Req to EGTP
2189 * @params[in] ueId, cellId, DuUeCfg
2190 * @return ROK - success
2193 * ****************************************************************/
2195 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2197 uint8_t ret = ROK, drbIdx, teIdx;
2198 bool drbFound = false;
2200 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2201 /*then update drbId and tunnel Info in duCb */
2202 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2204 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2205 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2206 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2208 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2209 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2211 drbFound = true; /* existing DRB */
2212 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2214 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2215 duUeCfg->upTnlInfo[drbIdx].drbId);
2224 if(!drbFound && ret == ROK)/* new DRB to Add */
2226 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2228 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2229 duUeCfg->upTnlInfo[drbIdx].drbId);
2240 /*******************************************************************
2242 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2247 * Function : duUpdateDuUeCbCfg
2249 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2251 * @params[in] ueId, cellIdx
2252 * @return ROK - success
2255 * ****************************************************************/
2257 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2259 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2260 DuUeCb *ueCb = NULLP;
2262 GET_CELL_IDX(cellId, cellIdx);
2264 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2265 (duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2267 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2269 /*Filling RLC Ue Cfg */
2270 ueCb->rlcUeCfg.cellId = cellId;
2271 ueCb->rlcUeCfg.ueId = ueId;
2272 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2275 /*Filling MAC Ue Cfg */
2276 GET_CRNTI(crnti, ueId);
2277 ueCb->macUeCfg.cellId = cellId;
2278 ueCb->macUeCfg.ueId = ueId;
2279 ueCb->macUeCfg.crnti = crnti;
2280 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2282 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2285 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2287 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2293 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2300 /*******************************************************************
2302 * @brief Handle UE config response from MAC
2306 * Function : DuProcMacUeCfgRsp
2308 * Functionality: Handle UE Config response from MAC
2310 * @params[in] Pointer to MacUeCfgRsp and Pst
2311 * @return ROK - success
2314 * ****************************************************************/
2315 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2321 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2323 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2325 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueId);
2326 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2327 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2329 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2331 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueId);
2332 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2333 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2335 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2341 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueId);
2342 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2344 //TODO: Send the failure case in Ue Context Setup Response
2348 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2352 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2359 /*******************************************************************
2361 * @brief Processes UE create Req to RLC UL
2365 * Function : duBuildAndSendUeCreateReqToRlc
2368 * Processes UE create Req to RLC UL
2370 * @params[in] cellId,
2372 * Pointer to RlcUeCfg
2373 * @return ROK - success
2376 *****************************************************************/
2378 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueId, RlcUeCfg *duRlcUeCfg)
2381 RlcUeCfg *rlcUeCfg = NULLP;
2384 ret = fillRlcUeCfg(cellId, ueId, NULL, duRlcUeCfg);
2387 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2391 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2392 /* Copying ueCfg to a sharable buffer */
2393 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2396 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2397 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2398 /* Processing one Ue at a time to RLC */
2399 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2400 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2403 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2404 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2410 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2416 /*******************************************************************
2418 * @brief Processes UE create Rsp received from RLC UL
2423 * Function : DuProcRlcUeCfgRsp
2426 * Processes UE create Rsp received from RLC UL
2428 * @params[in] Post structure
2429 * Pointer to RlcCfgCfm
2430 * @return ROK - success
2433 *****************************************************************/
2434 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2440 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2442 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2444 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2445 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2446 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2448 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2450 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2451 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].\
2452 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2453 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2455 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId);
2461 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2462 pst->event, cfgRsp->ueId, cfgRsp->reason);
2463 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2465 //TODO: update failure case in ue Context setup Response
2469 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2473 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2479 /*******************************************************************
2481 * @brief Builds and Send Ue Reconfig Req to RLC
2485 * Function : duBuildAndSendUeReCfgReqToRLC
2487 * Functionality: Builds and Send Ue Reconfig Req to RLC
2489 * @params[in] cellId, crnti
2491 * RlcUeCfg *rlcUeCfg
2492 * @return ROK - success
2495 * ****************************************************************/
2497 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2499 uint8_t ret = ROK, ueId = 0;
2500 RlcUeCfg *rlcUeCfg = NULLP;
2502 GET_UE_ID(crnti, ueId);
2503 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2506 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2507 ret = fillRlcUeCfg(cellId, ueId, ueCfgDb, rlcUeCfg);
2509 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2511 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2515 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2521 /*******************************************************************
2523 * @brief Builds and Send Ue Reconfig Req to MAC
2527 * Function : duBuildAndSendUeReCfgReqToMac
2529 * Functionality: Builds and Send Ue Reconfig Req to MAC
2531 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2533 * MacUeCfg *macUeCfg
2534 * @return ROK - success
2537 * ****************************************************************/
2539 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2541 uint8_t ret, ueId = 0;
2542 MacUeCfg *macUeCfg = NULLP;
2545 GET_UE_ID(crnti, ueId);
2547 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2550 memset(macUeCfg, 0, sizeof(MacUeCfg));
2551 ret = fillMacUeCfg(cellId, ueId, crnti, ueCfgDb, macUeCfg);
2553 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2555 ret = sendUeReCfgReqToMac(macUeCfg);
2559 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2565 /*******************************************************************
2567 * @brief Build and Send Ue context setup request
2572 * Function : duBuildAndSendUeContextSetupReq
2575 * Build and Send Ue context setup request
2577 * @params[in] cellId, crnti, DuUeCfg pointer
2578 * @return ROK - success
2581 *****************************************************************/
2583 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2587 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2588 /* Filling RLC Ue Reconfig */
2589 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2591 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2593 /* Filling MAC Ue Reconfig */
2594 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2596 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2601 /*******************************************************************
2603 * @brief Processes DL Rsp received from RLC DL
2608 * Function : DuProcRlcDlRrcMsgRsp
2611 * Processes UE Rsp received from RLC DL
2613 * @params[in] Post structure
2614 * Pointer to RlcCfgCfm
2615 * @return ROK - success
2618 *****************************************************************/
2619 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2621 uint8_t ret = ROK, ueId = 0;
2622 uint16_t cellId, crnti;
2623 DuUeCb *ueCb = NULLP;
2626 state = dlRrcMsg->state;
2627 cellId = dlRrcMsg->cellId;
2628 crnti = dlRrcMsg->crnti;
2629 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2631 if(state == TRANSMISSION_COMPLETE)
2633 GET_UE_ID(crnti, ueId);
2634 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
2636 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2638 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2640 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2642 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2645 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2647 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2649 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2652 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2654 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2657 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2663 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2667 /*******************************************************************
2669 * @brief Process UE context setup request from CU
2673 * Function : duProcUeContextSetupRequest
2675 * Functionality: Process UE context setup request from CU
2677 * @params[in] F1AP message
2678 * @return ROK - success
2681 * ****************************************************************/
2683 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2685 uint8_t ret, cellId;
2690 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2691 /* Send DL RRC msg for security Mode */
2692 if(ueCb->f1UeDb->dlRrcMsg)
2694 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2696 /* Sending DL RRC Message to RLC */
2697 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2700 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2701 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2702 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2703 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2707 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2709 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2712 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2718 //TODO: To send the failure cause in UeContextSetupRsp
2719 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2724 /*******************************************************************
2726 * @brief Build and Send Ue context mod request
2731 * Function : duBuildAndSendUeContextModReq
2734 * Build and Send Ue context mod request
2736 * @params[in] cellId, crnti, DuUeCfg pointer
2737 * @return ROK - success
2740 *****************************************************************/
2742 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2746 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2747 /* Filling RLC Ue Reconfig */
2748 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2750 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2752 /* Filling MAC Ue Reconfig */
2753 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2755 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2759 /*******************************************************************
2761 * @brief Processing Ue context mod request
2766 * Function : duProcUeContextModReq
2769 * Processing Ue context mod request
2771 * @params[in] DuUeCb *ueCb
2772 * @return ROK - success
2775 *****************************************************************/
2777 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2779 uint8_t ret, cellId;
2784 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2785 /* Send DL RRC msg for security Mode */
2786 if(ueCb->f1UeDb->dlRrcMsg)
2788 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2790 /* Sending DL RRC Message to RLC */
2791 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2794 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2795 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2796 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2797 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2801 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2803 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2806 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2810 else if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
2812 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
2814 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
2821 //TODO: To send the failure cause in UeContextModRsp
2823 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2829 /*******************************************************************
2831 * @brief Function to delete Pdsch ServCellCfg
2835 * Function : deletePdschServCellCfg
2837 * Functionality: Function to delete Pdsch ServCellCfg
2839 * @params[in] PdschServCellCfg *pdschServCellCfg
2842 * ****************************************************************/
2844 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2846 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2847 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2848 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2849 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2852 /*******************************************************************
2854 * @brief delete MacUeCfg from duCb
2858 * Function : deleteMacUeCfg
2860 * Functionality: delete MacUeCfg from duCb
2862 * @params[in] Pointer to MacUeCfg
2863 * @return ROK - success
2866 *******************************************************************/
2868 void deleteMacUeCfg(MacUeCfg *ueCfg)
2872 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2873 if(ueCfg->spCellCfgPres)
2875 freeUeReCfgCellGrpInfo(ueCfg);
2877 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2879 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2881 memset(ueCfg, 0, sizeof(MacUeCfg));
2884 /*******************************************************************
2886 * @brief delete UE Configuration of a particular UE
2890 * Function : deleteUeCfg
2892 * Functionality: delete UE Configuration of a particular UE
2894 * @params[in] uint16_t cellIdx, uint8_t ueId
2895 * @return ROK - success
2898 * ****************************************************************/
2899 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueId)
2902 DuUeCb *ueCb = NULLP;
2904 if(duCb.actvCellLst[cellIdx] != NULLP)
2906 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2907 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2909 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2910 deleteMacUeCfg(&ueCb->macUeCfg);
2911 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2912 if(ueCb->f1UeDb !=NULLP)
2914 freeF1UeDb(ueCb->f1UeDb);
2916 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
2918 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
2920 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2921 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2926 duCb.actvCellLst[cellIdx]->numActvUes--;
2927 memset(ueCb, 0, sizeof(DuUeCb));
2936 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2943 /*******************************************************************
2945 * @brief Handle UE delete response from MAC
2949 * Function : DuProcMacUeDeleteRsp
2951 * Functionality: Handle UE delete response from MAC
2953 * @params[in] Pointer to MacUeDeleteRsp and Pst
2954 * @return ROK - success
2957 * ****************************************************************/
2959 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2961 uint8_t ret =ROK,ueId=0;
2963 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2967 if(deleteRsp->result == SUCCESS)
2969 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2970 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2971 if(duCb.actvCellLst[cellIdx])
2973 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2974 ueId = deleteRsp->ueId;
2975 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2976 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2977 if(deleteUeCfg(cellIdx, ueId) == ROK)
2979 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2982 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2990 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2994 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2998 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3004 /*******************************************************************
3006 * @brief Processes UE Delete Rsp received from RLC
3010 * Function : DuProcRlcUeDeleteRsp
3013 * Processes UE Delete Rsp received from RLC
3015 * @params[in] Post structure
3016 * Pointer to RlcUeDeleteRsp
3017 * @return ROK - success
3020 * *****************************************************************/
3022 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3024 uint8_t ueId = 0, ret = ROK;
3025 uint16_t cellIdx = 0,crnti=0;
3029 ueId = delRsp->ueId;
3030 GET_CELL_IDX(delRsp->cellId, cellIdx);
3032 if(delRsp->result == SUCCESSFUL)
3034 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3035 if(duCb.actvCellLst[cellIdx]!=NULLP)
3037 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3038 GET_CRNTI(crnti, ueId);
3039 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3041 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3049 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3052 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3058 /*******************************************************************
3060 * @brief Sending UE Delete Req To Mac
3064 * Function : sendUeDeleteReqToMac
3067 * sending UE Delete Req To Mac
3069 * @params[in] cellId, ueId, crnti
3070 * @return ROK - success
3073 *****************************************************************/
3075 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3079 MacUeDelete *ueDelete = NULLP;
3081 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3084 ueDelete->cellId = cellId;
3085 ueDelete->ueId = ueId;
3086 ueDelete->crnti = crnti;
3087 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3089 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3090 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3093 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3094 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3099 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3105 /*******************************************************************
3107 * @brief Sending UE Delete Req To Rlc
3111 * Function : sendUeDeleteReqToRlc
3114 * Sending UE Delete Req To Rlc
3116 * @params[in] cellId, ueId
3117 * @return ROK - success
3120 *****************************************************************/
3122 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3126 RlcUeDelete *ueDelete;
3128 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3129 if(ueDelete !=NULLP)
3131 ueDelete->cellId = cellId;
3132 ueDelete->ueId = ueId;
3133 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3135 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3138 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3139 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3144 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3150 /*******************************************************************
3152 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3156 * Function : duBuildAndSendUeDeleteReq
3158 * Functionality: DU processes UE delete req from CU and sends to MAC
3161 * @params[in] cellId, crnti
3162 * @return ROK - success
3165 * ****************************************************************/
3167 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3170 uint16_t cellIdx = 0;
3172 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3173 GET_CELL_IDX(cellId, cellIdx);
3174 GET_UE_ID(crnti, ueId);
3176 if(duCb.actvCellLst[cellIdx] != NULLP)
3178 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3180 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3184 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3185 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3187 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3193 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3200 /*******************************************************************
3202 * @brief delete RlcUeCfg from duCb
3206 * Function : deleteRlcUeCfg
3209 * delete RlcUeCfg from duCb
3211 * @params[in] RlcUeCfg *ueCfg
3213 * @return ROK - success
3216 *****************************************************************/
3218 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3221 RlcBearerCfg *lcCfg= NULLP;
3224 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3226 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3227 switch(lcCfg->rlcMode)
3231 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3234 case RLC_UM_BI_DIRECTIONAL :
3236 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3239 case RLC_UM_UNI_DIRECTIONAL_UL :
3241 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3244 case RLC_UM_UNI_DIRECTIONAL_DL :
3246 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3250 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3252 memset(ueCfg, 0, sizeof(RlcUeCfg));
3256 /*******************************************************************
3258 * @brief Du process Ue Context Release Command
3262 * Function : duProcUeContextReleaseCommand
3264 * Functionality: Du process Ue Context Release Command
3266 * @params[in] DuUeCb *duUeCb
3267 * @return ROK - success
3270 * ****************************************************************/
3271 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3273 uint8_t ret =ROK, ueId=0;
3274 uint16_t cellId=0,crnti =0;
3277 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3280 if(duUeCb->f1UeDb == NULLP)
3282 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3286 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3287 crnti = duUeCb->crnti;
3288 GET_UE_ID(crnti, ueId);
3290 /* Send DL RRC msg for RRC release */
3291 if(duUeCb->f1UeDb->dlRrcMsg)
3293 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3295 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].rlcUeCfg,\
3296 duUeCb->f1UeDb->dlRrcMsg);
3299 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3300 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3301 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3302 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3308 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3311 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3318 /**********************************************************************
3320 ***********************************************************************/