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>
35 #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,
375 ulCcchIndInfo->ulCcchMsg));
378 DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
381 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, strlen((const char*)ulCcchIndInfo->ulCcchMsg));
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)
406 /* Filling PDCCH Config */
407 initDlBwp->pdcchPresent = TRUE;
408 if(initDlBwp->pdcchPresent)
410 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
411 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
412 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
414 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
415 PDCCH_CTRL_RSRC_SET_ONE_ID;
416 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
418 initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc[idx] =\
420 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
421 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
422 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
423 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
424 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
426 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
429 initDlBwp->pdcchCfg.numCRsetToRel = 0;
430 /* Filling Serach Space */
431 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
432 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
433 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
435 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
436 PDCCH_SRCH_SPC_TWO_ID;
437 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
438 PDCCH_CTRL_RSRC_SET_ONE_ID;
439 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
440 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
441 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
442 MONITORING_SYMB_WITHIN_SLOT_SIZE);
443 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
444 PDCCH_SYMBOL_WITHIN_SLOT;
445 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
447 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
449 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
451 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
453 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
455 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
456 SEARCHSPACETYPE_PR_UE_SPECIFIC;
457 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
458 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
460 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
464 /* Filling PDSCH Config */
465 initDlBwp->pdschPresent = TRUE;
466 if(initDlBwp->pdschPresent)
468 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
469 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
470 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
471 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
473 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
474 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
475 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
476 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
477 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
478 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
479 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
485 /******************************************************************
487 * @brief Fills Initial UL Bandwidth Part
491 * Function : fillInitUlBwp
493 * Functionality: Fills Initial UL Bandwidth Part
496 *****************************************************************/
497 void fillInitUlBwp(InitialUlBwp *initUlBwp)
502 initUlBwp->pucchPresent = FALSE;
504 /*Filling PUSCH Config */
505 initUlBwp->puschPresent = TRUE;
506 if(initUlBwp->puschPresent)
508 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
509 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
510 scramblingId0 = SCRAMBLING_ID;
511 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
512 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
514 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
516 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
517 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
519 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
520 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
521 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
522 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
524 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
529 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
533 /******************************************************************
535 * @brief Fills SpCell Group Info
539 * Function : fillSpCellGrpInfo
541 * Functionality: Fills Sp Cell Group Info
544 *****************************************************************/
545 void fillSpCellGrpInfo(SpCellCfg *spCell)
549 spCell->servCellIdx = SERV_CELL_IDX;
550 /* Filling Initial Dl Bwp */
551 fillInitDlBwp(&spCell->servCellCfg.initDlBwp);
553 spCell->servCellCfg.numDlBwpToAdd = 0;
554 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
555 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
556 spCell->servCellCfg.bwpInactivityTmr = NULLP;
557 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
558 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
559 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
560 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
561 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
562 NUM_HARQ_PROC_FOR_PDSCH_N_16;
563 /* Filling Initial UL Bwp*/
564 fillInitUlBwp(&spCell->servCellCfg.initUlBwp);
565 spCell->servCellCfg.numUlBwpToAdd = 0;
566 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
570 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
574 /******************************************************************
576 * @brief Fills Physical Cell Group Info
580 * Function : fillPhyCellGrpInfo
582 * Functionality: Fills Physical Cell Group Info
585 *****************************************************************/
586 void fillPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
590 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
591 cellGrp->pNrFr1 = P_NR_FR1;
595 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
599 /******************************************************************
601 * @brief Fills Mac Cell Group Info
605 * Function : fillMacCellGrpInfo
607 * Functionality: Fills Mac Cell Group Info
610 *****************************************************************/
611 void fillMacCellGrpInfo(MacCellGrpCfg *cellGrp)
617 /* Filling Scheduling Request Config */
618 cellGrp->schReqCfg.addModListCount = 1;
619 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
621 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
623 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
624 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
625 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
628 cellGrp->schReqCfg.relListCount = 0;
630 /* Filling Tag config */
631 cellGrp->tagCfg.addModListCount = 1;
632 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
634 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
636 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
637 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
640 cellGrp->tagCfg.relListCount = 0;
642 /* Filling BSR config */
643 cellGrp->bsrTmrCfg.periodicTimer = PERIODIC_BSR_TMR;
644 cellGrp->bsrTmrCfg.retxTimer = RETX_BSR_TMR;
645 cellGrp->bsrTmrCfg.srDelayTimer = SR_DELAY_TMR;
647 /* Filling PHR config */
648 cellGrp->phrCfgSetupPres = true;
649 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
650 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
651 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
652 cellGrp->phrCfg.multiplePHR = false;
653 cellGrp->phrCfg.dummy = false;
654 cellGrp->phrCfg.phrType2OtherCell = false;
655 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
660 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
664 /******************************************************************
666 * @brief Fills Logical Channel Config List
670 * Function : fillLcCfgList
672 * Functionality: Fills Logical channel Config List
675 *****************************************************************/
676 void fillLcCfgList(LcCfg *lcCfgInfo)
680 lcCfgInfo->lcId = SRB_ID_1;
681 lcCfgInfo->drbQos = NULLP;
682 lcCfgInfo->snssai = NULLP;
683 lcCfgInfo->ulLcCfg = NULLP;
684 lcCfgInfo->dlLcCfg.lcp = LC_PRIORITY_1;
687 /* TODO: To be filled on receving UE CONTEXT SETUP from CU */
688 /* Filling Qos characteristics */
689 lcCfgInfo->drbQos.fiveQiType = QoS_Characteristics_PR_non_Dynamic_5QI;
690 lcCfgInfo->drbQos.u.nonDyn5Qi.fiveQi = 0;
691 lcCfgInfo->drbQos.u.nonDyn5Qi.priorLevel = 0;
692 lcCfgInfo->drbQos.u.nonDyn5Qi.avgWindow = 0;
693 lcCfgInfo->drbQos.u.nonDyn5Qi.maxDataBurstVol = 0;
696 lcCfgInfo->drbQos.ngRanRetPri.priorityLevel = PriorityLevel_highest;
697 lcCfgInfo->drbQos.ngRanRetPri.preEmptionCap = \
698 Pre_emptionCapability_may_trigger_pre_emption;
699 lcCfgInfo->drbQos.ngRanRetPri.preEmptionVul = \
700 Pre_emptionVulnerability_not_pre_emptable;
702 /* Filling Grb Qos */
703 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateDl = 0;
704 lcCfgInfo->drbQos.grbQosInfo.maxFlowBitRateUl = 0;
705 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateDl = 0;
706 lcCfgInfo->drbQos.grbQosInfo.guarFlowBitRateUl = 0;
708 /* Filling S-NSSAI */
709 /* TODO :To be filled when UE Context Setup Request is sent from CU */
710 /* Filling UL Logical Channel Config */
711 lcCfgInfo->ulLcCfg.priority = 0;
712 lcCfgInfo->ulLcCfg.lcGroup = 0;
713 lcCfgInfo->ulLcCfg.schReqId = 0;
714 lcCfgInfo->ulLcCfg.pbr = 0;
715 lcCfgInfo->ulLcCfg.bsd = 0;
717 /* Filling DL Logical Channel Config */
718 lcCfgInfo->dlLcCfg.lcp = 0;
723 DU_LOG("\n Memory is null for LcCfgList");
727 /******************************************************************
729 * @brief Fills MacUeCfg structure
733 * Function : fillMacUeCfg
735 * Functionality: Fills MacUeCfg
738 *****************************************************************/
739 void fillMacUeCfg(uint16_t cellId, uint8_t ueIdx,\
740 uint16_t crnti, MacUeCfg *ueCfg)
743 ueCfg->cellId = cellId;
744 ueCfg->ueIdx = ueIdx;
745 ueCfg->crnti = crnti;
746 /* Filling MacCellGroup Config */
747 fillMacCellGrpInfo(&ueCfg->macCellGrpCfg);
748 /* Filling PhyCellGroup Config */
749 fillPhyCellGrpInfo(&ueCfg->phyCellGrpCfg);
750 /* Filling SpCellGroup Config */
751 fillSpCellGrpInfo(&ueCfg->spCellCfg);
752 /* Filling AMBR for UL and DL */
753 ueCfg->maxAggrBitRate = NULLP;
754 /* Filling LC Context */
755 ueCfg->numLcs = SRB_ID_1;
756 if(ueCfg->numLcs < MAX_NUM_LOGICAL_CHANNELS)
758 for(idx = 0; idx < ueCfg->numLcs; idx++)
760 fillLcCfgList(&ueCfg->lcCfgList[idx]);
766 /******************************************************************
768 * @brief Fills Rlc AM Information
772 * Function : fillAmInfo
774 * Functionality: Fills Rlc AM Information
777 *****************************************************************/
778 void fillAmInfo(AmBearerCfg *amCfg)
781 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
782 amCfg->dlAmCfg.pollRetxTmr = POLL_RETX_TMR_45MS;
783 amCfg->dlAmCfg.pollPdu = POLL_PDU_TMR_INFINITY;
784 amCfg->dlAmCfg.pollByte = POLL_BYTES_INFINITY;
785 amCfg->dlAmCfg.maxRetxTh = RETX_TH_8;
788 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
789 amCfg->ulAmCfg.reAssemTmr = RE_ASM_40MS;
790 amCfg->ulAmCfg.statProhTmr = PROH_35MS;
794 /******************************************************************
796 * @brief Fills RLC UM Bi Directional Information
800 * Function : fillUmBiDirInfo
802 * Functionality: Fills RLC UM Bi Directional Information
805 *****************************************************************/
806 void fillUmBiDirInfo(UmBiDirBearerCfg *umBiDirCfg)
808 /* UL UM BI DIR INFO */
809 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
810 umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
812 /* DL UM BI DIR INFO */
813 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
817 /******************************************************************
819 * @brief Fills RLC UM Uni Directional UL Information
823 * Function : fillUmUniDirUlInfo
825 * Functionality: Fills RLC UM Uni Directional Info
828 *****************************************************************/
829 void fillUmUniDirUlInfo(UmUniDirUlBearerCfg *umUniDirUlCfg)
831 umUniDirUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
832 umUniDirUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
835 /******************************************************************
837 * @brief Fills RLC UM Uni Directional DL Information
841 * Function : fillUmUniDirDlInfo
843 * Functionality: Fills RLC UM Uni Directional DL Info
846 *****************************************************************/
847 void fillUmUniDirDlInfo(UmUniDirDlBearerCfg *umUniDirDlCfg)
849 umUniDirDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
852 /******************************************************************
854 * @brief Fills RlcBearerCfg structure
858 * Function : fillRlcBearerCfg
860 * Functionality: Fills Rlc Bearer Cfg
863 *****************************************************************/
864 void fillRlcBearerCfg(uint16_t cellId, uint8_t ueIdx, RlcUeCfg *ueCfg)
867 ueCfg->cellId = cellId;
868 ueCfg->ueIdx = ueIdx;
869 ueCfg->numLcs = SRB_ID_1;
871 for(idx = 0; idx < ueCfg->numLcs; idx++)
873 ueCfg->rlcBearerCfg[idx].rbId = RB_ID_SRB;
874 ueCfg->rlcBearerCfg[idx].rbType = RB_TYPE_SRB;
875 ueCfg->rlcBearerCfg[idx].lcId = SRB_ID_1;
876 ueCfg->rlcBearerCfg[idx].lcType = LCH_DCCH;
877 ueCfg->rlcBearerCfg[idx].rlcMode = RLC_AM;
878 switch(ueCfg->rlcBearerCfg[idx].rlcMode)
881 memset(&ueCfg->rlcBearerCfg[idx].u.amCfg, 0, sizeof(AmBearerCfg));
882 fillAmInfo(&ueCfg->rlcBearerCfg[idx].u.amCfg);
884 case RLC_UM_BI_DIRECTIONAL:
885 memset(&ueCfg->rlcBearerCfg[idx].u.umBiDirCfg, 0, sizeof(UmBiDirBearerCfg));
886 fillUmBiDirInfo(&ueCfg->rlcBearerCfg[idx].u.umBiDirCfg);
888 case RLC_UM_UNI_DIRECTIONAL_UL:
889 memset(&ueCfg->rlcBearerCfg[idx].u.umUniDirUlCfg, 0, sizeof(UmUniDirUlBearerCfg));
890 fillUmUniDirUlInfo(&ueCfg->rlcBearerCfg[idx].u.umUniDirUlCfg);
892 case RLC_UM_UNI_DIRECTIONAL_DL:
893 memset(&ueCfg->rlcBearerCfg[idx].u.umUniDirDlCfg, 0, sizeof(UmUniDirDlBearerCfg));
894 fillUmUniDirDlInfo(&ueCfg->rlcBearerCfg[idx].u.umUniDirDlCfg);
897 DU_LOG("\nDU_APP: Rlc Mode invalid %d", ueCfg->rlcBearerCfg[idx].rlcMode);
903 /******************************************************************
905 * @brief creates UE context
909 * Function : duCreateUeCb
911 * Functionality: Creates UE Conetxt
913 * @params[in] UeCcchCtxt Pointer
916 * @return ROK - success
918 * ****************************************************************/
919 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
925 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
927 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
929 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
930 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
932 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
933 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
934 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
936 /* Filling Mac Ue Config */
937 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg, 0, sizeof(MacUeCfg));
938 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
939 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].macUeCfg);
941 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
943 /* Filling Rlc Ue Config */
944 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, 0, sizeof(RlcUeCfg));
945 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
946 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg);
948 DU_LOG("\nDU_APP: Failed to send UE create request to RLC");
950 duCb.actvCellLst[cellIdx]->numActvUes++;
951 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
957 /******************************************************************
959 * @brief Builds and Send UE Create Request to MAC
963 * Function : duBuildAndSendUeCreateReqToMac
965 * Functionality: Builds and Send UE Create Request to MAC
967 * @Params[in] cellId,
969 * @return ROK - success
972 * ****************************************************************/
974 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
975 uint16_t crnti, MacUeCfg *duMacUeCfg)
978 MacUeCfg *macUeCfg = NULLP;
980 memset(&pst, 0, sizeof(Pst));
982 fillMacUeCfg(cellId, ueIdx, crnti, duMacUeCfg);
985 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
987 /* Copying ueCb to a sharable buffer */
988 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
991 memset(macUeCfg, 0, sizeof(MacUeCfg));
992 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx].macUeCfg, sizeof(MacUeCfg));
993 DU_LOG("\nDU_APP: Sending UE create request to MAC");
994 /* Processing one Ue at a time to MAC */
995 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
998 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC");
999 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1005 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1011 /*******************************************************************
1013 * @brief Handle UE create response from MAC
1017 * Function : DuHandleMacUeCreateRsp
1019 * Functionality: Handle UE create response from MAC
1021 * @params[in] Pointer to MacUeCfgRsp and Pst
1022 * @return ROK - success
1025 * ****************************************************************/
1026 uint8_t DuHandleMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
1028 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
1030 DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1034 DU_LOG("\nDU APP : MAC UE Create Response : FAILURE [UE IDX : %d]", cfgRsp->ueIdx);
1039 /*******************************************************************
1041 * @brief Processes UE create Req to RLC UL
1045 * Function : duBuildAndSendUeCreateReqToRlc
1048 * Processes UE create Req to RLC UL
1050 * @params[in] cellId,
1052 * Pointer to RlcUeCfg
1053 * @return ROK - success
1056 *****************************************************************/
1058 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx, RlcUeCfg *duRlcUeCfg)
1061 RlcUeCfg *rlcUeCfg = NULLP;
1063 memset(&pst, 0, sizeof(Pst));
1065 fillRlcBearerCfg(cellId, ueIdx, duRlcUeCfg);
1066 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UL_UE_CREATE_REQ);
1068 /* Copying ueCfg to a sharable buffer */
1069 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
1072 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1073 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
1074 /* Processing one Ue at a time to RLC */
1075 DU_LOG("\nDU_APP: Sending UE create request to RLC UL");
1076 ret = (*packRlcUlUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
1079 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to RLC");
1080 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1086 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
1094 /*******************************************************************
1096 * @brief Processes UE create Rsp received from RLC UL
1100 * Function : DuProcRlcUlUeCfgRsp
1103 * Processes UE create Rsp received from RLC UL
1105 * @params[in] Post structure
1106 * Pointer to RlcCfgCfm
1107 * @return ROK - success
1110 *****************************************************************/
1112 uint8_t DuProcRlcUlUeCreateRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
1118 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
1120 DU_LOG("\nDU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
1124 DU_LOG("\nDU_APP: RLC UE Create Response : FAILED [UE IDX:%d, REASON :%d]",\
1125 cfgRsp->ueIdx, cfgRsp->reason);
1128 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
1132 DU_LOG("\nDU_APP: Received RLC Ue Create Response is NULL");
1137 /**********************************************************************
1139 ***********************************************************************/