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 */
23 #include "du_f1ap_msg_hdl.h"
26 #include "lphy_stub.h"
35 extern DuCfgParams duCfgParam;
36 extern S16 cmPkLkwCfgReq(Pst *pst, KwMngmt *cfg);
37 extern S16 cmPkLkwCntrlReq(Pst *pst, KwMngmt *cfg);
38 extern S16 cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
39 extern S16 BuildAndSendE2SetupReq();
40 extern S16 egtpHdlDatInd(EgtpMsg egtpMsg);
41 extern S16 BuildAndSendDUConfigUpdate();
42 extern U16 getTransId();
43 extern S16 cmPkLrgSchCfgReq(Pst * pst,RgMngmt * cfg);
45 packMacCellCfgReq packMacCellCfgOpts[] =
47 packMacCellCfg, /* packing for loosely coupled */
48 MacHdlCellCfgReq, /* packing for tightly coupled */
49 packMacCellCfg, /* packing for light weight loosly coupled */
52 DuMacCellStartReq packMacCellStartReqOpts[] =
54 packMacCellStartReq, /* Loose coupling */
55 MacHdlCellStartReq, /* TIght coupling */
56 packMacCellStartReq /* Light weight-loose coupling */
59 DuMacCellStopReq packMacCellStopReqOpts[] =
61 packMacCellStopReq, /* Loose coupling */
62 MacHdlCellStopReq, /* TIght coupling */
63 packMacCellStopReq /* Light weight-loose coupling */
66 /**************************************************************************
67 * @brief Function to fill configs required by RLC
71 * Function : duBuildRlcCfg
74 * Initiates general Configs towards RLC
76 * @param[in] Inst Specifies if RLC UL or RLC DL instance
77 * @return ROK - success
80 ***************************************************************************/
81 S16 duBuildRlcCfg(Inst inst)
84 KwGenCfg *genCfg = NULLP;
87 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
88 DU_SET_ZERO(&pst, sizeof(Pst));
90 genCfg = &(kwMngmt.t.cfg.s.gen);
92 /*----------- Fill General Configuration Parameters ---------*/
93 genCfg->maxUe = duCfgParam.maxUe;
94 genCfg->maxKwuSaps = 2;
95 genCfg->maxUdxSaps = 1;
96 genCfg->rlcMode = (inst == RLC_UL_INST) ?
97 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
99 genCfg->maxRguSaps = DEFAULT_CELLS;
101 /*----------- Fill lmPst
102 * Parameters ---------*/
103 genCfg->lmPst.dstProcId = DU_PROC;
104 genCfg->lmPst.srcProcId = DU_PROC;
105 genCfg->lmPst.dstEnt = ENTDUAPP;
106 genCfg->lmPst.dstInst = DU_INST;
107 genCfg->lmPst.srcEnt = ENTKW;
108 genCfg->lmPst.srcInst = inst;
109 genCfg->lmPst.prior = PRIOR0;
110 genCfg->lmPst.route = RTESPEC;
111 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
112 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
113 genCfg->lmPst.pool = RLC_POOL;
114 genCfg->lmPst.selector = DU_SELECTOR_LC;
117 kwMngmt.hdr.msgType = TCFG;
118 kwMngmt.hdr.msgLen = 0;
119 kwMngmt.hdr.entId.ent = ENTKW;
120 kwMngmt.hdr.entId.inst = (Inst)0;
121 kwMngmt.hdr.elmId.elmnt = STGEN;
122 kwMngmt.hdr.seqNmb = 0;
123 kwMngmt.hdr.version = 0;
124 kwMngmt.hdr.transId = 0;
125 kwMngmt.hdr.response.prior = PRIOR0;
126 kwMngmt.hdr.response.route = RTESPEC;
127 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
128 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
129 kwMngmt.hdr.response.mem.pool = DU_POOL;
130 kwMngmt.hdr.response.selector = DU_SELECTOR_LC;
133 pst.selector = DU_SELECTOR_LC;
134 pst.srcEnt = ENTDUAPP;
137 pst.dstProcId = DU_PROC;
138 pst.srcProcId = DU_PROC;
139 pst.region = duCb.init.region;
141 DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
143 /* Send the request to RLC */
144 cmPkLkwCfgReq(&pst, &kwMngmt);
149 /**************************************************************************
150 * @brief Function to fill configs required by RLC
154 * Function : duBuildRlcLsapCfg
157 * Initiates general Configs towards RLC
159 * @param[in] Inst Specifies if RLC UL or RLC DL instance
160 * @return ROK - success
163 ***************************************************************************/
164 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
168 KwSapCfg *lSap = NULLP;
171 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
172 DU_SET_ZERO(&pst, sizeof(Pst));
175 kwMngmt.hdr.msgType = TCFG;
176 kwMngmt.hdr.entId.ent = ENTKW;
177 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
178 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
180 kwMngmt.hdr.response.mem.pool = RLC_POOL;
183 pst.selector = DU_SELECTOR_LC;
184 pst.srcEnt = ENTDUAPP;
186 pst.dstProcId = DU_PROC;
188 pst.srcProcId = DU_PROC;
189 pst.region = duCb.init.region;
190 lSap = &(kwMngmt.t.cfg.s.sap);
192 lSap->mem.region = (inst == RLC_UL_INST) ?
193 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
194 lSap->mem.pool = RLC_POOL;
196 lSap->bndTmrIntvl = 10;
197 lSap->priority = PRIOR0;
198 lSap->route = RTESPEC;
201 lSap->procId = DU_PROC;
203 lSap->inst = lsapInst;
204 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
205 lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
206 kwMngmt.hdr.elmId.elmnt = STRGUSAP;
207 DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
212 lSap->procId = DU_PROC;
214 lSap->inst = (inst == RLC_UL_INST) ?
215 RLC_DL_INST : RLC_UL_INST;
217 lSap->selector = DU_SELECTOR_LC;
218 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
219 DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
222 cmPkLkwCfgReq(&pst, &kwMngmt);
226 /**************************************************************************
227 * @brief Function to fill configs required by RLC
231 * Function : duBuildRlcUsapCfg
234 * Initiates general Configs towards RLC
236 * @param[in] Inst Specifies if RLC UL or RLC DL instance
237 * @return ROK - success
240 ***************************************************************************/
241 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
244 KwSapCfg *uSap = NULLP;
247 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
248 DU_SET_ZERO(&pst, sizeof(Pst));
250 uSap = &(kwMngmt.t.cfg.s.sap);
252 uSap->selector = DU_SELECTOR_LC;
253 uSap->mem.region = (inst == RLC_UL_INST) ?
254 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
255 uSap->mem.pool = RLC_POOL;
258 uSap->procId = DU_PROC;
262 uSap->inst = (inst == RLC_UL_INST) ?
263 RLC_DL_INST : RLC_UL_INST;
264 uSap->bndTmrIntvl = 1000;
265 uSap->priority = PRIOR0;
266 uSap->route = RTESPEC;
269 kwMngmt.hdr.msgType = TCFG;
270 kwMngmt.hdr.entId.ent = ENTKW;
271 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
272 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
273 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
275 kwMngmt.hdr.response.mem.pool = RLC_POOL;
278 pst.selector = DU_SELECTOR_LC;
279 pst.srcEnt = ENTDUAPP;
281 pst.dstProcId = DU_PROC;
283 pst.srcProcId = DU_PROC;
284 pst.region = duCb.init.region;
286 DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
287 cmPkLkwCfgReq(&pst, &kwMngmt);
292 /**************************************************************************
293 * @brief Function to populate internal DS of DU APP
297 * Function : duProcCfgComplete
300 * Populates internal data structures of DU APP after
301 * receiving configurations.
304 * @return ROK - success
307 ***************************************************************************/
308 S16 duProcCfgComplete()
311 static U16 cellId = 0;
313 for(idx=0; idx< DEFAULT_CELLS; idx++)
316 DU_ALLOC(cell, sizeof(DuCellCb))
319 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
326 memset(cell, 0, sizeof(DuCellCb));
327 cell->cellId = cellId++;
328 cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0;
329 cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1;
330 cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2;
331 cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0;
332 cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1;
333 cell->cellInfo.nrEcgi.plmn.mnc[2] = PLMN_MNC2;
334 cell->cellInfo.nrEcgi.cellId = NR_CELL_ID;
335 cell->cellInfo.nrPci = NR_PCI;
336 cell->cellInfo.fiveGsTac = DU_TAC;
337 for(idx1=0; idx1<MAX_PLMN; idx1++)
339 cell->cellInfo.plmn[idx1].mcc[0] = PLMN_MCC0;
340 cell->cellInfo.plmn[idx1].mcc[1] = PLMN_MCC1;
341 cell->cellInfo.plmn[idx1].mcc[2] = PLMN_MCC2;
342 cell->cellInfo.plmn[idx1].mnc[0] = PLMN_MNC0;
343 cell->cellInfo.plmn[idx1].mnc[1] = PLMN_MNC1;
344 cell->cellInfo.plmn[idx1].mnc[2] = PLMN_MNC2;
346 cell->cellInfo.maxUe = duCfgParam.maxUe;
347 cell->cellStatus = CELL_OUT_OF_SERVICE;
348 nci = (U16)cell->cellInfo.nrEcgi.cellId;
350 duCb.cfgCellLst[nci-1] = cell;
355 //Start layer configs
356 ret = duSendRlcUlCfg();
360 /**************************************************************************
361 * @brief Function to invoke DU Layer Configs
365 * Function : duSendRlcUlCfg
368 * Initiates Configs towards layers of DU
371 * @return ROK - success
374 ***************************************************************************/
379 duBuildRlcCfg((Inst)RLC_UL_INST);
380 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
382 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
384 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
389 /**************************************************************************
390 * @brief Function to invoke DU Layer Configs
394 * Function : duSendRlcDlCfg
397 * Initiates Configs towards layers of DU
400 * @return ROK - success
403 ***************************************************************************/
408 duBuildRlcCfg((Inst)RLC_DL_INST);
409 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
410 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
412 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
417 /**************************************************************************
418 * @brief Function to handle Config Confirm from RLC
422 * Function : duHdlRlcCfgComplete
425 * Handles Gen Config Confirm from RLC
427 * @param[in] Pst *pst, Post structure of the primitive.
428 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
429 * @return ROK - success
432 ***************************************************************************/
433 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
436 if (pst->srcInst == RLC_UL_INST)
438 ret = duProcRlcUlCfgComplete(pst, cfm);
442 ret = duProcRlcDlCfgComplete(pst, cfm);
447 /**************************************************************************
448 * @brief Function to handle Control Config Confirm from RLC
452 * Function : duHdlRlcCntrlCfgComplete
455 * Handles Control Config Confirm from RLC
457 * @param[in] Pst *pst, Post structure of the primitive.
458 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
459 * @return ROK - success
462 ***************************************************************************/
463 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
467 if (cntrl->cfm.status == LCM_PRIM_OK)
469 switch (cntrl->hdr.elmId.elmnt)
473 if (pst->srcInst == RLC_DL_INST)
475 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
477 if(macCfgInst < DEFAULT_CELLS)
480 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
484 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
489 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
491 if(macCfgInst < DEFAULT_CELLS)
493 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
507 /**************************************************************************
508 * @brief Function to handle Config Confirm from RLC UL
512 * Function : duHdlRlcUlCfgComplete
515 * Handles Config Confirm from RLC UL
517 * @param[in] Pst *pst, Post structure of the primitive.
518 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
519 * @return ROK - success
522 ***************************************************************************/
523 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
527 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
528 if (cfm->cfm.status == LCM_PRIM_OK)
530 switch(cfm->hdr.elmId.elmnt)
534 rlcUlCfg |= RLC_GEN_CFG;
540 if(numRlcMacSaps == DEFAULT_CELLS)
542 rlcUlCfg |= RLC_MAC_SAP_CFG;
549 rlcUlCfg |= RLC_UDX_SAP_CFG;
556 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
557 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
561 //Start configuration of RLC DL
568 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
574 /**************************************************************************
575 * @brief Function to handle Config Confirm from RLC DL
579 * Function : duHdlRlcDlCfgComplete
582 * Handles Config Confirm from RLC DL
584 * @param[in] Pst *pst, Post structure of the primitive.
585 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
586 * @return ROK - success
589 ***************************************************************************/
590 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
592 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
593 if (cfm->cfm.status == LCM_PRIM_OK)
595 switch(cfm->hdr.elmId.elmnt)
599 rlcDlCfg |= RLC_GEN_CFG;
605 if(numRlcMacSaps == DEFAULT_CELLS)
607 rlcDlCfg |= RLC_MAC_SAP_CFG;
614 rlcDlCfg |= RLC_UDX_SAP_CFG;
622 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
623 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
626 //Start configuration of MAC
633 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
638 /**************************************************************************
639 * @brief Function to send configs to MAC
643 * Function : duSendMacCfg
646 * Initiates Configs towards MAC layer
649 * @return ROK - success
652 ***************************************************************************/
656 duBuildMacUsapCfg(RLC_UL_INST);
657 duBuildMacUsapCfg(RLC_DL_INST);
662 /**************************************************************************
663 * @brief Function to fill gen config required by MAC
667 * Function : duBuildMacGenCfg
670 * Initiates general Configs towards MAC
673 * @return ROK - success
676 ***************************************************************************/
677 S16 duBuildMacGenCfg()
680 RgGenCfg *genCfg=NULLP;
683 DU_SET_ZERO(&pst, sizeof(Pst));
684 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
686 genCfg = &(rgMngmt.t.cfg.s.genCfg);
688 /*----------- Fill General Configuration Parameters ---------*/
689 genCfg->mem.region = RG_MEM_REGION;
690 genCfg->mem.pool = RG_POOL;
692 genCfg->numRguSaps = 2;
694 genCfg->lmPst.dstProcId = DU_PROC;
695 genCfg->lmPst.srcProcId = DU_PROC;
696 genCfg->lmPst.dstEnt = ENTDUAPP;
697 genCfg->lmPst.dstInst = 0;
698 genCfg->lmPst.srcEnt = ENTRG;
699 genCfg->lmPst.srcInst = macCfgInst;
700 genCfg->lmPst.prior = PRIOR0;
701 genCfg->lmPst.route = RTESPEC;
702 genCfg->lmPst.region = RG_MEM_REGION;
703 genCfg->lmPst.pool = RG_POOL;
704 genCfg->lmPst.selector = DU_SELECTOR_LC;
707 rgMngmt.hdr.msgType = TCFG;
708 rgMngmt.hdr.msgLen = 0;
709 rgMngmt.hdr.entId.ent = ENTRG;
710 rgMngmt.hdr.entId.inst = (Inst)0;
711 rgMngmt.hdr.elmId.elmnt = STGEN;
712 rgMngmt.hdr.seqNmb = 0;
713 rgMngmt.hdr.version = 0;
714 rgMngmt.hdr.transId = 0;
716 rgMngmt.hdr.response.prior = PRIOR0;
717 rgMngmt.hdr.response.route = RTESPEC;
718 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
719 rgMngmt.hdr.response.mem.pool = RG_POOL;
720 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
723 pst.selector = DU_SELECTOR_LC;
724 pst.srcEnt = ENTDUAPP;
726 pst.dstInst = macCfgInst;
727 pst.dstProcId = DU_PROC;
728 pst.srcProcId = DU_PROC;
729 pst.region = duCb.init.region;
731 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
733 /* Send the request to MAC */
734 cmPkLrgCfgReq(&pst, &rgMngmt);
739 /**************************************************************************
740 * @brief Function to fill USAP config required by MAC
744 * Function : duBuildMacUsapCfg
747 * Initiates USAP Configs towards MAC
749 * @param[in] SpId Specifies if RLC UL or RLC DL instance
750 * @return ROK - success
753 ***************************************************************************/
754 S16 duBuildMacUsapCfg(SpId sapId)
757 RgUpSapCfg *uSap = NULLP;
760 DU_SET_ZERO(&pst, sizeof(Pst));
761 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
763 uSap = &(rgMngmt.t.cfg.s.rguSap);
765 uSap->mem.region = RG_MEM_REGION;
766 uSap->mem.pool = RG_POOL;
769 uSap->procId = DU_PROC;
772 uSap->prior = PRIOR0;
773 uSap->route = RTESPEC;
774 uSap->selector = DU_SELECTOR_LC ;
777 rgMngmt.hdr.msgType = TCFG;
778 rgMngmt.hdr.entId.ent = ENTRG;
779 rgMngmt.hdr.entId.inst = (Inst)0;
780 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
781 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
782 rgMngmt.hdr.response.mem.pool = RG_POOL;
785 pst.selector = DU_SELECTOR_LC;
786 pst.srcEnt = ENTDUAPP;
788 pst.dstInst = macCfgInst;
789 pst.dstProcId = DU_PROC;
790 pst.srcProcId = DU_PROC;
791 pst.region = duCb.init.region;
793 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
795 /* Send the request to MAC */
796 cmPkLrgCfgReq(&pst, &rgMngmt);
801 /**************************************************************************
802 * @brief Function to handle Config Confirm from MAC
806 * Function : duHdlMacCfgComplete
809 * Handles Gen Config Confirm from MAC
811 * @param[in] Pst *pst, Post structure of the primitive.
812 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
813 * @return ROK - success
816 ***************************************************************************/
817 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
821 if (cfm->cfm.status == LCM_PRIM_OK)
823 switch (cfm->hdr.elmId.elmnt)
827 macCfg |= MAC_GEN_CFG;
832 macCfg |= MAC_SAP_CFG;
839 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
840 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
843 DU_LOG("\nDU_APP : Completed sending Configs");
845 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
851 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
857 /**************************************************************************
858 * @brief Function to bind/unbind RLC to MAC SAP
862 * Function : duBindUnbindRlcToMacSap
865 * Initiates Bind/Unbind from RLC to MAC
867 * @param[in] Inst Specifies if RLC UL or RLC DL instance
868 * @param[in] action Specifies if action is bind or unbind
869 * @return ROK - success
872 ***************************************************************************/
873 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
875 KwCntrl *cntrl = NULLP;
879 TRC2(smBindKwToRguSap)
881 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
882 DU_SET_ZERO(&pst, sizeof(Pst));
886 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
890 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
892 cntrl = &(kwMngmt.t.cntrl);
894 cntrl->action = action;
895 cntrl->subAction = DU_ZERO_VAL;
896 cntrl->s.sapCntrl.suId = macCfgInst;
897 cntrl->s.sapCntrl.spId = inst;
900 kwMngmt.hdr.msgType = TCNTRL;
901 kwMngmt.hdr.entId.ent = ENTKW;
902 kwMngmt.hdr.entId.inst = inst;
903 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
904 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
905 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
906 kwMngmt.hdr.response.mem.pool = RLC_POOL;
909 pst.selector = DU_SELECTOR_LC;
910 pst.srcEnt = ENTDUAPP;
912 pst.dstProcId = DU_PROC;
914 pst.srcProcId = DU_PROC;
915 pst.region = duCb.init.region;
917 cmPkLkwCntrlReq(&pst, &kwMngmt);
921 /*******************************************************************
923 * @brief Handles SCTP notifications
927 * Function : duSctpNtfyHdl
930 * Handles SCTP notification
932 * @params[in] Message Buffer
935 * @return ROK - success
938 * ****************************************************************/
940 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
942 if(f1Params.assocId == ntfy->u.assocChange.assocId)
944 if(BuildAndSendF1SetupReq() != ROK)
949 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
951 if(BuildAndSendE2SetupReq() != ROK)
958 DU_LOG("\nDU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
964 /*******************************************************************
966 * @brief Fills Pst struct for ENTEGTP
970 * Function : duFillEgtpPst
973 * Fills Pst struct for ENTEGTP
976 * @return ROK - success
979 * ****************************************************************/
980 S16 duFillEgtpPst(Pst *pst, Event event)
982 cmMemset((U8 *)pst, 0, sizeof(Pst));
983 pst->srcEnt = (Ent)ENTDUAPP;
984 pst->srcInst = (Inst)DU_INST;
985 pst->srcProcId = DU_PROC;
986 pst->dstEnt = (Ent)ENTEGTP;
987 pst->dstInst = (Inst)EGTP_INST;
988 pst->dstProcId = pst->srcProcId;
990 pst->selector = DU_SELECTOR_LC;
997 /*******************************************************************
999 * @brief Function to configure EGTP
1003 * Function : duBuildEgtpCfgReq
1006 * Function to configure EGTP
1009 * @return ROK - success
1012 * ****************************************************************/
1014 S16 duBuildEgtpCfgReq()
1019 DU_LOG("\nDU_APP : Sending EGTP config request");
1021 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1022 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1024 duFillEgtpPst(&pst, EVTCFGREQ);
1025 packEgtpCfgReq(&pst, egtpCfg);
1030 /*******************************************************************
1032 * @brief Function to configure EGTP
1036 * Function : duBuildEgtpCfgReq
1039 * Function to configure EGTP
1042 * @return ROK - success
1045 * ****************************************************************/
1046 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1050 if(cfm.status == LCM_PRIM_OK)
1052 DU_LOG("\nDU_APP : EGTP configuraton complete");
1054 duSendEgtpSrvOpenReq();
1059 DU_LOG("\nDU_APP : EGTP configuraton failed");
1066 /*******************************************************************
1068 * @brief Sends server open request to EGTP
1072 * Function : duSendEgtpSrvOpenReq
1075 * Sends server open request to EGTP
1078 * @return ROK - success
1081 * ****************************************************************/
1083 S16 duSendEgtpSrvOpenReq()
1087 DU_LOG("\nDU_APP : Sending EGTP server open request");
1089 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1090 packEgtpSrvOpenReq(&pst);
1095 /*******************************************************************
1097 * @brief Handles server open confirmation
1101 * Function : duHdlEgtpSrvOpenComplete
1104 * Handles server open confirmation
1107 * @return ROK - success
1110 *****************************************************************/
1112 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1116 if(cfm.status == LCM_PRIM_OK)
1118 DU_LOG("\nDU_APP : EGTP server opened successfully");
1120 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1125 DU_LOG("\nDU_APP : EGTP server opening failed");
1132 /*******************************************************************
1134 * @brief Sends tunnel management request
1138 * Function : duSendEgtpTnlMgmtReq
1141 * Builds and sends tunnel management request to EGTP
1143 * @params[in] Action
1144 * Local tunnel endpoint id
1145 * Remote tunnel endpoint id
1146 * @return ROK - success
1149 * ****************************************************************/
1151 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1156 tnlEvt.action = action;
1157 tnlEvt.lclTeid = lclTeid;
1158 tnlEvt.remTeid = remTeid;
1160 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1162 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1163 packEgtpTnlMgmtReq(&pst, tnlEvt);
1168 /*******************************************************************
1170 * @brief Handles Tunnel management confirm
1174 * Function : duHdlEgtpTnlMgmtCfm
1177 * Handles tunnel management confirm received from Egtp
1179 * @params[in] Tunnel Event
1180 * @return ROK - success
1183 * ****************************************************************/
1184 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1188 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1190 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1193 duSendUeCreateReqToRlc();
1195 duSendEgtpTestData();
1200 DU_LOG("\nDU_APP : Tunnel management failed");
1207 S16 duSendEgtpDatInd(Buffer *mBuf)
1211 /* Fill EGTP header */
1212 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1213 egtpMsg.msgHdr.nPdu.pres = FALSE;
1214 egtpMsg.msgHdr.seqNum.pres = FALSE;
1215 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1216 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1217 egtpMsg.msgHdr.teId = 1;
1220 egtpHdlDatInd(egtpMsg);
1227 /*******************************************************************
1229 * @brief Simulate UL Data for intial test
1233 * Function : duSendEgtpTestData
1236 * Simulate UL data for initial test
1239 * @return ROK - success
1242 * ****************************************************************/
1243 S16 duSendEgtpTestData()
1245 char data[30] = "This is EGTP data from DU";
1250 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1252 if(SAddPstMsgMult((Data *)data, datSize, mBuf) != ROK)
1254 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1261 DU_LOG("\nDU_APP : Failed to allocate memory");
1265 /* filling IPv4 header */
1270 SFndLenMsg(mBuf, &mLen);
1272 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1273 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1274 ipv4Hdr.hdrVer = 0x45;
1276 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1277 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1279 /* Packing IPv4 header into buffer */
1281 Data revPkArray[CM_IPV4_HDRLEN];
1282 Data pkArray[CM_IPV4_HDRLEN];
1284 /* initialize locals */
1286 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1287 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1289 /* Pack Header Version */
1290 pkArray[cnt++] = ipv4Hdr.hdrVer;
1293 pkArray[cnt++] = ipv4Hdr.tos;
1295 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1296 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1299 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1300 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1303 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1304 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1307 pkArray[cnt++] = ipv4Hdr.ttl;
1310 pkArray[cnt++] = ipv4Hdr.proto;
1313 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1314 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1316 /* Pack Source Address */
1317 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1318 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1319 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1320 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1322 /* Pack Destination Address */
1323 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1324 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1325 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1326 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1328 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1329 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1331 /* this function automatically reverses revPkArray */
1332 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1334 duSendEgtpDatInd(mBuf);
1338 #endif /* EGTP_TEST */
1341 /**************************************************************************
1342 * @brief Function to send configs to SCH
1346 * Function : duSendSchCfg
1349 * Sends general config to Scheduler via MAC layer
1352 * @return ROK - success
1355 ***************************************************************************/
1359 RgSchInstCfg *cfg = NULLP;
1362 DU_SET_ZERO(&pst, sizeof(Pst));
1363 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1365 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1367 /* Filling of Instance Id */
1368 cfg->instId = DEFAULT_CELLS + 1;
1369 /* Filling of Gen config */
1370 cfg->genCfg.mem.region = RG_MEM_REGION;
1371 cfg->genCfg.mem.pool = RG_POOL;
1372 cfg->genCfg.tmrRes = 10;
1375 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1376 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1378 cfg->genCfg.startCellId = 1;
1379 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1380 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1381 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1382 cfg->genCfg.lmPst.dstInst = DU_INST;
1383 cfg->genCfg.lmPst.srcEnt = ENTRG;
1384 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1385 cfg->genCfg.lmPst.prior = PRIOR0;
1386 cfg->genCfg.lmPst.route = RTESPEC;
1387 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1388 cfg->genCfg.lmPst.pool = RG_POOL;
1389 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1392 rgMngmt.hdr.msgType = TCFG;
1393 rgMngmt.hdr.entId.ent = ENTRG;
1394 rgMngmt.hdr.entId.inst = DU_INST;
1395 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1396 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1397 rgMngmt.hdr.response.mem.pool = RG_POOL;
1400 pst.selector = DU_SELECTOR_LC;
1401 pst.srcEnt = ENTDUAPP;
1403 pst.dstProcId = DU_PROC;
1404 pst.srcProcId = DU_PROC;
1405 pst.srcInst = DU_INST;
1407 pst.region = duCb.init.region;
1408 pst.event = (Event) EVTMACSCHGENCFGREQ;
1410 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1412 /* Send the request to MAC */
1413 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1419 /**************************************************************************
1420 * @brief Function to configure SCTP params and
1421 * responsible for F1 and E2 interfaces
1425 * Function : duLayerConfigComplete
1428 * Configures SCTP Params and responsible for handling
1429 * F1 and E2 interface.
1432 * @return ROK - success
1435 ***************************************************************************/
1436 S16 duLayerConfigComplete()
1440 DU_LOG("\nDU_APP : Configuring all Layer is complete");
1442 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1444 DU_LOG("\nDU_APP : Failed configuring Sctp Params");
1447 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1449 DU_LOG("\nDU_APP : Failed to send AssocReq F1");
1452 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1454 DU_LOG("\nDU_APP : Failed to send AssocReq E2");
1461 /**************************************************************************
1462 * @brief Function to handle SCH Config Confirm from MAC
1466 * Function : duHdlSchCfgComplete
1469 * Handles Scheduler Gen Config Confirm from MAC
1471 * @param[in] Pst *pst, Post structure of the primitive.
1472 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1473 * @return ROK - success
1476 ***************************************************************************/
1477 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1479 if (cfm->cfm.status == LCM_PRIM_OK)
1481 switch (cfm->hdr.elmId.elmnt)
1485 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1492 duLayerConfigComplete();
1493 duBuildEgtpCfgReq();
1497 /*******************************************************************
1499 * @brief Sends Slot indication to EGTP
1503 * Function : duSendEgtpSlotInd
1506 * Sends Slot indication to EGTP
1509 * @return ROK - success
1512 * ****************************************************************/
1513 S16 duSendEgtpSlotInd()
1517 duFillEgtpPst(&pst, EVTSLOTIND);
1518 packEgtpSlotInd(&pst);
1524 /**************************************************************************
1525 * @brief Function to fill and send MacCellconfig
1529 * Function : duBuildAndSendMacCellCfg
1532 * Initiates MAC Configs towards MAC
1535 * @return ROK - success
1538 ***************************************************************************/
1539 S16 duBuildAndSendMacCellCfg()
1542 DU_SET_ZERO(&pst, sizeof(Pst));
1543 MacCellCfg *duMacCellCfg = NULLP;
1545 DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
1546 if(duMacCellCfg == NULLP)
1551 /* store the address in the duCb so that we can free on confirm msg */
1552 duCb.duMacCellCfg = duMacCellCfg;
1554 /* copy the mac config structure from duCfgParams */
1555 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1557 duMacCellCfg->transId = getTransId(); /* transaction ID */
1560 pst.selector = DU_SELECTOR_LWLC;
1561 pst.srcEnt = ENTDUAPP;
1565 pst.dstProcId = DU_PROC;
1566 pst.srcProcId = DU_PROC;
1567 pst.region = duCb.init.region;
1568 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1570 /* Send MAC cell config to MAC */
1571 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1574 /**************************************************************************
1575 * @brief Function to Handle MAC cell config confirm
1579 * Function : duHandleMacCellCfgCfm
1582 * Initiates general Configs towards MAC
1585 * @return ROK - success
1588 ***************************************************************************/
1589 uint16_t duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1593 if(macCellCfgCfm->rsp == ROK)
1595 if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
1597 /* free the memory allocated during sending macCellCfg request */
1598 DU_FREE(duCb.duMacCellCfg->sib1Cfg.sib1Pdu, duCfgParam.srvdCellLst[0].duSysInfo.sib1Len);
1599 DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
1600 duCb.duMacCellCfg = NULLP;
1602 /* Build and send GNB-DU config update */
1603 ret = BuildAndSendDUConfigUpdate();
1605 /* TODO: Trigger cell start req once cell up slot ind is received*/
1606 /* Build and Send Cell Start Req to MAC */
1607 ret = duBuildAndSendMacCellStartReq();
1612 /* transaction ID missmatch */
1613 DU_LOG("\n transaction ID mismatch in macCellCfg");
1619 DU_LOG("\nMac cell cfg failed");
1625 /*******************************************************************
1627 * @brief Handles slot indication from MAC
1631 * Function : duHandleSlotInd
1634 * Handles slot indication from MAC
1636 * @params[in] Post structure pointer
1638 * @return ROK - success
1641 * ****************************************************************/
1642 uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo)
1645 DU_LOG("\nDU APP : Slot Indication received");
1647 if(slotInfo->cellId <=0 || slotInfo->cellId > DU_MAX_CELLS)
1649 DU_LOG("\nDU APP : Invalid Cell Id %d", slotInfo->cellId);
1651 if(!duCb.actvCellLst[slotInfo->cellId-1]->firstSlotIndRcvd)
1653 duCb.actvCellLst[slotInfo->cellId-1]->firstSlotIndRcvd = true;
1654 if((duCb.actvCellLst[slotInfo->cellId-1] != NULL) && \
1655 (duCb.actvCellLst[slotInfo->cellId-1]->cellStatus == \
1656 ACTIVATION_IN_PROGRESS))
1658 DU_LOG("\nDU APP : Cell Id %d is ACTIVE", slotInfo->cellId);
1659 duCb.actvCellLst[slotInfo->cellId-1]->cellStatus = ACTIVATED;
1664 /* TODO : Slot Indication to be moved out of EGTP_TEST when
1665 * data path is established */
1667 duSendEgtpSlotInd();
1669 DU_FREE_MEM(pst->region, pst->pool, slotInfo, sizeof(SlotInfo));
1673 /*******************************************************************
1675 * @brief Builds and sends cell start request to MAC
1679 * Function : duBuildAndSendMacCellStartReq
1682 * Builds and sends cell start request to MAC
1685 * @return ROK - success
1688 * ****************************************************************/
1689 uint16_t duBuildAndSendMacCellStartReq()
1692 MacCellStartInfo *cellStartInfo = NULL;
1694 DU_LOG("\nDU APP : Building and Sending cell start request to MAC");
1696 /* Send Cell Start Request to MAC */
1697 DU_ALLOC(cellStartInfo, sizeof(MacCellStartInfo));
1700 DU_LOG("\nDU APP : Memory alloc failed while building cell start request");
1704 for(uint8_t id = 0; id < DU_MAX_CELLS; id++)
1706 if(duCb.actvCellLst[id])
1708 duCb.actvCellLst[id]->firstSlotIndRcvd = FALSE;
1709 cellStartInfo->cellId = duCb.actvCellLst[id]->cellInfo.nrEcgi.cellId;
1712 pst.selector = DU_MAC_LWLC;
1713 pst.srcEnt = ENTDUAPP;
1717 pst.dstProcId = DU_PROC;
1718 pst.srcProcId = DU_PROC;
1719 pst.region = DU_APP_MEM_REGION;
1721 pst.event = EVENT_MAC_CELL_START_REQ;
1723 return (*packMacCellStartReqOpts[pst.selector])(&pst, cellStartInfo);
1729 /*******************************************************************
1731 * @brief Builds and sends cell stop request to MAC
1735 * Function : duBuildAndSendMacCellStopReq
1738 * Builds and sends cell stop request to MAC
1741 * @return ROK - success
1744 * ****************************************************************/
1745 S16 duBuildAndSendMacCellStopReq()
1748 MacCellStopInfo *cellStopInfo = NULL;
1750 DU_LOG("\nDU APP : Building and Sending cell stop request to MAC");
1752 /* Send Cell Stop Request to MAC */
1753 DU_ALLOC(cellStopInfo, sizeof(MacCellStopInfo));
1756 DU_LOG("\nDU APP : Memory alloc failed while building cell stop request");
1759 cellStopInfo->cellId = duCb.actvCellLst[0]->cellId;
1762 pst.selector = DU_MAC_LWLC;
1763 pst.srcEnt = ENTDUAPP;
1767 pst.dstProcId = DU_PROC;
1768 pst.srcProcId = DU_PROC;
1769 pst.region = DU_APP_MEM_REGION;
1771 pst.event = EVENT_MAC_CELL_STOP_REQ;
1773 return (*packMacCellStopReqOpts[pst.selector])(&pst, cellStopInfo);
1777 /**********************************************************************
1779 **********************************************************************/