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"
37 DuMacDlCcchInd packMacDlCcchIndOpts[] =
39 packMacDlCcchInd, /* Loose coupling */
40 MacProcDlCcchInd, /* TIght coupling */
41 packMacDlCcchInd /* Light weight-loose coupling */
44 DuMacUeCreateReq packMacUeCreateReqOpts[] =
46 packDuMacUeCreateReq, /* Loose coupling */
47 MacProcUeCreateReq, /* TIght coupling */
48 packDuMacUeCreateReq /* Light weight-loose coupling */
51 DuRlcUeCreateReq packRlcUeCreateReqOpts[] =
53 packDuRlcUeCreateReq, /* Loose coupling */
54 RlcProcUeCreateReq, /* TIght coupling */
55 packDuRlcUeCreateReq /* Light weight-loose coupling */
58 DuDlRrcMsgToRlcFunc duSendDlRrcMsgToRlcOpts[] =
60 packDlRrcMsgToRlc, /* Loose coupling */
61 RlcProcDlRrcMsgTransfer, /* Tight coupling */
62 packDlRrcMsgToRlc /* Light weight-loose coupling */
65 DuRlcUeReconfigReq packRlcUeReconfigReqOpts[] =
67 packDuRlcUeReconfigReq, /* Loose coupling */
68 RlcProcUeReconfigReq, /* TIght coupling */
69 packDuRlcUeReconfigReq /* Light weight-loose coupling */
72 DuMacUeReconfigReq packMacUeReconfigReqOpts[] =
74 packDuMacUeReconfigReq, /* Loose coupling */
75 MacProcUeReconfigReq, /* TIght coupling */
76 packDuMacUeReconfigReq /* Light weight-loose coupling */
79 DuRlcDlUserDataToRlcFunc duSendRlcDlUserDataToRlcOpts[] =
81 packRlcDlUserDataToRlc, /* Loose coupling */
82 RlcProcDlUserDataTransfer, /* Tight coupling */
83 packRlcDlUserDataToRlc /* Light weight-loose coupling */
86 /*******************************************************************
88 * @brief Function to fillDlUserDataInfo
92 * Function : fillDlUserDataInfo
95 * Function to fillDlUserDataInfo
100 * @return ROK - success
103 * ****************************************************************/
105 uint8_t fillDlUserDataInfo(uint32_t teId, RlcDlUserDataInfo *dlDataMsgInfo)
109 for(drbIdx = 0; drbIdx < duCb.numDrb; drbIdx++)
111 if(duCb.upTnlCfg[drbIdx] && (duCb.upTnlCfg[drbIdx]->tnlCfg1 != NULLP))
113 if(duCb.upTnlCfg[drbIdx]->tnlCfg1->teId == teId)
115 dlDataMsgInfo->cellId = duCb.upTnlCfg[drbIdx]->cellId;
116 dlDataMsgInfo->ueIdx = duCb.upTnlCfg[drbIdx]->ueIdx;
117 dlDataMsgInfo->rbId = duCb.upTnlCfg[drbIdx]->drbId;
125 /*******************************************************************
127 * @brief Build and Send DL Data Message transfer to RLC
131 * Function : duBuildAndSendDlUserDataToRlc
134 * Build and Send DL Data Message transfer to RLC
136 * @params[in] Cell ID
138 * Logical Channgel ID
141 * @return ROK - success
144 * ****************************************************************/
146 uint8_t duBuildAndSendDlUserDataToRlc(uint16_t msgLen, EgtpMsg *egtpMsg)
148 uint8_t ret = RFAILED;
150 RlcDlUserDataInfo *dlDataMsgInfo = NULLP;
152 DU_ALLOC_SHRABL_BUF(dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
155 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlDataMsgInfo in duHdlEgtpDlData()");
158 memset(dlDataMsgInfo, 0, sizeof(RlcDlUserDataInfo));
159 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &dlDataMsgInfo->dlMsg) != ROK)
161 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for dlMsg in duHdlEgtpDlData()");
162 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
165 dlDataMsgInfo->dlMsg = egtpMsg->msg;
166 dlDataMsgInfo->msgLen = msgLen;
168 /* Filling DL DATA Msg Info */
169 if(fillDlUserDataInfo(egtpMsg->msgHdr.teId, dlDataMsgInfo) == ROK)
171 /* Filling post structure and sending msg */
172 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_USER_DATA_TRANS_TO_RLC);
173 DU_LOG("\nDEBUG --> DU_APP : Sending User Data Msg to RLC \n");
174 ret = (*duSendRlcDlUserDataToRlcOpts[pst.selector])(&pst, dlDataMsgInfo);
178 DU_LOG("\nERROR --> DU_APP : Failed to send User Data to RLC in duHdlEgtpDlData()");
179 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo->dlMsg, msgLen);
180 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlDataMsgInfo, sizeof(RlcDlUserDataInfo));
185 /*******************************************************************
187 * @brief Handles EGTP data from CU
191 * Function : duHdlEgtpData
194 * Processes EGTP header and sends data to RLC
196 * @params[in] Pointer to EGTP Message
197 * @return ROK - success
200 * ****************************************************************/
201 uint8_t duHdlEgtpDlData(EgtpMsg *egtpMsg)
204 DU_LOG("\nDEBUG --> DU_APP : Processing DL data in duHdlEgtpDlData()");
208 DU_LOG("\nERROR --> DU_APP : Recevied Dl Data is NULLP in duHdlEgtpDlData()");
211 ODU_GET_MSG_LEN(egtpMsg->msg, (MsgLen *)&msgLen);
212 if(duBuildAndSendDlUserDataToRlc(msgLen, egtpMsg) != ROK)
214 DU_LOG("\nERROR --> DU_APP : Failed to build DL USer Data in duHdlEgtpDlData()");
215 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, egtpMsg->msg, msgLen);
221 /******************************************************************
223 * @brief Builds and Sends DL CCCH Ind to MAC
227 * Function : duBuildAndSendDlCcchInd
229 * Functionality: Builds and sends DL CCCH Ind Msg to MAC
231 * @params[in] dlCcchMsg - uint8_t*
232 * @return ROK - success
235 * ****************************************************************/
236 uint8_t duBuildAndSendDlCcchInd(uint16_t *cellId, uint16_t *crnti, \
237 DlCcchMsgType msgType, uint16_t dlCcchMsgSize, uint8_t *dlCcchMsg)
241 DlCcchIndInfo *dlCcchIndInfo = NULLP;
244 DU_LOG("\nDEBUG --> DU APP : Building and Sending DL CCCH Ind to MAC");
246 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo, sizeof(DlCcchIndInfo));
250 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
254 dlCcchIndInfo->cellId = *cellId;
255 dlCcchIndInfo->crnti = *crnti;
256 dlCcchIndInfo->msgType = msgType;
257 dlCcchIndInfo->dlCcchMsgLen = dlCcchMsgSize;
259 DU_ALLOC_SHRABL_BUF(dlCcchIndInfo->dlCcchMsg, dlCcchIndInfo->dlCcchMsgLen);
260 if(!dlCcchIndInfo->dlCcchMsg)
262 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building DL CCCH Ind");
263 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, sizeof(DlCcchIndInfo));
266 for(idx2 = 0; idx2 < dlCcchIndInfo->dlCcchMsgLen; idx2++)
268 dlCcchIndInfo->dlCcchMsg[idx2] = dlCcchMsg[idx2];
270 DU_FREE(dlCcchMsg, dlCcchMsgSize);
273 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_DL_CCCH_IND);
274 ret = (*packMacDlCcchIndOpts[pst.selector])(&pst, dlCcchIndInfo);
277 DU_LOG("\nERROR --> DU_APP : Failure in sending DL CCCH to MAC");
278 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo->dlCcchMsg,\
279 dlCcchIndInfo->dlCcchMsgLen);
280 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlCcchIndInfo, \
281 sizeof(DlCcchIndInfo));
289 /*******************************************************************
291 * @brief Build and Send DL RRC Message transfer to RLC
295 * Function : duBuildAndSendDlRrcMsgToRlc
298 * Build and Send DL RRC Message transfer to RLC
300 * @params[in] Cell ID
302 * Logical Channgel ID
305 * @return ROK - success
308 * ****************************************************************/
309 uint8_t duBuildAndSendDlRrcMsgToRlc(uint16_t cellId, RlcUeCfg ueCfg, F1DlRrcMsg *f1DlRrcMsg)
314 RlcDlRrcMsgInfo *dlRrcMsgInfo = NULLP;
318 DU_LOG("\nERROR --> DU APP : Received Dl RRC Msg is NULL at duBuildAndSendDlRrcMsgToRlc()");
322 DU_ALLOC_SHRABL_BUF(dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
325 DU_LOG("\nERROR --> DU APP : Memory allocation failed for dlRrcMsgInfo in \
326 duBuildAndSendDlRrcMsgToRlc");
327 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
331 /* Filling up the RRC msg info */
332 dlRrcMsgInfo->cellId = cellId;
333 dlRrcMsgInfo->ueIdx = ueCfg.ueIdx;
334 for(lcIdx = 0; lcIdx <= MAX_NUM_LC; lcIdx++)
336 if(ueCfg.rlcLcCfg[lcIdx].lcId == f1DlRrcMsg->srbId)
338 dlRrcMsgInfo->rbType = ueCfg.rlcLcCfg[lcIdx].rbType;
339 dlRrcMsgInfo->rbId = ueCfg.rlcLcCfg[lcIdx].rbId;
340 dlRrcMsgInfo->lcType = ueCfg.rlcLcCfg[lcIdx].lcType;
341 dlRrcMsgInfo->lcId = ueCfg.rlcLcCfg[lcIdx].lcId;
345 dlRrcMsgInfo->execDup = f1DlRrcMsg->execDup;
346 dlRrcMsgInfo->deliveryStaRpt = f1DlRrcMsg->deliveryStatRpt;
347 dlRrcMsgInfo->msgLen = f1DlRrcMsg->rrcMsgSize;
348 dlRrcMsgInfo->rrcMsg = f1DlRrcMsg->rrcMsgPdu;
350 /* Filling post structure and sending msg */
351 FILL_PST_DUAPP_TO_RLC(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_TRANS_TO_RLC);
352 DU_LOG("\nDEBUG --> DU_APP: Sending Dl RRC Msg to RLC \n");
353 ret = (*duSendDlRrcMsgToRlcOpts[pst.selector])(&pst, dlRrcMsgInfo);
356 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1DlRrcMsg->rrcMsgPdu, f1DlRrcMsg->rrcMsgSize);
357 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
366 /******************************************************************
368 * @brief Process DL RRC Msg recevied from F1AP
372 * Function : duProcDlRrcMsg
374 * Functionality: Process DL RRC Msg recevied from F1AP
376 * @params[in] dlCcchMsg - uint8_t*
377 * @return ROK - success
380 * ****************************************************************/
382 uint8_t duProcDlRrcMsg(F1DlRrcMsg *dlRrcMsg)
385 uint16_t crnti, cellId, cellIdx;
386 bool ueCcchCtxtFound = false;
387 bool ueFound = false;
391 if(dlRrcMsg->srbId == SRB0_LCID) //RRC connection setup
393 for(ueIdx=0; ueIdx<duCb.numUe; ueIdx++)
395 if(dlRrcMsg->gnbDuUeF1apId == duCb.ueCcchCtxt[ueIdx].gnbDuUeF1apId)
397 ueCcchCtxtFound = true;
398 crnti = duCb.ueCcchCtxt[ueIdx].crnti;
399 cellId = duCb.ueCcchCtxt[ueIdx].cellId;
406 ret = duBuildAndSendDlCcchInd(&cellId, &crnti, RRC_SETUP, dlRrcMsg->rrcMsgSize, dlRrcMsg->rrcMsgPdu);
409 DU_LOG("\nERROR --> DU APP : Failed to build DlCcch Ind at procDlRrcMsgTrans()");
413 if(duCb.actvCellLst[cellId-1]->numActvUes < MAX_NUM_UE)
415 ret = duCreateUeCb(&duCb.ueCcchCtxt[ueIdx], dlRrcMsg->gnbCuUeF1apId);
418 DU_LOG("\nERROR --> DU APP : Failed to createUeCb for cellId [%d] at procDlRrcMsgTrans()", \
419 duCb.ueCcchCtxt[ueIdx].cellId);
424 DU_LOG("\nERROR --> DU_APP: Max Active UEs has reached at procDlRrcMsgTrans()");
431 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
433 for(ueIdx = 0 ; ueIdx < MAX_NUM_UE; ueIdx++)
435 if((dlRrcMsg->gnbCuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId)
436 && (dlRrcMsg->gnbDuUeF1apId == duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId))
439 ret = duBuildAndSendDlRrcMsgToRlc(duCb.actvCellLst[cellIdx]->cellId, \
440 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg, dlRrcMsg);
453 /******************************************************************
455 * @brief Generates GNB DU Ue F1AP ID
459 * Function : genGnbDuUeF1apId
461 * Functionality: Generates GNB DU Ue F1AP ID
464 * @return gnbDuF1apId
466 * ****************************************************************/
467 uint32_t genGnbDuUeF1apId()
469 static uint32_t gnbDuUeF1apId = 0;
471 return ++gnbDuUeF1apId;
474 /******************************************************************
476 * @brief Processes UL CCCH Ind recvd from MAC
480 * Function : duProcUlCcchInd
482 * Functionality: Processes UL CCCH Ind recvd from MAC
484 * @params[in] UlCcchIndInfo *ulCcchIndInfo
485 * @return ROK - success
488 * ****************************************************************/
489 uint8_t duProcUlCcchInd(UlCcchIndInfo *ulCcchIndInfo)
493 uint32_t gnbDuUeF1apId = 0;
495 gnbDuUeF1apId = genGnbDuUeF1apId();
497 /* Store Ue mapping */
498 duCb.ueCcchCtxt[duCb.numUe].gnbDuUeF1apId = gnbDuUeF1apId;
499 duCb.ueCcchCtxt[duCb.numUe].crnti = ulCcchIndInfo->crnti;
500 duCb.ueCcchCtxt[duCb.numUe].cellId = ulCcchIndInfo->cellId;
504 ret = (BuildAndSendInitialRrcMsgTransfer(gnbDuUeF1apId, ulCcchIndInfo->crnti, ulCcchIndInfo->ulCcchMsgLen,
505 ulCcchIndInfo->ulCcchMsg));
508 DU_LOG("\nERROR --> DU_APP : BuildAndSendInitialRrcMsgTransfer failed");
511 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo->ulCcchMsg, ulCcchIndInfo->ulCcchMsgLen);
512 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, MAC_POOL, ulCcchIndInfo, sizeof(UlCcchIndInfo));
518 /******************************************************************
520 * @brief Fills Default UL LC Cfg
524 * Function : fillDefaultUlLcCfg
526 * Functionality: Fills Default UL LC Cfg
528 * @params[in] UlLcCfg *ulLcCfg
530 *****************************************************************/
531 void fillDefaultUlLcCfg(UlLcCfg *ulLcCfg)
533 ulLcCfg->priority = LC_PRIORITY_1;
534 ulLcCfg->lcGroup = 0;
535 ulLcCfg->schReqId = 0;
536 ulLcCfg->pbr = PBR_KBPS_INFINITY;
537 ulLcCfg->bsd = BSD_MS_1000;
540 /******************************************************************
542 * @brief Fills Initial DL Bandwidth Part
546 * Function : fillDefaultInitDlBwp
548 * Functionality: Fills Initial DL Bandwidth Part
550 * @params[in] InitialDlBwp *initDlBwp
553 *****************************************************************/
554 void fillDefaultInitDlBwp(InitialDlBwp *initDlBwp)
557 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
558 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
563 /* Filling PDCCH Config */
564 initDlBwp->pdcchPresent = TRUE;
565 if(initDlBwp->pdcchPresent)
567 initDlBwp->pdcchCfg.numCRsetToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
568 memset(initDlBwp->pdcchCfg.cRSetToAddModList, 0, MAX_NUM_CRSET);
569 if(initDlBwp->pdcchCfg.numCRsetToAddMod <= MAX_NUM_CRSET)
571 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cRSetId = \
572 PDCCH_CTRL_RSRC_SET_ONE_ID;
573 memset(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, 0,\
575 coreset0EndPrb = CORESET0_END_PRB;
576 coreset1StartPrb = coreset0EndPrb +6;
577 coreset1NumPrb = CORESET1_NUM_PRB;
578 /* calculate the PRBs */
579 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
580 memcpy(initDlBwp->pdcchCfg.cRSetToAddModList[idx].freqDomainRsrc, freqDomainResource,
583 initDlBwp->pdcchCfg.cRSetToAddModList[idx].duration = \
584 PDCCH_CTRL_RSRC_SET_ONE_DURATION;
585 initDlBwp->pdcchCfg.cRSetToAddModList[idx].cceRegMappingType = \
586 CCE_REG_MAPPINGTYPE_PR_NONINTERLEAVED;
587 initDlBwp->pdcchCfg.cRSetToAddModList[idx].precoderGranularity = \
589 initDlBwp->pdcchCfg.cRSetToAddModList[idx].dmrsScramblingId = \
592 initDlBwp->pdcchCfg.numCRsetToRel = 0;
593 /* Filling Serach Space */
594 initDlBwp->pdcchCfg.numSearchSpcToAddMod = PDCCH_CTRL_RSRC_SET_ONE_ID;
595 memset(initDlBwp->pdcchCfg.searchSpcToAddModList, 0, MAX_NUM_CRSET);
596 if(initDlBwp->pdcchCfg.numSearchSpcToAddMod <= MAX_NUM_CRSET)
598 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceId =\
599 PDCCH_SRCH_SPC_TWO_ID;
600 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].cRSetId = \
601 PDCCH_CTRL_RSRC_SET_ONE_ID;
602 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].\
603 mSlotPeriodicityAndOffset = SLOTPERIODICITYANDOFFSET_PR_SL1;
604 memset(initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot, 0,\
605 MONITORING_SYMB_WITHIN_SLOT_SIZE);
606 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].mSymbolsWithinSlot[idx] =\
607 PDCCH_SYMBOL_WITHIN_SLOT;
608 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel1 =\
610 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel2 =\
612 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel4 =\
614 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel8 =\
616 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].numCandidatesAggLevel16 =\
618 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].searchSpaceType = \
619 SEARCHSPACETYPE_PR_UE_SPECIFIC;
620 initDlBwp->pdcchCfg.searchSpcToAddModList[idx].ueSpecificDciFormat =\
621 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
623 initDlBwp->pdcchCfg.numSearchSpcToRel = 0;
627 /* Filling PDSCH Config */
628 initDlBwp->pdschPresent = TRUE;
629 if(initDlBwp->pdschPresent)
631 initDlBwp->pdschCfg.dmrsDlCfgForPdschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
632 initDlBwp->pdschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
633 initDlBwp->pdschCfg.numTimeDomRsrcAlloc = 1;
634 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].mappingType = \
636 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbol = PDSCH_START_SYMBOL;
637 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].symbolLength = PDSCH_LENGTH_SYMBOL;
638 initDlBwp->pdschCfg.timeDomRsrcAllociList[idx].startSymbolAndLength = \
639 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
640 initDlBwp->pdschCfg.rbgSize = RBG_SIZE_CONFIG1;
641 initDlBwp->pdschCfg.numCodeWordsSchByDci = CODEWORDS_SCHED_BY_DCI_N1;
642 initDlBwp->pdschCfg.bundlingType = TYPE_STATIC_BUNDLING;
643 initDlBwp->pdschCfg.bundlingInfo.StaticBundling.size = 0;
649 /******************************************************************
651 * @brief Fills Initial UL Bandwidth Part
655 * Function : fillDefaultInitUlBwp
657 * Functionality: Fills Initial UL Bandwidth Part
659 * @params[in] InitialUlBwp *initUlBwp
662 *****************************************************************/
663 void fillDefaultInitUlBwp(InitialUlBwp *initUlBwp)
668 initUlBwp->pucchPresent = FALSE;
670 /*Filling PUSCH Config */
671 initUlBwp->puschPresent = TRUE;
672 if(initUlBwp->puschPresent)
674 initUlBwp->puschCfg.dataScramblingId = SCRAMBLING_ID;
675 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.addPos = ADDITIONALPOSITION_POS0;
676 initUlBwp->puschCfg.dmrsUlCfgForPuschMapTypeA.transPrecodDisabled. \
677 scramblingId0 = SCRAMBLING_ID;
678 initUlBwp->puschCfg.resourceAllocType = RESOURCEALLOCATION_TYPE1;
679 initUlBwp->puschCfg.numTimeDomRsrcAlloc = 1;
681 if(initUlBwp->puschCfg.numTimeDomRsrcAlloc <= MAX_NUM_UL_ALLOC)
683 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].k2 = PUSCH_K2;
684 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].mappingType =\
686 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbol = PUSCH_START_SYMBOL;
687 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].symbolLength = PUSCH_LENGTH_SYMBOL;
688 initUlBwp->puschCfg.timeDomRsrcAllocList[idx].startSymbolAndLength =\
689 calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
691 initUlBwp->puschCfg.transformPrecoder = TRANSFORM_PRECODER_DISABLED;
696 DU_LOG("\nERROR --> DU APP : Memory is NULL of InitalUlBwp");
700 /******************************************************************
702 * @brief Fills SpCell Group Info
706 * Function : fillDefaultSpCellGrpInfo
708 * Functionality: Fills Sp Cell Group Info
710 * @params[in] SpCellCfg *spCell
713 *****************************************************************/
714 void fillDefaultSpCellGrpInfo(SpCellCfg *spCell)
718 spCell->servCellIdx = SERV_CELL_IDX;
719 /* Filling Initial Dl Bwp */
720 fillDefaultInitDlBwp(&spCell->servCellCfg.initDlBwp);
722 spCell->servCellCfg.numDlBwpToAdd = 0;
723 spCell->servCellCfg.firstActvDlBwpId = ACTIVE_DL_BWP_ID;
724 spCell->servCellCfg.defaultDlBwpId = ACTIVE_DL_BWP_ID;
725 spCell->servCellCfg.bwpInactivityTmr = NULLP;
726 spCell->servCellCfg.pdschServCellCfg.maxMimoLayers = NULLP;
727 spCell->servCellCfg.pdschServCellCfg.maxCodeBlkGrpPerTb = NULLP;
728 spCell->servCellCfg.pdschServCellCfg.codeBlkGrpFlushInd = NULLP;
729 spCell->servCellCfg.pdschServCellCfg.xOverhead = NULLP;
730 spCell->servCellCfg.pdschServCellCfg.numHarqProcForPdsch =\
731 NUM_HARQ_PROC_FOR_PDSCH_N_16;
732 /* Filling Initial UL Bwp*/
733 fillDefaultInitUlBwp(&spCell->servCellCfg.initUlBwp);
734 spCell->servCellCfg.numUlBwpToAdd = 0;
735 spCell->servCellCfg.firstActvUlBwpId = ACTIVE_DL_BWP_ID;
739 DU_LOG("\nERROR --> DU APP : Memory is NULL for SpCellGrp");
743 /******************************************************************
745 * @brief Fills Physical Cell Group Info
749 * Function : fillDefaultPhyCellGrpInfo
751 * Functionality: Fills Physical Cell Group Info
753 * @params[in] PhyCellGrpCfg *cellGrp
756 *****************************************************************/
757 void fillDefaultPhyCellGrpInfo(PhyCellGrpCfg *cellGrp)
761 cellGrp->pdschHarqAckCodebook = PDSCH_HARQ_ACK_CODEBOOK_DYNAMIC;
762 cellGrp->pNrFr1 = P_NR_FR1;
766 DU_LOG("\nERROR --> DU APP : Memory is NULL for Physical Cell Group");
770 /******************************************************************
772 * @brief Fills Mac Cell Group Info
776 * Function : fillDefaultMacCellGrpInfo
778 * Functionality: Fills Mac Cell Group Info
780 * @params[in] MacCellGrpCfg *cellGrp
783 *****************************************************************/
784 void fillDefaultMacCellGrpInfo(MacCellGrpCfg *cellGrp)
790 /* Filling Scheduling Request Config */
791 cellGrp->schReqCfg.addModListCount = 1;
792 if(cellGrp->schReqCfg.addModListCount <= MAX_NUM_SR_CFG_PER_CELL_GRP)
794 for(idx = 0; idx < cellGrp->schReqCfg.addModListCount; idx++)
796 cellGrp->schReqCfg.addModList[idx].schedReqId = SCH_REQ_ID;
797 cellGrp->schReqCfg.addModList[idx].srProhibitTmr = SR_PROHIBIT_MS_32;
798 cellGrp->schReqCfg.addModList[idx].srTransMax = SR_TRANS_MAX_N_16;
801 cellGrp->schReqCfg.relListCount = 0;
803 /* Filling Tag config */
804 cellGrp->tagCfg.addModListCount = 1;
805 if(cellGrp->tagCfg.addModListCount <= MAC_NUM_TAGS)
807 for(idx = 0; idx < cellGrp->tagCfg.addModListCount; idx++)
809 cellGrp->tagCfg.addModList[idx].tagId = TAG_ID;
810 cellGrp->tagCfg.addModList[idx].timeAlignTimer = TIME_ALIGNMENT_TIMER_INFINITY;
813 cellGrp->tagCfg.relListCount = 0;
815 /* Filling BSR config */
816 cellGrp->bsrTmrCfg.periodicTimer = BSR_PERIODIC_TIMER_SF_10;
817 cellGrp->bsrTmrCfg.retxTimer = BSR_RETX_TIMER_SF_320;
818 cellGrp->bsrTmrCfg.srDelayTimer = BSR_SR_DELAY_TMR_2560;
820 /* Filling PHR config */
821 cellGrp->phrCfgSetupPres = true;
822 cellGrp->phrCfg.periodicTimer = PHR_PERIODIC_TIMER_INFINITY;
823 cellGrp->phrCfg.prohibitTimer = PHR_PROHIBIT_TIMER_SF_0;
824 cellGrp->phrCfg.txPowerFactor = PHR_TX_PWR_FACTOR_CHANGE_INFINITY;
825 cellGrp->phrCfg.multiplePHR = false;
826 cellGrp->phrCfg.dummy = false;
827 cellGrp->phrCfg.phrType2OtherCell = false;
828 cellGrp->phrCfg.phrOtherCG = PHR_MODE_OTHER_CG_REAL;
833 DU_LOG("\nERROR --> DU APP : Memory is NULL for Master Cell Group");
837 /*******************************************************************
839 * @brief Fills default modulation info for a UE
843 * Function : fillDefaultModulation
845 * Functionality: Fills default modulation info for a UE
847 * @params[in] Pointer to MAC UE configuration
848 * @return ROK - success
851 * ****************************************************************/
852 void fillDefaultModulation(MacUeCfg *ueCfg)
854 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
855 ueCfg->dlModInfo.mcsIndex = SIB1_MCS;
856 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
858 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
859 ueCfg->ulModInfo.mcsIndex = SIB1_MCS;
860 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64; /* Spec 38.214-Table 5.1.3.1-1 */
863 /******************************************************************
865 * @brief Function to fill Mac Lc Cfg for SRB1
869 * Function : fillMacSrb1LcCfg
871 * Functionality: Function to fill Mac Lc cfg for SRB1
873 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
875 *****************************************************************/
877 void fillMacSrb1LcCfg(LcCfg *macLcCfg)
879 macLcCfg->lcId = SRB1_LCID;
880 macLcCfg->configType = CONFIG_ADD;
881 macLcCfg->drbQos = NULLP;
882 macLcCfg->snssai = NULLP;
883 macLcCfg->ulLcCfgPres = true;
884 fillDefaultUlLcCfg(&macLcCfg->ulLcCfg);
887 /******************************************************************
889 * @brief Function to fill the Lc cfg from ueSetupReqDb
893 * Function : fillMacLcCfgToAddMod
895 * Functionality: Function to fill the Lc cfg from ueSetupReqDb
897 * @params[in] LcCfg *lcCfg, LcCfg *ueSetReqDb
898 * @return ROK/RFAILED
900 *****************************************************************/
902 uint8_t fillMacLcCfgToAddMod(LcCfg *lcCfg, LcCfg *ueSetReqDb)
905 lcCfg->lcId = ueSetReqDb->lcId;
906 lcCfg->configType = ueSetReqDb->configType;
908 if(ueSetReqDb->drbQos)
912 DU_ALLOC_SHRABL_BUF(lcCfg->drbQos, sizeof(DrbQosInfo));
915 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at drQos at fillMacLcCfgToAddMod()");
921 memcpy(lcCfg->drbQos, ueSetReqDb->drbQos, sizeof(DrbQosInfo));
926 lcCfg->drbQos = NULLP;
931 if(ueSetReqDb->snssai)
935 DU_ALLOC_SHRABL_BUF(lcCfg->snssai, sizeof(Snssai));
938 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at snnsai at fillMacLcCfgToAddMod()");
945 memcpy(lcCfg->snssai, ueSetReqDb->snssai, sizeof(Snssai));
949 lcCfg->snssai = NULLP;
952 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
953 lcCfg->drbQos = NULLP;
959 lcCfg->snssai = NULLP;
961 lcCfg->ulLcCfgPres = ueSetReqDb->ulLcCfgPres;
962 memcpy(&lcCfg->ulLcCfg, &ueSetReqDb->ulLcCfg, sizeof(UlLcCfg));
963 memcpy(&lcCfg->dlLcCfg, &ueSetReqDb->dlLcCfg, sizeof(DlLcCfg));
967 /******************************************************************
969 * @brief Function to copy the Bit rate from ueSetupReqDb
973 * Function : fillAmbr
975 * Functionality: Function to copy bit Rate from ueSetupReqDb
977 * @params[in] AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr
978 * @return ROK/RFAILED
980 *****************************************************************/
982 uint8_t fillAmbr(AmbrCfg **macAmbr, AmbrCfg *ueDbAmbr)
986 if(*macAmbr == NULLP)
988 DU_ALLOC_SHRABL_BUF(*macAmbr, sizeof(AmbrCfg));
989 if(*macAmbr == NULLP)
991 DU_LOG("\nERROR --> DU APP : Memory Alloc Failed at fillAmbr()");
995 memset(*macAmbr, 0, sizeof(AmbrCfg));
996 (*macAmbr)->ulBr = ueDbAmbr->ulBr;
1005 /******************************************************************
1007 * @brief Builds and Send UE ReConfig Request to MAC
1011 * Function : sendUeReCfgReqToMac
1013 * Functionality: Builds and Send UE ReConfig Request to MAC
1015 * @Params[in] MacUeCfg pointer
1016 * @return ROK - success
1019 * ****************************************************************/
1021 uint8_t sendUeReCfgReqToMac(MacUeCfg *macUeCfg)
1027 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_RECONFIG_REQ);
1031 /* Processing one Ue at a time to MAC */
1032 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to MAC");
1033 ret = (*packMacUeReconfigReqOpts[pst.selector])(&pst, macUeCfg);
1036 DU_LOG("\nERROR --> DU APP : Failed to send Reconfig Request to MAC at sendUeReCfgReqToMac()");
1037 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1042 DU_LOG("\nERROR --> DU_APP: Received macUeCfg is NULLP at sendUeReCfgReqToMac()");
1048 /******************************************************************
1050 * @brief Function to return Drb LcId
1054 * Function : getDrbLcId
1056 * Functionality: Function to return Drb LcId
1058 * Returns: lcId - SUCCESS
1060 *****************************************************************/
1062 uint8_t getDrbLcId(uint32_t *drbBitMap)
1064 uint8_t bitMask = 1, bitPos = 0;
1065 bitPos = MIN_DRB_LCID;
1067 while(bitPos <= MAX_DRB_LCID)
1069 if((*drbBitMap & (bitMask << bitPos)) == 0)
1071 *drbBitMap = ((bitMask << bitPos)| *drbBitMap);
1079 DU_LOG("\nERROR --> DU_APP: Max LC Reached in getDrbLcId()");
1083 /******************************************************************
1085 * @brief Fills MacUeCfg structure
1089 * Function : fillMacUeCfg
1091 * Functionality: Fills MacUeCfg
1093 * @params[in] cellId, ueIdx, crnti,
1096 * @return ROK/RFAILED
1098 *****************************************************************/
1099 uint8_t fillMacUeCfg(uint16_t cellId, uint8_t ueIdx, uint16_t crnti, \
1100 DuUeCfg *ueCfgDb, MacUeCfg *macUeCfg)
1102 uint8_t ret, dbIdx, lcIdx, cellIdx;
1103 bool lcIdFound = false;
1104 MacUeCfg *duMacDb = NULLP;
1110 macUeCfg->cellId = cellId;
1111 macUeCfg->ueIdx = ueIdx;
1112 macUeCfg->crnti = crnti;
1113 fillDefaultMacCellGrpInfo(&macUeCfg->macCellGrpCfg);
1114 fillDefaultPhyCellGrpInfo(&macUeCfg->phyCellGrpCfg);
1115 fillDefaultSpCellGrpInfo(&macUeCfg->spCellCfg);
1116 macUeCfg->ambrCfg = NULLP;
1117 fillMacSrb1LcCfg(&macUeCfg->lcCfgList[0]);
1118 fillDefaultModulation(macUeCfg);
1123 /* Fetching MacDb from DuUeCb */
1124 GET_CELL_IDX(cellId, cellIdx);
1125 duMacDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg;
1126 /* Fetching MaUeCfg List for ADD/MOD/DEL */
1127 macUeCfg->cellId = cellId;
1128 macUeCfg->ueIdx = ueIdx;
1129 macUeCfg->crnti = crnti;
1130 ret = procUeReCfgCellInfo(macUeCfg, ueCfgDb->cellGrpCfg);
1133 if(macUeCfg->spCellCfgPres == true)
1135 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1137 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1138 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1140 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1142 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1143 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1146 ret = fillAmbr(&macUeCfg->ambrCfg, ueCfgDb->ambrCfg);
1147 if(ueCfgDb->ueNrCapability != NULLP)
1149 duFillModulationDetails(macUeCfg, duMacDb, ueCfgDb->ueNrCapability);
1153 /* Filling LC Context */
1154 for(dbIdx = 0; (dbIdx < ueCfgDb->numMacLcs && ret == ROK); dbIdx++)
1156 if(!ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres)
1158 /* Filling default UL LC config in MAC if not present */
1159 ueCfgDb->macLcCfg[dbIdx].ulLcCfgPres = true;
1160 fillDefaultUlLcCfg(&ueCfgDb->macLcCfg[dbIdx].ulLcCfg);
1162 for(lcIdx = 0; lcIdx < duMacDb->numLcs; lcIdx++)
1164 if(ueCfgDb->macLcCfg[dbIdx].lcId == duMacDb->lcCfgList[lcIdx].lcId)
1167 if((ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_UNKNOWN) ||
1168 (ueCfgDb->macLcCfg[dbIdx].configType == CONFIG_MOD))
1170 ueCfgDb->macLcCfg[dbIdx].configType = CONFIG_MOD;
1171 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1179 /* ADD/DEL CONFIG */
1180 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[dbIdx], &ueCfgDb->macLcCfg[dbIdx]);
1188 DU_LOG("\nERROR --> DU APP : Failed to add Lc at Idx %d in fillMacUeCfg()", dbIdx);
1191 }/*End of Outer FOR loop */
1196 /******************************************************************
1198 * @brief Fills Rlc AM Information
1202 * Function : fillDefaultAmInfo
1204 * Functionality: Fills Rlc AM Information
1206 * @params[in] AmBearerCfg *amCfg
1209 *****************************************************************/
1210 void fillDefaultAmInfo(AmBearerCfg *amCfg)
1213 amCfg->dlAmCfg.snLenDl = AM_SIZE_12;
1214 amCfg->dlAmCfg.pollRetxTmr = T_POLL_RETRANSMIT_VAL;
1215 amCfg->dlAmCfg.pollPdu = POLL_PDU_VAL;
1216 amCfg->dlAmCfg.pollByte = POLL_BYTE_VAL;
1217 amCfg->dlAmCfg.maxRetxTh = MAX_RETX_THRESHOLD_VAL;
1220 amCfg->ulAmCfg.snLenUl = AM_SIZE_12;
1221 amCfg->ulAmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1222 amCfg->ulAmCfg.statProhTmr = T_STATUS_PROHIBHIT_VAL;
1225 /******************************************************************
1227 * @brief Fills RLC UM Bi Directional Information
1231 * Function : fillDefaultUmBiInfo
1233 * Functionality: Fills RLC UM Bi Directional Information
1235 * @params[in] UmBiDirBearerCfg *umBiDirCfg
1238 *****************************************************************/
1239 void fillDefaultUmBiInfo(UmBiDirBearerCfg *umBiDirCfg)
1241 /* UL UM BI DIR INFO */
1242 umBiDirCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1243 umBiDirCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1245 /* DL UM BI DIR INFO */
1246 umBiDirCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1249 /******************************************************************
1251 * @brief Fills RLC UM Uni Directional UL Information
1255 * Function : fillDefaultUmUlInfo
1257 * Functionality: Fills RLC UM Uni Directional Info
1259 * @params[in] UmUniDirUlBearerCfg *UmUlCfg
1262 *****************************************************************/
1263 void fillDefaultUmUlInfo(UmUniDirUlBearerCfg *UmUlCfg)
1265 UmUlCfg->ulUmCfg.snLenUlUm = UM_SIZE_12;
1266 UmUlCfg->ulUmCfg.reAssemTmr = T_REASSEMBLY_VAL;
1269 /******************************************************************
1271 * @brief Fills RLC UM Uni Directional DL Information
1275 * Function : fillDefaultUmDlInfo
1277 * Functionality: Fills RLC UM Uni Directional DL Info
1279 * @params[in] UmUniDirDlBearerCfg *UmDlCfg
1282 *****************************************************************/
1283 void fillDefaultUmDlInfo(UmUniDirDlBearerCfg *UmDlCfg)
1285 UmDlCfg->dlUmCfg.snLenDlUm = UM_SIZE_12;
1288 /******************************************************************
1290 * @brief Builds Rlc Mode Default Configuration
1294 * Function : fillDefaultRlcModeCfg
1296 * Functionality: Builds Rlc Mode Default Configuration
1298 * @params[in] rlcMode, RlcBearerCfg *lcCfg
1299 * @return ROK/RFAILED
1301 *****************************************************************/
1303 uint8_t fillDefaultRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *lcCfg)
1314 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1316 fillDefaultAmInfo(lcCfg->u.amCfg);
1319 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at AmCfg at fillDefaultRlcModeCfg()");
1325 case RLC_UM_BI_DIRECTIONAL :
1327 if(!lcCfg->u.umBiDirCfg)
1329 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1330 if(lcCfg->u.umBiDirCfg)
1331 fillDefaultUmBiInfo(lcCfg->u.umBiDirCfg);
1334 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmBiDirCfg at fillDefaultRlcModeCfg()");
1340 case RLC_UM_UNI_DIRECTIONAL_UL :
1342 if(!lcCfg->u.umUniDirUlCfg)
1344 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1345 if(lcCfg->u.umUniDirUlCfg)
1346 fillDefaultUmUlInfo(lcCfg->u.umUniDirUlCfg);
1349 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirUlCfg at fillDefaultRlcModeCfg()");
1355 case RLC_UM_UNI_DIRECTIONAL_DL :
1357 if(!lcCfg->u.umUniDirDlCfg)
1359 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1360 if(lcCfg->u.umUniDirDlCfg)
1361 fillDefaultUmDlInfo(lcCfg->u.umUniDirDlCfg);
1364 DU_LOG("\n ERROR --> DU APP : Memory Alloc failed at UmUniDirDlCfg at fillDefaultRlcModeCfg()");
1371 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
1378 DU_LOG("\nERROR --> DUAPP: Received LC Config is NULL");
1384 /*******************************************************************
1386 * @brief Function to fill Rlc Lc Cfg for SRB1
1390 * Function : fillRlcSrb1LcCfg
1393 * Function to fill Rlc Lc Cfg for SRB1
1395 * @params[in] Pointer to RlcBearerCfg
1396 * @return ROK/RFAILED
1398 *****************************************************************/
1400 uint8_t fillRlcSrb1LcCfg(RlcBearerCfg *rlcLcCfg)
1404 rlcLcCfg->rbId = SRB1_LCID;
1405 rlcLcCfg->rbType = RB_TYPE_SRB;
1406 rlcLcCfg->lcId = SRB1_LCID;
1407 rlcLcCfg->lcType = LCH_DCCH;
1408 rlcLcCfg->rlcMode = RLC_AM;
1409 rlcLcCfg->configType = CONFIG_ADD;
1410 ret = fillDefaultRlcModeCfg(rlcLcCfg->rlcMode, rlcLcCfg);
1414 /*******************************************************************
1416 * @brief Processes UE ReConfig Req to RLC UL
1420 * Function : sendUeReCfgReqToRlc
1423 * Processes UE Reconfig Req to RLC UL
1425 * @params[in] Pointer to RlcUeCfg
1426 * @return ROK - success
1429 *****************************************************************/
1431 uint8_t sendUeReCfgReqToRlc(RlcUeCfg *rlcUeCfg)
1436 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_REQ);
1439 /* Processing one Ue at a time to RLC */
1440 DU_LOG("\nDEBUG --> DU_APP: Sending Ue Reconfig Request to RLC UL");
1441 ret = (*packRlcUeReconfigReqOpts[pst.selector])(&pst, rlcUeCfg);
1444 DU_LOG("\nERROR --> DU_APP : Failed to send Ue Reconfig Req to RLC at sendUeReCfgReqToRlc()");
1445 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
1450 DU_LOG("\nERROR --> DU_APP: Received RlcUeCfg is NULL at sendUeReCfgReqToRlc()");
1456 /******************************************************************
1458 * @brief Fills RlcBearerCfg structure
1462 * Function : fillRlcUeCfg
1464 * Functionality: Fills Rlc Bearer Cfg
1467 *****************************************************************/
1468 uint8_t fillRlcUeCfg(uint16_t cellId, uint8_t ueIdx,\
1469 DuUeCfg *ueCfgDb, RlcUeCfg *rlcUeCfg)
1471 uint8_t ret, dbIdx, lcIdx, cellIdx;
1472 bool lcIdFound = false;
1473 RlcUeCfg *duRlcDb = NULLP;
1478 /* Initial RB being Added */
1479 rlcUeCfg->cellId = cellId;
1480 rlcUeCfg->ueIdx = ueIdx;
1481 ret = fillRlcSrb1LcCfg(&rlcUeCfg->rlcLcCfg[0]);
1485 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1489 /* Fetch RlcDb from DuUeCb */
1490 GET_CELL_IDX(cellId, cellIdx);
1491 duRlcDb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg;
1492 /*Filling RlcUeCfg */
1493 rlcUeCfg->cellId = cellId;
1494 rlcUeCfg->ueIdx = ueIdx;
1495 for(dbIdx = 0; (dbIdx < ueCfgDb->numRlcLcs && ret == ROK); dbIdx++)
1497 ret = fillDefaultRlcModeCfg(ueCfgDb->rlcLcCfg[dbIdx].rlcMode, &ueCfgDb->rlcLcCfg[dbIdx]);
1500 DU_LOG("\n ERROR --> DU APP : Failed to fill Rlc Mode at fillRlcUeCfg()");
1501 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
1504 /* Fill Rlc Ue Cfg List for ADD/MOD/DEL */
1505 for(lcIdx = 0; lcIdx < duRlcDb->numLcs; lcIdx++)
1507 if(ueCfgDb->rlcLcCfg[dbIdx].lcId == duRlcDb->rlcLcCfg[lcIdx].lcId)
1510 if((ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_UNKNOWN)||
1511 (ueCfgDb->rlcLcCfg[dbIdx].configType == CONFIG_MOD))
1514 ueCfgDb->rlcLcCfg[dbIdx].configType = CONFIG_MOD; /* update Db for MOD type */
1515 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1523 /* ADD/ DEL Config Type */
1524 memcpy(&rlcUeCfg->rlcLcCfg[dbIdx], &ueCfgDb->rlcLcCfg[dbIdx], sizeof(RlcBearerCfg));
1532 /******************************************************************
1534 * @brief creates UE context
1538 * Function : duCreateUeCb
1540 * Functionality: Creates UE Conetxt
1542 * @params[in] UeCcchCtxt Pointer
1545 * @return ROK - success
1547 * ****************************************************************/
1548 uint8_t duCreateUeCb(UeCcchCtxt *ueCcchCtxt, uint32_t gnbCuUeF1apId)
1550 uint8_t cellIdx = 0;
1554 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
1556 if(ueCcchCtxt->cellId == duCb.actvCellLst[cellIdx]->cellId)
1558 GET_UE_IDX(ueCcchCtxt->crnti, ueIdx);
1559 DU_LOG("\nDEBUG --> DU_APP: Filling UeCb for ueIdx [%d]", ueIdx);
1561 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb = NULLP;
1562 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti = ueCcchCtxt->crnti;
1563 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId = ueCcchCtxt->gnbDuUeF1apId;
1564 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId = gnbCuUeF1apId;
1565 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].drbBitMap = NULLP;
1566 duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].ueState = UE_ACTIVE;
1568 /* Filling Mac Ue Config */
1569 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg, 0, sizeof(MacUeCfg));
1570 ret = duBuildAndSendUeCreateReqToMac(ueCcchCtxt->cellId, ueIdx, ueCcchCtxt->crnti,\
1571 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg);
1573 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to MAC");
1575 /* Filling Rlc Ue Config */
1576 memset(&duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg, 0, sizeof(RlcUeCfg));
1577 ret = duBuildAndSendUeCreateReqToRlc(ueCcchCtxt->cellId, ueIdx, \
1578 &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg);
1580 DU_LOG("\nERROR --> DU APP : Failed to send UE create request to RLC");
1582 duCb.actvCellLst[cellIdx]->numActvUes++;
1583 memset(ueCcchCtxt, 0, sizeof(UeCcchCtxt));
1589 /******************************************************************
1591 * @brief Builds and Send UE Create Request to MAC
1595 * Function : duBuildAndSendUeCreateReqToMac
1597 * Functionality: Builds and Send UE Create Request to MAC
1599 * @Params[in] cellId,
1601 * @return ROK - success
1604 * ****************************************************************/
1606 uint8_t duBuildAndSendUeCreateReqToMac(uint16_t cellId, uint8_t ueIdx,\
1607 uint16_t crnti, MacUeCfg *duMacUeCfg)
1610 MacUeCfg *macUeCfg = NULLP;
1612 memset(&pst, 0, sizeof(Pst));
1615 ret = fillMacUeCfg(cellId, ueIdx, crnti, NULL, duMacUeCfg);
1618 DU_LOG("\nERROR --> DU APP : Failed to fill MacUeCfg at duBuildAndSendUeCreateReqToMac()");
1622 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_UE_CREATE_REQ);
1624 /* Copying ueCb to a sharable buffer */
1625 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
1628 memset(macUeCfg, 0, sizeof(MacUeCfg));
1629 memcpy(macUeCfg, &duCb.actvCellLst[cellId - 1]->ueCb[ueIdx -1].macUeCfg, sizeof(MacUeCfg));
1630 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to MAC");
1632 /* Processing one Ue at a time to MAC */
1633 ret = (*packMacUeCreateReqOpts[pst.selector])(&pst, macUeCfg);
1636 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to MAC at duBuildAndSendUeCreateReqToMac()");
1637 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macUeCfg, sizeof(MacUeCfg));
1642 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToMac()");
1648 /*******************************************************************
1650 * @brief To update DuUeCb Mac Cfg
1654 * Function : duUpdateMacCfg
1655 * Functionality: update DuUeCb MAC Cfg
1657 * @params[in] DuUeCb Pointer
1658 * F1UeContextSetupDb pointer
1659 * @return ROK - success
1662 * ****************************************************************/
1663 uint8_t duUpdateMacCfg(MacUeCfg *macUeCfg, F1UeContextSetupDb *f1UeDb)
1665 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1668 /*Filling Cell Group Cfg*/
1669 ret = procUeReCfgCellInfo(macUeCfg, f1UeDb->duUeCfg.cellGrpCfg);
1672 if(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschPresent)
1674 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg.numTimeDomRsrcAlloc,\
1675 &macUeCfg->spCellCfg.servCellCfg.initDlBwp.pdschCfg, NULL);
1677 if(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschPresent)
1679 fillStartSymbolAndLen(macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg.numTimeDomRsrcAlloc,\
1680 NULL, &macUeCfg->spCellCfg.servCellCfg.initUlBwp.puschCfg);
1682 ret = fillAmbr(&macUeCfg->ambrCfg, f1UeDb->duUeCfg.ambrCfg);
1684 /* Filling LC Context */
1685 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numMacLcs && ret == ROK); dbIdx++)
1687 numLcs = macUeCfg->numLcs;
1688 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1690 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].lcId == macUeCfg->lcCfgList[lcIdx].lcId)
1692 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_MOD)
1694 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcIdx],&f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1696 else if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_DEL)
1698 /* Free memory at matched lcIdx index */
1699 freeMacLcCfg(&macUeCfg->lcCfgList[lcIdx]);
1701 for(lcDelIdx = lcIdx; lcDelIdx < macUeCfg->numLcs; lcDelIdx++)
1703 /* moving all elements one index ahead */
1704 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[lcDelIdx], &macUeCfg->lcCfgList[lcDelIdx+1]);
1705 freeMacLcCfg(&macUeCfg->lcCfgList[lcDelIdx+1]);
1708 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateMacCfg()", lcDelIdx);
1715 if(f1UeDb->duUeCfg.macLcCfg[dbIdx].configType == CONFIG_ADD)
1717 ret = fillMacLcCfgToAddMod(&macUeCfg->lcCfgList[numLcs], &f1UeDb->duUeCfg.macLcCfg[dbIdx]);
1720 DU_LOG("\nERROR --> DU APP : Failed to add LC at Idx %d in duUpdateMacCfg()", numLcs);
1730 /******************************************************************
1732 * @brief Function to fill the RLC Lc cfg from ueSetupReqDb
1736 * Function : fillRlcCfgToAddMod
1738 * Functionality: Function to fill the RLC Lc cfg from ueSetupReqDb
1741 *****************************************************************/
1743 uint8_t fillRlcCfgToAddMod(RlcBearerCfg *lcCfg, RlcBearerCfg *f1UeDbLcCfg)
1745 lcCfg->configType = f1UeDbLcCfg->configType;
1746 lcCfg->rbId = f1UeDbLcCfg->rbId;
1747 lcCfg->rbType = f1UeDbLcCfg->rbType;
1748 lcCfg->lcId = f1UeDbLcCfg->lcId;
1749 lcCfg->lcType = f1UeDbLcCfg->lcType;
1750 lcCfg->rlcMode = f1UeDbLcCfg->rlcMode;
1751 switch(lcCfg->rlcMode)
1757 DU_ALLOC_SHRABL_BUF(lcCfg->u.amCfg, sizeof(AmBearerCfg));
1762 lcCfg->u.amCfg->dlAmCfg.snLenDl = f1UeDbLcCfg->u.amCfg->dlAmCfg.snLenDl;
1763 lcCfg->u.amCfg->dlAmCfg.pollRetxTmr = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollRetxTmr;
1764 lcCfg->u.amCfg->dlAmCfg.pollPdu = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollPdu;
1765 lcCfg->u.amCfg->dlAmCfg.pollByte = f1UeDbLcCfg->u.amCfg->dlAmCfg.pollByte;
1766 lcCfg->u.amCfg->dlAmCfg.maxRetxTh = f1UeDbLcCfg->u.amCfg->dlAmCfg.maxRetxTh;
1769 lcCfg->u.amCfg->ulAmCfg.snLenUl = f1UeDbLcCfg->u.amCfg->ulAmCfg.snLenUl;
1770 lcCfg->u.amCfg->ulAmCfg.reAssemTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.reAssemTmr;
1771 lcCfg->u.amCfg->ulAmCfg.statProhTmr = f1UeDbLcCfg->u.amCfg->ulAmCfg.statProhTmr;
1774 case RLC_UM_BI_DIRECTIONAL :
1776 if(!lcCfg->u.umBiDirCfg)
1778 DU_ALLOC_SHRABL_BUF(lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
1779 if(!lcCfg->u.umBiDirCfg)
1782 /* UL UM BI DIR INFO */
1783 lcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.snLenUlUm;
1784 lcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umBiDirCfg->ulUmCfg.reAssemTmr;
1785 /* DL UM BI DIR INFO */
1786 lcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umBiDirCfg->dlUmCfg.snLenDlUm;
1789 case RLC_UM_UNI_DIRECTIONAL_UL :
1791 if(!lcCfg->u.umUniDirUlCfg)
1793 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
1794 if(!lcCfg->u.umUniDirUlCfg)
1797 lcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.snLenUlUm;
1798 lcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr = f1UeDbLcCfg->u.umUniDirUlCfg->ulUmCfg.reAssemTmr;
1802 case RLC_UM_UNI_DIRECTIONAL_DL :
1804 if(!lcCfg->u.umUniDirDlCfg)
1806 DU_ALLOC_SHRABL_BUF(lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
1807 if(!lcCfg->u.umUniDirDlCfg)
1810 lcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm = f1UeDbLcCfg->u.umUniDirDlCfg->dlUmCfg.snLenDlUm;
1814 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at fillRlcCfgToAddMod()", lcCfg->rlcMode);
1820 /*******************************************************************
1822 * @brief To update DuUeCb Rlc Lc Cfg
1826 * Function : duUpdateRlcLcCfg
1827 * Functionality: update DuUeCb Rlc Lc Cfg
1829 * @params[in] DuUeCb Pointer
1830 * F1UeContextSetupDb pointer
1831 * @return ROK - success
1834 * ****************************************************************/
1836 uint8_t duUpdateRlcLcCfg(RlcUeCfg *rlcUeCfg, F1UeContextSetupDb *f1UeDb)
1838 uint8_t ret, lcIdx, dbIdx, numLcs, lcDelIdx;
1841 for(dbIdx = 0; (dbIdx < f1UeDb->duUeCfg.numRlcLcs && ret ==ROK); dbIdx++)
1843 numLcs = rlcUeCfg->numLcs;
1844 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
1846 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].lcId == rlcUeCfg->rlcLcCfg[lcIdx].lcId)
1848 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_MOD)
1850 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1852 else if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_DEL)
1854 /* Free memory at matched lcIdx index */
1855 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcIdx]);
1857 for(lcDelIdx = lcIdx; lcDelIdx < rlcUeCfg->numLcs; lcDelIdx++)
1859 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcDelIdx], &rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1860 freeRlcLcCfg(&rlcUeCfg->rlcLcCfg[lcDelIdx+1]);
1863 DU_LOG("\nERROR --> DU APP : Failed to delete LC at Idx %d in duUpdateRlcCfg()", lcDelIdx);
1870 if(f1UeDb->duUeCfg.rlcLcCfg[dbIdx].configType == CONFIG_ADD)
1872 ret = fillRlcCfgToAddMod(&rlcUeCfg->rlcLcCfg[lcIdx], &f1UeDb->duUeCfg.rlcLcCfg[dbIdx]);
1881 /*******************************************************************
1883 * @brief Function to fill Tunnel Config to Add/Mod
1888 * Function : fillTnlCfgToAddMod
1890 * Functionality: Function to fill tunnel Config to Add/Mod
1892 * @params[in] Pointer to tnlCfgDb,
1893 * pointer to f1TnlCfg
1894 * @return ROK - success
1897 * ****************************************************************/
1898 uint8_t fillTnlCfgToAddMod(UpTnlCfg **ueCbTnlCfg, UpTnlCfg *f1TnlCfg)
1900 if(*ueCbTnlCfg == NULLP)
1902 /* copying to DuCb Tnl Cfg */
1903 DU_ALLOC(*ueCbTnlCfg, sizeof(UpTnlCfg));
1904 if(*ueCbTnlCfg == NULLP)
1906 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for drbId[%d]", f1TnlCfg->drbId);
1910 memset(*ueCbTnlCfg, 0, sizeof(UpTnlCfg));
1911 (*ueCbTnlCfg)->configType = f1TnlCfg->configType;
1912 (*ueCbTnlCfg)->cellId = f1TnlCfg->cellId;
1913 (*ueCbTnlCfg)->ueIdx = f1TnlCfg->ueIdx;
1914 (*ueCbTnlCfg)->drbId = f1TnlCfg->drbId;
1915 if(f1TnlCfg->tnlCfg1)
1917 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1919 DU_ALLOC((*ueCbTnlCfg)->tnlCfg1, sizeof(GtpTnlCfg));
1920 if((*ueCbTnlCfg)->tnlCfg1 == NULLP)
1922 DU_LOG("\nERROR --> DU_APP : fillTnlCfgToAddMod: Memory Alloc failed for tnlCfg1 for drbId[%d]", f1TnlCfg->drbId);
1926 memset((*ueCbTnlCfg)->tnlCfg1, 0, sizeof(GtpTnlCfg));
1927 (*ueCbTnlCfg)->tnlCfg1->teId = f1TnlCfg->tnlCfg1->teId;
1928 (*ueCbTnlCfg)->tnlCfg1->ulTnlAddress = f1TnlCfg->tnlCfg1->ulTnlAddress;
1929 (*ueCbTnlCfg)->tnlCfg1->dlTnlAddress = f1TnlCfg->tnlCfg1->dlTnlAddress;
1934 /*******************************************************************
1936 * @brief Processing the tunnel Request to EGTP
1940 * Function : duProcEgtpTunnelCfg
1942 * Functionality: Processing the tunnel Request to EGTP
1944 * @params[in] UptnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg
1945 * @return ROK - success
1948 * ****************************************************************/
1950 uint8_t duProcEgtpTunnelCfg(uint8_t ueCbIdx, UpTnlCfg *duTnlCfg, UpTnlCfg *f1TnlCfg)
1952 uint8_t ret = RFAILED, delIdx;
1954 if(f1TnlCfg->tnlCfg1 == NULLP)
1956 DU_LOG("\nERROR --> DU_APP : Tunnel config not found");
1960 if(f1TnlCfg->configType == CONFIG_ADD)
1962 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, NULLP, f1TnlCfg->tnlCfg1) == ROK)
1964 if(fillTnlCfgToAddMod(&duCb.upTnlCfg[duCb.numDrb], f1TnlCfg) == ROK)
1971 else if(f1TnlCfg->configType == CONFIG_MOD)
1973 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_MOD, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1975 if(fillTnlCfgToAddMod(&duTnlCfg, f1TnlCfg) == ROK)
1981 else if(f1TnlCfg->configType == CONFIG_DEL)
1983 if(duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_DEL, duTnlCfg->tnlCfg1->teId, f1TnlCfg->tnlCfg1) == ROK)
1985 /* Free memory at drbIdx */
1986 DU_FREE(duTnlCfg->tnlCfg1, sizeof(GtpTnlCfg));
1987 DU_FREE(duTnlCfg, sizeof(UpTnlCfg));
1989 for(delIdx = ueCbIdx; delIdx < duCb.numDrb; delIdx++)
1991 /* moving all elements one index ahead */
1992 ret = fillTnlCfgToAddMod(&duCb.upTnlCfg[delIdx], duCb.upTnlCfg[delIdx+1]);
2003 /***********************************************************************
2005 * @brief Function to fill Tunnel Config
2006 * and sends tunnel Req to EGTP
2011 * Function : duUpdateTunnelCfgDb
2013 * Functionality: Function to fill tunnel Config
2014 * and sends tunnel Cfg Req to EGTP
2016 * @params[in] ueIdx, cellId, DuUeCfg
2017 * @return ROK - success
2020 * ****************************************************************/
2022 uint8_t duUpdateTunnelCfgDb(uint8_t ueIdx, uint8_t cellId, DuUeCfg *duUeCfg)
2024 uint8_t ret = ROK, drbIdx, duCbDrbIdx;
2025 bool drbFound = false;
2027 /*If Add/Mod tunnels request for that DRB is successful in EGTP */
2028 /*then update drbId and tunnel Info in duCb */
2029 for(drbIdx=0; drbIdx < duUeCfg->numDrb; drbIdx++)
2031 duUeCfg->upTnlInfo[drbIdx].cellId = cellId;
2032 duUeCfg->upTnlInfo[drbIdx].ueIdx = ueIdx;
2033 for(duCbDrbIdx = 0; duCbDrbIdx < duCb.numDrb; duCbDrbIdx++)
2035 if(duCb.upTnlCfg[duCbDrbIdx]->drbId == duUeCfg->upTnlInfo[drbIdx].drbId)
2037 drbFound = true; /* existing DRB */
2038 if(duProcEgtpTunnelCfg(duCbDrbIdx, duCb.upTnlCfg[duCbDrbIdx], &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2040 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to modify tunnel req for Drb id[%d]",
2041 duUeCfg->upTnlInfo[drbIdx].drbId);
2049 if(!drbFound && ret == ROK)/* new DRB to Add */
2051 if(duProcEgtpTunnelCfg(NULLP, NULLP, &duUeCfg->upTnlInfo[drbIdx]) != ROK)
2053 DU_LOG("\nERROR -> DU_APP : duUpdateTunnelCfgDb: Failed to add tunnel req for Drb id[%d]",
2054 duUeCfg->upTnlInfo[drbIdx].drbId);
2065 /*******************************************************************
2067 * @brief @brief To update DuUeCb Mac and Rlc Ue Cfg
2072 * Function : duUpdateDuUeCbCfg
2074 * Functionality: update DuUeCb Mac and Rlc Ue Cfg
2076 * @params[in] ueIdx, cellIdx
2077 * @return ROK - success
2080 * ****************************************************************/
2082 uint8_t duUpdateDuUeCbCfg(uint8_t ueIdx, uint8_t cellId)
2084 uint8_t ret = ROK, cellIdx = 0, crnti=0;
2085 DuUeCb *ueCb = NULLP;
2087 GET_CELL_IDX(cellId, cellIdx);
2089 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].macUeCfg. \
2090 macUeCfgState == UE_RECFG_COMPLETE) &&
2091 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].rlcUeCfg. \
2092 rlcUeCfgState == UE_RECFG_COMPLETE))
2094 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
2096 /*Filling RLC Ue Cfg */
2097 ueCb->rlcUeCfg.cellId = cellId;
2098 ueCb->rlcUeCfg.ueIdx = ueIdx;
2099 ret = duUpdateRlcLcCfg(&ueCb->rlcUeCfg, ueCb->f1UeDb);
2102 /*Filling MAC Ue Cfg */
2103 GET_CRNTI(crnti, ueIdx);
2104 ueCb->macUeCfg.cellId = cellId;
2105 ueCb->macUeCfg.ueIdx = ueIdx;
2106 ueCb->macUeCfg.crnti = crnti;
2107 ret = duUpdateMacCfg(&ueCb->macUeCfg, ueCb->f1UeDb);
2109 DU_LOG("\nERROR --> DU APP : Failed while updating MAC LC Config at duUpdateDuUeCbCfg()");
2112 if(duUpdateTunnelCfgDb(ueIdx, cellId, &ueCb->f1UeDb->duUeCfg) != ROK)
2114 DU_LOG("\nERROR --> DU_APP : Failed to establish tunnel in duUpdateDuUeCbCfg()");
2120 DU_LOG("\nERROR --> DU APP : Failed while updating RLC LC Config at duUpdateDuUeCbCfg()");
2127 /*******************************************************************
2129 * @brief Handle UE config response from MAC
2133 * Function : DuProcMacUeCfgRsp
2135 * Functionality: Handle UE Config response from MAC
2137 * @params[in] Pointer to MacUeCfgRsp and Pst
2138 * @return ROK - success
2141 * ****************************************************************/
2142 uint8_t DuProcMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
2148 if(cfgRsp->result == MAC_DU_APP_RSP_OK)
2150 if(pst->event == EVENT_MAC_UE_CREATE_RSP)
2152 DU_LOG("\nINFO --> DU APP : MAC UE Create Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2153 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2154 macUeCfg.macUeCfgState = UE_CREATE_COMPLETE;
2156 else if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2158 DU_LOG("\nINFO --> DU APP : MAC UE Reconfig Response : SUCCESS [UE IDX : %d]", cfgRsp->ueIdx);
2159 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2160 macUeCfg.macUeCfgState = UE_RECFG_COMPLETE;
2161 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2163 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2164 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2165 macUeCfg.macUeCfgState = 0;
2171 DU_LOG("\nERROR --> DU APP : MAC UE CFG Response for EVENT[%d]: FAILURE [UE IDX : %d]", pst->event, cfgRsp->ueIdx);
2172 if(pst->event == EVENT_MAC_UE_RECONFIG_RSP)
2174 //TODO: Send the failure case in Ue Context Setup Response
2178 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacUeCfgRsp));
2182 DU_LOG("\nERROR --> DU APP : Received MAC Ue Config Response is NULL at DuProcMacUeCfgRsp()");
2189 /*******************************************************************
2191 * @brief Processes UE create Req to RLC UL
2195 * Function : duBuildAndSendUeCreateReqToRlc
2198 * Processes UE create Req to RLC UL
2200 * @params[in] cellId,
2202 * Pointer to RlcUeCfg
2203 * @return ROK - success
2206 *****************************************************************/
2208 uint8_t duBuildAndSendUeCreateReqToRlc(uint16_t cellId, uint8_t ueIdx,\
2209 RlcUeCfg *duRlcUeCfg)
2212 RlcUeCfg *rlcUeCfg = NULLP;
2215 ret = fillRlcUeCfg(cellId, ueIdx, NULL, duRlcUeCfg);
2218 DU_LOG("\nERROR --> DU APP : Failed to fill Rlc Ue Cfg at duBuildAndSendUeCreateReqToRlc()");
2222 FILL_PST_DUAPP_TO_RLC(pst, RLC_UL_INST, EVENT_RLC_UE_CREATE_REQ);
2223 /* Copying ueCfg to a sharable buffer */
2224 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2227 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2228 memcpy(rlcUeCfg, duRlcUeCfg, sizeof(RlcUeCfg));
2229 /* Processing one Ue at a time to RLC */
2230 DU_LOG("\nDEBUG --> DU_APP: Sending UE create request to RLC UL");
2231 ret = (*packRlcUeCreateReqOpts[pst.selector])(&pst, rlcUeCfg);
2234 DU_LOG("\nERROR --> DU_APP : Failure in sending Ue Create Req to RLC");
2235 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, rlcUeCfg, sizeof(RlcUeCfg));
2241 DU_LOG("\n ERROR --> DU APP : Memory alloc failed at duBuildAndSendUeCreateReqToRlc()");
2247 /*******************************************************************
2249 * @brief Processes UE create Rsp received from RLC UL
2254 * Function : DuProcRlcUeCfgRsp
2257 * Processes UE create Rsp received from RLC UL
2259 * @params[in] Post structure
2260 * Pointer to RlcCfgCfm
2261 * @return ROK - success
2264 *****************************************************************/
2265 uint8_t DuProcRlcUeCfgRsp(Pst *pst, RlcUeCfgRsp *cfgRsp)
2271 if(cfgRsp->result == RLC_DU_APP_RSP_OK)
2273 if(pst->event == EVENT_RLC_UE_CREATE_RSP)
2275 DU_LOG("\nINFO --> DU_APP: RLC UE Create Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2276 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2277 rlcUeCfg.rlcUeCfgState = UE_CREATE_COMPLETE;
2279 else if(pst->event == EVENT_RLC_UE_RECONFIG_RSP)
2281 DU_LOG("\nINFO --> DU_APP: RLC UE Reconfig Response : SUCCESS [UE IDX:%d]", cfgRsp->ueIdx);
2282 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2283 rlcUeCfg.rlcUeCfgState = UE_RECFG_COMPLETE;
2284 if((ret = duUpdateDuUeCbCfg(cfgRsp->ueIdx, cfgRsp->cellId)) == ROK)
2286 BuildAndSendUeCtxtRsp(cfgRsp->ueIdx, cfgRsp->cellId);
2287 duCb.actvCellLst[cfgRsp->cellId -1]->ueCb[cfgRsp->ueIdx -1].\
2288 rlcUeCfg.rlcUeCfgState = 0;
2294 DU_LOG("\nERROR --> DU_APP: RLC UE CFG Response for EVENT[%d] : FAILED [UE IDX : %d, REASON :%d]",\
2295 pst->event, cfgRsp->ueIdx, cfgRsp->reason);
2296 if((pst->event == EVENT_RLC_UE_RECONFIG_RSP))
2298 //TODO: update failure case in ue Context setup Response
2302 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(RlcUeCfgRsp));
2306 DU_LOG("\nERROR --> DU_APP: Received RLC Ue Config Response is NULL at DuProcRlcUeCfgRsp()");
2312 /*******************************************************************
2314 * @brief Builds and Send Ue Reconfig Req to RLC
2318 * Function : duBuildAndSendUeReCfgReqToRLC
2320 * Functionality: Builds and Send Ue Reconfig Req to RLC
2322 * @params[in] cellId, crnti
2324 * RlcUeCfg *rlcUeCfg
2325 * @return ROK - success
2328 * ****************************************************************/
2330 uint8_t duBuildAndSendUeReCfgReqToRlc(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2332 uint8_t ret = ROK, ueIdx = 0;
2333 RlcUeCfg *rlcUeCfg = NULLP;
2335 GET_UE_IDX(crnti, ueIdx);
2336 DU_ALLOC_SHRABL_BUF(rlcUeCfg, sizeof(RlcUeCfg));
2339 memset(rlcUeCfg, 0, sizeof(RlcUeCfg));
2340 ret = fillRlcUeCfg(cellId, ueIdx, ueCfgDb, rlcUeCfg);
2342 DU_LOG("\nERROR --> DU APP : Failed at duBuildAndSendUeReCfgReqToRlc()");
2344 ret = sendUeReCfgReqToRlc(rlcUeCfg);
2348 DU_LOG("\nERROR --> DU APP : Memory Alloc failed at duBuildAndSendUeReCfgReqToRlc()");
2354 /*******************************************************************
2356 * @brief Builds and Send Ue Reconfig Req to MAC
2360 * Function : duBuildAndSendUeReCfgReqToMac
2362 * Functionality: Builds and Send Ue Reconfig Req to MAC
2364 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
2366 * MacUeCfg *macUeCfg
2367 * @return ROK - success
2370 * ****************************************************************/
2372 uint8_t duBuildAndSendUeReCfgReqToMac(uint8_t cellId, uint8_t crnti, DuUeCfg *ueCfgDb)
2374 uint8_t ret, ueIdx = 0;
2375 MacUeCfg *macUeCfg = NULLP;
2378 GET_UE_IDX(crnti, ueIdx);
2380 DU_ALLOC_SHRABL_BUF(macUeCfg, sizeof(MacUeCfg));
2383 memset(macUeCfg, 0, sizeof(MacUeCfg));
2384 ret = fillMacUeCfg(cellId, ueIdx, crnti, ueCfgDb, macUeCfg);
2386 DU_LOG("\nERROR --> DU APP : Failed to fill Mac Ue Cfg at duBuildAndSendUeReCfgReqToMac()");
2388 ret = sendUeReCfgReqToMac(macUeCfg);
2392 DU_LOG("\nERROR --> DU APP : Memory alloc failed for macUeCfg at duBuildAndSendUeReCfgReqToMac()");
2398 /*******************************************************************
2400 * @brief Build and Send Ue context setup request
2405 * Function : duBuildAndSendUeContextSetupReq
2408 * Build and Send Ue context setup request
2410 * @params[in] cellId, crnti, DuUeCfg pointer
2411 * @return ROK - success
2414 *****************************************************************/
2416 uint8_t duBuildAndSendUeContextSetupReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2420 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Setup Request for cellId [%d]", cellId);
2421 /* Filling RLC Ue Reconfig */
2422 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2424 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextSetupReq()");
2426 /* Filling MAC Ue Reconfig */
2427 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2429 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextSetupReq()");
2434 /*******************************************************************
2436 * @brief Processes DL Rsp received from RLC DL
2441 * Function : DuProcRlcDlRrcMsgRsp
2444 * Processes UE Rsp received from RLC DL
2446 * @params[in] Post structure
2447 * Pointer to RlcCfgCfm
2448 * @return ROK - success
2451 *****************************************************************/
2452 uint8_t DuProcRlcDlRrcMsgRsp(Pst *pst, RlcDlRrcMsgRsp *dlRrcMsg)
2454 uint8_t ret = ROK, ueIdx = 0;
2455 DuUeCb *ueCb = NULLP;
2457 if(dlRrcMsg->state == TRANSMISSION_COMPLETE)
2459 GET_UE_IDX(dlRrcMsg->crnti, ueIdx);
2460 ueCb = &duCb.actvCellLst[dlRrcMsg->cellId -1]->ueCb[ueIdx -1];
2461 if(ueCb->f1UeDb && ueCb->f1UeDb->dlRrcMsgPres)
2463 if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2465 ret = duBuildAndSendUeContextSetupReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2467 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Setup Request in DuProcRlcDlRrcMsgRsp()");
2469 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
2471 ret = duBuildAndSendUeContextModReq(dlRrcMsg->cellId, dlRrcMsg->crnti, &ueCb->f1UeDb->duUeCfg);
2473 DU_LOG("\nERROR --> DU APP : Failed to process UE Context Mod Request in DuProcRlcDlRrcMsgRsp()");
2478 DU_LOG("\nERROR --> DU APP : Failed to transmit DL RRC Msg");
2480 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, dlRrcMsg, sizeof(RlcDlRrcMsgRsp));
2483 /*******************************************************************
2485 * @brief Process UE context setup request from CU
2489 * Function : duProcUeContextSetupRequest
2491 * Functionality: Process UE context setup request from CU
2493 * @params[in] F1AP message
2494 * @return ROK - success
2497 * ****************************************************************/
2499 uint8_t duProcUeContextSetupRequest(DuUeCb *ueCb)
2501 uint8_t ret, cellId;
2506 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2507 /* Send DL RRC msg for security Mode */
2508 if(ueCb->f1UeDb->dlRrcMsg)
2510 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2512 /* Sending DL RRC Message to RLC */
2513 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2516 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextSetupRequest()");
2517 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2518 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2519 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2523 else if(ueCb->f1UeDb->actionType == UE_CTXT_SETUP)
2525 ret = duBuildAndSendUeContextSetupReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2528 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextSetupRequest()");
2534 //TODO: To send the failure cause in UeContextSetupRsp
2535 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT SETUP REQ at duProcUeContextSetupRequest()");
2540 /*******************************************************************
2542 * @brief Build and Send Ue context mod request
2547 * Function : duBuildAndSendUeContextModReq
2550 * Build and Send Ue context mod request
2552 * @params[in] cellId, crnti, DuUeCfg pointer
2553 * @return ROK - success
2556 *****************************************************************/
2558 uint8_t duBuildAndSendUeContextModReq(uint16_t cellId, uint16_t crnti, DuUeCfg *duUeCfg)
2562 DU_LOG("\nDEBUG --> DU_APP: Processing Ue Context Mod Request for cellId [%d]", cellId);
2563 /* Filling RLC Ue Reconfig */
2564 ret = duBuildAndSendUeReCfgReqToRlc(cellId, crnti, duUeCfg);
2566 DU_LOG("\nERROR --> DU APP : Failed to build ctxt setup req for RLC at duBuildAndSendUeContextModReq()");
2568 /* Filling MAC Ue Reconfig */
2569 ret = duBuildAndSendUeReCfgReqToMac(cellId, crnti, duUeCfg);
2571 DU_LOG("\nERROR --> DU APP : Failed at build ctxt setup req for MAC at duBuildAndSendUeContextModReq()");
2575 /*******************************************************************
2577 * @brief Processing Ue context mod request
2582 * Function : duProcUeContextModReq
2585 * Processing Ue context mod request
2587 * @params[in] DuUeCb *ueCb
2588 * @return ROK - success
2591 *****************************************************************/
2593 uint8_t duProcUeContextModReq(DuUeCb *ueCb)
2595 uint8_t ret, cellId;
2600 cellId = duCb.actvCellLst[ueCb->f1UeDb->cellIdx]->cellId;
2601 /* Send DL RRC msg for security Mode */
2602 if(ueCb->f1UeDb->dlRrcMsg)
2604 if(ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
2606 /* Sending DL RRC Message to RLC */
2607 ret = duBuildAndSendDlRrcMsgToRlc(cellId, ueCb->rlcUeCfg, ueCb->f1UeDb->dlRrcMsg);
2610 DU_LOG("\nERROR --> DU APP : Failed to send DL RRC msg in duProcUeContextModReq()");
2611 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg->rrcMsgPdu,\
2612 ueCb->f1UeDb->dlRrcMsg->rrcMsgSize);
2613 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
2619 ret = duBuildAndSendUeContextModReq(cellId, ueCb->crnti, &ueCb->f1UeDb->duUeCfg);
2622 DU_LOG("\nERROR --> DU APP : Failed to build ue context setup Req in duProcUeContextModReq()");
2628 //TODO: To send the failure cause in UeContextModRsp
2629 DU_LOG("ERROR --> DU APP : Failed to process UE CNTXT MOD REQ at duProcUeContextModReq()");
2633 /**********************************************************************
2635 ***********************************************************************/