1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
37 DuMacDlCcchInd packMacDlCcchIndOpts[] =
39 packMacDlCcchInd, /* Loose coupling */
40 MacProcDlCcchInd, /* TIght coupling */
41 packMacDlCcchInd /* Light weight-loose coupling */
44 DuMacUeCreateReq packMacUeCreateReqOpts[] =
46 packDuMacUeCreateReq, /* Loose coupling */
47 MacProcUeCreateReq, /* TIght coupling */
48 packDuMacUeCreateReq /* Light weight-loose coupling */
51 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
53 packDuRlcUeCreateReq, /* Loose coupling */
54 RlcProcUeCreateReq, /* TIght coupling */
55 packDuRlcUeCreateReq /* Light weight-loose coupling */
58 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
60 packDlRrcMsgToRlc, /* Loose coupling */
61 RlcProcDlRrcMsgTransfer, /* Tight coupling */
62 packDlRrcMsgToRlc /* Light weight-loose coupling */
65 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
67 packDuRlcUeReconfigReq, /* Loose coupling */
68 RlcProcUeReconfigReq, /* TIght coupling */
69 packDuRlcUeReconfigReq /* Light weight-loose coupling */
72 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
74 packDuMacUeReconfigReq, /* Loose coupling */
75 MacProcUeReconfigReq, /* TIght coupling */
76 packDuMacUeReconfigReq /* Light weight-loose coupling */
79 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
81 packRlcDlUserDataToRlc, /* Loose coupling */
82 RlcProcDlUserDataTransfer, /* Tight coupling */
83 packRlcDlUserDataToRlc /* Light weight-loose coupling */
86 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
88 packDuMacUeDeleteReq, /* Loose coupling */
89 MacProcUeDeleteReq, /* TIght coupling */
90 packDuMacUeDeleteReq /* Light weight-loose coupling */
93 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
95 packDuRlcUeDeleteReq, /* Loose coupling */
96 RlcProcUeDeleteReq, /* TIght coupling */
97 packDuRlcUeDeleteReq /* Light weight-loose coupling */
100 /*******************************************************************
102 * @brief Function to fillDlUserDataInfo
106 * Function : fillDlUserDataInfo
109 * Function to fillDlUserDataInfo
114 * @return ROK - success
117 * ****************************************************************/
119 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
123 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
125 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
127 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
129 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
130 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
131 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
139 /*******************************************************************
141 * @brief Build and Send DL Data Message transfer to RLC
145 * Function : duBuildAndSendDlUserDataToRlc
148 * Build and Send DL Data Message transfer to RLC
150 * @params[in] Cell ID
152 * Logical Channgel ID
155 * @return ROK - success
158 * ****************************************************************/
160 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
162 uint8_t ret = RFAILED;
164 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
166 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
169 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
172 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
173 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &dlDataMsgInfo->dlMsg) != ROK)
175 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlMsg in duHdlEgtpDlData()");
176 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
179 dlDataMsgInfo->dlMsg = egtpMsg->msg;
180 dlDataMsgInfo->msgLen = msgLen;
182 /* Filling DL DATA Msg Info */
183 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
185 /* Filling post structure and sending msg */
186 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
187 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
188 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
192 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
193 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo->dlMsg, msgLen);
194 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
199 /*******************************************************************
201 * @brief Handles EGTP data from CU
205 * Function : duHdlEgtpData
208 * Processes EGTP header and sends data to RLC
210 * @params[in] Pointer to EGTP Message
211 * @return ROK - success
214 * ****************************************************************/
215 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
218 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
222 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
225 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
226 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
228 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
229 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
235 /******************************************************************
237 * @brief Builds and Sends DL CCCH Ind to MAC
241 * Function : duBuildAndSendDlCcchInd
243 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
245 * @params[in] dlCcchMsg - uint8_t*
246 * @return ROK - success
249 * ****************************************************************/
250 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
251 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
255 DlCcchIndInfo *dlCcchIndInfo = NULLP;
258 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
260 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
264 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
268 dlCcchIndInfo->cellId = *cellId;
269 dlCcchIndInfo->crnti = *crnti;
270 dlCcchIndInfo->msgType = msgType;
271 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
273 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
274 if(!dlCcchIndInfo->dlCcchMsg)
276 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
277 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
280 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
282 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
284 DU_FREE(dlCcchMsg, dlCcchMsgSize);
287 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
288 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
291 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
292 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
293 dlCcchIndInfo->dlCcchMsgLen);
294 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
295 sizeof(DlCcchIndInfo));
303 /*******************************************************************
305 * @brief Build and Send DL RRC Message transfer to RLC
309 * Function : duBuildAndSendDlRrcMsgToRlc
312 * Build and Send DL RRC Message transfer to RLC
314 * @params[in] Cell ID
316 * Logical Channgel ID
319 * @return ROK - success
322 * ****************************************************************/
323 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
328 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
332 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
336 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
339 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
340 duBuildAndSendDlRrcMsgToRlc");
341 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
345 /* Filling up the RRC msg info */
346 dlRrcMsgInfo->cellId = cellId;
347 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
348 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
350 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
352 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
353 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
354 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
355 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
359 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
360 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
361 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
362 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
364 /* Filling post structure and sending msg */
365 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
366 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
367 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
370 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
371 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
380 /******************************************************************
382 * @brief Process DL RRC Msg recevied from F1AP
386 * Function : duProcDlRrcMsg
388 * Functionality: Process DL RRC Msg recevied from F1AP
390 * @params[in] dlCcchMsg - uint8_t*
391 * @return ROK - success
394 * ****************************************************************/
396 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
399 uint16_t crnti, cellId, cellIdx;
400 bool ueCcchCtxtFound = false;
401 bool ueFound = false;
405 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
407 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
409 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
411 ueCcchCtxtFound = true;
412 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
413 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
420 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
423 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
427 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
429 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
432 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
433 duCb.ueCcchCtxt[ueIdx].cellId);
438 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
445 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
447 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
449 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
450 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
453 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
454 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
467 /******************************************************************
469 * @brief Generates GNB DU Ue F1AP ID
473 * Function : genGnbDuUeF1apId
475 * Functionality: Generates GNB DU Ue F1AP ID
478 * @return gnbDuF1apId
480 * ****************************************************************/
481 uint32_t genGnbDuUeF1apId()
483 static uint32_t gnbDuUeF1apId = 0;
485 return ++gnbDuUeF1apId;
488 /******************************************************************
490 * @brief Processes UL CCCH Ind recvd from MAC
494 * Function : duProcUlCcchInd
496 * Functionality: Processes UL CCCH Ind recvd from MAC
498 * @params[in] UlCcchIndInfo *ulCcchIndInfo
499 * @return ROK - success
502 * ****************************************************************/
503 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
507 uint32_t gnbDuUeF1apId = 0;
509 gnbDuUeF1apId = genGnbDuUeF1apId();
511 /* Store Ue mapping */
512 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
513 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
514 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
518 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
519 ulCcchIndInfo->ulCcchMsg));
522 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
525 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
526 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
532 /******************************************************************
534 * @brief Fills Default UL LC Cfg
538 * Function : fillDefaultUlLcCfg
540 * Functionality: Fills Default UL LC Cfg
542 * @params[in] UlLcCfg *ulLcCfg
544 *****************************************************************/
545 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
547 ulLcCfg->priority = LC_PRIORITY_1;
548 ulLcCfg->lcGroup = 0;
549 ulLcCfg->schReqId = 0;
550 ulLcCfg->pbr = PBR_KBPS_INFINITY;
551 ulLcCfg->bsd = BSD_MS_1000;
554 /******************************************************************
556 * @brief Fills Initial DL Bandwidth Part
560 * Function : fillDefaultInitDlBwp
562 * Functionality: Fills Initial DL Bandwidth Part
564 * @params[in] InitialDlBwp *initDlBwp
567 *****************************************************************/
568 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
571 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
572 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
577 /* Filling PDCCH Config */
578 initDlBwp->pdcchPresent = TRUE;
579 if(initDlBwp->pdcchPresent)
581 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
582 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
583 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
585 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
586 PDCCH_CTRL_RSRC_SET_ONE_ID;
587 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
589 coreset0EndPrb = CORESET0_END_PRB;
590 coreset1StartPrb = coreset0EndPrb +6;
591 coreset1NumPrb = CORESET1_NUM_PRB;
592 /* calculate the PRBs */
593 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
594 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
597 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
598 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
599 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
600 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
601 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
603 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
606 initDlBwp->pdcchCfg.numCRsetToRel = 0;
607 /* Filling Serach Space */
608 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
609 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
610 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
612 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
613 PDCCH_SRCH_SPC_TWO_ID;
614 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
615 PDCCH_CTRL_RSRC_SET_ONE_ID;
616 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
617 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
618 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
619 MONITORING_SYMB_WITHIN_SLOT_SIZE);
620 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
621 PDCCH_SYMBOL_WITHIN_SLOT;
622 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
624 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
626 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
628 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
630 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
632 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
633 SEARCHSPACETYPE_PR_UE_SPECIFIC;
634 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
635 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
637 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
641 /* Filling PDSCH Config */
642 initDlBwp->pdschPresent = TRUE;
643 if(initDlBwp->pdschPresent)
645 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
646 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
647 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
648 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
650 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
651 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
652 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
653 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
654 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
655 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
656 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
657 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
663 /******************************************************************
665 * @brief Fills Initial UL Bandwidth Part
669 * Function : fillDefaultInitUlBwp
671 * Functionality: Fills Initial UL Bandwidth Part
673 * @params[in] InitialUlBwp *initUlBwp
676 *****************************************************************/
677 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
682 initUlBwp->pucchPresent = FALSE;
684 /*Filling PUSCH Config */
685 initUlBwp->puschPresent = TRUE;
686 if(initUlBwp->puschPresent)
688 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
689 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
690 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
691 scramblingId0 = SCRAMBLING_ID;
692 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
693 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
695 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
697 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
698 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
700 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
701 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
702 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
703 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
705 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
710 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
714 /******************************************************************
716 * @brief Fills SpCell Group Info
720 * Function : fillDefaultSpCellGrpInfo
722 * Functionality: Fills Sp Cell Group Info
724 * @params[in] SpCellCfg *spCell
727 *****************************************************************/
728 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
732 spCell->servCellIdx = SERV_CELL_IDX;
733 /* Filling Initial Dl Bwp */
734 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
736 spCell->servCellCfg.numDlBwpToAdd = 0;
737 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
738 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
739 spCell->servCellCfg.bwpInactivityTmr = NULLP;
740 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
741 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
742 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
743 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
744 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
745 NUM_HARQ_PROC_FOR_PDSCH_N_16;
746 /* Filling Initial UL Bwp*/
747 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
748 spCell->servCellCfg.numUlBwpToAdd = 0;
749 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
753 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
757 /******************************************************************
759 * @brief Fills Physical Cell Group Info
763 * Function : fillDefaultPhyCellGrpInfo
765 * Functionality: Fills Physical Cell Group Info
767 * @params[in] PhyCellGrpCfg *cellGrp
770 *****************************************************************/
771 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
775 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
776 cellGrp->pNrFr1 = P_NR_FR1;
780 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
784 /******************************************************************
786 * @brief Fills Mac Cell Group Info
790 * Function : fillDefaultMacCellGrpInfo
792 * Functionality: Fills Mac Cell Group Info
794 * @params[in] MacCellGrpCfg *cellGrp
797 *****************************************************************/
798 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
804 /* Filling Scheduling Request Config */
805 cellGrp->schReqCfg.addModListCount = 1;
806 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
808 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
810 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
811 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
812 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
815 cellGrp->schReqCfg.relListCount = 0;
817 /* Filling Tag config */
818 cellGrp->tagCfg.addModListCount = 1;
819 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
821 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
823 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
824 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
827 cellGrp->tagCfg.relListCount = 0;
829 /* Filling BSR config */
830 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
831 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
832 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
834 /* Filling PHR config */
835 cellGrp->phrCfgSetupPres = true;
836 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
837 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
838 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
839 cellGrp->phrCfg.multiplePHR = false;
840 cellGrp->phrCfg.dummy = false;
841 cellGrp->phrCfg.phrType2OtherCell = false;
842 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
847 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
851 /*******************************************************************
853 * @brief Fills default modulation info for a UE
857 * Function : fillDefaultModulation
859 * Functionality: Fills default modulation info for a UE
861 * @params[in] Pointer to MAC UE configuration
862 * @return ROK - success
865 * ****************************************************************/
866 void fillDefaultModulation(MacUeCfg *ueCfg)
868 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
869 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
870 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
872 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
873 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
874 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
877 /******************************************************************
879 * @brief Function to fill Mac Lc Cfg for SRB1
883 * Function : fillMacSrb1LcCfg
885 * Functionality: Function to fill Mac Lc cfg for SRB1
887 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
889 *****************************************************************/
891 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
893 macLcCfg->lcId = SRB1_LCID;
894 macLcCfg->configType = CONFIG_ADD;
895 macLcCfg->drbQos = NULLP;
896 macLcCfg->snssai = NULLP;
897 macLcCfg->ulLcCfgPres = true;
898 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
901 /******************************************************************
903 * @brief Function to fill the Lc cfg from ueSetupReqDb
907 * Function : fillMacLcCfgToAddMod
909 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
911 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
912 * @return ROK/RFAILED
914 *****************************************************************/
916 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
919 lcCfg->lcId = ueSetReqDb->lcId;
920 lcCfg->configType = ueSetReqDb->configType;
922 if(ueSetReqDb->drbQos)
926 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
929 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
935 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
940 lcCfg->drbQos = NULLP;
945 if(ueSetReqDb->snssai)
949 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
952 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
959 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
963 lcCfg->snssai = NULLP;
966 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
967 lcCfg->drbQos = NULLP;
973 lcCfg->snssai = NULLP;
975 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
976 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
977 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
981 /******************************************************************
983 * @brief Function to copy the Bit rate from ueSetupReqDb
987 * Function : fillAmbr
989 * Functionality: Function to copy bit Rate from ueSetupReqDb
991 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
992 * @return ROK/RFAILED
994 *****************************************************************/
996 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
1000 if(*macAmbr == NULLP)
1002 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
1003 if(*macAmbr == NULLP)
1005 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1009 memset(*macAmbr, 0, sizeof(AmbrCfg));
1010 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
1019 /******************************************************************
1021 * @brief Builds and Send UE ReConfig Request to MAC
1025 * Function : sendUeReCfgReqToMac
1027 * Functionality: Builds and Send UE ReConfig Request to MAC
1029 * @Params[in] MacUeCfg pointer
1030 * @return ROK - success
1033 * ****************************************************************/
1035 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1041 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1045 /* Processing one Ue at a time to MAC */
1046 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1047 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1050 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1051 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1056 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1062 /******************************************************************
1064 * @brief Function to return Drb LcId
1068 * Function : getDrbLcId
1070 * Functionality: Function to return Drb LcId
1072 * Returns: lcId - SUCCESS
1074 *****************************************************************/
1076 uint8_t getDrbLcId(uint32_t *drbBitMap)
1078 uint8_t bitMask = 1, bitPos = 0;
1079 bitPos = MIN_DRB_LCID;
1081 while(bitPos <= MAX_DRB_LCID)
1083 if((*drbBitMap & (bitMask << bitPos)) == 0)
1085 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1093 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1097 /******************************************************************
1099 * @brief Fills MacUeCfg structure
1103 * Function : fillMacUeCfg
1105 * Functionality: Fills MacUeCfg
1107 * @params[in] cellId, ueIdx, crnti,
1110 * @return ROK/RFAILED
1112 *****************************************************************/
1113 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1114 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1116 uint8_t ret, dbIdx, lcIdx, cellIdx;
1117 bool lcIdFound = false;
1118 MacUeCfg *duMacDb = NULLP;
1124 macUeCfg->cellId = cellId;
1125 macUeCfg->ueIdx = ueIdx;
1126 macUeCfg->crnti = crnti;
1127 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1128 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1129 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1130 macUeCfg->ambrCfg = NULLP;
1131 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1132 fillDefaultModulation(macUeCfg);
1137 /* Fetching MacDb from DuUeCb */
1138 GET_CELL_IDX(cellId, cellIdx);
1139 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1140 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1141 macUeCfg->cellId = cellId;
1142 macUeCfg->ueIdx = ueIdx;
1143 macUeCfg->crnti = crnti;
1144 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1147 if(macUeCfg->spCellCfgPres == true)
1149 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1151 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1152 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1154 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1156 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1157 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1160 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1161 if(ueCfgDb->ueNrCapability != NULLP)
1163 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1167 /* Filling LC Context */
1168 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1170 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1172 /* Filling default UL LC config in MAC if not present */
1173 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1174 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1176 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1178 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1181 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1182 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1184 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1185 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1193 /* ADD/DEL CONFIG */
1194 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1202 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1205 }/*End of Outer FOR loop */
1210 /******************************************************************
1212 * @brief Fills Rlc AM Information
1216 * Function : fillDefaultAmInfo
1218 * Functionality: Fills Rlc AM Information
1220 * @params[in] AmBearerCfg *amCfg
1223 *****************************************************************/
1224 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1227 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1228 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1229 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1230 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1231 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1234 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1235 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1236 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1239 /******************************************************************
1241 * @brief Fills RLC UM Bi Directional Information
1245 * Function : fillDefaultUmBiInfo
1247 * Functionality: Fills RLC UM Bi Directional Information
1249 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1252 *****************************************************************/
1253 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1255 /* UL UM BI DIR INFO */
1256 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1257 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1259 /* DL UM BI DIR INFO */
1260 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1263 /******************************************************************
1265 * @brief Fills RLC UM Uni Directional UL Information
1269 * Function : fillDefaultUmUlInfo
1271 * Functionality: Fills RLC UM Uni Directional Info
1273 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1276 *****************************************************************/
1277 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1279 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1280 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1283 /******************************************************************
1285 * @brief Fills RLC UM Uni Directional DL Information
1289 * Function : fillDefaultUmDlInfo
1291 * Functionality: Fills RLC UM Uni Directional DL Info
1293 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1296 *****************************************************************/
1297 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1299 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1302 /******************************************************************
1304 * @brief Builds Rlc Mode Default Configuration
1308 * Function : fillDefaultRlcModeCfg
1310 * Functionality: Builds Rlc Mode Default Configuration
1312 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1313 * @return ROK/RFAILED
1315 *****************************************************************/
1317 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1328 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1330 fillDefaultAmInfo(lcCfg->u.amCfg);
1333 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1339 case RLC_UM_BI_DIRECTIONAL :
1341 if(!lcCfg->u.umBiDirCfg)
1343 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1344 if(lcCfg->u.umBiDirCfg)
1345 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1348 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1354 case RLC_UM_UNI_DIRECTIONAL_UL :
1356 if(!lcCfg->u.umUniDirUlCfg)
1358 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1359 if(lcCfg->u.umUniDirUlCfg)
1360 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1363 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1369 case RLC_UM_UNI_DIRECTIONAL_DL :
1371 if(!lcCfg->u.umUniDirDlCfg)
1373 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1374 if(lcCfg->u.umUniDirDlCfg)
1375 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1378 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1385 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1392 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1398 /*******************************************************************
1400 * @brief Function to fill Rlc Lc Cfg for SRB1
1404 * Function : fillRlcSrb1LcCfg
1407 * Function to fill Rlc Lc Cfg for SRB1
1409 * @params[in] Pointer to RlcBearerCfg
1410 * @return ROK/RFAILED
1412 *****************************************************************/
1414 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1418 rlcLcCfg->rbId = SRB1_LCID;
1419 rlcLcCfg->rbType = RB_TYPE_SRB;
1420 rlcLcCfg->lcId = SRB1_LCID;
1421 rlcLcCfg->lcType = LCH_DCCH;
1422 rlcLcCfg->rlcMode = RLC_AM;
1423 rlcLcCfg->configType = CONFIG_ADD;
1424 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1428 /*******************************************************************
1430 * @brief Processes UE ReConfig Req to RLC UL
1434 * Function : sendUeReCfgReqToRlc
1437 * Processes UE Reconfig Req to RLC UL
1439 * @params[in] Pointer to RlcUeCfg
1440 * @return ROK - success
1443 *****************************************************************/
1445 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1450 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1453 /* Processing one Ue at a time to RLC */
1454 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1455 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1458 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1459 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1464 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1470 /******************************************************************
1472 * @brief Fills RlcBearerCfg structure
1476 * Function : fillRlcUeCfg
1478 * Functionality: Fills Rlc Bearer Cfg
1481 *****************************************************************/
1482 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1483 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1485 uint8_t ret, dbIdx, lcIdx, cellIdx;
1486 bool lcIdFound = false;
1487 RlcUeCfg *duRlcDb = NULLP;
1492 /* Initial RB being Added */
1493 rlcUeCfg->cellId = cellId;
1494 rlcUeCfg->ueIdx = ueIdx;
1495 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1499 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1503 /* Fetch RlcDb from DuUeCb */
1504 GET_CELL_IDX(cellId, cellIdx);
1505 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1506 /*Filling RlcUeCfg */
1507 rlcUeCfg->cellId = cellId;
1508 rlcUeCfg->ueIdx = ueIdx;
1509 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1511 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1514 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1515 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1518 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1519 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1521 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1524 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1525 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1528 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1529 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1537 /* ADD/ DEL Config Type */
1538 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1546 /******************************************************************
1548 * @brief creates UE context
1552 * Function : duCreateUeCb
1554 * Functionality: Creates UE Conetxt
1556 * @params[in] UeCcchCtxt Pointer
1559 * @return ROK - success
1561 * ****************************************************************/
1562 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1564 uint8_t cellIdx = 0;
1568 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1570 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1572 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1573 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1575 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1576 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1577 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1578 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1579 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1580 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1582 /* Filling Mac Ue Config */
1583 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1584 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1585 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1587 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1589 /* Filling Rlc Ue Config */
1590 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1591 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1592 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1594 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1596 duCb.actvCellLst[cellIdx]->numActvUes++;
1597 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1603 /******************************************************************
1605 * @brief Builds and Send UE Create Request to MAC
1609 * Function : duBuildAndSendUeCreateReqToMac
1611 * Functionality: Builds and Send UE Create Request to MAC
1613 * @Params[in] cellId,
1615 * @return ROK - success
1618 * ****************************************************************/
1620 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1621 uint16_t crnti, MacUeCfg *duMacUeCfg)
1624 MacUeCfg *macUeCfg = NULLP;
1626 memset(&pst, 0, sizeof(Pst));
1629 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1632 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1636 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1638 /* Copying ueCb to a sharable buffer */
1639 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1642 memset(macUeCfg, 0, sizeof(MacUeCfg));
1643 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1644 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1646 /* Processing one Ue at a time to MAC */
1647 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1650 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1651 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1656 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1662 /*******************************************************************
1664 * @brief To update DuUeCb Mac Cfg
1668 * Function : duUpdateMacCfg
1669 * Functionality: update DuUeCb MAC Cfg
1671 * @params[in] DuUeCb Pointer
1672 * F1UeContextSetupDb pointer
1673 * @return ROK - success
1676 * ****************************************************************/
1677 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1679 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1682 /*Filling Cell Group Cfg*/
1683 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1686 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1688 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1689 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1691 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1693 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1694 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1696 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1698 /* Filling LC Context */
1699 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1701 numLcs = macUeCfg->numLcs;
1702 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1704 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1706 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1708 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1710 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1712 /* Free memory at matched lcIdx index */
1713 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1715 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1717 /* moving all elements one index ahead */
1718 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1719 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1722 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1729 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1731 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1734 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1744 /******************************************************************
1746 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1750 * Function : fillRlcCfgToAddMod
1752 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1755 *****************************************************************/
1757 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1759 lcCfg->configType = f1UeDbLcCfg->configType;
1760 lcCfg->rbId = f1UeDbLcCfg->rbId;
1761 lcCfg->rbType = f1UeDbLcCfg->rbType;
1762 lcCfg->lcId = f1UeDbLcCfg->lcId;
1763 lcCfg->lcType = f1UeDbLcCfg->lcType;
1764 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1765 switch(lcCfg->rlcMode)
1771 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1776 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1777 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1778 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1779 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1780 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1783 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1784 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1785 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1788 case RLC_UM_BI_DIRECTIONAL :
1790 if(!lcCfg->u.umBiDirCfg)
1792 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1793 if(!lcCfg->u.umBiDirCfg)
1796 /* UL UM BI DIR INFO */
1797 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1798 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1799 /* DL UM BI DIR INFO */
1800 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1803 case RLC_UM_UNI_DIRECTIONAL_UL :
1805 if(!lcCfg->u.umUniDirUlCfg)
1807 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1808 if(!lcCfg->u.umUniDirUlCfg)
1811 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1812 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1816 case RLC_UM_UNI_DIRECTIONAL_DL :
1818 if(!lcCfg->u.umUniDirDlCfg)
1820 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1821 if(!lcCfg->u.umUniDirDlCfg)
1824 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1828 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1834 /*******************************************************************
1836 * @brief To update DuUeCb Rlc Lc Cfg
1840 * Function : duUpdateRlcLcCfg
1841 * Functionality: update DuUeCb Rlc Lc Cfg
1843 * @params[in] DuUeCb Pointer
1844 * F1UeContextSetupDb pointer
1845 * @return ROK - success
1848 * ****************************************************************/
1850 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1852 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1855 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1857 numLcs = rlcUeCfg->numLcs;
1858 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1860 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1862 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1864 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1866 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1868 /* Free memory at matched lcIdx index */
1869 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1871 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1873 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1874 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1877 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1884 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1886 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1895 /*******************************************************************
1897 * @brief Function to fill Tunnel Config to Add/Mod
1902 * Function : fillTnlCfgToAddMod
1904 * Functionality: Function to fill tunnel Config to Add/Mod
1906 * @params[in] Pointer to tnlCfgDb,
1907 * pointer to f1TnlCfg
1908 * @return ROK - success
1911 * ****************************************************************/
1912 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1914 if(*ueCbTnlCfg == NULLP)
1916 /* copying to DuCb Tnl Cfg */
1917 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1918 if(*ueCbTnlCfg == NULLP)
1920 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1924 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1925 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1926 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1927 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1928 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1929 if(f1TnlCfg->tnlCfg1)
1931 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1933 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1934 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1936 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1940 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1941 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1942 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1943 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1948 /*******************************************************************
1950 * @brief Processing the tunnel Request to EGTP
1954 * Function : duProcEgtpTunnelCfg
1956 * Functionality: Processing the tunnel Request to EGTP
1958 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1959 * @return ROK - success
1962 * ****************************************************************/
1964 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1966 uint8_t ret = RFAILED, delIdx;
1968 if(f1TnlCfg->tnlCfg1 == NULLP)
1970 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1974 if(f1TnlCfg->configType == CONFIG_ADD)
1976 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1978 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1985 else if(f1TnlCfg->configType == CONFIG_MOD)
1987 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1989 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
1995 else if(f1TnlCfg->configType == CONFIG_DEL)
1997 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1999 /* Free memory at drbIdx */
2000 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
2001 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
2003 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2005 /* moving all elements one index ahead */
2006 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2017 /***********************************************************************
2019 * @brief Function to fill Tunnel Config
2020 * and sends tunnel Req to EGTP
2025 * Function : duUpdateTunnelCfgDb
2027 * Functionality: Function to fill tunnel Config
2028 * and sends tunnel Cfg Req to EGTP
2030 * @params[in] ueIdx, cellId, DuUeCfg
2031 * @return ROK - success
2034 * ****************************************************************/
2036 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2038 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2039 bool drbFound = false;
2041 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2042 /*then update drbId and tunnel Info in duCb */
2043 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2045 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2046 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2047 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2049 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2051 drbFound = true; /* existing DRB */
2052 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2054 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2055 duUeCfg->upTnlInfo[drbIdx].drbId);
2063 if(!drbFound && ret == ROK)/* new DRB to Add */
2065 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2067 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2068 duUeCfg->upTnlInfo[drbIdx].drbId);
2079 /*******************************************************************
2081 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2086 * Function : duUpdateDuUeCbCfg
2088 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2090 * @params[in] ueIdx, cellIdx
2091 * @return ROK - success
2094 * ****************************************************************/
2096 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2098 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2099 DuUeCb *ueCb = NULLP;
2101 GET_CELL_IDX(cellId, cellIdx);
2103 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2104 macUeCfgState == UE_RECFG_COMPLETE) &&
2105 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2106 rlcUeCfgState == UE_RECFG_COMPLETE))
2108 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2110 /*Filling RLC Ue Cfg */
2111 ueCb->rlcUeCfg.cellId = cellId;
2112 ueCb->rlcUeCfg.ueIdx = ueIdx;
2113 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2116 /*Filling MAC Ue Cfg */
2117 GET_CRNTI(crnti, ueIdx);
2118 ueCb->macUeCfg.cellId = cellId;
2119 ueCb->macUeCfg.ueIdx = ueIdx;
2120 ueCb->macUeCfg.crnti = crnti;
2121 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2123 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2126 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2128 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2134 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2141 /*******************************************************************
2143 * @brief Handle UE config response from MAC
2147 * Function : DuProcMacUeCfgRsp
2149 * Functionality: Handle UE Config response from MAC
2151 * @params[in] Pointer to MacUeCfgRsp and Pst
2152 * @return ROK - success
2155 * ****************************************************************/
2156 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2162 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2164 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2166 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2167 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2168 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2170 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2172 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2173 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2174 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2175 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2177 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2178 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2179 macUeCfg.macUeCfgState = 0;
2185 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2186 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2188 //TODO: Send the failure case in Ue Context Setup Response
2192 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2196 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2203 /*******************************************************************
2205 * @brief Processes UE create Req to RLC UL
2209 * Function : duBuildAndSendUeCreateReqToRlc
2212 * Processes UE create Req to RLC UL
2214 * @params[in] cellId,
2216 * Pointer to RlcUeCfg
2217 * @return ROK - success
2220 *****************************************************************/
2222 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2223 RlcUeCfg *duRlcUeCfg)
2226 RlcUeCfg *rlcUeCfg = NULLP;
2229 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2232 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2236 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2237 /* Copying ueCfg to a sharable buffer */
2238 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2241 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2242 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2243 /* Processing one Ue at a time to RLC */
2244 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2245 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2248 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2249 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2255 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2261 /*******************************************************************
2263 * @brief Processes UE create Rsp received from RLC UL
2268 * Function : DuProcRlcUeCfgRsp
2271 * Processes UE create Rsp received from RLC UL
2273 * @params[in] Post structure
2274 * Pointer to RlcCfgCfm
2275 * @return ROK - success
2278 *****************************************************************/
2279 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2285 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2287 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2289 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2290 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2291 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2293 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2295 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2296 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2297 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2298 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2300 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2301 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2302 rlcUeCfg.rlcUeCfgState = 0;
2308 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2309 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2310 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2312 //TODO: update failure case in ue Context setup Response
2316 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2320 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2326 /*******************************************************************
2328 * @brief Builds and Send Ue Reconfig Req to RLC
2332 * Function : duBuildAndSendUeReCfgReqToRLC
2334 * Functionality: Builds and Send Ue Reconfig Req to RLC
2336 * @params[in] cellId, crnti
2338 * RlcUeCfg *rlcUeCfg
2339 * @return ROK - success
2342 * ****************************************************************/
2344 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2346 uint8_t ret = ROK, ueIdx = 0;
2347 RlcUeCfg *rlcUeCfg = NULLP;
2349 GET_UE_IDX(crnti, ueIdx);
2350 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2353 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2354 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2356 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2358 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2362 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2368 /*******************************************************************
2370 * @brief Builds and Send Ue Reconfig Req to MAC
2374 * Function : duBuildAndSendUeReCfgReqToMac
2376 * Functionality: Builds and Send Ue Reconfig Req to MAC
2378 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2380 * MacUeCfg *macUeCfg
2381 * @return ROK - success
2384 * ****************************************************************/
2386 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2388 uint8_t ret, ueIdx = 0;
2389 MacUeCfg *macUeCfg = NULLP;
2392 GET_UE_IDX(crnti, ueIdx);
2394 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2397 memset(macUeCfg, 0, sizeof(MacUeCfg));
2398 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2400 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2402 ret = sendUeReCfgReqToMac(macUeCfg);
2406 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2412 /*******************************************************************
2414 * @brief Build and Send Ue context setup request
2419 * Function : duBuildAndSendUeContextSetupReq
2422 * Build and Send Ue context setup request
2424 * @params[in] cellId, crnti, DuUeCfg pointer
2425 * @return ROK - success
2428 *****************************************************************/
2430 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2434 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2435 /* Filling RLC Ue Reconfig */
2436 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2438 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2440 /* Filling MAC Ue Reconfig */
2441 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2443 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2448 /*******************************************************************
2450 * @brief Processes DL Rsp received from RLC DL
2455 * Function : DuProcRlcDlRrcMsgRsp
2458 * Processes UE Rsp received from RLC DL
2460 * @params[in] Post structure
2461 * Pointer to RlcCfgCfm
2462 * @return ROK - success
2465 *****************************************************************/
2466 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2468 uint8_t ret = ROK, ueIdx = 0;
2469 DuUeCb *ueCb = NULLP;
2471 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2473 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2474 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2475 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2477 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2479 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2481 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2483 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2485 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2487 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2492 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2494 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2497 /*******************************************************************
2499 * @brief Process UE context setup request from CU
2503 * Function : duProcUeContextSetupRequest
2505 * Functionality: Process UE context setup request from CU
2507 * @params[in] F1AP message
2508 * @return ROK - success
2511 * ****************************************************************/
2513 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2515 uint8_t ret, cellId;
2520 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2521 /* Send DL RRC msg for security Mode */
2522 if(ueCb->f1UeDb->dlRrcMsg)
2524 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2526 /* Sending DL RRC Message to RLC */
2527 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2530 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2531 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2532 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2533 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2537 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2539 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2542 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2548 //TODO: To send the failure cause in UeContextSetupRsp
2549 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2554 /*******************************************************************
2556 * @brief Build and Send Ue context mod request
2561 * Function : duBuildAndSendUeContextModReq
2564 * Build and Send Ue context mod request
2566 * @params[in] cellId, crnti, DuUeCfg pointer
2567 * @return ROK - success
2570 *****************************************************************/
2572 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2576 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2577 /* Filling RLC Ue Reconfig */
2578 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2580 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2582 /* Filling MAC Ue Reconfig */
2583 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2585 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2589 /*******************************************************************
2591 * @brief Processing Ue context mod request
2596 * Function : duProcUeContextModReq
2599 * Processing Ue context mod request
2601 * @params[in] DuUeCb *ueCb
2602 * @return ROK - success
2605 *****************************************************************/
2607 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2609 uint8_t ret, cellId;
2614 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2615 /* Send DL RRC msg for security Mode */
2616 if(ueCb->f1UeDb->dlRrcMsg)
2618 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2620 /* Sending DL RRC Message to RLC */
2621 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2624 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2625 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2626 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2627 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2633 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2636 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2642 //TODO: To send the failure cause in UeContextModRsp
2643 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2648 /*******************************************************************
2650 * @brief Function to delete Pdsch ServCellCfg
2654 * Function : deletePdschServCellCfg
2656 * Functionality: Function to delete Pdsch ServCellCfg
2658 * @params[in] PdschServCellCfg *pdschServCellCfg
2661 * ****************************************************************/
2663 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2665 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2666 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2667 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2668 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2671 /*******************************************************************
2673 * @brief delete MacUeCfg from duCb
2677 * Function : deleteMacUeCfg
2679 * Functionality: delete MacUeCfg from duCb
2681 * @params[in] Pointer to MacUeCfg
2682 * @return ROK - success
2685 *******************************************************************/
2687 void deleteMacUeCfg(MacUeCfg *ueCfg)
2691 ServCellCfgInfo *servCellCfg;
2692 PucchResrcInfo *resrcToAddModList;
2696 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2697 if(ueCfg->spCellCfgPres)
2699 servCellCfg = &ueCfg->spCellCfg.servCellCfg;
2700 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->bwpInactivityTmr, sizeof(uint8_t));
2701 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrcSet,\
2702 sizeof(PucchResrcSetCfg));
2703 if(servCellCfg->initUlBwp.pucchCfg.resrc)
2705 /*freeing the PucchResrcCfg*/
2706 for(resrcIdx= 0; resrcIdx< servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModListCount; resrcIdx++)
2708 resrcToAddModList=&servCellCfg->initUlBwp.pucchCfg.resrc->resrcToAddModList[resrcIdx];
2709 switch(resrcToAddModList->pucchFormat)
2711 case PUCCH_FORMAT_0:
2713 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format0 ,\
2714 sizeof(PucchFormat0));
2717 case PUCCH_FORMAT_1:
2719 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format1 ,\
2720 sizeof(PucchFormat1));
2723 case PUCCH_FORMAT_2:
2725 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format2 ,\
2726 sizeof(PucchFormat2_3));
2729 case PUCCH_FORMAT_3:
2731 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format3 ,\
2732 sizeof(PucchFormat2_3));
2735 case PUCCH_FORMAT_4:
2737 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,resrcToAddModList->PucchFormat.format4 ,\
2738 sizeof(PucchFormat4));
2743 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.resrc,\
2744 sizeof(PucchResrcCfg));
2746 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format1,\
2747 sizeof(PucchFormatCfg));
2748 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format2,\
2749 sizeof(PucchFormatCfg));
2750 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format3,\
2751 sizeof(PucchFormatCfg));
2752 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.format4,\
2753 sizeof(PucchFormatCfg));
2754 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.schedReq,\
2755 sizeof(PucchSchedReqCfg));
2756 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.multiCsiCfg,\
2757 sizeof(PucchMultiCsiCfg));
2758 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.spatialInfo,\
2759 sizeof(PucchSpatialCfg));
2760 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.dlDataToUlAck ,\
2761 sizeof(PucchDlDataToUlAck));
2762 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,servCellCfg->initUlBwp.pucchCfg.powerControl,\
2763 sizeof(PucchPowerControl));
2764 deletePdschServCellCfg(&servCellCfg->pdschServCellCfg);
2766 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2768 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].drbQos, sizeof(DrbQosInfo));
2769 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->lcCfgList[lcCfgIdx].snssai, sizeof(Snssai));
2772 memset(ueCfg, 0, sizeof(MacUeCfg));
2775 /*******************************************************************
2777 * @brief Handle UE delete response from MAC
2781 * Function : DuProcMacUeDeleteRsp
2783 * Functionality: Handle UE delete response from MAC
2785 * @params[in] Pointer to MacUeDeleteRsp and Pst
2786 * @return ROK - success
2789 * ****************************************************************/
2791 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2796 if(deleteRsp->result == SUCCESS)
2798 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueIdx);
2799 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2800 if(duCb.actvCellLst[cellIdx])
2802 deleteMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueIdx -1].macUeCfg);
2807 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2811 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2815 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2821 /*******************************************************************
2823 * @brief delete RlcUeCfg from duCb
2827 * Function : deleteDuRlcUeCfg
2830 * delete RlcUeCfg from duCb
2832 * @params[in] Post structure
2833 * Pointer to RlcUeCfg
2834 * @return ROK - success
2837 *****************************************************************/
2839 void deleteDuRlcUeCfg(RlcUeCfg *ueCfg)
2842 RlcBearerCfg *lcCfg= NULLP;
2845 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
2847 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
2848 switch(lcCfg->rlcMode)
2852 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
2855 case RLC_UM_BI_DIRECTIONAL :
2857 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2860 case RLC_UM_UNI_DIRECTIONAL_UL :
2862 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2865 case RLC_UM_UNI_DIRECTIONAL_DL :
2867 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2872 memset(ueCfg, 0, sizeof(RlcUeCfg));
2876 /*******************************************************************
2878 * @brief Processes UE Delete Rsp received from RLC
2882 * Function : DuProcRlcUeDeleteRsp
2885 * Processes UE Delete Rsp received from RLC
2887 * @params[in] Post structure
2888 * Pointer to RlcUeDeleteRsp
2889 * @return ROK - success
2892 *****************************************************************/
2894 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2896 uint8_t ueIdx = 0, ret = ROK;
2897 uint16_t cellIdx = 0;
2900 ueIdx = delRsp->ueIdx;
2901 GET_CELL_IDX(delRsp->cellId, cellIdx);
2903 if(delRsp->result == SUCCESSFUL)
2905 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueIdx);
2906 if(duCb.actvCellLst[cellIdx]!=NULLP)
2908 deleteDuRlcUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
2913 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueIdx);
2916 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2922 /*******************************************************************
2924 * @brief Sending UE Delete Req To Mac
2928 * Function : sendUeDeleteReqToMac
2931 * sending UE Delete Req To Mac
2933 * @params[in] cellId, ueIdx, crnti
2934 * @return ROK - success
2937 *****************************************************************/
2939 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueIdx, uint16_t crnti)
2943 MacUeDelete *ueDelete = NULLP;
2945 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2948 ueDelete->cellId = cellId;
2949 ueDelete->ueIdx = ueIdx;
2950 ueDelete->crnti = crnti;
2951 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2953 /* Processing one Ue at a time to MAC */
2954 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2955 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2958 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2959 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2964 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
2970 /*******************************************************************
2972 * @brief Sending UE Delete Req To Rlc
2976 * Function : sendUeDeleteReqToRlc
2979 * Sending UE Delete Req To Rlc
2981 * @params[in] cellId, ueIdx
2982 * @return ROK - success
2985 *****************************************************************/
2987 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueIdx)
2991 RlcUeDelete *ueDelete;
2993 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
2994 if(ueDelete !=NULLP)
2996 ueDelete->cellId = cellId;
2997 ueDelete->ueIdx = ueIdx;
2998 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3000 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3003 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3004 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3009 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3015 /*******************************************************************
3017 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3021 * Function : duProcUeDeleteReq
3023 * Functionality: DU processes UE delete req from CU and sends to MAC
3026 * @params[in] cellId, crnti
3027 * @return ROK - success
3030 * ****************************************************************/
3032 uint8_t duProcUeDeleteReq(uint16_t cellId, uint16_t crnti)
3034 uint16_t cellIdx = 0;
3037 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3038 GET_CELL_IDX(cellId, cellIdx);
3039 GET_UE_IDX(crnti, ueIdx);
3041 if(duCb.actvCellLst[cellIdx] != NULLP)
3043 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti == crnti)
3045 if(sendUeDeleteReqToRlc(cellId, ueIdx) == RFAILED)
3047 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq():Failed to build UE delete req for RLC ");
3050 if(sendUeDeleteReqToMac(cellId, ueIdx, crnti) == RFAILED)
3052 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Failed to build UE delete req for MAC ");
3059 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): crnti is not found");
3065 DU_LOG("\nERROR --> DU APP : duProcUeDeleteReq(): Cell Id is not found");
3072 /**********************************************************************
3074 ***********************************************************************/