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)
137 lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].lcId;
144 DU_LOG("\nERROR --> DU_APP: fetchLcId() failed for drbId %d", drbId);
148 /******************************************************************
150 * @brief Function to return Drb LcId
154 * Function : getDrbLcId
156 * Functionality: Function to return Drb LcId
158 * @params[in] drbBitMap
160 * Returns: lcId - SUCCESS
162 *****************************************************************/
164 uint8_t getDrbLcId(uint32_t *drbBitMap)
166 uint8_t bitMask = 1, bitPos = 0;
167 bitPos = MIN_DRB_LCID;
169 while(bitPos <= MAX_DRB_LCID)
171 if((*drbBitMap & (bitMask << bitPos)) == 0)
173 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
181 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
185 /*******************************************************************
187 * @brief Function to fillDlUserDataInfo
191 * Function : fillDlUserDataInfo
194 * Function to fillDlUserDataInfo
199 * @return ROK - success
202 * ****************************************************************/
204 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
208 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
210 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
212 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
214 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
215 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
216 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
224 /*******************************************************************
226 * @brief Build and Send DL Data Message transfer to RLC
230 * Function : duBuildAndSendDlUserDataToRlc
233 * Build and Send DL Data Message transfer to RLC
235 * @params[in] Cell ID
237 * Logical Channgel ID
240 * @return ROK - success
243 * ****************************************************************/
245 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
247 uint8_t ret = RFAILED;
249 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
251 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
254 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
257 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
258 dlDataMsgInfo->dlMsg = egtpMsg->msg;
259 dlDataMsgInfo->msgLen = msgLen;
261 /* Filling DL DATA Msg Info */
262 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
264 /* Filling post structure and sending msg */
265 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
266 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
267 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
268 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
272 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
273 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
274 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
279 /*******************************************************************
281 * @brief Handles EGTP data from CU
285 * Function : duHdlEgtpData
288 * Processes EGTP header and sends data to RLC
290 * @params[in] Pointer to EGTP Message
291 * @return ROK - success
294 * ****************************************************************/
295 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
299 #ifdef CALL_FLOW_DEBUG_LOG
300 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
303 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
307 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
310 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
311 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
313 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
314 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
320 /******************************************************************
322 * @brief Builds and Sends DL CCCH Ind to MAC
326 * Function : duBuildAndSendDlCcchInd
328 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
330 * @params[in] dlCcchMsg - uint8_t*
331 * @return ROK - success
334 * ****************************************************************/
335 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
336 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
340 DlCcchIndInfo *dlCcchIndInfo = NULLP;
343 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
345 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
349 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
353 dlCcchIndInfo->cellId = *cellId;
354 dlCcchIndInfo->crnti = *crnti;
355 dlCcchIndInfo->msgType = msgType;
356 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
358 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
359 if(!dlCcchIndInfo->dlCcchMsg)
361 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
362 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
365 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
367 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
369 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
372 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
373 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
376 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
377 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
378 dlCcchIndInfo->dlCcchMsgLen);
379 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
380 sizeof(DlCcchIndInfo));
388 /*******************************************************************
390 * @brief Build and Send DL RRC Message transfer to RLC
394 * Function : duBuildAndSendDlRrcMsgToRlc
397 * Build and Send DL RRC Message transfer to RLC
399 * @params[in] Cell ID
401 * Logical Channgel ID
404 * @return ROK - success
407 * ****************************************************************/
408 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
413 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
417 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
421 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
424 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
425 duBuildAndSendDlRrcMsgToRlc");
426 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
430 /* Filling up the RRC msg info */
431 dlRrcMsgInfo->cellId = cellId;
432 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
433 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
435 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
437 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
438 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
439 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
440 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
444 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
445 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
446 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
447 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
449 /* Filling post structure and sending msg */
450 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
451 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
452 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
455 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
456 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
465 /******************************************************************
467 * @brief Process DL RRC Msg recevied from F1AP
471 * Function : duProcDlRrcMsg
473 * Functionality: Process DL RRC Msg recevied from F1AP
475 * @params[in] dlCcchMsg - uint8_t*
476 * @return ROK - success
479 * ****************************************************************/
481 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
484 uint16_t crnti, cellId, cellIdx;
485 bool ueCcchCtxtFound = false;
486 bool ueFound = false;
490 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
492 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
494 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
496 ueCcchCtxtFound = true;
497 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
498 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
505 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
508 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
512 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
514 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
517 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
518 duCb.ueCcchCtxt[ueIdx].cellId);
523 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
530 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
532 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
534 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
535 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
538 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
539 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
552 /******************************************************************
554 * @brief Generates GNB DU Ue F1AP ID
558 * Function : genGnbDuUeF1apId
560 * Functionality: Generates GNB DU Ue F1AP ID
563 * @return gnbDuF1apId
565 * ****************************************************************/
566 int32_t genGnbDuUeF1apId(uint8_t cellId)
570 GET_CELL_IDX(cellId, cellIdx);
571 if(duCb.actvCellLst[cellIdx])
573 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
577 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
582 /******************************************************************
584 * @brief Processes UL CCCH Ind recvd from MAC
588 * Function : duProcUlCcchInd
590 * Functionality: Processes UL CCCH Ind recvd from MAC
592 * @params[in] UlCcchIndInfo *ulCcchIndInfo
593 * @return ROK - success
596 * ****************************************************************/
597 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
601 int32_t gnbDuUeF1apId = 0;
603 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
605 if(gnbDuUeF1apId == -1)
607 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
611 /* Store Ue mapping */
612 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
613 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
614 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
618 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
619 ulCcchIndInfo->ulCcchMsg));
622 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
625 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
626 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
632 /******************************************************************
634 * @brief Fills Default UL LC Cfg
638 * Function : fillDefaultUlLcCfg
640 * Functionality: Fills Default UL LC Cfg
642 * @params[in] UlLcCfg *ulLcCfg
644 *****************************************************************/
645 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
647 ulLcCfg->priority = LC_PRIORITY_1;
648 ulLcCfg->lcGroup = 0;
649 ulLcCfg->schReqId = 0;
650 ulLcCfg->pbr = PBR_KBPS_INFINITY;
651 ulLcCfg->bsd = BSD_MS_1000;
654 /******************************************************************
656 * @brief Fills Initial DL Bandwidth Part
660 * Function : fillDefaultInitDlBwp
662 * Functionality: Fills Initial DL Bandwidth Part
664 * @params[in] InitialDlBwp *initDlBwp
667 *****************************************************************/
668 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
671 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
672 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
677 /* Filling PDCCH Config */
678 initDlBwp->pdcchPresent = TRUE;
679 if(initDlBwp->pdcchPresent)
681 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
682 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
683 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
685 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
686 PDCCH_CTRL_RSRC_SET_ONE_ID;
687 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
689 coreset0EndPrb = CORESET0_END_PRB;
690 coreset1StartPrb = coreset0EndPrb +6;
691 coreset1NumPrb = CORESET1_NUM_PRB;
692 /* calculate the PRBs */
693 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
694 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
697 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
698 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
699 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
700 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
701 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
703 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
706 initDlBwp->pdcchCfg.numCRsetToRel = 0;
707 /* Filling Serach Space */
708 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
709 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
710 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
712 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
713 PDCCH_SRCH_SPC_TWO_ID;
714 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
715 PDCCH_CTRL_RSRC_SET_ONE_ID;
716 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
717 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
718 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
719 MONITORING_SYMB_WITHIN_SLOT_SIZE);
720 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
721 PDCCH_SYMBOL_WITHIN_SLOT;
722 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
724 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
726 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
728 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
730 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
732 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
733 SEARCHSPACETYPE_PR_UE_SPECIFIC;
734 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
735 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
737 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
741 /* Filling PDSCH Config */
742 initDlBwp->pdschPresent = TRUE;
743 if(initDlBwp->pdschPresent)
745 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
746 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
747 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
748 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
750 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
751 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
752 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
753 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
754 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
755 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
756 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
757 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
763 /******************************************************************
765 * @brief Fills Initial UL Bandwidth Part
769 * Function : fillDefaultInitUlBwp
771 * Functionality: Fills Initial UL Bandwidth Part
773 * @params[in] InitialUlBwp *initUlBwp
776 *****************************************************************/
777 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
782 initUlBwp->pucchPresent = FALSE;
784 /*Filling PUSCH Config */
785 initUlBwp->puschPresent = TRUE;
786 if(initUlBwp->puschPresent)
788 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
789 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
790 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
791 scramblingId0 = SCRAMBLING_ID;
792 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
793 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
795 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
797 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
798 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
800 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
801 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
802 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
803 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
806 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
807 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
808 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
809 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
810 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
811 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
813 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
818 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
822 /******************************************************************
824 * @brief Fills SpCell Group Info
828 * Function : fillDefaultSpCellGrpInfo
830 * Functionality: Fills Sp Cell Group Info
832 * @params[in] MacUeCfg *macUeCfg
835 *****************************************************************/
836 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
838 SpCellCfg *spCell = NULL;
841 spCell = &macUeCfg->spCellCfg;
845 macUeCfg->spCellCfgPres = true;
847 spCell->servCellIdx = SERV_CELL_IDX;
848 /* Filling Initial Dl Bwp */
849 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
851 spCell->servCellCfg.numDlBwpToAdd = 0;
852 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
853 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
854 spCell->servCellCfg.bwpInactivityTmr = NULLP;
855 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
856 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
857 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
858 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
859 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
860 NUM_HARQ_PROC_FOR_PDSCH_N_16;
861 /* Filling Initial UL Bwp*/
862 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
863 spCell->servCellCfg.numUlBwpToAdd = 0;
864 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
868 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
872 /******************************************************************
874 * @brief Fills Physical Cell Group Info
878 * Function : fillDefaultPhyCellGrpInfo
880 * Functionality: Fills Physical Cell Group Info
882 * @params[in] MacUeCfg *macUeCfg
885 *****************************************************************/
886 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
888 PhyCellGrpCfg *cellGrp = NULL;
891 cellGrp = &macUeCfg->phyCellGrpCfg;
895 macUeCfg->phyCellGrpCfgPres = true;
896 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
897 cellGrp->pNrFr1 = P_NR_FR1;
901 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
905 /******************************************************************
907 * @brief Fills Mac Cell Group Info
911 * Function : fillDefaultMacCellGrpInfo
913 * Functionality: Fills Mac Cell Group Info
915 * @params[in] MacUeCfg *macUeCfg
918 *****************************************************************/
919 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
922 MacCellGrpCfg *cellGrp = NULL;
925 cellGrp = &macUeCfg->macCellGrpCfg;
929 macUeCfg->macCellGrpCfgPres = true;
931 /* Filling Scheduling Request Config */
932 cellGrp->schReqCfg.addModListCount = 1;
933 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
935 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
937 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
938 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
939 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
942 cellGrp->schReqCfg.relListCount = 0;
944 /* Filling Tag config */
945 cellGrp->tagCfg.addModListCount = 1;
946 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
948 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
950 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
951 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
954 cellGrp->tagCfg.relListCount = 0;
956 /* Filling BSR config */
957 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
958 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
959 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
961 /* Filling PHR config */
962 cellGrp->phrCfgSetupPres = true;
963 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
964 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
965 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
966 cellGrp->phrCfg.multiplePHR = false;
967 cellGrp->phrCfg.dummy = false;
968 cellGrp->phrCfg.phrType2OtherCell = false;
969 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
974 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
978 /*******************************************************************
980 * @brief Fills default modulation info for a UE
984 * Function : fillDefaultModulation
986 * Functionality: Fills default modulation info for a UE
988 * @params[in] Pointer to MAC UE configuration
989 * @return ROK - success
992 * ****************************************************************/
993 void fillDefaultModulation(MacUeCfg *ueCfg)
995 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
996 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
997 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
999 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
1000 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
1001 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
1004 /******************************************************************
1006 * @brief Function to fill Mac Lc Cfg for SRB1
1010 * Function : fillMacSrb1LcCfg
1012 * Functionality: Function to fill Mac Lc cfg for SRB1
1014 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1016 *****************************************************************/
1018 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
1020 macLcCfg->lcId = SRB1_LCID;
1021 macLcCfg->configType = CONFIG_ADD;
1022 macLcCfg->drbQos = NULLP;
1023 macLcCfg->snssai = NULLP;
1024 macLcCfg->ulLcCfgPres = true;
1025 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
1028 /******************************************************************
1030 * @brief Function to fill the Lc cfg from ueSetupReqDb
1034 * Function : fillMacLcCfgToAddMod
1036 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
1038 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
1039 * @return ROK/RFAILED
1041 *****************************************************************/
1043 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
1049 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
1050 macLcCfgToSend->configType = ueLcCfgDb->configType;
1052 if(ueLcCfgDb->drbQos)
1053 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
1055 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
1057 macLcCfgToSend->drbQos = NULL;
1059 if(ueLcCfgDb->snssai)
1060 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
1062 macLcCfgToSend->snssai = oldLcCfg->snssai;
1064 macLcCfgToSend->snssai = NULL;
1066 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1067 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1068 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1073 oldLcCfg->lcId = ueLcCfgDb->lcId;
1074 oldLcCfg->configType = ueLcCfgDb->configType;
1076 if(ueLcCfgDb->drbQos)
1078 if(oldLcCfg->drbQos)
1079 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1081 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1082 if(oldLcCfg->drbQos == NULL)
1084 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1087 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1090 if(ueLcCfgDb->snssai)
1092 if(oldLcCfg->snssai)
1093 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1095 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1096 if(oldLcCfg->snssai == NULL)
1098 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1099 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1102 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1105 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1106 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1107 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1112 /******************************************************************
1114 * @brief Function to copy the Bit rate from ueSetupReqDb
1118 * Function : fillAmbr
1120 * Functionality: Function to copy bit Rate from ueSetupReqDb
1122 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1123 * @return ROK/RFAILED
1125 *****************************************************************/
1127 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1133 *macAmbrCfgToSend = ueDbAmbr;
1136 *macAmbrCfgToSend = *oldMacAmbrCfg;
1144 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1146 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1147 if(*oldMacAmbrCfg == NULLP)
1149 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1152 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1153 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1160 /******************************************************************
1162 * @brief Builds and Send UE ReConfig Request to MAC
1166 * Function : sendUeReCfgReqToMac
1168 * Functionality: Builds and Send UE ReConfig Request to MAC
1170 * @Params[in] MacUeCfg pointer
1171 * @return ROK - success
1174 * ****************************************************************/
1176 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1182 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1186 /* Processing one Ue at a time to MAC */
1187 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1188 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1191 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1192 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1197 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1205 /******************************************************************
1207 * @brief Fills MacUeCfg structure
1211 * Function : fillMacUeCfg
1213 * Functionality: Fills MacUeCfg
1215 * @params[in] cellId, ueIdx, crnti,
1218 * @return ROK/RFAILED
1220 *****************************************************************/
1221 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1222 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1224 uint8_t ret, dbIdx, lcIdx, cellIdx;
1225 bool lcIdFound = false;
1226 MacUeCfg *duMacDb = NULLP;
1232 macUeCfg->cellId = cellId;
1233 macUeCfg->ueIdx = ueIdx;
1234 macUeCfg->crnti = crnti;
1236 fillDefaultMacCellGrpInfo(macUeCfg);
1237 fillDefaultPhyCellGrpInfo(macUeCfg);
1238 fillDefaultSpCellGrpInfo(macUeCfg);
1239 macUeCfg->ambrCfg = NULLP;
1240 fillDefaultModulation(macUeCfg);
1241 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1246 /* Fetching MacDb from DuUeCb */
1247 GET_CELL_IDX(cellId, cellIdx);
1248 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1249 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1250 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1251 macUeCfg->cellId = cellId;
1252 macUeCfg->ueIdx = ueIdx;
1253 macUeCfg->crnti = crnti;
1254 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1257 if(macUeCfg->spCellCfgPres == true)
1259 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1261 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1262 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1264 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1266 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1267 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1270 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1271 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1274 /* Filling LC Context */
1275 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1277 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1279 /* Filling default UL LC config in MAC if not present */
1280 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1281 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1283 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1285 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1288 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1289 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1291 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1292 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], &duMacDb->lcCfgList[lcIdx], FALSE);
1300 /* ADD/DEL CONFIG */
1301 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1309 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1312 }/*End of Outer FOR loop */
1313 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1318 /******************************************************************
1320 * @brief Fills Rlc AM Information
1324 * Function : fillDefaultAmInfo
1326 * Functionality: Fills Rlc AM Information
1328 * @params[in] AmBearerCfg *amCfg
1331 *****************************************************************/
1332 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1335 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1336 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1337 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1338 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1339 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1342 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1343 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1344 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1347 /******************************************************************
1349 * @brief Fills RLC UM Bi Directional Information
1353 * Function : fillDefaultUmBiInfo
1355 * Functionality: Fills RLC UM Bi Directional Information
1357 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1360 *****************************************************************/
1361 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1363 /* UL UM BI DIR INFO */
1364 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1365 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1367 /* DL UM BI DIR INFO */
1368 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1371 /******************************************************************
1373 * @brief Fills RLC UM Uni Directional UL Information
1377 * Function : fillDefaultUmUlInfo
1379 * Functionality: Fills RLC UM Uni Directional Info
1381 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1384 *****************************************************************/
1385 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1387 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1388 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1391 /******************************************************************
1393 * @brief Fills RLC UM Uni Directional DL Information
1397 * Function : fillDefaultUmDlInfo
1399 * Functionality: Fills RLC UM Uni Directional DL Info
1401 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1404 *****************************************************************/
1405 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1407 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1410 /******************************************************************
1412 * @brief Builds Rlc Mode Default Configuration
1416 * Function : fillDefaultRlcModeCfg
1418 * Functionality: Builds Rlc Mode Default Configuration
1420 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1421 * @return ROK/RFAILED
1423 *****************************************************************/
1425 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1435 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1437 fillDefaultAmInfo(lcCfg->u.amCfg);
1440 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1446 case RLC_UM_BI_DIRECTIONAL :
1448 if(!lcCfg->u.umBiDirCfg)
1450 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1451 if(lcCfg->u.umBiDirCfg)
1452 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1455 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1461 case RLC_UM_UNI_DIRECTIONAL_UL :
1463 if(!lcCfg->u.umUniDirUlCfg)
1465 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1466 if(lcCfg->u.umUniDirUlCfg)
1467 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1470 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1476 case RLC_UM_UNI_DIRECTIONAL_DL :
1478 if(!lcCfg->u.umUniDirDlCfg)
1480 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1481 if(lcCfg->u.umUniDirDlCfg)
1482 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1485 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1492 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1499 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1505 /*******************************************************************
1507 * @brief Function to fill Rlc Lc Cfg for SRB1
1511 * Function : fillRlcSrb1LcCfg
1514 * Function to fill Rlc Lc Cfg for SRB1
1516 * @params[in] Pointer to RlcBearerCfg
1517 * @return ROK/RFAILED
1519 *****************************************************************/
1521 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1525 rlcLcCfg->rbId = SRB1_LCID;
1526 rlcLcCfg->rbType = RB_TYPE_SRB;
1527 rlcLcCfg->lcId = SRB1_LCID;
1528 rlcLcCfg->lcType = LCH_DCCH;
1529 rlcLcCfg->rlcMode = RLC_AM;
1530 rlcLcCfg->configType = CONFIG_ADD;
1531 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1535 /*******************************************************************
1537 * @brief Processes UE ReConfig Req to RLC UL
1541 * Function : sendUeReCfgReqToRlc
1544 * Processes UE Reconfig Req to RLC UL
1546 * @params[in] Pointer to RlcUeCfg
1547 * @return ROK - success
1550 *****************************************************************/
1552 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1557 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1560 /* Processing one Ue at a time to RLC */
1561 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1562 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1565 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1566 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1571 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1577 /******************************************************************
1579 * @brief Fills RlcBearerCfg structure
1583 * Function : fillRlcUeCfg
1585 * Functionality: Fills Rlc Bearer Cfg
1588 *****************************************************************/
1589 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1590 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1592 uint8_t ret, dbIdx, lcIdx, cellIdx;
1593 bool lcIdFound = false;
1594 RlcUeCfg *duRlcDb = NULLP;
1599 /* Initial RB being Added */
1600 rlcUeCfg->cellId = cellId;
1601 rlcUeCfg->ueIdx = ueIdx;
1602 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1606 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1610 /* Fetch RlcDb from DuUeCb */
1611 GET_CELL_IDX(cellId, cellIdx);
1612 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1613 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1614 /*Filling RlcUeCfg */
1615 rlcUeCfg->cellId = cellId;
1616 rlcUeCfg->ueIdx = ueIdx;
1617 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1619 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1622 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1623 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1626 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1627 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1629 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1632 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1633 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1636 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1637 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1645 /* ADD/ DEL Config Type */
1646 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1654 /******************************************************************
1656 * @brief creates UE context
1660 * Function : duCreateUeCb
1662 * Functionality: Creates UE Conetxt
1664 * @params[in] UeCcchCtxt Pointer
1667 * @return ROK - success
1669 * ****************************************************************/
1670 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1672 uint8_t cellIdx = 0;
1676 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1678 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1680 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1681 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1683 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1684 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1685 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1686 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1687 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1688 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1690 /* Filling Mac Ue Config */
1691 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1692 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1693 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1695 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1697 /* Filling Rlc Ue Config */
1698 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1699 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1700 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1702 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1704 duCb.actvCellLst[cellIdx]->numActvUes++;
1705 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1712 /******************************************************************
1714 * @brief Builds and Send UE Create Request to MAC
1718 * Function : duBuildAndSendUeCreateReqToMac
1720 * Functionality: Builds and Send UE Create Request to MAC
1722 * @Params[in] cellId,
1724 * @return ROK - success
1727 * ****************************************************************/
1729 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1730 uint16_t crnti, MacUeCfg *duMacUeCfg)
1733 MacUeCfg *macUeCfg = NULLP;
1735 memset(&pst, 0, sizeof(Pst));
1738 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1741 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1745 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1747 /* Copying ueCb to a sharable buffer */
1748 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1751 memset(macUeCfg, 0, sizeof(MacUeCfg));
1752 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1753 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1755 /* Processing one Ue at a time to MAC */
1756 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1759 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1760 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1765 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1771 /*******************************************************************
1773 * @brief To update DuUeCb Mac Cfg
1777 * Function : duUpdateMacCfg
1778 * Functionality: update DuUeCb MAC Cfg
1780 * @params[in] DuUeCb Pointer
1781 * F1UeContextSetupDb pointer
1782 * @return ROK - success
1785 * ****************************************************************/
1786 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1788 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1789 MacUeCfg *oldMacUeCfg;
1792 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1793 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1795 /*Filling Cell Group Cfg*/
1796 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1799 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1801 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1802 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1804 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1806 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1807 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1809 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1810 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1813 /* Filling LC Context */
1814 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1816 numLcs = macUeCfg->numLcs;
1817 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1819 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1821 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1823 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1825 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1827 /* Free memory at matched lcIdx index */
1828 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1830 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1832 /* moving all elements one index ahead */
1833 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1834 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1837 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1844 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1846 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1849 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1859 /******************************************************************
1861 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1865 * Function : fillRlcCfgToAddMod
1867 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1870 *****************************************************************/
1872 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1874 lcCfg->configType = f1UeDbLcCfg->configType;
1875 lcCfg->rbId = f1UeDbLcCfg->rbId;
1876 lcCfg->rbType = f1UeDbLcCfg->rbType;
1877 lcCfg->lcId = f1UeDbLcCfg->lcId;
1878 lcCfg->lcType = f1UeDbLcCfg->lcType;
1879 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1880 switch(lcCfg->rlcMode)
1886 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1891 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1892 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1893 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1894 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1895 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1898 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1899 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1900 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1903 case RLC_UM_BI_DIRECTIONAL :
1905 if(!lcCfg->u.umBiDirCfg)
1907 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1908 if(!lcCfg->u.umBiDirCfg)
1911 /* UL UM BI DIR INFO */
1912 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1913 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1914 /* DL UM BI DIR INFO */
1915 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1918 case RLC_UM_UNI_DIRECTIONAL_UL :
1920 if(!lcCfg->u.umUniDirUlCfg)
1922 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1923 if(!lcCfg->u.umUniDirUlCfg)
1926 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1927 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1931 case RLC_UM_UNI_DIRECTIONAL_DL :
1933 if(!lcCfg->u.umUniDirDlCfg)
1935 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1936 if(!lcCfg->u.umUniDirDlCfg)
1939 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1943 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1949 /*******************************************************************
1951 * @brief To update DuUeCb Rlc Lc Cfg
1955 * Function : duUpdateRlcLcCfg
1956 * Functionality: update DuUeCb Rlc Lc Cfg
1958 * @params[in] DuUeCb Pointer
1959 * F1UeContextSetupDb pointer
1960 * @return ROK - success
1963 * ****************************************************************/
1965 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1967 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1970 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1972 numLcs = rlcUeCfg->numLcs;
1973 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1975 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1977 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1979 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1981 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1983 /* Free memory at matched lcIdx index */
1984 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1986 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1988 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1989 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1992 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1999 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2001 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2010 /*******************************************************************
2012 * @brief Function to fill Tunnel Config to Add/Mod
2017 * Function : fillTnlCfgToAddMod
2019 * Functionality: Function to fill tunnel Config to Add/Mod
2021 * @params[in] Pointer to tnlCfgDb,
2022 * pointer to f1TnlCfg
2023 * @return ROK - success
2026 * ****************************************************************/
2027 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2031 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2032 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2035 if(*ueCbTnlCfg == NULLP)
2037 /* copying to DuCb Tnl Cfg */
2038 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2039 if(*ueCbTnlCfg == NULLP)
2041 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2045 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2046 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2047 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2048 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2049 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2050 if(f1TnlCfg->tnlCfg1)
2052 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2054 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2055 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2057 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2061 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2062 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2063 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2064 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2069 /*******************************************************************
2071 * @brief Processing the tunnel Request to EGTP
2075 * Function : duProcEgtpTunnelCfg
2077 * Functionality: Processing the tunnel Request to EGTP
2079 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2080 * @return ROK - success
2083 * ****************************************************************/
2085 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2087 uint8_t ret = RFAILED, delIdx;
2089 if(f1TnlCfg->tnlCfg1 == NULLP)
2091 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2095 if(f1TnlCfg->configType == CONFIG_ADD)
2097 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2099 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2106 else if(f1TnlCfg->configType == CONFIG_MOD)
2108 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2110 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2116 else if(f1TnlCfg->configType == CONFIG_DEL)
2118 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2120 /* Free memory at drbIdx */
2122 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2124 /* moving all elements one index ahead */
2125 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2131 if(duCb.upTnlCfg[delIdx])
2133 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2134 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2141 /***********************************************************************
2143 * @brief Function to fill Tunnel Config
2144 * and sends tunnel Req to EGTP
2149 * Function : duUpdateTunnelCfgDb
2151 * Functionality: Function to fill tunnel Config
2152 * and sends tunnel Cfg Req to EGTP
2154 * @params[in] ueIdx, cellId, DuUeCfg
2155 * @return ROK - success
2158 * ****************************************************************/
2160 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2162 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2163 bool drbFound = false;
2165 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2166 /*then update drbId and tunnel Info in duCb */
2167 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2169 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2170 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2171 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2173 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2175 drbFound = true; /* existing DRB */
2176 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2178 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2179 duUeCfg->upTnlInfo[drbIdx].drbId);
2187 if(!drbFound && ret == ROK)/* new DRB to Add */
2189 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2191 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2192 duUeCfg->upTnlInfo[drbIdx].drbId);
2203 /*******************************************************************
2205 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2210 * Function : duUpdateDuUeCbCfg
2212 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2214 * @params[in] ueIdx, cellIdx
2215 * @return ROK - success
2218 * ****************************************************************/
2220 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2222 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2223 DuUeCb *ueCb = NULLP;
2225 GET_CELL_IDX(cellId, cellIdx);
2227 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2228 macUeCfgState == UE_RECFG_COMPLETE) &&
2229 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2230 rlcUeCfgState == UE_RECFG_COMPLETE))
2232 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2234 /*Filling RLC Ue Cfg */
2235 ueCb->rlcUeCfg.cellId = cellId;
2236 ueCb->rlcUeCfg.ueIdx = ueIdx;
2237 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2240 /*Filling MAC Ue Cfg */
2241 GET_CRNTI(crnti, ueIdx);
2242 ueCb->macUeCfg.cellId = cellId;
2243 ueCb->macUeCfg.ueIdx = ueIdx;
2244 ueCb->macUeCfg.crnti = crnti;
2245 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2247 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2250 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2252 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2258 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2265 /*******************************************************************
2267 * @brief Handle UE config response from MAC
2271 * Function : DuProcMacUeCfgRsp
2273 * Functionality: Handle UE Config response from MAC
2275 * @params[in] Pointer to MacUeCfgRsp and Pst
2276 * @return ROK - success
2279 * ****************************************************************/
2280 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2286 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2288 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2290 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2291 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2292 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2294 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2296 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2297 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2298 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2299 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2301 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2307 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2308 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2310 //TODO: Send the failure case in Ue Context Setup Response
2314 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2318 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2325 /*******************************************************************
2327 * @brief Processes UE create Req to RLC UL
2331 * Function : duBuildAndSendUeCreateReqToRlc
2334 * Processes UE create Req to RLC UL
2336 * @params[in] cellId,
2338 * Pointer to RlcUeCfg
2339 * @return ROK - success
2342 *****************************************************************/
2344 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2345 RlcUeCfg *duRlcUeCfg)
2348 RlcUeCfg *rlcUeCfg = NULLP;
2351 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2354 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2358 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2359 /* Copying ueCfg to a sharable buffer */
2360 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2363 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2364 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2365 /* Processing one Ue at a time to RLC */
2366 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2367 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2370 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2371 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2377 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2383 /*******************************************************************
2385 * @brief Processes UE create Rsp received from RLC UL
2390 * Function : DuProcRlcUeCfgRsp
2393 * Processes UE create Rsp received from RLC UL
2395 * @params[in] Post structure
2396 * Pointer to RlcCfgCfm
2397 * @return ROK - success
2400 *****************************************************************/
2401 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2407 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2409 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2411 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2412 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2413 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2415 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2417 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2418 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2419 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2420 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2422 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2428 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2429 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2430 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2432 //TODO: update failure case in ue Context setup Response
2436 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2440 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2446 /*******************************************************************
2448 * @brief Builds and Send Ue Reconfig Req to RLC
2452 * Function : duBuildAndSendUeReCfgReqToRLC
2454 * Functionality: Builds and Send Ue Reconfig Req to RLC
2456 * @params[in] cellId, crnti
2458 * RlcUeCfg *rlcUeCfg
2459 * @return ROK - success
2462 * ****************************************************************/
2464 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2466 uint8_t ret = ROK, ueIdx = 0;
2467 RlcUeCfg *rlcUeCfg = NULLP;
2469 GET_UE_IDX(crnti, ueIdx);
2470 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2473 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2474 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2476 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2478 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2482 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2488 /*******************************************************************
2490 * @brief Builds and Send Ue Reconfig Req to MAC
2494 * Function : duBuildAndSendUeReCfgReqToMac
2496 * Functionality: Builds and Send Ue Reconfig Req to MAC
2498 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2500 * MacUeCfg *macUeCfg
2501 * @return ROK - success
2504 * ****************************************************************/
2506 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2508 uint8_t ret, ueIdx = 0;
2509 MacUeCfg *macUeCfg = NULLP;
2512 GET_UE_IDX(crnti, ueIdx);
2514 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2517 memset(macUeCfg, 0, sizeof(MacUeCfg));
2518 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2520 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2522 ret = sendUeReCfgReqToMac(macUeCfg);
2526 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2532 /*******************************************************************
2534 * @brief Build and Send Ue context setup request
2539 * Function : duBuildAndSendUeContextSetupReq
2542 * Build and Send Ue context setup request
2544 * @params[in] cellId, crnti, DuUeCfg pointer
2545 * @return ROK - success
2548 *****************************************************************/
2550 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2554 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2555 /* Filling RLC Ue Reconfig */
2556 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2558 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2560 /* Filling MAC Ue Reconfig */
2561 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2563 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2568 /*******************************************************************
2570 * @brief Processes DL Rsp received from RLC DL
2575 * Function : DuProcRlcDlRrcMsgRsp
2578 * Processes UE Rsp received from RLC DL
2580 * @params[in] Post structure
2581 * Pointer to RlcCfgCfm
2582 * @return ROK - success
2585 *****************************************************************/
2586 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2588 uint8_t ret = ROK, ueIdx = 0;
2589 uint16_t cellId, crnti;
2590 DuUeCb *ueCb = NULLP;
2593 state = dlRrcMsg->state;
2594 cellId = dlRrcMsg->cellId;
2595 crnti = dlRrcMsg->crnti;
2596 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2598 if(state == TRANSMISSION_COMPLETE)
2600 GET_UE_IDX(crnti, ueIdx);
2601 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2603 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2605 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2607 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2609 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2612 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2614 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2616 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2619 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2621 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2624 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2630 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2634 /*******************************************************************
2636 * @brief Process UE context setup request from CU
2640 * Function : duProcUeContextSetupRequest
2642 * Functionality: Process UE context setup request from CU
2644 * @params[in] F1AP message
2645 * @return ROK - success
2648 * ****************************************************************/
2650 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2652 uint8_t ret, cellId;
2657 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2658 /* Send DL RRC msg for security Mode */
2659 if(ueCb->f1UeDb->dlRrcMsg)
2661 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2663 /* Sending DL RRC Message to RLC */
2664 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2667 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2668 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2669 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2670 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2674 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2676 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2679 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2685 //TODO: To send the failure cause in UeContextSetupRsp
2686 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2691 /*******************************************************************
2693 * @brief Build and Send Ue context mod request
2698 * Function : duBuildAndSendUeContextModReq
2701 * Build and Send Ue context mod request
2703 * @params[in] cellId, crnti, DuUeCfg pointer
2704 * @return ROK - success
2707 *****************************************************************/
2709 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2713 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2714 /* Filling RLC Ue Reconfig */
2715 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2717 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2719 /* Filling MAC Ue Reconfig */
2720 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2722 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2726 /*******************************************************************
2728 * @brief Processing Ue context mod request
2733 * Function : duProcUeContextModReq
2736 * Processing Ue context mod request
2738 * @params[in] DuUeCb *ueCb
2739 * @return ROK - success
2742 *****************************************************************/
2744 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2746 uint8_t ret, cellId;
2751 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2752 /* Send DL RRC msg for security Mode */
2753 if(ueCb->f1UeDb->dlRrcMsg)
2755 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2757 /* Sending DL RRC Message to RLC */
2758 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2761 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2762 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2763 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2764 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2770 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2773 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2779 //TODO: To send the failure cause in UeContextModRsp
2780 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2785 /*******************************************************************
2787 * @brief Function to delete Pdsch ServCellCfg
2791 * Function : deletePdschServCellCfg
2793 * Functionality: Function to delete Pdsch ServCellCfg
2795 * @params[in] PdschServCellCfg *pdschServCellCfg
2798 * ****************************************************************/
2800 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2802 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2803 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2804 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2805 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2808 /*******************************************************************
2810 * @brief delete MacUeCfg from duCb
2814 * Function : deleteMacUeCfg
2816 * Functionality: delete MacUeCfg from duCb
2818 * @params[in] Pointer to MacUeCfg
2819 * @return ROK - success
2822 *******************************************************************/
2824 void deleteMacUeCfg(MacUeCfg *ueCfg)
2828 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2829 if(ueCfg->spCellCfgPres)
2831 freeUeReCfgCellGrpInfo(ueCfg);
2833 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2835 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2837 memset(ueCfg, 0, sizeof(MacUeCfg));
2840 /*******************************************************************
2842 * @brief delete UE Configuration of a particular UE
2846 * Function : deleteUeCfg
2848 * Functionality: delete UE Configuration of a particular UE
2850 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2851 * @return ROK - success
2854 * ****************************************************************/
2855 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2858 DuUeCb *ueCb = NULLP;
2860 if(duCb.actvCellLst[cellIdx] != NULLP)
2862 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2863 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2865 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2866 deleteMacUeCfg(&ueCb->macUeCfg);
2867 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2868 if(ueCb->f1UeDb !=NULLP)
2870 freeF1UeDb(ueCb->f1UeDb);
2872 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2874 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2876 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2877 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2882 duCb.actvCellLst[cellIdx]->numActvUes--;
2883 memset(ueCb, 0, sizeof(DuUeCb));
2892 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2899 /*******************************************************************
2901 * @brief Handle UE delete response from MAC
2905 * Function : DuProcMacUeDeleteRsp
2907 * Functionality: Handle UE delete response from MAC
2909 * @params[in] Pointer to MacUeDeleteRsp and Pst
2910 * @return ROK - success
2913 * ****************************************************************/
2915 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2917 uint8_t ret =ROK,ueId=0;
2919 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2923 if(deleteRsp->result == SUCCESS)
2925 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2926 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2927 if(duCb.actvCellLst[cellIdx])
2929 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2930 ueId = deleteRsp->ueId;
2931 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2932 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2933 if(deleteUeCfg(cellIdx, ueId) == ROK)
2935 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2938 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2946 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2950 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2954 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2960 /*******************************************************************
2962 * @brief Processes UE Delete Rsp received from RLC
2966 * Function : DuProcRlcUeDeleteRsp
2969 * Processes UE Delete Rsp received from RLC
2971 * @params[in] Post structure
2972 * Pointer to RlcUeDeleteRsp
2973 * @return ROK - success
2976 * *****************************************************************/
2978 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2980 uint8_t ueId = 0, ret = ROK;
2981 uint16_t cellIdx = 0,crnti=0;
2985 ueId = delRsp->ueId;
2986 GET_CELL_IDX(delRsp->cellId, cellIdx);
2988 if(delRsp->result == SUCCESSFUL)
2990 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2991 if(duCb.actvCellLst[cellIdx]!=NULLP)
2993 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2994 GET_CRNTI(crnti, ueId);
2995 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2997 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3005 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3008 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3014 /*******************************************************************
3016 * @brief Sending UE Delete Req To Mac
3020 * Function : sendUeDeleteReqToMac
3023 * sending UE Delete Req To Mac
3025 * @params[in] cellId, ueId, crnti
3026 * @return ROK - success
3029 *****************************************************************/
3031 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3035 MacUeDelete *ueDelete = NULLP;
3037 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3040 ueDelete->cellId = cellId;
3041 ueDelete->ueId = ueId;
3042 ueDelete->crnti = crnti;
3043 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3045 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3046 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3049 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3050 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3055 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3061 /*******************************************************************
3063 * @brief Sending UE Delete Req To Rlc
3067 * Function : sendUeDeleteReqToRlc
3070 * Sending UE Delete Req To Rlc
3072 * @params[in] cellId, ueId
3073 * @return ROK - success
3076 *****************************************************************/
3078 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3082 RlcUeDelete *ueDelete;
3084 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3085 if(ueDelete !=NULLP)
3087 ueDelete->cellId = cellId;
3088 ueDelete->ueId = ueId;
3089 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3091 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3094 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3095 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3100 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3106 /*******************************************************************
3108 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3112 * Function : duBuildAndSendUeDeleteReq
3114 * Functionality: DU processes UE delete req from CU and sends to MAC
3117 * @params[in] cellId, crnti
3118 * @return ROK - success
3121 * ****************************************************************/
3123 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3126 uint16_t cellIdx = 0;
3128 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3129 GET_CELL_IDX(cellId, cellIdx);
3130 GET_UE_IDX(crnti, ueId);
3132 if(duCb.actvCellLst[cellIdx] != NULLP)
3134 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3136 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3140 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3141 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3143 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3149 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3156 /*******************************************************************
3158 * @brief delete RlcUeCfg from duCb
3162 * Function : deleteRlcUeCfg
3165 * delete RlcUeCfg from duCb
3167 * @params[in] RlcUeCfg *ueCfg
3169 * @return ROK - success
3172 *****************************************************************/
3174 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3177 RlcBearerCfg *lcCfg= NULLP;
3180 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3182 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3183 switch(lcCfg->rlcMode)
3187 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3190 case RLC_UM_BI_DIRECTIONAL :
3192 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3195 case RLC_UM_UNI_DIRECTIONAL_UL :
3197 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3200 case RLC_UM_UNI_DIRECTIONAL_DL :
3202 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3207 memset(ueCfg, 0, sizeof(RlcUeCfg));
3211 /*******************************************************************
3213 * @brief Du process Ue Context Release Command
3217 * Function : duProcUeContextReleaseCommand
3219 * Functionality: Du process Ue Context Release Command
3221 * @params[in] DuUeCb *duUeCb
3222 * @return ROK - success
3225 * ****************************************************************/
3226 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3228 uint8_t ret =ROK, ueIdx=0;
3229 uint16_t cellId=0,crnti =0;
3232 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3235 if(duUeCb->f1UeDb == NULLP)
3237 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3241 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3242 crnti = duUeCb->crnti;
3243 /* Send DL RRC msg for RRC release */
3244 if(duUeCb->f1UeDb->dlRrcMsg)
3246 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3248 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3249 duUeCb->f1UeDb->dlRrcMsg);
3252 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3253 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3254 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3255 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3261 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3264 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3271 /**********************************************************************
3273 ***********************************************************************/