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 APP */
23 #include "du_f1ap_msg_hdl.h"
26 #include "lphy_stub.h"
35 extern DuCfgParams duCfgParam;
36 extern S16 cmPkLkwCfgReq(Pst *pst, KwMngmt *cfg);
37 extern S16 cmPkLkwCntrlReq(Pst *pst, KwMngmt *cfg);
38 extern S16 cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
40 packMacCellCfgReq packMacCellCfgOpts[] =
42 packMacCellCfg, /* packing for loosely coupled */
43 MacHdlCellCfgReq, /* packing for tightly coupled */
44 packMacCellCfg, /* packing for light weight loosly coupled */
47 DuMacCellStartReq packMacCellStartReqOpts[] =
49 packMacCellStartReq, /* Loose coupling */
50 MacHdlCellStartReq, /* TIght coupling */
51 packMacCellStartReq /* Light weight-loose coupling */
54 DuMacCellStopReq packMacCellStopReqOpts[] =
56 packMacCellStopReq, /* Loose coupling */
57 MacHdlCellStopReq, /* TIght coupling */
58 packMacCellStopReq /* Light weight-loose coupling */
61 /**************************************************************************
62 * @brief Function to fill configs required by RLC
66 * Function : duBuildRlcCfg
69 * Initiates general Configs towards RLC
71 * @param[in] Inst Specifies if RLC UL or RLC DL instance
72 * @return ROK - success
75 ***************************************************************************/
76 S16 duBuildRlcCfg(Inst inst)
79 KwGenCfg *genCfg = NULLP;
82 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
83 DU_SET_ZERO(&pst, sizeof(Pst));
85 genCfg = &(kwMngmt.t.cfg.s.gen);
87 /*----------- Fill General Configuration Parameters ---------*/
88 genCfg->maxUe = duCfgParam.maxUe;
89 genCfg->maxKwuSaps = 2;
90 genCfg->maxUdxSaps = 1;
91 genCfg->rlcMode = (inst == RLC_UL_INST) ?
92 LKW_RLC_MODE_UL : LKW_RLC_MODE_DL;
94 genCfg->maxRguSaps = DEFAULT_CELLS;
96 /*----------- Fill lmPst
97 * Parameters ---------*/
98 genCfg->lmPst.dstProcId = DU_PROC;
99 genCfg->lmPst.srcProcId = DU_PROC;
100 genCfg->lmPst.dstEnt = ENTDUAPP;
101 genCfg->lmPst.dstInst = DU_INST;
102 genCfg->lmPst.srcEnt = ENTKW;
103 genCfg->lmPst.srcInst = inst;
104 genCfg->lmPst.prior = PRIOR0;
105 genCfg->lmPst.route = RTESPEC;
106 genCfg->lmPst.region = (inst == RLC_UL_INST) ?
107 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
108 genCfg->lmPst.pool = RLC_POOL;
109 genCfg->lmPst.selector = DU_SELECTOR_LC;
112 kwMngmt.hdr.msgType = TCFG;
113 kwMngmt.hdr.msgLen = 0;
114 kwMngmt.hdr.entId.ent = ENTKW;
115 kwMngmt.hdr.entId.inst = (Inst)0;
116 kwMngmt.hdr.elmId.elmnt = STGEN;
117 kwMngmt.hdr.seqNmb = 0;
118 kwMngmt.hdr.version = 0;
119 kwMngmt.hdr.transId = 0;
120 kwMngmt.hdr.response.prior = PRIOR0;
121 kwMngmt.hdr.response.route = RTESPEC;
122 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
123 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
124 kwMngmt.hdr.response.mem.pool = DU_POOL;
125 kwMngmt.hdr.response.selector = DU_SELECTOR_LC;
128 pst.selector = DU_SELECTOR_LC;
129 pst.srcEnt = ENTDUAPP;
132 pst.dstProcId = DU_PROC;
133 pst.srcProcId = DU_PROC;
134 pst.region = duCb.init.region;
136 DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
138 /* Send the request to RLC */
139 cmPkLkwCfgReq(&pst, &kwMngmt);
144 /**************************************************************************
145 * @brief Function to fill configs required by RLC
149 * Function : duBuildRlcLsapCfg
152 * Initiates general Configs towards RLC
154 * @param[in] Inst Specifies if RLC UL or RLC DL instance
155 * @return ROK - success
158 ***************************************************************************/
159 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
163 KwSapCfg *lSap = NULLP;
166 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
167 DU_SET_ZERO(&pst, sizeof(Pst));
170 kwMngmt.hdr.msgType = TCFG;
171 kwMngmt.hdr.entId.ent = ENTKW;
172 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
173 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
175 kwMngmt.hdr.response.mem.pool = RLC_POOL;
178 pst.selector = DU_SELECTOR_LC;
179 pst.srcEnt = ENTDUAPP;
181 pst.dstProcId = DU_PROC;
183 pst.srcProcId = DU_PROC;
184 pst.region = duCb.init.region;
185 lSap = &(kwMngmt.t.cfg.s.sap);
187 lSap->mem.region = (inst == RLC_UL_INST) ?
188 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
189 lSap->mem.pool = RLC_POOL;
191 lSap->bndTmrIntvl = 10;
192 lSap->priority = PRIOR0;
193 lSap->route = RTESPEC;
196 lSap->procId = DU_PROC;
198 lSap->inst = lsapInst;
199 lSap->sapId = lsapInst; /* SapId will be stored as suId in MAC */
200 lSap->selector = (inst == RLC_UL_INST) ? DU_SELECTOR_LWLC : DU_SELECTOR_TC;
201 kwMngmt.hdr.elmId.elmnt = STRGUSAP;
202 DU_LOG("\nDU_APP : RLC MAC Lower Sap Cfg Req sent for inst %d", inst);
207 lSap->procId = DU_PROC;
209 lSap->inst = (inst == RLC_UL_INST) ?
210 RLC_DL_INST : RLC_UL_INST;
212 lSap->selector = DU_SELECTOR_LC;
213 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
214 DU_LOG("\nDU_APP : RLC DL/UL Lower Sap Cfg Req sent for inst %d", inst);
217 cmPkLkwCfgReq(&pst, &kwMngmt);
221 /**************************************************************************
222 * @brief Function to fill configs required by RLC
226 * Function : duBuildRlcUsapCfg
229 * Initiates general Configs towards RLC
231 * @param[in] Inst Specifies if RLC UL or RLC DL instance
232 * @return ROK - success
235 ***************************************************************************/
236 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
239 KwSapCfg *uSap = NULLP;
242 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
243 DU_SET_ZERO(&pst, sizeof(Pst));
245 uSap = &(kwMngmt.t.cfg.s.sap);
247 uSap->selector = DU_SELECTOR_LC;
248 uSap->mem.region = (inst == RLC_UL_INST) ?
249 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
250 uSap->mem.pool = RLC_POOL;
253 uSap->procId = DU_PROC;
257 uSap->inst = (inst == RLC_UL_INST) ?
258 RLC_DL_INST : RLC_UL_INST;
259 uSap->bndTmrIntvl = 1000;
260 uSap->priority = PRIOR0;
261 uSap->route = RTESPEC;
264 kwMngmt.hdr.msgType = TCFG;
265 kwMngmt.hdr.entId.ent = ENTKW;
266 kwMngmt.hdr.elmId.elmnt = STUDXSAP;
267 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
268 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
270 kwMngmt.hdr.response.mem.pool = RLC_POOL;
273 pst.selector = DU_SELECTOR_LC;
274 pst.srcEnt = ENTDUAPP;
276 pst.dstProcId = DU_PROC;
278 pst.srcProcId = DU_PROC;
279 pst.region = duCb.init.region;
281 DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
282 cmPkLkwCfgReq(&pst, &kwMngmt);
287 /**************************************************************************
288 * @brief Function to populate internal DS of DU APP
292 * Function : duProcCfgComplete
295 * Populates internal data structures of DU APP after
296 * receiving configurations.
299 * @return ROK - success
302 ***************************************************************************/
303 S16 duProcCfgComplete()
306 static U16 cellId = 0;
308 for(idx=0; idx< DEFAULT_CELLS; idx++)
311 DU_ALLOC(cell, sizeof(DuCellCb))
314 DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
322 memset(cell, 0, sizeof(DuCellCb));
323 cell->cellId = cellId++;
324 cell->cellInfo.nrEcgi.plmn.mcc[0] = PLMN_MCC0;
325 cell->cellInfo.nrEcgi.plmn.mcc[1] = PLMN_MCC1;
326 cell->cellInfo.nrEcgi.plmn.mcc[2] = PLMN_MCC2;
327 cell->cellInfo.nrEcgi.plmn.mnc[0] = PLMN_MNC0;
328 cell->cellInfo.nrEcgi.plmn.mnc[1] = PLMN_MNC1;
329 cell->cellInfo.nrEcgi.plmn.mnc[2] = PLMN_MNC2;
330 cell->cellInfo.nrEcgi.cellId = NR_CELL_ID;
331 cell->cellInfo.nrPci = NR_PCI;
332 cell->cellInfo.fiveGsTac = DU_TAC;
333 for(idx=0; idx<MAX_PLMN; idx++)
335 cell->cellInfo.plmn[idx].mcc[0] = PLMN_MCC0;
336 cell->cellInfo.plmn[idx].mcc[1] = PLMN_MCC1;
337 cell->cellInfo.plmn[idx].mcc[2] = PLMN_MCC2;
338 cell->cellInfo.plmn[idx].mnc[0] = PLMN_MNC0;
339 cell->cellInfo.plmn[idx].mnc[1] = PLMN_MNC1;
340 cell->cellInfo.plmn[idx].mnc[2] = PLMN_MNC2;
342 cell->cellInfo.maxUe = duCfgParam.maxUe;
343 cell->cellStatus = CELL_OUT_OF_SERVICE;
344 nci = (U16)cell->cellInfo.nrEcgi.cellId;
346 duCb.cfgCellLst[nci-1] = cell;
351 //Start layer configs
352 ret = duSendRlcUlCfg();
356 /**************************************************************************
357 * @brief Function to invoke DU Layer Configs
361 * Function : duSendRlcUlCfg
364 * Initiates Configs towards layers of DU
367 * @return ROK - success
370 ***************************************************************************/
375 duBuildRlcCfg((Inst)RLC_UL_INST);
376 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
378 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
380 duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
385 /**************************************************************************
386 * @brief Function to invoke DU Layer Configs
390 * Function : duSendRlcDlCfg
393 * Initiates Configs towards layers of DU
396 * @return ROK - success
399 ***************************************************************************/
404 duBuildRlcCfg((Inst)RLC_DL_INST);
405 duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
406 for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
408 duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
413 /**************************************************************************
414 * @brief Function to handle Config Confirm from RLC
418 * Function : duHdlRlcCfgComplete
421 * Handles Gen 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 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
432 if (pst->srcInst == RLC_UL_INST)
434 ret = duProcRlcUlCfgComplete(pst, cfm);
438 ret = duProcRlcDlCfgComplete(pst, cfm);
443 /**************************************************************************
444 * @brief Function to handle Control Config Confirm from RLC
448 * Function : duHdlRlcCntrlCfgComplete
451 * Handles Control Config Confirm from RLC
453 * @param[in] Pst *pst, Post structure of the primitive.
454 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC
455 * @return ROK - success
458 ***************************************************************************/
459 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
463 if (cntrl->cfm.status == LCM_PRIM_OK)
465 switch (cntrl->hdr.elmId.elmnt)
469 if (pst->srcInst == RLC_DL_INST)
471 DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
473 if(macCfgInst < DEFAULT_CELLS)
476 duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
480 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
485 DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
487 if(macCfgInst < DEFAULT_CELLS)
489 duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
503 /**************************************************************************
504 * @brief Function to handle Config Confirm from RLC UL
508 * Function : duHdlRlcUlCfgComplete
511 * Handles Config Confirm from RLC UL
513 * @param[in] Pst *pst, Post structure of the primitive.
514 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC UL
515 * @return ROK - success
518 ***************************************************************************/
519 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
523 DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
524 if (cfm->cfm.status == LCM_PRIM_OK)
526 switch(cfm->hdr.elmId.elmnt)
530 rlcUlCfg |= RLC_GEN_CFG;
536 if(numRlcMacSaps == DEFAULT_CELLS)
538 rlcUlCfg |= RLC_MAC_SAP_CFG;
545 rlcUlCfg |= RLC_UDX_SAP_CFG;
552 DU_LOG("\nDU_APP : RLC UL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
553 if(rlcUlCfg == DU_RLC_UL_CONFIGURED)
557 //Start configuration of RLC DL
564 DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
570 /**************************************************************************
571 * @brief Function to handle Config Confirm from RLC DL
575 * Function : duHdlRlcDlCfgComplete
578 * Handles Config Confirm from RLC DL
580 * @param[in] Pst *pst, Post structure of the primitive.
581 * @param[in] KwMngmt *cfm, Unpacked primitive info received from RLC DL
582 * @return ROK - success
585 ***************************************************************************/
586 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
588 DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
589 if (cfm->cfm.status == LCM_PRIM_OK)
591 switch(cfm->hdr.elmId.elmnt)
595 rlcDlCfg |= RLC_GEN_CFG;
601 if(numRlcMacSaps == DEFAULT_CELLS)
603 rlcDlCfg |= RLC_MAC_SAP_CFG;
610 rlcDlCfg |= RLC_UDX_SAP_CFG;
618 DU_LOG("\nDU_APP : RLC DL Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
619 if(rlcDlCfg == DU_RLC_DL_CONFIGURED)
622 //Start configuration of MAC
629 DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
634 /**************************************************************************
635 * @brief Function to send configs to MAC
639 * Function : duSendMacCfg
642 * Initiates Configs towards MAC layer
645 * @return ROK - success
648 ***************************************************************************/
652 duBuildMacUsapCfg(RLC_UL_INST);
653 duBuildMacUsapCfg(RLC_DL_INST);
658 /**************************************************************************
659 * @brief Function to fill gen config required by MAC
663 * Function : duBuildMacGenCfg
666 * Initiates general Configs towards MAC
669 * @return ROK - success
672 ***************************************************************************/
673 S16 duBuildMacGenCfg()
676 RgGenCfg *genCfg=NULLP;
679 DU_SET_ZERO(&pst, sizeof(Pst));
680 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
682 genCfg = &(rgMngmt.t.cfg.s.genCfg);
684 /*----------- Fill General Configuration Parameters ---------*/
685 genCfg->mem.region = RG_MEM_REGION;
686 genCfg->mem.pool = RG_POOL;
688 genCfg->numRguSaps = 2;
690 genCfg->lmPst.dstProcId = DU_PROC;
691 genCfg->lmPst.srcProcId = DU_PROC;
692 genCfg->lmPst.dstEnt = ENTDUAPP;
693 genCfg->lmPst.dstInst = 0;
694 genCfg->lmPst.srcEnt = ENTRG;
695 genCfg->lmPst.srcInst = macCfgInst;
696 genCfg->lmPst.prior = PRIOR0;
697 genCfg->lmPst.route = RTESPEC;
698 genCfg->lmPst.region = RG_MEM_REGION;
699 genCfg->lmPst.pool = RG_POOL;
700 genCfg->lmPst.selector = DU_SELECTOR_LC;
703 rgMngmt.hdr.msgType = TCFG;
704 rgMngmt.hdr.msgLen = 0;
705 rgMngmt.hdr.entId.ent = ENTRG;
706 rgMngmt.hdr.entId.inst = (Inst)0;
707 rgMngmt.hdr.elmId.elmnt = STGEN;
708 rgMngmt.hdr.seqNmb = 0;
709 rgMngmt.hdr.version = 0;
710 rgMngmt.hdr.transId = 0;
712 rgMngmt.hdr.response.prior = PRIOR0;
713 rgMngmt.hdr.response.route = RTESPEC;
714 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
715 rgMngmt.hdr.response.mem.pool = RG_POOL;
716 rgMngmt.hdr.response.selector = DU_SELECTOR_LC;
719 pst.selector = DU_SELECTOR_LC;
720 pst.srcEnt = ENTDUAPP;
722 pst.dstInst = macCfgInst;
723 pst.dstProcId = DU_PROC;
724 pst.srcProcId = DU_PROC;
725 pst.region = duCb.init.region;
727 DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
729 /* Send the request to MAC */
730 cmPkLrgCfgReq(&pst, &rgMngmt);
735 /**************************************************************************
736 * @brief Function to fill USAP config required by MAC
740 * Function : duBuildMacUsapCfg
743 * Initiates USAP Configs towards MAC
745 * @param[in] SpId Specifies if RLC UL or RLC DL instance
746 * @return ROK - success
749 ***************************************************************************/
750 S16 duBuildMacUsapCfg(SpId sapId)
753 RgUpSapCfg *uSap = NULLP;
756 DU_SET_ZERO(&pst, sizeof(Pst));
757 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
759 uSap = &(rgMngmt.t.cfg.s.rguSap);
761 uSap->mem.region = RG_MEM_REGION;
762 uSap->mem.pool = RG_POOL;
765 uSap->procId = DU_PROC;
768 uSap->prior = PRIOR0;
769 uSap->route = RTESPEC;
770 uSap->selector = DU_SELECTOR_LC ;
773 rgMngmt.hdr.msgType = TCFG;
774 rgMngmt.hdr.entId.ent = ENTRG;
775 rgMngmt.hdr.entId.inst = (Inst)0;
776 rgMngmt.hdr.elmId.elmnt = STRGUSAP;
777 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
778 rgMngmt.hdr.response.mem.pool = RG_POOL;
781 pst.selector = DU_SELECTOR_LC;
782 pst.srcEnt = ENTDUAPP;
784 pst.dstInst = macCfgInst;
785 pst.dstProcId = DU_PROC;
786 pst.srcProcId = DU_PROC;
787 pst.region = duCb.init.region;
789 DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
791 /* Send the request to MAC */
792 cmPkLrgCfgReq(&pst, &rgMngmt);
797 /**************************************************************************
798 * @brief Function to handle Config Confirm from MAC
802 * Function : duHdlMacCfgComplete
805 * Handles Gen Config Confirm from MAC
807 * @param[in] Pst *pst, Post structure of the primitive.
808 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
809 * @return ROK - success
812 ***************************************************************************/
813 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
817 if (cfm->cfm.status == LCM_PRIM_OK)
819 switch (cfm->hdr.elmId.elmnt)
823 macCfg |= MAC_GEN_CFG;
828 macCfg |= MAC_SAP_CFG;
835 DU_LOG("\nDU_APP : MAC Cfg Cfm received for the element %d ",cfm->hdr.elmId.elmnt);
836 if(macCfg == MAC_CONFIGURED && numRlcMacSaps == MAX_MAC_SAP)
839 DU_LOG("\nDU_APP : Completed sending Configs");
841 duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
847 DU_LOG("\nDU_APP : Config confirm NOK from MAC");
853 /**************************************************************************
854 * @brief Function to bind/unbind RLC to MAC SAP
858 * Function : duBindUnbindRlcToMacSap
861 * Initiates Bind/Unbind from RLC to MAC
863 * @param[in] Inst Specifies if RLC UL or RLC DL instance
864 * @param[in] action Specifies if action is bind or unbind
865 * @return ROK - success
868 ***************************************************************************/
869 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
871 KwCntrl *cntrl = NULLP;
875 TRC2(smBindKwToRguSap)
877 DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
878 DU_SET_ZERO(&pst, sizeof(Pst));
882 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
886 DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
888 cntrl = &(kwMngmt.t.cntrl);
890 cntrl->action = action;
891 cntrl->subAction = DU_ZERO_VAL;
892 cntrl->s.sapCntrl.suId = macCfgInst;
893 cntrl->s.sapCntrl.spId = inst;
896 kwMngmt.hdr.msgType = TCNTRL;
897 kwMngmt.hdr.entId.ent = ENTKW;
898 kwMngmt.hdr.entId.inst = inst;
899 kwMngmt.hdr.elmId.elmnt = 186; /* ambiguous defines in lkw.h and lrg.h so direct hardcoded*/
900 kwMngmt.hdr.response.mem.region = (inst == RLC_UL_INST) ?
901 RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
902 kwMngmt.hdr.response.mem.pool = RLC_POOL;
905 pst.selector = DU_SELECTOR_LC;
906 pst.srcEnt = ENTDUAPP;
908 pst.dstProcId = DU_PROC;
910 pst.srcProcId = DU_PROC;
911 pst.region = duCb.init.region;
913 cmPkLkwCntrlReq(&pst, &kwMngmt);
917 /*******************************************************************
919 * @brief Handles SCTP notifications
923 * Function : duSctpNtfyHdl
926 * Handles SCTP notification
928 * @params[in] Message Buffer
931 * @return ROK - success
934 * ****************************************************************/
936 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
938 if(f1Params.assocId == ntfy->u.assocChange.assocId)
940 if(BuildAndSendF1SetupReq() != ROK)
945 else if(ricParams.assocId == ntfy->u.assocChange.assocId)
947 if(BuildAndSendE2SetupReq() != ROK)
954 DU_LOG("\nDU_APP : Invalid assocId %d received", ntfy->u.assocChange.assocId);
960 /*******************************************************************
962 * @brief Fills Pst struct for ENTEGTP
966 * Function : duFillEgtpPst
969 * Fills Pst struct for ENTEGTP
972 * @return ROK - success
975 * ****************************************************************/
976 S16 duFillEgtpPst(Pst *pst, Event event)
978 cmMemset((U8 *)pst, 0, sizeof(Pst));
979 pst->srcEnt = (Ent)ENTDUAPP;
980 pst->srcInst = (Inst)DU_INST;
981 pst->srcProcId = DU_PROC;
982 pst->dstEnt = (Ent)ENTEGTP;
983 pst->dstInst = (Inst)EGTP_INST;
984 pst->dstProcId = pst->srcProcId;
986 pst->selector = DU_SELECTOR_LC;
993 /*******************************************************************
995 * @brief Function to configure EGTP
999 * Function : duBuildEgtpCfgReq
1002 * Function to configure EGTP
1005 * @return ROK - success
1008 * ****************************************************************/
1010 S16 duBuildEgtpCfgReq()
1015 DU_LOG("\nDU_APP : Sending EGTP config request");
1017 cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1018 cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1020 duFillEgtpPst(&pst, EVTCFGREQ);
1021 packEgtpCfgReq(&pst, egtpCfg);
1026 /*******************************************************************
1028 * @brief Function to configure EGTP
1032 * Function : duBuildEgtpCfgReq
1035 * Function to configure EGTP
1038 * @return ROK - success
1041 * ****************************************************************/
1042 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1046 if(cfm.status == LCM_PRIM_OK)
1048 DU_LOG("\nDU_APP : EGTP configuraton complete");
1050 duSendEgtpSrvOpenReq();
1055 DU_LOG("\nDU_APP : EGTP configuraton failed");
1062 /*******************************************************************
1064 * @brief Sends server open request to EGTP
1068 * Function : duSendEgtpSrvOpenReq
1071 * Sends server open request to EGTP
1074 * @return ROK - success
1077 * ****************************************************************/
1079 S16 duSendEgtpSrvOpenReq()
1083 DU_LOG("\nDU_APP : Sending EGTP server open request");
1085 duFillEgtpPst(&pst, EVTSRVOPENREQ);
1086 packEgtpSrvOpenReq(&pst);
1091 /*******************************************************************
1093 * @brief Handles server open confirmation
1097 * Function : duHdlEgtpSrvOpenComplete
1100 * Handles server open confirmation
1103 * @return ROK - success
1106 *****************************************************************/
1108 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1112 if(cfm.status == LCM_PRIM_OK)
1114 DU_LOG("\nDU_APP : EGTP server opened successfully");
1116 duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1121 DU_LOG("\nDU_APP : EGTP server opening failed");
1128 /*******************************************************************
1130 * @brief Sends tunnel management request
1134 * Function : duSendEgtpTnlMgmtReq
1137 * Builds and sends tunnel management request to EGTP
1139 * @params[in] Action
1140 * Local tunnel endpoint id
1141 * Remote tunnel endpoint id
1142 * @return ROK - success
1145 * ****************************************************************/
1147 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1152 tnlEvt.action = action;
1153 tnlEvt.lclTeid = lclTeid;
1154 tnlEvt.remTeid = remTeid;
1156 DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1158 duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1159 packEgtpTnlMgmtReq(&pst, tnlEvt);
1164 /*******************************************************************
1166 * @brief Handles Tunnel management confirm
1170 * Function : duHdlEgtpTnlMgmtCfm
1173 * Handles tunnel management confirm received from Egtp
1175 * @params[in] Tunnel Event
1176 * @return ROK - success
1179 * ****************************************************************/
1180 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1184 if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1186 DU_LOG("\nDU_APP : Tunnel management confirm OK");
1189 duSendUeCreateReqToRlc();
1191 duSendEgtpTestData();
1196 DU_LOG("\nDU_APP : Tunnel management failed");
1203 S16 duSendEgtpDatInd(Buffer *mBuf)
1207 /* Fill EGTP header */
1208 egtpMsg.msgHdr.msgType = EGTPU_MSG_GPDU;
1209 egtpMsg.msgHdr.nPdu.pres = FALSE;
1210 egtpMsg.msgHdr.seqNum.pres = FALSE;
1211 egtpMsg.msgHdr.extHdr.udpPort.pres = FALSE;
1212 egtpMsg.msgHdr.extHdr.pdcpNmb.pres = FALSE;
1213 egtpMsg.msgHdr.teId = 1;
1216 egtpHdlDatInd(egtpMsg);
1223 /*******************************************************************
1225 * @brief Simulate UL Data for intial test
1229 * Function : duSendEgtpTestData
1232 * Simulate UL data for initial test
1235 * @return ROK - success
1238 * ****************************************************************/
1239 S16 duSendEgtpTestData()
1241 char data[30] = "This is EGTP data from DU";
1246 if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1248 if(SAddPstMsgMult((Data *)data, datSize, mBuf) != ROK)
1250 DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1257 DU_LOG("\nDU_APP : Failed to allocate memory");
1261 /* filling IPv4 header */
1266 SFndLenMsg(mBuf, &mLen);
1268 cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1269 ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1270 ipv4Hdr.hdrVer = 0x45;
1272 ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1273 ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1275 /* Packing IPv4 header into buffer */
1277 Data revPkArray[CM_IPV4_HDRLEN];
1278 Data pkArray[CM_IPV4_HDRLEN];
1280 /* initialize locals */
1282 cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1283 cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1285 /* Pack Header Version */
1286 pkArray[cnt++] = ipv4Hdr.hdrVer;
1289 pkArray[cnt++] = ipv4Hdr.tos;
1291 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1292 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1295 pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1296 pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1299 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1300 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1303 pkArray[cnt++] = ipv4Hdr.ttl;
1306 pkArray[cnt++] = ipv4Hdr.proto;
1309 pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1310 pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1312 /* Pack Source Address */
1313 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.srcAddr));
1314 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.srcAddr));
1315 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.srcAddr));
1316 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.srcAddr));
1318 /* Pack Destination Address */
1319 pkArray[cnt++] = (Data)GetHiByte(GetHiWord(ipv4Hdr.destAddr));
1320 pkArray[cnt++] = (Data)GetLoByte(GetHiWord(ipv4Hdr.destAddr));
1321 pkArray[cnt++] = (Data)GetHiByte(GetLoWord(ipv4Hdr.destAddr));
1322 pkArray[cnt++] = (Data)GetLoByte(GetLoWord(ipv4Hdr.destAddr));
1324 for (idx = 0; idx < CM_IPV4_HDRLEN; idx++)
1325 revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1327 /* this function automatically reverses revPkArray */
1328 ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1330 duSendEgtpDatInd(mBuf);
1334 #endif /* EGTP_TEST */
1337 /**************************************************************************
1338 * @brief Function to send configs to SCH
1342 * Function : duSendSchCfg
1345 * Sends general config to Scheduler via MAC layer
1348 * @return ROK - success
1351 ***************************************************************************/
1355 RgSchInstCfg *cfg = NULLP;
1358 DU_SET_ZERO(&pst, sizeof(Pst));
1359 DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1361 cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1363 /* Filling of Instance Id */
1364 cfg->instId = DEFAULT_CELLS + 1;
1365 /* Filling of Gen config */
1366 cfg->genCfg.mem.region = RG_MEM_REGION;
1367 cfg->genCfg.mem.pool = RG_POOL;
1368 cfg->genCfg.tmrRes = 10;
1371 cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1372 cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1374 cfg->genCfg.startCellId = 1;
1375 cfg->genCfg.lmPst.dstProcId = DU_PROC;
1376 cfg->genCfg.lmPst.srcProcId = DU_PROC;
1377 cfg->genCfg.lmPst.dstEnt = ENTDUAPP;
1378 cfg->genCfg.lmPst.dstInst = DU_INST;
1379 cfg->genCfg.lmPst.srcEnt = ENTRG;
1380 cfg->genCfg.lmPst.srcInst = DEFAULT_CELLS + 1;
1381 cfg->genCfg.lmPst.prior = PRIOR0;
1382 cfg->genCfg.lmPst.route = RTESPEC;
1383 cfg->genCfg.lmPst.region = RG_MEM_REGION;
1384 cfg->genCfg.lmPst.pool = RG_POOL;
1385 cfg->genCfg.lmPst.selector = DU_SELECTOR_LC;
1388 rgMngmt.hdr.msgType = TCFG;
1389 rgMngmt.hdr.entId.ent = ENTRG;
1390 rgMngmt.hdr.entId.inst = DU_INST;
1391 rgMngmt.hdr.elmId.elmnt = STSCHINST;
1392 rgMngmt.hdr.response.mem.region = RG_MEM_REGION;
1393 rgMngmt.hdr.response.mem.pool = RG_POOL;
1396 pst.selector = DU_SELECTOR_LC;
1397 pst.srcEnt = ENTDUAPP;
1399 pst.dstProcId = DU_PROC;
1400 pst.srcProcId = DU_PROC;
1401 pst.srcInst = DU_INST;
1403 pst.region = duCb.init.region;
1404 pst.event = (Event) EVTMACSCHGENCFGREQ;
1406 DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1408 /* Send the request to MAC */
1409 cmPkLrgSchCfgReq(&pst, &rgMngmt);
1415 /**************************************************************************
1416 * @brief Function to configure SCTP params and
1417 * responsible for F1 and E2 interfaces
1421 * Function : duLayerConfigComplete
1424 * Configures SCTP Params and responsible for handling
1425 * F1 and E2 interface.
1428 * @return ROK - success
1431 ***************************************************************************/
1432 S16 duLayerConfigComplete()
1436 DU_LOG("\nDU_APP : Configuring all Layer is complete");
1438 if((ret = duSctpCfgReq(duCfgParam.sctpParams)) != ROK)
1440 DU_LOG("\nDU_APP : Failed configuring Sctp Params");
1443 if((ret = duSctpAssocReq(F1_INTERFACE)) != ROK)
1445 DU_LOG("\nDU_APP : Failed to send AssocReq F1");
1448 if((ret = duSctpAssocReq(E2_INTERFACE)) != ROK)
1450 DU_LOG("\nDU_APP : Failed to send AssocReq E2");
1457 /**************************************************************************
1458 * @brief Function to handle SCH Config Confirm from MAC
1462 * Function : duHdlSchCfgComplete
1465 * Handles Scheduler Gen Config Confirm from MAC
1467 * @param[in] Pst *pst, Post structure of the primitive.
1468 * @param[in] RgMngmt *cfm, Unpacked primitive info received from MAC
1469 * @return ROK - success
1472 ***************************************************************************/
1473 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1475 if (cfm->cfm.status == LCM_PRIM_OK)
1477 switch (cfm->hdr.elmId.elmnt)
1481 DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1488 duLayerConfigComplete();
1489 duBuildEgtpCfgReq();
1493 /*******************************************************************
1495 * @brief Sends Slot indication to EGTP
1499 * Function : duSendEgtpSlotInd
1502 * Sends Slot indication to EGTP
1505 * @return ROK - success
1508 * ****************************************************************/
1509 S16 duSendEgtpSlotInd()
1513 duFillEgtpPst(&pst, EVTSLOTIND);
1514 packEgtpSlotInd(&pst);
1520 /**************************************************************************
1521 * @brief Function to fill and send MacCellconfig
1525 * Function : duBuildAndSendMacCellCfg
1528 * Initiates MAC Configs towards MAC
1531 * @return ROK - success
1534 ***************************************************************************/
1535 S16 duBuildAndSendMacCellCfg()
1538 DU_SET_ZERO(&pst, sizeof(Pst));
1539 MacCellCfg *duMacCellCfg = NULLP;
1541 DU_ALLOC(duMacCellCfg, sizeof(MacCellCfg));
1542 if(duMacCellCfg == NULLP)
1547 /* store the address in the duCb so that we can free on confirm msg */
1548 duCb.duMacCellCfg = duMacCellCfg;
1550 /* copy the mac config structure from duCfgParams */
1551 memcpy(duMacCellCfg,&duCfgParam.macCellCfg,sizeof(MacCellCfg));
1553 duMacCellCfg->transId = getTransId(); /* transaction ID */
1556 pst.selector = DU_SELECTOR_LWLC;
1557 pst.srcEnt = ENTDUAPP;
1561 pst.dstProcId = DU_PROC;
1562 pst.srcProcId = DU_PROC;
1563 pst.region = duCb.init.region;
1564 pst.event = EVENT_MAC_CELL_CONFIG_REQ;
1566 /* Send MAC cell config to MAC */
1567 return (*packMacCellCfgOpts[pst.selector])(&pst, duMacCellCfg);
1570 /**************************************************************************
1571 * @brief Function to Handle MAC cell config confirm
1575 * Function : duHandleMacCellCfgCfm
1578 * Initiates general Configs towards MAC
1581 * @return ROK - success
1584 ***************************************************************************/
1585 uint16_t duHandleMacCellCfgCfm(MacCellCfgCfm *macCellCfgCfm)
1589 if(macCellCfgCfm->rsp == ROK)
1591 if(macCellCfgCfm->transId == duCb.duMacCellCfg->transId)
1593 /* free the memory allocated during sending macCellCfg request */
1594 DU_FREE(duCb.duMacCellCfg,sizeof(MacCellCfg));
1595 duCb.duMacCellCfg = NULLP;
1597 /* Build and send GNB-DU config update */
1598 ret = BuildAndSendDUConfigUpdate();
1600 /* TODO: Trigger cell start req once cell up slot ind is received*/
1601 /* Build and Send Cell Start Req to MAC */
1602 //ret = duBuildAndSendMacCellStartReq();
1607 /* transaction ID missmatch */
1608 DU_LOG("\n transaction ID mismatch in macCellCfg");
1614 DU_LOG("\nMac cell cfg failed");
1620 /*******************************************************************
1622 * @brief Handles slot indication from MAC
1626 * Function : duHandleSlotInd
1629 * Handles slot indication from MAC
1631 * @params[in] Post structure pointer
1633 * @return ROK - success
1636 * ****************************************************************/
1637 uint16_t duHandleSlotInd(Pst *pst, SlotInfo *slotInfo)
1640 DU_LOG("\nDU APP : Slot Indication received");
1642 /* TODO : Slot Indication to be moved out of EGTP_TEST when
1643 * data path is established */
1645 duSendEgtpSlotInd();
1647 DU_FREE_MEM(pst->region, pst->pool, slotInfo, sizeof(SlotInfo));
1651 /*******************************************************************
1653 * @brief Builds and sends cell start request to MAC
1657 * Function : duBuildAndSendMacCellStartReq
1660 * Builds and sends cell start request to MAC
1663 * @return ROK - success
1666 * ****************************************************************/
1667 uint16_t duBuildAndSendMacCellStartReq()
1670 MacCellStartInfo *cellStartInfo = NULL;
1672 DU_LOG("\nDU APP : Building and Sending cell start request to MAC");
1674 /* Send Cell Start Request to MAC */
1675 DU_ALLOC(cellStartInfo, sizeof(MacCellStartInfo));
1678 DU_LOG("\nDU APP : Memory alloc failed while building cell start request");
1682 for(uint8_t id = 0; id < DU_MAX_CELLS; id++)
1684 if(duCb.actvCellLst[id])
1686 cellStartInfo->cellId = duCb.actvCellLst[id]->cellInfo.nrEcgi.cellId;
1689 pst.selector = DU_MAC_LWLC;
1690 pst.srcEnt = ENTDUAPP;
1694 pst.dstProcId = DU_PROC;
1695 pst.srcProcId = DU_PROC;
1696 pst.region = DU_APP_MEM_REGION;
1698 pst.event = EVENT_MAC_CELL_START_REQ;
1700 return (*packMacCellStartReqOpts[pst.selector])(&pst, cellStartInfo);
1706 /*******************************************************************
1708 * @brief Builds and sends cell stop request to MAC
1712 * Function : duBuildAndSendMacCellStopReq
1715 * Builds and sends cell stop request to MAC
1718 * @return ROK - success
1721 * ****************************************************************/
1722 S16 duBuildAndSendMacCellStopReq()
1725 MacCellStopInfo *cellStopInfo = NULL;
1727 DU_LOG("\nDU APP : Building and Sending cell stop request to MAC");
1729 /* Send Cell Stop Request to MAC */
1730 DU_ALLOC(cellStopInfo, sizeof(MacCellStopInfo));
1733 DU_LOG("\nDU APP : Memory alloc failed while building cell stop request");
1736 cellStopInfo->cellId = duCb.actvCellLst[0]->cellId;
1739 pst.selector = DU_MAC_LWLC;
1740 pst.srcEnt = ENTDUAPP;
1744 pst.dstProcId = DU_PROC;
1745 pst.srcProcId = DU_PROC;
1746 pst.region = DU_APP_MEM_REGION;
1748 pst.event = EVENT_MAC_CELL_STOP_REQ;
1750 return (*packMacCellStopReqOpts[pst.selector])(&pst, cellStopInfo);
1754 /**********************************************************************
1756 **********************************************************************/