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"
25 #include "du_ue_mgr.h"
26 #include<ProtocolIE-Field.h>
33 DuMacDlCcchInd packMacDlCcchIndOpts[] =
35 packMacDlCcchInd, /* Loose coupling */
36 MacHdlDlCcchInd, /* TIght coupling */
37 packMacDlCcchInd /* Light weight-loose coupling */
40 DuMacUeCreateReq packMacUeCreateReqOpts[] =
42 packDuMacUeCreateReq, /* Loose coupling */
43 MacHdlUeCreateReq, /* TIght coupling */
44 packDuMacUeCreateReq, /* Light weight-loose coupling */
47 /******************************************************************
49 * @brief Send UE configuration to RLC
53 * Function : duSendUeCreateReqToRlc
55 * Functionality: Send UeCreateReqToRlc
57 * @return ROK - success
60 * ****************************************************************/
61 S16 duSendUeCreateReqToRlc()
67 DU_SET_ZERO(&ueCfg, sizeof(ueCfg));
68 DU_SET_ZERO(&pst, sizeof(Pst));
70 DU_ALLOC(ueCfg, sizeof(CkwCfgInfo));
75 ueCfg->cellId = NR_CELL_ID;
78 for(idx = 0; idx < ueCfg->numEnt; idx++)
81 ueCfg->entCfg[idx].rbId = RB_ID;
82 ueCfg->entCfg[idx].rbType = CM_LTE_DRB;
83 ueCfg->entCfg[idx].lCh[0].lChId = LC_ID;
84 ueCfg->entCfg[idx].lCh[0].type = CM_LTE_LCH_DTCH;
86 ueCfg->entCfg[idx].entMode = CM_LTE_MODE_UM;
87 ueCfg->entCfg[idx].dir = CKW_CFG_DIR_BOTH;
88 switch(ueCfg->entCfg[idx].entMode)
97 ueCfg->entCfg[idx].m.umInfo.dl.snLen = 1; /* For 12 bit SN */
98 ueCfg->entCfg[idx].m.umInfo.ul.snLen = 1; /* For 12 bit SN */
99 ueCfg->entCfg[idx].m.umInfo.ul.reOrdTmr = 10; /* in msec */
110 } /* End of switch(entMode) */
111 } /* End of entity configuration for loop */
114 pst.selector = ODU_SELECTOR_LWLC;
115 pst.srcEnt = ENTDUAPP;
117 pst.dstInst = RLC_UL_INST;
118 pst.dstProcId = DU_PROC;
119 pst.srcProcId = DU_PROC;
120 pst.region = duCb.init.region;
123 packUeCreateReq(&pst, ueCfg);
126 } /* End of duSendUeCreateReqToRlc */
128 /*******************************************************************
130 * @brief Handles EGTP data from CU
134 * Function : duHdlEgtpData
137 * Processes EGTP header and sends data to RLC
139 * @params[in] Pointer to EGTP Message
140 * @return ROK - success
143 * ****************************************************************/
144 S16 duHdlEgtpDlData(EgtpMsg *egtpMsg)
146 /* TODO : Extract RbId/UeID/CellID/SduId from database
147 using tunnel id in egtp header */
149 DU_LOG("\nDU_APP : Processing DL data");
152 KwuDatReqInfo datReqInfo;
155 datReqInfo.rlcId.rbId = RB_ID;
156 datReqInfo.rlcId.rbType = CM_LTE_DRB;
157 datReqInfo.rlcId.ueId = UE_ID;
158 datReqInfo.rlcId.cellId = NR_CELL_ID;
160 datReqInfo.sduId = ++sduId;
161 datReqInfo.lcType = CM_LTE_LCH_DTCH;
163 /* Filling pst and Sending to RLC DL */
164 pst.selector = ODU_SELECTOR_LWLC;
165 pst.srcEnt = ENTDUAPP;
167 pst.dstInst = RLC_DL_INST;
168 pst.dstProcId = DU_PROC;
169 pst.srcProcId = DU_PROC;
170 pst.region = duCb.init.region;
172 cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
176 /*******************************************************************
178 * @brief Handles UL data and send to CU
182 * Function : duHdlRlcUlData
185 * Processes UL Data from RLC and sends to CU
187 * @params[in] Pointer to EGTP Message
188 * @return ROK - success
191 *****************************************************************/
193 PUBLIC S16 duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
195 DU_LOG("\nDU_APP : Received UL Data at DU_APP");
197 /* Send UL data to CU via EGTP */
198 duSendEgtpDatInd(mBuf);
204 /******************************************************************
206 * @brief Builds and Sends DL CCCH Ind to MAC
210 * Function : duBuildAndSendDlCcchInd
212 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
214 * @params[in] dlCcchMsg - uint8_t*
215 * @return ROK - success
218 * ****************************************************************/
219 uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \
220 DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize)
224 DlCcchIndInfo *dlCcchIndInfo = NULLP;
227 memset(&pst, 0, sizeof(Pst));
228 DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
230 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
234 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
238 dlCcchIndInfo->cellId = cellId;
239 dlCcchIndInfo->crnti = crnti;
240 dlCcchIndInfo->msgType = msgType;
241 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
243 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
244 if(!dlCcchIndInfo->dlCcchMsg)
246 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
247 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
250 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
252 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
254 DU_FREE(dlCcchMsg, dlCcchMsgSize);
257 pst.selector = ODU_SELECTOR_LWLC;
258 pst.srcEnt = ENTDUAPP;
262 pst.dstProcId = DU_PROC;
263 pst.srcProcId = DU_PROC;
264 pst.region = DU_APP_MEM_REGION;
266 pst.event = EVENT_MAC_DL_CCCH_IND;
268 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
271 DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC");
272 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
273 dlCcchIndInfo->dlCcchMsgLen);
274 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
275 sizeof(DlCcchIndInfo));
283 /******************************************************************
285 * @brief Processes DL RRC Message Transfer sent by CU
289 * Function : procDlRrcMsgTrans
291 * Functionality: Processes DL RRC Message Transfer sent by CU
293 * @params[in] F1AP_PDU_t ASN decoded F1AP message
294 * @return ROK - success
297 * ****************************************************************/
298 uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
300 DLRRCMessageTransfer_t *dlRrcMsg = NULLP;
301 uint8_t *dlCcchMsg = NULLP;
302 uint8_t idx, ret, srbId;
303 uint16_t idx2, crnti, cellId, dlCcchMsgSize;
304 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
307 DU_LOG("\nDU_APP : DL RRC message transfer Recevied");
308 dlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
312 for(idx=0; idx<dlRrcMsg->protocolIEs.list.count; idx++)
314 switch(dlRrcMsg->protocolIEs.list.array[idx]->id)
316 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
318 gnbCuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
321 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
323 gnbDuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
326 case ProtocolIE_ID_id_SRBID:
328 srbId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
331 case ProtocolIE_ID_id_ExecuteDuplication:
334 case ProtocolIE_ID_id_RRCContainer:
336 if(dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
338 dlCcchMsgSize = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
339 DU_ALLOC(dlCcchMsg, dlCcchMsgSize);
340 for(idx2 = 0; idx2 < dlCcchMsgSize; idx2++)
343 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf[idx2];
348 DU_LOG("\nDU_APP : RRC Container Size is invalid:%ld",\
349 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
355 DU_LOG("\nDU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
356 dlRrcMsg->protocolIEs.list.array[idx]->id);
360 for(idx=0; idx<duCb.numUe; idx++)
362 if(gnbDuUeF1apId == duCb.ueCcchCtxt[idx].gnbDuUeF1apId)
364 crnti = duCb.ueCcchCtxt[idx].crnti;
365 cellId = duCb.ueCcchCtxt[idx].cellId;
369 if(srbId == SRB_ID_1) //RRC connection setup
371 ret = duBuildAndSendDlCcchInd(cellId, crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize);
374 DU_LOG("\nDU_APP: Falied at duBuildAndSendDlCcchInd()");
378 if(duCb.actvCellLst[cellId-1]->numActvUes < DU_MAX_UE)
380 ret = duCreateUeCb(&duCb.ueCcchCtxt[idx], gnbCuUeF1apId);
383 DU_LOG("\nDU_APP: Failed at duCreateUeCb for cellId [%d]", duCb.ueCcchCtxt[idx].cellId);
389 DU_LOG("\nDU_APP: Max Active UEs has reached");
397 /******************************************************************
399 * @brief Generates GNB DU Ue F1AP ID
403 * Function : genGnbDuUeF1apId
405 * Functionality: Generates GNB DU Ue F1AP ID
408 * @return gnbDuF1apId
410 * ****************************************************************/
411 uint32_t genGnbDuUeF1apId()
413 static uint32_t gnbDuUeF1apId = 0;
415 return ++gnbDuUeF1apId;
418 /******************************************************************
420 * @brief Processes UL CCCH Ind recvd from MAC
424 * Function : duProcUlCcchInd
426 * Functionality: Processes UL CCCH Ind recvd from MAC
428 * @params[in] UlCcchIndInfo *ulCcchIndInfo
429 * @return ROK - success
432 * ****************************************************************/
433 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
437 uint32_t gnbDuUeF1apId = 0;
439 gnbDuUeF1apId = genGnbDuUeF1apId();
441 /* Store Ue mapping */
442 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
443 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
444 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
448 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti,
449 ulCcchIndInfo->ulCcchMsg));
452 DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
455 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, RG_POOL, ulCcchIndInfo->ulCcchMsg, strlen((const char*)ulCcchIndInfo->ulCcchMsg));
456 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, RG_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
462 /******************************************************************
464 * @brief Fills Initial DL Bandwidth Part
468 * Function : fillInitDlBwp
470 * Functionality: Fills Initial DL Bandwidth Part
473 *****************************************************************/
474 void fillInitDlBwp(InitialDlBwp *initDlBwp)
480 /* Filling PDCCH Config */
481 initDlBwp->pdcchPresent = TRUE;
482 if(initDlBwp->pdcchPresent)
484 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
485 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
486 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
488 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
489 PDCCH_CTRL_RSRC_SET_ONE_ID;
490 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
492 initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc[idx] =\
494 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
495 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
496 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
497 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
498 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
500 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
503 initDlBwp->pdcchCfg.numCRsetToRel = 0;
504 /* Filling Serach Space */
505 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
506 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
507 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
509 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
510 PDCCH_SRCH_SPC_TWO_ID;
511 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
512 PDCCH_CTRL_RSRC_SET_ONE_ID;
513 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
514 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
515 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
516 MONITORING_SYMB_WITHIN_SLOT_SIZE);
517 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
518 PDCCH_SYMBOL_WITHIN_SLOT;
519 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
521 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
523 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
525 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
527 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
529 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
530 SEARCHSPACETYPE_PR_UE_SPECIFIC;
531 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
532 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
534 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
538 /* Filling PDSCH Config */
539 initDlBwp->pdschPresent = TRUE;
540 if(initDlBwp->pdschPresent)
542 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
543 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
544 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
545 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
547 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
548 PDSCH_START_SYMBOL_LEN;
549 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
550 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
551 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
557 /******************************************************************
559 * @brief Fills Initial UL Bandwidth Part
563 * Function : fillInitUlBwp
565 * Functionality: Fills Initial UL Bandwidth Part
568 *****************************************************************/
569 void fillInitUlBwp(InitialUlBwp *initUlBwp)
574 initUlBwp->pucchPresent = FALSE;
576 /*Filling PUSCH Config */
577 initUlBwp->puschPresent = TRUE;
578 if(initUlBwp->puschPresent)
580 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
581 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
582 scramblingId0 = SCRAMBLING_ID;
583 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
584 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
586 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
588 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
589 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
591 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
592 PUSCH_START_SYMBOL_LEN;
594 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
599 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
603 /******************************************************************
605 * @brief Fills SpCell Group Info
609 * Function : fillSpCellGrpInfo
611 * Functionality: Fills Sp Cell Group Info
614 *****************************************************************/
615 void fillSpCellGrpInfo(SpCellCfg *spCell)
619 spCell->servCellIdx = SERV_CELL_IDX;
620 /* Filling Initial Dl Bwp */
621 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
623 spCell->servCellCfg.numDlBwpToAdd = 0;
624 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
625 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
626 spCell->servCellCfg.bwpInactivityTmr = NULLP;
627 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
628 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
629 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
630 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
631 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
632 NUM_HARQ_PROC_FOR_PDSCH_N_16;
633 /* Filling Initial UL Bwp*/
634 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
635 spCell->servCellCfg.numUlBwpToAdd = 0;
636 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
640 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
644 /******************************************************************
646 * @brief Fills Physical Cell Group Info
650 * Function : fillPhyCellGrpInfo
652 * Functionality: Fills Physical Cell Group Info
655 *****************************************************************/
656 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
660 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
661 cellGrp->pNrFr1 = P_NR_FR1;
665 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
669 /******************************************************************
671 * @brief Fills Mac Cell Group Info
675 * Function : fillMacCellGrpInfo
677 * Functionality: Fills Mac Cell Group Info
680 *****************************************************************/
681 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
687 /* Filling Scheduling Request Config */
688 cellGrp->schReqCfg.addModListCount = 1;
689 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
691 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
693 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
694 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
695 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
698 cellGrp->schReqCfg.relListCount = 0;
700 /* Filling Tag config */
701 cellGrp->tagCfg.addModListCount = 1;
702 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
704 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
706 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
707 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
710 cellGrp->tagCfg.relListCount = 0;
712 /* Filling PHR config */
713 cellGrp->phrCfgSetupPres = true;
714 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
715 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
716 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
717 cellGrp->phrCfg.multiplePHR = false;
718 cellGrp->phrCfg.dummy = false;
719 cellGrp->phrCfg.phrType2OtherCell = false;
720 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
725 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
729 /******************************************************************
731 * @brief Fills Logical Channel Config List
735 * Function : fillLcCfgList
737 * Functionality: Fills Logical channel Config List
740 *****************************************************************/
741 void fillLcCfgList(LcCfg *lcCfgInfo)
745 lcCfgInfo->lcId = SRB_ID_1;
746 lcCfgInfo->drbQos = NULLP;
747 lcCfgInfo->snssai = NULLP;
748 lcCfgInfo->ulLcCfg = NULLP;
749 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
752 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
753 /* Filling Qos characteristics */
754 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
755 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
756 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
757 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
758 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
761 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
762 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
763 Pre_emptionCapability_may_trigger_pre_emption;
764 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
765 Pre_emptionVulnerability_not_pre_emptable;
767 /* Filling Grb Qos */
768 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
769 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
770 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
771 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
773 /* Filling S-NSSAI */
774 /* TODO :To be filled when UE Context Setup Request is sent from CU */
775 /* Filling UL Logical Channel Config */
776 lcCfgInfo->ulLcCfg.priority = 0;
777 lcCfgInfo->ulLcCfg.lcGroup = 0;
778 lcCfgInfo->ulLcCfg.schReqId = 0;
779 lcCfgInfo->ulLcCfg.pbr = 0;
780 lcCfgInfo->ulLcCfg.bsd = 0;
782 /* Filling DL Logical Channel Config */
783 lcCfgInfo->dlLcCfg.lcp = 0;
788 DU_LOG("\n Memory is null for LcCfgList");
792 /******************************************************************
794 * @brief Fills MacUeCfg structure
798 * Function : fillMacUeCfg
800 * Functionality: Fills MacUeCfg
803 *****************************************************************/
804 void fillMacUeCfg(MacUeCfg *ueCfg)
808 /* Filling MacCellGroup Config */
809 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
810 /* Filling PhyCellGroup Config */
811 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
812 /* Filling SpCellGroup Config */
813 fillSpCellGrpInfo(&ueCfg->spCellCfg);
814 /* Filling AMBR for UL and DL */
815 ueCfg->maxAggrBitRate = NULLP;
816 /* Filling LC Context */
817 ueCfg->numLcs = SRB_ID_1;
818 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
820 for(idx = 0; idx < ueCfg->numLcs; idx++)
822 fillLcCfgList(&ueCfg->lcCfgList[idx]);
828 /******************************************************************
830 * @brief creates UE context
834 * Function : duCreateUeCb
836 * Functionality: Creates UE Conetxt
838 * @params[in] UeCcchCtxt Pointer
841 * @return ROK - success
843 * ****************************************************************/
844 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
850 for(cellIdx = 0; cellIdx < DU_MAX_CELLS; cellIdx++)
852 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
854 ueIdx = ueCcchCtxt->crnti % DU_UE_START_CRNTI;
855 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
856 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
857 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
858 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
860 /* Filling Mac Ue Config */
861 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
862 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellIdx = ueCcchCtxt->cellId;
863 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.ueIdx = ueIdx;
864 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.crnti = ueCcchCtxt->crnti;
865 fillMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
866 duCb.actvCellLst[cellIdx]->numActvUes++;
867 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
869 /* Send Ue Create Request to MAC */
870 ret = duBuildAndSendUeCreateReqToMac(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellIdx, ueIdx);
872 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
879 /******************************************************************
881 * @brief Builds and Send UE Create Request to MAC
885 * Function : duBuildAndSendUeCreateReqToMac
887 * Functionality: Builds and Send UE Create Request to MAC
889 * @Params[in] cellId,
891 * @return ROK - success
894 * ****************************************************************/
896 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx)
899 MacUeCfg *macUeCfg = NULLP;
902 memset(&pst, 0, sizeof(Pst));
905 pst.selector = ODU_SELECTOR_LWLC;
906 pst.srcEnt = ENTDUAPP;
907 pst.srcInst = DU_INST;
910 pst.dstProcId = DU_PROC;
911 pst.srcProcId = DU_PROC;
912 pst.region = DU_APP_MEM_REGION;
914 pst.event = EVENT_MAC_UE_CREATE_REQ;
916 /* Copying ueCb to a sharable buffer */
917 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
920 memset(macUeCfg, 0, sizeof(MacUeCfg));
921 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
922 /* Processing one Ue at a time to MAC */
923 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
926 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
927 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
933 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReq()");
939 /**********************************************************************
941 ***********************************************************************/