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 */
22 #include "du_f1ap_msg_hdl.h"
25 #include "lphy_stub.h"
34 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 packMacCellCfgMt[] =
42 packLcMacCellCfg, /* packing for loosely coupled */
43 packTcMacCellCfg, /* packing for tightly coupled */
44 packLwLcMacCellCfg, /* 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++) //TODO: the length of this loop must be determined
297 DU_ALLOC(cell, sizeof(DuCellCb))
300 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
307 cell->cellId = cellId++;
308 memcpy((void*)&cell->cellInfo, (void*)&duCfgParam.cellCfg[idx],\
309 sizeof(CellCfgParams));
310 cell->cellStatus = OOS;
311 nci = cell->cellInfo.nrEcgi.cellId;
312 ret = cmHashListInsert(&(duCb.cellLst), (PTR)(cell),
313 (U8 *)&(nci), (U16) sizeof(nci));
317 DU_LOG("\nDU_APP : HashListInsert into cellLst failed for [%d]", nci);
322 DU_LOG("\nDU_APP : HashListInsert into cellLst successful for [%d]", nci);
328 //Start layer configs
329 ret = duSendRlcUlCfg();
333 /**************************************************************************
334 * @brief Function to invoke DU Layer Configs
338 * Function : duSendRlcUlCfg
341 * Initiates Configs towards layers of DU
344 * @return ROK - success
347 ***************************************************************************/
352 duBuildRlcCfg((Inst)RLC_UL_INST);
353 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
355 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
357 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
362 /**************************************************************************
363 * @brief Function to invoke DU Layer Configs
367 * Function : duSendRlcDlCfg
370 * Initiates Configs towards layers of DU
373 * @return ROK - success
376 ***************************************************************************/
381 duBuildRlcCfg((Inst)RLC_DL_INST);
382 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
383 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
385 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
390 /**************************************************************************
391 * @brief Function to handle Config Confirm from RLC
395 * Function : duHdlRlcCfgComplete
398 * Handles Gen Config Confirm from RLC
400 * @param[in] Pst *pst, Post structure of the primitive.
401 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
402 * @return ROK - success
405 ***************************************************************************/
406 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
409 if (pst->srcInst == RLC_UL_INST)
411 ret = duProcRlcUlCfgComplete(pst, cfm);
415 ret = duProcRlcDlCfgComplete(pst, cfm);
420 /**************************************************************************
421 * @brief Function to handle Control Config Confirm from RLC
425 * Function : duHdlRlcCntrlCfgComplete
428 * Handles Control Config Confirm from RLC
430 * @param[in] Pst *pst, Post structure of the primitive.
431 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
432 * @return ROK - success
435 ***************************************************************************/
436 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
440 if (cntrl->cfm.status == LCM_PRIM_OK)
442 switch (cntrl->hdr.elmId.elmnt)
446 if (pst->srcInst == RLC_DL_INST)
448 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
450 if(macCfgInst < DEFAULT_CELLS)
453 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
457 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
462 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
464 if(macCfgInst < DEFAULT_CELLS)
466 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
480 /**************************************************************************
481 * @brief Function to handle Config Confirm from RLC UL
485 * Function : duHdlRlcUlCfgComplete
488 * Handles Config Confirm from RLC UL
490 * @param[in] Pst *pst, Post structure of the primitive.
491 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
492 * @return ROK - success
495 ***************************************************************************/
496 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
500 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
501 if (cfm->cfm.status == LCM_PRIM_OK)
503 switch(cfm->hdr.elmId.elmnt)
507 rlcUlCfg |= RLC_GEN_CFG;
513 if(numRlcMacSaps == DEFAULT_CELLS)
515 rlcUlCfg |= RLC_MAC_SAP_CFG;
522 rlcUlCfg |= RLC_UDX_SAP_CFG;
529 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
530 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
534 //Start configuration of RLC DL
541 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
547 /**************************************************************************
548 * @brief Function to handle Config Confirm from RLC DL
552 * Function : duHdlRlcDlCfgComplete
555 * Handles Config Confirm from RLC DL
557 * @param[in] Pst *pst, Post structure of the primitive.
558 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
559 * @return ROK - success
562 ***************************************************************************/
563 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
565 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
566 if (cfm->cfm.status == LCM_PRIM_OK)
568 switch(cfm->hdr.elmId.elmnt)
572 rlcDlCfg |= RLC_GEN_CFG;
578 if(numRlcMacSaps == DEFAULT_CELLS)
580 rlcDlCfg |= RLC_MAC_SAP_CFG;
587 rlcDlCfg |= RLC_UDX_SAP_CFG;
595 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
596 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
599 //Start configuration of MAC
606 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
611 /**************************************************************************
612 * @brief Function to send configs to MAC
616 * Function : duSendMacCfg
619 * Initiates Configs towards MAC layer
622 * @return ROK - success
625 ***************************************************************************/
629 duBuildMacUsapCfg(RLC_UL_INST);
630 duBuildMacUsapCfg(RLC_DL_INST);
635 /**************************************************************************
636 * @brief Function to fill gen config required by MAC
640 * Function : duBuildMacGenCfg
643 * Initiates general Configs towards MAC
646 * @return ROK - success
649 ***************************************************************************/
650 S16 duBuildMacGenCfg()
653 RgGenCfg *genCfg=NULLP;
656 DU_SET_ZERO(&pst, sizeof(Pst));
657 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
659 genCfg = &(rgMngmt.t.cfg.s.genCfg);
661 /*----------- Fill General Configuration Parameters ---------*/
662 genCfg->mem.region = RG_MEM_REGION;
663 genCfg->mem.pool = RG_POOL;
665 genCfg->numRguSaps = 2;
667 genCfg->lmPst.dstProcId = DU_PROC;
668 genCfg->lmPst.srcProcId = DU_PROC;
669 genCfg->lmPst.dstEnt = ENTDUAPP;
670 genCfg->lmPst.dstInst = 0;
671 genCfg->lmPst.srcEnt = ENTRG;
672 genCfg->lmPst.srcInst = macCfgInst;
673 genCfg->lmPst.prior = PRIOR0;
674 genCfg->lmPst.route = RTESPEC;
675 genCfg->lmPst.region = RG_MEM_REGION;
676 genCfg->lmPst.pool = RG_POOL;
677 genCfg->lmPst.selector = DU_SELECTOR_LC;
680 rgMngmt.hdr.msgType = TCFG;
681 rgMngmt.hdr.msgLen = 0;
682 rgMngmt.hdr.entId.ent = ENTRG;
683 rgMngmt.hdr.entId.inst = (Inst)0;
684 rgMngmt.hdr.elmId.elmnt = STGEN;
685 rgMngmt.hdr.seqNmb = 0;
686 rgMngmt.hdr.version = 0;
687 rgMngmt.hdr.transId = 0;
689 rgMngmt.hdr.response.prior = PRIOR0;
690 rgMngmt.hdr.response.route = RTESPEC;
691 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
692 rgMngmt.hdr.response.mem.pool = RG_POOL;
693 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
696 pst.selector = DU_SELECTOR_LC;
697 pst.srcEnt = ENTDUAPP;
699 pst.dstInst = macCfgInst;
700 pst.dstProcId = DU_PROC;
701 pst.srcProcId = DU_PROC;
702 pst.region = duCb.init.region;
704 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
706 /* Send the request to MAC */
707 cmPkLrgCfgReq(&pst, &rgMngmt);
712 /**************************************************************************
713 * @brief Function to fill USAP config required by MAC
717 * Function : duBuildMacUsapCfg
720 * Initiates USAP Configs towards MAC
722 * @param[in] SpId Specifies if RLC UL or RLC DL instance
723 * @return ROK - success
726 ***************************************************************************/
727 S16 duBuildMacUsapCfg(SpId sapId)
730 RgUpSapCfg *uSap = NULLP;
733 DU_SET_ZERO(&pst, sizeof(Pst));
734 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
736 uSap = &(rgMngmt.t.cfg.s.rguSap);
738 uSap->mem.region = RG_MEM_REGION;
739 uSap->mem.pool = RG_POOL;
742 uSap->procId = DU_PROC;
745 uSap->prior = PRIOR0;
746 uSap->route = RTESPEC;
747 uSap->selector = DU_SELECTOR_LC ;
750 rgMngmt.hdr.msgType = TCFG;
751 rgMngmt.hdr.entId.ent = ENTRG;
752 rgMngmt.hdr.entId.inst = (Inst)0;
753 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
754 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
755 rgMngmt.hdr.response.mem.pool = RG_POOL;
758 pst.selector = DU_SELECTOR_LC;
759 pst.srcEnt = ENTDUAPP;
761 pst.dstInst = macCfgInst;
762 pst.dstProcId = DU_PROC;
763 pst.srcProcId = DU_PROC;
764 pst.region = duCb.init.region;
766 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
768 /* Send the request to MAC */
769 cmPkLrgCfgReq(&pst, &rgMngmt);
774 /**************************************************************************
775 * @brief Function to handle Config Confirm from MAC
779 * Function : duHdlMacCfgComplete
782 * Handles Gen Config Confirm from MAC
784 * @param[in] Pst *pst, Post structure of the primitive.
785 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
786 * @return ROK - success
789 ***************************************************************************/
790 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
794 if (cfm->cfm.status == LCM_PRIM_OK)
796 switch (cfm->hdr.elmId.elmnt)
800 macCfg |= MAC_GEN_CFG;
805 macCfg |= MAC_SAP_CFG;
812 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
813 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
816 DU_LOG("\nDU_APP : Completed sending Configs");
818 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
824 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
830 /**************************************************************************
831 * @brief Function to bind/unbind RLC to MAC SAP
835 * Function : duBindUnbindRlcToMacSap
838 * Initiates Bind/Unbind from RLC to MAC
840 * @param[in] Inst Specifies if RLC UL or RLC DL instance
841 * @param[in] action Specifies if action is bind or unbind
842 * @return ROK - success
845 ***************************************************************************/
846 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
848 KwCntrl *cntrl = NULLP;
852 TRC2(smBindKwToRguSap)
854 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
855 DU_SET_ZERO(&pst, sizeof(Pst));
859 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
863 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
865 cntrl = &(kwMngmt.t.cntrl);
867 cntrl->action = action;
868 cntrl->subAction = DU_ZERO_VAL;
869 cntrl->s.sapCntrl.suId = macCfgInst;
870 cntrl->s.sapCntrl.spId = inst;
873 kwMngmt.hdr.msgType = TCNTRL;
874 kwMngmt.hdr.entId.ent = ENTKW;
875 kwMngmt.hdr.entId.inst = inst;
876 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
877 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
878 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
879 kwMngmt.hdr.response.mem.pool = RLC_POOL;
882 pst.selector = DU_SELECTOR_LC;
883 pst.srcEnt = ENTDUAPP;
885 pst.dstProcId = DU_PROC;
887 pst.srcProcId = DU_PROC;
888 pst.region = duCb.init.region;
890 cmPkLkwCntrlReq(&pst, &kwMngmt);
894 /*******************************************************************
896 * @brief Function to start SCTP
900 * Function : duSctpStartReq
903 * Function to start SCTP
906 * @return ROK - success
909 * ****************************************************************/
914 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
915 pst.srcEnt = (Ent)ENTDUAPP;
916 pst.srcInst = (Inst)DU_INST;
917 pst.srcProcId = DU_PROC;
918 pst.dstEnt = (Ent)ENTSCTP;
919 pst.dstInst = (Inst)SCTP_INST;
920 pst.dstProcId = pst.srcProcId;
921 pst.event = EVTSCTPSTRT;
922 pst.selector = DU_SELECTOR_LC;
925 cmPkSctpAssocReq(&pst, duCfgParam.sctpParams);
930 /*******************************************************************
932 * @brief Handles SCTP notifications
936 * Function : duSctpNtfyHdl
939 * Handles SCTP notification
941 * @params[in] Message Buffer
944 * @return ROK - success
947 * ****************************************************************/
949 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
951 switch(ntfy->header.nType)
953 case CM_INET_SCTP_ASSOC_CHANGE:
954 switch(ntfy->u.assocChange.state)
956 case CM_INET_SCTP_COMM_UP:
958 DU_LOG("\nDU_APP : SCTP communication UP");
962 /* Build and send F1 Setup response */
963 if(BuildAndSendF1SetupReq() != ROK)
970 //Only SCTP is down, when SCTP comes up again, no need to
971 //start from setting up F1 link
981 /*******************************************************************
983 * @brief Fills Pst struct for ENTEGTP
987 * Function : duFillEgtpPst
990 * Fills Pst struct for ENTEGTP
993 * @return ROK - success
996 * ****************************************************************/
997 S16 duFillEgtpPst(Pst *pst, Event event)
999 cmMemset((U8 *)pst, 0, sizeof(Pst));
1000 pst->srcEnt = (Ent)ENTDUAPP;
1001 pst->srcInst = (Inst)DU_INST;
1002 pst->srcProcId = DU_PROC;
1003 pst->dstEnt = (Ent)ENTEGTP;
1004 pst->dstInst = (Inst)EGTP_INST;
1005 pst->dstProcId = pst->srcProcId;
1007 pst->selector = DU_SELECTOR_LC;
1014 /*******************************************************************
1016 * @brief Function to configure EGTP
1020 * Function : duBuildEgtpCfgReq
1023 * Function to configure EGTP
1026 * @return ROK - success
1029 * ****************************************************************/
1031 S16 duBuildEgtpCfgReq()
1036 DU_LOG("\nDU_APP : Sending EGTP config request");
1038 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1039 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1041 duFillEgtpPst(&pst, EVTCFGREQ);
1042 cmPkEgtpCfgReq(&pst, egtpCfg);
1047 /*******************************************************************
1049 * @brief Function to configure EGTP
1053 * Function : duBuildEgtpCfgReq
1056 * Function to configure EGTP
1059 * @return ROK - success
1062 * ****************************************************************/
1063 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1067 if(cfm.status == LCM_PRIM_OK)
1069 DU_LOG("\nDU_APP : EGTP configuraton complete");
1071 duSendEgtpSrvOpenReq();
1076 DU_LOG("\nDU_APP : EGTP configuraton failed");
1083 /*******************************************************************
1085 * @brief Sends server open request to EGTP
1089 * Function : duSendEgtpSrvOpenReq
1092 * Sends server open request to EGTP
1095 * @return ROK - success
1098 * ****************************************************************/
1100 S16 duSendEgtpSrvOpenReq()
1104 DU_LOG("\nDU_APP : Sending EGTP server open request");
1106 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1107 cmPkEgtpSrvOpenReq(&pst);
1112 /*******************************************************************
1114 * @brief Handles server open confirmation
1118 * Function : duHdlEgtpSrvOpenComplete
1121 * Handles server open confirmation
1124 * @return ROK - success
1127 *****************************************************************/
1129 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1133 if(cfm.status == LCM_PRIM_OK)
1135 DU_LOG("\nDU_APP : EGTP server opened successfully");
1137 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1142 DU_LOG("\nDU_APP : EGTP server opening failed");
1149 /*******************************************************************
1151 * @brief Sends tunnel management request
1155 * Function : duSendEgtpTnlMgmtReq
1158 * Builds and sends tunnel management request to EGTP
1160 * @params[in] Action
1161 * Local tunnel endpoint id
1162 * Remote tunnel endpoint id
1163 * @return ROK - success
1166 * ****************************************************************/
1168 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1173 tnlEvt.action = action;
1174 tnlEvt.lclTeid = lclTeid;
1175 tnlEvt.remTeid = remTeid;
1177 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1179 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1180 cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1185 /*******************************************************************
1187 * @brief Handles Tunnel management confirm
1191 * Function : duHdlEgtpTnlMgmtCfm
1194 * Handles tunnel management confirm received from Egtp
1196 * @params[in] Tunnel Event
1197 * @return ROK - success
1200 * ****************************************************************/
1201 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1205 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1207 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1212 /* For testing purpose. TTI thread should actually be in L1 */
1218 DU_LOG("\nDU_APP : Tunnel management failed");
1226 /*******************************************************************
1228 * @brief Simulate RLC to EGTP data indication
1232 * Function : duSendEgtpDatInd
1235 * Simulate RLC to EGTP data indication
1238 * @return ROK - success
1241 * ****************************************************************/
1242 S16 duSendEgtpDatInd()
1244 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 SPrntMsg(mBuf, 0,0);
1258 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1265 DU_LOG("\nDU_APP : Failed to allocate memory");
1269 /* filling IPv4 header */
1274 SFndLenMsg(mBuf, &mLen);
1276 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1277 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1278 ipv4Hdr.hdrVer = 0x45;
1280 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1281 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1283 /* Packing IPv4 header into buffer */
1285 Data revPkArray[CM_IPV4_HDRLEN];
1286 Data pkArray[CM_IPV4_HDRLEN];
1288 /* initialize locals */
1290 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1291 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1293 /* Pack Header Version */
1294 pkArray[cnt++] = ipv4Hdr.hdrVer;
1297 pkArray[cnt++] = ipv4Hdr.tos;
1299 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1300 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1303 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1304 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1307 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1308 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1311 pkArray[cnt++] = ipv4Hdr.ttl;
1314 pkArray[cnt++] = ipv4Hdr.proto;
1317 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1318 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1320 /* Pack Source Address */
1321 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1322 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1323 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1324 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1326 /* Pack Destination Address */
1327 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1328 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1329 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1330 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1332 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1333 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1335 /* this function automatically reverses revPkArray */
1336 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1339 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1340 egtpMsg.msgHdr.nPdu.pres = FALSE;
1341 egtpMsg.msgHdr.seqNum.pres = FALSE;
1342 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1343 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1344 egtpMsg.msgHdr.teId = 1;
1347 SPrntMsg(mBuf, 0, 0);
1349 egtpHdlDatInd(egtpMsg);
1353 #endif /* EGTP_TEST */
1356 /**************************************************************************
1357 * @brief Function to send configs to SCH
1361 * Function : duSendSchCfg
1364 * Sends general config to Scheduler via MAC layer
1367 * @return ROK - success
1370 ***************************************************************************/
1374 RgSchInstCfg *cfg = NULLP;
1377 DU_SET_ZERO(&pst, sizeof(Pst));
1378 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1380 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1382 /* Filling of Instance Id */
1383 cfg->instId = DEFAULT_CELLS + 1;
1384 /* Filling of Gen config */
1385 cfg->genCfg.mem.region = RG_MEM_REGION;
1386 cfg->genCfg.mem.pool = RG_POOL;
1387 cfg->genCfg.tmrRes = 10;
1390 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1391 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1393 cfg->genCfg.startCellId = 1;
1394 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1395 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1396 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1397 cfg->genCfg.lmPst.dstInst = DU_INST;
1398 cfg->genCfg.lmPst.srcEnt = ENTRG;
1399 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1400 cfg->genCfg.lmPst.prior = PRIOR0;
1401 cfg->genCfg.lmPst.route = RTESPEC;
1402 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1403 cfg->genCfg.lmPst.pool = RG_POOL;
1404 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1407 rgMngmt.hdr.msgType = TCFG;
1408 rgMngmt.hdr.entId.ent = ENTRG;
1409 rgMngmt.hdr.entId.inst = DU_INST;
1410 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1411 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1412 rgMngmt.hdr.response.mem.pool = RG_POOL;
1415 pst.selector = DU_SELECTOR_LC;
1416 pst.srcEnt = ENTDUAPP;
1418 pst.dstProcId = DU_PROC;
1419 pst.srcProcId = DU_PROC;
1420 pst.srcInst = DU_INST;
1422 pst.region = duCb.init.region;
1423 pst.event = (Event) EVTMACSCHGENCFGREQ;
1425 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1427 /* Send the request to MAC */
1428 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1433 /**************************************************************************
1434 * @brief Function to handle SCH Config Confirm from MAC
1438 * Function : duHdlSchCfgComplete
1441 * Handles Scheduler Gen Config Confirm from MAC
1443 * @param[in] Pst *pst, Post structure of the primitive.
1444 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1445 * @return ROK - success
1448 ***************************************************************************/
1449 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1451 if (cfm->cfm.status == LCM_PRIM_OK)
1453 switch (cfm->hdr.elmId.elmnt)
1457 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1466 duBuildEgtpCfgReq();
1470 /*******************************************************************
1472 * @brief Handles TTI indication
1476 * Function : duSendEgtpTTIInd
1479 * Handles TTI indication received from PHY
1482 * @return ROK - success
1485 * ****************************************************************/
1486 S16 duSendEgtpTTIInd()
1490 duFillEgtpPst(&pst, EVTTTIIND);
1491 cmPkEgtpTTIInd(&pst);
1497 /**************************************************************************
1498 * @brief Function to fill and send MacCellconfig
1502 * Function : duBuildAndSendMacCellCfg
1505 * Initiates MAC Configs towards MAC
1508 * @return ROK - success
1511 ***************************************************************************/
1512 S16 duBuildAndSendMacCellCfg()
1515 DU_SET_ZERO(&pst, sizeof(Pst));
1516 MacCellCfg *pMacCellCfg = NULLP;
1518 DU_ALLOC(pMacCellCfg, sizeof(MacCellCfg));
1519 if(pMacCellCfg == NULLP)
1524 /* store the address in the duCb so that we can free on confirm msg */
1525 duCb.ptrMacCellCfg = pMacCellCfg;
1527 /* copy the mac config structure from duCfgParams */
1528 memcpy(pMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1530 pMacCellCfg->transId = cmGetTransId(); /* transaction ID */
1533 pst.selector = DU_SELECTOR_LWLC;
1534 pst.srcEnt = ENTDUAPP;
1538 pst.dstProcId = DU_PROC;
1539 pst.srcProcId = DU_PROC;
1540 pst.region = duCb.init.region;
1541 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1543 /* Send MAC cell config to MAC */
1544 return (*packMacCellCfgMt[pst.selector])(&pst, pMacCellCfg);
1547 /**************************************************************************
1548 * @brief Function to Handle MAC cell config confirm
1552 * Function : duHandleMacCellCfgCfm
1555 * Initiates general Configs towards MAC
1558 * @return ROK - success
1561 ***************************************************************************/
1562 S16 duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1566 if(macCellCfgCfm->transId == duCb.ptrMacCellCfg->transId)
1568 /* free the memory allocated during sending macCellCfg request */
1569 DU_FREE(duCb.ptrMacCellCfg,sizeof(MacCellCfg));
1570 duCb.ptrMacCellCfg = NULLP;
1572 /* Build and send GNB-DU config update */
1573 ret = BuildAndSendDUConfigUpdate();
1577 /* transaction ID missmatch */
1578 DU_LOG("\n transaction ID mismatch in macCellCfg");
1585 /**********************************************************************
1587 **********************************************************************/