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