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"
34 #include "du_f1ap_msg_hdl.h"
35 #include "du_ue_mgr.h"
38 #include "AlarmInterface.h"
39 #include "CmInterface.h"
42 DuMacDlCcchInd packMacDlCcchIndOpts[] =
44 packMacDlCcchInd, /* Loose coupling */
45 MacProcDlCcchInd, /* TIght coupling */
46 packMacDlCcchInd /* Light weight-loose coupling */
49 DuMacUeCreateReq packMacUeCreateReqOpts[] =
51 packDuMacUeCreateReq, /* Loose coupling */
52 MacProcUeCreateReq, /* TIght coupling */
53 packDuMacUeCreateReq /* Light weight-loose coupling */
56 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
58 packDuRlcUeCreateReq, /* Loose coupling */
59 RlcProcUeCreateReq, /* TIght coupling */
60 packDuRlcUeCreateReq /* Light weight-loose coupling */
63 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
65 packDlRrcMsgToRlc, /* Loose coupling */
66 RlcProcDlRrcMsgTransfer, /* Tight coupling */
67 packDlRrcMsgToRlc /* Light weight-loose coupling */
70 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
72 packDuRlcUeReconfigReq, /* Loose coupling */
73 RlcProcUeReconfigReq, /* TIght coupling */
74 packDuRlcUeReconfigReq /* Light weight-loose coupling */
77 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
79 packDuMacUeReconfigReq, /* Loose coupling */
80 MacProcUeReconfigReq, /* TIght coupling */
81 packDuMacUeReconfigReq /* Light weight-loose coupling */
84 DuMacRachRsrcReq packMacRachRsrcReqOpts[] =
86 packDuMacRachRsrcReq, /* Loose coupling */
87 MacProcRachRsrcReq, /* Tight coupling */
88 packDuMacRachRsrcReq /* Light weight-loose coupling */
91 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
93 packRlcDlUserDataToRlc, /* Loose coupling */
94 RlcProcDlUserDataTransfer, /* Tight coupling */
95 packRlcDlUserDataToRlc /* Light weight-loose coupling */
98 DuMacRachRsrcRel packMacRachRsrcRelOpts[] =
100 packDuMacRachRsrcRel, /* Loose coupling */
101 MacProcRachRsrcRel, /* Tight coupling */
102 packDuMacRachRsrcRel /* Light weight-loose coupling */
105 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
107 packDuMacUeDeleteReq, /* Loose coupling */
108 MacProcUeDeleteReq, /* TIght coupling */
109 packDuMacUeDeleteReq /* Light weight-loose coupling */
112 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
114 packDuRlcUeDeleteReq, /* Loose coupling */
115 RlcProcUeDeleteReq, /* TIght coupling */
116 packDuRlcUeDeleteReq /* Light weight-loose coupling */
119 DuMacUeResetReq packMacUeResetReqOpts[] =
121 packDuMacUeResetReq, /* Loose coupling */
122 MacProcUeResetReq, /* TIght coupling */
123 packDuMacUeResetReq /* Light weight-loose coupling */
125 /******************************************************************
127 * @brief Function to return Drb LcId
131 * Function : getDrbLcId
133 * Functionality: Function to return Drb LcId
135 * @params[in] drbBitMap
137 * Returns: lcId - SUCCESS
139 *****************************************************************/
141 uint8_t getDrbLcId(uint32_t *drbBitMap)
143 uint8_t bitMask = 1, bitPos = 0;
144 bitPos = MIN_DRB_LCID;
146 while(bitPos <= MAX_DRB_LCID)
148 if((*drbBitMap & (bitMask << bitPos)) == 0)
150 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
158 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
162 /*******************************************************************
164 * @brief Function to fillDlUserDataInfo
168 * Function : fillDlUserDataInfo
171 * Function to fillDlUserDataInfo
176 * @return ROK - success
179 * ****************************************************************/
181 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
185 /*Traversing the duCb to find the CellId, UeId, LCID corresponding to TEID*/
186 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
188 if(duCb.upTnlCfg[teIdx] && (duCb.upTnlCfg[teIdx]->tnlCfg1 != NULLP))
190 if(duCb.upTnlCfg[teIdx]->tnlCfg1->teId == teId)
192 dlDataMsgInfo->cellId = duCb.upTnlCfg[teIdx]->cellId;
193 dlDataMsgInfo->ueId = duCb.upTnlCfg[teIdx]->ueId;
194 dlDataMsgInfo->rbId = duCb.upTnlCfg[teIdx]->drbId;
202 /*******************************************************************
204 * @brief Build and Send DL Data Message transfer to RLC
208 * Function : duBuildAndSendDlUserDataToRlc
211 * Build and Send DL Data Message transfer to RLC
213 * @params[in] Cell ID
215 * Logical Channgel ID
218 * @return ROK - success
221 * ****************************************************************/
223 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
225 uint8_t ret = RFAILED;
227 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
229 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
232 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
235 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
236 dlDataMsgInfo->dlMsg = egtpMsg->msg;
237 dlDataMsgInfo->msgLen = msgLen;
239 /* Filling DL DATA Msg Info */
240 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
242 /* Filling post structure and sending msg */
243 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
244 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
245 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
246 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
250 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
251 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
252 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
257 /*******************************************************************
259 * @brief Handles EGTP data from CU
263 * Function : duHdlEgtpData
266 * Processes EGTP header and sends data to RLC
268 * @params[in] Pointer to EGTP Message
269 * @return ROK - success
272 * ****************************************************************/
273 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
277 #ifdef CALL_FLOW_DEBUG_LOG
278 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
281 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
285 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
288 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
289 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
291 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
297 /******************************************************************
299 * @brief Builds and Sends DL CCCH Ind to MAC
303 * Function : duBuildAndSendDlCcchInd
305 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
307 * @params[in] dlCcchMsg - uint8_t*
308 * @return ROK - success
311 * ****************************************************************/
312 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
313 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
317 DlCcchIndInfo *dlCcchIndInfo = NULLP;
320 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
322 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
326 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
330 dlCcchIndInfo->cellId = *cellId;
331 dlCcchIndInfo->crnti = *crnti;
332 dlCcchIndInfo->msgType = msgType;
333 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
335 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
336 if(!dlCcchIndInfo->dlCcchMsg)
338 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
339 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
342 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
344 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
346 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
349 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
350 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
353 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
354 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
355 dlCcchIndInfo->dlCcchMsgLen);
356 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
357 sizeof(DlCcchIndInfo));
365 /*******************************************************************
367 * @brief Build and Send DL RRC Message transfer to RLC
371 * Function : duBuildAndSendDlRrcMsgToRlc
374 * Build and Send DL RRC Message transfer to RLC
376 * @params[in] Cell ID
378 * Logical Channgel ID
381 * @return ROK - success
384 * ****************************************************************/
385 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, DuRlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
390 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
394 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
398 /*As per Spec ORAN WG8 AAD, lcId for DL RRC range from 1...3*/
399 if((f1DlRrcMsg->srbId < SRB1_LCID) || (f1DlRrcMsg->srbId > SRB3_LCID))
401 DU_LOG("\nERROR --> DU APP : Received SRBID for this Dl RRC Msg is not valid");
405 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
409 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
410 duBuildAndSendDlRrcMsgToRlc");
411 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
415 /* Filling up the RRC msg info */
416 dlRrcMsgInfo->cellId = cellId;
417 dlRrcMsgInfo->ueId = ueCfg.ueId;
418 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
420 if(ueCfg.rlcLcCfg[lcIdx].rlcBearerCfg.lcId == f1DlRrcMsg->srbId)
422 dlRrcMsgInfo->lcId = f1DlRrcMsg->srbId;
426 if(lcIdx == (MAX_NUM_LC + 1))
428 DU_LOG("\nERROR --> DU APP : (duBuildAndSendDlRrcMsgToRlc) SRB for this DL_RRC msg is not configured.");
429 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
433 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
434 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
435 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
436 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
438 /* Filling post structure and sending msg */
439 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
440 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
441 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
444 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
445 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
454 /******************************************************************
456 * @brief Process DL RRC Msg recevied from F1AP
460 * Function : duProcDlRrcMsg
462 * Functionality: Process DL RRC Msg recevied from F1AP
464 * @params[in] dlCcchMsg - uint8_t*
465 * @return ROK - success
468 * ****************************************************************/
470 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
473 uint16_t crnti, cellId, cellIdx;
474 bool ueCcchCtxtFound = false;
475 bool ueFound = false;
479 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
481 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
483 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
485 ueCcchCtxtFound = true;
486 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
487 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
494 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
497 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
501 if(duCb.actvCellLst[cellId-1] == NULLP)
503 DU_LOG("\nERROR --> DU APP : cellId [%d] does not exist", cellId);
506 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
508 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
511 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
512 duCb.ueCcchCtxt[ueIdx].cellId);
517 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
524 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
526 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
528 if(duCb.actvCellLst[cellIdx] && (dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
529 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
532 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
533 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg, dlRrcMsg);
536 DU_LOG("\nERROR --> DU_APP: duBuildAndSendDlRrcMsgToRlc() Failed for UE ID:%d", dlRrcMsg->gnbDuUeF1apId);
547 DU_LOG("\nERROR --> DU_APP: UE ID [%d] not found", dlRrcMsg->gnbDuUeF1apId);
554 /******************************************************************
556 * @brief Processes UL CCCH Ind recvd from MAC
560 * Function : duProcUlCcchInd
562 * Functionality: Processes UL CCCH Ind recvd from MAC
564 * @params[in] UlCcchIndInfo *ulCcchIndInfo
565 * @return ROK - success
568 * ****************************************************************/
569 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
573 int32_t gnbDuUeF1apId = 0;
575 if(ulCcchIndInfo->crnti)
577 GET_UE_ID(ulCcchIndInfo->crnti, gnbDuUeF1apId);
581 DU_LOG("\nERROR --> DU_APP : Received invalid CRNTI [%d] ", ulCcchIndInfo->crnti);
585 /* Store Ue mapping */
586 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
587 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
588 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
592 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
593 ulCcchIndInfo->ulCcchMsg));
596 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
599 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
600 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
606 /******************************************************************
608 * @brief Fills Default UL LC Cfg
612 * Function : fillDefaultUlLcCfg
614 * Functionality: Fills Default UL LC Cfg
616 * @params[in] UlLcCfg *ulLcCfg
618 *****************************************************************/
619 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
621 ulLcCfg->priority = LC_PRIORITY_1;
622 ulLcCfg->lcGroup = 0;
623 ulLcCfg->schReqId = 0;
624 ulLcCfg->pbr = PBR_KBPS_INFINITY;
625 ulLcCfg->bsd = BSD_MS_1000;
628 /******************************************************************
630 * @brief Fills Initial DL Bandwidth Part
634 * Function : fillDefaultInitDlBwp
636 * Functionality: Fills Initial DL Bandwidth Part
638 * @params[in] InitialDlBwp *initDlBwp
639 * @return ROK - success
642 *****************************************************************/
643 uint8_t fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
646 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
647 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
651 /* Filling PDCCH Config */
652 initDlBwp->pdcchPresent = TRUE;
653 if(initDlBwp->pdcchPresent)
655 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
656 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
657 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
659 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
660 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0, FREQ_DOM_RSRC_SIZE);
661 coreset0EndPrb = CORESET0_END_PRB;
662 coreset1StartPrb = coreset0EndPrb +6;
663 coreset1NumPrb = CORESET1_NUM_PRB;
664 /* calculate the PRBs */
665 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
666 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource, FREQ_DOM_RSRC_SIZE);
668 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
669 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
670 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = ALL_CONTIGUOUS_RBS;
671 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = SCRAMBLING_ID;
673 initDlBwp->pdcchCfg.numCRsetToRel = 0;
675 /* Filling Serach Space */
676 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
677 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
678 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
680 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
681 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
682 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
683 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0, MONITORING_SYMB_WITHIN_SLOT_SIZE);
684 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] = PDCCH_SYMBOL_WITHIN_SLOT;
685 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 = AGGREGATIONLEVEL_N8;
686 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 = AGGREGATIONLEVEL_N8;
687 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 = AGGREGATIONLEVEL_N4;
688 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 = AGGREGATIONLEVEL_N2;
689 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 = AGGREGATIONLEVEL_N1;
690 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = SEARCHSPACETYPE_PR_UE_SPECIFIC;
691 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
693 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
696 /* Filling PDSCH Config */
697 initDlBwp->pdschPresent = TRUE;
698 if(initDlBwp->pdschPresent)
700 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
701 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
703 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = NUM_TIME_DOM_RSRC_ALLOC;
706 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
707 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
708 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
709 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
712 DU_ALLOC_SHRABL_BUF(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0, sizeof(uint8_t));
713 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0 == NULLP)
715 DU_LOG("\nERROR --> DUAPP : Failed to allocate memory to K0 in fillDefaultInitDlBwp");
718 if(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0)
720 *(initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].k0) = 1;
722 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = MAPPING_TYPEA;
723 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
724 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
725 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
727 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
728 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
729 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
730 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
737 /******************************************************************
739 * @brief Fills Initial UL Bandwidth Part
743 * Function : fillDefaultInitUlBwp
745 * Functionality: Fills Initial UL Bandwidth Part
747 * @params[in] InitialUlBwp *initUlBwp
750 *****************************************************************/
751 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
756 initUlBwp->pucchPresent = FALSE;
758 /*Filling PUSCH Config */
759 initUlBwp->puschPresent = TRUE;
760 if(initUlBwp->puschPresent)
762 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
763 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
764 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
765 scramblingId0 = SCRAMBLING_ID;
766 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
767 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
769 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
771 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
772 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
774 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
775 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
776 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
777 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
780 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
781 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
782 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
783 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
784 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
785 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
787 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
792 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
796 /******************************************************************
798 * @brief Fills SpCell Group Info
802 * Function : fillDefaultSpCellGrpInfo
804 * Functionality: Fills Sp Cell Group Info
806 * @params[in] DuMacUeCfg *macUeCfg
807 * @return ROK - Success
810 *****************************************************************/
811 uint8_t fillDefaultSpCellGrpInfo(DuMacUeCfg *macUeCfg)
813 SpCellRecfg *spCell = NULL;
816 spCell = &macUeCfg->spCellCfg;
820 macUeCfg->spCellCfgPres = true;
822 spCell->servCellIdx = SERV_CELL_IDX;
823 /* Filling Initial Dl Bwp */
824 if((fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp)) != ROK)
826 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultInitDlBwp");
830 spCell->servCellCfg.numDlBwpToAddOrMod = 0;
831 spCell->servCellCfg.numDlBwpToRel = 0;
832 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
833 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
834 spCell->servCellCfg.bwpInactivityTmr = NULLP;
835 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
836 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
837 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
838 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
839 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch = NUM_HARQ_PROC_FOR_PDSCH_N_16;
841 /* Filling Initial UL Bwp*/
842 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
843 spCell->servCellCfg.numUlBwpToAddOrMod = 0;
844 spCell->servCellCfg.numUlBwpToRel = 0;
845 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
849 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
855 /******************************************************************
857 * @brief Fills Physical Cell Group Info
861 * Function : fillDefaultPhyCellGrpInfo
863 * Functionality: Fills Physical Cell Group Info
865 * @params[in] DuMacUeCfg *macUeCfg
868 *****************************************************************/
869 void fillDefaultPhyCellGrpInfo(DuMacUeCfg *macUeCfg)
871 PhyCellGrpCfg *cellGrp = NULL;
874 cellGrp = &macUeCfg->phyCellGrpCfg;
878 macUeCfg->phyCellGrpCfgPres = true;
879 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
880 cellGrp->pNrFr1 = P_NR_FR1;
884 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
888 /******************************************************************
890 * @brief Fills Mac Cell Group Info
894 * Function : fillDefaultMacCellGrpInfo
896 * Functionality: Fills Mac Cell Group Info
898 * @params[in] DuMacUeCfg *macUeCfg
901 *****************************************************************/
902 void fillDefaultMacCellGrpInfo(DuMacUeCfg *macUeCfg)
905 MacCellGrpCfg *cellGrp = NULL;
908 cellGrp = &macUeCfg->macCellGrpCfg;
912 macUeCfg->macCellGrpCfgPres = true;
914 /* Filling Scheduling Request Config */
915 cellGrp->schReqCfg.addModListCount = 1;
916 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
918 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
920 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
921 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
922 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
925 cellGrp->schReqCfg.relListCount = 0;
927 /* Filling Tag config */
928 cellGrp->tagCfg.addModListCount = 1;
929 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
931 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
933 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
934 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
937 cellGrp->tagCfg.relListCount = 0;
939 /* Filling BSR config */
940 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
941 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
942 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
944 /* Filling PHR config */
945 cellGrp->phrCfgSetupPres = true;
946 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
947 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
948 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
949 cellGrp->phrCfg.multiplePHR = false;
950 cellGrp->phrCfg.dummy = false;
951 cellGrp->phrCfg.phrType2OtherCell = false;
952 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
954 /* Filling Drx Config */
956 cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs = DRX_ONDURATION_TIMER_VALUE_PRESENT_IN_MS;
957 if(!cellGrp->drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
958 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = \
959 DRX_ONDURATION_TIMER_VALUE_IN_SUBMS;
961 cellGrp->drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds = \
962 DRX_ONDURATION_TIMER_VALUE_IN_MS;
963 cellGrp->drxCfg.drxInactivityTimer = DRX_INACTIVITY_TIMER;
964 cellGrp->drxCfg.drxHarqRttTimerDl = DRX_HARQ_RTT_TIMER_DL;
965 cellGrp->drxCfg.drxHarqRttTimerUl = DRX_HARQ_RTT_TIMER_UL;
966 cellGrp->drxCfg.drxRetransmissionTimerDl = DRX_RETRANSMISSION_TIMER_DL;
967 cellGrp->drxCfg.drxRetransmissionTimerUl = DRX_RETRANSMISSION_TIMER_UL;
968 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetVal = DRX_LONG_CYCLE_START_OFFSET_VAL;
969 cellGrp->drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = DRX_LONG_CYCLE_START_OFFSET_CHOICE;
970 cellGrp->drxCfg.shortDrxPres = DRX_SHORT_CYCLE_PRESENT;
971 if(cellGrp->drxCfg.shortDrxPres)
973 cellGrp->drxCfg.shortDrx.drxShortCycle = DRX_SHORT_CYCLE;
974 cellGrp->drxCfg.shortDrx.drxShortCycleTimer = DRX_SHORT_CYCLE_TIMER;
976 cellGrp->drxCfg.drxSlotOffset = DRX_SLOT_OFFSET;
982 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
986 /*******************************************************************
988 * @brief Fills default modulation info for a UE
992 * Function : fillDefaultModulation
994 * Functionality: Fills default modulation info for a UE
996 * @params[in] Pointer to MAC UE configuration
997 * @return ROK - success
1000 * ****************************************************************/
1001 void fillDefaultModulation(DuMacUeCfg *ueCfg)
1003 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
1004 ueCfg->dlModInfo.mcsIndex = DEFAULT_MCS;
1005 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1007 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
1008 ueCfg->ulModInfo.mcsIndex = DEFAULT_MCS;
1009 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1012 /******************************************************************
1014 * @brief Function to fill Mac Lc Cfg for SRB1
1018 * Function : fillMacSrb1LcCfg
1020 * Functionality: Function to fill Mac Lc cfg for SRB1
1022 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1024 *****************************************************************/
1026 void fillMacSrb1LcCfg(DuLcCfg *macLcCfg)
1028 macLcCfg->lcConfig.lcId = SRB1_LCID;
1029 macLcCfg->configType = CONFIG_ADD;
1030 macLcCfg->lcConfig.drbQos = NULLP;
1031 macLcCfg->lcConfig.snssai = NULLP;
1032 macLcCfg->lcConfig.ulLcCfgPres = true;
1033 fillDefaultUlLcCfg(&macLcCfg->lcConfig.ulLcCfg);
1036 /******************************************************************
1038 * @brief Function to fill the Lc cfg from ueSetupReqDb
1042 * Function : fillMacLcCfgToAddMod
1044 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1046 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1047 * @return ROK/RFAILED
1049 *****************************************************************/
1051 uint8_t fillMacLcCfgToAddMod(DuLcCfg *macLcCfgToSend, DuLcCfg *ueLcCfgDb, DuLcCfg *oldLcCfg, Bool toUpdate)
1057 macLcCfgToSend->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1058 macLcCfgToSend->configType = ueLcCfgDb->configType;
1060 if(ueLcCfgDb->lcConfig.drbQos)
1061 macLcCfgToSend->lcConfig.drbQos = ueLcCfgDb->lcConfig.drbQos;
1063 macLcCfgToSend->lcConfig.drbQos = oldLcCfg->lcConfig.drbQos;
1065 macLcCfgToSend->lcConfig.drbQos = NULL;
1067 if(ueLcCfgDb->lcConfig.snssai)
1068 macLcCfgToSend->lcConfig.snssai = ueLcCfgDb->lcConfig.snssai;
1070 macLcCfgToSend->lcConfig.snssai = oldLcCfg->lcConfig.snssai;
1072 macLcCfgToSend->lcConfig.snssai = NULL;
1074 macLcCfgToSend->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1075 memcpy(&macLcCfgToSend->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1076 memcpy(&macLcCfgToSend->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1081 oldLcCfg->lcConfig.lcId = ueLcCfgDb->lcConfig.lcId;
1082 oldLcCfg->configType = ueLcCfgDb->configType;
1084 if(ueLcCfgDb->lcConfig.drbQos)
1086 if(oldLcCfg->lcConfig.drbQos)
1087 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1089 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1090 if(oldLcCfg->lcConfig.drbQos == NULL)
1092 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1095 memcpy(oldLcCfg->lcConfig.drbQos, ueLcCfgDb->lcConfig.drbQos, sizeof(DrbQosInfo));
1098 if(ueLcCfgDb->lcConfig.snssai)
1100 if(oldLcCfg->lcConfig.snssai)
1101 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1103 DU_ALLOC_SHRABL_BUF(oldLcCfg->lcConfig.snssai, sizeof(Snssai));
1104 if(oldLcCfg->lcConfig.snssai == NULL)
1106 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1107 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->lcConfig.drbQos, sizeof(DrbQosInfo));
1110 memcpy(oldLcCfg->lcConfig.snssai, ueLcCfgDb->lcConfig.snssai, sizeof(Snssai));
1113 oldLcCfg->lcConfig.ulLcCfgPres = ueLcCfgDb->lcConfig.ulLcCfgPres;
1114 memcpy(&oldLcCfg->lcConfig.ulLcCfg, &ueLcCfgDb->lcConfig.ulLcCfg, sizeof(UlLcCfg));
1115 memcpy(&oldLcCfg->lcConfig.dlLcCfg, &ueLcCfgDb->lcConfig.dlLcCfg, sizeof(DlLcCfg));
1120 /******************************************************************
1122 * @brief Function to copy the Bit rate from ueSetupReqDb
1126 * Function : fillAmbr
1128 * Functionality: Function to copy bit Rate from ueSetupReqDb
1130 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1131 * @return ROK/RFAILED
1133 *****************************************************************/
1135 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1141 *macAmbrCfgToSend = ueDbAmbr;
1143 else if(oldMacAmbrCfg)
1144 *macAmbrCfgToSend = *oldMacAmbrCfg;
1154 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1156 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1157 if(*oldMacAmbrCfg == NULLP)
1159 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1162 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1163 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1171 /******************************************************************
1173 * @brief Builds and Send UE ReConfig Request to MAC
1177 * Function : sendUeRecfgReqToMac
1179 * Functionality: Builds and Send UE ReConfig Request to MAC
1181 * @Params[in] MacUeRecfg pointer
1182 * @return ROK - success
1185 * ****************************************************************/
1187 uint8_t sendUeRecfgReqToMac(MacUeRecfg *macUeRecfg)
1193 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1197 /* Processing one Ue at a time to MAC */
1198 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1199 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeRecfg);
1202 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeRecfgReqToMac()");
1203 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeRecfg, sizeof(MacUeRecfg));
1208 DU_LOG("\nERROR --> DU_APP: Received macUeRecfg is NULLP at sendUeRecfgReqToMac()");
1216 /******************************************************************
1218 * @brief update DuMacUeCfg structure
1222 * Function : updateDuMacUeCfg
1224 * Functionality: Fills DuMacUeCfg
1226 * @params[in] cellId, ueId, crnti,
1228 * DuMacUeCfg pointer
1229 * @return ROK/RFAILED
1231 *****************************************************************/
1232 uint8_t updateDuMacUeCfg(uint16_t cellId, uint8_t gnbDuUef1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1234 uint8_t ret = ROK, dbIdx = 0, lcIdx = 0, cellIdx = 0;
1235 bool lcIdFound = false;
1236 DuMacUeCfg *duMacDb = NULLP;
1238 duMacUeCfg->cellId = cellId;
1239 duMacUeCfg->ueId = gnbDuUef1apId;
1240 duMacUeCfg->crnti = crnti;
1244 fillDefaultMacCellGrpInfo(duMacUeCfg);
1245 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1247 if((fillDefaultSpCellGrpInfo(duMacUeCfg)) != ROK)
1249 DU_LOG("\nERROR --> DUAPP : Failed in fillDefaultSpCellGrpInfo");
1253 duMacUeCfg->ambrCfg = NULLP;
1254 fillDefaultModulation(duMacUeCfg);
1255 fillMacSrb1LcCfg(&duMacUeCfg->lcCfgList[0]);
1256 duMacUeCfg->numLcs++;
1260 if(ueCfgDb->dataTransmissionAction == STOP_TRANSMISSION)
1262 duMacUeCfg->transmissionAction = ueCfgDb->dataTransmissionAction;
1266 GET_CELL_IDX(cellId, cellIdx);
1267 if(duCb.actvCellLst[cellIdx])
1268 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[duMacUeCfg->ueId-1].duMacUeCfg;
1271 DU_LOG("\nERROR --> DU APP : Cell Id [%d] does not exist", cellId);
1274 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1276 if(ueCfgDb->cellGrpCfg)
1278 ret = procUeRecfgCellInfo(duMacUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1281 if(duMacUeCfg->spCellCfgPres == true)
1283 if(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1285 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1286 &duMacUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1288 if(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1290 fillStartSymbolAndLen(duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1291 NULL, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1296 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1298 ret = fillAmbr(&duMacUeCfg->ambrCfg, ueCfgDb->ambrCfg , NULL, FALSE);
1300 duFillModulationDetails(duMacUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1305 fillDefaultMacCellGrpInfo(duMacUeCfg);
1306 fillDefaultPhyCellGrpInfo(duMacUeCfg);
1307 fillDefaultSpCellGrpInfo(duMacUeCfg);
1308 fillDefaultModulation(duMacUeCfg);
1309 duMacUeCfg->ambrCfg = NULLP;
1314 duMacUeCfg->drxConfigIndicatorRelease = ueCfgDb->drxConfigIndicatorRelease;
1316 if(ueCfgDb->drxCyclePres)
1318 duMacUeCfg->macCellGrpCfg.drxCfg.drxLongCycleStartOffset.drxLongCycleStartOffsetChoice = ueCfgDb->drxCycle.drxLongCycleLength;
1319 if(ueCfgDb->drxCycle.shortDrxCyclePres)
1321 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = true;
1322 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycle = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycle;
1323 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer = ueCfgDb->drxCycle.shortDrxCycle.drxShortCycleTimer;
1327 duMacUeCfg->macCellGrpCfg.drxCfg.shortDrxPres = false;
1332 /* Filling LC Context */
1333 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1335 if(!ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres)
1337 /* Filling default UL LC config in MAC if not present */
1338 ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfgPres = true;
1339 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].lcConfig.ulLcCfg);
1344 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1346 if(ueCfgDb->macLcCfg[dbIdx].lcConfig.lcId == duMacDb->lcCfgList[lcIdx].lcConfig.lcId)
1349 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1350 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1352 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1353 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1354 &duMacDb->lcCfgList[lcIdx], FALSE);
1364 /* ADD/DEL CONFIG */
1365 ret = fillMacLcCfgToAddMod(&duMacUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1369 duMacUeCfg->numLcs++;
1373 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in updateDuMacUeCfg()", dbIdx);
1376 }/*End of Outer FOR loop */
1377 memcpy(&ueCfgDb->copyOfmacUeCfg, duMacUeCfg, sizeof(DuMacUeCfg));
1382 /******************************************************************
1384 * @brief Fills Rlc AM Information
1388 * Function : fillDefaultAmInfo
1390 * Functionality: Fills Rlc AM Information
1392 * @params[in] AmBearerCfg *amCfg
1395 *****************************************************************/
1396 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1399 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1400 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1401 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1402 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1403 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1406 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1407 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1408 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1411 /******************************************************************
1413 * @brief Fills RLC UM Bi Directional Information
1417 * Function : fillDefaultUmBiInfo
1419 * Functionality: Fills RLC UM Bi Directional Information
1421 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1424 *****************************************************************/
1425 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1427 /* UL UM BI DIR INFO */
1428 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1429 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1431 /* DL UM BI DIR INFO */
1432 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1435 /******************************************************************
1437 * @brief Fills RLC UM Uni Directional UL Information
1441 * Function : fillDefaultUmUlInfo
1443 * Functionality: Fills RLC UM Uni Directional Info
1445 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1448 *****************************************************************/
1449 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1451 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1452 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1455 /******************************************************************
1457 * @brief Fills RLC UM Uni Directional DL Information
1461 * Function : fillDefaultUmDlInfo
1463 * Functionality: Fills RLC UM Uni Directional DL Info
1465 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1468 *****************************************************************/
1469 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1471 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1474 /******************************************************************
1476 * @brief Builds Rlc Mode Default Configuration
1480 * Function : fillDefaultRlcModeCfg
1482 * Functionality: Builds Rlc Mode Default Configuration
1484 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1485 * @return ROK/RFAILED
1487 *****************************************************************/
1489 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1499 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1501 fillDefaultAmInfo(lcCfg->u.amCfg);
1504 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1510 case RLC_UM_BI_DIRECTIONAL :
1512 if(!lcCfg->u.umBiDirCfg)
1514 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1515 if(lcCfg->u.umBiDirCfg)
1516 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1519 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1525 case RLC_UM_UNI_DIRECTIONAL_UL :
1527 if(!lcCfg->u.umUniDirUlCfg)
1529 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1530 if(lcCfg->u.umUniDirUlCfg)
1531 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1534 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1540 case RLC_UM_UNI_DIRECTIONAL_DL :
1542 if(!lcCfg->u.umUniDirDlCfg)
1544 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1545 if(lcCfg->u.umUniDirDlCfg)
1546 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1549 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1556 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1563 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1569 /*******************************************************************
1571 * @brief Function to fill Rlc Lc Cfg for SRB1
1575 * Function : fillRlcSrb1LcCfg
1578 * Function to fill Rlc Lc Cfg for SRB1
1580 * @params[in] Pointer to RlcBearerCfg
1581 * @return ROK/RFAILED
1583 *****************************************************************/
1585 uint8_t fillRlcSrb1LcCfg(DuRlcBearerCfg *rlcLcCfg)
1589 rlcLcCfg->rlcBearerCfg.rbId = SRB1_LCID;
1590 rlcLcCfg->rlcBearerCfg.rbType = RB_TYPE_SRB;
1591 rlcLcCfg->rlcBearerCfg.lcId = SRB1_LCID;
1592 rlcLcCfg->rlcBearerCfg.lcType = LCH_DCCH;
1593 rlcLcCfg->rlcBearerCfg.rlcMode = RLC_AM;
1594 rlcLcCfg->configType = CONFIG_ADD;
1595 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcBearerCfg.rlcMode, &rlcLcCfg->rlcBearerCfg);
1596 rlcLcCfg->rlcBearerCfg.isLcAddModRspSent = true;
1600 /*******************************************************************
1602 * @brief Processes UE ReConfig Req to RLC UL
1606 * Function : sendUeRecfgReqToRlc
1609 * Processes UE Reconfig Req to RLC UL
1611 * @params[in] Pointer to RlcUeCfg
1612 * @return ROK - success
1615 *****************************************************************/
1617 uint8_t sendUeRecfgReqToRlc(RlcUeRecfg *rlcUeRecfg)
1622 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1625 /* Processing one Ue at a time to RLC */
1626 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1627 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeRecfg);
1630 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeRecfgReqToRlc()");
1631 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeRecfg, sizeof(RlcUeRecfg));
1636 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeRecfgReqToRlc()");
1642 /******************************************************************
1644 * @brief Fills Snssai information
1648 * Function : fillSnssaiInfo
1650 * Functionality: Fills Snssai information
1652 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1654 * @return ROK - success
1657 *****************************************************************/
1658 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1663 snssaiTobeSend = snssaiDb;
1665 snssaiTobeSend = *oldSnssai;
1667 snssaiTobeSend = NULL;
1674 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1676 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1677 if(*oldSnssai == NULL)
1679 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1682 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1687 /******************************************************************
1689 * @brief Fills RlcBearerCfg structure
1693 * Function : updateRlcUeCfg
1695 * Functionality: Fills Rlc Bearer Cfg
1698 *****************************************************************/
1699 uint8_t updateRlcUeCfg(uint16_t cellId, uint8_t duUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *rlcUeCfg)
1701 uint8_t ret, dbIdx, lcIdx, cellIdx;
1702 bool lcIdFound = false;
1703 DuRlcUeCfg *duRlcDb = NULLP;
1706 rlcUeCfg->cellId = cellId;
1707 rlcUeCfg->ueId = duUeF1apId;
1711 /* Initial RB being Added */
1712 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1716 memset(rlcUeCfg, 0, sizeof(DuRlcUeCfg));
1720 /* Fetch RlcDb from DuUeCb */
1721 GET_CELL_IDX(cellId, cellIdx);
1722 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[rlcUeCfg->ueId-1].duRlcUeCfg;
1723 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1725 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1727 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.rlcMode, &ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg);
1730 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1731 memset(rlcUeCfg, 0, sizeof(DuRlcUeCfg));
1737 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1738 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1740 if(ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.lcId == duRlcDb->rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
1743 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1744 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1747 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1748 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(DuRlcBearerCfg));
1749 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
1750 &duRlcDb->rlcLcCfg[lcIdx].rlcBearerCfg.snssai,false);
1760 /* ADD/ DEL Config Type */
1761 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(DuRlcBearerCfg));
1762 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, ueCfgDb->rlcLcCfg[dbIdx].rlcBearerCfg.snssai, NULL, false);
1770 /******************************************************************
1772 * @brief creates UE context
1776 * Function : duCreateUeCb
1778 * Functionality: Creates UE Conetxt
1780 * @params[in] UeCcchCtxt Pointer
1783 * @return ROK - success
1785 * ****************************************************************/
1786 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1788 uint8_t cellIdx = 0;
1790 uint8_t ueId = 0, ueIdx = 0;
1792 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1794 if(duCb.actvCellLst[cellIdx] && (ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId))
1796 GET_UE_ID(ueCcchCtxt->crnti, ueId);
1797 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueId [%d]", ueId);
1800 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].f1UeDb = NULLP;
1801 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti = ueCcchCtxt->crnti;
1802 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1803 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId = gnbCuUeF1apId;
1804 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].drbBitMap = NULLP;
1805 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState = UE_ACTIVE;
1807 /* Filling Mac Ue Config */
1808 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg, 0, sizeof(DuMacUeCfg));
1809 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, ueCcchCtxt->crnti, NULL,
1810 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duMacUeCfg);
1812 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1814 /* Filling Rlc Ue Config */
1815 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg, 0, sizeof(DuRlcUeCfg));
1816 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueCcchCtxt->gnbDuUeF1apId, NULL,
1817 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg);
1819 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1821 duCb.actvCellLst[cellIdx]->numActvUes++;
1822 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1829 /**********************************************************************************
1831 * @brief Fills Ue Cfg from DU DB to MacUeCfg
1835 * Function : fillMacUeCfg
1837 * Functionality: fills ue Cfg to be sent to MAC
1839 * @params[in] DuMacUeCfg Pointer
1842 * @return ROK - success
1844 * *******************************************************************************/
1845 void fillMacUeCfg(DuMacUeCfg *duMacUeCfg, MacUeCfg *macUeCfg)
1849 macUeCfg->cellId = duMacUeCfg->cellId;
1850 macUeCfg->ueId = duMacUeCfg->ueId;
1851 macUeCfg->crnti = duMacUeCfg->crnti;
1852 macUeCfg->macCellGrpCfgPres = duMacUeCfg->macCellGrpCfgPres;
1853 if(macUeCfg->macCellGrpCfgPres)
1855 memcpy(&macUeCfg->macCellGrpCfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
1857 macUeCfg->phyCellGrpCfgPres = duMacUeCfg->phyCellGrpCfgPres;
1858 if(macUeCfg->phyCellGrpCfgPres)
1860 memcpy(&macUeCfg->phyCellGrpCfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
1862 macUeCfg->spCellCfgPres = duMacUeCfg->spCellCfgPres;
1863 if(macUeCfg->spCellCfgPres)
1865 macUeCfg->spCellCfg.servCellIdx = duMacUeCfg->spCellCfg.servCellIdx;
1866 macUeCfg->spCellCfg.servCellCfg.initDlBwp = duMacUeCfg->spCellCfg.servCellCfg.initDlBwp;
1867 macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numDlBwpToAddOrMod;
1868 if(macUeCfg->spCellCfg.servCellCfg.numDlBwpToAdd > 0)
1870 memcpy(macUeCfg->spCellCfg.servCellCfg.dlBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.dlBwpToAddOrModList, \
1871 (sizeof(DlBwpInfo) * MAX_NUM_BWP));
1873 macUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvDlBwpId;
1874 macUeCfg->spCellCfg.servCellCfg.defaultDlBwpId = duMacUeCfg->spCellCfg.servCellCfg.defaultDlBwpId;
1875 macUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr = duMacUeCfg->spCellCfg.servCellCfg.bwpInactivityTmr;
1876 memcpy(&macUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, &duMacUeCfg->spCellCfg.servCellCfg.pdschServCellCfg, sizeof(PdschServCellCfg));
1877 memcpy(&macUeCfg->spCellCfg.servCellCfg.initUlBwp, &duMacUeCfg->spCellCfg.servCellCfg.initUlBwp, sizeof(InitialUlBwp));
1878 macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd = duMacUeCfg->spCellCfg.servCellCfg.numUlBwpToAddOrMod;
1879 if(macUeCfg->spCellCfg.servCellCfg.numUlBwpToAdd > 0)
1881 memcpy(macUeCfg->spCellCfg.servCellCfg.ulBwpToAddList, duMacUeCfg->spCellCfg.servCellCfg.ulBwpToAddOrModList,\
1882 (sizeof(UlBwpInfo) * MAX_NUM_BWP));
1884 macUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId = duMacUeCfg->spCellCfg.servCellCfg.firstActvUlBwpId;
1886 if(duMacUeCfg->ambrCfg != NULLP)
1888 memcpy(macUeCfg->ambrCfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
1890 memcpy(&macUeCfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
1891 memcpy(&macUeCfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
1892 if(duMacUeCfg->numLcs > 0)
1894 macUeCfg->numLcs = 0;
1895 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
1897 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
1899 //VS: To thoroughly check
1900 memcpy(&macUeCfg->lcCfgList[macUeCfg->numLcs], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
1907 /**********************************************************************************
1909 * @brief Fills Ue Cfg from DU DB to RLCUeCfg
1913 * Function : fillRlcUeCfg
1915 * Functionality: fills ue Cfg to be sent to RLC
1917 * @params[in] DuRlcUeCfg Pointer
1920 * @return ROK - success
1922 * *******************************************************************************/
1923 void fillRlcUeCfg(DuRlcUeCfg *duRlcUeCfg, RlcUeCfg *rlcUeCfg)
1927 rlcUeCfg->cellId = duRlcUeCfg->cellId;
1928 rlcUeCfg->ueId = duRlcUeCfg->ueId;
1930 rlcUeCfg->numLcsToAdd = 0;
1931 for(lcIdx = 0; lcIdx < duRlcUeCfg->numLcs; lcIdx++)
1933 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_ADD)
1935 memcpy(&rlcUeCfg->rlcLcCfgAdd[rlcUeCfg->numLcsToAdd], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
1936 rlcUeCfg->numLcsToAdd++;
1942 /******************************************************************
1944 * @brief Builds and Send UE Create Request to MAC
1948 * Function : duBuildAndSendUeCreateReqToMac
1950 * Functionality: Builds and Send UE Create Request to MAC
1952 * @Params[in] cellId,
1955 * UE config extracted from F1AP msg
1956 * MAC UE config struct to be filled
1957 * @return ROK - success
1960 * ****************************************************************/
1962 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *ueCfgDb, DuMacUeCfg *duMacUeCfg)
1965 MacUeCfg *macUeCfg = NULLP;
1967 memset(&pst, 0, sizeof(Pst));
1970 ret = updateDuMacUeCfg(cellId, gnbDuUeF1apId, crnti, ueCfgDb, duMacUeCfg);
1973 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1978 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1980 /* Copying ueCb to a sharable buffer */
1981 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1984 memset(macUeCfg, 0, sizeof(MacUeCfg));
1985 fillMacUeCfg(duMacUeCfg, macUeCfg);
1986 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1988 /* Processing one Ue at a time to MAC */
1989 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1992 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1993 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1998 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
2004 /*******************************************************************
2006 * @brief Build and send RACH Resource request to MAC
2010 * Function : duBuildAndSendRachRsrcReqToMac
2012 * Build and send RACH Resource request to MAC
2014 * @params[in] Cell Id
2016 * @return ROK - success
2019 * ****************************************************************/
2020 uint8_t duBuildAndSendRachRsrcReqToMac(uint16_t cellId, uint16_t ueId)
2022 uint16_t cellIdx = 0, ssbIdx = 0;
2024 MacRachRsrcReq *rachRsrcReq = NULLP;
2026 GET_CELL_IDX(cellId, cellIdx);
2027 if(duCb.actvCellLst[cellIdx] == NULLP)
2029 DU_LOG("\nERROR --> DU APP : Cell Id [%d] not found in duBuildAndSendRachRsrcReqToMac()", cellId);
2033 DU_ALLOC_SHRABL_BUF(rachRsrcReq, sizeof(MacRachRsrcReq));
2036 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Request in \
2037 duBuildAndSendRachRsrcReqToMac()");
2041 rachRsrcReq->cellId = cellId;
2042 rachRsrcReq->ueId = ueId;
2043 rachRsrcReq->numSsb = duCfgParam.macCellCfg.prachCfg.ssbPerRach;
2044 for(ssbIdx = 0; ssbIdx < rachRsrcReq->numSsb; ssbIdx++)
2046 rachRsrcReq->ssbIdx[ssbIdx] = ssbIdx;
2050 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REQ);
2052 if(((*packMacRachRsrcReqOpts[pst.selector])(&pst, rachRsrcReq)) != ROK)
2054 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Request to MAC at \
2055 duBuildAndSendRachRsrcReqToMac()");
2056 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcReq, sizeof(MacRachRsrcReq));
2063 /*******************************************************************
2065 * @brief Process RACH resource response from MAC
2069 * Function : DuProcMacRachRsrcRsp
2071 * Process RACH resource response from MAC
2073 * @params[in] Post structure
2074 * RACH resource response
2075 * @return ROK - success
2078 * ****************************************************************/
2079 uint8_t DuProcMacRachRsrcRsp(Pst *pst, MacRachRsrcRsp *rachRsrcRsp)
2081 uint8_t ret = RFAILED;
2082 uint16_t cellIdx = 0;
2083 DuCellCb *cellCb = NULLP;
2084 DuUeCb *ueCb = NULLP;
2086 DU_LOG("\nINFO --> DU APP : Received RACH Resource Response from MAC. Cell ID [%d] UE ID [%d]",
2087 rachRsrcRsp->cellId, rachRsrcRsp->ueId);
2089 if(rachRsrcRsp->result == MAC_DU_APP_RSP_OK)
2091 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [SUCCESS]");
2094 GET_CELL_IDX(rachRsrcRsp->cellId, cellIdx);
2095 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->cellId == rachRsrcRsp->cellId))
2097 cellCb = duCb.actvCellLst[cellIdx];
2100 if(cellCb->ueCb[rachRsrcRsp->ueId-1].gnbDuUeF1apId == rachRsrcRsp->ueId)
2102 ueCb = &cellCb->ueCb[rachRsrcRsp->ueId-1];
2104 /* Store CRNTI alloted to this UE by MAC */
2105 ueCb->crnti = rachRsrcRsp->newCrnti;
2107 /* Store the assigned CF-RA resources */
2108 memcpy(&ueCb->cfraResource, &rachRsrcRsp->cfraResource, sizeof(MacCfraResource));
2110 /* RACH resources allocated to UE is sent to CU in UE Context Setup Response
2111 * along with the result of UE Context setup requested by CU */
2112 if((ret = BuildAndSendUeCtxtRsp(rachRsrcRsp->cellId, rachRsrcRsp->ueId)) != ROK)
2113 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2116 DU_LOG("\nERROR --> DU APP : UE ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->ueId);
2119 DU_LOG("\nERROR --> DU APP : Cell ID [%d] not found in DuProcMacRachRsrcRsp", rachRsrcRsp->cellId);
2122 DU_LOG("\nINFO : DU APP : RACH Resource Response from MAC : Result [FAILURE]");
2124 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRsp, sizeof(MacRachRsrcRsp));
2128 /*******************************************************************
2130 * @brief fill k0 value in duCb
2134 * Function : fillK0Values
2135 * Functionality: update k0 value in duCb
2137 * @params[in] PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg
2138 * @return ROK - success
2141 * ****************************************************************/
2143 uint8_t fillK0Values(PdschConfig *cuPdschCfg, PdschConfig *storePdschCfg)
2145 uint8_t numTimeDomRsrcAlloc, rsrcIdx;
2149 if(storePdschCfg->numTimeDomRsrcAlloc)
2151 numTimeDomRsrcAlloc = cuPdschCfg->numTimeDomRsrcAlloc;
2152 for(rsrcIdx =0 ; rsrcIdx<numTimeDomRsrcAlloc; rsrcIdx++)
2154 if(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2156 if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2158 *(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = *(cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
2159 if(storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0 != cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0)
2160 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0, sizeof(uint8_t));
2164 (storePdschCfg->timeDomRsrcAllociList[rsrcIdx].k0) = (cuPdschCfg->timeDomRsrcAllociList[rsrcIdx].k0);
2173 /*******************************************************************
2175 * @brief To update DuUeCb Mac Cfg
2179 * Function : duUpdateMacCfg
2180 * Functionality: update DuUeCb MAC Cfg
2182 * @params[in] DuUeCb Pointer
2183 * F1UeContextSetupDb pointer
2184 * @return ROK - success
2187 * ****************************************************************/
2188 uint8_t duUpdateMacCfg(DuMacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
2190 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
2191 DuMacUeCfg *oldMacUeCfg;
2194 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
2195 if(duCb.actvCellLst[cellIdx] == NULLP)
2197 DU_LOG("\nERROR --> DU APP: CellId[%d] not found", macUeCfg->cellId);
2200 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueId-1].duMacUeCfg;
2202 /*Filling Cell Group Cfg*/
2203 ret = procUeRecfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
2205 memcpy(&macUeCfg->macCellGrpCfg.drxCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg.macCellGrpCfg.drxCfg, sizeof(DrxCfg));
2209 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
2211 /* update k0 values */
2212 fillK0Values(&f1UeDb->duUeCfg.copyOfmacUeCfg.spCellCfg.servCellCfg.initDlBwp.pdschCfg, &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg);
2213 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
2214 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
2216 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
2218 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
2219 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
2221 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
2222 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
2225 /* Filling LC Context */
2226 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
2228 numLcs = macUeCfg->numLcs;
2229 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2231 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcConfig.lcId == macUeCfg->lcCfgList[lcIdx].lcConfig.lcId)
2233 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
2235 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
2237 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
2239 /* Free memory at matched lcIdx index */
2240 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx].lcConfig);
2242 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
2244 /* moving all elements one index ahead */
2245 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
2246 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1].lcConfig);
2249 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
2256 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
2258 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
2261 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
2271 /******************************************************************
2273 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
2277 * Function : fillRlcCfgToAddMod
2279 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
2282 *****************************************************************/
2284 uint8_t fillRlcCfgToAddMod(DuRlcBearerCfg *lcCfg, DuRlcBearerCfg *f1UeDbLcCfg)
2286 lcCfg->configType = f1UeDbLcCfg->configType;
2287 lcCfg->rlcBearerCfg.rbId = f1UeDbLcCfg->rlcBearerCfg.rbId;
2288 lcCfg->rlcBearerCfg.rbType = f1UeDbLcCfg->rlcBearerCfg.rbType;
2289 lcCfg->rlcBearerCfg.lcId = f1UeDbLcCfg->rlcBearerCfg.lcId;
2290 lcCfg->rlcBearerCfg.lcType = f1UeDbLcCfg->rlcBearerCfg.lcType;
2291 lcCfg->rlcBearerCfg.rlcMode = f1UeDbLcCfg->rlcBearerCfg.rlcMode;
2293 switch(lcCfg->rlcBearerCfg.rlcMode)
2297 if(!lcCfg->rlcBearerCfg.u.amCfg)
2299 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.amCfg, sizeof(AmBearerCfg));
2300 if(!lcCfg->rlcBearerCfg.u.amCfg)
2304 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.snLenDl;
2305 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollRetxTmr;
2306 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollPdu;
2307 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.pollByte;
2308 lcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->dlAmCfg.maxRetxTh;
2311 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.snLenUl;
2312 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.reAssemTmr;
2313 lcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->rlcBearerCfg.u.amCfg->ulAmCfg.statProhTmr;
2316 case RLC_UM_BI_DIRECTIONAL :
2318 if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
2320 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
2321 if(!lcCfg->rlcBearerCfg.u.umBiDirCfg)
2324 /* UL UM BI DIR INFO */
2325 lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.snLenUlUm;
2326 lcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->ulUmCfg.reAssemTmr;
2327 /* DL UM BI DIR INFO */
2328 lcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umBiDirCfg->dlUmCfg.snLenDlUm;
2331 case RLC_UM_UNI_DIRECTIONAL_UL :
2333 if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
2335 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
2336 if(!lcCfg->rlcBearerCfg.u.umUniDirUlCfg)
2339 lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
2340 lcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
2344 case RLC_UM_UNI_DIRECTIONAL_DL :
2346 if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
2348 DU_ALLOC_SHRABL_BUF(lcCfg->rlcBearerCfg.u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
2349 if(!lcCfg->rlcBearerCfg.u.umUniDirDlCfg)
2352 lcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->rlcBearerCfg.u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
2356 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcBearerCfg.rlcMode);
2362 /*******************************************************************
2364 * @brief To update DuUeCb Rlc Lc Cfg
2368 * Function : duUpdateRlcLcCfg
2369 * Functionality: update DuUeCb Rlc Lc Cfg
2371 * @params[in] DuUeCb Pointer
2372 * F1UeContextSetupDb pointer
2373 * @return ROK - success
2376 * ****************************************************************/
2378 uint8_t duUpdateRlcLcCfg(DuRlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2380 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2383 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2385 numLcs = rlcUeCfg->numLcs;
2386 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2388 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.lcId == rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
2390 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2392 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2395 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2398 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
2399 &rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg.snssai, true);
2401 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2403 /* Free memory at matched lcIdx index */
2404 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg);
2406 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2408 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2409 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg.snssai,\
2410 &rlcUeCfg->rlcLcCfg[lcDelIdx].rlcBearerCfg.snssai, true);
2411 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1].rlcBearerCfg);
2414 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2421 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2423 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2426 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].rlcBearerCfg.snssai,\
2427 &rlcUeCfg->rlcLcCfg[rlcUeCfg->numLcs].rlcBearerCfg.snssai, true);
2435 /*******************************************************************
2437 * @brief Function to fill Tunnel Config to Add/Mod
2442 * Function : fillTnlCfgToAddMod
2444 * Functionality: Function to fill tunnel Config to Add/Mod
2446 * @params[in] Pointer to tnlCfgDb,
2447 * pointer to f1TnlCfg
2448 * @return ROK - success
2451 * ****************************************************************/
2452 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2456 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2457 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2460 if(*ueCbTnlCfg == NULLP)
2462 /* copying to DuCb Tnl Cfg */
2463 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2464 if(*ueCbTnlCfg == NULLP)
2466 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2470 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2471 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2472 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2473 (*ueCbTnlCfg)->ueId = f1TnlCfg->ueId;
2474 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2475 if(f1TnlCfg->tnlCfg1)
2477 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2479 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2480 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2482 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2486 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2487 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2488 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2489 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2494 /*******************************************************************
2496 * @brief Processing the tunnel Request to EGTP
2500 * Function : duProcEgtpTunnelCfg
2502 * Functionality: Processing the tunnel Request to EGTP
2504 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2505 * @return ROK - success
2508 * ****************************************************************/
2510 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2512 uint8_t ret = RFAILED, delIdx;
2514 if(f1TnlCfg->tnlCfg1 == NULLP)
2516 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2520 if(f1TnlCfg->configType == CONFIG_ADD)
2522 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2524 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numTeId], f1TnlCfg) == ROK)
2531 else if(f1TnlCfg->configType == CONFIG_MOD)
2533 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2535 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2541 else if(f1TnlCfg->configType == CONFIG_DEL)
2543 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2545 /* Free memory at drbIdx */
2547 for(delIdx = ueCbIdx; delIdx < duCb.numTeId; delIdx++)
2549 /* moving all elements one index ahead */
2550 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2556 if(duCb.upTnlCfg[delIdx])
2558 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2559 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2566 /***********************************************************************
2568 * @brief Function to fill Tunnel Config
2569 * and sends tunnel Req to EGTP
2574 * Function : duUpdateTunnelCfgDb
2576 * Functionality: Function to fill tunnel Config
2577 * and sends tunnel Cfg Req to EGTP
2579 * @params[in] ueId, cellId, DuUeCfg
2580 * @return ROK - success
2583 * ****************************************************************/
2585 uint8_t duUpdateTunnelCfgDb(uint8_t ueId, uint8_t cellId, DuUeCfg *duUeCfg)
2587 uint8_t ret = ROK, drbIdx, teIdx;
2588 bool drbFound = false;
2590 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2591 /*then update drbId and tunnel Info in duCb */
2592 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2594 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2595 duUeCfg->upTnlInfo[drbIdx].ueId = ueId;
2596 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
2598 if((duCb.upTnlCfg[teIdx]->ueId == duUeCfg->upTnlInfo[drbIdx].ueId) && \
2599 (duCb.upTnlCfg[teIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId))
2601 drbFound = true; /* existing DRB */
2602 if(duProcEgtpTunnelCfg(teIdx, duCb.upTnlCfg[teIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2604 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2605 duUeCfg->upTnlInfo[drbIdx].drbId);
2614 if(!drbFound && ret == ROK)/* new DRB to Add */
2616 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2618 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2619 duUeCfg->upTnlInfo[drbIdx].drbId);
2628 /*******************************************************************
2630 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2635 * Function : duUpdateDuUeCbCfg
2637 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2639 * @params[in] ueId, cellIdx
2640 * @return ROK - success
2643 * ****************************************************************/
2645 uint8_t duUpdateDuUeCbCfg(uint8_t ueId, uint8_t cellId)
2647 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2648 DuUeCb *ueCb = NULLP;
2650 GET_CELL_IDX(cellId, cellIdx);
2651 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
2653 /*Filling RLC Ue Cfg */
2654 ueCb->duRlcUeCfg.cellId = cellId;
2655 ueCb->duRlcUeCfg.ueId = ueId;
2656 ret = duUpdateRlcLcCfg(&ueCb->duRlcUeCfg, ueCb->f1UeDb);
2659 /*Filling MAC Ue Cfg */
2660 GET_CRNTI(crnti, ueId);
2661 ueCb->duMacUeCfg.cellId = cellId;
2662 ueCb->duMacUeCfg.ueId = ueId;
2663 ueCb->duMacUeCfg.crnti = crnti;
2664 ret = duUpdateMacCfg(&ueCb->duMacUeCfg, ueCb->f1UeDb);
2666 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2669 if(duUpdateTunnelCfgDb(ueId, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2671 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2677 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2681 /*******************************************************************
2683 * @brief Handle UE config response from MAC
2687 * Function : DuProcMacUeCfgRsp
2689 * Functionality: Handle UE Config response from MAC
2691 * @params[in] Pointer to MacUeCfgRsp and Pst
2692 * @return ROK - success
2695 * ****************************************************************/
2696 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2703 GET_CELL_IDX(cfgRsp->cellId, cellIdx);
2704 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2706 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2708 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [DU UE F1AP ID : %d]", cfgRsp->ueId);
2710 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].gnbDuUeF1apId == cfgRsp->ueId))
2712 duCb.actvCellLst[cellIdx]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2714 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2715 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2716 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2718 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2720 /* If UE is in handover, RACH resource needs to be requested
2721 * from MAC for CFRA */
2722 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2724 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2725 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2731 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2732 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2741 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, cfgRsp->ueId);
2744 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2748 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2754 /*******************************************************************
2756 * @brief Handle UE Reconfig response from MAC
2760 * Function : DuProcMacUeRecfgRsp
2762 * Functionality: Handle UE ReConfig response from MAC
2764 * @params[in] Pointer to MacUeRecfgRsp and Pst
2765 * @return ROK - success
2768 * ****************************************************************/
2769 uint8_t DuProcMacUeRecfgRsp(Pst *pst, MacUeRecfgRsp *reCfgRsp)
2776 GET_CELL_IDX(reCfgRsp->cellId, cellIdx);
2777 if(reCfgRsp->result == MAC_DU_APP_RSP_OK)
2779 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2781 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [DU UE F1AP ID : %d]", reCfgRsp->ueId);
2782 if(duCb.actvCellLst[cellIdx] &&
2783 (duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].gnbDuUeF1apId == reCfgRsp->ueId))
2785 duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2786 if((duCb.actvCellLst[cellIdx]->ueCb[reCfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2787 (duCb.actvCellLst[reCfgRsp->cellId -1]->ueCb[reCfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2789 if((ret = duUpdateDuUeCbCfg(reCfgRsp->ueId, reCfgRsp->cellId)) == ROK)
2791 if((BuildAndSendUeCtxtRsp(reCfgRsp->cellId, reCfgRsp->ueId)) != ROK)
2793 DU_LOG("\nERROR -> DU APP : Failure in BuildAndSendUeCtxtRsp()");
2794 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2800 DU_LOG("\nERROR -> DU APP : Failure in updating DU UE CB");
2801 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2810 DU_LOG("\nERROR --> DU APP : MAC UE RECFG Response for EVENT[%d]: FAILURE [DU UE F1AP ID : %d]", pst->event, reCfgRsp->ueId);
2811 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2813 //TODO: Send the failure case in Ue Context Setup Response
2817 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, reCfgRsp, sizeof(MacUeRecfgRsp));
2821 DU_LOG("\nERROR --> DU APP : Received MAC Ue ReConfig Response is NULL at DuProcMacUeRecfgRsp()");
2827 /*******************************************************************
2829 * @brief Processes UE create Req to RLC UL
2833 * Function : duBuildAndSendUeCreateReqToRlc
2836 * Processes UE create Req to RLC UL
2838 * @params[in] cellId,
2840 * Pointer to RlcUeCfg
2841 * @return ROK - success
2844 *****************************************************************/
2846 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t gnbDuUeF1apId, DuUeCfg *ueCfgDb, DuRlcUeCfg *duRlcUeCfg)
2849 RlcUeCfg *rlcUeCfg = NULLP;
2852 ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
2855 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2859 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2860 /* Copying ueCfg to a sharable buffer */
2861 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2864 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2865 fillRlcUeCfg(duRlcUeCfg, rlcUeCfg);
2867 /* Processing one Ue at a time to RLC */
2868 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2869 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2872 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2873 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2879 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2885 /*******************************************************************
2887 * @brief Processes UE create Rsp received from RLC UL
2892 * Function : DuProcRlcUeCfgRsp
2895 * Processes UE create Rsp received from RLC UL
2897 * @params[in] Post structure
2898 * Pointer to RlcCfgCfm
2899 * @return ROK - success
2902 *****************************************************************/
2903 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2909 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2911 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2913 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2914 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2916 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].ueState == UE_HANDIN_IN_PROGRESS) &&
2917 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_CREATE_COMPLETE) &&
2918 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_CREATE_COMPLETE))
2920 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2922 /* If UE is in handover, RACH resource needs to be requested
2923 * from MAC for CFRA */
2924 if((duBuildAndSendRachRsrcReqToMac(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2926 DU_LOG("\nERROR --> DU APP : Failed to send RACH Resource Request to MAC");
2927 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2928 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2934 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2935 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2940 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2942 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueId);
2944 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2945 if((duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duMacUeCfg.macUeCfgState == UE_RECFG_COMPLETE) &&
2946 (duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueId -1].duRlcUeCfg.rlcUeCfgState == UE_RECFG_COMPLETE))
2948 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueId, cfgRsp->cellId)) == ROK)
2950 if((BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueId)) != ROK)
2952 DU_LOG("\nERROR --> DU APP : Failure in BuildAndSendUeCtxtRsp");
2953 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2959 DU_LOG("\nERROR --> DU APP : Failure in updating DU UE CB");
2960 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2968 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2969 pst->event, cfgRsp->ueId, cfgRsp->reason);
2970 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2972 //TODO: update failure case in ue Context setup Response
2976 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2980 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2986 /**********************************************************************************
2988 * @brief Fills Ue ReCfg from DU DB to RlcUeRecfg
2992 * Function : fillRlcUeRecfg
2994 * Functionality: fills ue ReCfg to be sent to RLC
2996 * @params[in] DuRlcUeCfg Pointer
2997 * RlcUeRecfg Pointer
3000 * *******************************************************************************/
3001 void fillRlcUeRecfg(DuRlcUeCfg *duRlcUeCfg, RlcUeRecfg *rlcUeRecfg)
3005 rlcUeRecfg->cellId = duRlcUeCfg->cellId;
3006 rlcUeRecfg->ueId = duRlcUeCfg->ueId;
3009 if(duRlcUeCfg->numLcs > 0)
3011 rlcUeRecfg->numLcsToAdd = 0;
3012 rlcUeRecfg->numLcsToMod = 0;
3013 rlcUeRecfg->numLcsToRel = 0;
3015 for(lcIdx = 0; lcIdx < duRlcUeCfg->numLcs; lcIdx++)
3017 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_ADD)
3019 memcpy(&rlcUeRecfg->rlcLcCfgAdd[rlcUeRecfg->numLcsToAdd], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3020 rlcUeRecfg->numLcsToAdd++;
3022 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_MOD)
3024 memcpy(&rlcUeRecfg->rlcLcCfgMod[rlcUeRecfg->numLcsToMod], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3025 rlcUeRecfg->numLcsToMod++;
3027 if(duRlcUeCfg->rlcLcCfg[lcIdx].configType == CONFIG_DEL)
3029 memcpy(&rlcUeRecfg->rlcLcCfgRel[rlcUeRecfg->numLcsToRel], &duRlcUeCfg->rlcLcCfg[lcIdx].rlcBearerCfg, sizeof(RlcBearerCfg));
3030 rlcUeRecfg->numLcsToRel++;
3037 /*******************************************************************
3039 * @brief Builds and Send Ue Reconfig Req to RLC
3043 * Function : duBuildAndSendUeRecfgReqToRLC
3045 * Functionality: Builds and Send Ue Reconfig Req to RLC
3047 * @params[in] cellId, crnti
3049 * RlcUeCfg *rlcUeCfg
3050 * @return ROK - success
3053 * ****************************************************************/
3055 uint8_t duBuildAndSendUeRecfgReqToRlc(uint8_t cellId, uint8_t gnbDuUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
3058 DuRlcUeCfg *duRlcUeCfg = NULLP;
3059 RlcUeRecfg *rlcUeRecfg = NULLP;
3061 DU_ALLOC(duRlcUeCfg, sizeof(DuRlcUeCfg));
3062 DU_ALLOC_SHRABL_BUF(rlcUeRecfg, sizeof(RlcUeRecfg));
3063 if(duRlcUeCfg && rlcUeRecfg)
3065 memset(duRlcUeCfg, 0, sizeof(DuRlcUeCfg));
3066 memset(rlcUeRecfg, 0, sizeof(RlcUeRecfg));
3068 ret = updateRlcUeCfg(cellId, gnbDuUeF1apId, ueCfgDb, duRlcUeCfg);
3071 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeRecfgReqToRlc()");
3074 fillRlcUeRecfg(duRlcUeCfg, rlcUeRecfg);
3075 ret = sendUeRecfgReqToRlc(rlcUeRecfg);
3080 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeRecfgReqToRlc()");
3083 DU_FREE(duRlcUeCfg, sizeof(DuRlcUeCfg));
3087 /**********************************************************************************
3089 * @brief Fills Ue ReCfg from DU DB to MacUeRecfg
3093 * Function : fillMacUeRecfg
3095 * Functionality: fills ue ReCfg to be sent to MAC
3097 * @params[in] DuMacUeCfg Pointer
3098 * MacUeRecfg Pointer
3101 * *******************************************************************************/
3102 void fillMacUeRecfg(DuMacUeCfg *duMacUeCfg, MacUeRecfg *macUeRecfg)
3106 macUeRecfg->cellId = duMacUeCfg->cellId;
3107 macUeRecfg->ueId = duMacUeCfg->ueId;
3108 macUeRecfg->crnti = duMacUeCfg->crnti;
3109 macUeRecfg->macCellGrpRecfgPres = duMacUeCfg->macCellGrpCfgPres;
3110 if(macUeRecfg->macCellGrpRecfgPres)
3112 memcpy(&macUeRecfg->macCellGrpRecfg, &duMacUeCfg->macCellGrpCfg, sizeof(MacCellGrpCfg));
3114 macUeRecfg->phyCellGrpRecfgPres = duMacUeCfg->phyCellGrpCfgPres;
3115 if(macUeRecfg->phyCellGrpRecfgPres)
3117 memcpy(&macUeRecfg->phyCellGrpRecfg, &duMacUeCfg->phyCellGrpCfg, sizeof(PhyCellGrpCfg));
3119 macUeRecfg->spCellRecfgPres = duMacUeCfg->spCellCfgPres;
3120 if(macUeRecfg->spCellRecfgPres)
3122 memcpy(&macUeRecfg->spCellRecfg, &duMacUeCfg->spCellCfg, sizeof(SpCellRecfg));
3124 if(duMacUeCfg->ambrCfg != NULLP)
3126 DU_ALLOC_SHRABL_BUF(macUeRecfg->ambrRecfg, sizeof(AmbrCfg));
3127 memcpy(macUeRecfg->ambrRecfg, duMacUeCfg->ambrCfg, sizeof(AmbrCfg));
3129 memcpy(&macUeRecfg->dlModInfo, &duMacUeCfg->dlModInfo, sizeof(ModulationInfo));
3130 memcpy(&macUeRecfg->ulModInfo, &duMacUeCfg->ulModInfo, sizeof(ModulationInfo));
3131 if(duMacUeCfg->numLcs > 0)
3133 macUeRecfg->numLcsToAdd = 0;
3134 macUeRecfg->numLcsToDel = 0;
3135 macUeRecfg->numLcsToMod = 0;
3137 for(lcIdx = 0; lcIdx < duMacUeCfg->numLcs; lcIdx++)
3139 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_ADD)
3141 /*VS: To thoroughly check*/
3142 memcpy(&macUeRecfg->lcCfgAdd[macUeRecfg->numLcsToAdd], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
3143 macUeRecfg->numLcsToAdd++;
3145 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_DEL)
3147 /*VS: To thoroughly check*/
3148 macUeRecfg->lcIdToDel[macUeRecfg->numLcsToDel] = duMacUeCfg->lcCfgList[lcIdx].lcConfig.lcId;
3149 macUeRecfg->numLcsToDel++;
3151 if(duMacUeCfg->lcCfgList[lcIdx].configType == CONFIG_MOD)
3153 /*VS: To thoroughly check*/
3154 memcpy(&macUeRecfg->lcCfgMod[macUeRecfg->numLcsToMod], &duMacUeCfg->lcCfgList[lcIdx].lcConfig, sizeof(LcCfg));
3155 macUeRecfg->numLcsToMod++;
3159 macUeRecfg->transmissionAction = duMacUeCfg->transmissionAction;
3161 macUeRecfg->drxConfigIndicatorRelease = duMacUeCfg->drxConfigIndicatorRelease;
3165 /*******************************************************************
3167 * @brief Builds and Send Ue Reconfig Req to MAC
3171 * Function : duBuildAndSendUeRecfgReqToMac
3173 * Functionality: Builds and Send Ue Reconfig Req to MAC
3175 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
3177 * @return ROK - success
3180 * ****************************************************************/
3182 uint8_t duBuildAndSendUeRecfgReqToMac(uint8_t cellId, uint8_t duUeF1apId, uint8_t crnti, DuUeCfg *ueCfgDb)
3185 DuMacUeCfg *duMacUeCfg = NULLP;
3186 MacUeRecfg *macUeRecfg = NULLP;
3188 DU_ALLOC(duMacUeCfg, sizeof(DuMacUeCfg));
3189 DU_ALLOC_SHRABL_BUF(macUeRecfg, sizeof(MacUeRecfg));
3190 if(macUeRecfg && duMacUeCfg)
3192 memset(duMacUeCfg, 0, sizeof(DuMacUeCfg));
3193 memset(macUeRecfg, 0, sizeof(MacUeRecfg));
3195 ret = updateDuMacUeCfg(cellId, duUeF1apId, crnti, ueCfgDb, duMacUeCfg);
3197 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeRecfgReqToMac()");
3200 fillMacUeRecfg(duMacUeCfg, macUeRecfg);
3201 ret = sendUeRecfgReqToMac(macUeRecfg);
3206 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeRecfgReqToMac()");
3209 DU_FREE(duMacUeCfg, sizeof(DuMacUeCfg));
3214 /*******************************************************************
3216 * @brief Build and Send Ue context setup request
3221 * Function : duBuildAndSendUeContextSetupReq
3224 * Build and Send Ue context setup request
3226 * @params[in] cellId, crnti, DuUeCfg pointer
3227 * @return ROK - success
3230 *****************************************************************/
3232 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, DuUeCb *ueCb)
3236 DuUeCfg *duUeCfg = NULLP;
3238 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
3242 DU_LOG("\nERROR --> DU APP : UE Cb is NULL");
3246 crnti = ueCb->crnti;
3247 duUeCfg = &ueCb->f1UeDb->duUeCfg;
3249 /* If UE is being handed-in to this DU, UE context setup request will create
3250 * new UE context at MAC/SCH and RLC.
3251 * If UE is in active state, UE contex setup request will lead to
3252 * reconfiguration of UE at MAC/SCH and RLC
3254 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
3256 /* Filling MAC UE Config */
3257 memset(&ueCb->duMacUeCfg, 0, sizeof(DuMacUeCfg));
3259 /* Since UE attach has not yet happened, crnti is unknow. Hence passing 0 */
3260 ret = duBuildAndSendUeCreateReqToMac(cellId, ueCb->gnbDuUeF1apId, 0, duUeCfg, &ueCb->duMacUeCfg);
3262 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
3264 ret = duBuildAndSendUeCreateReqToRlc(cellId, ueCb->gnbDuUeF1apId, duUeCfg, &ueCb->duRlcUeCfg);
3266 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
3271 /* Filling RLC UE Reconfig */
3272 ret = duBuildAndSendUeRecfgReqToRlc(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3274 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
3276 /* Filling MAC UE Reconfig */
3277 ret = duBuildAndSendUeRecfgReqToMac(cellId, ueCb->gnbDuUeF1apId, crnti, duUeCfg);
3279 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
3285 /*******************************************************************
3287 * @brief Processes DL Rsp received from RLC DL
3292 * Function : DuProcRlcDlRrcMsgRsp
3295 * Processes UE Rsp received from RLC DL
3297 * @params[in] Post structure
3298 * Pointer to RlcCfgCfm
3299 * @return ROK - success
3302 *****************************************************************/
3303 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
3305 uint8_t ret = ROK, ueId = 0;
3306 uint16_t cellId, crnti;
3307 DuUeCb *ueCb = NULLP;
3310 state = dlRrcMsg->state;
3311 cellId = dlRrcMsg->cellId;
3312 crnti = dlRrcMsg->crnti;
3313 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
3315 if(state == TRANSMISSION_COMPLETE)
3317 GET_UE_ID(crnti, ueId);
3318 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueId -1];
3320 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
3322 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3324 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3326 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
3329 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3331 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, crnti, &ueCb->f1UeDb->duUeCfg);
3333 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
3336 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
3338 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
3341 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
3347 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
3351 /*******************************************************************
3353 * @brief Process UE context setup request from CU
3357 * Function : duProcUeContextSetupRequest
3359 * Functionality: Process UE context setup request from CU
3361 * @params[in] F1AP message
3362 * @return ROK - success
3365 * ****************************************************************/
3367 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
3369 uint8_t ret, cellId;
3374 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3376 /* Send DL RRC msg for security Mode */
3377 if(ueCb->f1UeDb->dlRrcMsg)
3379 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3381 /* Sending DL RRC Message to RLC */
3382 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3385 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
3386 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3387 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3388 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3392 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
3394 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb);
3397 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
3403 //TODO: To send the failure cause in UeContextSetupRsp
3404 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
3409 /*******************************************************************
3411 * @brief Build and Send Ue context mod request
3416 * Function : duBuildAndSendUeContextModReq
3419 * Build and Send Ue context mod request
3421 * @params[in] cellId, crnti, DuUeCfg pointer
3422 * @return ROK - success
3425 *****************************************************************/
3427 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint8_t gnbDuUeF1apId, uint16_t crnti, DuUeCfg *duUeCfg)
3431 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
3432 /* Filling RLC Ue Reconfig */
3433 ret = duBuildAndSendUeRecfgReqToRlc(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3435 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
3437 /* Filling MAC Ue Reconfig */
3438 ret = duBuildAndSendUeRecfgReqToMac(cellId, gnbDuUeF1apId, crnti, duUeCfg);
3440 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
3444 /*******************************************************************
3446 * @brief Processing Ue context mod request
3451 * Function : duProcUeContextModReq
3454 * Processing Ue context mod request
3456 * @params[in] DuUeCb *ueCb
3457 * @return ROK - success
3460 *****************************************************************/
3462 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
3464 uint8_t ret, cellId;
3469 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
3470 /* Send DL RRC msg for security Mode */
3471 if(ueCb->f1UeDb->dlRrcMsg)
3473 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
3475 /* Sending DL RRC Message to RLC */
3476 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->duRlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
3479 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
3480 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3481 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3482 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3486 else if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
3488 ret = duBuildAndSendUeContextModReq(cellId, ueCb->gnbDuUeF1apId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
3491 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
3495 else if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || (ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE))
3497 if((BuildAndSendUeContextModRsp(ueCb) != ROK))
3499 DU_LOG("\nERROR --> DU APP : Failed to build UE Context modification response");
3506 //TODO: To send the failure cause in UeContextModRsp
3508 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
3514 /*******************************************************************
3516 * @brief Build and send dedicated RACH resource release request to MAC
3520 * Function : duBuildAndSendRachRsrcRelToMac
3522 * Functionality: Function to Build and send dedicated RACH resource
3523 * release request to MAC
3525 * @params[in] Cell ID
3527 * @return ROK - Success
3530 * ****************************************************************/
3531 uint8_t duBuildAndSendRachRsrcRelToMac(uint16_t cellId, DuUeCb *ueCb)
3534 MacRachRsrcRel *rachRsrcRel = NULLP;
3536 DU_ALLOC_SHRABL_BUF(rachRsrcRel, sizeof(MacRachRsrcRel));
3539 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH Resource Release in \
3540 duBuildAndSendRachRsrcRelToMac()");
3544 rachRsrcRel->cellId = cellId;
3545 rachRsrcRel->ueId = ueCb->gnbDuUeF1apId;
3546 rachRsrcRel->crnti = ueCb->crnti;
3549 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_RACH_RESOURCE_REL);
3551 if(((*packMacRachRsrcRelOpts[pst.selector])(&pst, rachRsrcRel)) != ROK)
3553 DU_LOG("\nERROR --> DU_APP : Failure in sending RACH Resource Release to MAC at \
3554 duBuildAndSendRachRsrcRelToMac()");
3555 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rachRsrcRel, sizeof(MacRachRsrcRel));
3562 /*******************************************************************
3564 * @brief delete DuMacUeCfg from duCb
3568 * Function : deleteMacUeCfg
3570 * Functionality: delete DuMacUeCfg from duCb
3572 * @params[in] Pointer to DuMacUeCfg
3573 * @return ROK - success
3576 *******************************************************************/
3578 void deleteMacUeCfg(DuMacUeCfg *ueCfg)
3582 if(ueCfg->spCellCfgPres)
3584 freeUeRecfgCellGrpInfo(ueCfg);
3588 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
3590 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
3592 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx].lcConfig);
3594 memset(ueCfg, 0, sizeof(DuMacUeCfg));
3597 /*******************************************************************
3599 * @brief delete UE Configuration of a particular UE
3603 * Function : deleteUeCfg
3605 * Functionality: delete UE Configuration of a particular UE
3607 * @params[in] uint16_t cellIdx, uint8_t ueId
3608 * @return ROK - success
3611 * ****************************************************************/
3612 uint8_t deleteUeCfg(uint16_t cellId, uint8_t ueId)
3615 uint16_t cellIdx = 0;
3616 DuUeCb *ueCb = NULLP;
3618 GET_CELL_IDX(cellId, cellIdx);
3619 if(duCb.actvCellLst[cellIdx] != NULLP)
3621 if((duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duMacUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
3622 &&(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
3624 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
3625 deleteMacUeCfg(&ueCb->duMacUeCfg);
3626 deleteRlcUeCfg(&ueCb->duRlcUeCfg);
3627 if(ueCb->f1UeDb !=NULLP)
3629 freeF1UeDb(ueCb->f1UeDb);
3631 for(tnlIdx = 0; tnlIdx < duCb.numTeId; )
3633 if(duCb.upTnlCfg[tnlIdx]->ueId == ueId)
3635 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
3636 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
3641 unsetBitInUeBitMap(cellId, ueId-1);
3642 duCb.actvCellLst[cellIdx]->numActvUes--;
3643 memset(ueCb, 0, sizeof(DuUeCb));
3652 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
3659 /*******************************************************************
3661 * @brief Handle UE delete response from MAC
3665 * Function : DuProcMacUeDeleteRsp
3667 * Functionality: Handle UE delete response from MAC
3669 * @params[in] Pointer to MacUeDeleteRsp and Pst
3670 * @return ROK - success
3673 * ****************************************************************/
3675 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
3677 uint8_t ret =ROK,ueId=0;
3679 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
3683 if(deleteRsp->status == SUCCESSFUL)
3685 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
3686 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
3687 if(duCb.actvCellLst[cellIdx])
3689 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
3690 ueId = deleteRsp->ueId;
3691 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
3692 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
3693 if(deleteUeCfg(deleteRsp->cellId, ueId) == ROK)
3695 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3698 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3706 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3710 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3714 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3720 /*******************************************************************
3722 * @brief Processes UE Delete Rsp received from RLC
3726 * Function : DuProcRlcUeDeleteRsp
3729 * Processes UE Delete Rsp received from RLC
3731 * @params[in] Post structure
3732 * Pointer to RlcUeDeleteRsp
3733 * @return ROK - success
3736 * *****************************************************************/
3738 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3740 uint8_t ueId = 0, ret = ROK;
3741 uint16_t cellIdx = 0,crnti=0;
3745 ueId = delRsp->ueId;
3746 GET_CELL_IDX(delRsp->cellId, cellIdx);
3748 if(delRsp->status == SUCCESSFUL)
3750 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3751 if(duCb.actvCellLst[cellIdx]!=NULLP)
3753 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].duRlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3754 GET_CRNTI(crnti, ueId);
3755 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3757 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3765 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3768 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3774 /*******************************************************************
3776 * @brief Sending UE Delete Req To Mac
3780 * Function : sendUeDeleteReqToMac
3783 * sending UE Delete Req To Mac
3785 * @params[in] cellId, ueId, crnti
3786 * @return ROK - success
3789 *****************************************************************/
3791 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3795 MacUeDelete *ueDelete = NULLP;
3797 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3800 ueDelete->cellId = cellId;
3801 ueDelete->ueId = ueId;
3802 ueDelete->crnti = crnti;
3803 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3805 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3806 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3809 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3810 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3815 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3821 /*******************************************************************
3823 * @brief Sending UE Delete Req To Rlc
3827 * Function : sendUeDeleteReqToRlc
3830 * Sending UE Delete Req To Rlc
3832 * @params[in] cellId, ueId
3833 * @return ROK - success
3836 *****************************************************************/
3838 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3842 RlcUeDelete *ueDelete;
3844 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3845 if(ueDelete !=NULLP)
3847 ueDelete->cellId = cellId;
3848 ueDelete->ueId = ueId;
3849 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3851 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3854 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3855 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3860 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3866 /*******************************************************************
3868 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3872 * Function : duBuildAndSendUeDeleteReq
3874 * Functionality: DU processes UE delete req from CU and sends to MAC
3877 * @params[in] cellId, crnti
3878 * @return ROK - success
3881 * ****************************************************************/
3883 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3886 uint16_t cellIdx = 0;
3888 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3889 GET_CELL_IDX(cellId, cellIdx);
3890 GET_UE_ID(crnti, ueId);
3892 if(duCb.actvCellLst[cellIdx] != NULLP)
3894 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3896 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3900 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3901 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3903 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3909 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3916 /*******************************************************************
3918 * @brief delete RlcUeCfg from duCb
3922 * Function : deleteRlcUeCfg
3925 * delete RlcUeCfg from duCb
3927 * @params[in] RlcUeCfg *ueCfg
3929 * @return ROK - success
3932 *****************************************************************/
3934 void deleteRlcUeCfg(DuRlcUeCfg *ueCfg)
3937 RlcBearerCfg *lcCfg= NULLP;
3940 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3942 lcCfg = &ueCfg->rlcLcCfg[lcIdx].rlcBearerCfg;
3943 switch(lcCfg->rlcMode)
3947 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3950 case RLC_UM_BI_DIRECTIONAL :
3952 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3955 case RLC_UM_UNI_DIRECTIONAL_UL :
3957 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3960 case RLC_UM_UNI_DIRECTIONAL_DL :
3962 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3966 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3968 memset(ueCfg, 0, sizeof(RlcUeCfg));
3972 /*******************************************************************
3974 * @brief Du process Ue Context Release Command
3978 * Function : duProcUeContextReleaseCommand
3980 * Functionality: Du process Ue Context Release Command
3982 * @params[in] DuUeCb *duUeCb
3983 * @return ROK - success
3986 * ****************************************************************/
3987 uint8_t duProcUeContextReleaseCommand(uint16_t cellId, DuUeCb *duUeCb)
3989 uint8_t ret =ROK, ueId=0;
3994 crnti = duUeCb->crnti;
3995 GET_UE_ID(crnti, ueId);
3999 /* Send DL RRC msg for RRC release */
4000 if(duUeCb->f1UeDb->dlRrcMsg)
4002 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
4004 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueId-1].duRlcUeCfg,\
4005 duUeCb->f1UeDb->dlRrcMsg);
4008 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
4009 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
4010 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
4011 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
4018 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
4021 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
4028 /*******************************************************************
4030 * @brief Sending UE Reset Req To Mac
4034 * Function : sendUeResetReqToMac
4037 * sending UE Reset Req To Mac
4039 * @params[in] cellId, ueId, crnti
4040 * @return ROK - success
4043 *****************************************************************/
4045 uint8_t sendUeResetReqToMac(uint16_t cellId, uint8_t ueId)
4049 MacUeResetReq *ueReset = NULLP;
4051 DU_ALLOC_SHRABL_BUF(ueReset, sizeof(MacUeResetReq));
4054 ueReset->cellId = cellId;
4055 ueReset->ueId = ueId;
4056 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RESET_REQ);
4058 DU_LOG("\nDEBUG --> DU_APP: Sending UE Reset Request to MAC ");
4059 ret = (*packMacUeResetReqOpts[pst.selector])(&pst, ueReset);
4062 DU_LOG("\nERROR --> DU_APP: sendUeResetReqToMac(): Failed to send UE Reset Req to MAC");
4063 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueReset, sizeof(MacUeResetReq));
4068 DU_LOG("\nERROR --> DU_APP: sendUeResetReqToMac(): Failed to allocate memory");
4074 /*******************************************************************
4076 * @brief DU processes UE reset req and send it to MAC
4080 * Function : duBuildAndSendUeResetReq
4082 * Functionality: DU processes UE reset req and send to MAC
4085 * @params[in] cellId, crnti
4086 * @return ROK - success
4089 * ****************************************************************/
4091 uint8_t duBuildAndSendUeResetReq(uint16_t cellId, uint16_t crnti)
4094 uint16_t cellIdx = 0;
4096 DU_LOG("\nDEBUG --> DU_APP : Building UE reset request");
4097 GET_CELL_IDX(cellId, cellIdx);
4098 GET_UE_ID(crnti, ueId);
4100 if(duCb.actvCellLst[cellIdx] != NULLP)
4102 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
4104 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeResetReq(): CRNTI [%d] not found", crnti);
4108 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_RESET_IN_PROGRESS;
4109 if(sendUeResetReqToMac(cellId, ueId) == RFAILED)
4111 DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): Failed to build UE reset req for MAC ");
4117 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeResetReq(): Cell Id %d not found", cellId);
4124 /*******************************************************************
4126 * @brief Handle UE reset response from MAC
4130 * Function : DuProcMacUeResetRsp
4132 * Functionality: Handle UE reset response from MAC
4134 * @params[in] Pointer to MacUeResetRsp and Pst
4135 * @return ROK - success
4138 * ****************************************************************/
4140 uint8_t DuProcMacUeResetRsp(Pst *pst, MacUeResetRsp *resetRsp)
4147 if(resetRsp->status == SUCCESSFUL)
4149 DU_LOG("\nINFO --> DU APP : MAC UE Reset Response : SUCCESS [UE IDX : %d]", resetRsp->ueId);
4150 GET_CELL_IDX(resetRsp->cellId, cellIdx);
4151 if(duCb.actvCellLst[cellIdx])
4153 duCb.actvCellLst[cellIdx]->ueCb[resetRsp->ueId -1].duMacUeCfg.macUeCfgState = UE_RESET_COMPLETE;
4154 /*TODO - Complete the processing after receiving successfully reset rsp*/
4159 DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): MAC UE Reset Response : FAILURE [UE IDX : %d]",resetRsp->ueId);
4162 DU_FREE_SHRABL_BUF(pst->region, pst->pool, resetRsp, sizeof(MacUeResetRsp));
4166 DU_LOG("\nERROR --> DU APP : DuProcMacUeResetRsp(): MAC UE Reset Response is null");
4172 /**********************************************************************
4174 ***********************************************************************/