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 dlDataMsgInfo->dlMsg = egtpMsg->msg;
181 dlDataMsgInfo->msgLen = msgLen;
183 /* Filling DL DATA Msg Info */
184 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
186 /* Filling post structure and sending msg */
187 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
188 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
189 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
193 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
194 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
195 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
200 /*******************************************************************
202 * @brief Handles EGTP data from CU
206 * Function : duHdlEgtpData
209 * Processes EGTP header and sends data to RLC
211 * @params[in] Pointer to EGTP Message
212 * @return ROK - success
215 * ****************************************************************/
216 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
219 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
223 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
226 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
227 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
229 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
230 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
236 /******************************************************************
238 * @brief Builds and Sends DL CCCH Ind to MAC
242 * Function : duBuildAndSendDlCcchInd
244 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
246 * @params[in] dlCcchMsg - uint8_t*
247 * @return ROK - success
250 * ****************************************************************/
251 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
252 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
256 DlCcchIndInfo *dlCcchIndInfo = NULLP;
259 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
261 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
265 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
269 dlCcchIndInfo->cellId = *cellId;
270 dlCcchIndInfo->crnti = *crnti;
271 dlCcchIndInfo->msgType = msgType;
272 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
274 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
275 if(!dlCcchIndInfo->dlCcchMsg)
277 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
278 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
281 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
283 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
285 DU_FREE(dlCcchMsg, dlCcchMsgSize);
288 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
289 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
292 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
293 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
294 dlCcchIndInfo->dlCcchMsgLen);
295 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
296 sizeof(DlCcchIndInfo));
304 /*******************************************************************
306 * @brief Build and Send DL RRC Message transfer to RLC
310 * Function : duBuildAndSendDlRrcMsgToRlc
313 * Build and Send DL RRC Message transfer to RLC
315 * @params[in] Cell ID
317 * Logical Channgel ID
320 * @return ROK - success
323 * ****************************************************************/
324 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
329 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
333 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
337 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
340 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
341 duBuildAndSendDlRrcMsgToRlc");
342 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
346 /* Filling up the RRC msg info */
347 dlRrcMsgInfo->cellId = cellId;
348 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
349 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
351 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
353 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
354 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
355 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
356 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
360 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
361 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
362 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
363 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
365 /* Filling post structure and sending msg */
366 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
367 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
368 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
371 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
372 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
381 /******************************************************************
383 * @brief Process DL RRC Msg recevied from F1AP
387 * Function : duProcDlRrcMsg
389 * Functionality: Process DL RRC Msg recevied from F1AP
391 * @params[in] dlCcchMsg - uint8_t*
392 * @return ROK - success
395 * ****************************************************************/
397 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
400 uint16_t crnti, cellId, cellIdx;
401 bool ueCcchCtxtFound = false;
402 bool ueFound = false;
406 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
408 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
410 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
412 ueCcchCtxtFound = true;
413 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
414 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
421 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
424 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
428 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
430 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
433 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
434 duCb.ueCcchCtxt[ueIdx].cellId);
439 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
446 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
448 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
450 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
451 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
454 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
455 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
468 /******************************************************************
470 * @brief Generates GNB DU Ue F1AP ID
474 * Function : genGnbDuUeF1apId
476 * Functionality: Generates GNB DU Ue F1AP ID
479 * @return gnbDuF1apId
481 * ****************************************************************/
482 uint32_t genGnbDuUeF1apId()
484 static uint32_t gnbDuUeF1apId = 0;
486 return ++gnbDuUeF1apId;
489 /******************************************************************
491 * @brief Processes UL CCCH Ind recvd from MAC
495 * Function : duProcUlCcchInd
497 * Functionality: Processes UL CCCH Ind recvd from MAC
499 * @params[in] UlCcchIndInfo *ulCcchIndInfo
500 * @return ROK - success
503 * ****************************************************************/
504 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
508 uint32_t gnbDuUeF1apId = 0;
510 gnbDuUeF1apId = genGnbDuUeF1apId();
512 /* Store Ue mapping */
513 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
514 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
515 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
519 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
520 ulCcchIndInfo->ulCcchMsg));
523 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
526 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
527 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
533 /******************************************************************
535 * @brief Fills Default UL LC Cfg
539 * Function : fillDefaultUlLcCfg
541 * Functionality: Fills Default UL LC Cfg
543 * @params[in] UlLcCfg *ulLcCfg
545 *****************************************************************/
546 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
548 ulLcCfg->priority = LC_PRIORITY_1;
549 ulLcCfg->lcGroup = 0;
550 ulLcCfg->schReqId = 0;
551 ulLcCfg->pbr = PBR_KBPS_INFINITY;
552 ulLcCfg->bsd = BSD_MS_1000;
555 /******************************************************************
557 * @brief Fills Initial DL Bandwidth Part
561 * Function : fillDefaultInitDlBwp
563 * Functionality: Fills Initial DL Bandwidth Part
565 * @params[in] InitialDlBwp *initDlBwp
568 *****************************************************************/
569 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
572 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
573 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
578 /* Filling PDCCH Config */
579 initDlBwp->pdcchPresent = TRUE;
580 if(initDlBwp->pdcchPresent)
582 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
583 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
584 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
586 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
587 PDCCH_CTRL_RSRC_SET_ONE_ID;
588 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
590 coreset0EndPrb = CORESET0_END_PRB;
591 coreset1StartPrb = coreset0EndPrb +6;
592 coreset1NumPrb = CORESET1_NUM_PRB;
593 /* calculate the PRBs */
594 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
595 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
598 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
599 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
600 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
601 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
602 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
604 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
607 initDlBwp->pdcchCfg.numCRsetToRel = 0;
608 /* Filling Serach Space */
609 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
610 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
611 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
613 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
614 PDCCH_SRCH_SPC_TWO_ID;
615 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
616 PDCCH_CTRL_RSRC_SET_ONE_ID;
617 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
618 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
619 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
620 MONITORING_SYMB_WITHIN_SLOT_SIZE);
621 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
622 PDCCH_SYMBOL_WITHIN_SLOT;
623 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
625 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
627 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
629 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
631 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
633 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
634 SEARCHSPACETYPE_PR_UE_SPECIFIC;
635 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
636 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
638 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
642 /* Filling PDSCH Config */
643 initDlBwp->pdschPresent = TRUE;
644 if(initDlBwp->pdschPresent)
646 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
647 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
648 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
649 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
651 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
652 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
653 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
654 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
655 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
656 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
657 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
658 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
664 /******************************************************************
666 * @brief Fills Initial UL Bandwidth Part
670 * Function : fillDefaultInitUlBwp
672 * Functionality: Fills Initial UL Bandwidth Part
674 * @params[in] InitialUlBwp *initUlBwp
677 *****************************************************************/
678 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
683 initUlBwp->pucchPresent = FALSE;
685 /*Filling PUSCH Config */
686 initUlBwp->puschPresent = TRUE;
687 if(initUlBwp->puschPresent)
689 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
690 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
691 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
692 scramblingId0 = SCRAMBLING_ID;
693 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
694 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
696 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
698 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
699 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
701 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
702 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
703 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
704 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
706 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
711 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
715 /******************************************************************
717 * @brief Fills SpCell Group Info
721 * Function : fillDefaultSpCellGrpInfo
723 * Functionality: Fills Sp Cell Group Info
725 * @params[in] SpCellCfg *spCell
728 *****************************************************************/
729 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
733 spCell->servCellIdx = SERV_CELL_IDX;
734 /* Filling Initial Dl Bwp */
735 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
737 spCell->servCellCfg.numDlBwpToAdd = 0;
738 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
739 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
740 spCell->servCellCfg.bwpInactivityTmr = NULLP;
741 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
742 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
743 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
744 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
745 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
746 NUM_HARQ_PROC_FOR_PDSCH_N_16;
747 /* Filling Initial UL Bwp*/
748 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
749 spCell->servCellCfg.numUlBwpToAdd = 0;
750 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
754 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
758 /******************************************************************
760 * @brief Fills Physical Cell Group Info
764 * Function : fillDefaultPhyCellGrpInfo
766 * Functionality: Fills Physical Cell Group Info
768 * @params[in] PhyCellGrpCfg *cellGrp
771 *****************************************************************/
772 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
776 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
777 cellGrp->pNrFr1 = P_NR_FR1;
781 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
785 /******************************************************************
787 * @brief Fills Mac Cell Group Info
791 * Function : fillDefaultMacCellGrpInfo
793 * Functionality: Fills Mac Cell Group Info
795 * @params[in] MacCellGrpCfg *cellGrp
798 *****************************************************************/
799 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
805 /* Filling Scheduling Request Config */
806 cellGrp->schReqCfg.addModListCount = 1;
807 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
809 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
811 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
812 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
813 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
816 cellGrp->schReqCfg.relListCount = 0;
818 /* Filling Tag config */
819 cellGrp->tagCfg.addModListCount = 1;
820 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
822 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
824 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
825 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
828 cellGrp->tagCfg.relListCount = 0;
830 /* Filling BSR config */
831 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
832 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
833 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
835 /* Filling PHR config */
836 cellGrp->phrCfgSetupPres = true;
837 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
838 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
839 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
840 cellGrp->phrCfg.multiplePHR = false;
841 cellGrp->phrCfg.dummy = false;
842 cellGrp->phrCfg.phrType2OtherCell = false;
843 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
848 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
852 /*******************************************************************
854 * @brief Fills default modulation info for a UE
858 * Function : fillDefaultModulation
860 * Functionality: Fills default modulation info for a UE
862 * @params[in] Pointer to MAC UE configuration
863 * @return ROK - success
866 * ****************************************************************/
867 void fillDefaultModulation(MacUeCfg *ueCfg)
869 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
870 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
871 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
873 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
874 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
875 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
878 /******************************************************************
880 * @brief Function to fill Mac Lc Cfg for SRB1
884 * Function : fillMacSrb1LcCfg
886 * Functionality: Function to fill Mac Lc cfg for SRB1
888 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
890 *****************************************************************/
892 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
894 macLcCfg->lcId = SRB1_LCID;
895 macLcCfg->configType = CONFIG_ADD;
896 macLcCfg->drbQos = NULLP;
897 macLcCfg->snssai = NULLP;
898 macLcCfg->ulLcCfgPres = true;
899 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
902 /******************************************************************
904 * @brief Function to fill the Lc cfg from ueSetupReqDb
908 * Function : fillMacLcCfgToAddMod
910 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
912 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
913 * @return ROK/RFAILED
915 *****************************************************************/
917 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
920 lcCfg->lcId = ueSetReqDb->lcId;
921 lcCfg->configType = ueSetReqDb->configType;
923 if(ueSetReqDb->drbQos)
927 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
930 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
936 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
941 lcCfg->drbQos = NULLP;
946 if(ueSetReqDb->snssai)
950 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
953 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
960 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
964 lcCfg->snssai = NULLP;
967 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
968 lcCfg->drbQos = NULLP;
974 lcCfg->snssai = NULLP;
976 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
977 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
978 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
982 /******************************************************************
984 * @brief Function to copy the Bit rate from ueSetupReqDb
988 * Function : fillAmbr
990 * Functionality: Function to copy bit Rate from ueSetupReqDb
992 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
993 * @return ROK/RFAILED
995 *****************************************************************/
997 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
1001 if(*macAmbr == NULLP)
1003 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
1004 if(*macAmbr == NULLP)
1006 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1010 memset(*macAmbr, 0, sizeof(AmbrCfg));
1011 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
1020 /******************************************************************
1022 * @brief Builds and Send UE ReConfig Request to MAC
1026 * Function : sendUeReCfgReqToMac
1028 * Functionality: Builds and Send UE ReConfig Request to MAC
1030 * @Params[in] MacUeCfg pointer
1031 * @return ROK - success
1034 * ****************************************************************/
1036 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1042 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1046 /* Processing one Ue at a time to MAC */
1047 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1048 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1051 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1052 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1057 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1063 /******************************************************************
1065 * @brief Function to return Drb LcId
1069 * Function : getDrbLcId
1071 * Functionality: Function to return Drb LcId
1073 * Returns: lcId - SUCCESS
1075 *****************************************************************/
1077 uint8_t getDrbLcId(uint32_t *drbBitMap)
1079 uint8_t bitMask = 1, bitPos = 0;
1080 bitPos = MIN_DRB_LCID;
1082 while(bitPos <= MAX_DRB_LCID)
1084 if((*drbBitMap & (bitMask << bitPos)) == 0)
1086 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1094 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1098 /******************************************************************
1100 * @brief Fills MacUeCfg structure
1104 * Function : fillMacUeCfg
1106 * Functionality: Fills MacUeCfg
1108 * @params[in] cellId, ueIdx, crnti,
1111 * @return ROK/RFAILED
1113 *****************************************************************/
1114 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1115 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1117 uint8_t ret, dbIdx, lcIdx, cellIdx;
1118 bool lcIdFound = false;
1119 MacUeCfg *duMacDb = NULLP;
1125 macUeCfg->cellId = cellId;
1126 macUeCfg->ueIdx = ueIdx;
1127 macUeCfg->crnti = crnti;
1128 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1129 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1130 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1131 macUeCfg->ambrCfg = NULLP;
1132 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1133 fillDefaultModulation(macUeCfg);
1138 /* Fetching MacDb from DuUeCb */
1139 GET_CELL_IDX(cellId, cellIdx);
1140 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1141 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1142 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1143 macUeCfg->cellId = cellId;
1144 macUeCfg->ueIdx = ueIdx;
1145 macUeCfg->crnti = crnti;
1146 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1149 if(macUeCfg->spCellCfgPres == true)
1151 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1153 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1154 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1156 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1158 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1159 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1162 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1163 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1166 /* Filling LC Context */
1167 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1169 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1171 /* Filling default UL LC config in MAC if not present */
1172 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1173 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1175 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1177 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1180 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1181 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1183 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1184 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1192 /* ADD/DEL CONFIG */
1193 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1201 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1204 }/*End of Outer FOR loop */
1209 /******************************************************************
1211 * @brief Fills Rlc AM Information
1215 * Function : fillDefaultAmInfo
1217 * Functionality: Fills Rlc AM Information
1219 * @params[in] AmBearerCfg *amCfg
1222 *****************************************************************/
1223 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1226 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1227 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1228 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1229 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1230 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1233 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1234 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1235 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1238 /******************************************************************
1240 * @brief Fills RLC UM Bi Directional Information
1244 * Function : fillDefaultUmBiInfo
1246 * Functionality: Fills RLC UM Bi Directional Information
1248 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1251 *****************************************************************/
1252 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1254 /* UL UM BI DIR INFO */
1255 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1256 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1258 /* DL UM BI DIR INFO */
1259 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1262 /******************************************************************
1264 * @brief Fills RLC UM Uni Directional UL Information
1268 * Function : fillDefaultUmUlInfo
1270 * Functionality: Fills RLC UM Uni Directional Info
1272 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1275 *****************************************************************/
1276 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1278 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1279 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1282 /******************************************************************
1284 * @brief Fills RLC UM Uni Directional DL Information
1288 * Function : fillDefaultUmDlInfo
1290 * Functionality: Fills RLC UM Uni Directional DL Info
1292 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1295 *****************************************************************/
1296 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1298 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1301 /******************************************************************
1303 * @brief Builds Rlc Mode Default Configuration
1307 * Function : fillDefaultRlcModeCfg
1309 * Functionality: Builds Rlc Mode Default Configuration
1311 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1312 * @return ROK/RFAILED
1314 *****************************************************************/
1316 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1327 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1329 fillDefaultAmInfo(lcCfg->u.amCfg);
1332 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1338 case RLC_UM_BI_DIRECTIONAL :
1340 if(!lcCfg->u.umBiDirCfg)
1342 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1343 if(lcCfg->u.umBiDirCfg)
1344 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1347 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1353 case RLC_UM_UNI_DIRECTIONAL_UL :
1355 if(!lcCfg->u.umUniDirUlCfg)
1357 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1358 if(lcCfg->u.umUniDirUlCfg)
1359 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1362 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1368 case RLC_UM_UNI_DIRECTIONAL_DL :
1370 if(!lcCfg->u.umUniDirDlCfg)
1372 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1373 if(lcCfg->u.umUniDirDlCfg)
1374 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1377 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1384 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1391 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1397 /*******************************************************************
1399 * @brief Function to fill Rlc Lc Cfg for SRB1
1403 * Function : fillRlcSrb1LcCfg
1406 * Function to fill Rlc Lc Cfg for SRB1
1408 * @params[in] Pointer to RlcBearerCfg
1409 * @return ROK/RFAILED
1411 *****************************************************************/
1413 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1417 rlcLcCfg->rbId = SRB1_LCID;
1418 rlcLcCfg->rbType = RB_TYPE_SRB;
1419 rlcLcCfg->lcId = SRB1_LCID;
1420 rlcLcCfg->lcType = LCH_DCCH;
1421 rlcLcCfg->rlcMode = RLC_AM;
1422 rlcLcCfg->configType = CONFIG_ADD;
1423 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1427 /*******************************************************************
1429 * @brief Processes UE ReConfig Req to RLC UL
1433 * Function : sendUeReCfgReqToRlc
1436 * Processes UE Reconfig Req to RLC UL
1438 * @params[in] Pointer to RlcUeCfg
1439 * @return ROK - success
1442 *****************************************************************/
1444 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1449 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1452 /* Processing one Ue at a time to RLC */
1453 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1454 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1457 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1458 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1463 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1469 /******************************************************************
1471 * @brief Fills RlcBearerCfg structure
1475 * Function : fillRlcUeCfg
1477 * Functionality: Fills Rlc Bearer Cfg
1480 *****************************************************************/
1481 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1482 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1484 uint8_t ret, dbIdx, lcIdx, cellIdx;
1485 bool lcIdFound = false;
1486 RlcUeCfg *duRlcDb = NULLP;
1491 /* Initial RB being Added */
1492 rlcUeCfg->cellId = cellId;
1493 rlcUeCfg->ueIdx = ueIdx;
1494 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1498 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1502 /* Fetch RlcDb from DuUeCb */
1503 GET_CELL_IDX(cellId, cellIdx);
1504 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1505 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1506 /*Filling RlcUeCfg */
1507 rlcUeCfg->cellId = cellId;
1508 rlcUeCfg->ueIdx = ueIdx;
1509 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1511 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1514 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1515 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1518 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1519 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1521 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1524 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1525 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1528 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1529 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1537 /* ADD/ DEL Config Type */
1538 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1546 /******************************************************************
1548 * @brief creates UE context
1552 * Function : duCreateUeCb
1554 * Functionality: Creates UE Conetxt
1556 * @params[in] UeCcchCtxt Pointer
1559 * @return ROK - success
1561 * ****************************************************************/
1562 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1564 uint8_t cellIdx = 0;
1568 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1570 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1572 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1573 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1575 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1576 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1577 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1578 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1579 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1580 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1582 /* Filling Mac Ue Config */
1583 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1584 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1585 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1587 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1589 /* Filling Rlc Ue Config */
1590 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1591 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1592 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1594 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1596 duCb.actvCellLst[cellIdx]->numActvUes++;
1597 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1603 /******************************************************************
1605 * @brief Builds and Send UE Create Request to MAC
1609 * Function : duBuildAndSendUeCreateReqToMac
1611 * Functionality: Builds and Send UE Create Request to MAC
1613 * @Params[in] cellId,
1615 * @return ROK - success
1618 * ****************************************************************/
1620 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1621 uint16_t crnti, MacUeCfg *duMacUeCfg)
1624 MacUeCfg *macUeCfg = NULLP;
1626 memset(&pst, 0, sizeof(Pst));
1629 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1632 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1636 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1638 /* Copying ueCb to a sharable buffer */
1639 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1642 memset(macUeCfg, 0, sizeof(MacUeCfg));
1643 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1644 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1646 /* Processing one Ue at a time to MAC */
1647 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1650 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1651 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1656 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1662 /*******************************************************************
1664 * @brief To update DuUeCb Mac Cfg
1668 * Function : duUpdateMacCfg
1669 * Functionality: update DuUeCb MAC Cfg
1671 * @params[in] DuUeCb Pointer
1672 * F1UeContextSetupDb pointer
1673 * @return ROK - success
1676 * ****************************************************************/
1677 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1679 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1680 MacUeCfg *oldMacUeCfg;
1683 /*Filling Cell Group Cfg*/
1684 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1687 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1689 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1690 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1692 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1694 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1695 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1697 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1699 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1700 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1701 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1704 /* Filling LC Context */
1705 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1707 numLcs = macUeCfg->numLcs;
1708 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1710 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1712 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1714 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1716 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1718 /* Free memory at matched lcIdx index */
1719 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1721 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1723 /* moving all elements one index ahead */
1724 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1725 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1728 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1735 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1737 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1740 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1750 /******************************************************************
1752 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1756 * Function : fillRlcCfgToAddMod
1758 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1761 *****************************************************************/
1763 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1765 lcCfg->configType = f1UeDbLcCfg->configType;
1766 lcCfg->rbId = f1UeDbLcCfg->rbId;
1767 lcCfg->rbType = f1UeDbLcCfg->rbType;
1768 lcCfg->lcId = f1UeDbLcCfg->lcId;
1769 lcCfg->lcType = f1UeDbLcCfg->lcType;
1770 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1771 switch(lcCfg->rlcMode)
1777 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1782 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1783 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1784 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1785 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1786 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1789 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1790 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1791 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1794 case RLC_UM_BI_DIRECTIONAL :
1796 if(!lcCfg->u.umBiDirCfg)
1798 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1799 if(!lcCfg->u.umBiDirCfg)
1802 /* UL UM BI DIR INFO */
1803 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1804 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1805 /* DL UM BI DIR INFO */
1806 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1809 case RLC_UM_UNI_DIRECTIONAL_UL :
1811 if(!lcCfg->u.umUniDirUlCfg)
1813 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1814 if(!lcCfg->u.umUniDirUlCfg)
1817 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1818 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1822 case RLC_UM_UNI_DIRECTIONAL_DL :
1824 if(!lcCfg->u.umUniDirDlCfg)
1826 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1827 if(!lcCfg->u.umUniDirDlCfg)
1830 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1834 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1840 /*******************************************************************
1842 * @brief To update DuUeCb Rlc Lc Cfg
1846 * Function : duUpdateRlcLcCfg
1847 * Functionality: update DuUeCb Rlc Lc Cfg
1849 * @params[in] DuUeCb Pointer
1850 * F1UeContextSetupDb pointer
1851 * @return ROK - success
1854 * ****************************************************************/
1856 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1858 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1861 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1863 numLcs = rlcUeCfg->numLcs;
1864 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1866 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1868 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1870 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1872 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1874 /* Free memory at matched lcIdx index */
1875 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1877 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1879 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1880 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1883 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1890 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1892 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1901 /*******************************************************************
1903 * @brief Function to fill Tunnel Config to Add/Mod
1908 * Function : fillTnlCfgToAddMod
1910 * Functionality: Function to fill tunnel Config to Add/Mod
1912 * @params[in] Pointer to tnlCfgDb,
1913 * pointer to f1TnlCfg
1914 * @return ROK - success
1917 * ****************************************************************/
1918 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1920 if(*ueCbTnlCfg == NULLP)
1922 /* copying to DuCb Tnl Cfg */
1923 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1924 if(*ueCbTnlCfg == NULLP)
1926 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1930 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1931 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1932 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1933 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1934 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1935 if(f1TnlCfg->tnlCfg1)
1937 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1939 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1940 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1942 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1946 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1947 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1948 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1949 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1954 /*******************************************************************
1956 * @brief Processing the tunnel Request to EGTP
1960 * Function : duProcEgtpTunnelCfg
1962 * Functionality: Processing the tunnel Request to EGTP
1964 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1965 * @return ROK - success
1968 * ****************************************************************/
1970 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1972 uint8_t ret = RFAILED, delIdx;
1974 if(f1TnlCfg->tnlCfg1 == NULLP)
1976 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1980 if(f1TnlCfg->configType == CONFIG_ADD)
1982 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1984 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1991 else if(f1TnlCfg->configType == CONFIG_MOD)
1993 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1995 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2001 else if(f1TnlCfg->configType == CONFIG_DEL)
2003 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2005 /* Free memory at drbIdx */
2006 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
2007 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
2009 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2011 /* moving all elements one index ahead */
2012 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2023 /***********************************************************************
2025 * @brief Function to fill Tunnel Config
2026 * and sends tunnel Req to EGTP
2031 * Function : duUpdateTunnelCfgDb
2033 * Functionality: Function to fill tunnel Config
2034 * and sends tunnel Cfg Req to EGTP
2036 * @params[in] ueIdx, cellId, DuUeCfg
2037 * @return ROK - success
2040 * ****************************************************************/
2042 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2044 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2045 bool drbFound = false;
2047 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2048 /*then update drbId and tunnel Info in duCb */
2049 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2051 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2052 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2053 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2055 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2057 drbFound = true; /* existing DRB */
2058 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2060 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2061 duUeCfg->upTnlInfo[drbIdx].drbId);
2069 if(!drbFound && ret == ROK)/* new DRB to Add */
2071 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2073 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2074 duUeCfg->upTnlInfo[drbIdx].drbId);
2085 /*******************************************************************
2087 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2092 * Function : duUpdateDuUeCbCfg
2094 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2096 * @params[in] ueIdx, cellIdx
2097 * @return ROK - success
2100 * ****************************************************************/
2102 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2104 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2105 DuUeCb *ueCb = NULLP;
2107 GET_CELL_IDX(cellId, cellIdx);
2109 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2110 macUeCfgState == UE_RECFG_COMPLETE) &&
2111 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2112 rlcUeCfgState == UE_RECFG_COMPLETE))
2114 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2116 /*Filling RLC Ue Cfg */
2117 ueCb->rlcUeCfg.cellId = cellId;
2118 ueCb->rlcUeCfg.ueIdx = ueIdx;
2119 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2122 /*Filling MAC Ue Cfg */
2123 GET_CRNTI(crnti, ueIdx);
2124 ueCb->macUeCfg.cellId = cellId;
2125 ueCb->macUeCfg.ueIdx = ueIdx;
2126 ueCb->macUeCfg.crnti = crnti;
2127 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2129 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2132 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2134 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2140 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2147 /*******************************************************************
2149 * @brief Handle UE config response from MAC
2153 * Function : DuProcMacUeCfgRsp
2155 * Functionality: Handle UE Config response from MAC
2157 * @params[in] Pointer to MacUeCfgRsp and Pst
2158 * @return ROK - success
2161 * ****************************************************************/
2162 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2168 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2170 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2172 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2173 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2174 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2176 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2178 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2179 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2180 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2181 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2183 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2189 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2190 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2192 //TODO: Send the failure case in Ue Context Setup Response
2196 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2200 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2207 /*******************************************************************
2209 * @brief Processes UE create Req to RLC UL
2213 * Function : duBuildAndSendUeCreateReqToRlc
2216 * Processes UE create Req to RLC UL
2218 * @params[in] cellId,
2220 * Pointer to RlcUeCfg
2221 * @return ROK - success
2224 *****************************************************************/
2226 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2227 RlcUeCfg *duRlcUeCfg)
2230 RlcUeCfg *rlcUeCfg = NULLP;
2233 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2236 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2240 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2241 /* Copying ueCfg to a sharable buffer */
2242 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2245 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2246 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2247 /* Processing one Ue at a time to RLC */
2248 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2249 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2252 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2253 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2259 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2265 /*******************************************************************
2267 * @brief Processes UE create Rsp received from RLC UL
2272 * Function : DuProcRlcUeCfgRsp
2275 * Processes UE create Rsp received from RLC UL
2277 * @params[in] Post structure
2278 * Pointer to RlcCfgCfm
2279 * @return ROK - success
2282 *****************************************************************/
2283 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2289 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2291 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2293 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2294 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2295 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2297 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2299 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2300 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2301 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2302 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2304 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2310 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2311 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2312 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2314 //TODO: update failure case in ue Context setup Response
2318 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2322 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2328 /*******************************************************************
2330 * @brief Builds and Send Ue Reconfig Req to RLC
2334 * Function : duBuildAndSendUeReCfgReqToRLC
2336 * Functionality: Builds and Send Ue Reconfig Req to RLC
2338 * @params[in] cellId, crnti
2340 * RlcUeCfg *rlcUeCfg
2341 * @return ROK - success
2344 * ****************************************************************/
2346 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2348 uint8_t ret = ROK, ueIdx = 0;
2349 RlcUeCfg *rlcUeCfg = NULLP;
2351 GET_UE_IDX(crnti, ueIdx);
2352 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2355 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2356 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2358 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2360 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2364 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2370 /*******************************************************************
2372 * @brief Builds and Send Ue Reconfig Req to MAC
2376 * Function : duBuildAndSendUeReCfgReqToMac
2378 * Functionality: Builds and Send Ue Reconfig Req to MAC
2380 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2382 * MacUeCfg *macUeCfg
2383 * @return ROK - success
2386 * ****************************************************************/
2388 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2390 uint8_t ret, ueIdx = 0;
2391 MacUeCfg *macUeCfg = NULLP;
2394 GET_UE_IDX(crnti, ueIdx);
2396 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2399 memset(macUeCfg, 0, sizeof(MacUeCfg));
2400 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2402 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2404 ret = sendUeReCfgReqToMac(macUeCfg);
2408 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2414 /*******************************************************************
2416 * @brief Build and Send Ue context setup request
2421 * Function : duBuildAndSendUeContextSetupReq
2424 * Build and Send Ue context setup request
2426 * @params[in] cellId, crnti, DuUeCfg pointer
2427 * @return ROK - success
2430 *****************************************************************/
2432 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2436 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2437 /* Filling RLC Ue Reconfig */
2438 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2440 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2442 /* Filling MAC Ue Reconfig */
2443 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2445 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2450 /*******************************************************************
2452 * @brief Processes DL Rsp received from RLC DL
2457 * Function : DuProcRlcDlRrcMsgRsp
2460 * Processes UE Rsp received from RLC DL
2462 * @params[in] Post structure
2463 * Pointer to RlcCfgCfm
2464 * @return ROK - success
2467 *****************************************************************/
2468 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2470 uint8_t ret = ROK, ueIdx = 0;
2471 DuUeCb *ueCb = NULLP;
2473 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2475 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2476 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2477 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2479 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2481 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2483 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2485 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2487 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2489 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2494 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2496 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2499 /*******************************************************************
2501 * @brief Process UE context setup request from CU
2505 * Function : duProcUeContextSetupRequest
2507 * Functionality: Process UE context setup request from CU
2509 * @params[in] F1AP message
2510 * @return ROK - success
2513 * ****************************************************************/
2515 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2517 uint8_t ret, cellId;
2522 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2523 /* Send DL RRC msg for security Mode */
2524 if(ueCb->f1UeDb->dlRrcMsg)
2526 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2528 /* Sending DL RRC Message to RLC */
2529 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2532 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2533 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2534 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2535 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2539 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2541 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2544 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2550 //TODO: To send the failure cause in UeContextSetupRsp
2551 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2556 /*******************************************************************
2558 * @brief Build and Send Ue context mod request
2563 * Function : duBuildAndSendUeContextModReq
2566 * Build and Send Ue context mod request
2568 * @params[in] cellId, crnti, DuUeCfg pointer
2569 * @return ROK - success
2572 *****************************************************************/
2574 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2578 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2579 /* Filling RLC Ue Reconfig */
2580 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2582 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2584 /* Filling MAC Ue Reconfig */
2585 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2587 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2591 /*******************************************************************
2593 * @brief Processing Ue context mod request
2598 * Function : duProcUeContextModReq
2601 * Processing Ue context mod request
2603 * @params[in] DuUeCb *ueCb
2604 * @return ROK - success
2607 *****************************************************************/
2609 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2611 uint8_t ret, cellId;
2616 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2617 /* Send DL RRC msg for security Mode */
2618 if(ueCb->f1UeDb->dlRrcMsg)
2620 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2622 /* Sending DL RRC Message to RLC */
2623 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2626 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2627 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2628 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2629 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2635 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2638 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2644 //TODO: To send the failure cause in UeContextModRsp
2645 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2650 /*******************************************************************
2652 * @brief Function to delete Pdsch ServCellCfg
2656 * Function : deletePdschServCellCfg
2658 * Functionality: Function to delete Pdsch ServCellCfg
2660 * @params[in] PdschServCellCfg *pdschServCellCfg
2663 * ****************************************************************/
2665 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2667 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2668 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2669 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2670 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2673 /*******************************************************************
2675 * @brief delete MacUeCfg from duCb
2679 * Function : deleteMacUeCfg
2681 * Functionality: delete MacUeCfg from duCb
2683 * @params[in] Pointer to MacUeCfg
2684 * @return ROK - success
2687 *******************************************************************/
2689 void deleteMacUeCfg(MacUeCfg *ueCfg)
2693 ServCellCfgInfo *servCellCfg;
2694 PucchResrcInfo *resrcToAddModList;
2698 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2699 if(ueCfg->spCellCfgPres)
2701 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2702 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2703 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrcSet,\
2704 sizeof(PucchResrcSetCfg));
2705 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2707 /*freeing the PucchResrcCfg*/
2708 for(resrcIdx= 0; resrcIdx< servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModListCount; resrcIdx++)
2710 resrcToAddModList=&servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModList[resrcIdx];
2711 switch(resrcToAddModList->pucchFormat)
2713 case PUCCH_FORMAT_0:
2715 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format0 ,\
2716 sizeof(PucchFormat0));
2719 case PUCCH_FORMAT_1:
2721 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format1 ,\
2722 sizeof(PucchFormat1));
2725 case PUCCH_FORMAT_2:
2727 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format2 ,\
2728 sizeof(PucchFormat2_3));
2731 case PUCCH_FORMAT_3:
2733 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format3 ,\
2734 sizeof(PucchFormat2_3));
2737 case PUCCH_FORMAT_4:
2739 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format4 ,\
2740 sizeof(PucchFormat4));
2745 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrc,\
2746 sizeof(PucchResrcCfg));
2748 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format1,\
2749 sizeof(PucchFormatCfg));
2750 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format2,\
2751 sizeof(PucchFormatCfg));
2752 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format3,\
2753 sizeof(PucchFormatCfg));
2754 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format4,\
2755 sizeof(PucchFormatCfg));
2756 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.schedReq,\
2757 sizeof(PucchSchedReqCfg));
2758 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.multiCsiCfg,\
2759 sizeof(PucchMultiCsiCfg));
2760 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.spatialInfo,\
2761 sizeof(PucchSpatialCfg));
2762 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck ,\
2763 sizeof(PucchDlDataToUlAck));
2764 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.powerControl,\
2765 sizeof(PucchPowerControl));
2766 deletePdschServCellCfg(&servCellCfg->pdschServCellCfg);
2768 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2770 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].drbQos, sizeof(DrbQosInfo));
2771 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].snssai, sizeof(Snssai));
2774 memset(ueCfg, 0, sizeof(MacUeCfg));
2777 /*******************************************************************
2779 * @brief delete UE Configuration of a particular UE
2783 * Function : deleteUeCfg
2785 * Functionality: delete UE Configuration of a particular UE
2787 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2788 * @return ROK - success
2791 * ****************************************************************/
2792 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2794 DuUeCb *ueCb = NULLP;
2795 if(duCb.actvCellLst[cellIdx] != NULLP)
2797 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2798 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2800 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2801 deleteMacUeCfg(&ueCb->macUeCfg);
2802 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2803 if(ueCb->f1UeDb !=NULLP)
2805 freeF1UeDb(ueCb->f1UeDb);
2807 duCb.actvCellLst[cellIdx]->numActvUes--;
2808 memset(ueCb, 0, sizeof(DuUeCb));
2812 DU_LOG("INFO --> DU APP : deleteUeCfg(): MAC or RLC UE configuration state not UE_DELETE_COMPLETE");
2818 DU_LOG("ERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2825 /*******************************************************************
2827 * @brief Handle UE delete response from MAC
2831 * Function : DuProcMacUeDeleteRsp
2833 * Functionality: Handle UE delete response from MAC
2835 * @params[in] Pointer to MacUeDeleteRsp and Pst
2836 * @return ROK - success
2839 * ****************************************************************/
2841 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2843 uint8_t ueIdx = 0,ret =ROK;
2845 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId =0;
2849 if(deleteRsp->result == SUCCESS)
2851 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueIdx);
2852 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2853 ueIdx = deleteRsp->ueIdx;
2854 if(duCb.actvCellLst[cellIdx])
2856 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueIdx -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2857 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
2858 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
2859 if(deleteUeCfg(cellIdx, ueIdx) == ROK)
2861 ret = BuildAndSendUeContextReleaseComplete(gnbCuUeF1apId, gnbDuUeF1apId);
2864 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2871 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2875 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2879 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2885 /*******************************************************************
2887 * @brief Processes UE Delete Rsp received from RLC
2891 * Function : DuProcRlcUeDeleteRsp
2894 * Processes UE Delete Rsp received from RLC
2896 * @params[in] Post structure
2897 * Pointer to RlcUeDeleteRsp
2898 * @return ROK - success
2901 * *****************************************************************/
2903 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2905 uint8_t ueIdx = 0, ret = ROK;
2906 uint16_t cellIdx = 0;
2907 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId =0;
2911 ueIdx = delRsp->ueIdx;
2912 GET_CELL_IDX(delRsp->cellId, cellIdx);
2914 if(delRsp->result == SUCCESSFUL)
2916 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueIdx);
2917 if(duCb.actvCellLst[cellIdx]!=NULLP)
2919 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2920 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
2921 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
2922 if(deleteUeCfg(cellIdx, ueIdx) == ROK)
2924 ret = BuildAndSendUeContextReleaseComplete(gnbCuUeF1apId, gnbDuUeF1apId);
2927 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2934 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueIdx);
2937 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2943 /*******************************************************************
2945 * @brief Sending UE Delete Req To Mac
2949 * Function : sendUeDeleteReqToMac
2952 * sending UE Delete Req To Mac
2954 * @params[in] cellId, ueIdx, crnti
2955 * @return ROK - success
2958 *****************************************************************/
2960 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueIdx, uint16_t crnti)
2964 MacUeDelete *ueDelete = NULLP;
2966 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2969 ueDelete->cellId = cellId;
2970 ueDelete->ueIdx = ueIdx;
2971 ueDelete->crnti = crnti;
2972 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2974 /* Processing one Ue at a time to MAC */
2975 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2976 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2979 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2980 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2985 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
2991 /*******************************************************************
2993 * @brief Sending UE Delete Req To Rlc
2997 * Function : sendUeDeleteReqToRlc
3000 * Sending UE Delete Req To Rlc
3002 * @params[in] cellId, ueIdx
3003 * @return ROK - success
3006 *****************************************************************/
3008 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueIdx)
3012 RlcUeDelete *ueDelete;
3014 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3015 if(ueDelete !=NULLP)
3017 ueDelete->cellId = cellId;
3018 ueDelete->ueIdx = ueIdx;
3019 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3021 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3024 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3025 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3030 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3036 /*******************************************************************
3038 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3042 * Function : duProcUeDeleteReq
3044 * Functionality: DU processes UE delete req from CU and sends to MAC
3047 * @params[in] cellId, crnti
3048 * @return ROK - success
3051 * ****************************************************************/
3053 uint8_t duProcUeDeleteReq(uint16_t cellId)
3055 uint8_t ueIdx = 0, ueId =0;
3056 uint16_t cellIdx = 0, crnti = 0;
3058 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3059 GET_CELL_IDX(cellId, cellIdx);
3060 GET_CRNTI(crnti,ueIdx);
3062 if(duCb.actvCellLst[cellIdx] != NULLP)
3064 for(ueIdx =0;ueIdx< duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
3067 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3069 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq():Failed to build UE delete req for RLC ");
3073 GET_CRNTI(crnti,ueId);
3074 if(sendUeDeleteReqToMac(cellId, ueId, crnti) == RFAILED)
3076 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Failed to build UE delete req for MAC ");
3083 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Cell Id is not found");
3090 /*******************************************************************
3092 * @brief delete RlcUeCfg from duCb
3096 * Function : deleteRlcUeCfg
3099 * delete RlcUeCfg from duCb
3101 * @params[in] RlcUeCfg *ueCfg
3103 * @return ROK - success
3106 *****************************************************************/
3108 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3111 RlcBearerCfg *lcCfg= NULLP;
3114 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3116 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3117 switch(lcCfg->rlcMode)
3121 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3124 case RLC_UM_BI_DIRECTIONAL :
3126 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3129 case RLC_UM_UNI_DIRECTIONAL_UL :
3131 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3134 case RLC_UM_UNI_DIRECTIONAL_DL :
3136 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3141 memset(ueCfg, 0, sizeof(RlcUeCfg));
3145 /*******************************************************************
3147 * @brief Delete DU CellCb information
3151 * Function : deleteDuCellCb
3153 * Functionality: Delete DU CellCb information
3155 * @params[in] DuCellCb *cellCb
3156 * @return ROK - success
3159 * ****************************************************************/
3161 void deleteDuCellCb(DuCellCb *cellCb)
3164 if(cellCb->duMacCellCfg)
3166 if(cellCb->duMacCellCfg->prachCfg.fdm[0].unsuedRootSeq)
3168 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellCb->duMacCellCfg->prachCfg.fdm[0].unsuedRootSeq,\
3169 cellCb->duMacCellCfg->prachCfg.fdm[0].numUnusedRootSeq);
3171 if(cellCb->duMacCellCfg->sib1Cfg.sib1Pdu)
3173 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,cellCb->duMacCellCfg->sib1Cfg.sib1Pdu,\
3174 cellCb->duMacCellCfg->sib1Cfg.sib1PduLen);
3176 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellCb->duMacCellCfg, sizeof(MacCellCfg));
3178 memset(cellCb, 0, sizeof(DuCellCb));
3182 /*******************************************************************
3184 * @brief Handle Cell delete response from MAC
3188 * Function : DuProcMacCellDeleteRsp
3190 * Functionality: Handle Cell delete response from MAC
3192 * @params[in] Pointer to MacCellDeleteRsp and Pst
3193 * @return ROK - success
3196 * ****************************************************************/
3198 uint8_t DuProcMacCellDeleteRsp(Pst *pst, MacCellDeleteRsp *deleteRsp)
3204 if(deleteRsp->result == SUCCESSFUL_RSP)
3206 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3207 DU_LOG("\nINFO --> DU APP : MAC CELL Delete Response : SUCCESS [CELL IDX : %d]", deleteRsp->cellId);
3208 if(duCb.actvCellLst[cellIdx]->cellId == deleteRsp->cellId)
3210 deleteDuCellCb(duCb.actvCellLst[cellIdx]);
3211 duCb.numActvCells--;
3212 DU_FREE(duCb.actvCellLst[cellIdx], sizeof(DuCellCb));
3216 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): CellId [%d] doesnot exist", deleteRsp->cellId);
3222 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): MAC CELL Delete Response : FAILED\
3223 [CELL IDX : %d]", deleteRsp->cellId);
3226 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3230 DU_LOG("\nERROR --> DU APP : DuProcMacCellDeleteRsp(): Received MAC cell delete response is NULL");
3236 /*******************************************************************
3238 * @brief Sending Cell Delete Req To Mac
3242 * Function : sendCellDeleteReqToMac
3245 * sending Cell Delete Req To Mac
3247 * @params[in] uint16_t cellId
3248 * @return ROK - success
3252 *****************************************************************/
3254 uint8_t sendCellDeleteReqToMac(uint16_t cellId)
3258 MacCellDelete *cellDelete = NULLP;
3260 DU_ALLOC(cellDelete, sizeof(MacCellDelete));
3263 cellDelete->cellId = cellId;
3264 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_DELETE_REQ);
3266 DU_LOG("\nINFO --> DU APP : Sending Cell Delete Request to MAC");
3267 /* Processing one Cell at a time to MAC */
3268 ret = (*packMacCellDeleteReqOpts[pst.selector])(&pst, cellDelete);
3271 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to send Cell delete Req to MAC");
3272 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cellDelete, sizeof(MacCellDelete));
3277 DU_LOG("\nERROR --> DU APP : sendCellDeleteReqToMac(): Failed to allocate memory");
3283 /*******************************************************************
3285 * @brief DU preocess Cell Delete Req to MAC
3289 * Function : duProcCellDeleteReq
3291 * Functionality: DU process Cell Delete Req to MAC
3293 * @params[in] uint16_t cellId
3294 * @return ROK - success
3297 * ****************************************************************/
3299 uint8_t duProcCellDeleteReq(uint16_t cellId)
3301 uint16_t cellIdx = 0;
3303 DU_LOG("\nINFO --> DU APP : Processing Cell Delete Request ");
3304 GET_CELL_IDX(cellId, cellIdx);
3306 if(duCb.actvCellLst[cellIdx] != NULLP)
3308 if(duBuildAndSendMacCellStop() == RFAILED)
3310 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Failed to process Cell delete req for cellId[%d]",cellId);
3314 if(duCb.actvCellLst[cellIdx]->numActvUes)
3316 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Active UEs present Failed to process cell Delete\
3317 Req for cellID[%d]", cellId);
3320 if(sendCellDeleteReqToMac(cellId) == RFAILED)
3322 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): Failed to build and send Cell delete req for MAC for\
3323 cellId[%d]",cellId);
3329 DU_LOG("\nERROR --> DU APP : duProcCellDeleteReq(): CellId[%d] is not found", cellId);
3336 /**********************************************************************
3338 ***********************************************************************/