Removed ANSI from multiple folder Part - 1 [JIRA ID - ODUHIGH-249]
[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 "common_def.h"
41 #include "lrg.h"
42 #include "rgr.h"
43 #include "tfu.h"
44 #include "rgm.h"
45 #include "rg_env.h"
46 #include "rg_sch_inf.h"
47 #include "rg_sch.h"
48 #include "rg_sch_err.h"
49 #include "rg_sch_cmn.h"
50 #include "rl_interface.h"
51 #include "rl_common.h"
52
53 /* header/extern include files (.x) */
54 #include "tfu.x"           /* TFU types */
55 #include "lrg.x"           /* layer management typedefs for MAC */
56 #include "rgr.x"           /* layer management typedefs for MAC */
57 #include "rgm.x"           /* layer management typedefs for MAC */
58 #include "rg_sch_inf.x"         /* typedefs for Scheduler */
59 #include "rg_sch.x"        /* typedefs for Scheduler */
60 #include "rg_sch_cmn.x"
61
62 #ifdef EMTC_ENABLE
63 S16 rgEmtcMacSchUeDelInd ARGS((RgSchCellCb *cell,RgInfUeDelInd *ueDelInd));
64 S16 rgSCHGomEmtcHndlSiCfg ARGS((
65 Region        reg,
66 Pool          pool,
67 RgSchCb       *instCb,
68 SpId          spId,
69 RgrCfgTransId transId,
70 RgrSiCfgReqInfo *cfgReqInfo
71 ));
72 S16 rgSCHGomEmtcHndlWarningSiCfg ARGS((
73 Region        reg,
74 Pool          pool,
75 RgSchCb       *instCb,
76 SpId          spId,
77 RgrCfgTransId transId,
78 RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
79 ));
80 #endif
81 /* local defines */
82 /************** LRG Interface ****************/
83 \f
84 /**
85  * @brief Layer Manager Control request handler. 
86  *
87  * @details
88  *
89  *     Function : RgMiLrgSchCntrlReq
90  *     
91  *     This function handles the control
92  *     request received from the Layer Manager.
93  *      -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
94  *      and cntrl->t.cntrl.subAction, it performs the appropriate control action
95  *      of SAP (enable/disable) and layer shutdown.
96  *      -# Invokes the RgMiLrgSchCntrlCfm to send back the confirmation to LM.
97  *     
98  *  @param[in]  Pst *pst, the post structure     
99  *  @param[in]  RgMngmt *cntrl, the control parameter's structure
100  *  @return  S16
101  *      -# ROK
102  **/
103 S16 RgMiLrgSchCntrlReq
104 (
105 Pst      *pst,    /* post structure  */
106 RgMngmt  *cntrl   /* control structure  */
107 )
108 {
109    S16       ret = ROK;            /* return value */
110    Pst       cfmPst;
111    RgMngmt   cfm;
112    
113    Inst      inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
114
115    /* Fill the post structure for sending the confirmation */
116    SchFillCfmPst(pst, &cfmPst, cntrl);
117
118    /* Initialize the cfg cfm structure 
119    if (SGetSBuf(cfmPst.region, cfmPst.pool, (Data **)&cfm, sizeof(RgMngmt))
120       != ROK)
121    {
122       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Memory Unavailable for Confirmation");
123       SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt));
124       return ROK;
125    } */
126    memset(&cfm, 0, sizeof(RgMngmt));
127
128 #ifdef LMINT3
129    cfm.hdr.transId =
130       cntrl->hdr.transId;
131 #endif
132
133    cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
134    cfm.t.cntrl.action = cntrl->t.cntrl.action;
135    cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
136
137    /* Check if General Config Done*/
138    if(rgSchCb[inst].rgSchInit.cfgDone != TRUE)
139    {
140       cfm.cfm.status = LCM_PRIM_NOK;
141       cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
142       cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
143       RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
144       RLOG_ARG0(L_ERROR,DBG_INSTID,inst, "Gen Cfg not done.");
145       /*      SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt)); */
146       return ROK;
147    }
148
149    /* General Config done, process the Control request */   
150    switch(cntrl->hdr.elmId.elmnt)
151    {
152       case STGEN:
153          rgSCHLmmGenCntrl(cntrl, &cfm, &cfmPst);
154          break;
155       case STTFUSAP:
156       case STRGRSAP:
157          rgSCHLmmSapCntrl(cntrl, &cfm, &cfmPst);
158          break;
159       default:
160          cfm.cfm.status = LCM_PRIM_NOK;
161          cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
162          RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
163          RLOG_ARG1(L_ERROR,DBG_INSTID,inst, "invalid elmnt=%d",
164                   cntrl->hdr.elmId.elmnt);
165          break;
166    }
167    /*   SPutSBuf(pst->region, pst->pool, (Data *)cntrl, sizeof(RgMngmt)); */
168    return (ret);
169 }/*-- RgMiLrgSchCntrlReq --*/
170
171 #ifdef LTE_L2_MEAS
172 /**
173  * @brief Layer Manager L2 Measurement request handler. 
174  *
175  * @details
176  *
177  *     Function : RgMiLrgSchL2MeasReq
178  *     
179  *     This function handles the control
180  *     measurement request received from the Layer Manager.
181  *     
182  *  @param[in]  Pst *pst, the post structure     
183  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement request info
184  *  @return  S16
185  *      -# ROK
186  **/
187 S16 RgMiLrgSchL2MeasReq
188 (
189 Pst               *pst,     /* post structure  */
190 LrgSchMeasReqInfo *measInfo /* Meas Req Info */
191 )
192 {
193    Pst                 cfmPst;
194    RgSchCellCb         *cell;
195    RgSchErrInfo        err;
196    S16                 ret = ROK; 
197    RgSchCb             *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
198 #if (ERRCLASS & ERRCLS_ADD_RES) 
199    CmLList             *lnk;
200 #endif
201    uint32_t            idx;
202    RgSchL2MeasCb       *measCb = NULLP;
203 #ifdef DEBUGP
204    Inst      inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
205 #endif
206
207    err.errType  = 0;
208    err.errCause = 0;
209
210
211    /* Find the cellCb using cellId in measInfo. Iterate through all cells
212     * in rgrsapCb in RgschCb */
213    cell = NULLP;
214    for (idx = 0; idx < instCb->numSaps; idx++)
215    {
216       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
217       {
218          /* got the cell break the loop */
219          cell = instCb->rgrSap[idx].cell;
220          break;
221       }
222    }
223    /* If no cellCb return Err with Invalid Cell Id */
224    if (cell == NULLP)
225    {
226       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
227       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_CELLID);
228       rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
229       RLOG_ARG2(L_ERROR,DBG_INSTID,inst, 
230                "Meas req Failed.Invalid Cell Id errType(%d) errCause(%d)",
231                err.errType, err.errCause);
232       return RFAILED;
233    }
234    /* Validate for Meas Types */
235    if ( (ret = rgSCHUtlValidateMeasReq(cell, measInfo, &err)) != ROK)
236    {
237       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
238       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_MEASTYPE);
239       rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
240       RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
241                "Meas req Failed.Invalid Measurement Type"
242                "errCasue(%d) errType(%d)", err.errType, err.errCause);
243       return RFAILED;
244    }
245    /* Iterate through all meas requests in l2mList in cellCb */
246 #if (ERRCLASS & ERRCLS_ADD_RES) 
247    lnk = cell->l2mList.first;
248    while(lnk != NULLP)
249    {
250       /* Get the MeasCb : RgSchL2MeasCb */
251       measCb = (RgSchL2MeasCb *)lnk->node;
252       lnk = lnk->next;
253       if (measCb->measReq.hdr.transId == measInfo->hdr.transId)
254       {
255          rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
256          RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_DUP_TRANSID);
257          rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
258          RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
259                   "Meas req Failed.Dublicate TransId"
260                   "errType(%d) errCause(%d)", err.errType, err.errCause);
261          return RFAILED;
262       }
263    }
264 #endif
265    /* Call L2M Function to store Meas req */
266    ret = rgSchL2mMeasReq(cell, measInfo, err);
267    if (ret != ROK)
268    {
269       rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
270       RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_L2MEAS_FAILED);
271       rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
272       RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId, 
273                "Meas req Failed.errType(%d) errCause(%d)",
274                err.errType, err.errCause);
275       return RFAILED;
276    }
277    return (ret);
278 } /* -- RRgMiLrgSchL2MeasReq-- */
279
280 /**
281  * @brief Layer Manager L2 Measurement Stop request handler. 
282  *
283  * @details
284  *
285  *     Function : RgMiLrgSchL2MeasStopReq
286  *     
287  *     This function handles the control
288  *     measurement stop request received from the Layer Manager.
289  *     
290  *  @param[in]  Pst *pst, the post structure     
291  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement stop request info
292  *  @return  S16
293  *      -# ROK
294  **/
295 S16 RgMiLrgSchL2MeasStopReq
296 (
297 Pst               *pst,     /* post structure  */
298 LrgSchMeasStopReqInfo *measInfo /* Meas Req Info */
299 )
300 {
301    S16               ret = ROK;
302    RgSchCellCb       *cell = NULLP;
303    RgSchCb           *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
304    CmLList           *node = NULLP;
305    RgSchL2MeasCb     *measCb = NULLP;
306    LrgSchMeasCfmInfo measCfm;
307    uint8_t           idx;
308
309    for (idx = 0; idx < instCb->numSaps; idx++)
310    {
311       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
312       {
313          /* got the cell break the loop */
314          cell = instCb->rgrSap[idx].cell;
315          break;
316       }
317    }
318    if (cell == NULLP)
319    {
320       RLOG_ARG0(L_ERROR,DBG_CELLID,measInfo->cellId,
321                "Stop req Failed.Invalid Cell Id ");
322       return RFAILED;
323    }
324    memset(&measCfm, 0, sizeof(LrgSchMeasCfmInfo));
325    node = cell->l2mList.first;
326    while(node != NULLP)
327    {
328       measCb = (RgSchL2MeasCb *)(node)->node;
329
330       node = (node)->next;
331       cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
332       rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,
333             sizeof(RgSchL2MeasCb));    
334    }
335
336    if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
337    {
338       RgInfL2MeasStopReq measStopReq;
339       Pst               pstMac;
340       memset(&measStopReq, 0, sizeof(RgInfL2MeasStopReq));
341       measStopReq.transId  = measInfo->hdr.transId;
342       measStopReq.measType = measInfo->measType;
343       /* measReq.timePrd  = measInfo->timePrd; */
344       measStopReq.cellId   = measInfo->cellId;
345       rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
346       RgSchMacL2MeasStop(&pstMac,&measStopReq);
347    }
348    else
349    { 
350       RgMiLrgSchL2MeasStopCfm(&(rgSchCb[cell->instIdx].rgSchInit.lmPst),
351             &measCfm);
352    }
353    return (ret);
354 }/*RgMiLrgSchL2MeasStopReq*/
355 /**
356  * @brief Layer Manager L2 Measurement request handler. 
357  *        for Send l2 measurement req
358  * @details
359  *
360  *     Function : RgMiLrgSchL2MeasSendReq
361  *     
362  *     This function handles the control
363  *     measurement send request received from the Layer Manager.
364  *     
365  *  @param[in]  Pst *pst, the post structure     
366  *  @param[in]  LrgSchMeasReqInfo *measInfo, measurement stop request info
367  *  @return  S16
368  *      -# ROK
369  **/
370 S16 RgMiLrgSchL2MeasSendReq
371 (
372 Pst               *pst,     /* post structure  */
373 LrgSchMeasSndReqInfo *measInfo /* Meas Req Info */
374 )
375 {
376    S16                 ret = ROK;
377    RgSchCellCb         *cell;
378    RgSchCb             *instCb =  &rgSchCb[(pst->dstInst - SCH_INST_START)];
379    uint8_t             idx;
380
381    cell = NULLP;
382    for (idx = 0; idx < instCb->numSaps; idx++)
383    {
384       if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
385       {
386          /* got the cell break the loop */
387          cell = instCb->rgrSap[idx].cell;
388          break;
389       }
390    }
391    if (cell == NULLP)
392    {
393       RLOG_ARG0(L_ERROR,DBG_CELLID,measInfo->cellId,
394                "Send req Failed.Invalid Cell Id");
395       return RFAILED;
396    }
397
398    if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
399    {
400       RgInfL2MeasSndReq measSndReq;
401       Pst               pstMac;
402       memset(&measSndReq, 0, sizeof(RgInfL2MeasSndReq));
403       measSndReq.transId  = measInfo->hdr.transId;
404       measSndReq.measType = measInfo->measType;
405       measSndReq.timePrd  = measInfo->timePrd;
406       measSndReq.cellId   = measInfo->cellId;
407       rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
408       RgSchMacL2MeasSend(&pstMac, &measSndReq);
409    }
410    else
411    { 
412       cell->sndL2Meas = TRUE;
413    }
414
415    return (ret);
416 }/*RgMiLrgSchL2MeasSendReq*/
417 #endif /* LTE_L2_MEAS */
418
419
420
421
422 /************* RGR  Interface ****************/
423 /**
424  * @brief API for bind request from RRM towards MAC. 
425  *
426  * @details
427  *
428  *     Function: RgUiRgrBndReq
429  *     
430  *     This API is invoked by RRM towards MAC to bind RGR SAP. 
431  *     These API validates the Pst, spId, suId and sends the bind confirm to
432  *     RRM.
433  *
434  *           
435  *  @param[in]  Pst   *pst
436  *  @param[in]  SuId  suId
437  *  @param[in]  SpId  spId
438  *  @return  S16
439  *      -# ROK 
440  *      -# RFAILED 
441  **/
442 S16 RgUiRgrBndReq(Pst   *pst, SuId  suId, SpId  spId)
443 {
444    S16       ret = ROK;
445    Pst       tmpPst;   /* Temporary Post Structure */
446    Inst      instId = pst->dstInst-SCH_INST_START;
447    RgUstaDgn dgn;      /* Alarm diagnostics structure */
448
449    tmpPst.prior       = pst->prior;
450    tmpPst.route       = pst->route;
451    tmpPst.selector    = pst->selector;
452    tmpPst.region      = rgSchCb[instId].rgSchInit.region;
453    tmpPst.pool        = rgSchCb[instId].rgSchInit.pool;
454    tmpPst.srcProcId   = rgSchCb[instId].rgSchInit.procId;
455    tmpPst.srcEnt      = rgSchCb[instId].rgSchInit.ent;
456    tmpPst.srcInst     = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
457    tmpPst.event       = EVTNONE;
458    tmpPst.dstProcId   = pst->srcProcId;
459    tmpPst.dstEnt      = pst->srcEnt;
460    tmpPst.dstInst     = pst->srcInst;
461
462    if(spId < rgSchCb[instId].numSaps)
463    {
464       /* Check the state of the SAP */
465       switch (rgSchCb[instId].rgrSap[spId].sapSta.sapState)
466       {
467          /* This case might not be needed if SAP not configured then it will go
468           * to else of above if condition */
469          case LRG_UNBND: /* SAP is not bound */
470             RLOG0(L_DEBUG,"SAP Not yet bound");
471             rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_BND;
472             rgSchCb[instId].rgrSap[spId].sapCfg.suId = suId;
473             /* Send Bind Confirm with status as SUCCESS */
474             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
475             /*Indicate to Layer manager  */
476             rgSCHUtlFillDgnParams(instId, &dgn, LRG_USTA_DGNVAL_MEM); 
477             ret = rgSCHLmmStaInd(instId, LCM_CATEGORY_INTERFACE,
478                   LRG_EVENT_RGRSAP_ENB, LCM_CAUSE_UNKNOWN, &dgn);
479             break;
480          case LRG_BND: /* SAP is already bound*/
481             RLOG0(L_DEBUG,"SAP is already bound");
482             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
483             break;
484          default: /* Should Never Enter here */
485 #if (ERRCLASS & ERRCLS_ADD_RES) 
486             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG001, 
487                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
488                   "Invalid SAP State:RgUiRrgBndReq failed\n");
489 #endif
490             ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_NOK);
491             break;
492       }
493    }
494    else
495    {
496 #if (ERRCLASS & ERRCLS_ADD_RES)      
497       /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state 
498          to spId to avoid seg fault due to invalid sapID */
499       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG002,
500             (ErrVal)spId, "Invalid SAP Id:RgUiRrgBndReq failed\n");
501 #endif
502       ret = RgUiRgrBndCfm(&tmpPst, suId, CM_BND_NOK);
503    }
504    return (ret);
505 }  /* RgUiRgrBndReq */
506
507 /**
508  * @brief API for unbind request from RRM towards MAC. 
509  *
510  * @details
511  *
512  *     Function: RgUiRgrUbndReq
513  *     
514  *     This API is invoked by RRM towards MAC to unbind RGR SAP. 
515  *     These API validates the Pst, spId, suId and transfers the unbind request 
516  *     specific information to corresponding ownership module (GOM) API.
517  *
518  *           
519  *  @param[in]  Pst    *pst
520  *  @param[in]  SuId   suId
521  *  @param[in]  Reason reason
522  *  @return  S16
523  *      -# ROK 
524  *      -# RFAILED 
525  **/
526 S16 RgUiRgrUbndReq(Pst *pst,SpId spId,Reason reason)
527 {
528    Inst instId = pst->dstInst-SCH_INST_START;
529
530    /* SAP Id validation */
531    if (spId < rgSchCb[instId].numSaps)
532    {
533       switch(rgSchCb[instId].rgrSap[spId].sapSta.sapState)
534       {
535          case LRG_BND: /* SAP is already bound*/
536             RLOG0(L_DEBUG,"SAP is already bound");
537             /* setting SAP state to UN BOUND */
538             rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_UNBND;
539             break;
540          default:
541 #if (ERRCLASS & ERRCLS_ADD_RES)      
542             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG003,
543                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
544                   "Invalid SAP State: RgUiRgrUbndReq failed\n");
545 #endif
546             return RFAILED;
547       }
548    }
549    else
550    {
551 #if (ERRCLASS & ERRCLS_ADD_RES)      
552       RGSCHLOGERROR(instId,ERRCLS_INT_PAR, ERG004, 
553             (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
554             "Invalid SAP Id:RgUiRgrUbndReq failed\n");
555 #endif
556       return RFAILED;
557    }
558    return ROK;
559 }  /* RgUiRgrUbndReq */
560
561 #ifdef RGR_SI_SCH
562 /**
563  * @brief API for SI configuration request from RRM towards MAC. 
564  *
565  * @details
566  *
567  *     Function: RgUiRgrSiCfgReq
568  *     
569  *     This API is invoked by RRM towards MAC to configure SI at MAC. 
570  *     These API validates the Pst, spId, suId and transfers the 
571  *     config request specific information to corresponding ownership 
572  *     module (GOM) API.
573  *
574  *           
575  *  @param[in]  Pst           *pst
576  *  @param[in]  SpId          spId
577  *  @param[in]  RgrCfgTransId transId
578  *  @param[in]  RgrSiCfgReqInfo *cfgReqInfo
579  *  @return  S16
580  *      -# ROK 
581  *      -# RFAILED 
582  **/
583 S16 RgUiRgrSiCfgReq(Pst *pst, SpId  spId,RgrCfgTransId transId,RgrSiCfgReqInfo *cfgReqInfo)
584 {
585    S16       ret       = ROK;
586    uint8_t   cfmStatus = RGR_CFG_CFM_NOK;
587    uint8_t   prntTrans[RGR_CFG_TRANSID_SIZE+1];
588    Inst      instId = pst->dstInst-SCH_INST_START;
589
590    memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
591    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
592
593
594    if (cfgReqInfo == NULLP)
595    {
596       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
597                    "is NULL");
598       rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
599       return RFAILED;
600    }
601
602    if (spId < rgSchCb[instId].numSaps)
603    {
604       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
605       {
606 #if (ERRCLASS & ERRCLS_ADD_RES)      
607          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG007, 
608                   (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
609                   "Invalid SAP State: RgUiRgrSiCfgReq failed\n");
610 #endif
611          SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
612                                           (Size)sizeof(*cfgReqInfo));
613          rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
614          return RFAILED;
615       }
616    }
617    else
618    {
619 #if (ERRCLASS & ERRCLS_ADD_RES)      
620       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG008,
621             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
622             "Invalid SAP Id:RgUiRgrSiCfgReq failed\n");
623 #endif
624       SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo,
625                                    (Size)sizeof(*cfgReqInfo));
626       rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus); 
627       return RFAILED;
628    }
629
630    /* Handle configuration */
631 #ifdef EMTC_ENABLE
632 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
633 {
634    ret = rgSCHGomEmtcHndlSiCfg(pst->region, pst->pool,
635             &rgSchCb[instId], spId, transId, 
636                         cfgReqInfo);
637 }
638 else
639 {
640    ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
641             &rgSchCb[instId], spId, transId, 
642                         cfgReqInfo);
643 }
644  #else
645    ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
646             &rgSchCb[instId], spId, transId, 
647                         cfgReqInfo);
648  #endif
649    if (ret != ROK)
650    {
651       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"RgUiRgrSiCfgReq:"
652                    "Configuration Request Handling Failed");
653       return RFAILED;
654    }
655
656    return ROK;
657 }  /* RgUiRgrSiCfgReq */
658
659 \f
660 /**
661  * @brief API for Warning SI configuration request from RRM towards MAC. 
662  *
663  * @details
664  *
665  *     Function: RgUiRgrWarningSiCfgReq
666  *     
667  *     This API is invoked by RRM towards MAC to configure SI at MAC. 
668  *     These API validates the Pst, spId, suId and transfers the 
669  *     config request specific information to corresponding ownership 
670  *     module (GOM) API.
671  *
672  *           
673  *  @param[in]  Pst           *pst
674  *  @param[in]  SpId          spId
675  *  @param[in]  RgrCfgTransId transId
676  *  @param[in]  RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
677  *  @return  S16
678  *      -# ROK 
679  *      -# RFAILED 
680  **/
681 S16 RgUiRgrWarningSiCfgReq(Pst *pst, SpId spId,RgrCfgTransId transId,RgrWarningSiCfgReqInfo *warningSiCfgReqInfo)
682 {
683    Inst     instId = pst->dstInst-SCH_INST_START;
684    S16      ret    = ROK;
685    uint8_t  cfmStatus = RGR_CFG_CFM_NOK;
686    uint8_t  prntTrans[RGR_CFG_TRANSID_SIZE+1];
687
688    memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
689    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
690
691    if (warningSiCfgReqInfo == NULLP)
692    {
693       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
694                "is NULL");
695       rgSCHUtlRgrWarningSiCfgCfm(instId, spId, 0, transId, cfmStatus);
696       return RFAILED;
697    }
698
699    if (spId < rgSchCb[instId].numSaps)
700    {
701       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
702       {
703 #if (ERRCLASS & ERRCLS_ADD_RES)      
704          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG023, 
705                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
706                "Invalid SAP State: warningSiCfgReqInfo failed\n");
707 #endif
708          rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool, 
709                &warningSiCfgReqInfo->siPduLst);
710          SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo,
711                sizeof(RgrWarningSiCfgReqInfo));
712          rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId, 
713                transId, cfmStatus);
714          return RFAILED;
715       }
716    }
717    else
718    {
719 #if (ERRCLASS & ERRCLS_ADD_RES)      
720       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG024,
721             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
722             "Invalid SAP Id:warningSiCfgReqInfo failed\n");
723 #endif
724       rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool, 
725             &warningSiCfgReqInfo->siPduLst);
726       SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo,
727             sizeof(RgrWarningSiCfgReqInfo));
728       rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId, 
729             transId, cfmStatus);
730       return RFAILED;
731    }
732
733    /* Handle configuration */
734 #ifdef EMTC_ENABLE
735 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
736 {
737    ret = rgSCHGomEmtcHndlWarningSiCfg(pst->region, pst->pool,
738          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
739 }
740 else
741 {
742    ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
743          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
744 }
745 #else
746    ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
747          &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
748 #endif
749    if(ret != ROK)
750    {
751       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,
752                "Configuration Request Handling Failed");
753       return RFAILED;
754    }
755
756    return ROK;
757 }
758
759 \f
760 /**
761  * @brief API for Warning SI Stop  request from RRM towards MAC. 
762  *
763  * @details
764  *
765  *     Function: RgUiRgrWarningSiStopReq
766  *     
767  *     This API is invoked by RRM towards MAC to Stop warning SI at MAC. 
768  *     These API validates the Pst, spId, suId and transfers the 
769  *     stop request specific information to corresponding ownership 
770  *     module (GOM) API.
771  *
772  *           
773  *  @param[in]  Pst           *pst
774  *  @param[in]  SpId          spId
775  *  @param[in]  RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
776  *  @return  S16
777  *      -# ROK 
778  *      -# RFAILED 
779  **/
780 S16 RgUiRgrWarningSiStopReq(Pst *pst,SpId  spId,RgrCfgTransId transId,uint8_t siId)
781 {         
782    Inst         instId = pst->dstInst-SCH_INST_START;
783
784    if (spId < rgSchCb[instId].numSaps)
785    {
786       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
787       {
788 #if (ERRCLASS & ERRCLS_ADD_RES)      
789          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG025, 
790                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
791                "Invalid SAP State: RgUiRgrWarningSiStopReq failed\n");
792 #endif
793          return RFAILED;
794       }
795    }
796    else
797    {
798 #if (ERRCLASS & ERRCLS_ADD_RES)      
799       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG026,
800             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
801             "Invalid SAP Id:RgUiRgrWarningSiStopReq failed\n");
802 #endif
803       return RFAILED;
804    }
805
806    rgSCHGomHndlWarningSiStopReq(pst->region, pst->pool,
807          &rgSchCb[instId], siId, transId, spId);
808
809    return ROK;
810 }
811 #endif /*RGR_SI_SCH */
812
813 /* LTE_ADV_FLAG_REMOVED_START */
814
815 /**
816  * @brief API for LOAD INF request from RRM towards MAC.
817  *
818  * @details
819  *
820  *     Function: RgUiRgrLoadInfReq
821  *
822  *     This API is invoked by RRM towards MAC to configure LOAD INF Parameters at MAC.
823  *     These API validates the Pst, spId, suId and transfers the
824  *     LOAD INF request to corresponding ownership
825  *     module (GOM) API.
826  *
827  *
828  *  @param[in]  Pst               *pst
829  *  @param[in]  SpId              spId
830  *  @param[in]  RgrCfgTransId     transId
831  *  @param[in]  RgrLoadInfReqInfo *loadInfReq
832  *  @return  S16
833  *      -# ROK
834  *      -# RFAILED
835  **/
836 S16 RgUiRgrLoadInfReq(Pst *pst, SpId spId, RgrCfgTransId  transId,RgrLoadInfReqInfo *loadInfReq)
837 {
838    S16       ret       = ROK;
839    uint8_t   prntTrans[RGR_CFG_TRANSID_SIZE+1];
840    Inst      instId = pst->dstInst-SCH_INST_START;
841
842    memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
843    prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
844
845
846    if (loadInfReq == NULLP)
847    {
848       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,"Input Message Buffer "
849                "is NULL");
850       return RFAILED;
851    }
852
853    if (spId < rgSchCb[instId].numSaps)
854    {
855       if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
856       {
857 #if (ERRCLASS & ERRCLS_ADD_RES)
858          RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG007, 
859                (ErrVal)rgSchCb[instId].rgrSap[spId].sapSta.sapState,
860                "Invalid SAP State: RgUiRgrLoadInfReq failed\n");
861 #endif
862          SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq,
863                (Size)sizeof(*loadInfReq));
864          return RFAILED;
865       }
866    }
867    else
868    {
869 #if (ERRCLASS & ERRCLS_ADD_RES)
870       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG008,
871             (ErrVal)rgSchCb[instId].rgrSap[spId].sapCfg.spId,
872             "Invalid SAP Id:RgUiRgrLoadInfReq failed\n");
873 #endif
874       SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq,
875             (Size)sizeof(*loadInfReq));
876       return RFAILED;
877    }
878
879    /* Handle configuration */
880    ret = rgSCHGomHndlLoadInf(pst->region, pst->pool,
881          &rgSchCb[(pst->dstInst - SCH_INST_START)], spId, transId, 
882          loadInfReq);
883    if (ret != ROK)
884    {
885       RLOG_ARG0(L_ERROR,DBG_INSTID,instId,
886                "Configuration Request Handling Failed");
887       return RFAILED;
888    }
889
890    return ROK;
891 }  /* RgUiRgrLoadInfReq */
892 /* LTE_ADV_FLAG_REMOVED_END */
893
894 /************** MAC SCH Interface **************/ 
895 /**
896  * @brief Function for updating dedicated channel BO at scheduler from MAC.
897  *
898  * @details
899  *
900  *     Function : rgMacSchDedBoUpdtReq
901  *     
902  *     This function shall be invoked whenever MAC gets staRsp from RLC
903  *     Scheduler shall update BO in its dedicated logical channel control block.
904  *           
905  *  @param[in] Pst*           pst
906  *  @param[in] S16            cellSapId
907  *  @param[in] RgInfDedBoRpt  *boRpt
908  *  @return  S16
909  *      -# ROK 
910  **/
911 S16 RgMacSchDedBoUpdtReq(Pst*  pst,RgInfDedBoRpt  *boRpt)
912 {
913    RgSchCellCb   *cell;
914    RgSchUeCb     *ue;
915 #ifdef SCH_STATS
916    RgSchCmnDlUe  *dlUe;
917 #endif
918
919    Inst          inst = (pst->dstInst - SCH_INST_START);
920    S16           cellSapId = boRpt->cellSapId;
921 /*
922    RLOG_ARG2(L_DEBUG,DBG_CELLID,boRpt->cellId,"rgMacSchDedBoUpdtReq():"
923             " boRpt->rnti = %u  boRpt->lcId = %u",boRpt->rnti, boRpt->lcId);
924 */
925    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
926     * it doesnt exist */
927    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
928
929 #ifndef NO_ERRCLS
930    if (cell->cellId != boRpt->cellId)
931    {
932       /* Handle Cell fetch failure */
933       RGSCHLOGERROR(inst, ERRCLS_INT_PAR,ERG009,(ErrVal)boRpt->cellId,
934                             "rgMacSchDedBoUpdtReq(): Invalid cell Id");
935       return RFAILED;
936    }
937 #endif
938
939    /* Update Bo in the given logical channel of the UE */
940    if ((ue = rgSCHDbmGetUeCb(cell, boRpt->rnti)) != NULLP)
941    {
942       RgSchDlLcCb   *dlLc;
943       /* Honor BO Reports only from PCELL */
944 #ifdef LTE_ADV
945       if (cell != ue->cell)
946       {
947          return RFAILED;
948       }
949 #endif
950       if ((dlLc = rgSCHDbmGetDlDedLcCb(ue, boRpt->lcId)) != NULLP)
951       {
952 #ifdef LTE_L2_MEAS
953          if(dlLc->lcType == CM_LTE_LCH_DTCH)
954          {
955             if((dlLc->bo == 0) &&(boRpt->bo != 0))
956             {
957                /* UE is active */
958                if(!(ue->qciActiveLCs[dlLc->qciCb->qci]))
959                {
960                   dlLc->qciCb->dlUeCount++;
961                }
962                ue->qciActiveLCs[dlLc->qciCb->qci]++;
963             }
964             else if((dlLc->bo != 0) && (boRpt->bo == 0) && (dlLc->qciCb->dlUeCount))
965             {
966                /* UE is inactive */
967                if (ue->qciActiveLCs[dlLc->qciCb->qci])
968                {
969                   ue->qciActiveLCs[dlLc->qciCb->qci]--;
970                   if (!(ue->qciActiveLCs[dlLc->qciCb->qci]))
971                   {
972                      dlLc->qciCb->dlUeCount--;
973                   }
974                }
975             }
976         }
977 #endif
978 #ifdef SCH_STATS
979          dlUe = RG_SCH_CMN_GET_DL_UE(ue, cell);
980          if (boRpt->bo > dlLc->bo)
981          {
982             dlUe->boReported += (boRpt->bo - dlLc->bo);
983          }
984 #endif
985 #ifdef TENB_STATS
986          if (boRpt->bo > dlLc->bo)
987          {
988             ue->tenbStats->stats.nonPersistent.sch[RG_SCH_CELLINDEX(cell)].dlBo += ((boRpt->bo - dlLc->bo)<<3);
989          }
990 #endif
991          /* RLC provides cumulative BO for each LC.
992           * Reduce the left out unscheduled bo from total bo and 
993           * update the new BO to the total bo */
994          if(ue->totalBo >= dlLc->bo)
995          {
996             ue->totalBo -= dlLc->bo;
997          }
998          else
999          {
1000             ue->totalBo = 0; /* this case should not arise
1001                              * Resetting for safety */
1002          }
1003
1004          ue->totalBo +=  boRpt->bo;
1005          dlLc->bo = boRpt->bo;
1006          dlLc->oldestSduArrTime = boRpt->oldestSduArrTime;
1007          dlLc->staPduBo = boRpt->staPduBo;
1008          
1009          dlLc->setMaxUlPrio = boRpt->setMaxUlPrio;
1010          dlLc->setMaxDlPrio = boRpt->setMaxDlPrio;
1011          /* Update the scheduler */
1012          rgSCHUtlDlDedBoUpd(cell, ue, dlLc);
1013          return ROK;
1014       }
1015    }
1016    return RFAILED;
1017
1018 } /* end of rgMacSchDedBoUpdtReq */
1019
1020
1021 /**
1022  * @brief Function for updating common channel BO at scheduler from MAC.
1023  *
1024  * @details
1025  *
1026  *     Function : RgMacSchCmnBoUpdtReq
1027  *     
1028  *     This function shall be invoked whenever MAC gets staRsp from RLC
1029  *     Scheduler shall update BO in its common logical channel control block.
1030  *           
1031  *  @param[in] Pst*            pst
1032  *  @param[in] S16             cellSapId
1033  *  @param[in] RgInfCmnBoRpt  *boRpt
1034  *  @return  S16
1035  *      -# ROK 
1036  **/
1037 S16 RgMacSchCmnBoUpdtReq(Pst* pst,RgInfCmnBoRpt  *boRpt)
1038 {
1039    RgSchCellCb   *cell;
1040    Inst          inst = (pst->dstInst - SCH_INST_START);
1041    S16           cellSapId = boRpt->cellSapId;
1042
1043
1044    /* No need to chk for cell being NULL as MAC would not have found instance if
1045     * it doesnt exist */
1046    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1047    if (cell->cellId != boRpt->cellId)
1048    {
1049       RLOG_ARG1(L_DEBUG,DBG_CELLID,cell->cellId,"RgMacSchCmnBoUpdtReq():"
1050                "Invalid boRpt cell Id:%d",boRpt->cellId);
1051       return RFAILED;
1052    }
1053
1054    /* handle status response on CCCH */
1055    if(boRpt->lcId == cell->dlCcchId)
1056    {
1057       RLOG_ARG0(L_DEBUG,DBG_CELLID,cell->cellId,"RgMacSchCmnBoUpdtReq():"
1058                " BO update for CCCH");
1059       rgSCHUtlHndlCcchBoUpdt(cell, boRpt); 
1060    }
1061    else
1062    {
1063       rgSCHUtlHndlBcchPcchBoUpdt(cell, boRpt); 
1064    }
1065    
1066    return ROK;
1067 } /* end of RgMacSchCmnBoUpdtReq */
1068 /*Fix: start: Inform UE delete to scheduler*/
1069 /**
1070  * @brief This API is used to send data indication to Scheduler instance from MAC.
1071  *
1072  * @details
1073  *
1074  *     Function : rgMacSchUeDelInd
1075  *     
1076  *     This function shall be invoked whenever MAC gets Ue delete request. 
1077  *      
1078  *           
1079  *  @param[in] Pst*            pst
1080  *  @param[in] RgInfUeDelInd   *ueDelInd
1081  *  @return  S16
1082  *      -# ROK 
1083  **/
1084 S16 RgMacSchUeDelInd(Pst* pst,RgInfUeDelInd *ueDelInd)
1085 {
1086    RgSchCellCb       *cell;
1087    Inst              inst = (pst->dstInst - SCH_INST_START);
1088    S16               cellSapId = ueDelInd->cellSapId;
1089    CmLList           *tmp;
1090    RgSchRntiLnk      *rntiLnk=NULL;
1091    
1092    if (rgSchCb[inst].rgrSap == NULLP || rgSchCb[inst].rgrSap[cellSapId].cell == NULLP)
1093    {
1094       RLOG_ARG0(L_ERROR,DBG_CELLID,ueDelInd->cellId,"rgrSap or cell is not configured");
1095       return ROK;
1096    }
1097    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1098 #ifndef NO_ERRCLS
1099    if (cell->cellId != ueDelInd->cellId)
1100    {
1101       /* Handle Cell fetch failure */
1102       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1103                         "rgMacSchUeDelInd(): Invalid ueDelInd cell Id:%d",
1104                          ueDelInd->cellId);
1105       return ROK;
1106    }
1107 #endif
1108       
1109    CM_LLIST_FIRST_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1110
1111    while(tmp)
1112    {
1113       rntiLnk = (RgSchRntiLnk *)(tmp->node);
1114       if(rntiLnk->rnti == ueDelInd->rnti)
1115       {
1116          cmLListDelFrm(&cell->rntiDb.rntiGuardPool, tmp);
1117          tmp->node = NULLP;
1118          rgSCHDbmRlsRnti(cell, rntiLnk);
1119          RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
1120                   "RNTI:%d Released from the Guard pool(%ld)",
1121                   ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1122          
1123          break;
1124       }
1125       CM_LLIST_NEXT_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1126    }
1127
1128 #ifdef EMTC_ENABLE
1129  rgEmtcMacSchUeDelInd(cell,ueDelInd);  
1130 #endif
1131
1132    if(tmp == NULLP)
1133    {
1134       /* Fix : syed HO UE does not have a valid ue->rntiLnk */
1135       RLOG_ARG2(L_INFO,DBG_CELLID,ueDelInd->cellId,"HO CRNTI:%d not present in the"
1136            "Guard Pool:%ld", ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1137    } 
1138    
1139    return ROK;
1140 }  /* rgMacSchUeDelInd */
1141 /*Fix: end: Inform UE delete to scheduler*/
1142 /**
1143  * @brief This API is used to send data indication to Scheduler instance from MAC.
1144  *
1145  * @details
1146  *
1147  *     Function : rgMacSchSfRecpInd
1148  *     
1149  *     This function shall be invoked whenever MAC gets datInd on TFU
1150  *     Scheduler shall act on the CEs and data that are received as part of
1151  *     datInd.
1152  *           
1153  *  @param[in] Pst*            pst
1154  *  @param[in] S16             cellSapId
1155  *  @param[in] CmLteRnti       rnti
1156  *  @param[in] DatIndInfo      *datInd
1157  *  @return  S16
1158  *      -# ROK 
1159  **/
1160 S16 RgMacSchSfRecpInd(Pst*  pst,RgInfSfDatInd *subfrmInfo)
1161 {
1162    S16               ret = RFAILED;
1163    RgSchErrInfo      err;
1164    RgSchUeCb         *ue;
1165    RgInfUeDatInd     *datInd;
1166    RgSchCellCb       *cell;
1167    Inst              inst = (pst->dstInst - SCH_INST_START);
1168    CmLteRnti         rnti;
1169    CmLListCp         *lnkLst;
1170    CmLList           *tmp;
1171    S16               cellSapId = subfrmInfo->cellSapId;
1172    RgrUeStaIndInfo   *ueStaInd;
1173 #ifdef RG_UNUSED
1174 //#ifdef LTEMAC_SPS
1175    RgSchCmnUlUeSpsInfo   *ulSpsUe ;
1176 #endif
1177    /* RRM_RBC_X */
1178    uint32_t                   idx;
1179    /* RRM_RBC_Y */
1180    
1181 #ifdef LTE_L2_MEAS
1182    uint8_t               qci;
1183    uint16_t              datIndActQci = 0;
1184    uint16_t              combDatIndActQci = 0; /* Prev and Latest Dat Ind combined */
1185    uint16_t              tempUeActQci = 0; /* UE specific Active QCIs */
1186    uint16_t              diffBits = 0;
1187    uint8_t               lcCount;
1188 #endif
1189
1190    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1191     * it doesnt exist */
1192    cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1193
1194    /* lnkLst assignment */
1195    lnkLst = &(subfrmInfo->ueLst);
1196
1197    CM_LLIST_FIRST_NODE(lnkLst, tmp);
1198
1199    while((NULLP != tmp) && ((RgInfUeDatInd *)tmp->node != NULLP))
1200    {
1201       ue = NULLP;
1202 #ifdef LTE_L2_MEAS
1203       qci = 0;
1204 #endif
1205       datInd   = (RgInfUeDatInd *)tmp->node;
1206       rnti     = datInd->rnti;
1207
1208       /* We shall try and find
1209        * out the RaCb based on the following - 
1210        * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1211        * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1212        * have a ueCb also for this 
1213        */
1214       
1215       /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1216        * should check for CRNTI CE and if it exists the UECb must exist, also an
1217        * if the CRNTI in the CE and the one with which the message came in are
1218        * different we shall look for an raCb as well. 
1219        */
1220       if (datInd->ceInfo.bitMask & RGSCH_CRNTI_CE_PRSNT)
1221       {
1222          /* SR_RACH_STATS : CRNTI CE*/
1223          rgNumMsg3CrntiCE++;
1224
1225          if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1226          {
1227             RGSCH_FREE_MEM(subfrmInfo);
1228             err.errType = RGSCHERR_TOM_DATIND;
1229             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1230                       "Received MSG3 with CRNTI:%d and also CCCH ", 
1231                      datInd->ceInfo.ces.cRnti);
1232             return RFAILED;
1233          }
1234          ue = rgSCHDbmGetUeCb (cell, datInd->ceInfo.ces.cRnti);
1235          if (ue == NULLP)
1236          {
1237             /* SR_RACH_STATS : CRNTI CE UECB NOT FOUND*/
1238             rgNumCrntiCeCrntiNotFound++;
1239             /* ccpu00141318 - Removed condition for SPS rnti checking*/
1240             RGSCH_FREE_MEM(subfrmInfo);
1241             err.errType = RGSCHERR_TOM_DATIND;
1242             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, "Received MSG3 "
1243                      "with CRNTI:%d unable to find ueCb", 
1244                      datInd->ceInfo.ces.cRnti);
1245             return RFAILED;
1246          }
1247
1248          if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue, 
1249                rnti, datInd, &err)) != ROK)
1250          { 
1251             RGSCH_FREE_MEM(subfrmInfo);
1252             err.errType = RGSCHERR_TOM_DATIND;
1253             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, "Processing for MSG3 failed for CRNTI:%d", 
1254                      datInd->rnti);
1255             return RFAILED;
1256          }
1257          
1258 #ifdef LTEMAC_SPS
1259          rgSCHUtlHdlCrntiCE (cell, ue);
1260 #endif
1261          ret = rgSCHUtlAllocSBuf (cell->instIdx,(Data**)&ueStaInd,
1262                                   sizeof(RgrUeStaIndInfo));
1263          if(ret == ROK)
1264          {
1265             ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD;
1266 #ifdef RG_UNUSED
1267 //#ifdef LTEMAC_SPS
1268             ulSpsUe = RG_SCH_CMN_GET_UL_SPS_UE(ue);
1269             if(ulSpsUe->isUlSpsActv)
1270             {
1271                ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD_IN_SPS_ACTIVE;
1272                ue->ul.ulSpsCfg.isLcSRMaskEnab = FALSE;
1273             }
1274 #endif
1275             ret = rgSCHUtlFillSndUeStaInd(cell, ue, ueStaInd);
1276             if(ret != ROK)
1277             {
1278                RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1279                    "Could not Send Ue Sta Ind UEID:%d",ue->ueId);
1280             }
1281          }
1282          CM_LLIST_NEXT_NODE(lnkLst, tmp);
1283          continue;
1284       } /* end of CRNTI based message */
1285       else if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1286       {
1287          /* SR_RACH_STATS : CCCH SDU */
1288          rgNumMsg3CCCHSdu++;
1289          /* SR_RACH_STATS : CCCH SDU RACB NOT FOUND*/
1290          if (NULLP == rgSCHDbmGetRaCb (cell, rnti))
1291          {
1292             rgNumCCCHSduCrntiNotFound++;
1293          }
1294
1295          if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue, 
1296                rnti, datInd, &err)) != ROK)
1297          { 
1298             RGSCH_FREE_MEM(subfrmInfo);
1299             err.errType = RGSCHERR_TOM_DATIND;
1300             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Processing for MSG3 failed for CRNTI:%d", 
1301                      datInd->rnti);
1302             return RFAILED;
1303          }
1304          /* fix */
1305           CM_LLIST_NEXT_NODE(lnkLst, tmp);
1306           continue;
1307       } /* end of Msg3 processing */
1308
1309       if (ue == NULLP)
1310       {
1311          ue = rgSCHDbmGetUeCb (cell, datInd->rnti);
1312          if (ue == NULLP)
1313          {
1314 #ifdef LTEMAC_SPS 
1315          if((ue = rgSCHDbmGetSpsUeCb (cell, datInd->rnti)) == NULLP)
1316 #endif
1317             {
1318                RGSCH_FREE_MEM(subfrmInfo);
1319                err.errType = RGSCHERR_TOM_DATIND;
1320                RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Unable to get the UE CB for CRNTI:%d", 
1321                datInd->rnti);
1322                return RFAILED;
1323             }
1324          }
1325       }
1326 /* L2_COUNTERS */
1327 #ifdef LTE_L2_MEAS
1328       /* The LCs for which data is received at MAC is provided to SCH.
1329          This information is used to estimate the Active LCs at UE
1330          since estimates based on only BSR is not accurate */
1331       if (datInd->ceInfo.bitMask & RGSCH_ACTIVE_LC_PRSNT)
1332       {
1333       
1334         /* Compose a Bitmask with for the QCI's for which Data
1335            is received */
1336         for (lcCount = 0; lcCount < RGINF_MAX_NUM_DED_LC; lcCount++)
1337         {
1338            if ((datInd->ceInfo.ulActLCs[lcCount] == TRUE) && (TRUE == ue->ul.lcCb[lcCount].isValid))
1339            {
1340               datIndActQci |= (1 << (ue->ul.lcCb[lcCount].qciCb->qci -1));
1341            }
1342         }
1343         if (ue->ulActiveLCs && ue->lastDatIndLCs)
1344         {
1345            /* Combine previous Dat Ind and current Dat Ind to
1346               estimate active LCs at UE */
1347            combDatIndActQci = ue->lastDatIndLCs | datIndActQci;
1348            tempUeActQci = ue->ulActiveLCs;
1349            ue->ulActiveLCs = combDatIndActQci;
1350            diffBits = combDatIndActQci ^ tempUeActQci;
1351            while (diffBits)
1352            {
1353               qci++;
1354               if (0x1 & diffBits)
1355               {
1356                  if (0x1 & tempUeActQci)
1357                  {
1358                     /* An active QCI has become inactive */
1359                     cell->qciArray[qci].ulUeCount--;
1360                  }
1361                  else
1362                  {
1363                     /* An Inactive QCI has become active */
1364                     cell->qciArray[qci].ulUeCount++;
1365                  }
1366               }
1367               diffBits >>= 1;
1368               tempUeActQci >>= 1;
1369            }
1370         }
1371         ue->lastDatIndLCs = datIndActQci;
1372       
1373       }
1374
1375 #endif /* LTE_L2_MEAS */
1376       /* Just copy the timing information from the dat indication into the one
1377        * stored in the UE CB, will be later utilized to handle Timing advance 
1378        */
1379
1380       if ((ret = rgSCHUtlUpdSch (subfrmInfo, cell, ue, datInd, &err)) != ROK)
1381       {
1382          RGSCH_FREE_MEM(subfrmInfo);
1383          err.errType = RGSCHERR_TOM_DATIND;
1384          RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Unable to handle Data"
1385                    " Indication for UEID:%d",ue->ueId);
1386          return RFAILED;
1387       }
1388
1389       CM_LLIST_NEXT_NODE(lnkLst, tmp);
1390    }
1391    /* RRM_RBC_X */
1392    /* update the UL PRB usage for all GBR QCIs*/
1393    for (idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++)
1394    {
1395       cell->prbUsage.qciPrbRpts[idx].ulTotPrbUsed += subfrmInfo->qcisUlPrbCnt[idx];
1396    }
1397    /* RRM_RBC_Y */
1398
1399    /* chk if Sch needs to dealloc datInd after unpk */
1400    RGSCH_FREE_MEM(subfrmInfo);
1401    return (ret);
1402 }  /* rgMacSchSfRecpInd */
1403
1404 #ifdef LTEMAC_SPS
1405 /**
1406  * @brief Function to handle relInd from MAC for a UE
1407  *
1408  * @details
1409  *
1410  *     Function: RgMacSchSpsRelInd
1411  *
1412  *     Handler for processing relInd for UL SPS of a UE
1413  *
1414  *     Invoked by: 
1415  *         MAC
1416  *
1417  *     Processing Steps:
1418  *           
1419  *  @param[in] Pst               *pst
1420  *  @param[in] RgInfSpsRelInfo   *relInfo
1421  *  @return  S16
1422  *      -# ROK 
1423  *      -# RFAILED 
1424  **/
1425 S16 RgMacSchSpsRelInd(Pst *pst,RgInfSpsRelInfo *relInfo)
1426 {
1427    RgSchUeCb       *ue;
1428    RgSchCellCb     *cell;
1429    Inst            inst = (pst->dstInst - SCH_INST_START);
1430
1431
1432    /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1433     * it doesnt exist */
1434    cell = rgSchCb[inst].rgrSap[relInfo->cellSapId].cell;
1435
1436    if ((ue = rgSCHDbmGetUeCb(cell, relInfo->cRnti)) == NULLP)
1437    {
1438       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, 
1439            "No Ue exists with CRNTI:%d",relInfo->cRnti);
1440       return RFAILED;
1441    }
1442
1443    if ((rgSCHUtlSpsRelInd(cell, ue, relInfo->isExplRel)) != ROK)
1444    {
1445       RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId, 
1446            "RelInd processing for CRNTI:%d failed",relInfo->cRnti);
1447       return RFAILED;
1448    }
1449    return ROK;
1450 } /* end of RgMacSchSpsRelInd */
1451 #endif /* LTEMAC_SPS */
1452
1453 #ifdef LTE_L2_MEAS
1454
1455 /**
1456  * @brief Function to handle L2MeasCfm from MAC
1457  *
1458  * @details
1459  *
1460  *     Function: RgMacSchL2MeasCfm
1461  *
1462  *     Handler for processing L2 measurement confirm 
1463  *
1464  *     Invoked by: 
1465  *         MAC
1466  *
1467  *     Processing Steps:
1468  *           
1469  *  @param[in] Pst               *pst
1470  *  @param[in] RgInfL2MeasCfm    *measCfm
1471  *  @return  S16
1472  *      -# ROK 
1473  *      -# RFAILED 
1474  **/
1475 S16 RgMacSchL2MeasCfm(Pst *pst, RgInfL2MeasCfm *measCfm)
1476 {
1477    RgSchCellCb       *cell = NULLP;
1478    Inst              inst = (pst->dstInst - SCH_INST_START);
1479    CmLList           *lnk;
1480    RgSchL2MeasCb     *measCb = NULLP;
1481    RgSchCb           *instCb =  &rgSchCb[inst];
1482    uint32_t          idx;
1483    LrgSchMeasCfmInfo schMeasCfm;
1484    uint8_t           qciVal;
1485    uint8_t           idx1; /*LTE_L2_MEAS_PHASE2*/ 
1486    uint8_t           qciVal1;
1487
1488    /* Find the cellCb using cellId in measInfo. Iterate through all cells
1489     * in rgrsapCb in RgschCb */
1490    for (idx = 0; idx < instCb->numSaps; idx++)
1491    {
1492       if ( instCb->rgrSap[idx].cell->cellId == measCfm->cellId)
1493       {
1494          /* got the cell break the loop */
1495          cell = instCb->rgrSap[idx].cell;
1496          break;
1497       }
1498    }
1499    /* If no cellCb return Err with Invalid Cell Id */
1500    if (cell == NULLP)
1501    {
1502       RLOG_ARG0(L_ERROR,DBG_CELLID,measCfm->cellId,
1503                   "Meas Cfm Failed.Invalid Cell Id");
1504       return RFAILED;
1505    }
1506    
1507
1508    /* Iterate through all meas requests in l2mList in cellCb */
1509    lnk = cell->l2mList.first;
1510    while(lnk != NULLP)
1511    {
1512       /* Get the MeasCb : RgSchL2MeasCb */
1513       measCb = (RgSchL2MeasCb *)lnk->node;
1514       lnk = lnk->next;
1515       if (measCb->measReq.hdr.transId == measCfm->transId)
1516       {
1517          break;
1518       }
1519    }
1520    if ( measCb == NULLP )
1521    {
1522       return ( RFAILED );
1523    }
1524
1525
1526    if(measCfm->cfm.status != LCM_PRIM_OK)
1527    {
1528       for (idx = 0; idx < measCb->measReq.avgPrbQciUl.numQci; idx++)
1529       {
1530         qciVal = measCb->measReq.avgPrbQciUl.qci[idx];
1531         cell->qciArray[qciVal].qci = 0;
1532       }
1533       /* Delete this measCb, send the negative confirmation to
1534        * stack manager */
1535       cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
1536       /* ccpu00117052 - MOD - Passing double pointer
1537          for proper NULLP assignment*/
1538       rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb, sizeof(RgSchL2MeasCb));
1539       memset(&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
1540       schMeasCfm.measType     = measCfm->measType;
1541       schMeasCfm.cfm          = measCfm->cfm;
1542       schMeasCfm.hdr.transId  = measCfm->transId;
1543       schMeasCfm.cellId       = measCfm->cellId;
1544       RgMiLrgSchL2MeasCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
1545       return ROK;
1546    }
1547    for(idx = 0; idx < measCfm->u.prbCfm.numQci; idx++)
1548    {
1549       measCb->avgPrbQciUl.prbUsage[idx].prbUsage = measCfm->u.prbCfm.prbUsage[idx].prbUsage;
1550       measCb->avgPrbQciUl.prbUsage[idx].qciValue = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1551       /*LTE_L2_MEAS_PHASE2*/
1552       qciVal1 = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1553       for(idx1=0;idx1<measCb->measReq.avgPrbQciUl.numQci;idx1++)
1554       {
1555          if(measCb->measReq.avgPrbQciUl.qci[idx1] == qciVal1)
1556          {
1557             break;
1558          }
1559       }
1560       if(idx1 == measCb->measReq.avgPrbQciUl.numQci)
1561       {
1562          measCb->measReq.avgPrbQciUl.qci[measCb->measReq.avgPrbQciUl.numQci++] = qciVal1;
1563       }
1564    }
1565    measCb->avgPrbQciUl.numQci = measCfm->u.prbCfm.numQci;
1566    measCb->cfmRcvd = TRUE;
1567    cell->sndL2Meas = TRUE;
1568    return ROK;
1569 } /* end of RgMacSchL2MeasCfm */
1570
1571 /**
1572  * @brief Function to handle L2MeasStopCfm from MAC
1573  *
1574  * @details
1575  *
1576  *     Function: RgMacSchL2MeasStopCfm
1577  *
1578  *     Handler for processing L2 measurement confirm 
1579  *
1580  *     Invoked by: 
1581  *         MAC
1582  *
1583  *     Processing Steps:
1584  *           
1585  *  @param[in] Pst               *pst
1586  *  @param[in] RgInfL2MeasCfm    *measCfm
1587  *  @return  S16
1588  *      -# ROK 
1589  *      -# RFAILED 
1590  **/
1591 S16 RgMacSchL2MeasStopCfm(Pst *pst,RgInfL2MeasCfm  *measCfm)
1592 {
1593    LrgSchMeasCfmInfo schMeasCfm;
1594    Inst              inst = (pst->dstInst - SCH_INST_START);
1595    RgSchCb           *instCb =  &rgSchCb[inst];
1596
1597    memset(&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
1598    schMeasCfm.measType     = measCfm->measType;
1599    schMeasCfm.cfm          = measCfm->cfm;
1600    schMeasCfm.hdr.transId  = measCfm->transId;
1601    schMeasCfm.cellId       = measCfm->cellId;
1602    RgMiLrgSchL2MeasStopCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
1603    return ROK;
1604 }
1605 #endif
1606
1607 /************** TFU Interface *************/
1608
1609 /**
1610  * @brief Bind confirm API for TFU SAP on scheduler instance. 
1611  *
1612  * @details
1613  *
1614  *     Function : RgLiTfuSchBndCfm
1615  *      
1616  *      This API is invoked by PHY to confirm TFU SAP bind. 
1617  *     
1618  *           
1619  *  @param[in]  Pst   *pst 
1620  *  @param[in]  SuId  suId 
1621  *  @param[in]  uint8_t    status
1622  *  @return  S16
1623  *      -# ROK 
1624  *      -# RFAILED 
1625  **/
1626 S16 RgLiTfuSchBndCfm (Pst *pst,SuId suId, uint8_t status)
1627 {
1628    S16 ret;
1629    RgSchLowSapCb  *tfuSap;
1630    Inst  instId = pst->dstInst - SCH_INST_START;
1631
1632    if(suId >= rgSchCb[instId].numSaps)
1633    {
1634       RLOG_ARG0(L_ERROR,DBG_INSTID,instId, "Incorrect SuId");
1635       return RFAILED;
1636    }
1637    /* Lets validate suId first */
1638    tfuSap = &(rgSchCb[instId].tfuSap[suId]);
1639
1640    if (suId != tfuSap->sapCfg.suId)
1641    {
1642       RLOG_ARG2(L_ERROR,DBG_INSTID,instId, "Incorrect SuId. Configured (%d)"
1643             "Recieved (%d)", tfuSap->sapCfg.suId, suId);
1644       return RFAILED;
1645    }
1646    ret = rgSCHLmmBndCfm (pst, suId, status);
1647    return (ret);
1648 }  /* RgLiTfuSchBndCfm */
1649
1650 /**
1651  * @brief Random Access Request indication from PHY.
1652  *
1653  * @details
1654  *
1655  *     Function : RgLiTfuRaReqInd
1656  *      
1657  *      This API is invoked by PHY to send Random Access Request to Scheduler.
1658  *      This API contains information for Random Access Request including 
1659  *      raRnti, list of associated RAPIDs and related information.
1660  *           
1661  *  @param[in]  Pst              *pst 
1662  *  @param[in]  SuId             suId 
1663  *  @param[in]  TfuRaReqIndInfo  *raReqInd
1664  *  @return  S16
1665  *      -# ROK 
1666  *      -# RFAILED 
1667  **/
1668 S16 RgLiTfuRaReqInd(Pst *pst,SuId suId, TfuRaReqIndInfo *raReqInd)
1669 {
1670    S16   ret;
1671    Inst  inst = pst->dstInst-SCH_INST_START;
1672
1673    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1674    {
1675       RLOG_ARG1(L_ERROR,DBG_INSTID,inst,"SAP Validation failed SuId(%d)", suId);
1676       /* Free up the memory for the request structure */
1677       RGSCH_FREE_MEM(raReqInd);
1678       return (ret);
1679    }
1680
1681    if(raReqInd == NULLP)
1682    {
1683       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"Invalid input pointer for raReqInd Failed");
1684       return RFAILED;
1685    }
1686
1687    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1688    {
1689       RLOG_ARG0(L_ERROR,DBG_CELLID,raReqInd->cellId,"No cell exists");
1690       return RFAILED;
1691    }
1692
1693    ret = rgSCHTomRaReqInd(rgSchCb[inst].tfuSap[suId].cell, raReqInd);
1694    /* Free up the memory for the request structure */
1695    RGSCH_FREE_MEM(raReqInd);
1696    /*SPutSBuf (pst->region, pst->pool, (Data *)raReqInd,
1697          sizeof(TfuRaReqIndInfo)); */
1698    return (ret);
1699 }  /* RgLiTfuRaReqInd */
1700
1701 /**
1702  * @brief Uplink CQI indication from PHY.
1703  *
1704  * @details
1705  *
1706  *     Function : RgLiTfuUlCqiInd
1707  *      
1708  *      This API is invoked by PHY to send Uplink CQI to Scheduler.
1709  *      This API contains Uplink CQI information reported per UE.
1710  *           
1711  *  @param[in]  Pst               *pst 
1712  *  @param[in]  SuId              suId 
1713  *  @param[in]  TfuUlCqiIndInfo   *ulCqiInd
1714  *  @return  S16
1715  *      -# ROK 
1716  *      -# RFAILED 
1717  **/
1718 S16 RgLiTfuUlCqiInd(Pst *pst, SuId suId, TfuUlCqiIndInfo *ulCqiInd)
1719 {
1720    S16   ret;
1721    Inst  inst = pst->dstInst-SCH_INST_START;
1722
1723    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1724    {
1725       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
1726       /* Free up the memory for the request structure */
1727       RGSCH_FREE_MEM(ulCqiInd);
1728       return (ret);
1729    }
1730
1731    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1732    {
1733       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
1734       /* Free up the memory for the request structure */
1735       RGSCH_FREE_MEM(ulCqiInd);
1736       return RFAILED;
1737    }
1738    ret = rgSCHTomUlCqiInd (rgSchCb[inst].tfuSap[suId].cell, ulCqiInd);
1739    /* Free up the memory for the request structure */
1740    RGSCH_FREE_MEM(ulCqiInd);
1741    return (ret);
1742 }  /* RgLiTfuUlCqiInd */
1743
1744 /**
1745  * @brief PUCCH power adjustment indication.
1746  *
1747  * @details
1748  *
1749  *     Function : RgLiTfuPucchDeltaPwrInd
1750  *
1751  *      This API is invoked by PHY to send PUCCH power adjustment
1752  *      indication.
1753  *
1754  *  @param[in]  Pst                     *pst 
1755  *  @param[in]  SuId                    suId 
1756  *  @param[in]  TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
1757  *  @return  S16
1758  *      -# ROK 
1759  *      -# RFAILED 
1760  **/
1761 S16 RgLiTfuPucchDeltaPwrInd(Pst *pst,SuId suId,TfuPucchDeltaPwrIndInfo *pucchDeltaPwr)
1762 {
1763    S16   ret;
1764    Inst  inst = pst->dstInst-SCH_INST_START;
1765
1766    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1767    {
1768       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
1769       /* Free up the memory for the request structure */
1770       RGSCH_FREE_MEM(pucchDeltaPwr);
1771       return (ret);
1772    }
1773
1774    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1775    {
1776       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
1777       return RFAILED;
1778    }
1779    ret = rgSCHTomPucchDeltaPwrInd (rgSchCb[inst].tfuSap[suId].cell, pucchDeltaPwr);
1780    /* Free up the memory for the request structure */
1781    RGSCH_FREE_MEM(pucchDeltaPwr);
1782    return (ret);
1783 }  /* RgLiTfuPucchDeltaPwrInd */
1784
1785
1786 /**
1787  * @brief HARQ ACK indication from PHY for Downlink transmissions.
1788  *
1789  * @details
1790  *
1791  *     Function : RgLiTfuHqInd
1792  *      
1793  *      This API is invoked by PHY to send HARQ ACK information to Scheduler
1794  *      on recieving HARQ ACK/NACK from UEs.
1795  *      This API contains HARQ ACK information recieved by PHY for downlink
1796  *      transmissions.
1797  *           
1798  *  @param[in]  Pst                *pst
1799  *  @param[in]  SuId               suId 
1800  *  @param[in]  TfuHqIndInfo       *harqAckInd
1801  *  @return  S16
1802  *      -# ROK 
1803  *      -# RFAILED 
1804  **/
1805 S16 RgLiTfuHqInd(Pst *pst, SuId suId, TfuHqIndInfo *harqAckInd)
1806 {
1807    S16   ret;
1808    Inst  inst = (pst->dstInst - SCH_INST_START);
1809
1810
1811 #ifndef NO_ERRCLS
1812    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1813    {
1814       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
1815       RGSCH_FREE_MEM(harqAckInd);
1816       return (ret);
1817    }
1818
1819    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1820    {
1821       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
1822       return RFAILED;
1823    }
1824 #endif
1825
1826    /* Now call the TOM (Tfu ownership module) primitive to process further */
1827    ret = rgSCHTomHarqAckInd (rgSchCb[inst].tfuSap[suId].cell, harqAckInd);
1828    /* Free up the memory for the request structure */
1829    RGSCH_FREE_MEM(harqAckInd);
1830    return (ret);
1831 }  /* RgLiTfuHqInd */
1832
1833
1834 /**
1835  * @brief Scheduling request(SR) indication from PHY for an UE.
1836  *
1837  * @details
1838  *
1839  *     Function : RgLiTfuSrInd
1840  *      
1841  *      This API is invoked by PHY to send Scheduling request information to
1842  *      Scheduler on recieving SR from a list of UEs.
1843  *      This API contains scheduling request information recieved by PHY for UEs.
1844  *           
1845  *  @param[in]  Pst           *pst
1846  *  @param[in]  SuId          suId 
1847  *  @param[in]  TfuSrIndInfo  *srInd
1848  *  @return  S16
1849  *      -# ROK 
1850  *      -# RFAILED 
1851  **/
1852 S16 RgLiTfuSrInd(Pst *pst, SuId suId, TfuSrIndInfo *srInd)
1853 {
1854    S16   ret;
1855    Inst  inst = pst->dstInst-SCH_INST_START;
1856
1857 #ifndef NO_ERRCLS
1858    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1859    {
1860       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"() SAP Validation failed");
1861       RGSCH_FREE_MEM(srInd);
1862       return (ret);
1863    }
1864
1865    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1866    {
1867       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"RgLiTfuSrInd()No cell exists");
1868       return RFAILED;
1869    }
1870 #endif
1871    /* Now call the TOM (Tfu ownership module) primitive to process further */
1872    ret = rgSCHTomSrInd (rgSchCb[inst].tfuSap[suId].cell, srInd);
1873    /* Free up the memory for the request structure */
1874    RGSCH_FREE_MEM(srInd);
1875    return (ret);
1876 }  /* RgLiTfuSrInd */
1877
1878
1879 /**
1880  * @brief Downlink CQI indication from PHY for an UE.
1881  *
1882  * @details
1883  *
1884  *     Function : RgLiTfuDlCqiInd
1885  *      
1886  *      This API is invoked by PHY to send Downlink CQI indication to Scheduler
1887  *      on recieving downlink CQI from UE.
1888  *      This API contains downlink CQI information recieved by PHY for an UE.
1889  *           
1890  *  @param[in]  Pst              *pst
1891  *  @param[in]  SuId             suId 
1892  *  @param[in]  TfuDlCqiIndInfo  *dlCqiInd
1893  *  @return  S16
1894  *      -# ROK 
1895  *      -# RFAILED 
1896  **/
1897 S16 RgLiTfuDlCqiInd(Pst *pst, SuId suId, TfuDlCqiIndInfo *dlCqiInd)
1898 {
1899    S16   ret;
1900    Inst  inst = pst->dstInst-SCH_INST_START;
1901
1902    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1903    {
1904       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," SAP Validation failed");
1905       /* Free up the memory for the request structure */
1906       RGSCH_FREE_MEM(dlCqiInd);
1907       return (ret);
1908    }
1909
1910    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1911    {
1912       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
1913       return RFAILED;
1914    }
1915    ret = rgSCHTomDlCqiInd (rgSchCb[inst].tfuSap[suId].cell, dlCqiInd);
1916    /* Free up the memory for the request structure */
1917    RGSCH_FREE_MEM(dlCqiInd);
1918    return (ret);
1919 }  /* RgLiTfuDlCqiInd */
1920 #ifdef TFU_UPGRADE
1921
1922 /**
1923  * @brief Raw CQI indication from PHY for an UE.
1924  *
1925  * @details
1926  *
1927  *     Function : RgLiTfuRawCqiInd
1928  *      
1929  *      This API is invoked by PHY to send Raw CQI indication to Scheduler
1930  *      on receiving Raw CQI from UE.
1931  *      This API contains Raw CQI information recieved by PHY for an UE.
1932  *           
1933  *  @param[in]  Pst              *pst
1934  *  @param[in]  SuId             suId 
1935  *  @param[in]  TfuRawCqiIndInfo  *rawCqiInd
1936  *  @return  S16
1937  *      -# ROK 
1938  *      -# RFAILED 
1939  **/
1940 S16 RgLiTfuRawCqiInd(Pst *pst, SuId suId, TfuRawCqiIndInfo *rawCqiInd)
1941 {
1942    S16   ret;
1943    Inst  inst = pst->dstInst-SCH_INST_START;
1944
1945 #ifdef NO_ERRCLS
1946    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1947    {
1948       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
1949       /* Free up the memory for the request structure */
1950       RGSCH_FREE_MEM(rawCqiInd);
1951       return (ret);
1952    }
1953
1954    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1955    {
1956       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," No cell exists");
1957       return RFAILED;
1958    }
1959 #endif
1960    ret = rgSCHTomRawCqiInd (rgSchCb[inst].tfuSap[suId].cell, rawCqiInd);
1961    /* Free up the memory for the request structure */
1962    RGSCH_FREE_MEM(rawCqiInd);
1963    return (ret);
1964 }  /* RgLiTfuRawCqiInd */
1965
1966 /**
1967  * @brief SRS indication from PHY for an UE.
1968  *
1969  * @details
1970  *
1971  *     Function : RgLiTfuSrsInd
1972  *      
1973  *      This API is invoked by PHY to send UL SRS indication to Scheduler
1974  *      on receiving a SRS from UE.
1975  *      This API contains SRS information recieved by PHY for an UE.
1976  *           
1977  *  @param[in]  Pst              *pst
1978  *  @param[in]  SuId             suId 
1979  *  @param[in]  TfuSrsIndInfo  *srsInd
1980  *  @return  S16
1981  *      -# ROK 
1982  *      -# RFAILED 
1983  **/
1984 S16 RgLiTfuSrsInd(Pst *pst, SuId suId, TfuSrsIndInfo *srsInd)
1985 {
1986    S16   ret;
1987    Inst  inst = pst->dstInst-SCH_INST_START;
1988
1989    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1990    {
1991       RLOG_ARG0(L_ERROR,DBG_INSTID,inst," SAP Validation failed");
1992       /* Free up the memory for the request structure */
1993       RGSCH_FREE_MEM(srsInd);
1994       return (ret);
1995    }
1996
1997    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1998    {
1999       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2000       return RFAILED;
2001    }
2002    ret = rgSCHTomSrsInd (rgSchCb[inst].tfuSap[suId].cell, srsInd);
2003    /* Free up the memory for the request structure */
2004    RGSCH_FREE_MEM(srsInd);
2005    return (ret);
2006 }  /* RgLiTfuSrsInd */
2007
2008 #endif 
2009
2010 /**
2011  * @brief DOA indication from PHY for an UE.
2012  *
2013  * @details
2014  *
2015  *     Function : RgLiTfuDoaInd
2016  *      
2017  *      This API is invoked by PHY to send Direction Of Arrival to Scheduler
2018  *      on calculating DOA at PHYSICAL LAYER for an UE.
2019  *      This API contains DOA information calculated by PHY for an UE.
2020  *           
2021  *  @param[in]  Pst              *pst
2022  *  @param[in]  SuId             suId 
2023  *  @param[in]  TfuDoaIndInfo    *doaInd
2024  *  @return  S16
2025  *      -# ROK 
2026  *      -# RFAILED 
2027  **/
2028 S16 RgLiTfuDoaInd(Pst *pst, SuId suId, TfuDoaIndInfo *doaInd)
2029 {
2030    S16   ret;
2031    Inst  inst = pst->dstInst-SCH_INST_START;
2032
2033    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2034    {
2035       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2036       /* Free up the memory for the request structure */
2037       RGSCH_FREE_MEM(doaInd);
2038       return (ret);
2039    }
2040
2041    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2042    {
2043       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2044       return RFAILED;
2045    }
2046    ret = rgSCHTomDoaInd (rgSchCb[inst].tfuSap[suId].cell, doaInd);
2047    /* Free up the memory for the request structure */
2048    RGSCH_FREE_MEM(doaInd);
2049    return (ret);
2050 }  /* RgLiTfuDlCqiInd */
2051
2052 /**
2053  * @brief CRC indication from PHY.
2054  *
2055  * @details
2056  *
2057  *     Function : RgLiTfuCrcInd
2058  *      
2059  *      This API is invoked by PHY to give CRC indication to scheduler.
2060  *           
2061  *  @param[in]  Pst               *pst
2062  *  @param[in]  SuId              suId 
2063  *  @param[in]  TfuCrcIndInfo *crcInd
2064  *  @return  S16
2065  *      -# ROK 
2066  *      -# RFAILED 
2067  **/
2068 S16 RgLiTfuCrcInd(Pst *pst, SuId suId, TfuCrcIndInfo  *crcInd)
2069 {
2070    S16              ret;
2071    Inst             inst      = pst->dstInst-SCH_INST_START;
2072
2073 #ifdef XEON_SPECIFIC_CHANGES
2074 struct timeval start6, end6;
2075 gettimeofday(&start6, NULL);
2076 #endif
2077 #ifndef NO_ERRCLS
2078    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2079    {
2080       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2081       RGSCH_FREE_MEM(crcInd);
2082       return (ret);
2083    }
2084
2085    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2086    {
2087       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2088       return RFAILED;
2089    }
2090 #endif
2091
2092    /* Now call the TOM (Tfu ownership module) primitive to process further */
2093    ret = rgSCHTomCrcInd(rgSchCb[inst].tfuSap[suId].cell, crcInd);
2094    /* Free up the memory for the request structure */
2095    RGSCH_FREE_MEM(crcInd);
2096 #ifdef XEON_SPECIFIC_CHANGES
2097 gettimeofday(&end6, NULL);
2098 #endif
2099    return (ret);
2100 }  /* RgLiTfuCrcInd */
2101
2102 /**
2103  * @brief Timing Advance indication from PHY.
2104  *
2105  * @details
2106  *
2107  *     Function : RgLiTfuTimingAdvInd
2108  *      
2109  *      This API is invoked by PHY to indicate timing advance to Scheduler for
2110  *       an UE.
2111  *           
2112  *  @param[in]  Pst                  *pst
2113  *  @param[in]  SuId                 suId 
2114  *  @param[in]  TfuTimingAdvIndInfo  *timingAdvInd
2115  *  @return  S16
2116  *      -# ROK 
2117  *      -# RFAILED 
2118  **/
2119 S16 RgLiTfuTimingAdvInd(Pst *pst, SuId suId, TfuTimingAdvIndInfo *timingAdvInd)
2120 {
2121    S16   ret;
2122    Inst  inst = pst->dstInst-SCH_INST_START;
2123
2124    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2125    {
2126       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2127       /* Free up the memory for the request structure */
2128       RGSCH_FREE_MEM(timingAdvInd);
2129       return (ret);
2130    }
2131
2132    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2133    {
2134       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2135       return RFAILED;
2136    }
2137    /* Now call the TOM (Tfu ownership module) primitive to process further */
2138    ret = rgSCHTomTimingAdvInd(rgSchCb[inst].tfuSap[suId].cell, timingAdvInd);
2139    /* Free up the memory for the request structure */
2140    RGSCH_FREE_MEM(timingAdvInd);
2141    return (ret);
2142 }  /* RgLiTfuTimingAdvInd */
2143
2144 /************* RGM  Interface ****************/
2145 /**
2146  * @brief API for bind request from RRM towards MAC. 
2147  *
2148  * @details
2149  *
2150  *     Function: RgUiRgmBndReq
2151  *     
2152  *     This API is invoked by RRM towards MAC to bind RGM SAP. 
2153  *     These API validates the Pst, spId, suId and sends the bind confirm to
2154  *     RRM.
2155  *
2156  *           
2157  *  @param[in]  Pst   *pst
2158  *  @param[in]  SuId  suId
2159  *  @param[in]  SpId  spId
2160  *  @return  S16
2161  *      -# ROK 
2162  *      -# RFAILED 
2163  **/
2164 S16 RgUiRgmBndReq(Pst *pst,SuId  suId,SpId  spId)
2165 {
2166    S16       ret = ROK;
2167    Pst       tmpPst;   /* Temporary Post Structure */
2168    Inst      instId = pst->dstInst-SCH_INST_START;
2169
2170    tmpPst.prior       = pst->prior;
2171    tmpPst.route       = pst->route;
2172    tmpPst.selector    = pst->selector;
2173    tmpPst.region      = rgSchCb[instId].rgSchInit.region;
2174    tmpPst.pool        = rgSchCb[instId].rgSchInit.pool;
2175
2176    tmpPst.srcProcId   = rgSchCb[instId].rgSchInit.procId;
2177    tmpPst.srcEnt      = rgSchCb[instId].rgSchInit.ent;
2178    tmpPst.srcInst     = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
2179
2180    tmpPst.event       = EVTNONE;
2181
2182    tmpPst.dstProcId   = pst->srcProcId;
2183    tmpPst.dstEnt      = pst->srcEnt;
2184    tmpPst.dstInst     = pst->srcInst;
2185
2186    /*TODO remove follo statement*/
2187    rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2188
2189    if(spId < rgSchCb[instId].numSaps)
2190    {
2191       /* Check the state of the SAP */
2192       switch (rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2193       {
2194          /* This case might not be needed if SAP not configured then it will go
2195           * to else of above if condition */
2196          case LRG_UNBND: /* SAP is not bound */
2197                  RLOG0(L_DEBUG,"SAP is not yet bound");
2198             rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_BND;
2199             rgSchCb[instId].rgmSap[spId].sapCfg.suId = suId;
2200             /* Send Bind Confirm with status as SUCCESS */
2201             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2202              /*Indicate to Layer manager  */
2203             break;
2204          case LRG_BND: /* SAP is already bound*/
2205                  RLOG0(L_DEBUG,"SAP is already bound");
2206             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2207             break;
2208          default: /* Should Never Enter here */
2209 #if (ERRCLASS & ERRCLS_ADD_RES) 
2210             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG001, 
2211                  (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2212                   "Invalid SAP State:RgUiRgmBndReq failed\n");
2213 #endif
2214             ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_NOK);
2215             break;
2216       }
2217    }
2218    else
2219    {
2220 #if (ERRCLASS & ERRCLS_ADD_RES)      
2221 /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state 
2222    to spId to avoid seg fault due to invalid sapID */
2223       RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG002,
2224             (ErrVal)spId, "Invalid SAP Id:RgUiRrmBndReq failed\n");
2225 #endif
2226       ret = RgUiRgmBndCfm(&tmpPst, suId, CM_BND_NOK);
2227    }
2228    return (ret);
2229 }  /* RgUiRgmBndReq */
2230
2231 /**
2232  * @brief API for unbind request from RRM towards MAC. 
2233  *
2234  * @details
2235  *
2236  *     Function: RgUiRgmUbndReq
2237  *     
2238  *     This API is invoked by RRM towards MAC to unbind RGM SAP. 
2239  *     These API validates the Pst, spId, suId and transfers the unbind request 
2240  *     specific information to corresponding ownership module (GOM) API.
2241  *
2242  *           
2243  *  @param[in]  Pst    *pst
2244  *  @param[in]  SuId   suId
2245  *  @param[in]  Reason reason
2246  *  @return  S16
2247  *      -# ROK 
2248  *      -# RFAILED 
2249  **/
2250 S16 RgUiRgmUbndReq(Pst    *pst,SpId   spId,Reason reason)
2251 {
2252    Inst instId = pst->dstInst-SCH_INST_START;
2253
2254    /* SAP Id validation */
2255    if (spId < rgSchCb[instId].numSaps)
2256    {
2257       switch(rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2258       {
2259          case LRG_BND: /* SAP is already bound*/
2260             /* setting SAP state to UN BOUND */
2261                  RLOG0(L_DEBUG,"SAP is already bound");
2262             rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2263             break;
2264          default:
2265 #if (ERRCLASS & ERRCLS_ADD_RES)      
2266             RGSCHLOGERROR(instId, ERRCLS_INT_PAR, ERG003,
2267                    (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2268                   "Invalid SAP State: RgUiRgmUbndReq failed\n");
2269 #endif
2270             return RFAILED;
2271       }
2272    }
2273    else
2274    {
2275 #if (ERRCLASS & ERRCLS_ADD_RES)      
2276       RGSCHLOGERROR(instId,ERRCLS_INT_PAR, ERG004, 
2277             (ErrVal)rgSchCb[instId].rgmSap[spId].sapSta.sapState,
2278             "Invalid SAP Id:RgUiRgmUbndReq failed\n");
2279 #endif
2280       return RFAILED;
2281    }
2282    return ROK;
2283 }  /* RgUiRgmUbndReq */
2284
2285
2286 /**
2287  * @brief API for start or stop PRB reporting from RRM towards MAC. 
2288  *
2289  * @details
2290  *
2291  *     Function: RgUiRgmCfgPrbRprt
2292  *     
2293  *     This API is invoked by RRM towards MAC to start or stop calculating
2294  *     Average PRB usage in downlink and uplink. The average PRB usage will
2295  *     be reported to RRM based on confiured periodicity.
2296  *
2297  *           
2298  *  @param[in]  Pst   *pst
2299  *  @param[in]  SuId  suId
2300  *  @param[in]  SpId  spId
2301  *  @return  S16
2302  *      -# ROK 
2303  *      -# RFAILED 
2304  **/
2305 S16 RgUiRgmCfgPrbRprt(Pst   *pst, SpId  spId,RgmPrbRprtCfg *prbRprtCfg)
2306 {
2307 /* Initalize*/
2308    RgSchCellCb   *cell;
2309    RgSchPrbUsage *prbUsage;
2310    Inst          inst = (pst->dstInst  - SCH_INST_START);
2311
2312    cell = rgSchCb[inst].rgmSap[spId].cell;
2313    prbUsage = &cell->prbUsage;
2314    prbUsage->prbRprtEnabld = prbRprtCfg->bConfigType;
2315    prbUsage->rprtPeriod = prbRprtCfg->usPrbAvgPeriodicty;
2316    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, prbUsage->startTime, 1);
2317
2318    /* clear the qciPrbRpts for all GBR QCIs */
2319    memset(&prbUsage->qciPrbRpts[0], 0, 
2320              (RGM_MAX_QCI_REPORTS * sizeof(RgSchQciPrbUsage)));
2321
2322    RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
2323              "RgUiRgmCfgPrbRprt config type %d with the report period %d",
2324              prbUsage->prbRprtEnabld,prbUsage->rprtPeriod);
2325
2326    /* ccpu00134393 : mem leak fix */
2327       SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
2328   
2329    return ROK;
2330 }
2331 /**
2332  * @brief ERROR INDICATION from PHY for the i failed unlicensed Scell transmission. 
2333  *
2334  * @details
2335  *
2336  *     Function : RgLiTfuErrInd
2337  *      
2338  *      This API is invoked by PHY to send ERROR INDICATION to scheduler 
2339  *      Currently invoked in the cases when the Unlicensed SCell transmission
2340  *      fails.
2341  *      This API contains the Cell and subframe information for which the
2342  *      transmission failed. 
2343  *           
2344  *  @param[in]  Pst                *pst
2345  *  @param[in]  SuId               suId 
2346  *  @param[in]  TfuErrIndInfo      *errIndInfo 
2347  *  @return  S16
2348  *      -# ROK 
2349  *      -# RFAILED 
2350  **/
2351 S16 RgLiTfuErrInd(Pst *pst, SuId suId, TfuErrIndInfo  *errInd)
2352 {
2353    S16   ret = ROK;
2354 #ifdef LTE_ADV
2355    Inst  inst = (pst->dstInst - SCH_INST_START);
2356 #endif
2357
2358 #ifndef NO_ERRCLS
2359    if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2360    {
2361
2362       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"SAP Validation failed");
2363       return (ret);
2364    }
2365
2366    if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2367    {
2368       RLOG_ARG0(L_ERROR,DBG_INSTID,inst,"No cell exists");
2369       return RFAILED;
2370    }
2371 #endif
2372
2373 #ifdef LTE_ADV
2374    /* Now call the TOM (Tfu ownership module) primitive to process further */
2375    ret = rgSCHLaaErrInd(rgSchCb[inst].tfuSap[suId].cell, errInd);
2376 #endif
2377    return (ret);
2378 }  /* RgLiTfuErrInd */
2379
2380
2381 \f
2382 /**********************************************************************
2383  
2384          End of file
2385 **********************************************************************/