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 cell management */
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);
40 packMacCellCfgReq packMacCellCfgOpts[] =
42 packMacCellCfg, /* packing for loosely coupled */
43 MacHdlCellCfgReq, /* packing for tightly coupled */
44 packMacCellCfg, /* packing for light weight loosly coupled */
47 /**************************************************************************
48 * @brief Function to fill configs required by RLC
52 * Function : duBuildRlcCfg
55 * Initiates general Configs towards RLC
57 * @param[in] Inst Specifies if RLC UL or RLC DL instance
58 * @return ROK - success
61 ***************************************************************************/
62 S16 duBuildRlcCfg(Inst inst)
65 KwGenCfg *genCfg = NULLP;
68 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
69 DU_SET_ZERO(&pst, sizeof(Pst));
71 genCfg = &(kwMngmt.t.cfg.s.gen);
73 /*----------- Fill General Configuration Parameters ---------*/
74 genCfg->maxUe = duCfgParam.maxUe;
75 genCfg->maxKwuSaps = 2;
76 genCfg->maxUdxSaps = 1;
77 genCfg->rlcMode = (inst == RLC_UL_INST) ?
78 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
80 genCfg->maxRguSaps = DEFAULT_CELLS;
82 /*----------- Fill lmPst
83 * Parameters ---------*/
84 genCfg->lmPst.dstProcId = DU_PROC;
85 genCfg->lmPst.srcProcId = DU_PROC;
86 genCfg->lmPst.dstEnt = ENTDUAPP;
87 genCfg->lmPst.dstInst = DU_INST;
88 genCfg->lmPst.srcEnt = ENTKW;
89 genCfg->lmPst.srcInst = inst;
90 genCfg->lmPst.prior = PRIOR0;
91 genCfg->lmPst.route = RTESPEC;
92 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
93 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
94 genCfg->lmPst.pool = RLC_POOL;
95 genCfg->lmPst.selector = DU_SELECTOR_LC;
98 kwMngmt.hdr.msgType = TCFG;
99 kwMngmt.hdr.msgLen = 0;
100 kwMngmt.hdr.entId.ent = ENTKW;
101 kwMngmt.hdr.entId.inst = (Inst)0;
102 kwMngmt.hdr.elmId.elmnt = STGEN;
103 kwMngmt.hdr.seqNmb = 0;
104 kwMngmt.hdr.version = 0;
105 kwMngmt.hdr.transId = 0;
106 kwMngmt.hdr.response.prior = PRIOR0;
107 kwMngmt.hdr.response.route = RTESPEC;
108 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
109 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
110 kwMngmt.hdr.response.mem.pool = DU_POOL;
111 kwMngmt.hdr.response.selector = DU_SELECTOR_LC;
114 pst.selector = DU_SELECTOR_LC;
115 pst.srcEnt = ENTDUAPP;
118 pst.dstProcId = DU_PROC;
119 pst.srcProcId = DU_PROC;
120 pst.region = duCb.init.region;
122 DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
124 /* Send the request to RLC */
125 cmPkLkwCfgReq(&pst, &kwMngmt);
130 /**************************************************************************
131 * @brief Function to fill configs required by RLC
135 * Function : duBuildRlcLsapCfg
138 * Initiates general Configs towards RLC
140 * @param[in] Inst Specifies if RLC UL or RLC DL instance
141 * @return ROK - success
144 ***************************************************************************/
145 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
149 KwSapCfg *lSap = NULLP;
152 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
153 DU_SET_ZERO(&pst, sizeof(Pst));
156 kwMngmt.hdr.msgType = TCFG;
157 kwMngmt.hdr.entId.ent = ENTKW;
158 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
159 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
161 kwMngmt.hdr.response.mem.pool = RLC_POOL;
164 pst.selector = DU_SELECTOR_LC;
165 pst.srcEnt = ENTDUAPP;
167 pst.dstProcId = DU_PROC;
169 pst.srcProcId = DU_PROC;
170 pst.region = duCb.init.region;
171 lSap = &(kwMngmt.t.cfg.s.sap);
173 lSap->mem.region = (inst == RLC_UL_INST) ?
174 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
175 lSap->mem.pool = RLC_POOL;
177 lSap->bndTmrIntvl = 10;
178 lSap->priority = PRIOR0;
179 lSap->route = RTESPEC;
182 lSap->procId = DU_PROC;
184 lSap->inst = lsapInst;
185 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
186 lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
187 kwMngmt.hdr.elmId.elmnt = STRGUSAP;
188 DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
193 lSap->procId = DU_PROC;
195 lSap->inst = (inst == RLC_UL_INST) ?
196 RLC_DL_INST : RLC_UL_INST;
198 lSap->selector = DU_SELECTOR_LC;
199 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
200 DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
203 cmPkLkwCfgReq(&pst, &kwMngmt);
207 /**************************************************************************
208 * @brief Function to fill configs required by RLC
212 * Function : duBuildRlcUsapCfg
215 * Initiates general Configs towards RLC
217 * @param[in] Inst Specifies if RLC UL or RLC DL instance
218 * @return ROK - success
221 ***************************************************************************/
222 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
225 KwSapCfg *uSap = NULLP;
228 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
229 DU_SET_ZERO(&pst, sizeof(Pst));
231 uSap = &(kwMngmt.t.cfg.s.sap);
233 uSap->selector = DU_SELECTOR_LC;
234 uSap->mem.region = (inst == RLC_UL_INST) ?
235 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
236 uSap->mem.pool = RLC_POOL;
239 uSap->procId = DU_PROC;
243 uSap->inst = (inst == RLC_UL_INST) ?
244 RLC_DL_INST : RLC_UL_INST;
245 uSap->bndTmrIntvl = 1000;
246 uSap->priority = PRIOR0;
247 uSap->route = RTESPEC;
250 kwMngmt.hdr.msgType = TCFG;
251 kwMngmt.hdr.entId.ent = ENTKW;
252 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
253 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
254 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
256 kwMngmt.hdr.response.mem.pool = RLC_POOL;
259 pst.selector = DU_SELECTOR_LC;
260 pst.srcEnt = ENTDUAPP;
262 pst.dstProcId = DU_PROC;
264 pst.srcProcId = DU_PROC;
265 pst.region = duCb.init.region;
267 DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
268 cmPkLkwCfgReq(&pst, &kwMngmt);
273 /**************************************************************************
274 * @brief Function to populate internal DS of DU APP
278 * Function : duProcCfgComplete
281 * Populates internal data structures of DU APP after
282 * receiving configurations.
285 * @return ROK - success
288 ***************************************************************************/
289 S16 duProcCfgComplete()
292 static U16 cellId = 0;
294 for(idx=0; idx< DEFAULT_CELLS; idx++)
297 DU_ALLOC(cell, sizeof(DuCellCb))
300 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
308 memset(cell, 0, sizeof(DuCellCb));
309 cell->cellId = cellId++;
310 cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0;
311 cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1;
312 cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2;
313 cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0;
314 cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1;
315 cell->cellInfo.nrEcgi.plmn.mnc[2] = PLMN_MNC2;
316 cell->cellInfo.nrEcgi.cellId = NR_CELL_ID;
317 cell->cellInfo.nrPci = NR_PCI;
318 cell->cellInfo.fiveGsTac = DU_TAC;
319 for(idx=0; idx<MAX_PLMN; idx++)
321 cell->cellInfo.plmn[idx].mcc[0] = PLMN_MCC0;
322 cell->cellInfo.plmn[idx].mcc[1] = PLMN_MCC1;
323 cell->cellInfo.plmn[idx].mcc[2] = PLMN_MCC2;
324 cell->cellInfo.plmn[idx].mnc[0] = PLMN_MNC0;
325 cell->cellInfo.plmn[idx].mnc[1] = PLMN_MNC1;
326 cell->cellInfo.plmn[idx].mnc[2] = PLMN_MNC2;
328 cell->cellInfo.maxUe = duCfgParam.maxUe;
329 cell->cellStatus = CELL_OUT_OF_SERVICE;
330 nci = (U16)cell->cellInfo.nrEcgi.cellId;
332 duCb.cfgCellLst[nci-1] = cell;
337 //Start layer configs
338 ret = duSendRlcUlCfg();
342 /**************************************************************************
343 * @brief Function to invoke DU Layer Configs
347 * Function : duSendRlcUlCfg
350 * Initiates Configs towards layers of DU
353 * @return ROK - success
356 ***************************************************************************/
361 duBuildRlcCfg((Inst)RLC_UL_INST);
362 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
364 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
366 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
371 /**************************************************************************
372 * @brief Function to invoke DU Layer Configs
376 * Function : duSendRlcDlCfg
379 * Initiates Configs towards layers of DU
382 * @return ROK - success
385 ***************************************************************************/
390 duBuildRlcCfg((Inst)RLC_DL_INST);
391 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
392 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
394 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
399 /**************************************************************************
400 * @brief Function to handle Config Confirm from RLC
404 * Function : duHdlRlcCfgComplete
407 * Handles Gen Config Confirm from RLC
409 * @param[in] Pst *pst, Post structure of the primitive.
410 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
411 * @return ROK - success
414 ***************************************************************************/
415 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
418 if (pst->srcInst == RLC_UL_INST)
420 ret = duProcRlcUlCfgComplete(pst, cfm);
424 ret = duProcRlcDlCfgComplete(pst, cfm);
429 /**************************************************************************
430 * @brief Function to handle Control Config Confirm from RLC
434 * Function : duHdlRlcCntrlCfgComplete
437 * Handles Control Config Confirm from RLC
439 * @param[in] Pst *pst, Post structure of the primitive.
440 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
441 * @return ROK - success
444 ***************************************************************************/
445 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
449 if (cntrl->cfm.status == LCM_PRIM_OK)
451 switch (cntrl->hdr.elmId.elmnt)
455 if (pst->srcInst == RLC_DL_INST)
457 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
459 if(macCfgInst < DEFAULT_CELLS)
462 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
466 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
471 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
473 if(macCfgInst < DEFAULT_CELLS)
475 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
489 /**************************************************************************
490 * @brief Function to handle Config Confirm from RLC UL
494 * Function : duHdlRlcUlCfgComplete
497 * Handles Config Confirm from RLC UL
499 * @param[in] Pst *pst, Post structure of the primitive.
500 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
501 * @return ROK - success
504 ***************************************************************************/
505 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
509 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
510 if (cfm->cfm.status == LCM_PRIM_OK)
512 switch(cfm->hdr.elmId.elmnt)
516 rlcUlCfg |= RLC_GEN_CFG;
522 if(numRlcMacSaps == DEFAULT_CELLS)
524 rlcUlCfg |= RLC_MAC_SAP_CFG;
531 rlcUlCfg |= RLC_UDX_SAP_CFG;
538 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
539 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
543 //Start configuration of RLC DL
550 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
556 /**************************************************************************
557 * @brief Function to handle Config Confirm from RLC DL
561 * Function : duHdlRlcDlCfgComplete
564 * Handles Config Confirm from RLC DL
566 * @param[in] Pst *pst, Post structure of the primitive.
567 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
568 * @return ROK - success
571 ***************************************************************************/
572 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
574 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
575 if (cfm->cfm.status == LCM_PRIM_OK)
577 switch(cfm->hdr.elmId.elmnt)
581 rlcDlCfg |= RLC_GEN_CFG;
587 if(numRlcMacSaps == DEFAULT_CELLS)
589 rlcDlCfg |= RLC_MAC_SAP_CFG;
596 rlcDlCfg |= RLC_UDX_SAP_CFG;
604 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
605 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
608 //Start configuration of MAC
615 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
620 /**************************************************************************
621 * @brief Function to send configs to MAC
625 * Function : duSendMacCfg
628 * Initiates Configs towards MAC layer
631 * @return ROK - success
634 ***************************************************************************/
638 duBuildMacUsapCfg(RLC_UL_INST);
639 duBuildMacUsapCfg(RLC_DL_INST);
644 /**************************************************************************
645 * @brief Function to fill gen config required by MAC
649 * Function : duBuildMacGenCfg
652 * Initiates general Configs towards MAC
655 * @return ROK - success
658 ***************************************************************************/
659 S16 duBuildMacGenCfg()
662 RgGenCfg *genCfg=NULLP;
665 DU_SET_ZERO(&pst, sizeof(Pst));
666 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
668 genCfg = &(rgMngmt.t.cfg.s.genCfg);
670 /*----------- Fill General Configuration Parameters ---------*/
671 genCfg->mem.region = RG_MEM_REGION;
672 genCfg->mem.pool = RG_POOL;
674 genCfg->numRguSaps = 2;
676 genCfg->lmPst.dstProcId = DU_PROC;
677 genCfg->lmPst.srcProcId = DU_PROC;
678 genCfg->lmPst.dstEnt = ENTDUAPP;
679 genCfg->lmPst.dstInst = 0;
680 genCfg->lmPst.srcEnt = ENTRG;
681 genCfg->lmPst.srcInst = macCfgInst;
682 genCfg->lmPst.prior = PRIOR0;
683 genCfg->lmPst.route = RTESPEC;
684 genCfg->lmPst.region = RG_MEM_REGION;
685 genCfg->lmPst.pool = RG_POOL;
686 genCfg->lmPst.selector = DU_SELECTOR_LC;
689 rgMngmt.hdr.msgType = TCFG;
690 rgMngmt.hdr.msgLen = 0;
691 rgMngmt.hdr.entId.ent = ENTRG;
692 rgMngmt.hdr.entId.inst = (Inst)0;
693 rgMngmt.hdr.elmId.elmnt = STGEN;
694 rgMngmt.hdr.seqNmb = 0;
695 rgMngmt.hdr.version = 0;
696 rgMngmt.hdr.transId = 0;
698 rgMngmt.hdr.response.prior = PRIOR0;
699 rgMngmt.hdr.response.route = RTESPEC;
700 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
701 rgMngmt.hdr.response.mem.pool = RG_POOL;
702 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
705 pst.selector = DU_SELECTOR_LC;
706 pst.srcEnt = ENTDUAPP;
708 pst.dstInst = macCfgInst;
709 pst.dstProcId = DU_PROC;
710 pst.srcProcId = DU_PROC;
711 pst.region = duCb.init.region;
713 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
715 /* Send the request to MAC */
716 cmPkLrgCfgReq(&pst, &rgMngmt);
721 /**************************************************************************
722 * @brief Function to fill USAP config required by MAC
726 * Function : duBuildMacUsapCfg
729 * Initiates USAP Configs towards MAC
731 * @param[in] SpId Specifies if RLC UL or RLC DL instance
732 * @return ROK - success
735 ***************************************************************************/
736 S16 duBuildMacUsapCfg(SpId sapId)
739 RgUpSapCfg *uSap = NULLP;
742 DU_SET_ZERO(&pst, sizeof(Pst));
743 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
745 uSap = &(rgMngmt.t.cfg.s.rguSap);
747 uSap->mem.region = RG_MEM_REGION;
748 uSap->mem.pool = RG_POOL;
751 uSap->procId = DU_PROC;
754 uSap->prior = PRIOR0;
755 uSap->route = RTESPEC;
756 uSap->selector = DU_SELECTOR_LC ;
759 rgMngmt.hdr.msgType = TCFG;
760 rgMngmt.hdr.entId.ent = ENTRG;
761 rgMngmt.hdr.entId.inst = (Inst)0;
762 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
763 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
764 rgMngmt.hdr.response.mem.pool = RG_POOL;
767 pst.selector = DU_SELECTOR_LC;
768 pst.srcEnt = ENTDUAPP;
770 pst.dstInst = macCfgInst;
771 pst.dstProcId = DU_PROC;
772 pst.srcProcId = DU_PROC;
773 pst.region = duCb.init.region;
775 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
777 /* Send the request to MAC */
778 cmPkLrgCfgReq(&pst, &rgMngmt);
783 /**************************************************************************
784 * @brief Function to handle Config Confirm from MAC
788 * Function : duHdlMacCfgComplete
791 * Handles Gen Config Confirm from MAC
793 * @param[in] Pst *pst, Post structure of the primitive.
794 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
795 * @return ROK - success
798 ***************************************************************************/
799 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
803 if (cfm->cfm.status == LCM_PRIM_OK)
805 switch (cfm->hdr.elmId.elmnt)
809 macCfg |= MAC_GEN_CFG;
814 macCfg |= MAC_SAP_CFG;
821 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
822 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
825 DU_LOG("\nDU_APP : Completed sending Configs");
827 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
833 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
839 /**************************************************************************
840 * @brief Function to bind/unbind RLC to MAC SAP
844 * Function : duBindUnbindRlcToMacSap
847 * Initiates Bind/Unbind from RLC to MAC
849 * @param[in] Inst Specifies if RLC UL or RLC DL instance
850 * @param[in] action Specifies if action is bind or unbind
851 * @return ROK - success
854 ***************************************************************************/
855 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
857 KwCntrl *cntrl = NULLP;
861 TRC2(smBindKwToRguSap)
863 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
864 DU_SET_ZERO(&pst, sizeof(Pst));
868 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
872 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
874 cntrl = &(kwMngmt.t.cntrl);
876 cntrl->action = action;
877 cntrl->subAction = DU_ZERO_VAL;
878 cntrl->s.sapCntrl.suId = macCfgInst;
879 cntrl->s.sapCntrl.spId = inst;
882 kwMngmt.hdr.msgType = TCNTRL;
883 kwMngmt.hdr.entId.ent = ENTKW;
884 kwMngmt.hdr.entId.inst = inst;
885 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
886 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
887 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
888 kwMngmt.hdr.response.mem.pool = RLC_POOL;
891 pst.selector = DU_SELECTOR_LC;
892 pst.srcEnt = ENTDUAPP;
894 pst.dstProcId = DU_PROC;
896 pst.srcProcId = DU_PROC;
897 pst.region = duCb.init.region;
899 cmPkLkwCntrlReq(&pst, &kwMngmt);
903 /*******************************************************************
905 * @brief Handles SCTP notifications
909 * Function : duSctpNtfyHdl
912 * Handles SCTP notification
914 * @params[in] Message Buffer
917 * @return ROK - success
920 * ****************************************************************/
922 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
924 if(f1Params.assocId == ntfy->u.assocChange.assocId)
926 if(BuildAndSendF1SetupReq() != ROK)
931 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
933 if(BuildAndSendE2SetupReq() != ROK)
940 DU_LOG("\nDU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
946 /*******************************************************************
948 * @brief Fills Pst struct for ENTEGTP
952 * Function : duFillEgtpPst
955 * Fills Pst struct for ENTEGTP
958 * @return ROK - success
961 * ****************************************************************/
962 S16 duFillEgtpPst(Pst *pst, Event event)
964 cmMemset((U8 *)pst, 0, sizeof(Pst));
965 pst->srcEnt = (Ent)ENTDUAPP;
966 pst->srcInst = (Inst)DU_INST;
967 pst->srcProcId = DU_PROC;
968 pst->dstEnt = (Ent)ENTEGTP;
969 pst->dstInst = (Inst)EGTP_INST;
970 pst->dstProcId = pst->srcProcId;
972 pst->selector = DU_SELECTOR_LC;
979 /*******************************************************************
981 * @brief Function to configure EGTP
985 * Function : duBuildEgtpCfgReq
988 * Function to configure EGTP
991 * @return ROK - success
994 * ****************************************************************/
996 S16 duBuildEgtpCfgReq()
1001 DU_LOG("\nDU_APP : Sending EGTP config request");
1003 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1004 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1006 duFillEgtpPst(&pst, EVTCFGREQ);
1007 cmPkEgtpCfgReq(&pst, egtpCfg);
1012 /*******************************************************************
1014 * @brief Function to configure EGTP
1018 * Function : duBuildEgtpCfgReq
1021 * Function to configure EGTP
1024 * @return ROK - success
1027 * ****************************************************************/
1028 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1032 if(cfm.status == LCM_PRIM_OK)
1034 DU_LOG("\nDU_APP : EGTP configuraton complete");
1036 duSendEgtpSrvOpenReq();
1041 DU_LOG("\nDU_APP : EGTP configuraton failed");
1048 /*******************************************************************
1050 * @brief Sends server open request to EGTP
1054 * Function : duSendEgtpSrvOpenReq
1057 * Sends server open request to EGTP
1060 * @return ROK - success
1063 * ****************************************************************/
1065 S16 duSendEgtpSrvOpenReq()
1069 DU_LOG("\nDU_APP : Sending EGTP server open request");
1071 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1072 cmPkEgtpSrvOpenReq(&pst);
1077 /*******************************************************************
1079 * @brief Handles server open confirmation
1083 * Function : duHdlEgtpSrvOpenComplete
1086 * Handles server open confirmation
1089 * @return ROK - success
1092 *****************************************************************/
1094 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1098 if(cfm.status == LCM_PRIM_OK)
1100 DU_LOG("\nDU_APP : EGTP server opened successfully");
1102 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1107 DU_LOG("\nDU_APP : EGTP server opening failed");
1114 /*******************************************************************
1116 * @brief Sends tunnel management request
1120 * Function : duSendEgtpTnlMgmtReq
1123 * Builds and sends tunnel management request to EGTP
1125 * @params[in] Action
1126 * Local tunnel endpoint id
1127 * Remote tunnel endpoint id
1128 * @return ROK - success
1131 * ****************************************************************/
1133 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1138 tnlEvt.action = action;
1139 tnlEvt.lclTeid = lclTeid;
1140 tnlEvt.remTeid = remTeid;
1142 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1144 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1145 cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1150 /*******************************************************************
1152 * @brief Handles Tunnel management confirm
1156 * Function : duHdlEgtpTnlMgmtCfm
1159 * Handles tunnel management confirm received from Egtp
1161 * @params[in] Tunnel Event
1162 * @return ROK - success
1165 * ****************************************************************/
1166 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1170 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1172 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1175 duSendUeCreateReqToRlc();
1177 duSendEgtpTestData();
1179 /* For testing purpose. TTI thread should actually be in L1 */
1185 DU_LOG("\nDU_APP : Tunnel management failed");
1192 S16 duSendEgtpDatInd(Buffer *mBuf)
1196 /* Fill EGTP header */
1197 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1198 egtpMsg.msgHdr.nPdu.pres = FALSE;
1199 egtpMsg.msgHdr.seqNum.pres = FALSE;
1200 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1201 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1202 egtpMsg.msgHdr.teId = 1;
1205 egtpHdlDatInd(egtpMsg);
1212 /*******************************************************************
1214 * @brief Simulate UL Data for intial test
1218 * Function : duSendEgtpTestData
1221 * Simulate UL data for initial test
1224 * @return ROK - success
1227 * ****************************************************************/
1228 S16 duSendEgtpTestData()
1230 char data[30] = "This is EGTP data from DU";
1235 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1237 if(SAddPstMsgMult((Data *)data, datSize, mBuf) != ROK)
1239 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1246 DU_LOG("\nDU_APP : Failed to allocate memory");
1250 /* filling IPv4 header */
1255 SFndLenMsg(mBuf, &mLen);
1257 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1258 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1259 ipv4Hdr.hdrVer = 0x45;
1261 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1262 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1264 /* Packing IPv4 header into buffer */
1266 Data revPkArray[CM_IPV4_HDRLEN];
1267 Data pkArray[CM_IPV4_HDRLEN];
1269 /* initialize locals */
1271 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1272 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1274 /* Pack Header Version */
1275 pkArray[cnt++] = ipv4Hdr.hdrVer;
1278 pkArray[cnt++] = ipv4Hdr.tos;
1280 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1281 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1284 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1285 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1288 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1289 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1292 pkArray[cnt++] = ipv4Hdr.ttl;
1295 pkArray[cnt++] = ipv4Hdr.proto;
1298 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1299 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1301 /* Pack Source Address */
1302 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1303 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1304 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1305 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1307 /* Pack Destination Address */
1308 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1309 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1310 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1311 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1313 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1314 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1316 /* this function automatically reverses revPkArray */
1317 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1319 duSendEgtpDatInd(mBuf);
1323 #endif /* EGTP_TEST */
1326 /**************************************************************************
1327 * @brief Function to send configs to SCH
1331 * Function : duSendSchCfg
1334 * Sends general config to Scheduler via MAC layer
1337 * @return ROK - success
1340 ***************************************************************************/
1344 RgSchInstCfg *cfg = NULLP;
1347 DU_SET_ZERO(&pst, sizeof(Pst));
1348 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1350 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1352 /* Filling of Instance Id */
1353 cfg->instId = DEFAULT_CELLS + 1;
1354 /* Filling of Gen config */
1355 cfg->genCfg.mem.region = RG_MEM_REGION;
1356 cfg->genCfg.mem.pool = RG_POOL;
1357 cfg->genCfg.tmrRes = 10;
1360 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1361 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1363 cfg->genCfg.startCellId = 1;
1364 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1365 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1366 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1367 cfg->genCfg.lmPst.dstInst = DU_INST;
1368 cfg->genCfg.lmPst.srcEnt = ENTRG;
1369 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1370 cfg->genCfg.lmPst.prior = PRIOR0;
1371 cfg->genCfg.lmPst.route = RTESPEC;
1372 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1373 cfg->genCfg.lmPst.pool = RG_POOL;
1374 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1377 rgMngmt.hdr.msgType = TCFG;
1378 rgMngmt.hdr.entId.ent = ENTRG;
1379 rgMngmt.hdr.entId.inst = DU_INST;
1380 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1381 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1382 rgMngmt.hdr.response.mem.pool = RG_POOL;
1385 pst.selector = DU_SELECTOR_LC;
1386 pst.srcEnt = ENTDUAPP;
1388 pst.dstProcId = DU_PROC;
1389 pst.srcProcId = DU_PROC;
1390 pst.srcInst = DU_INST;
1392 pst.region = duCb.init.region;
1393 pst.event = (Event) EVTMACSCHGENCFGREQ;
1395 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1397 /* Send the request to MAC */
1398 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1404 /**************************************************************************
1405 * @brief Function to configure SCTP params and
1406 * responsible for F1 and E2 interfaces
1410 * Function : duLayerConfigComplete
1413 * Configures SCTP Params and responsible for handling
1414 * F1 and E2 interface.
1417 * @return ROK - success
1420 ***************************************************************************/
1421 S16 duLayerConfigComplete()
1425 DU_LOG("\nDU_APP : Configuring all Layer is complete");
1427 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1429 DU_LOG("\nDU_APP : Failed configuring Sctp Params");
1432 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1434 DU_LOG("\nDU_APP : Failed to send AssocReq F1");
1437 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1439 DU_LOG("\nDU_APP : Failed to send AssocReq E2");
1446 /**************************************************************************
1447 * @brief Function to handle SCH Config Confirm from MAC
1451 * Function : duHdlSchCfgComplete
1454 * Handles Scheduler Gen Config Confirm from MAC
1456 * @param[in] Pst *pst, Post structure of the primitive.
1457 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1458 * @return ROK - success
1461 ***************************************************************************/
1462 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1464 if (cfm->cfm.status == LCM_PRIM_OK)
1466 switch (cfm->hdr.elmId.elmnt)
1470 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1477 duLayerConfigComplete();
1478 duBuildEgtpCfgReq();
1482 /*******************************************************************
1484 * @brief Handles TTI indication
1488 * Function : duSendEgtpTTIInd
1491 * Handles TTI indication received from PHY
1494 * @return ROK - success
1497 * ****************************************************************/
1498 S16 duSendEgtpTTIInd()
1502 duFillEgtpPst(&pst, EVTTTIIND);
1503 cmPkEgtpTTIInd(&pst);
1509 /**************************************************************************
1510 * @brief Function to fill and send MacCellconfig
1514 * Function : duBuildAndSendMacCellCfg
1517 * Initiates MAC Configs towards MAC
1520 * @return ROK - success
1523 ***************************************************************************/
1524 S16 duBuildAndSendMacCellCfg()
1527 DU_SET_ZERO(&pst, sizeof(Pst));
1528 MacCellCfg *duMacCellCfg = NULLP;
1530 DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
1531 if(duMacCellCfg == NULLP)
1536 /* store the address in the duCb so that we can free on confirm msg */
1537 duCb.duMacCellCfg = duMacCellCfg;
1539 /* copy the mac config structure from duCfgParams */
1540 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1542 duMacCellCfg->transId = getTransId(); /* transaction ID */
1545 pst.selector = DU_SELECTOR_LWLC;
1546 pst.srcEnt = ENTDUAPP;
1550 pst.dstProcId = DU_PROC;
1551 pst.srcProcId = DU_PROC;
1552 pst.region = duCb.init.region;
1553 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1555 /* Send MAC cell config to MAC */
1556 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1559 /**************************************************************************
1560 * @brief Function to Handle MAC cell config confirm
1564 * Function : duHandleMacCellCfgCfm
1567 * Initiates general Configs towards MAC
1570 * @return ROK - success
1573 ***************************************************************************/
1574 S16 duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1578 if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
1580 /* free the memory allocated during sending macCellCfg request */
1581 DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
1582 duCb.duMacCellCfg = NULLP;
1584 /* Build and send GNB-DU config update */
1585 ret = BuildAndSendDUConfigUpdate();
1589 /* transaction ID missmatch */
1590 DU_LOG("\n transaction ID mismatch in macCellCfg");
1597 /**********************************************************************
1599 **********************************************************************/