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 "du_ue_mgr.h"
25 DuMacDlCcchInd packMacDlCcchIndOpts[] =
27 packMacDlCcchInd, /* Loose coupling */
28 MacHdlDlCcchInd, /* TIght coupling */
29 packMacDlCcchInd /* Light weight-loose coupling */
32 DuMacUeCreateReq packMacUeCreateReqOpts[] =
34 packDuMacUeCreateReq, /* Loose coupling */
35 MacHdlUeCreateReq, /* TIght coupling */
36 packDuMacUeCreateReq, /* Light weight-loose coupling */
39 /******************************************************************
41 * @brief Send UE configuration to RLC
45 * Function : duSendUeCreateReqToRlc
47 * Functionality: Send UeCreateReqToRlc
49 * @return ROK - success
52 * ****************************************************************/
53 S16 duSendUeCreateReqToRlc()
59 DU_SET_ZERO(&ueCfg, sizeof(ueCfg));
60 DU_SET_ZERO(&pst, sizeof(Pst));
62 DU_ALLOC(ueCfg, sizeof(CkwCfgInfo));
67 ueCfg->cellId = NR_CELL_ID;
70 for(idx = 0; idx < ueCfg->numEnt; idx++)
73 ueCfg->entCfg[idx].rbId = RB_ID;
74 ueCfg->entCfg[idx].rbType = CM_LTE_DRB;
75 ueCfg->entCfg[idx].lCh[0].lChId = LC_ID;
76 ueCfg->entCfg[idx].lCh[0].type = CM_LTE_LCH_DTCH;
78 ueCfg->entCfg[idx].entMode = CM_LTE_MODE_UM;
79 ueCfg->entCfg[idx].dir = CKW_CFG_DIR_BOTH;
80 switch(ueCfg->entCfg[idx].entMode)
89 ueCfg->entCfg[idx].m.umInfo.dl.snLen = 1; /* For 12 bit SN */
90 ueCfg->entCfg[idx].m.umInfo.ul.snLen = 1; /* For 12 bit SN */
91 ueCfg->entCfg[idx].m.umInfo.ul.reOrdTmr = 10; /* in msec */
102 } /* End of switch(entMode) */
103 } /* End of entity configuration for loop */
106 pst.selector = DU_SELECTOR_LWLC;
107 pst.srcEnt = ENTDUAPP;
109 pst.dstInst = RLC_UL_INST;
110 pst.dstProcId = DU_PROC;
111 pst.srcProcId = DU_PROC;
112 pst.region = duCb.init.region;
115 packUeCreateReq(&pst, ueCfg);
118 } /* End of duSendUeCreateReqToRlc */
120 /*******************************************************************
122 * @brief Handles EGTP data from CU
126 * Function : duHdlEgtpData
129 * Processes EGTP header and sends data to RLC
131 * @params[in] Pointer to EGTP Message
132 * @return ROK - success
135 * ****************************************************************/
136 S16 duHdlEgtpDlData(EgtpMsg *egtpMsg)
138 /* TODO : Extract RbId/UeID/CellID/SduId from database
139 using tunnel id in egtp header */
141 DU_LOG("\nDU_APP : Processing DL data");
144 KwuDatReqInfo datReqInfo;
147 datReqInfo.rlcId.rbId = RB_ID;
148 datReqInfo.rlcId.rbType = CM_LTE_DRB;
149 datReqInfo.rlcId.ueId = UE_ID;
150 datReqInfo.rlcId.cellId = NR_CELL_ID;
152 datReqInfo.sduId = ++sduId;
153 datReqInfo.lcType = CM_LTE_LCH_DTCH;
155 /* Filling pst and Sending to RLC DL */
156 pst.selector = DU_SELECTOR_LWLC;
157 pst.srcEnt = ENTDUAPP;
159 pst.dstInst = RLC_DL_INST;
160 pst.dstProcId = DU_PROC;
161 pst.srcProcId = DU_PROC;
162 pst.region = duCb.init.region;
164 cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
168 /*******************************************************************
170 * @brief Handles UL data and send to CU
174 * Function : duHdlRlcUlData
177 * Processes UL Data from RLC and sends to CU
179 * @params[in] Pointer to EGTP Message
180 * @return ROK - success
183 *****************************************************************/
185 PUBLIC S16 duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
187 DU_LOG("\nDU_APP : Received UL Data at DU_APP");
189 /* Send UL data to CU via EGTP */
190 duSendEgtpDatInd(mBuf);
196 /******************************************************************
198 * @brief Builds and Sends DL CCCH Ind to MAC
202 * Function : duBuildAndSendDlCcchInd
204 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
206 * @params[in] dlCcchMsg - uint8_t*
207 * @return ROK - success
210 * ****************************************************************/
211 uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \
212 DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize)
216 DlCcchIndInfo *dlCcchIndInfo = NULLP;
219 memset(&pst, 0, sizeof(Pst));
220 DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
222 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
226 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
230 dlCcchIndInfo->cellId = cellId;
231 dlCcchIndInfo->crnti = crnti;
232 dlCcchIndInfo->msgType = msgType;
233 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
235 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
236 if(!dlCcchIndInfo->dlCcchMsg)
238 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
239 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
242 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
244 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
246 DU_FREE(dlCcchMsg, dlCcchMsgSize);
249 pst.selector = DU_MAC_LWLC;
250 pst.srcEnt = ENTDUAPP;
254 pst.dstProcId = DU_PROC;
255 pst.srcProcId = DU_PROC;
256 pst.region = DU_APP_MEM_REGION;
258 pst.event = EVENT_MAC_DL_CCCH_IND;
260 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
263 DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC");
264 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
265 dlCcchIndInfo->dlCcchMsgLen);
266 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
267 sizeof(DlCcchIndInfo));
275 /******************************************************************
277 * @brief Processes DL RRC Message Transfer sent by CU
281 * Function : procDlRrcMsgTrans
283 * Functionality: Processes DL RRC Message Transfer sent by CU
285 * @params[in] F1AP_PDU_t ASN decoded F1AP message
286 * @return ROK - success
289 * ****************************************************************/
290 uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
292 DLRRCMessageTransfer_t *dlRrcMsg = NULLP;
293 uint8_t *dlCcchMsg = NULLP;
294 uint8_t idx, ret, srbId;
295 uint16_t idx2, crnti, cellId, dlCcchMsgSize;
296 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
299 DU_LOG("\nDU_APP : DL RRC message transfer Recevied");
300 dlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
304 for(idx=0; idx<dlRrcMsg->protocolIEs.list.count; idx++)
306 switch(dlRrcMsg->protocolIEs.list.array[idx]->id)
308 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
310 gnbCuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
313 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
315 gnbDuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
318 case ProtocolIE_ID_id_SRBID:
320 srbId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
323 case ProtocolIE_ID_id_ExecuteDuplication:
326 case ProtocolIE_ID_id_RRCContainer:
328 if(dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
330 dlCcchMsgSize = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
331 DU_ALLOC(dlCcchMsg, dlCcchMsgSize);
332 for(idx2 = 0; idx2 < dlCcchMsgSize; idx2++)
335 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf[idx2];
340 DU_LOG("\nDU_APP : RRC Container Size is invalid:%ld",\
341 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
347 DU_LOG("\nDU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
348 dlRrcMsg->protocolIEs.list.array[idx]->id);
352 for(idx=0; idx<duCb.numUe; idx++)
354 if(gnbDuUeF1apId == duCb.ueCcchCtxt[idx].gnbDuUeF1apId)
356 crnti = duCb.ueCcchCtxt[idx].crnti;
357 cellId = duCb.ueCcchCtxt[idx].cellId;
361 if(srbId == SRB_ID_1) //RRC connection setup
363 ret = duBuildAndSendDlCcchInd(cellId, crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize);
366 DU_LOG("\nDU_APP: Falied at duBuildAndSendDlCcchInd()");
370 if(duCb.actvCellLst[cellId-1]->numActvUes < DU_MAX_UE)
372 ret = duCreateUeCb(&duCb.ueCcchCtxt[idx], gnbCuUeF1apId);
375 DU_LOG("\nDU_APP: Failed at duCreateUeCb for cellId [%d]", duCb.ueCcchCtxt[idx].cellId);
381 DU_LOG("\nDU_APP: Max Active UEs has reached");
389 /******************************************************************
391 * @brief Generates GNB DU Ue F1AP ID
395 * Function : genGnbDuUeF1apId
397 * Functionality: Generates GNB DU Ue F1AP ID
400 * @return gnbDuF1apId
402 * ****************************************************************/
403 uint32_t genGnbDuUeF1apId()
405 static uint32_t gnbDuUeF1apId = 0;
407 return ++gnbDuUeF1apId;
410 /******************************************************************
412 * @brief Processes UL CCCH Ind recvd from MAC
416 * Function : duProcUlCcchInd
418 * Functionality: Processes UL CCCH Ind recvd from MAC
420 * @params[in] UlCcchIndInfo *ulCcchIndInfo
421 * @return ROK - success
424 * ****************************************************************/
425 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
429 uint32_t gnbDuUeF1apId = 0;
431 gnbDuUeF1apId = genGnbDuUeF1apId();
433 /* Store Ue mapping */
434 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
435 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
436 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
440 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti,
441 ulCcchIndInfo->ulCcchMsg));
444 DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
447 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, RG_POOL, ulCcchIndInfo->ulCcchMsg, strlen((const char*)ulCcchIndInfo->ulCcchMsg));
448 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, RG_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
454 /******************************************************************
456 * @brief Fills Initial DL Bandwidth Part
460 * Function : fillInitDlBwp
462 * Functionality: Fills Initial DL Bandwidth Part
465 *****************************************************************/
466 void fillInitDlBwp(InitialDlBwp *initDlBwp)
472 /* Filling PDCCH Config */
473 initDlBwp->pdcchPresent = TRUE;
474 if(initDlBwp->pdcchPresent)
476 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
477 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
478 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
480 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
481 PDCCH_CTRL_RSRC_SET_ONE_ID;
482 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
484 initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc[idx] =\
486 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
487 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
488 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
489 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
490 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
492 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
495 initDlBwp->pdcchCfg.numCRsetToRel = 0;
496 /* Filling Serach Space */
497 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
498 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
499 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
501 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
502 PDCCH_SRCH_SPC_TWO_ID;
503 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
504 PDCCH_CTRL_RSRC_SET_ONE_ID;
505 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
506 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
507 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
508 MONITORING_SYMB_WITHIN_SLOT_SIZE);
509 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
510 PDCCH_SYMBOL_WITHIN_SLOT;
511 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
513 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
515 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
517 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
519 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
521 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
522 SEARCHSPACETYPE_PR_UE_SPECIFIC;
523 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
524 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
526 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
530 /* Filling PDSCH Config */
531 initDlBwp->pdschPresent = TRUE;
532 if(initDlBwp->pdschPresent)
534 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
535 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
536 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
537 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
539 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
540 PDSCH_START_SYMBOL_LEN;
541 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
542 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
543 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
549 /******************************************************************
551 * @brief Fills Initial UL Bandwidth Part
555 * Function : fillInitUlBwp
557 * Functionality: Fills Initial UL Bandwidth Part
560 *****************************************************************/
561 void fillInitUlBwp(InitialUlBwp *initUlBwp)
566 initUlBwp->pucchPresent = FALSE;
568 /*Filling PUSCH Config */
569 initUlBwp->puschPresent = TRUE;
570 if(initUlBwp->puschPresent)
572 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
573 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
574 scramblingId0 = SCRAMBLING_ID;
575 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
576 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
578 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
580 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
581 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
583 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
584 PUSCH_START_SYMBOL_LEN;
586 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
591 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
595 /******************************************************************
597 * @brief Fills SpCell Group Info
601 * Function : fillSpCellGrpInfo
603 * Functionality: Fills Sp Cell Group Info
606 *****************************************************************/
607 void fillSpCellGrpInfo(SpCellCfg *spCell)
611 spCell->servCellIdx = SERV_CELL_IDX;
612 /* Filling Initial Dl Bwp */
613 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
615 spCell->servCellCfg.numDlBwpToAdd = 0;
616 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
617 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
618 spCell->servCellCfg.bwpInactivityTmr = NULLP;
619 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
620 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
621 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
622 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
623 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
624 NUM_HARQ_PROC_FOR_PDSCH_N_16;
625 /* Filling Initial UL Bwp*/
626 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
627 spCell->servCellCfg.numUlBwpToAdd = 0;
628 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
632 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
636 /******************************************************************
638 * @brief Fills Physical Cell Group Info
642 * Function : fillPhyCellGrpInfo
644 * Functionality: Fills Physical Cell Group Info
647 *****************************************************************/
648 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
652 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
653 cellGrp->pNrFr1 = P_NR_FR1;
657 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
661 /******************************************************************
663 * @brief Fills Mac Cell Group Info
667 * Function : fillMacCellGrpInfo
669 * Functionality: Fills Mac Cell Group Info
672 *****************************************************************/
673 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
679 /* Filling Scheduling Request Config */
680 cellGrp->schReqCfg.addModListCount = 1;
681 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
683 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
685 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
686 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
687 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
690 cellGrp->schReqCfg.relListCount = 0;
692 /* Filling Tag config */
693 cellGrp->tagCfg.addModListCount = 1;
694 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
696 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
698 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
699 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
702 cellGrp->tagCfg.relListCount = 0;
704 /* Filling PHR config */
705 cellGrp->phrCfgSetupPres = true;
706 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
707 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
708 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
709 cellGrp->phrCfg.multiplePHR = false;
710 cellGrp->phrCfg.dummy = false;
711 cellGrp->phrCfg.phrType2OtherCell = false;
712 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
717 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
721 /******************************************************************
723 * @brief Fills Logical Channel Config List
727 * Function : fillLcCfgList
729 * Functionality: Fills Logical channel Config List
732 *****************************************************************/
733 void fillLcCfgList(LcCfg *lcCfgInfo)
737 lcCfgInfo->lcId = SRB_ID_1;
738 lcCfgInfo->drbQos = NULLP;
739 lcCfgInfo->snssai = NULLP;
740 lcCfgInfo->ulLcCfg = NULLP;
741 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
744 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
745 /* Filling Qos characteristics */
746 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
747 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
748 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
749 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
750 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
753 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
754 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
755 Pre_emptionCapability_may_trigger_pre_emption;
756 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
757 Pre_emptionVulnerability_not_pre_emptable;
759 /* Filling Grb Qos */
760 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
761 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
762 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
763 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
765 /* Filling S-NSSAI */
766 /* TODO :To be filled when UE Context Setup Request is sent from CU */
767 /* Filling UL Logical Channel Config */
768 lcCfgInfo->ulLcCfg.priority = 0;
769 lcCfgInfo->ulLcCfg.lcGroup = 0;
770 lcCfgInfo->ulLcCfg.schReqId = 0;
771 lcCfgInfo->ulLcCfg.pbr = 0;
772 lcCfgInfo->ulLcCfg.bsd = 0;
774 /* Filling DL Logical Channel Config */
775 lcCfgInfo->dlLcCfg.lcp = 0;
780 DU_LOG("\n Memory is null for LcCfgList");
784 /******************************************************************
786 * @brief Fills MacUeCfg structure
790 * Function : fillMacUeCfg
792 * Functionality: Fills MacUeCfg
795 *****************************************************************/
796 void fillMacUeCfg(MacUeCfg *ueCfg)
800 /* Filling MacCellGroup Config */
801 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
802 /* Filling PhyCellGroup Config */
803 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
804 /* Filling SpCellGroup Config */
805 fillSpCellGrpInfo(&ueCfg->spCellCfg);
806 /* Filling AMBR for UL and DL */
807 ueCfg->maxAggrBitRate = NULLP;
808 /* Filling LC Context */
809 ueCfg->numLcs = SRB_ID_1;
810 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
812 for(idx = 0; idx < ueCfg->numLcs; idx++)
814 fillLcCfgList(&ueCfg->lcCfgList[idx]);
820 /******************************************************************
822 * @brief creates UE context
826 * Function : duCreateUeCb
828 * Functionality: Creates UE Conetxt
830 * @params[in] UeCcchCtxt Pointer
833 * @return ROK - success
835 * ****************************************************************/
836 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
842 for(cellIdx = 0; cellIdx < DU_MAX_CELLS; cellIdx++)
844 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
846 ueIdx = ueCcchCtxt->crnti % DU_UE_START_CRNTI;
847 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
848 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
849 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
850 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
852 /* Filling Mac Ue Config */
853 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
854 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellIdx = ueCcchCtxt->cellId;
855 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.ueIdx = ueIdx;
856 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.crnti = ueCcchCtxt->crnti;
857 fillMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
858 duCb.actvCellLst[cellIdx]->numActvUes++;
859 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
861 /* Send Ue Create Request to MAC */
862 ret = duBuildAndSendUeCreateReqToMac(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellIdx, ueIdx);
864 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
871 /******************************************************************
873 * @brief Builds and Send UE Create Request to MAC
877 * Function : duBuildAndSendUeCreateReqToMac
879 * Functionality: Builds and Send UE Create Request to MAC
881 * @Params[in] cellId,
883 * @return ROK - success
886 * ****************************************************************/
888 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx)
891 MacUeCfg *macUeCfg = NULLP;
894 memset(&pst, 0, sizeof(Pst));
897 pst.selector = DU_MAC_LWLC;
898 pst.srcEnt = ENTDUAPP;
899 pst.srcInst = DU_INST;
902 pst.dstProcId = DU_PROC;
903 pst.srcProcId = DU_PROC;
904 pst.region = DU_APP_MEM_REGION;
906 pst.event = EVENT_MAC_UE_CREATE_REQ;
908 /* Copying ueCb to a sharable buffer */
909 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
912 memset(macUeCfg, 0, sizeof(MacUeCfg));
913 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
914 /* Processing one Ue at a time to MAC */
915 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
918 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
919 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
925 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReq()");
931 /**********************************************************************
933 ***********************************************************************/