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;
35 extern S16 cmPkLkwCfgReq(Pst *pst, KwMngmt *cfg);
36 extern S16 cmPkLkwCntrlReq(Pst *pst, KwMngmt *cfg);
37 extern S16 cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
39 packMacCellCfgReq packMacCellCfgOpts[] =
41 packMacCellCfg, /* packing for loosely coupled */
42 MacHdlCellCfgReq, /* packing for tightly coupled */
43 packMacCellCfg, /* packing for light weight loosly coupled */
46 /**************************************************************************
47 * @brief Function to fill configs required by RLC
51 * Function : duBuildRlcCfg
54 * Initiates general Configs towards RLC
56 * @param[in] Inst Specifies if RLC UL or RLC DL instance
57 * @return ROK - success
60 ***************************************************************************/
61 S16 duBuildRlcCfg(Inst inst)
64 KwGenCfg *genCfg = NULLP;
67 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
68 DU_SET_ZERO(&pst, sizeof(Pst));
70 genCfg = &(kwMngmt.t.cfg.s.gen);
72 /*----------- Fill General Configuration Parameters ---------*/
73 genCfg->maxUe = duCfgParam.maxUe;
74 genCfg->maxKwuSaps = 2;
75 genCfg->maxUdxSaps = 1;
76 genCfg->rlcMode = (inst == RLC_UL_INST) ?
77 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
79 genCfg->maxRguSaps = DEFAULT_CELLS;
81 /*----------- Fill lmPst
82 * Parameters ---------*/
83 genCfg->lmPst.dstProcId = DU_PROC;
84 genCfg->lmPst.srcProcId = DU_PROC;
85 genCfg->lmPst.dstEnt = ENTDUAPP;
86 genCfg->lmPst.dstInst = DU_INST;
87 genCfg->lmPst.srcEnt = ENTKW;
88 genCfg->lmPst.srcInst = inst;
89 genCfg->lmPst.prior = PRIOR0;
90 genCfg->lmPst.route = RTESPEC;
91 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
92 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
93 genCfg->lmPst.pool = RLC_POOL;
94 genCfg->lmPst.selector = DU_SELECTOR_LC;
97 kwMngmt.hdr.msgType = TCFG;
98 kwMngmt.hdr.msgLen = 0;
99 kwMngmt.hdr.entId.ent = ENTKW;
100 kwMngmt.hdr.entId.inst = (Inst)0;
101 kwMngmt.hdr.elmId.elmnt = STGEN;
102 kwMngmt.hdr.seqNmb = 0;
103 kwMngmt.hdr.version = 0;
104 kwMngmt.hdr.transId = 0;
105 kwMngmt.hdr.response.prior = PRIOR0;
106 kwMngmt.hdr.response.route = RTESPEC;
107 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
108 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
109 kwMngmt.hdr.response.mem.pool = DU_POOL;
110 kwMngmt.hdr.response.selector = DU_SELECTOR_LC;
113 pst.selector = DU_SELECTOR_LC;
114 pst.srcEnt = ENTDUAPP;
117 pst.dstProcId = DU_PROC;
118 pst.srcProcId = DU_PROC;
119 pst.region = duCb.init.region;
121 DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
123 /* Send the request to RLC */
124 cmPkLkwCfgReq(&pst, &kwMngmt);
129 /**************************************************************************
130 * @brief Function to fill configs required by RLC
134 * Function : duBuildRlcLsapCfg
137 * Initiates general Configs towards RLC
139 * @param[in] Inst Specifies if RLC UL or RLC DL instance
140 * @return ROK - success
143 ***************************************************************************/
144 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
148 KwSapCfg *lSap = NULLP;
151 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
152 DU_SET_ZERO(&pst, sizeof(Pst));
155 kwMngmt.hdr.msgType = TCFG;
156 kwMngmt.hdr.entId.ent = ENTKW;
157 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
158 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
160 kwMngmt.hdr.response.mem.pool = RLC_POOL;
163 pst.selector = DU_SELECTOR_LC;
164 pst.srcEnt = ENTDUAPP;
166 pst.dstProcId = DU_PROC;
168 pst.srcProcId = DU_PROC;
169 pst.region = duCb.init.region;
170 lSap = &(kwMngmt.t.cfg.s.sap);
172 lSap->mem.region = (inst == RLC_UL_INST) ?
173 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
174 lSap->mem.pool = RLC_POOL;
176 lSap->bndTmrIntvl = 10;
177 lSap->priority = PRIOR0;
178 lSap->route = RTESPEC;
181 lSap->procId = DU_PROC;
183 lSap->inst = lsapInst;
184 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
185 lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
186 kwMngmt.hdr.elmId.elmnt = STRGUSAP;
187 DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
192 lSap->procId = DU_PROC;
194 lSap->inst = (inst == RLC_UL_INST) ?
195 RLC_DL_INST : RLC_UL_INST;
197 lSap->selector = DU_SELECTOR_LC;
198 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
199 DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
202 cmPkLkwCfgReq(&pst, &kwMngmt);
206 /**************************************************************************
207 * @brief Function to fill configs required by RLC
211 * Function : duBuildRlcUsapCfg
214 * Initiates general Configs towards RLC
216 * @param[in] Inst Specifies if RLC UL or RLC DL instance
217 * @return ROK - success
220 ***************************************************************************/
221 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
224 KwSapCfg *uSap = NULLP;
227 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
228 DU_SET_ZERO(&pst, sizeof(Pst));
230 uSap = &(kwMngmt.t.cfg.s.sap);
232 uSap->selector = DU_SELECTOR_LC;
233 uSap->mem.region = (inst == RLC_UL_INST) ?
234 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
235 uSap->mem.pool = RLC_POOL;
238 uSap->procId = DU_PROC;
242 uSap->inst = (inst == RLC_UL_INST) ?
243 RLC_DL_INST : RLC_UL_INST;
244 uSap->bndTmrIntvl = 1000;
245 uSap->priority = PRIOR0;
246 uSap->route = RTESPEC;
249 kwMngmt.hdr.msgType = TCFG;
250 kwMngmt.hdr.entId.ent = ENTKW;
251 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
252 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
253 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
255 kwMngmt.hdr.response.mem.pool = RLC_POOL;
258 pst.selector = DU_SELECTOR_LC;
259 pst.srcEnt = ENTDUAPP;
261 pst.dstProcId = DU_PROC;
263 pst.srcProcId = DU_PROC;
264 pst.region = duCb.init.region;
266 DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
267 cmPkLkwCfgReq(&pst, &kwMngmt);
272 /**************************************************************************
273 * @brief Function to populate internal DS of DU APP
277 * Function : duProcCfgComplete
280 * Populates internal data structures of DU APP after
281 * receiving configurations.
284 * @return ROK - success
287 ***************************************************************************/
288 S16 duProcCfgComplete()
291 static U16 cellId = 0;
293 for(idx=0; idx< DEFAULT_CELLS; idx++) //TODO: the length of this loop must be determined
296 DU_ALLOC(cell, sizeof(DuCellCb))
299 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
306 cell->cellId = cellId++;
307 memcpy((void*)&cell->cellInfo, (void*)&duCfgParam.cellCfg[idx],\
308 sizeof(CellCfgParams));
309 cell->cellStatus = OOS;
310 nci = cell->cellInfo.nrEcgi.cellId;
311 ret = cmHashListInsert(&(duCb.cellLst), (PTR)(cell),
312 (U8 *)&(nci), (U16) sizeof(nci));
316 DU_LOG("\nDU_APP : HashListInsert into cellLst failed for [%d]", nci);
321 DU_LOG("\nDU_APP : HashListInsert into cellLst successful for [%d]", nci);
327 //Start layer configs
328 ret = duSendRlcUlCfg();
332 /**************************************************************************
333 * @brief Function to invoke DU Layer Configs
337 * Function : duSendRlcUlCfg
340 * Initiates Configs towards layers of DU
343 * @return ROK - success
346 ***************************************************************************/
351 duBuildRlcCfg((Inst)RLC_UL_INST);
352 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
354 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
356 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
361 /**************************************************************************
362 * @brief Function to invoke DU Layer Configs
366 * Function : duSendRlcDlCfg
369 * Initiates Configs towards layers of DU
372 * @return ROK - success
375 ***************************************************************************/
380 duBuildRlcCfg((Inst)RLC_DL_INST);
381 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
382 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
384 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
389 /**************************************************************************
390 * @brief Function to handle Config Confirm from RLC
394 * Function : duHdlRlcCfgComplete
397 * Handles Gen Config Confirm from RLC
399 * @param[in] Pst *pst, Post structure of the primitive.
400 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
401 * @return ROK - success
404 ***************************************************************************/
405 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
408 if (pst->srcInst == RLC_UL_INST)
410 ret = duProcRlcUlCfgComplete(pst, cfm);
414 ret = duProcRlcDlCfgComplete(pst, cfm);
419 /**************************************************************************
420 * @brief Function to handle Control Config Confirm from RLC
424 * Function : duHdlRlcCntrlCfgComplete
427 * Handles Control Config Confirm from RLC
429 * @param[in] Pst *pst, Post structure of the primitive.
430 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
431 * @return ROK - success
434 ***************************************************************************/
435 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
439 if (cntrl->cfm.status == LCM_PRIM_OK)
441 switch (cntrl->hdr.elmId.elmnt)
445 if (pst->srcInst == RLC_DL_INST)
447 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
449 if(macCfgInst < DEFAULT_CELLS)
452 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
456 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
461 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
463 if(macCfgInst < DEFAULT_CELLS)
465 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
479 /**************************************************************************
480 * @brief Function to handle Config Confirm from RLC UL
484 * Function : duHdlRlcUlCfgComplete
487 * Handles Config Confirm from RLC UL
489 * @param[in] Pst *pst, Post structure of the primitive.
490 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
491 * @return ROK - success
494 ***************************************************************************/
495 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
499 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
500 if (cfm->cfm.status == LCM_PRIM_OK)
502 switch(cfm->hdr.elmId.elmnt)
506 rlcUlCfg |= RLC_GEN_CFG;
512 if(numRlcMacSaps == DEFAULT_CELLS)
514 rlcUlCfg |= RLC_MAC_SAP_CFG;
521 rlcUlCfg |= RLC_UDX_SAP_CFG;
528 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
529 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
533 //Start configuration of RLC DL
540 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
546 /**************************************************************************
547 * @brief Function to handle Config Confirm from RLC DL
551 * Function : duHdlRlcDlCfgComplete
554 * Handles Config Confirm from RLC DL
556 * @param[in] Pst *pst, Post structure of the primitive.
557 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
558 * @return ROK - success
561 ***************************************************************************/
562 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
564 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
565 if (cfm->cfm.status == LCM_PRIM_OK)
567 switch(cfm->hdr.elmId.elmnt)
571 rlcDlCfg |= RLC_GEN_CFG;
577 if(numRlcMacSaps == DEFAULT_CELLS)
579 rlcDlCfg |= RLC_MAC_SAP_CFG;
586 rlcDlCfg |= RLC_UDX_SAP_CFG;
594 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
595 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
598 //Start configuration of MAC
605 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
610 /**************************************************************************
611 * @brief Function to send configs to MAC
615 * Function : duSendMacCfg
618 * Initiates Configs towards MAC layer
621 * @return ROK - success
624 ***************************************************************************/
628 duBuildMacUsapCfg(RLC_UL_INST);
629 duBuildMacUsapCfg(RLC_DL_INST);
634 /**************************************************************************
635 * @brief Function to fill gen config required by MAC
639 * Function : duBuildMacGenCfg
642 * Initiates general Configs towards MAC
645 * @return ROK - success
648 ***************************************************************************/
649 S16 duBuildMacGenCfg()
652 RgGenCfg *genCfg=NULLP;
655 DU_SET_ZERO(&pst, sizeof(Pst));
656 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
658 genCfg = &(rgMngmt.t.cfg.s.genCfg);
660 /*----------- Fill General Configuration Parameters ---------*/
661 genCfg->mem.region = RG_MEM_REGION;
662 genCfg->mem.pool = RG_POOL;
664 genCfg->numRguSaps = 2;
666 genCfg->lmPst.dstProcId = DU_PROC;
667 genCfg->lmPst.srcProcId = DU_PROC;
668 genCfg->lmPst.dstEnt = ENTDUAPP;
669 genCfg->lmPst.dstInst = 0;
670 genCfg->lmPst.srcEnt = ENTRG;
671 genCfg->lmPst.srcInst = macCfgInst;
672 genCfg->lmPst.prior = PRIOR0;
673 genCfg->lmPst.route = RTESPEC;
674 genCfg->lmPst.region = RG_MEM_REGION;
675 genCfg->lmPst.pool = RG_POOL;
676 genCfg->lmPst.selector = DU_SELECTOR_LC;
679 rgMngmt.hdr.msgType = TCFG;
680 rgMngmt.hdr.msgLen = 0;
681 rgMngmt.hdr.entId.ent = ENTRG;
682 rgMngmt.hdr.entId.inst = (Inst)0;
683 rgMngmt.hdr.elmId.elmnt = STGEN;
684 rgMngmt.hdr.seqNmb = 0;
685 rgMngmt.hdr.version = 0;
686 rgMngmt.hdr.transId = 0;
688 rgMngmt.hdr.response.prior = PRIOR0;
689 rgMngmt.hdr.response.route = RTESPEC;
690 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
691 rgMngmt.hdr.response.mem.pool = RG_POOL;
692 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
695 pst.selector = DU_SELECTOR_LC;
696 pst.srcEnt = ENTDUAPP;
698 pst.dstInst = macCfgInst;
699 pst.dstProcId = DU_PROC;
700 pst.srcProcId = DU_PROC;
701 pst.region = duCb.init.region;
703 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
705 /* Send the request to MAC */
706 cmPkLrgCfgReq(&pst, &rgMngmt);
711 /**************************************************************************
712 * @brief Function to fill USAP config required by MAC
716 * Function : duBuildMacUsapCfg
719 * Initiates USAP Configs towards MAC
721 * @param[in] SpId Specifies if RLC UL or RLC DL instance
722 * @return ROK - success
725 ***************************************************************************/
726 S16 duBuildMacUsapCfg(SpId sapId)
729 RgUpSapCfg *uSap = NULLP;
732 DU_SET_ZERO(&pst, sizeof(Pst));
733 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
735 uSap = &(rgMngmt.t.cfg.s.rguSap);
737 uSap->mem.region = RG_MEM_REGION;
738 uSap->mem.pool = RG_POOL;
741 uSap->procId = DU_PROC;
744 uSap->prior = PRIOR0;
745 uSap->route = RTESPEC;
746 uSap->selector = DU_SELECTOR_LC ;
749 rgMngmt.hdr.msgType = TCFG;
750 rgMngmt.hdr.entId.ent = ENTRG;
751 rgMngmt.hdr.entId.inst = (Inst)0;
752 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
753 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
754 rgMngmt.hdr.response.mem.pool = RG_POOL;
757 pst.selector = DU_SELECTOR_LC;
758 pst.srcEnt = ENTDUAPP;
760 pst.dstInst = macCfgInst;
761 pst.dstProcId = DU_PROC;
762 pst.srcProcId = DU_PROC;
763 pst.region = duCb.init.region;
765 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
767 /* Send the request to MAC */
768 cmPkLrgCfgReq(&pst, &rgMngmt);
773 /**************************************************************************
774 * @brief Function to handle Config Confirm from MAC
778 * Function : duHdlMacCfgComplete
781 * Handles Gen Config Confirm from MAC
783 * @param[in] Pst *pst, Post structure of the primitive.
784 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
785 * @return ROK - success
788 ***************************************************************************/
789 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
793 if (cfm->cfm.status == LCM_PRIM_OK)
795 switch (cfm->hdr.elmId.elmnt)
799 macCfg |= MAC_GEN_CFG;
804 macCfg |= MAC_SAP_CFG;
811 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
812 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
815 DU_LOG("\nDU_APP : Completed sending Configs");
817 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
823 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
829 /**************************************************************************
830 * @brief Function to bind/unbind RLC to MAC SAP
834 * Function : duBindUnbindRlcToMacSap
837 * Initiates Bind/Unbind from RLC to MAC
839 * @param[in] Inst Specifies if RLC UL or RLC DL instance
840 * @param[in] action Specifies if action is bind or unbind
841 * @return ROK - success
844 ***************************************************************************/
845 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
847 KwCntrl *cntrl = NULLP;
851 TRC2(smBindKwToRguSap)
853 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
854 DU_SET_ZERO(&pst, sizeof(Pst));
858 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
862 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
864 cntrl = &(kwMngmt.t.cntrl);
866 cntrl->action = action;
867 cntrl->subAction = DU_ZERO_VAL;
868 cntrl->s.sapCntrl.suId = macCfgInst;
869 cntrl->s.sapCntrl.spId = inst;
872 kwMngmt.hdr.msgType = TCNTRL;
873 kwMngmt.hdr.entId.ent = ENTKW;
874 kwMngmt.hdr.entId.inst = inst;
875 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
876 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
877 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
878 kwMngmt.hdr.response.mem.pool = RLC_POOL;
881 pst.selector = DU_SELECTOR_LC;
882 pst.srcEnt = ENTDUAPP;
884 pst.dstProcId = DU_PROC;
886 pst.srcProcId = DU_PROC;
887 pst.region = duCb.init.region;
889 cmPkLkwCntrlReq(&pst, &kwMngmt);
893 /*******************************************************************
895 * @brief Handles SCTP notifications
899 * Function : duSctpNtfyHdl
902 * Handles SCTP notification
904 * @params[in] Message Buffer
907 * @return ROK - success
910 * ****************************************************************/
912 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
914 switch(ntfy->header.nType)
916 case CM_INET_SCTP_ASSOC_CHANGE:
917 switch(ntfy->u.assocChange.state)
919 case CM_INET_SCTP_COMM_UP:
921 DU_LOG("\nDU_APP : SCTP communication UP");
923 if(ntfy->u.assocChange.assocId == f1Params.assocId & (!duCb.f1Status))
925 /* Build and send F1 Setup response */
926 if(BuildAndSendF1SetupReq() != ROK)
932 if(ntfy->u.assocChange.assocId == ricParams.assocId & (!duCb.e2Status))
934 /* Build and send F1 Setup response */
935 if(BuildAndSendE2SetupReq() != ROK)
949 /*******************************************************************
951 * @brief Fills Pst struct for ENTEGTP
955 * Function : duFillEgtpPst
958 * Fills Pst struct for ENTEGTP
961 * @return ROK - success
964 * ****************************************************************/
965 S16 duFillEgtpPst(Pst *pst, Event event)
967 cmMemset((U8 *)pst, 0, sizeof(Pst));
968 pst->srcEnt = (Ent)ENTDUAPP;
969 pst->srcInst = (Inst)DU_INST;
970 pst->srcProcId = DU_PROC;
971 pst->dstEnt = (Ent)ENTEGTP;
972 pst->dstInst = (Inst)EGTP_INST;
973 pst->dstProcId = pst->srcProcId;
975 pst->selector = DU_SELECTOR_LC;
982 /*******************************************************************
984 * @brief Function to configure EGTP
988 * Function : duBuildEgtpCfgReq
991 * Function to configure EGTP
994 * @return ROK - success
997 * ****************************************************************/
999 S16 duBuildEgtpCfgReq()
1004 DU_LOG("\nDU_APP : Sending EGTP config request");
1006 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1007 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1009 duFillEgtpPst(&pst, EVTCFGREQ);
1010 cmPkEgtpCfgReq(&pst, egtpCfg);
1015 /*******************************************************************
1017 * @brief Function to configure EGTP
1021 * Function : duBuildEgtpCfgReq
1024 * Function to configure EGTP
1027 * @return ROK - success
1030 * ****************************************************************/
1031 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1035 if(cfm.status == LCM_PRIM_OK)
1037 DU_LOG("\nDU_APP : EGTP configuraton complete");
1039 duSendEgtpSrvOpenReq();
1044 DU_LOG("\nDU_APP : EGTP configuraton failed");
1051 /*******************************************************************
1053 * @brief Sends server open request to EGTP
1057 * Function : duSendEgtpSrvOpenReq
1060 * Sends server open request to EGTP
1063 * @return ROK - success
1066 * ****************************************************************/
1068 S16 duSendEgtpSrvOpenReq()
1072 DU_LOG("\nDU_APP : Sending EGTP server open request");
1074 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1075 cmPkEgtpSrvOpenReq(&pst);
1080 /*******************************************************************
1082 * @brief Handles server open confirmation
1086 * Function : duHdlEgtpSrvOpenComplete
1089 * Handles server open confirmation
1092 * @return ROK - success
1095 *****************************************************************/
1097 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1101 if(cfm.status == LCM_PRIM_OK)
1103 DU_LOG("\nDU_APP : EGTP server opened successfully");
1105 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1110 DU_LOG("\nDU_APP : EGTP server opening failed");
1117 /*******************************************************************
1119 * @brief Sends tunnel management request
1123 * Function : duSendEgtpTnlMgmtReq
1126 * Builds and sends tunnel management request to EGTP
1128 * @params[in] Action
1129 * Local tunnel endpoint id
1130 * Remote tunnel endpoint id
1131 * @return ROK - success
1134 * ****************************************************************/
1136 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1141 tnlEvt.action = action;
1142 tnlEvt.lclTeid = lclTeid;
1143 tnlEvt.remTeid = remTeid;
1145 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1147 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1148 cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1153 /*******************************************************************
1155 * @brief Handles Tunnel management confirm
1159 * Function : duHdlEgtpTnlMgmtCfm
1162 * Handles tunnel management confirm received from Egtp
1164 * @params[in] Tunnel Event
1165 * @return ROK - success
1168 * ****************************************************************/
1169 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1173 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1175 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1180 /* For testing purpose. TTI thread should actually be in L1 */
1186 DU_LOG("\nDU_APP : Tunnel management failed");
1194 /*******************************************************************
1196 * @brief Simulate RLC to EGTP data indication
1200 * Function : duSendEgtpDatInd
1203 * Simulate RLC to EGTP data indication
1206 * @return ROK - success
1209 * ****************************************************************/
1210 S16 duSendEgtpDatInd()
1212 char data[30] = "This is EGTP data from DU";
1218 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1220 if(SAddPstMsgMult((Data *)data, datSize, mBuf) == ROK)
1222 SPrntMsg(mBuf, 0,0);
1226 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1233 DU_LOG("\nDU_APP : Failed to allocate memory");
1237 /* filling IPv4 header */
1242 SFndLenMsg(mBuf, &mLen);
1244 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1245 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1246 ipv4Hdr.hdrVer = 0x45;
1248 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1249 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1251 /* Packing IPv4 header into buffer */
1253 Data revPkArray[CM_IPV4_HDRLEN];
1254 Data pkArray[CM_IPV4_HDRLEN];
1256 /* initialize locals */
1258 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1259 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1261 /* Pack Header Version */
1262 pkArray[cnt++] = ipv4Hdr.hdrVer;
1265 pkArray[cnt++] = ipv4Hdr.tos;
1267 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1268 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1271 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1272 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1275 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1276 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1279 pkArray[cnt++] = ipv4Hdr.ttl;
1282 pkArray[cnt++] = ipv4Hdr.proto;
1285 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1286 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1288 /* Pack Source Address */
1289 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1290 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1291 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1292 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1294 /* Pack Destination Address */
1295 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1296 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1297 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1298 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1300 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1301 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1303 /* this function automatically reverses revPkArray */
1304 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1307 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1308 egtpMsg.msgHdr.nPdu.pres = FALSE;
1309 egtpMsg.msgHdr.seqNum.pres = FALSE;
1310 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1311 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1312 egtpMsg.msgHdr.teId = 1;
1315 SPrntMsg(mBuf, 0, 0);
1317 egtpHdlDatInd(egtpMsg);
1321 #endif /* EGTP_TEST */
1324 /**************************************************************************
1325 * @brief Function to send configs to SCH
1329 * Function : duSendSchCfg
1332 * Sends general config to Scheduler via MAC layer
1335 * @return ROK - success
1338 ***************************************************************************/
1342 RgSchInstCfg *cfg = NULLP;
1345 DU_SET_ZERO(&pst, sizeof(Pst));
1346 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1348 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1350 /* Filling of Instance Id */
1351 cfg->instId = DEFAULT_CELLS + 1;
1352 /* Filling of Gen config */
1353 cfg->genCfg.mem.region = RG_MEM_REGION;
1354 cfg->genCfg.mem.pool = RG_POOL;
1355 cfg->genCfg.tmrRes = 10;
1358 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1359 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1361 cfg->genCfg.startCellId = 1;
1362 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1363 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1364 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1365 cfg->genCfg.lmPst.dstInst = DU_INST;
1366 cfg->genCfg.lmPst.srcEnt = ENTRG;
1367 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1368 cfg->genCfg.lmPst.prior = PRIOR0;
1369 cfg->genCfg.lmPst.route = RTESPEC;
1370 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1371 cfg->genCfg.lmPst.pool = RG_POOL;
1372 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1375 rgMngmt.hdr.msgType = TCFG;
1376 rgMngmt.hdr.entId.ent = ENTRG;
1377 rgMngmt.hdr.entId.inst = DU_INST;
1378 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1379 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1380 rgMngmt.hdr.response.mem.pool = RG_POOL;
1383 pst.selector = DU_SELECTOR_LC;
1384 pst.srcEnt = ENTDUAPP;
1386 pst.dstProcId = DU_PROC;
1387 pst.srcProcId = DU_PROC;
1388 pst.srcInst = DU_INST;
1390 pst.region = duCb.init.region;
1391 pst.event = (Event) EVTMACSCHGENCFGREQ;
1393 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1395 /* Send the request to MAC */
1396 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1401 /*******************************************************************
1403 * @brief Checks the status of the received information
1407 * Function : duCheckReqStatus
1410 * Checks the status of the received information
1412 * @params[in] Confirm status
1413 * @return ROK - success
1416 ******************************************************************/
1417 S16 duCheckReqStatus(CmStatus *cfm)
1420 if(cfm->status != LCM_PRIM_OK)
1422 DU_LOG("\nDU_APP : Failed to process the request successfully");
1428 /**************************************************************************
1429 * @brief Function to configure SCTP params and
1430 * responsible for F1 and E2 interfaces
1434 * Function : duLayerConfigComplete
1437 * Configures SCTP Params and responsible for handling
1438 * F1 and E2 interface.
1441 * @return ROK - success
1444 ***************************************************************************/
1445 S16 duLayerConfigComplete()
1450 DU_LOG("\nDU_APP : Configuring all Layer is complete");
1452 duSctpCfgReq(duCfgParam.sctpParams, &cfm);
1453 if((ret = duCheckReqStatus(&cfm)) != ROK)
1455 DU_LOG("\nDU_APP : Failed configuring Sctp Params");
1458 duSctpAssocReq(duCfgParam.sctpParams.itfType.f1Itf, &cfm);
1459 if((ret = duCheckReqStatus(&cfm)) != ROK)
1461 DU_LOG("\nDU_APP : Failed to send AssocReq F1");
1464 duSctpAssocReq(duCfgParam.sctpParams.itfType.e2Itf, &cfm);
1465 if((ret = duCheckReqStatus(&cfm)) != ROK)
1467 DU_LOG("\nDU_APP : Failed to send AssocReq E2");
1474 /**************************************************************************
1475 * @brief Function to handle SCH Config Confirm from MAC
1479 * Function : duHdlSchCfgComplete
1482 * Handles Scheduler Gen Config Confirm from MAC
1484 * @param[in] Pst *pst, Post structure of the primitive.
1485 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1486 * @return ROK - success
1489 ***************************************************************************/
1490 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1492 if (cfm->cfm.status == LCM_PRIM_OK)
1494 switch (cfm->hdr.elmId.elmnt)
1498 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1505 duLayerConfigComplete();
1506 duBuildEgtpCfgReq();
1510 /*******************************************************************
1512 * @brief Handles TTI indication
1516 * Function : duSendEgtpTTIInd
1519 * Handles TTI indication received from PHY
1522 * @return ROK - success
1525 * ****************************************************************/
1526 S16 duSendEgtpTTIInd()
1530 duFillEgtpPst(&pst, EVTTTIIND);
1531 cmPkEgtpTTIInd(&pst);
1537 /**************************************************************************
1538 * @brief Function to fill and send MacCellconfig
1542 * Function : duBuildAndSendMacCellCfg
1545 * Initiates MAC Configs towards MAC
1548 * @return ROK - success
1551 ***************************************************************************/
1552 S16 duBuildAndSendMacCellCfg()
1555 DU_SET_ZERO(&pst, sizeof(Pst));
1556 MacCellCfg *duMacCellCfg = NULLP;
1558 DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
1559 if(duMacCellCfg == NULLP)
1564 /* store the address in the duCb so that we can free on confirm msg */
1565 duCb.duMacCellCfg = duMacCellCfg;
1567 /* copy the mac config structure from duCfgParams */
1568 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1570 duMacCellCfg->transId = getTransId(); /* transaction ID */
1573 pst.selector = DU_SELECTOR_LWLC;
1574 pst.srcEnt = ENTDUAPP;
1578 pst.dstProcId = DU_PROC;
1579 pst.srcProcId = DU_PROC;
1580 pst.region = duCb.init.region;
1581 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1583 /* Send MAC cell config to MAC */
1584 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1587 /**************************************************************************
1588 * @brief Function to Handle MAC cell config confirm
1592 * Function : duHandleMacCellCfgCfm
1595 * Initiates general Configs towards MAC
1598 * @return ROK - success
1601 ***************************************************************************/
1602 S16 duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1606 if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
1608 /* free the memory allocated during sending macCellCfg request */
1609 DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
1610 duCb.duMacCellCfg = NULLP;
1612 /* Build and send GNB-DU config update */
1613 ret = BuildAndSendDUConfigUpdate();
1617 /* transaction ID missmatch */
1618 DU_LOG("\n transaction ID mismatch in macCellCfg");
1625 /**********************************************************************
1627 **********************************************************************/