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 egtpHdlDatInd(EgtpMsg egtpMsg);
62 uint8_t BuildAndSendDUConfigUpdate();
63 uint16_t getTransId();
64 uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
65 uint8_t sendCellDeleteReqToMac(uint16_t cellId);
67 packMacCellCfgReq packMacCellCfgOpts[] =
69 packMacCellCfg, /* packing for loosely coupled */
70 MacProcCellCfgReq, /* packing for tightly coupled */
71 packMacCellCfg, /* packing for light weight loosly coupled */
74 DuMacCellStart packMacCellStartOpts[] =
76 packMacCellStart, /* Loose coupling */
77 MacProcCellStart, /* TIght coupling */
78 packMacCellStart /* Light weight-loose coupling */
81 DuMacCellStop packMacCellStopOpts[] =
83 packMacCellStop, /* Loose coupling */
84 MacProcCellStop, /* TIght coupling */
85 packMacCellStop /* Light weight-loose coupling */
88 DuMacSliceCfgReq packMacSliceCfgReqOpts[] =
90 packDuMacSliceCfgReq, /* Loose coupling */
91 MacProcSliceCfgReq, /* TIght coupling */
92 packDuMacSliceCfgReq /* Light weight-loose coupling */
96 DuMacSliceRecfgReq packMacSliceReCfgReqOpts[] =
98 packDuMacSliceRecfgReq, /* Loose coupling */
99 MacProcSliceReCfgReq, /* TIght coupling */
100 packDuMacSliceRecfgReq /* Light weight-loose coupling */
102 /**************************************************************************
103 * @brief Function to fill configs required by RLC
107 * Function : duBuildRlcCfg
110 * Initiates general Configs towards RLC
112 * @param[in] Inst Specifies if RLC UL or RLC DL instance
113 * @return ROK - success
116 ***************************************************************************/
117 uint8_t duBuildRlcCfg(Inst inst)
120 RlcGenCfg *genCfg = NULLP;
123 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
124 DU_SET_ZERO(&pst, sizeof(Pst));
126 genCfg = &(rlcMngmt.t.cfg.s.gen);
128 /*----------- Fill General Configuration Parameters ---------*/
129 genCfg->maxUe = duCfgParam.maxUe;
130 genCfg->maxKwuSaps = 2;
131 genCfg->maxUdxSaps = 1;
132 genCfg->rlcMode = (inst == RLC_UL_INST) ?
133 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
135 genCfg->maxRguSaps = DEFAULT_CELLS;
137 /*----------- Fill lmPst
138 * Parameters ---------*/
139 genCfg->lmPst.dstProcId = DU_PROC;
140 genCfg->lmPst.srcProcId = DU_PROC;
141 genCfg->lmPst.dstEnt = ENTDUAPP;
142 genCfg->lmPst.dstInst = DU_INST;
143 genCfg->lmPst.srcEnt = ENTRLC;
144 genCfg->lmPst.srcInst = inst;
145 genCfg->lmPst.prior = PRIOR0;
146 genCfg->lmPst.route = RTESPEC;
147 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
148 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
149 genCfg->lmPst.pool = RLC_POOL;
150 genCfg->lmPst.selector = ODU_SELECTOR_LC;
153 rlcMngmt.hdr.msgType = TCFG;
154 rlcMngmt.hdr.msgLen = 0;
155 rlcMngmt.hdr.entId.ent = ENTRLC;
156 rlcMngmt.hdr.entId.inst = (Inst)0;
157 rlcMngmt.hdr.elmId.elmnt = STGEN;
158 rlcMngmt.hdr.seqNmb = 0;
159 rlcMngmt.hdr.version = 0;
160 rlcMngmt.hdr.transId = 0;
161 rlcMngmt.hdr.response.prior = PRIOR0;
162 rlcMngmt.hdr.response.route = RTESPEC;
163 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
164 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
165 rlcMngmt.hdr.response.mem.pool = DU_POOL;
166 rlcMngmt.hdr.response.selector = ODU_SELECTOR_LC;
169 pst.selector = ODU_SELECTOR_LC;
170 pst.srcEnt = ENTDUAPP;
173 pst.dstProcId = DU_PROC;
174 pst.srcProcId = DU_PROC;
175 pst.region = duCb.init.region;
177 DU_LOG("\nDEBUG --> DU_APP : RLC Gen Cfg Req sent for inst %d", inst);
179 /* Send the request to RLC */
180 packRlcConfigReq(&pst, &rlcMngmt);
185 /**************************************************************************
186 * @brief Function to fill configs required by RLC
190 * Function : duBuildRlcLsapCfg
193 * Initiates general Configs towards RLC
195 * @param[in] Inst Specifies if RLC UL or RLC DL instance
196 * @return ROK - success
199 ***************************************************************************/
200 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst)
204 RlcSapCfg *lSap = NULLP;
207 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
208 DU_SET_ZERO(&pst, sizeof(Pst));
211 rlcMngmt.hdr.msgType = TCFG;
212 rlcMngmt.hdr.entId.ent = ENTRLC;
213 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
214 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
216 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
219 pst.selector = ODU_SELECTOR_LC;
220 pst.srcEnt = ENTDUAPP;
222 pst.dstProcId = DU_PROC;
224 pst.srcProcId = DU_PROC;
225 pst.region = duCb.init.region;
226 lSap = &(rlcMngmt.t.cfg.s.sap);
228 lSap->mem.region = (inst == RLC_UL_INST) ?
229 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
230 lSap->mem.pool = RLC_POOL;
232 lSap->bndTmrIntvl = 10;
233 lSap->priority = PRIOR0;
234 lSap->route = RTESPEC;
237 lSap->procId = DU_PROC;
239 lSap->inst = lsapInst;
240 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
241 lSap->selector = (inst == RLC_UL_INST) ? ODU_SELECTOR_LWLC : ODU_SELECTOR_TC;
242 rlcMngmt.hdr.elmId.elmnt = STRGUSAP;
243 DU_LOG("\nDEBUG --> DU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
248 lSap->procId = DU_PROC;
250 lSap->inst = (inst == RLC_UL_INST) ?
251 RLC_DL_INST : RLC_UL_INST;
253 lSap->selector = ODU_SELECTOR_LC;
254 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
255 DU_LOG("\nDEBUG --> DU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
258 packRlcConfigReq(&pst, &rlcMngmt);
262 /**************************************************************************
263 * @brief Function to fill configs required by RLC
267 * Function : duBuildRlcUsapCfg
270 * Initiates general Configs towards RLC
272 * @param[in] Inst Specifies if RLC UL or RLC DL instance
273 * @return ROK - success
276 ***************************************************************************/
277 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
280 RlcSapCfg *uSap = NULLP;
283 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
284 DU_SET_ZERO(&pst, sizeof(Pst));
286 uSap = &(rlcMngmt.t.cfg.s.sap);
288 uSap->selector = ODU_SELECTOR_LC;
289 uSap->mem.region = (inst == RLC_UL_INST) ?
290 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
291 uSap->mem.pool = RLC_POOL;
294 uSap->procId = DU_PROC;
298 uSap->inst = (inst == RLC_UL_INST) ?
299 RLC_DL_INST : RLC_UL_INST;
300 uSap->bndTmrIntvl = 1000;
301 uSap->priority = PRIOR0;
302 uSap->route = RTESPEC;
305 rlcMngmt.hdr.msgType = TCFG;
306 rlcMngmt.hdr.entId.ent = ENTRLC;
307 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
308 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
309 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
311 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
314 pst.selector = ODU_SELECTOR_LC;
315 pst.srcEnt = ENTDUAPP;
317 pst.dstProcId = DU_PROC;
319 pst.srcProcId = DU_PROC;
320 pst.region = duCb.init.region;
322 DU_LOG("\nDEBUG --> DU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
323 packRlcConfigReq(&pst, &rlcMngmt);
328 /**************************************************************************
329 * @brief Function to populate internal DS of DU APP
333 * Function : duProcCfgComplete
336 * Populates internal data structures of DU APP after
337 * receiving configurations.
340 * @return ROK - success
343 ***************************************************************************/
344 uint8_t duProcCfgComplete()
349 for(idx=0; idx< DEFAULT_CELLS; idx++)
351 DuCellCb *cell = NULLP;
352 DU_ALLOC(cell, sizeof(DuCellCb));
355 DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete");
361 memset(cell, 0, sizeof(DuCellCb));
362 cell->cellId = ++cellId;
363 memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
364 cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
365 cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
366 cell->cellInfo.nrEcgi.plmn.mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
367 cell->cellInfo.nrEcgi.plmn.mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
368 cell->cellInfo.nrEcgi.plmn.mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
369 cell->cellInfo.nrEcgi.plmn.mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
370 cell->cellInfo.nrEcgi.cellId = cell->cellId;
371 cell->cellInfo.nrPci = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
372 cell->cellInfo.fiveGsTac = duCfgParam.srvdCellLst[0].duCellInfo.tac;
373 memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn));
374 for(idx1=0; idx1<MAX_PLMN; idx1++)
376 cell->cellInfo.plmn[idx1].mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
377 cell->cellInfo.plmn[idx1].mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
378 cell->cellInfo.plmn[idx1].mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
379 cell->cellInfo.plmn[idx1].mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
380 cell->cellInfo.plmn[idx1].mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
381 cell->cellInfo.plmn[idx1].mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
383 cell->cellInfo.maxUe = duCfgParam.maxUe;
384 cell->cellStatus = CELL_OUT_OF_SERVICE;
385 gCellStatus = CELL_DOWN;
386 duCb.cfgCellLst[duCb.numCfgCells] = cell;
392 //Start layer configs
393 ret = duSendRlcUlCfg();
397 /**************************************************************************
398 * @brief Function to invoke DU Layer Configs
402 * Function : duSendRlcUlCfg
405 * Initiates Configs towards layers of DU
408 * @return ROK - success
411 ***************************************************************************/
412 uint8_t duSendRlcUlCfg()
416 duBuildRlcCfg((Inst)RLC_UL_INST);
417 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
419 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
421 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
426 /**************************************************************************
427 * @brief Function to invoke DU Layer Configs
431 * Function : duSendRlcDlCfg
434 * Initiates Configs towards layers of DU
437 * @return ROK - success
440 ***************************************************************************/
441 uint8_t duSendRlcDlCfg()
445 duBuildRlcCfg((Inst)RLC_DL_INST);
446 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
447 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
449 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
454 /**************************************************************************
455 * @brief Function to handle Config Confirm from RLC
459 * Function : DuHdlRlcCfgComplete
462 * Handles Gen Config Confirm from RLC
464 * @param[in] Pst *pst, Post structure of the primitive.
465 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
466 * @return ROK - success
469 ***************************************************************************/
470 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
473 if (pst->srcInst == RLC_UL_INST)
475 ret = duProcRlcUlCfgComplete(pst, cfm);
479 ret = duProcRlcDlCfgComplete(pst, cfm);
484 /**************************************************************************
485 * @brief Function to handle Control Config Confirm from RLC
489 * Function : duHdlRlcCntrlCfgComplete
492 * Handles Control Config Confirm from RLC
494 * @param[in] Pst *pst, Post structure of the primitive.
495 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
496 * @return ROK - success
499 ***************************************************************************/
500 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
504 if (cntrl->cfm.status == LCM_PRIM_OK)
506 switch (cntrl->hdr.elmId.elmnt)
510 if (pst->srcInst == RLC_DL_INST)
512 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
514 if(macCfgInst < DEFAULT_CELLS)
517 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
521 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
526 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
528 if(macCfgInst < DEFAULT_CELLS)
530 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
544 /**************************************************************************
545 * @brief Function to handle Config Confirm from RLC UL
549 * Function : duHdlRlcUlCfgComplete
552 * Handles Config Confirm from RLC UL
554 * @param[in] Pst *pst, Post structure of the primitive.
555 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
556 * @return ROK - success
559 ***************************************************************************/
560 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
564 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
565 if (cfm->cfm.status == LCM_PRIM_OK)
567 switch(cfm->hdr.elmId.elmnt)
571 rlcUlCfg |= RLC_GEN_CFG;
577 if(numRlcMacSaps == DEFAULT_CELLS)
579 rlcUlCfg |= RLC_MAC_SAP_CFG;
586 rlcUlCfg |= RLC_UDX_SAP_CFG;
593 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
594 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
598 //Start configuration of RLC DL
605 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
611 /**************************************************************************
612 * @brief Function to handle Config Confirm from RLC DL
616 * Function : duHdlRlcDlCfgComplete
619 * Handles Config Confirm from RLC DL
621 * @param[in] Pst *pst, Post structure of the primitive.
622 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
623 * @return ROK - success
626 ***************************************************************************/
627 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
629 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
630 if (cfm->cfm.status == LCM_PRIM_OK)
632 switch(cfm->hdr.elmId.elmnt)
636 rlcDlCfg |= RLC_GEN_CFG;
642 if(numRlcMacSaps == DEFAULT_CELLS)
644 rlcDlCfg |= RLC_MAC_SAP_CFG;
651 rlcDlCfg |= RLC_UDX_SAP_CFG;
659 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
660 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
663 //Start configuration of MAC
670 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
675 /**************************************************************************
676 * @brief Function to send configs to MAC
680 * Function : duSendMacCfg
683 * Initiates Configs towards MAC layer
686 * @return ROK - success
689 ***************************************************************************/
690 uint8_t duSendMacCfg()
693 duBuildMacUsapCfg(RLC_UL_INST);
694 duBuildMacUsapCfg(RLC_DL_INST);
699 /**************************************************************************
700 * @brief Function to fill gen config required by MAC
704 * Function : duBuildMacGenCfg
707 * Initiates general Configs towards MAC
710 * @return ROK - success
713 ***************************************************************************/
714 uint8_t duBuildMacGenCfg()
717 RgGenCfg *genCfg=NULLP;
720 DU_SET_ZERO(&pst, sizeof(Pst));
721 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
723 genCfg = &(rgMngmt.t.cfg.s.genCfg);
725 /*----------- Fill General Configuration Parameters ---------*/
726 genCfg->mem.region = MAC_MEM_REGION;
727 genCfg->mem.pool = MAC_POOL;
729 genCfg->numRguSaps = 2;
731 genCfg->lmPst.dstProcId = DU_PROC;
732 genCfg->lmPst.srcProcId = DU_PROC;
733 genCfg->lmPst.dstEnt = ENTDUAPP;
734 genCfg->lmPst.dstInst = 0;
735 genCfg->lmPst.srcEnt = ENTMAC;
736 genCfg->lmPst.srcInst = macCfgInst;
737 genCfg->lmPst.prior = PRIOR0;
738 genCfg->lmPst.route = RTESPEC;
739 genCfg->lmPst.region = MAC_MEM_REGION;
740 genCfg->lmPst.pool = MAC_POOL;
741 genCfg->lmPst.selector = ODU_SELECTOR_LC;
744 rgMngmt.hdr.msgType = TCFG;
745 rgMngmt.hdr.msgLen = 0;
746 rgMngmt.hdr.entId.ent = ENTMAC;
747 rgMngmt.hdr.entId.inst = (Inst)0;
748 rgMngmt.hdr.elmId.elmnt = STGEN;
749 rgMngmt.hdr.seqNmb = 0;
750 rgMngmt.hdr.version = 0;
751 rgMngmt.hdr.transId = 0;
753 rgMngmt.hdr.response.prior = PRIOR0;
754 rgMngmt.hdr.response.route = RTESPEC;
755 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
756 rgMngmt.hdr.response.mem.pool = MAC_POOL;
757 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
760 pst.selector = ODU_SELECTOR_LC;
761 pst.srcEnt = ENTDUAPP;
763 pst.dstInst = macCfgInst;
764 pst.dstProcId = DU_PROC;
765 pst.srcProcId = DU_PROC;
766 pst.region = duCb.init.region;
768 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
770 /* Send the request to MAC */
771 cmPkLrgCfgReq(&pst, &rgMngmt);
776 /**************************************************************************
777 * @brief Function to fill USAP config required by MAC
781 * Function : duBuildMacUsapCfg
784 * Initiates USAP Configs towards MAC
786 * @param[in] SpId Specifies if RLC UL or RLC DL instance
787 * @return ROK - success
790 ***************************************************************************/
791 uint8_t duBuildMacUsapCfg(SpId sapId)
794 RgUpSapCfg *uSap = NULLP;
797 DU_SET_ZERO(&pst, sizeof(Pst));
798 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
800 uSap = &(rgMngmt.t.cfg.s.rguSap);
802 uSap->mem.region = MAC_MEM_REGION;
803 uSap->mem.pool = MAC_POOL;
806 uSap->procId = DU_PROC;
809 uSap->prior = PRIOR0;
810 uSap->route = RTESPEC;
811 uSap->selector = ODU_SELECTOR_LC ;
814 rgMngmt.hdr.msgType = TCFG;
815 rgMngmt.hdr.entId.ent = ENTMAC;
816 rgMngmt.hdr.entId.inst = (Inst)0;
817 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
818 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
819 rgMngmt.hdr.response.mem.pool = MAC_POOL;
822 pst.selector = ODU_SELECTOR_LC;
823 pst.srcEnt = ENTDUAPP;
825 pst.dstInst = macCfgInst;
826 pst.dstProcId = DU_PROC;
827 pst.srcProcId = DU_PROC;
828 pst.region = duCb.init.region;
830 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
832 /* Send the request to MAC */
833 cmPkLrgCfgReq(&pst, &rgMngmt);
838 /**************************************************************************
839 * @brief Function to handle Config Confirm from MAC
843 * Function : duHdlMacCfgComplete
846 * Handles Gen Config Confirm from MAC
848 * @param[in] Pst *pst, Post structure of the primitive.
849 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
850 * @return ROK - success
853 ***************************************************************************/
854 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
858 if (cfm->cfm.status == LCM_PRIM_OK)
860 switch (cfm->hdr.elmId.elmnt)
864 macCfg |= MAC_GEN_CFG;
869 macCfg |= MAC_SAP_CFG;
876 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
877 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
880 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
882 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
888 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
894 /**************************************************************************
895 * @brief Function to bind/unbind RLC to MAC SAP
899 * Function : duBindUnbindRlcToMacSap
902 * Initiates Bind/Unbind from RLC to MAC
904 * @param[in] Inst Specifies if RLC UL or RLC DL instance
905 * @param[in] action Specifies if action is bind or unbind
906 * @return ROK - success
909 ***************************************************************************/
910 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
912 RlcCntrl *cntrl = NULLP;
917 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
918 DU_SET_ZERO(&pst, sizeof(Pst));
922 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
926 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
928 cntrl = &(rlcMngmt.t.cntrl);
930 cntrl->action = action;
931 cntrl->subAction = DU_ZERO_VAL;
932 cntrl->s.sapCntrl.suId = macCfgInst;
933 cntrl->s.sapCntrl.spId = inst;
936 rlcMngmt.hdr.msgType = TCNTRL;
937 rlcMngmt.hdr.entId.ent = ENTRLC;
938 rlcMngmt.hdr.entId.inst = inst;
939 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
940 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
941 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
942 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
945 pst.selector = ODU_SELECTOR_LC;
946 pst.srcEnt = ENTDUAPP;
948 pst.dstProcId = DU_PROC;
950 pst.srcProcId = DU_PROC;
951 pst.region = duCb.init.region;
953 cmPkLkwCntrlReq(&pst, &rlcMngmt);
957 /*******************************************************************
959 * @brief Handles SCTP notifications
963 * Function : duSctpNtfyHdl
966 * Handles SCTP notification
968 * @params[in] Message Buffer
971 * @return ROK - success
974 * ****************************************************************/
976 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
978 if(f1Params.assocId == ntfy->u.assocChange.assocId)
980 if(BuildAndSendF1SetupReq() != ROK)
985 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
991 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
997 /*******************************************************************
999 * @brief Fills Pst struct for ENTEGTP
1003 * Function : duFillEgtpPst
1006 * Fills Pst struct for ENTEGTP
1009 * @return ROK - success
1012 * ****************************************************************/
1013 uint8_t duFillEgtpPst(Pst *pst, Event event)
1015 memset(pst, 0, sizeof(Pst));
1016 pst->srcEnt = (Ent)ENTDUAPP;
1017 pst->srcInst = (Inst)DU_INST;
1018 pst->srcProcId = DU_PROC;
1019 pst->dstEnt = (Ent)ENTEGTP;
1020 pst->dstInst = (Inst)EGTP_INST;
1021 pst->dstProcId = pst->srcProcId;
1023 pst->selector = ODU_SELECTOR_LC;
1030 /*******************************************************************
1032 * @brief Function to configure EGTP
1036 * Function : duBuildEgtpCfgReq
1039 * Function to configure EGTP
1042 * @return ROK - success
1045 * ****************************************************************/
1047 uint8_t duBuildEgtpCfgReq()
1052 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1054 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1055 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1057 duFillEgtpPst(&pst, EVTCFGREQ);
1058 packEgtpCfgReq(&pst, egtpCfg);
1063 /*******************************************************************
1065 * @brief Function to configure EGTP
1069 * Function : duBuildEgtpCfgReq
1072 * Function to configure EGTP
1075 * @return ROK - success
1078 * ****************************************************************/
1079 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1083 if(cfm.status == LCM_PRIM_OK)
1085 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1086 duSendEgtpSrvOpenReq();
1090 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1097 /*******************************************************************
1099 * @brief Sends server open request to EGTP
1103 * Function : duSendEgtpSrvOpenReq
1106 * Sends server open request to EGTP
1109 * @return ROK - success
1112 * ****************************************************************/
1114 uint8_t duSendEgtpSrvOpenReq()
1118 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1120 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1121 packEgtpSrvOpenReq(&pst);
1126 /*******************************************************************
1128 * @brief Handles server open confirmation
1132 * Function : duHdlEgtpSrvOpenComplete
1135 * Handles server open confirmation
1138 * @return ROK - success
1141 *****************************************************************/
1143 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1147 if(cfm.status == LCM_PRIM_OK)
1149 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1153 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1160 /*******************************************************************
1162 * @brief Sends tunnel management request
1166 * Function : duSendEgtpTnlMgmtReq
1169 * Builds and sends tunnel management request to EGTP
1171 * @params[in] Action
1172 * Local tunnel endpoint id
1173 * Remote tunnel endpoint id
1174 * @return ROK - success
1177 * ****************************************************************/
1179 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1185 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1187 /* ADD/MOD/DEL per tunnel */
1188 tnlEvt.action = action;
1189 tnlEvt.remTeid = ueCbTnlCfg->teId;
1190 if(action != EGTP_TNL_MGMT_ADD)
1192 tnlEvt.lclTeid = teIdTobeMod;
1196 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1198 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1199 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1203 /*******************************************************************
1205 * @brief Handles Tunnel management confirm
1209 * Function : duHdlEgtpTnlMgmtCfm
1212 * Handles tunnel management confirm received from Egtp
1214 * @params[in] Tunnel Event
1215 * @return ROK - success
1218 * ****************************************************************/
1219 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1223 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1225 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1229 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1236 /*******************************************************************
1238 * @brief Sends UL user data over to EGTP
1242 * Function : duSendEgtpDatInd
1244 * Functionality: Sends UL user data over to EGTP
1246 * @params[in] UL data buffer
1247 * @return ROK - success
1250 * ****************************************************************/
1251 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1255 /* Fill EGTP header */
1256 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1257 egtpMsg.msgHdr.nPdu.pres = FALSE;
1258 egtpMsg.msgHdr.seqNum.pres = FALSE;
1259 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1260 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1261 egtpMsg.msgHdr.teId = 1;
1264 egtpHdlDatInd(egtpMsg);
1270 /**************************************************************************
1271 * @brief Function to send configs to SCH
1275 * Function : duSendSchCfg
1278 * Sends general config to Scheduler via MAC layer
1281 * @return ROK - success
1284 ***************************************************************************/
1285 uint8_t duSendSchCfg()
1288 RgSchInstCfg *cfg = NULLP;
1291 DU_SET_ZERO(&pst, sizeof(Pst));
1292 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1294 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1296 /* Filling of Instance Id */
1297 cfg->instId = DEFAULT_CELLS + 1;
1298 /* Filling of Gen config */
1299 cfg->genCfg.mem.region = MAC_MEM_REGION;
1300 cfg->genCfg.mem.pool = MAC_POOL;
1301 cfg->genCfg.tmrRes = 10;
1304 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1305 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1307 cfg->genCfg.startCellId = 1;
1308 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1309 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1310 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1311 cfg->genCfg.lmPst.dstInst = DU_INST;
1312 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1313 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1314 cfg->genCfg.lmPst.prior = PRIOR0;
1315 cfg->genCfg.lmPst.route = RTESPEC;
1316 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1317 cfg->genCfg.lmPst.pool = MAC_POOL;
1318 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1321 rgMngmt.hdr.msgType = TCFG;
1322 rgMngmt.hdr.entId.ent = ENTMAC;
1323 rgMngmt.hdr.entId.inst = DU_INST;
1324 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1325 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1326 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1329 pst.selector = ODU_SELECTOR_LC;
1330 pst.srcEnt = ENTDUAPP;
1331 pst.dstEnt = ENTMAC;
1332 pst.dstProcId = DU_PROC;
1333 pst.srcProcId = DU_PROC;
1334 pst.srcInst = DU_INST;
1336 pst.region = duCb.init.region;
1337 pst.event = (Event) EVTMACSCHGENCFGREQ;
1339 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1341 /* Send the request to MAC */
1342 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1348 /**************************************************************************
1349 * @brief Function to configure SCTP params and
1350 * responsible for F1 and E2 interfaces
1354 * Function : duLayerConfigComplete
1357 * Configures SCTP Params and responsible for handling
1358 * F1 and E2 interface.
1361 * @return ROK - success
1364 ***************************************************************************/
1365 uint8_t duLayerConfigComplete()
1369 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1371 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1373 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1376 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1378 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1381 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1383 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1390 /**************************************************************************
1391 * @brief Function to handle SCH Config Confirm from MAC
1395 * Function : duHdlSchCfgComplete
1398 * Handles Scheduler Gen Config Confirm from MAC
1400 * @param[in] Pst *pst, Post structure of the primitive.
1401 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1402 * @return ROK - success
1405 ***************************************************************************/
1406 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1408 if (cfm->cfm.status == LCM_PRIM_OK)
1410 switch (cfm->hdr.elmId.elmnt)
1414 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1421 duLayerConfigComplete();
1422 duBuildEgtpCfgReq();
1426 /**************************************************************************
1427 * @brief Function to fill and send MacCellconfig
1431 * Function : duBuildAndSendMacCellCfg
1434 * Initiates MAC Configs towards MAC
1437 * @return ROK - success
1440 ***************************************************************************/
1441 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1444 MacCellCfg *duMacCellCfg = NULLP;
1446 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1447 if(duMacCellCfg == NULLP)
1452 /* store the address in the duCellCb so that we can free on confirm msg */
1453 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1455 /* copy the mac config structure from duCfgParams */
1456 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1459 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1461 /* Send MAC cell config to MAC */
1462 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1465 /**************************************************************************
1466 * @brief Function to Handle MAC cell config confirm
1470 * Function : duHandleMacCellCfgCfm
1473 * Initiates general Configs towards MAC
1476 * @return ROK - success
1479 ***************************************************************************/
1480 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1482 uint8_t actvCellIdx = 0;
1485 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1487 if(macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId)
1489 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1492 if(macCellCfgCfm->rsp == ROK)
1494 /* Build and send GNB-DU config update */
1495 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1497 /* Build and Send Cell Start Req to MAC */
1498 ret = duBuildAndSendMacCellStart();
1502 /* TODO : Action to be taken if cell configuration fails.
1503 * Should CU be informed? */
1505 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1511 /*******************************************************************
1513 * @brief Builds and sends cell start request to MAC
1517 * Function : duBuildAndSendMacCellStart
1520 * Builds and sends cell start request to MAC
1523 * @return ROK - success
1526 * ****************************************************************/
1527 uint8_t duBuildAndSendMacCellStart()
1530 OduCellId *cellId = NULL;
1532 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1534 /* Send Cell Start Request to MAC */
1535 DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId));
1538 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1542 for(uint8_t id = 0; id < duCb.numActvCells; id++)
1544 if(duCb.actvCellLst[id])
1546 cellId->cellId = duCb.actvCellLst[id]->cellId;
1549 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1551 return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
1557 /*******************************************************************
1559 * @brief Builds and sends cell stop request to MAC
1563 * Function : duBuildAndSendMacCellStop
1566 * Builds and sends cell stop request to MAC
1569 * @return ROK - success
1572 * ****************************************************************/
1573 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1577 OduCellId *oduCellId = NULL;
1579 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1581 GET_CELL_IDX(cellId, cellIdx);
1582 if(duCb.actvCellLst[cellIdx] != NULLP)
1584 /* Send Cell Stop Request to MAC */
1585 DU_ALLOC_SHRABL_BUF(oduCellId, sizeof(OduCellId));
1588 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): Memory allocation failed ");
1591 memset(oduCellId, 0, sizeof(OduCellId));
1592 oduCellId->cellId = duCb.actvCellLst[cellIdx]->cellId;
1595 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1597 return (*packMacCellStopOpts[pst.selector])(&pst, oduCellId);
1601 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1607 /*******************************************************************
1609 * @brief Handles stop indication from MAC
1613 * Function : duHandleStopInd
1616 * Handles stop indication from MAC
1618 * @params[in] Post structure pointer
1619 * @return ROK - success
1622 * ****************************************************************/
1623 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1625 DuCellCb *cellCb = NULLP;
1627 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1629 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1632 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1635 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1637 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1638 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1640 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1641 cellId[%d]", cellId->cellId);
1647 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1648 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1649 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1653 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1654 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1656 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1662 /*******************************************************************
1664 * @brief Handles slot indication from MAC
1668 * Function : duHandleUlCcchInd
1671 * Handles UL CCCH indication from MAC
1673 * @params[in] Post structure pointer
1674 * UL CCCH Ind pointer
1675 * @return ROK - success
1678 * ****************************************************************/
1679 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1682 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1684 return (duProcUlCcchInd(ulCcchIndInfo));
1687 /*******************************************************************
1689 * @brief Process UL RRC Message from RLC
1693 * Function : DuProcRlcUlRrcMsgTrans
1695 * Functionality: Process UL RRC Message from RLC
1697 * @params[in] Post structure
1698 * UL RRC Message Info
1699 * @return ROK - success
1702 * ****************************************************************/
1703 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1705 DuCellCb *cellCb = NULLP;
1708 if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK)
1710 if(ulRrcMsgInfo->ueId > 0)
1712 ueCb = cellCb->ueCb[ulRrcMsgInfo->ueId -1];
1715 BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg);
1717 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1718 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1723 /*******************************************************************
1725 * @brief Process RRC delivery report from RLC
1729 * Function : DuProcRlcRrcDeliveryReport
1731 * Functionality: Process RRC delivery Message from RLC
1733 * @params[in] Post structure
1734 * UL RRC Message Info
1735 * @return ROK - success
1738 * ****************************************************************/
1739 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1741 DuCellCb *cellCb = NULLP;
1743 uint8_t ret = RFAILED;
1745 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1748 ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1];
1749 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1751 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1755 /*******************************************************************
1757 * @brief Process UL user data from RLC
1761 * Function : DuProcRlcUlUserDataTrans
1763 * Functionality: Process UL user data from RLC
1765 * @params[in] Post structure
1767 * @return ROK - success
1770 * ****************************************************************/
1771 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1777 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1779 /* Fill EGTP header */
1780 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1781 egtpMsg.msgHdr.nPdu.pres = FALSE;
1782 egtpMsg.msgHdr.seqNum.pres = FALSE;
1783 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1784 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1786 /* Fetch EGTP tunnel info */
1787 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
1789 /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
1790 if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \
1791 (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
1793 if(duCb.upTnlCfg[teIdx]->tnlCfg1)
1795 egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1801 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1803 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1804 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1805 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1808 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1809 ODU_PRINT_MSG(mBuf, 0, 0);
1811 egtpHdlDatInd(egtpMsg);
1813 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1814 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1818 /*******************************************************************
1820 * @brief Free tempSLiceCfg stored in duCfgParams
1824 * Function : duFreeTempSliceCfg
1826 * Functionality: Free tempSLiceCfg stored in duCfgParams
1828 * @params[in] Post structure,
1832 * ****************************************************************/
1834 void duFreeTempSliceCfg()
1836 uint8_t policyIdx = 0, memberListTdx =0;
1837 CopyOfRecvdSliceCfg *tempSliceCfg = &duCfgParam.tempSliceCfg;
1839 if(tempSliceCfg->totalRrmPolicy)
1841 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1843 if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList)
1845 for(memberListTdx = 0; memberListTdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListTdx++)
1847 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListTdx], sizeof(PolicyMemberList));
1849 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList, (tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) * sizeof(PolicyMemberList*));
1851 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1853 DU_FREE(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy* sizeof(RrmPolicy*));
1855 memset(tempSliceCfg, 0, sizeof(CopyOfRecvdSliceCfg));
1858 /*******************************************************************
1860 * @brief free the slice cfg rsp
1864 * Function : duFreeSliceCfgRsp
1866 * Functionality: free the slice cfg rsp
1868 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1870 * @return ROK - success
1873 **********************************************************************/
1874 void duFreeSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1880 if(cfgRsp->numSliceCfgRsp)
1882 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1884 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(MacSliceRsp));
1886 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp, cfgRsp->numSliceCfgRsp * sizeof(MacSliceRsp*));
1888 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1892 /*******************************************************************
1894 * @brief process the slice cfg rsp received from MAC
1898 * Function : DuProcMacSliceCfgRsp
1900 * Functionality: process the slice cfg rsp received from MAC
1902 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1904 * @return ROK - success
1907 **********************************************************************/
1908 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1914 if(cfgRsp->listOfSliceCfgRsp)
1916 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1918 if(cfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
1920 duCb.sliceState = SLICE_CONFIGURED;
1923 DU_LOG("\nINFO --> DU_APP : Slice Configuration is done sucessfully ");
1925 duFreeSliceCfgRsp(pst, cfgRsp);
1927 duFreeTempSliceCfg();
1931 /*******************************************************************
1933 * @brief Fill the slice configration and rrm policy ratio
1934 * information received form O1
1938 * Function : fillSliceCfgReCfgInfo
1940 * Functionality: Fill the slice configration and recfg info
1942 * @params[in] Post structure
1944 * @return ROK - success
1947 * ****************************************************************/
1949 uint8_t fillSliceCfgReCfgInfo(MacSliceCfgReq *sliceCfgReq, RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
1951 uint8_t sliceIdx = 0, cfgIdx = 0, memberListIdx = 0;
1955 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg, totalSliceCount*sizeof(MacSliceRrmPolicy*));
1956 if(sliceCfgReq->listOfSliceCfg == NULLP)
1958 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1962 for(sliceIdx = 0; sliceIdx<totalRrmPolicy; sliceIdx++)
1964 for(memberListIdx = 0; memberListIdx<rrmPolicy[sliceIdx]->numMemberList; memberListIdx++)
1966 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
1967 if(sliceCfgReq->listOfSliceCfg[cfgIdx] == NULLP)
1969 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1974 memcpy(&sliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, &rrmPolicy[sliceIdx]->memberList[memberListIdx]->snssai, sizeof(Snssai));
1976 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
1977 if(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio == NULLP)
1979 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1983 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio = rrmPolicy[sliceIdx]->policyMaxRatio;
1984 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio = rrmPolicy[sliceIdx]->policyMinRatio;
1985 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio = rrmPolicy[sliceIdx]->policyDedicatedRatio;
1986 sliceCfgReq->numOfConfiguredSlice++;
1994 /*******************************************************************
1996 * @brief Fill the slice configration and rrm policy related
1997 * information received form O1
2001 * Function : BuildAndSendSliceConfigReq
2003 * Functionality: Fill the slice configration and rrm policy related
2005 * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t
2008 * @return ROK - success
2011 * ****************************************************************/
2012 uint8_t BuildAndSendSliceConfigReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCnt)
2015 MacSliceCfgReq *sliceCfgReq;
2017 DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq));
2018 if(sliceCfgReq == NULLP)
2020 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq");
2025 if(fillSliceCfgReCfgInfo(sliceCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCnt) != ROK)
2027 DU_LOG("\nERROR --> DU_APP : Failed to fill slice Configuration info in MacSliceCfgReq");
2030 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ);
2032 DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC ");
2033 if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED)
2035 DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC");
2036 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq));
2043 /*******************************************************************
2045 * @brief Fill the slice configration and rrm policy related
2046 * information received form O1
2050 * Function : BuildAndSendSliceReCfgReq
2052 * Functionality: Fill the slice configration and rrm policy related
2054 * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount
2056 * @return ROK - success
2059 * ****************************************************************/
2060 uint8_t BuildAndSendSliceReCfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
2063 MacSliceCfgReq *sliceReCfgReq = NULLP;
2065 DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received");
2067 DU_ALLOC_SHRABL_BUF(sliceReCfgReq, sizeof(MacSliceCfgReq));
2068 if(sliceReCfgReq == NULLP)
2070 DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceReCfgReq");
2075 if(fillSliceCfgReCfgInfo(sliceReCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCount) != ROK)
2077 DU_LOG("\nERROR --> DU_APP: Failed to fill slice cfg request info");
2080 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ);
2082 DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC ");
2083 if( (*packMacSliceReCfgReqOpts[pst.selector])(&pst, sliceReCfgReq) == RFAILED)
2085 DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC");
2086 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceReCfgReq, sizeof(MacSliceCfgReq));
2091 /*******************************************************************
2093 * @brief process the slice ReCfg rsp received from MAC
2097 * Function : DuProcMacSliceReCfgRsp
2099 * Functionality: process the slice ReCfg rsp received from MAC
2101 * @params[in] Post structure, MacSliceCfgRsp *ReCfgRsp
2103 * @return ROK - success
2106 **********************************************************************/
2107 uint8_t DuProcMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *reCfgRsp)
2113 if(reCfgRsp->listOfSliceCfgRsp)
2115 for(cfgIdx = 0; cfgIdx < reCfgRsp->numSliceCfgRsp; cfgIdx++)
2117 if(reCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
2119 duCb.sliceState = SLICE_RECONFIGURED;
2123 DU_LOG("\nERROR --> DU_APP : Slice not available");
2126 DU_LOG("\nINFO --> DU_APP : Slice ReCOnfiguration response received");
2128 duFreeSliceCfgRsp(pst, reCfgRsp);
2130 duFreeTempSliceCfg();
2134 /*******************************************************************
2136 * @brief Handles received Slice Metrics from RLC and forward it to O1
2140 * Function : DuProcRlcSliceMetrics
2143 * Handles received Slice Metrics from RLC and forward it to O1
2145 * @params[in] Post structure pointer
2146 * SlicePmList *sliceStats
2148 * @return ROK - success
2151 * ****************************************************************/
2152 uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
2154 uint8_t sliceRecord = 0;
2156 DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics");
2157 if(sliceStats == NULLP)
2159 DU_LOG("\nERROR --> DU APP : Empty Metrics");
2163 for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
2165 DU_LOG("\nINFO --> DU_APP: SliceIndx:%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier,\
2166 sliceStats->sliceRecord[sliceRecord].ThpDl, sliceStats->sliceRecord[sliceRecord].ThpUl);
2171 sendSliceMetric((SliceMetricList*) sliceStats);
2175 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2176 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2181 /**********************************************************************
2183 **********************************************************************/