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 switch(ntfy->header.nType)
926 case CM_INET_SCTP_ASSOC_CHANGE:
927 switch(ntfy->u.assocChange.state)
929 case CM_INET_SCTP_COMM_UP:
931 DU_LOG("\nDU_APP : SCTP communication UP");
933 if(ntfy->u.assocChange.assocId == f1Params.assocId)
935 /* Build and send F1 Setup response */
936 if(BuildAndSendF1SetupReq() != ROK)
942 if(ntfy->u.assocChange.assocId == ricParams.assocId)
944 /* Build and send F1 Setup response */
945 if(BuildAndSendE2SetupReq() != ROK)
959 /*******************************************************************
961 * @brief Fills Pst struct for ENTEGTP
965 * Function : duFillEgtpPst
968 * Fills Pst struct for ENTEGTP
971 * @return ROK - success
974 * ****************************************************************/
975 S16 duFillEgtpPst(Pst *pst, Event event)
977 cmMemset((U8 *)pst, 0, sizeof(Pst));
978 pst->srcEnt = (Ent)ENTDUAPP;
979 pst->srcInst = (Inst)DU_INST;
980 pst->srcProcId = DU_PROC;
981 pst->dstEnt = (Ent)ENTEGTP;
982 pst->dstInst = (Inst)EGTP_INST;
983 pst->dstProcId = pst->srcProcId;
985 pst->selector = DU_SELECTOR_LC;
992 /*******************************************************************
994 * @brief Function to configure EGTP
998 * Function : duBuildEgtpCfgReq
1001 * Function to configure EGTP
1004 * @return ROK - success
1007 * ****************************************************************/
1009 S16 duBuildEgtpCfgReq()
1014 DU_LOG("\nDU_APP : Sending EGTP config request");
1016 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1017 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1019 duFillEgtpPst(&pst, EVTCFGREQ);
1020 cmPkEgtpCfgReq(&pst, egtpCfg);
1025 /*******************************************************************
1027 * @brief Function to configure EGTP
1031 * Function : duBuildEgtpCfgReq
1034 * Function to configure EGTP
1037 * @return ROK - success
1040 * ****************************************************************/
1041 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1045 if(cfm.status == LCM_PRIM_OK)
1047 DU_LOG("\nDU_APP : EGTP configuraton complete");
1049 duSendEgtpSrvOpenReq();
1054 DU_LOG("\nDU_APP : EGTP configuraton failed");
1061 /*******************************************************************
1063 * @brief Sends server open request to EGTP
1067 * Function : duSendEgtpSrvOpenReq
1070 * Sends server open request to EGTP
1073 * @return ROK - success
1076 * ****************************************************************/
1078 S16 duSendEgtpSrvOpenReq()
1082 DU_LOG("\nDU_APP : Sending EGTP server open request");
1084 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1085 cmPkEgtpSrvOpenReq(&pst);
1090 /*******************************************************************
1092 * @brief Handles server open confirmation
1096 * Function : duHdlEgtpSrvOpenComplete
1099 * Handles server open confirmation
1102 * @return ROK - success
1105 *****************************************************************/
1107 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1111 if(cfm.status == LCM_PRIM_OK)
1113 DU_LOG("\nDU_APP : EGTP server opened successfully");
1115 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1120 DU_LOG("\nDU_APP : EGTP server opening failed");
1127 /*******************************************************************
1129 * @brief Sends tunnel management request
1133 * Function : duSendEgtpTnlMgmtReq
1136 * Builds and sends tunnel management request to EGTP
1138 * @params[in] Action
1139 * Local tunnel endpoint id
1140 * Remote tunnel endpoint id
1141 * @return ROK - success
1144 * ****************************************************************/
1146 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1151 tnlEvt.action = action;
1152 tnlEvt.lclTeid = lclTeid;
1153 tnlEvt.remTeid = remTeid;
1155 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1157 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1158 cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1163 /*******************************************************************
1165 * @brief Handles Tunnel management confirm
1169 * Function : duHdlEgtpTnlMgmtCfm
1172 * Handles tunnel management confirm received from Egtp
1174 * @params[in] Tunnel Event
1175 * @return ROK - success
1178 * ****************************************************************/
1179 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1183 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1185 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1188 duSendUeCreateReqToRlc();
1190 duSendEgtpTestData();
1192 /* For testing purpose. TTI thread should actually be in L1 */
1198 DU_LOG("\nDU_APP : Tunnel management failed");
1205 S16 duSendEgtpDatInd(Buffer *mBuf)
1209 /* Fill EGTP header */
1210 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1211 egtpMsg.msgHdr.nPdu.pres = FALSE;
1212 egtpMsg.msgHdr.seqNum.pres = FALSE;
1213 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1214 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1215 egtpMsg.msgHdr.teId = 1;
1218 egtpHdlDatInd(egtpMsg);
1225 /*******************************************************************
1227 * @brief Simulate UL Data for intial test
1231 * Function : duSendEgtpTestData
1234 * Simulate UL data for initial test
1237 * @return ROK - success
1240 * ****************************************************************/
1241 S16 duSendEgtpTestData()
1243 char data[30] = "This is EGTP data from DU";
1248 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1250 if(SAddPstMsgMult((Data *)data, datSize, mBuf) != ROK)
1252 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1259 DU_LOG("\nDU_APP : Failed to allocate memory");
1263 /* filling IPv4 header */
1268 SFndLenMsg(mBuf, &mLen);
1270 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1271 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1272 ipv4Hdr.hdrVer = 0x45;
1274 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1275 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1277 /* Packing IPv4 header into buffer */
1279 Data revPkArray[CM_IPV4_HDRLEN];
1280 Data pkArray[CM_IPV4_HDRLEN];
1282 /* initialize locals */
1284 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1285 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1287 /* Pack Header Version */
1288 pkArray[cnt++] = ipv4Hdr.hdrVer;
1291 pkArray[cnt++] = ipv4Hdr.tos;
1293 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1294 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1297 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1298 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1301 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1302 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1305 pkArray[cnt++] = ipv4Hdr.ttl;
1308 pkArray[cnt++] = ipv4Hdr.proto;
1311 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1312 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1314 /* Pack Source Address */
1315 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1316 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1317 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1318 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1320 /* Pack Destination Address */
1321 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1322 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1323 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1324 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1326 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1327 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1329 /* this function automatically reverses revPkArray */
1330 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1332 duSendEgtpDatInd(mBuf);
1336 #endif /* EGTP_TEST */
1339 /**************************************************************************
1340 * @brief Function to send configs to SCH
1344 * Function : duSendSchCfg
1347 * Sends general config to Scheduler via MAC layer
1350 * @return ROK - success
1353 ***************************************************************************/
1357 RgSchInstCfg *cfg = NULLP;
1360 DU_SET_ZERO(&pst, sizeof(Pst));
1361 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1363 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1365 /* Filling of Instance Id */
1366 cfg->instId = DEFAULT_CELLS + 1;
1367 /* Filling of Gen config */
1368 cfg->genCfg.mem.region = RG_MEM_REGION;
1369 cfg->genCfg.mem.pool = RG_POOL;
1370 cfg->genCfg.tmrRes = 10;
1373 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1374 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1376 cfg->genCfg.startCellId = 1;
1377 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1378 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1379 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1380 cfg->genCfg.lmPst.dstInst = DU_INST;
1381 cfg->genCfg.lmPst.srcEnt = ENTRG;
1382 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1383 cfg->genCfg.lmPst.prior = PRIOR0;
1384 cfg->genCfg.lmPst.route = RTESPEC;
1385 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1386 cfg->genCfg.lmPst.pool = RG_POOL;
1387 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1390 rgMngmt.hdr.msgType = TCFG;
1391 rgMngmt.hdr.entId.ent = ENTRG;
1392 rgMngmt.hdr.entId.inst = DU_INST;
1393 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1394 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1395 rgMngmt.hdr.response.mem.pool = RG_POOL;
1398 pst.selector = DU_SELECTOR_LC;
1399 pst.srcEnt = ENTDUAPP;
1401 pst.dstProcId = DU_PROC;
1402 pst.srcProcId = DU_PROC;
1403 pst.srcInst = DU_INST;
1405 pst.region = duCb.init.region;
1406 pst.event = (Event) EVTMACSCHGENCFGREQ;
1408 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1410 /* Send the request to MAC */
1411 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1417 /**************************************************************************
1418 * @brief Function to configure SCTP params and
1419 * responsible for F1 and E2 interfaces
1423 * Function : duLayerConfigComplete
1426 * Configures SCTP Params and responsible for handling
1427 * F1 and E2 interface.
1430 * @return ROK - success
1433 ***************************************************************************/
1434 S16 duLayerConfigComplete()
1438 DU_LOG("\nDU_APP : Configuring all Layer is complete");
1440 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1442 DU_LOG("\nDU_APP : Failed configuring Sctp Params");
1445 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1447 DU_LOG("\nDU_APP : Failed to send AssocReq F1");
1450 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1452 DU_LOG("\nDU_APP : Failed to send AssocReq E2");
1459 /**************************************************************************
1460 * @brief Function to handle SCH Config Confirm from MAC
1464 * Function : duHdlSchCfgComplete
1467 * Handles Scheduler Gen Config Confirm from MAC
1469 * @param[in] Pst *pst, Post structure of the primitive.
1470 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1471 * @return ROK - success
1474 ***************************************************************************/
1475 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1477 if (cfm->cfm.status == LCM_PRIM_OK)
1479 switch (cfm->hdr.elmId.elmnt)
1483 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1490 duLayerConfigComplete();
1491 duBuildEgtpCfgReq();
1495 /*******************************************************************
1497 * @brief Handles TTI indication
1501 * Function : duSendEgtpTTIInd
1504 * Handles TTI indication received from PHY
1507 * @return ROK - success
1510 * ****************************************************************/
1511 S16 duSendEgtpTTIInd()
1515 duFillEgtpPst(&pst, EVTTTIIND);
1516 cmPkEgtpTTIInd(&pst);
1522 /**************************************************************************
1523 * @brief Function to fill and send MacCellconfig
1527 * Function : duBuildAndSendMacCellCfg
1530 * Initiates MAC Configs towards MAC
1533 * @return ROK - success
1536 ***************************************************************************/
1537 S16 duBuildAndSendMacCellCfg()
1540 DU_SET_ZERO(&pst, sizeof(Pst));
1541 MacCellCfg *duMacCellCfg = NULLP;
1543 DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
1544 if(duMacCellCfg == NULLP)
1549 /* store the address in the duCb so that we can free on confirm msg */
1550 duCb.duMacCellCfg = duMacCellCfg;
1552 /* copy the mac config structure from duCfgParams */
1553 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1555 duMacCellCfg->transId = getTransId(); /* transaction ID */
1558 pst.selector = DU_SELECTOR_LWLC;
1559 pst.srcEnt = ENTDUAPP;
1563 pst.dstProcId = DU_PROC;
1564 pst.srcProcId = DU_PROC;
1565 pst.region = duCb.init.region;
1566 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1568 /* Send MAC cell config to MAC */
1569 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1572 /**************************************************************************
1573 * @brief Function to Handle MAC cell config confirm
1577 * Function : duHandleMacCellCfgCfm
1580 * Initiates general Configs towards MAC
1583 * @return ROK - success
1586 ***************************************************************************/
1587 S16 duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1591 if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
1593 /* free the memory allocated during sending macCellCfg request */
1594 DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
1595 duCb.duMacCellCfg = NULLP;
1597 /* Build and send GNB-DU config update */
1598 ret = BuildAndSendDUConfigUpdate();
1602 /* transaction ID missmatch */
1603 DU_LOG("\n transaction ID mismatch in macCellCfg");
1610 /**********************************************************************
1612 **********************************************************************/