1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
18 /* This file contains UE management handling functionality for DU APP */
19 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
33 #include<ProtocolIE-Field.h>
36 #include "du_f1ap_msg_hdl.h"
37 #include "du_ue_mgr.h"
43 DuMacDlCcchInd packMacDlCcchIndOpts[] =
45 packMacDlCcchInd, /* Loose coupling */
46 MacProcDlCcchInd, /* TIght coupling */
47 packMacDlCcchInd /* Light weight-loose coupling */
50 DuMacUeCreateReq packMacUeCreateReqOpts[] =
52 packDuMacUeCreateReq, /* Loose coupling */
53 MacProcUeCreateReq, /* TIght coupling */
54 packDuMacUeCreateReq, /* Light weight-loose coupling */
57 DuRlcUlUeCreateReq packRlcUlUeCreateReqOpts[] =
59 packDuRlcUlUeCreateReq, /* Loose coupling */
60 RlcUlProcUeCreateReq, /* TIght coupling */
61 packDuRlcUlUeCreateReq, /* Light weight-loose coupling */
64 /*******************************************************************
66 * @brief Handles EGTP data from CU
70 * Function : duHdlEgtpData
73 * Processes EGTP header and sends data to RLC
75 * @params[in] Pointer to EGTP Message
76 * @return ROK - success
79 * ****************************************************************/
80 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
82 /* TODO : Extract RbId/UeID/CellID/SduId from database
83 using tunnel id in egtp header */
85 DU_LOG("\nDU_APP : Processing DL data");
88 KwuDatReqInfo datReqInfo;
91 datReqInfo.rlcId.rbId = RB_ID;
92 datReqInfo.rlcId.rbType = CM_LTE_DRB;
93 datReqInfo.rlcId.ueId = UE_ID;
94 datReqInfo.rlcId.cellId = NR_CELL_ID;
96 datReqInfo.sduId = ++sduId;
97 datReqInfo.lcType = CM_LTE_LCH_DTCH;
99 /* Filling pst and Sending to RLC DL */
100 pst.selector = ODU_SELECTOR_LWLC;
101 pst.srcEnt = ENTDUAPP;
103 pst.dstInst = RLC_DL_INST;
104 pst.dstProcId = DU_PROC;
105 pst.srcProcId = DU_PROC;
106 pst.region = duCb.init.region;
108 cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
112 /*******************************************************************
114 * @brief Handles UL data and send to CU
118 * Function : duHdlRlcUlData
121 * Processes UL Data from RLC and sends to CU
123 * @params[in] Pointer to EGTP Message
124 * @return ROK - success
127 *****************************************************************/
129 uint8_t duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
131 DU_LOG("\nDU_APP : Received UL Data at DU_APP");
133 /* Send UL data to CU via EGTP */
134 duSendEgtpDatInd(mBuf);
140 /******************************************************************
142 * @brief Builds and Sends DL CCCH Ind to MAC
146 * Function : duBuildAndSendDlCcchInd
148 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
150 * @params[in] dlCcchMsg - uint8_t*
151 * @return ROK - success
154 * ****************************************************************/
155 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
156 DlCcchMsgType msgType, uint8_t *dlCcchMsg, uint16_t dlCcchMsgSize)
160 DlCcchIndInfo *dlCcchIndInfo = NULLP;
162 memset(&pst, 0, sizeof(Pst));
164 DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
166 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
170 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
174 dlCcchIndInfo->cellId = *cellId;
175 dlCcchIndInfo->crnti = *crnti;
176 dlCcchIndInfo->msgType = msgType;
177 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
179 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
180 if(!dlCcchIndInfo->dlCcchMsg)
182 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
183 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
186 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
188 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
190 DU_FREE(dlCcchMsg, dlCcchMsgSize);
193 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
194 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
197 DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC");
198 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
199 dlCcchIndInfo->dlCcchMsgLen);
200 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
201 sizeof(DlCcchIndInfo));
209 /******************************************************************
211 * @brief Processes DL RRC Message Transfer sent by CU
215 * Function : procDlRrcMsgTrans
217 * Functionality: Processes DL RRC Message Transfer sent by CU
219 * @params[in] F1AP_PDU_t ASN decoded F1AP message
220 * @return ROK - success
223 * ****************************************************************/
224 uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
226 DLRRCMessageTransfer_t *dlRrcMsg = NULLP;
227 uint8_t *dlCcchMsg = NULLP;
228 uint8_t idx, ret, srbId;
229 uint16_t idx2, crnti, cellId, dlCcchMsgSize;
230 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
233 DU_LOG("\nDU_APP : DL RRC message transfer Recevied");
234 dlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
238 for(idx=0; idx<dlRrcMsg->protocolIEs.list.count; idx++)
240 switch(dlRrcMsg->protocolIEs.list.array[idx]->id)
242 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
244 gnbCuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
247 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
249 gnbDuUeF1apId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
252 case ProtocolIE_ID_id_SRBID:
254 srbId = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
257 case ProtocolIE_ID_id_ExecuteDuplication:
260 case ProtocolIE_ID_id_RRCContainer:
262 if(dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
264 dlCcchMsgSize = dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
265 DU_ALLOC(dlCcchMsg, dlCcchMsgSize);
266 for(idx2 = 0; idx2 < dlCcchMsgSize; idx2++)
269 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf[idx2];
274 DU_LOG("\nDU_APP : RRC Container Size is invalid:%ld",\
275 dlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
281 DU_LOG("\nDU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
282 dlRrcMsg->protocolIEs.list.array[idx]->id);
286 for(idx=0; idx<duCb.numUe; idx++)
288 if(gnbDuUeF1apId == duCb.ueCcchCtxt[idx].gnbDuUeF1apId)
290 crnti = duCb.ueCcchCtxt[idx].crnti;
291 cellId = duCb.ueCcchCtxt[idx].cellId;
295 if(srbId == SRB_ID_1) //RRC connection setup
297 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlCcchMsg, dlCcchMsgSize);
300 DU_LOG("\nDU_APP: Falied at duBuildAndSendDlCcchInd()");
304 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
306 ret = duCreateUeCb(&duCb.ueCcchCtxt[idx], gnbCuUeF1apId);
309 DU_LOG("\nDU_APP: Failed at duCreateUeCb for cellId [%d]", duCb.ueCcchCtxt[idx].cellId);
315 DU_LOG("\nDU_APP: Max Active UEs has reached");
323 /******************************************************************
325 * @brief Generates GNB DU Ue F1AP ID
329 * Function : genGnbDuUeF1apId
331 * Functionality: Generates GNB DU Ue F1AP ID
334 * @return gnbDuF1apId
336 * ****************************************************************/
337 uint32_t genGnbDuUeF1apId()
339 static uint32_t gnbDuUeF1apId = 0;
341 return ++gnbDuUeF1apId;
344 /******************************************************************
346 * @brief Processes UL CCCH Ind recvd from MAC
350 * Function : duProcUlCcchInd
352 * Functionality: Processes UL CCCH Ind recvd from MAC
354 * @params[in] UlCcchIndInfo *ulCcchIndInfo
355 * @return ROK - success
358 * ****************************************************************/
359 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
363 uint32_t gnbDuUeF1apId = 0;
365 gnbDuUeF1apId = genGnbDuUeF1apId();
367 /* Store Ue mapping */
368 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
369 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
370 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
374 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
375 ulCcchIndInfo->ulCcchMsg));
378 DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
381 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
382 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
388 /******************************************************************
390 * @brief Fills Initial DL Bandwidth Part
394 * Function : fillInitDlBwp
396 * Functionality: Fills Initial DL Bandwidth Part
399 *****************************************************************/
400 void fillInitDlBwp(InitialDlBwp *initDlBwp)
403 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
404 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
409 /* Filling PDCCH Config */
410 initDlBwp->pdcchPresent = TRUE;
411 if(initDlBwp->pdcchPresent)
413 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
414 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
415 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
417 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
418 PDCCH_CTRL_RSRC_SET_ONE_ID;
419 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
421 coreset0EndPrb = CORESET0_END_PRB;
422 coreset1StartPrb = coreset0EndPrb +6;
423 coreset1NumPrb = CORESET1_NUM_PRB;
424 /* calculate the PRBs */
425 schAllocFreqDomRscType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
426 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
429 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
430 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
431 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
432 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
433 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
435 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
438 initDlBwp->pdcchCfg.numCRsetToRel = 0;
439 /* Filling Serach Space */
440 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
441 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
442 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
444 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
445 PDCCH_SRCH_SPC_TWO_ID;
446 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
447 PDCCH_CTRL_RSRC_SET_ONE_ID;
448 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
449 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
450 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
451 MONITORING_SYMB_WITHIN_SLOT_SIZE);
452 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
453 PDCCH_SYMBOL_WITHIN_SLOT;
454 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
456 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
458 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
460 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
462 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
464 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
465 SEARCHSPACETYPE_PR_UE_SPECIFIC;
466 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
467 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
469 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
473 /* Filling PDSCH Config */
474 initDlBwp->pdschPresent = TRUE;
475 if(initDlBwp->pdschPresent)
477 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
478 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
479 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
480 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
482 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
483 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
484 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
485 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
486 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
487 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
488 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
494 /******************************************************************
496 * @brief Fills Initial UL Bandwidth Part
500 * Function : fillInitUlBwp
502 * Functionality: Fills Initial UL Bandwidth Part
505 *****************************************************************/
506 void fillInitUlBwp(InitialUlBwp *initUlBwp)
511 initUlBwp->pucchPresent = FALSE;
513 /*Filling PUSCH Config */
514 initUlBwp->puschPresent = TRUE;
515 if(initUlBwp->puschPresent)
517 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
518 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
519 scramblingId0 = SCRAMBLING_ID;
520 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
521 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
523 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
525 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
526 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
528 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
529 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
530 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
531 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
533 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
538 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
542 /******************************************************************
544 * @brief Fills SpCell Group Info
548 * Function : fillSpCellGrpInfo
550 * Functionality: Fills Sp Cell Group Info
553 *****************************************************************/
554 void fillSpCellGrpInfo(SpCellCfg *spCell)
558 spCell->servCellIdx = SERV_CELL_IDX;
559 /* Filling Initial Dl Bwp */
560 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
562 spCell->servCellCfg.numDlBwpToAdd = 0;
563 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
564 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
565 spCell->servCellCfg.bwpInactivityTmr = NULLP;
566 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
567 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
568 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
569 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
570 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
571 NUM_HARQ_PROC_FOR_PDSCH_N_16;
572 /* Filling Initial UL Bwp*/
573 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
574 spCell->servCellCfg.numUlBwpToAdd = 0;
575 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
579 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
583 /******************************************************************
585 * @brief Fills Physical Cell Group Info
589 * Function : fillPhyCellGrpInfo
591 * Functionality: Fills Physical Cell Group Info
594 *****************************************************************/
595 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
599 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
600 cellGrp->pNrFr1 = P_NR_FR1;
604 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
608 /******************************************************************
610 * @brief Fills Mac Cell Group Info
614 * Function : fillMacCellGrpInfo
616 * Functionality: Fills Mac Cell Group Info
619 *****************************************************************/
620 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
626 /* Filling Scheduling Request Config */
627 cellGrp->schReqCfg.addModListCount = 1;
628 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
630 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
632 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
633 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
634 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
637 cellGrp->schReqCfg.relListCount = 0;
639 /* Filling Tag config */
640 cellGrp->tagCfg.addModListCount = 1;
641 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
643 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
645 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
646 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
649 cellGrp->tagCfg.relListCount = 0;
651 /* Filling BSR config */
652 cellGrp->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR;
653 cellGrp->bsrTmrCfg.retxTimer = RETX_BSR_TMR;
654 cellGrp->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR;
656 /* Filling PHR config */
657 cellGrp->phrCfgSetupPres = true;
658 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
659 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
660 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
661 cellGrp->phrCfg.multiplePHR = false;
662 cellGrp->phrCfg.dummy = false;
663 cellGrp->phrCfg.phrType2OtherCell = false;
664 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
669 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
673 /******************************************************************
675 * @brief Fills Logical Channel Config List
679 * Function : fillLcCfgList
681 * Functionality: Fills Logical channel Config List
684 *****************************************************************/
685 void fillLcCfgList(LcCfg *lcCfgInfo)
689 lcCfgInfo->lcId = SRB_ID_1;
690 lcCfgInfo->drbQos = NULLP;
691 lcCfgInfo->snssai = NULLP;
692 lcCfgInfo->ulLcCfg = NULLP;
693 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
696 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
697 /* Filling Qos characteristics */
698 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
699 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
700 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
701 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
702 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
705 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
706 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
707 Pre_emptionCapability_may_trigger_pre_emption;
708 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
709 Pre_emptionVulnerability_not_pre_emptable;
711 /* Filling Grb Qos */
712 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
713 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
714 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
715 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
717 /* Filling S-NSSAI */
718 /* TODO :To be filled when UE Context Setup Request is sent from CU */
719 /* Filling UL Logical Channel Config */
720 lcCfgInfo->ulLcCfg.priority = 0;
721 lcCfgInfo->ulLcCfg.lcGroup = 0;
722 lcCfgInfo->ulLcCfg.schReqId = 0;
723 lcCfgInfo->ulLcCfg.pbr = 0;
724 lcCfgInfo->ulLcCfg.bsd = 0;
726 /* Filling DL Logical Channel Config */
727 lcCfgInfo->dlLcCfg.lcp = 0;
732 DU_LOG("\n Memory is null for LcCfgList");
736 /******************************************************************
738 * @brief Fills MacUeCfg structure
742 * Function : fillMacUeCfg
744 * Functionality: Fills MacUeCfg
747 *****************************************************************/
748 void fillMacUeCfg(uint16_t cellId, uint8_t ueIdx,\
749 uint16_t crnti, MacUeCfg *ueCfg)
752 ueCfg->cellId = cellId;
753 ueCfg->ueIdx = ueIdx;
754 ueCfg->crnti = crnti;
755 /* Filling MacCellGroup Config */
756 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
757 /* Filling PhyCellGroup Config */
758 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
759 /* Filling SpCellGroup Config */
760 fillSpCellGrpInfo(&ueCfg->spCellCfg);
761 /* Filling AMBR for UL and DL */
762 ueCfg->maxAggrBitRate = NULLP;
763 /* Filling LC Context */
764 ueCfg->numLcs = SRB_ID_1;
765 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
767 for(idx = 0; idx < ueCfg->numLcs; idx++)
769 fillLcCfgList(&ueCfg->lcCfgList[idx]);
775 /******************************************************************
777 * @brief Fills Rlc AM Information
781 * Function : fillAmInfo
783 * Functionality: Fills Rlc AM Information
786 *****************************************************************/
787 void fillAmInfo(AmBearerCfg *amCfg)
790 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
791 amCfg->dlAmCfg.pollRetxTmr = POLL_RETX_TMR_45MS;
792 amCfg->dlAmCfg.pollPdu = POLL_PDU_TMR_INFINITY;
793 amCfg->dlAmCfg.pollByte = POLL_BYTES_INFINITY;
794 amCfg->dlAmCfg.maxRetxTh = RETX_TH_8;
797 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
798 amCfg->ulAmCfg.reAssemTmr = RE_ASM_40MS;
799 amCfg->ulAmCfg.statProhTmr = PROH_35MS;
803 /******************************************************************
805 * @brief Fills RLC UM Bi Directional Information
809 * Function : fillUmBiDirInfo
811 * Functionality: Fills RLC UM Bi Directional Information
814 *****************************************************************/
815 void fillUmBiDirInfo(UmBiDirBearerCfg *umBiDirCfg)
817 /* UL UM BI DIR INFO */
818 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
819 umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
821 /* DL UM BI DIR INFO */
822 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
826 /******************************************************************
828 * @brief Fills RLC UM Uni Directional UL Information
832 * Function : fillUmUniDirUlInfo
834 * Functionality: Fills RLC UM Uni Directional Info
837 *****************************************************************/
838 void fillUmUniDirUlInfo(UmUniDirUlBearerCfg *umUniDirUlCfg)
840 umUniDirUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
841 umUniDirUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
844 /******************************************************************
846 * @brief Fills RLC UM Uni Directional DL Information
850 * Function : fillUmUniDirDlInfo
852 * Functionality: Fills RLC UM Uni Directional DL Info
855 *****************************************************************/
856 void fillUmUniDirDlInfo(UmUniDirDlBearerCfg *umUniDirDlCfg)
858 umUniDirDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
861 /******************************************************************
863 * @brief Fills RlcBearerCfg structure
867 * Function : fillRlcBearerCfg
869 * Functionality: Fills Rlc Bearer Cfg
872 *****************************************************************/
873 void fillRlcBearerCfg(uint16_t cellId, uint8_t ueIdx, RlcUeCfg *ueCfg)
876 ueCfg->cellId = cellId;
877 ueCfg->ueIdx = ueIdx;
878 ueCfg->numLcs = SRB_ID_1;
880 for(idx = 0; idx < ueCfg->numLcs; idx++)
882 ueCfg->rlcBearerCfg[idx].rbId = RB_ID_SRB;
883 ueCfg->rlcBearerCfg[idx].rbType = RB_TYPE_SRB;
884 ueCfg->rlcBearerCfg[idx].lcId = SRB_ID_1;
885 ueCfg->rlcBearerCfg[idx].lcType = LCH_DCCH;
886 ueCfg->rlcBearerCfg[idx].rlcMode = RLC_AM;
887 switch(ueCfg->rlcBearerCfg[idx].rlcMode)
890 memset(&ueCfg->rlcBearerCfg[idx].u.amCfg, 0, sizeof(AmBearerCfg));
891 fillAmInfo(&ueCfg->rlcBearerCfg[idx].u.amCfg);
893 case RLC_UM_BI_DIRECTIONAL:
894 memset(&ueCfg->rlcBearerCfg[idx].u.umBiDirCfg, 0, sizeof(UmBiDirBearerCfg));
895 fillUmBiDirInfo(&ueCfg->rlcBearerCfg[idx].u.umBiDirCfg);
897 case RLC_UM_UNI_DIRECTIONAL_UL:
898 memset(&ueCfg->rlcBearerCfg[idx].u.umUniDirUlCfg, 0, sizeof(UmUniDirUlBearerCfg));
899 fillUmUniDirUlInfo(&ueCfg->rlcBearerCfg[idx].u.umUniDirUlCfg);
901 case RLC_UM_UNI_DIRECTIONAL_DL:
902 memset(&ueCfg->rlcBearerCfg[idx].u.umUniDirDlCfg, 0, sizeof(UmUniDirDlBearerCfg));
903 fillUmUniDirDlInfo(&ueCfg->rlcBearerCfg[idx].u.umUniDirDlCfg);
906 DU_LOG("\nDU_APP: Rlc Mode invalid %d", ueCfg->rlcBearerCfg[idx].rlcMode);
912 /******************************************************************
914 * @brief creates UE context
918 * Function : duCreateUeCb
920 * Functionality: Creates UE Conetxt
922 * @params[in] UeCcchCtxt Pointer
925 * @return ROK - success
927 * ****************************************************************/
928 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
934 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
936 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
938 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
939 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
941 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
942 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
943 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
945 /* Filling Mac Ue Config */
946 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
947 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
948 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
950 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
952 /* Filling Rlc Ue Config */
953 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
954 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
955 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
957 DU_LOG("\nDU_APP: Failed to send UE create request to RLC");
959 duCb.actvCellLst[cellIdx]->numActvUes++;
960 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
966 /******************************************************************
968 * @brief Builds and Send UE Create Request to MAC
972 * Function : duBuildAndSendUeCreateReqToMac
974 * Functionality: Builds and Send UE Create Request to MAC
976 * @Params[in] cellId,
978 * @return ROK - success
981 * ****************************************************************/
983 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
984 uint16_t crnti, MacUeCfg *duMacUeCfg)
987 MacUeCfg *macUeCfg = NULLP;
989 memset(&pst, 0, sizeof(Pst));
991 fillMacUeCfg(cellId, ueIdx, crnti, duMacUeCfg);
994 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
996 /* Copying ueCb to a sharable buffer */
997 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1000 memset(macUeCfg, 0, sizeof(MacUeCfg));
1001 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1002 DU_LOG("\nDU_APP: Sending UE create request to MAC");
1004 /* Processing one Ue at a time to MAC */
1005 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1008 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
1009 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1015 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1021 /*******************************************************************
1023 * @brief Handle UE create response from MAC
1027 * Function : DuHandleMacUeCreateRsp
1029 * Functionality: Handle UE create response from MAC
1031 * @params[in] Pointer to MacUeCfgRsp and Pst
1032 * @return ROK - success
1035 * ****************************************************************/
1036 uint8_t DuHandleMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
1038 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
1040 DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1044 DU_LOG("\nDU APP : MAC UE Create Response : FAILURE [UE IDX : %d]", cfgRsp->ueIdx);
1049 /*******************************************************************
1051 * @brief Processes UE create Req to RLC UL
1055 * Function : duBuildAndSendUeCreateReqToRlc
1058 * Processes UE create Req to RLC UL
1060 * @params[in] cellId,
1062 * Pointer to RlcUeCfg
1063 * @return ROK - success
1066 *****************************************************************/
1068 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx, RlcUeCfg *duRlcUeCfg)
1071 RlcUeCfg *rlcUeCfg = NULLP;
1073 memset(&pst, 0, sizeof(Pst));
1075 fillRlcBearerCfg(cellId, ueIdx, duRlcUeCfg);
1076 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UL_UE_CREATE_REQ);
1078 /* Copying ueCfg to a sharable buffer */
1079 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
1082 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1083 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
1084 /* Processing one Ue at a time to RLC */
1085 DU_LOG("\nDU_APP: Sending UE create request to RLC UL");
1086 ret = (*packRlcUlUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
1089 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to RLC");
1090 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1096 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
1104 /*******************************************************************
1106 * @brief Processes UE create Rsp received from RLC UL
1110 * Function : DuProcRlcUlUeCfgRsp
1113 * Processes UE create Rsp received from RLC UL
1115 * @params[in] Post structure
1116 * Pointer to RlcCfgCfm
1117 * @return ROK - success
1120 *****************************************************************/
1122 uint8_t DuProcRlcUlUeCreateRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
1128 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
1130 DU_LOG("\nDU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
1134 DU_LOG("\nDU_APP: RLC UE Create Response : FAILED [UE IDX:%d, REASON :%d]",\
1135 cfgRsp->ueIdx, cfgRsp->reason);
1138 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
1142 DU_LOG("\nDU_APP: Received RLC Ue Create Response is NULL");
1147 /**********************************************************************
1149 ***********************************************************************/