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"
41 DuMacDlCcchInd packMacDlCcchIndOpts[] =
43 packMacDlCcchInd, /* Loose coupling */
44 MacProcDlCcchInd, /* TIght coupling */
45 packMacDlCcchInd /* Light weight-loose coupling */
48 DuMacUeCreateReq packMacUeCreateReqOpts[] =
50 packDuMacUeCreateReq, /* Loose coupling */
51 MacProcUeCreateReq, /* TIght coupling */
52 packDuMacUeCreateReq /* Light weight-loose coupling */
55 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
57 packDuRlcUeCreateReq, /* Loose coupling */
58 RlcProcUeCreateReq, /* TIght coupling */
59 packDuRlcUeCreateReq /* Light weight-loose coupling */
62 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
64 packDlRrcMsgToRlc, /* Loose coupling */
65 RlcProcDlRrcMsgTransfer, /* Tight coupling */
66 packDlRrcMsgToRlc /* Light weight-loose coupling */
69 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
71 packDuRlcUeReconfigReq, /* Loose coupling */
72 RlcProcUeReconfigReq, /* TIght coupling */
73 packDuRlcUeReconfigReq /* Light weight-loose coupling */
76 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
78 packDuMacUeReconfigReq, /* Loose coupling */
79 MacProcUeReconfigReq, /* TIght coupling */
80 packDuMacUeReconfigReq /* Light weight-loose coupling */
82 /*******************************************************************
84 * @brief Handles EGTP data from CU
88 * Function : duHdlEgtpData
91 * Processes EGTP header and sends data to RLC
93 * @params[in] Pointer to EGTP Message
94 * @return ROK - success
97 * ****************************************************************/
98 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
101 /* TODO : Extract RbId/UeID/CellID/SduId from database
102 using tunnel id in egtp header */
104 DU_LOG("\nDEBUG --> DU_APP : Processing DL data");
109 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
111 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
114 DU_LOG("\nDU APP : Memory allocation failed for dlRrcMsgInfo in \
115 duBuildAndSendDlRrcMsgToRlc");
116 ODU_PUT_MSG_BUF(egtpMsg->msg);
120 /* Filling up the RRC msg info */
121 dlRrcMsgInfo->cellId = NR_CELL_ID;
122 dlRrcMsgInfo->ueIdx = UE_ID;
123 dlRrcMsgInfo->rbType = CM_LTE_DRB;
124 dlRrcMsgInfo->rbId = RB_ID;
125 dlRrcMsgInfo->lcType = CM_LTE_LCH_DTCH;
126 dlRrcMsgInfo->lcId = 4;
127 dlRrcMsgInfo->execDup = false;
128 dlRrcMsgInfo->deliveryStaRpt = false;
129 ODU_GET_MSG_LEN(egtpMsg->msg, &dlRrcMsgInfo->msgLen);
130 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
131 ODU_COPY_MSG_TO_FIX_BUF(egtpMsg->msg, 0, dlRrcMsgInfo->msgLen, dlRrcMsgInfo->rrcMsg, (MsgLen *)©Len);
132 ODU_PUT_MSG_BUF(egtpMsg->msg);
134 /* Filling post structure and sending msg */
135 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
136 DU_LOG("\nDU_APP: Sending Dl User Msg to RLC \n");
137 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
140 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
147 /******************************************************************
149 * @brief Builds and Sends DL CCCH Ind to MAC
153 * Function : duBuildAndSendDlCcchInd
155 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
157 * @params[in] dlCcchMsg - uint8_t*
158 * @return ROK - success
161 * ****************************************************************/
162 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
163 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
167 DlCcchIndInfo *dlCcchIndInfo = NULLP;
170 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
172 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
176 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
180 dlCcchIndInfo->cellId = *cellId;
181 dlCcchIndInfo->crnti = *crnti;
182 dlCcchIndInfo->msgType = msgType;
183 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
185 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
186 if(!dlCcchIndInfo->dlCcchMsg)
188 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
189 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
192 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
194 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
196 DU_FREE(dlCcchMsg, dlCcchMsgSize);
199 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
200 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
203 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
204 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
205 dlCcchIndInfo->dlCcchMsgLen);
206 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
207 sizeof(DlCcchIndInfo));
215 /*******************************************************************
217 * @brief Build and Send DL RRC Message transfer to RLC
221 * Function : duBuildAndSendDlRrcMsgToRlc
224 * Build and Send DL RRC Message transfer to RLC
226 * @params[in] Cell ID
228 * Logical Channgel ID
231 * @return ROK - success
234 * ****************************************************************/
235 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
240 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
244 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
248 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
251 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
252 duBuildAndSendDlRrcMsgToRlc");
253 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
257 /* Filling up the RRC msg info */
258 dlRrcMsgInfo->cellId = cellId;
259 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
260 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
262 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
264 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
265 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
266 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
267 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
271 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
272 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
273 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
274 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
276 /* Filling post structure and sending msg */
277 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
278 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
279 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
282 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
283 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
292 /******************************************************************
294 * @brief Process DL RRC Msg recevied from F1AP
298 * Function : duProcDlRrcMsg
300 * Functionality: Process DL RRC Msg recevied from F1AP
302 * @params[in] dlCcchMsg - uint8_t*
303 * @return ROK - success
306 * ****************************************************************/
308 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
311 uint16_t crnti, cellId, cellIdx;
312 bool ueCcchCtxtFound = false;
313 bool ueFound = false;
317 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
319 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
321 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
323 ueCcchCtxtFound = true;
324 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
325 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
332 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
335 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
339 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
341 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
344 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
345 duCb.ueCcchCtxt[ueIdx].cellId);
350 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
357 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
359 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
361 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
362 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
365 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
366 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
379 /******************************************************************
381 * @brief Generates GNB DU Ue F1AP ID
385 * Function : genGnbDuUeF1apId
387 * Functionality: Generates GNB DU Ue F1AP ID
390 * @return gnbDuF1apId
392 * ****************************************************************/
393 uint32_t genGnbDuUeF1apId()
395 static uint32_t gnbDuUeF1apId = 0;
397 return ++gnbDuUeF1apId;
400 /******************************************************************
402 * @brief Processes UL CCCH Ind recvd from MAC
406 * Function : duProcUlCcchInd
408 * Functionality: Processes UL CCCH Ind recvd from MAC
410 * @params[in] UlCcchIndInfo *ulCcchIndInfo
411 * @return ROK - success
414 * ****************************************************************/
415 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
419 uint32_t gnbDuUeF1apId = 0;
421 gnbDuUeF1apId = genGnbDuUeF1apId();
423 /* Store Ue mapping */
424 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
425 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
426 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
430 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
431 ulCcchIndInfo->ulCcchMsg));
434 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
437 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
438 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
444 /******************************************************************
446 * @brief Fills Default UL LC Cfg
450 * Function : fillDefaultUlLcCfg
452 * Functionality: Fills Default UL LC Cfg
454 * @params[in] UlLcCfg *ulLcCfg
456 *****************************************************************/
457 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
459 ulLcCfg->priority = LC_PRIORITY_1;
460 ulLcCfg->lcGroup = 0;
461 ulLcCfg->schReqId = 0;
462 ulLcCfg->pbr = PBR_KBPS_INFINITY;
463 ulLcCfg->bsd = BSD_MS_1000;
466 /******************************************************************
468 * @brief Fills Initial DL Bandwidth Part
472 * Function : fillDefaultInitDlBwp
474 * Functionality: Fills Initial DL Bandwidth Part
476 * @params[in] InitialDlBwp *initDlBwp
479 *****************************************************************/
480 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
483 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
484 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
489 /* Filling PDCCH Config */
490 initDlBwp->pdcchPresent = TRUE;
491 if(initDlBwp->pdcchPresent)
493 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
494 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
495 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
497 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
498 PDCCH_CTRL_RSRC_SET_ONE_ID;
499 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
501 coreset0EndPrb = CORESET0_END_PRB;
502 coreset1StartPrb = coreset0EndPrb +6;
503 coreset1NumPrb = CORESET1_NUM_PRB;
504 /* calculate the PRBs */
505 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
506 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
509 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
510 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
511 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
512 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
513 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
515 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
518 initDlBwp->pdcchCfg.numCRsetToRel = 0;
519 /* Filling Serach Space */
520 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
521 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
522 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
524 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
525 PDCCH_SRCH_SPC_TWO_ID;
526 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
527 PDCCH_CTRL_RSRC_SET_ONE_ID;
528 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
529 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
530 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
531 MONITORING_SYMB_WITHIN_SLOT_SIZE);
532 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
533 PDCCH_SYMBOL_WITHIN_SLOT;
534 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
536 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
538 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
540 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
542 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
544 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
545 SEARCHSPACETYPE_PR_UE_SPECIFIC;
546 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
547 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
549 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
553 /* Filling PDSCH Config */
554 initDlBwp->pdschPresent = TRUE;
555 if(initDlBwp->pdschPresent)
557 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
558 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
559 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
560 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
562 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
563 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
564 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
565 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
566 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
567 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
568 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
569 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
575 /******************************************************************
577 * @brief Fills Initial UL Bandwidth Part
581 * Function : fillDefaultInitUlBwp
583 * Functionality: Fills Initial UL Bandwidth Part
585 * @params[in] InitialUlBwp *initUlBwp
588 *****************************************************************/
589 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
594 initUlBwp->pucchPresent = FALSE;
596 /*Filling PUSCH Config */
597 initUlBwp->puschPresent = TRUE;
598 if(initUlBwp->puschPresent)
600 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
601 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
602 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
603 scramblingId0 = SCRAMBLING_ID;
604 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
605 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
607 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
609 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
610 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
612 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
613 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
614 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
615 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
617 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
622 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
626 /******************************************************************
628 * @brief Fills SpCell Group Info
632 * Function : fillDefaultSpCellGrpInfo
634 * Functionality: Fills Sp Cell Group Info
636 * @params[in] SpCellCfg *spCell
639 *****************************************************************/
640 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
644 spCell->servCellIdx = SERV_CELL_IDX;
645 /* Filling Initial Dl Bwp */
646 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
648 spCell->servCellCfg.numDlBwpToAdd = 0;
649 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
650 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
651 spCell->servCellCfg.bwpInactivityTmr = NULLP;
652 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
653 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
654 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
655 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
656 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
657 NUM_HARQ_PROC_FOR_PDSCH_N_16;
658 /* Filling Initial UL Bwp*/
659 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
660 spCell->servCellCfg.numUlBwpToAdd = 0;
661 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
665 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
669 /******************************************************************
671 * @brief Fills Physical Cell Group Info
675 * Function : fillDefaultPhyCellGrpInfo
677 * Functionality: Fills Physical Cell Group Info
679 * @params[in] PhyCellGrpCfg *cellGrp
682 *****************************************************************/
683 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
687 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
688 cellGrp->pNrFr1 = P_NR_FR1;
692 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
696 /******************************************************************
698 * @brief Fills Mac Cell Group Info
702 * Function : fillDefaultMacCellGrpInfo
704 * Functionality: Fills Mac Cell Group Info
706 * @params[in] MacCellGrpCfg *cellGrp
709 *****************************************************************/
710 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
716 /* Filling Scheduling Request Config */
717 cellGrp->schReqCfg.addModListCount = 1;
718 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
720 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
722 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
723 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
724 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
727 cellGrp->schReqCfg.relListCount = 0;
729 /* Filling Tag config */
730 cellGrp->tagCfg.addModListCount = 1;
731 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
733 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
735 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
736 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
739 cellGrp->tagCfg.relListCount = 0;
741 /* Filling BSR config */
742 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
743 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
744 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
746 /* Filling PHR config */
747 cellGrp->phrCfgSetupPres = true;
748 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
749 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
750 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
751 cellGrp->phrCfg.multiplePHR = false;
752 cellGrp->phrCfg.dummy = false;
753 cellGrp->phrCfg.phrType2OtherCell = false;
754 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
759 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
763 /*******************************************************************
765 * @brief Fills default modulation info for a UE
769 * Function : fillDefaultModulation
771 * Functionality: Fills default modulation info for a UE
773 * @params[in] Pointer to MAC UE configuration
774 * @return ROK - success
777 * ****************************************************************/
778 void fillDefaultModulation(MacUeCfg *ueCfg)
780 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
781 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
782 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
784 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
785 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
786 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
789 /******************************************************************
791 * @brief Function to fill Mac Lc Cfg for SRB1
795 * Function : fillMacSrb1LcCfg
797 * Functionality: Function to fill Mac Lc cfg for SRB1
799 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
801 *****************************************************************/
803 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
805 macLcCfg->lcId = SRB1_LCID;
806 macLcCfg->configType = CONFIG_ADD;
807 macLcCfg->drbQos = NULLP;
808 macLcCfg->snssai = NULLP;
809 macLcCfg->ulLcCfgPres = true;
810 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
813 /******************************************************************
815 * @brief Function to fill the Lc cfg from ueSetupReqDb
819 * Function : fillMacLcCfgToAddMod
821 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
823 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
824 * @return ROK/RFAILED
826 *****************************************************************/
828 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
831 lcCfg->lcId = ueSetReqDb->lcId;
832 lcCfg->configType = ueSetReqDb->configType;
834 if(ueSetReqDb->drbQos)
838 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
841 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
847 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
852 lcCfg->drbQos = NULLP;
857 if(ueSetReqDb->snssai)
861 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
864 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
871 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
875 lcCfg->snssai = NULLP;
878 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
879 lcCfg->drbQos = NULLP;
885 lcCfg->snssai = NULLP;
887 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
888 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
889 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
893 /******************************************************************
895 * @brief Function to copy the Bit rate from ueSetupReqDb
899 * Function : fillAmbr
901 * Functionality: Function to copy bit Rate from ueSetupReqDb
903 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
904 * @return ROK/RFAILED
906 *****************************************************************/
908 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
912 if(*macAmbr == NULLP)
914 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
915 if(*macAmbr == NULLP)
917 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
921 memset(*macAmbr, 0, sizeof(AmbrCfg));
922 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
923 (*macAmbr)->dlBr = ueDbAmbr->dlBr;
932 /******************************************************************
934 * @brief Builds and Send UE ReConfig Request to MAC
938 * Function : sendUeReCfgReqToMac
940 * Functionality: Builds and Send UE ReConfig Request to MAC
942 * @Params[in] MacUeCfg pointer
943 * @return ROK - success
946 * ****************************************************************/
948 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
954 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
958 /* Processing one Ue at a time to MAC */
959 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
960 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
963 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
964 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
969 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
975 /******************************************************************
977 * @brief Function to return Drb LcId
981 * Function : getDrbLcId
983 * Functionality: Function to return Drb LcId
985 * Returns: lcId - SUCCESS
987 *****************************************************************/
989 uint8_t getDrbLcId(uint32_t *drbBitMap)
991 uint8_t bitMask = 1, bitPos = 0;
992 bitPos = MIN_DRB_LCID;
994 while(bitPos <= MAX_DRB_LCID)
996 if((*drbBitMap & (bitMask << bitPos)) == 0)
998 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1006 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1010 /******************************************************************
1012 * @brief Fills MacUeCfg structure
1016 * Function : fillMacUeCfg
1018 * Functionality: Fills MacUeCfg
1020 * @params[in] cellId, ueIdx, crnti,
1023 * @return ROK/RFAILED
1025 *****************************************************************/
1026 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1027 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1029 uint8_t ret, dbIdx, lcIdx, cellIdx;
1030 bool lcIdFound = false;
1031 MacUeCfg *duMacDb = NULLP;
1037 macUeCfg->cellId = cellId;
1038 macUeCfg->ueIdx = ueIdx;
1039 macUeCfg->crnti = crnti;
1040 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1041 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1042 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1043 macUeCfg->ambrCfg = NULLP;
1044 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1045 fillDefaultModulation(macUeCfg);
1050 /* Fetching MacDb from DuUeCb */
1051 GET_CELL_IDX(cellId, cellIdx);
1052 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1053 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1054 macUeCfg->cellId = cellId;
1055 macUeCfg->ueIdx = ueIdx;
1056 macUeCfg->crnti = crnti;
1057 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1060 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1062 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1063 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1065 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1067 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1068 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1070 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1072 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1075 /* Filling LC Context */
1076 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1078 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1080 /* Filling default UL LC config in MAC if not present */
1081 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1082 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1084 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1086 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1089 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1090 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1092 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1093 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1101 /* ADD/DEL CONFIG */
1102 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1110 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1113 }/*End of Outer FOR loop */
1118 /******************************************************************
1120 * @brief Fills Rlc AM Information
1124 * Function : fillDefaultAmInfo
1126 * Functionality: Fills Rlc AM Information
1128 * @params[in] AmBearerCfg *amCfg
1131 *****************************************************************/
1132 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1135 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1136 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1137 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1138 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1139 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1142 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1143 amCfg->ulAmCfg.reAssemTmr = RE_ASM_40MS;
1144 amCfg->ulAmCfg.statProhTmr = PROH_35MS;
1147 /******************************************************************
1149 * @brief Fills RLC UM Bi Directional Information
1153 * Function : fillDefaultUmBiInfo
1155 * Functionality: Fills RLC UM Bi Directional Information
1157 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1160 *****************************************************************/
1161 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1163 /* UL UM BI DIR INFO */
1164 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1165 umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1167 /* DL UM BI DIR INFO */
1168 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1171 /******************************************************************
1173 * @brief Fills RLC UM Uni Directional UL Information
1177 * Function : fillDefaultUmUlInfo
1179 * Functionality: Fills RLC UM Uni Directional Info
1181 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1184 *****************************************************************/
1185 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1187 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1188 UmUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1191 /******************************************************************
1193 * @brief Fills RLC UM Uni Directional DL Information
1197 * Function : fillDefaultUmDlInfo
1199 * Functionality: Fills RLC UM Uni Directional DL Info
1201 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1204 *****************************************************************/
1205 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1207 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1210 /******************************************************************
1212 * @brief Builds Rlc Mode Default Configuration
1216 * Function : fillDefaultRlcModeCfg
1218 * Functionality: Builds Rlc Mode Default Configuration
1220 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1221 * @return ROK/RFAILED
1223 *****************************************************************/
1225 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1236 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1238 fillDefaultAmInfo(lcCfg->u.amCfg);
1241 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1247 case RLC_UM_BI_DIRECTIONAL :
1249 if(!lcCfg->u.umBiDirCfg)
1251 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1252 if(lcCfg->u.umBiDirCfg)
1253 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1256 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1262 case RLC_UM_UNI_DIRECTIONAL_UL :
1264 if(!lcCfg->u.umUniDirUlCfg)
1266 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1267 if(lcCfg->u.umUniDirUlCfg)
1268 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1271 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1277 case RLC_UM_UNI_DIRECTIONAL_DL :
1279 if(!lcCfg->u.umUniDirDlCfg)
1281 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1282 if(lcCfg->u.umUniDirDlCfg)
1283 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1286 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1293 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1300 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1306 /*******************************************************************
1308 * @brief Function to fill Rlc Lc Cfg for SRB1
1312 * Function : fillRlcSrb1LcCfg
1315 * Function to fill Rlc Lc Cfg for SRB1
1317 * @params[in] Pointer to RlcBearerCfg
1318 * @return ROK/RFAILED
1320 *****************************************************************/
1322 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1326 rlcLcCfg->rbId = SRB1_LCID;
1327 rlcLcCfg->rbType = RB_TYPE_SRB;
1328 rlcLcCfg->lcId = SRB1_LCID;
1329 rlcLcCfg->lcType = LCH_DCCH;
1330 rlcLcCfg->rlcMode = RLC_AM;
1331 rlcLcCfg->configType = CONFIG_ADD;
1332 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1336 /*******************************************************************
1338 * @brief Processes UE ReConfig Req to RLC UL
1342 * Function : sendUeReCfgReqToRlc
1345 * Processes UE Reconfig Req to RLC UL
1347 * @params[in] Pointer to RlcUeCfg
1348 * @return ROK - success
1351 *****************************************************************/
1353 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1358 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1361 /* Processing one Ue at a time to RLC */
1362 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1363 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1366 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1367 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1372 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1378 /******************************************************************
1380 * @brief Fills RlcBearerCfg structure
1384 * Function : fillRlcUeCfg
1386 * Functionality: Fills Rlc Bearer Cfg
1389 *****************************************************************/
1390 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1391 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1393 uint8_t ret, dbIdx, lcIdx, cellIdx;
1394 bool lcIdFound = false;
1395 RlcUeCfg *duRlcDb = NULLP;
1400 /* Initial RB being Added */
1401 rlcUeCfg->cellId = cellId;
1402 rlcUeCfg->ueIdx = ueIdx;
1403 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1407 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1411 /* Fetch RlcDb from DuUeCb */
1412 GET_CELL_IDX(cellId, cellIdx);
1413 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1414 /*Filling RlcUeCfg */
1415 rlcUeCfg->cellId = cellId;
1416 rlcUeCfg->ueIdx = ueIdx;
1417 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1419 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1422 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1423 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1426 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1427 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1429 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1432 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1433 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1436 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1437 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1445 /* ADD/ DEL Config Type */
1446 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1454 /******************************************************************
1456 * @brief creates UE context
1460 * Function : duCreateUeCb
1462 * Functionality: Creates UE Conetxt
1464 * @params[in] UeCcchCtxt Pointer
1467 * @return ROK - success
1469 * ****************************************************************/
1470 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1472 uint8_t cellIdx = 0;
1476 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1478 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1480 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1481 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1483 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1484 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1485 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1486 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1487 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1488 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1490 /* Filling Mac Ue Config */
1491 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1492 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1493 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1495 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1497 /* Filling Rlc Ue Config */
1498 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1499 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1500 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1502 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1504 duCb.actvCellLst[cellIdx]->numActvUes++;
1505 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1511 /******************************************************************
1513 * @brief Builds and Send UE Create Request to MAC
1517 * Function : duBuildAndSendUeCreateReqToMac
1519 * Functionality: Builds and Send UE Create Request to MAC
1521 * @Params[in] cellId,
1523 * @return ROK - success
1526 * ****************************************************************/
1528 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1529 uint16_t crnti, MacUeCfg *duMacUeCfg)
1532 MacUeCfg *macUeCfg = NULLP;
1534 memset(&pst, 0, sizeof(Pst));
1537 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1540 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1544 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1546 /* Copying ueCb to a sharable buffer */
1547 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1550 memset(macUeCfg, 0, sizeof(MacUeCfg));
1551 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1552 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1554 /* Processing one Ue at a time to MAC */
1555 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1558 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1559 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1564 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1570 /*******************************************************************
1572 * @brief To update DuUeCb Mac Cfg
1576 * Function : duUpdateMacCfg
1577 * Functionality: update DuUeCb MAC Cfg
1579 * @params[in] DuUeCb Pointer
1580 * F1UeContextSetupDb pointer
1581 * @return ROK - success
1584 * ****************************************************************/
1585 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1587 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1590 /*Filling Cell Group Cfg*/
1591 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1594 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1596 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1597 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1599 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1601 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1602 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1604 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1606 /* Filling LC Context */
1607 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1609 numLcs = macUeCfg->numLcs;
1610 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1612 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1614 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1616 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1618 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1620 /* Free memory at matched lcIdx index */
1621 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1623 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1625 /* moving all elements one index ahead */
1626 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1627 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1630 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1637 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1639 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1642 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1652 /******************************************************************
1654 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1658 * Function : fillRlcCfgToAddMod
1660 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1663 *****************************************************************/
1665 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1667 lcCfg->configType = f1UeDbLcCfg->configType;
1668 lcCfg->rbId = f1UeDbLcCfg->rbId;
1669 lcCfg->rbType = f1UeDbLcCfg->rbType;
1670 lcCfg->lcId = f1UeDbLcCfg->lcId;
1671 lcCfg->lcType = f1UeDbLcCfg->lcType;
1672 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1673 switch(lcCfg->rlcMode)
1679 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1684 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1685 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1686 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1687 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1688 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1691 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1692 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1693 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1696 case RLC_UM_BI_DIRECTIONAL :
1698 if(!lcCfg->u.umBiDirCfg)
1700 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1701 if(!lcCfg->u.umBiDirCfg)
1704 /* UL UM BI DIR INFO */
1705 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1706 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1707 /* DL UM BI DIR INFO */
1708 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1711 case RLC_UM_UNI_DIRECTIONAL_UL :
1713 if(!lcCfg->u.umUniDirUlCfg)
1715 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1716 if(!lcCfg->u.umUniDirUlCfg)
1719 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1720 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1724 case RLC_UM_UNI_DIRECTIONAL_DL :
1726 if(!lcCfg->u.umUniDirDlCfg)
1728 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1729 if(!lcCfg->u.umUniDirDlCfg)
1732 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1736 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1742 /*******************************************************************
1744 * @brief To update DuUeCb Rlc Lc Cfg
1748 * Function : duUpdateRlcLcCfg
1749 * Functionality: update DuUeCb Rlc Lc Cfg
1751 * @params[in] DuUeCb Pointer
1752 * F1UeContextSetupDb pointer
1753 * @return ROK - success
1756 * ****************************************************************/
1758 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1760 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1763 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1765 numLcs = rlcUeCfg->numLcs;
1766 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1768 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1770 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1772 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1774 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1776 /* Free memory at matched lcIdx index */
1777 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1779 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1781 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1782 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1785 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1792 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1794 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1803 /*******************************************************************
1805 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
1810 * Function : duUpdateDuUeCbCfg
1812 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
1814 * @params[in] ueIdx, cellIdx
1815 * @return ROK - success
1818 * ****************************************************************/
1820 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
1822 uint8_t ret = ROK, cellIdx = 0, crnti=0;
1823 DuUeCb *ueCb = NULLP;
1825 GET_CELL_IDX(cellId, cellIdx);
1827 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
1828 macUeCfgState == UE_RECFG_COMPLETE) &&
1829 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
1830 rlcUeCfgState == UE_RECFG_COMPLETE))
1832 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
1834 /*Filling RLC Ue Cfg */
1835 ueCb->rlcUeCfg.cellId = cellId;
1836 ueCb->rlcUeCfg.ueIdx = ueIdx;
1837 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
1840 /*Filling MAC Ue Cfg */
1841 GET_CRNTI(crnti, ueIdx);
1842 ueCb->macUeCfg.cellId = cellId;
1843 ueCb->macUeCfg.ueIdx = ueIdx;
1844 ueCb->macUeCfg.crnti = crnti;
1845 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
1847 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
1850 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
1857 /*******************************************************************
1859 * @brief Handle UE config response from MAC
1863 * Function : DuProcMacUeCfgRsp
1865 * Functionality: Handle UE Config response from MAC
1867 * @params[in] Pointer to MacUeCfgRsp and Pst
1868 * @return ROK - success
1871 * ****************************************************************/
1872 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
1878 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
1880 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
1882 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1883 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1884 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
1886 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1888 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1889 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1890 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
1891 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
1892 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
1897 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
1898 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1900 //TODO: Send the failure case in Ue Context Setup Response
1904 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
1908 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
1915 /*******************************************************************
1917 * @brief Processes UE create Req to RLC UL
1921 * Function : duBuildAndSendUeCreateReqToRlc
1924 * Processes UE create Req to RLC UL
1926 * @params[in] cellId,
1928 * Pointer to RlcUeCfg
1929 * @return ROK - success
1932 *****************************************************************/
1934 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
1935 RlcUeCfg *duRlcUeCfg)
1938 RlcUeCfg *rlcUeCfg = NULLP;
1941 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
1944 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
1948 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
1949 /* Copying ueCfg to a sharable buffer */
1950 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
1953 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1954 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
1955 /* Processing one Ue at a time to RLC */
1956 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
1957 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
1960 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
1961 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1967 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
1973 /*******************************************************************
1975 * @brief Processes UE create Rsp received from RLC UL
1980 * Function : DuProcRlcUeCfgRsp
1983 * Processes UE create Rsp received from RLC UL
1985 * @params[in] Post structure
1986 * Pointer to RlcCfgCfm
1987 * @return ROK - success
1990 *****************************************************************/
1991 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
1997 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
1999 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2001 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2002 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2003 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2005 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2007 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2008 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2009 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2010 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2011 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2016 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2017 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2018 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2020 //TODO: update failure case in ue Context setup Response
2024 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2028 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2036 /*******************************************************************
2038 * @brief Builds and Send Ue Reconfig Req to RLC
2042 * Function : duBuildAndSendUeReCfgReqToRLC
2044 * Functionality: Builds and Send Ue Reconfig Req to RLC
2046 * @params[in] cellId, crnti
2048 * RlcUeCfg *rlcUeCfg
2049 * @return ROK - success
2052 * ****************************************************************/
2054 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2056 uint8_t ret = ROK, ueIdx = 0;
2057 RlcUeCfg *rlcUeCfg = NULLP;
2059 GET_UE_IDX(crnti, ueIdx);
2060 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2063 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2064 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2066 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2068 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2072 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2078 /*******************************************************************
2080 * @brief Builds and Send Ue Reconfig Req to MAC
2084 * Function : duBuildAndSendUeReCfgReqToMac
2086 * Functionality: Builds and Send Ue Reconfig Req to MAC
2088 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2090 * MacUeCfg *macUeCfg
2091 * @return ROK - success
2094 * ****************************************************************/
2096 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2098 uint8_t ret, ueIdx = 0;
2099 MacUeCfg *macUeCfg = NULLP;
2102 GET_UE_IDX(crnti, ueIdx);
2104 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2107 memset(macUeCfg, 0, sizeof(MacUeCfg));
2108 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2110 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2112 ret = sendUeReCfgReqToMac(macUeCfg);
2116 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2122 /*******************************************************************
2124 * @brief Build and Send Ue context setup request
2129 * Function : duBuildAndSendUeContextSetupReq
2132 * Build and Send Ue context setup request
2134 * @params[in] cellId, crnti, DuUeCfg pointer
2135 * @return ROK - success
2138 *****************************************************************/
2140 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2144 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2145 /* Filling RLC Ue Reconfig */
2146 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2148 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2150 /* Filling MAC Ue Reconfig */
2151 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2153 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2158 /*******************************************************************
2160 * @brief Processes DL Rsp received from RLC DL
2165 * Function : DuProcRlcDlRrcMsgRsp
2168 * Processes UE Rsp received from RLC DL
2170 * @params[in] Post structure
2171 * Pointer to RlcCfgCfm
2172 * @return ROK - success
2175 *****************************************************************/
2176 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2178 uint8_t ret = ROK, ueIdx = 0;
2179 DuUeCb *ueCb = NULLP;
2181 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2183 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2184 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2187 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2189 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2193 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2195 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2198 /*******************************************************************
2200 * @brief Process UE context setup request from CU
2204 * Function : duProcUeContextSetupRequest
2206 * Functionality: Process UE context setup request from CU
2208 * @params[in] F1AP message
2209 * @return ROK - success
2212 * ****************************************************************/
2214 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2216 uint8_t ret, cellId;
2221 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2222 /* Send DL RRC msg for security Mode */
2223 if(ueCb->f1UeDb->dlRrcMsg)
2225 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2227 /* Sending DL RRC Message to RLC */
2228 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2231 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2232 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2233 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2234 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2240 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2243 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2249 //TODO: To send the failure cause in UeContextSetupRsp
2250 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2255 /**********************************************************************
2257 ***********************************************************************/