Initial commit for Bronze release
[o-du/l2.git] / src / 5gnrsch / rg_sch.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 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Entry point fucntions
26   
27      File:     rg_sch.c
28   
29 **********************************************************************/
30
31 /** @file rg_sch.c
32 @brief This file implements the schedulers main access to MAC layer code.
33 */
34
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=185;
37 static int RLOG_MODULE_ID=4096;
38
39 /* header include files -- defines (.h) */
40 #include "envopt.h"        /* environment options */
41 #include "envdep.h"        /* environment dependent */
42 #include "envind.h"        /* environment independent */
43 #include "gen.h"           /* general layer */
44 #include "ssi.h"           /* system service interface */
45 #include "cm_hash.h"       /* common hash list */
46 #include "cm_llist.h"      /* common linked list library */
47 #include "cm_err.h"        /* common error */
48 #include "cm_lte.h"        /* common LTE */
49 #include "lrg.h"
50 #include "rgr.h"
51 #include "tfu.h"
52 #include "rgm.h"
53 #include "rg_env.h"
54 #include "rg_sch_inf.h"
55 #include "rg_sch.h"
56 #include "rg_sch_err.h"
57 #include "rg_sch_cmn.h"
58 #include "rl_interface.h"
59 #include "rl_common.h"
60
61 /* header/extern include files (.x) */
62 #include "gen.x"           /* general layer typedefs */
63 #include "ssi.x"           /* system services typedefs */
64 #include "cm5.x"           /* common timers */
65 #include "cm_hash.x"       /* common hash list */
66 #include "cm_lib.x"        /* common library */
67 #include "cm_llist.x"      /* common linked list */
68 #include "cm_mblk.x"       /* memory management */
69 #include "cm_tkns.x"       /* common tokens */
70 #include "cm_lte.x"       /* common tokens */
71 #include "tfu.x"           /* TFU types */
72 #include "lrg.x"           /* layer management typedefs for MAC */
73 #include "rgr.x"           /* layer management typedefs for MAC */
74 #include "rgm.x"           /* layer management typedefs for MAC */
75 #include "rg_sch_inf.x"         /* typedefs for Scheduler */
76 #include "rg_sch.x"        /* typedefs for Scheduler */
77 #include "rg_sch_cmn.x"
78
79 #ifdef EMTC_ENABLE
80 EXTERN S16 rgEmtcMacSchUeDelInd ARGS((RgSchCellCb *cell,RgInfUeDelInd *ueDelInd));
81 EXTERN S16 rgSCHGomEmtcHndlSiCfg ARGS((
82 Region        reg,
83 Pool          pool,
84 RgSchCb       *instCb,
85 SpId          spId,
86 RgrCfgTransId transId,
87 RgrSiCfgReqInfo *cfgReqInfo
88 ));
89 EXTERN S16 rgSCHGomEmtcHndlWarningSiCfg ARGS((
90 Region        reg,
91 Pool          pool,
92 RgSchCb       *instCb,
93 SpId          spId,
94 RgrCfgTransId transId,
95 RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
96 ));
97 #endif
98 /* local defines */
99 /************** LRG Interface ****************/
100 /**
101  * @brief Layer Manager Configuration request handler. 
102  *
103  * @details
104  *
105  *     Function : HandleSchGenCfgReq
106  *     
107  *     This function handles the configuration
108  *     request received at scheduler instance from the Layer Manager.
109  *     -# Based on the cfg->hdr.elmId.elmnt value it invokes one of the
110  *        functions rgHdlGenCfg() or rgHdlSapCfg().
111  *     -# Invokes RgMiLrgSchCfgCfm() to send back the confirmation to the LM.
112  *     
113  *  @param[in]  Pst *pst, the post structure     
114  *  @param[in]  RgMngmt *cfg, the configuration parameter's structure
115  *  @return  S16
116  *      -# ROK
117  **/
118 #ifdef ANSI
119 PUBLIC S16 HandleSchGenCfgReq
120 (
121 Pst      *pst,    /* post structure  */
122 RgMngmt  *cfg     /* config structure  */
123 )
124 #else
125 PUBLIC S16 HandleSchGenCfgReq(pst, cfg)
126 Pst      *pst;    /* post structure  */
127 RgMngmt  *cfg;    /* config structure  */
128 #endif    
129 {
130    U16       ret = LCM_PRIM_OK;
131    U16       reason = LCM_REASON_NOT_APPL;
132    RgMngmt   cfm;
133    Pst       cfmPst;
134 #ifdef DEBUGP
135    Inst      inst = (pst->dstInst  - SCH_INST_START);
136 #endif
137
138    TRC3(HandleSchGenCfgReq)
139    
140
141    if(pst->dstInst < SCH_INST_START)
142    {
143       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Invalid inst ID");
144       RLOG_ARG2(L_DEBUG,DBG_INSTID,inst, "HandleSchGenCfgReq(): "
145                         "pst->dstInst=%d SCH_INST_START=%d", pst->dstInst,SCH_INST_START); 
146       RETVALUE(ROK);
147    }
148    printf("\nReceived scheduler gen config");
149    /* Fill the post structure for sending the confirmation */
150    SchFillCfmPst(pst, &cfmPst, cfg);
151
152    /* Initialize the cfg cfm structure 
153    if (SGetSBuf(cfmPst.region, cfmPst.pool, (Data **)&cfm, sizeof(RgMngmt))
154       != ROK)
155    {
156       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Memory Unavailable for Confirmation");
157       RETVALUE(ROK);
158    } */
159    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
160
161 #ifdef LMINT3
162    cfm.hdr.transId =
163       cfg->hdr.transId;
164 #endif
165
166    cfm.hdr.elmId.elmnt = cfg->hdr.elmId.elmnt;
167    switch(cfg->hdr.elmId.elmnt)
168    {
169       case STSCHINST:
170          reason = SchInstCfg(&cfg->t.cfg,pst->dstInst );
171          break;
172       default:
173          ret = LCM_PRIM_NOK;
174          reason = LCM_REASON_INVALID_ELMNT;
175          RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "Invalid Elmnt=%d", cfg->hdr.elmId.elmnt);
176          break;
177    }
178
179    if (reason != LCM_REASON_NOT_APPL)
180    {
181       ret = LCM_PRIM_NOK;
182    }
183
184    cfm.cfm.status = ret;
185    cfm.cfm.reason = reason;
186
187    SchSendCfgCfm(&cfmPst, &cfm);
188    /*   SPutSBuf(pst->region, pst->pool, (Data *)cfg, sizeof(RgMngmt)); */
189    
190    RETVALUE(ROK);
191 }/*-- HandleSchGenCfgReq --*/
192
193 \f
194 /**
195  * @brief Layer Manager Control request handler. 
196  *
197  * @details
198  *
199  *     Function : RgMiLrgSchCntrlReq
200  *     
201  *     This function handles the control
202  *     request received from the Layer Manager.
203  *      -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
204  *      and cntrl->t.cntrl.subAction, it performs the appropriate control action
205  *      of SAP (enable/disable) and layer shutdown.
206  *      -# Invokes the RgMiLrgSchCntrlCfm to send back the confirmation to LM.
207  *     
208  *  @param[in]  Pst *pst, the post structure     
209  *  @param[in]  RgMngmt *cntrl, the control parameter's structure
210  *  @return  S16
211  *      -# ROK
212  **/
213 #ifdef ANSI
214 PUBLIC S16 RgMiLrgSchCntrlReq
215 (
216 Pst      *pst,    /* post structure  */
217 RgMngmt  *cntrl   /* control structure  */
218 )
219 #else
220 PUBLIC S16 RgMiLrgSchCntrlReq(pst, cntrl)
221 Pst      *pst;    /* post structure  */
222 RgMngmt  *cntrl;  /* control structure  */
223 #endif    
224 {
225    S16       ret = ROK;            /* return value */
226    Pst       cfmPst;
227    RgMngmt   cfm;
228    
229    Inst      inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
230    TRC3(RgMiLrgSchCntrlReq)
231    
232
233    /* Fill the post structure for sending the confirmation */
234    SchFillCfmPst(pst, &cfmPst, cntrl);
235
236    /* Initialize the cfg cfm structure 
237    if (SGetSBuf(cfmPst.region, cfmPst.pool, (Data **)&cfm, sizeof(RgMngmt))
238       != ROK)
239    {
240       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Memory Unavailable for Confirmation");
241       SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt));
242       RETVALUE(ROK);
243    } */
244    cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt));
245
246 #ifdef LMINT3
247    cfm.hdr.transId =
248       cntrl->hdr.transId;
249 #endif
250
251    cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
252    cfm.t.cntrl.action = cntrl->t.cntrl.action;
253    cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
254
255    /* Check if General Config Done*/
256    if(rgSchCb[inst].rgSchInit.cfgDone != TRUE)
257    {
258       cfm.cfm.status = LCM_PRIM_NOK;
259       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
260       cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
261       RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
262       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Gen Cfg not done.");
263       /*      SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt)); */
264       RETVALUE(ROK);
265    }
266
267    /* General Config done, process the Control request */   
268    switch(cntrl->hdr.elmId.elmnt)
269    {
270       case STGEN:
271          rgSCHLmmGenCntrl(cntrl, &cfm, &cfmPst);
272          break;
273       case STTFUSAP:
274       case STRGRSAP:
275          rgSCHLmmSapCntrl(cntrl, &cfm, &cfmPst);
276          break;
277       default:
278          cfm.cfm.status = LCM_PRIM_NOK;
279          cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
280          RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
281          RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "invalid elmnt=%d",
282                   cntrl->hdr.elmId.elmnt);
283          break;
284    }
285    /*   SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt)); */
286    RETVALUE(ret);
287 }/*-- RgMiLrgSchCntrlReq --*/
288
289 #ifdef LTE_L2_MEAS
290 /**
291  * @brief Layer Manager L2 Measurement request handler. 
292  *
293  * @details
294  *
295  *     Function : RgMiLrgSchL2MeasReq
296  *     
297  *     This function handles the control
298  *     measurement request received from the Layer Manager.
299  *     
300  *  @param[in]  Pst *pst, the post structure     
301  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement request info
302  *  @return  S16
303  *      -# ROK
304  **/
305 #ifdef ANSI
306 PUBLIC S16 RgMiLrgSchL2MeasReq
307 (
308 Pst               *pst,     /* post structure  */
309 LrgSchMeasReqInfo *measInfo /* Meas Req Info */
310 )
311 #else
312 PUBLIC S16 RgMiLrgSchL2MeasReq(pst, measInfo)
313    Pst               *pst;     /* post structure  */
314    LrgSchMeasReqInfo *measInfo; /* Meas Req Info */
315 #endif    
316 {
317    Pst                 cfmPst;
318    RgSchCellCb         *cell;
319    RgSchErrInfo        err;
320    S16                 ret = ROK; 
321    RgSchCb             *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
322 #if (ERRCLASS & ERRCLS_ADD_RES) 
323    CmLList             *lnk;
324 #endif
325    U32                 idx;
326    RgSchL2MeasCb       *measCb = NULLP;
327 #ifdef DEBUGP
328    Inst      inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
329 #endif
330
331    err.errType  = 0;
332    err.errCause = 0;
333
334    TRC3(RgMiLrgSchL2MeasReq)
335
336
337    /* Find the cellCb using cellId in measInfo. Iterate through all cells
338     * in rgrsapCb in RgschCb */
339    cell = NULLP;
340    for (idx = 0; idx < instCb->numSaps; idx++)
341    {
342       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
343       {
344          /* got the cell break the loop */
345          cell = instCb->rgrSap[idx].cell;
346          break;
347       }
348    }
349    /* If no cellCb return Err with Invalid Cell Id */
350    if (cell == NULLP)
351    {
352       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
353       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_CELLID);
354       rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
355       RLOG_ARG2(L_ERROR,DBG_INSTID,inst, 
356                "Meas req Failed.Invalid Cell Id errType(%d) errCause(%d)",
357                err.errType, err.errCause);
358       RETVALUE(RFAILED);
359    }
360    /* Validate for Meas Types */
361    if ( (ret = rgSCHUtlValidateMeasReq(cell, measInfo, &err)) != ROK)
362    {
363       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
364       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_MEASTYPE);
365       rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
366       RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
367                "Meas req Failed.Invalid Measurement Type"
368                "errCasue(%d) errType(%d)", err.errType, err.errCause);
369       RETVALUE(RFAILED);
370    }
371    /* Iterate through all meas requests in l2mList in cellCb */
372 #if (ERRCLASS & ERRCLS_ADD_RES) 
373    lnk = cell->l2mList.first;
374    while(lnk != NULLP)
375    {
376       /* Get the MeasCb : RgSchL2MeasCb */
377       measCb = (RgSchL2MeasCb *)lnk->node;
378       lnk = lnk->next;
379       if (measCb->measReq.hdr.transId == measInfo->hdr.transId)
380       {
381          rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
382          RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_DUP_TRANSID);
383          rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
384          RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
385                   "Meas req Failed.Dublicate TransId"
386                   "errType(%d) errCause(%d)", err.errType, err.errCause);
387          RETVALUE(RFAILED);
388       }
389    }
390 #endif
391    /* Call L2M Function to store Meas req */
392    ret = rgSchL2mMeasReq(cell, measInfo, err);
393    if (ret != ROK)
394    {
395       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
396       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_L2MEAS_FAILED);
397       rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
398       RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId, 
399                "Meas req Failed.errType(%d) errCause(%d)",
400                err.errType, err.errCause);
401       RETVALUE(RFAILED);
402    }
403    RETVALUE(ret);
404 } /* -- RRgMiLrgSchL2MeasReq-- */
405
406 /**
407  * @brief Layer Manager L2 Measurement Stop request handler. 
408  *
409  * @details
410  *
411  *     Function : RgMiLrgSchL2MeasStopReq
412  *     
413  *     This function handles the control
414  *     measurement stop request received from the Layer Manager.
415  *     
416  *  @param[in]  Pst *pst, the post structure     
417  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement stop request info
418  *  @return  S16
419  *      -# ROK
420  **/
421 #ifdef ANSI
422 PUBLIC S16 RgMiLrgSchL2MeasStopReq
423 (
424 Pst               *pst,     /* post structure  */
425 LrgSchMeasStopReqInfo *measInfo /* Meas Req Info */
426 )
427 #else
428 PUBLIC S16 RgMiLrgSchL2MeasStopReq(pst, measInfo)
429    Pst               *pst;     /* post structure  */
430    LrgSchMeasStopReqInfo *measInfo; /* Meas Req Info */
431 #endif
432 {
433    S16                 ret = ROK;
434    RgSchCellCb         *cell = NULLP;
435    RgSchCb             *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
436    CmLList             *node = NULLP;
437    RgSchL2MeasCb       *measCb = NULLP;
438    LrgSchMeasCfmInfo measCfm;
439    U8                  idx;
440
441
442    TRC3(RgMiLrgSchL2MeasStopReq)
443
444
445    for (idx = 0; idx < instCb->numSaps; idx++)
446    {
447       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
448       {
449          /* got the cell break the loop */
450          cell = instCb->rgrSap[idx].cell;
451          break;
452       }
453    }
454    if (cell == NULLP)
455    {
456       RLOG_ARG0(L_ERROR,DBG_CELLID,measInfo->cellId,
457                "Stop req Failed.Invalid Cell Id ");
458       RETVALUE(RFAILED);
459    }
460    cmMemset((U8 *)&measCfm, 0, sizeof(LrgSchMeasCfmInfo));
461    node = cell->l2mList.first;
462    while(node != NULLP)
463    {
464       measCb = (RgSchL2MeasCb *)(node)->node;
465
466       node = (node)->next;
467       cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
468       rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,
469             sizeof(RgSchL2MeasCb));    
470    }
471
472    if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
473    {
474       RgInfL2MeasStopReq measStopReq;
475       Pst               pstMac;
476       cmMemset((U8 *)&measStopReq, 0, sizeof(RgInfL2MeasStopReq));
477       measStopReq.transId  = measInfo->hdr.transId;
478       measStopReq.measType = measInfo->measType;
479       /* measReq.timePrd  = measInfo->timePrd; */
480       measStopReq.cellId   = measInfo->cellId;
481       rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
482       RgSchMacL2MeasStop(&pstMac,&measStopReq);
483    }
484    else
485    { 
486       RgMiLrgSchL2MeasStopCfm(&(rgSchCb[cell->instIdx].rgSchInit.lmPst),
487             &measCfm);
488    }
489    RETVALUE(ret);
490 }/*RgMiLrgSchL2MeasStopReq*/
491 /**
492  * @brief Layer Manager L2 Measurement request handler. 
493  *        for Send l2 measurement req
494  * @details
495  *
496  *     Function : RgMiLrgSchL2MeasSendReq
497  *     
498  *     This function handles the control
499  *     measurement send request received from the Layer Manager.
500  *     
501  *  @param[in]  Pst *pst, the post structure     
502  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement stop request info
503  *  @return  S16
504  *      -# ROK
505  **/
506 #ifdef ANSI
507 PUBLIC S16 RgMiLrgSchL2MeasSendReq
508 (
509 Pst               *pst,     /* post structure  */
510 LrgSchMeasSndReqInfo *measInfo /* Meas Req Info */
511 )
512 #else
513 PUBLIC S16 RgMiLrgSchL2MeasSendReq(pst, measInfo)
514    Pst               *pst;     /* post structure  */
515    LrgSchMeasSndReqInfo *measInfo; /* Meas Req Info */
516 #endif
517 {
518    S16                 ret = ROK;
519    RgSchCellCb         *cell;
520    RgSchCb             *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
521    U8                  idx;
522
523    TRC3(RgMiLrgSchL2MeasSendReq)
524
525
526
527    cell = NULLP;
528    for (idx = 0; idx < instCb->numSaps; idx++)
529    {
530       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
531       {
532          /* got the cell break the loop */
533          cell = instCb->rgrSap[idx].cell;
534          break;
535       }
536    }
537    if (cell == NULLP)
538    {
539       RLOG_ARG0(L_ERROR,DBG_CELLID,measInfo->cellId,
540                "Send req Failed.Invalid Cell Id");
541       RETVALUE(RFAILED);
542    }
543
544    if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
545    {
546       RgInfL2MeasSndReq measSndReq;
547       Pst               pstMac;
548       cmMemset((U8 *)&measSndReq, 0, sizeof(RgInfL2MeasSndReq));
549       measSndReq.transId  = measInfo->hdr.transId;
550       measSndReq.measType = measInfo->measType;
551       measSndReq.timePrd  = measInfo->timePrd;
552       measSndReq.cellId   = measInfo->cellId;
553       rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
554       RgSchMacL2MeasSend(&pstMac, &measSndReq);
555    }
556    else
557    { 
558       cell->sndL2Meas = TRUE;
559    }
560
561    RETVALUE(ret);
562 }/*RgMiLrgSchL2MeasSendReq*/
563 #endif /* LTE_L2_MEAS */
564
565
566
567
568 /************* RGR  Interface ****************/
569 /**
570  * @brief API for bind request from RRM towards MAC. 
571  *
572  * @details
573  *
574  *     Function: RgUiRgrBndReq
575  *     
576  *     This API is invoked by RRM towards MAC to bind RGR SAP. 
577  *     These API validates the Pst, spId, suId and sends the bind confirm to
578  *     RRM.
579  *
580  *           
581  *  @param[in]  Pst   *pst
582  *  @param[in]  SuId  suId
583  *  @param[in]  SpId  spId
584  *  @return  S16
585  *      -# ROK 
586  *      -# RFAILED 
587  **/
588 #ifdef ANSI
589 PUBLIC S16 RgUiRgrBndReq
590 (
591  Pst   *pst, 
592  SuId  suId,
593  SpId  spId
594  )
595 #else
596 PUBLIC S16 RgUiRgrBndReq(pst, suId, spId)
597    Pst   *pst; 
598    SuId  suId;
599    SpId  spId;
600 #endif
601 {
602    S16       ret = ROK;
603    Pst       tmpPst;   /* Temporary Post Structure */
604    Inst      instId = pst->dstInst-SCH_INST_START;
605    RgUstaDgn dgn;      /* Alarm diagnostics structure */
606
607    TRC3(RgUiRgrBndReq)
608
609
610    tmpPst.prior       = pst->prior;
611    tmpPst.route       = pst->route;
612    tmpPst.selector    = pst->selector;
613    tmpPst.region      = rgSchCb[instId].rgSchInit.region;
614    tmpPst.pool        = rgSchCb[instId].rgSchInit.pool;
615    tmpPst.srcProcId   = rgSchCb[instId].rgSchInit.procId;
616    tmpPst.srcEnt      = rgSchCb[instId].rgSchInit.ent;
617    tmpPst.srcInst     = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
618    tmpPst.event       = EVTNONE;
619    tmpPst.dstProcId   = pst->srcProcId;
620    tmpPst.dstEnt      = pst->srcEnt;
621    tmpPst.dstInst     = pst->srcInst;
622
623    if(spId < rgSchCb[instId].numSaps)
624    {
625       /* Check the state of the SAP */
626       switch (rgSchCb[instId].rgrSap[spId].sapSta.sapState)
627       {
628          /* This case might not be needed if SAP not configured then it will go
629           * to else of above if condition */
630          case LRG_UNBND: /* SAP is not bound */
631             RLOG0(L_DEBUG,"SAP Not yet bound");
632             rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_BND;
633             rgSchCb[instId].rgrSap[spId].sapCfg.suId = suId;
634             /* Send Bind Confirm with status as SUCCESS */
635             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
636             /*Indicate to Layer manager  */
637             rgSCHUtlFillDgnParams(instId, &dgn, LRG_USTA_DGNVAL_MEM); 
638             ret = rgSCHLmmStaInd(instId, LCM_CATEGORY_INTERFACE,
639                   LRG_EVENT_RGRSAP_ENB, LCM_CAUSE_UNKNOWN, &dgn);
640             break;
641          case LRG_BND: /* SAP is already bound*/
642             RLOG0(L_DEBUG,"SAP is already bound");
643             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
644             break;
645          default: /* Should Never Enter here */
646 #if (ERRCLASS & ERRCLS_ADD_RES) 
647             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG001, 
648                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
649                   "Invalid SAP State:RgUiRrgBndReq failed\n");
650 #endif
651             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_NOK);
652             break;
653       }
654    }
655    else
656    {
657 #if (ERRCLASS & ERRCLS_ADD_RES)      
658       /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state 
659          to spId to avoid seg fault due to invalid sapID */
660       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG002,
661             (ErrVal)spId, "Invalid SAP Id:RgUiRrgBndReq failed\n");
662 #endif
663       ret = RgUiRgrBndCfm(&tmpPst, suId, CM_BND_NOK);
664    }
665    RETVALUE(ret);
666 }  /* RgUiRgrBndReq */
667
668 /**
669  * @brief API for unbind request from RRM towards MAC. 
670  *
671  * @details
672  *
673  *     Function: RgUiRgrUbndReq
674  *     
675  *     This API is invoked by RRM towards MAC to unbind RGR SAP. 
676  *     These API validates the Pst, spId, suId and transfers the unbind request 
677  *     specific information to corresponding ownership module (GOM) API.
678  *
679  *           
680  *  @param[in]  Pst    *pst
681  *  @param[in]  SuId   suId
682  *  @param[in]  Reason reason
683  *  @return  S16
684  *      -# ROK 
685  *      -# RFAILED 
686  **/
687 #ifdef ANSI
688 PUBLIC S16 RgUiRgrUbndReq
689 (
690  Pst    *pst,
691  SpId   spId,
692  Reason reason
693  )
694 #else
695 PUBLIC S16 RgUiRgrUbndReq(pst, spId, reason)
696    Pst    *pst; 
697    SpId   spId;
698    Reason reason;
699 #endif
700 {
701    Inst instId = pst->dstInst-SCH_INST_START;
702    TRC3(RgUiRgrUbndReq)
703
704
705    /* SAP Id validation */
706    if (spId < rgSchCb[instId].numSaps)
707    {
708       switch(rgSchCb[instId].rgrSap[spId].sapSta.sapState)
709       {
710          case LRG_BND: /* SAP is already bound*/
711             RLOG0(L_DEBUG,"SAP is already bound");
712             /* setting SAP state to UN BOUND */
713             rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_UNBND;
714             break;
715          default:
716 #if (ERRCLASS & ERRCLS_ADD_RES)      
717             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG003,
718                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
719                   "Invalid SAP State: RgUiRgrUbndReq failed\n");
720 #endif
721             RETVALUE(RFAILED);
722       }
723    }
724    else
725    {
726 #if (ERRCLASS & ERRCLS_ADD_RES)      
727       RGSCHLOGERROR(instId,ERRCLS_INT_PAR, ERG004, 
728             (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
729             "Invalid SAP Id:RgUiRgrUbndReq failed\n");
730 #endif
731       RETVALUE(RFAILED);
732    }
733    RETVALUE(ROK);
734 }  /* RgUiRgrUbndReq */
735
736 /**
737  * @brief API for configuration request from RRM towards MAC. 
738  *
739  * @details
740  *
741  *     Function: HandleSchCfgReq 
742  *     
743  *     This API is invoked by RRM towards MAC to configure MAC. 
744  *     These API validates the Pst, spId, suId and transfers the config request 
745  *     specific information to corresponding ownership module (GOM) API.
746  *
747  *           
748  *  @param[in]  Pst           *pst
749  *  @param[in]  RgrCfgTransId transId
750  *  @param[in]  RgrCfgReqInfo *cfgReqInfo
751  *  @return  S16
752  *      -# ROK 
753  *      -# RFAILED 
754  **/
755 #ifdef ANSI
756 PUBLIC S16 HandleSchCfgReq
757 (
758  Pst           *pst, 
759  RgrCfgTransId transId,
760  RgrCfgReqInfo *cfgReqInfo
761  )
762 #else
763 PUBLIC S16 HandleSchCfgReq(pst, transId, cfgReqInfo)
764    Pst           *pst; 
765    RgrCfgTransId transId;
766    RgrCfgReqInfo *cfgReqInfo;
767 #endif
768 {
769
770    SpId      spId = 0;
771    S16       ret       = ROK;
772    U8        cfmStatus = 0x00ff;
773    U8        prntTrans[RGR_CFG_TRANSID_SIZE+1];
774    Inst      instId = pst->dstInst-SCH_INST_START;
775
776    TRC3(HandleSchCfgReq);
777
778    cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, RGR_CFG_TRANSID_SIZE);
779    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
780
781
782    if (cfgReqInfo == NULLP)
783    {
784       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer is NULL");
785       schSendCfgCfm(pst->region, pst->pool, transId, cfmStatus);
786       RETVALUE(RFAILED);
787    }
788 #if 0
789    if (spId < rgSchCb[instId].numSaps)
790    {
791       switch(rgSchCb[instId].rgrSap[spId].sapSta.sapState)
792       {
793          case LRG_BND: /* SAP is already bound */
794             RLOG0(L_DEBUG,"SAP is already bound");
795             break;
796          default: /* Should never reach here */
797 #if (ERRCLASS & ERRCLS_ADD_RES)      
798             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG005, 
799                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
800                   "Invalid SAP State: HandleSchCfgReq failed\n");
801 #endif
802             SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
803                   (Size)sizeof(*cfgReqInfo));
804             schSendCfgCfm(pst->region, pst->pool, transId, cfmStatus); 
805             RETVALUE(RFAILED);
806       }
807    }
808    else
809    {
810 #if (ERRCLASS & ERRCLS_ADD_RES)      
811       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG006,
812             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
813             "Invalid SAP Id:HandleSchCfgReq failed\n");
814 #endif
815       SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
816             (Size)sizeof(*cfgReqInfo));
817       schSendCfgCfm(pst->region, pst->pool, transId, cfmStatus); 
818       RETVALUE(RFAILED);
819    }
820 #endif
821    /* Handle configuration */
822    ret = rgSCHGomHndlCfg(pst, &rgSchCb[instId], 
823          transId, cfgReqInfo);
824    if (ret != ROK)
825    {
826       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Configuration Request Handling Failed");
827       RETVALUE(RFAILED);
828    }
829
830    RETVALUE(ROK);
831 }  /* HandleSchCfgReq */
832
833 #ifdef RGR_SI_SCH
834 /**
835  * @brief API for SI configuration request from RRM towards MAC. 
836  *
837  * @details
838  *
839  *     Function: RgUiRgrSiCfgReq
840  *     
841  *     This API is invoked by RRM towards MAC to configure SI at MAC. 
842  *     These API validates the Pst, spId, suId and transfers the 
843  *     config request specific information to corresponding ownership 
844  *     module (GOM) API.
845  *
846  *           
847  *  @param[in]  Pst           *pst
848  *  @param[in]  SpId          spId
849  *  @param[in]  RgrCfgTransId transId
850  *  @param[in]  RgrSiCfgReqInfo *cfgReqInfo
851  *  @return  S16
852  *      -# ROK 
853  *      -# RFAILED 
854  **/
855 #ifdef ANSI
856 PUBLIC S16 RgUiRgrSiCfgReq
857 (
858 Pst           *pst, 
859 SpId          spId,
860 RgrCfgTransId transId,
861 RgrSiCfgReqInfo *cfgReqInfo
862 )
863 #else
864 PUBLIC S16 RgUiRgrSiCfgReq(pst, spId, transId, cfgReqInfo)
865 Pst           *pst; 
866 SpId          spId;
867 RgrCfgTransId transId;
868 RgrSiCfgReqInfo *cfgReqInfo;
869 #endif
870 {
871    S16       ret       = ROK;
872    U8        cfmStatus = RGR_CFG_CFM_NOK;
873    U8        prntTrans[RGR_CFG_TRANSID_SIZE+1];
874    Inst      instId = pst->dstInst-SCH_INST_START;
875
876    TRC2(RgUiRgrSiCfgReq);
877
878    cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, RGR_CFG_TRANSID_SIZE);
879    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
880
881
882    if (cfgReqInfo == NULLP)
883    {
884       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
885                    "is NULL");
886       rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
887       RETVALUE(RFAILED);
888    }
889
890    if (spId < rgSchCb[instId].numSaps)
891    {
892       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
893       {
894 #if (ERRCLASS & ERRCLS_ADD_RES)      
895          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG007, 
896                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
897                   "Invalid SAP State: RgUiRgrSiCfgReq failed\n");
898 #endif
899          SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
900                                           (Size)sizeof(*cfgReqInfo));
901          rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
902          RETVALUE(RFAILED);
903       }
904    }
905    else
906    {
907 #if (ERRCLASS & ERRCLS_ADD_RES)      
908       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG008,
909             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
910             "Invalid SAP Id:RgUiRgrSiCfgReq failed\n");
911 #endif
912       SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
913                                    (Size)sizeof(*cfgReqInfo));
914       rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
915       RETVALUE(RFAILED);
916    }
917
918    /* Handle configuration */
919 #ifdef EMTC_ENABLE
920 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
921 {
922    ret = rgSCHGomEmtcHndlSiCfg(pst->region, pst->pool,
923             &rgSchCb[instId], spId, transId, 
924                         cfgReqInfo);
925 }
926 else
927 {
928    ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
929             &rgSchCb[instId], spId, transId, 
930                         cfgReqInfo);
931 }
932  #else
933    ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
934             &rgSchCb[instId], spId, transId, 
935                         cfgReqInfo);
936  #endif
937    if (ret != ROK)
938    {
939       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"RgUiRgrSiCfgReq:"
940                    "Configuration Request Handling Failed");
941       RETVALUE(RFAILED);
942    }
943
944    RETVALUE(ROK);
945 }  /* RgUiRgrSiCfgReq */
946
947 \f
948 /**
949  * @brief API for Warning SI configuration request from RRM towards MAC. 
950  *
951  * @details
952  *
953  *     Function: RgUiRgrWarningSiCfgReq
954  *     
955  *     This API is invoked by RRM towards MAC to configure SI at MAC. 
956  *     These API validates the Pst, spId, suId and transfers the 
957  *     config request specific information to corresponding ownership 
958  *     module (GOM) API.
959  *
960  *           
961  *  @param[in]  Pst           *pst
962  *  @param[in]  SpId          spId
963  *  @param[in]  RgrCfgTransId transId
964  *  @param[in]  RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
965  *  @return  S16
966  *      -# ROK 
967  *      -# RFAILED 
968  **/
969 #ifdef ANSI
970 PUBLIC S16 RgUiRgrWarningSiCfgReq
971 (
972 Pst           *pst, 
973 SpId          spId,
974 RgrCfgTransId transId,
975 RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
976 )
977 #else
978 PUBLIC S16 RgUiRgrWarningSiCfgReq(pst, spId, transId, warningSiCfgReqInfo)
979 Pst           *pst; 
980 SpId          spId;
981 RgrCfgTransId transId;
982 RgrWarningSiCfgReqInfo *warningSiCfgReqInfo;
983 #endif
984 {
985    Inst     instId = pst->dstInst-SCH_INST_START;
986    S16      ret    = ROK;
987    U8       cfmStatus = RGR_CFG_CFM_NOK;
988    U8       prntTrans[RGR_CFG_TRANSID_SIZE+1];
989
990    TRC2(RgUiRgrWarningSiCfgReq);
991
992    cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, RGR_CFG_TRANSID_SIZE);
993    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
994
995
996
997    if (warningSiCfgReqInfo == NULLP)
998    {
999       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
1000                "is NULL");
1001       rgSCHUtlRgrWarningSiCfgCfm(instId, spId, 0, transId, cfmStatus);
1002       RETVALUE(RFAILED);
1003    }
1004
1005    if (spId < rgSchCb[instId].numSaps)
1006    {
1007       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
1008       {
1009 #if (ERRCLASS & ERRCLS_ADD_RES)      
1010          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG023, 
1011                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
1012                "Invalid SAP State: warningSiCfgReqInfo failed\n");
1013 #endif
1014          rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool, 
1015                &warningSiCfgReqInfo->siPduLst);
1016          SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo,
1017                sizeof(RgrWarningSiCfgReqInfo));
1018          rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId, 
1019                transId, cfmStatus);
1020          RETVALUE(RFAILED);
1021       }
1022    }
1023    else
1024    {
1025 #if (ERRCLASS & ERRCLS_ADD_RES)      
1026       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG024,
1027             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
1028             "Invalid SAP Id:warningSiCfgReqInfo failed\n");
1029 #endif
1030       rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool, 
1031             &warningSiCfgReqInfo->siPduLst);
1032       SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo,
1033             sizeof(RgrWarningSiCfgReqInfo));
1034       rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId, 
1035             transId, cfmStatus);
1036       RETVALUE(RFAILED);
1037    }
1038
1039    /* Handle configuration */
1040 #ifdef EMTC_ENABLE
1041 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
1042 {
1043    ret = rgSCHGomEmtcHndlWarningSiCfg(pst->region, pst->pool,
1044          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
1045 }
1046 else
1047 {
1048    ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
1049          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
1050 }
1051 #else
1052    ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
1053          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
1054 #endif
1055    if(ret != ROK)
1056    {
1057       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,
1058                "Configuration Request Handling Failed");
1059       RETVALUE(RFAILED);
1060    }
1061
1062    RETVALUE(ROK);
1063 }
1064
1065 \f
1066 /**
1067  * @brief API for Warning SI Stop  request from RRM towards MAC. 
1068  *
1069  * @details
1070  *
1071  *     Function: RgUiRgrWarningSiStopReq
1072  *     
1073  *     This API is invoked by RRM towards MAC to Stop warning SI at MAC. 
1074  *     These API validates the Pst, spId, suId and transfers the 
1075  *     stop request specific information to corresponding ownership 
1076  *     module (GOM) API.
1077  *
1078  *           
1079  *  @param[in]  Pst           *pst
1080  *  @param[in]  SpId          spId
1081  *  @param[in]  RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
1082  *  @return  S16
1083  *      -# ROK 
1084  *      -# RFAILED 
1085  **/
1086 #ifdef ANSI
1087 PUBLIC S16 RgUiRgrWarningSiStopReq
1088 (
1089 Pst           *pst,
1090 SpId          spId,
1091 RgrCfgTransId transId,
1092 U8            siId
1093 )
1094 #else
1095 PUBLIC S16 RgUiRgrWarningSiStopReq(pst,spId, transId, siId)
1096 Pst           *pst;
1097 SpId          spId;
1098 RgrCfgTransId transId;
1099 U8            siId;
1100 #endif
1101 {         
1102    Inst         instId = pst->dstInst-SCH_INST_START;
1103
1104    TRC3(RgUiRgrWarningSiStopReq)
1105
1106
1107
1108    if (spId < rgSchCb[instId].numSaps)
1109    {
1110       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
1111       {
1112 #if (ERRCLASS & ERRCLS_ADD_RES)      
1113          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG025, 
1114                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
1115                "Invalid SAP State: RgUiRgrWarningSiStopReq failed\n");
1116 #endif
1117          RETVALUE(RFAILED);
1118       }
1119    }
1120    else
1121    {
1122 #if (ERRCLASS & ERRCLS_ADD_RES)      
1123       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG026,
1124             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
1125             "Invalid SAP Id:RgUiRgrWarningSiStopReq failed\n");
1126 #endif
1127       RETVALUE(RFAILED);
1128    }
1129
1130    rgSCHGomHndlWarningSiStopReq(pst->region, pst->pool,
1131          &rgSchCb[instId], siId, transId, spId);
1132
1133    RETVALUE(ROK);
1134 }
1135 #endif /*RGR_SI_SCH */
1136
1137 /* LTE_ADV_FLAG_REMOVED_START */
1138
1139 /**
1140  * @brief API for LOAD INF request from RRM towards MAC.
1141  *
1142  * @details
1143  *
1144  *     Function: RgUiRgrLoadInfReq
1145  *
1146  *     This API is invoked by RRM towards MAC to configure LOAD INF Parameters at MAC.
1147  *     These API validates the Pst, spId, suId and transfers the
1148  *     LOAD INF request to corresponding ownership
1149  *     module (GOM) API.
1150  *
1151  *
1152  *  @param[in]  Pst               *pst
1153  *  @param[in]  SpId              spId
1154  *  @param[in]  RgrCfgTransId     transId
1155  *  @param[in]  RgrLoadInfReqInfo *loadInfReq
1156  *  @return  S16
1157  *      -# ROK
1158  *      -# RFAILED
1159  **/
1160 #ifdef ANSI
1161 PUBLIC S16 RgUiRgrLoadInfReq
1162 (
1163  Pst               *pst,
1164  SpId              spId,
1165  RgrCfgTransId     transId,
1166  RgrLoadInfReqInfo *loadInfReq
1167  )
1168 #else
1169 PUBLIC S16 RgUiRgrLoadInfReq(pst, spId, transId, loadInfReq)
1170    Pst               *pst;
1171    SpId              spId;
1172    RgrCfgTransId     transId;
1173    RgrLoadInfReqInfo *loadInfReq;
1174 #endif
1175 {
1176    S16       ret       = ROK;
1177    U8        prntTrans[RGR_CFG_TRANSID_SIZE+1];
1178    Inst      instId = pst->dstInst-SCH_INST_START;
1179
1180    TRC2(RgUiRgrLoadInfReq);
1181
1182    cmMemcpy((U8 *)prntTrans, (U8 *)transId.trans, RGR_CFG_TRANSID_SIZE);
1183    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
1184
1185
1186    if (loadInfReq == NULLP)
1187    {
1188       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
1189                "is NULL");
1190       RETVALUE(RFAILED);
1191    }
1192
1193    if (spId < rgSchCb[instId].numSaps)
1194    {
1195       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
1196       {
1197 #if (ERRCLASS & ERRCLS_ADD_RES)
1198          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG007, 
1199                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
1200                "Invalid SAP State: RgUiRgrLoadInfReq failed\n");
1201 #endif
1202          SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq,
1203                (Size)sizeof(*loadInfReq));
1204          RETVALUE(RFAILED);
1205       }
1206    }
1207    else
1208    {
1209 #if (ERRCLASS & ERRCLS_ADD_RES)
1210       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG008,
1211             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
1212             "Invalid SAP Id:RgUiRgrLoadInfReq failed\n");
1213 #endif
1214       SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq,
1215             (Size)sizeof(*loadInfReq));
1216       RETVALUE(RFAILED);
1217    }
1218
1219    /* Handle configuration */
1220    ret = rgSCHGomHndlLoadInf(pst->region, pst->pool,
1221          &rgSchCb[(pst->dstInst - SCH_INST_START)], spId, transId, 
1222          loadInfReq);
1223    if (ret != ROK)
1224    {
1225       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,
1226                "Configuration Request Handling Failed");
1227       RETVALUE(RFAILED);
1228    }
1229
1230    RETVALUE(ROK);
1231 }  /* RgUiRgrLoadInfReq */
1232 /* LTE_ADV_FLAG_REMOVED_END */
1233
1234 /************** MAC SCH Interface **************/ 
1235 /**
1236  * @brief Function for updating dedicated channel BO at scheduler from MAC.
1237  *
1238  * @details
1239  *
1240  *     Function : rgMacSchDedBoUpdtReq
1241  *     
1242  *     This function shall be invoked whenever MAC gets staRsp from RLC
1243  *     Scheduler shall update BO in its dedicated logical channel control block.
1244  *           
1245  *  @param[in] Pst*           pst
1246  *  @param[in] S16            cellSapId
1247  *  @param[in] RgInfDedBoRpt  *boRpt
1248  *  @return  S16
1249  *      -# ROK 
1250  **/
1251 #ifdef ANSI
1252 PUBLIC S16 RgMacSchDedBoUpdtReq
1253 (
1254 Pst*           pst,
1255 RgInfDedBoRpt  *boRpt
1256 )
1257 #else
1258 PUBLIC S16 RgMacSchDedBoUpdtReq(pst, boRpt)
1259 Pst*           pst;
1260 RgInfDedBoRpt  *boRpt;
1261 #endif
1262 {
1263    RgSchCellCb   *cell;
1264    RgSchUeCb     *ue;
1265 #ifdef SCH_STATS
1266       RgSchCmnDlUe  *dlUe;
1267 #endif
1268
1269
1270    Inst          inst = (pst->dstInst - SCH_INST_START);
1271    S16           cellSapId = boRpt->cellSapId;
1272
1273    TRC3(RgMacSchDedBoUpdtReq)
1274 /*
1275    RLOG_ARG2(L_DEBUG,DBG_CELLID,boRpt->cellId,"rgMacSchDedBoUpdtReq():"
1276             " boRpt->rnti = %u  boRpt->lcId = %u",boRpt->rnti, boRpt->lcId);
1277 */
1278    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1279     * it doesnt exist */
1280    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1281
1282 #ifndef NO_ERRCLS
1283    if (cell->cellId != boRpt->cellId)
1284    {
1285       /* Handle Cell fetch failure */
1286       RGSCHLOGERROR(inst, ERRCLS_INT_PAR,ERG009,(ErrVal)boRpt->cellId,
1287                             "rgMacSchDedBoUpdtReq(): Invalid cell Id");
1288       RETVALUE(RFAILED);
1289    }
1290 #endif
1291
1292    /* Update Bo in the given logical channel of the UE */
1293    if ((ue = rgSCHDbmGetUeCb(cell, boRpt->rnti)) != NULLP)
1294    {
1295       RgSchDlLcCb   *dlLc;
1296       /* Honor BO Reports only from PCELL */
1297 #ifdef LTE_ADV
1298       if (cell != ue->cell)
1299       {
1300          RETVALUE(RFAILED);
1301       }
1302 #endif
1303       if ((dlLc = rgSCHDbmGetDlDedLcCb(ue, boRpt->lcId)) != NULLP)
1304       {
1305 #ifdef LTE_L2_MEAS
1306          if(dlLc->lcType == CM_LTE_LCH_DTCH)
1307          {
1308             if((dlLc->bo == 0) &&(boRpt->bo != 0))
1309             {
1310                /* UE is active */
1311                if(!(ue->qciActiveLCs[dlLc->qciCb->qci]))
1312                {
1313                   dlLc->qciCb->dlUeCount++;
1314                }
1315                ue->qciActiveLCs[dlLc->qciCb->qci]++;
1316             }
1317             else if((dlLc->bo != 0) && (boRpt->bo == 0) && (dlLc->qciCb->dlUeCount))
1318             {
1319                /* UE is inactive */
1320                if (ue->qciActiveLCs[dlLc->qciCb->qci])
1321                {
1322                   ue->qciActiveLCs[dlLc->qciCb->qci]--;
1323                   if (!(ue->qciActiveLCs[dlLc->qciCb->qci]))
1324                   {
1325                      dlLc->qciCb->dlUeCount--;
1326                   }
1327                }
1328             }
1329         }
1330 #endif
1331 #ifdef SCH_STATS
1332          dlUe = RG_SCH_CMN_GET_DL_UE(ue, cell);
1333          if (boRpt->bo > dlLc->bo)
1334          {
1335             dlUe->boReported += (boRpt->bo - dlLc->bo);
1336          }
1337 #endif
1338 #ifdef TENB_STATS
1339          if (boRpt->bo > dlLc->bo)
1340          {
1341             ue->tenbStats->stats.nonPersistent.sch[RG_SCH_CELLINDEX(cell)].dlBo += ((boRpt->bo - dlLc->bo)<<3);
1342          }
1343 #endif
1344          /* RLC provides cumulative BO for each LC.
1345           * Reduce the left out unscheduled bo from total bo and 
1346           * update the new BO to the total bo */
1347          if(ue->totalBo >= dlLc->bo)
1348          {
1349             ue->totalBo -= dlLc->bo;
1350          }
1351          else
1352          {
1353             ue->totalBo = 0; /* this case should not arise
1354                              * Resetting for safety */
1355          }
1356
1357          ue->totalBo +=  boRpt->bo;
1358          dlLc->bo = boRpt->bo;
1359          dlLc->oldestSduArrTime = boRpt->oldestSduArrTime;
1360          dlLc->staPduBo = boRpt->staPduBo;
1361          
1362          dlLc->setMaxUlPrio = boRpt->setMaxUlPrio;
1363          dlLc->setMaxDlPrio = boRpt->setMaxDlPrio;
1364          /* Update the scheduler */
1365          rgSCHUtlDlDedBoUpd(cell, ue, dlLc);
1366          RETVALUE(ROK);
1367       }
1368    }
1369    RETVALUE(RFAILED);
1370
1371 } /* end of rgMacSchDedBoUpdtReq */
1372
1373
1374 /**
1375  * @brief Function for updating common channel BO at scheduler from MAC.
1376  *
1377  * @details
1378  *
1379  *     Function : RgMacSchCmnBoUpdtReq
1380  *     
1381  *     This function shall be invoked whenever MAC gets staRsp from RLC
1382  *     Scheduler shall update BO in its common logical channel control block.
1383  *           
1384  *  @param[in] Pst*            pst
1385  *  @param[in] S16             cellSapId
1386  *  @param[in] RgInfCmnBoRpt  *boRpt
1387  *  @return  S16
1388  *      -# ROK 
1389  **/
1390 #ifdef ANSI
1391 PUBLIC S16 RgMacSchCmnBoUpdtReq
1392 (
1393 Pst*           pst,
1394 RgInfCmnBoRpt  *boRpt
1395 )
1396 #else
1397 PUBLIC S16 RgMacSchCmnBoUpdtReq(pst, boRpt)
1398 Pst*           pst;
1399 RgInfCmnBoRpt  *boRpt;
1400 #endif
1401 {
1402    RgSchCellCb   *cell;
1403    Inst          inst = (pst->dstInst - SCH_INST_START);
1404    S16           cellSapId = boRpt->cellSapId;
1405
1406    TRC3(RgMacSchCmnBoUpdtReq)
1407
1408    /* No need to chk for cell being NULL as MAC would not have found instance if
1409     * it doesnt exist */
1410    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1411    if (cell->cellId != boRpt->cellId)
1412    {
1413       RLOG_ARG1(L_DEBUG,DBG_CELLID,cell->cellId,"RgMacSchCmnBoUpdtReq():"
1414                "Invalid boRpt cell Id:%d",boRpt->cellId);
1415       RETVALUE(RFAILED);
1416    }
1417
1418    /* handle status response on CCCH */
1419    if(boRpt->lcId == cell->dlCcchId)
1420    {
1421       RLOG_ARG0(L_DEBUG,DBG_CELLID,cell->cellId,"RgMacSchCmnBoUpdtReq():"
1422                " BO update for CCCH");
1423       rgSCHUtlHndlCcchBoUpdt(cell, boRpt); 
1424    }
1425    else
1426    {
1427       rgSCHUtlHndlBcchPcchBoUpdt(cell, boRpt); 
1428    }
1429    
1430    RETVALUE(ROK);
1431 } /* end of RgMacSchCmnBoUpdtReq */
1432 /*Fix: start: Inform UE delete to scheduler*/
1433 /**
1434  * @brief This API is used to send data indication to Scheduler instance from MAC.
1435  *
1436  * @details
1437  *
1438  *     Function : rgMacSchUeDelInd
1439  *     
1440  *     This function shall be invoked whenever MAC gets Ue delete request. 
1441  *      
1442  *           
1443  *  @param[in] Pst*            pst
1444  *  @param[in] RgInfUeDelInd   *ueDelInd
1445  *  @return  S16
1446  *      -# ROK 
1447  **/
1448 #ifdef ANSI
1449 PUBLIC S16 RgMacSchUeDelInd
1450 (
1451 Pst*             pst,
1452 RgInfUeDelInd    *ueDelInd
1453 )
1454 #else
1455 PUBLIC S16 RgMacSchUeDelInd(pst, ueDelInd)
1456 Pst*             pst;
1457 RgInfUeDelInd    *ueDelInd;
1458 #endif
1459 {
1460    RgSchCellCb       *cell;
1461    Inst              inst = (pst->dstInst - SCH_INST_START);
1462    S16               cellSapId = ueDelInd->cellSapId;
1463    CmLList           *tmp;
1464    RgSchRntiLnk      *rntiLnk=NULL;
1465    
1466    TRC3(RgMacSchUeDelInd)
1467
1468    if (rgSchCb[inst].rgrSap == NULLP || rgSchCb[inst].rgrSap[cellSapId].cell == NULLP)
1469    {
1470       RLOG_ARG0(L_ERROR,DBG_CELLID,ueDelInd->cellId,"rgrSap or cell is not configured");
1471       RETVALUE(ROK);
1472    }
1473    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1474 #ifndef NO_ERRCLS
1475    if (cell->cellId != ueDelInd->cellId)
1476    {
1477       /* Handle Cell fetch failure */
1478       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1479                         "rgMacSchUeDelInd(): Invalid ueDelInd cell Id:%d",
1480                          ueDelInd->cellId);
1481       RETVALUE(ROK);
1482    }
1483 #endif
1484       
1485    CM_LLIST_FIRST_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1486
1487    while(tmp)
1488    {
1489       rntiLnk = (RgSchRntiLnk *)(tmp->node);
1490       if(rntiLnk->rnti == ueDelInd->rnti)
1491       {
1492          cmLListDelFrm(&cell->rntiDb.rntiGuardPool, tmp);
1493          tmp->node = NULLP;
1494          rgSCHDbmRlsRnti(cell, rntiLnk);
1495          RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
1496                   "RNTI:%d Released from the Guard pool(%ld)",
1497                   ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1498          
1499          break;
1500       }
1501       CM_LLIST_NEXT_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1502    }
1503
1504 #ifdef EMTC_ENABLE
1505  rgEmtcMacSchUeDelInd(cell,ueDelInd);  
1506 #endif
1507
1508    if(tmp == NULLP)
1509    {
1510       /* Fix : syed HO UE does not have a valid ue->rntiLnk */
1511       RLOG_ARG2(L_INFO,DBG_CELLID,ueDelInd->cellId,"HO CRNTI:%d not present in the"
1512            "Guard Pool:%ld", ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1513    } 
1514    
1515    RETVALUE(ROK);
1516 }  /* rgMacSchUeDelInd */
1517 /*Fix: end: Inform UE delete to scheduler*/
1518 /**
1519  * @brief This API is used to send data indication to Scheduler instance from MAC.
1520  *
1521  * @details
1522  *
1523  *     Function : rgMacSchSfRecpInd
1524  *     
1525  *     This function shall be invoked whenever MAC gets datInd on TFU
1526  *     Scheduler shall act on the CEs and data that are received as part of
1527  *     datInd.
1528  *           
1529  *  @param[in] Pst*            pst
1530  *  @param[in] S16             cellSapId
1531  *  @param[in] CmLteRnti       rnti
1532  *  @param[in] DatIndInfo      *datInd
1533  *  @return  S16
1534  *      -# ROK 
1535  **/
1536 #ifdef ANSI
1537 PUBLIC S16 RgMacSchSfRecpInd
1538 (
1539 Pst*             pst,
1540 RgInfSfDatInd    *subfrmInfo
1541 )
1542 #else
1543 PUBLIC S16 RgMacSchSfRecpInd(pst, subfrmInfo)
1544 Pst*             pst;
1545 RgInfSfDatInd    *subfrmInfo;
1546 #endif
1547 {
1548    S16               ret = RFAILED;
1549    RgSchErrInfo      err;
1550    RgSchUeCb         *ue;
1551    RgInfUeDatInd     *datInd;
1552    RgSchCellCb       *cell;
1553    Inst              inst = (pst->dstInst - SCH_INST_START);
1554    CmLteRnti         rnti;
1555    CmLListCp         *lnkLst;
1556    CmLList           *tmp;
1557    S16               cellSapId = subfrmInfo->cellSapId;
1558    RgrUeStaIndInfo   *ueStaInd;
1559 #ifdef RG_UNUSED
1560 //#ifdef LTEMAC_SPS
1561    RgSchCmnUlUeSpsInfo   *ulSpsUe ;
1562 #endif
1563    /* RRM_RBC_X */
1564    U32                   idx;
1565    /* RRM_RBC_Y */
1566    
1567 #ifdef LTE_L2_MEAS
1568    U8               qci;
1569    U16              datIndActQci = 0;
1570    U16              combDatIndActQci = 0; /* Prev and Latest Dat Ind combined */
1571    U16              tempUeActQci = 0; /* UE specific Active QCIs */
1572    U16              diffBits = 0;
1573    U8               lcCount;
1574 #endif
1575    TRC3(RgMacSchSfRecpInd)
1576
1577    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1578     * it doesnt exist */
1579    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1580
1581    /* lnkLst assignment */
1582    lnkLst = &(subfrmInfo->ueLst);
1583
1584    CM_LLIST_FIRST_NODE(lnkLst, tmp);
1585
1586    while((NULLP != tmp) && ((RgInfUeDatInd *)tmp->node != NULLP))
1587    {
1588       ue = NULLP;
1589 #ifdef LTE_L2_MEAS
1590       qci = 0;
1591 #endif
1592       datInd   = (RgInfUeDatInd *)tmp->node;
1593       rnti     = datInd->rnti;
1594
1595       /* We shall try and find
1596        * out the RaCb based on the following - 
1597        * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1598        * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1599        * have a ueCb also for this 
1600        */
1601       
1602       /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1603        * should check for CRNTI CE and if it exists the UECb must exist, also an
1604        * if the CRNTI in the CE and the one with which the message came in are
1605        * different we shall look for an raCb as well. 
1606        */
1607       if (datInd->ceInfo.bitMask & RGSCH_CRNTI_CE_PRSNT)
1608       {
1609          /* SR_RACH_STATS : CRNTI CE*/
1610          rgNumMsg3CrntiCE++;
1611
1612          if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1613          {
1614             RGSCH_FREE_MEM(subfrmInfo);
1615             err.errType = RGSCHERR_TOM_DATIND;
1616             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1617                       "Received MSG3 with CRNTI:%d and also CCCH ", 
1618                      datInd->ceInfo.ces.cRnti);
1619             RETVALUE(RFAILED);
1620          }
1621          ue = rgSCHDbmGetUeCb (cell, datInd->ceInfo.ces.cRnti);
1622          if (ue == NULLP)
1623          {
1624             /* SR_RACH_STATS : CRNTI CE UECB NOT FOUND*/
1625             rgNumCrntiCeCrntiNotFound++;
1626             /* ccpu00141318 - Removed condition for SPS rnti checking*/
1627             RGSCH_FREE_MEM(subfrmInfo);
1628             err.errType = RGSCHERR_TOM_DATIND;
1629             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, "Received MSG3 "
1630                      "with CRNTI:%d unable to find ueCb", 
1631                      datInd->ceInfo.ces.cRnti);
1632             RETVALUE(RFAILED);
1633          }
1634
1635          if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue, 
1636                rnti, datInd, &err)) != ROK)
1637          { 
1638             RGSCH_FREE_MEM(subfrmInfo);
1639             err.errType = RGSCHERR_TOM_DATIND;
1640             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, "Processing for MSG3 failed for CRNTI:%d", 
1641                      datInd->rnti);
1642             RETVALUE(RFAILED);
1643          }
1644          
1645 #ifdef LTEMAC_SPS
1646          rgSCHUtlHdlCrntiCE (cell, ue);
1647 #endif
1648          ret = rgSCHUtlAllocSBuf (cell->instIdx,(Data**)&ueStaInd,
1649                                   sizeof(RgrUeStaIndInfo));
1650          if(ret == ROK)
1651          {
1652             ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD;
1653 #ifdef RG_UNUSED
1654 //#ifdef LTEMAC_SPS
1655             ulSpsUe = RG_SCH_CMN_GET_UL_SPS_UE(ue);
1656             if(ulSpsUe->isUlSpsActv)
1657             {
1658                ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD_IN_SPS_ACTIVE;
1659                ue->ul.ulSpsCfg.isLcSRMaskEnab = FALSE;
1660             }
1661 #endif
1662             ret = rgSCHUtlFillSndUeStaInd(cell, ue, ueStaInd);
1663             if(ret != ROK)
1664             {
1665                RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1666                    "Could not Send Ue Sta Ind UEID:%d",ue->ueId);
1667             }
1668          }
1669          CM_LLIST_NEXT_NODE(lnkLst, tmp);
1670          continue;
1671       } /* end of CRNTI based message */
1672       else if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1673       {
1674          /* SR_RACH_STATS : CCCH SDU */
1675          rgNumMsg3CCCHSdu++;
1676          /* SR_RACH_STATS : CCCH SDU RACB NOT FOUND*/
1677          if (NULLP == rgSCHDbmGetRaCb (cell, rnti))
1678          {
1679             rgNumCCCHSduCrntiNotFound++;
1680          }
1681
1682          if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue, 
1683                rnti, datInd, &err)) != ROK)
1684          { 
1685             RGSCH_FREE_MEM(subfrmInfo);
1686             err.errType = RGSCHERR_TOM_DATIND;
1687             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Processing for MSG3 failed for CRNTI:%d", 
1688                      datInd->rnti);
1689             RETVALUE(RFAILED);
1690          }
1691          /* fix */
1692           CM_LLIST_NEXT_NODE(lnkLst, tmp);
1693           continue;
1694       } /* end of Msg3 processing */
1695
1696       if (ue == NULLP)
1697       {
1698          ue = rgSCHDbmGetUeCb (cell, datInd->rnti);
1699          if (ue == NULLP)
1700          {
1701 #ifdef LTEMAC_SPS 
1702          if((ue = rgSCHDbmGetSpsUeCb (cell, datInd->rnti)) == NULLP)
1703 #endif
1704             {
1705                RGSCH_FREE_MEM(subfrmInfo);
1706                err.errType = RGSCHERR_TOM_DATIND;
1707                RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Unable to get the UE CB for CRNTI:%d", 
1708                datInd->rnti);
1709                RETVALUE(RFAILED);
1710             }
1711          }
1712       }
1713 /* L2_COUNTERS */
1714 #ifdef LTE_L2_MEAS
1715       /* The LCs for which data is received at MAC is provided to SCH.
1716          This information is used to estimate the Active LCs at UE
1717          since estimates based on only BSR is not accurate */
1718       if (datInd->ceInfo.bitMask & RGSCH_ACTIVE_LC_PRSNT)
1719       {
1720       
1721         /* Compose a Bitmask with for the QCI's for which Data
1722            is received */
1723         for (lcCount = 0; lcCount < RGINF_MAX_NUM_DED_LC; lcCount++)
1724         {
1725            if ((datInd->ceInfo.ulActLCs[lcCount] == TRUE) && (TRUE == ue->ul.lcCb[lcCount].isValid))
1726            {
1727               datIndActQci |= (1 << (ue->ul.lcCb[lcCount].qciCb->qci -1));
1728            }
1729         }
1730         if (ue->ulActiveLCs && ue->lastDatIndLCs)
1731         {
1732            /* Combine previous Dat Ind and current Dat Ind to
1733               estimate active LCs at UE */
1734            combDatIndActQci = ue->lastDatIndLCs | datIndActQci;
1735            tempUeActQci = ue->ulActiveLCs;
1736            ue->ulActiveLCs = combDatIndActQci;
1737            diffBits = combDatIndActQci ^ tempUeActQci;
1738            while (diffBits)
1739            {
1740               qci++;
1741               if (0x1 & diffBits)
1742               {
1743                  if (0x1 & tempUeActQci)
1744                  {
1745                     /* An active QCI has become inactive */
1746                     cell->qciArray[qci].ulUeCount--;
1747                  }
1748                  else
1749                  {
1750                     /* An Inactive QCI has become active */
1751                     cell->qciArray[qci].ulUeCount++;
1752                  }
1753               }
1754               diffBits >>= 1;
1755               tempUeActQci >>= 1;
1756            }
1757         }
1758         ue->lastDatIndLCs = datIndActQci;
1759       
1760       }
1761
1762 #endif /* LTE_L2_MEAS */
1763       /* Just copy the timing information from the dat indication into the one
1764        * stored in the UE CB, will be later utilized to handle Timing advance 
1765        */
1766
1767       if ((ret = rgSCHUtlUpdSch (subfrmInfo, cell, ue, datInd, &err)) != ROK)
1768       {
1769          RGSCH_FREE_MEM(subfrmInfo);
1770          err.errType = RGSCHERR_TOM_DATIND;
1771          RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Unable to handle Data"
1772                    " Indication for UEID:%d",ue->ueId);
1773          RETVALUE(RFAILED);
1774       }
1775
1776       CM_LLIST_NEXT_NODE(lnkLst, tmp);
1777    }
1778    /* RRM_RBC_X */
1779    /* update the UL PRB usage for all GBR QCIs*/
1780    for (idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++)
1781    {
1782       cell->prbUsage.qciPrbRpts[idx].ulTotPrbUsed += subfrmInfo->qcisUlPrbCnt[idx];
1783    }
1784    /* RRM_RBC_Y */
1785
1786    /* chk if Sch needs to dealloc datInd after unpk */
1787    RGSCH_FREE_MEM(subfrmInfo);
1788    RETVALUE(ret);
1789 }  /* rgMacSchSfRecpInd */
1790
1791 #ifdef LTEMAC_SPS
1792 /**
1793  * @brief Function to handle relInd from MAC for a UE
1794  *
1795  * @details
1796  *
1797  *     Function: RgMacSchSpsRelInd
1798  *
1799  *     Handler for processing relInd for UL SPS of a UE
1800  *
1801  *     Invoked by: 
1802  *         MAC
1803  *
1804  *     Processing Steps:
1805  *           
1806  *  @param[in] Pst               *pst
1807  *  @param[in] RgInfSpsRelInfo   *relInfo
1808  *  @return  S16
1809  *      -# ROK 
1810  *      -# RFAILED 
1811  **/
1812 #ifdef ANSI
1813 PUBLIC S16 RgMacSchSpsRelInd
1814 (
1815 Pst                *pst, 
1816 RgInfSpsRelInfo    *relInfo
1817 )
1818 #else
1819 PUBLIC S16 RgMacSchSpsRelInd(pst, relInfo)
1820 Pst                *pst;
1821 RgInfSpsRelInfo    *relInfo;
1822 #endif
1823 {
1824    RgSchUeCb       *ue;
1825    RgSchCellCb     *cell;
1826    Inst            inst = (pst->dstInst - SCH_INST_START);
1827
1828    TRC2(RgMacSchSpsRelInd);
1829
1830    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1831     * it doesnt exist */
1832    cell = rgSchCb[inst].rgrSap[relInfo->cellSapId].cell;
1833
1834    if ((ue = rgSCHDbmGetUeCb(cell, relInfo->cRnti)) == NULLP)
1835    {
1836       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, 
1837            "No Ue exists with CRNTI:%d",relInfo->cRnti);
1838       RETVALUE(RFAILED);
1839    }
1840
1841    if ((rgSCHUtlSpsRelInd(cell, ue, relInfo->isExplRel)) != ROK)
1842    {
1843       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, 
1844            "RelInd processing for CRNTI:%d failed",relInfo->cRnti);
1845       RETVALUE(RFAILED);
1846    }
1847    RETVALUE(ROK);
1848 } /* end of RgMacSchSpsRelInd */
1849 #endif /* LTEMAC_SPS */
1850
1851 #ifdef LTE_L2_MEAS
1852
1853 /**
1854  * @brief Function to handle L2MeasCfm from MAC
1855  *
1856  * @details
1857  *
1858  *     Function: RgMacSchL2MeasCfm
1859  *
1860  *     Handler for processing L2 measurement confirm 
1861  *
1862  *     Invoked by: 
1863  *         MAC
1864  *
1865  *     Processing Steps:
1866  *           
1867  *  @param[in] Pst               *pst
1868  *  @param[in] RgInfL2MeasCfm    *measCfm
1869  *  @return  S16
1870  *      -# ROK 
1871  *      -# RFAILED 
1872  **/
1873 #ifdef ANSI
1874 PUBLIC S16 RgMacSchL2MeasCfm
1875 (
1876 Pst                *pst, 
1877 RgInfL2MeasCfm     *measCfm
1878 )
1879 #else
1880 PUBLIC S16 RgMacSchL2MeasCfm(pst, measCfm)
1881 Pst                *pst;
1882 RgInfL2MeasCfm     *measCfm;
1883 #endif
1884 {
1885    RgSchCellCb       *cell = NULLP;
1886    Inst              inst = (pst->dstInst - SCH_INST_START);
1887    CmLList           *lnk;
1888    RgSchL2MeasCb     *measCb = NULLP;
1889    RgSchCb           *instCb =  &rgSchCb[inst];
1890    U32               idx;
1891    LrgSchMeasCfmInfo schMeasCfm;
1892    U8                qciVal;
1893    U8                idx1; /*LTE_L2_MEAS_PHASE2*/ 
1894    U8                qciVal1;
1895    TRC2(RgMacSchL2MeasCfm);
1896
1897    /* Find the cellCb using cellId in measInfo. Iterate through all cells
1898     * in rgrsapCb in RgschCb */
1899    for (idx = 0; idx < instCb->numSaps; idx++)
1900    {
1901       if ( instCb->rgrSap[idx].cell->cellId == measCfm->cellId)
1902       {
1903          /* got the cell break the loop */
1904          cell = instCb->rgrSap[idx].cell;
1905          break;
1906       }
1907    }
1908    /* If no cellCb return Err with Invalid Cell Id */
1909    if (cell == NULLP)
1910    {
1911       RLOG_ARG0(L_ERROR,DBG_CELLID,measCfm->cellId,
1912                   "Meas Cfm Failed.Invalid Cell Id");
1913       RETVALUE(RFAILED);
1914    }
1915    
1916
1917    /* Iterate through all meas requests in l2mList in cellCb */
1918    lnk = cell->l2mList.first;
1919    while(lnk != NULLP)
1920    {
1921       /* Get the MeasCb : RgSchL2MeasCb */
1922       measCb = (RgSchL2MeasCb *)lnk->node;
1923       lnk = lnk->next;
1924       if (measCb->measReq.hdr.transId == measCfm->transId)
1925       {
1926          break;
1927       }
1928    }
1929    if ( measCb == NULLP )
1930    {
1931       RETVALUE( RFAILED );
1932    }
1933
1934
1935    if(measCfm->cfm.status != LCM_PRIM_OK)
1936    {
1937       for (idx = 0; idx < measCb->measReq.avgPrbQciUl.numQci; idx++)
1938       {
1939         qciVal = measCb->measReq.avgPrbQciUl.qci[idx];
1940         cell->qciArray[qciVal].qci = 0;
1941       }
1942       /* Delete this measCb, send the negative confirmation to
1943        * stack manager */
1944       cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
1945       /* ccpu00117052 - MOD - Passing double pointer
1946          for proper NULLP assignment*/
1947       rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb, sizeof(RgSchL2MeasCb));
1948       cmMemset((U8 *)&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
1949       schMeasCfm.measType     = measCfm->measType;
1950       schMeasCfm.cfm          = measCfm->cfm;
1951       schMeasCfm.hdr.transId  = measCfm->transId;
1952       schMeasCfm.cellId       = measCfm->cellId;
1953       RgMiLrgSchL2MeasCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
1954       RETVALUE(ROK);
1955    }
1956    for(idx = 0; idx < measCfm->u.prbCfm.numQci; idx++)
1957    {
1958       measCb->avgPrbQciUl.prbUsage[idx].prbUsage = measCfm->u.prbCfm.prbUsage[idx].prbUsage;
1959       measCb->avgPrbQciUl.prbUsage[idx].qciValue = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1960       /*LTE_L2_MEAS_PHASE2*/
1961       qciVal1 = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1962       for(idx1=0;idx1<measCb->measReq.avgPrbQciUl.numQci;idx1++)
1963       {
1964          if(measCb->measReq.avgPrbQciUl.qci[idx1] == qciVal1)
1965          {
1966             break;
1967          }
1968       }
1969       if(idx1 == measCb->measReq.avgPrbQciUl.numQci)
1970       {
1971          measCb->measReq.avgPrbQciUl.qci[measCb->measReq.avgPrbQciUl.numQci++] = qciVal1;
1972       }
1973    }
1974    measCb->avgPrbQciUl.numQci = measCfm->u.prbCfm.numQci;
1975    measCb->cfmRcvd = TRUE;
1976    cell->sndL2Meas = TRUE;
1977    RETVALUE(ROK);
1978 } /* end of RgMacSchL2MeasCfm */
1979
1980 /**
1981  * @brief Function to handle L2MeasStopCfm from MAC
1982  *
1983  * @details
1984  *
1985  *     Function: RgMacSchL2MeasStopCfm
1986  *
1987  *     Handler for processing L2 measurement confirm 
1988  *
1989  *     Invoked by: 
1990  *         MAC
1991  *
1992  *     Processing Steps:
1993  *           
1994  *  @param[in] Pst               *pst
1995  *  @param[in] RgInfL2MeasCfm    *measCfm
1996  *  @return  S16
1997  *      -# ROK 
1998  *      -# RFAILED 
1999  **/
2000 #ifdef ANSI
2001 PUBLIC S16 RgMacSchL2MeasStopCfm
2002 (
2003 Pst                *pst,
2004 RgInfL2MeasCfm     *measCfm
2005 )
2006 #else
2007 PUBLIC S16 RgMacSchL2MeasStopCfm(pst, measCfm)
2008 Pst                *pst;
2009 RgInfL2MeasCfm     *measCfm;
2010 #endif
2011 {
2012    LrgSchMeasCfmInfo schMeasCfm;
2013    Inst              inst = (pst->dstInst - SCH_INST_START);
2014    RgSchCb           *instCb =  &rgSchCb[inst];
2015
2016    TRC2(RgMacSchL2MeasStopCfm);
2017
2018    cmMemset((U8 *)&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
2019    schMeasCfm.measType     = measCfm->measType;
2020    schMeasCfm.cfm          = measCfm->cfm;
2021    schMeasCfm.hdr.transId  = measCfm->transId;
2022    schMeasCfm.cellId       = measCfm->cellId;
2023    RgMiLrgSchL2MeasStopCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
2024    RETVALUE(ROK);
2025 }
2026 #endif
2027
2028 /************** TFU Interface *************/
2029
2030 /**
2031  * @brief Bind confirm API for TFU SAP on scheduler instance. 
2032  *
2033  * @details
2034  *
2035  *     Function : RgLiTfuSchBndCfm
2036  *      
2037  *      This API is invoked by PHY to confirm TFU SAP bind. 
2038  *     
2039  *           
2040  *  @param[in]  Pst   *pst 
2041  *  @param[in]  SuId  suId 
2042  *  @param[in]  U8    status
2043  *  @return  S16
2044  *      -# ROK 
2045  *      -# RFAILED 
2046  **/
2047 #ifdef ANSI
2048 PUBLIC S16 RgLiTfuSchBndCfm 
2049 (
2050 Pst     *pst,
2051 SuId    suId, 
2052 U8      status
2053 )
2054 #else
2055 PUBLIC S16 RgLiTfuSchBndCfm(pst, suId, status)
2056 Pst     *pst; 
2057 SuId    suId; 
2058 U8      status;
2059 #endif
2060 {
2061    S16 ret;
2062    RgSchLowSapCb  *tfuSap;
2063    Inst  instId = pst->dstInst - SCH_INST_START;
2064
2065    TRC3(RgLiTfuSchBndCfm);
2066
2067
2068    if(suId >= rgSchCb[instId].numSaps)
2069    {
2070       RLOG_ARG0(L_ERROR,DBG_INSTID,instId, "Incorrect SuId");
2071       RETVALUE(RFAILED);
2072    }
2073    /* Lets validate suId first */
2074    tfuSap = &(rgSchCb[instId].tfuSap[suId]);
2075
2076    if (suId != tfuSap->sapCfg.suId)
2077    {
2078       RLOG_ARG2(L_ERROR,DBG_INSTID,instId, "Incorrect SuId. Configured (%d)"
2079             "Recieved (%d)", tfuSap->sapCfg.suId, suId);
2080       RETVALUE(RFAILED);
2081    }
2082    ret = rgSCHLmmBndCfm (pst, suId, status);
2083    RETVALUE(ret);
2084 }  /* RgLiTfuSchBndCfm */
2085
2086 /**
2087  * @brief Random Access Request indication from PHY.
2088  *
2089  * @details
2090  *
2091  *     Function : RgLiTfuRaReqInd
2092  *      
2093  *      This API is invoked by PHY to send Random Access Request to Scheduler.
2094  *      This API contains information for Random Access Request including 
2095  *      raRnti, list of associated RAPIDs and related information.
2096  *           
2097  *  @param[in]  Pst              *pst 
2098  *  @param[in]  SuId             suId 
2099  *  @param[in]  TfuRaReqIndInfo  *raReqInd
2100  *  @return  S16
2101  *      -# ROK 
2102  *      -# RFAILED 
2103  **/
2104 #ifdef ANSI
2105 PUBLIC S16 RgLiTfuRaReqInd
2106 (
2107 Pst              *pst, 
2108 SuId             suId, 
2109 TfuRaReqIndInfo  *raReqInd
2110 )
2111 #else
2112 PUBLIC S16 RgLiTfuRaReqInd(pst, suId, raReqInd)
2113 Pst              *pst; 
2114 SuId             suId; 
2115 TfuRaReqIndInfo  *raReqInd;
2116 #endif
2117 {
2118    S16   ret;
2119    Inst  inst = pst->dstInst-SCH_INST_START;
2120
2121    TRC3(RgLiTfuRaReqInd);
2122
2123    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2124    {
2125       RLOG_ARG1(L_ERROR,DBG_INSTID,inst,"SAP Validation failed SuId(%d)", suId);
2126       /* Free up the memory for the request structure */
2127       RGSCH_FREE_MEM(raReqInd);
2128       RETVALUE(ret);
2129    }
2130
2131    if(raReqInd == NULLP)
2132    {
2133       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"Invalid input pointer for raReqInd Failed");
2134       RETVALUE(RFAILED);
2135    }
2136
2137    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2138    {
2139       RLOG_ARG0(L_ERROR,DBG_CELLID,raReqInd->cellId,"No cell exists");
2140       RETVALUE(RFAILED);
2141    }
2142
2143    ret = rgSCHTomRaReqInd(rgSchCb[inst].tfuSap[suId].cell, raReqInd);
2144    /* Free up the memory for the request structure */
2145    RGSCH_FREE_MEM(raReqInd);
2146    /*SPutSBuf (pst->region, pst->pool, (Data *)raReqInd,
2147          sizeof(TfuRaReqIndInfo)); */
2148    RETVALUE(ret);
2149 }  /* RgLiTfuRaReqInd */
2150
2151 /**
2152  * @brief Uplink CQI indication from PHY.
2153  *
2154  * @details
2155  *
2156  *     Function : RgLiTfuUlCqiInd
2157  *      
2158  *      This API is invoked by PHY to send Uplink CQI to Scheduler.
2159  *      This API contains Uplink CQI information reported per UE.
2160  *           
2161  *  @param[in]  Pst               *pst 
2162  *  @param[in]  SuId              suId 
2163  *  @param[in]  TfuUlCqiIndInfo   *ulCqiInd
2164  *  @return  S16
2165  *      -# ROK 
2166  *      -# RFAILED 
2167  **/
2168 #ifdef ANSI
2169 PUBLIC S16 RgLiTfuUlCqiInd
2170 (
2171 Pst              *pst, 
2172 SuId             suId, 
2173 TfuUlCqiIndInfo  *ulCqiInd
2174 )
2175 #else
2176 PUBLIC S16 RgLiTfuUlCqiInd(pst, suId, ulCqiInd)
2177 Pst              *pst; 
2178 SuId             suId; 
2179 TfuUlCqiIndInfo  *ulCqiInd;
2180 #endif
2181 {
2182    S16   ret;
2183    Inst  inst = pst->dstInst-SCH_INST_START;
2184
2185    TRC3(RgLiTfuUlCqiInd);
2186
2187    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2188    {
2189       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2190       /* Free up the memory for the request structure */
2191       RGSCH_FREE_MEM(ulCqiInd);
2192       RETVALUE(ret);
2193    }
2194
2195    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2196    {
2197       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2198       /* Free up the memory for the request structure */
2199       RGSCH_FREE_MEM(ulCqiInd);
2200       RETVALUE(RFAILED);
2201    }
2202    ret = rgSCHTomUlCqiInd (rgSchCb[inst].tfuSap[suId].cell, ulCqiInd);
2203    /* Free up the memory for the request structure */
2204    RGSCH_FREE_MEM(ulCqiInd);
2205    RETVALUE(ret);
2206 }  /* RgLiTfuUlCqiInd */
2207
2208 /**
2209  * @brief PUCCH power adjustment indication.
2210  *
2211  * @details
2212  *
2213  *     Function : RgLiTfuPucchDeltaPwrInd
2214  *
2215  *      This API is invoked by PHY to send PUCCH power adjustment
2216  *      indication.
2217  *
2218  *  @param[in]  Pst                     *pst 
2219  *  @param[in]  SuId                    suId 
2220  *  @param[in]  TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
2221  *  @return  S16
2222  *      -# ROK 
2223  *      -# RFAILED 
2224  **/
2225 #ifdef ANSI
2226 PUBLIC S16 RgLiTfuPucchDeltaPwrInd
2227 (
2228 Pst                     *pst,
2229 SuId                    suId,
2230 TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
2231 )
2232 #else
2233 PUBLIC S16 RgLiTfuPucchDeltaPwrInd(pst, suId, pucchDeltaPwr)
2234 Pst                     *pst;
2235 SuId                    suId;
2236 TfuPucchDeltaPwrIndInfo *pucchDeltaPwr;
2237 #endif
2238 {
2239    S16   ret;
2240    Inst  inst = pst->dstInst-SCH_INST_START;
2241
2242    TRC3(RgLiTfuPucchDeltaPwrInd);
2243
2244    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2245    {
2246       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2247       /* Free up the memory for the request structure */
2248       RGSCH_FREE_MEM(pucchDeltaPwr);
2249       RETVALUE(ret);
2250    }
2251
2252    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2253    {
2254       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2255       RETVALUE(RFAILED);
2256    }
2257    ret = rgSCHTomPucchDeltaPwrInd (rgSchCb[inst].tfuSap[suId].cell, pucchDeltaPwr);
2258    /* Free up the memory for the request structure */
2259    RGSCH_FREE_MEM(pucchDeltaPwr);
2260    RETVALUE(ret);
2261 }  /* RgLiTfuPucchDeltaPwrInd */
2262
2263
2264 /**
2265  * @brief HARQ ACK indication from PHY for Downlink transmissions.
2266  *
2267  * @details
2268  *
2269  *     Function : RgLiTfuHqInd
2270  *      
2271  *      This API is invoked by PHY to send HARQ ACK information to Scheduler
2272  *      on recieving HARQ ACK/NACK from UEs.
2273  *      This API contains HARQ ACK information recieved by PHY for downlink
2274  *      transmissions.
2275  *           
2276  *  @param[in]  Pst                *pst
2277  *  @param[in]  SuId               suId 
2278  *  @param[in]  TfuHqIndInfo       *harqAckInd
2279  *  @return  S16
2280  *      -# ROK 
2281  *      -# RFAILED 
2282  **/
2283 #ifdef ANSI
2284 PUBLIC S16 RgLiTfuHqInd
2285 (
2286 Pst                *pst, 
2287 SuId               suId, 
2288 TfuHqIndInfo       *harqAckInd
2289 )
2290 #else
2291 PUBLIC S16 RgLiTfuHqInd(pst, suId, harqAckInd)
2292 Pst                *pst; 
2293 SuId               suId; 
2294 TfuHqIndInfo       *harqAckInd;
2295 #endif
2296 {
2297    S16   ret;
2298    Inst  inst = (pst->dstInst - SCH_INST_START);
2299
2300    TRC3(RgLiTfuHqInd);
2301
2302 #ifndef NO_ERRCLS
2303    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2304    {
2305       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2306       RGSCH_FREE_MEM(harqAckInd);
2307       RETVALUE(ret);
2308    }
2309
2310    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2311    {
2312       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2313       RETVALUE(RFAILED);
2314    }
2315 #endif
2316
2317    /* Now call the TOM (Tfu ownership module) primitive to process further */
2318    ret = rgSCHTomHarqAckInd (rgSchCb[inst].tfuSap[suId].cell, harqAckInd);
2319    /* Free up the memory for the request structure */
2320    RGSCH_FREE_MEM(harqAckInd);
2321    RETVALUE(ret);
2322 }  /* RgLiTfuHqInd */
2323
2324
2325 /**
2326  * @brief Scheduling request(SR) indication from PHY for an UE.
2327  *
2328  * @details
2329  *
2330  *     Function : RgLiTfuSrInd
2331  *      
2332  *      This API is invoked by PHY to send Scheduling request information to
2333  *      Scheduler on recieving SR from a list of UEs.
2334  *      This API contains scheduling request information recieved by PHY for UEs.
2335  *           
2336  *  @param[in]  Pst           *pst
2337  *  @param[in]  SuId          suId 
2338  *  @param[in]  TfuSrIndInfo  *srInd
2339  *  @return  S16
2340  *      -# ROK 
2341  *      -# RFAILED 
2342  **/
2343 #ifdef ANSI
2344 PUBLIC S16 RgLiTfuSrInd
2345 (
2346 Pst                *pst, 
2347 SuId               suId, 
2348 TfuSrIndInfo       *srInd
2349 )
2350 #else 
2351 PUBLIC S16 RgLiTfuSrInd(pst, suId, srInd)
2352 Pst                *pst; 
2353 SuId               suId; 
2354 TfuSrIndInfo       *srInd;
2355 #endif
2356 {
2357    S16   ret;
2358    Inst  inst = pst->dstInst-SCH_INST_START;
2359
2360    TRC3(RgLiTfuSrInd);
2361
2362 #ifndef NO_ERRCLS
2363    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2364    {
2365       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"() SAP Validation failed");
2366       RGSCH_FREE_MEM(srInd);
2367       RETVALUE(ret);
2368    }
2369
2370    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2371    {
2372       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"RgLiTfuSrInd()No cell exists");
2373       RETVALUE(RFAILED);
2374    }
2375 #endif
2376    /* Now call the TOM (Tfu ownership module) primitive to process further */
2377    ret = rgSCHTomSrInd (rgSchCb[inst].tfuSap[suId].cell, srInd);
2378    /* Free up the memory for the request structure */
2379    RGSCH_FREE_MEM(srInd);
2380    RETVALUE(ret);
2381 }  /* RgLiTfuSrInd */
2382
2383
2384 /**
2385  * @brief Downlink CQI indication from PHY for an UE.
2386  *
2387  * @details
2388  *
2389  *     Function : RgLiTfuDlCqiInd
2390  *      
2391  *      This API is invoked by PHY to send Downlink CQI indication to Scheduler
2392  *      on recieving downlink CQI from UE.
2393  *      This API contains downlink CQI information recieved by PHY for an UE.
2394  *           
2395  *  @param[in]  Pst              *pst
2396  *  @param[in]  SuId             suId 
2397  *  @param[in]  TfuDlCqiIndInfo  *dlCqiInd
2398  *  @return  S16
2399  *      -# ROK 
2400  *      -# RFAILED 
2401  **/
2402 #ifdef ANSI
2403 PUBLIC S16 RgLiTfuDlCqiInd
2404 (
2405 Pst                *pst, 
2406 SuId               suId, 
2407 TfuDlCqiIndInfo    *dlCqiInd
2408 )
2409 #else
2410 PUBLIC S16 RgLiTfuDlCqiInd(pst, suId, dlCqiInd)
2411 Pst                *pst; 
2412 SuId               suId; 
2413 TfuDlCqiIndInfo    *dlCqiInd;
2414 #endif
2415 {
2416    S16   ret;
2417    Inst  inst = pst->dstInst-SCH_INST_START;
2418
2419    TRC3(RgLiTfuDlCqiInd);
2420
2421    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2422    {
2423       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," SAP Validation failed");
2424       /* Free up the memory for the request structure */
2425       RGSCH_FREE_MEM(dlCqiInd);
2426       RETVALUE(ret);
2427    }
2428
2429    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2430    {
2431       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2432       RETVALUE(RFAILED);
2433    }
2434    ret = rgSCHTomDlCqiInd (rgSchCb[inst].tfuSap[suId].cell, dlCqiInd);
2435    /* Free up the memory for the request structure */
2436    RGSCH_FREE_MEM(dlCqiInd);
2437    RETVALUE(ret);
2438 }  /* RgLiTfuDlCqiInd */
2439 #ifdef TFU_UPGRADE
2440
2441 /**
2442  * @brief Raw CQI indication from PHY for an UE.
2443  *
2444  * @details
2445  *
2446  *     Function : RgLiTfuRawCqiInd
2447  *      
2448  *      This API is invoked by PHY to send Raw CQI indication to Scheduler
2449  *      on receiving Raw CQI from UE.
2450  *      This API contains Raw CQI information recieved by PHY for an UE.
2451  *           
2452  *  @param[in]  Pst              *pst
2453  *  @param[in]  SuId             suId 
2454  *  @param[in]  TfuRawCqiIndInfo  *rawCqiInd
2455  *  @return  S16
2456  *      -# ROK 
2457  *      -# RFAILED 
2458  **/
2459 #ifdef ANSI
2460 PUBLIC S16 RgLiTfuRawCqiInd
2461 (
2462 Pst                *pst, 
2463 SuId               suId, 
2464 TfuRawCqiIndInfo    *rawCqiInd
2465 )
2466 #else
2467 PUBLIC S16 RgLiTfuRawCqiInd(pst, suId, rawCqiInd)
2468 Pst                *pst; 
2469 SuId               suId; 
2470 TfuRawCqiIndInfo    *rawCqiInd;
2471 #endif
2472 {
2473    S16   ret;
2474    Inst  inst = pst->dstInst-SCH_INST_START;
2475
2476    TRC3(RgLiTfuRawCqiInd);
2477
2478 #ifdef NO_ERRCLS
2479    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2480    {
2481       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2482       /* Free up the memory for the request structure */
2483       RGSCH_FREE_MEM(rawCqiInd);
2484       RETVALUE(ret);
2485    }
2486
2487    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2488    {
2489       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," No cell exists");
2490       RETVALUE(RFAILED);
2491    }
2492 #endif
2493    ret = rgSCHTomRawCqiInd (rgSchCb[inst].tfuSap[suId].cell, rawCqiInd);
2494    /* Free up the memory for the request structure */
2495    RGSCH_FREE_MEM(rawCqiInd);
2496    RETVALUE(ret);
2497 }  /* RgLiTfuRawCqiInd */
2498
2499 /**
2500  * @brief SRS indication from PHY for an UE.
2501  *
2502  * @details
2503  *
2504  *     Function : RgLiTfuSrsInd
2505  *      
2506  *      This API is invoked by PHY to send UL SRS indication to Scheduler
2507  *      on receiving a SRS from UE.
2508  *      This API contains SRS information recieved by PHY for an UE.
2509  *           
2510  *  @param[in]  Pst              *pst
2511  *  @param[in]  SuId             suId 
2512  *  @param[in]  TfuSrsIndInfo  *srsInd
2513  *  @return  S16
2514  *      -# ROK 
2515  *      -# RFAILED 
2516  **/
2517 #ifdef ANSI
2518 PUBLIC S16 RgLiTfuSrsInd
2519 (
2520 Pst                *pst, 
2521 SuId               suId, 
2522 TfuSrsIndInfo    *srsInd
2523 )
2524 #else
2525 PUBLIC S16 RgLiTfuSrsInd(pst, suId, srsInd)
2526 Pst                *pst; 
2527 SuId               suId; 
2528 TfuSrsIndInfo    *srsInd;
2529 #endif
2530 {
2531    S16   ret;
2532    Inst  inst = pst->dstInst-SCH_INST_START;
2533
2534    TRC3(RgLiTfuSrsInd);
2535
2536    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2537    {
2538       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," SAP Validation failed");
2539       /* Free up the memory for the request structure */
2540       RGSCH_FREE_MEM(srsInd);
2541       RETVALUE(ret);
2542    }
2543
2544    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2545    {
2546       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2547       RETVALUE(RFAILED);
2548    }
2549    ret = rgSCHTomSrsInd (rgSchCb[inst].tfuSap[suId].cell, srsInd);
2550    /* Free up the memory for the request structure */
2551    RGSCH_FREE_MEM(srsInd);
2552    RETVALUE(ret);
2553 }  /* RgLiTfuSrsInd */
2554
2555 #endif 
2556
2557 /**
2558  * @brief DOA indication from PHY for an UE.
2559  *
2560  * @details
2561  *
2562  *     Function : RgLiTfuDoaInd
2563  *      
2564  *      This API is invoked by PHY to send Direction Of Arrival to Scheduler
2565  *      on calculating DOA at PHYSICAL LAYER for an UE.
2566  *      This API contains DOA information calculated by PHY for an UE.
2567  *           
2568  *  @param[in]  Pst              *pst
2569  *  @param[in]  SuId             suId 
2570  *  @param[in]  TfuDoaIndInfo    *doaInd
2571  *  @return  S16
2572  *      -# ROK 
2573  *      -# RFAILED 
2574  **/
2575 #ifdef ANSI
2576 PUBLIC S16 RgLiTfuDoaInd 
2577 (
2578 Pst                *pst, 
2579 SuId               suId, 
2580 TfuDoaIndInfo      *doaInd
2581 )
2582 #else
2583 PUBLIC S16 RgLiTfuDoaInd(pst, suId, doaInd)
2584 Pst                *pst; 
2585 SuId               suId; 
2586 TfuDoaIndInfo      *doaInd;
2587 #endif
2588 {
2589    S16   ret;
2590    Inst  inst = pst->dstInst-SCH_INST_START;
2591
2592    TRC2(RgLiTfuDoaInd);
2593
2594    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2595    {
2596       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2597       /* Free up the memory for the request structure */
2598       RGSCH_FREE_MEM(doaInd);
2599       RETVALUE(ret);
2600    }
2601
2602    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2603    {
2604       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2605       RETVALUE(RFAILED);
2606    }
2607    ret = rgSCHTomDoaInd (rgSchCb[inst].tfuSap[suId].cell, doaInd);
2608    /* Free up the memory for the request structure */
2609    RGSCH_FREE_MEM(doaInd);
2610    RETVALUE(ret);
2611 }  /* RgLiTfuDlCqiInd */
2612
2613 /**
2614  * @brief CRC indication from PHY.
2615  *
2616  * @details
2617  *
2618  *     Function : RgLiTfuCrcInd
2619  *      
2620  *      This API is invoked by PHY to give CRC indication to scheduler.
2621  *           
2622  *  @param[in]  Pst               *pst
2623  *  @param[in]  SuId              suId 
2624  *  @param[in]  TfuCrcIndInfo *crcInd
2625  *  @return  S16
2626  *      -# ROK 
2627  *      -# RFAILED 
2628  **/
2629 #ifdef ANSI
2630 PUBLIC S16 RgLiTfuCrcInd
2631 (
2632 Pst                *pst, 
2633 SuId               suId, 
2634 TfuCrcIndInfo  *crcInd
2635 )
2636 #else
2637 PUBLIC S16 RgLiTfuCrcInd (pst, suId, crcInd)
2638 Pst                *pst; 
2639 SuId               suId; 
2640 TfuCrcIndInfo  *crcInd;
2641 #endif
2642 {
2643    S16              ret;
2644    Inst             inst      = pst->dstInst-SCH_INST_START;
2645
2646    TRC3(RgLiTfuCrcInd);
2647 #ifdef XEON_SPECIFIC_CHANGES
2648 struct timeval start6, end6;
2649 gettimeofday(&start6, NULL);
2650 #endif
2651 #ifndef NO_ERRCLS
2652    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2653    {
2654       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2655       RGSCH_FREE_MEM(crcInd);
2656       RETVALUE(ret);
2657    }
2658
2659    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2660    {
2661       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2662       RETVALUE(RFAILED);
2663    }
2664 #endif
2665
2666    /* Now call the TOM (Tfu ownership module) primitive to process further */
2667    ret = rgSCHTomCrcInd(rgSchCb[inst].tfuSap[suId].cell, crcInd);
2668    /* Free up the memory for the request structure */
2669    RGSCH_FREE_MEM(crcInd);
2670 #ifdef XEON_SPECIFIC_CHANGES
2671 gettimeofday(&end6, NULL);
2672 #endif
2673    RETVALUE(ret);
2674 }  /* RgLiTfuCrcInd */
2675
2676 /**
2677  * @brief Timing Advance indication from PHY.
2678  *
2679  * @details
2680  *
2681  *     Function : RgLiTfuTimingAdvInd
2682  *      
2683  *      This API is invoked by PHY to indicate timing advance to Scheduler for
2684  *       an UE.
2685  *           
2686  *  @param[in]  Pst                  *pst
2687  *  @param[in]  SuId                 suId 
2688  *  @param[in]  TfuTimingAdvIndInfo  *timingAdvInd
2689  *  @return  S16
2690  *      -# ROK 
2691  *      -# RFAILED 
2692  **/
2693 #ifdef ANSI
2694 PUBLIC S16 RgLiTfuTimingAdvInd
2695 (
2696 Pst                  *pst, 
2697 SuId                 suId, 
2698 TfuTimingAdvIndInfo  *timingAdvInd
2699 )
2700 #else
2701 PUBLIC S16 RgLiTfuTimingAdvInd(pst, suId, timingAdvInd)
2702 Pst                  *pst; 
2703 SuId                 suId; 
2704 TfuTimingAdvIndInfo  *timingAdvInd;
2705 #endif
2706 {
2707    S16   ret;
2708    Inst  inst = pst->dstInst-SCH_INST_START;
2709
2710    TRC3(RgLiTfuTimingAdvInd);
2711
2712    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2713    {
2714       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2715       /* Free up the memory for the request structure */
2716       RGSCH_FREE_MEM(timingAdvInd);
2717       RETVALUE(ret);
2718    }
2719
2720    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2721    {
2722       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2723       RETVALUE(RFAILED);
2724    }
2725    /* Now call the TOM (Tfu ownership module) primitive to process further */
2726    ret = rgSCHTomTimingAdvInd(rgSchCb[inst].tfuSap[suId].cell, timingAdvInd);
2727    /* Free up the memory for the request structure */
2728    RGSCH_FREE_MEM(timingAdvInd);
2729    RETVALUE(ret);
2730 }  /* RgLiTfuTimingAdvInd */
2731
2732
2733 /**
2734  * @brief Transmission time interval indication from PHY.
2735  *
2736  * @details
2737  *
2738  *     Function : RgLiTfuSchTtiInd 
2739  *      
2740  *      This API is invoked by PHY to indicate TTI indication to Scheduler for
2741  *      a cell.
2742  *           
2743  *  @param[in]  Pst            *pst
2744  *  @param[in]  SuId           suId 
2745  *  @param[in]  TfuTtiIndInfo  *ttiInd
2746  *  @return  S16
2747  *      -# ROK 
2748  *      -# RFAILED 
2749  **/
2750 #ifdef ANSI
2751 PUBLIC S16 RgLiTfuSchTtiInd 
2752 (
2753 Pst                 *pst, 
2754 SuId                suId, 
2755 TfuTtiIndInfo       *ttiInd
2756 )
2757 #else
2758 PUBLIC S16 RgLiTfuSchTtiInd(pst, suId, ttiInd)
2759 Pst                 *pst; 
2760 SuId                suId; 
2761 TfuTtiIndInfo       *ttiInd;
2762 #endif
2763 {
2764    S16   ret = ROK;
2765    Inst  inst = pst->dstInst-SCH_INST_START;
2766
2767    TRC3(RgLiTfuSchTtiInd);
2768
2769    
2770    /* Removing the validation with every TTI - for optimization */
2771 #ifndef NO_ERRCLS 
2772    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2773    {
2774       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2775       RETVALUE(ret);
2776    }
2777 #endif
2778    /* Moved check for cell outside ERRCLS*/
2779
2780    /* Now call the TOM (Tfu ownership module) primitive to process further */
2781    rgSCHTomTtiInd(ttiInd, inst);
2782
2783    RETVALUE(ret);
2784 }  /* RgLiTfuSchTtiInd */
2785
2786 /************* RGM  Interface ****************/
2787 /**
2788  * @brief API for bind request from RRM towards MAC. 
2789  *
2790  * @details
2791  *
2792  *     Function: RgUiRgmBndReq
2793  *     
2794  *     This API is invoked by RRM towards MAC to bind RGM SAP. 
2795  *     These API validates the Pst, spId, suId and sends the bind confirm to
2796  *     RRM.
2797  *
2798  *           
2799  *  @param[in]  Pst   *pst
2800  *  @param[in]  SuId  suId
2801  *  @param[in]  SpId  spId
2802  *  @return  S16
2803  *      -# ROK 
2804  *      -# RFAILED 
2805  **/
2806 #ifdef ANSI
2807 PUBLIC S16 RgUiRgmBndReq
2808 (
2809 Pst   *pst, 
2810 SuId  suId,
2811 SpId  spId
2812 )
2813 #else
2814 PUBLIC S16 RgUiRgmBndReq(pst, suId, spId)
2815 Pst   *pst; 
2816 SuId  suId;
2817 SpId  spId;
2818 #endif
2819 {
2820    S16       ret = ROK;
2821    Pst       tmpPst;   /* Temporary Post Structure */
2822    Inst      instId = pst->dstInst-SCH_INST_START;
2823
2824    TRC3(RgUiRgmBndReq)
2825    
2826    
2827    tmpPst.prior       = pst->prior;
2828    tmpPst.route       = pst->route;
2829    tmpPst.selector    = pst->selector;
2830    tmpPst.region      = rgSchCb[instId].rgSchInit.region;
2831    tmpPst.pool        = rgSchCb[instId].rgSchInit.pool;
2832
2833    tmpPst.srcProcId   = rgSchCb[instId].rgSchInit.procId;
2834    tmpPst.srcEnt      = rgSchCb[instId].rgSchInit.ent;
2835    tmpPst.srcInst     = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
2836
2837    tmpPst.event       = EVTNONE;
2838
2839    tmpPst.dstProcId   = pst->srcProcId;
2840    tmpPst.dstEnt      = pst->srcEnt;
2841    tmpPst.dstInst     = pst->srcInst;
2842
2843    /*TODO remove follo statement*/
2844    rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2845
2846    if(spId < rgSchCb[instId].numSaps)
2847    {
2848       /* Check the state of the SAP */
2849       switch (rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2850       {
2851          /* This case might not be needed if SAP not configured then it will go
2852           * to else of above if condition */
2853          case LRG_UNBND: /* SAP is not bound */
2854                  RLOG0(L_DEBUG,"SAP is not yet bound");
2855             rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_BND;
2856             rgSchCb[instId].rgmSap[spId].sapCfg.suId = suId;
2857             /* Send Bind Confirm with status as SUCCESS */
2858             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2859              /*Indicate to Layer manager  */
2860             break;
2861          case LRG_BND: /* SAP is already bound*/
2862                  RLOG0(L_DEBUG,"SAP is already bound");
2863             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2864             break;
2865          default: /* Should Never Enter here */
2866 #if (ERRCLASS & ERRCLS_ADD_RES) 
2867             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG001, 
2868                  (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2869                   "Invalid SAP State:RgUiRgmBndReq failed\n");
2870 #endif
2871             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_NOK);
2872             break;
2873       }
2874    }
2875    else
2876    {
2877 #if (ERRCLASS & ERRCLS_ADD_RES)      
2878 /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state 
2879    to spId to avoid seg fault due to invalid sapID */
2880       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG002,
2881             (ErrVal)spId, "Invalid SAP Id:RgUiRrmBndReq failed\n");
2882 #endif
2883       ret = RgUiRgmBndCfm(&tmpPst, suId, CM_BND_NOK);
2884    }
2885    RETVALUE(ret);
2886 }  /* RgUiRgmBndReq */
2887
2888 /**
2889  * @brief API for unbind request from RRM towards MAC. 
2890  *
2891  * @details
2892  *
2893  *     Function: RgUiRgmUbndReq
2894  *     
2895  *     This API is invoked by RRM towards MAC to unbind RGM SAP. 
2896  *     These API validates the Pst, spId, suId and transfers the unbind request 
2897  *     specific information to corresponding ownership module (GOM) API.
2898  *
2899  *           
2900  *  @param[in]  Pst    *pst
2901  *  @param[in]  SuId   suId
2902  *  @param[in]  Reason reason
2903  *  @return  S16
2904  *      -# ROK 
2905  *      -# RFAILED 
2906  **/
2907 #ifdef ANSI
2908 PUBLIC S16 RgUiRgmUbndReq
2909 (
2910 Pst    *pst,
2911 SpId   spId,
2912 Reason reason
2913 )
2914 #else
2915 PUBLIC S16 RgUiRgmUbndReq(pst, spId, reason)
2916 Pst    *pst; 
2917 SpId   spId;
2918 Reason reason;
2919 #endif
2920 {
2921    Inst instId = pst->dstInst-SCH_INST_START;
2922    TRC3(RgUiRgmUbndReq)
2923    
2924
2925    /* SAP Id validation */
2926    if (spId < rgSchCb[instId].numSaps)
2927    {
2928       switch(rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2929       {
2930          case LRG_BND: /* SAP is already bound*/
2931             /* setting SAP state to UN BOUND */
2932                  RLOG0(L_DEBUG,"SAP is already bound");
2933             rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2934             break;
2935          default:
2936 #if (ERRCLASS & ERRCLS_ADD_RES)      
2937             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG003,
2938                    (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2939                   "Invalid SAP State: RgUiRgmUbndReq failed\n");
2940 #endif
2941             RETVALUE(RFAILED);
2942       }
2943    }
2944    else
2945    {
2946 #if (ERRCLASS & ERRCLS_ADD_RES)      
2947       RGSCHLOGERROR(instId,ERRCLS_INT_PAR, ERG004, 
2948             (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2949             "Invalid SAP Id:RgUiRgmUbndReq failed\n");
2950 #endif
2951       RETVALUE(RFAILED);
2952    }
2953    RETVALUE(ROK);
2954 }  /* RgUiRgmUbndReq */
2955
2956
2957 /**
2958  * @brief API for start or stop PRB reporting from RRM towards MAC. 
2959  *
2960  * @details
2961  *
2962  *     Function: RgUiRgmCfgPrbRprt
2963  *     
2964  *     This API is invoked by RRM towards MAC to start or stop calculating
2965  *     Average PRB usage in downlink and uplink. The average PRB usage will
2966  *     be reported to RRM based on confiured periodicity.
2967  *
2968  *           
2969  *  @param[in]  Pst   *pst
2970  *  @param[in]  SuId  suId
2971  *  @param[in]  SpId  spId
2972  *  @return  S16
2973  *      -# ROK 
2974  *      -# RFAILED 
2975  **/
2976 #ifdef ANSI
2977 PUBLIC S16 RgUiRgmCfgPrbRprt
2978 (
2979 Pst   *pst, 
2980 SpId  spId,
2981 RgmPrbRprtCfg   *prbRprtCfg
2982 )
2983 #else
2984 PUBLIC S16 RgUiRgmCfgPrbRprt(pst, spId, prbRprtCfg)
2985 Pst   *pst; 
2986 SpId  spId;
2987 RgmPrbRprtCfg   *prbRprtCfg;
2988 #endif
2989 {
2990 /* Initalize*/
2991    RgSchCellCb   *cell;
2992    RgSchPrbUsage *prbUsage;
2993    Inst          inst = (pst->dstInst  - SCH_INST_START);
2994
2995    TRC2(RgUiRgmCfgPrbRprt);
2996    cell = rgSchCb[inst].rgmSap[spId].cell;
2997    prbUsage = &cell->prbUsage;
2998    prbUsage->prbRprtEnabld = prbRprtCfg->bConfigType;
2999    prbUsage->rprtPeriod = prbRprtCfg->usPrbAvgPeriodicty;
3000    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, prbUsage->startTime, 1);
3001
3002    /* clear the qciPrbRpts for all GBR QCIs */
3003    cmMemset((U8*)&prbUsage->qciPrbRpts[0], 0, 
3004              (RGM_MAX_QCI_REPORTS * sizeof(RgSchQciPrbUsage)));
3005
3006    RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
3007              "RgUiRgmCfgPrbRprt config type %d with the report period %d",
3008              prbUsage->prbRprtEnabld,prbUsage->rprtPeriod);
3009
3010    /* ccpu00134393 : mem leak fix */
3011       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
3012   
3013    RETVALUE(ROK);
3014 }
3015 /**
3016  * @brief ERROR INDICATION from PHY for the i failed unlicensed Scell transmission. 
3017  *
3018  * @details
3019  *
3020  *     Function : RgLiTfuErrInd
3021  *      
3022  *      This API is invoked by PHY to send ERROR INDICATION to scheduler 
3023  *      Currently invoked in the cases when the Unlicensed SCell transmission
3024  *      fails.
3025  *      This API contains the Cell and subframe information for which the
3026  *      transmission failed. 
3027  *           
3028  *  @param[in]  Pst                *pst
3029  *  @param[in]  SuId               suId 
3030  *  @param[in]  TfuErrIndInfo      *errIndInfo 
3031  *  @return  S16
3032  *      -# ROK 
3033  *      -# RFAILED 
3034  **/
3035 #ifdef ANSI
3036 PUBLIC S16 RgLiTfuErrInd
3037 (
3038 Pst                *pst, 
3039 SuId               suId, 
3040 TfuErrIndInfo       *errInd
3041 )
3042 #else
3043 PUBLIC S16 RgLiTfuErrInd(pst, suId, errInd)
3044 Pst                *pst; 
3045 SuId               suId; 
3046 TfuErrIndInfo       *errInd;
3047 #endif
3048 {
3049    S16   ret = ROK;
3050 #ifdef LTE_ADV
3051    Inst  inst = (pst->dstInst - SCH_INST_START);
3052 #endif
3053
3054    TRC3(RgLiTfuErrInd);
3055
3056 #ifndef NO_ERRCLS
3057    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
3058    {
3059
3060       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
3061       RETVALUE(ret);
3062    }
3063
3064    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
3065    {
3066       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
3067       RETVALUE(RFAILED);
3068    }
3069 #endif
3070
3071 #ifdef LTE_ADV
3072    /* Now call the TOM (Tfu ownership module) primitive to process further */
3073    ret = rgSCHLaaErrInd(rgSchCb[inst].tfuSap[suId].cell, errInd);
3074 #endif
3075    RETVALUE(ret);
3076 }  /* RgLiTfuErrInd */
3077
3078
3079 \f
3080 /**********************************************************************
3081  
3082          End of file
3083 **********************************************************************/