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);
1155 if(ueCfgDb->ueNrCapability != NULLP)
1157 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1161 /* Filling LC Context */
1162 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1164 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1166 /* Filling default UL LC config in MAC if not present */
1167 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1168 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1170 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1172 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1175 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1176 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1178 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1179 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1187 /* ADD/DEL CONFIG */
1188 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1196 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1199 }/*End of Outer FOR loop */
1204 /******************************************************************
1206 * @brief Fills Rlc AM Information
1210 * Function : fillDefaultAmInfo
1212 * Functionality: Fills Rlc AM Information
1214 * @params[in] AmBearerCfg *amCfg
1217 *****************************************************************/
1218 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1221 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1222 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1223 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1224 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1225 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1228 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1229 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1230 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1233 /******************************************************************
1235 * @brief Fills RLC UM Bi Directional Information
1239 * Function : fillDefaultUmBiInfo
1241 * Functionality: Fills RLC UM Bi Directional Information
1243 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1246 *****************************************************************/
1247 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1249 /* UL UM BI DIR INFO */
1250 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1251 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1253 /* DL UM BI DIR INFO */
1254 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1257 /******************************************************************
1259 * @brief Fills RLC UM Uni Directional UL Information
1263 * Function : fillDefaultUmUlInfo
1265 * Functionality: Fills RLC UM Uni Directional Info
1267 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1270 *****************************************************************/
1271 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1273 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1274 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1277 /******************************************************************
1279 * @brief Fills RLC UM Uni Directional DL Information
1283 * Function : fillDefaultUmDlInfo
1285 * Functionality: Fills RLC UM Uni Directional DL Info
1287 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1290 *****************************************************************/
1291 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1293 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1296 /******************************************************************
1298 * @brief Builds Rlc Mode Default Configuration
1302 * Function : fillDefaultRlcModeCfg
1304 * Functionality: Builds Rlc Mode Default Configuration
1306 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1307 * @return ROK/RFAILED
1309 *****************************************************************/
1311 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1322 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1324 fillDefaultAmInfo(lcCfg->u.amCfg);
1327 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1333 case RLC_UM_BI_DIRECTIONAL :
1335 if(!lcCfg->u.umBiDirCfg)
1337 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1338 if(lcCfg->u.umBiDirCfg)
1339 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1342 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1348 case RLC_UM_UNI_DIRECTIONAL_UL :
1350 if(!lcCfg->u.umUniDirUlCfg)
1352 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1353 if(lcCfg->u.umUniDirUlCfg)
1354 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1357 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1363 case RLC_UM_UNI_DIRECTIONAL_DL :
1365 if(!lcCfg->u.umUniDirDlCfg)
1367 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1368 if(lcCfg->u.umUniDirDlCfg)
1369 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1372 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1379 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1386 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1392 /*******************************************************************
1394 * @brief Function to fill Rlc Lc Cfg for SRB1
1398 * Function : fillRlcSrb1LcCfg
1401 * Function to fill Rlc Lc Cfg for SRB1
1403 * @params[in] Pointer to RlcBearerCfg
1404 * @return ROK/RFAILED
1406 *****************************************************************/
1408 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1412 rlcLcCfg->rbId = SRB1_LCID;
1413 rlcLcCfg->rbType = RB_TYPE_SRB;
1414 rlcLcCfg->lcId = SRB1_LCID;
1415 rlcLcCfg->lcType = LCH_DCCH;
1416 rlcLcCfg->rlcMode = RLC_AM;
1417 rlcLcCfg->configType = CONFIG_ADD;
1418 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1422 /*******************************************************************
1424 * @brief Processes UE ReConfig Req to RLC UL
1428 * Function : sendUeReCfgReqToRlc
1431 * Processes UE Reconfig Req to RLC UL
1433 * @params[in] Pointer to RlcUeCfg
1434 * @return ROK - success
1437 *****************************************************************/
1439 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1444 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1447 /* Processing one Ue at a time to RLC */
1448 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1449 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1452 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1453 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1458 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1464 /******************************************************************
1466 * @brief Fills RlcBearerCfg structure
1470 * Function : fillRlcUeCfg
1472 * Functionality: Fills Rlc Bearer Cfg
1475 *****************************************************************/
1476 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1477 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1479 uint8_t ret, dbIdx, lcIdx, cellIdx;
1480 bool lcIdFound = false;
1481 RlcUeCfg *duRlcDb = NULLP;
1486 /* Initial RB being Added */
1487 rlcUeCfg->cellId = cellId;
1488 rlcUeCfg->ueIdx = ueIdx;
1489 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1493 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1497 /* Fetch RlcDb from DuUeCb */
1498 GET_CELL_IDX(cellId, cellIdx);
1499 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1500 /*Filling RlcUeCfg */
1501 rlcUeCfg->cellId = cellId;
1502 rlcUeCfg->ueIdx = ueIdx;
1503 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1505 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1508 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1509 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1512 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1513 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1515 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1518 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1519 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1522 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1523 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1531 /* ADD/ DEL Config Type */
1532 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1540 /******************************************************************
1542 * @brief creates UE context
1546 * Function : duCreateUeCb
1548 * Functionality: Creates UE Conetxt
1550 * @params[in] UeCcchCtxt Pointer
1553 * @return ROK - success
1555 * ****************************************************************/
1556 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1558 uint8_t cellIdx = 0;
1562 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1564 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1566 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1567 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1569 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1570 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1571 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1572 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1573 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1574 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1576 /* Filling Mac Ue Config */
1577 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1578 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1579 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1581 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1583 /* Filling Rlc Ue Config */
1584 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1585 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1586 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1588 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1590 duCb.actvCellLst[cellIdx]->numActvUes++;
1591 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1597 /******************************************************************
1599 * @brief Builds and Send UE Create Request to MAC
1603 * Function : duBuildAndSendUeCreateReqToMac
1605 * Functionality: Builds and Send UE Create Request to MAC
1607 * @Params[in] cellId,
1609 * @return ROK - success
1612 * ****************************************************************/
1614 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1615 uint16_t crnti, MacUeCfg *duMacUeCfg)
1618 MacUeCfg *macUeCfg = NULLP;
1620 memset(&pst, 0, sizeof(Pst));
1623 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1626 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1630 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1632 /* Copying ueCb to a sharable buffer */
1633 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1636 memset(macUeCfg, 0, sizeof(MacUeCfg));
1637 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1638 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1640 /* Processing one Ue at a time to MAC */
1641 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1644 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1645 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1650 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1656 /*******************************************************************
1658 * @brief To update DuUeCb Mac Cfg
1662 * Function : duUpdateMacCfg
1663 * Functionality: update DuUeCb MAC Cfg
1665 * @params[in] DuUeCb Pointer
1666 * F1UeContextSetupDb pointer
1667 * @return ROK - success
1670 * ****************************************************************/
1671 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1673 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1676 /*Filling Cell Group Cfg*/
1677 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1680 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1682 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1683 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1685 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1687 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1688 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1690 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1692 /* Filling LC Context */
1693 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1695 numLcs = macUeCfg->numLcs;
1696 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1698 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1700 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1702 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1704 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1706 /* Free memory at matched lcIdx index */
1707 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1709 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1711 /* moving all elements one index ahead */
1712 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1713 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1716 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1723 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1725 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1728 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1738 /******************************************************************
1740 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1744 * Function : fillRlcCfgToAddMod
1746 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1749 *****************************************************************/
1751 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1753 lcCfg->configType = f1UeDbLcCfg->configType;
1754 lcCfg->rbId = f1UeDbLcCfg->rbId;
1755 lcCfg->rbType = f1UeDbLcCfg->rbType;
1756 lcCfg->lcId = f1UeDbLcCfg->lcId;
1757 lcCfg->lcType = f1UeDbLcCfg->lcType;
1758 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1759 switch(lcCfg->rlcMode)
1765 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1770 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1771 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1772 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1773 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1774 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1777 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1778 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1779 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1782 case RLC_UM_BI_DIRECTIONAL :
1784 if(!lcCfg->u.umBiDirCfg)
1786 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1787 if(!lcCfg->u.umBiDirCfg)
1790 /* UL UM BI DIR INFO */
1791 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1792 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1793 /* DL UM BI DIR INFO */
1794 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1797 case RLC_UM_UNI_DIRECTIONAL_UL :
1799 if(!lcCfg->u.umUniDirUlCfg)
1801 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1802 if(!lcCfg->u.umUniDirUlCfg)
1805 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1806 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1810 case RLC_UM_UNI_DIRECTIONAL_DL :
1812 if(!lcCfg->u.umUniDirDlCfg)
1814 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1815 if(!lcCfg->u.umUniDirDlCfg)
1818 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1822 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1828 /*******************************************************************
1830 * @brief To update DuUeCb Rlc Lc Cfg
1834 * Function : duUpdateRlcLcCfg
1835 * Functionality: update DuUeCb Rlc Lc Cfg
1837 * @params[in] DuUeCb Pointer
1838 * F1UeContextSetupDb pointer
1839 * @return ROK - success
1842 * ****************************************************************/
1844 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1846 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1849 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1851 numLcs = rlcUeCfg->numLcs;
1852 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1854 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1856 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1858 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1860 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1862 /* Free memory at matched lcIdx index */
1863 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1865 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1867 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1868 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1871 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1878 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1880 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1889 /*******************************************************************
1891 * @brief Function to fill Tunnel Config to Add/Mod
1896 * Function : fillTnlCfgToAddMod
1898 * Functionality: Function to fill tunnel Config to Add/Mod
1900 * @params[in] Pointer to tnlCfgDb,
1901 * pointer to f1TnlCfg
1902 * @return ROK - success
1905 * ****************************************************************/
1906 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1908 if(*ueCbTnlCfg == NULLP)
1910 /* copying to DuCb Tnl Cfg */
1911 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1912 if(*ueCbTnlCfg == NULLP)
1914 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1918 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1919 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1920 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1921 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1922 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1923 if(f1TnlCfg->tnlCfg1)
1925 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1927 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1928 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1930 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1934 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1935 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1936 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1937 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1942 /*******************************************************************
1944 * @brief Processing the tunnel Request to EGTP
1948 * Function : duProcEgtpTunnelCfg
1950 * Functionality: Processing the tunnel Request to EGTP
1952 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1953 * @return ROK - success
1956 * ****************************************************************/
1958 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1960 uint8_t ret = RFAILED, delIdx;
1962 if(f1TnlCfg->tnlCfg1 == NULLP)
1964 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1968 if(f1TnlCfg->configType == CONFIG_ADD)
1970 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1972 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1979 else if(f1TnlCfg->configType == CONFIG_MOD)
1981 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1983 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
1989 else if(f1TnlCfg->configType == CONFIG_DEL)
1991 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1993 /* Free memory at drbIdx */
1994 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
1995 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
1997 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
1999 /* moving all elements one index ahead */
2000 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2011 /***********************************************************************
2013 * @brief Function to fill Tunnel Config
2014 * and sends tunnel Req to EGTP
2019 * Function : duUpdateTunnelCfgDb
2021 * Functionality: Function to fill tunnel Config
2022 * and sends tunnel Cfg Req to EGTP
2024 * @params[in] ueIdx, cellId, DuUeCfg
2025 * @return ROK - success
2028 * ****************************************************************/
2030 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2032 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2033 bool drbFound = false;
2035 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2036 /*then update drbId and tunnel Info in duCb */
2037 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2039 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2040 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2041 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2043 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2045 drbFound = true; /* existing DRB */
2046 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2048 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2049 duUeCfg->upTnlInfo[drbIdx].drbId);
2057 if(!drbFound && ret == ROK)/* new DRB to Add */
2059 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2061 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2062 duUeCfg->upTnlInfo[drbIdx].drbId);
2073 /*******************************************************************
2075 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2080 * Function : duUpdateDuUeCbCfg
2082 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2084 * @params[in] ueIdx, cellIdx
2085 * @return ROK - success
2088 * ****************************************************************/
2090 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2092 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2093 DuUeCb *ueCb = NULLP;
2095 GET_CELL_IDX(cellId, cellIdx);
2097 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2098 macUeCfgState == UE_RECFG_COMPLETE) &&
2099 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2100 rlcUeCfgState == UE_RECFG_COMPLETE))
2102 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2104 /*Filling RLC Ue Cfg */
2105 ueCb->rlcUeCfg.cellId = cellId;
2106 ueCb->rlcUeCfg.ueIdx = ueIdx;
2107 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2110 /*Filling MAC Ue Cfg */
2111 GET_CRNTI(crnti, ueIdx);
2112 ueCb->macUeCfg.cellId = cellId;
2113 ueCb->macUeCfg.ueIdx = ueIdx;
2114 ueCb->macUeCfg.crnti = crnti;
2115 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2117 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2120 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2122 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2128 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2135 /*******************************************************************
2137 * @brief Handle UE config response from MAC
2141 * Function : DuProcMacUeCfgRsp
2143 * Functionality: Handle UE Config response from MAC
2145 * @params[in] Pointer to MacUeCfgRsp and Pst
2146 * @return ROK - success
2149 * ****************************************************************/
2150 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2156 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2158 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2160 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2161 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2162 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2164 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2166 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2167 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2168 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2169 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2171 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2172 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2173 macUeCfg.macUeCfgState = 0;
2179 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2180 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2182 //TODO: Send the failure case in Ue Context Setup Response
2186 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2190 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2197 /*******************************************************************
2199 * @brief Processes UE create Req to RLC UL
2203 * Function : duBuildAndSendUeCreateReqToRlc
2206 * Processes UE create Req to RLC UL
2208 * @params[in] cellId,
2210 * Pointer to RlcUeCfg
2211 * @return ROK - success
2214 *****************************************************************/
2216 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2217 RlcUeCfg *duRlcUeCfg)
2220 RlcUeCfg *rlcUeCfg = NULLP;
2223 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2226 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2230 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2231 /* Copying ueCfg to a sharable buffer */
2232 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2235 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2236 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2237 /* Processing one Ue at a time to RLC */
2238 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2239 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2242 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2243 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2249 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2255 /*******************************************************************
2257 * @brief Processes UE create Rsp received from RLC UL
2262 * Function : DuProcRlcUeCfgRsp
2265 * Processes UE create Rsp received from RLC UL
2267 * @params[in] Post structure
2268 * Pointer to RlcCfgCfm
2269 * @return ROK - success
2272 *****************************************************************/
2273 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2279 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2281 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2283 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2284 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2285 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2287 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2289 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2290 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2291 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2292 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2294 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2295 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2296 rlcUeCfg.rlcUeCfgState = 0;
2302 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2303 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2304 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2306 //TODO: update failure case in ue Context setup Response
2310 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2314 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2320 /*******************************************************************
2322 * @brief Builds and Send Ue Reconfig Req to RLC
2326 * Function : duBuildAndSendUeReCfgReqToRLC
2328 * Functionality: Builds and Send Ue Reconfig Req to RLC
2330 * @params[in] cellId, crnti
2332 * RlcUeCfg *rlcUeCfg
2333 * @return ROK - success
2336 * ****************************************************************/
2338 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2340 uint8_t ret = ROK, ueIdx = 0;
2341 RlcUeCfg *rlcUeCfg = NULLP;
2343 GET_UE_IDX(crnti, ueIdx);
2344 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2347 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2348 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2350 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2352 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2356 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2362 /*******************************************************************
2364 * @brief Builds and Send Ue Reconfig Req to MAC
2368 * Function : duBuildAndSendUeReCfgReqToMac
2370 * Functionality: Builds and Send Ue Reconfig Req to MAC
2372 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2374 * MacUeCfg *macUeCfg
2375 * @return ROK - success
2378 * ****************************************************************/
2380 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2382 uint8_t ret, ueIdx = 0;
2383 MacUeCfg *macUeCfg = NULLP;
2386 GET_UE_IDX(crnti, ueIdx);
2388 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2391 memset(macUeCfg, 0, sizeof(MacUeCfg));
2392 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2394 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2396 ret = sendUeReCfgReqToMac(macUeCfg);
2400 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2406 /*******************************************************************
2408 * @brief Build and Send Ue context setup request
2413 * Function : duBuildAndSendUeContextSetupReq
2416 * Build and Send Ue context setup request
2418 * @params[in] cellId, crnti, DuUeCfg pointer
2419 * @return ROK - success
2422 *****************************************************************/
2424 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2428 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2429 /* Filling RLC Ue Reconfig */
2430 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2432 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2434 /* Filling MAC Ue Reconfig */
2435 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2437 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2442 /*******************************************************************
2444 * @brief Processes DL Rsp received from RLC DL
2449 * Function : DuProcRlcDlRrcMsgRsp
2452 * Processes UE Rsp received from RLC DL
2454 * @params[in] Post structure
2455 * Pointer to RlcCfgCfm
2456 * @return ROK - success
2459 *****************************************************************/
2460 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2462 uint8_t ret = ROK, ueIdx = 0;
2463 DuUeCb *ueCb = NULLP;
2465 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2467 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2468 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2469 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2471 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2473 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2475 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2477 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2479 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2481 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2486 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2488 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2491 /*******************************************************************
2493 * @brief Process UE context setup request from CU
2497 * Function : duProcUeContextSetupRequest
2499 * Functionality: Process UE context setup request from CU
2501 * @params[in] F1AP message
2502 * @return ROK - success
2505 * ****************************************************************/
2507 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2509 uint8_t ret, cellId;
2514 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2515 /* Send DL RRC msg for security Mode */
2516 if(ueCb->f1UeDb->dlRrcMsg)
2518 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2520 /* Sending DL RRC Message to RLC */
2521 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2524 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2525 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2526 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2527 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2531 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2533 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2536 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2542 //TODO: To send the failure cause in UeContextSetupRsp
2543 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2548 /*******************************************************************
2550 * @brief Build and Send Ue context mod request
2555 * Function : duBuildAndSendUeContextModReq
2558 * Build and Send Ue context mod request
2560 * @params[in] cellId, crnti, DuUeCfg pointer
2561 * @return ROK - success
2564 *****************************************************************/
2566 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2570 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2571 /* Filling RLC Ue Reconfig */
2572 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2574 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2576 /* Filling MAC Ue Reconfig */
2577 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2579 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2583 /*******************************************************************
2585 * @brief Processing Ue context mod request
2590 * Function : duProcUeContextModReq
2593 * Processing Ue context mod request
2595 * @params[in] DuUeCb *ueCb
2596 * @return ROK - success
2599 *****************************************************************/
2601 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2603 uint8_t ret, cellId;
2608 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2609 /* Send DL RRC msg for security Mode */
2610 if(ueCb->f1UeDb->dlRrcMsg)
2612 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2614 /* Sending DL RRC Message to RLC */
2615 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2618 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2619 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2620 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2621 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2627 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2630 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2636 //TODO: To send the failure cause in UeContextModRsp
2637 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2641 /*******************************************************************
2643 * @brief Function to delete Pdsch ServCellCfg
2647 * Function : deletePdschServCellCfg
2649 * Functionality: Function to delete Pdsch ServCellCfg
2651 * @params[in] PdschServCellCfg *pdschServCellCfg
2654 * ****************************************************************/
2655 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2657 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2658 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2659 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2660 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2663 /*******************************************************************
2665 * @brief delete MacUeCfg from duCb
2669 * Function : deleteMacUeCfg
2671 * Functionality: delete MacUeCfg from duCb
2673 * @params[in] Pointer to MacUeCfg
2674 * @return ROK - success
2677 *******************************************************************/
2678 void deleteMacUeCfg(MacUeCfg *ueCfg)
2682 ServCellCfgInfo *servCellCfg;
2683 PucchResrcInfo *resrcToAddModList;
2687 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2688 if(ueCfg->spCellCfgPres)
2690 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2691 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2692 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrcSet,\
2693 sizeof(PucchResrcSetCfg));
2694 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2696 /*freeing the PucchResrcCfg*/
2697 for(resrcIdx= 0; resrcIdx< servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModListCount; resrcIdx++)
2699 resrcToAddModList=&servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModList[resrcIdx];
2700 switch(resrcToAddModList->pucchFormat)
2702 case PUCCH_FORMAT_0:
2704 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format0 ,\
2705 sizeof(PucchFormat0));
2708 case PUCCH_FORMAT_1:
2710 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format1 ,\
2711 sizeof(PucchFormat1));
2714 case PUCCH_FORMAT_2:
2716 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format2 ,\
2717 sizeof(PucchFormat2_3));
2720 case PUCCH_FORMAT_3:
2722 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format3 ,\
2723 sizeof(PucchFormat2_3));
2726 case PUCCH_FORMAT_4:
2728 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format4 ,\
2729 sizeof(PucchFormat4));
2734 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrc,\
2735 sizeof(PucchResrcCfg));
2737 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format1,\
2738 sizeof(PucchFormatCfg));
2739 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format2,\
2740 sizeof(PucchFormatCfg));
2741 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format3,\
2742 sizeof(PucchFormatCfg));
2743 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format4,\
2744 sizeof(PucchFormatCfg));
2745 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.schedReq,\
2746 sizeof(PucchSchedReqCfg));
2747 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.multiCsiCfg,\
2748 sizeof(PucchMultiCsiCfg));
2749 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.spatialInfo,\
2750 sizeof(PucchSpatialCfg));
2751 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck ,\
2752 sizeof(PucchDlDataToUlAck));
2753 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.powerControl,\
2754 sizeof(PucchPowerControl));
2755 deletePdschServCellCfg(&servCellCfg->pdschServCellCfg);
2757 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2759 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].drbQos, sizeof(DrbQosInfo));
2760 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].snssai, sizeof(Snssai));
2763 memset(ueCfg, 0, sizeof(MacUeCfg));
2765 /*******************************************************************
2767 * @brief Handle UE delete response from MAC
2771 * Function : DuProcMacUeDeleteRsp
2773 * Functionality: Handle UE delete response from MAC
2775 * @params[in] Pointer to MacUeDeleteRsp and Pst
2776 * @return ROK - success
2779 * ****************************************************************/
2780 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2785 if(deleteRsp->result == SUCCESS)
2787 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueIdx);
2788 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2789 if(duCb.actvCellLst[cellIdx])
2791 deleteMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueIdx -1].macUeCfg);
2796 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2800 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2804 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2809 /*******************************************************************
2811 * @brief Sending UE Delete Req To Mac
2815 * Function : sendUeDeleteReqToMac
2818 * sending UE Delete Req To Mac
2820 * @params[in] uint8_t cellId, uint8_t ueId
2821 * @return ROK - success
2824 *****************************************************************/
2826 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueIdx, uint16_t crnti)
2830 MacUeDelete *ueDelete = NULLP;
2832 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2835 ueDelete->cellId = cellId;
2836 ueDelete->ueIdx = ueIdx;
2837 ueDelete->crnti = crnti;
2838 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2840 /* Processing one Ue at a time to MAC */
2841 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2842 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2845 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2846 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2851 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
2857 /*******************************************************************
2859 * @brief Du preocess Ue Delete Req to MAC and RLC
2863 * Function : duProcUeDeleteReq
2865 * Functionality: Du process Ue Delete Req to MAC and RLC
2867 * @params[in] cellId, crnti
2868 * @return ROK - success
2871 * ****************************************************************/
2872 uint8_t duProcUeDeleteReq(uint16_t cellId, uint16_t crnti)
2874 uint16_t cellIdx = 0;
2877 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
2878 GET_CELL_IDX(cellId, cellIdx);
2879 GET_UE_IDX(crnti, ueIdx);
2881 if(duCb.actvCellLst[cellIdx] != NULLP)
2883 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti == crnti)
2885 if(sendUeDeleteReqToMac(cellId, ueIdx, crnti) == RFAILED)
2887 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Failed to build UE delete req for MAC ");
2894 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): crnti is not found");
2900 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Cell Id is not found");
2907 /**********************************************************************
2909 ***********************************************************************/