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 freqDomRscAllocType0(((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], &duMacDb->lcCfgList[lcIdx], FALSE);
1301 /* ADD/DEL CONFIG */
1302 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1310 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1313 }/*End of Outer FOR loop */
1314 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1319 /******************************************************************
1321 * @brief Fills Rlc AM Information
1325 * Function : fillDefaultAmInfo
1327 * Functionality: Fills Rlc AM Information
1329 * @params[in] AmBearerCfg *amCfg
1332 *****************************************************************/
1333 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1336 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1337 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1338 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1339 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1340 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1343 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1344 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1345 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1348 /******************************************************************
1350 * @brief Fills RLC UM Bi Directional Information
1354 * Function : fillDefaultUmBiInfo
1356 * Functionality: Fills RLC UM Bi Directional Information
1358 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1361 *****************************************************************/
1362 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1364 /* UL UM BI DIR INFO */
1365 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1366 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1368 /* DL UM BI DIR INFO */
1369 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1372 /******************************************************************
1374 * @brief Fills RLC UM Uni Directional UL Information
1378 * Function : fillDefaultUmUlInfo
1380 * Functionality: Fills RLC UM Uni Directional Info
1382 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1385 *****************************************************************/
1386 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1388 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1389 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1392 /******************************************************************
1394 * @brief Fills RLC UM Uni Directional DL Information
1398 * Function : fillDefaultUmDlInfo
1400 * Functionality: Fills RLC UM Uni Directional DL Info
1402 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1405 *****************************************************************/
1406 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1408 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1411 /******************************************************************
1413 * @brief Builds Rlc Mode Default Configuration
1417 * Function : fillDefaultRlcModeCfg
1419 * Functionality: Builds Rlc Mode Default Configuration
1421 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1422 * @return ROK/RFAILED
1424 *****************************************************************/
1426 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1436 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1438 fillDefaultAmInfo(lcCfg->u.amCfg);
1441 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1447 case RLC_UM_BI_DIRECTIONAL :
1449 if(!lcCfg->u.umBiDirCfg)
1451 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1452 if(lcCfg->u.umBiDirCfg)
1453 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1456 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1462 case RLC_UM_UNI_DIRECTIONAL_UL :
1464 if(!lcCfg->u.umUniDirUlCfg)
1466 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1467 if(lcCfg->u.umUniDirUlCfg)
1468 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1471 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1477 case RLC_UM_UNI_DIRECTIONAL_DL :
1479 if(!lcCfg->u.umUniDirDlCfg)
1481 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1482 if(lcCfg->u.umUniDirDlCfg)
1483 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1486 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1493 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1500 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1506 /*******************************************************************
1508 * @brief Function to fill Rlc Lc Cfg for SRB1
1512 * Function : fillRlcSrb1LcCfg
1515 * Function to fill Rlc Lc Cfg for SRB1
1517 * @params[in] Pointer to RlcBearerCfg
1518 * @return ROK/RFAILED
1520 *****************************************************************/
1522 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1526 rlcLcCfg->rbId = SRB1_LCID;
1527 rlcLcCfg->rbType = RB_TYPE_SRB;
1528 rlcLcCfg->lcId = SRB1_LCID;
1529 rlcLcCfg->lcType = LCH_DCCH;
1530 rlcLcCfg->rlcMode = RLC_AM;
1531 rlcLcCfg->configType = CONFIG_ADD;
1532 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1536 /*******************************************************************
1538 * @brief Processes UE ReConfig Req to RLC UL
1542 * Function : sendUeReCfgReqToRlc
1545 * Processes UE Reconfig Req to RLC UL
1547 * @params[in] Pointer to RlcUeCfg
1548 * @return ROK - success
1551 *****************************************************************/
1553 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1558 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1561 /* Processing one Ue at a time to RLC */
1562 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1563 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1566 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1567 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1572 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1578 /******************************************************************
1580 * @brief Fills RlcBearerCfg structure
1584 * Function : fillRlcUeCfg
1586 * Functionality: Fills Rlc Bearer Cfg
1589 *****************************************************************/
1590 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1591 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1593 uint8_t ret, dbIdx, lcIdx, cellIdx;
1594 bool lcIdFound = false;
1595 RlcUeCfg *duRlcDb = NULLP;
1600 /* Initial RB being Added */
1601 rlcUeCfg->cellId = cellId;
1602 rlcUeCfg->ueIdx = ueIdx;
1603 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1607 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1611 /* Fetch RlcDb from DuUeCb */
1612 GET_CELL_IDX(cellId, cellIdx);
1613 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1614 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1615 /*Filling RlcUeCfg */
1616 rlcUeCfg->cellId = cellId;
1617 rlcUeCfg->ueIdx = ueIdx;
1618 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1620 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1623 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1624 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1627 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1628 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1630 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1633 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1634 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1637 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1638 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1646 /* ADD/ DEL Config Type */
1647 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1655 /******************************************************************
1657 * @brief creates UE context
1661 * Function : duCreateUeCb
1663 * Functionality: Creates UE Conetxt
1665 * @params[in] UeCcchCtxt Pointer
1668 * @return ROK - success
1670 * ****************************************************************/
1671 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1673 uint8_t cellIdx = 0;
1677 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1679 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1681 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1682 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1684 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1685 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1686 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1687 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1688 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1689 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1691 /* Filling Mac Ue Config */
1692 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1693 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1694 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1696 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1698 /* Filling Rlc Ue Config */
1699 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1700 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1701 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1703 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1705 duCb.actvCellLst[cellIdx]->numActvUes++;
1706 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1713 /******************************************************************
1715 * @brief Builds and Send UE Create Request to MAC
1719 * Function : duBuildAndSendUeCreateReqToMac
1721 * Functionality: Builds and Send UE Create Request to MAC
1723 * @Params[in] cellId,
1725 * @return ROK - success
1728 * ****************************************************************/
1730 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1731 uint16_t crnti, MacUeCfg *duMacUeCfg)
1734 MacUeCfg *macUeCfg = NULLP;
1736 memset(&pst, 0, sizeof(Pst));
1739 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1742 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1746 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1748 /* Copying ueCb to a sharable buffer */
1749 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1752 memset(macUeCfg, 0, sizeof(MacUeCfg));
1753 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1754 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1756 /* Processing one Ue at a time to MAC */
1757 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1760 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1761 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1766 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1772 /*******************************************************************
1774 * @brief To update DuUeCb Mac Cfg
1778 * Function : duUpdateMacCfg
1779 * Functionality: update DuUeCb MAC Cfg
1781 * @params[in] DuUeCb Pointer
1782 * F1UeContextSetupDb pointer
1783 * @return ROK - success
1786 * ****************************************************************/
1787 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1789 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1790 MacUeCfg *oldMacUeCfg;
1793 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1794 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1796 /*Filling Cell Group Cfg*/
1797 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1800 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1802 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1803 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1805 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1807 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1808 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1810 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1811 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1814 /* Filling LC Context */
1815 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1817 numLcs = macUeCfg->numLcs;
1818 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1820 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1822 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1824 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1826 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1828 /* Free memory at matched lcIdx index */
1829 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1831 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1833 /* moving all elements one index ahead */
1834 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1835 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1838 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1845 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1847 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1850 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1860 /******************************************************************
1862 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1866 * Function : fillRlcCfgToAddMod
1868 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1871 *****************************************************************/
1873 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1875 lcCfg->configType = f1UeDbLcCfg->configType;
1876 lcCfg->rbId = f1UeDbLcCfg->rbId;
1877 lcCfg->rbType = f1UeDbLcCfg->rbType;
1878 lcCfg->lcId = f1UeDbLcCfg->lcId;
1879 lcCfg->lcType = f1UeDbLcCfg->lcType;
1880 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1881 switch(lcCfg->rlcMode)
1887 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1892 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1893 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1894 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1895 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1896 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1899 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1900 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1901 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1904 case RLC_UM_BI_DIRECTIONAL :
1906 if(!lcCfg->u.umBiDirCfg)
1908 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1909 if(!lcCfg->u.umBiDirCfg)
1912 /* UL UM BI DIR INFO */
1913 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1914 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1915 /* DL UM BI DIR INFO */
1916 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1919 case RLC_UM_UNI_DIRECTIONAL_UL :
1921 if(!lcCfg->u.umUniDirUlCfg)
1923 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1924 if(!lcCfg->u.umUniDirUlCfg)
1927 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1928 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1932 case RLC_UM_UNI_DIRECTIONAL_DL :
1934 if(!lcCfg->u.umUniDirDlCfg)
1936 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1937 if(!lcCfg->u.umUniDirDlCfg)
1940 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1944 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1950 /*******************************************************************
1952 * @brief To update DuUeCb Rlc Lc Cfg
1956 * Function : duUpdateRlcLcCfg
1957 * Functionality: update DuUeCb Rlc Lc Cfg
1959 * @params[in] DuUeCb Pointer
1960 * F1UeContextSetupDb pointer
1961 * @return ROK - success
1964 * ****************************************************************/
1966 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1968 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1971 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1973 numLcs = rlcUeCfg->numLcs;
1974 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1976 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1978 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1980 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1982 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1984 /* Free memory at matched lcIdx index */
1985 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1987 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1989 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1990 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1993 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
2000 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
2002 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
2011 /*******************************************************************
2013 * @brief Function to fill Tunnel Config to Add/Mod
2018 * Function : fillTnlCfgToAddMod
2020 * Functionality: Function to fill tunnel Config to Add/Mod
2022 * @params[in] Pointer to tnlCfgDb,
2023 * pointer to f1TnlCfg
2024 * @return ROK - success
2027 * ****************************************************************/
2028 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
2032 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2033 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
2036 if(*ueCbTnlCfg == NULLP)
2038 /* copying to DuCb Tnl Cfg */
2039 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
2040 if(*ueCbTnlCfg == NULLP)
2042 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
2046 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2047 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2048 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2049 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2050 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2051 if(f1TnlCfg->tnlCfg1)
2053 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2055 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2056 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2058 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2062 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2063 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2064 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2065 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2070 /*******************************************************************
2072 * @brief Processing the tunnel Request to EGTP
2076 * Function : duProcEgtpTunnelCfg
2078 * Functionality: Processing the tunnel Request to EGTP
2080 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2081 * @return ROK - success
2084 * ****************************************************************/
2086 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2088 uint8_t ret = RFAILED, delIdx;
2090 if(f1TnlCfg->tnlCfg1 == NULLP)
2092 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2096 if(f1TnlCfg->configType == CONFIG_ADD)
2098 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2100 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2107 else if(f1TnlCfg->configType == CONFIG_MOD)
2109 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2111 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2117 else if(f1TnlCfg->configType == CONFIG_DEL)
2119 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2121 /* Free memory at drbIdx */
2123 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2125 /* moving all elements one index ahead */
2126 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2132 if(duCb.upTnlCfg[delIdx])
2134 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2135 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2142 /***********************************************************************
2144 * @brief Function to fill Tunnel Config
2145 * and sends tunnel Req to EGTP
2150 * Function : duUpdateTunnelCfgDb
2152 * Functionality: Function to fill tunnel Config
2153 * and sends tunnel Cfg Req to EGTP
2155 * @params[in] ueIdx, cellId, DuUeCfg
2156 * @return ROK - success
2159 * ****************************************************************/
2161 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2163 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2164 bool drbFound = false;
2166 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2167 /*then update drbId and tunnel Info in duCb */
2168 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2170 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2171 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2172 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2174 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2176 drbFound = true; /* existing DRB */
2177 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2179 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2180 duUeCfg->upTnlInfo[drbIdx].drbId);
2188 if(!drbFound && ret == ROK)/* new DRB to Add */
2190 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2192 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2193 duUeCfg->upTnlInfo[drbIdx].drbId);
2204 /*******************************************************************
2206 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2211 * Function : duUpdateDuUeCbCfg
2213 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2215 * @params[in] ueIdx, cellIdx
2216 * @return ROK - success
2219 * ****************************************************************/
2221 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2223 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2224 DuUeCb *ueCb = NULLP;
2226 GET_CELL_IDX(cellId, cellIdx);
2228 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2229 macUeCfgState == UE_RECFG_COMPLETE) &&
2230 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2231 rlcUeCfgState == UE_RECFG_COMPLETE))
2233 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2235 /*Filling RLC Ue Cfg */
2236 ueCb->rlcUeCfg.cellId = cellId;
2237 ueCb->rlcUeCfg.ueIdx = ueIdx;
2238 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2241 /*Filling MAC Ue Cfg */
2242 GET_CRNTI(crnti, ueIdx);
2243 ueCb->macUeCfg.cellId = cellId;
2244 ueCb->macUeCfg.ueIdx = ueIdx;
2245 ueCb->macUeCfg.crnti = crnti;
2246 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2248 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2251 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2253 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2259 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2266 /*******************************************************************
2268 * @brief Handle UE config response from MAC
2272 * Function : DuProcMacUeCfgRsp
2274 * Functionality: Handle UE Config response from MAC
2276 * @params[in] Pointer to MacUeCfgRsp and Pst
2277 * @return ROK - success
2280 * ****************************************************************/
2281 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2287 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2289 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2291 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2292 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2293 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2295 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2297 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2298 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2299 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2300 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2302 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2308 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2309 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2311 //TODO: Send the failure case in Ue Context Setup Response
2315 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2319 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2326 /*******************************************************************
2328 * @brief Processes UE create Req to RLC UL
2332 * Function : duBuildAndSendUeCreateReqToRlc
2335 * Processes UE create Req to RLC UL
2337 * @params[in] cellId,
2339 * Pointer to RlcUeCfg
2340 * @return ROK - success
2343 *****************************************************************/
2345 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2346 RlcUeCfg *duRlcUeCfg)
2349 RlcUeCfg *rlcUeCfg = NULLP;
2352 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2355 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2359 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2360 /* Copying ueCfg to a sharable buffer */
2361 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2364 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2365 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2366 /* Processing one Ue at a time to RLC */
2367 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2368 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2371 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2372 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2378 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2384 /*******************************************************************
2386 * @brief Processes UE create Rsp received from RLC UL
2391 * Function : DuProcRlcUeCfgRsp
2394 * Processes UE create Rsp received from RLC UL
2396 * @params[in] Post structure
2397 * Pointer to RlcCfgCfm
2398 * @return ROK - success
2401 *****************************************************************/
2402 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2408 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2410 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2412 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2413 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2414 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2416 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2418 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2419 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2420 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2421 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2423 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2429 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2430 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2431 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2433 //TODO: update failure case in ue Context setup Response
2437 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2441 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2447 /*******************************************************************
2449 * @brief Builds and Send Ue Reconfig Req to RLC
2453 * Function : duBuildAndSendUeReCfgReqToRLC
2455 * Functionality: Builds and Send Ue Reconfig Req to RLC
2457 * @params[in] cellId, crnti
2459 * RlcUeCfg *rlcUeCfg
2460 * @return ROK - success
2463 * ****************************************************************/
2465 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2467 uint8_t ret = ROK, ueIdx = 0;
2468 RlcUeCfg *rlcUeCfg = NULLP;
2470 GET_UE_IDX(crnti, ueIdx);
2471 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2474 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2475 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2477 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2479 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2483 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2489 /*******************************************************************
2491 * @brief Builds and Send Ue Reconfig Req to MAC
2495 * Function : duBuildAndSendUeReCfgReqToMac
2497 * Functionality: Builds and Send Ue Reconfig Req to MAC
2499 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2501 * MacUeCfg *macUeCfg
2502 * @return ROK - success
2505 * ****************************************************************/
2507 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2509 uint8_t ret, ueIdx = 0;
2510 MacUeCfg *macUeCfg = NULLP;
2513 GET_UE_IDX(crnti, ueIdx);
2515 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2518 memset(macUeCfg, 0, sizeof(MacUeCfg));
2519 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2521 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2523 ret = sendUeReCfgReqToMac(macUeCfg);
2527 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2533 /*******************************************************************
2535 * @brief Build and Send Ue context setup request
2540 * Function : duBuildAndSendUeContextSetupReq
2543 * Build and Send Ue context setup request
2545 * @params[in] cellId, crnti, DuUeCfg pointer
2546 * @return ROK - success
2549 *****************************************************************/
2551 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2555 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2556 /* Filling RLC Ue Reconfig */
2557 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2559 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2561 /* Filling MAC Ue Reconfig */
2562 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2564 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2569 /*******************************************************************
2571 * @brief Processes DL Rsp received from RLC DL
2576 * Function : DuProcRlcDlRrcMsgRsp
2579 * Processes UE Rsp received from RLC DL
2581 * @params[in] Post structure
2582 * Pointer to RlcCfgCfm
2583 * @return ROK - success
2586 *****************************************************************/
2587 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2589 uint8_t ret = ROK, ueIdx = 0;
2590 uint16_t cellId, crnti;
2591 DuUeCb *ueCb = NULLP;
2594 state = dlRrcMsg->state;
2595 cellId = dlRrcMsg->cellId;
2596 crnti = dlRrcMsg->crnti;
2597 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2599 if(state == TRANSMISSION_COMPLETE)
2601 GET_UE_IDX(crnti, ueIdx);
2602 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2604 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2606 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2608 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2610 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2613 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2615 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2617 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2620 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2622 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2625 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2631 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2635 /*******************************************************************
2637 * @brief Process UE context setup request from CU
2641 * Function : duProcUeContextSetupRequest
2643 * Functionality: Process UE context setup request from CU
2645 * @params[in] F1AP message
2646 * @return ROK - success
2649 * ****************************************************************/
2651 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2653 uint8_t ret, cellId;
2658 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2659 /* Send DL RRC msg for security Mode */
2660 if(ueCb->f1UeDb->dlRrcMsg)
2662 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2664 /* Sending DL RRC Message to RLC */
2665 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2668 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2669 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2670 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2671 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2675 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2677 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2680 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2686 //TODO: To send the failure cause in UeContextSetupRsp
2687 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2692 /*******************************************************************
2694 * @brief Build and Send Ue context mod request
2699 * Function : duBuildAndSendUeContextModReq
2702 * Build and Send Ue context mod request
2704 * @params[in] cellId, crnti, DuUeCfg pointer
2705 * @return ROK - success
2708 *****************************************************************/
2710 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2714 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2715 /* Filling RLC Ue Reconfig */
2716 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2718 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2720 /* Filling MAC Ue Reconfig */
2721 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2723 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2727 /*******************************************************************
2729 * @brief Processing Ue context mod request
2734 * Function : duProcUeContextModReq
2737 * Processing Ue context mod request
2739 * @params[in] DuUeCb *ueCb
2740 * @return ROK - success
2743 *****************************************************************/
2745 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2747 uint8_t ret, cellId;
2752 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2753 /* Send DL RRC msg for security Mode */
2754 if(ueCb->f1UeDb->dlRrcMsg)
2756 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2758 /* Sending DL RRC Message to RLC */
2759 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2762 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2763 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2764 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2765 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2771 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2774 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2780 //TODO: To send the failure cause in UeContextModRsp
2781 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2786 /*******************************************************************
2788 * @brief Function to delete Pdsch ServCellCfg
2792 * Function : deletePdschServCellCfg
2794 * Functionality: Function to delete Pdsch ServCellCfg
2796 * @params[in] PdschServCellCfg *pdschServCellCfg
2799 * ****************************************************************/
2801 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2803 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2804 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2805 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2806 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2809 /*******************************************************************
2811 * @brief delete MacUeCfg from duCb
2815 * Function : deleteMacUeCfg
2817 * Functionality: delete MacUeCfg from duCb
2819 * @params[in] Pointer to MacUeCfg
2820 * @return ROK - success
2823 *******************************************************************/
2825 void deleteMacUeCfg(MacUeCfg *ueCfg)
2829 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2830 if(ueCfg->spCellCfgPres)
2832 freeUeReCfgCellGrpInfo(ueCfg);
2834 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2836 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2838 memset(ueCfg, 0, sizeof(MacUeCfg));
2841 /*******************************************************************
2843 * @brief delete UE Configuration of a particular UE
2847 * Function : deleteUeCfg
2849 * Functionality: delete UE Configuration of a particular UE
2851 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2852 * @return ROK - success
2855 * ****************************************************************/
2856 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2859 DuUeCb *ueCb = NULLP;
2861 if(duCb.actvCellLst[cellIdx] != NULLP)
2863 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2864 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2866 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2867 deleteMacUeCfg(&ueCb->macUeCfg);
2868 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2869 if(ueCb->f1UeDb !=NULLP)
2871 freeF1UeDb(ueCb->f1UeDb);
2873 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2875 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2877 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2878 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2883 duCb.actvCellLst[cellIdx]->numActvUes--;
2884 memset(ueCb, 0, sizeof(DuUeCb));
2893 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2900 /*******************************************************************
2902 * @brief Handle UE delete response from MAC
2906 * Function : DuProcMacUeDeleteRsp
2908 * Functionality: Handle UE delete response from MAC
2910 * @params[in] Pointer to MacUeDeleteRsp and Pst
2911 * @return ROK - success
2914 * ****************************************************************/
2916 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2918 uint8_t ret =ROK,ueId=0;
2920 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2924 if(deleteRsp->result == SUCCESS)
2926 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2927 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2928 if(duCb.actvCellLst[cellIdx])
2930 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2931 ueId = deleteRsp->ueId;
2932 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2933 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2934 if(deleteUeCfg(cellIdx, ueId) == ROK)
2936 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2939 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2947 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2951 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2955 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2961 /*******************************************************************
2963 * @brief Processes UE Delete Rsp received from RLC
2967 * Function : DuProcRlcUeDeleteRsp
2970 * Processes UE Delete Rsp received from RLC
2972 * @params[in] Post structure
2973 * Pointer to RlcUeDeleteRsp
2974 * @return ROK - success
2977 * *****************************************************************/
2979 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2981 uint8_t ueId = 0, ret = ROK;
2982 uint16_t cellIdx = 0,crnti=0;
2986 ueId = delRsp->ueId;
2987 GET_CELL_IDX(delRsp->cellId, cellIdx);
2989 if(delRsp->result == SUCCESSFUL)
2991 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2992 if(duCb.actvCellLst[cellIdx]!=NULLP)
2994 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2995 GET_CRNTI(crnti, ueId);
2996 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2998 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
3006 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
3009 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
3015 /*******************************************************************
3017 * @brief Sending UE Delete Req To Mac
3021 * Function : sendUeDeleteReqToMac
3024 * sending UE Delete Req To Mac
3026 * @params[in] cellId, ueId, crnti
3027 * @return ROK - success
3030 *****************************************************************/
3032 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
3036 MacUeDelete *ueDelete = NULLP;
3038 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
3041 ueDelete->cellId = cellId;
3042 ueDelete->ueId = ueId;
3043 ueDelete->crnti = crnti;
3044 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
3046 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3047 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3050 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3051 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3056 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3062 /*******************************************************************
3064 * @brief Sending UE Delete Req To Rlc
3068 * Function : sendUeDeleteReqToRlc
3071 * Sending UE Delete Req To Rlc
3073 * @params[in] cellId, ueId
3074 * @return ROK - success
3077 *****************************************************************/
3079 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3083 RlcUeDelete *ueDelete;
3085 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3086 if(ueDelete !=NULLP)
3088 ueDelete->cellId = cellId;
3089 ueDelete->ueId = ueId;
3090 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3092 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3095 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3096 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3101 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3107 /*******************************************************************
3109 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3113 * Function : duBuildAndSendUeDeleteReq
3115 * Functionality: DU processes UE delete req from CU and sends to MAC
3118 * @params[in] cellId, crnti
3119 * @return ROK - success
3122 * ****************************************************************/
3124 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3127 uint16_t cellIdx = 0;
3129 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3130 GET_CELL_IDX(cellId, cellIdx);
3131 GET_UE_IDX(crnti, ueId);
3133 if(duCb.actvCellLst[cellIdx] != NULLP)
3135 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3137 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3141 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3142 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3144 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3150 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3157 /*******************************************************************
3159 * @brief delete RlcUeCfg from duCb
3163 * Function : deleteRlcUeCfg
3166 * delete RlcUeCfg from duCb
3168 * @params[in] RlcUeCfg *ueCfg
3170 * @return ROK - success
3173 *****************************************************************/
3175 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3178 RlcBearerCfg *lcCfg= NULLP;
3181 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3183 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3184 switch(lcCfg->rlcMode)
3188 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3191 case RLC_UM_BI_DIRECTIONAL :
3193 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3196 case RLC_UM_UNI_DIRECTIONAL_UL :
3198 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3201 case RLC_UM_UNI_DIRECTIONAL_DL :
3203 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3208 memset(ueCfg, 0, sizeof(RlcUeCfg));
3212 /*******************************************************************
3214 * @brief Du process Ue Context Release Command
3218 * Function : duProcUeContextReleaseCommand
3220 * Functionality: Du process Ue Context Release Command
3222 * @params[in] DuUeCb *duUeCb
3223 * @return ROK - success
3226 * ****************************************************************/
3227 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3229 uint8_t ret =ROK, ueIdx=0;
3230 uint16_t cellId=0,crnti =0;
3233 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3236 if(duUeCb->f1UeDb == NULLP)
3238 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3242 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3243 crnti = duUeCb->crnti;
3244 /* Send DL RRC msg for RRC release */
3245 if(duUeCb->f1UeDb->dlRrcMsg)
3247 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3249 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3250 duUeCb->f1UeDb->dlRrcMsg);
3253 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3254 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3255 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3256 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3262 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3265 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3272 /**********************************************************************
3274 ***********************************************************************/