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 /**************************************************************************
41 * @brief Function to fill configs required by RLC
45 * Function : duBuildRlcCfg
48 * Initiates general Configs towards RLC
50 * @param[in] Inst Specifies if RLC UL or RLC DL instance
51 * @return ROK - success
54 ***************************************************************************/
55 S16 duBuildRlcCfg(Inst inst)
58 KwGenCfg *genCfg = NULLP;
61 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
62 DU_SET_ZERO(&pst, sizeof(Pst));
64 genCfg = &(kwMngmt.t.cfg.s.gen);
66 /*----------- Fill General Configuration Parameters ---------*/
67 genCfg->maxUe = duCfgParam.maxUe;
68 genCfg->maxKwuSaps = 2;
69 genCfg->maxUdxSaps = 1;
70 genCfg->rlcMode = (inst == RLC_UL_INST) ?
71 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
73 genCfg->maxRguSaps = DEFAULT_CELLS;
75 /*----------- Fill lmPst
76 * Parameters ---------*/
77 genCfg->lmPst.dstProcId = DU_PROC;
78 genCfg->lmPst.srcProcId = DU_PROC;
79 genCfg->lmPst.dstEnt = ENTDUAPP;
80 genCfg->lmPst.dstInst = DU_INST;
81 genCfg->lmPst.srcEnt = ENTKW;
82 genCfg->lmPst.srcInst = inst;
83 genCfg->lmPst.prior = PRIOR0;
84 genCfg->lmPst.route = RTESPEC;
85 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
86 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
87 genCfg->lmPst.pool = RLC_POOL;
88 genCfg->lmPst.selector = DU_SELECTOR_LC;
91 kwMngmt.hdr.msgType = TCFG;
92 kwMngmt.hdr.msgLen = 0;
93 kwMngmt.hdr.entId.ent = ENTKW;
94 kwMngmt.hdr.entId.inst = (Inst)0;
95 kwMngmt.hdr.elmId.elmnt = STGEN;
96 kwMngmt.hdr.seqNmb = 0;
97 kwMngmt.hdr.version = 0;
98 kwMngmt.hdr.transId = 0;
99 kwMngmt.hdr.response.prior = PRIOR0;
100 kwMngmt.hdr.response.route = RTESPEC;
101 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
102 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
103 kwMngmt.hdr.response.mem.pool = DU_POOL;
104 kwMngmt.hdr.response.selector = DU_SELECTOR_LC;
107 pst.selector = DU_SELECTOR_LC;
108 pst.srcEnt = ENTDUAPP;
111 pst.dstProcId = DU_PROC;
112 pst.srcProcId = DU_PROC;
113 pst.region = duCb.init.region;
115 DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
117 /* Send the request to RLC */
118 cmPkLkwCfgReq(&pst, &kwMngmt);
123 /**************************************************************************
124 * @brief Function to fill configs required by RLC
128 * Function : duBuildRlcLsapCfg
131 * Initiates general Configs towards RLC
133 * @param[in] Inst Specifies if RLC UL or RLC DL instance
134 * @return ROK - success
137 ***************************************************************************/
138 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
142 KwSapCfg *lSap = NULLP;
145 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
146 DU_SET_ZERO(&pst, sizeof(Pst));
149 kwMngmt.hdr.msgType = TCFG;
150 kwMngmt.hdr.entId.ent = ENTKW;
151 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
152 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
154 kwMngmt.hdr.response.mem.pool = RLC_POOL;
157 pst.selector = DU_SELECTOR_LC;
158 pst.srcEnt = ENTDUAPP;
160 pst.dstProcId = DU_PROC;
162 pst.srcProcId = DU_PROC;
163 pst.region = duCb.init.region;
164 lSap = &(kwMngmt.t.cfg.s.sap);
166 lSap->mem.region = (inst == RLC_UL_INST) ?
167 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
168 lSap->mem.pool = RLC_POOL;
170 lSap->bndTmrIntvl = 10;
171 lSap->priority = PRIOR0;
172 lSap->route = RTESPEC;
175 lSap->procId = DU_PROC;
177 lSap->inst = lsapInst;
178 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
179 lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
180 kwMngmt.hdr.elmId.elmnt = STRGUSAP;
181 DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
186 lSap->procId = DU_PROC;
188 lSap->inst = (inst == RLC_UL_INST) ?
189 RLC_DL_INST : RLC_UL_INST;
191 lSap->selector = DU_SELECTOR_LC;
192 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
193 DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
196 cmPkLkwCfgReq(&pst, &kwMngmt);
200 /**************************************************************************
201 * @brief Function to fill configs required by RLC
205 * Function : duBuildRlcUsapCfg
208 * Initiates general Configs towards RLC
210 * @param[in] Inst Specifies if RLC UL or RLC DL instance
211 * @return ROK - success
214 ***************************************************************************/
215 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
218 KwSapCfg *uSap = NULLP;
221 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
222 DU_SET_ZERO(&pst, sizeof(Pst));
224 uSap = &(kwMngmt.t.cfg.s.sap);
226 uSap->selector = DU_SELECTOR_LC;
227 uSap->mem.region = (inst == RLC_UL_INST) ?
228 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
229 uSap->mem.pool = RLC_POOL;
232 uSap->procId = DU_PROC;
236 uSap->inst = (inst == RLC_UL_INST) ?
237 RLC_DL_INST : RLC_UL_INST;
238 uSap->bndTmrIntvl = 1000;
239 uSap->priority = PRIOR0;
240 uSap->route = RTESPEC;
243 kwMngmt.hdr.msgType = TCFG;
244 kwMngmt.hdr.entId.ent = ENTKW;
245 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
246 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
247 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
249 kwMngmt.hdr.response.mem.pool = RLC_POOL;
252 pst.selector = DU_SELECTOR_LC;
253 pst.srcEnt = ENTDUAPP;
255 pst.dstProcId = DU_PROC;
257 pst.srcProcId = DU_PROC;
258 pst.region = duCb.init.region;
260 DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
261 cmPkLkwCfgReq(&pst, &kwMngmt);
266 /**************************************************************************
267 * @brief Function to populate internal DS of DU APP
271 * Function : duProcCfgComplete
274 * Populates internal data structures of DU APP after
275 * receiving configurations.
278 * @return ROK - success
281 ***************************************************************************/
282 S16 duProcCfgComplete()
285 static U16 cellId = 0;
287 for(idx=0; idx< DEFAULT_CELLS; idx++) //TODO: the length of this loop must be determined
290 DU_ALLOC(cell, sizeof(DuCellCb))
293 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
300 cell->cellId = cellId++;
301 memcpy((void*)&cell->cellInfo, (void*)&duCfgParam.cellCfg[idx],\
302 sizeof(CellCfgParams));
303 cell->cellStatus = OOS;
304 nci = cell->cellInfo.nrEcgi.cellId;
305 ret = cmHashListInsert(&(duCb.cellLst), (PTR)(cell),
306 (U8 *)&(nci), (U16) sizeof(nci));
310 DU_LOG("\nDU_APP : HashListInsert into cellLst failed for [%d]", nci);
315 DU_LOG("\nDU_APP : HashListInsert into cellLst successful for [%d]", nci);
321 //Start layer configs
322 ret = duSendRlcUlCfg();
326 /**************************************************************************
327 * @brief Function to invoke DU Layer Configs
331 * Function : duSendRlcUlCfg
334 * Initiates Configs towards layers of DU
337 * @return ROK - success
340 ***************************************************************************/
345 duBuildRlcCfg((Inst)RLC_UL_INST);
346 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
348 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
350 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
355 /**************************************************************************
356 * @brief Function to invoke DU Layer Configs
360 * Function : duSendRlcDlCfg
363 * Initiates Configs towards layers of DU
366 * @return ROK - success
369 ***************************************************************************/
374 duBuildRlcCfg((Inst)RLC_DL_INST);
375 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
376 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
378 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
383 /**************************************************************************
384 * @brief Function to handle Config Confirm from RLC
388 * Function : duHdlRlcCfgComplete
391 * Handles Gen Config Confirm from RLC
393 * @param[in] Pst *pst, Post structure of the primitive.
394 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
395 * @return ROK - success
398 ***************************************************************************/
399 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
402 if (pst->srcInst == RLC_UL_INST)
404 ret = duProcRlcUlCfgComplete(pst, cfm);
408 ret = duProcRlcDlCfgComplete(pst, cfm);
413 /**************************************************************************
414 * @brief Function to handle Control Config Confirm from RLC
418 * Function : duHdlRlcCntrlCfgComplete
421 * Handles Control Config Confirm from RLC
423 * @param[in] Pst *pst, Post structure of the primitive.
424 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
425 * @return ROK - success
428 ***************************************************************************/
429 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
433 if (cntrl->cfm.status == LCM_PRIM_OK)
435 switch (cntrl->hdr.elmId.elmnt)
439 if (pst->srcInst == RLC_DL_INST)
441 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
443 if(macCfgInst < DEFAULT_CELLS)
446 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
450 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
455 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
457 if(macCfgInst < DEFAULT_CELLS)
459 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
473 /**************************************************************************
474 * @brief Function to handle Config Confirm from RLC UL
478 * Function : duHdlRlcUlCfgComplete
481 * Handles Config Confirm from RLC UL
483 * @param[in] Pst *pst, Post structure of the primitive.
484 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
485 * @return ROK - success
488 ***************************************************************************/
489 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
493 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
494 if (cfm->cfm.status == LCM_PRIM_OK)
496 switch(cfm->hdr.elmId.elmnt)
500 rlcUlCfg |= RLC_GEN_CFG;
506 if(numRlcMacSaps == DEFAULT_CELLS)
508 rlcUlCfg |= RLC_MAC_SAP_CFG;
515 rlcUlCfg |= RLC_UDX_SAP_CFG;
522 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
523 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
527 //Start configuration of RLC DL
534 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
540 /**************************************************************************
541 * @brief Function to handle Config Confirm from RLC DL
545 * Function : duHdlRlcDlCfgComplete
548 * Handles Config Confirm from RLC DL
550 * @param[in] Pst *pst, Post structure of the primitive.
551 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
552 * @return ROK - success
555 ***************************************************************************/
556 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
558 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
559 if (cfm->cfm.status == LCM_PRIM_OK)
561 switch(cfm->hdr.elmId.elmnt)
565 rlcDlCfg |= RLC_GEN_CFG;
571 if(numRlcMacSaps == DEFAULT_CELLS)
573 rlcDlCfg |= RLC_MAC_SAP_CFG;
580 rlcDlCfg |= RLC_UDX_SAP_CFG;
588 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
589 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
592 //Start configuration of MAC
599 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
604 /**************************************************************************
605 * @brief Function to send configs to MAC
609 * Function : duSendMacCfg
612 * Initiates Configs towards MAC layer
615 * @return ROK - success
618 ***************************************************************************/
622 duBuildMacUsapCfg(RLC_UL_INST);
623 duBuildMacUsapCfg(RLC_DL_INST);
628 /**************************************************************************
629 * @brief Function to fill gen config required by MAC
633 * Function : duBuildMacGenCfg
636 * Initiates general Configs towards MAC
639 * @return ROK - success
642 ***************************************************************************/
643 S16 duBuildMacGenCfg()
646 RgGenCfg *genCfg=NULLP;
649 DU_SET_ZERO(&pst, sizeof(Pst));
650 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
652 genCfg = &(rgMngmt.t.cfg.s.genCfg);
654 /*----------- Fill General Configuration Parameters ---------*/
655 genCfg->mem.region = RG_MEM_REGION;
656 genCfg->mem.pool = RG_POOL;
658 genCfg->numRguSaps = 2;
660 genCfg->lmPst.dstProcId = DU_PROC;
661 genCfg->lmPst.srcProcId = DU_PROC;
662 genCfg->lmPst.dstEnt = ENTDUAPP;
663 genCfg->lmPst.dstInst = 0;
664 genCfg->lmPst.srcEnt = ENTRG;
665 genCfg->lmPst.srcInst = macCfgInst;
666 genCfg->lmPst.prior = PRIOR0;
667 genCfg->lmPst.route = RTESPEC;
668 genCfg->lmPst.region = RG_MEM_REGION;
669 genCfg->lmPst.pool = RG_POOL;
670 genCfg->lmPst.selector = DU_SELECTOR_LC;
673 rgMngmt.hdr.msgType = TCFG;
674 rgMngmt.hdr.msgLen = 0;
675 rgMngmt.hdr.entId.ent = ENTRG;
676 rgMngmt.hdr.entId.inst = (Inst)0;
677 rgMngmt.hdr.elmId.elmnt = STGEN;
678 rgMngmt.hdr.seqNmb = 0;
679 rgMngmt.hdr.version = 0;
680 rgMngmt.hdr.transId = 0;
682 rgMngmt.hdr.response.prior = PRIOR0;
683 rgMngmt.hdr.response.route = RTESPEC;
684 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
685 rgMngmt.hdr.response.mem.pool = RG_POOL;
686 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
689 pst.selector = DU_SELECTOR_LC;
690 pst.srcEnt = ENTDUAPP;
692 pst.dstInst = macCfgInst;
693 pst.dstProcId = DU_PROC;
694 pst.srcProcId = DU_PROC;
695 pst.region = duCb.init.region;
697 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
699 /* Send the request to MAC */
700 cmPkLrgCfgReq(&pst, &rgMngmt);
705 /**************************************************************************
706 * @brief Function to fill USAP config required by MAC
710 * Function : duBuildMacUsapCfg
713 * Initiates USAP Configs towards MAC
715 * @param[in] SpId Specifies if RLC UL or RLC DL instance
716 * @return ROK - success
719 ***************************************************************************/
720 S16 duBuildMacUsapCfg(SpId sapId)
723 RgUpSapCfg *uSap = NULLP;
726 DU_SET_ZERO(&pst, sizeof(Pst));
727 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
729 uSap = &(rgMngmt.t.cfg.s.rguSap);
731 uSap->mem.region = RG_MEM_REGION;
732 uSap->mem.pool = RG_POOL;
735 uSap->procId = DU_PROC;
738 uSap->prior = PRIOR0;
739 uSap->route = RTESPEC;
740 uSap->selector = DU_SELECTOR_LC ;
743 rgMngmt.hdr.msgType = TCFG;
744 rgMngmt.hdr.entId.ent = ENTRG;
745 rgMngmt.hdr.entId.inst = (Inst)0;
746 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
747 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
748 rgMngmt.hdr.response.mem.pool = RG_POOL;
751 pst.selector = DU_SELECTOR_LC;
752 pst.srcEnt = ENTDUAPP;
754 pst.dstInst = macCfgInst;
755 pst.dstProcId = DU_PROC;
756 pst.srcProcId = DU_PROC;
757 pst.region = duCb.init.region;
759 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
761 /* Send the request to MAC */
762 cmPkLrgCfgReq(&pst, &rgMngmt);
767 /**************************************************************************
768 * @brief Function to handle Config Confirm from MAC
772 * Function : duHdlMacCfgComplete
775 * Handles Gen Config Confirm from MAC
777 * @param[in] Pst *pst, Post structure of the primitive.
778 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
779 * @return ROK - success
782 ***************************************************************************/
783 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
787 if (cfm->cfm.status == LCM_PRIM_OK)
789 switch (cfm->hdr.elmId.elmnt)
793 macCfg |= MAC_GEN_CFG;
798 macCfg |= MAC_SAP_CFG;
805 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
806 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
809 DU_LOG("\nDU_APP : Completed sending Configs");
811 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
817 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
823 /**************************************************************************
824 * @brief Function to bind/unbind RLC to MAC SAP
828 * Function : duBindUnbindRlcToMacSap
831 * Initiates Bind/Unbind from RLC to MAC
833 * @param[in] Inst Specifies if RLC UL or RLC DL instance
834 * @param[in] action Specifies if action is bind or unbind
835 * @return ROK - success
838 ***************************************************************************/
839 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
841 KwCntrl *cntrl = NULLP;
845 TRC2(smBindKwToRguSap)
847 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
848 DU_SET_ZERO(&pst, sizeof(Pst));
852 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
856 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
858 cntrl = &(kwMngmt.t.cntrl);
860 cntrl->action = action;
861 cntrl->subAction = DU_ZERO_VAL;
862 cntrl->s.sapCntrl.suId = macCfgInst;
863 cntrl->s.sapCntrl.spId = inst;
866 kwMngmt.hdr.msgType = TCNTRL;
867 kwMngmt.hdr.entId.ent = ENTKW;
868 kwMngmt.hdr.entId.inst = inst;
869 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
870 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
871 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
872 kwMngmt.hdr.response.mem.pool = RLC_POOL;
875 pst.selector = DU_SELECTOR_LC;
876 pst.srcEnt = ENTDUAPP;
878 pst.dstProcId = DU_PROC;
880 pst.srcProcId = DU_PROC;
881 pst.region = duCb.init.region;
883 cmPkLkwCntrlReq(&pst, &kwMngmt);
887 /*******************************************************************
889 * @brief Function to start SCTP
893 * Function : duSctpStartReq
896 * Function to start SCTP
899 * @return ROK - success
902 * ****************************************************************/
907 cmMemset((U8 *)&(pst), 0, sizeof(Pst));
908 pst.srcEnt = (Ent)ENTDUAPP;
909 pst.srcInst = (Inst)DU_INST;
910 pst.srcProcId = DU_PROC;
911 pst.dstEnt = (Ent)ENTSCTP;
912 pst.dstInst = (Inst)SCTP_INST;
913 pst.dstProcId = pst.srcProcId;
914 pst.event = EVTSCTPSTRT;
915 pst.selector = DU_SELECTOR_LC;
918 cmPkSctpAssocReq(&pst, duCfgParam.sctpParams);
923 /*******************************************************************
925 * @brief Handles SCTP notifications
929 * Function : duSctpNtfyHdl
932 * Handles SCTP notification
934 * @params[in] Message Buffer
937 * @return ROK - success
940 * ****************************************************************/
942 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
944 switch(ntfy->header.nType)
946 case CM_INET_SCTP_ASSOC_CHANGE:
947 switch(ntfy->u.assocChange.state)
949 case CM_INET_SCTP_COMM_UP:
951 DU_LOG("\nDU_APP : SCTP communication UP");
955 /* Build and send F1 Setup response */
956 if(BuildAndSendF1SetupReq() != ROK)
963 //Only SCTP is down, when SCTP comes up again, no need to
964 //start from setting up F1 link
974 /*******************************************************************
976 * @brief Fills Pst struct for ENTEGTP
980 * Function : duFillEgtpPst
983 * Fills Pst struct for ENTEGTP
986 * @return ROK - success
989 * ****************************************************************/
990 S16 duFillEgtpPst(Pst *pst, Event event)
992 cmMemset((U8 *)pst, 0, sizeof(Pst));
993 pst->srcEnt = (Ent)ENTDUAPP;
994 pst->srcInst = (Inst)DU_INST;
995 pst->srcProcId = DU_PROC;
996 pst->dstEnt = (Ent)ENTEGTP;
997 pst->dstInst = (Inst)EGTP_INST;
998 pst->dstProcId = pst->srcProcId;
1000 pst->selector = DU_SELECTOR_LC;
1007 /*******************************************************************
1009 * @brief Function to configure EGTP
1013 * Function : duBuildEgtpCfgReq
1016 * Function to configure EGTP
1019 * @return ROK - success
1022 * ****************************************************************/
1024 S16 duBuildEgtpCfgReq()
1029 DU_LOG("\nDU_APP : Sending EGTP config request");
1031 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1032 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1034 duFillEgtpPst(&pst, EVTCFGREQ);
1035 cmPkEgtpCfgReq(&pst, egtpCfg);
1040 /*******************************************************************
1042 * @brief Function to configure EGTP
1046 * Function : duBuildEgtpCfgReq
1049 * Function to configure EGTP
1052 * @return ROK - success
1055 * ****************************************************************/
1056 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1060 if(cfm.status == LCM_PRIM_OK)
1062 DU_LOG("\nDU_APP : EGTP configuraton complete");
1064 duSendEgtpSrvOpenReq();
1069 DU_LOG("\nDU_APP : EGTP configuraton failed");
1076 /*******************************************************************
1078 * @brief Sends server open request to EGTP
1082 * Function : duSendEgtpSrvOpenReq
1085 * Sends server open request to EGTP
1088 * @return ROK - success
1091 * ****************************************************************/
1093 S16 duSendEgtpSrvOpenReq()
1097 DU_LOG("\nDU_APP : Sending EGTP server open request");
1099 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1100 cmPkEgtpSrvOpenReq(&pst);
1105 /*******************************************************************
1107 * @brief Handles server open confirmation
1111 * Function : duHdlEgtpSrvOpenComplete
1114 * Handles server open confirmation
1117 * @return ROK - success
1120 *****************************************************************/
1122 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1126 if(cfm.status == LCM_PRIM_OK)
1128 DU_LOG("\nDU_APP : EGTP server opened successfully");
1130 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1135 DU_LOG("\nDU_APP : EGTP server opening failed");
1142 /*******************************************************************
1144 * @brief Sends tunnel management request
1148 * Function : duSendEgtpTnlMgmtReq
1151 * Builds and sends tunnel management request to EGTP
1153 * @params[in] Action
1154 * Local tunnel endpoint id
1155 * Remote tunnel endpoint id
1156 * @return ROK - success
1159 * ****************************************************************/
1161 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1166 tnlEvt.action = action;
1167 tnlEvt.lclTeid = lclTeid;
1168 tnlEvt.remTeid = remTeid;
1170 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1172 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1173 cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1178 /*******************************************************************
1180 * @brief Handles Tunnel management confirm
1184 * Function : duHdlEgtpTnlMgmtCfm
1187 * Handles tunnel management confirm received from Egtp
1189 * @params[in] Tunnel Event
1190 * @return ROK - success
1193 * ****************************************************************/
1194 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1198 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1200 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1205 /* For testing purpose. TTI thread should actually be in L1 */
1211 DU_LOG("\nDU_APP : Tunnel management failed");
1219 /*******************************************************************
1221 * @brief Simulate RLC to EGTP data indication
1225 * Function : duSendEgtpDatInd
1228 * Simulate RLC to EGTP data indication
1231 * @return ROK - success
1234 * ****************************************************************/
1235 S16 duSendEgtpDatInd()
1237 char data[30] = "This is EGTP data from DU";
1243 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1245 if(SAddPstMsgMult((Data *)data, datSize, mBuf) == ROK)
1247 SPrntMsg(mBuf, 0,0);
1251 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1258 DU_LOG("\nDU_APP : Failed to allocate memory");
1262 /* filling IPv4 header */
1267 SFndLenMsg(mBuf, &mLen);
1269 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1270 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1271 ipv4Hdr.hdrVer = 0x45;
1273 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1274 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1276 /* Packing IPv4 header into buffer */
1278 Data revPkArray[CM_IPV4_HDRLEN];
1279 Data pkArray[CM_IPV4_HDRLEN];
1281 /* initialize locals */
1283 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1284 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1286 /* Pack Header Version */
1287 pkArray[cnt++] = ipv4Hdr.hdrVer;
1290 pkArray[cnt++] = ipv4Hdr.tos;
1292 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1293 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1296 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1297 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1300 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1301 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1304 pkArray[cnt++] = ipv4Hdr.ttl;
1307 pkArray[cnt++] = ipv4Hdr.proto;
1310 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1311 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1313 /* Pack Source Address */
1314 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1315 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1316 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1317 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1319 /* Pack Destination Address */
1320 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1321 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1322 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1323 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1325 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1326 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1328 /* this function automatically reverses revPkArray */
1329 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1332 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1333 egtpMsg.msgHdr.nPdu.pres = FALSE;
1334 egtpMsg.msgHdr.seqNum.pres = FALSE;
1335 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1336 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1337 egtpMsg.msgHdr.teId = 1;
1340 SPrntMsg(mBuf, 0, 0);
1342 egtpHdlDatInd(egtpMsg);
1346 #endif /* EGTP_TEST */
1349 /**************************************************************************
1350 * @brief Function to send configs to SCH
1354 * Function : duSendSchCfg
1357 * Sends general config to Scheduler via MAC layer
1360 * @return ROK - success
1363 ***************************************************************************/
1367 RgSchInstCfg *cfg = NULLP;
1370 DU_SET_ZERO(&pst, sizeof(Pst));
1371 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1373 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1375 /* Filling of Instance Id */
1376 cfg->instId = DEFAULT_CELLS + 1;
1377 /* Filling of Gen config */
1378 cfg->genCfg.mem.region = RG_MEM_REGION;
1379 cfg->genCfg.mem.pool = RG_POOL;
1380 cfg->genCfg.tmrRes = 10;
1383 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1384 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1386 cfg->genCfg.startCellId = 1;
1387 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1388 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1389 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1390 cfg->genCfg.lmPst.dstInst = DU_INST;
1391 cfg->genCfg.lmPst.srcEnt = ENTRG;
1392 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1393 cfg->genCfg.lmPst.prior = PRIOR0;
1394 cfg->genCfg.lmPst.route = RTESPEC;
1395 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1396 cfg->genCfg.lmPst.pool = RG_POOL;
1397 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1400 rgMngmt.hdr.msgType = TCFG;
1401 rgMngmt.hdr.entId.ent = ENTRG;
1402 rgMngmt.hdr.entId.inst = DU_INST;
1403 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1404 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1405 rgMngmt.hdr.response.mem.pool = RG_POOL;
1408 pst.selector = DU_SELECTOR_LC;
1409 pst.srcEnt = ENTDUAPP;
1411 pst.dstProcId = DU_PROC;
1412 pst.srcProcId = DU_PROC;
1413 pst.srcInst = DU_INST;
1415 pst.region = duCb.init.region;
1416 pst.event = (Event) EVTMACSCHGENCFGREQ;
1418 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1420 /* Send the request to MAC */
1421 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1426 /**************************************************************************
1427 * @brief Function to handle SCH Config Confirm from MAC
1431 * Function : duHdlSchCfgComplete
1434 * Handles Scheduler Gen Config Confirm from MAC
1436 * @param[in] Pst *pst, Post structure of the primitive.
1437 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1438 * @return ROK - success
1441 ***************************************************************************/
1442 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1444 if (cfm->cfm.status == LCM_PRIM_OK)
1446 switch (cfm->hdr.elmId.elmnt)
1450 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1459 duBuildEgtpCfgReq();
1463 /*******************************************************************
1465 * @brief Handles TTI indication
1469 * Function : duSendEgtpTTIInd
1472 * Handles TTI indication received from PHY
1475 * @return ROK - success
1478 * ****************************************************************/
1479 S16 duSendEgtpTTIInd()
1483 duFillEgtpPst(&pst, EVTTTIIND);
1484 cmPkEgtpTTIInd(&pst);
1489 /**********************************************************************
1491 **********************************************************************/