Merge "replaced cmMemSet, cmMemcpy with memset and memcpy resp AND Removed TRC()...
[o-du/l2.git] / src / 5gnrsch / rg_sch_scell.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 Round Robin functions
26
27      File:     rg_sch_scell.c
28
29 **********************************************************************/
30
31 /** @file rg_sch_rr.c
32 @brief This module handles the round robin scheduler functionality
33 */
34
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
37 #include "lrg.h"
38 #include "rgr.h"
39 #include "rgm.h"
40 #include "tfu.h"
41 #include "rg_env.h"
42 #include "rg_sch_inf.h"
43 #include "rg_sch_err.h"
44 #include "rg_sch.h"
45 #include "rg_sch_cmn.h"
46
47 /* header/extern include files (.x) */
48 #include "tfu.x"           /* RGU types */
49 #include "lrg.x"           /* layer management typedefs for MAC */
50 #include "rgr.x"           /* layer management typedefs for MAC */
51 #include "rgm.x"           /* layer management typedefs for MAC */
52 #include "rg_sch_inf.x"    /* typedefs for Scheduler */
53 #include "rg_sch.x"        /* typedefs for Scheduler */
54 #include "rg_sch_cmn.x"
55
56 #ifdef LTE_ADV
57
58 Void rgSCHSCellActivation ARGS((
59 RgSchUeCellInfo  *sCell
60 ));
61
62 Void rgSCHSCellSchdActDeactCe ARGS((
63 RgSchUeCb         *ueCb,
64 RgSchDlHqTbCb     *tbInfo
65 ));
66 Void rgSCHSCellAddToActDeactLst ARGS((
67 RgSchCellCb                *cell,
68 RgSchUeCb                  *ue
69 ));
70
71 Void rgSCHSCellRmvFrmActLst ARGS((
72 RgSchCellCb                *cell,
73 RgSchUeCb                  *ue
74 ));
75 S16 rgSCHSCellIsActive ARGS((
76 RgSchCellCb                *cell,
77 RgSchUeCb                  *ue
78 ));
79
80 Void rgSCHSCellHndlFdbkInd ARGS((
81 RgSchDlHqProcCb   *hqP,
82 U8                tbIdx,
83 U8                fdbk,
84 Bool              maxHqRetxReached
85 ));
86
87 #ifdef LTE_ADV
88 Void rgSCHSCellDeactTmrExpry ARGS((
89 RgSchUeCellInfo *sCell
90 ));
91 #endif
92
93 Void rgSCHSCellDelUeSCell ARGS((
94 RgSchCellCb  *cellCb,
95 RgSchUeCb    *ueCb,
96 U8            sCellIdx
97 ));
98
99 S16 rgSCHSCellDelUe ARGS((
100 RgSchCellCb  *cellCb,
101 RgSchUeCb    *ueCb
102 ));
103 #ifdef TFU_UPGRADE
104 S16 rgSCHSCellPCqiCfg ARGS((
105 RgSchCellCb  *priCellCb,
106 RgSchCellCb  *secCellCb,
107 RgSchUeCb    *ueCb,
108 RgrUePrdDlCqiCfg  *cqiCfg,
109 CmLteUeCategory   ueCat,
110 U8            sCellIdx
111 ));
112 #endif
113 PRIVATE S16 rgSCHSCellTrgMacHqEReset ARGS((
114 Inst          inst,
115 U16           secCellId,
116 U16           rnti
117 ));
118
119
120
121 /** * @brief Handler for scheduling Scell Activation CE.
122  *
123  * @details
124  *
125  *     Function : rgSCHDhmShcdSCellActCe
126  *     
127  *     This function is called by scheduler when resource allocation
128  *     for SCell Activation CE transmission is done.
129  *           
130  *  @param[in]  RgSchUeCb         *ue
131  *  @param[out] RgSchDlHqTbCb     *tbInfo
132  *  @return     Void
133  *      -# None.
134  **/
135 #ifdef ANSI
136 Void rgSCHSCellSchdActDeactCe
137 (
138 RgSchUeCb         *ueCb,
139 RgSchDlHqTbCb     *tbInfo
140 )
141 #else
142 Void rgSCHSCellSchdActDeactCe(ueCb, tbInfo)
143 RgSchUeCb         *ueCb;
144 RgSchDlHqTbCb     *tbInfo;
145 #endif
146 {
147
148    U8   bitVal = 0;
149    U8   sCellActDeactBitMask = 0;
150
151    /* Change the state of all Scells waiting for
152     * activation */
153
154    /* -------------------------
155     * | C7|C6|C5|C4|C3|C2|C1|R|
156     * -------------------------*/
157     /* 1 for activation
158      * 0 for deactivation
159      * */
160
161    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
162    {
163       if(ueCb->cellInfo[idx] != NULLP)
164       {
165          switch(ueCb->cellInfo[idx]->sCellState)
166          {
167             case RG_SCH_SCELL_TOBE_ACTIVATED:
168             case RG_SCH_SCELL_ACTVTN_IN_PROG:
169                {
170                   ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_ACTVTN_IN_PROG; 
171                   bitVal = 1;
172                }
173                break;
174             case RG_SCH_SCELL_ACTIVE:
175                {
176                   bitVal = 1;
177                }
178                break;
179             case RG_SCH_SCELL_TOBE_DEACTIVATED:
180             case RG_SCH_SCELL_DEACTVTN_IN_PROG:
181                {
182                   ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_DEACTVTN_IN_PROG; 
183                   bitVal = 0;
184                }
185                break;
186             case RG_SCH_SCELL_INACTIVE:
187             case RG_SCH_SCELL_READY:
188                {
189                   bitVal = 0;
190                }
191                break;
192          }
193       }
194       if(1 == bitVal)
195       {
196          sCellActDeactBitMask |= 1 << (idx);/* servCellIdx = idx + 1 */
197          bitVal = 0;
198       }
199    }
200    tbInfo->schdSCellActCe.pres    = PRSNT_NODEF;
201    tbInfo->schdSCellActCe.val     = sCellActDeactBitMask;
202
203    RETVOID;
204 } /* rgSCHSCellSchdActDeactCe */
205
206 \f
207 /**
208  * @brief Adds an UE to the Cell's SCell Activation list
209  *
210  * @details
211  *
212  *     Function: rgSCHSCellAddToActDeactLst
213  *     Purpose:  Adds an UE to Cell's SCEll Act list
214  *
215  *     Invoked by: Common Scheduler
216  *
217  *  @param[in]  RgSchCellCb*     cell
218  *  @param[in]  RgSchUeCb*       ue
219  *  @return  Void
220  *
221  **/
222 #ifdef ANSI
223 Void rgSCHSCellAddToActDeactLst
224 (
225 RgSchCellCb                *cell,
226 RgSchUeCb                  *ue
227 )
228 #else
229 Void rgSCHSCellAddToActDeactLst(cell, ue)
230 RgSchCellCb                *cell;
231 RgSchUeCb                  *ue;
232 #endif
233 {
234    RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
235
236    if(NULLP == ue->sCellActLnk.node)
237    {/* Ue is not present in the list */
238       cmLListAdd2Tail(&cellCmnDl->secCellActCeLst, &ue->sCellActLnk);
239       ue->sCellActLnk.node = (PTR)ue;
240    }
241    else
242    {
243       RGSCHDBGINFONEW(cell->instIdx,(rgSchPBuf(cell->instIdx),
244             "SCell is already added in the Act List: ueId(%u)\n", ue->ueId));
245    }
246    
247    RETVOID;
248 }
249
250 \f
251 /**
252  * @brief Removes an UE from Cell's SCell Activation list
253  *
254  * @details
255  *
256  *     Function: rgSCHSCellRmvFrmActLst
257  *     Purpose:  Removes an UE from Cell's SCEll Act list
258  *
259  *     Invoked by: Specific Scheduler
260  *
261  *  @param[in]  RgSchCellCb*     cell
262  *  @param[in]  RgSchUeCb*       ue
263  *  @return  Void
264  *
265  **/
266 #ifdef ANSI
267 Void rgSCHSCellRmvFrmActLst
268 (
269 RgSchCellCb                *cell,
270 RgSchUeCb                  *ue
271 )
272 #else
273 Void rgSCHSCellRmvFrmActLst(cell, ue)
274 RgSchCellCb                *cell;
275 RgSchUeCb                  *ue;
276 #endif
277 {
278    RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
279    if (NULLP != ue->sCellActLnk.node)
280    {
281       cmLListDelFrm(&cellCmnDl->secCellActCeLst, &ue->sCellActLnk);
282    }
283    ue->sCellActLnk.node = (PTR)NULLP;
284
285    RETVOID;
286 }
287 \f
288 /**
289  * @brief Handling of SCell Activation
290  *
291  * @details
292  *
293  *     Function: rgSCHSCellActivation
294  *     Purpose : Perform Activation of secondary cell
295  *             : Move the state to ACTIVE
296  *             : Start the procedure for PCQI/SRS for this scell
297  *
298  *     Invoked by:Cfg/Commn Scheduler 
299  *
300  *  @param[in]  RgSchUeCellInfo *sCellInfo
301  *
302  *  @return  ROK/RFAILED
303  *
304  **/
305 #ifdef ANSI
306 Void rgSCHSCellActivation
307 (
308 RgSchUeCellInfo  *sCellInfo
309 )
310 #else
311 Void rgSCHSCellActivation(sCellInfo)
312 RgSchUeCellInfo  *sCellInfo
313 #endif
314 {
315    RgSchCellCb  *sCell = sCellInfo->cell;
316    RgSchUeCb    *ueCb = sCellInfo->ue;
317    RgSchCmnCell *cellSch;
318 #ifdef TFU_UPGRADE
319 #ifdef DEBUGP
320    Inst   inst = ueCb->cell->instIdx;
321 #endif
322    U16    tempIdx; 
323    RgrUePrdDlCqiCfg  *cqiCfg;
324    U8     j;  /*Bandwidth Parts*/
325    U16    riTrInsTime; 
326    U16    periodicity; 
327    U16    cqiTrInstTime; 
328    RgSchUePCqiCb *cqiCb = NULLP;
329    CmLteTimingInfo timingInfo;
330    U16    crntTime;           
331 #endif
332
333
334    sCellInfo->sCellState = RG_SCH_SCELL_ACTIVE;
335 #ifdef TENB_STATS
336    ueCb->tenbStats->stats.persistent.numActivation++;
337 #endif
338
339 #ifdef CA_DBG 
340    printf("ueId is SCELL_ACTIVE\n ueCb->ueId = %d sCell->sCellIdx =%d, sCell->sCellId=%d, sCell->sCellState=%d \n", ueCb->ueId, sCellInfo->sCellIdx, sCellInfo->sCellId, sCellInfo->sCellState);
341 #endif
342    /* Start the sCellDeactivation timer if cfgd */
343    if(PRSNT_NODEF == ueCb->sCellDeactTmrVal.pres)
344    {
345       //rgSCHTmrStartTmr (sCell,sCellInfo ,RG_SCH_TMR_SCELL_DEACT,
346         //    ueCb->sCellDeactTmrVal.val);
347    }
348
349 #ifdef TFU_UPGRADE
350    /* Start receiving CQI for this SCell for this UE */
351    crntTime = (ueCb->cell->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)+
352                   (ueCb->cell->crntTime.slot);
353
354    cqiCb = &sCellInfo->cqiCb;
355    cqiCfg = &cqiCb->cqiCfg;
356    if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
357    {
358       cqiTrInstTime = ((cqiCb->cqiPeri+crntTime) - cqiCb->cqiOffset)
359          %cqiCb->cqiPeri;
360       cqiCb->nCqiTrIdx = (crntTime + 
361             (cqiCb->cqiPeri - cqiTrInstTime));
362       /* Introduced timing delta for reception req
363        * in FDD*/
364       if(cqiCb->nCqiTrIdx  <= (crntTime + TFU_RECPREQ_DLDELTA))
365       {
366          cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx + cqiCb->cqiPeri;
367       }
368
369       timingInfo.sfn =  cqiCb->nCqiTrIdx/RGSCH_NUM_SUB_FRAMES_5G;
370       timingInfo.slot =  cqiCb->nCqiTrIdx%RGSCH_NUM_SUB_FRAMES_5G;
371       if(cqiCb->cqiCfg.cqiSetup.cqiRepType == RGR_UE_PCQI_SB_REP)
372       {
373          rgSCHTomUtlPcqiSbCalcBpIdx(timingInfo,ueCb,cqiCb); 
374       }
375
376       cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx
377          %RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
378       RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), "CQI Config: idx(%u) Periodicity %u"
379                "Offset %u uePosInQ (%u)\n", cqiCfg->cqiSetup.cqiPCfgIdx,
380                cqiCb->cqiPeri, cqiCb->cqiOffset,cqiCb->nCqiTrIdx));
381
382       cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
383             &cqiCb->cqiLstEnt);  
384
385       rgSCHUtlSCellHndlCqiCollsn(cqiCb);
386
387       RGSCHDBGINFO(inst,(rgSchPBuf(inst), 
388                "\n rgSCHCfgPCqiUeCfg():"
389                "  CrntTime=%d  Next CqiTrInstTime=%d  Index Stored at=%d  ",
390                crntTime, cqiTrInstTime, cqiCb->nCqiTrIdx));
391
392       if(cqiCfg->cqiSetup.riEna)
393       {
394          cqiCb->perRiVal = 1;
395          cqiCb->invalidateCqi = FALSE;
396
397          if(RGR_UE_PCQI_WB_REP == cqiCfg->cqiSetup.cqiRepType)
398          {
399             /* 
400                1. wideband RI reporting is configured 
401                (Mode 1-0 or 1-1)
402                (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )Mod(NCqiperiod
403              *MriPeriod)=0  
404              */ 
405             periodicity = cqiCb->cqiPeri * cqiCb->riPeri; 
406          }
407          else
408          {
409             /*
410              *  Where Widesband and Subband RI reporting is configured
411              *   (Mode 2-0 or 2-1 )
412              *   (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )
413              *   Mod(H. NCqiperiod *MriPeriod )=0 
414              *   where H= J * K +1;  J=Number of bandwidth parts(BW/subsize). 
415              *   K is RGR interf input 
416              */
417
418             RG_SCH_GET_CQI_J_VAL(sCell->bwCfg.dlTotalBw, j);
419             cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1;  
420             periodicity = cqiCb->h * cqiCb->cqiPeri * 
421                cqiCb->riPeri; 
422
423          }
424
425          /* In case of SFN wraparound, the SB CQI reporting cycle breaks
426           * and RI->WB CQI->SBCQI.. should resume. RI is repositioned 
427           * accordingly. WBCQI handling is naturally accomplished */
428          if (periodicity >= RGSCH_MAX_SUBFRM_5G)
429          {
430             periodicity = cqiCb->cqiOffset - cqiCb->riOffset + 
431                RGSCH_MAX_SUBFRM_5G - (crntTime);
432             tempIdx = crntTime + periodicity;
433          }
434          else
435          {
436             riTrInsTime = ((periodicity +crntTime )- \
437                   cqiCb->cqiOffset + cqiCb->riOffset)\
438                           % periodicity;
439             tempIdx = (crntTime + (periodicity -riTrInsTime));
440          }
441          if (tempIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
442          {
443             tempIdx = tempIdx + periodicity; 
444          }
445          cqiCb->nRiTrIdx = tempIdx 
446             % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
447          if(periodicity >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
448          {  
449             cqiCb->riDist = rgSCHUtlFindDist((U16)(crntTime + TFU_RECPREQ_DLDELTA),
450                   (U16) tempIdx);
451          }
452          else
453          {
454             cqiCb->riDist =0; 
455          }
456
457
458          /* Start receiving RI for this SCell for this UE */
459          cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst,
460                &cqiCb->riLstEnt);  
461          RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_ADD,
462             &ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
463
464          rgSCHUtlSCellHndlRiCollsn(cqiCb);
465          /*werror*/
466 #ifndef BIT_64
467          RGSCHDBGINFONEW(inst,(rgSchPBuf(inst), "SCel RI cfg:"
468                   "idx %u period %u Offset %u posInQ(%u) riDist(%u)lst count"
469                   "%lu\n", cqiCfg->cqiSetup.riCfgIdx, cqiCb->riPeri,
470                   cqiCb->riOffset, cqiCb->nRiTrIdx, cqiCb->riDist, 
471                   ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst.count));
472 #else
473          RGSCHDBGINFONEW(inst,(rgSchPBuf(inst), "SCel RI cfg:"
474                   "idx %u period %u Offset %u posInQ(%u) riDist(%u)lst count"
475                   "%u\n", cqiCfg->cqiSetup.riCfgIdx, cqiCb->riPeri,
476                   cqiCb->riOffset, cqiCb->nRiTrIdx, cqiCb->riDist, 
477                   ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst.count));
478
479
480 #endif
481
482          RGSCHDBGINFO(inst,(rgSchPBuf(inst),
483                   "\n rgSCHSCellActivation(): CrntTime=%d Next RiTrInstTime=%d"
484                   "Index Stored at=%d riDis=%d ",
485                   crntTime, riTrInsTime, cqiCb->nRiTrIdx, cqiCb->riDist));
486       }
487    }
488 #endif
489
490    cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
491    cellSch->apisDl->rgSCHDlSCellActv(sCellInfo->cell, sCellInfo->ue);
492
493    RETVOID;
494 }
495
496 #ifdef TFU_UPGRADE
497 \f
498 /**
499  * @brief Remove CQI from Scell Lst
500  *
501  * @details
502  *
503  *     Function: rgSCHCellClearScellLstOfCQI
504  *     Purpose : Remove CQI from Scell Lst
505  *              
506  *
507  *     Invoked by: Timer
508  *
509  *  @param[in]  RgSchUeCellInfo *sCellInfo
510  *  @return  Void
511  *
512  **/
513 #ifdef ANSI
514 PRIVATE Void rgSCHCellClearScellLstOfCQI
515 (
516 RgSchUeCellInfo *sCellInfo
517 )
518 #else
519 PRIVATE Void rgSCHCellClearScellLstOfCQI(sCellInfo)
520 RgSchUeCellInfo *sCellInfo;
521 #endif
522 {
523
524    RgSchUePCqiCb *cqiRiCb = NULLP;
525    RgSchUeCb    *ueCb;
526    ueCb = sCellInfo->ue;
527    /* Clear CQI/RI entry for this SCELL */
528    cqiRiCb = &sCellInfo->cqiCb;
529    /* Delete Periodic CQI/PMI  Transmission Instance  */
530    if (cqiRiCb->nCqiTrIdx != RG_SCH_INVALID_IDX)
531    {
532       cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nCqiTrIdx].cqiLst, 
533             &cqiRiCb->cqiLstEnt); 
534       cqiRiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
535
536       if (ueCb->nPCqiCb == cqiRiCb)
537       {
538          rgSCHUtlSCellHndlCqiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
539       }
540       /* Delete Periodic  RI  Transmission Instance  */
541
542       if (cqiRiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
543       {
544          cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst, 
545                &cqiRiCb->riLstEnt); 
546          RG_SCH_RECORD(&cqiRiCb->histElem,RGSCH_ACTION_DEL,
547             &ueCb->cell->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst);
548          cqiRiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
549          if (ueCb->nPRiCb == cqiRiCb)
550          {
551             rgSCHUtlSCellHndlRiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
552          }
553       }
554    }
555
556    RETVOID;
557 }
558 #endif/*TFU_UPGRADE*/
559 \f
560 /**
561  * @brief Handling of SCell DeActivation
562  *
563  * @details
564  *
565  *     Function: rgSCHSCellDeActivation
566  *     Purpose : Perform Deactivation of secondary cell
567  *             : Move the state to IN_ACTIVE
568  *             : Flush the harqEntity
569  *             : Trigger harqEntity flushing to MAC
570  *             : Remove  PCQI/SRS for this scell
571  *             : Stop Deactivation timer if running
572  *
573  *     Invoked by:Cfg/Commn Scheduler 
574  *
575  *  @param[in]  RgSchUeCellInfo *sCellInfo
576  *
577  *  @return  ROK/RFAILED
578  *
579  **/
580 #ifdef ANSI
581 PRIVATE S16 rgSCHSCellDeActivation
582 (
583 RgSchUeCellInfo *sCellInfo
584 )
585 #else
586 PRIVATE S16 rgSCHSCellDeActivation(sCellInfo)
587 RgSchUeCellInfo *sCellInfo
588 #endif
589 {
590    return ROK;
591    RgSchCmnCell *cellSch;
592    Inst inst = sCellInfo->cell->instIdx;
593
594    /* Stop the timer if running */
595
596    if(sCellInfo->deactTmr.tmrEvnt != TMR_NONE)
597    {
598       rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_DEACT, sCellInfo);
599    }
600
601    if (sCellInfo->actDelayTmr.tmrEvnt != TMR_NONE)
602    {
603       rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_ACT_DELAY, sCellInfo);
604    }
605
606    cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
607    cellSch->apisDl->rgSCHDlUeReset(sCellInfo->cell, sCellInfo->ue);
608
609    if(sCellInfo->ue->isDrxEnabled)
610    {   
611       rgSCHDrxUeHqReset(sCellInfo->ue->cell, sCellInfo->ue, 
612                         sCellInfo->hqEnt, sCellInfo->sCellIdx);
613    }
614
615    /* Flush the harqEntity at scheduler */
616    if(sCellInfo->hqEnt != NULLP) 
617    {
618       rgSCHDhmHqEntReset(sCellInfo->hqEnt);
619    }
620    /* Trigger harq flush req to MAC */
621
622
623    rgSCHSCellTrgMacHqEReset(inst,sCellInfo->sCellId,sCellInfo->ue->ueId);
624    
625    sCellInfo->sCellState = RG_SCH_SCELL_READY;
626 #ifdef TFU_UPGRADE
627    rgSCHCellClearScellLstOfCQI(sCellInfo);
628 #endif
629
630 #ifdef TENB_STATS
631    sCellInfo->ue->tenbStats->stats.persistent.numDeactivation++;
632 #endif
633
634    cellSch->apisDl->rgSCHDlSCellDeactv(sCellInfo->cell, sCellInfo->ue);
635
636 #ifdef CA_DBG 
637    printf("SCELL DEATIVATED  sCellInfo->ue->ueId =%d, sCellInfo->sCellId =%d\n", sCellInfo->ue->ueId, sCellInfo->sCellId);
638    //MSPD_DBG("SCELL DEATIVATED  sCellInfo->ue->ueId =%d, sCellInfo->sCellId =%d\n", sCellInfo->ue->ueId, sCellInfo->sCellId);
639 #endif
640    return ROK;
641 }
642
643 \f
644 /**
645  * @brief Triggering hqEntity reset to mac
646  *
647  * @details
648  *
649  *     Function: rgSCHSCellTrgMacHqEReset
650  *     Purpose: Frame the interface for mac to reset
651  *              the mac
652  *              Derive the macInstance corresponding
653  *              to the secondary cell going to be deactivated.
654  *              Triiger the msg to that macInstance
655  *
656  *     Invoked by: CommonScheduler
657  *
658  *  @param[in]  U16        sCellId
659  *  @param[in]  U16        rnti
660  *  @return  Void
661  *
662  **/
663 #ifdef ANSI
664 PRIVATE S16 rgSCHSCellTrgMacHqEReset
665 (
666 Inst          inst,
667 U16           secCellId,
668 U16           rnti
669 )
670 #else
671 PRIVATE S16 rgSCHSCellTrgMacHqEReset(inst,secCellId,rnti)
672 Inst          inst;
673 U16           secCellId;
674 U16           rnti;
675 #endif
676 {
677    Pst               pst;
678    RgSchCellCb      *secCellCb = NULLP;
679    RgInfResetHqEnt   hqEntRstInfo;
680
681    if((secCellCb = (RgSchCellCb *)rgSchUtlGetCellCb(inst, secCellId)) == NULLP)
682    {
683       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst), "SCell doesnt exists"));
684       return RFAILED;
685    }
686
687    hqEntRstInfo.cellId = secCellId;
688    hqEntRstInfo.crnti  = rnti;
689
690    rgSCHUtlGetPstToLyr(&pst, &rgSchCb[inst], secCellCb->macInst);
691
692    RgSchMacRstHqEnt(&pst, &hqEntRstInfo);
693
694    return ROK;
695 }
696 /*removed endif*/
697
698
699 \f
700 /**
701  * @brief Handling of harq feeback for SCell act CE txion
702  *
703  * @details
704  *
705  *     Function: rgSCHSCellHndlFdbkInd
706  *     Purpose:  Handling the harq feedback for SCell ACT ce txion
707  *               ACK:: Set the state as active for the Scells for which
708  *                     CE was sent
709  *               HQ FAILURE/DTX/NACK:: Perform retxion. Add to Act CE list
710  *                                   Set the state to TOBE_SCHEDULED
711  *               
712  *
713  *     Invoked by: CommonScheduler
714  *
715  *  @param[in]  RgSchCellCb*     cell
716  *  @param[in]  RgSchUeCb*       ue
717  *  @return  Void
718  *
719  **/
720 #ifdef ANSI
721 Void rgSCHSCellHndlFdbkInd
722 (
723 RgSchDlHqProcCb   *hqP,
724 U8                tbIdx,
725 U8                fdbk,
726 Bool              maxHqRetxReached
727 )
728 #else
729 Void rgSCHSCellHndlFdbkInd(hqP, tbIdx, fdbk,maxHqRetxReached)
730 RgSchDlHqProcCb   *hqP;
731 U8                tbIdx;
732 U8                fdbk;
733 Bool              maxHqRetxReached;
734 #endif
735 {
736
737    RgSchUeCb      *ueCb;
738    RgSchCellCb    *cell;
739    RgSchUeCellInfo *sCellInfo;
740
741
742    ueCb  = hqP->hqE->ue;
743    cell  = ueCb->cell;
744    switch(fdbk)
745    {
746       case TFU_HQFDB_ACK:
747          {
748             hqP->tbInfo[tbIdx].schdSCellActCe.pres =  FALSE;
749
750             for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
751             {
752                if(ueCb->cellInfo[idx] != NULLP) 
753                {
754                   if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
755                   {
756 #ifdef CA_DBG
757                      printf("\n starting delay timer...\n");
758 #endif                     
759                      rgSCHTmrStartTmr (cell,ueCb->cellInfo[idx] ,RG_SCH_TMR_SCELL_ACT_DELAY,
760                            RG_SCH_CMN_SCELL_ACT_DELAY_TMR);
761                   }
762                   else
763                   {
764                      if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
765                      {
766                         sCellInfo = ueCb->cellInfo[idx];
767                         rgSCHSCellDeActivation(sCellInfo);
768                      }
769                   }
770                }
771             }
772          }
773          break;
774       case TFU_HQFDB_NACK:
775       case TFU_HQFDB_DTX:
776          {
777             if(TRUE == maxHqRetxReached)
778             {
779                hqP->tbInfo[tbIdx].schdSCellActCe.pres =  FALSE;
780                for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
781                {
782                   if(ueCb->cellInfo[idx] != NULLP) 
783                   {
784                      if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
785                      {
786                         ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
787                      }
788                      else
789                      {
790                         if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
791                         {
792                            ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
793                         }
794                      }
795                   }
796                   /* Add to actDeactCe lst */
797                   rgSCHSCellAddToActDeactLst(cell,ueCb);
798                }
799             }
800          }
801          break;
802       default:
803          break;
804    }
805    RETVOID;
806 }
807
808 #ifdef LTE_ADV
809 /**
810  * @brief Handling of SCell Deactivation Tmr Expiry
811  *
812  * @details
813  *
814  *     Function: rgSCHSCellDeactTmrExpry
815  *     Purpose : Deactivating the SCell. a
816  *               Clear all the Harq Procs associated with this
817  *               scell.
818  *               Trigger Harq Reset to the respective MAC
819  *               Set the state of the cell to Inactive  
820  *              
821  *
822  *     Invoked by: Timer
823  *
824  *  @param[in]  RgSchUeCellInfo *sCellInfo
825  *  @return  Void
826  *
827  **/
828 #ifdef ANSI
829 Void rgSCHSCellDeactTmrExpry
830 (
831 RgSchUeCellInfo *sCellInfo
832 )
833 #else
834 Void rgSCHSCellDeactTmrExpry(sCellInfo)
835 RgSchUeCellInfo *sCellInfo;
836 #endif
837 {
838
839    if (sCellInfo->ue->isScellExplicitDeAct == TRUE)
840    {
841       /* Deactivation Timer is not configured (infinity), thus send deactivation CE explicitly */ 
842       /* No doing Deactivaiton of LAA Cell */
843       if (FALSE == rgSCHLaaSCellEnabled(sCellInfo->cell))
844       {
845          rgSCHSCellTrigActDeact(sCellInfo->ue->cell, sCellInfo->ue, sCellInfo->sCellIdx, RGR_SCELL_DEACT);
846       }
847       else
848       {
849          printf (" !!!!!! Avoiding DEACT for UE %d because of LAA Cell !!!!!!!!!!!!! \n",
850          sCellInfo->ue->ueId);
851       }
852
853    }
854    else
855    {
856       /* Deactivation Timer is configured, thus assume that UE has deactivated */ 
857       rgSCHSCellDeActivation(sCellInfo);
858    }
859    RETVOID;
860 }
861 #endif
862 \f
863 /**
864  * @brief This function handles the action of the SCell
865  *
866  * @details
867  *
868  *     Function: rgSCHSCellTrigActDeact
869  *     Purpose :  
870  *        1) Prepares SCELL ready for activation OR
871  *        2) Initiates activation of SCELL OR
872  *        3) Initiate deactivation of SCELL OR
873  *
874  *     Invoked by:Cfg/Commn Scheduler 
875  *
876  *  @param[in]  RgSchCellCb *cellCb
877  *  @param[in]  RgSchUeCb   *ueCb
878  *  @param[in]  U8           sCellIdx
879  *  @param[in]  U8           action
880  *
881  *  @return  ROK/RFAILED
882  *
883  **/
884 #ifdef ANSI
885 S16 rgSCHSCellTrigActDeact
886 (
887 RgSchCellCb  *cell,
888 RgSchUeCb    *ueCb,
889 U8            sCellIdx,
890 U8            action
891 )
892 #else
893 S16 rgSCHSCellTrigActDeact(cell,ueCb,sCellIdx,action)
894 RgSchCellCb  *cell,
895 RgSchUeCb    *ueCb;
896 U8            sCellIdx;
897 U8            action;
898 #endif
899 {
900    Inst inst = cell->instIdx;
901    S16 ret   = ROK;
902
903    if((sCellIdx < 1) ||
904       (sCellIdx > RGR_MAX_SCELL_PER_UE))
905    {
906       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n", \
907                sCellIdx));
908       return RFAILED;
909    }
910
911    if(ueCb->cellInfo[sCellIdx] == NULLP)
912    {
913       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d ueId %d\n", \
914               sCellIdx,ueCb->ueId));
915       return RFAILED;
916    }
917
918    switch (action)
919    {
920       case RGR_SCELL_READY:
921       {
922          if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_INACTIVE)
923          {
924             RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for preparing SCell Idx %u for UE %u\n", \
925                      ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
926             ret = RFAILED;
927          }
928          else
929          {
930             ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_READY;
931             //TODO_SID Activating the cell directly. Ignoring the ActCe procedure.
932             rgSCHSCellActivation(ueCb->cellInfo[sCellIdx]);
933             /* Setting allocCmnUlPdcch flag to FALSE, So that PDCCH allocation will be done 
934                from UE Searchspace */
935             ueCb->allocCmnUlPdcch = FALSE;
936             printf("\n***** SCellIdx=%d state Changed to %d State \n",sCellIdx, ueCb->cellInfo[sCellIdx]->sCellState);
937             printf("\n***** SCellInfo Addr=%p state Changed to RG_SCH_SCELL_READY\n",(void*)ueCb->cellInfo[sCellIdx]);
938          }
939          break;
940       }
941       case RGR_SCELL_ACT:
942       {
943          if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_READY)
944          {
945             RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for activating SCell Idx %u for UE %u\n", \
946                      ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
947             ret = RFAILED;
948          }
949          else
950          {
951             ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
952             if (NULLP == ueCb->sCellActLnk.node)
953             {
954                /* Add only if UE is not already present in the activation/deactivation list */
955                rgSCHSCellAddToActDeactLst(cell,ueCb);
956             }
957          }
958          break;
959       }
960       case RGR_SCELL_DEACT:
961       {
962          if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_ACTIVE)
963          {
964             RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for deactivating SCell Idx %u for UE %u\n", \
965                      ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
966             ret = RFAILED;
967          }
968          else
969          {
970             ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
971             if (NULLP == ueCb->sCellActLnk.node)
972             {
973                /* Add only if UE is not already present in the activation/deactivation list */
974                rgSCHSCellAddToActDeactLst(cell,ueCb);
975             }
976          }
977          break;
978       }
979       default:
980       {
981          RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid action received for SCell Idx %u for UE %u\n", \
982                   sCellIdx, ueCb->ueId));
983          ret = RFAILED;
984          break;
985       }
986    }
987    return (ret);
988 }
989
990  \f
991 /**
992  * @brief SCell Activation of selected cell
993  *
994  * @details
995  *
996  *     Function: rgSCHSCellSelectForAct
997  *     Purpose :  Perform Selection of secondary cell for activation
998  *
999  *     Invoked by:Cfg/Commn Scheduler 
1000  *
1001  *  @param[in]  RgSchCellCb *cellCb
1002  *  @param[in]  RgSchUeCb   *ueCb
1003  *
1004  *  @return  ROK/RFAILED
1005  *
1006  **/
1007 #ifdef ANSI
1008 PRIVATE S16 rgSCHSCellSelectForAct
1009 (
1010 RgSchCellCb  *cell,
1011 RgSchUeCb    *ueCb,
1012 U8           *sCellIdx
1013 )
1014 #else
1015 PRIVATE S16 rgSCHSCellSelectForAct(cell, ueCb)
1016 RgSchCellCb  *cell;
1017 RgSchUeCb    *ueCb;
1018 U8           *sCellIdx;
1019 #endif
1020 {
1021
1022    for((*sCellIdx) = 1; (*sCellIdx) <= RG_SCH_MAX_SCELL; (*sCellIdx)++)
1023    {
1024       if((ueCb->cellInfo[(*sCellIdx)] != NULLP) &&
1025             (ueCb->cellInfo[(*sCellIdx)]->sCellState == RG_SCH_SCELL_READY))
1026       {
1027          return ROK;
1028       }
1029    }
1030    return RFAILED;
1031 }
1032
1033 /**
1034  * @brief SCell Activation of selected cell
1035  *
1036  * @details
1037  *
1038  *     Function: rgSCHSCellSelectAndActDeAct
1039  *     Purpose :  Perform Selection and Activation/Deactivation of secondary cell
1040  *
1041  *     Invoked by:Cfg/Commn Scheduler 
1042  *
1043  *  @param[in]  RgSchCellCb *cellCb
1044  *  @param[in]  RgSchUeCb   *ueCb
1045  *  @param[in]  U8          action
1046  *
1047  *  @return  Void
1048  *
1049  **/
1050 #ifdef ANSI
1051 Void rgSCHSCellSelectAndActDeAct
1052 (
1053 RgSchCellCb  *pCell,
1054 RgSchUeCb    *ueCb,
1055 U8           action
1056 )
1057 #else
1058 Void rgSCHSCellSelectAndActDeAct(pCell, ueCb, action)
1059 RgSchCellCb  *pCell;
1060 RgSchUeCb    *ueCb;
1061 U8           action;
1062 #endif
1063 {
1064    U8  sCellIdx = 0;
1065    S16 ret = ROK;
1066
1067    switch (action)
1068    {
1069       case RGR_SCELL_ACT:
1070          {
1071
1072             if(((ret = rgSCHSCellSelectForAct(pCell, ueCb, &sCellIdx)) == ROK)
1073                   && (sCellIdx == 0))
1074                RETVOID;
1075             break;
1076          }
1077          default:
1078          RETVOID;
1079    }
1080    if ((ret != ROK) || 
1081          (ROK != (rgSCHSCellTrigActDeact(pCell, ueCb, sCellIdx, action))))
1082    {
1083       RGSCHDBGERR(pCell->instIdx,(rgSchPBuf(pCell->instIdx), "SCell Actication failed"
1084                "for UE [%d] with SCellIdx [%d]\n", ueCb->ueId, sCellIdx));
1085    }
1086    RETVOID;
1087 }
1088
1089  \f
1090 /**
1091  * @brief Handling of Scell Deletion 
1092  *
1093  * @details
1094  *
1095  *     Function: rgSCHSCellDelUeSCell
1096  *     Purpose : Perform Scell Deletion for an UE
1097  *             : flush harqEnttiy of the given scell associated
1098  *               with this UE
1099  *              
1100  *
1101  *     Invoked by:Cfg module 
1102  *
1103  *  @param[in]  RgSchCellCb  *cellCb
1104  *  @param[in]  RgSchUeCb    *ueCb
1105  *  @param[in]  U8            idx
1106  *  @return  ROK/RFAILED
1107  *
1108  **/
1109 #ifdef ANSI
1110 Void rgSCHSCellDelUeSCell
1111 (
1112 RgSchCellCb  *cellCb,
1113 RgSchUeCb    *ueCb,
1114 U8            sCellIdx
1115 )
1116 #else
1117 Void rgSCHSCellDelUeSCell(cellCb,ueCb,sCellIdx)
1118 RgSchCellCb  *cellCb;
1119 RgSchUeCb    *ueCb;
1120 U8            sCellIdx;
1121 #endif
1122 {
1123    RgUeUlHqCb       *ulHqEnt;
1124    Inst inst = cellCb->instIdx;
1125    RgSchUeCellInfo *sCellInfo;
1126    RgSchCmnUlUe *ueUl;
1127
1128    sCellInfo = ueCb->cellInfo[sCellIdx];
1129
1130
1131    if(sCellInfo == NULLP)
1132    {
1133       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d\
1134                ueId %d\n",
1135                sCellIdx,ueCb->ueId));
1136       RETVOID;
1137    }
1138
1139    rgSCHDbmDelUeCb(sCellInfo->cell, ueCb);
1140    ueUl = RG_SCH_CMN_GET_UL_UE(ueCb, sCellInfo->cell);
1141
1142    if (NULLP != sCellInfo->sCellLnk.node)
1143    {
1144       cmLListDelFrm(&sCellInfo->cell->sCellUeLst, &sCellInfo->sCellLnk);
1145    }
1146
1147    /* Clear Scheduler specific list for this UE from the 
1148     * corresponding CELL */
1149
1150    /*Updating 1BCS Value*/
1151    ueCb->f1bCsAVal = (ueCb->f1bCsAVal - 
1152          rgSCHUtlGetMaxTbSupp(sCellInfo->txMode.txModeEnum));
1153
1154 #ifdef LTE_TDD
1155    rgSCHUtlDelUeANFdbkInfo(ueCb,sCellIdx);
1156 #endif
1157
1158    rgSCHSCellDeActivation(sCellInfo);
1159    /* Release hqEnt mem */
1160    rgSCHDhmDelHqEnt(cellCb, &sCellInfo->hqEnt);
1161
1162    ulHqEnt = &(ueUl->hqEnt);
1163
1164    cellCb->sc.apis->rgSCHRgrSCellUeDel(sCellInfo, sCellInfo->ue);
1165
1166    rgSCHUhmFreeUe(sCellInfo->cell, ulHqEnt);
1167
1168    rgSCHUtlFreeSBuf(cellCb->instIdx,
1169          (Data**)(&(sCellInfo)), (sizeof(RgSchUeCellInfo)));
1170
1171    ueCb->cellInfo[sCellIdx] = NULLP;
1172    
1173    RETVOID;
1174 }
1175 \f
1176 /**
1177  * @brief Handling of UE Deletion
1178  *
1179  * @details
1180  *
1181  *     Function: rgSCHSCellDelUe
1182  *     Purpose : Perform UE Deletion
1183  *             : Delete all the SCells added for this UE
1184  *             : flush harqEnttiy of all scells associated
1185  *               with this UE
1186  *              
1187  *
1188  *     Invoked by:Cfg module 
1189  *
1190  *  @param[in]  RgSchCellCb  *cellCb
1191  *  @param[in]  RgSchUeCb    *ueCb
1192  *  @return  ROK/RFAILED
1193  *
1194  **/
1195 #ifdef ANSI
1196 S16 rgSCHSCellDelUe
1197 (
1198 RgSchCellCb  *cellCb,
1199 RgSchUeCb    *ueCb
1200 )
1201 #else
1202 S16 rgSCHSCellDelUe(cellCb,ueCb)
1203 RgSchCellCb  *cellCb;
1204 RgSchUeCb    *ueCb;
1205 #endif
1206 {
1207
1208    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1209    {
1210       rgSCHSCellDelUeSCell(cellCb,ueCb,idx);
1211    }
1212
1213    return ROK;
1214 }
1215
1216 #ifdef TFU_UPGRADE
1217 \f
1218 /**
1219  * @brief Handling of PCqi cfg fro a scell
1220  *
1221  * @details
1222  *
1223  *     Function: rgSCHSCellPCqiCfg
1224  *     Purpose : 
1225  *             : Delete all the SCells added for this UE
1226  *             : flush harqEnttiy of all scells associated
1227  *               with this UE
1228  *    Processing Steps:
1229  *             - For SCell-specific Periodic CQI  related configuration, 
1230  *             - If Periodic CQI/PMI is configured,
1231  *                   - Update SCell with the configured values.
1232  *                   - Update the CQI offset and CQI perodicity information
1233  *        
1234  *
1235  *     - For SCell-specific Periodic RI  related configuration, 
1236  *      - If Periodic RI is configured,
1237  *        - Update SCell with the configured values.
1238  *         - Update the  RI offset and RI perodicity information
1239  *      
1240  *
1241  *     Invoked by:Cfg module 
1242  *
1243  *  @param[in]  RgSchCellCb  *cellCb
1244  *  @param[in]  RgSchUeCb    *ueCb
1245  *  @return  ROK/RFAILED
1246  *
1247  **/
1248 #ifdef ANSI
1249 S16 rgSCHSCellPCqiCfg
1250 (
1251 RgSchCellCb  *priCellCb,
1252 RgSchCellCb  *secCellCb,
1253 RgSchUeCb    *ueCb,
1254 RgrUePrdDlCqiCfg  *cqiCfg,
1255 CmLteUeCategory   ueCat,
1256 U8            sCellIdx
1257 )
1258 #else
1259 S16 rgSCHSCellPCqiCfg(priCellCb,secCellCb,ueCb,cqiCfg,ueCat,sCellIdx)
1260 RgSchCellCb       *priCellCb;
1261 RgSchCellCb       *secCellCb;
1262 RgSchUeCb         *ueCb;
1263 RgrUePrdDlCqiCfg  *cqiCfg;
1264 CmLteUeCategory    ueCat;
1265 U8                sCellIdx;
1266 #endif
1267 {
1268    U8     j;  /*Bandwidth Parts*/
1269    U8     temp; 
1270 #ifdef DEBUGP
1271    Inst   inst = priCellCb->instIdx;
1272 #endif
1273    RgSchUeCellInfo *sCellInfo;
1274    RgSchUePCqiCb *cqiCb = NULLP;
1275
1276    RGSCHDBGINFO(priCellCb->instIdx, (rgSchPBuf(priCellCb->instIdx), 
1277             "rgSCHSCellPCqiCfg cellId =%d, ueId = %d, CfgType =%d\n",
1278             secCellCb->cellId,  ueCb->ueId, cqiCfg->type));
1279    
1280    if((sCellIdx < 1) ||
1281       (sCellIdx > RGR_MAX_SCELL_PER_UE))
1282    {
1283       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n",
1284                sCellIdx));
1285       return RFAILED;
1286    }
1287
1288    sCellInfo = ueCb->cellInfo[sCellIdx];
1289
1290    cqiCb = &ueCb->cellInfo[sCellIdx]->cqiCb;
1291    cqiCb->servCellInfo = sCellInfo;
1292
1293    /* Periodic CQI is setup  */
1294    if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
1295    {   
1296       /*  1. Copy the Received CQI Cfg parameters to ueCb  */
1297       memcpy(&cqiCb->cqiCfg, cqiCfg, 
1298             sizeof(RgrUePrdDlCqiCfg));
1299
1300       /*  2. Compute Periodic CQI Periodicity and subframe offset   */
1301 #ifndef LTE_TDD           
1302       rgSCHUtlGetCfgPerOff(RG_SCH_FDD_PCQI_TBL, cqiCfg->cqiSetup.cqiPCfgIdx,
1303             &cqiCb->cqiPeri, &cqiCb->cqiOffset);      
1304 #else
1305       rgSCHUtlGetCfgPerOff( RG_SCH_TDD_PCQI_TBL, 
1306             cqiCfg->cqiSetup.cqiPCfgIdx,
1307             &cqiCb->cqiPeri, &cqiCb->cqiOffset);    
1308 #endif
1309
1310
1311       RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx), 
1312                "\n rgSCHSCellPCqiCfg(): CQI Peri=%d, CQI Offset=%d", 
1313                cqiCb->cqiPeri,cqiCb->cqiOffset));
1314
1315       if(RGR_UE_PCQI_SB_REP == cqiCfg->cqiSetup.cqiRepType)
1316       {
1317          U8     k;  /*SubBand Size (RB) */
1318          RG_SCH_GET_CQI_J_VAL(secCellCb->bwCfg.dlTotalBw, j);
1319          RG_SCH_GET_CQI_K_VAL(secCellCb->bwCfg.dlTotalBw, k);
1320          cqiCb->J = j; /*Number of Bandwidth Parts*/
1321          /*h: reporting instances required for a complete CQI/PMI report */
1322          /*j:Number of bandwidth parts; k: Subband Size*/
1323          cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1; 
1324          /* ccpu00140905- L-size is coming as 3 for 100Rbs where it should be 2*/
1325          temp = RGSCH_CEIL(secCellCb->bwCfg.dlTotalBw, (j*k));
1326          cqiCb->label = (temp & (temp-1)) ?
1327             (1+ rgSCHUtlLog32bitNbase2(temp)) : rgSCHUtlLog32bitNbase2(temp);
1328       }
1329       else
1330       {
1331          /* Wideband Cqi Rep Type */
1332          cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_1;
1333       }
1334       cqiCb->cqiLstEnt.node=(PTR)cqiCb;
1335       cqiCb->isCqiIgnoByCollsn = FALSE;
1336
1337
1338       /* 4. Rank Indicator Cfg handler */
1339       /* 1. Rank Indicator is enabled  */
1340       if(cqiCfg->cqiSetup.riEna)
1341       {
1342          rgSCHUtlGetCfgPerOff(RG_SCH_RI_TBL, 
1343                cqiCfg->cqiSetup.riCfgIdx,
1344                &cqiCb->riPeri, &cqiCb->riOffset);
1345
1346          RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx),
1347                   "\n rgSCHSCellPCqiCfg(): RI Peri=%d, RI Offset=%d", 
1348                   cqiCb->riPeri,cqiCb->riOffset));
1349
1350          if(ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_3 
1351                || ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_4)
1352          {
1353             if (secCellCb->numTxAntPorts ==2)
1354             {
1355                cqiCb->riNumBits = 1;
1356             }
1357             else if(secCellCb->numTxAntPorts ==4)
1358             {
1359                if(ueCat == CM_LTE_UE_CAT_8)
1360                {
1361                   cqiCb->riNumBits = 3;
1362                }
1363                else if((ueCat == CM_LTE_UE_CAT_5) || 
1364                      (ueCat == CM_LTE_UE_CAT_6) || CM_LTE_UE_CAT_7)
1365                {
1366                   cqiCb->riNumBits = 2;
1367                }
1368                else
1369                {
1370                   cqiCb->riNumBits = 1;
1371                }
1372             }
1373          }
1374          cqiCb->riLstEnt.node=(PTR) cqiCb;
1375          cqiCb->isRiIgnoByCollsn = FALSE;
1376
1377       }
1378    }
1379    else
1380    {
1381       sCellInfo->cqiCb.cqiCfg.type =  RGR_SCH_PCQI_REL;
1382    }
1383    /* Setting the indices to invalid during
1384       scell addition. These indices will be set during 
1385       activation */
1386    cqiCb->nRiTrIdx  = RG_SCH_INVALID_IDX;
1387    cqiCb->riDist    = RG_SCH_INVALID_IDX; 
1388    cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
1389  
1390    return ROK;
1391 }
1392 #endif
1393
1394 /**
1395  * @brief Handling of Ue Reset from common scheduler
1396  *
1397  * @details
1398  *
1399  *     Function: rgSCHSCellDlUeReset
1400  *     Purpose:  Call scheudler type spcefic UE RESET
1401  *               for all the secondary cells
1402  *
1403  *     Invoked by: CommonScheduler
1404  *
1405  *  @param[in]  RgSchCellCb*     cell
1406  *  @param[in]  RgSchUeCb*       ue
1407  *  @return  Void
1408  *
1409  **/
1410 #ifdef ANSI
1411 Void rgSCHSCellDlUeReset
1412 (
1413 RgSchCellCb                *cell,
1414 RgSchUeCb                  *ue
1415 )
1416 #else
1417 Void rgSCHSCellDlUeReset(cell, ue)
1418 RgSchCellCb                *cell;
1419 RgSchUeCb                  *ue;
1420 #endif
1421 {
1422    RgSchCmnCell *cellSch;
1423
1424    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1425    {
1426       if(ue->cellInfo[idx] != NULLP) 
1427       {
1428          cellSch = RG_SCH_CMN_GET_CELL(ue->cellInfo[idx]->cell);
1429          cellSch->apisDl->rgSCHDlUeReset(ue->cellInfo[idx]->cell, ue);
1430          rgSCHSCellDeActivation(ue->cellInfo[idx]);
1431          ue->cellInfo[idx]->sCellState = RG_SCH_SCELL_INACTIVE;
1432       }
1433    }
1434    RETVOID;
1435 }
1436
1437
1438 /**
1439  * @brief Handling of LC Cfg from common scheduler
1440  *
1441  * @details
1442  *
1443  *     Function: rgSCHSCellDlLcCfg
1444  *     Purpose:  Call scheudler type spcefic LC config
1445  *               for all the secondary cells
1446  *
1447  *     Invoked by: CommonScheduler
1448  *
1449  *  @param[in]  RgSchCellCb*     cell
1450  *  @param[in]  RgSchUeCb*       ue
1451  *  @return  Void
1452  *
1453  **/
1454 #ifdef ANSI
1455 Void rgSCHSCellDlLcCfg
1456 (
1457 RgSchCellCb                *cell,
1458 RgSchUeCb                  *ue,
1459 RgSchDlLcCb                *svc
1460 )
1461 #else
1462 Void rgSCHSCellDlLcCfg(cell, ue, svc)
1463 RgSchCellCb                *cell;
1464 RgSchUeCb                  *ue;
1465 RgSchDlLcCb                *svc;
1466 #endif
1467 {
1468    RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1469    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1470    {
1471       if(ue->cellInfo[idx] != NULLP) 
1472       {
1473          cellSch->apisDl->rgSCHRgrDlLcCfg(ue->cellInfo[idx]->cell, ue, svc,NULLP,NULLP);
1474       }
1475    }
1476    RETVOID;
1477 }
1478
1479 /**
1480  * @brief Handling of LC Delete from common scheduler
1481  *
1482  * @details
1483  *
1484  *     Function: rgSCHSCellDlLcDel
1485  *     Purpose:  Call scheudler type spcefic bo update handler
1486  *               for all the secondary cells
1487  *
1488  *     Invoked by: CommonScheduler
1489  *
1490  *  @param[in]  RgSchCellCb*     cell
1491  *  @param[in]  RgSchUeCb*       ue
1492  *  @return  Void
1493  *
1494  **/
1495 #ifdef ANSI
1496 Void rgSCHSCellDlLcDel
1497 (
1498 RgSchCellCb                *cell,
1499 RgSchUeCb                  *ue,
1500 RgSchDlLcCb                *svc
1501 )
1502 #else
1503 Void rgSCHSCellDlLcDel(cell, ue, svc)
1504 RgSchCellCb                *cell;
1505 RgSchUeCb                  *ue;
1506 RgSchDlLcCb                *svc;
1507 #endif
1508 {
1509    RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1510    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1511    {
1512       if(ue->cellInfo[idx] != NULLP) 
1513       {
1514          cellSch->apisDl->rgSCHFreeDlLc(ue->cellInfo[idx]->cell, ue, svc);
1515       }
1516    }
1517    RETVOID;
1518 }
1519
1520 /**
1521  * @brief Handling of Bo update from common scheduler
1522  *
1523  * @details
1524  *
1525  *     Function: rgSCHSCellDlDedBoUpd
1526  *     Purpose:  Call scheudler type spcefic bo update handler
1527  *               for all the secondary cells
1528  *
1529  *     Invoked by: CommonScheduler
1530  *
1531  *  @param[in]  RgSchCellCb*     cell
1532  *  @param[in]  RgSchUeCb*       ue
1533  *  @return  Void
1534  *
1535  **/
1536 #ifdef ANSI
1537 Void rgSCHSCellDlDedBoUpd
1538 (
1539 RgSchCellCb                *cell,
1540 RgSchUeCb                  *ue,
1541 RgSchDlLcCb                *svc
1542 )
1543 #else
1544 Void rgSCHSCellDlDedBoUpd(cell, ue, svc)
1545 RgSchCellCb                *cell;
1546 RgSchUeCb                  *ue;
1547 RgSchDlLcCb                *svc;
1548 #endif
1549 {
1550    RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1551
1552    /* If this is not invoked by PCell, then
1553       invoke the call to PCell handler 
1554       This happens during finalization if LC Bo becomes zero*/
1555    if (ue->cell != cell)
1556    {
1557       cellSch->apisDl->rgSCHDlDedBoUpd(ue->cell, ue, svc);
1558    }
1559    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1560    {
1561       if((ue->cellInfo[idx] != NULLP) &&
1562             (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE) &&
1563            (ue->cellInfo[idx]->cell != cell))
1564       {
1565          cellSch->apisDl->rgSCHDlDedBoUpd(ue->cellInfo[idx]->cell, ue, svc);
1566       }
1567    }
1568    RETVOID;
1569 }
1570 #ifdef TFU_UPGRADE
1571 /**
1572  * @brief Compare two CQI CB configs are return the result
1573  *
1574  * @details
1575  *
1576  *     Function: rgSCHUtlSCellCmpCqiCfg
1577  *     Purpose : Compare priority levels of cqiCb1 and cqiCb2
1578  *               and set the isCqiIgnoByCollsn to TRUE for the 
1579  *               cqiCb which has lower priority 
1580  *     Invoked by:scell module 
1581  *
1582  *  @param[in] RgSchUePCqiCb *cqiCb1
1583  *  @param[in] RgSchUePCqiCb *cqiCb2
1584  *  @return U8 cqiCb cell idx which has the higher priority
1585  *
1586  **/
1587 #ifdef ANSI
1588 PRIVATE U8  rgSCHUtlSCellCmpCqiCfg
1589 (
1590 RgSchUePCqiCb *cqiCb1,
1591 RgSchUePCqiCb *cqiCb2
1592 )
1593 #else
1594 PRIVATE U8  rgSCHUtlSCellCmpCqiCfg(cqiCb1, cqiCb2)
1595 RgSchUePCqiCb     *cqiCb1;
1596 RgSchUePCqiCb     *cqiCb2;
1597 #endif
1598 {
1599    RgSchUePCqiCb     *retCqiCb;
1600    /* Collision rules are defined in TS 36.213,7.2.2 */
1601    /* RI, WB first PMI > WB CQI >  SB CQI */
1602    /* As of now only taking care of RI > WB CQI > SB CQI */
1603
1604    if (cqiCb1->prioLvl > cqiCb2->prioLvl)
1605    {
1606       cqiCb2->isCqiIgnoByCollsn = TRUE;
1607       cqiCb1->isCqiIgnoByCollsn = FALSE;
1608       retCqiCb = cqiCb1;
1609    }
1610    else if (cqiCb2->prioLvl > cqiCb1->prioLvl)
1611    {
1612       cqiCb1->isCqiIgnoByCollsn = TRUE;
1613       cqiCb2->isCqiIgnoByCollsn = FALSE;
1614       retCqiCb = cqiCb2;
1615    }
1616    else
1617    {
1618       if (cqiCb1->servCellInfo->sCellIdx > cqiCb2->servCellInfo->sCellIdx)
1619       {
1620          cqiCb1->isCqiIgnoByCollsn = TRUE;
1621          cqiCb2->isCqiIgnoByCollsn = FALSE;
1622          retCqiCb = cqiCb2;
1623       }
1624       else
1625       {
1626          cqiCb2->isCqiIgnoByCollsn = TRUE;
1627          cqiCb1->isCqiIgnoByCollsn = FALSE;
1628          retCqiCb = cqiCb1;
1629       }
1630    }
1631
1632    return (retCqiCb->servCellInfo->sCellIdx);
1633 }
1634
1635 /**
1636  * @brief Handling of collision of CQI types between serving cells
1637  *
1638  * @details
1639  *
1640  *     Function: rgSCHUtlSCellHndlCqiCollsn
1641  *     Purpose : Takes care of collision clauses specified in 36.213 7.2.2 Rel 10 
1642  *               and selects next nearest cqiCb 
1643  *     Invoked by:Cfg module 
1644  *
1645  *  @param[in]  RgSchCellCb  *cellCb
1646  *  @param[in]  RgSchUeCb    *ueCb
1647  *  @return  ROK/RFAILED
1648  *
1649  **/
1650 #ifdef ANSI
1651 S16 rgSCHUtlSCellHndlCqiCollsn
1652 (
1653 RgSchUePCqiCb *cqiCb
1654 )
1655 #else
1656 S16 rgSCHUtlSCellHndlCqiCollsn(cqiCb)
1657 RgSchUePCqiCb     *cqiCb;
1658 #endif
1659 {
1660    U32 nPCqiServCellIdx;
1661    U32 minPCqiTrIdx;
1662    U32 scellPCqiTrIdx;
1663    U32 pCqiTrIdx;
1664    RgSchCellCb       *priCellCb = cqiCb->servCellInfo->ue->cell;
1665    RgSchUeCb         *ueCb = cqiCb->servCellInfo->ue;
1666    U16 crntSfIdx;
1667    U32 cellIdx;
1668    U32 sCellCnt = 0;
1669    CmLteTimingInfo timingInfo;
1670    U8 idx = 0;
1671
1672 #ifdef xLTE_TDD
1673    RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1674 #else
1675    RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1676          TFU_RECPREQ_DLDELTA);
1677 #endif
1678
1679    RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1680
1681    cqiCb->isCqiIgnoByCollsn = FALSE;
1682
1683    pCqiTrIdx = cqiCb->nCqiTrIdx;
1684    nPCqiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1685    /* Handle wrap around case */
1686    if (pCqiTrIdx < crntSfIdx)
1687    {
1688       pCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1689    }
1690    minPCqiTrIdx = pCqiTrIdx;
1691
1692    for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1693    {
1694       /* If a serving cell is configured */
1695       if(ueCb->cellInfo[cellIdx] != NULLP)
1696       {
1697          /* If the serving cell is in ACTIVE state and 
1698             If it is not the same serving cell as cqiCb for which 
1699             collision is being checked */
1700          if ((ueCb->cellInfo[cellIdx]->sCellState == RG_SCH_SCELL_ACTIVE)&&
1701                (cellIdx != cqiCb->servCellInfo->sCellIdx))
1702          {
1703             scellPCqiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nCqiTrIdx;
1704
1705             /* Handle wrap around case */
1706             if (scellPCqiTrIdx < crntSfIdx)
1707             {
1708                scellPCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1709             }
1710             
1711             /* If cqiCb->isCqiIgnoByCollsn is TRUE then a higher prio cqiCb
1712                is already found so need to compare */
1713             if ((FALSE == ueCb->cellInfo[cellIdx]->cqiCb.isCqiIgnoByCollsn) &&
1714                   (FALSE == cqiCb->isCqiIgnoByCollsn) && 
1715                   (scellPCqiTrIdx == pCqiTrIdx))
1716             {
1717                /* Handle Collision */
1718                /* set isCqiIgnoByCollsn to TRUE for low prio CQI Rep type */
1719                nPCqiServCellIdx = rgSCHUtlSCellCmpCqiCfg(&ueCb->cellInfo[cellIdx]->cqiCb,cqiCb);
1720             }
1721             else if (scellPCqiTrIdx < minPCqiTrIdx)
1722             {
1723                minPCqiTrIdx = scellPCqiTrIdx;
1724                nPCqiServCellIdx = cellIdx;
1725             }
1726          }
1727
1728          /* If all of the num of configured scells are checked then break */
1729          if (sCellCnt == ueCb->numSCells)
1730          {
1731             break;
1732          }   
1733          sCellCnt++;
1734       }
1735    }
1736
1737    /* Set the next expected Cqi into nPCqiCb */
1738    idx = ((nPCqiServCellIdx)& (CM_LTE_MAX_CELLS -1));
1739    ueCb->nPCqiCb = &ueCb->cellInfo[idx]->cqiCb;
1740
1741    return ROK;
1742 }
1743
1744
1745 /**
1746  * @brief Handling of collision of RI types between serving cells
1747  *
1748  * @details
1749  *
1750  *     Function: rgSCHUtlSCellHndlRiCollsn
1751  *     Purpose : Takes care of collision clauses specified in 36.213 7.2.2 Rel 10 
1752  *               and selects next nearest cqiCb 
1753  *     Invoked by:Cfg module 
1754  *
1755  *  @param[in]  RgSchCellCb  *cellCb
1756  *  @param[in]  RgSchUeCb    *ueCb
1757  *  @return  ROK/RFAILED
1758  *
1759  **/
1760 #ifdef ANSI
1761 S16 rgSCHUtlSCellHndlRiCollsn
1762 (
1763 RgSchUePCqiCb *cqiCb
1764 )
1765 #else
1766 S16 rgSCHUtlSCellHndlRiCollsn(cqiCb)
1767 RgSchUePCqiCb     *cqiCb;
1768 #endif
1769 {
1770    U32 nPRiServCellIdx;
1771    U32 minPRiTrIdx;
1772    U32 scellPRiTrIdx;
1773    U32 pRiTrIdx;
1774    RgSchCellCb       *priCellCb = cqiCb->servCellInfo->ue->cell;
1775    RgSchUeCb         *ueCb = cqiCb->servCellInfo->ue;
1776    U16 crntSfIdx;
1777    U32 cellIdx;
1778    U32 sCellCnt = 0;
1779    CmLteTimingInfo timingInfo;
1780
1781 #ifdef xLTE_TDD
1782    RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1783 #else
1784    RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1785          TFU_RECPREQ_DLDELTA);
1786 #endif
1787
1788    RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1789
1790    pRiTrIdx = cqiCb->nRiTrIdx + cqiCb->riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1791
1792    /* Handle wrap around case */
1793    if (pRiTrIdx < crntSfIdx)
1794    {
1795       pRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1796    }
1797
1798    cqiCb->isRiIgnoByCollsn = FALSE;
1799    nPRiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1800    minPRiTrIdx = pRiTrIdx;
1801
1802    for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1803    {
1804       /* If a serving cell is configured */
1805       if(ueCb->cellInfo[cellIdx] != NULLP)
1806       {
1807          /* If the serving cell is in ACTIVE state and 
1808             If it is not the same serving cell as cqiCb for which 
1809             collision is being checked */
1810          if ((ueCb->cellInfo[cellIdx]->sCellState == RG_SCH_SCELL_ACTIVE)&&
1811                (cellIdx != cqiCb->servCellInfo->sCellIdx))
1812          {
1813             scellPRiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nRiTrIdx + 
1814                ueCb->cellInfo[cellIdx]->cqiCb.riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1815
1816             /* Handle wrap around case */
1817             if (scellPRiTrIdx < crntSfIdx)
1818             {
1819                scellPRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1820             }
1821             
1822             /* If cqiCb->isRiIgnoByCollsn is TRUE then a higher prio cqiCb
1823                is already found so need to compare */
1824             if ((FALSE == ueCb->cellInfo[cellIdx]->cqiCb.isRiIgnoByCollsn) &&
1825                   (FALSE == cqiCb->isRiIgnoByCollsn) && 
1826                   (scellPRiTrIdx == pRiTrIdx))
1827             {
1828                /* Handle Collision */
1829                /* set isRiIgnoByCollsn to TRUE for low prio CQI Rep type */
1830                if (cqiCb->servCellInfo->sCellIdx < (ueCb->cellInfo[cellIdx]->sCellIdx))
1831                {
1832                   ueCb->cellInfo[cellIdx]->cqiCb.isRiIgnoByCollsn = TRUE;
1833                }
1834                else
1835                {
1836                   cqiCb->isRiIgnoByCollsn = TRUE;
1837                }
1838             }
1839             else if (scellPRiTrIdx < minPRiTrIdx)
1840             {
1841                minPRiTrIdx = scellPRiTrIdx;
1842                nPRiServCellIdx = cellIdx;
1843             }
1844          }
1845
1846          /* If all of the num of configured scells are checked then break */
1847          if (sCellCnt == ueCb->numSCells)
1848          {
1849             break;
1850          }   
1851          sCellCnt++;
1852       }
1853    }
1854
1855    /* Set the next expected Cqi into nPCqiCb */
1856    ueCb->nPRiCb = &ueCb->cellInfo[nPRiServCellIdx]->cqiCb;
1857
1858    return ROK;
1859 }
1860 #endif/*TFU_UPGRADE*/
1861
1862 /**
1863  * @brief Checking whethter the scell is active or not
1864  *
1865  * @details
1866  *
1867  *     Function: rgSCHSCellIsActive
1868  *     Purpose: Check the Scell is in active state or not 
1869  *              
1870  *
1871  *     Invoked by: SpecificScheduler
1872  *
1873  *  @param[in]  RgSchCellCb*     cell
1874  *  @param[in]  RgSchUeCb*       ue
1875  *  @return  Void
1876  *
1877  **/
1878 #ifdef ANSI
1879 S16 rgSCHSCellIsActive
1880 (
1881 RgSchCellCb                *cell,
1882 RgSchUeCb                  *ue
1883 )
1884 #else
1885 S16 rgSCHSCellIsActive(cell, ue)
1886 RgSchCellCb                *cell;
1887 RgSchUeCb                  *ue;
1888 #endif
1889 {
1890    S16 retVal = RFAILED;
1891
1892    for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1893    {
1894       if((ue->cellInfo[idx] != NULLP) &&
1895          (ue->cellInfo[idx]->cell->cellId == cell->cellId)&&
1896          (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE)) 
1897       {
1898          retVal = ROK;
1899          break;
1900       }
1901    }
1902    return (retVal);     
1903 }
1904
1905 /**
1906  * @brief Function to check for Acell Activation Trigered.
1907  *
1908  * @details
1909  *
1910  *     Function : rgSCHIsActvReqd
1911  *       This function will check for Secondary cell activation criteria
1912  *       If met this will return TRUE else FALSE
1913  *     
1914  *  @param[in]     RgSchCellCb    *cell
1915  *  @param[in]     RgSchUeCb      *ue
1916  *  @return  BOOL
1917  *      -#  TRUE
1918  **/
1919 #ifdef ANSI
1920 Bool rgSCHIsActvReqd 
1921 (
1922 RgSchCellCb    *cell,
1923 RgSchUeCb      *ue
1924 )
1925 #else
1926 Bool rgSCHIsActvReqd(cell, ue)
1927 RgSchCellCb    *cell;
1928 RgSchUeCb      *ue
1929 #endif
1930 {
1931    /* Check if remBoCnt in this UE is greater than ZERO for sufficient number of
1932     * Scheduling TTIs. If yes then We should activate a secondary cell to handle
1933     * outstanding BO */
1934    if(ue->remBoCnt == RG_SCH_ACTIVATION_COUNT)
1935    {
1936       return (TRUE);
1937    }
1938    return (FALSE);
1939 }
1940 #endif/*LTE_ADV*/
1941
1942
1943
1944 /**********************************************************************
1945
1946          End of file
1947 **********************************************************************/