Initial commit for Bronze release
[o-du/l2.git] / src / du_app / du_msg_hdl.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /* This file contains message handling functionality for DU cell management */
20
21 #include "du_sctp.h"
22 #include "du_f1ap_msg_hdl.h"
23 #include "lsctp.h"
24 #include "legtp.h"
25 #include "lphy_stub.h"
26
27 U8 rlcDlCfg = 0;
28 U8 numRlcDlSaps = 0;
29 U8 rlcUlCfg = 0;
30 U8 numRlcMacSaps = 0;
31 U8 macCfg = 0;
32 U8 macCfgInst = 0;
33
34 extern DuCfgParams duCfgParam;;
35
36 extern S16 cmPkLkwCfgReq(Pst *pst, KwMngmt *cfg);
37 extern S16 cmPkLkwCntrlReq(Pst *pst, KwMngmt *cfg);
38 extern S16 cmPkLrgCfgReq(Pst *pst, RgMngmt *cfg);
39
40 /**************************************************************************
41  * @brief Function to fill configs required by RLC
42  *
43  * @details
44  *
45  *      Function : duBuildRlcCfg 
46  * 
47  *      Functionality:
48  *           Initiates general Configs towards RLC 
49  *     
50  * @param[in] Inst  Specifies if RLC UL or RLC DL instance 
51  * @return ROK     - success
52  *         RFAILED - failure
53  *
54  ***************************************************************************/
55 S16 duBuildRlcCfg(Inst inst)
56 {
57    KwMngmt   kwMngmt;
58    KwGenCfg  *genCfg = NULLP;
59    Pst pst;
60
61    DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
62    DU_SET_ZERO(&pst, sizeof(Pst));
63
64    genCfg   = &(kwMngmt.t.cfg.s.gen);
65
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;
72    genCfg->timeRes     = 1; 
73    genCfg->maxRguSaps  = DEFAULT_CELLS;
74
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;
89
90     /* Fill Header */
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;
105
106    /* Fill Pst */
107    pst.selector  = DU_SELECTOR_LC;
108    pst.srcEnt    = ENTDUAPP;
109    pst.dstEnt    = ENTKW;
110    pst.dstInst   = inst;
111    pst.dstProcId = DU_PROC;
112    pst.srcProcId = DU_PROC;
113    pst.region    = duCb.init.region;
114
115    DU_LOG("\nDU_APP : RLC Gen Cfg Req sent for inst %d", inst);
116
117    /* Send the request to RLC */
118    cmPkLkwCfgReq(&pst, &kwMngmt);
119
120    return ROK;
121 }
122
123 /**************************************************************************
124  * @brief Function to fill configs required by RLC
125  *
126  * @details
127  *
128  *      Function : duBuildRlcLsapCfg 
129  * 
130  *      Functionality:
131  *           Initiates general Configs towards RLC 
132  *     
133  * @param[in] Inst  Specifies if RLC UL or RLC DL instance 
134  * @return ROK     - success
135  *         RFAILED - failure
136  *
137  ***************************************************************************/
138 S16 duBuildRlcLsapCfg(Ent ent, Inst inst, U8 lsapInst)
139 {
140
141    KwMngmt    kwMngmt;
142    KwSapCfg   *lSap = NULLP;
143    Pst        pst;
144
145    DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
146    DU_SET_ZERO(&pst, sizeof(Pst));
147
148    /* Fill Header */
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;
153
154    kwMngmt.hdr.response.mem.pool   = RLC_POOL;
155
156    /* Fill Pst */
157    pst.selector  = DU_SELECTOR_LC;
158    pst.srcEnt    = ENTDUAPP;
159    pst.dstEnt    = ENTKW;
160    pst.dstProcId = DU_PROC;
161    pst.dstInst   = inst;
162    pst.srcProcId = DU_PROC;
163    pst.region    = duCb.init.region;
164    lSap   = &(kwMngmt.t.cfg.s.sap);
165
166    lSap->mem.region = (inst == RLC_UL_INST) ?
167       RLC_UL_MEM_REGION:RLC_DL_MEM_REGION;
168    lSap->mem.pool    = RLC_POOL;
169    lSap->mem.spare   = 0;
170    lSap->bndTmrIntvl = 10;
171    lSap->priority    = PRIOR0;
172    lSap->route       = RTESPEC;
173    if (ent == ENTRG)
174    {
175       lSap->procId      = DU_PROC;
176       lSap->ent         = ENTRG;
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);
182
183    }
184    else
185    {
186       lSap->procId    = DU_PROC;
187       lSap->ent       = ENTKW;
188       lSap->inst      = (inst == RLC_UL_INST) ?
189          RLC_DL_INST : RLC_UL_INST;
190       lSap->sapId       = 0;
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);
194    }
195
196    cmPkLkwCfgReq(&pst, &kwMngmt);
197    return ROK;
198 }
199
200 /**************************************************************************
201  * @brief Function to fill configs required by RLC
202  *
203  * @details
204  *
205  *      Function : duBuildRlcUsapCfg 
206  * 
207  *      Functionality:
208  *           Initiates general Configs towards RLC 
209  *     
210  * @param[in] Inst  Specifies if RLC UL or RLC DL instance 
211  * @return ROK     - success
212  *         RFAILED - failure
213  *
214  ***************************************************************************/
215 S16 duBuildRlcUsapCfg(U8 elemId, Ent ent, Inst inst)
216 {
217    KwMngmt    kwMngmt;
218    KwSapCfg   *uSap = NULLP;
219    Pst        pst;
220
221    DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
222    DU_SET_ZERO(&pst, sizeof(Pst));
223
224    uSap   = &(kwMngmt.t.cfg.s.sap);
225
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;
230    uSap->mem.spare = 0;
231
232    uSap->procId = DU_PROC;
233    uSap->ent = ENTKW;
234    uSap->sapId = 0;
235
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;
241
242    /* Fill Header */
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;
248
249    kwMngmt.hdr.response.mem.pool   = RLC_POOL;
250
251    /* Fill Pst */
252    pst.selector  = DU_SELECTOR_LC;
253    pst.srcEnt    = ENTDUAPP;
254    pst.dstEnt    = ENTKW;
255    pst.dstProcId = DU_PROC;
256    pst.dstInst = inst;
257    pst.srcProcId = DU_PROC;
258    pst.region = duCb.init.region;
259
260    DU_LOG("\nDU_APP : RLC Kwu Upper Sap Cfg Req sent for inst %d", inst);
261    cmPkLkwCfgReq(&pst, &kwMngmt);
262
263    return ROK;
264 }
265
266 /**************************************************************************
267  * @brief Function to populate internal DS of DU APP
268  *
269  * @details
270  *
271  *      Function : duProcCfgComplete
272  * 
273  *      Functionality:
274  *           Populates internal data structures of DU APP after 
275  *           receiving configurations.
276  *     
277  * @param[in]  void
278  * @return ROK     - success
279  *         RFAILED - failure
280  *
281  ***************************************************************************/
282 S16 duProcCfgComplete()
283 {
284    S16 ret = ROK;
285    static U16 cellId = 0;
286    U16 idx;
287    for(idx=0; idx< DEFAULT_CELLS; idx++) //TODO: the length of this loop must be determined
288    {
289       DuCellCb *cell;
290       DU_ALLOC(cell, sizeof(DuCellCb))
291       if(cell == NULLP)
292       {
293          DU_LOG("\nDU_APP : Memory Allocation failed in duProcCfgComplete");
294          ret = RFAILED;
295       }
296       else
297       {
298          U16 nci;
299
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));
307
308          if(ret != ROK)
309          {
310             DU_LOG("\nDU_APP : HashListInsert into cellLst failed for [%d]", nci);
311             break;
312          }
313          else
314          {
315             DU_LOG("\nDU_APP : HashListInsert into cellLst successful for [%d]", nci);
316          }
317       }
318    }
319    if(ret != RFAILED)
320    {
321       //Start layer configs
322       ret = duSendRlcUlCfg();
323    }
324    return ret;
325 }
326 /**************************************************************************
327  * @brief Function to invoke DU Layer Configs
328  *
329  * @details
330  *
331  *      Function : duSendRlcUlCfg 
332  * 
333  *      Functionality:
334  *           Initiates Configs towards layers of DU
335  *     
336  * @param[in]  void
337  * @return ROK     - success
338  *         RFAILED - failure
339  *
340  ***************************************************************************/
341 S16 duSendRlcUlCfg()
342 {
343    U8 cellIdx; 
344
345    duBuildRlcCfg((Inst)RLC_UL_INST);
346    for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
347    {
348       duBuildRlcLsapCfg(ENTRG, (Inst)RLC_UL_INST, cellIdx);
349    }
350    duBuildRlcLsapCfg(ENTKW, (Inst)RLC_UL_INST, 0);
351    
352    return ROK;
353 }
354
355 /**************************************************************************
356  * @brief Function to invoke DU Layer Configs
357  *
358  * @details
359  *
360  *      Function : duSendRlcDlCfg 
361  * 
362  *      Functionality:
363  *           Initiates Configs towards layers of DU
364  *     
365  * @param[in]  void
366  * @return ROK     - success
367  *         RFAILED - failure
368  *
369  ***************************************************************************/
370 S16 duSendRlcDlCfg()
371 {
372    U8 cellIdx; 
373
374    duBuildRlcCfg((Inst)RLC_DL_INST);
375    duBuildRlcUsapCfg(STUDXSAP, ENTKW, (Inst)RLC_DL_INST);
376    for(cellIdx = 0; cellIdx < DEFAULT_CELLS; cellIdx++)
377    {
378       duBuildRlcLsapCfg(ENTRG, (Inst)RLC_DL_INST, cellIdx);
379    }
380    
381    return ROK;
382 }
383 /**************************************************************************
384  * @brief Function to handle Config Confirm from RLC
385  *
386  * @details
387  *
388  *      Function : duHdlRlcCfgComplete 
389  * 
390  *      Functionality:
391  *           Handles Gen Config Confirm from RLC
392  *     
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
396  *         RFAILED - failure
397  *
398  ***************************************************************************/
399 S16 duHdlRlcCfgComplete(Pst *pst, KwMngmt *cfm)
400 {
401    S16 ret = ROK;
402    if (pst->srcInst == RLC_UL_INST)
403    {
404       ret = duProcRlcUlCfgComplete(pst, cfm);
405    }
406    else
407    {
408       ret = duProcRlcDlCfgComplete(pst, cfm);
409    }
410    return ret;
411 }
412
413 /**************************************************************************
414  * @brief Function to handle Control Config Confirm from RLC
415  *
416  * @details
417  *
418  *      Function : duHdlRlcCntrlCfgComplete 
419  * 
420  *      Functionality:
421  *           Handles Control Config Confirm from RLC
422  *     
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
426  *         RFAILED - failure
427  *
428  ***************************************************************************/
429 S16 duHdlRlcCntrlCfgComplete(Pst *pst, KwMngmt *cntrl)
430 {
431    S16 ret = ROK;
432
433    if (cntrl->cfm.status == LCM_PRIM_OK)
434    {
435       switch (cntrl->hdr.elmId.elmnt)
436       {
437          case  STRGUSAP:
438             {
439                if (pst->srcInst == RLC_DL_INST)
440                {
441                   DU_LOG("\nDU_APP : BIND OF RLC DL TO MAC (RGU) SAP SUCCESSFUL");
442                   macCfgInst++;
443                   if(macCfgInst < DEFAULT_CELLS)
444                   {
445                      macCfgInst = 0;
446                      duBindUnbindRlcToMacSap((Inst) RLC_DL_INST, ABND);
447                   }
448                   else
449                   {
450                      duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
451                   }
452                }
453                else
454                {
455                   DU_LOG("\nDU_APP : BIND OF RLC UL TO MAC (RGU) SAP SUCCESSFUL");
456                   macCfgInst++;
457                   if(macCfgInst < DEFAULT_CELLS)
458                   {
459                      duBindUnbindRlcToMacSap((Inst) RLC_UL_INST, ABND);
460                   }
461                   else
462                   {
463                      duSendSchCfg();
464                   }
465                   break;
466                }
467             }
468
469       }
470    }
471    return ret;
472 }
473 /**************************************************************************
474  * @brief Function to handle Config Confirm from RLC UL
475  *
476  * @details
477  *
478  *      Function : duHdlRlcUlCfgComplete 
479  * 
480  *      Functionality:
481  *           Handles Config Confirm from RLC UL
482  *     
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
486  *         RFAILED - failure
487  *
488  ***************************************************************************/
489 S16 duProcRlcUlCfgComplete(Pst *pst, KwMngmt *cfm)
490 {
491    S16 ret;
492
493    DU_LOG("\nDU_APP : RLC UL Cfg Status %d", cfm->cfm.status);
494    if (cfm->cfm.status == LCM_PRIM_OK)
495    {
496       switch(cfm->hdr.elmId.elmnt)
497       {
498          case STGEN:
499             {
500                rlcUlCfg |= RLC_GEN_CFG;
501                break;
502             }
503          case STRGUSAP:
504             {
505                numRlcMacSaps++;
506                if(numRlcMacSaps == DEFAULT_CELLS)
507                {
508                   rlcUlCfg |= RLC_MAC_SAP_CFG;
509                   numRlcMacSaps = 0;
510                }
511                break;
512             }
513          case STUDXSAP:
514             {
515                rlcUlCfg |= RLC_UDX_SAP_CFG;
516                break;
517
518             }
519          default:
520             break;
521       }
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)
524       {
525           rlcUlCfg = 0;
526           numRlcMacSaps = 0;
527           //Start configuration of RLC DL
528           duSendRlcDlCfg();
529
530       }
531    }
532    else
533    {
534       DU_LOG("\nDU_APP : Config confirm NOK from RLC UL");
535       ret = RFAILED;
536    }
537    return ret;
538 }
539
540 /**************************************************************************
541  * @brief Function to handle Config Confirm from RLC DL
542  *
543  * @details
544  *
545  *      Function : duHdlRlcDlCfgComplete 
546  * 
547  *      Functionality:
548  *           Handles Config Confirm from RLC DL
549  *     
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
553  *         RFAILED - failure
554  *
555  ***************************************************************************/
556 S16 duProcRlcDlCfgComplete(Pst *pst, KwMngmt *cfm)
557 {
558    DU_LOG("\nDU_APP : RLC DL Cfg Status %d", cfm->cfm.status);
559    if (cfm->cfm.status == LCM_PRIM_OK)
560    {
561       switch(cfm->hdr.elmId.elmnt)
562       {
563          case STGEN:
564             {
565                rlcDlCfg |= RLC_GEN_CFG;
566                break;
567             }
568          case STRGUSAP:
569             {
570                numRlcMacSaps++;
571                if(numRlcMacSaps == DEFAULT_CELLS)
572                {
573                   rlcDlCfg |= RLC_MAC_SAP_CFG;
574                   numRlcMacSaps = 0;
575                }
576                break;
577             }
578          case STUDXSAP:
579             {
580                rlcDlCfg |= RLC_UDX_SAP_CFG;
581                break;
582
583             }
584          default:
585             break;
586
587       }
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)
590       {
591           rlcDlCfg = 0;
592           //Start configuration of MAC
593           duSendMacCfg();
594
595       }
596    }
597    else
598    {
599       DU_LOG("\nDU_APP : Config confirm NOK from RLC DL");
600    }
601    return ROK;
602 }
603
604 /**************************************************************************
605  * @brief Function to send configs to MAC
606  *
607  * @details
608  *
609  *      Function : duSendMacCfg 
610  * 
611  *      Functionality:
612  *           Initiates Configs towards MAC layer
613  *     
614  * @param[in]  void
615  * @return ROK     - success
616  *         RFAILED - failure
617  *
618  ***************************************************************************/
619 S16 duSendMacCfg()
620 {
621    duBuildMacGenCfg();
622    duBuildMacUsapCfg(RLC_UL_INST);
623    duBuildMacUsapCfg(RLC_DL_INST);
624
625    return ROK;
626 }
627
628 /**************************************************************************
629  * @brief Function to fill gen config required by MAC
630  *
631  * @details
632  *
633  *      Function : duBuildMacGenCfg 
634  * 
635  *      Functionality:
636  *           Initiates general Configs towards MAC
637  *     
638  * @param[in] void
639  * @return ROK     - success
640  *         RFAILED - failure
641  *
642  ***************************************************************************/
643 S16 duBuildMacGenCfg()
644 {
645    RgMngmt       rgMngmt;
646    RgGenCfg      *genCfg=NULLP;
647    Pst           pst;
648
649    DU_SET_ZERO(&pst, sizeof(Pst));
650    DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
651
652    genCfg   = &(rgMngmt.t.cfg.s.genCfg);
653    
654    /*----------- Fill General Configuration Parameters ---------*/
655    genCfg->mem.region = RG_MEM_REGION;
656    genCfg->mem.pool   = RG_POOL;
657    genCfg->tmrRes     = 10;
658    genCfg->numRguSaps = 2;
659
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;
671
672     /* Fill Header */
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;
681
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;
687
688    /* Fill Pst */
689    pst.selector  = DU_SELECTOR_LC;
690    pst.srcEnt    = ENTDUAPP;
691    pst.dstEnt    = ENTRG;
692    pst.dstInst   = macCfgInst;
693    pst.dstProcId = DU_PROC;
694    pst.srcProcId = DU_PROC;
695    pst.region = duCb.init.region;
696
697    DU_LOG("\nDU_APP : MAC Gen Cfg Req sent");
698
699    /* Send the request to MAC */
700    cmPkLrgCfgReq(&pst, &rgMngmt);
701
702    return ROK;
703 }
704
705 /**************************************************************************
706  * @brief Function to fill USAP config required by MAC
707  *
708  * @details
709  *
710  *      Function : duBuildMacUsapCfg 
711  * 
712  *      Functionality:
713  *           Initiates USAP Configs towards MAC
714  *     
715  * @param[in] SpId  Specifies if RLC UL or RLC DL instance 
716  * @return ROK     - success
717  *         RFAILED - failure
718  *
719  ***************************************************************************/
720 S16 duBuildMacUsapCfg(SpId sapId)
721 {
722    RgMngmt     rgMngmt;
723    RgUpSapCfg  *uSap = NULLP;
724    Pst         pst;
725
726    DU_SET_ZERO(&pst, sizeof(Pst));
727    DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
728
729    uSap   = &(rgMngmt.t.cfg.s.rguSap);
730
731    uSap->mem.region = RG_MEM_REGION;
732    uSap->mem.pool   = RG_POOL;
733    uSap->suId       = 0;
734    uSap->spId       = sapId;
735    uSap->procId     = DU_PROC;
736    uSap->ent        = ENTKW;
737    uSap->inst       = sapId;
738    uSap->prior      = PRIOR0;
739    uSap->route      = RTESPEC;
740    uSap->selector   = DU_SELECTOR_LC ;
741
742    /* fill header */
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;
749    
750    /* fill pst */
751    pst.selector  = DU_SELECTOR_LC;
752    pst.srcEnt    = ENTDUAPP;
753    pst.dstEnt    = ENTRG;
754    pst.dstInst   = macCfgInst;
755    pst.dstProcId = DU_PROC;
756    pst.srcProcId = DU_PROC;
757    pst.region    = duCb.init.region;
758
759    DU_LOG("\nDU_APP : MAC Rgu USap Cfg Req sent");
760
761    /* Send the request to MAC */
762    cmPkLrgCfgReq(&pst, &rgMngmt);
763
764    return ROK;
765 }
766
767 /**************************************************************************
768  * @brief Function to handle Config Confirm from MAC
769  *
770  * @details
771  *
772  *      Function : duHdlMacCfgComplete 
773  * 
774  *      Functionality:
775  *           Handles Gen Config Confirm from MAC
776  *     
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
780  *         RFAILED - failure
781  *
782  ***************************************************************************/
783 S16 duHdlMacCfgComplete(Pst *pst, RgMngmt *cfm)
784 {
785    S16 ret = ROK;
786
787    if (cfm->cfm.status == LCM_PRIM_OK)
788    {
789       switch (cfm->hdr.elmId.elmnt)
790       {
791          case STGEN:
792             {
793                macCfg |= MAC_GEN_CFG;
794                break;
795             }
796          case STRGUSAP:
797             {
798                macCfg |= MAC_SAP_CFG;
799                numRlcMacSaps++;
800                break;
801             }
802          default:
803             break;
804       }
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)
807       {
808          macCfg = 0;
809          DU_LOG("\nDU_APP : Completed sending Configs");
810          macCfgInst = 0;
811          duBindUnbindRlcToMacSap(RLC_DL_INST, ABND);
812       }
813
814    }
815    else
816    {
817       DU_LOG("\nDU_APP : Config confirm NOK from MAC");
818       ret = RFAILED;
819    }
820    return ret;
821 }
822
823 /**************************************************************************
824  * @brief Function to bind/unbind RLC to MAC SAP
825  *
826  * @details
827  *
828  *      Function : duBindUnbindRlcToMacSap 
829  * 
830  *      Functionality:
831  *           Initiates Bind/Unbind from RLC to MAC
832  *     
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
836  *         RFAILED - failure
837  *
838  ***************************************************************************/
839 S16 duBindUnbindRlcToMacSap(U8 inst, U8 action)
840 {
841    KwCntrl  *cntrl = NULLP;
842    KwMngmt  kwMngmt;
843    Pst      pst;
844
845    TRC2(smBindKwToRguSap)
846
847    DU_SET_ZERO(&kwMngmt, sizeof(KwMngmt));
848    DU_SET_ZERO(&pst, sizeof(Pst));
849
850    if (action == ABND)
851    {
852       DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to bind MAC sap", inst);
853    }
854    else
855    {
856       DU_LOG("\nDU_APP : Cntrl Req to RLC inst %d to unbind MAC sap", inst);
857    }
858    cntrl = &(kwMngmt.t.cntrl);
859
860    cntrl->action            =  action;
861    cntrl->subAction         =  DU_ZERO_VAL;
862    cntrl->s.sapCntrl.suId   =  macCfgInst;
863    cntrl->s.sapCntrl.spId   =  inst;
864
865    /* Fill header */
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;
873
874    /* Fill pst */
875    pst.selector  = DU_SELECTOR_LC;
876    pst.srcEnt    = ENTDUAPP;
877    pst.dstEnt    = ENTKW;
878    pst.dstProcId = DU_PROC;
879    pst.dstInst   = inst;
880    pst.srcProcId = DU_PROC;
881    pst.region    = duCb.init.region;
882
883    cmPkLkwCntrlReq(&pst, &kwMngmt);
884
885    return ROK;
886 }
887 /*******************************************************************
888  *
889  * @brief  Function to start SCTP
890  *
891  * @details
892  *
893  *    Function : duSctpStartReq
894  *
895  *    Functionality:
896  *       Function to start SCTP
897  *
898  * @params[in] 
899  * @return ROK     - success
900  *         RFAILED - failure
901  *
902  * ****************************************************************/
903 S16 duSctpStartReq()
904 {
905    Pst pst;
906
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;
916    pst.pool= DU_POOL;
917
918    cmPkSctpAssocReq(&pst, duCfgParam.sctpParams);
919
920    RETVALUE(ROK);
921 }
922
923 /*******************************************************************
924  *
925  * @brief Handles SCTP notifications
926  *
927  * @details
928  *
929  *    Function : duSctpNtfyHdl
930  *
931  *    Functionality:
932  *         Handles SCTP notification
933  *
934  * @params[in] Message Buffer
935  *             SCTP notification
936  *
937  * @return ROK     - success
938  *         RFAILED - failure
939  *
940  * ****************************************************************/
941
942 S16 duSctpNtfyHdl(Buffer *mBuf, CmInetSctpNotification *ntfy)
943 {
944    switch(ntfy->header.nType)
945    {
946       case CM_INET_SCTP_ASSOC_CHANGE:
947          switch(ntfy->u.assocChange.state)
948          {
949             case CM_INET_SCTP_COMM_UP:
950                {
951                   DU_LOG("\nDU_APP : SCTP communication UP");
952                   //Setup F1-C
953                   if(!duCb.f1Status)
954                   {
955                      /* Build and send F1 Setup response */
956                      if(BuildAndSendF1SetupReq() != ROK)
957                      {
958                         RETVALUE(RFAILED);
959                      }
960                   }
961                   else
962                   {
963                      //Only SCTP is down, when SCTP comes up again, no need to
964                      //start from setting up F1 link
965                   }
966                   break;
967                }
968          }
969          break;
970    }
971    RETVALUE(ROK);
972 }
973
974 /*******************************************************************
975  *
976  * @brief  Fills Pst struct for ENTEGTP
977  *
978  * @details
979  *
980  *    Function : duFillEgtpPst
981  *
982  *    Functionality:
983  *       Fills Pst struct for ENTEGTP
984  *
985  * @params[in] 
986  * @return ROK     - success
987  *         RFAILED - failure
988  *
989  * ****************************************************************/
990 S16 duFillEgtpPst(Pst *pst, Event event)
991 {
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;
999    pst->event = event;
1000    pst->selector = DU_SELECTOR_LC;
1001    pst->pool= DU_POOL;
1002   
1003    RETVALUE(ROK);
1004 }
1005
1006
1007 /*******************************************************************
1008  *
1009  * @brief  Function to configure EGTP
1010  *
1011  * @details
1012  *
1013  *    Function : duBuildEgtpCfgReq
1014  *
1015  *    Functionality:
1016  *       Function to configure EGTP
1017  *
1018  * @params[in] 
1019  * @return ROK     - success
1020  *         RFAILED - failure
1021  *
1022  * ****************************************************************/
1023
1024 S16 duBuildEgtpCfgReq()
1025 {
1026     Pst pst;
1027     EgtpConfig egtpCfg;
1028     
1029     DU_LOG("\nDU_APP : Sending EGTP config request");
1030
1031     cmMemset((U8 *)&egtpCfg, 0, sizeof(EgtpConfig));
1032     cmMemcpy((U8 *)&egtpCfg, (U8 *)&duCfgParam.egtpParams, (PTR)sizeof(EgtpConfig));
1033     
1034     duFillEgtpPst(&pst, EVTCFGREQ);
1035     cmPkEgtpCfgReq(&pst, egtpCfg);
1036  
1037     RETVALUE(ROK);
1038 }
1039
1040 /*******************************************************************
1041  *
1042  * @brief  Function to configure EGTP
1043  *
1044  * @details
1045  *
1046  *    Function : duBuildEgtpCfgReq
1047  *
1048  *    Functionality:
1049  *       Function to configure EGTP
1050  *
1051  * @params[in] 
1052  * @return ROK     - success
1053  *         RFAILED - failure
1054  *
1055  * ****************************************************************/
1056 S16 duHdlEgtpCfgComplete(CmStatus cfm)
1057 {
1058    S16 ret = ROK;
1059
1060    if(cfm.status == LCM_PRIM_OK)
1061    {
1062       DU_LOG("\nDU_APP : EGTP configuraton complete");
1063 #ifdef EGTP_TEST
1064       duSendEgtpSrvOpenReq();
1065 #endif
1066    }
1067    else
1068    {
1069       DU_LOG("\nDU_APP : EGTP configuraton failed");
1070       ret = RFAILED;
1071    }
1072
1073    RETVALUE(ret);
1074 }
1075
1076 /*******************************************************************
1077  *
1078  * @brief  Sends server open request to EGTP
1079  *
1080  * @details
1081  *
1082  *    Function : duSendEgtpSrvOpenReq
1083  *
1084  *    Functionality:
1085  *       Sends server open request to EGTP
1086  *
1087  * @params[in] 
1088  * @return ROK     - success
1089  *         RFAILED - failure
1090  *
1091  * ****************************************************************/
1092  
1093 S16 duSendEgtpSrvOpenReq()
1094 {
1095    Pst pst;
1096
1097    DU_LOG("\nDU_APP : Sending EGTP server open request");
1098
1099    duFillEgtpPst(&pst, EVTSRVOPENREQ);
1100    cmPkEgtpSrvOpenReq(&pst);
1101
1102    RETVALUE(ROK);
1103 }
1104
1105 /*******************************************************************
1106  *
1107  * @brief Handles server open confirmation
1108  *
1109  * @details
1110  *
1111  *    Function : duHdlEgtpSrvOpenComplete
1112  *
1113  *    Functionality:
1114  *        Handles server open confirmation
1115  *
1116  * @params[in] 
1117  * @return ROK     - success
1118  *         RFAILED - failure
1119  *
1120  *****************************************************************/
1121
1122 S16 duHdlEgtpSrvOpenComplete(CmStatus cfm)
1123 {
1124     S16 ret = ROK;
1125  
1126     if(cfm.status == LCM_PRIM_OK)
1127     {
1128        DU_LOG("\nDU_APP : EGTP server opened successfully");
1129 #ifdef EGTP_TEST
1130        duSendEgtpTnlMgmtReq(EGTP_TNL_MGMT_ADD, EGTP_LCL_TEID, EGTP_REM_TEID);
1131 #endif
1132     }
1133     else
1134     {
1135        DU_LOG("\nDU_APP : EGTP server opening failed");
1136        ret = RFAILED;
1137     }
1138  
1139     RETVALUE(ret);
1140 }
1141
1142 /*******************************************************************
1143  *
1144  * @brief Sends tunnel management request
1145  *
1146  * @details
1147  *
1148  *    Function : duSendEgtpTnlMgmtReq 
1149  *
1150  *    Functionality:
1151  *        Builds and sends tunnel management request to EGTP
1152  *
1153  * @params[in] Action
1154  *             Local tunnel endpoint id
1155  *             Remote tunnel endpoint id 
1156  * @return ROK     - success
1157  *         RFAILED - failure
1158  *
1159  * ****************************************************************/
1160
1161 S16 duSendEgtpTnlMgmtReq(U8 action, U32 lclTeid, U32 remTeid)
1162 {
1163    Pst pst;
1164    EgtpTnlEvt tnlEvt;
1165
1166    tnlEvt.action = action;
1167    tnlEvt.lclTeid = lclTeid;
1168    tnlEvt.remTeid = remTeid;
1169     
1170    DU_LOG("\nDU_APP : Sending EGTP tunnel management request");
1171     
1172    duFillEgtpPst(&pst, EVTTNLMGMTREQ);
1173    cmPkEgtpTnlMgmtReq(&pst, tnlEvt);
1174     
1175    RETVALUE(ROK);
1176 }
1177
1178 /*******************************************************************
1179  *
1180  * @brief Handles Tunnel management confirm 
1181  *
1182  * @details
1183  *
1184  *    Function : duHdlEgtpTnlMgmtCfm
1185  *
1186  *    Functionality:
1187  *      Handles tunnel management confirm received from Egtp
1188  *
1189  * @params[in] Tunnel Event  
1190  * @return ROK     - success
1191  *         RFAILED - failure
1192  *
1193  * ****************************************************************/
1194 S16 duHdlEgtpTnlMgmtCfm(EgtpTnlEvt tnlEvtCfm)
1195 {
1196    S16 ret = ROK;
1197
1198    if(tnlEvtCfm.cfmStatus.status == LCM_PRIM_OK)
1199    {
1200       DU_LOG("\nDU_APP : Tunnel management confirm OK");
1201
1202 #ifdef EGTP_TEST
1203       duSendEgtpDatInd();
1204       
1205       /* For testing purpose. TTI thread should actually be in L1 */
1206       duStartTtiThread();
1207 #endif      
1208    }
1209    else
1210    {
1211       DU_LOG("\nDU_APP : Tunnel management failed");
1212       ret = RFAILED;
1213    }
1214
1215    RETVALUE(ret);
1216 }
1217
1218 #ifdef EGTP_TEST
1219 /*******************************************************************
1220  *
1221  * @brief Simulate RLC to EGTP data indication 
1222  *
1223  * @details
1224  *
1225  *    Function : duSendEgtpDatInd
1226  *
1227  *    Functionality:
1228  *      Simulate RLC to EGTP data indication
1229  *
1230  * @params[in] 
1231  * @return ROK     - success
1232  *         RFAILED - failure
1233  *
1234  * ****************************************************************/
1235 S16 duSendEgtpDatInd()
1236 {
1237    char data[30] = "This is EGTP data from DU";
1238    int datSize = 30;
1239
1240    Buffer   *mBuf;
1241    EgtpMsg  egtpMsg;
1242
1243    if(SGetMsg(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1244    {
1245       if(SAddPstMsgMult((Data *)data, datSize, mBuf) == ROK)
1246       {
1247          SPrntMsg(mBuf, 0,0);
1248       }
1249       else
1250       {
1251          DU_LOG("\nDU_APP : SAddPstMsgMult failed");
1252          SPutMsg(mBuf);
1253          RETVALUE(RFAILED);
1254       }
1255    }
1256    else
1257    {
1258       DU_LOG("\nDU_APP : Failed to allocate memory");
1259       RETVALUE(RFAILED);
1260    }
1261
1262    /* filling IPv4 header */ 
1263    CmIpv4Hdr ipv4Hdr;
1264    MsgLen    mLen;
1265
1266    mLen = 0;
1267    SFndLenMsg(mBuf, &mLen);
1268
1269    cmMemset((U8 *)&ipv4Hdr, 0, sizeof(CmIpv4Hdr));
1270    ipv4Hdr.length = CM_IPV4_HDRLEN + mLen;
1271    ipv4Hdr.hdrVer = 0x45;
1272    ipv4Hdr.proto = 1;
1273    ipv4Hdr.srcAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.localIp.ipV4Addr);
1274    ipv4Hdr.destAddr = CM_INET_NTOH_U32(duCfgParam.egtpParams.destIp.ipV4Addr);
1275
1276    /* Packing IPv4 header into buffer */
1277    S16          ret, cnt, idx;
1278    Data         revPkArray[CM_IPV4_HDRLEN];
1279    Data         pkArray[CM_IPV4_HDRLEN];
1280  
1281    /* initialize locals */
1282    cnt = 0;
1283    cmMemset(revPkArray, 0, CM_IPV4_HDRLEN);
1284    cmMemset(pkArray, 0, CM_IPV4_HDRLEN);
1285
1286    /* Pack Header Version */
1287    pkArray[cnt++] = ipv4Hdr.hdrVer;
1288
1289    /* Pack TOS */
1290    pkArray[cnt++] = ipv4Hdr.tos;
1291
1292    pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.length);
1293    pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.length);
1294
1295    /* Pack Id */
1296    pkArray[cnt++] = (Data) GetHiByte(ipv4Hdr.id);
1297    pkArray[cnt++] = (Data) GetLoByte(ipv4Hdr.id);
1298
1299    /* Pack Offset */
1300    pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.off);
1301    pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.off);
1302
1303    /* Pack TTL */
1304    pkArray[cnt++] = ipv4Hdr.ttl;
1305
1306    /* Pack Protocol */
1307    pkArray[cnt++] = ipv4Hdr.proto;
1308
1309    /* Pack Checksum */
1310    pkArray[cnt++] = (Data)GetHiByte(ipv4Hdr.chkSum);
1311    pkArray[cnt++] = (Data)GetLoByte(ipv4Hdr.chkSum);
1312
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));
1318
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));
1324
1325    for (idx = 0;  idx < CM_IPV4_HDRLEN;  idx++)
1326       revPkArray[idx] = pkArray[CM_IPV4_HDRLEN - idx -1];
1327
1328    /* this function automatically reverses revPkArray */
1329    ret = SAddPreMsgMult(revPkArray, (MsgLen)cnt, mBuf);
1330
1331
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;
1338    egtpMsg.msg = mBuf;
1339
1340    SPrntMsg(mBuf, 0, 0);
1341
1342    egtpHdlDatInd(egtpMsg);
1343  
1344    RETVALUE(ROK);
1345 }
1346 #endif /* EGTP_TEST */
1347
1348
1349 /**************************************************************************
1350  * @brief Function to send configs to SCH
1351  *
1352  * @details
1353  *
1354  *      Function : duSendSchCfg 
1355  * 
1356  *      Functionality:
1357  *           Sends general config to Scheduler via MAC layer
1358  *     
1359  * @param[in]  void
1360  * @return ROK     - success
1361  *         RFAILED - failure
1362  *
1363  ***************************************************************************/
1364 S16 duSendSchCfg()
1365 {
1366    RgMngmt       rgMngmt;
1367    RgSchInstCfg  *cfg = NULLP;
1368    Pst           pst;
1369
1370    DU_SET_ZERO(&pst, sizeof(Pst));
1371    DU_SET_ZERO(&rgMngmt, sizeof(RgMngmt));
1372
1373    cfg = &(rgMngmt.t.cfg.s.schInstCfg);
1374
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;
1381
1382 #ifdef LTE_ADV
1383    cfg->genCfg.forceCntrlSrbBoOnPCel = FALSE;
1384    cfg->genCfg.isSCellActDeactAlgoEnable = TRUE;
1385 #endif/*LTE_ADV*/
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;
1398
1399    /* Fill Header */
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;
1406
1407    /* Fill Pst */
1408    pst.selector  = DU_SELECTOR_LC;
1409    pst.srcEnt    = ENTDUAPP;
1410    pst.dstEnt    = ENTRG;
1411    pst.dstProcId = DU_PROC;
1412    pst.srcProcId = DU_PROC;
1413    pst.srcInst   = DU_INST;
1414    pst.dstInst   = 0;
1415    pst.region    = duCb.init.region;
1416    pst.event    = (Event) EVTMACSCHGENCFGREQ;
1417
1418    DU_LOG("\nDU_APP : MAC Sch Cfg sent");
1419
1420    /* Send the request to MAC */
1421    cmPkLrgSchCfgReq(&pst, &rgMngmt);
1422
1423    return ROK;
1424 }
1425
1426 /**************************************************************************
1427  * @brief Function to handle  SCH Config Confirm from MAC
1428  *
1429  * @details
1430  *
1431  *      Function : duHdlSchCfgComplete 
1432  * 
1433  *      Functionality:
1434  *           Handles Scheduler Gen Config Confirm from MAC
1435  *     
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
1439  *         RFAILED - failure
1440  *
1441  ***************************************************************************/
1442 S16 duHdlSchCfgComplete(Pst *pst, RgMngmt *cfm)
1443 {
1444    if (cfm->cfm.status == LCM_PRIM_OK)
1445    {
1446       switch (cfm->hdr.elmId.elmnt)
1447       {
1448          case STSCHINST:
1449             {
1450                DU_LOG("\nDU_APP : Received SCH CFG CFM at DU APP");
1451                break;
1452             }
1453          default:
1454             break;
1455       }
1456    }
1457    duSctpStartReq();
1458
1459    duBuildEgtpCfgReq();
1460    return ROK;
1461 }
1462
1463 /*******************************************************************
1464  *
1465  * @brief Handles TTI indication 
1466  *
1467  * @details
1468  *
1469  *    Function : duSendEgtpTTIInd
1470  *
1471  *    Functionality:
1472  *     Handles TTI indication received from PHY
1473  *
1474  * @params[in] 
1475  * @return ROK     - success
1476  *         RFAILED - failure
1477  *
1478  * ****************************************************************/
1479 S16 duSendEgtpTTIInd()
1480 {
1481    Pst pst;
1482
1483    duFillEgtpPst(&pst, EVTTTIIND);
1484    cmPkEgtpTTIInd(&pst);
1485    
1486    RETVALUE(ROK);
1487    
1488 }
1489 /**********************************************************************
1490   End of file
1491  **********************************************************************/