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()
348 for(idx=0; idx< DEFAULT_CELLS; idx++)
350 DuCellCb *cell = NULLP;
351 DU_ALLOC(cell, sizeof(DuCellCb));
354 DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete");
360 memset(cell, 0, sizeof(DuCellCb));
361 cell->cellId = NR_CELL_ID; //++cellId;
362 memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
363 cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
364 cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
365 cell->cellInfo.nrEcgi.plmn.mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
366 cell->cellInfo.nrEcgi.plmn.mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
367 cell->cellInfo.nrEcgi.plmn.mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
368 cell->cellInfo.nrEcgi.plmn.mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
369 cell->cellInfo.nrEcgi.cellId = cell->cellId;
370 cell->cellInfo.nrPci = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
371 cell->cellInfo.fiveGsTac = duCfgParam.srvdCellLst[0].duCellInfo.tac;
372 memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn));
373 for(idx1=0; idx1<MAX_PLMN; idx1++)
375 cell->cellInfo.plmn[idx1].mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
376 cell->cellInfo.plmn[idx1].mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
377 cell->cellInfo.plmn[idx1].mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
378 cell->cellInfo.plmn[idx1].mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
379 cell->cellInfo.plmn[idx1].mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
380 cell->cellInfo.plmn[idx1].mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
382 cell->cellInfo.maxUe = duCfgParam.maxUe;
383 cell->cellStatus = CELL_OUT_OF_SERVICE;
384 gCellStatus = CELL_DOWN;
385 duCb.cfgCellLst[duCb.numCfgCells] = cell;
391 //Start layer configs
392 ret = duSendRlcUlCfg();
396 /**************************************************************************
397 * @brief Function to invoke DU Layer Configs
401 * Function : duSendRlcUlCfg
404 * Initiates Configs towards layers of DU
407 * @return ROK - success
410 ***************************************************************************/
411 uint8_t duSendRlcUlCfg()
415 duBuildRlcCfg((Inst)RLC_UL_INST);
416 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
418 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
420 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
425 /**************************************************************************
426 * @brief Function to invoke DU Layer Configs
430 * Function : duSendRlcDlCfg
433 * Initiates Configs towards layers of DU
436 * @return ROK - success
439 ***************************************************************************/
440 uint8_t duSendRlcDlCfg()
444 duBuildRlcCfg((Inst)RLC_DL_INST);
445 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
446 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
448 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
453 /**************************************************************************
454 * @brief Function to handle Config Confirm from RLC
458 * Function : DuHdlRlcCfgComplete
461 * Handles Gen Config Confirm from RLC
463 * @param[in] Pst *pst, Post structure of the primitive.
464 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
465 * @return ROK - success
468 ***************************************************************************/
469 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
472 if (pst->srcInst == RLC_UL_INST)
474 ret = duProcRlcUlCfgComplete(pst, cfm);
478 ret = duProcRlcDlCfgComplete(pst, cfm);
483 /**************************************************************************
484 * @brief Function to handle Control Config Confirm from RLC
488 * Function : duHdlRlcCntrlCfgComplete
491 * Handles Control Config Confirm from RLC
493 * @param[in] Pst *pst, Post structure of the primitive.
494 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
495 * @return ROK - success
498 ***************************************************************************/
499 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
503 if (cntrl->cfm.status == LCM_PRIM_OK)
505 switch (cntrl->hdr.elmId.elmnt)
509 if (pst->srcInst == RLC_DL_INST)
511 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
513 if(macCfgInst < DEFAULT_CELLS)
516 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
520 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
525 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
527 if(macCfgInst < DEFAULT_CELLS)
529 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
543 /**************************************************************************
544 * @brief Function to handle Config Confirm from RLC UL
548 * Function : duHdlRlcUlCfgComplete
551 * Handles Config Confirm from RLC UL
553 * @param[in] Pst *pst, Post structure of the primitive.
554 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
555 * @return ROK - success
558 ***************************************************************************/
559 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
563 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
564 if (cfm->cfm.status == LCM_PRIM_OK)
566 switch(cfm->hdr.elmId.elmnt)
570 rlcUlCfg |= RLC_GEN_CFG;
576 if(numRlcMacSaps == DEFAULT_CELLS)
578 rlcUlCfg |= RLC_MAC_SAP_CFG;
585 rlcUlCfg |= RLC_UDX_SAP_CFG;
592 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
593 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
597 //Start configuration of RLC DL
604 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
610 /**************************************************************************
611 * @brief Function to handle Config Confirm from RLC DL
615 * Function : duHdlRlcDlCfgComplete
618 * Handles Config Confirm from RLC DL
620 * @param[in] Pst *pst, Post structure of the primitive.
621 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
622 * @return ROK - success
625 ***************************************************************************/
626 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
628 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
629 if (cfm->cfm.status == LCM_PRIM_OK)
631 switch(cfm->hdr.elmId.elmnt)
635 rlcDlCfg |= RLC_GEN_CFG;
641 if(numRlcMacSaps == DEFAULT_CELLS)
643 rlcDlCfg |= RLC_MAC_SAP_CFG;
650 rlcDlCfg |= RLC_UDX_SAP_CFG;
658 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
659 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
662 //Start configuration of MAC
669 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
674 /**************************************************************************
675 * @brief Function to send configs to MAC
679 * Function : duSendMacCfg
682 * Initiates Configs towards MAC layer
685 * @return ROK - success
688 ***************************************************************************/
689 uint8_t duSendMacCfg()
692 duBuildMacUsapCfg(RLC_UL_INST);
693 duBuildMacUsapCfg(RLC_DL_INST);
698 /**************************************************************************
699 * @brief Function to fill gen config required by MAC
703 * Function : duBuildMacGenCfg
706 * Initiates general Configs towards MAC
709 * @return ROK - success
712 ***************************************************************************/
713 uint8_t duBuildMacGenCfg()
716 RgGenCfg *genCfg=NULLP;
719 DU_SET_ZERO(&pst, sizeof(Pst));
720 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
722 genCfg = &(rgMngmt.t.cfg.s.genCfg);
724 /*----------- Fill General Configuration Parameters ---------*/
725 genCfg->mem.region = MAC_MEM_REGION;
726 genCfg->mem.pool = MAC_POOL;
728 genCfg->numRguSaps = 2;
730 genCfg->lmPst.dstProcId = DU_PROC;
731 genCfg->lmPst.srcProcId = DU_PROC;
732 genCfg->lmPst.dstEnt = ENTDUAPP;
733 genCfg->lmPst.dstInst = 0;
734 genCfg->lmPst.srcEnt = ENTMAC;
735 genCfg->lmPst.srcInst = macCfgInst;
736 genCfg->lmPst.prior = PRIOR0;
737 genCfg->lmPst.route = RTESPEC;
738 genCfg->lmPst.region = MAC_MEM_REGION;
739 genCfg->lmPst.pool = MAC_POOL;
740 genCfg->lmPst.selector = ODU_SELECTOR_LC;
743 rgMngmt.hdr.msgType = TCFG;
744 rgMngmt.hdr.msgLen = 0;
745 rgMngmt.hdr.entId.ent = ENTMAC;
746 rgMngmt.hdr.entId.inst = (Inst)0;
747 rgMngmt.hdr.elmId.elmnt = STGEN;
748 rgMngmt.hdr.seqNmb = 0;
749 rgMngmt.hdr.version = 0;
750 rgMngmt.hdr.transId = 0;
752 rgMngmt.hdr.response.prior = PRIOR0;
753 rgMngmt.hdr.response.route = RTESPEC;
754 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
755 rgMngmt.hdr.response.mem.pool = MAC_POOL;
756 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
759 pst.selector = ODU_SELECTOR_LC;
760 pst.srcEnt = ENTDUAPP;
762 pst.dstInst = macCfgInst;
763 pst.dstProcId = DU_PROC;
764 pst.srcProcId = DU_PROC;
765 pst.region = duCb.init.region;
767 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
769 /* Send the request to MAC */
770 cmPkLrgCfgReq(&pst, &rgMngmt);
775 /**************************************************************************
776 * @brief Function to fill USAP config required by MAC
780 * Function : duBuildMacUsapCfg
783 * Initiates USAP Configs towards MAC
785 * @param[in] SpId Specifies if RLC UL or RLC DL instance
786 * @return ROK - success
789 ***************************************************************************/
790 uint8_t duBuildMacUsapCfg(SpId sapId)
793 RgUpSapCfg *uSap = NULLP;
796 DU_SET_ZERO(&pst, sizeof(Pst));
797 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
799 uSap = &(rgMngmt.t.cfg.s.rguSap);
801 uSap->mem.region = MAC_MEM_REGION;
802 uSap->mem.pool = MAC_POOL;
805 uSap->procId = DU_PROC;
808 uSap->prior = PRIOR0;
809 uSap->route = RTESPEC;
810 uSap->selector = ODU_SELECTOR_LC ;
813 rgMngmt.hdr.msgType = TCFG;
814 rgMngmt.hdr.entId.ent = ENTMAC;
815 rgMngmt.hdr.entId.inst = (Inst)0;
816 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
817 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
818 rgMngmt.hdr.response.mem.pool = MAC_POOL;
821 pst.selector = ODU_SELECTOR_LC;
822 pst.srcEnt = ENTDUAPP;
824 pst.dstInst = macCfgInst;
825 pst.dstProcId = DU_PROC;
826 pst.srcProcId = DU_PROC;
827 pst.region = duCb.init.region;
829 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
831 /* Send the request to MAC */
832 cmPkLrgCfgReq(&pst, &rgMngmt);
837 /**************************************************************************
838 * @brief Function to handle Config Confirm from MAC
842 * Function : duHdlMacCfgComplete
845 * Handles Gen Config Confirm from MAC
847 * @param[in] Pst *pst, Post structure of the primitive.
848 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
849 * @return ROK - success
852 ***************************************************************************/
853 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
857 if (cfm->cfm.status == LCM_PRIM_OK)
859 switch (cfm->hdr.elmId.elmnt)
863 macCfg |= MAC_GEN_CFG;
868 macCfg |= MAC_SAP_CFG;
875 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
876 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
879 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
881 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
887 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
893 /**************************************************************************
894 * @brief Function to bind/unbind RLC to MAC SAP
898 * Function : duBindUnbindRlcToMacSap
901 * Initiates Bind/Unbind from RLC to MAC
903 * @param[in] Inst Specifies if RLC UL or RLC DL instance
904 * @param[in] action Specifies if action is bind or unbind
905 * @return ROK - success
908 ***************************************************************************/
909 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
911 RlcCntrl *cntrl = NULLP;
916 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
917 DU_SET_ZERO(&pst, sizeof(Pst));
921 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
925 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
927 cntrl = &(rlcMngmt.t.cntrl);
929 cntrl->action = action;
930 cntrl->subAction = DU_ZERO_VAL;
931 cntrl->s.sapCntrl.suId = macCfgInst;
932 cntrl->s.sapCntrl.spId = inst;
935 rlcMngmt.hdr.msgType = TCNTRL;
936 rlcMngmt.hdr.entId.ent = ENTRLC;
937 rlcMngmt.hdr.entId.inst = inst;
938 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
939 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
940 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
941 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
944 pst.selector = ODU_SELECTOR_LC;
945 pst.srcEnt = ENTDUAPP;
947 pst.dstProcId = DU_PROC;
949 pst.srcProcId = DU_PROC;
950 pst.region = duCb.init.region;
952 cmPkLkwCntrlReq(&pst, &rlcMngmt);
956 /*******************************************************************
958 * @brief Handles SCTP notifications
962 * Function : duSctpNtfyHdl
965 * Handles SCTP notification
967 * @params[in] Message Buffer
970 * @return ROK - success
973 * ****************************************************************/
975 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
977 if(f1Params.assocId == ntfy->u.assocChange.assocId)
979 if(BuildAndSendF1SetupReq() != ROK)
984 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
990 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
996 /*******************************************************************
998 * @brief Fills Pst struct for ENTEGTP
1002 * Function : duFillEgtpPst
1005 * Fills Pst struct for ENTEGTP
1008 * @return ROK - success
1011 * ****************************************************************/
1012 uint8_t duFillEgtpPst(Pst *pst, Event event)
1014 memset(pst, 0, sizeof(Pst));
1015 pst->srcEnt = (Ent)ENTDUAPP;
1016 pst->srcInst = (Inst)DU_INST;
1017 pst->srcProcId = DU_PROC;
1018 pst->dstEnt = (Ent)ENTEGTP;
1019 pst->dstInst = (Inst)EGTP_INST;
1020 pst->dstProcId = pst->srcProcId;
1022 pst->selector = ODU_SELECTOR_LC;
1029 /*******************************************************************
1031 * @brief Function to configure EGTP
1035 * Function : duBuildEgtpCfgReq
1038 * Function to configure EGTP
1041 * @return ROK - success
1044 * ****************************************************************/
1046 uint8_t duBuildEgtpCfgReq()
1051 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1053 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1054 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1056 duFillEgtpPst(&pst, EVTCFGREQ);
1057 packEgtpCfgReq(&pst, egtpCfg);
1062 /*******************************************************************
1064 * @brief Function to configure EGTP
1068 * Function : duBuildEgtpCfgReq
1071 * Function to configure EGTP
1074 * @return ROK - success
1077 * ****************************************************************/
1078 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1082 if(cfm.status == LCM_PRIM_OK)
1084 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1085 duSendEgtpSrvOpenReq();
1089 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1096 /*******************************************************************
1098 * @brief Sends server open request to EGTP
1102 * Function : duSendEgtpSrvOpenReq
1105 * Sends server open request to EGTP
1108 * @return ROK - success
1111 * ****************************************************************/
1113 uint8_t duSendEgtpSrvOpenReq()
1117 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1119 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1120 packEgtpSrvOpenReq(&pst);
1125 /*******************************************************************
1127 * @brief Handles server open confirmation
1131 * Function : duHdlEgtpSrvOpenComplete
1134 * Handles server open confirmation
1137 * @return ROK - success
1140 *****************************************************************/
1142 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1146 if(cfm.status == LCM_PRIM_OK)
1148 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1152 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1159 /*******************************************************************
1161 * @brief Sends tunnel management request
1165 * Function : duSendEgtpTnlMgmtReq
1168 * Builds and sends tunnel management request to EGTP
1170 * @params[in] Action
1171 * Local tunnel endpoint id
1172 * Remote tunnel endpoint id
1173 * @return ROK - success
1176 * ****************************************************************/
1178 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1184 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1186 /* ADD/MOD/DEL per tunnel */
1187 tnlEvt.action = action;
1188 tnlEvt.remTeid = ueCbTnlCfg->teId;
1189 if(action != EGTP_TNL_MGMT_ADD)
1191 tnlEvt.lclTeid = teIdTobeMod;
1195 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1197 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1198 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1202 /*******************************************************************
1204 * @brief Handles Tunnel management confirm
1208 * Function : duHdlEgtpTnlMgmtCfm
1211 * Handles tunnel management confirm received from Egtp
1213 * @params[in] Tunnel Event
1214 * @return ROK - success
1217 * ****************************************************************/
1218 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1222 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1224 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1228 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1235 /*******************************************************************
1237 * @brief Sends UL user data over to EGTP
1241 * Function : duSendEgtpDatInd
1243 * Functionality: Sends UL user data over to EGTP
1245 * @params[in] UL data buffer
1246 * @return ROK - success
1249 * ****************************************************************/
1250 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1254 /* Fill EGTP header */
1255 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1256 egtpMsg.msgHdr.nPdu.pres = FALSE;
1257 egtpMsg.msgHdr.seqNum.pres = FALSE;
1258 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1259 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1260 egtpMsg.msgHdr.teId = 1;
1263 egtpHdlDatInd(egtpMsg);
1269 /**************************************************************************
1270 * @brief Function to send configs to SCH
1274 * Function : duSendSchCfg
1277 * Sends general config to Scheduler via MAC layer
1280 * @return ROK - success
1283 ***************************************************************************/
1284 uint8_t duSendSchCfg()
1287 RgSchInstCfg *cfg = NULLP;
1290 DU_SET_ZERO(&pst, sizeof(Pst));
1291 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1293 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1295 /* Filling of Instance Id */
1296 cfg->instId = DEFAULT_CELLS + 1;
1297 /* Filling of Gen config */
1298 cfg->genCfg.mem.region = MAC_MEM_REGION;
1299 cfg->genCfg.mem.pool = MAC_POOL;
1300 cfg->genCfg.tmrRes = 10;
1303 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1304 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1306 cfg->genCfg.startCellId = 1;
1307 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1308 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1309 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1310 cfg->genCfg.lmPst.dstInst = DU_INST;
1311 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1312 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1313 cfg->genCfg.lmPst.prior = PRIOR0;
1314 cfg->genCfg.lmPst.route = RTESPEC;
1315 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1316 cfg->genCfg.lmPst.pool = MAC_POOL;
1317 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1320 rgMngmt.hdr.msgType = TCFG;
1321 rgMngmt.hdr.entId.ent = ENTMAC;
1322 rgMngmt.hdr.entId.inst = DU_INST;
1323 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1324 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1325 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1328 pst.selector = ODU_SELECTOR_LC;
1329 pst.srcEnt = ENTDUAPP;
1330 pst.dstEnt = ENTMAC;
1331 pst.dstProcId = DU_PROC;
1332 pst.srcProcId = DU_PROC;
1333 pst.srcInst = DU_INST;
1335 pst.region = duCb.init.region;
1336 pst.event = (Event) EVTMACSCHGENCFGREQ;
1338 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1340 /* Send the request to MAC */
1341 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1347 /**************************************************************************
1348 * @brief Function to configure SCTP params and
1349 * responsible for F1 and E2 interfaces
1353 * Function : duLayerConfigComplete
1356 * Configures SCTP Params and responsible for handling
1357 * F1 and E2 interface.
1360 * @return ROK - success
1363 ***************************************************************************/
1364 uint8_t duLayerConfigComplete()
1368 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1370 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1372 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1375 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1377 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1380 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1382 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1389 /**************************************************************************
1390 * @brief Function to handle SCH Config Confirm from MAC
1394 * Function : duHdlSchCfgComplete
1397 * Handles Scheduler Gen Config Confirm from MAC
1399 * @param[in] Pst *pst, Post structure of the primitive.
1400 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1401 * @return ROK - success
1404 ***************************************************************************/
1405 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1407 if (cfm->cfm.status == LCM_PRIM_OK)
1409 switch (cfm->hdr.elmId.elmnt)
1413 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1420 duLayerConfigComplete();
1421 duBuildEgtpCfgReq();
1425 /**************************************************************************
1426 * @brief Function to fill and send MacCellconfig
1430 * Function : duBuildAndSendMacCellCfg
1433 * Initiates MAC Configs towards MAC
1436 * @return ROK - success
1439 ***************************************************************************/
1440 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1443 MacCellCfg *duMacCellCfg = NULLP;
1445 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1446 if(duMacCellCfg == NULLP)
1451 /* store the address in the duCellCb so that we can free on confirm msg */
1452 if(duCb.actvCellLst[cellId-1])
1453 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1456 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duMacCellCfg, sizeof(MacCellCfg));
1460 /* copy the mac config structure from duCfgParams */
1461 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1464 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1466 /* Send MAC cell config to MAC */
1467 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1470 /**************************************************************************
1471 * @brief Function to Handle MAC cell config confirm
1475 * Function : duHandleMacCellCfgCfm
1478 * Initiates general Configs towards MAC
1481 * @return ROK - success
1484 ***************************************************************************/
1485 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1487 uint8_t actvCellIdx = 0;
1490 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1492 if((duCb.actvCellLst[actvCellIdx]) && (macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId))
1494 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1497 if(macCellCfgCfm->rsp == ROK)
1499 /* Build and send GNB-DU config update */
1500 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1502 /* Build and Send Cell Start Req to MAC */
1503 ret = duBuildAndSendMacCellStart();
1507 /* TODO : Action to be taken if cell configuration fails.
1508 * Should CU be informed? */
1510 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1516 /*******************************************************************
1518 * @brief Builds and sends cell start request to MAC
1522 * Function : duBuildAndSendMacCellStart
1525 * Builds and sends cell start request to MAC
1528 * @return ROK - success
1531 * ****************************************************************/
1532 uint8_t duBuildAndSendMacCellStart()
1535 OduCellId *cellId = NULL;
1537 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1539 /* Send Cell Start Request to MAC */
1540 DU_ALLOC_SHRABL_BUF(cellId, sizeof(OduCellId));
1543 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1547 for(uint8_t id = 0; id < MAX_NUM_CELL; id++)
1549 if(duCb.actvCellLst[id])
1551 cellId->cellId = duCb.actvCellLst[id]->cellId;
1554 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1556 return (*packMacCellStartOpts[pst.selector])(&pst, cellId);
1562 /*******************************************************************
1564 * @brief Builds and sends cell stop request to MAC
1568 * Function : duBuildAndSendMacCellStop
1571 * Builds and sends cell stop request to MAC
1574 * @return ROK - success
1577 * ****************************************************************/
1578 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1582 OduCellId *oduCellId = NULL;
1584 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1586 GET_CELL_IDX(cellId, cellIdx);
1587 if(duCb.actvCellLst[cellIdx] != NULLP)
1589 /* Send Cell Stop Request to MAC */
1590 DU_ALLOC_SHRABL_BUF(oduCellId, sizeof(OduCellId));
1593 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): Memory allocation failed ");
1596 memset(oduCellId, 0, sizeof(OduCellId));
1597 oduCellId->cellId = duCb.actvCellLst[cellIdx]->cellId;
1600 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1602 return (*packMacCellStopOpts[pst.selector])(&pst, oduCellId);
1606 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1612 /*******************************************************************
1614 * @brief Handles stop indication from MAC
1618 * Function : duHandleStopInd
1621 * Handles stop indication from MAC
1623 * @params[in] Post structure pointer
1624 * @return ROK - success
1627 * ****************************************************************/
1628 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1630 DuCellCb *cellCb = NULLP;
1632 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1634 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1637 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1640 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1642 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1643 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1645 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1646 cellId[%d]", cellId->cellId);
1652 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1653 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1654 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1658 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1659 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1661 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1667 /*******************************************************************
1669 * @brief Handles slot indication from MAC
1673 * Function : duHandleUlCcchInd
1676 * Handles UL CCCH indication from MAC
1678 * @params[in] Post structure pointer
1679 * UL CCCH Ind pointer
1680 * @return ROK - success
1683 * ****************************************************************/
1684 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1687 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1689 return (duProcUlCcchInd(ulCcchIndInfo));
1692 /*******************************************************************
1694 * @brief Process UL RRC Message from RLC
1698 * Function : DuProcRlcUlRrcMsgTrans
1700 * Functionality: Process UL RRC Message from RLC
1702 * @params[in] Post structure
1703 * UL RRC Message Info
1704 * @return ROK - success
1707 * ****************************************************************/
1708 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1710 DuCellCb *cellCb = NULLP;
1713 if(duGetCellCb(ulRrcMsgInfo->cellId, &cellCb) != ROK)
1715 if(ulRrcMsgInfo->ueId > 0)
1717 ueCb = cellCb->ueCb[ulRrcMsgInfo->ueId -1];
1720 BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg);
1722 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1723 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1728 /*******************************************************************
1730 * @brief Process RRC delivery report from RLC
1734 * Function : DuProcRlcRrcDeliveryReport
1736 * Functionality: Process RRC delivery Message from RLC
1738 * @params[in] Post structure
1739 * UL RRC Message Info
1740 * @return ROK - success
1743 * ****************************************************************/
1744 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1746 DuCellCb *cellCb = NULLP;
1748 uint8_t ret = RFAILED;
1750 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1753 ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1];
1754 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1756 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1760 /*******************************************************************
1762 * @brief Process UL user data from RLC
1766 * Function : DuProcRlcUlUserDataTrans
1768 * Functionality: Process UL user data from RLC
1770 * @params[in] Post structure
1772 * @return ROK - success
1775 * ****************************************************************/
1776 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1782 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1784 /* Fill EGTP header */
1785 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1786 egtpMsg.msgHdr.nPdu.pres = FALSE;
1787 egtpMsg.msgHdr.seqNum.pres = FALSE;
1788 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1789 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1791 /* Fetch EGTP tunnel info */
1792 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
1794 /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
1795 if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \
1796 (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
1798 if(duCb.upTnlCfg[teIdx]->tnlCfg1)
1800 egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1806 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1808 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1809 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1810 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1813 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1814 ODU_PRINT_MSG(mBuf, 0, 0);
1816 egtpHdlDatInd(egtpMsg);
1818 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1819 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1823 /*******************************************************************
1825 * @brief Free tempSLiceCfg stored in duCfgParams
1829 * Function : duFreeTempSliceCfg
1831 * Functionality: Free tempSLiceCfg stored in duCfgParams
1833 * @params[in] Post structure,
1837 * ****************************************************************/
1839 void duFreeTempSliceCfg()
1841 uint8_t policyIdx = 0, memberListTdx =0;
1842 CopyOfRecvdSliceCfg *tempSliceCfg = &duCfgParam.tempSliceCfg;
1844 if(tempSliceCfg->totalRrmPolicy)
1846 for(policyIdx = 0; policyIdx<tempSliceCfg->totalRrmPolicy; policyIdx++)
1848 if(tempSliceCfg->rrmPolicy[policyIdx]->numMemberList)
1850 for(memberListTdx = 0; memberListTdx<tempSliceCfg->rrmPolicy[policyIdx]->numMemberList; memberListTdx++)
1852 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList[memberListTdx], sizeof(PolicyMemberList));
1854 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx]->memberList, (tempSliceCfg->rrmPolicy[policyIdx]->numMemberList) * sizeof(PolicyMemberList*));
1856 DU_FREE(tempSliceCfg->rrmPolicy[policyIdx], sizeof(RrmPolicy));
1858 DU_FREE(tempSliceCfg->rrmPolicy, tempSliceCfg->totalRrmPolicy* sizeof(RrmPolicy*));
1860 memset(tempSliceCfg, 0, sizeof(CopyOfRecvdSliceCfg));
1863 /*******************************************************************
1865 * @brief free the slice cfg rsp
1869 * Function : duFreeSliceCfgRsp
1871 * Functionality: free the slice cfg rsp
1873 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1875 * @return ROK - success
1878 **********************************************************************/
1879 void duFreeSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1885 if(cfgRsp->numSliceCfgRsp)
1887 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1889 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp[cfgIdx], sizeof(MacSliceRsp));
1891 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp->listOfSliceCfgRsp, cfgRsp->numSliceCfgRsp * sizeof(MacSliceRsp*));
1893 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1897 /*******************************************************************
1899 * @brief process the slice cfg rsp received from MAC
1903 * Function : DuProcMacSliceCfgRsp
1905 * Functionality: process the slice cfg rsp received from MAC
1907 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1909 * @return ROK - success
1912 **********************************************************************/
1913 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1919 if(cfgRsp->listOfSliceCfgRsp)
1921 for(cfgIdx = 0; cfgIdx<cfgRsp->numSliceCfgRsp; cfgIdx++)
1923 if(cfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
1925 duCb.sliceState = SLICE_CONFIGURED;
1928 DU_LOG("\nINFO --> DU_APP : Slice Configuration is done sucessfully ");
1930 duFreeSliceCfgRsp(pst, cfgRsp);
1932 duFreeTempSliceCfg();
1936 /*******************************************************************
1938 * @brief Fill the slice configration and rrm policy ratio
1939 * information received form O1
1943 * Function : fillSliceCfgReCfgInfo
1945 * Functionality: Fill the slice configration and recfg info
1947 * @params[in] Post structure
1949 * @return ROK - success
1952 * ****************************************************************/
1954 uint8_t fillSliceCfgReCfgInfo(MacSliceCfgReq *sliceCfgReq, RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
1956 uint8_t sliceIdx = 0, cfgIdx = 0, memberListIdx = 0;
1960 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg, totalSliceCount*sizeof(MacSliceRrmPolicy*));
1961 if(sliceCfgReq->listOfSliceCfg == NULLP)
1963 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1967 for(sliceIdx = 0; sliceIdx<totalRrmPolicy; sliceIdx++)
1969 for(memberListIdx = 0; memberListIdx<rrmPolicy[sliceIdx]->numMemberList; memberListIdx++)
1971 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx], sizeof(MacSliceRrmPolicy));
1972 if(sliceCfgReq->listOfSliceCfg[cfgIdx] == NULLP)
1974 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1979 memcpy(&sliceCfgReq->listOfSliceCfg[cfgIdx]->snssai, &rrmPolicy[sliceIdx]->memberList[memberListIdx]->snssai, sizeof(Snssai));
1981 DU_ALLOC_SHRABL_BUF(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio, sizeof(RrmPolicyRatio));
1982 if(sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio == NULLP)
1984 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in fillSliceCfgReCfgInfo");
1988 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMaxRatio = rrmPolicy[sliceIdx]->policyMaxRatio;
1989 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyMinRatio = rrmPolicy[sliceIdx]->policyMinRatio;
1990 sliceCfgReq->listOfSliceCfg[cfgIdx]->rrmPolicyRatio->policyDedicatedRatio = rrmPolicy[sliceIdx]->policyDedicatedRatio;
1991 sliceCfgReq->numOfConfiguredSlice++;
1999 /*******************************************************************
2001 * @brief Fill the slice configration and rrm policy related
2002 * information received form O1
2006 * Function : BuildAndSendSliceConfigReq
2008 * Functionality: Fill the slice configration and rrm policy related
2010 * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t
2013 * @return ROK - success
2016 * ****************************************************************/
2017 uint8_t BuildAndSendSliceConfigReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCnt)
2020 MacSliceCfgReq *sliceCfgReq;
2022 DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq));
2023 if(sliceCfgReq == NULLP)
2025 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq");
2030 if(fillSliceCfgReCfgInfo(sliceCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCnt) != ROK)
2032 DU_LOG("\nERROR --> DU_APP : Failed to fill slice Configuration info in MacSliceCfgReq");
2035 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ);
2037 DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC ");
2038 if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED)
2040 DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC");
2041 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq));
2048 /*******************************************************************
2050 * @brief Fill the slice configration and rrm policy related
2051 * information received form O1
2055 * Function : BuildAndSendSliceReCfgReq
2057 * Functionality: Fill the slice configration and rrm policy related
2059 * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount
2061 * @return ROK - success
2064 * ****************************************************************/
2065 uint8_t BuildAndSendSliceReCfgReq(RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t totalSliceCount)
2068 MacSliceCfgReq *sliceReCfgReq = NULLP;
2070 DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received");
2072 DU_ALLOC_SHRABL_BUF(sliceReCfgReq, sizeof(MacSliceCfgReq));
2073 if(sliceReCfgReq == NULLP)
2075 DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceReCfgReq");
2080 if(fillSliceCfgReCfgInfo(sliceReCfgReq, rrmPolicy, totalRrmPolicy, totalSliceCount) != ROK)
2082 DU_LOG("\nERROR --> DU_APP: Failed to fill slice cfg request info");
2085 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ);
2087 DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC ");
2088 if( (*packMacSliceReCfgReqOpts[pst.selector])(&pst, sliceReCfgReq) == RFAILED)
2090 DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC");
2091 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceReCfgReq, sizeof(MacSliceCfgReq));
2096 /*******************************************************************
2098 * @brief process the slice ReCfg rsp received from MAC
2102 * Function : DuProcMacSliceReCfgRsp
2104 * Functionality: process the slice ReCfg rsp received from MAC
2106 * @params[in] Post structure, MacSliceCfgRsp *ReCfgRsp
2108 * @return ROK - success
2111 **********************************************************************/
2112 uint8_t DuProcMacSliceReCfgRsp(Pst *pst, MacSliceCfgRsp *reCfgRsp)
2118 if(reCfgRsp->listOfSliceCfgRsp)
2120 for(cfgIdx = 0; cfgIdx < reCfgRsp->numSliceCfgRsp; cfgIdx++)
2122 if(reCfgRsp->listOfSliceCfgRsp[cfgIdx]->rsp == MAC_DU_APP_RSP_OK)
2124 duCb.sliceState = SLICE_RECONFIGURED;
2128 DU_LOG("\nERROR --> DU_APP : Slice not available");
2131 DU_LOG("\nINFO --> DU_APP : Slice ReCOnfiguration response received");
2133 duFreeSliceCfgRsp(pst, reCfgRsp);
2135 duFreeTempSliceCfg();
2139 /*******************************************************************
2141 * @brief Handles received Slice Metrics from RLC and forward it to O1
2145 * Function : DuProcRlcSliceMetrics
2148 * Handles received Slice Metrics from RLC and forward it to O1
2150 * @params[in] Post structure pointer
2151 * SlicePmList *sliceStats
2153 * @return ROK - success
2156 * ****************************************************************/
2157 uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
2159 uint8_t sliceRecord = 0;
2161 DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics");
2162 if(sliceStats == NULLP)
2164 DU_LOG("\nERROR --> DU APP : Empty Metrics");
2168 for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
2170 DU_LOG("\nINFO --> DU_APP: SliceId[SST-SD]:%d-%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sst,\
2171 sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sd,sliceStats->sliceRecord[sliceRecord].ThpDl,\
2172 sliceStats->sliceRecord[sliceRecord].ThpUl);
2177 sendSliceMetric((SliceMetricList*) sliceStats);
2181 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2182 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2187 /**********************************************************************
2189 **********************************************************************/