1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains message handling functionality for DU APP */
20 #include "common_def.h"
29 #include "du_app_mac_inf.h"
30 #include "du_app_rlc_inf.h"
31 #include "du_e2ap_mgr.h"
32 #include "du_e2ap_msg_hdl.h"
34 #include "du_app_rlc_inf.h"
38 #include "du_f1ap_msg_hdl.h"
39 #include "du_ue_mgr.h"
43 #include "du_cell_mgr.h"
47 #include "AlarmInterface.h"
48 #include "CmInterface.h"
49 #include "PmInterface.h"
54 uint8_t numRlcDlSaps = 0;
56 uint8_t numRlcMacSaps = 0;
58 uint8_t macCfgInst = 0;
60 DuCfgParams duCfgParam;
61 uint8_t packRlcConfigReq(Pst *pst, RlcMngmt *cfg);
62 uint8_t cmPkLkwCntrlReq(Pst *pst, RlcMngmt *cfg);
63 uint8_t cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
64 uint8_t egtpHdlDatInd(EgtpMsg egtpMsg);
65 uint8_t BuildAndSendDUConfigUpdate();
66 uint16_t getTransId();
67 uint8_t cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
68 uint8_t sendCellDeleteReqToMac(uint16_t cellId);
69 uint8_t BuildAndSendStatsDeleteReq(RicSubscription *ricSubscriptionInfo);
71 packMacCellCfgReq packMacCellCfgOpts[] =
73 packMacCellCfg, /* packing for loosely coupled */
74 MacProcCellCfgReq, /* packing for tightly coupled */
75 packMacCellCfg, /* packing for light weight loosly coupled */
78 DuMacCellStart packMacCellStartOpts[] =
80 packMacCellStart, /* Loose coupling */
81 MacProcCellStart, /* TIght coupling */
82 packMacCellStart /* Light weight-loose coupling */
85 DuMacCellStop packMacCellStopOpts[] =
87 packMacCellStop, /* Loose coupling */
88 MacProcCellStop, /* TIght coupling */
89 packMacCellStop /* Light weight-loose coupling */
92 DuMacSliceCfgReq packMacSliceCfgReqOpts[] =
94 packDuMacSliceCfgReq, /* Loose coupling */
95 MacProcSliceCfgReq, /* TIght coupling */
96 packDuMacSliceCfgReq /* Light weight-loose coupling */
100 DuMacSliceRecfgReq packMacSliceRecfgReqOpts[] =
102 packDuMacSliceRecfgReq, /* Loose coupling */
103 MacProcSliceRecfgReq, /* TIght coupling */
104 packDuMacSliceRecfgReq /* Light weight-loose coupling */
107 DuMacStatsReqFunc packMacStatsReqOpts[]=
109 packDuMacStatsReq, /* Loose Coupling */
110 MacProcStatsReq, /* Tight Coupling */
111 packDuMacStatsReq /* Light weight-loose coupling */
114 DuMacStatsDeleteReqFunc packMacStatsDeleteReqOpts[]=
116 packDuMacStatsDeleteReq, /* Loose Coupling */
117 MacProcStatsDeleteReq, /* Tight Coupling */
118 packDuMacStatsDeleteReq /* Light weight-loose coupling */
121 /**************************************************************************
122 * @brief Function to fill configs required by RLC
126 * Function : duBuildRlcCfg
129 * Initiates general Configs towards RLC
131 * @param[in] Inst Specifies if RLC UL or RLC DL instance
132 * @return ROK - success
135 ***************************************************************************/
136 uint8_t duBuildRlcCfg(Inst inst)
139 RlcGenCfg *genCfg = NULLP;
142 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
143 DU_SET_ZERO(&pst, sizeof(Pst));
145 genCfg = &(rlcMngmt.t.cfg.s.gen);
147 /*----------- Fill General Configuration Parameters ---------*/
148 genCfg->maxUe = duCfgParam.maxUe;
149 genCfg->maxKwuSaps = 2;
150 genCfg->maxUdxSaps = 1;
151 genCfg->rlcMode = (inst == RLC_UL_INST) ?
152 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
154 genCfg->maxRguSaps = DEFAULT_CELLS;
156 /*----------- Fill lmPst
157 * Parameters ---------*/
158 genCfg->lmPst.dstProcId = DU_PROC;
159 genCfg->lmPst.srcProcId = DU_PROC;
160 genCfg->lmPst.dstEnt = ENTDUAPP;
161 genCfg->lmPst.dstInst = DU_INST;
162 genCfg->lmPst.srcEnt = ENTRLC;
163 genCfg->lmPst.srcInst = inst;
164 genCfg->lmPst.prior = PRIOR0;
165 genCfg->lmPst.route = RTESPEC;
166 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
167 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
168 genCfg->lmPst.pool = RLC_POOL;
169 genCfg->lmPst.selector = ODU_SELECTOR_LC;
172 rlcMngmt.hdr.msgType = TCFG;
173 rlcMngmt.hdr.msgLen = 0;
174 rlcMngmt.hdr.entId.ent = ENTRLC;
175 rlcMngmt.hdr.entId.inst = (Inst)0;
176 rlcMngmt.hdr.elmId.elmnt = STGEN;
177 rlcMngmt.hdr.seqNmb = 0;
178 rlcMngmt.hdr.version = 0;
179 rlcMngmt.hdr.transId = 0;
180 rlcMngmt.hdr.response.prior = PRIOR0;
181 rlcMngmt.hdr.response.route = RTESPEC;
182 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
183 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
184 rlcMngmt.hdr.response.mem.pool = DU_POOL;
185 rlcMngmt.hdr.response.selector = ODU_SELECTOR_LC;
188 pst.selector = ODU_SELECTOR_LC;
189 pst.srcEnt = ENTDUAPP;
192 pst.dstProcId = DU_PROC;
193 pst.srcProcId = DU_PROC;
194 pst.region = duCb.init.region;
196 DU_LOG("\nDEBUG --> DU_APP : RLC Gen Cfg Req sent for inst %d", inst);
198 /* Send the request to RLC */
199 packRlcConfigReq(&pst, &rlcMngmt);
204 /**************************************************************************
205 * @brief Function to fill configs required by RLC
209 * Function : duBuildRlcLsapCfg
212 * Initiates general Configs towards RLC
214 * @param[in] Inst Specifies if RLC UL or RLC DL instance
215 * @return ROK - success
218 ***************************************************************************/
219 uint8_t duBuildRlcLsapCfg(Ent ent, Inst inst, uint8_t lsapInst)
223 RlcSapCfg *lSap = NULLP;
226 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
227 DU_SET_ZERO(&pst, sizeof(Pst));
230 rlcMngmt.hdr.msgType = TCFG;
231 rlcMngmt.hdr.entId.ent = ENTRLC;
232 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
233 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
235 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
238 pst.selector = ODU_SELECTOR_LC;
239 pst.srcEnt = ENTDUAPP;
241 pst.dstProcId = DU_PROC;
243 pst.srcProcId = DU_PROC;
244 pst.region = duCb.init.region;
245 lSap = &(rlcMngmt.t.cfg.s.sap);
247 lSap->mem.region = (inst == RLC_UL_INST) ?
248 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
249 lSap->mem.pool = RLC_POOL;
251 lSap->bndTmrIntvl = 10;
252 lSap->priority = PRIOR0;
253 lSap->route = RTESPEC;
256 lSap->procId = DU_PROC;
258 lSap->inst = lsapInst;
259 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
260 lSap->selector = (inst == RLC_UL_INST) ? ODU_SELECTOR_LWLC : ODU_SELECTOR_TC;
261 rlcMngmt.hdr.elmId.elmnt = STRGUSAP;
262 DU_LOG("\nDEBUG --> DU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
267 lSap->procId = DU_PROC;
269 lSap->inst = (inst == RLC_UL_INST) ?
270 RLC_DL_INST : RLC_UL_INST;
272 lSap->selector = ODU_SELECTOR_LC;
273 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
274 DU_LOG("\nDEBUG --> DU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
277 packRlcConfigReq(&pst, &rlcMngmt);
281 /**************************************************************************
282 * @brief Function to fill configs required by RLC
286 * Function : duBuildRlcUsapCfg
289 * Initiates general Configs towards RLC
291 * @param[in] Inst Specifies if RLC UL or RLC DL instance
292 * @return ROK - success
295 ***************************************************************************/
296 uint8_t duBuildRlcUsapCfg(uint8_t elemId, Ent ent, Inst inst)
299 RlcSapCfg *uSap = NULLP;
302 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
303 DU_SET_ZERO(&pst, sizeof(Pst));
305 uSap = &(rlcMngmt.t.cfg.s.sap);
307 uSap->selector = ODU_SELECTOR_LC;
308 uSap->mem.region = (inst == RLC_UL_INST) ?
309 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
310 uSap->mem.pool = RLC_POOL;
313 uSap->procId = DU_PROC;
317 uSap->inst = (inst == RLC_UL_INST) ?
318 RLC_DL_INST : RLC_UL_INST;
319 uSap->bndTmrIntvl = 1000;
320 uSap->priority = PRIOR0;
321 uSap->route = RTESPEC;
324 rlcMngmt.hdr.msgType = TCFG;
325 rlcMngmt.hdr.entId.ent = ENTRLC;
326 rlcMngmt.hdr.elmId.elmnt = STUDXSAP;
327 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
328 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
330 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
333 pst.selector = ODU_SELECTOR_LC;
334 pst.srcEnt = ENTDUAPP;
336 pst.dstProcId = DU_PROC;
338 pst.srcProcId = DU_PROC;
339 pst.region = duCb.init.region;
341 DU_LOG("\nDEBUG --> DU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
342 packRlcConfigReq(&pst, &rlcMngmt);
347 /**************************************************************************
348 * @brief Function to populate internal DS of DU APP
352 * Function : duProcCfgComplete
355 * Populates internal data structures of DU APP after
356 * receiving configurations.
359 * @return ROK - success
362 ***************************************************************************/
363 uint8_t duProcCfgComplete()
367 for(idx=0; idx< DEFAULT_CELLS; idx++)
369 DuCellCb *cell = NULLP;
370 DU_ALLOC(cell, sizeof(DuCellCb));
373 DU_LOG("\nERROR --> DU_APP : Memory Allocation failed in duProcCfgComplete");
379 memset(cell, 0, sizeof(DuCellCb));
380 cell->cellId = NR_CELL_ID; //++cellId;
381 memset(&cell->cellInfo.nrEcgi.plmn, 0, sizeof(Plmn));
382 cell->cellInfo.nrEcgi.plmn.mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
383 cell->cellInfo.nrEcgi.plmn.mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
384 cell->cellInfo.nrEcgi.plmn.mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
385 cell->cellInfo.nrEcgi.plmn.mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
386 cell->cellInfo.nrEcgi.plmn.mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
387 cell->cellInfo.nrEcgi.plmn.mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
388 cell->cellInfo.nrEcgi.cellId = cell->cellId;
389 cell->cellInfo.nrPci = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
390 cell->cellInfo.fiveGsTac = duCfgParam.srvdCellLst[0].duCellInfo.tac;
391 memset(&cell->cellInfo.plmn[idx1], 0, sizeof(Plmn));
392 for(idx1=0; idx1<MAX_PLMN; idx1++)
394 cell->cellInfo.plmn[idx1].mcc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[0];
395 cell->cellInfo.plmn[idx1].mcc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[1];
396 cell->cellInfo.plmn[idx1].mcc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mcc[2];
397 cell->cellInfo.plmn[idx1].mnc[0] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[0];
398 cell->cellInfo.plmn[idx1].mnc[1] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[1];
399 cell->cellInfo.plmn[idx1].mnc[2] = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].plmn.mnc[2];
401 cell->cellInfo.maxUe = duCfgParam.maxUe;
402 cell->cellStatus = CELL_OUT_OF_SERVICE;
403 gCellStatus = CELL_DOWN;
404 duCb.cfgCellLst[duCb.numCfgCells] = cell;
410 //Start layer configs
411 ret = duSendRlcUlCfg();
415 /**************************************************************************
416 * @brief Function to invoke DU Layer Configs
420 * Function : duSendRlcUlCfg
423 * Initiates Configs towards layers of DU
426 * @return ROK - success
429 ***************************************************************************/
430 uint8_t duSendRlcUlCfg()
434 duBuildRlcCfg((Inst)RLC_UL_INST);
435 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
437 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_UL_INST, cellIdx);
439 duBuildRlcLsapCfg(ENTRLC, (Inst)RLC_UL_INST, 0);
444 /**************************************************************************
445 * @brief Function to invoke DU Layer Configs
449 * Function : duSendRlcDlCfg
452 * Initiates Configs towards layers of DU
455 * @return ROK - success
458 ***************************************************************************/
459 uint8_t duSendRlcDlCfg()
463 duBuildRlcCfg((Inst)RLC_DL_INST);
464 duBuildRlcUsapCfg(STUDXSAP, ENTRLC, (Inst)RLC_DL_INST);
465 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
467 duBuildRlcLsapCfg(ENTMAC, (Inst)RLC_DL_INST, cellIdx);
472 /**************************************************************************
473 * @brief Function to handle Config Confirm from RLC
477 * Function : DuHdlRlcCfgComplete
480 * Handles Gen Config Confirm from RLC
482 * @param[in] Pst *pst, Post structure of the primitive.
483 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
484 * @return ROK - success
487 ***************************************************************************/
488 uint8_t DuHdlRlcCfgComplete(Pst *pst, RlcMngmt *cfm)
491 if (pst->srcInst == RLC_UL_INST)
493 ret = duProcRlcUlCfgComplete(pst, cfm);
497 ret = duProcRlcDlCfgComplete(pst, cfm);
502 /**************************************************************************
503 * @brief Function to handle Control Config Confirm from RLC
507 * Function : duHdlRlcCntrlCfgComplete
510 * Handles Control Config Confirm from RLC
512 * @param[in] Pst *pst, Post structure of the primitive.
513 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC
514 * @return ROK - success
517 ***************************************************************************/
518 uint8_t duHdlRlcCntrlCfgComplete(Pst *pst, RlcMngmt *cntrl)
522 if (cntrl->cfm.status == LCM_PRIM_OK)
524 switch (cntrl->hdr.elmId.elmnt)
528 if (pst->srcInst == RLC_DL_INST)
530 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
532 if(macCfgInst < DEFAULT_CELLS)
535 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
539 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
544 DU_LOG("\nDEBUG --> DU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
546 if(macCfgInst < DEFAULT_CELLS)
548 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
562 /**************************************************************************
563 * @brief Function to handle Config Confirm from RLC UL
567 * Function : duHdlRlcUlCfgComplete
570 * Handles Config Confirm from RLC UL
572 * @param[in] Pst *pst, Post structure of the primitive.
573 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC UL
574 * @return ROK - success
577 ***************************************************************************/
578 uint8_t duProcRlcUlCfgComplete(Pst *pst, RlcMngmt *cfm)
582 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
583 if (cfm->cfm.status == LCM_PRIM_OK)
585 switch(cfm->hdr.elmId.elmnt)
589 rlcUlCfg |= RLC_GEN_CFG;
595 if(numRlcMacSaps == DEFAULT_CELLS)
597 rlcUlCfg |= RLC_MAC_SAP_CFG;
604 rlcUlCfg |= RLC_UDX_SAP_CFG;
611 DU_LOG("\nDEBUG --> DU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
612 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
616 //Start configuration of RLC DL
623 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC UL");
629 /**************************************************************************
630 * @brief Function to handle Config Confirm from RLC DL
634 * Function : duHdlRlcDlCfgComplete
637 * Handles Config Confirm from RLC DL
639 * @param[in] Pst *pst, Post structure of the primitive.
640 * @param[in] RlcMngmt *cfm, Unpacked primitive info received from RLC DL
641 * @return ROK - success
644 ***************************************************************************/
645 uint8_t duProcRlcDlCfgComplete(Pst *pst, RlcMngmt *cfm)
647 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
648 if (cfm->cfm.status == LCM_PRIM_OK)
650 switch(cfm->hdr.elmId.elmnt)
654 rlcDlCfg |= RLC_GEN_CFG;
660 if(numRlcMacSaps == DEFAULT_CELLS)
662 rlcDlCfg |= RLC_MAC_SAP_CFG;
669 rlcDlCfg |= RLC_UDX_SAP_CFG;
677 DU_LOG("\nDEBUG --> DU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
678 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
681 //Start configuration of MAC
688 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from RLC DL");
693 /**************************************************************************
694 * @brief Function to send configs to MAC
698 * Function : duSendMacCfg
701 * Initiates Configs towards MAC layer
704 * @return ROK - success
707 ***************************************************************************/
708 uint8_t duSendMacCfg()
711 duBuildMacUsapCfg(RLC_UL_INST);
712 duBuildMacUsapCfg(RLC_DL_INST);
717 /**************************************************************************
718 * @brief Function to fill gen config required by MAC
722 * Function : duBuildMacGenCfg
725 * Initiates general Configs towards MAC
728 * @return ROK - success
731 ***************************************************************************/
732 uint8_t duBuildMacGenCfg()
735 RgGenCfg *genCfg=NULLP;
738 DU_SET_ZERO(&pst, sizeof(Pst));
739 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
741 genCfg = &(rgMngmt.t.cfg.s.genCfg);
743 /*----------- Fill General Configuration Parameters ---------*/
744 genCfg->mem.region = MAC_MEM_REGION;
745 genCfg->mem.pool = MAC_POOL;
747 genCfg->numRguSaps = 2;
749 genCfg->lmPst.dstProcId = DU_PROC;
750 genCfg->lmPst.srcProcId = DU_PROC;
751 genCfg->lmPst.dstEnt = ENTDUAPP;
752 genCfg->lmPst.dstInst = 0;
753 genCfg->lmPst.srcEnt = ENTMAC;
754 genCfg->lmPst.srcInst = macCfgInst;
755 genCfg->lmPst.prior = PRIOR0;
756 genCfg->lmPst.route = RTESPEC;
757 genCfg->lmPst.region = MAC_MEM_REGION;
758 genCfg->lmPst.pool = MAC_POOL;
759 genCfg->lmPst.selector = ODU_SELECTOR_LC;
762 rgMngmt.hdr.msgType = TCFG;
763 rgMngmt.hdr.msgLen = 0;
764 rgMngmt.hdr.entId.ent = ENTMAC;
765 rgMngmt.hdr.entId.inst = (Inst)0;
766 rgMngmt.hdr.elmId.elmnt = STGEN;
767 rgMngmt.hdr.seqNmb = 0;
768 rgMngmt.hdr.version = 0;
769 rgMngmt.hdr.transId = 0;
771 rgMngmt.hdr.response.prior = PRIOR0;
772 rgMngmt.hdr.response.route = RTESPEC;
773 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
774 rgMngmt.hdr.response.mem.pool = MAC_POOL;
775 rgMngmt.hdr.response.selector = ODU_SELECTOR_LC;
778 pst.selector = ODU_SELECTOR_LC;
779 pst.srcEnt = ENTDUAPP;
781 pst.dstInst = macCfgInst;
782 pst.dstProcId = DU_PROC;
783 pst.srcProcId = DU_PROC;
784 pst.region = duCb.init.region;
786 DU_LOG("\nDEBUG --> DU_APP : MAC Gen Cfg Req sent");
788 /* Send the request to MAC */
789 cmPkLrgCfgReq(&pst, &rgMngmt);
794 /**************************************************************************
795 * @brief Function to fill USAP config required by MAC
799 * Function : duBuildMacUsapCfg
802 * Initiates USAP Configs towards MAC
804 * @param[in] SpId Specifies if RLC UL or RLC DL instance
805 * @return ROK - success
808 ***************************************************************************/
809 uint8_t duBuildMacUsapCfg(SpId sapId)
812 RgUpSapCfg *uSap = NULLP;
815 DU_SET_ZERO(&pst, sizeof(Pst));
816 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
818 uSap = &(rgMngmt.t.cfg.s.rguSap);
820 uSap->mem.region = MAC_MEM_REGION;
821 uSap->mem.pool = MAC_POOL;
824 uSap->procId = DU_PROC;
827 uSap->prior = PRIOR0;
828 uSap->route = RTESPEC;
829 uSap->selector = ODU_SELECTOR_LC ;
832 rgMngmt.hdr.msgType = TCFG;
833 rgMngmt.hdr.entId.ent = ENTMAC;
834 rgMngmt.hdr.entId.inst = (Inst)0;
835 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
836 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
837 rgMngmt.hdr.response.mem.pool = MAC_POOL;
840 pst.selector = ODU_SELECTOR_LC;
841 pst.srcEnt = ENTDUAPP;
843 pst.dstInst = macCfgInst;
844 pst.dstProcId = DU_PROC;
845 pst.srcProcId = DU_PROC;
846 pst.region = duCb.init.region;
848 DU_LOG("\nDEBUG --> DU_APP : MAC Rgu USap Cfg Req sent");
850 /* Send the request to MAC */
851 cmPkLrgCfgReq(&pst, &rgMngmt);
856 /**************************************************************************
857 * @brief Function to handle Config Confirm from MAC
861 * Function : duHdlMacCfgComplete
864 * Handles Gen Config Confirm from MAC
866 * @param[in] Pst *pst, Post structure of the primitive.
867 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
868 * @return ROK - success
871 ***************************************************************************/
872 uint8_t duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
876 if (cfm->cfm.status == LCM_PRIM_OK)
878 switch (cfm->hdr.elmId.elmnt)
882 macCfg |= MAC_GEN_CFG;
887 macCfg |= MAC_SAP_CFG;
894 DU_LOG("\nDEBUG --> DU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
895 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
898 DU_LOG("\nDEBUG --> DU_APP : Completed sending Configs");
900 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
906 DU_LOG("\nERROR --> DU_APP : Config confirm NOK from MAC");
912 /**************************************************************************
913 * @brief Function to bind/unbind RLC to MAC SAP
917 * Function : duBindUnbindRlcToMacSap
920 * Initiates Bind/Unbind from RLC to MAC
922 * @param[in] Inst Specifies if RLC UL or RLC DL instance
923 * @param[in] action Specifies if action is bind or unbind
924 * @return ROK - success
927 ***************************************************************************/
928 uint8_t duBindUnbindRlcToMacSap(uint8_t inst, uint8_t action)
930 RlcCntrl *cntrl = NULLP;
935 DU_SET_ZERO(&rlcMngmt, sizeof(RlcMngmt));
936 DU_SET_ZERO(&pst, sizeof(Pst));
940 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
944 DU_LOG("\nDEBUG --> DU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
946 cntrl = &(rlcMngmt.t.cntrl);
948 cntrl->action = action;
949 cntrl->subAction = DU_ZERO_VAL;
950 cntrl->s.sapCntrl.suId = macCfgInst;
951 cntrl->s.sapCntrl.spId = inst;
954 rlcMngmt.hdr.msgType = TCNTRL;
955 rlcMngmt.hdr.entId.ent = ENTRLC;
956 rlcMngmt.hdr.entId.inst = inst;
957 rlcMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
958 rlcMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
959 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
960 rlcMngmt.hdr.response.mem.pool = RLC_POOL;
963 pst.selector = ODU_SELECTOR_LC;
964 pst.srcEnt = ENTDUAPP;
966 pst.dstProcId = DU_PROC;
968 pst.srcProcId = DU_PROC;
969 pst.region = duCb.init.region;
971 cmPkLkwCntrlReq(&pst, &rlcMngmt);
975 /*******************************************************************
977 * @brief Handles SCTP notifications
981 * Function : duSctpNtfyHdl
984 * Handles SCTP notification
986 * @params[in] Message Buffer
989 * @return ROK - success
992 * ****************************************************************/
994 uint8_t duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
996 if(f1Params.assocId == ntfy->u.assocChange.assocId)
998 if(BuildAndSendF1SetupReq() != ROK)
1003 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
1009 DU_LOG("\nERROR --> DU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
1015 /*******************************************************************
1017 * @brief Fills Pst struct for ENTEGTP
1021 * Function : duFillEgtpPst
1024 * Fills Pst struct for ENTEGTP
1027 * @return ROK - success
1030 * ****************************************************************/
1031 uint8_t duFillEgtpPst(Pst *pst, Event event)
1033 memset(pst, 0, sizeof(Pst));
1034 pst->srcEnt = (Ent)ENTDUAPP;
1035 pst->srcInst = (Inst)DU_INST;
1036 pst->srcProcId = DU_PROC;
1037 pst->dstEnt = (Ent)ENTEGTP;
1038 pst->dstInst = (Inst)EGTP_INST;
1039 pst->dstProcId = pst->srcProcId;
1041 pst->selector = ODU_SELECTOR_LC;
1048 /*******************************************************************
1050 * @brief Function to configure EGTP
1054 * Function : duBuildEgtpCfgReq
1057 * Function to configure EGTP
1060 * @return ROK - success
1063 * ****************************************************************/
1065 uint8_t duBuildEgtpCfgReq()
1070 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP config request");
1072 memset(&egtpCfg, 0, sizeof(EgtpConfig));
1073 memcpy(&egtpCfg, &duCfgParam.egtpParams, sizeof(EgtpConfig));
1075 duFillEgtpPst(&pst, EVTCFGREQ);
1076 packEgtpCfgReq(&pst, egtpCfg);
1081 /*******************************************************************
1083 * @brief Function to configure EGTP
1087 * Function : duBuildEgtpCfgReq
1090 * Function to configure EGTP
1093 * @return ROK - success
1096 * ****************************************************************/
1097 uint8_t duHdlEgtpCfgComplete(CmStatus cfm)
1101 if(cfm.status == LCM_PRIM_OK)
1103 DU_LOG("\nDEBUG --> DU_APP : EGTP configuraton complete");
1104 duSendEgtpSrvOpenReq();
1108 DU_LOG("\nERROR --> DU_APP : EGTP configuraton failed");
1115 /*******************************************************************
1117 * @brief Sends server open request to EGTP
1121 * Function : duSendEgtpSrvOpenReq
1124 * Sends server open request to EGTP
1127 * @return ROK - success
1130 * ****************************************************************/
1132 uint8_t duSendEgtpSrvOpenReq()
1136 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP server open request");
1138 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1139 packEgtpSrvOpenReq(&pst);
1144 /*******************************************************************
1146 * @brief Handles server open confirmation
1150 * Function : duHdlEgtpSrvOpenComplete
1153 * Handles server open confirmation
1156 * @return ROK - success
1159 *****************************************************************/
1161 uint8_t duHdlEgtpSrvOpenComplete(CmStatus cfm)
1165 if(cfm.status == LCM_PRIM_OK)
1167 DU_LOG("\nDEBUG --> DU_APP : EGTP server opened successfully");
1171 DU_LOG("\nERROR --> DU_APP : EGTP server opening failed");
1178 /*******************************************************************
1180 * @brief Sends tunnel management request
1184 * Function : duSendEgtpTnlMgmtReq
1187 * Builds and sends tunnel management request to EGTP
1189 * @params[in] Action
1190 * Local tunnel endpoint id
1191 * Remote tunnel endpoint id
1192 * @return ROK - success
1195 * ****************************************************************/
1197 uint8_t duSendEgtpTnlMgmtReq(uint8_t action, uint32_t teIdTobeMod, GtpTnlCfg *ueCbTnlCfg)
1203 DU_LOG("\nDEBUG --> DU_APP : Sending EGTP tunnel management request for teId [%d]", ueCbTnlCfg->teId);
1205 /* ADD/MOD/DEL per tunnel */
1206 tnlEvt.action = action;
1207 tnlEvt.remTeid = ueCbTnlCfg->teId;
1208 if(action != EGTP_TNL_MGMT_ADD)
1210 tnlEvt.lclTeid = teIdTobeMod;
1214 tnlEvt.lclTeid = ueCbTnlCfg->teId;
1216 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1217 ret = egtpTnlMgmtReq(&pst, tnlEvt);
1221 /*******************************************************************
1223 * @brief Handles Tunnel management confirm
1227 * Function : duHdlEgtpTnlMgmtCfm
1230 * Handles tunnel management confirm received from Egtp
1232 * @params[in] Tunnel Event
1233 * @return ROK - success
1236 * ****************************************************************/
1237 uint8_t duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1241 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1243 DU_LOG("\nDEBUG --> DU_APP: Tunnel management confirm OK");
1247 DU_LOG("\nERROR --> DU_APP: Tunnel management failed");
1254 /*******************************************************************
1256 * @brief Sends UL user data over to EGTP
1260 * Function : duSendEgtpDatInd
1262 * Functionality: Sends UL user data over to EGTP
1264 * @params[in] UL data buffer
1265 * @return ROK - success
1268 * ****************************************************************/
1269 uint8_t duSendEgtpDatInd(Buffer *mBuf)
1273 /* Fill EGTP header */
1274 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1275 egtpMsg.msgHdr.nPdu.pres = FALSE;
1276 egtpMsg.msgHdr.seqNum.pres = FALSE;
1277 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1278 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1279 egtpMsg.msgHdr.teId = 1;
1282 egtpHdlDatInd(egtpMsg);
1288 /**************************************************************************
1289 * @brief Function to send configs to SCH
1293 * Function : duSendSchCfg
1296 * Sends general config to Scheduler via MAC layer
1299 * @return ROK - success
1302 ***************************************************************************/
1303 uint8_t duSendSchCfg()
1306 RgSchInstCfg *cfg = NULLP;
1309 DU_SET_ZERO(&pst, sizeof(Pst));
1310 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1312 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1314 /* Filling of Instance Id */
1315 cfg->instId = DEFAULT_CELLS + 1;
1316 /* Filling of Gen config */
1317 cfg->genCfg.mem.region = MAC_MEM_REGION;
1318 cfg->genCfg.mem.pool = MAC_POOL;
1319 cfg->genCfg.tmrRes = 1;
1322 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1323 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1325 cfg->genCfg.startCellId = 1;
1326 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1327 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1328 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1329 cfg->genCfg.lmPst.dstInst = DU_INST;
1330 cfg->genCfg.lmPst.srcEnt = ENTMAC;
1331 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1332 cfg->genCfg.lmPst.prior = PRIOR0;
1333 cfg->genCfg.lmPst.route = RTESPEC;
1334 cfg->genCfg.lmPst.region = MAC_MEM_REGION;
1335 cfg->genCfg.lmPst.pool = MAC_POOL;
1336 cfg->genCfg.lmPst.selector = ODU_SELECTOR_LC;
1339 rgMngmt.hdr.msgType = TCFG;
1340 rgMngmt.hdr.entId.ent = ENTMAC;
1341 rgMngmt.hdr.entId.inst = DU_INST;
1342 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1343 rgMngmt.hdr.response.mem.region = MAC_MEM_REGION;
1344 rgMngmt.hdr.response.mem.pool = MAC_POOL;
1347 pst.selector = ODU_SELECTOR_LC;
1348 pst.srcEnt = ENTDUAPP;
1349 pst.dstEnt = ENTMAC;
1350 pst.dstProcId = DU_PROC;
1351 pst.srcProcId = DU_PROC;
1352 pst.srcInst = DU_INST;
1354 pst.region = duCb.init.region;
1355 pst.event = (Event) EVTMACSCHGENCFGREQ;
1357 DU_LOG("\nDEBUG --> DU_APP : MAC Sch Cfg sent");
1359 /* Send the request to MAC */
1360 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1366 /**************************************************************************
1367 * @brief Function to configure SCTP params and
1368 * responsible for F1 and E2 interfaces
1372 * Function : duLayerConfigComplete
1375 * Configures SCTP Params and responsible for handling
1376 * F1 and E2 interface.
1379 * @return ROK - success
1382 ***************************************************************************/
1383 uint8_t duLayerConfigComplete()
1387 DU_LOG("\nINFO --> DU_APP : Configuring all Layer is complete");
1389 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1391 DU_LOG("\nERROR --> DU_APP : Failed configuring Sctp Params");
1394 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1396 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq F1");
1399 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1401 DU_LOG("\nERROR --> DU_APP : Failed to send AssocReq E2");
1408 /**************************************************************************
1409 * @brief Function to handle SCH Config Confirm from MAC
1413 * Function : duHdlSchCfgComplete
1416 * Handles Scheduler Gen Config Confirm from MAC
1418 * @param[in] Pst *pst, Post structure of the primitive.
1419 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1420 * @return ROK - success
1423 ***************************************************************************/
1424 uint8_t duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1426 if (cfm->cfm.status == LCM_PRIM_OK)
1428 switch (cfm->hdr.elmId.elmnt)
1432 DU_LOG("\nDEBUG --> DU_APP : Received SCH CFG CFM at DU APP");
1439 duLayerConfigComplete();
1440 duBuildEgtpCfgReq();
1444 /**************************************************************************
1445 * @brief Function to fill and send MacCellconfig
1449 * Function : duBuildAndSendMacCellCfg
1452 * Initiates MAC Configs towards MAC
1455 * @return ROK - success
1458 ***************************************************************************/
1459 uint8_t duBuildAndSendMacCellCfg(uint16_t cellId)
1462 MacCellCfg *duMacCellCfg = NULLP;
1464 DU_ALLOC_SHRABL_BUF(duMacCellCfg, sizeof(MacCellCfg));
1465 if(duMacCellCfg == NULLP)
1470 /* store the address in the duCellCb so that we can free on confirm msg */
1471 if(duCb.actvCellLst[cellId-1])
1472 duCb.actvCellLst[cellId-1]->duMacCellCfg = duMacCellCfg;
1475 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, duMacCellCfg, sizeof(MacCellCfg));
1479 /* copy the mac config structure from duCfgParams */
1480 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1483 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_CONFIG_REQ);
1485 /* Send MAC cell config to MAC */
1486 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1489 /**************************************************************************
1490 * @brief Function to Handle MAC cell config confirm
1494 * Function : duHandleMacCellCfgCfm
1497 * Initiates general Configs towards MAC
1500 * @return ROK - success
1503 ***************************************************************************/
1504 uint8_t duHandleMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
1506 uint8_t actvCellIdx = 0;
1509 for(actvCellIdx = 0; actvCellIdx < MAX_NUM_CELL; actvCellIdx++)
1511 if((duCb.actvCellLst[actvCellIdx]) && (macCellCfgCfm->cellId == duCb.actvCellLst[actvCellIdx]->cellId))
1513 duCb.actvCellLst[actvCellIdx]->duMacCellCfg = NULLP;
1516 if(macCellCfgCfm->rsp == ROK)
1518 /* Build and send GNB-DU config update */
1519 ret = BuildAndSendDUConfigUpdate(SERV_CELL_TO_MODIFY);
1521 /* Build and Send Cell Start Req to MAC */
1522 ret = duBuildAndSendMacCellStart();
1526 /* TODO : Action to be taken if cell configuration fails.
1527 * Should CU be informed? */
1529 DU_LOG("\nERROR --> DU_APP : Mac cell cfg failed");
1535 /*******************************************************************
1537 * @brief Builds and sends cell start request to MAC
1541 * Function : duBuildAndSendMacCellStart
1544 * Builds and sends cell start request to MAC
1547 * @return ROK - success
1550 * ****************************************************************/
1551 uint8_t duBuildAndSendMacCellStart()
1554 CellStartInfo *cellStart = NULL;
1556 DU_LOG("\nINFO --> DU APP : Building and Sending cell start request to MAC");
1558 /* Send Cell Start Request to MAC */
1559 DU_ALLOC_SHRABL_BUF(cellStart, sizeof(CellStartInfo));
1562 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell start request");
1566 for(uint8_t id = 0; id < MAX_NUM_CELL; id++)
1568 if(duCb.actvCellLst[id])
1570 cellStart->cellId = duCb.actvCellLst[id]->cellId;
1573 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_START);
1575 return (*packMacCellStartOpts[pst.selector])(&pst, cellStart);
1581 /*******************************************************************
1583 * @brief Builds and sends cell stop request to MAC
1587 * Function : duBuildAndSendMacCellStop
1590 * Builds and sends cell stop request to MAC
1593 * @return ROK - success
1596 * ****************************************************************/
1597 uint8_t duBuildAndSendMacCellStop(uint16_t cellId)
1601 CellStopInfo *cellStop = NULL;
1603 DU_LOG("\nINFO --> DU APP : Building and Sending cell stop request to MAC");
1605 GET_CELL_IDX(cellId, cellIdx);
1606 if(duCb.actvCellLst[cellIdx] != NULLP)
1608 /* Send Cell Stop Request to MAC */
1609 DU_ALLOC_SHRABL_BUF(cellStop, sizeof(CellStopInfo));
1612 DU_LOG("\nERROR --> DU APP : Memory alloc failed while building cell stop request");
1615 memset(cellStop, 0, sizeof(CellStopInfo));
1616 cellStop->cellId = duCb.actvCellLst[cellIdx]->cellId;
1619 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_CELL_STOP);
1621 return (*packMacCellStopOpts[pst.selector])(&pst, cellStop);
1625 DU_LOG("\nERROR --> DU APP : duBuildAndSendMacCellStop(): cellId[%d] doesnot exists", cellId);
1631 /*******************************************************************
1633 * @brief Handles stop indication from MAC
1637 * Function : duHandleStopInd
1640 * Handles stop indication from MAC
1642 * @params[in] Post structure pointer
1643 * @return ROK - success
1646 * ****************************************************************/
1647 uint8_t duHandleStopInd(Pst *pst, OduCellId *cellId)
1649 DuCellCb *cellCb = NULLP;
1651 if(cellId->cellId <=0 || cellId->cellId > MAX_NUM_CELL)
1653 DU_LOG("\nERROR --> DU APP : Invalid Cell Id %d in duHandleStopInd()", cellId->cellId);
1656 if(duGetCellCb(cellId->cellId, &cellCb) != ROK)
1659 if((cellCb->cellStatus == ACTIVATED) || (cellCb->cellStatus == DELETION_IN_PROGRESS))
1661 DU_LOG("\nINFO --> DU APP : 5G-NR Cell %d is DOWN", cellId->cellId);
1662 if(sendCellDeleteReqToMac(cellId->cellId) == RFAILED)
1664 DU_LOG("\nERROR --> DU APP : duHandleStopInd(): Failed to send Cell delete req to MAC for\
1665 cellId[%d]", cellId->cellId);
1671 DU_LOG("\nINFO --> DU APP : Raise cell down alarm for cell id=%d", cellId->cellId);
1672 raiseCellAlrm(CELL_DOWN_ALARM_ID, cellId->cellId);
1673 setCellOpState(cellId->cellId, DISABLED, INACTIVE);
1677 if((pst->selector == ODU_SELECTOR_LWLC) || (pst->selector == ODU_SELECTOR_TC))
1678 DU_FREE_SHRABL_BUF(MAC_MEM_REGION, pst->pool, cellId, sizeof(OduCellId));
1680 cellCb->cellStatus = CELL_OUT_OF_SERVICE; //TODO: cell status must be set to OOS after all UE and cell cleanup which is not
1686 /*******************************************************************
1688 * @brief Handles slot indication from MAC
1692 * Function : duHandleUlCcchInd
1695 * Handles UL CCCH indication from MAC
1697 * @params[in] Post structure pointer
1698 * UL CCCH Ind pointer
1699 * @return ROK - success
1702 * ****************************************************************/
1703 uint8_t duHandleUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
1706 DU_LOG("\nINFO --> DU APP : UL CCCH Indication received");
1708 return (duProcUlCcchInd(ulCcchIndInfo));
1711 /*******************************************************************
1713 * @brief Process UL RRC Message from RLC
1717 * Function : DuProcRlcUlRrcMsgTrans
1719 * Functionality: Process UL RRC Message from RLC
1721 * @params[in] Post structure
1722 * UL RRC Message Info
1723 * @return ROK - success
1726 * ****************************************************************/
1727 uint8_t DuProcRlcUlRrcMsgTrans(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
1730 DuCellCb *cellCb = NULLP;
1731 DuUeCb *ueCb = NULLP;
1733 duGetCellCb(ulRrcMsgInfo->cellId, &cellCb);
1736 if(ulRrcMsgInfo->ueId > 0)
1738 if(cellCb->ueCb[ulRrcMsgInfo->ueId -1].gnbDuUeF1apId == ulRrcMsgInfo->ueId)
1739 ueCb = &cellCb->ueCb[ulRrcMsgInfo->ueId -1];
1743 /* If UL message is received for a UE in handover, it signifies that UE is now
1744 * attached to GNB. Hence marking this UE as active and requesting MAC to
1745 * release the dedicated RACH resources */
1746 if(ueCb->ueState == UE_HANDIN_IN_PROGRESS)
1748 ueCb->ueState = UE_ACTIVE;
1749 cellCb->numActvUes++;
1751 /* Release RACH resources */
1752 memset(&ueCb->cfraResource, 0, sizeof(MacCfraResource));
1753 if(duBuildAndSendRachRsrcRelToMac(ulRrcMsgInfo->cellId, ueCb) != ROK)
1755 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to send RACH resource release to MAC");
1759 if(BuildAndSendULRRCMessageTransfer(ueCb, ulRrcMsgInfo->lcId, ulRrcMsgInfo->msgLen, ulRrcMsgInfo->rrcMsg) != ROK)
1761 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Failed to build and send UL RRC Message Transfer");
1767 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : UE ID [%d] not found", ulRrcMsgInfo->ueId);
1773 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Invalid UE ID [%d]", ulRrcMsgInfo->ueId);
1779 DU_LOG("\nERROR --> DU_APP : DuProcRlcUlRrcMsgTrans() : Cell ID [%d] not found", ulRrcMsgInfo->cellId);
1783 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo->rrcMsg, ulRrcMsgInfo->msgLen);
1784 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
1788 /*******************************************************************
1790 * @brief Process RRC delivery report from RLC
1794 * Function : DuProcRlcRrcDeliveryReport
1796 * Functionality: Process RRC delivery Message from RLC
1798 * @params[in] Post structure
1799 * UL RRC Message Info
1800 * @return ROK - success
1803 * ****************************************************************/
1804 uint8_t DuProcRlcRrcDeliveryReport(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
1806 DuCellCb *cellCb = NULLP;
1808 uint8_t ret = RFAILED;
1810 if(duGetCellCb(rrcDeliveryReport->cellId, &cellCb) != ROK)
1813 ueCb = cellCb->ueCb[rrcDeliveryReport->ueId -1];
1814 ret = BuildAndSendRrcDeliveryReport(ueCb.gnbCuUeF1apId, ueCb.gnbDuUeF1apId,rrcDeliveryReport);
1816 DU_FREE_SHRABL_BUF(pst->region, pst->pool, rrcDeliveryReport, sizeof(RrcDeliveryReport));
1820 /*******************************************************************
1822 * @brief Process UL user data from RLC
1826 * Function : DuProcRlcUlUserDataTrans
1828 * Functionality: Process UL user data from RLC
1830 * @params[in] Post structure
1832 * @return ROK - success
1835 * ****************************************************************/
1836 uint8_t DuProcRlcUlUserDataTrans(Pst *pst, RlcUlUserDatInfo *ulUserData)
1842 DU_LOG("\nDEBUG --> DU APP : Received UL user data");
1844 /* Fill EGTP header */
1845 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1846 egtpMsg.msgHdr.nPdu.pres = FALSE;
1847 egtpMsg.msgHdr.seqNum.pres = FALSE;
1848 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1849 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1851 /* Fetch EGTP tunnel info */
1852 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
1854 /*TODO: If multiple Cell Support is enables then CellId also needs to be validated alongwith ueId and DrbId*/
1855 if((duCb.upTnlCfg[teIdx] != NULLP) && (duCb.upTnlCfg[teIdx]->ueId == ulUserData->ueId) && \
1856 (duCb.upTnlCfg[teIdx]->drbId == ulUserData->rbId))
1858 if(duCb.upTnlCfg[teIdx]->tnlCfg1)
1860 egtpMsg.msgHdr.teId = duCb.upTnlCfg[teIdx]->tnlCfg1->teId; /*As we are supporting only 1 tunnel per DRB*/
1866 if (ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) != ROK)
1868 DU_LOG("\nERROR --> DU APP : Failed to allocated buffer memory in DuProcRlcUlUserDataTrans");
1869 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1870 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1873 oduCpyFixBufToMsg(ulUserData->userData, mBuf, ulUserData->msgLen);
1874 ODU_PRINT_MSG(mBuf, 0, 0);
1876 egtpHdlDatInd(egtpMsg);
1878 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData->userData, ulUserData->msgLen);
1879 DU_FREE_SHRABL_BUF(pst->region, pst->pool, ulUserData, sizeof(RlcUlUserDatInfo));
1883 /*******************************************************************
1885 * @brief process the slice cfg rsp received from MAC
1889 * Function : DuProcMacSliceCfgRsp
1891 * Functionality: process the slice cfg rsp received from MAC
1893 * @params[in] Post structure, MacSliceCfgRsp *cfgRsp
1895 * @return ROK - success
1898 **********************************************************************/
1899 uint8_t DuProcMacSliceCfgRsp(Pst *pst, MacSliceCfgRsp *cfgRsp)
1903 if(cfgRsp->rsp == MAC_DU_APP_RSP_OK)
1905 duCb.sliceState = SLICE_CONFIGURED;
1906 DU_LOG("\nINFO --> DU_APP : Slice configured successfully ");
1910 DU_LOG("\nERROR --> DU_APP : Slice not available");
1912 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, cfgRsp, sizeof(MacSliceCfgRsp));
1917 /*******************************************************************
1919 * @brief Fill the slice configration and rrm policy related
1920 * information received form O1
1924 * Function : BuildAndSendSliceConfigReq
1926 * Functionality: Fill the slice configration and rrm policy related
1928 * @params[in] RrmPolicy *rrmPolicy[], uint8_t totalRrmPolicy, uint8_t
1931 * @return ROK - success
1934 * ****************************************************************/
1935 uint8_t BuildAndSendSliceConfigReq()
1938 MacSliceCfgReq *sliceCfgReq;
1940 DU_ALLOC_SHRABL_BUF(sliceCfgReq, sizeof(MacSliceCfgReq));
1941 if(sliceCfgReq == NULLP)
1943 DU_LOG("\nERROR --> DU_APP : Memory allocation failed in BuildAndSendSliceConfigReq");
1948 memcpy(sliceCfgReq, &duCfgParam.tempSliceCfg, sizeof(MacSliceCfgReq));
1949 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_CFG_REQ);
1951 DU_LOG("\nDEBUG --> DU_APP : Sending Slice Cfg Request to MAC ");
1952 if((*packMacSliceCfgReqOpts[pst.selector])(&pst, sliceCfgReq) == RFAILED)
1954 DU_LOG("\nERROR --> DU_APP : Failed to send Slice Cfg Req to MAC");
1955 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceCfgReq, sizeof(MacSliceCfgReq));
1961 /*******************************************************************
1963 * @brief Fill the slice configration and rrm policy related
1964 * information received form O1
1968 * Function : BuildAndSendSliceRecfgReq
1970 * Functionality: Fill the slice configration and rrm policy related
1972 * @params[in] RrmPolicy rrmPolicy[], uint8_t totalSliceCount
1974 * @return ROK - success
1977 * ****************************************************************/
1978 uint8_t BuildAndSendSliceRecfgReq()
1981 MacSliceRecfgReq *sliceRecfgReq = NULLP;
1983 DU_LOG("\nINFO --> DU_APP : Slice ReConfiguration Request received");
1985 DU_ALLOC_SHRABL_BUF(sliceRecfgReq, sizeof(MacSliceRecfgReq));
1986 if(sliceRecfgReq == NULLP)
1988 DU_LOG("\nERROR --> DU_APP : Memory allocation failed to BuildAndSendSliceRecfgReq");
1993 memcpy(sliceRecfgReq, &duCfgParam.tempSliceCfg, sizeof(MacSliceRecfgReq));
1995 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_SLICE_RECFG_REQ);
1997 DU_LOG("\nDEBUG --> DU_APP: Sending Slice ReCfg Request to MAC ");
1998 if( (*packMacSliceRecfgReqOpts[pst.selector])(&pst, sliceRecfgReq) == RFAILED)
2000 DU_LOG("\nERROR --> DU_APP: Failed to send Slice ReCfg Req to MAC");
2001 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, sliceRecfgReq, sizeof(MacSliceRecfgReq));
2006 /*******************************************************************
2008 * @brief process the slice ReCfg rsp received from MAC
2012 * Function : DuProcMacSliceRecfgRsp
2014 * Functionality: process the slice ReCfg rsp received from MAC
2016 * @params[in] Post structure, MacSliceRecfgRsp *ReCfgRsp
2018 * @return ROK - success
2021 **********************************************************************/
2022 uint8_t DuProcMacSliceRecfgRsp(Pst *pst, MacSliceRecfgRsp *recfgRsp)
2026 if(recfgRsp->rsp == MAC_DU_APP_RSP_OK)
2028 duCb.sliceState = SLICE_RECONFIGURED;
2029 DU_LOG("\nINFO --> DU_APP : Slice Reconfigured successfully ");
2033 DU_LOG("\nERROR --> DU_APP : Slice not available");
2035 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, recfgRsp, sizeof(MacSliceCfgRsp));
2040 /*******************************************************************
2042 * @brief Handles received Slice Metrics from RLC and forward it to O1
2046 * Function : DuProcRlcSliceMetrics
2049 * Handles received Slice Metrics from RLC and forward it to O1
2051 * @params[in] Post structure pointer
2052 * SlicePmList *sliceStats
2054 * @return ROK - success
2057 * ****************************************************************/
2058 uint8_t DuProcRlcSliceMetrics(Pst *pst, SlicePmList *sliceStats)
2060 uint8_t sliceRecord = 0;
2062 DU_LOG("\nDEBUG --> DU APP : Received Slice Metrics");
2063 if(sliceStats == NULLP)
2065 DU_LOG("\nERROR --> DU APP : Empty Metrics");
2069 for(sliceRecord = 0; sliceRecord < sliceStats->numSlice; sliceRecord++)
2071 DU_LOG("\nINFO --> DU_APP: SliceId[SST-SD]:%d-%d, DlTput %.5lf, UlTput:%.5lf", sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sst,\
2072 sliceStats->sliceRecord[sliceRecord].networkSliceIdentifier.sd,sliceStats->sliceRecord[sliceRecord].ThpDl,\
2073 sliceStats->sliceRecord[sliceRecord].ThpUl);
2078 sendSliceMetric((SliceMetricList*) sliceStats);
2082 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats->sliceRecord, (sliceStats->numSlice) * (sizeof(SlicePm)));
2083 DU_FREE_SHRABL_BUF(pst->region, pst->pool,sliceStats, sizeof(SlicePmList));
2089 /*******************************************************************
2091 * @brief Send Statistics request to MAC
2095 * Function : BuildAndSendStatsReqToMac()
2097 * Functionality: Send Statistics Request To Mac
2101 * @return ROK - success
2104 * ****************************************************************/
2105 uint8_t BuildAndSendStatsReqToMac(RicSubscription *ricSubscriptionInfo)
2108 MacStatsReq *macStatsReq = NULLP;
2110 /* Fill MAC statistics request */
2111 DU_ALLOC_SHRABL_BUF(macStatsReq, sizeof(MacStatsReq));
2112 if(macStatsReq == NULLP)
2114 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for macStatsReq in BuildAndSendStatsReqToMac");
2118 /* Fill E2 Subscription Info in MAC Statistics Request and send to MAC */
2119 if(fillRicSubsInMacStatsReq(macStatsReq, ricSubscriptionInfo) == ROK)
2121 DU_LOG("\nDEBUG --> DU_APP: Sending Statistics Request to MAC ");
2122 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_STATISTICS_REQ);
2124 if( (*packMacStatsReqOpts[pst.selector])(&pst, macStatsReq) == ROK)
2127 DU_LOG("\nERROR --> DU_APP: Failed to send Statistics Request to MAC");
2130 DU_LOG("\nERROR --> DU_APP: No Statistics group found valid. Hence statistics request is not sent to MAC");
2131 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macStatsReq, sizeof(MacStatsReq));
2135 /*******************************************************************
2137 * @brief Send Statistics request to DU layers
2141 * Function : BuildAndSendStatsReq()
2143 * Functionality: Check if there is an update in statistics
2144 * reporting configuration. If so, send the update to
2147 * @params[in] Subscription Info
2149 * @return ROK - success
2152 * ****************************************************************/
2153 uint8_t BuildAndSendStatsReq(RicSubscription *ricSubscriptionInfo)
2155 /* Build and sent subscription information to MAC in Statistics Request */
2156 if(BuildAndSendStatsReqToMac(ricSubscriptionInfo) != ROK)
2158 DU_LOG("\nERROR --> DU_APP : Failed at BuildAndSendStatsReqToMac()");
2162 /* TODO : When KPI collection from RLC will be supported, this function will be
2163 * called to configure KPIs to be colled */
2165 if(BuildAndSendStatsReqToRlc() != ROK)
2167 DU_LOG("\nERROR --> DU_APP : Failed at BuildAndSendStatsReqToRlc()");
2175 /*******************************************************************
2177 * @brief Process statistics response from MAC
2181 * Function : DuProcMacStatsRsp
2183 * Functionality: Processes statistics configuration response
2184 * from MAC. If configuration is succsessful, DUAPP starts
2185 * reporting period timer for this subscription request
2190 * @return ROK - success
2193 * ****************************************************************/
2194 uint8_t DuProcMacStatsRsp(Pst *pst, MacStatsRsp *statsRsp)
2196 uint8_t ret = RFAILED;
2197 DU_LOG("\nINFO --> DU_APP : DuProcMacStatsRsp: Received Statistics Response from MAC");
2203 DU_LOG("\n Subscription Id [%ld]", statsRsp->subscriptionId);
2205 DU_LOG("\n Number of Accepted Groups [%d]", statsRsp->numGrpAccepted);
2206 for(idx=0; idx<statsRsp->numGrpAccepted; idx++)
2208 DU_LOG("\n Group Id [%d]", statsRsp->statsGrpAcceptedList[idx]);
2211 DU_LOG("\n Number of Rejected Groups [%d]", statsRsp->numGrpRejected);
2212 for(idx=0; idx<statsRsp->numGrpRejected; idx++)
2214 DU_LOG("\n Group Id [%d]", statsRsp->statsGrpRejectedList[idx].groupId);
2218 /* Check the list of accepted and rejected statistics group and send
2219 * Ric subscription response/failure accordingly */
2220 if((ret = e2ProcStatsRsp(statsRsp)) != ROK)
2222 DU_LOG("\nERROR --> DU_APP : DuProcMacStatsRsp: Failed in %s at line %d", __func__, __LINE__);
2225 DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsRsp, sizeof(MacStatsRsp));
2229 DU_LOG("\nERROR --> DU_APP : DuProcMacStatsRsp: Received NULL Pointer");
2234 /*******************************************************************
2236 * @brief Process statistics indication from MAC
2240 * Function : DuProcMacStatsInd
2242 * Functionality: Processes statistics indication from MAC.
2246 * @return ROK - success
2249 * ****************************************************************/
2250 uint8_t DuProcMacStatsInd(Pst *pst, MacStatsInd *statsInd)
2252 uint8_t ret = RFAILED;
2257 DU_LOG("\nDEBUG --> DU_APP : DuProcMacStatsInd: Received Statistics Indication");
2258 DU_LOG("\n Subscription Id [%ld]", statsInd->subscriptionId);
2259 DU_LOG("\n Group Id [%d]", statsInd->groupId);
2260 for(int idx = 0; idx < statsInd->numStats; idx++)
2262 DU_LOG("\n Meas type [%d] Meas Value [%lf]", statsInd->measuredStatsList[idx].type,\
2263 statsInd->measuredStatsList[idx].value);
2267 /* Extract statistics from statistics indication message and store in E2 DB */
2268 if((ret = e2ProcStatsInd(statsInd)) != ROK)
2270 DU_LOG("\nINFO --> DU_APP : Failed in %s at line %d", __func__, __LINE__);
2273 /* Free statistics indication */
2274 DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsInd, sizeof(MacStatsInd));
2278 DU_LOG("\nINFO --> DU_APP : DuProcMacStatsInd: Received NULL Pointer");
2283 /*******************************************************************
2285 * @brief Process statistics delete response from MAC
2289 * Function : DuProcMacStatsDeleteRsp
2291 * Functionality: Processes statistics delete response
2296 * Mac stats delete rsp
2298 * @return ROK - success
2301 * ****************************************************************/
2303 uint8_t DuProcMacStatsDeleteRsp(Pst *pst, MacStatsDeleteRsp *statsDeleteRsp)
2305 uint8_t ret = RFAILED;
2306 DU_LOG("\nINFO --> DU_APP : DuProcMacStatsDeleteRsp: Received Statistics Response from MAC");
2310 if((ret = e2ProcStatsDeleteRsp(statsDeleteRsp)) != ROK)
2312 DU_LOG("\nINFO --> DU_APP : Failed in %s at line %d", __func__, __LINE__);
2314 DU_FREE_SHRABL_BUF(pst->region, pst->pool, statsDeleteRsp, sizeof(MacStatsDeleteRsp));
2318 DU_LOG("\nERROR --> DU_APP : DuProcMacStatsDeleteRsp: Received NULL Pointer");
2323 /*******************************************************************
2325 * @brief Send Statistics delete req to MAC
2329 * Function : BuildAndSendStatsDeleteReqToMac()
2331 * Functionality: Send Statistics delete req To Mac
2335 * @return ROK - success
2338 * ****************************************************************/
2339 uint8_t BuildAndSendStatsDeleteReqToMac(RicSubscription *ricSubscriptionInfo)
2342 MacStatsDeleteReq *macStatsDelete = NULLP;
2344 /* Fill MAC statistics delete */
2345 DU_ALLOC_SHRABL_BUF(macStatsDelete, sizeof(MacStatsDeleteReq));
2346 if(macStatsDelete == NULLP)
2348 DU_LOG("\nERROR --> DU_APP : Memory allocation failed for macStatsDelete in BuildAndSendStatsDeleteReqToMac");
2352 /* Generate subscription ID using RIC Request ID and RAN Function ID */
2353 encodeSubscriptionId(&macStatsDelete->subscriptionId, ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId);
2355 DU_LOG("\nDEBUG --> DU_APP: Sending Statistics delete req to MAC ");
2356 FILL_PST_DUAPP_TO_MAC(pst, EVENT_MAC_STATS_DELETE_REQ);
2358 if( (*packMacStatsDeleteReqOpts[pst.selector])(&pst, macStatsDelete) != ROK)
2360 DU_LOG("\nERROR --> DU_APP: Failed to send Statistics delete req to MAC");
2361 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, macStatsDelete, sizeof(MacStatsDeleteReq));
2369 /*******************************************************************
2371 * @brief Statistics delete to DU layers
2375 * Function : BuildAndSendStatsDeleteReq()
2377 * Functionality: Statistics delete to DU layers
2379 * @params[in] Subscription Info
2381 * @return ROK - success
2384 * ****************************************************************/
2385 uint8_t BuildAndSendStatsDeleteReq(RicSubscription *ricSubscriptionInfo)
2387 /* Build and sent subscription information to MAC in Statistics delete */
2388 if(BuildAndSendStatsDeleteReqToMac(ricSubscriptionInfo) != ROK)
2390 DU_LOG("\nERROR --> DU_APP : Failed at BuildAndSendStatsDeleteReqToMac()");
2396 /**********************************************************************
2398 **********************************************************************/