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 "ConfigInterface.h"
47 /*TODO: Uncomment when PM O1 gerrit gets ready*/
49 #include "PmInterface.h"
55 uint8_t numRlcDlSaps = 0;
57 uint8_t numRlcMacSaps = 0;
59 uint8_t macCfgInst = 0;
61 DuCfgParams duCfgParam;
62 uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg);
63 uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg);
64 uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
65 uint8_t BuildAndSendE2SetupReq();
66 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg);
67 uint8_t BuildAndSendDUConfigUpdate();
68 uint16_t getTransId();
69 uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
70 uint8_t sendCellDeleteReqToMac(uint16_t cellId);
72 packMacCellCfgReq packMacCellCfgOpts[] =
74 packMacCellCfg, /* packing for loosely coupled */
75 MacProcCellCfgReq, /* packing for tightly coupled */
76 packMacCellCfg, /* packing for light weight loosly coupled */
79 DuMacCellStart packMacCellStartOpts[] =
81 packMacCellStart, /* Loose coupling */
82 MacProcCellStart, /* TIght coupling */
83 packMacCellStart /* Light weight-loose coupling */
86 DuMacCellStop packMacCellStopOpts[] =
88 packMacCellStop, /* Loose coupling */
89 MacProcCellStop, /* TIght coupling */
90 packMacCellStop /* Light weight-loose coupling */
93 DuMacSliceCfgReq packMacSliceCfgReqOpts[] =
95 packDuMacSliceCfgReq, /* Loose coupling */
96 MacProcSliceCfgReq, /* TIght coupling */
97 packDuMacSliceCfgReq /* Light weight-loose coupling */
101 DuMacSliceRecfgReq packMacSliceReCfgReqOpts[] =
103 packDuMacSliceRecfgReq, /* Loose coupling */
104 MacProcSliceReCfgReq, /* TIght coupling */
105 packDuMacSliceRecfgReq /* Light weight-loose coupling */
107 /**************************************************************************
108 * @brief Function to fill configs required by RLC
112 * Function : duBuildRlcCfg
115 * Initiates general Configs towards RLC
117 * @param[in] Inst Specifies if RLC UL or RLC DL instance
118 * @return ROK - success
121 ***************************************************************************/
122 uint8_t duBuildRlcCfg(Inst inst)
125 RlcGenCfg *genCfg = NULLP;
128 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
129 DU_SET_ZERO(&pst, sizeof(Pst));
131 genCfg = &(rlcMngmt.t.cfg.s.gen);
133 /*----------- Fill General Configuration Parameters ---------*/
134 genCfg->maxUe = duCfgParam.maxUe;
135 genCfg->maxKwuSaps = 2;
136 genCfg->maxUdxSaps = 1;
137 genCfg->rlcMode = (inst == RLC_UL_INST) ?
138 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
140 genCfg->maxRguSaps = DEFAULT_CELLS;
142 /*----------- Fill lmPst
143 * Parameters ---------*/
144 genCfg->lmPst.dstProcId = DU_PROC;
145 genCfg->lmPst.srcProcId = DU_PROC;
146 genCfg->lmPst.dstEnt = ENTDUAPP;
147 genCfg->lmPst.dstInst = DU_INST;
148 genCfg->lmPst.srcEnt = ENTRLC;
149 genCfg->lmPst.srcInst = inst;
150 genCfg->lmPst.prior = PRIOR0;
151 genCfg->lmPst.route = RTESPEC;
152 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
153 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
154 genCfg->lmPst.pool = RLC_POOL;
155 genCfg->lmPst.selector = ODU_SELECTOR_LC;
158 rlcMngmt.hdr.msgType = TCFG;
159 rlcMngmt.hdr.msgLen = 0;
160 rlcMngmt.hdr.entId.ent = ENTRLC;
161 rlcMngmt.hdr.entId.inst = (Inst)0;
162 rlcMngmt.hdr.elmId.elmnt = STGEN;
163 rlcMngmt.hdr.seqNmb = 0;
164 rlcMngmt.hdr.version = 0;
165 rlcMngmt.hdr.transId = 0;
166 rlcMngmt.hdr.response.prior = PRIOR0;
167 rlcMngmt.hdr.response.route = RTESPEC;
168 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
169 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
170 rlcMngmt.hdr.response.mem.pool = DU_POOL;
171 rlcMngmt.hdr.response.selector = ODU_SELECTOR_LC;
174 pst.selector = ODU_SELECTOR_LC;
175 pst.srcEnt = ENTDUAPP;
178 pst.dstProcId = DU_PROC;
179 pst.srcProcId = DU_PROC;
180 pst.region = duCb.init.region;
182 DU_LOG("\nDEBUG --> DU_APP : RLC Gen Cfg Req sent for inst %d", inst);
184 /* Send the request to RLC */
185 packRlcConfigReq(&pst, &rlcMngmt);
190 /**************************************************************************
191 * @brief Function to fill configs required by RLC
195 * Function : duBuildRlcLsapCfg
198 * Initiates general Configs towards RLC
200 * @param[in] Inst Specifies if RLC UL or RLC DL instance
201 * @return ROK - success
204 ***************************************************************************/
205 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst)
209 RlcSapCfg *lSap = NULLP;
212 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
213 DU_SET_ZERO(&pst, sizeof(Pst));
216 rlcMngmt.hdr.msgType = TCFG;
217 rlcMngmt.hdr.entId.ent = ENTRLC;
218 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
219 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
221 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
224 pst.selector = ODU_SELECTOR_LC;
225 pst.srcEnt = ENTDUAPP;
227 pst.dstProcId = DU_PROC;
229 pst.srcProcId = DU_PROC;
230 pst.region = duCb.init.region;
231 lSap = &(rlcMngmt.t.cfg.s.sap);
233 lSap->mem.region = (inst == RLC_UL_INST) ?
234 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
235 lSap->mem.pool = RLC_POOL;
237 lSap->bndTmrIntvl = 10;
238 lSap->priority = PRIOR0;
239 lSap->route = RTESPEC;
242 lSap->procId = DU_PROC;
244 lSap->inst = lsapInst;
245 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
246 lSap->selector = (inst == RLC_UL_INST) ? ODU_SELECTOR_LWLC : ODU_SELECTOR_TC;
247 rlcMngmt.hdr.elmId.elmnt = STRGUSAP;
248 DU_LOG("\nDEBUG --> DU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
253 lSap->procId = DU_PROC;
255 lSap->inst = (inst == RLC_UL_INST) ?
256 RLC_DL_INST : RLC_UL_INST;
258 lSap->selector = ODU_SELECTOR_LC;
259 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
260 DU_LOG("\nDEBUG --> DU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
263 packRlcConfigReq(&pst, &rlcMngmt);
267 /**************************************************************************
268 * @brief Function to fill configs required by RLC
272 * Function : duBuildRlcUsapCfg
275 * Initiates general Configs towards RLC
277 * @param[in] Inst Specifies if RLC UL or RLC DL instance
278 * @return ROK - success
281 ***************************************************************************/
282 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
285 RlcSapCfg *uSap = NULLP;
288 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
289 DU_SET_ZERO(&pst, sizeof(Pst));
291 uSap = &(rlcMngmt.t.cfg.s.sap);
293 uSap->selector = ODU_SELECTOR_LC;
294 uSap->mem.region = (inst == RLC_UL_INST) ?
295 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
296 uSap->mem.pool = RLC_POOL;
299 uSap->procId = DU_PROC;
303 uSap->inst = (inst == RLC_UL_INST) ?
304 RLC_DL_INST : RLC_UL_INST;
305 uSap->bndTmrIntvl = 1000;
306 uSap->priority = PRIOR0;
307 uSap->route = RTESPEC;
310 rlcMngmt.hdr.msgType = TCFG;
311 rlcMngmt.hdr.entId.ent = ENTRLC;
312 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
313 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
314 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
316 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
319 pst.selector = ODU_SELECTOR_LC;
320 pst.srcEnt = ENTDUAPP;
322 pst.dstProcId = DU_PROC;
324 pst.srcProcId = DU_PROC;
325 pst.region = duCb.init.region;
327 DU_LOG("\nDEBUG --> DU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
328 packRlcConfigReq(&pst, &rlcMngmt);
333 /**************************************************************************
334 * @brief Function to populate internal DS of DU APP
338 * Function : duProcCfgComplete
341 * Populates internal data structures of DU APP after
342 * receiving configurations.
345 * @return ROK - success
348 ***************************************************************************/
349 uint8_t duProcCfgComplete()
354 for(idx=0; idx< DEFAULT_CELLS; idx++)
356 DuCellCb *cell = NULLP;
357 DU_ALLOC(cell, sizeof(DuCellCb));
360 DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete");
366 memset(cell, 0, sizeof(DuCellCb));
367 cell->cellId = ++cellId;
368 memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
369 cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0;
370 cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1;
371 cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2;
372 cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0;
373 cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1;
374 cell->cellInfo.nrEcgi.cellId = cell->cellId;
375 cell->cellInfo.nrPci = NR_PCI;
376 cell->cellInfo.fiveGsTac = DU_TAC;
377 memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn));
378 for(idx1=0; idx1<MAX_PLMN; idx1++)
380 cell->cellInfo.plmn[idx1].mcc[0] = PLMN_MCC0;
381 cell->cellInfo.plmn[idx1].mcc[1] = PLMN_MCC1;
382 cell->cellInfo.plmn[idx1].mcc[2] = PLMN_MCC2;
383 cell->cellInfo.plmn[idx1].mnc[0] = PLMN_MNC0;
384 cell->cellInfo.plmn[idx1].mnc[1] = PLMN_MNC1;
386 cell->cellInfo.maxUe = duCfgParam.maxUe;
387 cell->cellStatus = CELL_OUT_OF_SERVICE;
388 gCellStatus = CELL_DOWN;
389 cell->gnbDuUeF1apIdGenerator = 0;
390 duCb.cfgCellLst[duCb.numCfgCells] = cell;
396 //Start layer configs
397 ret = duSendRlcUlCfg();
401 /**************************************************************************
402 * @brief Function to invoke DU Layer Configs
406 * Function : duSendRlcUlCfg
409 * Initiates Configs towards layers of DU
412 * @return ROK - success
415 ***************************************************************************/
416 uint8_t duSendRlcUlCfg()
420 duBuildRlcCfg((Inst)RLC_UL_INST);
421 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
423 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
425 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
430 /**************************************************************************
431 * @brief Function to invoke DU Layer Configs
435 * Function : duSendRlcDlCfg
438 * Initiates Configs towards layers of DU
441 * @return ROK - success
444 ***************************************************************************/
445 uint8_t duSendRlcDlCfg()
449 duBuildRlcCfg((Inst)RLC_DL_INST);
450 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
451 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
453 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
458 /**************************************************************************
459 * @brief Function to handle Config Confirm from RLC
463 * Function : DuHdlRlcCfgComplete
466 * Handles Gen Config Confirm from RLC
468 * @param[in] Pst *pst, Post structure of the primitive.
469 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
470 * @return ROK - success
473 ***************************************************************************/
474 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
477 if (pst->srcInst == RLC_UL_INST)
479 ret = duProcRlcUlCfgComplete(pst, cfm);
483 ret = duProcRlcDlCfgComplete(pst, cfm);
488 /**************************************************************************
489 * @brief Function to handle Control Config Confirm from RLC
493 * Function : duHdlRlcCntrlCfgComplete
496 * Handles Control Config Confirm from RLC
498 * @param[in] Pst *pst, Post structure of the primitive.
499 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
500 * @return ROK - success
503 ***************************************************************************/
504 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
508 if (cntrl->cfm.status == LCM_PRIM_OK)
510 switch (cntrl->hdr.elmId.elmnt)
514 if (pst->srcInst == RLC_DL_INST)
516 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
518 if(macCfgInst < DEFAULT_CELLS)
521 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
525 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
530 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
532 if(macCfgInst < DEFAULT_CELLS)
534 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
548 /**************************************************************************
549 * @brief Function to handle Config Confirm from RLC UL
553 * Function : duHdlRlcUlCfgComplete
556 * Handles Config Confirm from RLC UL
558 * @param[in] Pst *pst, Post structure of the primitive.
559 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
560 * @return ROK - success
563 ***************************************************************************/
564 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
568 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
569 if (cfm->cfm.status == LCM_PRIM_OK)
571 switch(cfm->hdr.elmId.elmnt)
575 rlcUlCfg |= RLC_GEN_CFG;
581 if(numRlcMacSaps == DEFAULT_CELLS)
583 rlcUlCfg |= RLC_MAC_SAP_CFG;
590 rlcUlCfg |= RLC_UDX_SAP_CFG;
597 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
598 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
602 //Start configuration of RLC DL
609 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
615 /**************************************************************************
616 * @brief Function to handle Config Confirm from RLC DL
620 * Function : duHdlRlcDlCfgComplete
623 * Handles Config Confirm from RLC DL
625 * @param[in] Pst *pst, Post structure of the primitive.
626 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
627 * @return ROK - success
630 ***************************************************************************/
631 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
633 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
634 if (cfm->cfm.status == LCM_PRIM_OK)
636 switch(cfm->hdr.elmId.elmnt)
640 rlcDlCfg |= RLC_GEN_CFG;
646 if(numRlcMacSaps == DEFAULT_CELLS)
648 rlcDlCfg |= RLC_MAC_SAP_CFG;
655 rlcDlCfg |= RLC_UDX_SAP_CFG;
663 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
664 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
667 //Start configuration of MAC
674 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
679 /**************************************************************************
680 * @brief Function to send configs to MAC
684 * Function : duSendMacCfg
687 * Initiates Configs towards MAC layer
690 * @return ROK - success
693 ***************************************************************************/
694 uint8_t duSendMacCfg()
697 duBuildMacUsapCfg(RLC_UL_INST);
698 duBuildMacUsapCfg(RLC_DL_INST);
703 /**************************************************************************
704 * @brief Function to fill gen config required by MAC
708 * Function : duBuildMacGenCfg
711 * Initiates general Configs towards MAC
714 * @return ROK - success
717 ***************************************************************************/
718 uint8_t duBuildMacGenCfg()
721 RgGenCfg *genCfg=NULLP;
724 DU_SET_ZERO(&pst, sizeof(Pst));
725 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
727 genCfg = &(rgMngmt.t.cfg.s.genCfg);
729 /*----------- Fill General Configuration Parameters ---------*/
730 genCfg->mem.region = MAC_MEM_REGION;
731 genCfg->mem.pool = MAC_POOL;
733 genCfg->numRguSaps = 2;
735 genCfg->lmPst.dstProcId = DU_PROC;
736 genCfg->lmPst.srcProcId = DU_PROC;
737 genCfg->lmPst.dstEnt = ENTDUAPP;
738 genCfg->lmPst.dstInst = 0;
739 genCfg->lmPst.srcEnt = ENTMAC;
740 genCfg->lmPst.srcInst = macCfgInst;
741 genCfg->lmPst.prior = PRIOR0;
742 genCfg->lmPst.route = RTESPEC;
743 genCfg->lmPst.region = MAC_MEM_REGION;
744 genCfg->lmPst.pool = MAC_POOL;
745 genCfg->lmPst.selector = ODU_SELECTOR_LC;
748 rgMngmt.hdr.msgType = TCFG;
749 rgMngmt.hdr.msgLen = 0;
750 rgMngmt.hdr.entId.ent = ENTMAC;
751 rgMngmt.hdr.entId.inst = (Inst)0;
752 rgMngmt.hdr.elmId.elmnt = STGEN;
753 rgMngmt.hdr.seqNmb = 0;
754 rgMngmt.hdr.version = 0;
755 rgMngmt.hdr.transId = 0;
757 rgMngmt.hdr.response.prior = PRIOR0;
758 rgMngmt.hdr.response.route = RTESPEC;
759 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
760 rgMngmt.hdr.response.mem.pool = MAC_POOL;
761 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
764 pst.selector = ODU_SELECTOR_LC;
765 pst.srcEnt = ENTDUAPP;
767 pst.dstInst = macCfgInst;
768 pst.dstProcId = DU_PROC;
769 pst.srcProcId = DU_PROC;
770 pst.region = duCb.init.region;
772 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
774 /* Send the request to MAC */
775 cmPkLrgCfgReq(&pst, &rgMngmt);
780 /**************************************************************************
781 * @brief Function to fill USAP config required by MAC
785 * Function : duBuildMacUsapCfg
788 * Initiates USAP Configs towards MAC
790 * @param[in] SpId Specifies if RLC UL or RLC DL instance
791 * @return ROK - success
794 ***************************************************************************/
795 uint8_t duBuildMacUsapCfg(SpId sapId)
798 RgUpSapCfg *uSap = NULLP;
801 DU_SET_ZERO(&pst, sizeof(Pst));
802 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
804 uSap = &(rgMngmt.t.cfg.s.rguSap);
806 uSap->mem.region = MAC_MEM_REGION;
807 uSap->mem.pool = MAC_POOL;
810 uSap->procId = DU_PROC;
813 uSap->prior = PRIOR0;
814 uSap->route = RTESPEC;
815 uSap->selector = ODU_SELECTOR_LC ;
818 rgMngmt.hdr.msgType = TCFG;
819 rgMngmt.hdr.entId.ent = ENTMAC;
820 rgMngmt.hdr.entId.inst = (Inst)0;
821 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
822 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
823 rgMngmt.hdr.response.mem.pool = MAC_POOL;
826 pst.selector = ODU_SELECTOR_LC;
827 pst.srcEnt = ENTDUAPP;
829 pst.dstInst = macCfgInst;
830 pst.dstProcId = DU_PROC;
831 pst.srcProcId = DU_PROC;
832 pst.region = duCb.init.region;
834 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
836 /* Send the request to MAC */
837 cmPkLrgCfgReq(&pst, &rgMngmt);
842 /**************************************************************************
843 * @brief Function to handle Config Confirm from MAC
847 * Function : duHdlMacCfgComplete
850 * Handles Gen Config Confirm from MAC
852 * @param[in] Pst *pst, Post structure of the primitive.
853 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
854 * @return ROK - success
857 ***************************************************************************/
858 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
862 if (cfm->cfm.status == LCM_PRIM_OK)
864 switch (cfm->hdr.elmId.elmnt)
868 macCfg |= MAC_GEN_CFG;
873 macCfg |= MAC_SAP_CFG;
880 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
881 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
884 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
886 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
892 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
898 /**************************************************************************
899 * @brief Function to bind/unbind RLC to MAC SAP
903 * Function : duBindUnbindRlcToMacSap
906 * Initiates Bind/Unbind from RLC to MAC
908 * @param[in] Inst Specifies if RLC UL or RLC DL instance
909 * @param[in] action Specifies if action is bind or unbind
910 * @return ROK - success
913 ***************************************************************************/
914 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
916 RlcCntrl *cntrl = NULLP;
921 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
922 DU_SET_ZERO(&pst, sizeof(Pst));
926 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
930 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
932 cntrl = &(rlcMngmt.t.cntrl);
934 cntrl->action = action;
935 cntrl->subAction = DU_ZERO_VAL;
936 cntrl->s.sapCntrl.suId = macCfgInst;
937 cntrl->s.sapCntrl.spId = inst;
940 rlcMngmt.hdr.msgType = TCNTRL;
941 rlcMngmt.hdr.entId.ent = ENTRLC;
942 rlcMngmt.hdr.entId.inst = inst;
943 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
944 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
945 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
946 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
949 pst.selector = ODU_SELECTOR_LC;
950 pst.srcEnt = ENTDUAPP;
952 pst.dstProcId = DU_PROC;
954 pst.srcProcId = DU_PROC;
955 pst.region = duCb.init.region;
957 cmPkLkwCntrlReq(&pst, &rlcMngmt);
961 /*******************************************************************
963 * @brief Handles SCTP notifications
967 * Function : duSctpNtfyHdl
970 * Handles SCTP notification
972 * @params[in] Message Buffer
975 * @return ROK - success
978 * ****************************************************************/
980 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
982 if(f1Params.assocId == ntfy->u.assocChange.assocId)
984 if(BuildAndSendF1SetupReq() != ROK)
989 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
991 if(BuildAndSendE2SetupReq() != ROK)
998 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
1004 /*******************************************************************
1006 * @brief Fills Pst struct for ENTEGTP
1010 * Function : duFillEgtpPst
1013 * Fills Pst struct for ENTEGTP
1016 * @return ROK - success
1019 * ****************************************************************/
1020 uint8_t duFillEgtpPst(Pst *pst, Event event)
1022 memset(pst, 0, sizeof(Pst));
1023 pst->srcEnt = (Ent)ENTDUAPP;
1024 pst->srcInst = (Inst)DU_INST;
1025 pst->srcProcId = DU_PROC;
1026 pst->dstEnt = (Ent)ENTEGTP;
1027 pst->dstInst = (Inst)EGTP_INST;
1028 pst->dstProcId = pst->srcProcId;
1030 pst->selector = ODU_SELECTOR_LC;
1037 /*******************************************************************
1039 * @brief Function to configure EGTP
1043 * Function : duBuildEgtpCfgReq
1046 * Function to configure EGTP
1049 * @return ROK - success
1052 * ****************************************************************/
1054 uint8_t duBuildEgtpCfgReq()
1059 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1061 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1062 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1064 duFillEgtpPst(&pst, EVTCFGREQ);
1065 packEgtpCfgReq(&pst, egtpCfg);
1070 /*******************************************************************
1072 * @brief Function to configure EGTP
1076 * Function : duBuildEgtpCfgReq
1079 * Function to configure EGTP
1082 * @return ROK - success
1085 * ****************************************************************/
1086 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1090 if(cfm.status == LCM_PRIM_OK)
1092 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1093 duSendEgtpSrvOpenReq();
1097 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1104 /*******************************************************************
1106 * @brief Sends server open request to EGTP
1110 * Function : duSendEgtpSrvOpenReq
1113 * Sends server open request to EGTP
1116 * @return ROK - success
1119 * ****************************************************************/
1121 uint8_t duSendEgtpSrvOpenReq()
1125 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1127 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1128 packEgtpSrvOpenReq(&pst);
1133 /*******************************************************************
1135 * @brief Handles server open confirmation
1139 * Function : duHdlEgtpSrvOpenComplete
1142 * Handles server open confirmation
1145 * @return ROK - success
1148 *****************************************************************/
1150 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1154 if(cfm.status == LCM_PRIM_OK)
1156 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1160 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1167 /*******************************************************************
1169 * @brief Sends tunnel management request
1173 * Function : duSendEgtpTnlMgmtReq
1176 * Builds and sends tunnel management request to EGTP
1178 * @params[in] Action
1179 * Local tunnel endpoint id
1180 * Remote tunnel endpoint id
1181 * @return ROK - success
1184 * ****************************************************************/
1186 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1192 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1194 /* ADD/MOD/DEL per tunnel */
1195 tnlEvt.action = action;
1196 tnlEvt.remTeid = ueCbTnlCfg->teId;
1197 if(action != EGTP_TNL_MGMT_ADD)
1199 tnlEvt.lclTeid = teIdTobeMod;
1203 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1205 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1206 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1210 /*******************************************************************
1212 * @brief Handles Tunnel management confirm
1216 * Function : duHdlEgtpTnlMgmtCfm
1219 * Handles tunnel management confirm received from Egtp
1221 * @params[in] Tunnel Event
1222 * @return ROK - success
1225 * ****************************************************************/
1226 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1230 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1232 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1236 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1243 /*******************************************************************
1245 * @brief Sends UL user data over to EGTP
1249 * Function : duSendEgtpDatInd
1251 * Functionality: Sends UL user data over to EGTP
1253 * @params[in] UL data buffer
1254 * @return ROK - success
1257 * ****************************************************************/
1258 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1262 /* Fill EGTP header */
1263 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1264 egtpMsg.msgHdr.nPdu.pres = FALSE;
1265 egtpMsg.msgHdr.seqNum.pres = FALSE;
1266 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1267 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1268 egtpMsg.msgHdr.teId = 1;
1271 egtpHdlDatInd(egtpMsg);
1277 /**************************************************************************
1278 * @brief Function to send configs to SCH
1282 * Function : duSendSchCfg
1285 * Sends general config to Scheduler via MAC layer
1288 * @return ROK - success
1291 ***************************************************************************/
1292 uint8_t duSendSchCfg()
1295 RgSchInstCfg *cfg = NULLP;
1298 DU_SET_ZERO(&pst, sizeof(Pst));
1299 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1301 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1303 /* Filling of Instance Id */
1304 cfg->instId = DEFAULT_CELLS + 1;
1305 /* Filling of Gen config */
1306 cfg->genCfg.mem.region = MAC_MEM_REGION;
1307 cfg->genCfg.mem.pool = MAC_POOL;
1308 cfg->genCfg.tmrRes = 10;
1311 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1312 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1314 cfg->genCfg.startCellId = 1;
1315 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1316 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1317 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1318 cfg->genCfg.lmPst.dstInst = DU_INST;
1319 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1320 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1321 cfg->genCfg.lmPst.prior = PRIOR0;
1322 cfg->genCfg.lmPst.route = RTESPEC;
1323 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1324 cfg->genCfg.lmPst.pool = MAC_POOL;
1325 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1328 rgMngmt.hdr.msgType = TCFG;
1329 rgMngmt.hdr.entId.ent = ENTMAC;
1330 rgMngmt.hdr.entId.inst = DU_INST;
1331 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1332 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1333 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1336 pst.selector = ODU_SELECTOR_LC;
1337 pst.srcEnt = ENTDUAPP;
1338 pst.dstEnt = ENTMAC;
1339 pst.dstProcId = DU_PROC;
1340 pst.srcProcId = DU_PROC;
1341 pst.srcInst = DU_INST;
1343 pst.region = duCb.init.region;
1344 pst.event = (Event) EVTMACSCHGENCFGREQ;
1346 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1348 /* Send the request to MAC */
1349 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1355 /**************************************************************************
1356 * @brief Function to configure SCTP params and
1357 * responsible for F1 and E2 interfaces
1361 * Function : duLayerConfigComplete
1364 * Configures SCTP Params and responsible for handling
1365 * F1 and E2 interface.
1368 * @return ROK - success
1371 ***************************************************************************/
1372 uint8_t duLayerConfigComplete()
1376 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1378 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1380 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1383 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1385 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1388 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1390 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1397 /**************************************************************************
1398 * @brief Function to handle SCH Config Confirm from MAC
1402 * Function : duHdlSchCfgComplete
1405 * Handles Scheduler Gen Config Confirm from MAC
1407 * @param[in] Pst *pst, Post structure of the primitive.
1408 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1409 * @return ROK - success
1412 ***************************************************************************/
1413 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1415 if (cfm->cfm.status == LCM_PRIM_OK)
1417 switch (cfm->hdr.elmId.elmnt)
1421 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1428 duLayerConfigComplete();
1429 duBuildEgtpCfgReq();
1433 /**************************************************************************
1434 * @brief Function to fill and send MacCellconfig
1438 * Function : duBuildAndSendMacCellCfg
1441 * Initiates MAC Configs towards MAC
1444 * @return ROK - success
1447 ***************************************************************************/
1448 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1451 MacCellCfg *duMacCellCfg = NULLP;
1453 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1454 if(duMacCellCfg == NULLP)
1459 /* store the address in the duCellCb so that we can free on confirm msg */
1460 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1462 /* copy the mac config structure from duCfgParams */
1463 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1466 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1468 /* Send MAC cell config to MAC */
1469 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1472 /**************************************************************************
1473 * @brief Function to Handle MAC cell config confirm
1477 * Function : duHandleMacCellCfgCfm
1480 * Initiates general Configs towards MAC
1483 * @return ROK - success
1486 ***************************************************************************/
1487 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1489 uint8_t actvCellIdx = 0;
1492 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1494 if(macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId)
1496 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1499 if(macCellCfgCfm->rsp == ROK)
1501 /* Build and send GNB-DU config update */
1502 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1504 /* Build and Send Cell Start Req to MAC */
1505 ret = duBuildAndSendMacCellStart();
1509 /* TODO : Action to be taken if cell configuration fails.
1510 * Should CU be informed? */
1512 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1518 /*******************************************************************
1520 * @brief Builds and sends cell start request to MAC
1524 * Function : duBuildAndSendMacCellStart
1527 * Builds and sends cell start request to MAC
1530 * @return ROK - success
1533 * ****************************************************************/
1534 uint8_t duBuildAndSendMacCellStart()
1537 OduCellId *cellId = NULL;
1539 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1541 /* Send Cell Start Request to MAC */
1542 DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId));
1545 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1549 for(uint8_t id = 0; id < duCb.numActvCells; id++)
1551 if(duCb.actvCellLst[id])
1553 cellId->cellId = duCb.actvCellLst[id]->cellId;
1556 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1558 return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
1564 /*******************************************************************
1566 * @brief Builds and sends cell stop request to MAC
1570 * Function : duBuildAndSendMacCellStop
1573 * Builds and sends cell stop request to MAC
1576 * @return ROK - success
1579 * ****************************************************************/
1580 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1584 OduCellId *oduCellId = NULL;
1586 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1588 GET_CELL_IDX(cellId, cellIdx);
1589 if(duCb.actvCellLst[cellIdx] != NULLP)
1591 /* Send Cell Stop Request to MAC */
1592 DU_ALLOC_SHRABL_BUF(oduCellId, sizeof(OduCellId));
1595 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): Memory allocation failed ");
1598 memset(oduCellId, 0, sizeof(OduCellId));
1599 oduCellId->cellId = duCb.actvCellLst[cellIdx]->cellId;
1602 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1604 return (*packMacCellStopOpts[pst.selector])(&pst, oduCellId);
1608 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1614 /*******************************************************************
1616 * @brief Handles stop indication from MAC
1620 * Function : duHandleStopInd
1623 * Handles stop indication from MAC
1625 * @params[in] Post structure pointer
1626 * @return ROK - success
1629 * ****************************************************************/
1630 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1632 DuCellCb *cellCb = NULLP;
1634 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1636 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1639 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1642 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1644 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1645 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1647 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1648 cellId[%d]", cellId->cellId);
1654 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1655 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1656 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1660 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1661 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1663 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1669 /*******************************************************************
1671 * @brief Handles slot indication from MAC
1675 * Function : duHandleUlCcchInd
1678 * Handles UL CCCH indication from MAC
1680 * @params[in] Post structure pointer
1681 * UL CCCH Ind pointer
1682 * @return ROK - success
1685 * ****************************************************************/
1686 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1689 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1691 return (duProcUlCcchInd(ulCcchIndInfo));
1694 /*******************************************************************
1696 * @brief Process UL RRC Message from RLC
1700 * Function : DuProcRlcUlRrcMsgTrans
1702 * Functionality: Process UL RRC Message from RLC
1704 * @params[in] Post structure
1705 * UL RRC Message Info
1706 * @return ROK - success
1709 * ****************************************************************/
1710 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1712 DuCellCb *cellCb = NULLP;
1715 if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK)
1717 if(ulRrcMsgInfo->ueIdx > 0)
1719 ueCb = cellCb->ueCb[ulRrcMsgInfo->ueIdx -1];
1722 BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, \
1723 ulRrcMsgInfo->rrcMsg);
1725 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1726 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1731 /*******************************************************************
1733 * @brief Process RRC delivery report from RLC
1737 * Function : DuProcRlcRrcDeliveryReport
1739 * Functionality: Process RRC delivery Message from RLC
1741 * @params[in] Post structure
1742 * UL RRC Message Info
1743 * @return ROK - success
1746 * ****************************************************************/
1747 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1749 DuCellCb *cellCb = NULLP;
1751 uint8_t ret = RFAILED;
1753 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1756 ueCb = cellCb->ueCb[rrcDeliveryReport->ueIdx -1];
1757 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1759 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1763 /*******************************************************************
1765 * @brief Process UL user data from RLC
1769 * Function : DuProcRlcUlUserDataTrans
1771 * Functionality: Process UL user data from RLC
1773 * @params[in] Post structure
1775 * @return ROK - success
1778 * ****************************************************************/
1779 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1785 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1787 /* Fill EGTP header */
1788 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1789 egtpMsg.msgHdr.nPdu.pres = FALSE;
1790 egtpMsg.msgHdr.seqNum.pres = FALSE;
1791 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1792 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1794 /* Fetch EGTP tunnel info */
1795 for(rbIdx = 0; rbIdx < duCb.numDrb; rbIdx++)
1797 if((duCb.upTnlCfg[rbIdx] != NULLP) && (duCb.upTnlCfg[rbIdx]->ueIdx == ulUserData->ueIdx) && \
1798 (duCb.upTnlCfg[rbIdx]->drbId == ulUserData->rbId))
1800 if(duCb.upTnlCfg[rbIdx]->tnlCfg1)
1802 egtpMsg.msgHdr.teId = duCb.upTnlCfg[rbIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1808 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1810 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1811 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1812 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1815 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1816 ODU_PRINT_MSG(mBuf, 0, 0);
1818 egtpHdlDatInd(egtpMsg);
1820 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1821 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1825 /*******************************************************************
1827 * @brief Free tempSLiceCfg stored in duCfgParams
1831 * Function : duFreeTempSliceCfg
1833 * Functionality: Free tempSLiceCfg stored in duCfgParams
1835 * @params[in] Post structure,
1839 * ****************************************************************/
1841 void duFreeTempSliceCfg()
1843 uint8_t policyIdx = 0, memberListTdx =0;
1844 CopyOfRecvdSliceCfg *tempSliceCfg = &duCfgParam.tempSliceCfg;
1846 if(tempSliceCfg->totalRrmPolicy)
1848 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1850 if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList)
1852 for(memberListTdx = 0; memberListTdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListTdx++)
1854 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListTdx], sizeof(PolicyMemberList));
1856 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList, (tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) * sizeof(PolicyMemberList*));
1858 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1860 DU_FREE(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy* sizeof(RrmPolicy*));
1862 memset(tempSliceCfg, 0, sizeof(CopyOfRecvdSliceCfg));
1865 /*******************************************************************
1867 * @brief free the slice cfg rsp
1871 * Function : duFreeSliceCfgRsp
1873 * Functionality: free the slice cfg rsp
1875 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1877 * @return ROK - success
1880 **********************************************************************/
1881 void duFreeSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1887 if(cfgRsp->numSliceCfgRsp)
1889 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1891 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(MacSliceRsp));
1893 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp, cfgRsp->numSliceCfgRsp * sizeof(MacSliceRsp*));
1895 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1900 /*******************************************************************
1902 * @brief process the slice cfg rsp received from MAC
1906 * Function : DuProcMacSliceCfgRsp
1908 * Functionality: process the slice cfg rsp received from MAC
1910 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1912 * @return ROK - success
1915 **********************************************************************/
1916 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1922 if(cfgRsp->listOfSliceCfgRsp)
1924 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1926 if(cfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
1928 duCb.sliceState = SLICE_CONFIGURED;
1931 DU_LOG("\nINFO --> DU_APP : Slice Configuration is done sucessfully ");
1933 duFreeSliceCfgRsp(pst, cfgRsp);
1935 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);
2175 /*TODO: Uncomment when PM O1 gerrit gets ready*/
2180 sendSliceMetric(sliceStats);
2185 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2186 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2191 /**********************************************************************
2193 **********************************************************************/