1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
37 DuMacDlCcchInd packMacDlCcchIndOpts[] =
39 packMacDlCcchInd, /* Loose coupling */
40 MacProcDlCcchInd, /* TIght coupling */
41 packMacDlCcchInd /* Light weight-loose coupling */
44 DuMacUeCreateReq packMacUeCreateReqOpts[] =
46 packDuMacUeCreateReq, /* Loose coupling */
47 MacProcUeCreateReq, /* TIght coupling */
48 packDuMacUeCreateReq /* Light weight-loose coupling */
51 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
53 packDuRlcUeCreateReq, /* Loose coupling */
54 RlcProcUeCreateReq, /* TIght coupling */
55 packDuRlcUeCreateReq /* Light weight-loose coupling */
58 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
60 packDlRrcMsgToRlc, /* Loose coupling */
61 RlcProcDlRrcMsgTransfer, /* Tight coupling */
62 packDlRrcMsgToRlc /* Light weight-loose coupling */
65 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
67 packDuRlcUeReconfigReq, /* Loose coupling */
68 RlcProcUeReconfigReq, /* TIght coupling */
69 packDuRlcUeReconfigReq /* Light weight-loose coupling */
72 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
74 packDuMacUeReconfigReq, /* Loose coupling */
75 MacProcUeReconfigReq, /* TIght coupling */
76 packDuMacUeReconfigReq /* Light weight-loose coupling */
83 /*******************************************************************
85 * @brief Handles EGTP data from CU
89 * Function : duHdlEgtpData
92 * Processes EGTP header and sends data to RLC
94 * @params[in] Pointer to EGTP Message
95 * @return ROK - success
98 * ****************************************************************/
99 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
102 /* TODO : Extract RbId/UeID/CellID/SduId from database
103 using tunnel id in egtp header */
105 DU_LOG("\nDEBUG --> DU_APP : Processing DL data");
110 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
112 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
115 DU_LOG("\nDU APP : Memory allocation failed for dlRrcMsgInfo in \
116 duBuildAndSendDlRrcMsgToRlc");
117 ODU_PUT_MSG_BUF(egtpMsg->msg);
121 /* Filling up the RRC msg info */
122 dlRrcMsgInfo->cellId = NR_CELL_ID;
123 dlRrcMsgInfo->ueIdx = UE_ID;
124 dlRrcMsgInfo->rbType = CM_LTE_DRB;
125 dlRrcMsgInfo->rbId = RB_ID;
126 dlRrcMsgInfo->lcType = CM_LTE_LCH_DTCH;
127 dlRrcMsgInfo->lcId = 4;
128 dlRrcMsgInfo->execDup = false;
129 dlRrcMsgInfo->deliveryStaRpt = false;
130 ODU_GET_MSG_LEN(egtpMsg->msg, &dlRrcMsgInfo->msgLen);
131 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
132 ODU_COPY_MSG_TO_FIX_BUF(egtpMsg->msg, 0, dlRrcMsgInfo->msgLen, dlRrcMsgInfo->rrcMsg, (MsgLen *)©Len);
133 ODU_PUT_MSG_BUF(egtpMsg->msg);
135 /* Filling post structure and sending msg */
136 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
137 DU_LOG("\nDU_APP: Sending Dl User Msg to RLC \n");
138 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
141 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
148 /******************************************************************
150 * @brief Builds and Sends DL CCCH Ind to MAC
154 * Function : duBuildAndSendDlCcchInd
156 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
158 * @params[in] dlCcchMsg - uint8_t*
159 * @return ROK - success
162 * ****************************************************************/
163 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
164 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
168 DlCcchIndInfo *dlCcchIndInfo = NULLP;
171 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
173 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
177 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
181 dlCcchIndInfo->cellId = *cellId;
182 dlCcchIndInfo->crnti = *crnti;
183 dlCcchIndInfo->msgType = msgType;
184 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
186 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
187 if(!dlCcchIndInfo->dlCcchMsg)
189 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
190 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
193 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
195 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
197 DU_FREE(dlCcchMsg, dlCcchMsgSize);
200 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
201 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
204 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
205 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
206 dlCcchIndInfo->dlCcchMsgLen);
207 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
208 sizeof(DlCcchIndInfo));
216 /*******************************************************************
218 * @brief Build and Send DL RRC Message transfer to RLC
222 * Function : duBuildAndSendDlRrcMsgToRlc
225 * Build and Send DL RRC Message transfer to RLC
227 * @params[in] Cell ID
229 * Logical Channgel ID
232 * @return ROK - success
235 * ****************************************************************/
236 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
241 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
245 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
249 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
252 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
253 duBuildAndSendDlRrcMsgToRlc");
254 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
258 /* Filling up the RRC msg info */
259 dlRrcMsgInfo->cellId = cellId;
260 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
261 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
263 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
265 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
266 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
267 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
268 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
272 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
273 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
274 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
275 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
277 /* Filling post structure and sending msg */
278 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
279 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
280 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
283 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
284 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
293 /******************************************************************
295 * @brief Process DL RRC Msg recevied from F1AP
299 * Function : duProcDlRrcMsg
301 * Functionality: Process DL RRC Msg recevied from F1AP
303 * @params[in] dlCcchMsg - uint8_t*
304 * @return ROK - success
307 * ****************************************************************/
309 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
312 uint16_t crnti, cellId, cellIdx;
313 bool ueCcchCtxtFound = false;
314 bool ueFound = false;
318 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
320 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
322 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
324 ueCcchCtxtFound = true;
325 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
326 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
333 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
336 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
340 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
342 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
345 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
346 duCb.ueCcchCtxt[ueIdx].cellId);
351 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
358 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
360 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
362 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
363 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
366 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
367 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
380 /******************************************************************
382 * @brief Generates GNB DU Ue F1AP ID
386 * Function : genGnbDuUeF1apId
388 * Functionality: Generates GNB DU Ue F1AP ID
391 * @return gnbDuF1apId
393 * ****************************************************************/
394 uint32_t genGnbDuUeF1apId()
396 static uint32_t gnbDuUeF1apId = 0;
398 return ++gnbDuUeF1apId;
401 /******************************************************************
403 * @brief Processes UL CCCH Ind recvd from MAC
407 * Function : duProcUlCcchInd
409 * Functionality: Processes UL CCCH Ind recvd from MAC
411 * @params[in] UlCcchIndInfo *ulCcchIndInfo
412 * @return ROK - success
415 * ****************************************************************/
416 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
420 uint32_t gnbDuUeF1apId = 0;
422 gnbDuUeF1apId = genGnbDuUeF1apId();
424 /* Store Ue mapping */
425 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
426 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
427 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
431 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
432 ulCcchIndInfo->ulCcchMsg));
435 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
438 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
439 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
445 /******************************************************************
447 * @brief Fills Default UL LC Cfg
451 * Function : fillDefaultUlLcCfg
453 * Functionality: Fills Default UL LC Cfg
455 * @params[in] UlLcCfg *ulLcCfg
457 *****************************************************************/
458 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
460 ulLcCfg->priority = LC_PRIORITY_1;
461 ulLcCfg->lcGroup = 0;
462 ulLcCfg->schReqId = 0;
463 ulLcCfg->pbr = PBR_KBPS_INFINITY;
464 ulLcCfg->bsd = BSD_MS_1000;
467 /******************************************************************
469 * @brief Fills Initial DL Bandwidth Part
473 * Function : fillDefaultInitDlBwp
475 * Functionality: Fills Initial DL Bandwidth Part
477 * @params[in] InitialDlBwp *initDlBwp
480 *****************************************************************/
481 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
484 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
485 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
490 /* Filling PDCCH Config */
491 initDlBwp->pdcchPresent = TRUE;
492 if(initDlBwp->pdcchPresent)
494 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
495 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
496 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
498 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
499 PDCCH_CTRL_RSRC_SET_ONE_ID;
500 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
502 coreset0EndPrb = CORESET0_END_PRB;
503 coreset1StartPrb = coreset0EndPrb +6;
504 coreset1NumPrb = CORESET1_NUM_PRB;
505 /* calculate the PRBs */
506 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
507 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
510 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
511 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
512 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
513 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
514 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
516 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
519 initDlBwp->pdcchCfg.numCRsetToRel = 0;
520 /* Filling Serach Space */
521 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
522 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
523 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
525 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
526 PDCCH_SRCH_SPC_TWO_ID;
527 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
528 PDCCH_CTRL_RSRC_SET_ONE_ID;
529 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
530 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
531 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
532 MONITORING_SYMB_WITHIN_SLOT_SIZE);
533 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
534 PDCCH_SYMBOL_WITHIN_SLOT;
535 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
537 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
539 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
541 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
543 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
545 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
546 SEARCHSPACETYPE_PR_UE_SPECIFIC;
547 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
548 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
550 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
554 /* Filling PDSCH Config */
555 initDlBwp->pdschPresent = TRUE;
556 if(initDlBwp->pdschPresent)
558 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
559 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
560 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
561 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
563 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
564 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
565 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
566 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
567 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
568 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
569 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
570 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
576 /******************************************************************
578 * @brief Fills Initial UL Bandwidth Part
582 * Function : fillDefaultInitUlBwp
584 * Functionality: Fills Initial UL Bandwidth Part
586 * @params[in] InitialUlBwp *initUlBwp
589 *****************************************************************/
590 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
595 initUlBwp->pucchPresent = FALSE;
597 /*Filling PUSCH Config */
598 initUlBwp->puschPresent = TRUE;
599 if(initUlBwp->puschPresent)
601 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
602 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
603 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
604 scramblingId0 = SCRAMBLING_ID;
605 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
606 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
608 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
610 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
611 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
613 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
614 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
615 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
616 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
618 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
623 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
627 /******************************************************************
629 * @brief Fills SpCell Group Info
633 * Function : fillDefaultSpCellGrpInfo
635 * Functionality: Fills Sp Cell Group Info
637 * @params[in] SpCellCfg *spCell
640 *****************************************************************/
641 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
645 spCell->servCellIdx = SERV_CELL_IDX;
646 /* Filling Initial Dl Bwp */
647 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
649 spCell->servCellCfg.numDlBwpToAdd = 0;
650 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
651 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
652 spCell->servCellCfg.bwpInactivityTmr = NULLP;
653 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
654 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
655 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
656 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
657 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
658 NUM_HARQ_PROC_FOR_PDSCH_N_16;
659 /* Filling Initial UL Bwp*/
660 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
661 spCell->servCellCfg.numUlBwpToAdd = 0;
662 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
666 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
670 /******************************************************************
672 * @brief Fills Physical Cell Group Info
676 * Function : fillDefaultPhyCellGrpInfo
678 * Functionality: Fills Physical Cell Group Info
680 * @params[in] PhyCellGrpCfg *cellGrp
683 *****************************************************************/
684 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
688 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
689 cellGrp->pNrFr1 = P_NR_FR1;
693 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
697 /******************************************************************
699 * @brief Fills Mac Cell Group Info
703 * Function : fillDefaultMacCellGrpInfo
705 * Functionality: Fills Mac Cell Group Info
707 * @params[in] MacCellGrpCfg *cellGrp
710 *****************************************************************/
711 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
717 /* Filling Scheduling Request Config */
718 cellGrp->schReqCfg.addModListCount = 1;
719 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
721 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
723 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
724 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
725 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
728 cellGrp->schReqCfg.relListCount = 0;
730 /* Filling Tag config */
731 cellGrp->tagCfg.addModListCount = 1;
732 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
734 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
736 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
737 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
740 cellGrp->tagCfg.relListCount = 0;
742 /* Filling BSR config */
743 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
744 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
745 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
747 /* Filling PHR config */
748 cellGrp->phrCfgSetupPres = true;
749 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
750 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
751 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
752 cellGrp->phrCfg.multiplePHR = false;
753 cellGrp->phrCfg.dummy = false;
754 cellGrp->phrCfg.phrType2OtherCell = false;
755 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
760 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
764 /*******************************************************************
766 * @brief Fills default modulation info for a UE
770 * Function : fillDefaultModulation
772 * Functionality: Fills default modulation info for a UE
774 * @params[in] Pointer to MAC UE configuration
775 * @return ROK - success
778 * ****************************************************************/
779 void fillDefaultModulation(MacUeCfg *ueCfg)
781 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
782 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
783 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
785 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
786 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
787 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
790 /******************************************************************
792 * @brief Function to fill Mac Lc Cfg for SRB1
796 * Function : fillMacSrb1LcCfg
798 * Functionality: Function to fill Mac Lc cfg for SRB1
800 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
802 *****************************************************************/
804 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
806 macLcCfg->lcId = SRB1_LCID;
807 macLcCfg->configType = CONFIG_ADD;
808 macLcCfg->drbQos = NULLP;
809 macLcCfg->snssai = NULLP;
810 macLcCfg->ulLcCfgPres = true;
811 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
814 /******************************************************************
816 * @brief Function to fill the Lc cfg from ueSetupReqDb
820 * Function : fillMacLcCfgToAddMod
822 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
824 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
825 * @return ROK/RFAILED
827 *****************************************************************/
829 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
832 lcCfg->lcId = ueSetReqDb->lcId;
833 lcCfg->configType = ueSetReqDb->configType;
835 if(ueSetReqDb->drbQos)
839 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
842 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
848 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
853 lcCfg->drbQos = NULLP;
858 if(ueSetReqDb->snssai)
862 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
865 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
872 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
876 lcCfg->snssai = NULLP;
879 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
880 lcCfg->drbQos = NULLP;
886 lcCfg->snssai = NULLP;
888 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
889 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
890 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
894 /******************************************************************
896 * @brief Function to copy the Bit rate from ueSetupReqDb
900 * Function : fillAmbr
902 * Functionality: Function to copy bit Rate from ueSetupReqDb
904 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
905 * @return ROK/RFAILED
907 *****************************************************************/
909 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
913 if(*macAmbr == NULLP)
915 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
916 if(*macAmbr == NULLP)
918 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
922 memset(*macAmbr, 0, sizeof(AmbrCfg));
923 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
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 = T_REASSEMBLY_VAL;
1144 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
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 = T_REASSEMBLY_VAL;
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 = T_REASSEMBLY_VAL;
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 Function to fill Tunnel Config to Add/Mod
1810 * Function : fillTnlCfgToAddMod
1812 * Functionality: Function to fill tunnel Config to Add/Mod
1814 * @params[in] Pointer to tnlCfgDb,
1815 * pointer to f1TnlCfg
1816 * @return ROK - success
1819 * ****************************************************************/
1820 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1822 if(*ueCbTnlCfg == NULLP)
1824 /* copying to DuCb Tnl Cfg */
1825 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1826 if(*ueCbTnlCfg == NULLP)
1828 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1832 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1833 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1834 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1835 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1836 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1837 if(f1TnlCfg->tnlCfg1)
1839 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1841 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1842 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1844 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1848 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1849 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1850 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1851 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1856 /*******************************************************************
1858 * @brief Processing the tunnel Request to EGTP
1862 * Function : duProcEgtpTunnelCfg
1864 * Functionality: Processing the tunnel Request to EGTP
1866 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1867 * @return ROK - success
1870 * ****************************************************************/
1872 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1874 uint8_t ret = RFAILED, delIdx;
1876 if(f1TnlCfg->tnlCfg1 == NULLP)
1878 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1882 if(f1TnlCfg->configType == CONFIG_ADD)
1884 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1886 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1893 else if(f1TnlCfg->configType == CONFIG_MOD)
1895 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1897 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
1903 else if(f1TnlCfg->configType == CONFIG_DEL)
1905 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1907 /* Free memory at drbIdx */
1908 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
1909 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
1911 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
1913 /* moving all elements one index ahead */
1914 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
1925 /***********************************************************************
1927 * @brief Function to fill Tunnel Config
1928 * and sends tunnel Req to EGTP
1933 * Function : duUpdateTunnelCfgDb
1935 * Functionality: Function to fill tunnel Config
1936 * and sends tunnel Cfg Req to EGTP
1938 * @params[in] ueIdx, cellId, DuUeCfg
1939 * @return ROK - success
1942 * ****************************************************************/
1944 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
1946 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
1947 bool drbFound = false;
1949 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
1950 /*then update drbId and tunnel Info in duCb */
1951 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
1953 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
1954 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
1955 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
1957 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
1959 drbFound = true; /* existing DRB */
1960 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
1962 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
1963 duUeCfg->upTnlInfo[drbIdx].drbId);
1971 if(!drbFound && ret == ROK)/* new DRB to Add */
1973 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
1975 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
1976 duUeCfg->upTnlInfo[drbIdx].drbId);
1987 /*******************************************************************
1989 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
1994 * Function : duUpdateDuUeCbCfg
1996 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
1998 * @params[in] ueIdx, cellIdx
1999 * @return ROK - success
2002 * ****************************************************************/
2004 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2006 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2007 DuUeCb *ueCb = NULLP;
2009 GET_CELL_IDX(cellId, cellIdx);
2011 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2012 macUeCfgState == UE_RECFG_COMPLETE) &&
2013 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2014 rlcUeCfgState == UE_RECFG_COMPLETE))
2016 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2018 /*Filling RLC Ue Cfg */
2019 ueCb->rlcUeCfg.cellId = cellId;
2020 ueCb->rlcUeCfg.ueIdx = ueIdx;
2021 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2024 /*Filling MAC Ue Cfg */
2025 GET_CRNTI(crnti, ueIdx);
2026 ueCb->macUeCfg.cellId = cellId;
2027 ueCb->macUeCfg.ueIdx = ueIdx;
2028 ueCb->macUeCfg.crnti = crnti;
2029 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2031 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2034 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2036 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2042 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2049 /*******************************************************************
2051 * @brief Handle UE config response from MAC
2055 * Function : DuProcMacUeCfgRsp
2057 * Functionality: Handle UE Config response from MAC
2059 * @params[in] Pointer to MacUeCfgRsp and Pst
2060 * @return ROK - success
2063 * ****************************************************************/
2064 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2070 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2072 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2074 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2075 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2076 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2078 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2080 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2081 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2082 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2083 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2084 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2089 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2090 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2092 //TODO: Send the failure case in Ue Context Setup Response
2096 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2100 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2107 /*******************************************************************
2109 * @brief Processes UE create Req to RLC UL
2113 * Function : duBuildAndSendUeCreateReqToRlc
2116 * Processes UE create Req to RLC UL
2118 * @params[in] cellId,
2120 * Pointer to RlcUeCfg
2121 * @return ROK - success
2124 *****************************************************************/
2126 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2127 RlcUeCfg *duRlcUeCfg)
2130 RlcUeCfg *rlcUeCfg = NULLP;
2133 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2136 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2140 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2141 /* Copying ueCfg to a sharable buffer */
2142 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2145 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2146 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2147 /* Processing one Ue at a time to RLC */
2148 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2149 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2152 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2153 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2159 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2165 /*******************************************************************
2167 * @brief Processes UE create Rsp received from RLC UL
2172 * Function : DuProcRlcUeCfgRsp
2175 * Processes UE create Rsp received from RLC UL
2177 * @params[in] Post structure
2178 * Pointer to RlcCfgCfm
2179 * @return ROK - success
2182 *****************************************************************/
2183 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2189 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2191 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2193 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2194 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2195 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2197 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2199 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2200 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2201 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2202 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2203 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2208 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2209 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2210 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2212 //TODO: update failure case in ue Context setup Response
2216 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2220 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2228 /*******************************************************************
2230 * @brief Builds and Send Ue Reconfig Req to RLC
2234 * Function : duBuildAndSendUeReCfgReqToRLC
2236 * Functionality: Builds and Send Ue Reconfig Req to RLC
2238 * @params[in] cellId, crnti
2240 * RlcUeCfg *rlcUeCfg
2241 * @return ROK - success
2244 * ****************************************************************/
2246 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2248 uint8_t ret = ROK, ueIdx = 0;
2249 RlcUeCfg *rlcUeCfg = NULLP;
2251 GET_UE_IDX(crnti, ueIdx);
2252 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2255 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2256 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2258 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2260 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2264 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2270 /*******************************************************************
2272 * @brief Builds and Send Ue Reconfig Req to MAC
2276 * Function : duBuildAndSendUeReCfgReqToMac
2278 * Functionality: Builds and Send Ue Reconfig Req to MAC
2280 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2282 * MacUeCfg *macUeCfg
2283 * @return ROK - success
2286 * ****************************************************************/
2288 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2290 uint8_t ret, ueIdx = 0;
2291 MacUeCfg *macUeCfg = NULLP;
2294 GET_UE_IDX(crnti, ueIdx);
2296 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2299 memset(macUeCfg, 0, sizeof(MacUeCfg));
2300 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2302 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2304 ret = sendUeReCfgReqToMac(macUeCfg);
2308 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2314 /*******************************************************************
2316 * @brief Build and Send Ue context setup request
2321 * Function : duBuildAndSendUeContextSetupReq
2324 * Build and Send Ue context setup request
2326 * @params[in] cellId, crnti, DuUeCfg pointer
2327 * @return ROK - success
2330 *****************************************************************/
2332 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2336 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2337 /* Filling RLC Ue Reconfig */
2338 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2340 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2342 /* Filling MAC Ue Reconfig */
2343 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2345 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2350 /*******************************************************************
2352 * @brief Processes DL Rsp received from RLC DL
2357 * Function : DuProcRlcDlRrcMsgRsp
2360 * Processes UE Rsp received from RLC DL
2362 * @params[in] Post structure
2363 * Pointer to RlcCfgCfm
2364 * @return ROK - success
2367 *****************************************************************/
2368 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2370 uint8_t ret = ROK, ueIdx = 0;
2371 DuUeCb *ueCb = NULLP;
2373 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2375 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2376 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2379 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2381 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2385 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2387 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2390 /*******************************************************************
2392 * @brief Process UE context setup request from CU
2396 * Function : duProcUeContextSetupRequest
2398 * Functionality: Process UE context setup request from CU
2400 * @params[in] F1AP message
2401 * @return ROK - success
2404 * ****************************************************************/
2406 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2408 uint8_t ret, cellId;
2413 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2414 /* Send DL RRC msg for security Mode */
2415 if(ueCb->f1UeDb->dlRrcMsg)
2417 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2419 /* Sending DL RRC Message to RLC */
2420 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2423 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2424 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2425 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2426 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2432 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2435 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2441 //TODO: To send the failure cause in UeContextSetupRsp
2442 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2447 /**********************************************************************
2449 ***********************************************************************/