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].startSymbol = PDSCH_START_SYMBOL;
548 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
549 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
550 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
551 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
552 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
553 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
559 /******************************************************************
561 * @brief Fills Initial UL Bandwidth Part
565 * Function : fillInitUlBwp
567 * Functionality: Fills Initial UL Bandwidth Part
570 *****************************************************************/
571 void fillInitUlBwp(InitialUlBwp *initUlBwp)
576 initUlBwp->pucchPresent = FALSE;
578 /*Filling PUSCH Config */
579 initUlBwp->puschPresent = TRUE;
580 if(initUlBwp->puschPresent)
582 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
583 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
584 scramblingId0 = SCRAMBLING_ID;
585 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
586 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
588 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
590 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
591 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
593 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
594 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
595 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
596 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
598 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
603 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
607 /******************************************************************
609 * @brief Fills SpCell Group Info
613 * Function : fillSpCellGrpInfo
615 * Functionality: Fills Sp Cell Group Info
618 *****************************************************************/
619 void fillSpCellGrpInfo(SpCellCfg *spCell)
623 spCell->servCellIdx = SERV_CELL_IDX;
624 /* Filling Initial Dl Bwp */
625 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
627 spCell->servCellCfg.numDlBwpToAdd = 0;
628 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
629 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
630 spCell->servCellCfg.bwpInactivityTmr = NULLP;
631 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
632 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
633 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
634 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
635 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
636 NUM_HARQ_PROC_FOR_PDSCH_N_16;
637 /* Filling Initial UL Bwp*/
638 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
639 spCell->servCellCfg.numUlBwpToAdd = 0;
640 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
644 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
648 /******************************************************************
650 * @brief Fills Physical Cell Group Info
654 * Function : fillPhyCellGrpInfo
656 * Functionality: Fills Physical Cell Group Info
659 *****************************************************************/
660 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
664 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
665 cellGrp->pNrFr1 = P_NR_FR1;
669 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
673 /******************************************************************
675 * @brief Fills Mac Cell Group Info
679 * Function : fillMacCellGrpInfo
681 * Functionality: Fills Mac Cell Group Info
684 *****************************************************************/
685 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
691 /* Filling Scheduling Request Config */
692 cellGrp->schReqCfg.addModListCount = 1;
693 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
695 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
697 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
698 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
699 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
702 cellGrp->schReqCfg.relListCount = 0;
704 /* Filling Tag config */
705 cellGrp->tagCfg.addModListCount = 1;
706 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
708 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
710 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
711 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
714 cellGrp->tagCfg.relListCount = 0;
716 /* Filling BSR config */
717 cellGrp->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR;
718 cellGrp->bsrTmrCfg.retxTimer = RETX_BSR_TMR;
719 cellGrp->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR;
721 /* Filling PHR config */
722 cellGrp->phrCfgSetupPres = true;
723 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
724 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
725 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
726 cellGrp->phrCfg.multiplePHR = false;
727 cellGrp->phrCfg.dummy = false;
728 cellGrp->phrCfg.phrType2OtherCell = false;
729 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
734 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
738 /******************************************************************
740 * @brief Fills Logical Channel Config List
744 * Function : fillLcCfgList
746 * Functionality: Fills Logical channel Config List
749 *****************************************************************/
750 void fillLcCfgList(LcCfg *lcCfgInfo)
754 lcCfgInfo->lcId = SRB_ID_1;
755 lcCfgInfo->drbQos = NULLP;
756 lcCfgInfo->snssai = NULLP;
757 lcCfgInfo->ulLcCfg = NULLP;
758 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
761 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
762 /* Filling Qos characteristics */
763 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
764 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
765 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
766 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
767 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
770 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
771 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
772 Pre_emptionCapability_may_trigger_pre_emption;
773 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
774 Pre_emptionVulnerability_not_pre_emptable;
776 /* Filling Grb Qos */
777 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
778 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
779 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
780 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
782 /* Filling S-NSSAI */
783 /* TODO :To be filled when UE Context Setup Request is sent from CU */
784 /* Filling UL Logical Channel Config */
785 lcCfgInfo->ulLcCfg.priority = 0;
786 lcCfgInfo->ulLcCfg.lcGroup = 0;
787 lcCfgInfo->ulLcCfg.schReqId = 0;
788 lcCfgInfo->ulLcCfg.pbr = 0;
789 lcCfgInfo->ulLcCfg.bsd = 0;
791 /* Filling DL Logical Channel Config */
792 lcCfgInfo->dlLcCfg.lcp = 0;
797 DU_LOG("\n Memory is null for LcCfgList");
801 /******************************************************************
803 * @brief Fills MacUeCfg structure
807 * Function : fillMacUeCfg
809 * Functionality: Fills MacUeCfg
812 *****************************************************************/
813 void fillMacUeCfg(MacUeCfg *ueCfg)
817 /* Filling MacCellGroup Config */
818 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
819 /* Filling PhyCellGroup Config */
820 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
821 /* Filling SpCellGroup Config */
822 fillSpCellGrpInfo(&ueCfg->spCellCfg);
823 /* Filling AMBR for UL and DL */
824 ueCfg->maxAggrBitRate = NULLP;
825 /* Filling LC Context */
826 ueCfg->numLcs = SRB_ID_1;
827 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
829 for(idx = 0; idx < ueCfg->numLcs; idx++)
831 fillLcCfgList(&ueCfg->lcCfgList[idx]);
837 /******************************************************************
839 * @brief creates UE context
843 * Function : duCreateUeCb
845 * Functionality: Creates UE Conetxt
847 * @params[in] UeCcchCtxt Pointer
850 * @return ROK - success
852 * ****************************************************************/
853 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
859 for(cellIdx = 0; cellIdx < DU_MAX_CELLS; cellIdx++)
861 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
863 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
864 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
865 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
866 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
867 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
869 /* Filling Mac Ue Config */
870 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
871 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellId = ueCcchCtxt->cellId;
872 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.ueIdx = ueIdx;
873 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.crnti = ueCcchCtxt->crnti;
874 fillMacUeCfg(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
875 duCb.actvCellLst[cellIdx]->numActvUes++;
876 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
878 /* Send Ue Create Request to MAC */
879 ret = duBuildAndSendUeCreateReqToMac(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg.cellId, ueIdx);
881 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
888 /******************************************************************
890 * @brief Builds and Send UE Create Request to MAC
894 * Function : duBuildAndSendUeCreateReqToMac
896 * Functionality: Builds and Send UE Create Request to MAC
898 * @Params[in] cellId,
900 * @return ROK - success
903 * ****************************************************************/
905 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx)
908 MacUeCfg *macUeCfg = NULLP;
911 memset(&pst, 0, sizeof(Pst));
914 pst.selector = ODU_SELECTOR_LWLC;
915 pst.srcEnt = ENTDUAPP;
916 pst.srcInst = DU_INST;
919 pst.dstProcId = DU_PROC;
920 pst.srcProcId = DU_PROC;
921 pst.region = DU_APP_MEM_REGION;
923 pst.event = EVENT_MAC_UE_CREATE_REQ;
925 /* Copying ueCb to a sharable buffer */
926 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
929 memset(macUeCfg, 0, sizeof(MacUeCfg));
930 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
931 /* Processing one Ue at a time to MAC */
932 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
935 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
936 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
942 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReq()");
948 /*******************************************************************
950 * @brief Handle UE create response from MAC
954 * Function : duHandleMacUeCreateRsp
956 * Functionality: Handle UE create response from MAC
959 * @return ROK - success
962 * ****************************************************************/
963 uint8_t duHandleMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
965 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
967 DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
971 DU_LOG("\nDU APP : MAC UE Create Response : FAILURE [UE IDX : %d]", cfgRsp->ueIdx);
976 /**********************************************************************
978 ***********************************************************************/