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"
28 #include "du_app_mac_inf.h"
29 #include "du_app_rlc_inf.h"
31 #include "du_app_rlc_inf.h"
35 #include "du_f1ap_msg_hdl.h"
36 #include "du_ue_mgr.h"
40 #include "du_cell_mgr.h"
44 #include "AlarmInterface.h"
45 #include "CmInterface.h"
46 #include "PmInterface.h"
51 uint8_t numRlcDlSaps = 0;
53 uint8_t numRlcMacSaps = 0;
55 uint8_t macCfgInst = 0;
57 DuCfgParams duCfgParam;
58 uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg);
59 uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg);
60 uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
61 uint8_t BuildAndSendE2SetupReq();
62 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg);
63 uint8_t BuildAndSendDUConfigUpdate();
64 uint16_t getTransId();
65 uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
66 uint8_t sendCellDeleteReqToMac(uint16_t cellId);
68 packMacCellCfgReq packMacCellCfgOpts[] =
70 packMacCellCfg, /* packing for loosely coupled */
71 MacProcCellCfgReq, /* packing for tightly coupled */
72 packMacCellCfg, /* packing for light weight loosly coupled */
75 DuMacCellStart packMacCellStartOpts[] =
77 packMacCellStart, /* Loose coupling */
78 MacProcCellStart, /* TIght coupling */
79 packMacCellStart /* Light weight-loose coupling */
82 DuMacCellStop packMacCellStopOpts[] =
84 packMacCellStop, /* Loose coupling */
85 MacProcCellStop, /* TIght coupling */
86 packMacCellStop /* Light weight-loose coupling */
89 DuMacSliceCfgReq packMacSliceCfgReqOpts[] =
91 packDuMacSliceCfgReq, /* Loose coupling */
92 MacProcSliceCfgReq, /* TIght coupling */
93 packDuMacSliceCfgReq /* Light weight-loose coupling */
97 DuMacSliceRecfgReq packMacSliceReCfgReqOpts[] =
99 packDuMacSliceRecfgReq, /* Loose coupling */
100 MacProcSliceReCfgReq, /* TIght coupling */
101 packDuMacSliceRecfgReq /* Light weight-loose coupling */
103 /**************************************************************************
104 * @brief Function to fill configs required by RLC
108 * Function : duBuildRlcCfg
111 * Initiates general Configs towards RLC
113 * @param[in] Inst Specifies if RLC UL or RLC DL instance
114 * @return ROK - success
117 ***************************************************************************/
118 uint8_t duBuildRlcCfg(Inst inst)
121 RlcGenCfg *genCfg = NULLP;
124 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
125 DU_SET_ZERO(&pst, sizeof(Pst));
127 genCfg = &(rlcMngmt.t.cfg.s.gen);
129 /*----------- Fill General Configuration Parameters ---------*/
130 genCfg->maxUe = duCfgParam.maxUe;
131 genCfg->maxKwuSaps = 2;
132 genCfg->maxUdxSaps = 1;
133 genCfg->rlcMode = (inst == RLC_UL_INST) ?
134 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
136 genCfg->maxRguSaps = DEFAULT_CELLS;
138 /*----------- Fill lmPst
139 * Parameters ---------*/
140 genCfg->lmPst.dstProcId = DU_PROC;
141 genCfg->lmPst.srcProcId = DU_PROC;
142 genCfg->lmPst.dstEnt = ENTDUAPP;
143 genCfg->lmPst.dstInst = DU_INST;
144 genCfg->lmPst.srcEnt = ENTRLC;
145 genCfg->lmPst.srcInst = inst;
146 genCfg->lmPst.prior = PRIOR0;
147 genCfg->lmPst.route = RTESPEC;
148 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
149 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
150 genCfg->lmPst.pool = RLC_POOL;
151 genCfg->lmPst.selector = ODU_SELECTOR_LC;
154 rlcMngmt.hdr.msgType = TCFG;
155 rlcMngmt.hdr.msgLen = 0;
156 rlcMngmt.hdr.entId.ent = ENTRLC;
157 rlcMngmt.hdr.entId.inst = (Inst)0;
158 rlcMngmt.hdr.elmId.elmnt = STGEN;
159 rlcMngmt.hdr.seqNmb = 0;
160 rlcMngmt.hdr.version = 0;
161 rlcMngmt.hdr.transId = 0;
162 rlcMngmt.hdr.response.prior = PRIOR0;
163 rlcMngmt.hdr.response.route = RTESPEC;
164 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
165 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
166 rlcMngmt.hdr.response.mem.pool = DU_POOL;
167 rlcMngmt.hdr.response.selector = ODU_SELECTOR_LC;
170 pst.selector = ODU_SELECTOR_LC;
171 pst.srcEnt = ENTDUAPP;
174 pst.dstProcId = DU_PROC;
175 pst.srcProcId = DU_PROC;
176 pst.region = duCb.init.region;
178 DU_LOG("\nDEBUG --> DU_APP : RLC Gen Cfg Req sent for inst %d", inst);
180 /* Send the request to RLC */
181 packRlcConfigReq(&pst, &rlcMngmt);
186 /**************************************************************************
187 * @brief Function to fill configs required by RLC
191 * Function : duBuildRlcLsapCfg
194 * Initiates general Configs towards RLC
196 * @param[in] Inst Specifies if RLC UL or RLC DL instance
197 * @return ROK - success
200 ***************************************************************************/
201 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst)
205 RlcSapCfg *lSap = NULLP;
208 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
209 DU_SET_ZERO(&pst, sizeof(Pst));
212 rlcMngmt.hdr.msgType = TCFG;
213 rlcMngmt.hdr.entId.ent = ENTRLC;
214 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
215 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
217 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
220 pst.selector = ODU_SELECTOR_LC;
221 pst.srcEnt = ENTDUAPP;
223 pst.dstProcId = DU_PROC;
225 pst.srcProcId = DU_PROC;
226 pst.region = duCb.init.region;
227 lSap = &(rlcMngmt.t.cfg.s.sap);
229 lSap->mem.region = (inst == RLC_UL_INST) ?
230 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
231 lSap->mem.pool = RLC_POOL;
233 lSap->bndTmrIntvl = 10;
234 lSap->priority = PRIOR0;
235 lSap->route = RTESPEC;
238 lSap->procId = DU_PROC;
240 lSap->inst = lsapInst;
241 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
242 lSap->selector = (inst == RLC_UL_INST) ? ODU_SELECTOR_LWLC : ODU_SELECTOR_TC;
243 rlcMngmt.hdr.elmId.elmnt = STRGUSAP;
244 DU_LOG("\nDEBUG --> DU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
249 lSap->procId = DU_PROC;
251 lSap->inst = (inst == RLC_UL_INST) ?
252 RLC_DL_INST : RLC_UL_INST;
254 lSap->selector = ODU_SELECTOR_LC;
255 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
256 DU_LOG("\nDEBUG --> DU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
259 packRlcConfigReq(&pst, &rlcMngmt);
263 /**************************************************************************
264 * @brief Function to fill configs required by RLC
268 * Function : duBuildRlcUsapCfg
271 * Initiates general Configs towards RLC
273 * @param[in] Inst Specifies if RLC UL or RLC DL instance
274 * @return ROK - success
277 ***************************************************************************/
278 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
281 RlcSapCfg *uSap = NULLP;
284 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
285 DU_SET_ZERO(&pst, sizeof(Pst));
287 uSap = &(rlcMngmt.t.cfg.s.sap);
289 uSap->selector = ODU_SELECTOR_LC;
290 uSap->mem.region = (inst == RLC_UL_INST) ?
291 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
292 uSap->mem.pool = RLC_POOL;
295 uSap->procId = DU_PROC;
299 uSap->inst = (inst == RLC_UL_INST) ?
300 RLC_DL_INST : RLC_UL_INST;
301 uSap->bndTmrIntvl = 1000;
302 uSap->priority = PRIOR0;
303 uSap->route = RTESPEC;
306 rlcMngmt.hdr.msgType = TCFG;
307 rlcMngmt.hdr.entId.ent = ENTRLC;
308 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
309 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
310 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
312 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
315 pst.selector = ODU_SELECTOR_LC;
316 pst.srcEnt = ENTDUAPP;
318 pst.dstProcId = DU_PROC;
320 pst.srcProcId = DU_PROC;
321 pst.region = duCb.init.region;
323 DU_LOG("\nDEBUG --> DU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
324 packRlcConfigReq(&pst, &rlcMngmt);
329 /**************************************************************************
330 * @brief Function to populate internal DS of DU APP
334 * Function : duProcCfgComplete
337 * Populates internal data structures of DU APP after
338 * receiving configurations.
341 * @return ROK - success
344 ***************************************************************************/
345 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 = ++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 cell->gnbDuUeF1apIdGenerator = 0;
388 duCb.cfgCellLst[duCb.numCfgCells] = cell;
394 //Start layer configs
395 ret = duSendRlcUlCfg();
399 /**************************************************************************
400 * @brief Function to invoke DU Layer Configs
404 * Function : duSendRlcUlCfg
407 * Initiates Configs towards layers of DU
410 * @return ROK - success
413 ***************************************************************************/
414 uint8_t duSendRlcUlCfg()
418 duBuildRlcCfg((Inst)RLC_UL_INST);
419 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
421 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
423 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
428 /**************************************************************************
429 * @brief Function to invoke DU Layer Configs
433 * Function : duSendRlcDlCfg
436 * Initiates Configs towards layers of DU
439 * @return ROK - success
442 ***************************************************************************/
443 uint8_t duSendRlcDlCfg()
447 duBuildRlcCfg((Inst)RLC_DL_INST);
448 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
449 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
451 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
456 /**************************************************************************
457 * @brief Function to handle Config Confirm from RLC
461 * Function : DuHdlRlcCfgComplete
464 * Handles Gen Config Confirm from RLC
466 * @param[in] Pst *pst, Post structure of the primitive.
467 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
468 * @return ROK - success
471 ***************************************************************************/
472 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
475 if (pst->srcInst == RLC_UL_INST)
477 ret = duProcRlcUlCfgComplete(pst, cfm);
481 ret = duProcRlcDlCfgComplete(pst, cfm);
486 /**************************************************************************
487 * @brief Function to handle Control Config Confirm from RLC
491 * Function : duHdlRlcCntrlCfgComplete
494 * Handles Control Config Confirm from RLC
496 * @param[in] Pst *pst, Post structure of the primitive.
497 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
498 * @return ROK - success
501 ***************************************************************************/
502 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
506 if (cntrl->cfm.status == LCM_PRIM_OK)
508 switch (cntrl->hdr.elmId.elmnt)
512 if (pst->srcInst == RLC_DL_INST)
514 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
516 if(macCfgInst < DEFAULT_CELLS)
519 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
523 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
528 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
530 if(macCfgInst < DEFAULT_CELLS)
532 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
546 /**************************************************************************
547 * @brief Function to handle Config Confirm from RLC UL
551 * Function : duHdlRlcUlCfgComplete
554 * Handles Config Confirm from RLC UL
556 * @param[in] Pst *pst, Post structure of the primitive.
557 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
558 * @return ROK - success
561 ***************************************************************************/
562 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
566 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
567 if (cfm->cfm.status == LCM_PRIM_OK)
569 switch(cfm->hdr.elmId.elmnt)
573 rlcUlCfg |= RLC_GEN_CFG;
579 if(numRlcMacSaps == DEFAULT_CELLS)
581 rlcUlCfg |= RLC_MAC_SAP_CFG;
588 rlcUlCfg |= RLC_UDX_SAP_CFG;
595 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
596 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
600 //Start configuration of RLC DL
607 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
613 /**************************************************************************
614 * @brief Function to handle Config Confirm from RLC DL
618 * Function : duHdlRlcDlCfgComplete
621 * Handles Config Confirm from RLC DL
623 * @param[in] Pst *pst, Post structure of the primitive.
624 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
625 * @return ROK - success
628 ***************************************************************************/
629 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
631 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
632 if (cfm->cfm.status == LCM_PRIM_OK)
634 switch(cfm->hdr.elmId.elmnt)
638 rlcDlCfg |= RLC_GEN_CFG;
644 if(numRlcMacSaps == DEFAULT_CELLS)
646 rlcDlCfg |= RLC_MAC_SAP_CFG;
653 rlcDlCfg |= RLC_UDX_SAP_CFG;
661 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
662 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
665 //Start configuration of MAC
672 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
677 /**************************************************************************
678 * @brief Function to send configs to MAC
682 * Function : duSendMacCfg
685 * Initiates Configs towards MAC layer
688 * @return ROK - success
691 ***************************************************************************/
692 uint8_t duSendMacCfg()
695 duBuildMacUsapCfg(RLC_UL_INST);
696 duBuildMacUsapCfg(RLC_DL_INST);
701 /**************************************************************************
702 * @brief Function to fill gen config required by MAC
706 * Function : duBuildMacGenCfg
709 * Initiates general Configs towards MAC
712 * @return ROK - success
715 ***************************************************************************/
716 uint8_t duBuildMacGenCfg()
719 RgGenCfg *genCfg=NULLP;
722 DU_SET_ZERO(&pst, sizeof(Pst));
723 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
725 genCfg = &(rgMngmt.t.cfg.s.genCfg);
727 /*----------- Fill General Configuration Parameters ---------*/
728 genCfg->mem.region = MAC_MEM_REGION;
729 genCfg->mem.pool = MAC_POOL;
731 genCfg->numRguSaps = 2;
733 genCfg->lmPst.dstProcId = DU_PROC;
734 genCfg->lmPst.srcProcId = DU_PROC;
735 genCfg->lmPst.dstEnt = ENTDUAPP;
736 genCfg->lmPst.dstInst = 0;
737 genCfg->lmPst.srcEnt = ENTMAC;
738 genCfg->lmPst.srcInst = macCfgInst;
739 genCfg->lmPst.prior = PRIOR0;
740 genCfg->lmPst.route = RTESPEC;
741 genCfg->lmPst.region = MAC_MEM_REGION;
742 genCfg->lmPst.pool = MAC_POOL;
743 genCfg->lmPst.selector = ODU_SELECTOR_LC;
746 rgMngmt.hdr.msgType = TCFG;
747 rgMngmt.hdr.msgLen = 0;
748 rgMngmt.hdr.entId.ent = ENTMAC;
749 rgMngmt.hdr.entId.inst = (Inst)0;
750 rgMngmt.hdr.elmId.elmnt = STGEN;
751 rgMngmt.hdr.seqNmb = 0;
752 rgMngmt.hdr.version = 0;
753 rgMngmt.hdr.transId = 0;
755 rgMngmt.hdr.response.prior = PRIOR0;
756 rgMngmt.hdr.response.route = RTESPEC;
757 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
758 rgMngmt.hdr.response.mem.pool = MAC_POOL;
759 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
762 pst.selector = ODU_SELECTOR_LC;
763 pst.srcEnt = ENTDUAPP;
765 pst.dstInst = macCfgInst;
766 pst.dstProcId = DU_PROC;
767 pst.srcProcId = DU_PROC;
768 pst.region = duCb.init.region;
770 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
772 /* Send the request to MAC */
773 cmPkLrgCfgReq(&pst, &rgMngmt);
778 /**************************************************************************
779 * @brief Function to fill USAP config required by MAC
783 * Function : duBuildMacUsapCfg
786 * Initiates USAP Configs towards MAC
788 * @param[in] SpId Specifies if RLC UL or RLC DL instance
789 * @return ROK - success
792 ***************************************************************************/
793 uint8_t duBuildMacUsapCfg(SpId sapId)
796 RgUpSapCfg *uSap = NULLP;
799 DU_SET_ZERO(&pst, sizeof(Pst));
800 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
802 uSap = &(rgMngmt.t.cfg.s.rguSap);
804 uSap->mem.region = MAC_MEM_REGION;
805 uSap->mem.pool = MAC_POOL;
808 uSap->procId = DU_PROC;
811 uSap->prior = PRIOR0;
812 uSap->route = RTESPEC;
813 uSap->selector = ODU_SELECTOR_LC ;
816 rgMngmt.hdr.msgType = TCFG;
817 rgMngmt.hdr.entId.ent = ENTMAC;
818 rgMngmt.hdr.entId.inst = (Inst)0;
819 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
820 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
821 rgMngmt.hdr.response.mem.pool = MAC_POOL;
824 pst.selector = ODU_SELECTOR_LC;
825 pst.srcEnt = ENTDUAPP;
827 pst.dstInst = macCfgInst;
828 pst.dstProcId = DU_PROC;
829 pst.srcProcId = DU_PROC;
830 pst.region = duCb.init.region;
832 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
834 /* Send the request to MAC */
835 cmPkLrgCfgReq(&pst, &rgMngmt);
840 /**************************************************************************
841 * @brief Function to handle Config Confirm from MAC
845 * Function : duHdlMacCfgComplete
848 * Handles Gen Config Confirm from MAC
850 * @param[in] Pst *pst, Post structure of the primitive.
851 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
852 * @return ROK - success
855 ***************************************************************************/
856 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
860 if (cfm->cfm.status == LCM_PRIM_OK)
862 switch (cfm->hdr.elmId.elmnt)
866 macCfg |= MAC_GEN_CFG;
871 macCfg |= MAC_SAP_CFG;
878 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
879 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
882 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
884 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
890 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
896 /**************************************************************************
897 * @brief Function to bind/unbind RLC to MAC SAP
901 * Function : duBindUnbindRlcToMacSap
904 * Initiates Bind/Unbind from RLC to MAC
906 * @param[in] Inst Specifies if RLC UL or RLC DL instance
907 * @param[in] action Specifies if action is bind or unbind
908 * @return ROK - success
911 ***************************************************************************/
912 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
914 RlcCntrl *cntrl = NULLP;
919 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
920 DU_SET_ZERO(&pst, sizeof(Pst));
924 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
928 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
930 cntrl = &(rlcMngmt.t.cntrl);
932 cntrl->action = action;
933 cntrl->subAction = DU_ZERO_VAL;
934 cntrl->s.sapCntrl.suId = macCfgInst;
935 cntrl->s.sapCntrl.spId = inst;
938 rlcMngmt.hdr.msgType = TCNTRL;
939 rlcMngmt.hdr.entId.ent = ENTRLC;
940 rlcMngmt.hdr.entId.inst = inst;
941 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
942 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
943 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
944 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
947 pst.selector = ODU_SELECTOR_LC;
948 pst.srcEnt = ENTDUAPP;
950 pst.dstProcId = DU_PROC;
952 pst.srcProcId = DU_PROC;
953 pst.region = duCb.init.region;
955 cmPkLkwCntrlReq(&pst, &rlcMngmt);
959 /*******************************************************************
961 * @brief Handles SCTP notifications
965 * Function : duSctpNtfyHdl
968 * Handles SCTP notification
970 * @params[in] Message Buffer
973 * @return ROK - success
976 * ****************************************************************/
978 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
980 if(f1Params.assocId == ntfy->u.assocChange.assocId)
982 if(BuildAndSendF1SetupReq() != ROK)
987 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
989 if(BuildAndSendE2SetupReq() != ROK)
996 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
1002 /*******************************************************************
1004 * @brief Fills Pst struct for ENTEGTP
1008 * Function : duFillEgtpPst
1011 * Fills Pst struct for ENTEGTP
1014 * @return ROK - success
1017 * ****************************************************************/
1018 uint8_t duFillEgtpPst(Pst *pst, Event event)
1020 memset(pst, 0, sizeof(Pst));
1021 pst->srcEnt = (Ent)ENTDUAPP;
1022 pst->srcInst = (Inst)DU_INST;
1023 pst->srcProcId = DU_PROC;
1024 pst->dstEnt = (Ent)ENTEGTP;
1025 pst->dstInst = (Inst)EGTP_INST;
1026 pst->dstProcId = pst->srcProcId;
1028 pst->selector = ODU_SELECTOR_LC;
1035 /*******************************************************************
1037 * @brief Function to configure EGTP
1041 * Function : duBuildEgtpCfgReq
1044 * Function to configure EGTP
1047 * @return ROK - success
1050 * ****************************************************************/
1052 uint8_t duBuildEgtpCfgReq()
1057 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1059 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1060 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1062 duFillEgtpPst(&pst, EVTCFGREQ);
1063 packEgtpCfgReq(&pst, egtpCfg);
1068 /*******************************************************************
1070 * @brief Function to configure EGTP
1074 * Function : duBuildEgtpCfgReq
1077 * Function to configure EGTP
1080 * @return ROK - success
1083 * ****************************************************************/
1084 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1088 if(cfm.status == LCM_PRIM_OK)
1090 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1091 duSendEgtpSrvOpenReq();
1095 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1102 /*******************************************************************
1104 * @brief Sends server open request to EGTP
1108 * Function : duSendEgtpSrvOpenReq
1111 * Sends server open request to EGTP
1114 * @return ROK - success
1117 * ****************************************************************/
1119 uint8_t duSendEgtpSrvOpenReq()
1123 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1125 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1126 packEgtpSrvOpenReq(&pst);
1131 /*******************************************************************
1133 * @brief Handles server open confirmation
1137 * Function : duHdlEgtpSrvOpenComplete
1140 * Handles server open confirmation
1143 * @return ROK - success
1146 *****************************************************************/
1148 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1152 if(cfm.status == LCM_PRIM_OK)
1154 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1158 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1165 /*******************************************************************
1167 * @brief Sends tunnel management request
1171 * Function : duSendEgtpTnlMgmtReq
1174 * Builds and sends tunnel management request to EGTP
1176 * @params[in] Action
1177 * Local tunnel endpoint id
1178 * Remote tunnel endpoint id
1179 * @return ROK - success
1182 * ****************************************************************/
1184 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1190 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1192 /* ADD/MOD/DEL per tunnel */
1193 tnlEvt.action = action;
1194 tnlEvt.remTeid = ueCbTnlCfg->teId;
1195 if(action != EGTP_TNL_MGMT_ADD)
1197 tnlEvt.lclTeid = teIdTobeMod;
1201 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1203 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1204 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1208 /*******************************************************************
1210 * @brief Handles Tunnel management confirm
1214 * Function : duHdlEgtpTnlMgmtCfm
1217 * Handles tunnel management confirm received from Egtp
1219 * @params[in] Tunnel Event
1220 * @return ROK - success
1223 * ****************************************************************/
1224 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1228 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1230 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1234 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1241 /*******************************************************************
1243 * @brief Sends UL user data over to EGTP
1247 * Function : duSendEgtpDatInd
1249 * Functionality: Sends UL user data over to EGTP
1251 * @params[in] UL data buffer
1252 * @return ROK - success
1255 * ****************************************************************/
1256 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1260 /* Fill EGTP header */
1261 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1262 egtpMsg.msgHdr.nPdu.pres = FALSE;
1263 egtpMsg.msgHdr.seqNum.pres = FALSE;
1264 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1265 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1266 egtpMsg.msgHdr.teId = 1;
1269 egtpHdlDatInd(egtpMsg);
1275 /**************************************************************************
1276 * @brief Function to send configs to SCH
1280 * Function : duSendSchCfg
1283 * Sends general config to Scheduler via MAC layer
1286 * @return ROK - success
1289 ***************************************************************************/
1290 uint8_t duSendSchCfg()
1293 RgSchInstCfg *cfg = NULLP;
1296 DU_SET_ZERO(&pst, sizeof(Pst));
1297 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1299 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1301 /* Filling of Instance Id */
1302 cfg->instId = DEFAULT_CELLS + 1;
1303 /* Filling of Gen config */
1304 cfg->genCfg.mem.region = MAC_MEM_REGION;
1305 cfg->genCfg.mem.pool = MAC_POOL;
1306 cfg->genCfg.tmrRes = 10;
1309 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1310 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1312 cfg->genCfg.startCellId = 1;
1313 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1314 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1315 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1316 cfg->genCfg.lmPst.dstInst = DU_INST;
1317 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1318 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1319 cfg->genCfg.lmPst.prior = PRIOR0;
1320 cfg->genCfg.lmPst.route = RTESPEC;
1321 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1322 cfg->genCfg.lmPst.pool = MAC_POOL;
1323 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1326 rgMngmt.hdr.msgType = TCFG;
1327 rgMngmt.hdr.entId.ent = ENTMAC;
1328 rgMngmt.hdr.entId.inst = DU_INST;
1329 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1330 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1331 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1334 pst.selector = ODU_SELECTOR_LC;
1335 pst.srcEnt = ENTDUAPP;
1336 pst.dstEnt = ENTMAC;
1337 pst.dstProcId = DU_PROC;
1338 pst.srcProcId = DU_PROC;
1339 pst.srcInst = DU_INST;
1341 pst.region = duCb.init.region;
1342 pst.event = (Event) EVTMACSCHGENCFGREQ;
1344 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1346 /* Send the request to MAC */
1347 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1353 /**************************************************************************
1354 * @brief Function to configure SCTP params and
1355 * responsible for F1 and E2 interfaces
1359 * Function : duLayerConfigComplete
1362 * Configures SCTP Params and responsible for handling
1363 * F1 and E2 interface.
1366 * @return ROK - success
1369 ***************************************************************************/
1370 uint8_t duLayerConfigComplete()
1374 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1376 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1378 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1381 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1383 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1386 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1388 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1395 /**************************************************************************
1396 * @brief Function to handle SCH Config Confirm from MAC
1400 * Function : duHdlSchCfgComplete
1403 * Handles Scheduler Gen Config Confirm from MAC
1405 * @param[in] Pst *pst, Post structure of the primitive.
1406 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1407 * @return ROK - success
1410 ***************************************************************************/
1411 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1413 if (cfm->cfm.status == LCM_PRIM_OK)
1415 switch (cfm->hdr.elmId.elmnt)
1419 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1426 duLayerConfigComplete();
1427 duBuildEgtpCfgReq();
1431 /**************************************************************************
1432 * @brief Function to fill and send MacCellconfig
1436 * Function : duBuildAndSendMacCellCfg
1439 * Initiates MAC Configs towards MAC
1442 * @return ROK - success
1445 ***************************************************************************/
1446 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1449 MacCellCfg *duMacCellCfg = NULLP;
1451 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1452 if(duMacCellCfg == NULLP)
1457 /* store the address in the duCellCb so that we can free on confirm msg */
1458 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1460 /* copy the mac config structure from duCfgParams */
1461 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1464 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1466 /* Send MAC cell config to MAC */
1467 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1470 /**************************************************************************
1471 * @brief Function to Handle MAC cell config confirm
1475 * Function : duHandleMacCellCfgCfm
1478 * Initiates general Configs towards MAC
1481 * @return ROK - success
1484 ***************************************************************************/
1485 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1487 uint8_t actvCellIdx = 0;
1490 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1492 if(macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId)
1494 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1497 if(macCellCfgCfm->rsp == ROK)
1499 /* Build and send GNB-DU config update */
1500 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1502 /* Build and Send Cell Start Req to MAC */
1503 ret = duBuildAndSendMacCellStart();
1507 /* TODO : Action to be taken if cell configuration fails.
1508 * Should CU be informed? */
1510 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1516 /*******************************************************************
1518 * @brief Builds and sends cell start request to MAC
1522 * Function : duBuildAndSendMacCellStart
1525 * Builds and sends cell start request to MAC
1528 * @return ROK - success
1531 * ****************************************************************/
1532 uint8_t duBuildAndSendMacCellStart()
1535 OduCellId *cellId = NULL;
1537 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1539 /* Send Cell Start Request to MAC */
1540 DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId));
1543 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1547 for(uint8_t id = 0; id < duCb.numActvCells; id++)
1549 if(duCb.actvCellLst[id])
1551 cellId->cellId = duCb.actvCellLst[id]->cellId;
1554 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1556 return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
1562 /*******************************************************************
1564 * @brief Builds and sends cell stop request to MAC
1568 * Function : duBuildAndSendMacCellStop
1571 * Builds and sends cell stop request to MAC
1574 * @return ROK - success
1577 * ****************************************************************/
1578 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1582 OduCellId *oduCellId = NULL;
1584 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1586 GET_CELL_IDX(cellId, cellIdx);
1587 if(duCb.actvCellLst[cellIdx] != NULLP)
1589 /* Send Cell Stop Request to MAC */
1590 DU_ALLOC_SHRABL_BUF(oduCellId, sizeof(OduCellId));
1593 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): Memory allocation failed ");
1596 memset(oduCellId, 0, sizeof(OduCellId));
1597 oduCellId->cellId = duCb.actvCellLst[cellIdx]->cellId;
1600 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1602 return (*packMacCellStopOpts[pst.selector])(&pst, oduCellId);
1606 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1612 /*******************************************************************
1614 * @brief Handles stop indication from MAC
1618 * Function : duHandleStopInd
1621 * Handles stop indication from MAC
1623 * @params[in] Post structure pointer
1624 * @return ROK - success
1627 * ****************************************************************/
1628 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1630 DuCellCb *cellCb = NULLP;
1632 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1634 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1637 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1640 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1642 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1643 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1645 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1646 cellId[%d]", cellId->cellId);
1652 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1653 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1654 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1658 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1659 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1661 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1667 /*******************************************************************
1669 * @brief Handles slot indication from MAC
1673 * Function : duHandleUlCcchInd
1676 * Handles UL CCCH indication from MAC
1678 * @params[in] Post structure pointer
1679 * UL CCCH Ind pointer
1680 * @return ROK - success
1683 * ****************************************************************/
1684 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1687 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1689 return (duProcUlCcchInd(ulCcchIndInfo));
1692 /*******************************************************************
1694 * @brief Process UL RRC Message from RLC
1698 * Function : DuProcRlcUlRrcMsgTrans
1700 * Functionality: Process UL RRC Message from RLC
1702 * @params[in] Post structure
1703 * UL RRC Message Info
1704 * @return ROK - success
1707 * ****************************************************************/
1708 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1710 DuCellCb *cellCb = NULLP;
1713 if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK)
1715 if(ulRrcMsgInfo->ueIdx > 0)
1717 ueCb = cellCb->ueCb[ulRrcMsgInfo->ueIdx -1];
1720 BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, \
1721 ulRrcMsgInfo->rrcMsg);
1723 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1724 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1729 /*******************************************************************
1731 * @brief Process RRC delivery report from RLC
1735 * Function : DuProcRlcRrcDeliveryReport
1737 * Functionality: Process RRC delivery Message from RLC
1739 * @params[in] Post structure
1740 * UL RRC Message Info
1741 * @return ROK - success
1744 * ****************************************************************/
1745 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1747 DuCellCb *cellCb = NULLP;
1749 uint8_t ret = RFAILED;
1751 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1754 ueCb = cellCb->ueCb[rrcDeliveryReport->ueIdx -1];
1755 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1757 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1761 /*******************************************************************
1763 * @brief Process UL user data from RLC
1767 * Function : DuProcRlcUlUserDataTrans
1769 * Functionality: Process UL user data from RLC
1771 * @params[in] Post structure
1773 * @return ROK - success
1776 * ****************************************************************/
1777 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1783 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1785 /* Fill EGTP header */
1786 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1787 egtpMsg.msgHdr.nPdu.pres = FALSE;
1788 egtpMsg.msgHdr.seqNum.pres = FALSE;
1789 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1790 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1792 /* Fetch EGTP tunnel info */
1793 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
1795 /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
1796 if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueIdx == ulUserData->ueIdx) && \
1797 (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
1799 if(duCb.upTnlCfg[teIdx]->tnlCfg1)
1801 egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1807 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1809 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1810 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1811 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1814 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1815 ODU_PRINT_MSG(mBuf, 0, 0);
1817 egtpHdlDatInd(egtpMsg);
1819 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1820 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1824 /*******************************************************************
1826 * @brief Free tempSLiceCfg stored in duCfgParams
1830 * Function : duFreeTempSliceCfg
1832 * Functionality: Free tempSLiceCfg stored in duCfgParams
1834 * @params[in] Post structure,
1838 * ****************************************************************/
1840 void duFreeTempSliceCfg()
1842 uint8_t policyIdx = 0, memberListTdx =0;
1843 CopyOfRecvdSliceCfg *tempSliceCfg = &duCfgParam.tempSliceCfg;
1845 if(tempSliceCfg->totalRrmPolicy)
1847 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1849 if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList)
1851 for(memberListTdx = 0; memberListTdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListTdx++)
1853 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListTdx], sizeof(PolicyMemberList));
1855 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList, (tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) * sizeof(PolicyMemberList*));
1857 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1859 DU_FREE(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy* sizeof(RrmPolicy*));
1861 memset(tempSliceCfg, 0, sizeof(CopyOfRecvdSliceCfg));
1864 /*******************************************************************
1866 * @brief free the slice cfg rsp
1870 * Function : duFreeSliceCfgRsp
1872 * Functionality: free the slice cfg rsp
1874 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1876 * @return ROK - success
1879 **********************************************************************/
1880 void duFreeSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1886 if(cfgRsp->numSliceCfgRsp)
1888 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1890 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(MacSliceRsp));
1892 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp, cfgRsp->numSliceCfgRsp * sizeof(MacSliceRsp*));
1894 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1899 /*******************************************************************
1901 * @brief process the slice cfg rsp received from MAC
1905 * Function : DuProcMacSliceCfgRsp
1907 * Functionality: process the slice cfg rsp received from MAC
1909 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1911 * @return ROK - success
1914 **********************************************************************/
1915 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1921 if(cfgRsp->listOfSliceCfgRsp)
1923 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1925 if(cfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
1927 duCb.sliceState = SLICE_CONFIGURED;
1930 DU_LOG("\nINFO --> DU_APP : Slice Configuration is done sucessfully ");
1932 duFreeSliceCfgRsp(pst, cfgRsp);
1934 duFreeTempSliceCfg();
1938 /*******************************************************************
1940 * @brief Fill the slice configration and rrm policy ratio
1941 * information received form O1
1945 * Function : fillSliceCfgReCfgInfo
1947 * Functionality: Fill the slice configration and recfg info
1949 * @params[in] Post structure
1951 * @return ROK - success
1954 * ****************************************************************/
1956 uint8_t fillSliceCfgReCfgInfo(MacSliceCfgReq *sliceCfgReq, RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
1958 uint8_t sliceIdx = 0, cfgIdx = 0, memberListIdx = 0;
1962 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg, totalSliceCount*sizeof(MacSliceRrmPolicy*));
1963 if(sliceCfgReq->listOfSliceCfg == NULLP)
1965 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1969 for(sliceIdx = 0; sliceIdx<totalRrmPolicy; sliceIdx++)
1971 for(memberListIdx = 0; memberListIdx<rrmPolicy[sliceIdx]->numMemberList; memberListIdx++)
1973 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
1974 if(sliceCfgReq->listOfSliceCfg[cfgIdx] == NULLP)
1976 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1981 memcpy(&sliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, &rrmPolicy[sliceIdx]->memberList[memberListIdx]->snssai, sizeof(Snssai));
1983 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
1984 if(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio == NULLP)
1986 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1990 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio = rrmPolicy[sliceIdx]->policyMaxRatio;
1991 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio = rrmPolicy[sliceIdx]->policyMinRatio;
1992 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio = rrmPolicy[sliceIdx]->policyDedicatedRatio;
1993 sliceCfgReq->numOfConfiguredSlice++;
2001 /*******************************************************************
2003 * @brief Fill the slice configration and rrm policy related
2004 * information received form O1
2008 * Function : BuildAndSendSliceConfigReq
2010 * Functionality: Fill the slice configration and rrm policy related
2012 * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t
2015 * @return ROK - success
2018 * ****************************************************************/
2019 uint8_t BuildAndSendSliceConfigReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCnt)
2022 MacSliceCfgReq *sliceCfgReq;
2024 DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq));
2025 if(sliceCfgReq == NULLP)
2027 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq");
2032 if(fillSliceCfgReCfgInfo(sliceCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCnt) != ROK)
2034 DU_LOG("\nERROR --> DU_APP : Failed to fill slice Configuration info in MacSliceCfgReq");
2037 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ);
2039 DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC ");
2040 if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED)
2042 DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC");
2043 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq));
2050 /*******************************************************************
2052 * @brief Fill the slice configration and rrm policy related
2053 * information received form O1
2057 * Function : BuildAndSendSliceReCfgReq
2059 * Functionality: Fill the slice configration and rrm policy related
2061 * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount
2063 * @return ROK - success
2066 * ****************************************************************/
2067 uint8_t BuildAndSendSliceReCfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
2070 MacSliceCfgReq *sliceReCfgReq = NULLP;
2072 DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received");
2074 DU_ALLOC_SHRABL_BUF(sliceReCfgReq, sizeof(MacSliceCfgReq));
2075 if(sliceReCfgReq == NULLP)
2077 DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceReCfgReq");
2082 if(fillSliceCfgReCfgInfo(sliceReCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCount) != ROK)
2084 DU_LOG("\nERROR --> DU_APP: Failed to fill slice cfg request info");
2087 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ);
2089 DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC ");
2090 if( (*packMacSliceReCfgReqOpts[pst.selector])(&pst, sliceReCfgReq) == RFAILED)
2092 DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC");
2093 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceReCfgReq, sizeof(MacSliceCfgReq));
2098 /*******************************************************************
2100 * @brief process the slice ReCfg rsp received from MAC
2104 * Function : DuProcMacSliceReCfgRsp
2106 * Functionality: process the slice ReCfg rsp received from MAC
2108 * @params[in] Post structure, MacSliceCfgRsp *ReCfgRsp
2110 * @return ROK - success
2113 **********************************************************************/
2114 uint8_t DuProcMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *reCfgRsp)
2116 uint8_t cfgIdx = 0, sliceIdx =0;
2120 if(reCfgRsp->listOfSliceCfgRsp)
2122 for(cfgIdx = 0; cfgIdx < reCfgRsp->numSliceCfgRsp; cfgIdx++)
2124 if(reCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
2126 duCb.sliceState = SLICE_RECONFIGURED;
2130 DU_LOG("\nERROR --> DU_APP : Slice not available");
2133 DU_LOG("\nINFO --> DU_APP : Slice ReCOnfiguration response received");
2135 duFreeSliceCfgRsp(pst, reCfgRsp);
2137 duFreeTempSliceCfg();
2141 /*******************************************************************
2143 * @brief Handles received Slice Metrics from RLC and forward it to O1
2147 * Function : DuProcRlcSliceMetrics
2150 * Handles received Slice Metrics from RLC and forward it to O1
2152 * @params[in] Post structure pointer
2153 * SlicePmList *sliceStats
2155 * @return ROK - success
2158 * ****************************************************************/
2159 uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
2161 uint8_t sliceRecord = 0;
2163 DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics");
2164 if(sliceStats == NULLP)
2166 DU_LOG("\nERROR --> DU APP : Empty Metrics");
2170 for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
2172 DU_LOG("\nINFO --> DU_APP: SliceIndx:%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier,\
2173 sliceStats->sliceRecord[sliceRecord].ThpDl, sliceStats->sliceRecord[sliceRecord].ThpUl);
2178 sendSliceMetric((SliceMetricList*) sliceStats);
2182 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2183 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2188 /**********************************************************************
2190 **********************************************************************/