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"
38 #include "AlarmInterface.h"
39 #include "ConfigInterface.h"
42 DuMacDlCcchInd packMacDlCcchIndOpts[] =
44 packMacDlCcchInd, /* Loose coupling */
45 MacProcDlCcchInd, /* TIght coupling */
46 packMacDlCcchInd /* Light weight-loose coupling */
49 DuMacUeCreateReq packMacUeCreateReqOpts[] =
51 packDuMacUeCreateReq, /* Loose coupling */
52 MacProcUeCreateReq, /* TIght coupling */
53 packDuMacUeCreateReq /* Light weight-loose coupling */
56 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
58 packDuRlcUeCreateReq, /* Loose coupling */
59 RlcProcUeCreateReq, /* TIght coupling */
60 packDuRlcUeCreateReq /* Light weight-loose coupling */
63 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
65 packDlRrcMsgToRlc, /* Loose coupling */
66 RlcProcDlRrcMsgTransfer, /* Tight coupling */
67 packDlRrcMsgToRlc /* Light weight-loose coupling */
70 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
72 packDuRlcUeReconfigReq, /* Loose coupling */
73 RlcProcUeReconfigReq, /* TIght coupling */
74 packDuRlcUeReconfigReq /* Light weight-loose coupling */
77 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
79 packDuMacUeReconfigReq, /* Loose coupling */
80 MacProcUeReconfigReq, /* TIght coupling */
81 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
86 packRlcDlUserDataToRlc, /* Loose coupling */
87 RlcProcDlUserDataTransfer, /* Tight coupling */
88 packRlcDlUserDataToRlc /* Light weight-loose coupling */
91 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
93 packDuMacUeDeleteReq, /* Loose coupling */
94 MacProcUeDeleteReq, /* TIght coupling */
95 packDuMacUeDeleteReq /* Light weight-loose coupling */
98 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
100 packDuRlcUeDeleteReq, /* Loose coupling */
101 RlcProcUeDeleteReq, /* TIght coupling */
102 packDuRlcUeDeleteReq /* Light weight-loose coupling */
105 /*******************************************************************
107 * @brief Function to fillDlUserDataInfo
111 * Function : fillDlUserDataInfo
114 * Function to fillDlUserDataInfo
119 * @return ROK - success
122 * ****************************************************************/
124 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
128 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
130 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
132 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
134 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
135 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
136 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
144 /*******************************************************************
146 * @brief Build and Send DL Data Message transfer to RLC
150 * Function : duBuildAndSendDlUserDataToRlc
153 * Build and Send DL Data Message transfer to RLC
155 * @params[in] Cell ID
157 * Logical Channgel ID
160 * @return ROK - success
163 * ****************************************************************/
165 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
167 uint8_t ret = RFAILED;
169 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
171 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
174 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
177 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
178 dlDataMsgInfo->dlMsg = egtpMsg->msg;
179 dlDataMsgInfo->msgLen = msgLen;
181 /* Filling DL DATA Msg Info */
182 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
184 /* Filling post structure and sending msg */
185 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
186 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
187 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
191 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
192 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
193 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
198 /*******************************************************************
200 * @brief Handles EGTP data from CU
204 * Function : duHdlEgtpData
207 * Processes EGTP header and sends data to RLC
209 * @params[in] Pointer to EGTP Message
210 * @return ROK - success
213 * ****************************************************************/
214 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
217 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
221 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
224 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
225 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
227 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
228 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
234 /******************************************************************
236 * @brief Builds and Sends DL CCCH Ind to MAC
240 * Function : duBuildAndSendDlCcchInd
242 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
244 * @params[in] dlCcchMsg - uint8_t*
245 * @return ROK - success
248 * ****************************************************************/
249 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
250 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
254 DlCcchIndInfo *dlCcchIndInfo = NULLP;
257 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
259 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
263 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
267 dlCcchIndInfo->cellId = *cellId;
268 dlCcchIndInfo->crnti = *crnti;
269 dlCcchIndInfo->msgType = msgType;
270 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
272 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
273 if(!dlCcchIndInfo->dlCcchMsg)
275 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
276 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
279 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
281 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
283 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
286 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
287 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
290 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
291 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
292 dlCcchIndInfo->dlCcchMsgLen);
293 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
294 sizeof(DlCcchIndInfo));
302 /*******************************************************************
304 * @brief Build and Send DL RRC Message transfer to RLC
308 * Function : duBuildAndSendDlRrcMsgToRlc
311 * Build and Send DL RRC Message transfer to RLC
313 * @params[in] Cell ID
315 * Logical Channgel ID
318 * @return ROK - success
321 * ****************************************************************/
322 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
327 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
331 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
335 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
338 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
339 duBuildAndSendDlRrcMsgToRlc");
340 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
344 /* Filling up the RRC msg info */
345 dlRrcMsgInfo->cellId = cellId;
346 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
347 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
349 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
351 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
352 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
353 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
354 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
358 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
359 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
360 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
361 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
363 /* Filling post structure and sending msg */
364 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
365 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
366 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
369 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
370 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
379 /******************************************************************
381 * @brief Process DL RRC Msg recevied from F1AP
385 * Function : duProcDlRrcMsg
387 * Functionality: Process DL RRC Msg recevied from F1AP
389 * @params[in] dlCcchMsg - uint8_t*
390 * @return ROK - success
393 * ****************************************************************/
395 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
398 uint16_t crnti, cellId, cellIdx;
399 bool ueCcchCtxtFound = false;
400 bool ueFound = false;
404 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
406 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
408 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
410 ueCcchCtxtFound = true;
411 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
412 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
419 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
422 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
426 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
428 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
431 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
432 duCb.ueCcchCtxt[ueIdx].cellId);
437 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
444 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
446 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
448 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
449 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
452 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
453 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
466 /******************************************************************
468 * @brief Generates GNB DU Ue F1AP ID
472 * Function : genGnbDuUeF1apId
474 * Functionality: Generates GNB DU Ue F1AP ID
477 * @return gnbDuF1apId
479 * ****************************************************************/
480 int32_t genGnbDuUeF1apId(uint8_t cellId)
484 GET_CELL_IDX(cellId, cellIdx);
485 if(duCb.actvCellLst[cellIdx])
487 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
491 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
496 /******************************************************************
498 * @brief Processes UL CCCH Ind recvd from MAC
502 * Function : duProcUlCcchInd
504 * Functionality: Processes UL CCCH Ind recvd from MAC
506 * @params[in] UlCcchIndInfo *ulCcchIndInfo
507 * @return ROK - success
510 * ****************************************************************/
511 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
515 int32_t gnbDuUeF1apId = 0;
517 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
519 if(gnbDuUeF1apId == -1)
521 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
525 /* Store Ue mapping */
526 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
527 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
528 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
532 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
533 ulCcchIndInfo->ulCcchMsg));
536 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
539 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
540 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
546 /******************************************************************
548 * @brief Fills Default UL LC Cfg
552 * Function : fillDefaultUlLcCfg
554 * Functionality: Fills Default UL LC Cfg
556 * @params[in] UlLcCfg *ulLcCfg
558 *****************************************************************/
559 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
561 ulLcCfg->priority = LC_PRIORITY_1;
562 ulLcCfg->lcGroup = 0;
563 ulLcCfg->schReqId = 0;
564 ulLcCfg->pbr = PBR_KBPS_INFINITY;
565 ulLcCfg->bsd = BSD_MS_1000;
568 /******************************************************************
570 * @brief Fills Initial DL Bandwidth Part
574 * Function : fillDefaultInitDlBwp
576 * Functionality: Fills Initial DL Bandwidth Part
578 * @params[in] InitialDlBwp *initDlBwp
581 *****************************************************************/
582 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
585 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
586 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
591 /* Filling PDCCH Config */
592 initDlBwp->pdcchPresent = TRUE;
593 if(initDlBwp->pdcchPresent)
595 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
596 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
597 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
599 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
600 PDCCH_CTRL_RSRC_SET_ONE_ID;
601 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
603 coreset0EndPrb = CORESET0_END_PRB;
604 coreset1StartPrb = coreset0EndPrb +6;
605 coreset1NumPrb = CORESET1_NUM_PRB;
606 /* calculate the PRBs */
607 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
608 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
611 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
612 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
613 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
614 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
615 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
617 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
620 initDlBwp->pdcchCfg.numCRsetToRel = 0;
621 /* Filling Serach Space */
622 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
623 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
624 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
626 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
627 PDCCH_SRCH_SPC_TWO_ID;
628 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
629 PDCCH_CTRL_RSRC_SET_ONE_ID;
630 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
631 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
632 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
633 MONITORING_SYMB_WITHIN_SLOT_SIZE);
634 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
635 PDCCH_SYMBOL_WITHIN_SLOT;
636 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
638 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
640 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
642 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
644 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
646 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
647 SEARCHSPACETYPE_PR_UE_SPECIFIC;
648 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
649 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
651 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
655 /* Filling PDSCH Config */
656 initDlBwp->pdschPresent = TRUE;
657 if(initDlBwp->pdschPresent)
659 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
660 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
661 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
662 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
664 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
665 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
666 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
667 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
668 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
669 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
670 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
671 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
677 /******************************************************************
679 * @brief Fills Initial UL Bandwidth Part
683 * Function : fillDefaultInitUlBwp
685 * Functionality: Fills Initial UL Bandwidth Part
687 * @params[in] InitialUlBwp *initUlBwp
690 *****************************************************************/
691 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
696 initUlBwp->pucchPresent = FALSE;
698 /*Filling PUSCH Config */
699 initUlBwp->puschPresent = TRUE;
700 if(initUlBwp->puschPresent)
702 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
703 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
704 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
705 scramblingId0 = SCRAMBLING_ID;
706 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
707 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
709 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
711 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
712 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
714 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
715 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
716 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
717 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
719 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
724 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
728 /******************************************************************
730 * @brief Fills SpCell Group Info
734 * Function : fillDefaultSpCellGrpInfo
736 * Functionality: Fills Sp Cell Group Info
738 * @params[in] MacUeCfg *macUeCfg
741 *****************************************************************/
742 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
744 SpCellCfg *spCell = NULL;
747 spCell = &macUeCfg->spCellCfg;
751 macUeCfg->spCellCfgPres = true;
753 spCell->servCellIdx = SERV_CELL_IDX;
754 /* Filling Initial Dl Bwp */
755 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
757 spCell->servCellCfg.numDlBwpToAdd = 0;
758 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
759 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
760 spCell->servCellCfg.bwpInactivityTmr = NULLP;
761 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
762 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
763 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
764 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
765 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
766 NUM_HARQ_PROC_FOR_PDSCH_N_16;
767 /* Filling Initial UL Bwp*/
768 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
769 spCell->servCellCfg.numUlBwpToAdd = 0;
770 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
774 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
778 /******************************************************************
780 * @brief Fills Physical Cell Group Info
784 * Function : fillDefaultPhyCellGrpInfo
786 * Functionality: Fills Physical Cell Group Info
788 * @params[in] MacUeCfg *macUeCfg
791 *****************************************************************/
792 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
794 PhyCellGrpCfg *cellGrp = NULL;
797 cellGrp = &macUeCfg->phyCellGrpCfg;
801 macUeCfg->phyCellGrpCfgPres = true;
802 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
803 cellGrp->pNrFr1 = P_NR_FR1;
807 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
811 /******************************************************************
813 * @brief Fills Mac Cell Group Info
817 * Function : fillDefaultMacCellGrpInfo
819 * Functionality: Fills Mac Cell Group Info
821 * @params[in] MacUeCfg *macUeCfg
824 *****************************************************************/
825 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
828 MacCellGrpCfg *cellGrp = NULL;
831 cellGrp = &macUeCfg->macCellGrpCfg;
835 macUeCfg->macCellGrpCfgPres = true;
837 /* Filling Scheduling Request Config */
838 cellGrp->schReqCfg.addModListCount = 1;
839 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
841 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
843 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
844 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
845 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
848 cellGrp->schReqCfg.relListCount = 0;
850 /* Filling Tag config */
851 cellGrp->tagCfg.addModListCount = 1;
852 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
854 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
856 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
857 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
860 cellGrp->tagCfg.relListCount = 0;
862 /* Filling BSR config */
863 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
864 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
865 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
867 /* Filling PHR config */
868 cellGrp->phrCfgSetupPres = true;
869 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
870 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
871 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
872 cellGrp->phrCfg.multiplePHR = false;
873 cellGrp->phrCfg.dummy = false;
874 cellGrp->phrCfg.phrType2OtherCell = false;
875 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
880 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
884 /*******************************************************************
886 * @brief Fills default modulation info for a UE
890 * Function : fillDefaultModulation
892 * Functionality: Fills default modulation info for a UE
894 * @params[in] Pointer to MAC UE configuration
895 * @return ROK - success
898 * ****************************************************************/
899 void fillDefaultModulation(MacUeCfg *ueCfg)
901 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
902 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
903 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
905 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
906 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
907 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
910 /******************************************************************
912 * @brief Function to fill Mac Lc Cfg for SRB1
916 * Function : fillMacSrb1LcCfg
918 * Functionality: Function to fill Mac Lc cfg for SRB1
920 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
922 *****************************************************************/
924 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
926 macLcCfg->lcId = SRB1_LCID;
927 macLcCfg->configType = CONFIG_ADD;
928 macLcCfg->drbQos = NULLP;
929 macLcCfg->snssai = NULLP;
930 macLcCfg->ulLcCfgPres = true;
931 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
934 /******************************************************************
936 * @brief Function to fill the Lc cfg from ueSetupReqDb
940 * Function : fillMacLcCfgToAddMod
942 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
944 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
945 * @return ROK/RFAILED
947 *****************************************************************/
949 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
955 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
956 macLcCfgToSend->configType = ueLcCfgDb->configType;
958 if(ueLcCfgDb->drbQos)
959 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
961 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
963 macLcCfgToSend->drbQos = NULL;
965 if(ueLcCfgDb->snssai)
966 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
968 macLcCfgToSend->snssai = oldLcCfg->snssai;
970 macLcCfgToSend->snssai = NULL;
972 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
973 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
974 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
979 oldLcCfg->lcId = ueLcCfgDb->lcId;
980 oldLcCfg->configType = ueLcCfgDb->configType;
982 if(ueLcCfgDb->drbQos)
985 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
987 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
988 if(oldLcCfg->drbQos == NULL)
990 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
993 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
996 if(ueLcCfgDb->snssai)
999 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1001 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1002 if(oldLcCfg->snssai == NULL)
1004 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1005 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1008 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1011 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1012 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1013 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1018 /******************************************************************
1020 * @brief Function to copy the Bit rate from ueSetupReqDb
1024 * Function : fillAmbr
1026 * Functionality: Function to copy bit Rate from ueSetupReqDb
1028 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1029 * @return ROK/RFAILED
1031 *****************************************************************/
1033 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1039 *macAmbrCfgToSend = ueDbAmbr;
1042 *macAmbrCfgToSend = *oldMacAmbrCfg;
1050 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1052 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1053 if(*oldMacAmbrCfg == NULLP)
1055 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1058 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1059 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1066 /******************************************************************
1068 * @brief Builds and Send UE ReConfig Request to MAC
1072 * Function : sendUeReCfgReqToMac
1074 * Functionality: Builds and Send UE ReConfig Request to MAC
1076 * @Params[in] MacUeCfg pointer
1077 * @return ROK - success
1080 * ****************************************************************/
1082 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1088 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1092 /* Processing one Ue at a time to MAC */
1093 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1094 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1097 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1098 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1103 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1109 /******************************************************************
1111 * @brief Function to return Drb LcId
1115 * Function : getDrbLcId
1117 * Functionality: Function to return Drb LcId
1119 * Returns: lcId - SUCCESS
1121 *****************************************************************/
1123 uint8_t getDrbLcId(uint32_t *drbBitMap)
1125 uint8_t bitMask = 1, bitPos = 0;
1126 bitPos = MIN_DRB_LCID;
1128 while(bitPos <= MAX_DRB_LCID)
1130 if((*drbBitMap & (bitMask << bitPos)) == 0)
1132 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1140 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1144 /******************************************************************
1146 * @brief Fills MacUeCfg structure
1150 * Function : fillMacUeCfg
1152 * Functionality: Fills MacUeCfg
1154 * @params[in] cellId, ueIdx, crnti,
1157 * @return ROK/RFAILED
1159 *****************************************************************/
1160 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1161 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1163 uint8_t ret, dbIdx, lcIdx, cellIdx;
1164 bool lcIdFound = false;
1165 MacUeCfg *duMacDb = NULLP;
1171 macUeCfg->cellId = cellId;
1172 macUeCfg->ueIdx = ueIdx;
1173 macUeCfg->crnti = crnti;
1175 fillDefaultMacCellGrpInfo(macUeCfg);
1176 fillDefaultPhyCellGrpInfo(macUeCfg);
1177 fillDefaultSpCellGrpInfo(macUeCfg);
1178 macUeCfg->ambrCfg = NULLP;
1179 fillDefaultModulation(macUeCfg);
1180 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1185 /* Fetching MacDb from DuUeCb */
1186 GET_CELL_IDX(cellId, cellIdx);
1187 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1188 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1189 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1190 macUeCfg->cellId = cellId;
1191 macUeCfg->ueIdx = ueIdx;
1192 macUeCfg->crnti = crnti;
1193 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1196 if(macUeCfg->spCellCfgPres == true)
1198 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1200 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1201 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1203 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1205 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1206 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1209 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1210 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1213 /* Filling LC Context */
1214 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1216 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1218 /* Filling default UL LC config in MAC if not present */
1219 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1220 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1222 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1224 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1227 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1228 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1230 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1231 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], &duMacDb->lcCfgList[lcIdx], FALSE);
1239 /* ADD/DEL CONFIG */
1240 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1248 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1251 }/*End of Outer FOR loop */
1256 /******************************************************************
1258 * @brief Fills Rlc AM Information
1262 * Function : fillDefaultAmInfo
1264 * Functionality: Fills Rlc AM Information
1266 * @params[in] AmBearerCfg *amCfg
1269 *****************************************************************/
1270 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1273 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1274 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1275 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1276 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1277 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1280 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1281 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1282 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1285 /******************************************************************
1287 * @brief Fills RLC UM Bi Directional Information
1291 * Function : fillDefaultUmBiInfo
1293 * Functionality: Fills RLC UM Bi Directional Information
1295 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1298 *****************************************************************/
1299 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1301 /* UL UM BI DIR INFO */
1302 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1303 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1305 /* DL UM BI DIR INFO */
1306 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1309 /******************************************************************
1311 * @brief Fills RLC UM Uni Directional UL Information
1315 * Function : fillDefaultUmUlInfo
1317 * Functionality: Fills RLC UM Uni Directional Info
1319 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1322 *****************************************************************/
1323 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1325 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1326 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1329 /******************************************************************
1331 * @brief Fills RLC UM Uni Directional DL Information
1335 * Function : fillDefaultUmDlInfo
1337 * Functionality: Fills RLC UM Uni Directional DL Info
1339 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1342 *****************************************************************/
1343 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1345 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1348 /******************************************************************
1350 * @brief Builds Rlc Mode Default Configuration
1354 * Function : fillDefaultRlcModeCfg
1356 * Functionality: Builds Rlc Mode Default Configuration
1358 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1359 * @return ROK/RFAILED
1361 *****************************************************************/
1363 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1374 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1376 fillDefaultAmInfo(lcCfg->u.amCfg);
1379 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1385 case RLC_UM_BI_DIRECTIONAL :
1387 if(!lcCfg->u.umBiDirCfg)
1389 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1390 if(lcCfg->u.umBiDirCfg)
1391 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1394 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1400 case RLC_UM_UNI_DIRECTIONAL_UL :
1402 if(!lcCfg->u.umUniDirUlCfg)
1404 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1405 if(lcCfg->u.umUniDirUlCfg)
1406 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1409 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1415 case RLC_UM_UNI_DIRECTIONAL_DL :
1417 if(!lcCfg->u.umUniDirDlCfg)
1419 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1420 if(lcCfg->u.umUniDirDlCfg)
1421 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1424 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1431 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1438 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1444 /*******************************************************************
1446 * @brief Function to fill Rlc Lc Cfg for SRB1
1450 * Function : fillRlcSrb1LcCfg
1453 * Function to fill Rlc Lc Cfg for SRB1
1455 * @params[in] Pointer to RlcBearerCfg
1456 * @return ROK/RFAILED
1458 *****************************************************************/
1460 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1464 rlcLcCfg->rbId = SRB1_LCID;
1465 rlcLcCfg->rbType = RB_TYPE_SRB;
1466 rlcLcCfg->lcId = SRB1_LCID;
1467 rlcLcCfg->lcType = LCH_DCCH;
1468 rlcLcCfg->rlcMode = RLC_AM;
1469 rlcLcCfg->configType = CONFIG_ADD;
1470 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1474 /*******************************************************************
1476 * @brief Processes UE ReConfig Req to RLC UL
1480 * Function : sendUeReCfgReqToRlc
1483 * Processes UE Reconfig Req to RLC UL
1485 * @params[in] Pointer to RlcUeCfg
1486 * @return ROK - success
1489 *****************************************************************/
1491 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1496 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1499 /* Processing one Ue at a time to RLC */
1500 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1501 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1504 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1505 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1510 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1516 /******************************************************************
1518 * @brief Fills RlcBearerCfg structure
1522 * Function : fillRlcUeCfg
1524 * Functionality: Fills Rlc Bearer Cfg
1527 *****************************************************************/
1528 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1529 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1531 uint8_t ret, dbIdx, lcIdx, cellIdx;
1532 bool lcIdFound = false;
1533 RlcUeCfg *duRlcDb = NULLP;
1538 /* Initial RB being Added */
1539 rlcUeCfg->cellId = cellId;
1540 rlcUeCfg->ueIdx = ueIdx;
1541 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1545 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1549 /* Fetch RlcDb from DuUeCb */
1550 GET_CELL_IDX(cellId, cellIdx);
1551 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1552 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1553 /*Filling RlcUeCfg */
1554 rlcUeCfg->cellId = cellId;
1555 rlcUeCfg->ueIdx = ueIdx;
1556 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1558 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1561 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1562 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1565 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1566 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1568 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1571 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1572 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1575 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1576 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1584 /* ADD/ DEL Config Type */
1585 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1593 /******************************************************************
1595 * @brief creates UE context
1599 * Function : duCreateUeCb
1601 * Functionality: Creates UE Conetxt
1603 * @params[in] UeCcchCtxt Pointer
1606 * @return ROK - success
1608 * ****************************************************************/
1609 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1611 uint8_t cellIdx = 0;
1615 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1617 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1619 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1620 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1622 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1623 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1624 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1625 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1626 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1627 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1629 /* Filling Mac Ue Config */
1630 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1631 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1632 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1634 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1636 /* Filling Rlc Ue Config */
1637 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1638 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1639 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1641 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1643 duCb.actvCellLst[cellIdx]->numActvUes++;
1644 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1651 /******************************************************************
1653 * @brief Builds and Send UE Create Request to MAC
1657 * Function : duBuildAndSendUeCreateReqToMac
1659 * Functionality: Builds and Send UE Create Request to MAC
1661 * @Params[in] cellId,
1663 * @return ROK - success
1666 * ****************************************************************/
1668 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1669 uint16_t crnti, MacUeCfg *duMacUeCfg)
1672 MacUeCfg *macUeCfg = NULLP;
1674 memset(&pst, 0, sizeof(Pst));
1677 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1680 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1684 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1686 /* Copying ueCb to a sharable buffer */
1687 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1690 memset(macUeCfg, 0, sizeof(MacUeCfg));
1691 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1692 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1694 /* Processing one Ue at a time to MAC */
1695 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1698 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1699 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1704 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1710 /*******************************************************************
1712 * @brief To update DuUeCb Mac Cfg
1716 * Function : duUpdateMacCfg
1717 * Functionality: update DuUeCb MAC Cfg
1719 * @params[in] DuUeCb Pointer
1720 * F1UeContextSetupDb pointer
1721 * @return ROK - success
1724 * ****************************************************************/
1725 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1727 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1728 MacUeCfg *oldMacUeCfg;
1731 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1732 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1734 /*Filling Cell Group Cfg*/
1735 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1738 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1740 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1741 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1743 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1745 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1746 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1748 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1749 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1752 /* Filling LC Context */
1753 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1755 numLcs = macUeCfg->numLcs;
1756 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1758 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1760 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1762 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1764 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1766 /* Free memory at matched lcIdx index */
1767 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1769 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1771 /* moving all elements one index ahead */
1772 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1773 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1776 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1783 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1785 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1788 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1798 /******************************************************************
1800 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1804 * Function : fillRlcCfgToAddMod
1806 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1809 *****************************************************************/
1811 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1813 lcCfg->configType = f1UeDbLcCfg->configType;
1814 lcCfg->rbId = f1UeDbLcCfg->rbId;
1815 lcCfg->rbType = f1UeDbLcCfg->rbType;
1816 lcCfg->lcId = f1UeDbLcCfg->lcId;
1817 lcCfg->lcType = f1UeDbLcCfg->lcType;
1818 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1819 switch(lcCfg->rlcMode)
1825 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1830 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1831 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1832 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1833 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1834 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1837 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1838 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1839 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1842 case RLC_UM_BI_DIRECTIONAL :
1844 if(!lcCfg->u.umBiDirCfg)
1846 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1847 if(!lcCfg->u.umBiDirCfg)
1850 /* UL UM BI DIR INFO */
1851 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1852 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1853 /* DL UM BI DIR INFO */
1854 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1857 case RLC_UM_UNI_DIRECTIONAL_UL :
1859 if(!lcCfg->u.umUniDirUlCfg)
1861 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1862 if(!lcCfg->u.umUniDirUlCfg)
1865 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1866 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1870 case RLC_UM_UNI_DIRECTIONAL_DL :
1872 if(!lcCfg->u.umUniDirDlCfg)
1874 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1875 if(!lcCfg->u.umUniDirDlCfg)
1878 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1882 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1888 /*******************************************************************
1890 * @brief To update DuUeCb Rlc Lc Cfg
1894 * Function : duUpdateRlcLcCfg
1895 * Functionality: update DuUeCb Rlc Lc Cfg
1897 * @params[in] DuUeCb Pointer
1898 * F1UeContextSetupDb pointer
1899 * @return ROK - success
1902 * ****************************************************************/
1904 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1906 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1909 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1911 numLcs = rlcUeCfg->numLcs;
1912 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1914 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1916 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1918 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1920 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1922 /* Free memory at matched lcIdx index */
1923 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1925 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1927 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1928 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1931 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1938 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1940 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1949 /*******************************************************************
1951 * @brief Function to fill Tunnel Config to Add/Mod
1956 * Function : fillTnlCfgToAddMod
1958 * Functionality: Function to fill tunnel Config to Add/Mod
1960 * @params[in] Pointer to tnlCfgDb,
1961 * pointer to f1TnlCfg
1962 * @return ROK - success
1965 * ****************************************************************/
1966 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1970 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1971 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
1974 if(*ueCbTnlCfg == NULLP)
1976 /* copying to DuCb Tnl Cfg */
1977 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1978 if(*ueCbTnlCfg == NULLP)
1980 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1984 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1985 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1986 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1987 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1988 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1989 if(f1TnlCfg->tnlCfg1)
1991 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1993 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1994 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1996 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2000 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2001 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2002 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2003 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2008 /*******************************************************************
2010 * @brief Processing the tunnel Request to EGTP
2014 * Function : duProcEgtpTunnelCfg
2016 * Functionality: Processing the tunnel Request to EGTP
2018 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2019 * @return ROK - success
2022 * ****************************************************************/
2024 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2026 uint8_t ret = RFAILED, delIdx;
2028 if(f1TnlCfg->tnlCfg1 == NULLP)
2030 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2034 if(f1TnlCfg->configType == CONFIG_ADD)
2036 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2038 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2045 else if(f1TnlCfg->configType == CONFIG_MOD)
2047 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2049 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2055 else if(f1TnlCfg->configType == CONFIG_DEL)
2057 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2059 /* Free memory at drbIdx */
2061 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2063 /* moving all elements one index ahead */
2064 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2070 if(duCb.upTnlCfg[delIdx])
2072 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2073 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2080 /***********************************************************************
2082 * @brief Function to fill Tunnel Config
2083 * and sends tunnel Req to EGTP
2088 * Function : duUpdateTunnelCfgDb
2090 * Functionality: Function to fill tunnel Config
2091 * and sends tunnel Cfg Req to EGTP
2093 * @params[in] ueIdx, cellId, DuUeCfg
2094 * @return ROK - success
2097 * ****************************************************************/
2099 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2101 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2102 bool drbFound = false;
2104 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2105 /*then update drbId and tunnel Info in duCb */
2106 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2108 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2109 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2110 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2112 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2114 drbFound = true; /* existing DRB */
2115 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2117 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2118 duUeCfg->upTnlInfo[drbIdx].drbId);
2126 if(!drbFound && ret == ROK)/* new DRB to Add */
2128 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2130 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2131 duUeCfg->upTnlInfo[drbIdx].drbId);
2142 /*******************************************************************
2144 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2149 * Function : duUpdateDuUeCbCfg
2151 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2153 * @params[in] ueIdx, cellIdx
2154 * @return ROK - success
2157 * ****************************************************************/
2159 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2161 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2162 DuUeCb *ueCb = NULLP;
2164 GET_CELL_IDX(cellId, cellIdx);
2166 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2167 macUeCfgState == UE_RECFG_COMPLETE) &&
2168 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2169 rlcUeCfgState == UE_RECFG_COMPLETE))
2171 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2173 /*Filling RLC Ue Cfg */
2174 ueCb->rlcUeCfg.cellId = cellId;
2175 ueCb->rlcUeCfg.ueIdx = ueIdx;
2176 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2179 /*Filling MAC Ue Cfg */
2180 GET_CRNTI(crnti, ueIdx);
2181 ueCb->macUeCfg.cellId = cellId;
2182 ueCb->macUeCfg.ueIdx = ueIdx;
2183 ueCb->macUeCfg.crnti = crnti;
2184 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2186 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2189 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2191 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2197 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2204 /*******************************************************************
2206 * @brief Handle UE config response from MAC
2210 * Function : DuProcMacUeCfgRsp
2212 * Functionality: Handle UE Config response from MAC
2214 * @params[in] Pointer to MacUeCfgRsp and Pst
2215 * @return ROK - success
2218 * ****************************************************************/
2219 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2225 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2227 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2229 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2230 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2231 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2233 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2235 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2236 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2237 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2238 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2240 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2246 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2247 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2249 //TODO: Send the failure case in Ue Context Setup Response
2253 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2257 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2264 /*******************************************************************
2266 * @brief Processes UE create Req to RLC UL
2270 * Function : duBuildAndSendUeCreateReqToRlc
2273 * Processes UE create Req to RLC UL
2275 * @params[in] cellId,
2277 * Pointer to RlcUeCfg
2278 * @return ROK - success
2281 *****************************************************************/
2283 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2284 RlcUeCfg *duRlcUeCfg)
2287 RlcUeCfg *rlcUeCfg = NULLP;
2290 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2293 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2297 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2298 /* Copying ueCfg to a sharable buffer */
2299 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2302 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2303 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2304 /* Processing one Ue at a time to RLC */
2305 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2306 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2309 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2310 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2316 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2322 /*******************************************************************
2324 * @brief Processes UE create Rsp received from RLC UL
2329 * Function : DuProcRlcUeCfgRsp
2332 * Processes UE create Rsp received from RLC UL
2334 * @params[in] Post structure
2335 * Pointer to RlcCfgCfm
2336 * @return ROK - success
2339 *****************************************************************/
2340 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2346 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2348 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2350 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2351 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2352 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2354 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2356 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2357 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2358 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2359 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2361 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2367 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2368 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2369 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2371 //TODO: update failure case in ue Context setup Response
2375 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2379 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2385 /*******************************************************************
2387 * @brief Builds and Send Ue Reconfig Req to RLC
2391 * Function : duBuildAndSendUeReCfgReqToRLC
2393 * Functionality: Builds and Send Ue Reconfig Req to RLC
2395 * @params[in] cellId, crnti
2397 * RlcUeCfg *rlcUeCfg
2398 * @return ROK - success
2401 * ****************************************************************/
2403 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2405 uint8_t ret = ROK, ueIdx = 0;
2406 RlcUeCfg *rlcUeCfg = NULLP;
2408 GET_UE_IDX(crnti, ueIdx);
2409 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2412 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2413 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2415 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2417 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2421 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2427 /*******************************************************************
2429 * @brief Builds and Send Ue Reconfig Req to MAC
2433 * Function : duBuildAndSendUeReCfgReqToMac
2435 * Functionality: Builds and Send Ue Reconfig Req to MAC
2437 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2439 * MacUeCfg *macUeCfg
2440 * @return ROK - success
2443 * ****************************************************************/
2445 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2447 uint8_t ret, ueIdx = 0;
2448 MacUeCfg *macUeCfg = NULLP;
2451 GET_UE_IDX(crnti, ueIdx);
2453 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2456 memset(macUeCfg, 0, sizeof(MacUeCfg));
2457 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2459 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2461 ret = sendUeReCfgReqToMac(macUeCfg);
2465 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2471 /*******************************************************************
2473 * @brief Build and Send Ue context setup request
2478 * Function : duBuildAndSendUeContextSetupReq
2481 * Build and Send Ue context setup request
2483 * @params[in] cellId, crnti, DuUeCfg pointer
2484 * @return ROK - success
2487 *****************************************************************/
2489 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2493 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2494 /* Filling RLC Ue Reconfig */
2495 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2497 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2499 /* Filling MAC Ue Reconfig */
2500 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2502 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2507 /*******************************************************************
2509 * @brief Processes DL Rsp received from RLC DL
2514 * Function : DuProcRlcDlRrcMsgRsp
2517 * Processes UE Rsp received from RLC DL
2519 * @params[in] Post structure
2520 * Pointer to RlcCfgCfm
2521 * @return ROK - success
2524 *****************************************************************/
2525 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2527 uint8_t ret = ROK, ueIdx = 0;
2528 uint16_t cellId, crnti;
2529 DuUeCb *ueCb = NULLP;
2532 state = dlRrcMsg->state;
2533 cellId = dlRrcMsg->cellId;
2534 crnti = dlRrcMsg->crnti;
2535 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2537 if(state == TRANSMISSION_COMPLETE)
2539 GET_UE_IDX(crnti, ueIdx);
2540 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2542 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2544 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2546 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2548 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2551 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2553 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2555 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2558 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2560 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2563 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2569 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2573 /*******************************************************************
2575 * @brief Process UE context setup request from CU
2579 * Function : duProcUeContextSetupRequest
2581 * Functionality: Process UE context setup request from CU
2583 * @params[in] F1AP message
2584 * @return ROK - success
2587 * ****************************************************************/
2589 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2591 uint8_t ret, cellId;
2596 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2597 /* Send DL RRC msg for security Mode */
2598 if(ueCb->f1UeDb->dlRrcMsg)
2600 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2602 /* Sending DL RRC Message to RLC */
2603 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2606 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2607 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2608 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2609 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2613 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2615 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2618 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2624 //TODO: To send the failure cause in UeContextSetupRsp
2625 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2630 /*******************************************************************
2632 * @brief Build and Send Ue context mod request
2637 * Function : duBuildAndSendUeContextModReq
2640 * Build and Send Ue context mod request
2642 * @params[in] cellId, crnti, DuUeCfg pointer
2643 * @return ROK - success
2646 *****************************************************************/
2648 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2652 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2653 /* Filling RLC Ue Reconfig */
2654 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2656 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2658 /* Filling MAC Ue Reconfig */
2659 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2661 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2665 /*******************************************************************
2667 * @brief Processing Ue context mod request
2672 * Function : duProcUeContextModReq
2675 * Processing Ue context mod request
2677 * @params[in] DuUeCb *ueCb
2678 * @return ROK - success
2681 *****************************************************************/
2683 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2685 uint8_t ret, cellId;
2690 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2691 /* Send DL RRC msg for security Mode */
2692 if(ueCb->f1UeDb->dlRrcMsg)
2694 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2696 /* Sending DL RRC Message to RLC */
2697 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2700 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2701 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2702 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2703 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2709 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2712 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2718 //TODO: To send the failure cause in UeContextModRsp
2719 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2724 /*******************************************************************
2726 * @brief Function to delete Pdsch ServCellCfg
2730 * Function : deletePdschServCellCfg
2732 * Functionality: Function to delete Pdsch ServCellCfg
2734 * @params[in] PdschServCellCfg *pdschServCellCfg
2737 * ****************************************************************/
2739 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2741 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2742 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2743 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2744 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2747 /*******************************************************************
2749 * @brief delete MacUeCfg from duCb
2753 * Function : deleteMacUeCfg
2755 * Functionality: delete MacUeCfg from duCb
2757 * @params[in] Pointer to MacUeCfg
2758 * @return ROK - success
2761 *******************************************************************/
2763 void deleteMacUeCfg(MacUeCfg *ueCfg)
2767 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2768 if(ueCfg->spCellCfgPres)
2770 freeUeReCfgCellGrpInfo(ueCfg);
2772 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2774 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2776 memset(ueCfg, 0, sizeof(MacUeCfg));
2779 /*******************************************************************
2781 * @brief delete UE Configuration of a particular UE
2785 * Function : deleteUeCfg
2787 * Functionality: delete UE Configuration of a particular UE
2789 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2790 * @return ROK - success
2793 * ****************************************************************/
2794 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2797 DuUeCb *ueCb = NULLP;
2799 if(duCb.actvCellLst[cellIdx] != NULLP)
2801 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2802 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2804 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2805 deleteMacUeCfg(&ueCb->macUeCfg);
2806 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2807 if(ueCb->f1UeDb !=NULLP)
2809 freeF1UeDb(ueCb->f1UeDb);
2811 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2813 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2815 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2816 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2821 duCb.actvCellLst[cellIdx]->numActvUes--;
2822 memset(ueCb, 0, sizeof(DuUeCb));
2831 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2838 /*******************************************************************
2840 * @brief Handle UE delete response from MAC
2844 * Function : DuProcMacUeDeleteRsp
2846 * Functionality: Handle UE delete response from MAC
2848 * @params[in] Pointer to MacUeDeleteRsp and Pst
2849 * @return ROK - success
2852 * ****************************************************************/
2854 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2856 uint8_t ret =ROK,ueId=0;
2858 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2862 if(deleteRsp->result == SUCCESS)
2864 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2865 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2866 if(duCb.actvCellLst[cellIdx])
2868 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2869 ueId = deleteRsp->ueId;
2870 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2871 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2872 if(deleteUeCfg(cellIdx, ueId) == ROK)
2874 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2877 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2885 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2889 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2893 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2899 /*******************************************************************
2901 * @brief Processes UE Delete Rsp received from RLC
2905 * Function : DuProcRlcUeDeleteRsp
2908 * Processes UE Delete Rsp received from RLC
2910 * @params[in] Post structure
2911 * Pointer to RlcUeDeleteRsp
2912 * @return ROK - success
2915 * *****************************************************************/
2917 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2919 uint8_t ueId = 0, ret = ROK;
2920 uint16_t cellIdx = 0,crnti=0;
2924 ueId = delRsp->ueId;
2925 GET_CELL_IDX(delRsp->cellId, cellIdx);
2927 if(delRsp->result == SUCCESSFUL)
2929 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2930 if(duCb.actvCellLst[cellIdx]!=NULLP)
2932 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2933 GET_CRNTI(crnti, ueId);
2934 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2936 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
2944 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
2947 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2953 /*******************************************************************
2955 * @brief Sending UE Delete Req To Mac
2959 * Function : sendUeDeleteReqToMac
2962 * sending UE Delete Req To Mac
2964 * @params[in] cellId, ueId, crnti
2965 * @return ROK - success
2968 *****************************************************************/
2970 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
2974 MacUeDelete *ueDelete = NULLP;
2976 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2979 ueDelete->cellId = cellId;
2980 ueDelete->ueId = ueId;
2981 ueDelete->crnti = crnti;
2982 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2984 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2985 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
2988 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
2989 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
2994 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3000 /*******************************************************************
3002 * @brief Sending UE Delete Req To Rlc
3006 * Function : sendUeDeleteReqToRlc
3009 * Sending UE Delete Req To Rlc
3011 * @params[in] cellId, ueId
3012 * @return ROK - success
3015 *****************************************************************/
3017 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3021 RlcUeDelete *ueDelete;
3023 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3024 if(ueDelete !=NULLP)
3026 ueDelete->cellId = cellId;
3027 ueDelete->ueId = ueId;
3028 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3030 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3033 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3034 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3039 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3045 /*******************************************************************
3047 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3051 * Function : duBuildAndSendUeDeleteReq
3053 * Functionality: DU processes UE delete req from CU and sends to MAC
3056 * @params[in] cellId, crnti
3057 * @return ROK - success
3060 * ****************************************************************/
3062 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3065 uint16_t cellIdx = 0;
3067 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3068 GET_CELL_IDX(cellId, cellIdx);
3069 GET_UE_IDX(crnti, ueId);
3071 if(duCb.actvCellLst[cellIdx] != NULLP)
3073 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3075 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3079 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3080 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3082 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3088 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3095 /*******************************************************************
3097 * @brief delete RlcUeCfg from duCb
3101 * Function : deleteRlcUeCfg
3104 * delete RlcUeCfg from duCb
3106 * @params[in] RlcUeCfg *ueCfg
3108 * @return ROK - success
3111 *****************************************************************/
3113 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3116 RlcBearerCfg *lcCfg= NULLP;
3119 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3121 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3122 switch(lcCfg->rlcMode)
3126 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3129 case RLC_UM_BI_DIRECTIONAL :
3131 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3134 case RLC_UM_UNI_DIRECTIONAL_UL :
3136 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3139 case RLC_UM_UNI_DIRECTIONAL_DL :
3141 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3146 memset(ueCfg, 0, sizeof(RlcUeCfg));
3150 /*******************************************************************
3152 * @brief Du process Ue Context Release Command
3156 * Function : duProcUeContextReleaseCommand
3158 * Functionality: Du process Ue Context Release Command
3160 * @params[in] DuUeCb *duUeCb
3161 * @return ROK - success
3164 * ****************************************************************/
3165 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3167 uint8_t ret =ROK, ueIdx=0;
3168 uint16_t cellId=0,crnti =0;
3171 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3174 if(duUeCb->f1UeDb == NULLP)
3176 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3180 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3181 crnti = duUeCb->crnti;
3182 /* Send DL RRC msg for RRC release */
3183 if(duUeCb->f1UeDb->dlRrcMsg)
3185 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3187 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3188 duUeCb->f1UeDb->dlRrcMsg);
3191 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3192 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3193 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3194 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3200 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3203 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3210 /**********************************************************************
3212 ***********************************************************************/