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"
37 DuMacDlCcchInd packMacDlCcchIndOpts[] =
39 packMacDlCcchInd, /* Loose coupling */
40 MacProcDlCcchInd, /* TIght coupling */
41 packMacDlCcchInd /* Light weight-loose coupling */
44 DuMacUeCreateReq packMacUeCreateReqOpts[] =
46 packDuMacUeCreateReq, /* Loose coupling */
47 MacProcUeCreateReq, /* TIght coupling */
48 packDuMacUeCreateReq /* Light weight-loose coupling */
51 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
53 packDuRlcUeCreateReq, /* Loose coupling */
54 RlcProcUeCreateReq, /* TIght coupling */
55 packDuRlcUeCreateReq /* Light weight-loose coupling */
58 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
60 packDlRrcMsgToRlc, /* Loose coupling */
61 RlcProcDlRrcMsgTransfer, /* Tight coupling */
62 packDlRrcMsgToRlc /* Light weight-loose coupling */
65 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
67 packDuRlcUeReconfigReq, /* Loose coupling */
68 RlcProcUeReconfigReq, /* TIght coupling */
69 packDuRlcUeReconfigReq /* Light weight-loose coupling */
72 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
74 packDuMacUeReconfigReq, /* Loose coupling */
75 MacProcUeReconfigReq, /* TIght coupling */
76 packDuMacUeReconfigReq /* Light weight-loose coupling */
79 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
81 packRlcDlUserDataToRlc, /* Loose coupling */
82 RlcProcDlUserDataTransfer, /* Tight coupling */
83 packRlcDlUserDataToRlc /* Light weight-loose coupling */
86 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
88 packDuMacUeDeleteReq, /* Loose coupling */
89 MacProcUeDeleteReq, /* TIght coupling */
90 packDuMacUeDeleteReq /* Light weight-loose coupling */
93 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
95 packDuRlcUeDeleteReq, /* Loose coupling */
96 RlcProcUeDeleteReq, /* TIght coupling */
97 packDuRlcUeDeleteReq /* Light weight-loose coupling */
100 DuMacCellDeleteReq packMacCellDeleteReqOpts[] =
102 packDuMacCellDeleteReq, /* Loose coupling */
103 MacProcCellDeleteReq, /* TIght coupling */
104 packDuMacCellDeleteReq /* Light weight-loose coupling */
107 /*******************************************************************
109 * @brief Function to fillDlUserDataInfo
113 * Function : fillDlUserDataInfo
116 * Function to fillDlUserDataInfo
121 * @return ROK - success
124 * ****************************************************************/
126 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
130 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
132 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
134 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
136 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
137 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
138 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
146 /*******************************************************************
148 * @brief Build and Send DL Data Message transfer to RLC
152 * Function : duBuildAndSendDlUserDataToRlc
155 * Build and Send DL Data Message transfer to RLC
157 * @params[in] Cell ID
159 * Logical Channgel ID
162 * @return ROK - success
165 * ****************************************************************/
167 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
169 uint8_t ret = RFAILED;
171 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
173 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
176 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
179 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
180 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &dlDataMsgInfo->dlMsg) != ROK)
182 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlMsg in duHdlEgtpDlData()");
183 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
186 dlDataMsgInfo->dlMsg = egtpMsg->msg;
187 dlDataMsgInfo->msgLen = msgLen;
189 /* Filling DL DATA Msg Info */
190 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
192 /* Filling post structure and sending msg */
193 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
194 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
195 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
199 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
200 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
201 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
206 /*******************************************************************
208 * @brief Handles EGTP data from CU
212 * Function : duHdlEgtpData
215 * Processes EGTP header and sends data to RLC
217 * @params[in] Pointer to EGTP Message
218 * @return ROK - success
221 * ****************************************************************/
222 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
225 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
229 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
232 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
233 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
235 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
236 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
242 /******************************************************************
244 * @brief Builds and Sends DL CCCH Ind to MAC
248 * Function : duBuildAndSendDlCcchInd
250 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
252 * @params[in] dlCcchMsg - uint8_t*
253 * @return ROK - success
256 * ****************************************************************/
257 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
258 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
262 DlCcchIndInfo *dlCcchIndInfo = NULLP;
265 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
267 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
271 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
275 dlCcchIndInfo->cellId = *cellId;
276 dlCcchIndInfo->crnti = *crnti;
277 dlCcchIndInfo->msgType = msgType;
278 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
280 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
281 if(!dlCcchIndInfo->dlCcchMsg)
283 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
284 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
287 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
289 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
291 DU_FREE(dlCcchMsg, dlCcchMsgSize);
294 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
295 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
298 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
299 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
300 dlCcchIndInfo->dlCcchMsgLen);
301 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
302 sizeof(DlCcchIndInfo));
310 /*******************************************************************
312 * @brief Build and Send DL RRC Message transfer to RLC
316 * Function : duBuildAndSendDlRrcMsgToRlc
319 * Build and Send DL RRC Message transfer to RLC
321 * @params[in] Cell ID
323 * Logical Channgel ID
326 * @return ROK - success
329 * ****************************************************************/
330 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
335 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
339 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
343 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
346 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
347 duBuildAndSendDlRrcMsgToRlc");
348 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
352 /* Filling up the RRC msg info */
353 dlRrcMsgInfo->cellId = cellId;
354 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
355 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
357 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
359 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
360 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
361 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
362 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
366 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
367 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
368 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
369 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
371 /* Filling post structure and sending msg */
372 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
373 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
374 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
377 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
378 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
387 /******************************************************************
389 * @brief Process DL RRC Msg recevied from F1AP
393 * Function : duProcDlRrcMsg
395 * Functionality: Process DL RRC Msg recevied from F1AP
397 * @params[in] dlCcchMsg - uint8_t*
398 * @return ROK - success
401 * ****************************************************************/
403 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
406 uint16_t crnti, cellId, cellIdx;
407 bool ueCcchCtxtFound = false;
408 bool ueFound = false;
412 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
414 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
416 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
418 ueCcchCtxtFound = true;
419 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
420 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
427 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
430 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
434 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
436 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
439 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
440 duCb.ueCcchCtxt[ueIdx].cellId);
445 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
452 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
454 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
456 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
457 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
460 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
461 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
474 /******************************************************************
476 * @brief Generates GNB DU Ue F1AP ID
480 * Function : genGnbDuUeF1apId
482 * Functionality: Generates GNB DU Ue F1AP ID
485 * @return gnbDuF1apId
487 * ****************************************************************/
488 uint32_t genGnbDuUeF1apId()
490 static uint32_t gnbDuUeF1apId = 0;
492 return ++gnbDuUeF1apId;
495 /******************************************************************
497 * @brief Processes UL CCCH Ind recvd from MAC
501 * Function : duProcUlCcchInd
503 * Functionality: Processes UL CCCH Ind recvd from MAC
505 * @params[in] UlCcchIndInfo *ulCcchIndInfo
506 * @return ROK - success
509 * ****************************************************************/
510 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
514 uint32_t gnbDuUeF1apId = 0;
516 gnbDuUeF1apId = genGnbDuUeF1apId();
518 /* Store Ue mapping */
519 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
520 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
521 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
525 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
526 ulCcchIndInfo->ulCcchMsg));
529 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
532 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
533 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
539 /******************************************************************
541 * @brief Fills Default UL LC Cfg
545 * Function : fillDefaultUlLcCfg
547 * Functionality: Fills Default UL LC Cfg
549 * @params[in] UlLcCfg *ulLcCfg
551 *****************************************************************/
552 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
554 ulLcCfg->priority = LC_PRIORITY_1;
555 ulLcCfg->lcGroup = 0;
556 ulLcCfg->schReqId = 0;
557 ulLcCfg->pbr = PBR_KBPS_INFINITY;
558 ulLcCfg->bsd = BSD_MS_1000;
561 /******************************************************************
563 * @brief Fills Initial DL Bandwidth Part
567 * Function : fillDefaultInitDlBwp
569 * Functionality: Fills Initial DL Bandwidth Part
571 * @params[in] InitialDlBwp *initDlBwp
574 *****************************************************************/
575 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
578 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
579 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
584 /* Filling PDCCH Config */
585 initDlBwp->pdcchPresent = TRUE;
586 if(initDlBwp->pdcchPresent)
588 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
589 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
590 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
592 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
593 PDCCH_CTRL_RSRC_SET_ONE_ID;
594 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
596 coreset0EndPrb = CORESET0_END_PRB;
597 coreset1StartPrb = coreset0EndPrb +6;
598 coreset1NumPrb = CORESET1_NUM_PRB;
599 /* calculate the PRBs */
600 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
601 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
604 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
605 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
606 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
607 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
608 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
610 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
613 initDlBwp->pdcchCfg.numCRsetToRel = 0;
614 /* Filling Serach Space */
615 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
616 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
617 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
619 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
620 PDCCH_SRCH_SPC_TWO_ID;
621 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
622 PDCCH_CTRL_RSRC_SET_ONE_ID;
623 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
624 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
625 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
626 MONITORING_SYMB_WITHIN_SLOT_SIZE);
627 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
628 PDCCH_SYMBOL_WITHIN_SLOT;
629 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
631 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
633 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
635 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
637 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
639 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
640 SEARCHSPACETYPE_PR_UE_SPECIFIC;
641 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
642 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
644 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
648 /* Filling PDSCH Config */
649 initDlBwp->pdschPresent = TRUE;
650 if(initDlBwp->pdschPresent)
652 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
653 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
654 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
655 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
657 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
658 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
659 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
660 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
661 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
662 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
663 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
664 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
670 /******************************************************************
672 * @brief Fills Initial UL Bandwidth Part
676 * Function : fillDefaultInitUlBwp
678 * Functionality: Fills Initial UL Bandwidth Part
680 * @params[in] InitialUlBwp *initUlBwp
683 *****************************************************************/
684 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
689 initUlBwp->pucchPresent = FALSE;
691 /*Filling PUSCH Config */
692 initUlBwp->puschPresent = TRUE;
693 if(initUlBwp->puschPresent)
695 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
696 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
697 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
698 scramblingId0 = SCRAMBLING_ID;
699 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
700 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
702 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
704 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
705 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
707 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
708 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
709 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
710 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
712 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
717 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
721 /******************************************************************
723 * @brief Fills SpCell Group Info
727 * Function : fillDefaultSpCellGrpInfo
729 * Functionality: Fills Sp Cell Group Info
731 * @params[in] SpCellCfg *spCell
734 *****************************************************************/
735 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
739 spCell->servCellIdx = SERV_CELL_IDX;
740 /* Filling Initial Dl Bwp */
741 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
743 spCell->servCellCfg.numDlBwpToAdd = 0;
744 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
745 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
746 spCell->servCellCfg.bwpInactivityTmr = NULLP;
747 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
748 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
749 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
750 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
751 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
752 NUM_HARQ_PROC_FOR_PDSCH_N_16;
753 /* Filling Initial UL Bwp*/
754 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
755 spCell->servCellCfg.numUlBwpToAdd = 0;
756 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
760 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
764 /******************************************************************
766 * @brief Fills Physical Cell Group Info
770 * Function : fillDefaultPhyCellGrpInfo
772 * Functionality: Fills Physical Cell Group Info
774 * @params[in] PhyCellGrpCfg *cellGrp
777 *****************************************************************/
778 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
782 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
783 cellGrp->pNrFr1 = P_NR_FR1;
787 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
791 /******************************************************************
793 * @brief Fills Mac Cell Group Info
797 * Function : fillDefaultMacCellGrpInfo
799 * Functionality: Fills Mac Cell Group Info
801 * @params[in] MacCellGrpCfg *cellGrp
804 *****************************************************************/
805 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
811 /* Filling Scheduling Request Config */
812 cellGrp->schReqCfg.addModListCount = 1;
813 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
815 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
817 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
818 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
819 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
822 cellGrp->schReqCfg.relListCount = 0;
824 /* Filling Tag config */
825 cellGrp->tagCfg.addModListCount = 1;
826 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
828 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
830 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
831 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
834 cellGrp->tagCfg.relListCount = 0;
836 /* Filling BSR config */
837 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
838 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
839 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
841 /* Filling PHR config */
842 cellGrp->phrCfgSetupPres = true;
843 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
844 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
845 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
846 cellGrp->phrCfg.multiplePHR = false;
847 cellGrp->phrCfg.dummy = false;
848 cellGrp->phrCfg.phrType2OtherCell = false;
849 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
854 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
858 /*******************************************************************
860 * @brief Fills default modulation info for a UE
864 * Function : fillDefaultModulation
866 * Functionality: Fills default modulation info for a UE
868 * @params[in] Pointer to MAC UE configuration
869 * @return ROK - success
872 * ****************************************************************/
873 void fillDefaultModulation(MacUeCfg *ueCfg)
875 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
876 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
877 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
879 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
880 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
881 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
884 /******************************************************************
886 * @brief Function to fill Mac Lc Cfg for SRB1
890 * Function : fillMacSrb1LcCfg
892 * Functionality: Function to fill Mac Lc cfg for SRB1
894 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
896 *****************************************************************/
898 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
900 macLcCfg->lcId = SRB1_LCID;
901 macLcCfg->configType = CONFIG_ADD;
902 macLcCfg->drbQos = NULLP;
903 macLcCfg->snssai = NULLP;
904 macLcCfg->ulLcCfgPres = true;
905 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
908 /******************************************************************
910 * @brief Function to fill the Lc cfg from ueSetupReqDb
914 * Function : fillMacLcCfgToAddMod
916 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
918 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
919 * @return ROK/RFAILED
921 *****************************************************************/
923 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
926 lcCfg->lcId = ueSetReqDb->lcId;
927 lcCfg->configType = ueSetReqDb->configType;
929 if(ueSetReqDb->drbQos)
933 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
936 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
942 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
947 lcCfg->drbQos = NULLP;
952 if(ueSetReqDb->snssai)
956 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
959 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
966 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
970 lcCfg->snssai = NULLP;
973 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
974 lcCfg->drbQos = NULLP;
980 lcCfg->snssai = NULLP;
982 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
983 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
984 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
988 /******************************************************************
990 * @brief Function to copy the Bit rate from ueSetupReqDb
994 * Function : fillAmbr
996 * Functionality: Function to copy bit Rate from ueSetupReqDb
998 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
999 * @return ROK/RFAILED
1001 *****************************************************************/
1003 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
1007 if(*macAmbr == NULLP)
1009 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
1010 if(*macAmbr == NULLP)
1012 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1016 memset(*macAmbr, 0, sizeof(AmbrCfg));
1017 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
1026 /******************************************************************
1028 * @brief Builds and Send UE ReConfig Request to MAC
1032 * Function : sendUeReCfgReqToMac
1034 * Functionality: Builds and Send UE ReConfig Request to MAC
1036 * @Params[in] MacUeCfg pointer
1037 * @return ROK - success
1040 * ****************************************************************/
1042 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1048 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1052 /* Processing one Ue at a time to MAC */
1053 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1054 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1057 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1058 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1063 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1069 /******************************************************************
1071 * @brief Function to return Drb LcId
1075 * Function : getDrbLcId
1077 * Functionality: Function to return Drb LcId
1079 * Returns: lcId - SUCCESS
1081 *****************************************************************/
1083 uint8_t getDrbLcId(uint32_t *drbBitMap)
1085 uint8_t bitMask = 1, bitPos = 0;
1086 bitPos = MIN_DRB_LCID;
1088 while(bitPos <= MAX_DRB_LCID)
1090 if((*drbBitMap & (bitMask << bitPos)) == 0)
1092 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1100 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1104 /******************************************************************
1106 * @brief Fills MacUeCfg structure
1110 * Function : fillMacUeCfg
1112 * Functionality: Fills MacUeCfg
1114 * @params[in] cellId, ueIdx, crnti,
1117 * @return ROK/RFAILED
1119 *****************************************************************/
1120 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1121 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1123 uint8_t ret, dbIdx, lcIdx, cellIdx;
1124 bool lcIdFound = false;
1125 MacUeCfg *duMacDb = NULLP;
1131 macUeCfg->cellId = cellId;
1132 macUeCfg->ueIdx = ueIdx;
1133 macUeCfg->crnti = crnti;
1134 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1135 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1136 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1137 macUeCfg->ambrCfg = NULLP;
1138 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1139 fillDefaultModulation(macUeCfg);
1144 /* Fetching MacDb from DuUeCb */
1145 GET_CELL_IDX(cellId, cellIdx);
1146 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1147 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1148 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1149 macUeCfg->cellId = cellId;
1150 macUeCfg->ueIdx = ueIdx;
1151 macUeCfg->crnti = crnti;
1152 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1155 if(macUeCfg->spCellCfgPres == true)
1157 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1159 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1160 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1162 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1164 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1165 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1168 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1169 if(ueCfgDb->ueNrCapability != NULLP)
1171 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1175 /* Filling LC Context */
1176 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1178 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1180 /* Filling default UL LC config in MAC if not present */
1181 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1182 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1184 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1186 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1189 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1190 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1192 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1193 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1201 /* ADD/DEL CONFIG */
1202 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1210 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1213 }/*End of Outer FOR loop */
1218 /******************************************************************
1220 * @brief Fills Rlc AM Information
1224 * Function : fillDefaultAmInfo
1226 * Functionality: Fills Rlc AM Information
1228 * @params[in] AmBearerCfg *amCfg
1231 *****************************************************************/
1232 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1235 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1236 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1237 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1238 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1239 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1242 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1243 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1244 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1247 /******************************************************************
1249 * @brief Fills RLC UM Bi Directional Information
1253 * Function : fillDefaultUmBiInfo
1255 * Functionality: Fills RLC UM Bi Directional Information
1257 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1260 *****************************************************************/
1261 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1263 /* UL UM BI DIR INFO */
1264 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1265 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1267 /* DL UM BI DIR INFO */
1268 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1271 /******************************************************************
1273 * @brief Fills RLC UM Uni Directional UL Information
1277 * Function : fillDefaultUmUlInfo
1279 * Functionality: Fills RLC UM Uni Directional Info
1281 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1284 *****************************************************************/
1285 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1287 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1288 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1291 /******************************************************************
1293 * @brief Fills RLC UM Uni Directional DL Information
1297 * Function : fillDefaultUmDlInfo
1299 * Functionality: Fills RLC UM Uni Directional DL Info
1301 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1304 *****************************************************************/
1305 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1307 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1310 /******************************************************************
1312 * @brief Builds Rlc Mode Default Configuration
1316 * Function : fillDefaultRlcModeCfg
1318 * Functionality: Builds Rlc Mode Default Configuration
1320 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1321 * @return ROK/RFAILED
1323 *****************************************************************/
1325 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1336 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1338 fillDefaultAmInfo(lcCfg->u.amCfg);
1341 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1347 case RLC_UM_BI_DIRECTIONAL :
1349 if(!lcCfg->u.umBiDirCfg)
1351 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1352 if(lcCfg->u.umBiDirCfg)
1353 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1356 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1362 case RLC_UM_UNI_DIRECTIONAL_UL :
1364 if(!lcCfg->u.umUniDirUlCfg)
1366 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1367 if(lcCfg->u.umUniDirUlCfg)
1368 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1371 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1377 case RLC_UM_UNI_DIRECTIONAL_DL :
1379 if(!lcCfg->u.umUniDirDlCfg)
1381 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1382 if(lcCfg->u.umUniDirDlCfg)
1383 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1386 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1393 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1400 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1406 /*******************************************************************
1408 * @brief Function to fill Rlc Lc Cfg for SRB1
1412 * Function : fillRlcSrb1LcCfg
1415 * Function to fill Rlc Lc Cfg for SRB1
1417 * @params[in] Pointer to RlcBearerCfg
1418 * @return ROK/RFAILED
1420 *****************************************************************/
1422 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1426 rlcLcCfg->rbId = SRB1_LCID;
1427 rlcLcCfg->rbType = RB_TYPE_SRB;
1428 rlcLcCfg->lcId = SRB1_LCID;
1429 rlcLcCfg->lcType = LCH_DCCH;
1430 rlcLcCfg->rlcMode = RLC_AM;
1431 rlcLcCfg->configType = CONFIG_ADD;
1432 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1436 /*******************************************************************
1438 * @brief Processes UE ReConfig Req to RLC UL
1442 * Function : sendUeReCfgReqToRlc
1445 * Processes UE Reconfig Req to RLC UL
1447 * @params[in] Pointer to RlcUeCfg
1448 * @return ROK - success
1451 *****************************************************************/
1453 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1458 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1461 /* Processing one Ue at a time to RLC */
1462 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1463 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1466 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1467 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1472 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1478 /******************************************************************
1480 * @brief Fills RlcBearerCfg structure
1484 * Function : fillRlcUeCfg
1486 * Functionality: Fills Rlc Bearer Cfg
1489 *****************************************************************/
1490 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1491 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1493 uint8_t ret, dbIdx, lcIdx, cellIdx;
1494 bool lcIdFound = false;
1495 RlcUeCfg *duRlcDb = NULLP;
1500 /* Initial RB being Added */
1501 rlcUeCfg->cellId = cellId;
1502 rlcUeCfg->ueIdx = ueIdx;
1503 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1507 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1511 /* Fetch RlcDb from DuUeCb */
1512 GET_CELL_IDX(cellId, cellIdx);
1513 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1514 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1515 /*Filling RlcUeCfg */
1516 rlcUeCfg->cellId = cellId;
1517 rlcUeCfg->ueIdx = ueIdx;
1518 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1520 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1523 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1524 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1527 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1528 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1530 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1533 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1534 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1537 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1538 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1546 /* ADD/ DEL Config Type */
1547 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1555 /******************************************************************
1557 * @brief creates UE context
1561 * Function : duCreateUeCb
1563 * Functionality: Creates UE Conetxt
1565 * @params[in] UeCcchCtxt Pointer
1568 * @return ROK - success
1570 * ****************************************************************/
1571 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1573 uint8_t cellIdx = 0;
1577 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1579 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1581 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1582 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1584 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1585 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1586 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1587 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1588 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1589 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1591 /* Filling Mac Ue Config */
1592 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1593 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1594 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1596 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1598 /* Filling Rlc Ue Config */
1599 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1600 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1601 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1603 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1605 duCb.actvCellLst[cellIdx]->numActvUes++;
1606 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1612 /******************************************************************
1614 * @brief Builds and Send UE Create Request to MAC
1618 * Function : duBuildAndSendUeCreateReqToMac
1620 * Functionality: Builds and Send UE Create Request to MAC
1622 * @Params[in] cellId,
1624 * @return ROK - success
1627 * ****************************************************************/
1629 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1630 uint16_t crnti, MacUeCfg *duMacUeCfg)
1633 MacUeCfg *macUeCfg = NULLP;
1635 memset(&pst, 0, sizeof(Pst));
1638 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1641 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1645 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1647 /* Copying ueCb to a sharable buffer */
1648 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1651 memset(macUeCfg, 0, sizeof(MacUeCfg));
1652 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1653 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1655 /* Processing one Ue at a time to MAC */
1656 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1659 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1660 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1665 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1671 /*******************************************************************
1673 * @brief To update DuUeCb Mac Cfg
1677 * Function : duUpdateMacCfg
1678 * Functionality: update DuUeCb MAC Cfg
1680 * @params[in] DuUeCb Pointer
1681 * F1UeContextSetupDb pointer
1682 * @return ROK - success
1685 * ****************************************************************/
1686 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1688 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1689 MacUeCfg *oldMacUeCfg;
1692 /*Filling Cell Group Cfg*/
1693 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1696 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1698 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1699 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1701 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1703 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1704 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1706 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1708 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1709 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1710 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1713 /* Filling LC Context */
1714 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1716 numLcs = macUeCfg->numLcs;
1717 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1719 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1721 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1723 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1725 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1727 /* Free memory at matched lcIdx index */
1728 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1730 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1732 /* moving all elements one index ahead */
1733 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1734 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1737 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1744 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1746 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1749 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1759 /******************************************************************
1761 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1765 * Function : fillRlcCfgToAddMod
1767 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1770 *****************************************************************/
1772 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1774 lcCfg->configType = f1UeDbLcCfg->configType;
1775 lcCfg->rbId = f1UeDbLcCfg->rbId;
1776 lcCfg->rbType = f1UeDbLcCfg->rbType;
1777 lcCfg->lcId = f1UeDbLcCfg->lcId;
1778 lcCfg->lcType = f1UeDbLcCfg->lcType;
1779 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1780 switch(lcCfg->rlcMode)
1786 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1791 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1792 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1793 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1794 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1795 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1798 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1799 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1800 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1803 case RLC_UM_BI_DIRECTIONAL :
1805 if(!lcCfg->u.umBiDirCfg)
1807 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1808 if(!lcCfg->u.umBiDirCfg)
1811 /* UL UM BI DIR INFO */
1812 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1813 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1814 /* DL UM BI DIR INFO */
1815 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1818 case RLC_UM_UNI_DIRECTIONAL_UL :
1820 if(!lcCfg->u.umUniDirUlCfg)
1822 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1823 if(!lcCfg->u.umUniDirUlCfg)
1826 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1827 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1831 case RLC_UM_UNI_DIRECTIONAL_DL :
1833 if(!lcCfg->u.umUniDirDlCfg)
1835 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1836 if(!lcCfg->u.umUniDirDlCfg)
1839 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1843 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1849 /*******************************************************************
1851 * @brief To update DuUeCb Rlc Lc Cfg
1855 * Function : duUpdateRlcLcCfg
1856 * Functionality: update DuUeCb Rlc Lc Cfg
1858 * @params[in] DuUeCb Pointer
1859 * F1UeContextSetupDb pointer
1860 * @return ROK - success
1863 * ****************************************************************/
1865 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1867 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1870 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1872 numLcs = rlcUeCfg->numLcs;
1873 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1875 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1877 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1879 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1881 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1883 /* Free memory at matched lcIdx index */
1884 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1886 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1888 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1889 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1892 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1899 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1901 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1910 /*******************************************************************
1912 * @brief Function to fill Tunnel Config to Add/Mod
1917 * Function : fillTnlCfgToAddMod
1919 * Functionality: Function to fill tunnel Config to Add/Mod
1921 * @params[in] Pointer to tnlCfgDb,
1922 * pointer to f1TnlCfg
1923 * @return ROK - success
1926 * ****************************************************************/
1927 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1929 if(*ueCbTnlCfg == NULLP)
1931 /* copying to DuCb Tnl Cfg */
1932 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1933 if(*ueCbTnlCfg == NULLP)
1935 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1939 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1940 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1941 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1942 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1943 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1944 if(f1TnlCfg->tnlCfg1)
1946 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1948 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1949 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1951 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1955 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1956 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1957 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1958 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1963 /*******************************************************************
1965 * @brief Processing the tunnel Request to EGTP
1969 * Function : duProcEgtpTunnelCfg
1971 * Functionality: Processing the tunnel Request to EGTP
1973 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1974 * @return ROK - success
1977 * ****************************************************************/
1979 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1981 uint8_t ret = RFAILED, delIdx;
1983 if(f1TnlCfg->tnlCfg1 == NULLP)
1985 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1989 if(f1TnlCfg->configType == CONFIG_ADD)
1991 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1993 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2000 else if(f1TnlCfg->configType == CONFIG_MOD)
2002 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2004 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2010 else if(f1TnlCfg->configType == CONFIG_DEL)
2012 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2014 /* Free memory at drbIdx */
2015 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
2016 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
2018 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2020 /* moving all elements one index ahead */
2021 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2032 /***********************************************************************
2034 * @brief Function to fill Tunnel Config
2035 * and sends tunnel Req to EGTP
2040 * Function : duUpdateTunnelCfgDb
2042 * Functionality: Function to fill tunnel Config
2043 * and sends tunnel Cfg Req to EGTP
2045 * @params[in] ueIdx, cellId, DuUeCfg
2046 * @return ROK - success
2049 * ****************************************************************/
2051 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2053 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2054 bool drbFound = false;
2056 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2057 /*then update drbId and tunnel Info in duCb */
2058 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2060 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2061 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2062 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2064 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2066 drbFound = true; /* existing DRB */
2067 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2069 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2070 duUeCfg->upTnlInfo[drbIdx].drbId);
2078 if(!drbFound && ret == ROK)/* new DRB to Add */
2080 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2082 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2083 duUeCfg->upTnlInfo[drbIdx].drbId);
2094 /*******************************************************************
2096 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2101 * Function : duUpdateDuUeCbCfg
2103 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2105 * @params[in] ueIdx, cellIdx
2106 * @return ROK - success
2109 * ****************************************************************/
2111 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2113 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2114 DuUeCb *ueCb = NULLP;
2116 GET_CELL_IDX(cellId, cellIdx);
2118 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2119 macUeCfgState == UE_RECFG_COMPLETE) &&
2120 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2121 rlcUeCfgState == UE_RECFG_COMPLETE))
2123 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2125 /*Filling RLC Ue Cfg */
2126 ueCb->rlcUeCfg.cellId = cellId;
2127 ueCb->rlcUeCfg.ueIdx = ueIdx;
2128 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2131 /*Filling MAC Ue Cfg */
2132 GET_CRNTI(crnti, ueIdx);
2133 ueCb->macUeCfg.cellId = cellId;
2134 ueCb->macUeCfg.ueIdx = ueIdx;
2135 ueCb->macUeCfg.crnti = crnti;
2136 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2138 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2141 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2143 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2149 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2156 /*******************************************************************
2158 * @brief Handle UE config response from MAC
2162 * Function : DuProcMacUeCfgRsp
2164 * Functionality: Handle UE Config response from MAC
2166 * @params[in] Pointer to MacUeCfgRsp and Pst
2167 * @return ROK - success
2170 * ****************************************************************/
2171 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2177 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2179 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2181 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2182 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2183 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2185 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2187 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2188 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2189 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2190 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2192 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2198 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2199 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2201 //TODO: Send the failure case in Ue Context Setup Response
2205 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2209 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2216 /*******************************************************************
2218 * @brief Processes UE create Req to RLC UL
2222 * Function : duBuildAndSendUeCreateReqToRlc
2225 * Processes UE create Req to RLC UL
2227 * @params[in] cellId,
2229 * Pointer to RlcUeCfg
2230 * @return ROK - success
2233 *****************************************************************/
2235 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2236 RlcUeCfg *duRlcUeCfg)
2239 RlcUeCfg *rlcUeCfg = NULLP;
2242 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2245 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2249 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2250 /* Copying ueCfg to a sharable buffer */
2251 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2254 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2255 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2256 /* Processing one Ue at a time to RLC */
2257 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2258 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2261 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2262 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2268 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2274 /*******************************************************************
2276 * @brief Processes UE create Rsp received from RLC UL
2281 * Function : DuProcRlcUeCfgRsp
2284 * Processes UE create Rsp received from RLC UL
2286 * @params[in] Post structure
2287 * Pointer to RlcCfgCfm
2288 * @return ROK - success
2291 *****************************************************************/
2292 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2298 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2300 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2302 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2303 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2304 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2306 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2308 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2309 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2310 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2311 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2313 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2319 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2320 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2321 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2323 //TODO: update failure case in ue Context setup Response
2327 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2331 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2337 /*******************************************************************
2339 * @brief Builds and Send Ue Reconfig Req to RLC
2343 * Function : duBuildAndSendUeReCfgReqToRLC
2345 * Functionality: Builds and Send Ue Reconfig Req to RLC
2347 * @params[in] cellId, crnti
2349 * RlcUeCfg *rlcUeCfg
2350 * @return ROK - success
2353 * ****************************************************************/
2355 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2357 uint8_t ret = ROK, ueIdx = 0;
2358 RlcUeCfg *rlcUeCfg = NULLP;
2360 GET_UE_IDX(crnti, ueIdx);
2361 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2364 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2365 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2367 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2369 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2373 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2379 /*******************************************************************
2381 * @brief Builds and Send Ue Reconfig Req to MAC
2385 * Function : duBuildAndSendUeReCfgReqToMac
2387 * Functionality: Builds and Send Ue Reconfig Req to MAC
2389 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2391 * MacUeCfg *macUeCfg
2392 * @return ROK - success
2395 * ****************************************************************/
2397 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2399 uint8_t ret, ueIdx = 0;
2400 MacUeCfg *macUeCfg = NULLP;
2403 GET_UE_IDX(crnti, ueIdx);
2405 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2408 memset(macUeCfg, 0, sizeof(MacUeCfg));
2409 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2411 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2413 ret = sendUeReCfgReqToMac(macUeCfg);
2417 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2423 /*******************************************************************
2425 * @brief Build and Send Ue context setup request
2430 * Function : duBuildAndSendUeContextSetupReq
2433 * Build and Send Ue context setup request
2435 * @params[in] cellId, crnti, DuUeCfg pointer
2436 * @return ROK - success
2439 *****************************************************************/
2441 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2445 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2446 /* Filling RLC Ue Reconfig */
2447 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2449 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2451 /* Filling MAC Ue Reconfig */
2452 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2454 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2459 /*******************************************************************
2461 * @brief Processes DL Rsp received from RLC DL
2466 * Function : DuProcRlcDlRrcMsgRsp
2469 * Processes UE Rsp received from RLC DL
2471 * @params[in] Post structure
2472 * Pointer to RlcCfgCfm
2473 * @return ROK - success
2476 *****************************************************************/
2477 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2479 uint8_t ret = ROK, ueIdx = 0;
2480 DuUeCb *ueCb = NULLP;
2482 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2484 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2485 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2486 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2488 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2490 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2492 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2494 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2496 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2498 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2503 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2505 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2508 /*******************************************************************
2510 * @brief Process UE context setup request from CU
2514 * Function : duProcUeContextSetupRequest
2516 * Functionality: Process UE context setup request from CU
2518 * @params[in] F1AP message
2519 * @return ROK - success
2522 * ****************************************************************/
2524 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2526 uint8_t ret, cellId;
2531 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2532 /* Send DL RRC msg for security Mode */
2533 if(ueCb->f1UeDb->dlRrcMsg)
2535 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2537 /* Sending DL RRC Message to RLC */
2538 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2541 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2542 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2543 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2544 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2548 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2550 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2553 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2559 //TODO: To send the failure cause in UeContextSetupRsp
2560 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2565 /*******************************************************************
2567 * @brief Build and Send Ue context mod request
2572 * Function : duBuildAndSendUeContextModReq
2575 * Build and Send Ue context mod request
2577 * @params[in] cellId, crnti, DuUeCfg pointer
2578 * @return ROK - success
2581 *****************************************************************/
2583 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2587 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod 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 duBuildAndSendUeContextModReq()");
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 duBuildAndSendUeContextModReq()");
2600 /*******************************************************************
2602 * @brief Processing Ue context mod request
2607 * Function : duProcUeContextModReq
2610 * Processing Ue context mod request
2612 * @params[in] DuUeCb *ueCb
2613 * @return ROK - success
2616 *****************************************************************/
2618 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2620 uint8_t ret, cellId;
2625 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2626 /* Send DL RRC msg for security Mode */
2627 if(ueCb->f1UeDb->dlRrcMsg)
2629 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2631 /* Sending DL RRC Message to RLC */
2632 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2635 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2636 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2637 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2638 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2644 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2647 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2653 //TODO: To send the failure cause in UeContextModRsp
2654 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2659 /*******************************************************************
2661 * @brief Function to delete Pdsch ServCellCfg
2665 * Function : deletePdschServCellCfg
2667 * Functionality: Function to delete Pdsch ServCellCfg
2669 * @params[in] PdschServCellCfg *pdschServCellCfg
2672 * ****************************************************************/
2674 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2676 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2677 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2678 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2679 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2682 /*******************************************************************
2684 * @brief delete MacUeCfg from duCb
2688 * Function : deleteMacUeCfg
2690 * Functionality: delete MacUeCfg from duCb
2692 * @params[in] Pointer to MacUeCfg
2693 * @return ROK - success
2696 *******************************************************************/
2698 void deleteMacUeCfg(MacUeCfg *ueCfg)
2702 ServCellCfgInfo *servCellCfg;
2703 PucchResrcInfo *resrcToAddModList;
2707 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2708 if(ueCfg->spCellCfgPres)
2710 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2711 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2712 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrcSet,\
2713 sizeof(PucchResrcSetCfg));
2714 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2716 /*freeing the PucchResrcCfg*/
2717 for(resrcIdx= 0; resrcIdx< servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModListCount; resrcIdx++)
2719 resrcToAddModList=&servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModList[resrcIdx];
2720 switch(resrcToAddModList->pucchFormat)
2722 case PUCCH_FORMAT_0:
2724 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format0 ,\
2725 sizeof(PucchFormat0));
2728 case PUCCH_FORMAT_1:
2730 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format1 ,\
2731 sizeof(PucchFormat1));
2734 case PUCCH_FORMAT_2:
2736 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format2 ,\
2737 sizeof(PucchFormat2_3));
2740 case PUCCH_FORMAT_3:
2742 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format3 ,\
2743 sizeof(PucchFormat2_3));
2746 case PUCCH_FORMAT_4:
2748 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format4 ,\
2749 sizeof(PucchFormat4));
2754 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrc,\
2755 sizeof(PucchResrcCfg));
2757 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format1,\
2758 sizeof(PucchFormatCfg));
2759 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format2,\
2760 sizeof(PucchFormatCfg));
2761 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format3,\
2762 sizeof(PucchFormatCfg));
2763 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format4,\
2764 sizeof(PucchFormatCfg));
2765 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.schedReq,\
2766 sizeof(PucchSchedReqCfg));
2767 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.multiCsiCfg,\
2768 sizeof(PucchMultiCsiCfg));
2769 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.spatialInfo,\
2770 sizeof(PucchSpatialCfg));
2771 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck ,\
2772 sizeof(PucchDlDataToUlAck));
2773 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.powerControl,\
2774 sizeof(PucchPowerControl));
2775 deletePdschServCellCfg(&servCellCfg->pdschServCellCfg);
2777 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2779 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].drbQos, sizeof(DrbQosInfo));
2780 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].snssai, sizeof(Snssai));
2783 memset(ueCfg, 0, sizeof(MacUeCfg));
2786 /*******************************************************************
2788 * @brief delete UE Configuration of a particular UE
2792 * Function : deleteUeCfg
2794 * Functionality: delete UE Configuration of a particular UE
2796 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2797 * @return ROK - success
2800 * ****************************************************************/
2801 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2803 DuUeCb *ueCb = NULLP;
2804 if(duCb.actvCellLst[cellIdx] != NULLP)
2806 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2807 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2809 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2810 deleteMacUeCfg(&ueCb->macUeCfg);
2811 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2812 if(ueCb->f1UeDb !=NULLP)
2814 freeF1UeDb(ueCb->f1UeDb);
2816 duCb.actvCellLst[cellIdx]->numActvUes--;
2817 memset(ueCb, 0, sizeof(DuUeCb));
2821 DU_LOG("INFO --> DU APP : deleteUeCfg(): MAC or RLC UE configuration state not UE_DELETE_COMPLETE");
2827 DU_LOG("ERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2834 /*******************************************************************
2836 * @brief Handle UE delete response from MAC
2840 * Function : DuProcMacUeDeleteRsp
2842 * Functionality: Handle UE delete response from MAC
2844 * @params[in] Pointer to MacUeDeleteRsp and Pst
2845 * @return ROK - success
2848 * ****************************************************************/
2850 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2852 uint8_t ueIdx = 0,ret =ROK;
2854 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId =0;
2858 if(deleteRsp->result == SUCCESS)
2860 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueIdx);
2861 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2862 ueIdx = deleteRsp->ueIdx;
2863 if(duCb.actvCellLst[cellIdx])
2865 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueIdx -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2866 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
2867 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
2868 if(deleteUeCfg(cellIdx, ueIdx) == ROK)
2870 ret = BuildAndSendUeContextReleaseComplete(gnbCuUeF1apId, gnbDuUeF1apId);
2873 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2880 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2884 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2888 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2894 /*******************************************************************
2896 * @brief Processes UE Delete Rsp received from RLC
2900 * Function : DuProcRlcUeDeleteRsp
2903 * Processes UE Delete Rsp received from RLC
2905 * @params[in] Post structure
2906 * Pointer to RlcUeDeleteRsp
2907 * @return ROK - success
2910 * *****************************************************************/
2912 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2914 uint8_t ueIdx = 0, ret = ROK;
2915 uint16_t cellIdx = 0;
2916 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId =0;
2920 ueIdx = delRsp->ueIdx;
2921 GET_CELL_IDX(delRsp->cellId, cellIdx);
2923 if(delRsp->result == SUCCESSFUL)
2925 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueIdx);
2926 if(duCb.actvCellLst[cellIdx]!=NULLP)
2928 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2929 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
2930 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
2931 if(deleteUeCfg(cellIdx, ueIdx) == ROK)
2933 ret = BuildAndSendUeContextReleaseComplete(gnbCuUeF1apId, gnbDuUeF1apId);
2936 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2943 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueIdx);
2946 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2952 /*******************************************************************
2954 * @brief Sending UE Delete Req To Mac
2958 * Function : sendUeDeleteReqToMac
2961 * sending UE Delete Req To Mac
2963 * @params[in] cellId, ueIdx, crnti
2964 * @return ROK - success
2967 *****************************************************************/
2969 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueIdx, uint16_t crnti)
2973 MacUeDelete *ueDelete = NULLP;
2975 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2978 ueDelete->cellId = cellId;
2979 ueDelete->ueIdx = ueIdx;
2980 ueDelete->crnti = crnti;
2981 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2983 /* Processing one Ue at a time to MAC */
2984 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2985 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2988 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2989 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2994 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3000 /*******************************************************************
3002 * @brief Sending UE Delete Req To Rlc
3006 * Function : sendUeDeleteReqToRlc
3009 * Sending UE Delete Req To Rlc
3011 * @params[in] cellId, ueIdx
3012 * @return ROK - success
3015 *****************************************************************/
3017 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueIdx)
3021 RlcUeDelete *ueDelete;
3023 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3024 if(ueDelete !=NULLP)
3026 ueDelete->cellId = cellId;
3027 ueDelete->ueIdx = ueIdx;
3028 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3030 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3033 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3034 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3039 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3045 /*******************************************************************
3047 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3051 * Function : duProcUeDeleteReq
3053 * Functionality: DU processes UE delete req from CU and sends to MAC
3056 * @params[in] cellId, crnti
3057 * @return ROK - success
3060 * ****************************************************************/
3062 uint8_t duProcUeDeleteReq(uint16_t cellId)
3064 uint8_t ueIdx = 0, ueId =0;
3065 uint16_t cellIdx = 0, crnti = 0;
3067 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3068 GET_CELL_IDX(cellId, cellIdx);
3069 GET_CRNTI(crnti,ueIdx);
3071 if(duCb.actvCellLst[cellIdx] != NULLP)
3073 for(ueIdx =0;ueIdx< duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
3076 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3078 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq():Failed to build UE delete req for RLC ");
3082 GET_CRNTI(crnti,ueId);
3083 if(sendUeDeleteReqToMac(cellId, ueId, crnti) == RFAILED)
3085 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Failed to build UE delete req for MAC ");
3092 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Cell Id is not found");
3099 /*******************************************************************
3101 * @brief delete RlcUeCfg from duCb
3105 * Function : deleteRlcUeCfg
3108 * delete RlcUeCfg from duCb
3110 * @params[in] RlcUeCfg *ueCfg
3112 * @return ROK - success
3115 *****************************************************************/
3117 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3120 RlcBearerCfg *lcCfg= NULLP;
3123 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3125 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3126 switch(lcCfg->rlcMode)
3130 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3133 case RLC_UM_BI_DIRECTIONAL :
3135 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3138 case RLC_UM_UNI_DIRECTIONAL_UL :
3140 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3143 case RLC_UM_UNI_DIRECTIONAL_DL :
3145 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3150 memset(ueCfg, 0, sizeof(RlcUeCfg));
3154 /*******************************************************************
3156 * @brief Delete DU CellCb information
3160 * Function : deleteDuCellCb
3162 * Functionality: Delete DU CellCb information
3164 * @params[in] DuCellCb *cellCb
3165 * @return ROK - success
3168 * ****************************************************************/
3170 void deleteDuCellCb(DuCellCb *cellCb)
3173 if(cellCb->duMacCellCfg)
3175 if(cellCb->duMacCellCfg->prachCfg.fdm[0].unsuedRootSeq)
3177 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellCb->duMacCellCfg->prachCfg.fdm[0].unsuedRootSeq,\
3178 cellCb->duMacCellCfg->prachCfg.fdm[0].numUnusedRootSeq);
3180 if(cellCb->duMacCellCfg->sib1Cfg.sib1Pdu)
3182 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,cellCb->duMacCellCfg->sib1Cfg.sib1Pdu,\
3183 cellCb->duMacCellCfg->sib1Cfg.sib1PduLen);
3185 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellCb->duMacCellCfg, sizeof(MacCellCfg));
3187 memset(cellCb, 0, sizeof(DuCellCb));
3191 /*******************************************************************
3193 * @brief Handle Cell delete response from MAC
3197 * Function : DuProcMacCellDeleteRsp
3199 * Functionality: Handle Cell delete response from MAC
3201 * @params[in] Pointer to MacCellDeleteRsp and Pst
3202 * @return ROK - success
3205 * ****************************************************************/
3207 uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *deleteRsp)
3213 if(deleteRsp->result == SUCCESSFUL_RSP)
3215 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3216 DU_LOG("\nINFO --> DU APP : MAC CELL Delete Response : SUCCESS [CELL IDX : %d]", deleteRsp->cellId);
3217 if(duCb.actvCellLst[cellIdx]->cellId == deleteRsp->cellId)
3219 deleteDuCellCb(duCb.actvCellLst[cellIdx]);
3220 duCb.numActvCells--;
3221 DU_FREE(duCb.actvCellLst[cellIdx], sizeof(DuCellCb));
3225 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): CellId [%d] doesnot exist", deleteRsp->cellId);
3231 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): MAC CELL Delete Response : FAILED\
3232 [CELL IDX : %d]", deleteRsp->cellId);
3235 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3239 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): Received MAC cell delete response is NULL");
3245 /*******************************************************************
3247 * @brief Sending Cell Delete Req To Mac
3251 * Function : sendCellDeleteReqToMac
3254 * sending Cell Delete Req To Mac
3256 * @params[in] uint16_t cellId
3257 * @return ROK - success
3261 *****************************************************************/
3263 uint8_t sendCellDeleteReqToMac(uint16_t cellId)
3267 MacCellDelete *cellDelete = NULLP;
3269 DU_ALLOC(cellDelete, sizeof(MacCellDelete));
3272 cellDelete->cellId = cellId;
3273 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_DELETE_REQ);
3275 DU_LOG("\nINFO --> DU APP : Sending Cell Delete Request to MAC");
3276 /* Processing one Cell at a time to MAC */
3277 ret = (*packMacCellDeleteReqOpts[pst.selector])(&pst, cellDelete);
3280 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to send Cell delete Req to MAC");
3281 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDelete));
3286 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to allocate memory");
3292 /*******************************************************************
3294 * @brief DU preocess Cell Delete Req to MAC
3298 * Function : duProcCellDeleteReq
3300 * Functionality: DU process Cell Delete Req to MAC
3302 * @params[in] uint16_t cellId
3303 * @return ROK - success
3306 * ****************************************************************/
3308 uint8_t duProcCellDeleteReq(uint16_t cellId)
3310 uint16_t cellIdx = 0;
3312 DU_LOG("\nINFO --> DU APP : Processing Cell Delete Request ");
3313 GET_CELL_IDX(cellId, cellIdx);
3315 if(duCb.actvCellLst[cellIdx] != NULLP)
3317 if(duBuildAndSendMacCellStop() == RFAILED)
3319 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Failed to process Cell delete req for cellId[%d]",cellId);
3323 if(duCb.actvCellLst[cellIdx]->numActvUes)
3325 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Active UEs present Failed to process cell Delete\
3326 Req for cellID[%d]", cellId);
3329 if(sendCellDeleteReqToMac(cellId) == RFAILED)
3331 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Failed to build and send Cell delete req for MAC for\
3332 cellId[%d]",cellId);
3338 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): CellId[%d] is not found", cellId);
3345 /**********************************************************************
3347 ***********************************************************************/