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)
218 #ifdef CALL_FLOW_DEBUG_LOG
219 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
222 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
226 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
229 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
230 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
232 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
233 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
239 /******************************************************************
241 * @brief Builds and Sends DL CCCH Ind to MAC
245 * Function : duBuildAndSendDlCcchInd
247 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
249 * @params[in] dlCcchMsg - uint8_t*
250 * @return ROK - success
253 * ****************************************************************/
254 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
255 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
259 DlCcchIndInfo *dlCcchIndInfo = NULLP;
262 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
264 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
268 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
272 dlCcchIndInfo->cellId = *cellId;
273 dlCcchIndInfo->crnti = *crnti;
274 dlCcchIndInfo->msgType = msgType;
275 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
277 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
278 if(!dlCcchIndInfo->dlCcchMsg)
280 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
281 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
284 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
286 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
288 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
291 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
292 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
295 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
296 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
297 dlCcchIndInfo->dlCcchMsgLen);
298 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
299 sizeof(DlCcchIndInfo));
307 /*******************************************************************
309 * @brief Build and Send DL RRC Message transfer to RLC
313 * Function : duBuildAndSendDlRrcMsgToRlc
316 * Build and Send DL RRC Message transfer to RLC
318 * @params[in] Cell ID
320 * Logical Channgel ID
323 * @return ROK - success
326 * ****************************************************************/
327 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
332 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
336 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
340 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
343 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
344 duBuildAndSendDlRrcMsgToRlc");
345 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
349 /* Filling up the RRC msg info */
350 dlRrcMsgInfo->cellId = cellId;
351 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
352 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
354 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
356 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
357 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
358 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
359 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
363 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
364 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
365 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
366 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
368 /* Filling post structure and sending msg */
369 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
370 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
371 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
374 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
375 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
384 /******************************************************************
386 * @brief Process DL RRC Msg recevied from F1AP
390 * Function : duProcDlRrcMsg
392 * Functionality: Process DL RRC Msg recevied from F1AP
394 * @params[in] dlCcchMsg - uint8_t*
395 * @return ROK - success
398 * ****************************************************************/
400 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
403 uint16_t crnti, cellId, cellIdx;
404 bool ueCcchCtxtFound = false;
405 bool ueFound = false;
409 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
411 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
413 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
415 ueCcchCtxtFound = true;
416 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
417 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
424 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
427 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
431 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
433 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
436 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
437 duCb.ueCcchCtxt[ueIdx].cellId);
442 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
449 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
451 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
453 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
454 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
457 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
458 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
471 /******************************************************************
473 * @brief Generates GNB DU Ue F1AP ID
477 * Function : genGnbDuUeF1apId
479 * Functionality: Generates GNB DU Ue F1AP ID
482 * @return gnbDuF1apId
484 * ****************************************************************/
485 int32_t genGnbDuUeF1apId(uint8_t cellId)
489 GET_CELL_IDX(cellId, cellIdx);
490 if(duCb.actvCellLst[cellIdx])
492 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
496 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
501 /******************************************************************
503 * @brief Processes UL CCCH Ind recvd from MAC
507 * Function : duProcUlCcchInd
509 * Functionality: Processes UL CCCH Ind recvd from MAC
511 * @params[in] UlCcchIndInfo *ulCcchIndInfo
512 * @return ROK - success
515 * ****************************************************************/
516 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
520 int32_t gnbDuUeF1apId = 0;
522 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
524 if(gnbDuUeF1apId == -1)
526 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
530 /* Store Ue mapping */
531 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
532 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
533 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
537 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
538 ulCcchIndInfo->ulCcchMsg));
541 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
544 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
545 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
551 /******************************************************************
553 * @brief Fills Default UL LC Cfg
557 * Function : fillDefaultUlLcCfg
559 * Functionality: Fills Default UL LC Cfg
561 * @params[in] UlLcCfg *ulLcCfg
563 *****************************************************************/
564 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
566 ulLcCfg->priority = LC_PRIORITY_1;
567 ulLcCfg->lcGroup = 0;
568 ulLcCfg->schReqId = 0;
569 ulLcCfg->pbr = PBR_KBPS_INFINITY;
570 ulLcCfg->bsd = BSD_MS_1000;
573 /******************************************************************
575 * @brief Fills Initial DL Bandwidth Part
579 * Function : fillDefaultInitDlBwp
581 * Functionality: Fills Initial DL Bandwidth Part
583 * @params[in] InitialDlBwp *initDlBwp
586 *****************************************************************/
587 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
590 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
591 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
596 /* Filling PDCCH Config */
597 initDlBwp->pdcchPresent = TRUE;
598 if(initDlBwp->pdcchPresent)
600 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
601 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
602 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
604 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
605 PDCCH_CTRL_RSRC_SET_ONE_ID;
606 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
608 coreset0EndPrb = CORESET0_END_PRB;
609 coreset1StartPrb = coreset0EndPrb +6;
610 coreset1NumPrb = CORESET1_NUM_PRB;
611 /* calculate the PRBs */
612 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
613 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
616 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
617 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
618 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
619 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
620 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
622 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
625 initDlBwp->pdcchCfg.numCRsetToRel = 0;
626 /* Filling Serach Space */
627 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
628 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
629 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
631 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
632 PDCCH_SRCH_SPC_TWO_ID;
633 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
634 PDCCH_CTRL_RSRC_SET_ONE_ID;
635 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
636 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
637 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
638 MONITORING_SYMB_WITHIN_SLOT_SIZE);
639 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
640 PDCCH_SYMBOL_WITHIN_SLOT;
641 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
643 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
645 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
647 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
649 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
651 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
652 SEARCHSPACETYPE_PR_UE_SPECIFIC;
653 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
654 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
656 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
660 /* Filling PDSCH Config */
661 initDlBwp->pdschPresent = TRUE;
662 if(initDlBwp->pdschPresent)
664 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
665 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
666 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
667 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
669 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
670 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
671 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
672 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
673 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
674 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
675 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
676 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
682 /******************************************************************
684 * @brief Fills Initial UL Bandwidth Part
688 * Function : fillDefaultInitUlBwp
690 * Functionality: Fills Initial UL Bandwidth Part
692 * @params[in] InitialUlBwp *initUlBwp
695 *****************************************************************/
696 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
701 initUlBwp->pucchPresent = FALSE;
703 /*Filling PUSCH Config */
704 initUlBwp->puschPresent = TRUE;
705 if(initUlBwp->puschPresent)
707 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
708 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
709 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
710 scramblingId0 = SCRAMBLING_ID;
711 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
712 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
714 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
716 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
717 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
719 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
720 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
721 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
722 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
725 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
726 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
727 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
728 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
729 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
730 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
732 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
737 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
741 /******************************************************************
743 * @brief Fills SpCell Group Info
747 * Function : fillDefaultSpCellGrpInfo
749 * Functionality: Fills Sp Cell Group Info
751 * @params[in] MacUeCfg *macUeCfg
754 *****************************************************************/
755 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
757 SpCellCfg *spCell = NULL;
760 spCell = &macUeCfg->spCellCfg;
764 macUeCfg->spCellCfgPres = true;
766 spCell->servCellIdx = SERV_CELL_IDX;
767 /* Filling Initial Dl Bwp */
768 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
770 spCell->servCellCfg.numDlBwpToAdd = 0;
771 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
772 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
773 spCell->servCellCfg.bwpInactivityTmr = NULLP;
774 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
775 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
776 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
777 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
778 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
779 NUM_HARQ_PROC_FOR_PDSCH_N_16;
780 /* Filling Initial UL Bwp*/
781 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
782 spCell->servCellCfg.numUlBwpToAdd = 0;
783 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
787 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
791 /******************************************************************
793 * @brief Fills Physical Cell Group Info
797 * Function : fillDefaultPhyCellGrpInfo
799 * Functionality: Fills Physical Cell Group Info
801 * @params[in] MacUeCfg *macUeCfg
804 *****************************************************************/
805 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
807 PhyCellGrpCfg *cellGrp = NULL;
810 cellGrp = &macUeCfg->phyCellGrpCfg;
814 macUeCfg->phyCellGrpCfgPres = true;
815 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
816 cellGrp->pNrFr1 = P_NR_FR1;
820 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
824 /******************************************************************
826 * @brief Fills Mac Cell Group Info
830 * Function : fillDefaultMacCellGrpInfo
832 * Functionality: Fills Mac Cell Group Info
834 * @params[in] MacUeCfg *macUeCfg
837 *****************************************************************/
838 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
841 MacCellGrpCfg *cellGrp = NULL;
844 cellGrp = &macUeCfg->macCellGrpCfg;
848 macUeCfg->macCellGrpCfgPres = true;
850 /* Filling Scheduling Request Config */
851 cellGrp->schReqCfg.addModListCount = 1;
852 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
854 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
856 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
857 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
858 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
861 cellGrp->schReqCfg.relListCount = 0;
863 /* Filling Tag config */
864 cellGrp->tagCfg.addModListCount = 1;
865 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
867 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
869 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
870 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
873 cellGrp->tagCfg.relListCount = 0;
875 /* Filling BSR config */
876 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
877 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
878 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
880 /* Filling PHR config */
881 cellGrp->phrCfgSetupPres = true;
882 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
883 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
884 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
885 cellGrp->phrCfg.multiplePHR = false;
886 cellGrp->phrCfg.dummy = false;
887 cellGrp->phrCfg.phrType2OtherCell = false;
888 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
893 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
897 /*******************************************************************
899 * @brief Fills default modulation info for a UE
903 * Function : fillDefaultModulation
905 * Functionality: Fills default modulation info for a UE
907 * @params[in] Pointer to MAC UE configuration
908 * @return ROK - success
911 * ****************************************************************/
912 void fillDefaultModulation(MacUeCfg *ueCfg)
914 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
915 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
916 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
918 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
919 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
920 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
923 /******************************************************************
925 * @brief Function to fill Mac Lc Cfg for SRB1
929 * Function : fillMacSrb1LcCfg
931 * Functionality: Function to fill Mac Lc cfg for SRB1
933 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
935 *****************************************************************/
937 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
939 macLcCfg->lcId = SRB1_LCID;
940 macLcCfg->configType = CONFIG_ADD;
941 macLcCfg->drbQos = NULLP;
942 macLcCfg->snssai = NULLP;
943 macLcCfg->ulLcCfgPres = true;
944 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
947 /******************************************************************
949 * @brief Function to fill the Lc cfg from ueSetupReqDb
953 * Function : fillMacLcCfgToAddMod
955 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
957 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
958 * @return ROK/RFAILED
960 *****************************************************************/
962 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
968 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
969 macLcCfgToSend->configType = ueLcCfgDb->configType;
971 if(ueLcCfgDb->drbQos)
972 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
974 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
976 macLcCfgToSend->drbQos = NULL;
978 if(ueLcCfgDb->snssai)
979 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
981 macLcCfgToSend->snssai = oldLcCfg->snssai;
983 macLcCfgToSend->snssai = NULL;
985 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
986 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
987 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
992 oldLcCfg->lcId = ueLcCfgDb->lcId;
993 oldLcCfg->configType = ueLcCfgDb->configType;
995 if(ueLcCfgDb->drbQos)
998 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1000 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1001 if(oldLcCfg->drbQos == NULL)
1003 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1006 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1009 if(ueLcCfgDb->snssai)
1011 if(oldLcCfg->snssai)
1012 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1014 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1015 if(oldLcCfg->snssai == NULL)
1017 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1018 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1021 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1024 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1025 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1026 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1031 /******************************************************************
1033 * @brief Function to copy the Bit rate from ueSetupReqDb
1037 * Function : fillAmbr
1039 * Functionality: Function to copy bit Rate from ueSetupReqDb
1041 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1042 * @return ROK/RFAILED
1044 *****************************************************************/
1046 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1052 *macAmbrCfgToSend = ueDbAmbr;
1055 *macAmbrCfgToSend = *oldMacAmbrCfg;
1063 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1065 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1066 if(*oldMacAmbrCfg == NULLP)
1068 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1071 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1072 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1079 /******************************************************************
1081 * @brief Builds and Send UE ReConfig Request to MAC
1085 * Function : sendUeReCfgReqToMac
1087 * Functionality: Builds and Send UE ReConfig Request to MAC
1089 * @Params[in] MacUeCfg pointer
1090 * @return ROK - success
1093 * ****************************************************************/
1095 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1101 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1105 /* Processing one Ue at a time to MAC */
1106 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1107 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1110 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1111 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1116 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1122 /******************************************************************
1124 * @brief Function to return Drb LcId
1128 * Function : getDrbLcId
1130 * Functionality: Function to return Drb LcId
1132 * Returns: lcId - SUCCESS
1134 *****************************************************************/
1136 uint8_t getDrbLcId(uint32_t *drbBitMap)
1138 uint8_t bitMask = 1, bitPos = 0;
1139 bitPos = MIN_DRB_LCID;
1141 while(bitPos <= MAX_DRB_LCID)
1143 if((*drbBitMap & (bitMask << bitPos)) == 0)
1145 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1153 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1157 /******************************************************************
1159 * @brief Fills MacUeCfg structure
1163 * Function : fillMacUeCfg
1165 * Functionality: Fills MacUeCfg
1167 * @params[in] cellId, ueIdx, crnti,
1170 * @return ROK/RFAILED
1172 *****************************************************************/
1173 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1174 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1176 uint8_t ret, dbIdx, lcIdx, cellIdx;
1177 bool lcIdFound = false;
1178 MacUeCfg *duMacDb = NULLP;
1184 macUeCfg->cellId = cellId;
1185 macUeCfg->ueIdx = ueIdx;
1186 macUeCfg->crnti = crnti;
1188 fillDefaultMacCellGrpInfo(macUeCfg);
1189 fillDefaultPhyCellGrpInfo(macUeCfg);
1190 fillDefaultSpCellGrpInfo(macUeCfg);
1191 macUeCfg->ambrCfg = NULLP;
1192 fillDefaultModulation(macUeCfg);
1193 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1198 /* Fetching MacDb from DuUeCb */
1199 GET_CELL_IDX(cellId, cellIdx);
1200 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1201 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1202 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1203 macUeCfg->cellId = cellId;
1204 macUeCfg->ueIdx = ueIdx;
1205 macUeCfg->crnti = crnti;
1206 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1209 if(macUeCfg->spCellCfgPres == true)
1211 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1213 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1214 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1216 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1218 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1219 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1222 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1223 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1226 /* Filling LC Context */
1227 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1229 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1231 /* Filling default UL LC config in MAC if not present */
1232 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1233 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1235 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1237 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1240 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1241 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1243 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1244 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], &duMacDb->lcCfgList[lcIdx], FALSE);
1252 /* ADD/DEL CONFIG */
1253 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1261 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1264 }/*End of Outer FOR loop */
1265 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1270 /******************************************************************
1272 * @brief Fills Rlc AM Information
1276 * Function : fillDefaultAmInfo
1278 * Functionality: Fills Rlc AM Information
1280 * @params[in] AmBearerCfg *amCfg
1283 *****************************************************************/
1284 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1287 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1288 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1289 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1290 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1291 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1294 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1295 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1296 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1299 /******************************************************************
1301 * @brief Fills RLC UM Bi Directional Information
1305 * Function : fillDefaultUmBiInfo
1307 * Functionality: Fills RLC UM Bi Directional Information
1309 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1312 *****************************************************************/
1313 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1315 /* UL UM BI DIR INFO */
1316 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1317 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1319 /* DL UM BI DIR INFO */
1320 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1323 /******************************************************************
1325 * @brief Fills RLC UM Uni Directional UL Information
1329 * Function : fillDefaultUmUlInfo
1331 * Functionality: Fills RLC UM Uni Directional Info
1333 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1336 *****************************************************************/
1337 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1339 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1340 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1343 /******************************************************************
1345 * @brief Fills RLC UM Uni Directional DL Information
1349 * Function : fillDefaultUmDlInfo
1351 * Functionality: Fills RLC UM Uni Directional DL Info
1353 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1356 *****************************************************************/
1357 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1359 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1362 /******************************************************************
1364 * @brief Builds Rlc Mode Default Configuration
1368 * Function : fillDefaultRlcModeCfg
1370 * Functionality: Builds Rlc Mode Default Configuration
1372 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1373 * @return ROK/RFAILED
1375 *****************************************************************/
1377 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1388 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1390 fillDefaultAmInfo(lcCfg->u.amCfg);
1393 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1399 case RLC_UM_BI_DIRECTIONAL :
1401 if(!lcCfg->u.umBiDirCfg)
1403 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1404 if(lcCfg->u.umBiDirCfg)
1405 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1408 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1414 case RLC_UM_UNI_DIRECTIONAL_UL :
1416 if(!lcCfg->u.umUniDirUlCfg)
1418 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1419 if(lcCfg->u.umUniDirUlCfg)
1420 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1423 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1429 case RLC_UM_UNI_DIRECTIONAL_DL :
1431 if(!lcCfg->u.umUniDirDlCfg)
1433 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1434 if(lcCfg->u.umUniDirDlCfg)
1435 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1438 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1445 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1452 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1458 /*******************************************************************
1460 * @brief Function to fill Rlc Lc Cfg for SRB1
1464 * Function : fillRlcSrb1LcCfg
1467 * Function to fill Rlc Lc Cfg for SRB1
1469 * @params[in] Pointer to RlcBearerCfg
1470 * @return ROK/RFAILED
1472 *****************************************************************/
1474 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1478 rlcLcCfg->rbId = SRB1_LCID;
1479 rlcLcCfg->rbType = RB_TYPE_SRB;
1480 rlcLcCfg->lcId = SRB1_LCID;
1481 rlcLcCfg->lcType = LCH_DCCH;
1482 rlcLcCfg->rlcMode = RLC_AM;
1483 rlcLcCfg->configType = CONFIG_ADD;
1484 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1488 /*******************************************************************
1490 * @brief Processes UE ReConfig Req to RLC UL
1494 * Function : sendUeReCfgReqToRlc
1497 * Processes UE Reconfig Req to RLC UL
1499 * @params[in] Pointer to RlcUeCfg
1500 * @return ROK - success
1503 *****************************************************************/
1505 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1510 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1513 /* Processing one Ue at a time to RLC */
1514 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1515 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1518 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1519 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1524 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1530 /******************************************************************
1532 * @brief Fills RlcBearerCfg structure
1536 * Function : fillRlcUeCfg
1538 * Functionality: Fills Rlc Bearer Cfg
1541 *****************************************************************/
1542 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1543 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1545 uint8_t ret, dbIdx, lcIdx, cellIdx;
1546 bool lcIdFound = false;
1547 RlcUeCfg *duRlcDb = NULLP;
1552 /* Initial RB being Added */
1553 rlcUeCfg->cellId = cellId;
1554 rlcUeCfg->ueIdx = ueIdx;
1555 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1559 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1563 /* Fetch RlcDb from DuUeCb */
1564 GET_CELL_IDX(cellId, cellIdx);
1565 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1566 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1567 /*Filling RlcUeCfg */
1568 rlcUeCfg->cellId = cellId;
1569 rlcUeCfg->ueIdx = ueIdx;
1570 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1572 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1575 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1576 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1579 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1580 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1582 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1585 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1586 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1589 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1590 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1598 /* ADD/ DEL Config Type */
1599 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1607 /******************************************************************
1609 * @brief creates UE context
1613 * Function : duCreateUeCb
1615 * Functionality: Creates UE Conetxt
1617 * @params[in] UeCcchCtxt Pointer
1620 * @return ROK - success
1622 * ****************************************************************/
1623 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1625 uint8_t cellIdx = 0;
1629 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1631 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1633 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1634 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1636 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1637 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1638 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1639 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1640 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1641 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1643 /* Filling Mac Ue Config */
1644 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1645 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1646 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1648 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1650 /* Filling Rlc Ue Config */
1651 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1652 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1653 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1655 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1657 duCb.actvCellLst[cellIdx]->numActvUes++;
1658 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1665 /******************************************************************
1667 * @brief Builds and Send UE Create Request to MAC
1671 * Function : duBuildAndSendUeCreateReqToMac
1673 * Functionality: Builds and Send UE Create Request to MAC
1675 * @Params[in] cellId,
1677 * @return ROK - success
1680 * ****************************************************************/
1682 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1683 uint16_t crnti, MacUeCfg *duMacUeCfg)
1686 MacUeCfg *macUeCfg = NULLP;
1688 memset(&pst, 0, sizeof(Pst));
1691 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1694 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1698 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1700 /* Copying ueCb to a sharable buffer */
1701 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1704 memset(macUeCfg, 0, sizeof(MacUeCfg));
1705 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1706 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1708 /* Processing one Ue at a time to MAC */
1709 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1712 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1713 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1718 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1724 /*******************************************************************
1726 * @brief To update DuUeCb Mac Cfg
1730 * Function : duUpdateMacCfg
1731 * Functionality: update DuUeCb MAC Cfg
1733 * @params[in] DuUeCb Pointer
1734 * F1UeContextSetupDb pointer
1735 * @return ROK - success
1738 * ****************************************************************/
1739 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1741 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1742 MacUeCfg *oldMacUeCfg;
1745 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1746 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1748 /*Filling Cell Group Cfg*/
1749 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1752 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1754 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1755 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1757 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1759 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1760 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1762 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1763 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1766 /* Filling LC Context */
1767 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1769 numLcs = macUeCfg->numLcs;
1770 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1772 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1774 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1776 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1778 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1780 /* Free memory at matched lcIdx index */
1781 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1783 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1785 /* moving all elements one index ahead */
1786 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1787 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1790 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1797 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1799 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1802 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1812 /******************************************************************
1814 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1818 * Function : fillRlcCfgToAddMod
1820 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1823 *****************************************************************/
1825 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1827 lcCfg->configType = f1UeDbLcCfg->configType;
1828 lcCfg->rbId = f1UeDbLcCfg->rbId;
1829 lcCfg->rbType = f1UeDbLcCfg->rbType;
1830 lcCfg->lcId = f1UeDbLcCfg->lcId;
1831 lcCfg->lcType = f1UeDbLcCfg->lcType;
1832 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1833 switch(lcCfg->rlcMode)
1839 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1844 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1845 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1846 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1847 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1848 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1851 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1852 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1853 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1856 case RLC_UM_BI_DIRECTIONAL :
1858 if(!lcCfg->u.umBiDirCfg)
1860 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1861 if(!lcCfg->u.umBiDirCfg)
1864 /* UL UM BI DIR INFO */
1865 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1866 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1867 /* DL UM BI DIR INFO */
1868 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1871 case RLC_UM_UNI_DIRECTIONAL_UL :
1873 if(!lcCfg->u.umUniDirUlCfg)
1875 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1876 if(!lcCfg->u.umUniDirUlCfg)
1879 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1880 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1884 case RLC_UM_UNI_DIRECTIONAL_DL :
1886 if(!lcCfg->u.umUniDirDlCfg)
1888 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1889 if(!lcCfg->u.umUniDirDlCfg)
1892 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1896 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1902 /*******************************************************************
1904 * @brief To update DuUeCb Rlc Lc Cfg
1908 * Function : duUpdateRlcLcCfg
1909 * Functionality: update DuUeCb Rlc Lc Cfg
1911 * @params[in] DuUeCb Pointer
1912 * F1UeContextSetupDb pointer
1913 * @return ROK - success
1916 * ****************************************************************/
1918 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1920 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1923 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1925 numLcs = rlcUeCfg->numLcs;
1926 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1928 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1930 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1932 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1934 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1936 /* Free memory at matched lcIdx index */
1937 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1939 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1941 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1942 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1945 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1952 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1954 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1963 /*******************************************************************
1965 * @brief Function to fill Tunnel Config to Add/Mod
1970 * Function : fillTnlCfgToAddMod
1972 * Functionality: Function to fill tunnel Config to Add/Mod
1974 * @params[in] Pointer to tnlCfgDb,
1975 * pointer to f1TnlCfg
1976 * @return ROK - success
1979 * ****************************************************************/
1980 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1984 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1985 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
1988 if(*ueCbTnlCfg == NULLP)
1990 /* copying to DuCb Tnl Cfg */
1991 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1992 if(*ueCbTnlCfg == NULLP)
1994 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1998 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1999 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2000 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2001 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2002 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2003 if(f1TnlCfg->tnlCfg1)
2005 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2007 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2008 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2010 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2014 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2015 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2016 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2017 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2022 /*******************************************************************
2024 * @brief Processing the tunnel Request to EGTP
2028 * Function : duProcEgtpTunnelCfg
2030 * Functionality: Processing the tunnel Request to EGTP
2032 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2033 * @return ROK - success
2036 * ****************************************************************/
2038 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2040 uint8_t ret = RFAILED, delIdx;
2042 if(f1TnlCfg->tnlCfg1 == NULLP)
2044 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2048 if(f1TnlCfg->configType == CONFIG_ADD)
2050 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2052 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2059 else if(f1TnlCfg->configType == CONFIG_MOD)
2061 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2063 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2069 else if(f1TnlCfg->configType == CONFIG_DEL)
2071 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2073 /* Free memory at drbIdx */
2075 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2077 /* moving all elements one index ahead */
2078 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2084 if(duCb.upTnlCfg[delIdx])
2086 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2087 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2094 /***********************************************************************
2096 * @brief Function to fill Tunnel Config
2097 * and sends tunnel Req to EGTP
2102 * Function : duUpdateTunnelCfgDb
2104 * Functionality: Function to fill tunnel Config
2105 * and sends tunnel Cfg Req to EGTP
2107 * @params[in] ueIdx, cellId, DuUeCfg
2108 * @return ROK - success
2111 * ****************************************************************/
2113 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2115 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2116 bool drbFound = false;
2118 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2119 /*then update drbId and tunnel Info in duCb */
2120 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2122 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2123 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2124 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2126 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2128 drbFound = true; /* existing DRB */
2129 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2131 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2132 duUeCfg->upTnlInfo[drbIdx].drbId);
2140 if(!drbFound && ret == ROK)/* new DRB to Add */
2142 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2144 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2145 duUeCfg->upTnlInfo[drbIdx].drbId);
2156 /*******************************************************************
2158 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2163 * Function : duUpdateDuUeCbCfg
2165 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2167 * @params[in] ueIdx, cellIdx
2168 * @return ROK - success
2171 * ****************************************************************/
2173 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2175 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2176 DuUeCb *ueCb = NULLP;
2178 GET_CELL_IDX(cellId, cellIdx);
2180 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2181 macUeCfgState == UE_RECFG_COMPLETE) &&
2182 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2183 rlcUeCfgState == UE_RECFG_COMPLETE))
2185 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2187 /*Filling RLC Ue Cfg */
2188 ueCb->rlcUeCfg.cellId = cellId;
2189 ueCb->rlcUeCfg.ueIdx = ueIdx;
2190 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2193 /*Filling MAC Ue Cfg */
2194 GET_CRNTI(crnti, ueIdx);
2195 ueCb->macUeCfg.cellId = cellId;
2196 ueCb->macUeCfg.ueIdx = ueIdx;
2197 ueCb->macUeCfg.crnti = crnti;
2198 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2200 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2203 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2205 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2211 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2218 /*******************************************************************
2220 * @brief Handle UE config response from MAC
2224 * Function : DuProcMacUeCfgRsp
2226 * Functionality: Handle UE Config response from MAC
2228 * @params[in] Pointer to MacUeCfgRsp and Pst
2229 * @return ROK - success
2232 * ****************************************************************/
2233 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2239 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2241 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2243 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2244 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2245 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2247 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2249 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2250 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2251 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2252 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2254 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2260 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2261 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2263 //TODO: Send the failure case in Ue Context Setup Response
2267 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2271 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2278 /*******************************************************************
2280 * @brief Processes UE create Req to RLC UL
2284 * Function : duBuildAndSendUeCreateReqToRlc
2287 * Processes UE create Req to RLC UL
2289 * @params[in] cellId,
2291 * Pointer to RlcUeCfg
2292 * @return ROK - success
2295 *****************************************************************/
2297 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2298 RlcUeCfg *duRlcUeCfg)
2301 RlcUeCfg *rlcUeCfg = NULLP;
2304 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2307 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2311 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2312 /* Copying ueCfg to a sharable buffer */
2313 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2316 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2317 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2318 /* Processing one Ue at a time to RLC */
2319 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2320 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2323 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2324 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2330 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2336 /*******************************************************************
2338 * @brief Processes UE create Rsp received from RLC UL
2343 * Function : DuProcRlcUeCfgRsp
2346 * Processes UE create Rsp received from RLC UL
2348 * @params[in] Post structure
2349 * Pointer to RlcCfgCfm
2350 * @return ROK - success
2353 *****************************************************************/
2354 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2360 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2362 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2364 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2365 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2366 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2368 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2370 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2371 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2372 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2373 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2375 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2381 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2382 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2383 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2385 //TODO: update failure case in ue Context setup Response
2389 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2393 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2399 /*******************************************************************
2401 * @brief Builds and Send Ue Reconfig Req to RLC
2405 * Function : duBuildAndSendUeReCfgReqToRLC
2407 * Functionality: Builds and Send Ue Reconfig Req to RLC
2409 * @params[in] cellId, crnti
2411 * RlcUeCfg *rlcUeCfg
2412 * @return ROK - success
2415 * ****************************************************************/
2417 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2419 uint8_t ret = ROK, ueIdx = 0;
2420 RlcUeCfg *rlcUeCfg = NULLP;
2422 GET_UE_IDX(crnti, ueIdx);
2423 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2426 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2427 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2429 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2431 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2435 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2441 /*******************************************************************
2443 * @brief Builds and Send Ue Reconfig Req to MAC
2447 * Function : duBuildAndSendUeReCfgReqToMac
2449 * Functionality: Builds and Send Ue Reconfig Req to MAC
2451 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2453 * MacUeCfg *macUeCfg
2454 * @return ROK - success
2457 * ****************************************************************/
2459 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2461 uint8_t ret, ueIdx = 0;
2462 MacUeCfg *macUeCfg = NULLP;
2465 GET_UE_IDX(crnti, ueIdx);
2467 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2470 memset(macUeCfg, 0, sizeof(MacUeCfg));
2471 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2473 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2475 ret = sendUeReCfgReqToMac(macUeCfg);
2479 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2485 /*******************************************************************
2487 * @brief Build and Send Ue context setup request
2492 * Function : duBuildAndSendUeContextSetupReq
2495 * Build and Send Ue context setup request
2497 * @params[in] cellId, crnti, DuUeCfg pointer
2498 * @return ROK - success
2501 *****************************************************************/
2503 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2507 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2508 /* Filling RLC Ue Reconfig */
2509 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2511 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2513 /* Filling MAC Ue Reconfig */
2514 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2516 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2521 /*******************************************************************
2523 * @brief Processes DL Rsp received from RLC DL
2528 * Function : DuProcRlcDlRrcMsgRsp
2531 * Processes UE Rsp received from RLC DL
2533 * @params[in] Post structure
2534 * Pointer to RlcCfgCfm
2535 * @return ROK - success
2538 *****************************************************************/
2539 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2541 uint8_t ret = ROK, ueIdx = 0;
2542 uint16_t cellId, crnti;
2543 DuUeCb *ueCb = NULLP;
2546 state = dlRrcMsg->state;
2547 cellId = dlRrcMsg->cellId;
2548 crnti = dlRrcMsg->crnti;
2549 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2551 if(state == TRANSMISSION_COMPLETE)
2553 GET_UE_IDX(crnti, ueIdx);
2554 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2556 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2558 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2560 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2562 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2565 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2567 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2569 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2572 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2574 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2577 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2583 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2587 /*******************************************************************
2589 * @brief Process UE context setup request from CU
2593 * Function : duProcUeContextSetupRequest
2595 * Functionality: Process UE context setup request from CU
2597 * @params[in] F1AP message
2598 * @return ROK - success
2601 * ****************************************************************/
2603 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2605 uint8_t ret, cellId;
2610 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2611 /* Send DL RRC msg for security Mode */
2612 if(ueCb->f1UeDb->dlRrcMsg)
2614 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2616 /* Sending DL RRC Message to RLC */
2617 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2620 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2621 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2622 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2623 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2627 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2629 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2632 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2638 //TODO: To send the failure cause in UeContextSetupRsp
2639 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2644 /*******************************************************************
2646 * @brief Build and Send Ue context mod request
2651 * Function : duBuildAndSendUeContextModReq
2654 * Build and Send Ue context mod request
2656 * @params[in] cellId, crnti, DuUeCfg pointer
2657 * @return ROK - success
2660 *****************************************************************/
2662 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2666 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2667 /* Filling RLC Ue Reconfig */
2668 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2670 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2672 /* Filling MAC Ue Reconfig */
2673 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2675 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2679 /*******************************************************************
2681 * @brief Processing Ue context mod request
2686 * Function : duProcUeContextModReq
2689 * Processing Ue context mod request
2691 * @params[in] DuUeCb *ueCb
2692 * @return ROK - success
2695 *****************************************************************/
2697 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2699 uint8_t ret, cellId;
2704 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2705 /* Send DL RRC msg for security Mode */
2706 if(ueCb->f1UeDb->dlRrcMsg)
2708 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2710 /* Sending DL RRC Message to RLC */
2711 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2714 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2715 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2716 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2717 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2723 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2726 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2732 //TODO: To send the failure cause in UeContextModRsp
2733 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2738 /*******************************************************************
2740 * @brief Function to delete Pdsch ServCellCfg
2744 * Function : deletePdschServCellCfg
2746 * Functionality: Function to delete Pdsch ServCellCfg
2748 * @params[in] PdschServCellCfg *pdschServCellCfg
2751 * ****************************************************************/
2753 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2755 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2756 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2757 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2758 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2761 /*******************************************************************
2763 * @brief delete MacUeCfg from duCb
2767 * Function : deleteMacUeCfg
2769 * Functionality: delete MacUeCfg from duCb
2771 * @params[in] Pointer to MacUeCfg
2772 * @return ROK - success
2775 *******************************************************************/
2777 void deleteMacUeCfg(MacUeCfg *ueCfg)
2781 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2782 if(ueCfg->spCellCfgPres)
2784 freeUeReCfgCellGrpInfo(ueCfg);
2786 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2788 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2790 memset(ueCfg, 0, sizeof(MacUeCfg));
2793 /*******************************************************************
2795 * @brief delete UE Configuration of a particular UE
2799 * Function : deleteUeCfg
2801 * Functionality: delete UE Configuration of a particular UE
2803 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2804 * @return ROK - success
2807 * ****************************************************************/
2808 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2811 DuUeCb *ueCb = NULLP;
2813 if(duCb.actvCellLst[cellIdx] != NULLP)
2815 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2816 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2818 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2819 deleteMacUeCfg(&ueCb->macUeCfg);
2820 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2821 if(ueCb->f1UeDb !=NULLP)
2823 freeF1UeDb(ueCb->f1UeDb);
2825 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2827 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2829 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2830 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2835 duCb.actvCellLst[cellIdx]->numActvUes--;
2836 memset(ueCb, 0, sizeof(DuUeCb));
2845 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2852 /*******************************************************************
2854 * @brief Handle UE delete response from MAC
2858 * Function : DuProcMacUeDeleteRsp
2860 * Functionality: Handle UE delete response from MAC
2862 * @params[in] Pointer to MacUeDeleteRsp and Pst
2863 * @return ROK - success
2866 * ****************************************************************/
2868 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2870 uint8_t ret =ROK,ueId=0;
2872 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2876 if(deleteRsp->result == SUCCESS)
2878 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2879 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2880 if(duCb.actvCellLst[cellIdx])
2882 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2883 ueId = deleteRsp->ueId;
2884 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2885 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2886 if(deleteUeCfg(cellIdx, ueId) == ROK)
2888 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2891 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2899 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2903 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2907 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2913 /*******************************************************************
2915 * @brief Processes UE Delete Rsp received from RLC
2919 * Function : DuProcRlcUeDeleteRsp
2922 * Processes UE Delete Rsp received from RLC
2924 * @params[in] Post structure
2925 * Pointer to RlcUeDeleteRsp
2926 * @return ROK - success
2929 * *****************************************************************/
2931 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2933 uint8_t ueId = 0, ret = ROK;
2934 uint16_t cellIdx = 0,crnti=0;
2938 ueId = delRsp->ueId;
2939 GET_CELL_IDX(delRsp->cellId, cellIdx);
2941 if(delRsp->result == SUCCESSFUL)
2943 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2944 if(duCb.actvCellLst[cellIdx]!=NULLP)
2946 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2947 GET_CRNTI(crnti, ueId);
2948 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2950 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
2958 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
2961 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2967 /*******************************************************************
2969 * @brief Sending UE Delete Req To Mac
2973 * Function : sendUeDeleteReqToMac
2976 * sending UE Delete Req To Mac
2978 * @params[in] cellId, ueId, crnti
2979 * @return ROK - success
2982 *****************************************************************/
2984 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
2988 MacUeDelete *ueDelete = NULLP;
2990 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2993 ueDelete->cellId = cellId;
2994 ueDelete->ueId = ueId;
2995 ueDelete->crnti = crnti;
2996 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2998 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2999 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3002 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3003 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3008 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3014 /*******************************************************************
3016 * @brief Sending UE Delete Req To Rlc
3020 * Function : sendUeDeleteReqToRlc
3023 * Sending UE Delete Req To Rlc
3025 * @params[in] cellId, ueId
3026 * @return ROK - success
3029 *****************************************************************/
3031 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3035 RlcUeDelete *ueDelete;
3037 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3038 if(ueDelete !=NULLP)
3040 ueDelete->cellId = cellId;
3041 ueDelete->ueId = ueId;
3042 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3044 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3047 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3048 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3053 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3059 /*******************************************************************
3061 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3065 * Function : duBuildAndSendUeDeleteReq
3067 * Functionality: DU processes UE delete req from CU and sends to MAC
3070 * @params[in] cellId, crnti
3071 * @return ROK - success
3074 * ****************************************************************/
3076 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3079 uint16_t cellIdx = 0;
3081 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3082 GET_CELL_IDX(cellId, cellIdx);
3083 GET_UE_IDX(crnti, ueId);
3085 if(duCb.actvCellLst[cellIdx] != NULLP)
3087 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3089 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3093 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3094 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3096 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3102 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3109 /*******************************************************************
3111 * @brief delete RlcUeCfg from duCb
3115 * Function : deleteRlcUeCfg
3118 * delete RlcUeCfg from duCb
3120 * @params[in] RlcUeCfg *ueCfg
3122 * @return ROK - success
3125 *****************************************************************/
3127 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3130 RlcBearerCfg *lcCfg= NULLP;
3133 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3135 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3136 switch(lcCfg->rlcMode)
3140 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3143 case RLC_UM_BI_DIRECTIONAL :
3145 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3148 case RLC_UM_UNI_DIRECTIONAL_UL :
3150 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3153 case RLC_UM_UNI_DIRECTIONAL_DL :
3155 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3160 memset(ueCfg, 0, sizeof(RlcUeCfg));
3164 /*******************************************************************
3166 * @brief Du process Ue Context Release Command
3170 * Function : duProcUeContextReleaseCommand
3172 * Functionality: Du process Ue Context Release Command
3174 * @params[in] DuUeCb *duUeCb
3175 * @return ROK - success
3178 * ****************************************************************/
3179 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3181 uint8_t ret =ROK, ueIdx=0;
3182 uint16_t cellId=0,crnti =0;
3185 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3188 if(duUeCb->f1UeDb == NULLP)
3190 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3194 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3195 crnti = duUeCb->crnti;
3196 /* Send DL RRC msg for RRC release */
3197 if(duUeCb->f1UeDb->dlRrcMsg)
3199 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3201 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3202 duUeCb->f1UeDb->dlRrcMsg);
3205 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3206 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3207 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3208 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3214 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3217 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3224 /**********************************************************************
3226 ***********************************************************************/