1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Round Robin functions
29 **********************************************************************/
32 @brief This module handles the round robin scheduler functionality
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
42 #include "rg_sch_inf.h"
43 #include "rg_sch_err.h"
45 #include "rg_sch_cmn.h"
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"
58 Void rgSCHSCellActivation ARGS((
59 RgSchUeCellInfo *sCell
62 Void rgSCHSCellSchdActDeactCe ARGS((
66 Void rgSCHSCellAddToActDeactLst ARGS((
71 Void rgSCHSCellRmvFrmActLst ARGS((
75 S16 rgSCHSCellIsActive ARGS((
80 Void rgSCHSCellHndlFdbkInd ARGS((
88 Void rgSCHSCellDeactTmrExpry ARGS((
89 RgSchUeCellInfo *sCell
93 Void rgSCHSCellDelUeSCell ARGS((
99 S16 rgSCHSCellDelUe ARGS((
104 S16 rgSCHSCellPCqiCfg ARGS((
105 RgSchCellCb *priCellCb,
106 RgSchCellCb *secCellCb,
108 RgrUePrdDlCqiCfg *cqiCfg,
109 CmLteUeCategory ueCat,
113 PRIVATE S16 rgSCHSCellTrgMacHqEReset ARGS((
121 /** * @brief Handler for scheduling Scell Activation CE.
125 * Function : rgSCHDhmShcdSCellActCe
127 * This function is called by scheduler when resource allocation
128 * for SCell Activation CE transmission is done.
130 * @param[in] RgSchUeCb *ue
131 * @param[out] RgSchDlHqTbCb *tbInfo
136 Void rgSCHSCellSchdActDeactCe
139 RgSchDlHqTbCb *tbInfo
142 Void rgSCHSCellSchdActDeactCe(ueCb, tbInfo)
144 RgSchDlHqTbCb *tbInfo;
149 U8 sCellActDeactBitMask = 0;
151 /* Change the state of all Scells waiting for
154 /* -------------------------
155 * | C7|C6|C5|C4|C3|C2|C1|R|
156 * -------------------------*/
161 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
163 if(ueCb->cellInfo[idx] != NULLP)
165 switch(ueCb->cellInfo[idx]->sCellState)
167 case RG_SCH_SCELL_TOBE_ACTIVATED:
168 case RG_SCH_SCELL_ACTVTN_IN_PROG:
170 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_ACTVTN_IN_PROG;
174 case RG_SCH_SCELL_ACTIVE:
179 case RG_SCH_SCELL_TOBE_DEACTIVATED:
180 case RG_SCH_SCELL_DEACTVTN_IN_PROG:
182 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_DEACTVTN_IN_PROG;
186 case RG_SCH_SCELL_INACTIVE:
187 case RG_SCH_SCELL_READY:
196 sCellActDeactBitMask |= 1 << (idx);/* servCellIdx = idx + 1 */
200 tbInfo->schdSCellActCe.pres = PRSNT_NODEF;
201 tbInfo->schdSCellActCe.val = sCellActDeactBitMask;
204 } /* rgSCHSCellSchdActDeactCe */
208 * @brief Adds an UE to the Cell's SCell Activation list
212 * Function: rgSCHSCellAddToActDeactLst
213 * Purpose: Adds an UE to Cell's SCEll Act list
215 * Invoked by: Common Scheduler
217 * @param[in] RgSchCellCb* cell
218 * @param[in] RgSchUeCb* ue
223 Void rgSCHSCellAddToActDeactLst
229 Void rgSCHSCellAddToActDeactLst(cell, ue)
234 RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
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;
243 RGSCHDBGINFONEW(cell->instIdx,(rgSchPBuf(cell->instIdx),
244 "SCell is already added in the Act List: ueId(%u)\n", ue->ueId));
252 * @brief Removes an UE from Cell's SCell Activation list
256 * Function: rgSCHSCellRmvFrmActLst
257 * Purpose: Removes an UE from Cell's SCEll Act list
259 * Invoked by: Specific Scheduler
261 * @param[in] RgSchCellCb* cell
262 * @param[in] RgSchUeCb* ue
267 Void rgSCHSCellRmvFrmActLst
273 Void rgSCHSCellRmvFrmActLst(cell, ue)
278 RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
279 if (NULLP != ue->sCellActLnk.node)
281 cmLListDelFrm(&cellCmnDl->secCellActCeLst, &ue->sCellActLnk);
283 ue->sCellActLnk.node = (PTR)NULLP;
289 * @brief Handling of SCell Activation
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
298 * Invoked by:Cfg/Commn Scheduler
300 * @param[in] RgSchUeCellInfo *sCellInfo
302 * @return ROK/RFAILED
306 Void rgSCHSCellActivation
308 RgSchUeCellInfo *sCellInfo
311 Void rgSCHSCellActivation(sCellInfo)
312 RgSchUeCellInfo *sCellInfo
315 RgSchCellCb *sCell = sCellInfo->cell;
316 RgSchUeCb *ueCb = sCellInfo->ue;
317 RgSchCmnCell *cellSch;
320 Inst inst = ueCb->cell->instIdx;
323 RgrUePrdDlCqiCfg *cqiCfg;
324 U8 j; /*Bandwidth Parts*/
328 RgSchUePCqiCb *cqiCb = NULLP;
329 CmLteTimingInfo timingInfo;
334 sCellInfo->sCellState = RG_SCH_SCELL_ACTIVE;
336 ueCb->tenbStats->stats.persistent.numActivation++;
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);
342 /* Start the sCellDeactivation timer if cfgd */
343 if(PRSNT_NODEF == ueCb->sCellDeactTmrVal.pres)
345 //rgSCHTmrStartTmr (sCell,sCellInfo ,RG_SCH_TMR_SCELL_DEACT,
346 // ueCb->sCellDeactTmrVal.val);
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);
354 cqiCb = &sCellInfo->cqiCb;
355 cqiCfg = &cqiCb->cqiCfg;
356 if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
358 cqiTrInstTime = ((cqiCb->cqiPeri+crntTime) - cqiCb->cqiOffset)
360 cqiCb->nCqiTrIdx = (crntTime +
361 (cqiCb->cqiPeri - cqiTrInstTime));
362 /* Introduced timing delta for reception req
364 if(cqiCb->nCqiTrIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
366 cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx + cqiCb->cqiPeri;
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)
373 rgSCHTomUtlPcqiSbCalcBpIdx(timingInfo,ueCb,cqiCb);
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));
382 cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
385 rgSCHUtlSCellHndlCqiCollsn(cqiCb);
387 RGSCHDBGINFO(inst,(rgSchPBuf(inst),
388 "\n rgSCHCfgPCqiUeCfg():"
389 " CrntTime=%d Next CqiTrInstTime=%d Index Stored at=%d ",
390 crntTime, cqiTrInstTime, cqiCb->nCqiTrIdx));
392 if(cqiCfg->cqiSetup.riEna)
395 cqiCb->invalidateCqi = FALSE;
397 if(RGR_UE_PCQI_WB_REP == cqiCfg->cqiSetup.cqiRepType)
400 1. wideband RI reporting is configured
402 (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )Mod(NCqiperiod
405 periodicity = cqiCb->cqiPeri * cqiCb->riPeri;
410 * Where Widesband and Subband RI reporting is configured
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
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 *
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)
430 periodicity = cqiCb->cqiOffset - cqiCb->riOffset +
431 RGSCH_MAX_SUBFRM_5G - (crntTime);
432 tempIdx = crntTime + periodicity;
436 riTrInsTime = ((periodicity +crntTime )- \
437 cqiCb->cqiOffset + cqiCb->riOffset)\
439 tempIdx = (crntTime + (periodicity -riTrInsTime));
441 if (tempIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
443 tempIdx = tempIdx + periodicity;
445 cqiCb->nRiTrIdx = tempIdx
446 % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
447 if(periodicity >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
449 cqiCb->riDist = rgSCHUtlFindDist((U16)(crntTime + TFU_RECPREQ_DLDELTA),
458 /* Start receiving RI for this SCell for this UE */
459 cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst,
461 RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_ADD,
462 &ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
464 rgSCHUtlSCellHndlRiCollsn(cqiCb);
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));
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));
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));
490 cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
491 cellSch->apisDl->rgSCHDlSCellActv(sCellInfo->cell, sCellInfo->ue);
499 * @brief Remove CQI from Scell Lst
503 * Function: rgSCHCellClearScellLstOfCQI
504 * Purpose : Remove CQI from Scell Lst
509 * @param[in] RgSchUeCellInfo *sCellInfo
514 PRIVATE Void rgSCHCellClearScellLstOfCQI
516 RgSchUeCellInfo *sCellInfo
519 PRIVATE Void rgSCHCellClearScellLstOfCQI(sCellInfo)
520 RgSchUeCellInfo *sCellInfo;
524 RgSchUePCqiCb *cqiRiCb = NULLP;
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)
532 cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nCqiTrIdx].cqiLst,
533 &cqiRiCb->cqiLstEnt);
534 cqiRiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
536 if (ueCb->nPCqiCb == cqiRiCb)
538 rgSCHUtlSCellHndlCqiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
540 /* Delete Periodic RI Transmission Instance */
542 if (cqiRiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
544 cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst,
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)
551 rgSCHUtlSCellHndlRiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
558 #endif/*TFU_UPGRADE*/
561 * @brief Handling of SCell DeActivation
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
573 * Invoked by:Cfg/Commn Scheduler
575 * @param[in] RgSchUeCellInfo *sCellInfo
577 * @return ROK/RFAILED
581 PRIVATE S16 rgSCHSCellDeActivation
583 RgSchUeCellInfo *sCellInfo
586 PRIVATE S16 rgSCHSCellDeActivation(sCellInfo)
587 RgSchUeCellInfo *sCellInfo
591 RgSchCmnCell *cellSch;
592 Inst inst = sCellInfo->cell->instIdx;
594 /* Stop the timer if running */
596 if(sCellInfo->deactTmr.tmrEvnt != TMR_NONE)
598 rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_DEACT, sCellInfo);
601 if (sCellInfo->actDelayTmr.tmrEvnt != TMR_NONE)
603 rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_ACT_DELAY, sCellInfo);
606 cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
607 cellSch->apisDl->rgSCHDlUeReset(sCellInfo->cell, sCellInfo->ue);
609 if(sCellInfo->ue->isDrxEnabled)
611 rgSCHDrxUeHqReset(sCellInfo->ue->cell, sCellInfo->ue,
612 sCellInfo->hqEnt, sCellInfo->sCellIdx);
615 /* Flush the harqEntity at scheduler */
616 if(sCellInfo->hqEnt != NULLP)
618 rgSCHDhmHqEntReset(sCellInfo->hqEnt);
620 /* Trigger harq flush req to MAC */
623 rgSCHSCellTrgMacHqEReset(inst,sCellInfo->sCellId,sCellInfo->ue->ueId);
625 sCellInfo->sCellState = RG_SCH_SCELL_READY;
627 rgSCHCellClearScellLstOfCQI(sCellInfo);
631 sCellInfo->ue->tenbStats->stats.persistent.numDeactivation++;
634 cellSch->apisDl->rgSCHDlSCellDeactv(sCellInfo->cell, sCellInfo->ue);
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);
645 * @brief Triggering hqEntity reset to mac
649 * Function: rgSCHSCellTrgMacHqEReset
650 * Purpose: Frame the interface for mac to reset
652 * Derive the macInstance corresponding
653 * to the secondary cell going to be deactivated.
654 * Triiger the msg to that macInstance
656 * Invoked by: CommonScheduler
658 * @param[in] U16 sCellId
659 * @param[in] U16 rnti
664 PRIVATE S16 rgSCHSCellTrgMacHqEReset
671 PRIVATE S16 rgSCHSCellTrgMacHqEReset(inst,secCellId,rnti)
678 RgSchCellCb *secCellCb = NULLP;
679 RgInfResetHqEnt hqEntRstInfo;
681 if((secCellCb = (RgSchCellCb *)rgSchUtlGetCellCb(inst, secCellId)) == NULLP)
683 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst), "SCell doesnt exists"));
687 hqEntRstInfo.cellId = secCellId;
688 hqEntRstInfo.crnti = rnti;
690 rgSCHUtlGetPstToLyr(&pst, &rgSchCb[inst], secCellCb->macInst);
692 RgSchMacRstHqEnt(&pst, &hqEntRstInfo);
701 * @brief Handling of harq feeback for SCell act CE txion
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
709 * HQ FAILURE/DTX/NACK:: Perform retxion. Add to Act CE list
710 * Set the state to TOBE_SCHEDULED
713 * Invoked by: CommonScheduler
715 * @param[in] RgSchCellCb* cell
716 * @param[in] RgSchUeCb* ue
721 Void rgSCHSCellHndlFdbkInd
723 RgSchDlHqProcCb *hqP,
726 Bool maxHqRetxReached
729 Void rgSCHSCellHndlFdbkInd(hqP, tbIdx, fdbk,maxHqRetxReached)
730 RgSchDlHqProcCb *hqP;
733 Bool maxHqRetxReached;
739 RgSchUeCellInfo *sCellInfo;
748 hqP->tbInfo[tbIdx].schdSCellActCe.pres = FALSE;
750 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
752 if(ueCb->cellInfo[idx] != NULLP)
754 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
757 printf("\n starting delay timer...\n");
759 rgSCHTmrStartTmr (cell,ueCb->cellInfo[idx] ,RG_SCH_TMR_SCELL_ACT_DELAY,
760 RG_SCH_CMN_SCELL_ACT_DELAY_TMR);
764 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
766 sCellInfo = ueCb->cellInfo[idx];
767 rgSCHSCellDeActivation(sCellInfo);
777 if(TRUE == maxHqRetxReached)
779 hqP->tbInfo[tbIdx].schdSCellActCe.pres = FALSE;
780 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
782 if(ueCb->cellInfo[idx] != NULLP)
784 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
786 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
790 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
792 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
796 /* Add to actDeactCe lst */
797 rgSCHSCellAddToActDeactLst(cell,ueCb);
810 * @brief Handling of SCell Deactivation Tmr Expiry
814 * Function: rgSCHSCellDeactTmrExpry
815 * Purpose : Deactivating the SCell. a
816 * Clear all the Harq Procs associated with this
818 * Trigger Harq Reset to the respective MAC
819 * Set the state of the cell to Inactive
824 * @param[in] RgSchUeCellInfo *sCellInfo
829 Void rgSCHSCellDeactTmrExpry
831 RgSchUeCellInfo *sCellInfo
834 Void rgSCHSCellDeactTmrExpry(sCellInfo)
835 RgSchUeCellInfo *sCellInfo;
839 if (sCellInfo->ue->isScellExplicitDeAct == TRUE)
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))
845 rgSCHSCellTrigActDeact(sCellInfo->ue->cell, sCellInfo->ue, sCellInfo->sCellIdx, RGR_SCELL_DEACT);
849 printf (" !!!!!! Avoiding DEACT for UE %d because of LAA Cell !!!!!!!!!!!!! \n",
850 sCellInfo->ue->ueId);
856 /* Deactivation Timer is configured, thus assume that UE has deactivated */
857 rgSCHSCellDeActivation(sCellInfo);
864 * @brief This function handles the action of the SCell
868 * Function: rgSCHSCellTrigActDeact
870 * 1) Prepares SCELL ready for activation OR
871 * 2) Initiates activation of SCELL OR
872 * 3) Initiate deactivation of SCELL OR
874 * Invoked by:Cfg/Commn Scheduler
876 * @param[in] RgSchCellCb *cellCb
877 * @param[in] RgSchUeCb *ueCb
878 * @param[in] U8 sCellIdx
879 * @param[in] U8 action
881 * @return ROK/RFAILED
885 S16 rgSCHSCellTrigActDeact
893 S16 rgSCHSCellTrigActDeact(cell,ueCb,sCellIdx,action)
900 Inst inst = cell->instIdx;
904 (sCellIdx > RGR_MAX_SCELL_PER_UE))
906 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n", \
911 if(ueCb->cellInfo[sCellIdx] == NULLP)
913 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d ueId %d\n", \
914 sCellIdx,ueCb->ueId));
920 case RGR_SCELL_READY:
922 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_INACTIVE)
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));
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]);
943 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_READY)
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));
951 ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
952 if (NULLP == ueCb->sCellActLnk.node)
954 /* Add only if UE is not already present in the activation/deactivation list */
955 rgSCHSCellAddToActDeactLst(cell,ueCb);
960 case RGR_SCELL_DEACT:
962 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_ACTIVE)
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));
970 ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
971 if (NULLP == ueCb->sCellActLnk.node)
973 /* Add only if UE is not already present in the activation/deactivation list */
974 rgSCHSCellAddToActDeactLst(cell,ueCb);
981 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid action received for SCell Idx %u for UE %u\n", \
982 sCellIdx, ueCb->ueId));
992 * @brief SCell Activation of selected cell
996 * Function: rgSCHSCellSelectForAct
997 * Purpose : Perform Selection of secondary cell for activation
999 * Invoked by:Cfg/Commn Scheduler
1001 * @param[in] RgSchCellCb *cellCb
1002 * @param[in] RgSchUeCb *ueCb
1004 * @return ROK/RFAILED
1008 PRIVATE S16 rgSCHSCellSelectForAct
1015 PRIVATE S16 rgSCHSCellSelectForAct(cell, ueCb)
1022 for((*sCellIdx) = 1; (*sCellIdx) <= RG_SCH_MAX_SCELL; (*sCellIdx)++)
1024 if((ueCb->cellInfo[(*sCellIdx)] != NULLP) &&
1025 (ueCb->cellInfo[(*sCellIdx)]->sCellState == RG_SCH_SCELL_READY))
1034 * @brief SCell Activation of selected cell
1038 * Function: rgSCHSCellSelectAndActDeAct
1039 * Purpose : Perform Selection and Activation/Deactivation of secondary cell
1041 * Invoked by:Cfg/Commn Scheduler
1043 * @param[in] RgSchCellCb *cellCb
1044 * @param[in] RgSchUeCb *ueCb
1045 * @param[in] U8 action
1051 Void rgSCHSCellSelectAndActDeAct
1058 Void rgSCHSCellSelectAndActDeAct(pCell, ueCb, action)
1072 if(((ret = rgSCHSCellSelectForAct(pCell, ueCb, &sCellIdx)) == ROK)
1081 (ROK != (rgSCHSCellTrigActDeact(pCell, ueCb, sCellIdx, action))))
1083 RGSCHDBGERR(pCell->instIdx,(rgSchPBuf(pCell->instIdx), "SCell Actication failed"
1084 "for UE [%d] with SCellIdx [%d]\n", ueCb->ueId, sCellIdx));
1091 * @brief Handling of Scell Deletion
1095 * Function: rgSCHSCellDelUeSCell
1096 * Purpose : Perform Scell Deletion for an UE
1097 * : flush harqEnttiy of the given scell associated
1101 * Invoked by:Cfg module
1103 * @param[in] RgSchCellCb *cellCb
1104 * @param[in] RgSchUeCb *ueCb
1106 * @return ROK/RFAILED
1110 Void rgSCHSCellDelUeSCell
1112 RgSchCellCb *cellCb,
1117 Void rgSCHSCellDelUeSCell(cellCb,ueCb,sCellIdx)
1118 RgSchCellCb *cellCb;
1123 RgUeUlHqCb *ulHqEnt;
1124 Inst inst = cellCb->instIdx;
1125 RgSchUeCellInfo *sCellInfo;
1128 sCellInfo = ueCb->cellInfo[sCellIdx];
1131 if(sCellInfo == NULLP)
1133 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d\
1135 sCellIdx,ueCb->ueId));
1139 rgSCHDbmDelUeCb(sCellInfo->cell, ueCb);
1140 ueUl = RG_SCH_CMN_GET_UL_UE(ueCb, sCellInfo->cell);
1142 if (NULLP != sCellInfo->sCellLnk.node)
1144 cmLListDelFrm(&sCellInfo->cell->sCellUeLst, &sCellInfo->sCellLnk);
1147 /* Clear Scheduler specific list for this UE from the
1148 * corresponding CELL */
1150 /*Updating 1BCS Value*/
1151 ueCb->f1bCsAVal = (ueCb->f1bCsAVal -
1152 rgSCHUtlGetMaxTbSupp(sCellInfo->txMode.txModeEnum));
1155 rgSCHUtlDelUeANFdbkInfo(ueCb,sCellIdx);
1158 rgSCHSCellDeActivation(sCellInfo);
1159 /* Release hqEnt mem */
1160 rgSCHDhmDelHqEnt(cellCb, &sCellInfo->hqEnt);
1162 ulHqEnt = &(ueUl->hqEnt);
1164 cellCb->sc.apis->rgSCHRgrSCellUeDel(sCellInfo, sCellInfo->ue);
1166 rgSCHUhmFreeUe(sCellInfo->cell, ulHqEnt);
1168 rgSCHUtlFreeSBuf(cellCb->instIdx,
1169 (Data**)(&(sCellInfo)), (sizeof(RgSchUeCellInfo)));
1171 ueCb->cellInfo[sCellIdx] = NULLP;
1177 * @brief Handling of UE Deletion
1181 * Function: rgSCHSCellDelUe
1182 * Purpose : Perform UE Deletion
1183 * : Delete all the SCells added for this UE
1184 * : flush harqEnttiy of all scells associated
1188 * Invoked by:Cfg module
1190 * @param[in] RgSchCellCb *cellCb
1191 * @param[in] RgSchUeCb *ueCb
1192 * @return ROK/RFAILED
1198 RgSchCellCb *cellCb,
1202 S16 rgSCHSCellDelUe(cellCb,ueCb)
1203 RgSchCellCb *cellCb;
1208 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1210 rgSCHSCellDelUeSCell(cellCb,ueCb,idx);
1219 * @brief Handling of PCqi cfg fro a scell
1223 * Function: rgSCHSCellPCqiCfg
1225 * : Delete all the SCells added for this UE
1226 * : flush harqEnttiy of all scells associated
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
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
1241 * Invoked by:Cfg module
1243 * @param[in] RgSchCellCb *cellCb
1244 * @param[in] RgSchUeCb *ueCb
1245 * @return ROK/RFAILED
1249 S16 rgSCHSCellPCqiCfg
1251 RgSchCellCb *priCellCb,
1252 RgSchCellCb *secCellCb,
1254 RgrUePrdDlCqiCfg *cqiCfg,
1255 CmLteUeCategory ueCat,
1259 S16 rgSCHSCellPCqiCfg(priCellCb,secCellCb,ueCb,cqiCfg,ueCat,sCellIdx)
1260 RgSchCellCb *priCellCb;
1261 RgSchCellCb *secCellCb;
1263 RgrUePrdDlCqiCfg *cqiCfg;
1264 CmLteUeCategory ueCat;
1268 U8 j; /*Bandwidth Parts*/
1271 Inst inst = priCellCb->instIdx;
1273 RgSchUeCellInfo *sCellInfo;
1274 RgSchUePCqiCb *cqiCb = NULLP;
1276 RGSCHDBGINFO(priCellCb->instIdx, (rgSchPBuf(priCellCb->instIdx),
1277 "rgSCHSCellPCqiCfg cellId =%d, ueId = %d, CfgType =%d\n",
1278 secCellCb->cellId, ueCb->ueId, cqiCfg->type));
1280 if((sCellIdx < 1) ||
1281 (sCellIdx > RGR_MAX_SCELL_PER_UE))
1283 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n",
1288 sCellInfo = ueCb->cellInfo[sCellIdx];
1290 cqiCb = &ueCb->cellInfo[sCellIdx]->cqiCb;
1291 cqiCb->servCellInfo = sCellInfo;
1293 /* Periodic CQI is setup */
1294 if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
1296 /* 1. Copy the Received CQI Cfg parameters to ueCb */
1297 memcpy(&cqiCb->cqiCfg, cqiCfg,
1298 sizeof(RgrUePrdDlCqiCfg));
1300 /* 2. Compute Periodic CQI Periodicity and subframe offset */
1302 rgSCHUtlGetCfgPerOff(RG_SCH_FDD_PCQI_TBL, cqiCfg->cqiSetup.cqiPCfgIdx,
1303 &cqiCb->cqiPeri, &cqiCb->cqiOffset);
1305 rgSCHUtlGetCfgPerOff( RG_SCH_TDD_PCQI_TBL,
1306 cqiCfg->cqiSetup.cqiPCfgIdx,
1307 &cqiCb->cqiPeri, &cqiCb->cqiOffset);
1311 RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx),
1312 "\n rgSCHSCellPCqiCfg(): CQI Peri=%d, CQI Offset=%d",
1313 cqiCb->cqiPeri,cqiCb->cqiOffset));
1315 if(RGR_UE_PCQI_SB_REP == cqiCfg->cqiSetup.cqiRepType)
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);
1331 /* Wideband Cqi Rep Type */
1332 cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_1;
1334 cqiCb->cqiLstEnt.node=(PTR)cqiCb;
1335 cqiCb->isCqiIgnoByCollsn = FALSE;
1338 /* 4. Rank Indicator Cfg handler */
1339 /* 1. Rank Indicator is enabled */
1340 if(cqiCfg->cqiSetup.riEna)
1342 rgSCHUtlGetCfgPerOff(RG_SCH_RI_TBL,
1343 cqiCfg->cqiSetup.riCfgIdx,
1344 &cqiCb->riPeri, &cqiCb->riOffset);
1346 RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx),
1347 "\n rgSCHSCellPCqiCfg(): RI Peri=%d, RI Offset=%d",
1348 cqiCb->riPeri,cqiCb->riOffset));
1350 if(ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_3
1351 || ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_4)
1353 if (secCellCb->numTxAntPorts ==2)
1355 cqiCb->riNumBits = 1;
1357 else if(secCellCb->numTxAntPorts ==4)
1359 if(ueCat == CM_LTE_UE_CAT_8)
1361 cqiCb->riNumBits = 3;
1363 else if((ueCat == CM_LTE_UE_CAT_5) ||
1364 (ueCat == CM_LTE_UE_CAT_6) || CM_LTE_UE_CAT_7)
1366 cqiCb->riNumBits = 2;
1370 cqiCb->riNumBits = 1;
1374 cqiCb->riLstEnt.node=(PTR) cqiCb;
1375 cqiCb->isRiIgnoByCollsn = FALSE;
1381 sCellInfo->cqiCb.cqiCfg.type = RGR_SCH_PCQI_REL;
1383 /* Setting the indices to invalid during
1384 scell addition. These indices will be set during
1386 cqiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
1387 cqiCb->riDist = RG_SCH_INVALID_IDX;
1388 cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
1395 * @brief Handling of Ue Reset from common scheduler
1399 * Function: rgSCHSCellDlUeReset
1400 * Purpose: Call scheudler type spcefic UE RESET
1401 * for all the secondary cells
1403 * Invoked by: CommonScheduler
1405 * @param[in] RgSchCellCb* cell
1406 * @param[in] RgSchUeCb* ue
1411 Void rgSCHSCellDlUeReset
1417 Void rgSCHSCellDlUeReset(cell, ue)
1422 RgSchCmnCell *cellSch;
1424 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1426 if(ue->cellInfo[idx] != NULLP)
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;
1439 * @brief Handling of LC Cfg from common scheduler
1443 * Function: rgSCHSCellDlLcCfg
1444 * Purpose: Call scheudler type spcefic LC config
1445 * for all the secondary cells
1447 * Invoked by: CommonScheduler
1449 * @param[in] RgSchCellCb* cell
1450 * @param[in] RgSchUeCb* ue
1455 Void rgSCHSCellDlLcCfg
1462 Void rgSCHSCellDlLcCfg(cell, ue, svc)
1468 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1469 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1471 if(ue->cellInfo[idx] != NULLP)
1473 cellSch->apisDl->rgSCHRgrDlLcCfg(ue->cellInfo[idx]->cell, ue, svc,NULLP,NULLP);
1480 * @brief Handling of LC Delete from common scheduler
1484 * Function: rgSCHSCellDlLcDel
1485 * Purpose: Call scheudler type spcefic bo update handler
1486 * for all the secondary cells
1488 * Invoked by: CommonScheduler
1490 * @param[in] RgSchCellCb* cell
1491 * @param[in] RgSchUeCb* ue
1496 Void rgSCHSCellDlLcDel
1503 Void rgSCHSCellDlLcDel(cell, ue, svc)
1509 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1510 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1512 if(ue->cellInfo[idx] != NULLP)
1514 cellSch->apisDl->rgSCHFreeDlLc(ue->cellInfo[idx]->cell, ue, svc);
1521 * @brief Handling of Bo update from common scheduler
1525 * Function: rgSCHSCellDlDedBoUpd
1526 * Purpose: Call scheudler type spcefic bo update handler
1527 * for all the secondary cells
1529 * Invoked by: CommonScheduler
1531 * @param[in] RgSchCellCb* cell
1532 * @param[in] RgSchUeCb* ue
1537 Void rgSCHSCellDlDedBoUpd
1544 Void rgSCHSCellDlDedBoUpd(cell, ue, svc)
1550 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
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)
1557 cellSch->apisDl->rgSCHDlDedBoUpd(ue->cell, ue, svc);
1559 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1561 if((ue->cellInfo[idx] != NULLP) &&
1562 (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE) &&
1563 (ue->cellInfo[idx]->cell != cell))
1565 cellSch->apisDl->rgSCHDlDedBoUpd(ue->cellInfo[idx]->cell, ue, svc);
1572 * @brief Compare two CQI CB configs are return the result
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
1582 * @param[in] RgSchUePCqiCb *cqiCb1
1583 * @param[in] RgSchUePCqiCb *cqiCb2
1584 * @return U8 cqiCb cell idx which has the higher priority
1588 PRIVATE U8 rgSCHUtlSCellCmpCqiCfg
1590 RgSchUePCqiCb *cqiCb1,
1591 RgSchUePCqiCb *cqiCb2
1594 PRIVATE U8 rgSCHUtlSCellCmpCqiCfg(cqiCb1, cqiCb2)
1595 RgSchUePCqiCb *cqiCb1;
1596 RgSchUePCqiCb *cqiCb2;
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 */
1604 if (cqiCb1->prioLvl > cqiCb2->prioLvl)
1606 cqiCb2->isCqiIgnoByCollsn = TRUE;
1607 cqiCb1->isCqiIgnoByCollsn = FALSE;
1610 else if (cqiCb2->prioLvl > cqiCb1->prioLvl)
1612 cqiCb1->isCqiIgnoByCollsn = TRUE;
1613 cqiCb2->isCqiIgnoByCollsn = FALSE;
1618 if (cqiCb1->servCellInfo->sCellIdx > cqiCb2->servCellInfo->sCellIdx)
1620 cqiCb1->isCqiIgnoByCollsn = TRUE;
1621 cqiCb2->isCqiIgnoByCollsn = FALSE;
1626 cqiCb2->isCqiIgnoByCollsn = TRUE;
1627 cqiCb1->isCqiIgnoByCollsn = FALSE;
1632 return (retCqiCb->servCellInfo->sCellIdx);
1636 * @brief Handling of collision of CQI types between serving cells
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
1645 * @param[in] RgSchCellCb *cellCb
1646 * @param[in] RgSchUeCb *ueCb
1647 * @return ROK/RFAILED
1651 S16 rgSCHUtlSCellHndlCqiCollsn
1653 RgSchUePCqiCb *cqiCb
1656 S16 rgSCHUtlSCellHndlCqiCollsn(cqiCb)
1657 RgSchUePCqiCb *cqiCb;
1660 U32 nPCqiServCellIdx;
1664 RgSchCellCb *priCellCb = cqiCb->servCellInfo->ue->cell;
1665 RgSchUeCb *ueCb = cqiCb->servCellInfo->ue;
1669 CmLteTimingInfo timingInfo;
1673 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1675 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1676 TFU_RECPREQ_DLDELTA);
1679 RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1681 cqiCb->isCqiIgnoByCollsn = FALSE;
1683 pCqiTrIdx = cqiCb->nCqiTrIdx;
1684 nPCqiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1685 /* Handle wrap around case */
1686 if (pCqiTrIdx < crntSfIdx)
1688 pCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1690 minPCqiTrIdx = pCqiTrIdx;
1692 for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1694 /* If a serving cell is configured */
1695 if(ueCb->cellInfo[cellIdx] != NULLP)
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))
1703 scellPCqiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nCqiTrIdx;
1705 /* Handle wrap around case */
1706 if (scellPCqiTrIdx < crntSfIdx)
1708 scellPCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
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))
1717 /* Handle Collision */
1718 /* set isCqiIgnoByCollsn to TRUE for low prio CQI Rep type */
1719 nPCqiServCellIdx = rgSCHUtlSCellCmpCqiCfg(&ueCb->cellInfo[cellIdx]->cqiCb,cqiCb);
1721 else if (scellPCqiTrIdx < minPCqiTrIdx)
1723 minPCqiTrIdx = scellPCqiTrIdx;
1724 nPCqiServCellIdx = cellIdx;
1728 /* If all of the num of configured scells are checked then break */
1729 if (sCellCnt == ueCb->numSCells)
1737 /* Set the next expected Cqi into nPCqiCb */
1738 idx = ((nPCqiServCellIdx)& (CM_LTE_MAX_CELLS -1));
1739 ueCb->nPCqiCb = &ueCb->cellInfo[idx]->cqiCb;
1746 * @brief Handling of collision of RI types between serving cells
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
1755 * @param[in] RgSchCellCb *cellCb
1756 * @param[in] RgSchUeCb *ueCb
1757 * @return ROK/RFAILED
1761 S16 rgSCHUtlSCellHndlRiCollsn
1763 RgSchUePCqiCb *cqiCb
1766 S16 rgSCHUtlSCellHndlRiCollsn(cqiCb)
1767 RgSchUePCqiCb *cqiCb;
1770 U32 nPRiServCellIdx;
1774 RgSchCellCb *priCellCb = cqiCb->servCellInfo->ue->cell;
1775 RgSchUeCb *ueCb = cqiCb->servCellInfo->ue;
1779 CmLteTimingInfo timingInfo;
1782 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1784 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1785 TFU_RECPREQ_DLDELTA);
1788 RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1790 pRiTrIdx = cqiCb->nRiTrIdx + cqiCb->riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1792 /* Handle wrap around case */
1793 if (pRiTrIdx < crntSfIdx)
1795 pRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1798 cqiCb->isRiIgnoByCollsn = FALSE;
1799 nPRiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1800 minPRiTrIdx = pRiTrIdx;
1802 for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1804 /* If a serving cell is configured */
1805 if(ueCb->cellInfo[cellIdx] != NULLP)
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))
1813 scellPRiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nRiTrIdx +
1814 ueCb->cellInfo[cellIdx]->cqiCb.riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1816 /* Handle wrap around case */
1817 if (scellPRiTrIdx < crntSfIdx)
1819 scellPRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
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))
1828 /* Handle Collision */
1829 /* set isRiIgnoByCollsn to TRUE for low prio CQI Rep type */
1830 if (cqiCb->servCellInfo->sCellIdx < (ueCb->cellInfo[cellIdx]->sCellIdx))
1832 ueCb->cellInfo[cellIdx]->cqiCb.isRiIgnoByCollsn = TRUE;
1836 cqiCb->isRiIgnoByCollsn = TRUE;
1839 else if (scellPRiTrIdx < minPRiTrIdx)
1841 minPRiTrIdx = scellPRiTrIdx;
1842 nPRiServCellIdx = cellIdx;
1846 /* If all of the num of configured scells are checked then break */
1847 if (sCellCnt == ueCb->numSCells)
1855 /* Set the next expected Cqi into nPCqiCb */
1856 ueCb->nPRiCb = &ueCb->cellInfo[nPRiServCellIdx]->cqiCb;
1860 #endif/*TFU_UPGRADE*/
1863 * @brief Checking whethter the scell is active or not
1867 * Function: rgSCHSCellIsActive
1868 * Purpose: Check the Scell is in active state or not
1871 * Invoked by: SpecificScheduler
1873 * @param[in] RgSchCellCb* cell
1874 * @param[in] RgSchUeCb* ue
1879 S16 rgSCHSCellIsActive
1885 S16 rgSCHSCellIsActive(cell, ue)
1890 S16 retVal = RFAILED;
1892 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1894 if((ue->cellInfo[idx] != NULLP) &&
1895 (ue->cellInfo[idx]->cell->cellId == cell->cellId)&&
1896 (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE))
1906 * @brief Function to check for Acell Activation Trigered.
1910 * Function : rgSCHIsActvReqd
1911 * This function will check for Secondary cell activation criteria
1912 * If met this will return TRUE else FALSE
1914 * @param[in] RgSchCellCb *cell
1915 * @param[in] RgSchUeCb *ue
1920 Bool rgSCHIsActvReqd
1926 Bool rgSCHIsActvReqd(cell, ue)
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
1934 if(ue->remBoCnt == RG_SCH_ACTIVATION_COUNT)
1944 /**********************************************************************
1947 **********************************************************************/