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 "ConfigInterface.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 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
86 packRlcDlUserDataToRlc, /* Loose coupling */
87 RlcProcDlUserDataTransfer, /* Tight coupling */
88 packRlcDlUserDataToRlc /* Light weight-loose coupling */
91 DuMacUeDeleteReq packMacUeDeleteReqOpts[] =
93 packDuMacUeDeleteReq, /* Loose coupling */
94 MacProcUeDeleteReq, /* TIght coupling */
95 packDuMacUeDeleteReq /* Light weight-loose coupling */
98 DuRlcUeDeleteReq packRlcUeDeleteReqOpts[] =
100 packDuRlcUeDeleteReq, /* Loose coupling */
101 RlcProcUeDeleteReq, /* TIght coupling */
102 packDuRlcUeDeleteReq /* Light weight-loose coupling */
106 /******************************************************************
108 * @brief Function to fetch lcId based on DRB Id
112 * Function : fetchLcId
116 * Functionality: Function to fetch lcId based on DRB Id
118 * Returns: lcId - SUCCESS
120 *****************************************************************/
122 uint8_t fetchLcId(uint8_t drbId)
124 uint8_t cellIdx = 0, ueIdx = 0, lcIdx = 0, numLcs = 0, lcId = 0;
126 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
128 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
130 if(duCb.actvCellLst[cellIdx] != NULLP)
132 numLcs = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.numLcs;
133 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
135 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbId == drbId && \
136 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbType == RB_TYPE_DRB)
138 lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].lcId;
145 DU_LOG("\nERROR --> DU_APP: fetchLcId() failed for drbId %d", drbId);
149 /******************************************************************
151 * @brief Function to return Drb LcId
155 * Function : getDrbLcId
157 * Functionality: Function to return Drb LcId
159 * @params[in] drbBitMap
161 * Returns: lcId - SUCCESS
163 *****************************************************************/
165 uint8_t getDrbLcId(uint32_t *drbBitMap)
167 uint8_t bitMask = 1, bitPos = 0;
168 bitPos = MIN_DRB_LCID;
170 while(bitPos <= MAX_DRB_LCID)
172 if((*drbBitMap & (bitMask << bitPos)) == 0)
174 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
182 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
186 /*******************************************************************
188 * @brief Function to fillDlUserDataInfo
192 * Function : fillDlUserDataInfo
195 * Function to fillDlUserDataInfo
200 * @return ROK - success
203 * ****************************************************************/
205 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
209 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
211 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
213 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
215 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
216 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
217 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
225 /*******************************************************************
227 * @brief Build and Send DL Data Message transfer to RLC
231 * Function : duBuildAndSendDlUserDataToRlc
234 * Build and Send DL Data Message transfer to RLC
236 * @params[in] Cell ID
238 * Logical Channgel ID
241 * @return ROK - success
244 * ****************************************************************/
246 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
248 uint8_t ret = RFAILED;
250 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
252 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
255 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
258 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
259 dlDataMsgInfo->dlMsg = egtpMsg->msg;
260 dlDataMsgInfo->msgLen = msgLen;
262 /* Filling DL DATA Msg Info */
263 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
265 /* Filling post structure and sending msg */
266 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
267 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
268 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
269 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
273 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
274 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
275 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
280 /*******************************************************************
282 * @brief Handles EGTP data from CU
286 * Function : duHdlEgtpData
289 * Processes EGTP header and sends data to RLC
291 * @params[in] Pointer to EGTP Message
292 * @return ROK - success
295 * ****************************************************************/
296 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
300 #ifdef CALL_FLOW_DEBUG_LOG
301 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
304 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
308 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
311 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
312 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
314 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
315 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
321 /******************************************************************
323 * @brief Builds and Sends DL CCCH Ind to MAC
327 * Function : duBuildAndSendDlCcchInd
329 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
331 * @params[in] dlCcchMsg - uint8_t*
332 * @return ROK - success
335 * ****************************************************************/
336 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
337 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
341 DlCcchIndInfo *dlCcchIndInfo = NULLP;
344 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
346 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
350 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
354 dlCcchIndInfo->cellId = *cellId;
355 dlCcchIndInfo->crnti = *crnti;
356 dlCcchIndInfo->msgType = msgType;
357 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
359 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
360 if(!dlCcchIndInfo->dlCcchMsg)
362 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
363 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
366 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
368 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
370 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
373 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
374 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
377 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
378 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
379 dlCcchIndInfo->dlCcchMsgLen);
380 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
381 sizeof(DlCcchIndInfo));
389 /*******************************************************************
391 * @brief Build and Send DL RRC Message transfer to RLC
395 * Function : duBuildAndSendDlRrcMsgToRlc
398 * Build and Send DL RRC Message transfer to RLC
400 * @params[in] Cell ID
402 * Logical Channgel ID
405 * @return ROK - success
408 * ****************************************************************/
409 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
414 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
418 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
422 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
425 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
426 duBuildAndSendDlRrcMsgToRlc");
427 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
431 /* Filling up the RRC msg info */
432 dlRrcMsgInfo->cellId = cellId;
433 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
434 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
436 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
438 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
439 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
440 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
441 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
445 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
446 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
447 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
448 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
450 /* Filling post structure and sending msg */
451 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
452 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
453 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
456 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
457 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
466 /******************************************************************
468 * @brief Process DL RRC Msg recevied from F1AP
472 * Function : duProcDlRrcMsg
474 * Functionality: Process DL RRC Msg recevied from F1AP
476 * @params[in] dlCcchMsg - uint8_t*
477 * @return ROK - success
480 * ****************************************************************/
482 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
485 uint16_t crnti, cellId, cellIdx;
486 bool ueCcchCtxtFound = false;
487 bool ueFound = false;
491 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
493 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
495 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
497 ueCcchCtxtFound = true;
498 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
499 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
506 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
509 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
513 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
515 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
518 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
519 duCb.ueCcchCtxt[ueIdx].cellId);
524 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
531 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
533 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
535 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
536 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
539 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
540 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
553 /******************************************************************
555 * @brief Generates GNB DU Ue F1AP ID
559 * Function : genGnbDuUeF1apId
561 * Functionality: Generates GNB DU Ue F1AP ID
564 * @return gnbDuF1apId
566 * ****************************************************************/
567 int32_t genGnbDuUeF1apId(uint8_t cellId)
571 GET_CELL_IDX(cellId, cellIdx);
572 if(duCb.actvCellLst[cellIdx])
574 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
578 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
583 /******************************************************************
585 * @brief Processes UL CCCH Ind recvd from MAC
589 * Function : duProcUlCcchInd
591 * Functionality: Processes UL CCCH Ind recvd from MAC
593 * @params[in] UlCcchIndInfo *ulCcchIndInfo
594 * @return ROK - success
597 * ****************************************************************/
598 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
602 int32_t gnbDuUeF1apId = 0;
604 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
606 if(gnbDuUeF1apId == -1)
608 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
612 /* Store Ue mapping */
613 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
614 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
615 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
619 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
620 ulCcchIndInfo->ulCcchMsg));
623 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
626 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
627 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
633 /******************************************************************
635 * @brief Fills Default UL LC Cfg
639 * Function : fillDefaultUlLcCfg
641 * Functionality: Fills Default UL LC Cfg
643 * @params[in] UlLcCfg *ulLcCfg
645 *****************************************************************/
646 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
648 ulLcCfg->priority = LC_PRIORITY_1;
649 ulLcCfg->lcGroup = 0;
650 ulLcCfg->schReqId = 0;
651 ulLcCfg->pbr = PBR_KBPS_INFINITY;
652 ulLcCfg->bsd = BSD_MS_1000;
655 /******************************************************************
657 * @brief Fills Initial DL Bandwidth Part
661 * Function : fillDefaultInitDlBwp
663 * Functionality: Fills Initial DL Bandwidth Part
665 * @params[in] InitialDlBwp *initDlBwp
668 *****************************************************************/
669 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
672 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
673 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
678 /* Filling PDCCH Config */
679 initDlBwp->pdcchPresent = TRUE;
680 if(initDlBwp->pdcchPresent)
682 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
683 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
684 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
686 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
687 PDCCH_CTRL_RSRC_SET_ONE_ID;
688 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
690 coreset0EndPrb = CORESET0_END_PRB;
691 coreset1StartPrb = coreset0EndPrb +6;
692 coreset1NumPrb = CORESET1_NUM_PRB;
693 /* calculate the PRBs */
694 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
695 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
698 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
699 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
700 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
701 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
702 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
704 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
707 initDlBwp->pdcchCfg.numCRsetToRel = 0;
708 /* Filling Serach Space */
709 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
710 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
711 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
713 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
714 PDCCH_SRCH_SPC_TWO_ID;
715 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
716 PDCCH_CTRL_RSRC_SET_ONE_ID;
717 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
718 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
719 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
720 MONITORING_SYMB_WITHIN_SLOT_SIZE);
721 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
722 PDCCH_SYMBOL_WITHIN_SLOT;
723 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
725 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
727 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
729 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
731 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
733 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
734 SEARCHSPACETYPE_PR_UE_SPECIFIC;
735 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
736 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
738 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
742 /* Filling PDSCH Config */
743 initDlBwp->pdschPresent = TRUE;
744 if(initDlBwp->pdschPresent)
746 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
747 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
748 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
749 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
751 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
752 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
753 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
754 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
755 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
756 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
757 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
758 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
764 /******************************************************************
766 * @brief Fills Initial UL Bandwidth Part
770 * Function : fillDefaultInitUlBwp
772 * Functionality: Fills Initial UL Bandwidth Part
774 * @params[in] InitialUlBwp *initUlBwp
777 *****************************************************************/
778 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
783 initUlBwp->pucchPresent = FALSE;
785 /*Filling PUSCH Config */
786 initUlBwp->puschPresent = TRUE;
787 if(initUlBwp->puschPresent)
789 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
790 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
791 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
792 scramblingId0 = SCRAMBLING_ID;
793 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
794 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
796 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
798 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
799 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
801 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
802 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
803 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
804 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
807 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
808 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
809 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
810 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
811 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
812 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
814 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
819 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
823 /******************************************************************
825 * @brief Fills SpCell Group Info
829 * Function : fillDefaultSpCellGrpInfo
831 * Functionality: Fills Sp Cell Group Info
833 * @params[in] MacUeCfg *macUeCfg
836 *****************************************************************/
837 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
839 SpCellCfg *spCell = NULL;
842 spCell = &macUeCfg->spCellCfg;
846 macUeCfg->spCellCfgPres = true;
848 spCell->servCellIdx = SERV_CELL_IDX;
849 /* Filling Initial Dl Bwp */
850 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
852 spCell->servCellCfg.numDlBwpToAdd = 0;
853 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
854 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
855 spCell->servCellCfg.bwpInactivityTmr = NULLP;
856 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
857 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
858 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
859 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
860 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
861 NUM_HARQ_PROC_FOR_PDSCH_N_16;
862 /* Filling Initial UL Bwp*/
863 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
864 spCell->servCellCfg.numUlBwpToAdd = 0;
865 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
869 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
873 /******************************************************************
875 * @brief Fills Physical Cell Group Info
879 * Function : fillDefaultPhyCellGrpInfo
881 * Functionality: Fills Physical Cell Group Info
883 * @params[in] MacUeCfg *macUeCfg
886 *****************************************************************/
887 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
889 PhyCellGrpCfg *cellGrp = NULL;
892 cellGrp = &macUeCfg->phyCellGrpCfg;
896 macUeCfg->phyCellGrpCfgPres = true;
897 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
898 cellGrp->pNrFr1 = P_NR_FR1;
902 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
906 /******************************************************************
908 * @brief Fills Mac Cell Group Info
912 * Function : fillDefaultMacCellGrpInfo
914 * Functionality: Fills Mac Cell Group Info
916 * @params[in] MacUeCfg *macUeCfg
919 *****************************************************************/
920 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
923 MacCellGrpCfg *cellGrp = NULL;
926 cellGrp = &macUeCfg->macCellGrpCfg;
930 macUeCfg->macCellGrpCfgPres = true;
932 /* Filling Scheduling Request Config */
933 cellGrp->schReqCfg.addModListCount = 1;
934 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
936 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
938 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
939 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
940 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
943 cellGrp->schReqCfg.relListCount = 0;
945 /* Filling Tag config */
946 cellGrp->tagCfg.addModListCount = 1;
947 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
949 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
951 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
952 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
955 cellGrp->tagCfg.relListCount = 0;
957 /* Filling BSR config */
958 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
959 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
960 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
962 /* Filling PHR config */
963 cellGrp->phrCfgSetupPres = true;
964 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
965 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
966 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
967 cellGrp->phrCfg.multiplePHR = false;
968 cellGrp->phrCfg.dummy = false;
969 cellGrp->phrCfg.phrType2OtherCell = false;
970 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
975 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
979 /*******************************************************************
981 * @brief Fills default modulation info for a UE
985 * Function : fillDefaultModulation
987 * Functionality: Fills default modulation info for a UE
989 * @params[in] Pointer to MAC UE configuration
990 * @return ROK - success
993 * ****************************************************************/
994 void fillDefaultModulation(MacUeCfg *ueCfg)
996 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
997 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
998 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1000 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
1001 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
1002 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1005 /******************************************************************
1007 * @brief Function to fill Mac Lc Cfg for SRB1
1011 * Function : fillMacSrb1LcCfg
1013 * Functionality: Function to fill Mac Lc cfg for SRB1
1015 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1017 *****************************************************************/
1019 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
1021 macLcCfg->lcId = SRB1_LCID;
1022 macLcCfg->configType = CONFIG_ADD;
1023 macLcCfg->drbQos = NULLP;
1024 macLcCfg->snssai = NULLP;
1025 macLcCfg->ulLcCfgPres = true;
1026 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
1029 /******************************************************************
1031 * @brief Function to fill the Lc cfg from ueSetupReqDb
1035 * Function : fillMacLcCfgToAddMod
1037 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1039 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1040 * @return ROK/RFAILED
1042 *****************************************************************/
1044 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1050 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1051 macLcCfgToSend->configType = ueLcCfgDb->configType;
1053 if(ueLcCfgDb->drbQos)
1054 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1056 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1058 macLcCfgToSend->drbQos = NULL;
1060 if(ueLcCfgDb->snssai)
1061 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1063 macLcCfgToSend->snssai = oldLcCfg->snssai;
1065 macLcCfgToSend->snssai = NULL;
1067 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1068 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1069 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1074 oldLcCfg->lcId = ueLcCfgDb->lcId;
1075 oldLcCfg->configType = ueLcCfgDb->configType;
1077 if(ueLcCfgDb->drbQos)
1079 if(oldLcCfg->drbQos)
1080 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1082 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1083 if(oldLcCfg->drbQos == NULL)
1085 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1088 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1091 if(ueLcCfgDb->snssai)
1093 if(oldLcCfg->snssai)
1094 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1096 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1097 if(oldLcCfg->snssai == NULL)
1099 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1100 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1103 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1106 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1107 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1108 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1113 /******************************************************************
1115 * @brief Function to copy the Bit rate from ueSetupReqDb
1119 * Function : fillAmbr
1121 * Functionality: Function to copy bit Rate from ueSetupReqDb
1123 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1124 * @return ROK/RFAILED
1126 *****************************************************************/
1128 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1134 *macAmbrCfgToSend = ueDbAmbr;
1137 *macAmbrCfgToSend = *oldMacAmbrCfg;
1145 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1147 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1148 if(*oldMacAmbrCfg == NULLP)
1150 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1153 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1154 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1161 /******************************************************************
1163 * @brief Builds and Send UE ReConfig Request to MAC
1167 * Function : sendUeReCfgReqToMac
1169 * Functionality: Builds and Send UE ReConfig Request to MAC
1171 * @Params[in] MacUeCfg pointer
1172 * @return ROK - success
1175 * ****************************************************************/
1177 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1183 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1187 /* Processing one Ue at a time to MAC */
1188 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1189 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1192 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1193 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1198 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1206 /******************************************************************
1208 * @brief Fills MacUeCfg structure
1212 * Function : fillMacUeCfg
1214 * Functionality: Fills MacUeCfg
1216 * @params[in] cellId, ueIdx, crnti,
1219 * @return ROK/RFAILED
1221 *****************************************************************/
1222 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1223 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1225 uint8_t ret, dbIdx, lcIdx, cellIdx;
1226 bool lcIdFound = false;
1227 MacUeCfg *duMacDb = NULLP;
1233 macUeCfg->cellId = cellId;
1234 macUeCfg->ueIdx = ueIdx;
1235 macUeCfg->crnti = crnti;
1237 fillDefaultMacCellGrpInfo(macUeCfg);
1238 fillDefaultPhyCellGrpInfo(macUeCfg);
1239 fillDefaultSpCellGrpInfo(macUeCfg);
1240 macUeCfg->ambrCfg = NULLP;
1241 fillDefaultModulation(macUeCfg);
1242 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1247 /* Fetching MacDb from DuUeCb */
1248 GET_CELL_IDX(cellId, cellIdx);
1249 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1250 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1251 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1252 macUeCfg->cellId = cellId;
1253 macUeCfg->ueIdx = ueIdx;
1254 macUeCfg->crnti = crnti;
1255 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1258 if(macUeCfg->spCellCfgPres == true)
1260 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1262 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1263 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1265 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1267 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1268 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1271 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1272 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1275 /* Filling LC Context */
1276 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1278 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1280 /* Filling default UL LC config in MAC if not present */
1281 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1282 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1284 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1286 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1289 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1290 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1292 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1293 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx],\
1294 &duMacDb->lcCfgList[lcIdx], FALSE);
1302 /* ADD/DEL CONFIG */
1303 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1311 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1314 }/*End of Outer FOR loop */
1315 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1320 /******************************************************************
1322 * @brief Fills Rlc AM Information
1326 * Function : fillDefaultAmInfo
1328 * Functionality: Fills Rlc AM Information
1330 * @params[in] AmBearerCfg *amCfg
1333 *****************************************************************/
1334 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1337 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1338 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1339 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1340 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1341 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1344 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1345 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1346 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1349 /******************************************************************
1351 * @brief Fills RLC UM Bi Directional Information
1355 * Function : fillDefaultUmBiInfo
1357 * Functionality: Fills RLC UM Bi Directional Information
1359 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1362 *****************************************************************/
1363 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1365 /* UL UM BI DIR INFO */
1366 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1367 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1369 /* DL UM BI DIR INFO */
1370 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1373 /******************************************************************
1375 * @brief Fills RLC UM Uni Directional UL Information
1379 * Function : fillDefaultUmUlInfo
1381 * Functionality: Fills RLC UM Uni Directional Info
1383 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1386 *****************************************************************/
1387 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1389 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1390 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1393 /******************************************************************
1395 * @brief Fills RLC UM Uni Directional DL Information
1399 * Function : fillDefaultUmDlInfo
1401 * Functionality: Fills RLC UM Uni Directional DL Info
1403 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1406 *****************************************************************/
1407 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1409 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1412 /******************************************************************
1414 * @brief Builds Rlc Mode Default Configuration
1418 * Function : fillDefaultRlcModeCfg
1420 * Functionality: Builds Rlc Mode Default Configuration
1422 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1423 * @return ROK/RFAILED
1425 *****************************************************************/
1427 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1437 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1439 fillDefaultAmInfo(lcCfg->u.amCfg);
1442 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1448 case RLC_UM_BI_DIRECTIONAL :
1450 if(!lcCfg->u.umBiDirCfg)
1452 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1453 if(lcCfg->u.umBiDirCfg)
1454 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1457 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1463 case RLC_UM_UNI_DIRECTIONAL_UL :
1465 if(!lcCfg->u.umUniDirUlCfg)
1467 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1468 if(lcCfg->u.umUniDirUlCfg)
1469 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1472 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1478 case RLC_UM_UNI_DIRECTIONAL_DL :
1480 if(!lcCfg->u.umUniDirDlCfg)
1482 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1483 if(lcCfg->u.umUniDirDlCfg)
1484 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1487 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1494 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1501 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1507 /*******************************************************************
1509 * @brief Function to fill Rlc Lc Cfg for SRB1
1513 * Function : fillRlcSrb1LcCfg
1516 * Function to fill Rlc Lc Cfg for SRB1
1518 * @params[in] Pointer to RlcBearerCfg
1519 * @return ROK/RFAILED
1521 *****************************************************************/
1523 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1527 rlcLcCfg->rbId = SRB1_LCID;
1528 rlcLcCfg->rbType = RB_TYPE_SRB;
1529 rlcLcCfg->lcId = SRB1_LCID;
1530 rlcLcCfg->lcType = LCH_DCCH;
1531 rlcLcCfg->rlcMode = RLC_AM;
1532 rlcLcCfg->configType = CONFIG_ADD;
1533 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1537 /*******************************************************************
1539 * @brief Processes UE ReConfig Req to RLC UL
1543 * Function : sendUeReCfgReqToRlc
1546 * Processes UE Reconfig Req to RLC UL
1548 * @params[in] Pointer to RlcUeCfg
1549 * @return ROK - success
1552 *****************************************************************/
1554 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1559 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1562 /* Processing one Ue at a time to RLC */
1563 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1564 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1567 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1568 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1573 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1579 /******************************************************************
1581 * @brief Fills Snssai information
1585 * Function : fillSnssaiInfo
1587 * Functionality: Fills Snssai information
1589 * @params[in] LcCfg *snssaiTobeSend, LcCfg *snssaiDb, LcCfg *oldSnssai,
1591 * @return ROK - success
1594 *****************************************************************/
1595 uint8_t fillSnssaiInfo(Snssai *snssaiTobeSend, Snssai *snssaiDb, Snssai **oldSnssai, Bool toUpdate)
1600 snssaiTobeSend = snssaiDb;
1602 snssaiTobeSend = *oldSnssai;
1604 snssaiTobeSend = NULL;
1611 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldSnssai, sizeof(Snssai));
1613 DU_ALLOC_SHRABL_BUF(*oldSnssai, sizeof(Snssai));
1614 if(*oldSnssai == NULL)
1616 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillSnssaiInfo()");
1619 memcpy(*oldSnssai, snssaiDb, sizeof(Snssai));
1624 /******************************************************************
1626 * @brief Fills RlcBearerCfg structure
1630 * Function : fillRlcUeCfg
1632 * Functionality: Fills Rlc Bearer Cfg
1635 *****************************************************************/
1636 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1637 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1639 uint8_t ret, dbIdx, lcIdx, cellIdx;
1640 bool lcIdFound = false;
1641 RlcUeCfg *duRlcDb = NULLP;
1646 /* Initial RB being Added */
1647 rlcUeCfg->cellId = cellId;
1648 rlcUeCfg->ueIdx = ueIdx;
1649 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1653 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1657 /* Fetch RlcDb from DuUeCb */
1658 GET_CELL_IDX(cellId, cellIdx);
1659 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1660 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1661 /*Filling RlcUeCfg */
1662 rlcUeCfg->cellId = cellId;
1663 rlcUeCfg->ueIdx = ueIdx;
1664 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1666 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1669 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1670 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1673 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1674 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1676 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1679 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1680 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1683 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1684 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1685 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai,\
1686 &duRlcDb->rlcLcCfg[lcIdx].snssai,false);
1694 /* ADD/ DEL Config Type */
1695 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1696 fillSnssaiInfo(rlcUeCfg->rlcLcCfg[dbIdx].snssai, ueCfgDb->rlcLcCfg[dbIdx].snssai, NULL, false);
1704 /******************************************************************
1706 * @brief creates UE context
1710 * Function : duCreateUeCb
1712 * Functionality: Creates UE Conetxt
1714 * @params[in] UeCcchCtxt Pointer
1717 * @return ROK - success
1719 * ****************************************************************/
1720 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1722 uint8_t cellIdx = 0;
1726 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1728 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1730 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1731 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1733 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1734 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1735 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1736 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1737 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1738 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1740 /* Filling Mac Ue Config */
1741 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1742 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1743 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1745 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1747 /* Filling Rlc Ue Config */
1748 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1749 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1750 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1752 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1754 duCb.actvCellLst[cellIdx]->numActvUes++;
1755 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1762 /******************************************************************
1764 * @brief Builds and Send UE Create Request to MAC
1768 * Function : duBuildAndSendUeCreateReqToMac
1770 * Functionality: Builds and Send UE Create Request to MAC
1772 * @Params[in] cellId,
1774 * @return ROK - success
1777 * ****************************************************************/
1779 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1780 uint16_t crnti, MacUeCfg *duMacUeCfg)
1783 MacUeCfg *macUeCfg = NULLP;
1785 memset(&pst, 0, sizeof(Pst));
1788 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1791 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1795 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1797 /* Copying ueCb to a sharable buffer */
1798 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1801 memset(macUeCfg, 0, sizeof(MacUeCfg));
1802 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1803 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1805 /* Processing one Ue at a time to MAC */
1806 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1809 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1810 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1815 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1821 /*******************************************************************
1823 * @brief To update DuUeCb Mac Cfg
1827 * Function : duUpdateMacCfg
1828 * Functionality: update DuUeCb MAC Cfg
1830 * @params[in] DuUeCb Pointer
1831 * F1UeContextSetupDb pointer
1832 * @return ROK - success
1835 * ****************************************************************/
1836 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1838 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1839 MacUeCfg *oldMacUeCfg;
1842 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1843 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1845 /*Filling Cell Group Cfg*/
1846 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1849 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1851 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1852 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1854 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1856 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1857 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1859 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1860 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1863 /* Filling LC Context */
1864 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1866 numLcs = macUeCfg->numLcs;
1867 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1869 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1871 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1873 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1875 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1877 /* Free memory at matched lcIdx index */
1878 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1880 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1882 /* moving all elements one index ahead */
1883 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1884 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1887 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1894 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1896 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1899 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1909 /******************************************************************
1911 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1915 * Function : fillRlcCfgToAddMod
1917 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1920 *****************************************************************/
1922 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1924 lcCfg->configType = f1UeDbLcCfg->configType;
1925 lcCfg->rbId = f1UeDbLcCfg->rbId;
1926 lcCfg->rbType = f1UeDbLcCfg->rbType;
1927 lcCfg->lcId = f1UeDbLcCfg->lcId;
1928 lcCfg->lcType = f1UeDbLcCfg->lcType;
1929 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1931 switch(lcCfg->rlcMode)
1937 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1942 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1943 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1944 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1945 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1946 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1949 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1950 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1951 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1954 case RLC_UM_BI_DIRECTIONAL :
1956 if(!lcCfg->u.umBiDirCfg)
1958 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1959 if(!lcCfg->u.umBiDirCfg)
1962 /* UL UM BI DIR INFO */
1963 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1964 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1965 /* DL UM BI DIR INFO */
1966 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1969 case RLC_UM_UNI_DIRECTIONAL_UL :
1971 if(!lcCfg->u.umUniDirUlCfg)
1973 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1974 if(!lcCfg->u.umUniDirUlCfg)
1977 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1978 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1982 case RLC_UM_UNI_DIRECTIONAL_DL :
1984 if(!lcCfg->u.umUniDirDlCfg)
1986 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1987 if(!lcCfg->u.umUniDirDlCfg)
1990 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1994 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
2000 /*******************************************************************
2002 * @brief To update DuUeCb Rlc Lc Cfg
2006 * Function : duUpdateRlcLcCfg
2007 * Functionality: update DuUeCb Rlc Lc Cfg
2009 * @params[in] DuUeCb Pointer
2010 * F1UeContextSetupDb pointer
2011 * @return ROK - success
2014 * ****************************************************************/
2016 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
2018 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
2021 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
2023 numLcs = rlcUeCfg->numLcs;
2024 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
2026 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
2028 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
2030 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2033 DU_LOG("\nERROR --> DU APP : Failed to modify LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2036 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[lcIdx].snssai, true);
2038 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
2040 /* Free memory at matched lcIdx index */
2041 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
2043 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
2045 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2046 fillSnssaiInfo(NULL, rlcUeCfg->rlcLcCfg[lcDelIdx+1].snssai, &rlcUeCfg->rlcLcCfg[lcDelIdx].snssai,\
2048 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
2051 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2058 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2060 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2063 fillSnssaiInfo(NULL, f1UeDb->duUeCfg.rlcLcCfg[dbIdx].snssai, &rlcUeCfg->rlcLcCfg[ rlcUeCfg->numLcs].snssai,\
2072 /*******************************************************************
2074 * @brief Function to fill Tunnel Config to Add/Mod
2079 * Function : fillTnlCfgToAddMod
2081 * Functionality: Function to fill tunnel Config to Add/Mod
2083 * @params[in] Pointer to tnlCfgDb,
2084 * pointer to f1TnlCfg
2085 * @return ROK - success
2088 * ****************************************************************/
2089 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2093 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2094 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2097 if(*ueCbTnlCfg == NULLP)
2099 /* copying to DuCb Tnl Cfg */
2100 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2101 if(*ueCbTnlCfg == NULLP)
2103 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2107 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2108 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2109 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2110 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2111 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2112 if(f1TnlCfg->tnlCfg1)
2114 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2116 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2117 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2119 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2123 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2124 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2125 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2126 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2131 /*******************************************************************
2133 * @brief Processing the tunnel Request to EGTP
2137 * Function : duProcEgtpTunnelCfg
2139 * Functionality: Processing the tunnel Request to EGTP
2141 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2142 * @return ROK - success
2145 * ****************************************************************/
2147 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2149 uint8_t ret = RFAILED, delIdx;
2151 if(f1TnlCfg->tnlCfg1 == NULLP)
2153 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2157 if(f1TnlCfg->configType == CONFIG_ADD)
2159 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2161 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2168 else if(f1TnlCfg->configType == CONFIG_MOD)
2170 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2172 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2178 else if(f1TnlCfg->configType == CONFIG_DEL)
2180 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2182 /* Free memory at drbIdx */
2184 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2186 /* moving all elements one index ahead */
2187 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2193 if(duCb.upTnlCfg[delIdx])
2195 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2196 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2203 /***********************************************************************
2205 * @brief Function to fill Tunnel Config
2206 * and sends tunnel Req to EGTP
2211 * Function : duUpdateTunnelCfgDb
2213 * Functionality: Function to fill tunnel Config
2214 * and sends tunnel Cfg Req to EGTP
2216 * @params[in] ueIdx, cellId, DuUeCfg
2217 * @return ROK - success
2220 * ****************************************************************/
2222 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2224 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2225 bool drbFound = false;
2227 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2228 /*then update drbId and tunnel Info in duCb */
2229 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2231 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2232 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2233 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2235 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2237 drbFound = true; /* existing DRB */
2238 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2240 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2241 duUeCfg->upTnlInfo[drbIdx].drbId);
2249 if(!drbFound && ret == ROK)/* new DRB to Add */
2251 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2253 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2254 duUeCfg->upTnlInfo[drbIdx].drbId);
2265 /*******************************************************************
2267 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2272 * Function : duUpdateDuUeCbCfg
2274 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2276 * @params[in] ueIdx, cellIdx
2277 * @return ROK - success
2280 * ****************************************************************/
2282 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2284 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2285 DuUeCb *ueCb = NULLP;
2287 GET_CELL_IDX(cellId, cellIdx);
2289 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2290 macUeCfgState == UE_RECFG_COMPLETE) &&
2291 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2292 rlcUeCfgState == UE_RECFG_COMPLETE))
2294 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2296 /*Filling RLC Ue Cfg */
2297 ueCb->rlcUeCfg.cellId = cellId;
2298 ueCb->rlcUeCfg.ueIdx = ueIdx;
2299 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2302 /*Filling MAC Ue Cfg */
2303 GET_CRNTI(crnti, ueIdx);
2304 ueCb->macUeCfg.cellId = cellId;
2305 ueCb->macUeCfg.ueIdx = ueIdx;
2306 ueCb->macUeCfg.crnti = crnti;
2307 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2309 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2312 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2314 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2320 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2327 /*******************************************************************
2329 * @brief Handle UE config response from MAC
2333 * Function : DuProcMacUeCfgRsp
2335 * Functionality: Handle UE Config response from MAC
2337 * @params[in] Pointer to MacUeCfgRsp and Pst
2338 * @return ROK - success
2341 * ****************************************************************/
2342 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2348 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2350 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2352 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2353 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2354 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2356 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2358 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2359 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2360 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2361 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2363 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2369 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2370 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2372 //TODO: Send the failure case in Ue Context Setup Response
2376 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2380 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2387 /*******************************************************************
2389 * @brief Processes UE create Req to RLC UL
2393 * Function : duBuildAndSendUeCreateReqToRlc
2396 * Processes UE create Req to RLC UL
2398 * @params[in] cellId,
2400 * Pointer to RlcUeCfg
2401 * @return ROK - success
2404 *****************************************************************/
2406 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2407 RlcUeCfg *duRlcUeCfg)
2410 RlcUeCfg *rlcUeCfg = NULLP;
2413 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2416 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2420 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2421 /* Copying ueCfg to a sharable buffer */
2422 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2425 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2426 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2427 /* Processing one Ue at a time to RLC */
2428 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2429 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2432 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2433 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2439 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2445 /*******************************************************************
2447 * @brief Processes UE create Rsp received from RLC UL
2452 * Function : DuProcRlcUeCfgRsp
2455 * Processes UE create Rsp received from RLC UL
2457 * @params[in] Post structure
2458 * Pointer to RlcCfgCfm
2459 * @return ROK - success
2462 *****************************************************************/
2463 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2469 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2471 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2473 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2474 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2475 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2477 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2479 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2480 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2481 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2482 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2484 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2490 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2491 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2492 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2494 //TODO: update failure case in ue Context setup Response
2498 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2502 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2508 /*******************************************************************
2510 * @brief Builds and Send Ue Reconfig Req to RLC
2514 * Function : duBuildAndSendUeReCfgReqToRLC
2516 * Functionality: Builds and Send Ue Reconfig Req to RLC
2518 * @params[in] cellId, crnti
2520 * RlcUeCfg *rlcUeCfg
2521 * @return ROK - success
2524 * ****************************************************************/
2526 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2528 uint8_t ret = ROK, ueIdx = 0;
2529 RlcUeCfg *rlcUeCfg = NULLP;
2531 GET_UE_IDX(crnti, ueIdx);
2532 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2535 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2536 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2538 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2540 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2544 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2550 /*******************************************************************
2552 * @brief Builds and Send Ue Reconfig Req to MAC
2556 * Function : duBuildAndSendUeReCfgReqToMac
2558 * Functionality: Builds and Send Ue Reconfig Req to MAC
2560 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2562 * MacUeCfg *macUeCfg
2563 * @return ROK - success
2566 * ****************************************************************/
2568 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2570 uint8_t ret, ueIdx = 0;
2571 MacUeCfg *macUeCfg = NULLP;
2574 GET_UE_IDX(crnti, ueIdx);
2576 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2579 memset(macUeCfg, 0, sizeof(MacUeCfg));
2580 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2582 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2584 ret = sendUeReCfgReqToMac(macUeCfg);
2588 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2594 /*******************************************************************
2596 * @brief Build and Send Ue context setup request
2601 * Function : duBuildAndSendUeContextSetupReq
2604 * Build and Send Ue context setup request
2606 * @params[in] cellId, crnti, DuUeCfg pointer
2607 * @return ROK - success
2610 *****************************************************************/
2612 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2616 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2617 /* Filling RLC Ue Reconfig */
2618 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2620 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2622 /* Filling MAC Ue Reconfig */
2623 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2625 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2630 /*******************************************************************
2632 * @brief Processes DL Rsp received from RLC DL
2637 * Function : DuProcRlcDlRrcMsgRsp
2640 * Processes UE Rsp received from RLC DL
2642 * @params[in] Post structure
2643 * Pointer to RlcCfgCfm
2644 * @return ROK - success
2647 *****************************************************************/
2648 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2650 uint8_t ret = ROK, ueIdx = 0;
2651 uint16_t cellId, crnti;
2652 DuUeCb *ueCb = NULLP;
2655 state = dlRrcMsg->state;
2656 cellId = dlRrcMsg->cellId;
2657 crnti = dlRrcMsg->crnti;
2658 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2660 if(state == TRANSMISSION_COMPLETE)
2662 GET_UE_IDX(crnti, ueIdx);
2663 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2665 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2667 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2669 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2671 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2674 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2676 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2678 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2681 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2683 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2686 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2692 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2696 /*******************************************************************
2698 * @brief Process UE context setup request from CU
2702 * Function : duProcUeContextSetupRequest
2704 * Functionality: Process UE context setup request from CU
2706 * @params[in] F1AP message
2707 * @return ROK - success
2710 * ****************************************************************/
2712 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2714 uint8_t ret, cellId;
2719 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2720 /* Send DL RRC msg for security Mode */
2721 if(ueCb->f1UeDb->dlRrcMsg)
2723 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2725 /* Sending DL RRC Message to RLC */
2726 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2729 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2730 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2731 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2732 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2736 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2738 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2741 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2747 //TODO: To send the failure cause in UeContextSetupRsp
2748 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2753 /*******************************************************************
2755 * @brief Build and Send Ue context mod request
2760 * Function : duBuildAndSendUeContextModReq
2763 * Build and Send Ue context mod request
2765 * @params[in] cellId, crnti, DuUeCfg pointer
2766 * @return ROK - success
2769 *****************************************************************/
2771 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2775 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2776 /* Filling RLC Ue Reconfig */
2777 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2779 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2781 /* Filling MAC Ue Reconfig */
2782 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2784 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2788 /*******************************************************************
2790 * @brief Processing Ue context mod request
2795 * Function : duProcUeContextModReq
2798 * Processing Ue context mod request
2800 * @params[in] DuUeCb *ueCb
2801 * @return ROK - success
2804 *****************************************************************/
2806 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2808 uint8_t ret, cellId;
2813 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2814 /* Send DL RRC msg for security Mode */
2815 if(ueCb->f1UeDb->dlRrcMsg)
2817 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2819 /* Sending DL RRC Message to RLC */
2820 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2823 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2824 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2825 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2826 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2832 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2835 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2841 //TODO: To send the failure cause in UeContextModRsp
2842 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2847 /*******************************************************************
2849 * @brief Function to delete Pdsch ServCellCfg
2853 * Function : deletePdschServCellCfg
2855 * Functionality: Function to delete Pdsch ServCellCfg
2857 * @params[in] PdschServCellCfg *pdschServCellCfg
2860 * ****************************************************************/
2862 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2864 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2865 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2866 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2867 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2870 /*******************************************************************
2872 * @brief delete MacUeCfg from duCb
2876 * Function : deleteMacUeCfg
2878 * Functionality: delete MacUeCfg from duCb
2880 * @params[in] Pointer to MacUeCfg
2881 * @return ROK - success
2884 *******************************************************************/
2886 void deleteMacUeCfg(MacUeCfg *ueCfg)
2890 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2891 if(ueCfg->spCellCfgPres)
2893 freeUeReCfgCellGrpInfo(ueCfg);
2895 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2897 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2899 memset(ueCfg, 0, sizeof(MacUeCfg));
2902 /*******************************************************************
2904 * @brief delete UE Configuration of a particular UE
2908 * Function : deleteUeCfg
2910 * Functionality: delete UE Configuration of a particular UE
2912 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2913 * @return ROK - success
2916 * ****************************************************************/
2917 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2920 DuUeCb *ueCb = NULLP;
2922 if(duCb.actvCellLst[cellIdx] != NULLP)
2924 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2925 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2927 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2928 deleteMacUeCfg(&ueCb->macUeCfg);
2929 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2930 if(ueCb->f1UeDb !=NULLP)
2932 freeF1UeDb(ueCb->f1UeDb);
2934 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2936 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2938 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2939 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2944 duCb.actvCellLst[cellIdx]->numActvUes--;
2945 memset(ueCb, 0, sizeof(DuUeCb));
2954 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2961 /*******************************************************************
2963 * @brief Handle UE delete response from MAC
2967 * Function : DuProcMacUeDeleteRsp
2969 * Functionality: Handle UE delete response from MAC
2971 * @params[in] Pointer to MacUeDeleteRsp and Pst
2972 * @return ROK - success
2975 * ****************************************************************/
2977 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2979 uint8_t ret =ROK,ueId=0;
2981 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2985 if(deleteRsp->result == SUCCESS)
2987 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2988 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2989 if(duCb.actvCellLst[cellIdx])
2991 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2992 ueId = deleteRsp->ueId;
2993 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2994 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2995 if(deleteUeCfg(cellIdx, ueId) == ROK)
2997 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
3000 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
3008 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
3012 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
3016 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
3022 /*******************************************************************
3024 * @brief Processes UE Delete Rsp received from RLC
3028 * Function : DuProcRlcUeDeleteRsp
3031 * Processes UE Delete Rsp received from RLC
3033 * @params[in] Post structure
3034 * Pointer to RlcUeDeleteRsp
3035 * @return ROK - success
3038 * *****************************************************************/
3040 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
3042 uint8_t ueId = 0, ret = ROK;
3043 uint16_t cellIdx = 0,crnti=0;
3047 ueId = delRsp->ueId;
3048 GET_CELL_IDX(delRsp->cellId, cellIdx);
3050 if(delRsp->result == SUCCESSFUL)
3052 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
3053 if(duCb.actvCellLst[cellIdx]!=NULLP)
3055 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
3056 GET_CRNTI(crnti, ueId);
3057 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
3059 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3067 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3070 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3076 /*******************************************************************
3078 * @brief Sending UE Delete Req To Mac
3082 * Function : sendUeDeleteReqToMac
3085 * sending UE Delete Req To Mac
3087 * @params[in] cellId, ueId, crnti
3088 * @return ROK - success
3091 *****************************************************************/
3093 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3097 MacUeDelete *ueDelete = NULLP;
3099 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3102 ueDelete->cellId = cellId;
3103 ueDelete->ueId = ueId;
3104 ueDelete->crnti = crnti;
3105 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3107 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3108 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3111 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3112 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3117 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3123 /*******************************************************************
3125 * @brief Sending UE Delete Req To Rlc
3129 * Function : sendUeDeleteReqToRlc
3132 * Sending UE Delete Req To Rlc
3134 * @params[in] cellId, ueId
3135 * @return ROK - success
3138 *****************************************************************/
3140 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3144 RlcUeDelete *ueDelete;
3146 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3147 if(ueDelete !=NULLP)
3149 ueDelete->cellId = cellId;
3150 ueDelete->ueId = ueId;
3151 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3153 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3156 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3157 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3162 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3168 /*******************************************************************
3170 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3174 * Function : duBuildAndSendUeDeleteReq
3176 * Functionality: DU processes UE delete req from CU and sends to MAC
3179 * @params[in] cellId, crnti
3180 * @return ROK - success
3183 * ****************************************************************/
3185 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3188 uint16_t cellIdx = 0;
3190 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3191 GET_CELL_IDX(cellId, cellIdx);
3192 GET_UE_IDX(crnti, ueId);
3194 if(duCb.actvCellLst[cellIdx] != NULLP)
3196 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3198 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3202 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3203 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3205 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3211 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3218 /*******************************************************************
3220 * @brief delete RlcUeCfg from duCb
3224 * Function : deleteRlcUeCfg
3227 * delete RlcUeCfg from duCb
3229 * @params[in] RlcUeCfg *ueCfg
3231 * @return ROK - success
3234 *****************************************************************/
3236 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3239 RlcBearerCfg *lcCfg= NULLP;
3242 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3244 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3245 switch(lcCfg->rlcMode)
3249 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3252 case RLC_UM_BI_DIRECTIONAL :
3254 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3257 case RLC_UM_UNI_DIRECTIONAL_UL :
3259 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3262 case RLC_UM_UNI_DIRECTIONAL_DL :
3264 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3268 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
3270 memset(ueCfg, 0, sizeof(RlcUeCfg));
3274 /*******************************************************************
3276 * @brief Du process Ue Context Release Command
3280 * Function : duProcUeContextReleaseCommand
3282 * Functionality: Du process Ue Context Release Command
3284 * @params[in] DuUeCb *duUeCb
3285 * @return ROK - success
3288 * ****************************************************************/
3289 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3291 uint8_t ret =ROK, ueIdx=0;
3292 uint16_t cellId=0,crnti =0;
3295 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3298 if(duUeCb->f1UeDb == NULLP)
3300 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3304 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3305 crnti = duUeCb->crnti;
3306 /* Send DL RRC msg for RRC release */
3307 if(duUeCb->f1UeDb->dlRrcMsg)
3309 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3311 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3312 duUeCb->f1UeDb->dlRrcMsg);
3315 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3316 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3317 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3318 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3324 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3327 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3334 /**********************************************************************
3336 ***********************************************************************/