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 */
94 /*******************************************************************
96 * @brief Function to fillDlUserDataInfo
100 * Function : fillDlUserDataInfo
103 * Function to fillDlUserDataInfo
108 * @return ROK - success
111 * ****************************************************************/
113 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
117 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
119 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
121 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
123 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
124 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
125 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
133 /*******************************************************************
135 * @brief Build and Send DL Data Message transfer to RLC
139 * Function : duBuildAndSendDlUserDataToRlc
142 * Build and Send DL Data Message transfer to RLC
144 * @params[in] Cell ID
146 * Logical Channgel ID
149 * @return ROK - success
152 * ****************************************************************/
154 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
156 uint8_t ret = RFAILED;
158 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
160 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
163 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
166 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
167 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &dlDataMsgInfo->dlMsg) != ROK)
169 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlMsg in duHdlEgtpDlData()");
170 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
173 dlDataMsgInfo->dlMsg = egtpMsg->msg;
174 dlDataMsgInfo->msgLen = msgLen;
176 /* Filling DL DATA Msg Info */
177 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
179 /* Filling post structure and sending msg */
180 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
181 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
182 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
186 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
187 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo->dlMsg, msgLen);
188 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
193 /*******************************************************************
195 * @brief Handles EGTP data from CU
199 * Function : duHdlEgtpData
202 * Processes EGTP header and sends data to RLC
204 * @params[in] Pointer to EGTP Message
205 * @return ROK - success
208 * ****************************************************************/
209 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
212 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
216 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
219 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
220 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
222 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
223 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
229 /******************************************************************
231 * @brief Builds and Sends DL CCCH Ind to MAC
235 * Function : duBuildAndSendDlCcchInd
237 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
239 * @params[in] dlCcchMsg - uint8_t*
240 * @return ROK - success
243 * ****************************************************************/
244 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
245 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
249 DlCcchIndInfo *dlCcchIndInfo = NULLP;
252 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
254 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
258 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
262 dlCcchIndInfo->cellId = *cellId;
263 dlCcchIndInfo->crnti = *crnti;
264 dlCcchIndInfo->msgType = msgType;
265 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
267 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
268 if(!dlCcchIndInfo->dlCcchMsg)
270 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
271 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
274 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
276 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
278 DU_FREE(dlCcchMsg, dlCcchMsgSize);
281 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
282 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
285 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
286 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
287 dlCcchIndInfo->dlCcchMsgLen);
288 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
289 sizeof(DlCcchIndInfo));
297 /*******************************************************************
299 * @brief Build and Send DL RRC Message transfer to RLC
303 * Function : duBuildAndSendDlRrcMsgToRlc
306 * Build and Send DL RRC Message transfer to RLC
308 * @params[in] Cell ID
310 * Logical Channgel ID
313 * @return ROK - success
316 * ****************************************************************/
317 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
322 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
326 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
330 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
333 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
334 duBuildAndSendDlRrcMsgToRlc");
335 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
339 /* Filling up the RRC msg info */
340 dlRrcMsgInfo->cellId = cellId;
341 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
342 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
344 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
346 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
347 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
348 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
349 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
353 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
354 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
355 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
356 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
358 /* Filling post structure and sending msg */
359 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
360 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
361 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
364 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
365 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
374 /******************************************************************
376 * @brief Process DL RRC Msg recevied from F1AP
380 * Function : duProcDlRrcMsg
382 * Functionality: Process DL RRC Msg recevied from F1AP
384 * @params[in] dlCcchMsg - uint8_t*
385 * @return ROK - success
388 * ****************************************************************/
390 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
393 uint16_t crnti, cellId, cellIdx;
394 bool ueCcchCtxtFound = false;
395 bool ueFound = false;
399 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
401 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
403 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
405 ueCcchCtxtFound = true;
406 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
407 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
414 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
417 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
421 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
423 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
426 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
427 duCb.ueCcchCtxt[ueIdx].cellId);
432 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
439 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
441 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
443 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
444 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
447 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
448 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
461 /******************************************************************
463 * @brief Generates GNB DU Ue F1AP ID
467 * Function : genGnbDuUeF1apId
469 * Functionality: Generates GNB DU Ue F1AP ID
472 * @return gnbDuF1apId
474 * ****************************************************************/
475 uint32_t genGnbDuUeF1apId()
477 static uint32_t gnbDuUeF1apId = 0;
479 return ++gnbDuUeF1apId;
482 /******************************************************************
484 * @brief Processes UL CCCH Ind recvd from MAC
488 * Function : duProcUlCcchInd
490 * Functionality: Processes UL CCCH Ind recvd from MAC
492 * @params[in] UlCcchIndInfo *ulCcchIndInfo
493 * @return ROK - success
496 * ****************************************************************/
497 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
501 uint32_t gnbDuUeF1apId = 0;
503 gnbDuUeF1apId = genGnbDuUeF1apId();
505 /* Store Ue mapping */
506 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
507 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
508 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
512 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
513 ulCcchIndInfo->ulCcchMsg));
516 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
519 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
520 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
526 /******************************************************************
528 * @brief Fills Default UL LC Cfg
532 * Function : fillDefaultUlLcCfg
534 * Functionality: Fills Default UL LC Cfg
536 * @params[in] UlLcCfg *ulLcCfg
538 *****************************************************************/
539 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
541 ulLcCfg->priority = LC_PRIORITY_1;
542 ulLcCfg->lcGroup = 0;
543 ulLcCfg->schReqId = 0;
544 ulLcCfg->pbr = PBR_KBPS_INFINITY;
545 ulLcCfg->bsd = BSD_MS_1000;
548 /******************************************************************
550 * @brief Fills Initial DL Bandwidth Part
554 * Function : fillDefaultInitDlBwp
556 * Functionality: Fills Initial DL Bandwidth Part
558 * @params[in] InitialDlBwp *initDlBwp
561 *****************************************************************/
562 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
565 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
566 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
571 /* Filling PDCCH Config */
572 initDlBwp->pdcchPresent = TRUE;
573 if(initDlBwp->pdcchPresent)
575 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
576 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
577 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
579 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
580 PDCCH_CTRL_RSRC_SET_ONE_ID;
581 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
583 coreset0EndPrb = CORESET0_END_PRB;
584 coreset1StartPrb = coreset0EndPrb +6;
585 coreset1NumPrb = CORESET1_NUM_PRB;
586 /* calculate the PRBs */
587 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
588 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
591 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
592 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
593 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
594 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
595 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
597 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
600 initDlBwp->pdcchCfg.numCRsetToRel = 0;
601 /* Filling Serach Space */
602 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
603 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
604 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
606 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
607 PDCCH_SRCH_SPC_TWO_ID;
608 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
609 PDCCH_CTRL_RSRC_SET_ONE_ID;
610 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
611 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
612 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
613 MONITORING_SYMB_WITHIN_SLOT_SIZE);
614 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
615 PDCCH_SYMBOL_WITHIN_SLOT;
616 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
618 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
620 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
622 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
624 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
626 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
627 SEARCHSPACETYPE_PR_UE_SPECIFIC;
628 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
629 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
631 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
635 /* Filling PDSCH Config */
636 initDlBwp->pdschPresent = TRUE;
637 if(initDlBwp->pdschPresent)
639 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
640 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
641 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
642 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
644 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
645 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
646 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
647 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
648 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
649 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
650 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
651 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
657 /******************************************************************
659 * @brief Fills Initial UL Bandwidth Part
663 * Function : fillDefaultInitUlBwp
665 * Functionality: Fills Initial UL Bandwidth Part
667 * @params[in] InitialUlBwp *initUlBwp
670 *****************************************************************/
671 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
676 initUlBwp->pucchPresent = FALSE;
678 /*Filling PUSCH Config */
679 initUlBwp->puschPresent = TRUE;
680 if(initUlBwp->puschPresent)
682 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
683 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
684 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
685 scramblingId0 = SCRAMBLING_ID;
686 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
687 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
689 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
691 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
692 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
694 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
695 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
696 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
697 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
699 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
704 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
708 /******************************************************************
710 * @brief Fills SpCell Group Info
714 * Function : fillDefaultSpCellGrpInfo
716 * Functionality: Fills Sp Cell Group Info
718 * @params[in] SpCellCfg *spCell
721 *****************************************************************/
722 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
726 spCell->servCellIdx = SERV_CELL_IDX;
727 /* Filling Initial Dl Bwp */
728 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
730 spCell->servCellCfg.numDlBwpToAdd = 0;
731 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
732 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
733 spCell->servCellCfg.bwpInactivityTmr = NULLP;
734 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
735 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
736 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
737 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
738 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
739 NUM_HARQ_PROC_FOR_PDSCH_N_16;
740 /* Filling Initial UL Bwp*/
741 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
742 spCell->servCellCfg.numUlBwpToAdd = 0;
743 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
747 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
751 /******************************************************************
753 * @brief Fills Physical Cell Group Info
757 * Function : fillDefaultPhyCellGrpInfo
759 * Functionality: Fills Physical Cell Group Info
761 * @params[in] PhyCellGrpCfg *cellGrp
764 *****************************************************************/
765 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
769 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
770 cellGrp->pNrFr1 = P_NR_FR1;
774 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
778 /******************************************************************
780 * @brief Fills Mac Cell Group Info
784 * Function : fillDefaultMacCellGrpInfo
786 * Functionality: Fills Mac Cell Group Info
788 * @params[in] MacCellGrpCfg *cellGrp
791 *****************************************************************/
792 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
798 /* Filling Scheduling Request Config */
799 cellGrp->schReqCfg.addModListCount = 1;
800 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
802 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
804 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
805 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
806 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
809 cellGrp->schReqCfg.relListCount = 0;
811 /* Filling Tag config */
812 cellGrp->tagCfg.addModListCount = 1;
813 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
815 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
817 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
818 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
821 cellGrp->tagCfg.relListCount = 0;
823 /* Filling BSR config */
824 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
825 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
826 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
828 /* Filling PHR config */
829 cellGrp->phrCfgSetupPres = true;
830 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
831 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
832 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
833 cellGrp->phrCfg.multiplePHR = false;
834 cellGrp->phrCfg.dummy = false;
835 cellGrp->phrCfg.phrType2OtherCell = false;
836 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
841 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
845 /*******************************************************************
847 * @brief Fills default modulation info for a UE
851 * Function : fillDefaultModulation
853 * Functionality: Fills default modulation info for a UE
855 * @params[in] Pointer to MAC UE configuration
856 * @return ROK - success
859 * ****************************************************************/
860 void fillDefaultModulation(MacUeCfg *ueCfg)
862 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
863 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
864 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
866 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
867 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
868 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
871 /******************************************************************
873 * @brief Function to fill Mac Lc Cfg for SRB1
877 * Function : fillMacSrb1LcCfg
879 * Functionality: Function to fill Mac Lc cfg for SRB1
881 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
883 *****************************************************************/
885 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
887 macLcCfg->lcId = SRB1_LCID;
888 macLcCfg->configType = CONFIG_ADD;
889 macLcCfg->drbQos = NULLP;
890 macLcCfg->snssai = NULLP;
891 macLcCfg->ulLcCfgPres = true;
892 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
895 /******************************************************************
897 * @brief Function to fill the Lc cfg from ueSetupReqDb
901 * Function : fillMacLcCfgToAddMod
903 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
905 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
906 * @return ROK/RFAILED
908 *****************************************************************/
910 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
913 lcCfg->lcId = ueSetReqDb->lcId;
914 lcCfg->configType = ueSetReqDb->configType;
916 if(ueSetReqDb->drbQos)
920 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
923 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
929 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
934 lcCfg->drbQos = NULLP;
939 if(ueSetReqDb->snssai)
943 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
946 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
953 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
957 lcCfg->snssai = NULLP;
960 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
961 lcCfg->drbQos = NULLP;
967 lcCfg->snssai = NULLP;
969 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
970 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
971 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
975 /******************************************************************
977 * @brief Function to copy the Bit rate from ueSetupReqDb
981 * Function : fillAmbr
983 * Functionality: Function to copy bit Rate from ueSetupReqDb
985 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
986 * @return ROK/RFAILED
988 *****************************************************************/
990 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
994 if(*macAmbr == NULLP)
996 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
997 if(*macAmbr == NULLP)
999 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1003 memset(*macAmbr, 0, sizeof(AmbrCfg));
1004 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
1013 /******************************************************************
1015 * @brief Builds and Send UE ReConfig Request to MAC
1019 * Function : sendUeReCfgReqToMac
1021 * Functionality: Builds and Send UE ReConfig Request to MAC
1023 * @Params[in] MacUeCfg pointer
1024 * @return ROK - success
1027 * ****************************************************************/
1029 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1035 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1039 /* Processing one Ue at a time to MAC */
1040 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1041 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1044 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1045 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1050 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1056 /******************************************************************
1058 * @brief Function to return Drb LcId
1062 * Function : getDrbLcId
1064 * Functionality: Function to return Drb LcId
1066 * Returns: lcId - SUCCESS
1068 *****************************************************************/
1070 uint8_t getDrbLcId(uint32_t *drbBitMap)
1072 uint8_t bitMask = 1, bitPos = 0;
1073 bitPos = MIN_DRB_LCID;
1075 while(bitPos <= MAX_DRB_LCID)
1077 if((*drbBitMap & (bitMask << bitPos)) == 0)
1079 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1087 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1091 /******************************************************************
1093 * @brief Fills MacUeCfg structure
1097 * Function : fillMacUeCfg
1099 * Functionality: Fills MacUeCfg
1101 * @params[in] cellId, ueIdx, crnti,
1104 * @return ROK/RFAILED
1106 *****************************************************************/
1107 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1108 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1110 uint8_t ret, dbIdx, lcIdx, cellIdx;
1111 bool lcIdFound = false;
1112 MacUeCfg *duMacDb = NULLP;
1118 macUeCfg->cellId = cellId;
1119 macUeCfg->ueIdx = ueIdx;
1120 macUeCfg->crnti = crnti;
1121 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1122 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1123 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1124 macUeCfg->ambrCfg = NULLP;
1125 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1126 fillDefaultModulation(macUeCfg);
1131 /* Fetching MacDb from DuUeCb */
1132 GET_CELL_IDX(cellId, cellIdx);
1133 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1134 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1135 macUeCfg->cellId = cellId;
1136 macUeCfg->ueIdx = ueIdx;
1137 macUeCfg->crnti = crnti;
1138 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1141 if(macUeCfg->spCellCfgPres == true)
1143 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1145 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1146 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1148 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1150 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1151 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1154 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1156 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1159 /* Filling LC Context */
1160 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1162 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1164 /* Filling default UL LC config in MAC if not present */
1165 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1166 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1168 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1170 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1173 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1174 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1176 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1177 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1185 /* ADD/DEL CONFIG */
1186 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1194 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1197 }/*End of Outer FOR loop */
1202 /******************************************************************
1204 * @brief Fills Rlc AM Information
1208 * Function : fillDefaultAmInfo
1210 * Functionality: Fills Rlc AM Information
1212 * @params[in] AmBearerCfg *amCfg
1215 *****************************************************************/
1216 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1219 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1220 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1221 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1222 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1223 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1226 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1227 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1228 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1231 /******************************************************************
1233 * @brief Fills RLC UM Bi Directional Information
1237 * Function : fillDefaultUmBiInfo
1239 * Functionality: Fills RLC UM Bi Directional Information
1241 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1244 *****************************************************************/
1245 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1247 /* UL UM BI DIR INFO */
1248 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1249 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1251 /* DL UM BI DIR INFO */
1252 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1255 /******************************************************************
1257 * @brief Fills RLC UM Uni Directional UL Information
1261 * Function : fillDefaultUmUlInfo
1263 * Functionality: Fills RLC UM Uni Directional Info
1265 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1268 *****************************************************************/
1269 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1271 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1272 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1275 /******************************************************************
1277 * @brief Fills RLC UM Uni Directional DL Information
1281 * Function : fillDefaultUmDlInfo
1283 * Functionality: Fills RLC UM Uni Directional DL Info
1285 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1288 *****************************************************************/
1289 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1291 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1294 /******************************************************************
1296 * @brief Builds Rlc Mode Default Configuration
1300 * Function : fillDefaultRlcModeCfg
1302 * Functionality: Builds Rlc Mode Default Configuration
1304 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1305 * @return ROK/RFAILED
1307 *****************************************************************/
1309 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1320 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1322 fillDefaultAmInfo(lcCfg->u.amCfg);
1325 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1331 case RLC_UM_BI_DIRECTIONAL :
1333 if(!lcCfg->u.umBiDirCfg)
1335 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1336 if(lcCfg->u.umBiDirCfg)
1337 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1340 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1346 case RLC_UM_UNI_DIRECTIONAL_UL :
1348 if(!lcCfg->u.umUniDirUlCfg)
1350 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1351 if(lcCfg->u.umUniDirUlCfg)
1352 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1355 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1361 case RLC_UM_UNI_DIRECTIONAL_DL :
1363 if(!lcCfg->u.umUniDirDlCfg)
1365 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1366 if(lcCfg->u.umUniDirDlCfg)
1367 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1370 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1377 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1384 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1390 /*******************************************************************
1392 * @brief Function to fill Rlc Lc Cfg for SRB1
1396 * Function : fillRlcSrb1LcCfg
1399 * Function to fill Rlc Lc Cfg for SRB1
1401 * @params[in] Pointer to RlcBearerCfg
1402 * @return ROK/RFAILED
1404 *****************************************************************/
1406 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1410 rlcLcCfg->rbId = SRB1_LCID;
1411 rlcLcCfg->rbType = RB_TYPE_SRB;
1412 rlcLcCfg->lcId = SRB1_LCID;
1413 rlcLcCfg->lcType = LCH_DCCH;
1414 rlcLcCfg->rlcMode = RLC_AM;
1415 rlcLcCfg->configType = CONFIG_ADD;
1416 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1420 /*******************************************************************
1422 * @brief Processes UE ReConfig Req to RLC UL
1426 * Function : sendUeReCfgReqToRlc
1429 * Processes UE Reconfig Req to RLC UL
1431 * @params[in] Pointer to RlcUeCfg
1432 * @return ROK - success
1435 *****************************************************************/
1437 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1442 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1445 /* Processing one Ue at a time to RLC */
1446 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1447 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1450 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1451 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1456 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1462 /******************************************************************
1464 * @brief Fills RlcBearerCfg structure
1468 * Function : fillRlcUeCfg
1470 * Functionality: Fills Rlc Bearer Cfg
1473 *****************************************************************/
1474 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1475 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1477 uint8_t ret, dbIdx, lcIdx, cellIdx;
1478 bool lcIdFound = false;
1479 RlcUeCfg *duRlcDb = NULLP;
1484 /* Initial RB being Added */
1485 rlcUeCfg->cellId = cellId;
1486 rlcUeCfg->ueIdx = ueIdx;
1487 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1491 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1495 /* Fetch RlcDb from DuUeCb */
1496 GET_CELL_IDX(cellId, cellIdx);
1497 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1498 /*Filling RlcUeCfg */
1499 rlcUeCfg->cellId = cellId;
1500 rlcUeCfg->ueIdx = ueIdx;
1501 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1503 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1506 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1507 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1510 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1511 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1513 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1516 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1517 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1520 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1521 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1529 /* ADD/ DEL Config Type */
1530 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1538 /******************************************************************
1540 * @brief creates UE context
1544 * Function : duCreateUeCb
1546 * Functionality: Creates UE Conetxt
1548 * @params[in] UeCcchCtxt Pointer
1551 * @return ROK - success
1553 * ****************************************************************/
1554 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1556 uint8_t cellIdx = 0;
1560 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1562 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1564 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1565 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1567 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1568 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1569 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1570 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1571 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1572 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1574 /* Filling Mac Ue Config */
1575 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1576 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1577 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1579 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1581 /* Filling Rlc Ue Config */
1582 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1583 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1584 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1586 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1588 duCb.actvCellLst[cellIdx]->numActvUes++;
1589 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1595 /******************************************************************
1597 * @brief Builds and Send UE Create Request to MAC
1601 * Function : duBuildAndSendUeCreateReqToMac
1603 * Functionality: Builds and Send UE Create Request to MAC
1605 * @Params[in] cellId,
1607 * @return ROK - success
1610 * ****************************************************************/
1612 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1613 uint16_t crnti, MacUeCfg *duMacUeCfg)
1616 MacUeCfg *macUeCfg = NULLP;
1618 memset(&pst, 0, sizeof(Pst));
1621 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1624 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1628 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1630 /* Copying ueCb to a sharable buffer */
1631 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1634 memset(macUeCfg, 0, sizeof(MacUeCfg));
1635 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1636 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1638 /* Processing one Ue at a time to MAC */
1639 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1642 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1643 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1648 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1654 /*******************************************************************
1656 * @brief To update DuUeCb Mac Cfg
1660 * Function : duUpdateMacCfg
1661 * Functionality: update DuUeCb MAC Cfg
1663 * @params[in] DuUeCb Pointer
1664 * F1UeContextSetupDb pointer
1665 * @return ROK - success
1668 * ****************************************************************/
1669 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1671 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1674 /*Filling Cell Group Cfg*/
1675 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1678 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1680 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1681 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1683 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1685 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1686 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1688 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1690 /* Filling LC Context */
1691 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1693 numLcs = macUeCfg->numLcs;
1694 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1696 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1698 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1700 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1702 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1704 /* Free memory at matched lcIdx index */
1705 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1707 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1709 /* moving all elements one index ahead */
1710 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1711 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1714 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1721 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1723 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1726 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1736 /******************************************************************
1738 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1742 * Function : fillRlcCfgToAddMod
1744 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1747 *****************************************************************/
1749 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1751 lcCfg->configType = f1UeDbLcCfg->configType;
1752 lcCfg->rbId = f1UeDbLcCfg->rbId;
1753 lcCfg->rbType = f1UeDbLcCfg->rbType;
1754 lcCfg->lcId = f1UeDbLcCfg->lcId;
1755 lcCfg->lcType = f1UeDbLcCfg->lcType;
1756 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1757 switch(lcCfg->rlcMode)
1763 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1768 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1769 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1770 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1771 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1772 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1775 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1776 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1777 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1780 case RLC_UM_BI_DIRECTIONAL :
1782 if(!lcCfg->u.umBiDirCfg)
1784 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1785 if(!lcCfg->u.umBiDirCfg)
1788 /* UL UM BI DIR INFO */
1789 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1790 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1791 /* DL UM BI DIR INFO */
1792 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1795 case RLC_UM_UNI_DIRECTIONAL_UL :
1797 if(!lcCfg->u.umUniDirUlCfg)
1799 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1800 if(!lcCfg->u.umUniDirUlCfg)
1803 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1804 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1808 case RLC_UM_UNI_DIRECTIONAL_DL :
1810 if(!lcCfg->u.umUniDirDlCfg)
1812 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1813 if(!lcCfg->u.umUniDirDlCfg)
1816 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1820 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1826 /*******************************************************************
1828 * @brief To update DuUeCb Rlc Lc Cfg
1832 * Function : duUpdateRlcLcCfg
1833 * Functionality: update DuUeCb Rlc Lc Cfg
1835 * @params[in] DuUeCb Pointer
1836 * F1UeContextSetupDb pointer
1837 * @return ROK - success
1840 * ****************************************************************/
1842 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1844 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1847 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1849 numLcs = rlcUeCfg->numLcs;
1850 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1852 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1854 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1856 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1858 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1860 /* Free memory at matched lcIdx index */
1861 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1863 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1865 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1866 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1869 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1876 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1878 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1887 /*******************************************************************
1889 * @brief Function to fill Tunnel Config to Add/Mod
1894 * Function : fillTnlCfgToAddMod
1896 * Functionality: Function to fill tunnel Config to Add/Mod
1898 * @params[in] Pointer to tnlCfgDb,
1899 * pointer to f1TnlCfg
1900 * @return ROK - success
1903 * ****************************************************************/
1904 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1906 if(*ueCbTnlCfg == NULLP)
1908 /* copying to DuCb Tnl Cfg */
1909 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1910 if(*ueCbTnlCfg == NULLP)
1912 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1916 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1917 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1918 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1919 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1920 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1921 if(f1TnlCfg->tnlCfg1)
1923 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1925 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1926 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1928 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1932 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1933 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1934 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1935 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1940 /*******************************************************************
1942 * @brief Processing the tunnel Request to EGTP
1946 * Function : duProcEgtpTunnelCfg
1948 * Functionality: Processing the tunnel Request to EGTP
1950 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1951 * @return ROK - success
1954 * ****************************************************************/
1956 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1958 uint8_t ret = RFAILED, delIdx;
1960 if(f1TnlCfg->tnlCfg1 == NULLP)
1962 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1966 if(f1TnlCfg->configType == CONFIG_ADD)
1968 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1970 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1977 else if(f1TnlCfg->configType == CONFIG_MOD)
1979 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1981 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
1987 else if(f1TnlCfg->configType == CONFIG_DEL)
1989 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1991 /* Free memory at drbIdx */
1992 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
1993 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
1995 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
1997 /* moving all elements one index ahead */
1998 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2009 /***********************************************************************
2011 * @brief Function to fill Tunnel Config
2012 * and sends tunnel Req to EGTP
2017 * Function : duUpdateTunnelCfgDb
2019 * Functionality: Function to fill tunnel Config
2020 * and sends tunnel Cfg Req to EGTP
2022 * @params[in] ueIdx, cellId, DuUeCfg
2023 * @return ROK - success
2026 * ****************************************************************/
2028 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2030 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2031 bool drbFound = false;
2033 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2034 /*then update drbId and tunnel Info in duCb */
2035 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2037 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2038 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2039 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2041 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2043 drbFound = true; /* existing DRB */
2044 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2046 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2047 duUeCfg->upTnlInfo[drbIdx].drbId);
2055 if(!drbFound && ret == ROK)/* new DRB to Add */
2057 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2059 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2060 duUeCfg->upTnlInfo[drbIdx].drbId);
2071 /*******************************************************************
2073 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2078 * Function : duUpdateDuUeCbCfg
2080 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2082 * @params[in] ueIdx, cellIdx
2083 * @return ROK - success
2086 * ****************************************************************/
2088 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2090 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2091 DuUeCb *ueCb = NULLP;
2093 GET_CELL_IDX(cellId, cellIdx);
2095 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2096 macUeCfgState == UE_RECFG_COMPLETE) &&
2097 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2098 rlcUeCfgState == UE_RECFG_COMPLETE))
2100 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2102 /*Filling RLC Ue Cfg */
2103 ueCb->rlcUeCfg.cellId = cellId;
2104 ueCb->rlcUeCfg.ueIdx = ueIdx;
2105 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2108 /*Filling MAC Ue Cfg */
2109 GET_CRNTI(crnti, ueIdx);
2110 ueCb->macUeCfg.cellId = cellId;
2111 ueCb->macUeCfg.ueIdx = ueIdx;
2112 ueCb->macUeCfg.crnti = crnti;
2113 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2115 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2118 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2120 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2126 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2133 /*******************************************************************
2135 * @brief Handle UE config response from MAC
2139 * Function : DuProcMacUeCfgRsp
2141 * Functionality: Handle UE Config response from MAC
2143 * @params[in] Pointer to MacUeCfgRsp and Pst
2144 * @return ROK - success
2147 * ****************************************************************/
2148 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2154 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2156 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2158 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2159 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2160 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2162 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2164 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2165 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2166 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2167 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2169 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2170 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2171 macUeCfg.macUeCfgState = 0;
2177 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2178 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2180 //TODO: Send the failure case in Ue Context Setup Response
2184 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2188 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2195 /*******************************************************************
2197 * @brief Processes UE create Req to RLC UL
2201 * Function : duBuildAndSendUeCreateReqToRlc
2204 * Processes UE create Req to RLC UL
2206 * @params[in] cellId,
2208 * Pointer to RlcUeCfg
2209 * @return ROK - success
2212 *****************************************************************/
2214 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2215 RlcUeCfg *duRlcUeCfg)
2218 RlcUeCfg *rlcUeCfg = NULLP;
2221 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2224 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2228 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2229 /* Copying ueCfg to a sharable buffer */
2230 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2233 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2234 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2235 /* Processing one Ue at a time to RLC */
2236 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2237 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2240 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2241 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2247 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2253 /*******************************************************************
2255 * @brief Processes UE create Rsp received from RLC UL
2260 * Function : DuProcRlcUeCfgRsp
2263 * Processes UE create Rsp received from RLC UL
2265 * @params[in] Post structure
2266 * Pointer to RlcCfgCfm
2267 * @return ROK - success
2270 *****************************************************************/
2271 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2277 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2279 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2281 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2282 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2283 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2285 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2287 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2288 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2289 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2290 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2292 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2293 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2294 rlcUeCfg.rlcUeCfgState = 0;
2300 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2301 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2302 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2304 //TODO: update failure case in ue Context setup Response
2308 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2312 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2318 /*******************************************************************
2320 * @brief Builds and Send Ue Reconfig Req to RLC
2324 * Function : duBuildAndSendUeReCfgReqToRLC
2326 * Functionality: Builds and Send Ue Reconfig Req to RLC
2328 * @params[in] cellId, crnti
2330 * RlcUeCfg *rlcUeCfg
2331 * @return ROK - success
2334 * ****************************************************************/
2336 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2338 uint8_t ret = ROK, ueIdx = 0;
2339 RlcUeCfg *rlcUeCfg = NULLP;
2341 GET_UE_IDX(crnti, ueIdx);
2342 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2345 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2346 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2348 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2350 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2354 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2360 /*******************************************************************
2362 * @brief Builds and Send Ue Reconfig Req to MAC
2366 * Function : duBuildAndSendUeReCfgReqToMac
2368 * Functionality: Builds and Send Ue Reconfig Req to MAC
2370 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2372 * MacUeCfg *macUeCfg
2373 * @return ROK - success
2376 * ****************************************************************/
2378 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2380 uint8_t ret, ueIdx = 0;
2381 MacUeCfg *macUeCfg = NULLP;
2384 GET_UE_IDX(crnti, ueIdx);
2386 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2389 memset(macUeCfg, 0, sizeof(MacUeCfg));
2390 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2392 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2394 ret = sendUeReCfgReqToMac(macUeCfg);
2398 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2404 /*******************************************************************
2406 * @brief Build and Send Ue context setup request
2411 * Function : duBuildAndSendUeContextSetupReq
2414 * Build and Send Ue context setup request
2416 * @params[in] cellId, crnti, DuUeCfg pointer
2417 * @return ROK - success
2420 *****************************************************************/
2422 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2426 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2427 /* Filling RLC Ue Reconfig */
2428 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2430 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2432 /* Filling MAC Ue Reconfig */
2433 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2435 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2440 /*******************************************************************
2442 * @brief Processes DL Rsp received from RLC DL
2447 * Function : DuProcRlcDlRrcMsgRsp
2450 * Processes UE Rsp received from RLC DL
2452 * @params[in] Post structure
2453 * Pointer to RlcCfgCfm
2454 * @return ROK - success
2457 *****************************************************************/
2458 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2460 uint8_t ret = ROK, ueIdx = 0;
2461 DuUeCb *ueCb = NULLP;
2463 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2465 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2466 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2467 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2469 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2471 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2473 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2475 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2477 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2479 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2484 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2486 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2489 /*******************************************************************
2491 * @brief Process UE context setup request from CU
2495 * Function : duProcUeContextSetupRequest
2497 * Functionality: Process UE context setup request from CU
2499 * @params[in] F1AP message
2500 * @return ROK - success
2503 * ****************************************************************/
2505 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2507 uint8_t ret, cellId;
2512 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2513 /* Send DL RRC msg for security Mode */
2514 if(ueCb->f1UeDb->dlRrcMsg)
2516 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2518 /* Sending DL RRC Message to RLC */
2519 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2522 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2523 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2524 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2525 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2529 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2531 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2534 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2540 //TODO: To send the failure cause in UeContextSetupRsp
2541 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2546 /*******************************************************************
2548 * @brief Build and Send Ue context mod request
2553 * Function : duBuildAndSendUeContextModReq
2556 * Build and Send Ue context mod request
2558 * @params[in] cellId, crnti, DuUeCfg pointer
2559 * @return ROK - success
2562 *****************************************************************/
2564 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2568 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2569 /* Filling RLC Ue Reconfig */
2570 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2572 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2574 /* Filling MAC Ue Reconfig */
2575 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2577 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2581 /*******************************************************************
2583 * @brief Processing Ue context mod request
2588 * Function : duProcUeContextModReq
2591 * Processing Ue context mod request
2593 * @params[in] DuUeCb *ueCb
2594 * @return ROK - success
2597 *****************************************************************/
2599 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2601 uint8_t ret, cellId;
2606 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2607 /* Send DL RRC msg for security Mode */
2608 if(ueCb->f1UeDb->dlRrcMsg)
2610 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2612 /* Sending DL RRC Message to RLC */
2613 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2616 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2617 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2618 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2619 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2625 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2628 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2634 //TODO: To send the failure cause in UeContextModRsp
2635 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2639 /*******************************************************************
2641 * @brief Function to delete Pdsch ServCellCfg
2645 * Function : deletePdschServCellCfg
2647 * Functionality: Function to delete Pdsch ServCellCfg
2649 * @params[in] PdschServCellCfg *pdschServCellCfg
2652 * ****************************************************************/
2653 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2655 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2656 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2657 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2658 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2661 /*******************************************************************
2663 * @brief delete MacUeCfg from duCb
2667 * Function : deleteMacUeCfg
2669 * Functionality: delete MacUeCfg from duCb
2671 * @params[in] Pointer to MacUeCfg
2672 * @return ROK - success
2675 *******************************************************************/
2676 void deleteMacUeCfg(MacUeCfg *ueCfg)
2680 ServCellCfgInfo *servCellCfg;
2681 PucchResrcInfo *resrcToAddModList;
2685 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2686 if(ueCfg->spCellCfgPres)
2688 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2689 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2690 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrcSet,\
2691 sizeof(PucchResrcSetCfg));
2692 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2694 /*freeing the PucchResrcCfg*/
2695 for(resrcIdx= 0; resrcIdx< servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModListCount; resrcIdx++)
2697 resrcToAddModList=&servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModList[resrcIdx];
2698 switch(resrcToAddModList->pucchFormat)
2700 case PUCCH_FORMAT_0:
2702 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format0 ,\
2703 sizeof(PucchFormat0));
2706 case PUCCH_FORMAT_1:
2708 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format1 ,\
2709 sizeof(PucchFormat1));
2712 case PUCCH_FORMAT_2:
2714 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format2 ,\
2715 sizeof(PucchFormat2_3));
2718 case PUCCH_FORMAT_3:
2720 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format3 ,\
2721 sizeof(PucchFormat2_3));
2724 case PUCCH_FORMAT_4:
2726 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format4 ,\
2727 sizeof(PucchFormat4));
2732 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrc,\
2733 sizeof(PucchResrcCfg));
2735 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format1,\
2736 sizeof(PucchFormatCfg));
2737 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format2,\
2738 sizeof(PucchFormatCfg));
2739 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format3,\
2740 sizeof(PucchFormatCfg));
2741 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format4,\
2742 sizeof(PucchFormatCfg));
2743 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.schedReq,\
2744 sizeof(PucchSchedReqCfg));
2745 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.multiCsiCfg,\
2746 sizeof(PucchMultiCsiCfg));
2747 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.spatialInfo,\
2748 sizeof(PucchSpatialCfg));
2749 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck ,\
2750 sizeof(PucchDlDataToUlAck));
2751 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.powerControl,\
2752 sizeof(PucchPowerControl));
2753 deletePdschServCellCfg(&servCellCfg->pdschServCellCfg);
2755 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2757 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].drbQos, sizeof(DrbQosInfo));
2758 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].snssai, sizeof(Snssai));
2761 memset(ueCfg, 0, sizeof(MacUeCfg));
2763 /*******************************************************************
2765 * @brief Handle UE delete response from MAC
2769 * Function : DuProcMacUeDeleteRsp
2771 * Functionality: Handle UE delete response from MAC
2773 * @params[in] Pointer to MacUeDeleteRsp and Pst
2774 * @return ROK - success
2777 * ****************************************************************/
2778 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2783 if(deleteRsp->result == SUCCESS)
2785 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueIdx);
2786 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2787 if(duCb.actvCellLst[cellIdx])
2789 deleteMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueIdx -1].macUeCfg);
2794 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2798 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2802 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2807 /*******************************************************************
2809 * @brief Sending UE Delete Req To Mac
2813 * Function : sendUeDeleteReqToMac
2816 * sending UE Delete Req To Mac
2818 * @params[in] uint8_t cellId, uint8_t ueId
2819 * @return ROK - success
2822 *****************************************************************/
2824 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueIdx, uint16_t crnti)
2828 MacUeDelete *ueDelete = NULLP;
2830 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2833 ueDelete->cellId = cellId;
2834 ueDelete->ueIdx = ueIdx;
2835 ueDelete->crnti = crnti;
2836 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2838 /* Processing one Ue at a time to MAC */
2839 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2840 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2843 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2844 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2849 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
2855 /*******************************************************************
2857 * @brief Du preocess Ue Delete Req to MAC and RLC
2861 * Function : duProcUeDeleteReq
2863 * Functionality: Du process Ue Delete Req to MAC and RLC
2865 * @params[in] cellId, crnti
2866 * @return ROK - success
2869 * ****************************************************************/
2870 uint8_t duProcUeDeleteReq(uint16_t cellId, uint16_t crnti)
2872 uint16_t cellIdx = 0;
2875 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
2876 GET_CELL_IDX(cellId, cellIdx);
2877 GET_UE_IDX(crnti, ueIdx);
2879 if(duCb.actvCellLst[cellIdx] != NULLP)
2881 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti == crnti)
2883 if(sendUeDeleteReqToMac(cellId, ueIdx, crnti) == RFAILED)
2885 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Failed to build UE delete req for MAC ");
2892 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): crnti is not found");
2898 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Cell Id is not found");
2905 /**********************************************************************
2907 ***********************************************************************/