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 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
59 packDuRlcUeCreateReq, /* Loose coupling */
60 RlcProcUeCreateReq, /* TIght coupling */
61 packDuRlcUeCreateReq /* Light weight-loose coupling */
64 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
66 packDlRrcMsgToRlc, /* Loose coupling */
67 RlcProcDlRrcMsgTransfer, /* Tight coupling */
68 packDlRrcMsgToRlc /* Light weight-loose coupling */
71 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
73 packDuRlcUeReconfigReq, /* Loose coupling */
74 RlcProcUeReconfigReq, /* TIght coupling */
75 packDuRlcUeReconfigReq /* Light weight-loose coupling */
78 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
80 packDuMacUeReconfigReq, /* Loose coupling */
81 MacProcUeReconfigReq, /* TIght coupling */
82 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 /*******************************************************************
86 * @brief Handles EGTP data from CU
90 * Function : duHdlEgtpData
93 * Processes EGTP header and sends data to RLC
95 * @params[in] Pointer to EGTP Message
96 * @return ROK - success
99 * ****************************************************************/
100 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
103 /* TODO : Extract RbId/UeID/CellID/SduId from database
104 using tunnel id in egtp header */
106 DU_LOG("\nDU_APP : Processing DL data");
109 KwuDatReqInfo datReqInfo;
111 datReqInfo.rlcId.rbId = RB_ID;
112 datReqInfo.rlcId.rbType = CM_LTE_DRB;
113 datReqInfo.rlcId.ueId = UE_ID;
114 datReqInfo.rlcId.cellId = NR_CELL_ID;
116 datReqInfo.sduId = ++sduId;
117 datReqInfo.lcType = CM_LTE_LCH_DTCH;
119 /* Filling pst and Sending to RLC DL */
120 pst.selector = ODU_SELECTOR_LWLC;
121 pst.srcEnt = ENTDUAPP;
123 pst.dstInst = RLC_DL_INST;
124 pst.dstProcId = DU_PROC;
125 pst.srcProcId = DU_PROC;
126 pst.region = duCb.init.region;
128 cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
130 //duBuildAndSendDlRrcMsgToRlc();
135 /******************************************************************
137 * @brief Builds and Sends DL CCCH Ind to MAC
141 * Function : duBuildAndSendDlCcchInd
143 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
145 * @params[in] dlCcchMsg - uint8_t*
146 * @return ROK - success
149 * ****************************************************************/
150 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
151 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
155 DlCcchIndInfo *dlCcchIndInfo = NULLP;
158 DU_LOG("\nDU APP : Building and Sending DL CCCH Ind to MAC");
160 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
164 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
168 dlCcchIndInfo->cellId = *cellId;
169 dlCcchIndInfo->crnti = *crnti;
170 dlCcchIndInfo->msgType = msgType;
171 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
173 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
174 if(!dlCcchIndInfo->dlCcchMsg)
176 DU_LOG("\nDU APP : Memory alloc failed while building DL CCCH Ind");
177 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
180 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
182 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
184 DU_FREE(dlCcchMsg, dlCcchMsgSize);
187 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
188 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
191 DU_LOG("\nDU_APP : Failure in sending DL CCCH to MAC");
192 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
193 dlCcchIndInfo->dlCcchMsgLen);
194 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
195 sizeof(DlCcchIndInfo));
203 /*******************************************************************
205 * @brief Build and Send DL RRC Message transfer to RLC
209 * Function : duBuildAndSendDlRrcMsgToRlc
212 * Build and Send DL RRC Message transfer to RLC
214 * @params[in] Cell ID
216 * Logical Channgel ID
219 * @return ROK - success
222 * ****************************************************************/
223 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, \
224 uint8_t lcId, bool execDup, bool deliveryStaReq, uint16_t rrcMsgLen, uint8_t *rrcMsg)
229 RlcDlRrcMsgInfo *dlRrcMsgInfo;
231 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
234 DU_LOG("\nDU APP : Memory allocation failed for dlRrcMsgInfo in \
235 duBuildAndSendDlRrcMsgToRlc");
236 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rrcMsg, rrcMsgLen);
240 /* Filling up the RRC msg info */
241 dlRrcMsgInfo->cellId = cellId;
242 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
243 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
245 if(ueCfg.rlcLcCfg[lcIdx].lcId == lcId)
247 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
248 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
249 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
250 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
254 dlRrcMsgInfo->execDup = execDup;
255 dlRrcMsgInfo->deliveryStaRpt = deliveryStaReq;
256 dlRrcMsgInfo->rrcMsg = rrcMsg;
257 dlRrcMsgInfo->msgLen = rrcMsgLen;
259 /* Filling post structure and sending msg */
260 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
261 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
264 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rrcMsg, rrcMsgLen);
265 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
274 /******************************************************************
276 * @brief Processes DL RRC Message Transfer sent by CU
280 * Function : procDlRrcMsgTrans
282 * Functionality: Processes DL RRC Message Transfer sent by CU
284 * @params[in] F1AP_PDU_t ASN decoded F1AP message
285 * @return ROK - success
288 * ****************************************************************/
289 uint8_t procDlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
291 DLRRCMessageTransfer_t *dlRrcMsg = NULLP;
292 uint8_t *rrcMsgPdu = NULLP;
293 uint8_t ieIdx, ueIdx, cellIdx;
295 uint16_t byteIdx, crnti, cellId, rrcMsgSize;
296 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
297 bool execDup = false;
298 bool deliveryStaRpt = false;
299 bool ueFound = false;
300 bool ueCcchCtxtFound = false;
302 DU_LOG("\nDU_APP : DL RRC message transfer Recevied");
304 dlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
308 for(ieIdx=0; ieIdx<dlRrcMsg->protocolIEs.list.count; ieIdx++)
310 switch(dlRrcMsg->protocolIEs.list.array[ieIdx]->id)
312 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
314 gnbCuUeF1apId = dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
317 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
319 gnbDuUeF1apId = dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
322 case ProtocolIE_ID_id_SRBID:
324 srbId = dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.SRBID;
327 case ProtocolIE_ID_id_ExecuteDuplication:
332 case ProtocolIE_ID_id_RRCContainer:
334 if(dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size > 0)
336 rrcMsgSize = dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size;
337 DU_ALLOC(rrcMsgPdu, rrcMsgSize);
340 DU_LOG("\nDU_APP : Memory allocation failed in procDlRrcMsgTrans");
343 for(byteIdx = 0; byteIdx < rrcMsgSize; byteIdx++)
345 rrcMsgPdu[byteIdx] = \
346 dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf[byteIdx];
351 DU_LOG("\nDU_APP : RRC Container Size is invalid:%ld",\
352 dlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
357 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
359 deliveryStaRpt = true;
363 DU_LOG("\nDU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
364 dlRrcMsg->protocolIEs.list.array[ieIdx]->id);
368 if(srbId == SRB1_LCID) //RRC connection setup
370 for(ueIdx=0; ueIdx < duCb.numUe; ueIdx++)
372 if(gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
374 ueCcchCtxtFound = true;
375 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
376 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
383 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, rrcMsgSize, rrcMsgPdu);
386 DU_LOG("\nDU_APP: Falied to build DlCcch Ind at procDlRrcMsgTrans()");
390 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
392 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], gnbCuUeF1apId);
395 DU_LOG("\nDU_APP: Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
396 duCb.ueCcchCtxt[ueIdx].cellId);
402 DU_LOG("\nDU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
409 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
411 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
413 if((gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
414 && (gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
417 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
418 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, srbId, \
419 execDup, deliveryStaRpt, rrcMsgSize, rrcMsgPdu);
432 /******************************************************************
434 * @brief Generates GNB DU Ue F1AP ID
438 * Function : genGnbDuUeF1apId
440 * Functionality: Generates GNB DU Ue F1AP ID
443 * @return gnbDuF1apId
445 * ****************************************************************/
446 uint32_t genGnbDuUeF1apId()
448 static uint32_t gnbDuUeF1apId = 0;
450 return ++gnbDuUeF1apId;
453 /******************************************************************
455 * @brief Processes UL CCCH Ind recvd from MAC
459 * Function : duProcUlCcchInd
461 * Functionality: Processes UL CCCH Ind recvd from MAC
463 * @params[in] UlCcchIndInfo *ulCcchIndInfo
464 * @return ROK - success
467 * ****************************************************************/
468 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
472 uint32_t gnbDuUeF1apId = 0;
474 gnbDuUeF1apId = genGnbDuUeF1apId();
476 /* Store Ue mapping */
477 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
478 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
479 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
483 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
484 ulCcchIndInfo->ulCcchMsg));
487 DU_LOG("\nDU_APP : BuildAndSendInitialRrcMsgTransfer failed");
490 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
491 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
497 /******************************************************************
499 * @brief Fills Default UL LC Cfg
503 * Function : fillDefaultUlLcCfg
505 * Functionality: Fills Default UL LC Cfg
507 * @params[in] UlLcCfg *ulLcCfg
509 *****************************************************************/
510 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
512 ulLcCfg->priority = LC_PRIORITY_1;
513 ulLcCfg->lcGroup = 0;
514 ulLcCfg->schReqId = 0;
515 ulLcCfg->pbr = PBR_KBPS_INFINITY;
516 ulLcCfg->bsd = BSD_MS_1000;
519 /******************************************************************
521 * @brief Fills Initial DL Bandwidth Part
525 * Function : fillDefaultInitDlBwp
527 * Functionality: Fills Initial DL Bandwidth Part
529 * @params[in] InitialDlBwp *initDlBwp
532 *****************************************************************/
533 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
536 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
537 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
542 /* Filling PDCCH Config */
543 initDlBwp->pdcchPresent = TRUE;
544 if(initDlBwp->pdcchPresent)
546 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
547 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
548 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
550 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
551 PDCCH_CTRL_RSRC_SET_ONE_ID;
552 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
554 coreset0EndPrb = CORESET0_END_PRB;
555 coreset1StartPrb = coreset0EndPrb +6;
556 coreset1NumPrb = CORESET1_NUM_PRB;
557 /* calculate the PRBs */
558 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
559 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
562 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
563 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
564 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
565 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
566 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
568 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
571 initDlBwp->pdcchCfg.numCRsetToRel = 0;
572 /* Filling Serach Space */
573 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
574 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
575 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
577 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
578 PDCCH_SRCH_SPC_TWO_ID;
579 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
580 PDCCH_CTRL_RSRC_SET_ONE_ID;
581 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
582 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
583 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
584 MONITORING_SYMB_WITHIN_SLOT_SIZE);
585 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
586 PDCCH_SYMBOL_WITHIN_SLOT;
587 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
589 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
591 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
593 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
595 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
597 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
598 SEARCHSPACETYPE_PR_UE_SPECIFIC;
599 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
600 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
602 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
606 /* Filling PDSCH Config */
607 initDlBwp->pdschPresent = TRUE;
608 if(initDlBwp->pdschPresent)
610 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
611 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
612 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
613 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
615 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
616 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
617 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
618 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
619 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
620 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
621 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
622 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
628 /******************************************************************
630 * @brief Fills Initial UL Bandwidth Part
634 * Function : fillDefaultInitUlBwp
636 * Functionality: Fills Initial UL Bandwidth Part
638 * @params[in] InitialUlBwp *initUlBwp
641 *****************************************************************/
642 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
647 initUlBwp->pucchPresent = FALSE;
649 /*Filling PUSCH Config */
650 initUlBwp->puschPresent = TRUE;
651 if(initUlBwp->puschPresent)
653 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
654 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
655 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
656 scramblingId0 = SCRAMBLING_ID;
657 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
658 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
660 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
662 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
663 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
665 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
666 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
667 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
668 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
670 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
675 DU_LOG("\n DUAPP: Memory is NULL of InitalUlBwp");
679 /******************************************************************
681 * @brief Fills SpCell Group Info
685 * Function : fillDefaultSpCellGrpInfo
687 * Functionality: Fills Sp Cell Group Info
689 * @params[in] SpCellCfg *spCell
692 *****************************************************************/
693 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
697 spCell->servCellIdx = SERV_CELL_IDX;
698 /* Filling Initial Dl Bwp */
699 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
701 spCell->servCellCfg.numDlBwpToAdd = 0;
702 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
703 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
704 spCell->servCellCfg.bwpInactivityTmr = NULLP;
705 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
706 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
707 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
708 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
709 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
710 NUM_HARQ_PROC_FOR_PDSCH_N_16;
711 /* Filling Initial UL Bwp*/
712 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
713 spCell->servCellCfg.numUlBwpToAdd = 0;
714 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
718 DU_LOG("\n DU_APP: Memory is NULL for SpCellGrp");
722 /******************************************************************
724 * @brief Fills Physical Cell Group Info
728 * Function : fillDefaultPhyCellGrpInfo
730 * Functionality: Fills Physical Cell Group Info
732 * @params[in] PhyCellGrpCfg *cellGrp
735 *****************************************************************/
736 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
740 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
741 cellGrp->pNrFr1 = P_NR_FR1;
745 DU_LOG("\nDUAPP: Memory is NULL for Physical Cell Group");
749 /******************************************************************
751 * @brief Fills Mac Cell Group Info
755 * Function : fillDefaultMacCellGrpInfo
757 * Functionality: Fills Mac Cell Group Info
759 * @params[in] MacCellGrpCfg *cellGrp
762 *****************************************************************/
763 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
769 /* Filling Scheduling Request Config */
770 cellGrp->schReqCfg.addModListCount = 1;
771 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
773 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
775 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
776 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
777 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
780 cellGrp->schReqCfg.relListCount = 0;
782 /* Filling Tag config */
783 cellGrp->tagCfg.addModListCount = 1;
784 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
786 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
788 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
789 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
792 cellGrp->tagCfg.relListCount = 0;
794 /* Filling BSR config */
795 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
796 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
797 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
799 /* Filling PHR config */
800 cellGrp->phrCfgSetupPres = true;
801 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
802 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
803 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
804 cellGrp->phrCfg.multiplePHR = false;
805 cellGrp->phrCfg.dummy = false;
806 cellGrp->phrCfg.phrType2OtherCell = false;
807 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
812 DU_LOG("\nDUAPP: Memory is NULL for Master Cell Group");
816 /******************************************************************
818 * @brief Function to fill Mac Lc Cfg for SRB1
822 * Function : fillMacSrb1LcCfg
824 * Functionality: Function to fill Mac Lc cfg for SRB1
826 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
828 *****************************************************************/
830 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
832 macLcCfg->lcId = SRB1_LCID;
833 macLcCfg->configType = CONFIG_ADD;
834 macLcCfg->drbQos = NULLP;
835 macLcCfg->snssai = NULLP;
836 macLcCfg->ulLcCfgPres = true;
837 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
840 /******************************************************************
842 * @brief Function to fill the Lc cfg from ueSetupReqDb
846 * Function : fillMacLcCfgToAddMod
848 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
850 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
851 * @return ROK/RFAILED
853 *****************************************************************/
855 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
858 lcCfg->lcId = ueSetReqDb->lcId;
859 lcCfg->configType = ueSetReqDb->configType;
861 if(ueSetReqDb->drbQos)
865 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
868 DU_LOG("\nDU APP: Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
874 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
879 lcCfg->drbQos = NULLP;
884 if(ueSetReqDb->snssai)
888 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
891 DU_LOG("\nDU APP: Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
898 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
902 lcCfg->snssai = NULLP;
905 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
906 lcCfg->drbQos = NULLP;
912 lcCfg->snssai = NULLP;
914 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
915 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
916 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
920 /******************************************************************
922 * @brief Function to copy the Bit rate from ueSetupReqDb
926 * Function : getMaxAggrBitRate
928 * Functionality: Function to copy bit Rate from ueSetupReqDb
930 * @params[in] MaxAggrBitRate *macBitRate, MaxAggrBitRate *ueDbBitRate
931 * @return ROK/RFAILED
933 *****************************************************************/
935 uint8_t getMaxAggrBitRate(MaxAggrBitRate *macBitRate, MaxAggrBitRate *ueDbBitRate)
941 DU_ALLOC_SHRABL_BUF(macBitRate, sizeof(MaxAggrBitRate));
944 DU_LOG("\nDUAPP: Memory Alloc Failed at getMaxAggrBitRate()");
948 memcpy(macBitRate, ueDbBitRate, sizeof(MaxAggrBitRate));
957 /******************************************************************
959 * @brief Builds and Send UE ReConfig Request to MAC
963 * Function : sendUeReCfgReqToMac
965 * Functionality: Builds and Send UE ReConfig Request to MAC
967 * @Params[in] MacUeCfg pointer
968 * @return ROK - success
971 * ****************************************************************/
973 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
979 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
983 /* Processing one Ue at a time to MAC */
984 DU_LOG("\nDU_APP: Sending Reconfig Request to MAC");
985 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
988 DU_LOG("\nDU_APP: Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
989 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
994 DU_LOG("\n DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1000 /******************************************************************
1002 * @brief Function to return Drb LcId
1006 * Function : getDrbLcId
1008 * Functionality: Function to return Drb LcId
1010 * Returns: lcId - SUCCESS
1012 *****************************************************************/
1014 uint8_t getDrbLcId(uint32_t *drbBitMap)
1016 uint8_t bitMask = 1, bitPos = 0;
1017 bitPos = MIN_DRB_LCID;
1019 while(bitPos <= MAX_DRB_LCID)
1021 if((*drbBitMap & (bitMask << bitPos)) == 0)
1023 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1031 DU_LOG("\nDU_APP: Max LC Reached in getDrbLcId()");
1035 /******************************************************************
1037 * @brief Fills MacUeCfg structure
1041 * Function : fillMacUeCfg
1043 * Functionality: Fills MacUeCfg
1045 * @params[in] cellId, ueIdx, crnti,
1046 * UeContextSetupDb pointer,
1048 * @return ROK/RFAILED
1050 *****************************************************************/
1051 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1052 UeContextSetupDb *ueCfgDb, MacUeCfg *macUeCfg)
1054 uint8_t ret, dbIdx, lcIdx, cellIdx;
1055 bool lcIdFound = false;
1056 MacUeCfg *duMacDb = NULLP;
1062 macUeCfg->cellId = cellId;
1063 macUeCfg->ueIdx = ueIdx;
1064 macUeCfg->crnti = crnti;
1065 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1066 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1067 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1068 macUeCfg->maxAggrBitRate = NULLP;
1069 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1074 /* Fetching MacDb from DuUeCb */
1075 GET_CELL_IDX(cellId, cellIdx);
1076 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1077 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1078 macUeCfg->cellId = cellId;
1079 macUeCfg->ueIdx = ueIdx;
1080 macUeCfg->crnti = crnti;
1081 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1084 ret = getMaxAggrBitRate(macUeCfg->maxAggrBitRate, ueCfgDb->duUeCfg.maxAggrBitRate);
1087 /* Filling LC Context */
1088 for(dbIdx = 0; (dbIdx < ueCfgDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1090 if(!ueCfgDb->duUeCfg.macLcCfg[dbIdx].ulLcCfgPres)
1092 /* Filling default UL LC config in MAC if not present */
1093 ueCfgDb->duUeCfg.macLcCfg[dbIdx].ulLcCfgPres = true;
1094 fillDefaultUlLcCfg(&ueCfgDb->duUeCfg.macLcCfg[dbIdx].ulLcCfg);
1096 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1098 if(ueCfgDb->duUeCfg.macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1101 if((ueCfgDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1102 (ueCfgDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD))
1104 ueCfgDb->duUeCfg.macLcCfg[dbIdx].configType = CONFIG_MOD;
1105 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->duUeCfg.macLcCfg[dbIdx]);
1113 /* ADD/DEL CONFIG */
1114 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->duUeCfg.macLcCfg[dbIdx]);
1122 DU_LOG("\n DU_APP: Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1125 }/*End of Outer FOR loop */
1130 /******************************************************************
1132 * @brief Fills Rlc AM Information
1136 * Function : fillDefaultAmInfo
1138 * Functionality: Fills Rlc AM Information
1140 * @params[in] AmBearerCfg *amCfg
1143 *****************************************************************/
1144 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1147 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1148 amCfg->dlAmCfg.pollRetxTmr = POLL_RETX_TMR_45MS;
1149 amCfg->dlAmCfg.pollPdu = POLL_PDU_TMR_INFINITY;
1150 amCfg->dlAmCfg.pollByte = POLL_BYTES_INFINITY;
1151 amCfg->dlAmCfg.maxRetxTh = RETX_TH_8;
1154 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1155 amCfg->ulAmCfg.reAssemTmr = RE_ASM_40MS;
1156 amCfg->ulAmCfg.statProhTmr = PROH_35MS;
1159 /******************************************************************
1161 * @brief Fills RLC UM Bi Directional Information
1165 * Function : fillDefaultUmBiInfo
1167 * Functionality: Fills RLC UM Bi Directional Information
1169 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1172 *****************************************************************/
1173 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1175 /* UL UM BI DIR INFO */
1176 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1177 umBiDirCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1179 /* DL UM BI DIR INFO */
1180 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1183 /******************************************************************
1185 * @brief Fills RLC UM Uni Directional UL Information
1189 * Function : fillDefaultUmUlInfo
1191 * Functionality: Fills RLC UM Uni Directional Info
1193 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1196 *****************************************************************/
1197 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1199 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1200 UmUlCfg->ulUmCfg.reAssemTmr = RE_ASM_40MS;
1203 /******************************************************************
1205 * @brief Fills RLC UM Uni Directional DL Information
1209 * Function : fillDefaultUmDlInfo
1211 * Functionality: Fills RLC UM Uni Directional DL Info
1213 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1216 *****************************************************************/
1217 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1219 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1222 /******************************************************************
1224 * @brief Builds Rlc Mode Default Configuration
1228 * Function : fillDefaultRlcModeCfg
1230 * Functionality: Builds Rlc Mode Default Configuration
1232 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1233 * @return ROK/RFAILED
1235 *****************************************************************/
1237 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1248 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1250 fillDefaultAmInfo(lcCfg->u.amCfg);
1253 DU_LOG("\n DU_APP: Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1259 case RLC_UM_BI_DIRECTIONAL :
1261 if(!lcCfg->u.umBiDirCfg)
1263 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1264 if(lcCfg->u.umBiDirCfg)
1265 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1268 DU_LOG("\n DU_APP: Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1274 case RLC_UM_UNI_DIRECTIONAL_UL :
1276 if(!lcCfg->u.umUniDirUlCfg)
1278 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1279 if(lcCfg->u.umUniDirUlCfg)
1280 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1283 DU_LOG("\n DU_APP: Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1289 case RLC_UM_UNI_DIRECTIONAL_DL :
1291 if(!lcCfg->u.umUniDirDlCfg)
1293 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1294 if(lcCfg->u.umUniDirDlCfg)
1295 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1298 DU_LOG("\n DU_APP: Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1305 DU_LOG("\nDUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1312 DU_LOG("\nDUAPP: Received Lc Config is NULL");
1318 /*******************************************************************
1320 * @brief Function to fill Rlc Lc Cfg for SRB1
1324 * Function : fillRlcSrb1LcCfg
1327 * Function to fill Rlc Lc Cfg for SRB1
1329 * @params[in] Pointer to RlcBearerCfg
1330 * @return ROK/RFAILED
1332 *****************************************************************/
1334 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1338 rlcLcCfg->rbId = SRB1_LCID;
1339 rlcLcCfg->rbType = RB_TYPE_SRB;
1340 rlcLcCfg->lcId = SRB1_LCID;
1341 rlcLcCfg->lcType = LCH_DCCH;
1342 rlcLcCfg->rlcMode = RLC_AM;
1343 rlcLcCfg->configType = CONFIG_ADD;
1344 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1348 /*******************************************************************
1350 * @brief Processes UE ReConfig Req to RLC UL
1354 * Function : sendUeReCfgReqToRlc
1357 * Processes UE Reconfig Req to RLC UL
1359 * @params[in] Pointer to RlcUeCfg
1360 * @return ROK - success
1363 *****************************************************************/
1365 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1370 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1373 /* Processing one Ue at a time to RLC */
1374 DU_LOG("\nDU_APP: Sending Reconfig Request to RLC UL");
1375 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1378 DU_LOG("\nDU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1379 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1384 DU_LOG("\n DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1390 /******************************************************************
1392 * @brief Fills RlcBearerCfg structure
1396 * Function : fillRlcUeCfg
1398 * Functionality: Fills Rlc Bearer Cfg
1401 *****************************************************************/
1402 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1403 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1405 uint8_t ret, dbIdx, lcIdx, cellIdx;
1406 bool lcIdFound = false;
1407 RlcUeCfg *duRlcDb = NULLP;
1412 /* Initial RB being Added */
1413 rlcUeCfg->cellId = cellId;
1414 rlcUeCfg->ueIdx = ueIdx;
1415 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1419 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1423 /* Fetch RlcDb from DuUeCb */
1424 GET_CELL_IDX(cellId, cellIdx);
1425 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1426 /*Filling RlcUeCfg */
1427 rlcUeCfg->cellId = cellId;
1428 rlcUeCfg->ueIdx = ueIdx;
1429 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1431 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1434 DU_LOG("\n DU_APP: Failed to fill Rlc Mode at fillRlcUeCfg()");
1435 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1438 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1439 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1441 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1444 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1445 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1448 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1449 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1457 /* ADD/ DEL Config Type */
1458 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1466 /******************************************************************
1468 * @brief creates UE context
1472 * Function : duCreateUeCb
1474 * Functionality: Creates UE Conetxt
1476 * @params[in] UeCcchCtxt Pointer
1479 * @return ROK - success
1481 * ****************************************************************/
1482 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1484 uint8_t cellIdx = 0;
1488 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1490 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1492 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1493 DU_LOG("\nDU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1495 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1496 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1497 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1498 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1499 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1500 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1502 /* Filling Mac Ue Config */
1503 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1504 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1505 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1507 DU_LOG("\nDU_APP: Failed to send UE create request to MAC");
1509 /* Filling Rlc Ue Config */
1510 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1511 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1512 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1514 DU_LOG("\nDU_APP: Failed to send UE create request to RLC");
1516 duCb.actvCellLst[cellIdx]->numActvUes++;
1517 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1523 /******************************************************************
1525 * @brief Builds and Send UE Create Request to MAC
1529 * Function : duBuildAndSendUeCreateReqToMac
1531 * Functionality: Builds and Send UE Create Request to MAC
1533 * @Params[in] cellId,
1535 * @return ROK - success
1538 * ****************************************************************/
1540 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1541 uint16_t crnti, MacUeCfg *duMacUeCfg)
1545 MacUeCfg *macUeCfg = NULLP;
1547 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1550 DU_LOG("\nDU APP: Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1554 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1556 /* Copying ueCb to a sharable buffer */
1557 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1560 memset(macUeCfg, 0, sizeof(MacUeCfg));
1561 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1562 DU_LOG("\nDU_APP: Sending UE create request to MAC");
1564 /* Processing one Ue at a time to MAC */
1565 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1568 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1569 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1574 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1580 /*******************************************************************
1582 * @brief To update DuUeCb Mac Cfg
1586 * Function : duUpdateMacCfg
1587 * Functionality: update DuUeCb MAC Cfg
1589 * @params[in] DuUeCb Pointer
1590 * UeContextSetupDb pointer
1591 * @return ROK - success
1594 * ****************************************************************/
1595 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, UeContextSetupDb *f1UeDb)
1597 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1600 /*Filling Cell Group Cfg*/
1601 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->cellGrpCfg);
1604 ret = getMaxAggrBitRate(macUeCfg->maxAggrBitRate, f1UeDb->duUeCfg.maxAggrBitRate);
1606 /* Filling LC Context */
1607 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1609 numLcs = macUeCfg->numLcs;
1610 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1612 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1614 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1616 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1618 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1620 /* Free memory at matched lcIdx index */
1621 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1623 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1625 /* moving all elements one index ahead */
1626 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1627 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1630 DU_LOG("\nDU_APP: Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1637 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1639 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1642 DU_LOG("\nDU_APP: Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1652 /******************************************************************
1654 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1658 * Function : fillRlcCfgToAddMod
1660 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1663 *****************************************************************/
1665 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1667 lcCfg->configType = f1UeDbLcCfg->configType;
1668 lcCfg->rbId = f1UeDbLcCfg->rbId;
1669 lcCfg->rbType = f1UeDbLcCfg->rbType;
1670 lcCfg->lcId = f1UeDbLcCfg->lcId;
1671 lcCfg->lcType = f1UeDbLcCfg->lcType;
1672 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1673 switch(lcCfg->rlcMode)
1679 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1684 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1685 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1686 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1687 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1688 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1691 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1692 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1693 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1696 case RLC_UM_BI_DIRECTIONAL :
1698 if(!lcCfg->u.umBiDirCfg)
1700 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1701 if(!lcCfg->u.umBiDirCfg)
1704 /* UL UM BI DIR INFO */
1705 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1706 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1707 /* DL UM BI DIR INFO */
1708 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1711 case RLC_UM_UNI_DIRECTIONAL_UL :
1713 if(!lcCfg->u.umUniDirUlCfg)
1715 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1716 if(!lcCfg->u.umUniDirUlCfg)
1719 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1720 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1724 case RLC_UM_UNI_DIRECTIONAL_DL :
1726 if(!lcCfg->u.umUniDirDlCfg)
1728 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1729 if(!lcCfg->u.umUniDirDlCfg)
1732 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1736 DU_LOG("\nDU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1742 /*******************************************************************
1744 * @brief To update DuUeCb Rlc Lc Cfg
1748 * Function : duUpdateRlcLcCfg
1749 * Functionality: update DuUeCb Rlc Lc Cfg
1751 * @params[in] DuUeCb Pointer
1752 * UeContextSetupDb pointer
1753 * @return ROK - success
1756 * ****************************************************************/
1758 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, UeContextSetupDb *f1UeDb)
1760 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1763 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1765 numLcs = rlcUeCfg->numLcs;
1766 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1768 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1770 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1772 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1774 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1776 /* Free memory at matched lcIdx index */
1777 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1779 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1781 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1782 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1785 DU_LOG("\nDU_APP: Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1792 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1794 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1803 /*******************************************************************
1805 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
1810 * Function : duUpdateDuUeCbCfg
1812 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
1814 * @params[in] ueIdx, cellIdx
1815 * @return ROK - success
1818 * ****************************************************************/
1820 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
1822 uint8_t ret = ROK, cellIdx = 0, crnti=0;
1823 DuUeCb *ueCb = NULLP;
1825 GET_CELL_IDX(cellId, cellIdx);
1827 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
1828 macUeCfgState == UE_RECFG_COMPLETE) &&
1829 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
1830 rlcUeCfgState == UE_RECFG_COMPLETE))
1832 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
1834 /*Filling RLC Ue Cfg */
1835 ueCb->rlcUeCfg.cellId = cellId;
1836 ueCb->rlcUeCfg.ueIdx = ueIdx;
1837 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
1840 /*Filling MAC Ue Cfg */
1841 GET_CRNTI(crnti, ueIdx);
1842 ueCb->macUeCfg.cellId = cellId;
1843 ueCb->macUeCfg.ueIdx = ueIdx;
1844 ueCb->macUeCfg.crnti = crnti;
1845 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
1847 DU_LOG("\nDU APP: Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
1850 DU_LOG("\nDU APP: Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
1857 /*******************************************************************
1859 * @brief Handle UE config response from MAC
1863 * Function : DuProcMacUeCfgRsp
1865 * Functionality: Handle UE Config response from MAC
1867 * @params[in] Pointer to MacUeCfgRsp and Pst
1868 * @return ROK - success
1871 * ****************************************************************/
1872 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
1878 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
1880 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
1882 DU_LOG("\nDU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1883 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1884 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
1886 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1888 DU_LOG("\nDU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
1889 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
1890 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
1891 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
1892 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
1897 DU_LOG("\nDU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
1898 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
1900 //TODO: Send the failure case in Ue Context Setup Response
1904 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
1908 DU_LOG("\nDU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
1915 /*******************************************************************
1917 * @brief Processes UE create Req to RLC UL
1921 * Function : duBuildAndSendUeCreateReqToRlc
1924 * Processes UE create Req to RLC UL
1926 * @params[in] cellId,
1928 * Pointer to RlcUeCfg
1929 * @return ROK - success
1932 *****************************************************************/
1934 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
1935 RlcUeCfg *duRlcUeCfg)
1938 RlcUeCfg *rlcUeCfg = NULLP;
1941 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
1944 DU_LOG("\nDU_APP: Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
1948 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
1949 /* Copying ueCfg to a sharable buffer */
1950 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
1953 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1954 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
1955 /* Processing one Ue at a time to RLC */
1956 DU_LOG("\nDU_APP: Sending UE create request to RLC UL");
1957 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
1960 DU_LOG("\nDU_APP : Failure in sending Ue Create Req to RLC");
1961 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1967 DU_LOG("\n DU_APP: Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
1973 /*******************************************************************
1975 * @brief Processes UE create Rsp received from RLC UL
1980 * Function : DuProcRlcUeCfgRsp
1983 * Processes UE create Rsp received from RLC UL
1985 * @params[in] Post structure
1986 * Pointer to RlcCfgCfm
1987 * @return ROK - success
1990 *****************************************************************/
1991 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
1997 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
1999 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2001 DU_LOG("\nDU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2002 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2003 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2005 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2007 DU_LOG("\nDU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2008 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2009 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2010 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2011 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2017 DU_LOG("\nDU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2018 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2019 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2021 //TODO: update failure case in ue Context setup Response
2025 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2029 DU_LOG("\nDU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2035 /*******************************************************************
2037 * @brief Builds and Send Ue Reconfig Req to RLC
2041 * Function : duBuildAndSendUeReCfgReqToRLC
2043 * Functionality: Builds and Send Ue Reconfig Req to RLC
2045 * @params[in] cellId, crnti
2047 * RlcUeCfg *rlcUeCfg
2048 * @return ROK - success
2051 * ****************************************************************/
2053 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2055 uint8_t ret = ROK, ueIdx = 0;
2056 RlcUeCfg *rlcUeCfg = NULLP;
2058 GET_UE_IDX(crnti, ueIdx);
2059 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2062 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2063 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2065 DU_LOG("\nDU APP: Failed at duBuildAndSendUeReCfgReqToRlc()");
2067 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2071 DU_LOG("\nDU APP: Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2077 /*******************************************************************
2079 * @brief Builds and Send Ue Reconfig Req to MAC
2083 * Function : duBuildAndSendUeReCfgReqToMac
2085 * Functionality: Builds and Send Ue Reconfig Req to MAC
2087 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2089 * MacUeCfg *macUeCfg
2090 * @return ROK - success
2093 * ****************************************************************/
2095 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, UeContextSetupDb *ueCfgDb)
2097 uint8_t ret, ueIdx = 0;
2098 MacUeCfg *macUeCfg = NULLP;
2101 GET_UE_IDX(crnti, ueIdx);
2103 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2106 memset(macUeCfg, 0, sizeof(MacUeCfg));
2107 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2109 DU_LOG("\nDU_APP: Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2111 ret = sendUeReCfgReqToMac(macUeCfg);
2115 DU_LOG("\nDU_APP: Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2121 /*******************************************************************
2123 * @brief Process UE context setup request from CU
2127 * Function : duProcUeContextSetupRequest
2129 * Functionality: Process UE context setup request from CU
2131 * @params[in] F1AP message
2132 * @return ROK - success
2135 * ****************************************************************/
2137 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2139 uint8_t ret, cellId;
2144 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2146 if(ueCb->f1UeDb->rrcMsg)
2148 /* Sending DL RRC Message to RLC */
2149 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, SRB1_LCID, false, \
2150 ueCb->f1UeDb->deliveryStaReq, ueCb->f1UeDb->rrcMsgLen, ueCb->f1UeDb->rrcMsg);
2153 DU_LOG("\nDU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2154 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->rrcMsg, ueCb->f1UeDb->rrcMsgLen);
2160 DU_LOG("\nDU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2161 /* Filling RLC Ue Reconfig */
2162 ret = duBuildAndSendUeReCfgReqToRlc(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2164 DU_LOG("\nDU_APP: Failed to build ctxt setup req for RLC at duBuildAndSendUeReCfgReqToRlc()");
2166 /* Filling MAC Ue Reconfig */
2167 ret = duBuildAndSendUeReCfgReqToMac(cellId, ueCb->crnti, ueCb->f1UeDb);
2169 DU_LOG("\nDU_APP: Failed at build ctxt setup req for MAC at duBuildAndSendUeReCfgReqToMac()");
2175 //TODO: To send the failure cause in UeContextSetupRsp
2176 DU_LOG("DU_APP: Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2181 /**********************************************************************
2183 ***********************************************************************/