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, 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 */
1269 /******************************************************************
1271 * @brief Fills Rlc AM Information
1275 * Function : fillDefaultAmInfo
1277 * Functionality: Fills Rlc AM Information
1279 * @params[in] AmBearerCfg *amCfg
1282 *****************************************************************/
1283 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1286 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1287 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1288 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1289 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1290 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1293 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1294 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1295 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1298 /******************************************************************
1300 * @brief Fills RLC UM Bi Directional Information
1304 * Function : fillDefaultUmBiInfo
1306 * Functionality: Fills RLC UM Bi Directional Information
1308 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1311 *****************************************************************/
1312 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1314 /* UL UM BI DIR INFO */
1315 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1316 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1318 /* DL UM BI DIR INFO */
1319 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1322 /******************************************************************
1324 * @brief Fills RLC UM Uni Directional UL Information
1328 * Function : fillDefaultUmUlInfo
1330 * Functionality: Fills RLC UM Uni Directional Info
1332 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1335 *****************************************************************/
1336 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1338 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1339 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1342 /******************************************************************
1344 * @brief Fills RLC UM Uni Directional DL Information
1348 * Function : fillDefaultUmDlInfo
1350 * Functionality: Fills RLC UM Uni Directional DL Info
1352 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1355 *****************************************************************/
1356 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1358 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1361 /******************************************************************
1363 * @brief Builds Rlc Mode Default Configuration
1367 * Function : fillDefaultRlcModeCfg
1369 * Functionality: Builds Rlc Mode Default Configuration
1371 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1372 * @return ROK/RFAILED
1374 *****************************************************************/
1376 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1387 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1389 fillDefaultAmInfo(lcCfg->u.amCfg);
1392 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1398 case RLC_UM_BI_DIRECTIONAL :
1400 if(!lcCfg->u.umBiDirCfg)
1402 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1403 if(lcCfg->u.umBiDirCfg)
1404 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1407 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1413 case RLC_UM_UNI_DIRECTIONAL_UL :
1415 if(!lcCfg->u.umUniDirUlCfg)
1417 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1418 if(lcCfg->u.umUniDirUlCfg)
1419 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1422 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1428 case RLC_UM_UNI_DIRECTIONAL_DL :
1430 if(!lcCfg->u.umUniDirDlCfg)
1432 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1433 if(lcCfg->u.umUniDirDlCfg)
1434 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1437 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1444 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1451 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1457 /*******************************************************************
1459 * @brief Function to fill Rlc Lc Cfg for SRB1
1463 * Function : fillRlcSrb1LcCfg
1466 * Function to fill Rlc Lc Cfg for SRB1
1468 * @params[in] Pointer to RlcBearerCfg
1469 * @return ROK/RFAILED
1471 *****************************************************************/
1473 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1477 rlcLcCfg->rbId = SRB1_LCID;
1478 rlcLcCfg->rbType = RB_TYPE_SRB;
1479 rlcLcCfg->lcId = SRB1_LCID;
1480 rlcLcCfg->lcType = LCH_DCCH;
1481 rlcLcCfg->rlcMode = RLC_AM;
1482 rlcLcCfg->configType = CONFIG_ADD;
1483 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1487 /*******************************************************************
1489 * @brief Processes UE ReConfig Req to RLC UL
1493 * Function : sendUeReCfgReqToRlc
1496 * Processes UE Reconfig Req to RLC UL
1498 * @params[in] Pointer to RlcUeCfg
1499 * @return ROK - success
1502 *****************************************************************/
1504 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1509 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1512 /* Processing one Ue at a time to RLC */
1513 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1514 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1517 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1518 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1523 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1529 /******************************************************************
1531 * @brief Fills RlcBearerCfg structure
1535 * Function : fillRlcUeCfg
1537 * Functionality: Fills Rlc Bearer Cfg
1540 *****************************************************************/
1541 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1542 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1544 uint8_t ret, dbIdx, lcIdx, cellIdx;
1545 bool lcIdFound = false;
1546 RlcUeCfg *duRlcDb = NULLP;
1551 /* Initial RB being Added */
1552 rlcUeCfg->cellId = cellId;
1553 rlcUeCfg->ueIdx = ueIdx;
1554 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1558 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1562 /* Fetch RlcDb from DuUeCb */
1563 GET_CELL_IDX(cellId, cellIdx);
1564 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1565 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1566 /*Filling RlcUeCfg */
1567 rlcUeCfg->cellId = cellId;
1568 rlcUeCfg->ueIdx = ueIdx;
1569 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1571 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1574 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1575 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1578 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1579 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1581 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1584 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1585 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1588 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1589 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1597 /* ADD/ DEL Config Type */
1598 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1606 /******************************************************************
1608 * @brief creates UE context
1612 * Function : duCreateUeCb
1614 * Functionality: Creates UE Conetxt
1616 * @params[in] UeCcchCtxt Pointer
1619 * @return ROK - success
1621 * ****************************************************************/
1622 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1624 uint8_t cellIdx = 0;
1628 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1630 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1632 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1633 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1635 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1636 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1637 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1638 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1639 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1640 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1642 /* Filling Mac Ue Config */
1643 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1644 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1645 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1647 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1649 /* Filling Rlc Ue Config */
1650 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1651 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1652 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1654 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1656 duCb.actvCellLst[cellIdx]->numActvUes++;
1657 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1664 /******************************************************************
1666 * @brief Builds and Send UE Create Request to MAC
1670 * Function : duBuildAndSendUeCreateReqToMac
1672 * Functionality: Builds and Send UE Create Request to MAC
1674 * @Params[in] cellId,
1676 * @return ROK - success
1679 * ****************************************************************/
1681 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1682 uint16_t crnti, MacUeCfg *duMacUeCfg)
1685 MacUeCfg *macUeCfg = NULLP;
1687 memset(&pst, 0, sizeof(Pst));
1690 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1693 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1697 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1699 /* Copying ueCb to a sharable buffer */
1700 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1703 memset(macUeCfg, 0, sizeof(MacUeCfg));
1704 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1705 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1707 /* Processing one Ue at a time to MAC */
1708 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1711 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1712 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1717 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1723 /*******************************************************************
1725 * @brief To update DuUeCb Mac Cfg
1729 * Function : duUpdateMacCfg
1730 * Functionality: update DuUeCb MAC Cfg
1732 * @params[in] DuUeCb Pointer
1733 * F1UeContextSetupDb pointer
1734 * @return ROK - success
1737 * ****************************************************************/
1738 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1740 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1741 MacUeCfg *oldMacUeCfg;
1744 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1745 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1747 /*Filling Cell Group Cfg*/
1748 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1751 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1753 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1754 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1756 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1758 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1759 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1761 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1762 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1765 /* Filling LC Context */
1766 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1768 numLcs = macUeCfg->numLcs;
1769 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1771 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1773 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1775 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1777 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1779 /* Free memory at matched lcIdx index */
1780 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1782 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1784 /* moving all elements one index ahead */
1785 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1786 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1789 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1796 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1798 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1801 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1811 /******************************************************************
1813 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1817 * Function : fillRlcCfgToAddMod
1819 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1822 *****************************************************************/
1824 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1826 lcCfg->configType = f1UeDbLcCfg->configType;
1827 lcCfg->rbId = f1UeDbLcCfg->rbId;
1828 lcCfg->rbType = f1UeDbLcCfg->rbType;
1829 lcCfg->lcId = f1UeDbLcCfg->lcId;
1830 lcCfg->lcType = f1UeDbLcCfg->lcType;
1831 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1832 switch(lcCfg->rlcMode)
1838 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1843 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1844 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1845 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1846 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1847 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1850 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1851 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1852 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1855 case RLC_UM_BI_DIRECTIONAL :
1857 if(!lcCfg->u.umBiDirCfg)
1859 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1860 if(!lcCfg->u.umBiDirCfg)
1863 /* UL UM BI DIR INFO */
1864 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1865 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1866 /* DL UM BI DIR INFO */
1867 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1870 case RLC_UM_UNI_DIRECTIONAL_UL :
1872 if(!lcCfg->u.umUniDirUlCfg)
1874 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1875 if(!lcCfg->u.umUniDirUlCfg)
1878 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1879 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1883 case RLC_UM_UNI_DIRECTIONAL_DL :
1885 if(!lcCfg->u.umUniDirDlCfg)
1887 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1888 if(!lcCfg->u.umUniDirDlCfg)
1891 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1895 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1901 /*******************************************************************
1903 * @brief To update DuUeCb Rlc Lc Cfg
1907 * Function : duUpdateRlcLcCfg
1908 * Functionality: update DuUeCb Rlc Lc Cfg
1910 * @params[in] DuUeCb Pointer
1911 * F1UeContextSetupDb pointer
1912 * @return ROK - success
1915 * ****************************************************************/
1917 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1919 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1922 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1924 numLcs = rlcUeCfg->numLcs;
1925 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1927 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1929 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1931 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1933 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1935 /* Free memory at matched lcIdx index */
1936 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1938 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1940 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1941 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1944 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1951 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1953 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1962 /*******************************************************************
1964 * @brief Function to fill Tunnel Config to Add/Mod
1969 * Function : fillTnlCfgToAddMod
1971 * Functionality: Function to fill tunnel Config to Add/Mod
1973 * @params[in] Pointer to tnlCfgDb,
1974 * pointer to f1TnlCfg
1975 * @return ROK - success
1978 * ****************************************************************/
1979 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1983 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1984 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
1987 if(*ueCbTnlCfg == NULLP)
1989 /* copying to DuCb Tnl Cfg */
1990 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1991 if(*ueCbTnlCfg == NULLP)
1993 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1997 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1998 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1999 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2000 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2001 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2002 if(f1TnlCfg->tnlCfg1)
2004 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2006 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2007 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2009 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2013 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2014 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2015 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2016 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2021 /*******************************************************************
2023 * @brief Processing the tunnel Request to EGTP
2027 * Function : duProcEgtpTunnelCfg
2029 * Functionality: Processing the tunnel Request to EGTP
2031 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2032 * @return ROK - success
2035 * ****************************************************************/
2037 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2039 uint8_t ret = RFAILED, delIdx;
2041 if(f1TnlCfg->tnlCfg1 == NULLP)
2043 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2047 if(f1TnlCfg->configType == CONFIG_ADD)
2049 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2051 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2058 else if(f1TnlCfg->configType == CONFIG_MOD)
2060 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2062 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2068 else if(f1TnlCfg->configType == CONFIG_DEL)
2070 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2072 /* Free memory at drbIdx */
2074 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2076 /* moving all elements one index ahead */
2077 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2083 if(duCb.upTnlCfg[delIdx])
2085 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2086 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2093 /***********************************************************************
2095 * @brief Function to fill Tunnel Config
2096 * and sends tunnel Req to EGTP
2101 * Function : duUpdateTunnelCfgDb
2103 * Functionality: Function to fill tunnel Config
2104 * and sends tunnel Cfg Req to EGTP
2106 * @params[in] ueIdx, cellId, DuUeCfg
2107 * @return ROK - success
2110 * ****************************************************************/
2112 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2114 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2115 bool drbFound = false;
2117 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2118 /*then update drbId and tunnel Info in duCb */
2119 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2121 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2122 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2123 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2125 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2127 drbFound = true; /* existing DRB */
2128 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2130 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2131 duUeCfg->upTnlInfo[drbIdx].drbId);
2139 if(!drbFound && ret == ROK)/* new DRB to Add */
2141 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2143 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2144 duUeCfg->upTnlInfo[drbIdx].drbId);
2155 /*******************************************************************
2157 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2162 * Function : duUpdateDuUeCbCfg
2164 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2166 * @params[in] ueIdx, cellIdx
2167 * @return ROK - success
2170 * ****************************************************************/
2172 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2174 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2175 DuUeCb *ueCb = NULLP;
2177 GET_CELL_IDX(cellId, cellIdx);
2179 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2180 macUeCfgState == UE_RECFG_COMPLETE) &&
2181 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2182 rlcUeCfgState == UE_RECFG_COMPLETE))
2184 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2186 /*Filling RLC Ue Cfg */
2187 ueCb->rlcUeCfg.cellId = cellId;
2188 ueCb->rlcUeCfg.ueIdx = ueIdx;
2189 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2192 /*Filling MAC Ue Cfg */
2193 GET_CRNTI(crnti, ueIdx);
2194 ueCb->macUeCfg.cellId = cellId;
2195 ueCb->macUeCfg.ueIdx = ueIdx;
2196 ueCb->macUeCfg.crnti = crnti;
2197 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2199 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2202 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2204 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2210 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2217 /*******************************************************************
2219 * @brief Handle UE config response from MAC
2223 * Function : DuProcMacUeCfgRsp
2225 * Functionality: Handle UE Config response from MAC
2227 * @params[in] Pointer to MacUeCfgRsp and Pst
2228 * @return ROK - success
2231 * ****************************************************************/
2232 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2238 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2240 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2242 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2243 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2244 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2246 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2248 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2249 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2250 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2251 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2253 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2259 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2260 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2262 //TODO: Send the failure case in Ue Context Setup Response
2266 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2270 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2277 /*******************************************************************
2279 * @brief Processes UE create Req to RLC UL
2283 * Function : duBuildAndSendUeCreateReqToRlc
2286 * Processes UE create Req to RLC UL
2288 * @params[in] cellId,
2290 * Pointer to RlcUeCfg
2291 * @return ROK - success
2294 *****************************************************************/
2296 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2297 RlcUeCfg *duRlcUeCfg)
2300 RlcUeCfg *rlcUeCfg = NULLP;
2303 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2306 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2310 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2311 /* Copying ueCfg to a sharable buffer */
2312 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2315 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2316 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2317 /* Processing one Ue at a time to RLC */
2318 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2319 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2322 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2323 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2329 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2335 /*******************************************************************
2337 * @brief Processes UE create Rsp received from RLC UL
2342 * Function : DuProcRlcUeCfgRsp
2345 * Processes UE create Rsp received from RLC UL
2347 * @params[in] Post structure
2348 * Pointer to RlcCfgCfm
2349 * @return ROK - success
2352 *****************************************************************/
2353 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2359 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2361 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2363 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2364 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2365 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2367 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2369 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2370 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2371 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2372 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2374 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2380 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2381 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2382 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2384 //TODO: update failure case in ue Context setup Response
2388 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2392 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2398 /*******************************************************************
2400 * @brief Builds and Send Ue Reconfig Req to RLC
2404 * Function : duBuildAndSendUeReCfgReqToRLC
2406 * Functionality: Builds and Send Ue Reconfig Req to RLC
2408 * @params[in] cellId, crnti
2410 * RlcUeCfg *rlcUeCfg
2411 * @return ROK - success
2414 * ****************************************************************/
2416 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2418 uint8_t ret = ROK, ueIdx = 0;
2419 RlcUeCfg *rlcUeCfg = NULLP;
2421 GET_UE_IDX(crnti, ueIdx);
2422 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2425 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2426 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2428 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2430 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2434 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2440 /*******************************************************************
2442 * @brief Builds and Send Ue Reconfig Req to MAC
2446 * Function : duBuildAndSendUeReCfgReqToMac
2448 * Functionality: Builds and Send Ue Reconfig Req to MAC
2450 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2452 * MacUeCfg *macUeCfg
2453 * @return ROK - success
2456 * ****************************************************************/
2458 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2460 uint8_t ret, ueIdx = 0;
2461 MacUeCfg *macUeCfg = NULLP;
2464 GET_UE_IDX(crnti, ueIdx);
2466 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2469 memset(macUeCfg, 0, sizeof(MacUeCfg));
2470 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2472 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2474 ret = sendUeReCfgReqToMac(macUeCfg);
2478 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2484 /*******************************************************************
2486 * @brief Build and Send Ue context setup request
2491 * Function : duBuildAndSendUeContextSetupReq
2494 * Build and Send Ue context setup request
2496 * @params[in] cellId, crnti, DuUeCfg pointer
2497 * @return ROK - success
2500 *****************************************************************/
2502 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2506 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2507 /* Filling RLC Ue Reconfig */
2508 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2510 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2512 /* Filling MAC Ue Reconfig */
2513 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2515 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2520 /*******************************************************************
2522 * @brief Processes DL Rsp received from RLC DL
2527 * Function : DuProcRlcDlRrcMsgRsp
2530 * Processes UE Rsp received from RLC DL
2532 * @params[in] Post structure
2533 * Pointer to RlcCfgCfm
2534 * @return ROK - success
2537 *****************************************************************/
2538 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2540 uint8_t ret = ROK, ueIdx = 0;
2541 uint16_t cellId, crnti;
2542 DuUeCb *ueCb = NULLP;
2545 state = dlRrcMsg->state;
2546 cellId = dlRrcMsg->cellId;
2547 crnti = dlRrcMsg->crnti;
2548 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2550 if(state == TRANSMISSION_COMPLETE)
2552 GET_UE_IDX(crnti, ueIdx);
2553 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2555 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2557 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2559 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2561 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2564 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2566 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2568 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2571 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2573 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2576 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2582 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2586 /*******************************************************************
2588 * @brief Process UE context setup request from CU
2592 * Function : duProcUeContextSetupRequest
2594 * Functionality: Process UE context setup request from CU
2596 * @params[in] F1AP message
2597 * @return ROK - success
2600 * ****************************************************************/
2602 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2604 uint8_t ret, cellId;
2609 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2610 /* Send DL RRC msg for security Mode */
2611 if(ueCb->f1UeDb->dlRrcMsg)
2613 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2615 /* Sending DL RRC Message to RLC */
2616 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2619 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2620 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2621 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2622 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2626 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2628 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2631 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2637 //TODO: To send the failure cause in UeContextSetupRsp
2638 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2643 /*******************************************************************
2645 * @brief Build and Send Ue context mod request
2650 * Function : duBuildAndSendUeContextModReq
2653 * Build and Send Ue context mod request
2655 * @params[in] cellId, crnti, DuUeCfg pointer
2656 * @return ROK - success
2659 *****************************************************************/
2661 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2665 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2666 /* Filling RLC Ue Reconfig */
2667 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2669 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2671 /* Filling MAC Ue Reconfig */
2672 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2674 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2678 /*******************************************************************
2680 * @brief Processing Ue context mod request
2685 * Function : duProcUeContextModReq
2688 * Processing Ue context mod request
2690 * @params[in] DuUeCb *ueCb
2691 * @return ROK - success
2694 *****************************************************************/
2696 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2698 uint8_t ret, cellId;
2703 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2704 /* Send DL RRC msg for security Mode */
2705 if(ueCb->f1UeDb->dlRrcMsg)
2707 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2709 /* Sending DL RRC Message to RLC */
2710 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2713 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2714 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2715 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2716 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2722 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2725 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2731 //TODO: To send the failure cause in UeContextModRsp
2732 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2737 /*******************************************************************
2739 * @brief Function to delete Pdsch ServCellCfg
2743 * Function : deletePdschServCellCfg
2745 * Functionality: Function to delete Pdsch ServCellCfg
2747 * @params[in] PdschServCellCfg *pdschServCellCfg
2750 * ****************************************************************/
2752 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2754 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2755 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2756 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2757 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2760 /*******************************************************************
2762 * @brief delete MacUeCfg from duCb
2766 * Function : deleteMacUeCfg
2768 * Functionality: delete MacUeCfg from duCb
2770 * @params[in] Pointer to MacUeCfg
2771 * @return ROK - success
2774 *******************************************************************/
2776 void deleteMacUeCfg(MacUeCfg *ueCfg)
2780 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2781 if(ueCfg->spCellCfgPres)
2783 freeUeReCfgCellGrpInfo(ueCfg);
2785 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2787 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2789 memset(ueCfg, 0, sizeof(MacUeCfg));
2792 /*******************************************************************
2794 * @brief delete UE Configuration of a particular UE
2798 * Function : deleteUeCfg
2800 * Functionality: delete UE Configuration of a particular UE
2802 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2803 * @return ROK - success
2806 * ****************************************************************/
2807 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2810 DuUeCb *ueCb = NULLP;
2812 if(duCb.actvCellLst[cellIdx] != NULLP)
2814 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2815 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2817 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2818 deleteMacUeCfg(&ueCb->macUeCfg);
2819 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2820 if(ueCb->f1UeDb !=NULLP)
2822 freeF1UeDb(ueCb->f1UeDb);
2824 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2826 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2828 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2829 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2834 duCb.actvCellLst[cellIdx]->numActvUes--;
2835 memset(ueCb, 0, sizeof(DuUeCb));
2844 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2851 /*******************************************************************
2853 * @brief Handle UE delete response from MAC
2857 * Function : DuProcMacUeDeleteRsp
2859 * Functionality: Handle UE delete response from MAC
2861 * @params[in] Pointer to MacUeDeleteRsp and Pst
2862 * @return ROK - success
2865 * ****************************************************************/
2867 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2869 uint8_t ret =ROK,ueId=0;
2871 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2875 if(deleteRsp->result == SUCCESS)
2877 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2878 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2879 if(duCb.actvCellLst[cellIdx])
2881 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2882 ueId = deleteRsp->ueId;
2883 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2884 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2885 if(deleteUeCfg(cellIdx, ueId) == ROK)
2887 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2890 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2898 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2902 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2906 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2912 /*******************************************************************
2914 * @brief Processes UE Delete Rsp received from RLC
2918 * Function : DuProcRlcUeDeleteRsp
2921 * Processes UE Delete Rsp received from RLC
2923 * @params[in] Post structure
2924 * Pointer to RlcUeDeleteRsp
2925 * @return ROK - success
2928 * *****************************************************************/
2930 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2932 uint8_t ueId = 0, ret = ROK;
2933 uint16_t cellIdx = 0,crnti=0;
2937 ueId = delRsp->ueId;
2938 GET_CELL_IDX(delRsp->cellId, cellIdx);
2940 if(delRsp->result == SUCCESSFUL)
2942 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2943 if(duCb.actvCellLst[cellIdx]!=NULLP)
2945 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2946 GET_CRNTI(crnti, ueId);
2947 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2949 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
2957 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
2960 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2966 /*******************************************************************
2968 * @brief Sending UE Delete Req To Mac
2972 * Function : sendUeDeleteReqToMac
2975 * sending UE Delete Req To Mac
2977 * @params[in] cellId, ueId, crnti
2978 * @return ROK - success
2981 *****************************************************************/
2983 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
2987 MacUeDelete *ueDelete = NULLP;
2989 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2992 ueDelete->cellId = cellId;
2993 ueDelete->ueId = ueId;
2994 ueDelete->crnti = crnti;
2995 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2997 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
2998 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3001 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3002 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3007 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3013 /*******************************************************************
3015 * @brief Sending UE Delete Req To Rlc
3019 * Function : sendUeDeleteReqToRlc
3022 * Sending UE Delete Req To Rlc
3024 * @params[in] cellId, ueId
3025 * @return ROK - success
3028 *****************************************************************/
3030 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3034 RlcUeDelete *ueDelete;
3036 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3037 if(ueDelete !=NULLP)
3039 ueDelete->cellId = cellId;
3040 ueDelete->ueId = ueId;
3041 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3043 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3046 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3047 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3052 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3058 /*******************************************************************
3060 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3064 * Function : duBuildAndSendUeDeleteReq
3066 * Functionality: DU processes UE delete req from CU and sends to MAC
3069 * @params[in] cellId, crnti
3070 * @return ROK - success
3073 * ****************************************************************/
3075 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3078 uint16_t cellIdx = 0;
3080 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3081 GET_CELL_IDX(cellId, cellIdx);
3082 GET_UE_IDX(crnti, ueId);
3084 if(duCb.actvCellLst[cellIdx] != NULLP)
3086 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3088 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3092 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3093 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3095 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3101 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3108 /*******************************************************************
3110 * @brief delete RlcUeCfg from duCb
3114 * Function : deleteRlcUeCfg
3117 * delete RlcUeCfg from duCb
3119 * @params[in] RlcUeCfg *ueCfg
3121 * @return ROK - success
3124 *****************************************************************/
3126 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3129 RlcBearerCfg *lcCfg= NULLP;
3132 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3134 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3135 switch(lcCfg->rlcMode)
3139 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3142 case RLC_UM_BI_DIRECTIONAL :
3144 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3147 case RLC_UM_UNI_DIRECTIONAL_UL :
3149 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3152 case RLC_UM_UNI_DIRECTIONAL_DL :
3154 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3159 memset(ueCfg, 0, sizeof(RlcUeCfg));
3163 /*******************************************************************
3165 * @brief Du process Ue Context Release Command
3169 * Function : duProcUeContextReleaseCommand
3171 * Functionality: Du process Ue Context Release Command
3173 * @params[in] DuUeCb *duUeCb
3174 * @return ROK - success
3177 * ****************************************************************/
3178 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3180 uint8_t ret =ROK, ueIdx=0;
3181 uint16_t cellId=0,crnti =0;
3184 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3187 if(duUeCb->f1UeDb == NULLP)
3189 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3193 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3194 crnti = duUeCb->crnti;
3195 /* Send DL RRC msg for RRC release */
3196 if(duUeCb->f1UeDb->dlRrcMsg)
3198 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3200 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3201 duUeCb->f1UeDb->dlRrcMsg);
3204 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3205 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3206 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3207 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3213 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3216 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3223 /**********************************************************************
3225 ***********************************************************************/