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 *******************************************************************************/
19 /* This file contains message handling functionality for DU APP */
20 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
31 #include "du_e2ap_mgr.h"
33 #include "du_app_rlc_inf.h"
37 #include "du_f1ap_msg_hdl.h"
38 #include "du_ue_mgr.h"
42 #include "du_cell_mgr.h"
46 #include "AlarmInterface.h"
47 #include "CmInterface.h"
48 #include "PmInterface.h"
53 uint8_t numRlcDlSaps = 0;
55 uint8_t numRlcMacSaps = 0;
57 uint8_t macCfgInst = 0;
59 DuCfgParams duCfgParam;
60 uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg);
61 uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg);
62 uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
63 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg);
64 uint8_t BuildAndSendDUConfigUpdate();
65 uint16_t getTransId();
66 uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
67 uint8_t sendCellDeleteReqToMac(uint16_t cellId);
69 packMacCellCfgReq packMacCellCfgOpts[] =
71 packMacCellCfg, /* packing for loosely coupled */
72 MacProcCellCfgReq, /* packing for tightly coupled */
73 packMacCellCfg, /* packing for light weight loosly coupled */
76 DuMacCellStart packMacCellStartOpts[] =
78 packMacCellStart, /* Loose coupling */
79 MacProcCellStart, /* TIght coupling */
80 packMacCellStart /* Light weight-loose coupling */
83 DuMacCellStop packMacCellStopOpts[] =
85 packMacCellStop, /* Loose coupling */
86 MacProcCellStop, /* TIght coupling */
87 packMacCellStop /* Light weight-loose coupling */
90 DuMacSliceCfgReq packMacSliceCfgReqOpts[] =
92 packDuMacSliceCfgReq, /* Loose coupling */
93 MacProcSliceCfgReq, /* TIght coupling */
94 packDuMacSliceCfgReq /* Light weight-loose coupling */
98 DuMacSliceRecfgReq packMacSliceRecfgReqOpts[] =
100 packDuMacSliceRecfgReq, /* Loose coupling */
101 MacProcSliceRecfgReq, /* TIght coupling */
102 packDuMacSliceRecfgReq /* Light weight-loose coupling */
104 /**************************************************************************
105 * @brief Function to fill configs required by RLC
109 * Function : duBuildRlcCfg
112 * Initiates general Configs towards RLC
114 * @param[in] Inst Specifies if RLC UL or RLC DL instance
115 * @return ROK - success
118 ***************************************************************************/
119 uint8_t duBuildRlcCfg(Inst inst)
122 RlcGenCfg *genCfg = NULLP;
125 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
126 DU_SET_ZERO(&pst, sizeof(Pst));
128 genCfg = &(rlcMngmt.t.cfg.s.gen);
130 /*----------- Fill General Configuration Parameters ---------*/
131 genCfg->maxUe = duCfgParam.maxUe;
132 genCfg->maxKwuSaps = 2;
133 genCfg->maxUdxSaps = 1;
134 genCfg->rlcMode = (inst == RLC_UL_INST) ?
135 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
137 genCfg->maxRguSaps = DEFAULT_CELLS;
139 /*----------- Fill lmPst
140 * Parameters ---------*/
141 genCfg->lmPst.dstProcId = DU_PROC;
142 genCfg->lmPst.srcProcId = DU_PROC;
143 genCfg->lmPst.dstEnt = ENTDUAPP;
144 genCfg->lmPst.dstInst = DU_INST;
145 genCfg->lmPst.srcEnt = ENTRLC;
146 genCfg->lmPst.srcInst = inst;
147 genCfg->lmPst.prior = PRIOR0;
148 genCfg->lmPst.route = RTESPEC;
149 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
150 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
151 genCfg->lmPst.pool = RLC_POOL;
152 genCfg->lmPst.selector = ODU_SELECTOR_LC;
155 rlcMngmt.hdr.msgType = TCFG;
156 rlcMngmt.hdr.msgLen = 0;
157 rlcMngmt.hdr.entId.ent = ENTRLC;
158 rlcMngmt.hdr.entId.inst = (Inst)0;
159 rlcMngmt.hdr.elmId.elmnt = STGEN;
160 rlcMngmt.hdr.seqNmb = 0;
161 rlcMngmt.hdr.version = 0;
162 rlcMngmt.hdr.transId = 0;
163 rlcMngmt.hdr.response.prior = PRIOR0;
164 rlcMngmt.hdr.response.route = RTESPEC;
165 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
166 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
167 rlcMngmt.hdr.response.mem.pool = DU_POOL;
168 rlcMngmt.hdr.response.selector = ODU_SELECTOR_LC;
171 pst.selector = ODU_SELECTOR_LC;
172 pst.srcEnt = ENTDUAPP;
175 pst.dstProcId = DU_PROC;
176 pst.srcProcId = DU_PROC;
177 pst.region = duCb.init.region;
179 DU_LOG("\nDEBUG --> DU_APP : RLC Gen Cfg Req sent for inst %d", inst);
181 /* Send the request to RLC */
182 packRlcConfigReq(&pst, &rlcMngmt);
187 /**************************************************************************
188 * @brief Function to fill configs required by RLC
192 * Function : duBuildRlcLsapCfg
195 * Initiates general Configs towards RLC
197 * @param[in] Inst Specifies if RLC UL or RLC DL instance
198 * @return ROK - success
201 ***************************************************************************/
202 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst)
206 RlcSapCfg *lSap = NULLP;
209 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
210 DU_SET_ZERO(&pst, sizeof(Pst));
213 rlcMngmt.hdr.msgType = TCFG;
214 rlcMngmt.hdr.entId.ent = ENTRLC;
215 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
216 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
218 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
221 pst.selector = ODU_SELECTOR_LC;
222 pst.srcEnt = ENTDUAPP;
224 pst.dstProcId = DU_PROC;
226 pst.srcProcId = DU_PROC;
227 pst.region = duCb.init.region;
228 lSap = &(rlcMngmt.t.cfg.s.sap);
230 lSap->mem.region = (inst == RLC_UL_INST) ?
231 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
232 lSap->mem.pool = RLC_POOL;
234 lSap->bndTmrIntvl = 10;
235 lSap->priority = PRIOR0;
236 lSap->route = RTESPEC;
239 lSap->procId = DU_PROC;
241 lSap->inst = lsapInst;
242 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
243 lSap->selector = (inst == RLC_UL_INST) ? ODU_SELECTOR_LWLC : ODU_SELECTOR_TC;
244 rlcMngmt.hdr.elmId.elmnt = STRGUSAP;
245 DU_LOG("\nDEBUG --> DU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
250 lSap->procId = DU_PROC;
252 lSap->inst = (inst == RLC_UL_INST) ?
253 RLC_DL_INST : RLC_UL_INST;
255 lSap->selector = ODU_SELECTOR_LC;
256 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
257 DU_LOG("\nDEBUG --> DU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
260 packRlcConfigReq(&pst, &rlcMngmt);
264 /**************************************************************************
265 * @brief Function to fill configs required by RLC
269 * Function : duBuildRlcUsapCfg
272 * Initiates general Configs towards RLC
274 * @param[in] Inst Specifies if RLC UL or RLC DL instance
275 * @return ROK - success
278 ***************************************************************************/
279 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
282 RlcSapCfg *uSap = NULLP;
285 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
286 DU_SET_ZERO(&pst, sizeof(Pst));
288 uSap = &(rlcMngmt.t.cfg.s.sap);
290 uSap->selector = ODU_SELECTOR_LC;
291 uSap->mem.region = (inst == RLC_UL_INST) ?
292 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
293 uSap->mem.pool = RLC_POOL;
296 uSap->procId = DU_PROC;
300 uSap->inst = (inst == RLC_UL_INST) ?
301 RLC_DL_INST : RLC_UL_INST;
302 uSap->bndTmrIntvl = 1000;
303 uSap->priority = PRIOR0;
304 uSap->route = RTESPEC;
307 rlcMngmt.hdr.msgType = TCFG;
308 rlcMngmt.hdr.entId.ent = ENTRLC;
309 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
310 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
311 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
313 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
316 pst.selector = ODU_SELECTOR_LC;
317 pst.srcEnt = ENTDUAPP;
319 pst.dstProcId = DU_PROC;
321 pst.srcProcId = DU_PROC;
322 pst.region = duCb.init.region;
324 DU_LOG("\nDEBUG --> DU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
325 packRlcConfigReq(&pst, &rlcMngmt);
330 /**************************************************************************
331 * @brief Function to populate internal DS of DU APP
335 * Function : duProcCfgComplete
338 * Populates internal data structures of DU APP after
339 * receiving configurations.
342 * @return ROK - success
345 ***************************************************************************/
346 uint8_t duProcCfgComplete()
350 for(idx=0; idx< DEFAULT_CELLS; idx++)
352 DuCellCb *cell = NULLP;
353 DU_ALLOC(cell, sizeof(DuCellCb));
356 DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete");
362 memset(cell, 0, sizeof(DuCellCb));
363 cell->cellId = NR_CELL_ID; //++cellId;
364 memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
365 cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
366 cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
367 cell->cellInfo.nrEcgi.plmn.mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
368 cell->cellInfo.nrEcgi.plmn.mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
369 cell->cellInfo.nrEcgi.plmn.mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
370 cell->cellInfo.nrEcgi.plmn.mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
371 cell->cellInfo.nrEcgi.cellId = cell->cellId;
372 cell->cellInfo.nrPci = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
373 cell->cellInfo.fiveGsTac = duCfgParam.srvdCellLst[0].duCellInfo.tac;
374 memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn));
375 for(idx1=0; idx1<MAX_PLMN; idx1++)
377 cell->cellInfo.plmn[idx1].mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
378 cell->cellInfo.plmn[idx1].mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
379 cell->cellInfo.plmn[idx1].mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
380 cell->cellInfo.plmn[idx1].mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
381 cell->cellInfo.plmn[idx1].mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
382 cell->cellInfo.plmn[idx1].mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
384 cell->cellInfo.maxUe = duCfgParam.maxUe;
385 cell->cellStatus = CELL_OUT_OF_SERVICE;
386 gCellStatus = CELL_DOWN;
387 duCb.cfgCellLst[duCb.numCfgCells] = cell;
393 //Start layer configs
394 ret = duSendRlcUlCfg();
398 /**************************************************************************
399 * @brief Function to invoke DU Layer Configs
403 * Function : duSendRlcUlCfg
406 * Initiates Configs towards layers of DU
409 * @return ROK - success
412 ***************************************************************************/
413 uint8_t duSendRlcUlCfg()
417 duBuildRlcCfg((Inst)RLC_UL_INST);
418 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
420 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
422 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
427 /**************************************************************************
428 * @brief Function to invoke DU Layer Configs
432 * Function : duSendRlcDlCfg
435 * Initiates Configs towards layers of DU
438 * @return ROK - success
441 ***************************************************************************/
442 uint8_t duSendRlcDlCfg()
446 duBuildRlcCfg((Inst)RLC_DL_INST);
447 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
448 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
450 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
455 /**************************************************************************
456 * @brief Function to handle Config Confirm from RLC
460 * Function : DuHdlRlcCfgComplete
463 * Handles Gen Config Confirm from RLC
465 * @param[in] Pst *pst, Post structure of the primitive.
466 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
467 * @return ROK - success
470 ***************************************************************************/
471 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
474 if (pst->srcInst == RLC_UL_INST)
476 ret = duProcRlcUlCfgComplete(pst, cfm);
480 ret = duProcRlcDlCfgComplete(pst, cfm);
485 /**************************************************************************
486 * @brief Function to handle Control Config Confirm from RLC
490 * Function : duHdlRlcCntrlCfgComplete
493 * Handles Control Config Confirm from RLC
495 * @param[in] Pst *pst, Post structure of the primitive.
496 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
497 * @return ROK - success
500 ***************************************************************************/
501 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
505 if (cntrl->cfm.status == LCM_PRIM_OK)
507 switch (cntrl->hdr.elmId.elmnt)
511 if (pst->srcInst == RLC_DL_INST)
513 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
515 if(macCfgInst < DEFAULT_CELLS)
518 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
522 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
527 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
529 if(macCfgInst < DEFAULT_CELLS)
531 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
545 /**************************************************************************
546 * @brief Function to handle Config Confirm from RLC UL
550 * Function : duHdlRlcUlCfgComplete
553 * Handles Config Confirm from RLC UL
555 * @param[in] Pst *pst, Post structure of the primitive.
556 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
557 * @return ROK - success
560 ***************************************************************************/
561 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
565 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
566 if (cfm->cfm.status == LCM_PRIM_OK)
568 switch(cfm->hdr.elmId.elmnt)
572 rlcUlCfg |= RLC_GEN_CFG;
578 if(numRlcMacSaps == DEFAULT_CELLS)
580 rlcUlCfg |= RLC_MAC_SAP_CFG;
587 rlcUlCfg |= RLC_UDX_SAP_CFG;
594 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
595 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
599 //Start configuration of RLC DL
606 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
612 /**************************************************************************
613 * @brief Function to handle Config Confirm from RLC DL
617 * Function : duHdlRlcDlCfgComplete
620 * Handles Config Confirm from RLC DL
622 * @param[in] Pst *pst, Post structure of the primitive.
623 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
624 * @return ROK - success
627 ***************************************************************************/
628 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
630 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
631 if (cfm->cfm.status == LCM_PRIM_OK)
633 switch(cfm->hdr.elmId.elmnt)
637 rlcDlCfg |= RLC_GEN_CFG;
643 if(numRlcMacSaps == DEFAULT_CELLS)
645 rlcDlCfg |= RLC_MAC_SAP_CFG;
652 rlcDlCfg |= RLC_UDX_SAP_CFG;
660 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
661 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
664 //Start configuration of MAC
671 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
676 /**************************************************************************
677 * @brief Function to send configs to MAC
681 * Function : duSendMacCfg
684 * Initiates Configs towards MAC layer
687 * @return ROK - success
690 ***************************************************************************/
691 uint8_t duSendMacCfg()
694 duBuildMacUsapCfg(RLC_UL_INST);
695 duBuildMacUsapCfg(RLC_DL_INST);
700 /**************************************************************************
701 * @brief Function to fill gen config required by MAC
705 * Function : duBuildMacGenCfg
708 * Initiates general Configs towards MAC
711 * @return ROK - success
714 ***************************************************************************/
715 uint8_t duBuildMacGenCfg()
718 RgGenCfg *genCfg=NULLP;
721 DU_SET_ZERO(&pst, sizeof(Pst));
722 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
724 genCfg = &(rgMngmt.t.cfg.s.genCfg);
726 /*----------- Fill General Configuration Parameters ---------*/
727 genCfg->mem.region = MAC_MEM_REGION;
728 genCfg->mem.pool = MAC_POOL;
730 genCfg->numRguSaps = 2;
732 genCfg->lmPst.dstProcId = DU_PROC;
733 genCfg->lmPst.srcProcId = DU_PROC;
734 genCfg->lmPst.dstEnt = ENTDUAPP;
735 genCfg->lmPst.dstInst = 0;
736 genCfg->lmPst.srcEnt = ENTMAC;
737 genCfg->lmPst.srcInst = macCfgInst;
738 genCfg->lmPst.prior = PRIOR0;
739 genCfg->lmPst.route = RTESPEC;
740 genCfg->lmPst.region = MAC_MEM_REGION;
741 genCfg->lmPst.pool = MAC_POOL;
742 genCfg->lmPst.selector = ODU_SELECTOR_LC;
745 rgMngmt.hdr.msgType = TCFG;
746 rgMngmt.hdr.msgLen = 0;
747 rgMngmt.hdr.entId.ent = ENTMAC;
748 rgMngmt.hdr.entId.inst = (Inst)0;
749 rgMngmt.hdr.elmId.elmnt = STGEN;
750 rgMngmt.hdr.seqNmb = 0;
751 rgMngmt.hdr.version = 0;
752 rgMngmt.hdr.transId = 0;
754 rgMngmt.hdr.response.prior = PRIOR0;
755 rgMngmt.hdr.response.route = RTESPEC;
756 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
757 rgMngmt.hdr.response.mem.pool = MAC_POOL;
758 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
761 pst.selector = ODU_SELECTOR_LC;
762 pst.srcEnt = ENTDUAPP;
764 pst.dstInst = macCfgInst;
765 pst.dstProcId = DU_PROC;
766 pst.srcProcId = DU_PROC;
767 pst.region = duCb.init.region;
769 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
771 /* Send the request to MAC */
772 cmPkLrgCfgReq(&pst, &rgMngmt);
777 /**************************************************************************
778 * @brief Function to fill USAP config required by MAC
782 * Function : duBuildMacUsapCfg
785 * Initiates USAP Configs towards MAC
787 * @param[in] SpId Specifies if RLC UL or RLC DL instance
788 * @return ROK - success
791 ***************************************************************************/
792 uint8_t duBuildMacUsapCfg(SpId sapId)
795 RgUpSapCfg *uSap = NULLP;
798 DU_SET_ZERO(&pst, sizeof(Pst));
799 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
801 uSap = &(rgMngmt.t.cfg.s.rguSap);
803 uSap->mem.region = MAC_MEM_REGION;
804 uSap->mem.pool = MAC_POOL;
807 uSap->procId = DU_PROC;
810 uSap->prior = PRIOR0;
811 uSap->route = RTESPEC;
812 uSap->selector = ODU_SELECTOR_LC ;
815 rgMngmt.hdr.msgType = TCFG;
816 rgMngmt.hdr.entId.ent = ENTMAC;
817 rgMngmt.hdr.entId.inst = (Inst)0;
818 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
819 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
820 rgMngmt.hdr.response.mem.pool = MAC_POOL;
823 pst.selector = ODU_SELECTOR_LC;
824 pst.srcEnt = ENTDUAPP;
826 pst.dstInst = macCfgInst;
827 pst.dstProcId = DU_PROC;
828 pst.srcProcId = DU_PROC;
829 pst.region = duCb.init.region;
831 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
833 /* Send the request to MAC */
834 cmPkLrgCfgReq(&pst, &rgMngmt);
839 /**************************************************************************
840 * @brief Function to handle Config Confirm from MAC
844 * Function : duHdlMacCfgComplete
847 * Handles Gen Config Confirm from MAC
849 * @param[in] Pst *pst, Post structure of the primitive.
850 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
851 * @return ROK - success
854 ***************************************************************************/
855 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
859 if (cfm->cfm.status == LCM_PRIM_OK)
861 switch (cfm->hdr.elmId.elmnt)
865 macCfg |= MAC_GEN_CFG;
870 macCfg |= MAC_SAP_CFG;
877 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
878 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
881 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
883 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
889 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
895 /**************************************************************************
896 * @brief Function to bind/unbind RLC to MAC SAP
900 * Function : duBindUnbindRlcToMacSap
903 * Initiates Bind/Unbind from RLC to MAC
905 * @param[in] Inst Specifies if RLC UL or RLC DL instance
906 * @param[in] action Specifies if action is bind or unbind
907 * @return ROK - success
910 ***************************************************************************/
911 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
913 RlcCntrl *cntrl = NULLP;
918 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
919 DU_SET_ZERO(&pst, sizeof(Pst));
923 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
927 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
929 cntrl = &(rlcMngmt.t.cntrl);
931 cntrl->action = action;
932 cntrl->subAction = DU_ZERO_VAL;
933 cntrl->s.sapCntrl.suId = macCfgInst;
934 cntrl->s.sapCntrl.spId = inst;
937 rlcMngmt.hdr.msgType = TCNTRL;
938 rlcMngmt.hdr.entId.ent = ENTRLC;
939 rlcMngmt.hdr.entId.inst = inst;
940 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
941 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
942 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
943 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
946 pst.selector = ODU_SELECTOR_LC;
947 pst.srcEnt = ENTDUAPP;
949 pst.dstProcId = DU_PROC;
951 pst.srcProcId = DU_PROC;
952 pst.region = duCb.init.region;
954 cmPkLkwCntrlReq(&pst, &rlcMngmt);
958 /*******************************************************************
960 * @brief Handles SCTP notifications
964 * Function : duSctpNtfyHdl
967 * Handles SCTP notification
969 * @params[in] Message Buffer
972 * @return ROK - success
975 * ****************************************************************/
977 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
979 if(f1Params.assocId == ntfy->u.assocChange.assocId)
981 if(BuildAndSendF1SetupReq() != ROK)
986 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
992 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
998 /*******************************************************************
1000 * @brief Fills Pst struct for ENTEGTP
1004 * Function : duFillEgtpPst
1007 * Fills Pst struct for ENTEGTP
1010 * @return ROK - success
1013 * ****************************************************************/
1014 uint8_t duFillEgtpPst(Pst *pst, Event event)
1016 memset(pst, 0, sizeof(Pst));
1017 pst->srcEnt = (Ent)ENTDUAPP;
1018 pst->srcInst = (Inst)DU_INST;
1019 pst->srcProcId = DU_PROC;
1020 pst->dstEnt = (Ent)ENTEGTP;
1021 pst->dstInst = (Inst)EGTP_INST;
1022 pst->dstProcId = pst->srcProcId;
1024 pst->selector = ODU_SELECTOR_LC;
1031 /*******************************************************************
1033 * @brief Function to configure EGTP
1037 * Function : duBuildEgtpCfgReq
1040 * Function to configure EGTP
1043 * @return ROK - success
1046 * ****************************************************************/
1048 uint8_t duBuildEgtpCfgReq()
1053 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1055 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1056 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1058 duFillEgtpPst(&pst, EVTCFGREQ);
1059 packEgtpCfgReq(&pst, egtpCfg);
1064 /*******************************************************************
1066 * @brief Function to configure EGTP
1070 * Function : duBuildEgtpCfgReq
1073 * Function to configure EGTP
1076 * @return ROK - success
1079 * ****************************************************************/
1080 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1084 if(cfm.status == LCM_PRIM_OK)
1086 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1087 duSendEgtpSrvOpenReq();
1091 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1098 /*******************************************************************
1100 * @brief Sends server open request to EGTP
1104 * Function : duSendEgtpSrvOpenReq
1107 * Sends server open request to EGTP
1110 * @return ROK - success
1113 * ****************************************************************/
1115 uint8_t duSendEgtpSrvOpenReq()
1119 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1121 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1122 packEgtpSrvOpenReq(&pst);
1127 /*******************************************************************
1129 * @brief Handles server open confirmation
1133 * Function : duHdlEgtpSrvOpenComplete
1136 * Handles server open confirmation
1139 * @return ROK - success
1142 *****************************************************************/
1144 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1148 if(cfm.status == LCM_PRIM_OK)
1150 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1154 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1161 /*******************************************************************
1163 * @brief Sends tunnel management request
1167 * Function : duSendEgtpTnlMgmtReq
1170 * Builds and sends tunnel management request to EGTP
1172 * @params[in] Action
1173 * Local tunnel endpoint id
1174 * Remote tunnel endpoint id
1175 * @return ROK - success
1178 * ****************************************************************/
1180 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1186 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1188 /* ADD/MOD/DEL per tunnel */
1189 tnlEvt.action = action;
1190 tnlEvt.remTeid = ueCbTnlCfg->teId;
1191 if(action != EGTP_TNL_MGMT_ADD)
1193 tnlEvt.lclTeid = teIdTobeMod;
1197 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1199 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1200 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1204 /*******************************************************************
1206 * @brief Handles Tunnel management confirm
1210 * Function : duHdlEgtpTnlMgmtCfm
1213 * Handles tunnel management confirm received from Egtp
1215 * @params[in] Tunnel Event
1216 * @return ROK - success
1219 * ****************************************************************/
1220 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1224 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1226 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1230 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1237 /*******************************************************************
1239 * @brief Sends UL user data over to EGTP
1243 * Function : duSendEgtpDatInd
1245 * Functionality: Sends UL user data over to EGTP
1247 * @params[in] UL data buffer
1248 * @return ROK - success
1251 * ****************************************************************/
1252 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1256 /* Fill EGTP header */
1257 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1258 egtpMsg.msgHdr.nPdu.pres = FALSE;
1259 egtpMsg.msgHdr.seqNum.pres = FALSE;
1260 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1261 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1262 egtpMsg.msgHdr.teId = 1;
1265 egtpHdlDatInd(egtpMsg);
1271 /**************************************************************************
1272 * @brief Function to send configs to SCH
1276 * Function : duSendSchCfg
1279 * Sends general config to Scheduler via MAC layer
1282 * @return ROK - success
1285 ***************************************************************************/
1286 uint8_t duSendSchCfg()
1289 RgSchInstCfg *cfg = NULLP;
1292 DU_SET_ZERO(&pst, sizeof(Pst));
1293 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1295 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1297 /* Filling of Instance Id */
1298 cfg->instId = DEFAULT_CELLS + 1;
1299 /* Filling of Gen config */
1300 cfg->genCfg.mem.region = MAC_MEM_REGION;
1301 cfg->genCfg.mem.pool = MAC_POOL;
1302 cfg->genCfg.tmrRes = 10;
1305 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1306 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1308 cfg->genCfg.startCellId = 1;
1309 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1310 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1311 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1312 cfg->genCfg.lmPst.dstInst = DU_INST;
1313 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1314 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1315 cfg->genCfg.lmPst.prior = PRIOR0;
1316 cfg->genCfg.lmPst.route = RTESPEC;
1317 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1318 cfg->genCfg.lmPst.pool = MAC_POOL;
1319 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1322 rgMngmt.hdr.msgType = TCFG;
1323 rgMngmt.hdr.entId.ent = ENTMAC;
1324 rgMngmt.hdr.entId.inst = DU_INST;
1325 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1326 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1327 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1330 pst.selector = ODU_SELECTOR_LC;
1331 pst.srcEnt = ENTDUAPP;
1332 pst.dstEnt = ENTMAC;
1333 pst.dstProcId = DU_PROC;
1334 pst.srcProcId = DU_PROC;
1335 pst.srcInst = DU_INST;
1337 pst.region = duCb.init.region;
1338 pst.event = (Event) EVTMACSCHGENCFGREQ;
1340 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1342 /* Send the request to MAC */
1343 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1349 /**************************************************************************
1350 * @brief Function to configure SCTP params and
1351 * responsible for F1 and E2 interfaces
1355 * Function : duLayerConfigComplete
1358 * Configures SCTP Params and responsible for handling
1359 * F1 and E2 interface.
1362 * @return ROK - success
1365 ***************************************************************************/
1366 uint8_t duLayerConfigComplete()
1370 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1372 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1374 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1377 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1379 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1382 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1384 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1391 /**************************************************************************
1392 * @brief Function to handle SCH Config Confirm from MAC
1396 * Function : duHdlSchCfgComplete
1399 * Handles Scheduler Gen Config Confirm from MAC
1401 * @param[in] Pst *pst, Post structure of the primitive.
1402 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1403 * @return ROK - success
1406 ***************************************************************************/
1407 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1409 if (cfm->cfm.status == LCM_PRIM_OK)
1411 switch (cfm->hdr.elmId.elmnt)
1415 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1422 duLayerConfigComplete();
1423 duBuildEgtpCfgReq();
1427 /**************************************************************************
1428 * @brief Function to fill and send MacCellconfig
1432 * Function : duBuildAndSendMacCellCfg
1435 * Initiates MAC Configs towards MAC
1438 * @return ROK - success
1441 ***************************************************************************/
1442 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1445 MacCellCfg *duMacCellCfg = NULLP;
1447 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1448 if(duMacCellCfg == NULLP)
1453 /* store the address in the duCellCb so that we can free on confirm msg */
1454 if(duCb.actvCellLst[cellId-1])
1455 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1458 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duMacCellCfg, sizeof(MacCellCfg));
1462 /* copy the mac config structure from duCfgParams */
1463 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1466 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1468 /* Send MAC cell config to MAC */
1469 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1472 /**************************************************************************
1473 * @brief Function to Handle MAC cell config confirm
1477 * Function : duHandleMacCellCfgCfm
1480 * Initiates general Configs towards MAC
1483 * @return ROK - success
1486 ***************************************************************************/
1487 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1489 uint8_t actvCellIdx = 0;
1492 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1494 if((duCb.actvCellLst[actvCellIdx]) && (macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId))
1496 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1499 if(macCellCfgCfm->rsp == ROK)
1501 /* Build and send GNB-DU config update */
1502 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1504 /* Build and Send Cell Start Req to MAC */
1505 ret = duBuildAndSendMacCellStart();
1509 /* TODO : Action to be taken if cell configuration fails.
1510 * Should CU be informed? */
1512 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1518 /*******************************************************************
1520 * @brief Builds and sends cell start request to MAC
1524 * Function : duBuildAndSendMacCellStart
1527 * Builds and sends cell start request to MAC
1530 * @return ROK - success
1533 * ****************************************************************/
1534 uint8_t duBuildAndSendMacCellStart()
1537 CellStartInfo *cellStart = NULL;
1539 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1541 /* Send Cell Start Request to MAC */
1542 DU_ALLOC_SHRABL_BUF(cellStart, sizeof(CellStartInfo));
1545 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1549 for(uint8_t id = 0; id < MAX_NUM_CELL; id++)
1551 if(duCb.actvCellLst[id])
1553 cellStart->cellId = duCb.actvCellLst[id]->cellId;
1556 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1558 return (*packMacCellStartOpts[pst.selector])(&pst, cellStart);
1564 /*******************************************************************
1566 * @brief Builds and sends cell stop request to MAC
1570 * Function : duBuildAndSendMacCellStop
1573 * Builds and sends cell stop request to MAC
1576 * @return ROK - success
1579 * ****************************************************************/
1580 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1584 CellStopInfo *cellStop = NULL;
1586 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1588 GET_CELL_IDX(cellId, cellIdx);
1589 if(duCb.actvCellLst[cellIdx] != NULLP)
1591 /* Send Cell Stop Request to MAC */
1592 DU_ALLOC_SHRABL_BUF(cellStop, sizeof(CellStopInfo));
1595 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell stop request");
1598 memset(cellStop, 0, sizeof(CellStopInfo));
1599 cellStop->cellId = duCb.actvCellLst[cellIdx]->cellId;
1602 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1604 return (*packMacCellStopOpts[pst.selector])(&pst, cellStop);
1608 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1614 /*******************************************************************
1616 * @brief Handles stop indication from MAC
1620 * Function : duHandleStopInd
1623 * Handles stop indication from MAC
1625 * @params[in] Post structure pointer
1626 * @return ROK - success
1629 * ****************************************************************/
1630 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1632 DuCellCb *cellCb = NULLP;
1634 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1636 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1639 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1642 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1644 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1645 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1647 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1648 cellId[%d]", cellId->cellId);
1654 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1655 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1656 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1660 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1661 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1663 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1669 /*******************************************************************
1671 * @brief Handles slot indication from MAC
1675 * Function : duHandleUlCcchInd
1678 * Handles UL CCCH indication from MAC
1680 * @params[in] Post structure pointer
1681 * UL CCCH Ind pointer
1682 * @return ROK - success
1685 * ****************************************************************/
1686 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1689 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1691 return (duProcUlCcchInd(ulCcchIndInfo));
1694 /*******************************************************************
1696 * @brief Process UL RRC Message from RLC
1700 * Function : DuProcRlcUlRrcMsgTrans
1702 * Functionality: Process UL RRC Message from RLC
1704 * @params[in] Post structure
1705 * UL RRC Message Info
1706 * @return ROK - success
1709 * ****************************************************************/
1710 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1713 DuCellCb *cellCb = NULLP;
1714 DuUeCb *ueCb = NULLP;
1716 duGetCellCb(ulRrcMsgInfo->cellId, &cellCb);
1719 if(ulRrcMsgInfo->ueId > 0)
1721 if(cellCb->ueCb[ulRrcMsgInfo->ueId -1].gnbDuUeF1apId == ulRrcMsgInfo->ueId)
1722 ueCb = &cellCb->ueCb[ulRrcMsgInfo->ueId -1];
1726 /* If UL message is received for a UE in handover, it signifies that UE is now
1727 * attached to GNB. Hence marking this UE as active and requesting MAC to
1728 * release the dedicated RACH resources */
1729 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
1731 ueCb->ueState = UE_ACTIVE;
1732 cellCb->numActvUes++;
1734 /* Release RACH resources */
1735 memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource));
1736 if(duBuildAndSendRachRsrcRelToMac(ulRrcMsgInfo->cellId, ueCb) != ROK)
1738 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to send RACH resource release to MAC");
1742 if(BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg) != ROK)
1744 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to build and send UL RRC Message Transfer");
1750 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : UE ID [%d] not found", ulRrcMsgInfo->ueId);
1756 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Invalid UE ID [%d]", ulRrcMsgInfo->ueId);
1762 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Cell ID [%d] not found", ulRrcMsgInfo->cellId);
1766 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1767 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1771 /*******************************************************************
1773 * @brief Process RRC delivery report from RLC
1777 * Function : DuProcRlcRrcDeliveryReport
1779 * Functionality: Process RRC delivery Message from RLC
1781 * @params[in] Post structure
1782 * UL RRC Message Info
1783 * @return ROK - success
1786 * ****************************************************************/
1787 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1789 DuCellCb *cellCb = NULLP;
1791 uint8_t ret = RFAILED;
1793 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1796 ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1];
1797 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1799 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1803 /*******************************************************************
1805 * @brief Process UL user data from RLC
1809 * Function : DuProcRlcUlUserDataTrans
1811 * Functionality: Process UL user data from RLC
1813 * @params[in] Post structure
1815 * @return ROK - success
1818 * ****************************************************************/
1819 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1825 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1827 /* Fill EGTP header */
1828 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1829 egtpMsg.msgHdr.nPdu.pres = FALSE;
1830 egtpMsg.msgHdr.seqNum.pres = FALSE;
1831 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1832 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1834 /* Fetch EGTP tunnel info */
1835 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
1837 /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
1838 if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \
1839 (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
1841 if(duCb.upTnlCfg[teIdx]->tnlCfg1)
1843 egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1849 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1851 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1852 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1853 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1856 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1857 ODU_PRINT_MSG(mBuf, 0, 0);
1859 egtpHdlDatInd(egtpMsg);
1861 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1862 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1866 /*******************************************************************
1868 * @brief process the slice cfg rsp received from MAC
1872 * Function : DuProcMacSliceCfgRsp
1874 * Functionality: process the slice cfg rsp received from MAC
1876 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1878 * @return ROK - success
1881 **********************************************************************/
1882 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1886 if(cfgRsp->rsp == MAC_DU_APP_RSP_OK)
1888 duCb.sliceState = SLICE_CONFIGURED;
1889 DU_LOG("\nINFO --> DU_APP : Slice configured successfully ");
1893 DU_LOG("\nERROR --> DU_APP : Slice not available");
1895 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1900 /*******************************************************************
1902 * @brief Fill the slice configration and rrm policy related
1903 * information received form O1
1907 * Function : BuildAndSendSliceConfigReq
1909 * Functionality: Fill the slice configration and rrm policy related
1911 * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t
1914 * @return ROK - success
1917 * ****************************************************************/
1918 uint8_t BuildAndSendSliceConfigReq()
1921 MacSliceCfgReq *sliceCfgReq;
1923 DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq));
1924 if(sliceCfgReq == NULLP)
1926 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq");
1931 memcpy(sliceCfgReq, &duCfgParam.tempSliceCfg, sizeof(MacSliceCfgReq));
1932 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ);
1934 DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC ");
1935 if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED)
1937 DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC");
1938 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq));
1944 /*******************************************************************
1946 * @brief Fill the slice configration and rrm policy related
1947 * information received form O1
1951 * Function : BuildAndSendSliceRecfgReq
1953 * Functionality: Fill the slice configration and rrm policy related
1955 * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount
1957 * @return ROK - success
1960 * ****************************************************************/
1961 uint8_t BuildAndSendSliceRecfgReq()
1964 MacSliceRecfgReq *sliceRecfgReq = NULLP;
1966 DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received");
1968 DU_ALLOC_SHRABL_BUF(sliceRecfgReq, sizeof(MacSliceRecfgReq));
1969 if(sliceRecfgReq == NULLP)
1971 DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceRecfgReq");
1976 memcpy(sliceRecfgReq, &duCfgParam.tempSliceCfg, sizeof(MacSliceRecfgReq));
1978 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ);
1980 DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC ");
1981 if( (*packMacSliceRecfgReqOpts[pst.selector])(&pst, sliceRecfgReq) == RFAILED)
1983 DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC");
1984 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceRecfgReq, sizeof(MacSliceRecfgReq));
1989 /*******************************************************************
1991 * @brief process the slice ReCfg rsp received from MAC
1995 * Function : DuProcMacSliceRecfgRsp
1997 * Functionality: process the slice ReCfg rsp received from MAC
1999 * @params[in] Post structure, MacSliceRecfgRsp *ReCfgRsp
2001 * @return ROK - success
2004 **********************************************************************/
2005 uint8_t DuProcMacSliceRecfgRsp(Pst *pst, MacSliceRecfgRsp *recfgRsp)
2009 if(recfgRsp->rsp == MAC_DU_APP_RSP_OK)
2011 duCb.sliceState = SLICE_RECONFIGURED;
2012 DU_LOG("\nINFO --> DU_APP : Slice Reconfigured successfully ");
2016 DU_LOG("\nERROR --> DU_APP : Slice not available");
2018 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, recfgRsp, sizeof(MacSliceCfgRsp));
2023 /*******************************************************************
2025 * @brief Handles received Slice Metrics from RLC and forward it to O1
2029 * Function : DuProcRlcSliceMetrics
2032 * Handles received Slice Metrics from RLC and forward it to O1
2034 * @params[in] Post structure pointer
2035 * SlicePmList *sliceStats
2037 * @return ROK - success
2040 * ****************************************************************/
2041 uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
2043 uint8_t sliceRecord = 0;
2045 DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics");
2046 if(sliceStats == NULLP)
2048 DU_LOG("\nERROR --> DU APP : Empty Metrics");
2052 for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
2054 DU_LOG("\nINFO --> DU_APP: SliceId[SST-SD]:%d-%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sst,\
2055 sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sd,sliceStats->sliceRecord[sliceRecord].ThpDl,\
2056 sliceStats->sliceRecord[sliceRecord].ThpUl);
2061 sendSliceMetric((SliceMetricList*) sliceStats);
2065 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2066 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2071 /**********************************************************************
2073 **********************************************************************/