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 */
105 /*******************************************************************
107 * @brief Function to fillDlUserDataInfo
111 * Function : fillDlUserDataInfo
114 * Function to fillDlUserDataInfo
119 * @return ROK - success
122 * ****************************************************************/
124 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
128 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
130 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
132 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
134 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
135 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
136 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
144 /*******************************************************************
146 * @brief Build and Send DL Data Message transfer to RLC
150 * Function : duBuildAndSendDlUserDataToRlc
153 * Build and Send DL Data Message transfer to RLC
155 * @params[in] Cell ID
157 * Logical Channgel ID
160 * @return ROK - success
163 * ****************************************************************/
165 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
167 uint8_t ret = RFAILED;
169 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
171 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
174 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
177 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
178 dlDataMsgInfo->dlMsg = egtpMsg->msg;
179 dlDataMsgInfo->msgLen = msgLen;
181 /* Filling DL DATA Msg Info */
182 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
184 /* Filling post structure and sending msg */
185 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
186 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC [TEID, nPDU]:[%d, %d]\n",\
187 egtpMsg->msgHdr.teId, egtpMsg->msgHdr.nPdu.val);
188 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
192 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
193 ODU_PUT_MSG_BUF(dlDataMsgInfo->dlMsg);
194 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
199 /*******************************************************************
201 * @brief Handles EGTP data from CU
205 * Function : duHdlEgtpData
208 * Processes EGTP header and sends data to RLC
210 * @params[in] Pointer to EGTP Message
211 * @return ROK - success
214 * ****************************************************************/
215 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
219 #ifdef CALL_FLOW_DEBUG_LOG
220 DU_LOG("\nCall Flow: ENTEGTP -> ENTDUAPP : EVENT_HDL_RECV_DL_DATA\n");
223 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
227 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
230 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
231 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
233 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
234 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
240 /******************************************************************
242 * @brief Builds and Sends DL CCCH Ind to MAC
246 * Function : duBuildAndSendDlCcchInd
248 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
250 * @params[in] dlCcchMsg - uint8_t*
251 * @return ROK - success
254 * ****************************************************************/
255 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
256 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
260 DlCcchIndInfo *dlCcchIndInfo = NULLP;
263 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
265 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
269 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
273 dlCcchIndInfo->cellId = *cellId;
274 dlCcchIndInfo->crnti = *crnti;
275 dlCcchIndInfo->msgType = msgType;
276 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
278 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
279 if(!dlCcchIndInfo->dlCcchMsg)
281 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
282 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
285 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
287 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
289 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchMsg, dlCcchMsgSize);
292 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
293 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
296 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
297 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
298 dlCcchIndInfo->dlCcchMsgLen);
299 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
300 sizeof(DlCcchIndInfo));
308 /*******************************************************************
310 * @brief Build and Send DL RRC Message transfer to RLC
314 * Function : duBuildAndSendDlRrcMsgToRlc
317 * Build and Send DL RRC Message transfer to RLC
319 * @params[in] Cell ID
321 * Logical Channgel ID
324 * @return ROK - success
327 * ****************************************************************/
328 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
333 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
337 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
341 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
344 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
345 duBuildAndSendDlRrcMsgToRlc");
346 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
350 /* Filling up the RRC msg info */
351 dlRrcMsgInfo->cellId = cellId;
352 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
353 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
355 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
357 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
358 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
359 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
360 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
364 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
365 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
366 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
367 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
369 /* Filling post structure and sending msg */
370 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
371 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
372 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
375 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
376 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
385 /******************************************************************
387 * @brief Process DL RRC Msg recevied from F1AP
391 * Function : duProcDlRrcMsg
393 * Functionality: Process DL RRC Msg recevied from F1AP
395 * @params[in] dlCcchMsg - uint8_t*
396 * @return ROK - success
399 * ****************************************************************/
401 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
404 uint16_t crnti, cellId, cellIdx;
405 bool ueCcchCtxtFound = false;
406 bool ueFound = false;
410 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
412 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
414 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
416 ueCcchCtxtFound = true;
417 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
418 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
425 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
428 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
432 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
434 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
437 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
438 duCb.ueCcchCtxt[ueIdx].cellId);
443 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
450 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
452 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
454 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
455 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
458 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
459 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
472 /******************************************************************
474 * @brief Generates GNB DU Ue F1AP ID
478 * Function : genGnbDuUeF1apId
480 * Functionality: Generates GNB DU Ue F1AP ID
483 * @return gnbDuF1apId
485 * ****************************************************************/
486 int32_t genGnbDuUeF1apId(uint8_t cellId)
490 GET_CELL_IDX(cellId, cellIdx);
491 if(duCb.actvCellLst[cellIdx])
493 return ++duCb.actvCellLst[cellIdx]->gnbDuUeF1apIdGenerator;
497 DU_LOG("ERROR --> DU_APP : genGnbDuUeF1apId(): CellId[%d] does not exist", cellId);
502 /******************************************************************
504 * @brief Processes UL CCCH Ind recvd from MAC
508 * Function : duProcUlCcchInd
510 * Functionality: Processes UL CCCH Ind recvd from MAC
512 * @params[in] UlCcchIndInfo *ulCcchIndInfo
513 * @return ROK - success
516 * ****************************************************************/
517 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
521 int32_t gnbDuUeF1apId = 0;
523 gnbDuUeF1apId = genGnbDuUeF1apId(ulCcchIndInfo->cellId);
525 if(gnbDuUeF1apId == -1)
527 DU_LOG("ERROR --> DU_APP : duProcUlCcchInd(): Received cellId[%d] does not exist", ulCcchIndInfo->cellId);
531 /* Store Ue mapping */
532 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = (uint32_t)gnbDuUeF1apId;
533 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
534 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
538 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
539 ulCcchIndInfo->ulCcchMsg));
542 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
545 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
546 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
552 /******************************************************************
554 * @brief Fills Default UL LC Cfg
558 * Function : fillDefaultUlLcCfg
560 * Functionality: Fills Default UL LC Cfg
562 * @params[in] UlLcCfg *ulLcCfg
564 *****************************************************************/
565 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
567 ulLcCfg->priority = LC_PRIORITY_1;
568 ulLcCfg->lcGroup = 0;
569 ulLcCfg->schReqId = 0;
570 ulLcCfg->pbr = PBR_KBPS_INFINITY;
571 ulLcCfg->bsd = BSD_MS_1000;
574 /******************************************************************
576 * @brief Fills Initial DL Bandwidth Part
580 * Function : fillDefaultInitDlBwp
582 * Functionality: Fills Initial DL Bandwidth Part
584 * @params[in] InitialDlBwp *initDlBwp
587 *****************************************************************/
588 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
591 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
592 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
597 /* Filling PDCCH Config */
598 initDlBwp->pdcchPresent = TRUE;
599 if(initDlBwp->pdcchPresent)
601 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
602 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
603 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
605 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
606 PDCCH_CTRL_RSRC_SET_ONE_ID;
607 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
609 coreset0EndPrb = CORESET0_END_PRB;
610 coreset1StartPrb = coreset0EndPrb +6;
611 coreset1NumPrb = CORESET1_NUM_PRB;
612 /* calculate the PRBs */
613 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
614 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
617 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
618 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
619 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
620 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
621 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
623 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
626 initDlBwp->pdcchCfg.numCRsetToRel = 0;
627 /* Filling Serach Space */
628 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
629 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
630 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
632 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
633 PDCCH_SRCH_SPC_TWO_ID;
634 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
635 PDCCH_CTRL_RSRC_SET_ONE_ID;
636 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
637 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
638 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
639 MONITORING_SYMB_WITHIN_SLOT_SIZE);
640 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
641 PDCCH_SYMBOL_WITHIN_SLOT;
642 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
644 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
646 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
648 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
650 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
652 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
653 SEARCHSPACETYPE_PR_UE_SPECIFIC;
654 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
655 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
657 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
661 /* Filling PDSCH Config */
662 initDlBwp->pdschPresent = TRUE;
663 if(initDlBwp->pdschPresent)
665 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
666 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
667 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
668 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
670 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
671 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
672 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
673 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
674 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
675 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
676 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
677 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
683 /******************************************************************
685 * @brief Fills Initial UL Bandwidth Part
689 * Function : fillDefaultInitUlBwp
691 * Functionality: Fills Initial UL Bandwidth Part
693 * @params[in] InitialUlBwp *initUlBwp
696 *****************************************************************/
697 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
702 initUlBwp->pucchPresent = FALSE;
704 /*Filling PUSCH Config */
705 initUlBwp->puschPresent = TRUE;
706 if(initUlBwp->puschPresent)
708 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
709 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
710 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
711 scramblingId0 = SCRAMBLING_ID;
712 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
713 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 2;
715 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
717 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG1;
718 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
720 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
721 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
722 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
723 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
726 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2_CFG2;
727 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType = MAPPING_TYPEA;
728 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
729 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
730 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
731 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
733 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
738 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
742 /******************************************************************
744 * @brief Fills SpCell Group Info
748 * Function : fillDefaultSpCellGrpInfo
750 * Functionality: Fills Sp Cell Group Info
752 * @params[in] MacUeCfg *macUeCfg
755 *****************************************************************/
756 void fillDefaultSpCellGrpInfo(MacUeCfg *macUeCfg)
758 SpCellCfg *spCell = NULL;
761 spCell = &macUeCfg->spCellCfg;
765 macUeCfg->spCellCfgPres = true;
767 spCell->servCellIdx = SERV_CELL_IDX;
768 /* Filling Initial Dl Bwp */
769 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
771 spCell->servCellCfg.numDlBwpToAdd = 0;
772 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
773 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
774 spCell->servCellCfg.bwpInactivityTmr = NULLP;
775 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
776 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
777 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
778 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
779 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
780 NUM_HARQ_PROC_FOR_PDSCH_N_16;
781 /* Filling Initial UL Bwp*/
782 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
783 spCell->servCellCfg.numUlBwpToAdd = 0;
784 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
788 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
792 /******************************************************************
794 * @brief Fills Physical Cell Group Info
798 * Function : fillDefaultPhyCellGrpInfo
800 * Functionality: Fills Physical Cell Group Info
802 * @params[in] MacUeCfg *macUeCfg
805 *****************************************************************/
806 void fillDefaultPhyCellGrpInfo(MacUeCfg *macUeCfg)
808 PhyCellGrpCfg *cellGrp = NULL;
811 cellGrp = &macUeCfg->phyCellGrpCfg;
815 macUeCfg->phyCellGrpCfgPres = true;
816 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
817 cellGrp->pNrFr1 = P_NR_FR1;
821 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
825 /******************************************************************
827 * @brief Fills Mac Cell Group Info
831 * Function : fillDefaultMacCellGrpInfo
833 * Functionality: Fills Mac Cell Group Info
835 * @params[in] MacUeCfg *macUeCfg
838 *****************************************************************/
839 void fillDefaultMacCellGrpInfo(MacUeCfg *macUeCfg)
842 MacCellGrpCfg *cellGrp = NULL;
845 cellGrp = &macUeCfg->macCellGrpCfg;
849 macUeCfg->macCellGrpCfgPres = true;
851 /* Filling Scheduling Request Config */
852 cellGrp->schReqCfg.addModListCount = 1;
853 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
855 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
857 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
858 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
859 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
862 cellGrp->schReqCfg.relListCount = 0;
864 /* Filling Tag config */
865 cellGrp->tagCfg.addModListCount = 1;
866 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
868 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
870 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
871 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
874 cellGrp->tagCfg.relListCount = 0;
876 /* Filling BSR config */
877 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
878 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
879 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
881 /* Filling PHR config */
882 cellGrp->phrCfgSetupPres = true;
883 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
884 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
885 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
886 cellGrp->phrCfg.multiplePHR = false;
887 cellGrp->phrCfg.dummy = false;
888 cellGrp->phrCfg.phrType2OtherCell = false;
889 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
894 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
898 /*******************************************************************
900 * @brief Fills default modulation info for a UE
904 * Function : fillDefaultModulation
906 * Functionality: Fills default modulation info for a UE
908 * @params[in] Pointer to MAC UE configuration
909 * @return ROK - success
912 * ****************************************************************/
913 void fillDefaultModulation(MacUeCfg *ueCfg)
915 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
916 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
917 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
919 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
920 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
921 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
924 /******************************************************************
926 * @brief Function to fill Mac Lc Cfg for SRB1
930 * Function : fillMacSrb1LcCfg
932 * Functionality: Function to fill Mac Lc cfg for SRB1
934 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
936 *****************************************************************/
938 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
940 macLcCfg->lcId = SRB1_LCID;
941 macLcCfg->configType = CONFIG_ADD;
942 macLcCfg->drbQos = NULLP;
943 macLcCfg->snssai = NULLP;
944 macLcCfg->ulLcCfgPres = true;
945 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
948 /******************************************************************
950 * @brief Function to fill the Lc cfg from ueSetupReqDb
954 * Function : fillMacLcCfgToAddMod
956 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
958 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
959 * @return ROK/RFAILED
961 *****************************************************************/
963 uint8_t fillMacLcCfgToAddMod(LcCfg *macLcCfgToSend, LcCfg *ueLcCfgDb, LcCfg *oldLcCfg, Bool toUpdate)
969 macLcCfgToSend->lcId = ueLcCfgDb->lcId;
970 macLcCfgToSend->configType = ueLcCfgDb->configType;
972 if(ueLcCfgDb->drbQos)
973 macLcCfgToSend->drbQos = ueLcCfgDb->drbQos;
975 macLcCfgToSend->drbQos = oldLcCfg->drbQos;
977 macLcCfgToSend->drbQos = NULL;
979 if(ueLcCfgDb->snssai)
980 macLcCfgToSend->snssai = ueLcCfgDb->snssai;
982 macLcCfgToSend->snssai = oldLcCfg->snssai;
984 macLcCfgToSend->snssai = NULL;
986 macLcCfgToSend->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
987 memcpy(&macLcCfgToSend->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
988 memcpy(&macLcCfgToSend->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
993 oldLcCfg->lcId = ueLcCfgDb->lcId;
994 oldLcCfg->configType = ueLcCfgDb->configType;
996 if(ueLcCfgDb->drbQos)
999 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1001 DU_ALLOC_SHRABL_BUF(oldLcCfg->drbQos, sizeof(DrbQosInfo));
1002 if(oldLcCfg->drbQos == NULL)
1004 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1007 memcpy(oldLcCfg->drbQos, ueLcCfgDb->drbQos, sizeof(DrbQosInfo));
1010 if(ueLcCfgDb->snssai)
1012 if(oldLcCfg->snssai)
1013 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->snssai, sizeof(Snssai));
1015 DU_ALLOC_SHRABL_BUF(oldLcCfg->snssai, sizeof(Snssai));
1016 if(oldLcCfg->snssai == NULL)
1018 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillMacLcCfgToAddMod()");
1019 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, oldLcCfg->drbQos, sizeof(DrbQosInfo));
1022 memcpy(oldLcCfg->snssai, ueLcCfgDb->snssai, sizeof(Snssai));
1025 oldLcCfg->ulLcCfgPres = ueLcCfgDb->ulLcCfgPres;
1026 memcpy(&oldLcCfg->ulLcCfg, &ueLcCfgDb->ulLcCfg, sizeof(UlLcCfg));
1027 memcpy(&oldLcCfg->dlLcCfg, &ueLcCfgDb->dlLcCfg, sizeof(DlLcCfg));
1032 /******************************************************************
1034 * @brief Function to copy the Bit rate from ueSetupReqDb
1038 * Function : fillAmbr
1040 * Functionality: Function to copy bit Rate from ueSetupReqDb
1042 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
1043 * @return ROK/RFAILED
1045 *****************************************************************/
1047 uint8_t fillAmbr(AmbrCfg **macAmbrCfgToSend, AmbrCfg *ueDbAmbr, AmbrCfg **oldMacAmbrCfg, Bool toUpdate)
1053 *macAmbrCfgToSend = ueDbAmbr;
1056 *macAmbrCfgToSend = *oldMacAmbrCfg;
1064 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, *oldMacAmbrCfg, sizeof(AmbrCfg));
1066 DU_ALLOC_SHRABL_BUF(*oldMacAmbrCfg, sizeof(AmbrCfg));
1067 if(*oldMacAmbrCfg == NULLP)
1069 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
1072 memset(*oldMacAmbrCfg, 0, sizeof(AmbrCfg));
1073 (*oldMacAmbrCfg)->ulBr = ueDbAmbr->ulBr;
1080 /******************************************************************
1082 * @brief Builds and Send UE ReConfig Request to MAC
1086 * Function : sendUeReCfgReqToMac
1088 * Functionality: Builds and Send UE ReConfig Request to MAC
1090 * @Params[in] MacUeCfg pointer
1091 * @return ROK - success
1094 * ****************************************************************/
1096 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1102 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1106 /* Processing one Ue at a time to MAC */
1107 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1108 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1111 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1112 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1117 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1123 /******************************************************************
1125 * @brief Function to return Drb LcId
1129 * Function : getDrbLcId
1131 * Functionality: Function to return Drb LcId
1133 * Returns: lcId - SUCCESS
1135 *****************************************************************/
1137 uint8_t getDrbLcId(uint32_t *drbBitMap)
1139 uint8_t bitMask = 1, bitPos = 0;
1140 bitPos = MIN_DRB_LCID;
1142 while(bitPos <= MAX_DRB_LCID)
1144 if((*drbBitMap & (bitMask << bitPos)) == 0)
1146 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1154 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1158 /******************************************************************
1160 * @brief Fills MacUeCfg structure
1164 * Function : fillMacUeCfg
1166 * Functionality: Fills MacUeCfg
1168 * @params[in] cellId, ueIdx, crnti,
1171 * @return ROK/RFAILED
1173 *****************************************************************/
1174 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1175 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1177 uint8_t ret, dbIdx, lcIdx, cellIdx;
1178 bool lcIdFound = false;
1179 MacUeCfg *duMacDb = NULLP;
1185 macUeCfg->cellId = cellId;
1186 macUeCfg->ueIdx = ueIdx;
1187 macUeCfg->crnti = crnti;
1189 fillDefaultMacCellGrpInfo(macUeCfg);
1190 fillDefaultPhyCellGrpInfo(macUeCfg);
1191 fillDefaultSpCellGrpInfo(macUeCfg);
1192 macUeCfg->ambrCfg = NULLP;
1193 fillDefaultModulation(macUeCfg);
1194 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1199 /* Fetching MacDb from DuUeCb */
1200 GET_CELL_IDX(cellId, cellIdx);
1201 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1202 duMacDb->macUeCfgState = UE_CFG_INPROGRESS;
1203 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1204 macUeCfg->cellId = cellId;
1205 macUeCfg->ueIdx = ueIdx;
1206 macUeCfg->crnti = crnti;
1207 ret = procUeReCfgCellInfo(macUeCfg, duMacDb, ueCfgDb->cellGrpCfg);
1210 if(macUeCfg->spCellCfgPres == true)
1212 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1214 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1215 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1217 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1219 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1220 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1223 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg , &duMacDb->ambrCfg, FALSE);
1224 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1227 /* Filling LC Context */
1228 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1230 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1232 /* Filling default UL LC config in MAC if not present */
1233 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1234 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1236 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1238 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1241 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1242 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1244 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1245 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], &duMacDb->lcCfgList[lcIdx], FALSE);
1253 /* ADD/DEL CONFIG */
1254 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx], NULL, FALSE);
1262 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1265 }/*End of Outer FOR loop */
1266 memcpy(&ueCfgDb->copyOfmacUeCfg, macUeCfg, sizeof(MacUeCfg));
1271 /******************************************************************
1273 * @brief Fills Rlc AM Information
1277 * Function : fillDefaultAmInfo
1279 * Functionality: Fills Rlc AM Information
1281 * @params[in] AmBearerCfg *amCfg
1284 *****************************************************************/
1285 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1288 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1289 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1290 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1291 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1292 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1295 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1296 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1297 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1300 /******************************************************************
1302 * @brief Fills RLC UM Bi Directional Information
1306 * Function : fillDefaultUmBiInfo
1308 * Functionality: Fills RLC UM Bi Directional Information
1310 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1313 *****************************************************************/
1314 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1316 /* UL UM BI DIR INFO */
1317 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1318 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1320 /* DL UM BI DIR INFO */
1321 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1324 /******************************************************************
1326 * @brief Fills RLC UM Uni Directional UL Information
1330 * Function : fillDefaultUmUlInfo
1332 * Functionality: Fills RLC UM Uni Directional Info
1334 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1337 *****************************************************************/
1338 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1340 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1341 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1344 /******************************************************************
1346 * @brief Fills RLC UM Uni Directional DL Information
1350 * Function : fillDefaultUmDlInfo
1352 * Functionality: Fills RLC UM Uni Directional DL Info
1354 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1357 *****************************************************************/
1358 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1360 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1363 /******************************************************************
1365 * @brief Builds Rlc Mode Default Configuration
1369 * Function : fillDefaultRlcModeCfg
1371 * Functionality: Builds Rlc Mode Default Configuration
1373 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1374 * @return ROK/RFAILED
1376 *****************************************************************/
1378 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1389 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1391 fillDefaultAmInfo(lcCfg->u.amCfg);
1394 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1400 case RLC_UM_BI_DIRECTIONAL :
1402 if(!lcCfg->u.umBiDirCfg)
1404 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1405 if(lcCfg->u.umBiDirCfg)
1406 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1409 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1415 case RLC_UM_UNI_DIRECTIONAL_UL :
1417 if(!lcCfg->u.umUniDirUlCfg)
1419 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1420 if(lcCfg->u.umUniDirUlCfg)
1421 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1424 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1430 case RLC_UM_UNI_DIRECTIONAL_DL :
1432 if(!lcCfg->u.umUniDirDlCfg)
1434 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1435 if(lcCfg->u.umUniDirDlCfg)
1436 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1439 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1446 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1453 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1459 /*******************************************************************
1461 * @brief Function to fill Rlc Lc Cfg for SRB1
1465 * Function : fillRlcSrb1LcCfg
1468 * Function to fill Rlc Lc Cfg for SRB1
1470 * @params[in] Pointer to RlcBearerCfg
1471 * @return ROK/RFAILED
1473 *****************************************************************/
1475 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1479 rlcLcCfg->rbId = SRB1_LCID;
1480 rlcLcCfg->rbType = RB_TYPE_SRB;
1481 rlcLcCfg->lcId = SRB1_LCID;
1482 rlcLcCfg->lcType = LCH_DCCH;
1483 rlcLcCfg->rlcMode = RLC_AM;
1484 rlcLcCfg->configType = CONFIG_ADD;
1485 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1489 /*******************************************************************
1491 * @brief Processes UE ReConfig Req to RLC UL
1495 * Function : sendUeReCfgReqToRlc
1498 * Processes UE Reconfig Req to RLC UL
1500 * @params[in] Pointer to RlcUeCfg
1501 * @return ROK - success
1504 *****************************************************************/
1506 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1511 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1514 /* Processing one Ue at a time to RLC */
1515 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1516 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1519 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1520 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1525 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1531 /******************************************************************
1533 * @brief Fills RlcBearerCfg structure
1537 * Function : fillRlcUeCfg
1539 * Functionality: Fills Rlc Bearer Cfg
1542 *****************************************************************/
1543 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1544 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1546 uint8_t ret, dbIdx, lcIdx, cellIdx;
1547 bool lcIdFound = false;
1548 RlcUeCfg *duRlcDb = NULLP;
1553 /* Initial RB being Added */
1554 rlcUeCfg->cellId = cellId;
1555 rlcUeCfg->ueIdx = ueIdx;
1556 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1560 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1564 /* Fetch RlcDb from DuUeCb */
1565 GET_CELL_IDX(cellId, cellIdx);
1566 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1567 duRlcDb->rlcUeCfgState = UE_CFG_INPROGRESS;
1568 /*Filling RlcUeCfg */
1569 rlcUeCfg->cellId = cellId;
1570 rlcUeCfg->ueIdx = ueIdx;
1571 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1573 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1576 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1577 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1580 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1581 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1583 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1586 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1587 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1590 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1591 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1599 /* ADD/ DEL Config Type */
1600 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1608 /******************************************************************
1610 * @brief creates UE context
1614 * Function : duCreateUeCb
1616 * Functionality: Creates UE Conetxt
1618 * @params[in] UeCcchCtxt Pointer
1621 * @return ROK - success
1623 * ****************************************************************/
1624 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1626 uint8_t cellIdx = 0;
1630 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1632 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1634 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1635 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1637 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1638 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1639 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1640 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1641 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1642 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1644 /* Filling Mac Ue Config */
1645 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1646 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1647 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1649 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1651 /* Filling Rlc Ue Config */
1652 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1653 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1654 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1656 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1658 duCb.actvCellLst[cellIdx]->numActvUes++;
1659 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1666 /******************************************************************
1668 * @brief Builds and Send UE Create Request to MAC
1672 * Function : duBuildAndSendUeCreateReqToMac
1674 * Functionality: Builds and Send UE Create Request to MAC
1676 * @Params[in] cellId,
1678 * @return ROK - success
1681 * ****************************************************************/
1683 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1684 uint16_t crnti, MacUeCfg *duMacUeCfg)
1687 MacUeCfg *macUeCfg = NULLP;
1689 memset(&pst, 0, sizeof(Pst));
1692 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1695 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1699 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1701 /* Copying ueCb to a sharable buffer */
1702 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1705 memset(macUeCfg, 0, sizeof(MacUeCfg));
1706 memcpy(macUeCfg, duMacUeCfg, sizeof(MacUeCfg));
1707 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1709 /* Processing one Ue at a time to MAC */
1710 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1713 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1714 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1719 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1725 /*******************************************************************
1727 * @brief To update DuUeCb Mac Cfg
1731 * Function : duUpdateMacCfg
1732 * Functionality: update DuUeCb MAC Cfg
1734 * @params[in] DuUeCb Pointer
1735 * F1UeContextSetupDb pointer
1736 * @return ROK - success
1739 * ****************************************************************/
1740 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1742 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx, cellIdx;
1743 MacUeCfg *oldMacUeCfg;
1746 GET_CELL_IDX(macUeCfg->cellId, cellIdx);
1747 oldMacUeCfg = &duCb.actvCellLst[cellIdx]->ueCb[macUeCfg->ueIdx-1].macUeCfg;
1749 /*Filling Cell Group Cfg*/
1750 ret = procUeReCfgCellInfo(macUeCfg, &f1UeDb->duUeCfg.copyOfmacUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1753 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1755 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1756 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1758 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1760 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1761 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1763 ret = fillAmbr(NULL, f1UeDb->duUeCfg.ambrCfg, &oldMacUeCfg->ambrCfg, true);
1764 duFillModulationDetails(macUeCfg, oldMacUeCfg, f1UeDb->duUeCfg.ueNrCapability);
1767 /* Filling LC Context */
1768 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1770 numLcs = macUeCfg->numLcs;
1771 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1773 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1775 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1777 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[lcIdx], true);
1779 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1781 /* Free memory at matched lcIdx index */
1782 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1784 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1786 /* moving all elements one index ahead */
1787 ret = fillMacLcCfgToAddMod(NULL, &macUeCfg->lcCfgList[lcDelIdx+1], &macUeCfg->lcCfgList[lcDelIdx], true);
1788 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1791 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1798 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1800 ret = fillMacLcCfgToAddMod(NULL, &f1UeDb->duUeCfg.macLcCfg[dbIdx], &macUeCfg->lcCfgList[numLcs], true);
1803 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1813 /******************************************************************
1815 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1819 * Function : fillRlcCfgToAddMod
1821 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1824 *****************************************************************/
1826 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1828 lcCfg->configType = f1UeDbLcCfg->configType;
1829 lcCfg->rbId = f1UeDbLcCfg->rbId;
1830 lcCfg->rbType = f1UeDbLcCfg->rbType;
1831 lcCfg->lcId = f1UeDbLcCfg->lcId;
1832 lcCfg->lcType = f1UeDbLcCfg->lcType;
1833 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1834 switch(lcCfg->rlcMode)
1840 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1845 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1846 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1847 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1848 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1849 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1852 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1853 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1854 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1857 case RLC_UM_BI_DIRECTIONAL :
1859 if(!lcCfg->u.umBiDirCfg)
1861 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1862 if(!lcCfg->u.umBiDirCfg)
1865 /* UL UM BI DIR INFO */
1866 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1867 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1868 /* DL UM BI DIR INFO */
1869 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1872 case RLC_UM_UNI_DIRECTIONAL_UL :
1874 if(!lcCfg->u.umUniDirUlCfg)
1876 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1877 if(!lcCfg->u.umUniDirUlCfg)
1880 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1881 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1885 case RLC_UM_UNI_DIRECTIONAL_DL :
1887 if(!lcCfg->u.umUniDirDlCfg)
1889 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1890 if(!lcCfg->u.umUniDirDlCfg)
1893 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1897 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1903 /*******************************************************************
1905 * @brief To update DuUeCb Rlc Lc Cfg
1909 * Function : duUpdateRlcLcCfg
1910 * Functionality: update DuUeCb Rlc Lc Cfg
1912 * @params[in] DuUeCb Pointer
1913 * F1UeContextSetupDb pointer
1914 * @return ROK - success
1917 * ****************************************************************/
1919 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1921 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1924 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1926 numLcs = rlcUeCfg->numLcs;
1927 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1929 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1931 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1933 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1935 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1937 /* Free memory at matched lcIdx index */
1938 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1940 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1942 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1943 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1946 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1953 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1955 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1964 /*******************************************************************
1966 * @brief Function to fill Tunnel Config to Add/Mod
1971 * Function : fillTnlCfgToAddMod
1973 * Functionality: Function to fill tunnel Config to Add/Mod
1975 * @params[in] Pointer to tnlCfgDb,
1976 * pointer to f1TnlCfg
1977 * @return ROK - success
1980 * ****************************************************************/
1981 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1985 DU_FREE((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1986 DU_FREE(*ueCbTnlCfg, sizeof(UpTnlCfg));
1989 if(*ueCbTnlCfg == NULLP)
1991 /* copying to DuCb Tnl Cfg */
1992 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1993 if(*ueCbTnlCfg == NULLP)
1995 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1999 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
2000 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
2001 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
2002 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
2003 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
2004 if(f1TnlCfg->tnlCfg1)
2006 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2008 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
2009 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
2011 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
2015 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
2016 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
2017 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
2018 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
2023 /*******************************************************************
2025 * @brief Processing the tunnel Request to EGTP
2029 * Function : duProcEgtpTunnelCfg
2031 * Functionality: Processing the tunnel Request to EGTP
2033 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
2034 * @return ROK - success
2037 * ****************************************************************/
2039 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
2041 uint8_t ret = RFAILED, delIdx;
2043 if(f1TnlCfg->tnlCfg1 == NULLP)
2045 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
2049 if(f1TnlCfg->configType == CONFIG_ADD)
2051 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
2053 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
2060 else if(f1TnlCfg->configType == CONFIG_MOD)
2062 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2064 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
2070 else if(f1TnlCfg->configType == CONFIG_DEL)
2072 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
2074 /* Free memory at drbIdx */
2076 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
2078 /* moving all elements one index ahead */
2079 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2085 if(duCb.upTnlCfg[delIdx])
2087 DU_FREE(duCb.upTnlCfg[delIdx]->tnlCfg1, sizeof(GtpTnlCfg));
2088 DU_FREE(duCb.upTnlCfg[delIdx], sizeof(UpTnlCfg));
2095 /***********************************************************************
2097 * @brief Function to fill Tunnel Config
2098 * and sends tunnel Req to EGTP
2103 * Function : duUpdateTunnelCfgDb
2105 * Functionality: Function to fill tunnel Config
2106 * and sends tunnel Cfg Req to EGTP
2108 * @params[in] ueIdx, cellId, DuUeCfg
2109 * @return ROK - success
2112 * ****************************************************************/
2114 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2116 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2117 bool drbFound = false;
2119 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2120 /*then update drbId and tunnel Info in duCb */
2121 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2123 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2124 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2125 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2127 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2129 drbFound = true; /* existing DRB */
2130 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2132 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2133 duUeCfg->upTnlInfo[drbIdx].drbId);
2141 if(!drbFound && ret == ROK)/* new DRB to Add */
2143 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2145 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2146 duUeCfg->upTnlInfo[drbIdx].drbId);
2157 /*******************************************************************
2159 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2164 * Function : duUpdateDuUeCbCfg
2166 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2168 * @params[in] ueIdx, cellIdx
2169 * @return ROK - success
2172 * ****************************************************************/
2174 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2176 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2177 DuUeCb *ueCb = NULLP;
2179 GET_CELL_IDX(cellId, cellIdx);
2181 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2182 macUeCfgState == UE_RECFG_COMPLETE) &&
2183 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2184 rlcUeCfgState == UE_RECFG_COMPLETE))
2186 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2188 /*Filling RLC Ue Cfg */
2189 ueCb->rlcUeCfg.cellId = cellId;
2190 ueCb->rlcUeCfg.ueIdx = ueIdx;
2191 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2194 /*Filling MAC Ue Cfg */
2195 GET_CRNTI(crnti, ueIdx);
2196 ueCb->macUeCfg.cellId = cellId;
2197 ueCb->macUeCfg.ueIdx = ueIdx;
2198 ueCb->macUeCfg.crnti = crnti;
2199 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2201 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2204 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2206 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2212 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2219 /*******************************************************************
2221 * @brief Handle UE config response from MAC
2225 * Function : DuProcMacUeCfgRsp
2227 * Functionality: Handle UE Config response from MAC
2229 * @params[in] Pointer to MacUeCfgRsp and Pst
2230 * @return ROK - success
2233 * ****************************************************************/
2234 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2240 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2242 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2244 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2245 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2246 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2248 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2250 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2251 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2252 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2253 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2255 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2261 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2262 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2264 //TODO: Send the failure case in Ue Context Setup Response
2268 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2272 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2279 /*******************************************************************
2281 * @brief Processes UE create Req to RLC UL
2285 * Function : duBuildAndSendUeCreateReqToRlc
2288 * Processes UE create Req to RLC UL
2290 * @params[in] cellId,
2292 * Pointer to RlcUeCfg
2293 * @return ROK - success
2296 *****************************************************************/
2298 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2299 RlcUeCfg *duRlcUeCfg)
2302 RlcUeCfg *rlcUeCfg = NULLP;
2305 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2308 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2312 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2313 /* Copying ueCfg to a sharable buffer */
2314 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2317 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2318 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2319 /* Processing one Ue at a time to RLC */
2320 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2321 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2324 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2325 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2331 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2337 /*******************************************************************
2339 * @brief Processes UE create Rsp received from RLC UL
2344 * Function : DuProcRlcUeCfgRsp
2347 * Processes UE create Rsp received from RLC UL
2349 * @params[in] Post structure
2350 * Pointer to RlcCfgCfm
2351 * @return ROK - success
2354 *****************************************************************/
2355 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2361 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2363 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2365 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2366 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2367 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2369 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2371 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2372 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2373 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2374 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2376 BuildAndSendUeCtxtRsp(cfgRsp->cellId, cfgRsp->ueIdx);
2382 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2383 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2384 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2386 //TODO: update failure case in ue Context setup Response
2390 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2394 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2400 /*******************************************************************
2402 * @brief Builds and Send Ue Reconfig Req to RLC
2406 * Function : duBuildAndSendUeReCfgReqToRLC
2408 * Functionality: Builds and Send Ue Reconfig Req to RLC
2410 * @params[in] cellId, crnti
2412 * RlcUeCfg *rlcUeCfg
2413 * @return ROK - success
2416 * ****************************************************************/
2418 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2420 uint8_t ret = ROK, ueIdx = 0;
2421 RlcUeCfg *rlcUeCfg = NULLP;
2423 GET_UE_IDX(crnti, ueIdx);
2424 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2427 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2428 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2430 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2432 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2436 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2442 /*******************************************************************
2444 * @brief Builds and Send Ue Reconfig Req to MAC
2448 * Function : duBuildAndSendUeReCfgReqToMac
2450 * Functionality: Builds and Send Ue Reconfig Req to MAC
2452 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2454 * MacUeCfg *macUeCfg
2455 * @return ROK - success
2458 * ****************************************************************/
2460 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2462 uint8_t ret, ueIdx = 0;
2463 MacUeCfg *macUeCfg = NULLP;
2466 GET_UE_IDX(crnti, ueIdx);
2468 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2471 memset(macUeCfg, 0, sizeof(MacUeCfg));
2472 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2474 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2476 ret = sendUeReCfgReqToMac(macUeCfg);
2480 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2486 /*******************************************************************
2488 * @brief Build and Send Ue context setup request
2493 * Function : duBuildAndSendUeContextSetupReq
2496 * Build and Send Ue context setup request
2498 * @params[in] cellId, crnti, DuUeCfg pointer
2499 * @return ROK - success
2502 *****************************************************************/
2504 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2508 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2509 /* Filling RLC Ue Reconfig */
2510 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2512 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2514 /* Filling MAC Ue Reconfig */
2515 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2517 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2522 /*******************************************************************
2524 * @brief Processes DL Rsp received from RLC DL
2529 * Function : DuProcRlcDlRrcMsgRsp
2532 * Processes UE Rsp received from RLC DL
2534 * @params[in] Post structure
2535 * Pointer to RlcCfgCfm
2536 * @return ROK - success
2539 *****************************************************************/
2540 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2542 uint8_t ret = ROK, ueIdx = 0;
2543 uint16_t cellId, crnti;
2544 DuUeCb *ueCb = NULLP;
2547 state = dlRrcMsg->state;
2548 cellId = dlRrcMsg->cellId;
2549 crnti = dlRrcMsg->crnti;
2550 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2552 if(state == TRANSMISSION_COMPLETE)
2554 GET_UE_IDX(crnti, ueIdx);
2555 ueCb = &duCb.actvCellLst[cellId -1]->ueCb[ueIdx -1];
2557 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2559 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2561 ret = duBuildAndSendUeContextSetupReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2563 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2566 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2568 ret = duBuildAndSendUeContextModReq(cellId, crnti, &ueCb->f1UeDb->duUeCfg);
2570 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2573 if(ueCb->f1UeDb->actionType == UE_CTXT_RELEASE && ueCb->ueState == UE_ACTIVE)
2575 ret = duBuildAndSendUeDeleteReq(cellId, crnti);
2578 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Release Request in DuProcRlcDlRrcMsgRsp()");
2584 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2588 /*******************************************************************
2590 * @brief Process UE context setup request from CU
2594 * Function : duProcUeContextSetupRequest
2596 * Functionality: Process UE context setup request from CU
2598 * @params[in] F1AP message
2599 * @return ROK - success
2602 * ****************************************************************/
2604 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2606 uint8_t ret, cellId;
2611 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2612 /* Send DL RRC msg for security Mode */
2613 if(ueCb->f1UeDb->dlRrcMsg)
2615 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2617 /* Sending DL RRC Message to RLC */
2618 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2621 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2622 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2623 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2624 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2628 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2630 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2633 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2639 //TODO: To send the failure cause in UeContextSetupRsp
2640 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2645 /*******************************************************************
2647 * @brief Build and Send Ue context mod request
2652 * Function : duBuildAndSendUeContextModReq
2655 * Build and Send Ue context mod request
2657 * @params[in] cellId, crnti, DuUeCfg pointer
2658 * @return ROK - success
2661 *****************************************************************/
2663 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2667 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2668 /* Filling RLC Ue Reconfig */
2669 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2671 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2673 /* Filling MAC Ue Reconfig */
2674 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2676 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2680 /*******************************************************************
2682 * @brief Processing Ue context mod request
2687 * Function : duProcUeContextModReq
2690 * Processing Ue context mod request
2692 * @params[in] DuUeCb *ueCb
2693 * @return ROK - success
2696 *****************************************************************/
2698 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2700 uint8_t ret, cellId;
2705 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2706 /* Send DL RRC msg for security Mode */
2707 if(ueCb->f1UeDb->dlRrcMsg)
2709 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2711 /* Sending DL RRC Message to RLC */
2712 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2715 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2716 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2717 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2718 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2724 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2727 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2733 //TODO: To send the failure cause in UeContextModRsp
2734 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2739 /*******************************************************************
2741 * @brief Function to delete Pdsch ServCellCfg
2745 * Function : deletePdschServCellCfg
2747 * Functionality: Function to delete Pdsch ServCellCfg
2749 * @params[in] PdschServCellCfg *pdschServCellCfg
2752 * ****************************************************************/
2754 void deletePdschServCellCfg(PdschServCellCfg *pdschServCellCfg)
2756 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxMimoLayers, sizeof(uint8_t));
2757 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
2758 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->codeBlkGrpFlushInd, sizeof(bool));
2759 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,pdschServCellCfg->xOverhead, sizeof(PdschXOverhead));
2762 /*******************************************************************
2764 * @brief delete MacUeCfg from duCb
2768 * Function : deleteMacUeCfg
2770 * Functionality: delete MacUeCfg from duCb
2772 * @params[in] Pointer to MacUeCfg
2773 * @return ROK - success
2776 *******************************************************************/
2778 void deleteMacUeCfg(MacUeCfg *ueCfg)
2782 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,ueCfg->ambrCfg, sizeof(AmbrCfg));
2783 if(ueCfg->spCellCfgPres)
2785 freeUeReCfgCellGrpInfo(ueCfg);
2787 for(lcCfgIdx=0; lcCfgIdx< ueCfg->numLcs; lcCfgIdx++)
2789 freeMacLcCfg(&ueCfg->lcCfgList[lcCfgIdx]);
2791 memset(ueCfg, 0, sizeof(MacUeCfg));
2794 /*******************************************************************
2796 * @brief delete UE Configuration of a particular UE
2800 * Function : deleteUeCfg
2802 * Functionality: delete UE Configuration of a particular UE
2804 * @params[in] uint16_t cellIdx, uint8_t ueIdx
2805 * @return ROK - success
2808 * ****************************************************************/
2809 uint8_t deleteUeCfg(uint16_t cellIdx, uint8_t ueIdx)
2812 DuUeCb *ueCb = NULLP;
2814 if(duCb.actvCellLst[cellIdx] != NULLP)
2816 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg.macUeCfgState == UE_DELETE_COMPLETE)\
2817 &&(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg.rlcUeCfgState == UE_DELETE_COMPLETE))
2819 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2820 deleteMacUeCfg(&ueCb->macUeCfg);
2821 deleteRlcUeCfg(&ueCb->rlcUeCfg);
2822 if(ueCb->f1UeDb !=NULLP)
2824 freeF1UeDb(ueCb->f1UeDb);
2826 for(tnlIdx = 0; tnlIdx < duCb.numDrb; )
2828 if(duCb.upTnlCfg[tnlIdx]->ueIdx == ueIdx)
2830 duCb.upTnlCfg[tnlIdx]->configType = CONFIG_DEL;
2831 duProcEgtpTunnelCfg(tnlIdx, duCb.upTnlCfg[tnlIdx], duCb.upTnlCfg[tnlIdx]);
2836 duCb.actvCellLst[cellIdx]->numActvUes--;
2837 memset(ueCb, 0, sizeof(DuUeCb));
2846 DU_LOG("\nERROR --> DU APP : deleteUeCfg(): CellIdx[%d] is not found", cellIdx);
2853 /*******************************************************************
2855 * @brief Handle UE delete response from MAC
2859 * Function : DuProcMacUeDeleteRsp
2861 * Functionality: Handle UE delete response from MAC
2863 * @params[in] Pointer to MacUeDeleteRsp and Pst
2864 * @return ROK - success
2867 * ****************************************************************/
2869 uint8_t DuProcMacUeDeleteRsp(Pst *pst, MacUeDeleteRsp *deleteRsp)
2871 uint8_t ret =ROK,ueId=0;
2873 uint32_t gnbCuUeF1apId =0 , gnbDuUeF1apId =0;
2877 if(deleteRsp->result == SUCCESS)
2879 DU_LOG("\nINFO --> DU APP : MAC UE Delete Response : SUCCESS [UE IDX : %d]", deleteRsp->ueId);
2880 GET_CELL_IDX(deleteRsp->cellId, cellIdx);
2881 if(duCb.actvCellLst[cellIdx])
2883 duCb.actvCellLst[cellIdx]->ueCb[deleteRsp->ueId -1].macUeCfg.macUeCfgState = UE_DELETE_COMPLETE;
2884 ueId = deleteRsp->ueId;
2885 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
2886 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
2887 if(deleteUeCfg(cellIdx, ueId) == ROK)
2889 ret = BuildAndSendUeContextReleaseComplete(deleteRsp->cellId, gnbCuUeF1apId, gnbDuUeF1apId);
2892 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): failed to send UE context release complete");
2900 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response : FAILURE [UE IDX : %d]",\
2904 DU_FREE_SHRABL_BUF(pst->region, pst->pool, deleteRsp, sizeof(MacUeDeleteRsp));
2908 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp(): MAC UE Delete Response is null");
2914 /*******************************************************************
2916 * @brief Processes UE Delete Rsp received from RLC
2920 * Function : DuProcRlcUeDeleteRsp
2923 * Processes UE Delete Rsp received from RLC
2925 * @params[in] Post structure
2926 * Pointer to RlcUeDeleteRsp
2927 * @return ROK - success
2930 * *****************************************************************/
2932 uint8_t DuProcRlcUeDeleteRsp(Pst *pst, RlcUeDeleteRsp *delRsp)
2934 uint8_t ueId = 0, ret = ROK;
2935 uint16_t cellIdx = 0,crnti=0;
2939 ueId = delRsp->ueId;
2940 GET_CELL_IDX(delRsp->cellId, cellIdx);
2942 if(delRsp->result == SUCCESSFUL)
2944 DU_LOG("\nINFO --> DU_APP: RLC UE Delete Response : SUCCESS [UE IDX:%d]", ueId);
2945 if(duCb.actvCellLst[cellIdx]!=NULLP)
2947 duCb.actvCellLst[cellIdx]->ueCb[ueId-1].rlcUeCfg.rlcUeCfgState = UE_DELETE_COMPLETE;
2948 GET_CRNTI(crnti, ueId);
2949 if(sendUeDeleteReqToMac(delRsp->cellId, ueId, crnti) == RFAILED)
2951 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Failed to build UE delete req for MAC ");
2959 DU_LOG("\nERROR --> DU_APP: RLC UE Delete Response : FAILED [UE IDX:%d]", ueId);
2962 DU_FREE_SHRABL_BUF(pst->region, pst->pool, delRsp, sizeof(RlcUeDeleteRsp));
2968 /*******************************************************************
2970 * @brief Sending UE Delete Req To Mac
2974 * Function : sendUeDeleteReqToMac
2977 * sending UE Delete Req To Mac
2979 * @params[in] cellId, ueId, crnti
2980 * @return ROK - success
2983 *****************************************************************/
2985 uint8_t sendUeDeleteReqToMac(uint16_t cellId, uint8_t ueId, uint16_t crnti)
2989 MacUeDelete *ueDelete = NULLP;
2991 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(MacUeDelete));
2994 ueDelete->cellId = cellId;
2995 ueDelete->ueId = ueId;
2996 ueDelete->crnti = crnti;
2997 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_DELETE_REQ);
2999 DU_LOG("\nDEBUG --> DU_APP: Sending UE delete Request to MAC ");
3000 ret = (*packMacUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3003 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to send UE delete Req to MAC");
3004 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(MacUeDelete));
3009 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToMac(): Failed to allocate memory");
3015 /*******************************************************************
3017 * @brief Sending UE Delete Req To Rlc
3021 * Function : sendUeDeleteReqToRlc
3024 * Sending UE Delete Req To Rlc
3026 * @params[in] cellId, ueId
3027 * @return ROK - success
3030 *****************************************************************/
3032 uint8_t sendUeDeleteReqToRlc(uint16_t cellId, uint8_t ueId)
3036 RlcUeDelete *ueDelete;
3038 DU_ALLOC_SHRABL_BUF(ueDelete, sizeof(RlcUeDelete));
3039 if(ueDelete !=NULLP)
3041 ueDelete->cellId = cellId;
3042 ueDelete->ueId = ueId;
3043 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_DELETE_REQ);
3045 ret = (*packRlcUeDeleteReqOpts[pst.selector])(&pst, ueDelete);
3048 DU_LOG("\nERROR --> DU_APP : sendUeDeleteReqToRlc():Failed to send UE Delete Req to RLC");
3049 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueDelete, sizeof(RlcUeDelete));
3054 DU_LOG("\nERROR --> DU_APP: sendUeDeleteReqToRlc():Memory allocation failed");
3060 /*******************************************************************
3062 * @brief DU processes UE delete req from CU and sends to MAC and RLC
3066 * Function : duBuildAndSendUeDeleteReq
3068 * Functionality: DU processes UE delete req from CU and sends to MAC
3071 * @params[in] cellId, crnti
3072 * @return ROK - success
3075 * ****************************************************************/
3077 uint8_t duBuildAndSendUeDeleteReq(uint16_t cellId, uint16_t crnti)
3080 uint16_t cellIdx = 0;
3082 DU_LOG("\nDEBUG --> DU_APP: Processing UE Delete Request ");
3083 GET_CELL_IDX(cellId, cellIdx);
3084 GET_UE_IDX(crnti, ueId);
3086 if(duCb.actvCellLst[cellIdx] != NULLP)
3088 if(crnti != duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].crnti)
3090 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): CRNTI [%d] not found", crnti);
3094 duCb.actvCellLst[cellIdx]->ueCb[ueId - 1].ueState = UE_DELETION_IN_PROGRESS;
3095 if(sendUeDeleteReqToRlc(cellId, ueId) == RFAILED)
3097 DU_LOG("\nERROR --> DU APP : DuProcMacUeDeleteRsp():Failed to build UE delete req for RLC ");
3103 DU_LOG("\nERROR --> DU APP : duBuildAndSendUeDeleteReq(): Cell Id is not found");
3110 /*******************************************************************
3112 * @brief delete RlcUeCfg from duCb
3116 * Function : deleteRlcUeCfg
3119 * delete RlcUeCfg from duCb
3121 * @params[in] RlcUeCfg *ueCfg
3123 * @return ROK - success
3126 *****************************************************************/
3128 void deleteRlcUeCfg(RlcUeCfg *ueCfg)
3131 RlcBearerCfg *lcCfg= NULLP;
3134 for(lcIdx =0 ; lcIdx < ueCfg->numLcs ; lcIdx++)
3136 lcCfg = &ueCfg->rlcLcCfg[lcIdx];
3137 switch(lcCfg->rlcMode)
3141 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
3144 case RLC_UM_BI_DIRECTIONAL :
3146 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
3149 case RLC_UM_UNI_DIRECTIONAL_UL :
3151 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
3154 case RLC_UM_UNI_DIRECTIONAL_DL :
3156 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
3161 memset(ueCfg, 0, sizeof(RlcUeCfg));
3165 /*******************************************************************
3167 * @brief Du process Ue Context Release Command
3171 * Function : duProcUeContextReleaseCommand
3173 * Functionality: Du process Ue Context Release Command
3175 * @params[in] DuUeCb *duUeCb
3176 * @return ROK - success
3179 * ****************************************************************/
3180 uint8_t duProcUeContextReleaseCommand(DuUeCb *duUeCb)
3182 uint8_t ret =ROK, ueIdx=0;
3183 uint16_t cellId=0,crnti =0;
3186 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : duUeCb is null");
3189 if(duUeCb->f1UeDb == NULLP)
3191 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : f1UeDb is null");
3195 cellId = duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->cellId;
3196 crnti = duUeCb->crnti;
3197 /* Send DL RRC msg for RRC release */
3198 if(duUeCb->f1UeDb->dlRrcMsg)
3200 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu != NULLP)
3202 ret = duBuildAndSendDlRrcMsgToRlc(cellId, duCb.actvCellLst[duUeCb->f1UeDb->cellIdx]->ueCb[ueIdx].rlcUeCfg,\
3203 duUeCb->f1UeDb->dlRrcMsg);
3206 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand() : Failed to send DL RRC msg");
3207 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
3208 duUeCb->f1UeDb->dlRrcMsg->rrcMsgSize);
3209 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
3215 ret = duBuildAndSendUeDeleteReq(cellId,crnti);
3218 DU_LOG("\nERROR --> DU APP : duProcUeContextReleaseCommand(): Failed to build and send Ue Delete request");
3225 /**********************************************************************
3227 ***********************************************************************/