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"
24 #include "du_app_mac_inf.h"
26 #include "du_ue_mgr.h"
28 #include<ProtocolIE-Field.h>
35 DuMacDlCcchInd packMacDlCcchIndOpts[] =
37 packMacDlCcchInd, /* Loose coupling */
38 MacProcDlCcchInd, /* TIght coupling */
39 packMacDlCcchInd /* Light weight-loose coupling */
42 DuMacUeCreateReq packMacUeCreateReqOpts[] =
44 packDuMacUeCreateReq, /* Loose coupling */
45 MacProcUeCreateReq, /* TIght coupling */
46 packDuMacUeCreateReq, /* Light weight-loose coupling */
49 /******************************************************************
51 * @brief Send UE configuration to RLC
55 * Function : duSendUeCreateReqToRlc
57 * Functionality: Send UeCreateReqToRlc
59 * @return ROK - success
62 * ****************************************************************/
63 S16 duSendUeCreateReqToRlc()
69 DU_SET_ZERO(&ueCfg, sizeof(ueCfg));
70 DU_SET_ZERO(&pst, sizeof(Pst));
72 DU_ALLOC(ueCfg, sizeof(CkwCfgInfo));
77 ueCfg->cellId = NR_CELL_ID;
80 for(idx = 0; idx < ueCfg->numEnt; idx++)
83 ueCfg->entCfg[idx].rbId = RB_ID;
84 ueCfg->entCfg[idx].rbType = CM_LTE_DRB;
85 ueCfg->entCfg[idx].lCh[0].lChId = LC_ID;
86 ueCfg->entCfg[idx].lCh[0].type = CM_LTE_LCH_DTCH;
88 ueCfg->entCfg[idx].entMode = CM_LTE_MODE_UM;
89 ueCfg->entCfg[idx].dir = CKW_CFG_DIR_BOTH;
90 switch(ueCfg->entCfg[idx].entMode)
99 ueCfg->entCfg[idx].m.umInfo.dl.snLen = 1; /* For 12 bit SN */
100 ueCfg->entCfg[idx].m.umInfo.ul.snLen = 1; /* For 12 bit SN */
101 ueCfg->entCfg[idx].m.umInfo.ul.reOrdTmr = 10; /* in msec */
112 } /* End of switch(entMode) */
113 } /* End of entity configuration for loop */
116 pst.selector = ODU_SELECTOR_LWLC;
117 pst.srcEnt = ENTDUAPP;
119 pst.dstInst = RLC_UL_INST;
120 pst.dstProcId = DU_PROC;
121 pst.srcProcId = DU_PROC;
122 pst.region = duCb.init.region;
125 packUeCreateReq(&pst, ueCfg);
128 } /* End of duSendUeCreateReqToRlc */
130 /*******************************************************************
132 * @brief Handles EGTP data from CU
136 * Function : duHdlEgtpData
139 * Processes EGTP header and sends data to RLC
141 * @params[in] Pointer to EGTP Message
142 * @return ROK - success
145 * ****************************************************************/
146 S16 duHdlEgtpDlData(EgtpMsg *egtpMsg)
148 /* TODO : Extract RbId/UeID/CellID/SduId from database
149 using tunnel id in egtp header */
151 DU_LOG("\nDU_APP : Processing DL data");
154 KwuDatReqInfo datReqInfo;
157 datReqInfo.rlcId.rbId = RB_ID;
158 datReqInfo.rlcId.rbType = CM_LTE_DRB;
159 datReqInfo.rlcId.ueId = UE_ID;
160 datReqInfo.rlcId.cellId = NR_CELL_ID;
162 datReqInfo.sduId = ++sduId;
163 datReqInfo.lcType = CM_LTE_LCH_DTCH;
165 /* Filling pst and Sending to RLC DL */
166 pst.selector = ODU_SELECTOR_LWLC;
167 pst.srcEnt = ENTDUAPP;
169 pst.dstInst = RLC_DL_INST;
170 pst.dstProcId = DU_PROC;
171 pst.srcProcId = DU_PROC;
172 pst.region = duCb.init.region;
174 cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
178 /*******************************************************************
180 * @brief Handles UL data and send to CU
184 * Function : duHdlRlcUlData
187 * Processes UL Data from RLC and sends to CU
189 * @params[in] Pointer to EGTP Message
190 * @return ROK - success
193 *****************************************************************/
195 PUBLIC S16 duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
197 DU_LOG("\nDU_APP : Received UL Data at DU_APP");
199 /* Send UL data to CU via EGTP */
200 duSendEgtpDatInd(mBuf);
206 /******************************************************************
208 * @brief Builds and Sends DL CCCH Ind to MAC
212 * Function : duBuildAndSendDlCcchInd
214 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
216 * @params[in] dlCcchMsg - uint8_t*
217 * @return ROK - success
220 * ****************************************************************/
221 uint8_t duBuildAndSendDlCcchInd(uint16_t cellId, uint16_t crnti, \
222 DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize)
226 DlCcchIndInfo *dlCcchIndInfo = NULLP;
229 memset(&pst, 0, sizeof(Pst));
230 DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
232 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
236 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
240 dlCcchIndInfo->cellId = cellId;
241 dlCcchIndInfo->crnti = crnti;
242 dlCcchIndInfo->msgType = msgType;
243 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
245 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
246 if(!dlCcchIndInfo->dlCcchMsg)
248 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
249 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
252 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
254 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
256 DU_FREE(dlCcchMsg, dlCcchMsgSize);
259 FILL_PST_DUAPP_TO_MAC(pst, 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 < MAX_NUM_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, MAC_POOL, ulCcchIndInfo->ulCcchMsg, strlen((const char*)ulCcchIndInfo->ulCcchMsg));
448 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_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].startSymbol = PDSCH_START_SYMBOL;
540 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
541 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
542 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
543 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
544 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
545 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
551 /******************************************************************
553 * @brief Fills Initial UL Bandwidth Part
557 * Function : fillInitUlBwp
559 * Functionality: Fills Initial UL Bandwidth Part
562 *****************************************************************/
563 void fillInitUlBwp(InitialUlBwp *initUlBwp)
568 initUlBwp->pucchPresent = FALSE;
570 /*Filling PUSCH Config */
571 initUlBwp->puschPresent = TRUE;
572 if(initUlBwp->puschPresent)
574 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
575 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
576 scramblingId0 = SCRAMBLING_ID;
577 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
578 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
580 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
582 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
583 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
585 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
586 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
587 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
588 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
590 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
595 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
599 /******************************************************************
601 * @brief Fills SpCell Group Info
605 * Function : fillSpCellGrpInfo
607 * Functionality: Fills Sp Cell Group Info
610 *****************************************************************/
611 void fillSpCellGrpInfo(SpCellCfg *spCell)
615 spCell->servCellIdx = SERV_CELL_IDX;
616 /* Filling Initial Dl Bwp */
617 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
619 spCell->servCellCfg.numDlBwpToAdd = 0;
620 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
621 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
622 spCell->servCellCfg.bwpInactivityTmr = NULLP;
623 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
624 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
625 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
626 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
627 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
628 NUM_HARQ_PROC_FOR_PDSCH_N_16;
629 /* Filling Initial UL Bwp*/
630 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
631 spCell->servCellCfg.numUlBwpToAdd = 0;
632 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
636 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
640 /******************************************************************
642 * @brief Fills Physical Cell Group Info
646 * Function : fillPhyCellGrpInfo
648 * Functionality: Fills Physical Cell Group Info
651 *****************************************************************/
652 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
656 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
657 cellGrp->pNrFr1 = P_NR_FR1;
661 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
665 /******************************************************************
667 * @brief Fills Mac Cell Group Info
671 * Function : fillMacCellGrpInfo
673 * Functionality: Fills Mac Cell Group Info
676 *****************************************************************/
677 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
683 /* Filling Scheduling Request Config */
684 cellGrp->schReqCfg.addModListCount = 1;
685 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
687 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
689 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
690 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
691 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
694 cellGrp->schReqCfg.relListCount = 0;
696 /* Filling Tag config */
697 cellGrp->tagCfg.addModListCount = 1;
698 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
700 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
702 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
703 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
706 cellGrp->tagCfg.relListCount = 0;
708 /* Filling BSR config */
709 cellGrp->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR;
710 cellGrp->bsrTmrCfg.retxTimer = RETX_BSR_TMR;
711 cellGrp->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR;
713 /* Filling PHR config */
714 cellGrp->phrCfgSetupPres = true;
715 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
716 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
717 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
718 cellGrp->phrCfg.multiplePHR = false;
719 cellGrp->phrCfg.dummy = false;
720 cellGrp->phrCfg.phrType2OtherCell = false;
721 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
726 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
730 /******************************************************************
732 * @brief Fills Logical Channel Config List
736 * Function : fillLcCfgList
738 * Functionality: Fills Logical channel Config List
741 *****************************************************************/
742 void fillLcCfgList(LcCfg *lcCfgInfo)
746 lcCfgInfo->lcId = SRB_ID_1;
747 lcCfgInfo->drbQos = NULLP;
748 lcCfgInfo->snssai = NULLP;
749 lcCfgInfo->ulLcCfg = NULLP;
750 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
753 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
754 /* Filling Qos characteristics */
755 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
756 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
757 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
758 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
759 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
762 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
763 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
764 Pre_emptionCapability_may_trigger_pre_emption;
765 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
766 Pre_emptionVulnerability_not_pre_emptable;
768 /* Filling Grb Qos */
769 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
770 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
771 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
772 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
774 /* Filling S-NSSAI */
775 /* TODO :To be filled when UE Context Setup Request is sent from CU */
776 /* Filling UL Logical Channel Config */
777 lcCfgInfo->ulLcCfg.priority = 0;
778 lcCfgInfo->ulLcCfg.lcGroup = 0;
779 lcCfgInfo->ulLcCfg.schReqId = 0;
780 lcCfgInfo->ulLcCfg.pbr = 0;
781 lcCfgInfo->ulLcCfg.bsd = 0;
783 /* Filling DL Logical Channel Config */
784 lcCfgInfo->dlLcCfg.lcp = 0;
789 DU_LOG("\n Memory is null for LcCfgList");
793 /******************************************************************
795 * @brief Fills MacUeCfg structure
799 * Function : fillMacUeCfg
801 * Functionality: Fills MacUeCfg
804 *****************************************************************/
805 void fillMacUeCfg(MacUeCfg *ueCfg)
809 /* Filling MacCellGroup Config */
810 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
811 /* Filling PhyCellGroup Config */
812 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
813 /* Filling SpCellGroup Config */
814 fillSpCellGrpInfo(&ueCfg->spCellCfg);
815 /* Filling AMBR for UL and DL */
816 ueCfg->maxAggrBitRate = NULLP;
817 /* Filling LC Context */
818 ueCfg->numLcs = SRB_ID_1;
819 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
821 for(idx = 0; idx < ueCfg->numLcs; idx++)
823 fillLcCfgList(&ueCfg->lcCfgList[idx]);
829 /******************************************************************
831 * @brief creates UE context
835 * Function : duCreateUeCb
837 * Functionality: Creates UE Conetxt
839 * @params[in] UeCcchCtxt Pointer
842 * @return ROK - success
844 * ****************************************************************/
845 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
851 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
853 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
855 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
856 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
858 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
859 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
860 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
862 /* Filling Mac Ue Config */
863 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
864 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellId = ueCcchCtxt->cellId;
865 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.ueIdx = ueIdx;
866 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.crnti = ueCcchCtxt->crnti;
867 fillMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
868 duCb.actvCellLst[cellIdx]->numActvUes++;
869 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
871 /* Send Ue Create Request to MAC */
872 ret = duBuildAndSendUeCreateReqToMac(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellId, ueIdx);
874 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
881 /******************************************************************
883 * @brief Builds and Send UE Create Request to MAC
887 * Function : duBuildAndSendUeCreateReqToMac
889 * Functionality: Builds and Send UE Create Request to MAC
891 * @Params[in] cellId,
893 * @return ROK - success
896 * ****************************************************************/
898 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx)
901 MacUeCfg *macUeCfg = NULLP;
904 memset(&pst, 0, sizeof(Pst));
907 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
909 /* Copying ueCb to a sharable buffer */
910 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
913 memset(macUeCfg, 0, sizeof(MacUeCfg));
914 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
915 /* Processing one Ue at a time to MAC */
916 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
919 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
920 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
926 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReq()");
932 /*******************************************************************
934 * @brief Handle UE create response from MAC
938 * Function : duHandleMacUeCreateRsp
940 * Functionality: Handle UE create response from MAC
943 * @return ROK - success
946 * ****************************************************************/
947 uint8_t duHandleMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
949 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
951 DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
955 DU_LOG("\nDU APP : MAC UE Create Response : FAILURE [UE IDX : %d]", cfgRsp->ueIdx);
960 /**********************************************************************
962 ***********************************************************************/