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