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 "envopt.h" /* environment options */
37 #include "envdep.h" /* environment dependent */
38 #include "envind.h" /* environment independent */
39 #include "gen.h" /* general layer */
40 #include "ssi.h" /* system service interface */
41 #include "cm5.h" /* common timers */
42 #include "cm_hash.h" /* common hash list */
43 #include "cm_llist.h" /* common linked list library */
44 #include "cm_err.h" /* common error */
45 #include "cm_lte.h" /* common LTE */
51 #include "rg_sch_inf.h"
52 #include "rg_sch_err.h"
54 #include "rg_sch_cmn.h"
56 /* header/extern include files (.x) */
57 #include "gen.x" /* general layer typedefs */
58 #include "ssi.x" /* system services typedefs */
59 #include "cm5.x" /* common timers */
60 #include "cm_hash.x" /* common hash list */
61 #include "cm_lib.x" /* common library */
62 #include "cm_llist.x" /* common linked list */
63 #include "cm_mblk.x" /* memory management */
64 #include "cm_tkns.x" /* common tokens */
65 #include "cm_lte.x" /* common tokens */
66 #include "tfu.x" /* RGU types */
67 #include "lrg.x" /* layer management typedefs for MAC */
68 #include "rgr.x" /* layer management typedefs for MAC */
69 #include "rgm.x" /* layer management typedefs for MAC */
70 #include "rg_sch_inf.x" /* typedefs for Scheduler */
71 #include "rg_sch.x" /* typedefs for Scheduler */
72 #include "rg_sch_cmn.x"
76 PUBLIC Void rgSCHSCellActivation ARGS((
77 RgSchUeCellInfo *sCell
80 PUBLIC Void rgSCHSCellSchdActDeactCe ARGS((
84 PUBLIC Void rgSCHSCellAddToActDeactLst ARGS((
89 PUBLIC Void rgSCHSCellRmvFrmActLst ARGS((
93 PUBLIC S16 rgSCHSCellIsActive ARGS((
98 PUBLIC Void rgSCHSCellHndlFdbkInd ARGS((
102 Bool maxHqRetxReached
106 PUBLIC Void rgSCHSCellDeactTmrExpry ARGS((
107 RgSchUeCellInfo *sCell
111 PUBLIC Void rgSCHSCellDelUeSCell ARGS((
117 PUBLIC S16 rgSCHSCellDelUe ARGS((
122 PUBLIC S16 rgSCHSCellPCqiCfg ARGS((
123 RgSchCellCb *priCellCb,
124 RgSchCellCb *secCellCb,
126 RgrUePrdDlCqiCfg *cqiCfg,
127 CmLteUeCategory ueCat,
131 PRIVATE S16 rgSCHSCellTrgMacHqEReset ARGS((
139 /** * @brief Handler for scheduling Scell Activation CE.
143 * Function : rgSCHDhmShcdSCellActCe
145 * This function is called by scheduler when resource allocation
146 * for SCell Activation CE transmission is done.
148 * @param[in] RgSchUeCb *ue
149 * @param[out] RgSchDlHqTbCb *tbInfo
154 PUBLIC Void rgSCHSCellSchdActDeactCe
157 RgSchDlHqTbCb *tbInfo
160 PUBLIC Void rgSCHSCellSchdActDeactCe(ueCb, tbInfo)
162 RgSchDlHqTbCb *tbInfo;
167 U8 sCellActDeactBitMask = 0;
168 TRC3(rgSCHSCellSchdActDeactCe);
170 /* Change the state of all Scells waiting for
173 /* -------------------------
174 * | C7|C6|C5|C4|C3|C2|C1|R|
175 * -------------------------*/
180 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
182 if(ueCb->cellInfo[idx] != NULLP)
184 switch(ueCb->cellInfo[idx]->sCellState)
186 case RG_SCH_SCELL_TOBE_ACTIVATED:
187 case RG_SCH_SCELL_ACTVTN_IN_PROG:
189 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_ACTVTN_IN_PROG;
193 case RG_SCH_SCELL_ACTIVE:
198 case RG_SCH_SCELL_TOBE_DEACTIVATED:
199 case RG_SCH_SCELL_DEACTVTN_IN_PROG:
201 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_DEACTVTN_IN_PROG;
205 case RG_SCH_SCELL_INACTIVE:
206 case RG_SCH_SCELL_READY:
215 sCellActDeactBitMask |= 1 << (idx);/* servCellIdx = idx + 1 */
219 tbInfo->schdSCellActCe.pres = PRSNT_NODEF;
220 tbInfo->schdSCellActCe.val = sCellActDeactBitMask;
223 } /* rgSCHSCellSchdActDeactCe */
227 * @brief Adds an UE to the Cell's SCell Activation list
231 * Function: rgSCHSCellAddToActDeactLst
232 * Purpose: Adds an UE to Cell's SCEll Act list
234 * Invoked by: Common Scheduler
236 * @param[in] RgSchCellCb* cell
237 * @param[in] RgSchUeCb* ue
242 PUBLIC Void rgSCHSCellAddToActDeactLst
248 PUBLIC Void rgSCHSCellAddToActDeactLst(cell, ue)
253 RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
254 TRC3(rgSCHSCellAddToActDeactLst);
256 if(NULLP == ue->sCellActLnk.node)
257 {/* Ue is not present in the list */
258 cmLListAdd2Tail(&cellCmnDl->secCellActCeLst, &ue->sCellActLnk);
259 ue->sCellActLnk.node = (PTR)ue;
263 RGSCHDBGINFONEW(cell->instIdx,(rgSchPBuf(cell->instIdx),
264 "SCell is already added in the Act List: ueId(%u)\n", ue->ueId));
272 * @brief Removes an UE from Cell's SCell Activation list
276 * Function: rgSCHSCellRmvFrmActLst
277 * Purpose: Removes an UE from Cell's SCEll Act list
279 * Invoked by: Specific Scheduler
281 * @param[in] RgSchCellCb* cell
282 * @param[in] RgSchUeCb* ue
287 PUBLIC Void rgSCHSCellRmvFrmActLst
293 PUBLIC Void rgSCHSCellRmvFrmActLst(cell, ue)
298 RgSchCmnDlCell *cellCmnDl = RG_SCH_CMN_GET_DL_CELL(cell);
299 TRC3(rgSCHSCellRmvFrmActLst);
300 if (NULLP != ue->sCellActLnk.node)
302 cmLListDelFrm(&cellCmnDl->secCellActCeLst, &ue->sCellActLnk);
304 ue->sCellActLnk.node = (PTR)NULLP;
310 * @brief Handling of SCell Activation
314 * Function: rgSCHSCellActivation
315 * Purpose : Perform Activation of secondary cell
316 * : Move the state to ACTIVE
317 * : Start the procedure for PCQI/SRS for this scell
319 * Invoked by:Cfg/Commn Scheduler
321 * @param[in] RgSchUeCellInfo *sCellInfo
323 * @return ROK/RFAILED
327 PUBLIC Void rgSCHSCellActivation
329 RgSchUeCellInfo *sCellInfo
332 PUBLIC Void rgSCHSCellActivation(sCellInfo)
333 RgSchUeCellInfo *sCellInfo
336 RgSchCellCb *sCell = sCellInfo->cell;
337 RgSchUeCb *ueCb = sCellInfo->ue;
338 RgSchCmnCell *cellSch;
341 Inst inst = ueCb->cell->instIdx;
344 RgrUePrdDlCqiCfg *cqiCfg;
345 U8 j; /*Bandwidth Parts*/
349 RgSchUePCqiCb *cqiCb = NULLP;
350 CmLteTimingInfo timingInfo;
354 TRC3(rgSCHSCellActivation);
356 sCellInfo->sCellState = RG_SCH_SCELL_ACTIVE;
358 ueCb->tenbStats->stats.persistent.numActivation++;
362 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);
364 /* Start the sCellDeactivation timer if cfgd */
365 if(PRSNT_NODEF == ueCb->sCellDeactTmrVal.pres)
367 //rgSCHTmrStartTmr (sCell,sCellInfo ,RG_SCH_TMR_SCELL_DEACT,
368 // ueCb->sCellDeactTmrVal.val);
372 /* Start receiving CQI for this SCell for this UE */
373 crntTime = (ueCb->cell->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)+
374 (ueCb->cell->crntTime.subframe);
376 cqiCb = &sCellInfo->cqiCb;
377 cqiCfg = &cqiCb->cqiCfg;
378 if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
380 cqiTrInstTime = ((cqiCb->cqiPeri+crntTime) - cqiCb->cqiOffset)
382 cqiCb->nCqiTrIdx = (crntTime +
383 (cqiCb->cqiPeri - cqiTrInstTime));
384 /* Introduced timing delta for reception req
386 if(cqiCb->nCqiTrIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
388 cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx + cqiCb->cqiPeri;
391 timingInfo.sfn = cqiCb->nCqiTrIdx/RGSCH_NUM_SUB_FRAMES_5G;
392 timingInfo.subframe = cqiCb->nCqiTrIdx%RGSCH_NUM_SUB_FRAMES_5G;
393 if(cqiCb->cqiCfg.cqiSetup.cqiRepType == RGR_UE_PCQI_SB_REP)
395 rgSCHTomUtlPcqiSbCalcBpIdx(timingInfo,ueCb,cqiCb);
398 cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx
399 %RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
400 RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), "CQI Config: idx(%u) Periodicity %u"
401 "Offset %u uePosInQ (%u)\n", cqiCfg->cqiSetup.cqiPCfgIdx,
402 cqiCb->cqiPeri, cqiCb->cqiOffset,cqiCb->nCqiTrIdx));
404 cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
407 rgSCHUtlSCellHndlCqiCollsn(cqiCb);
409 RGSCHDBGINFO(inst,(rgSchPBuf(inst),
410 "\n rgSCHCfgPCqiUeCfg():"
411 " CrntTime=%d Next CqiTrInstTime=%d Index Stored at=%d ",
412 crntTime, cqiTrInstTime, cqiCb->nCqiTrIdx));
414 if(cqiCfg->cqiSetup.riEna)
417 cqiCb->invalidateCqi = FALSE;
419 if(RGR_UE_PCQI_WB_REP == cqiCfg->cqiSetup.cqiRepType)
422 1. wideband RI reporting is configured
424 (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )Mod(NCqiperiod
427 periodicity = cqiCb->cqiPeri * cqiCb->riPeri;
432 * Where Widesband and Subband RI reporting is configured
434 * (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )
435 * Mod(H. NCqiperiod *MriPeriod )=0
436 * where H= J * K +1; J=Number of bandwidth parts(BW/subsize).
437 * K is RGR interf input
440 RG_SCH_GET_CQI_J_VAL(sCell->bwCfg.dlTotalBw, j);
441 cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1;
442 periodicity = cqiCb->h * cqiCb->cqiPeri *
447 /* In case of SFN wraparound, the SB CQI reporting cycle breaks
448 * and RI->WB CQI->SBCQI.. should resume. RI is repositioned
449 * accordingly. WBCQI handling is naturally accomplished */
450 if (periodicity >= RGSCH_MAX_SUBFRM_5G)
452 periodicity = cqiCb->cqiOffset - cqiCb->riOffset +
453 RGSCH_MAX_SUBFRM_5G - (crntTime);
454 tempIdx = crntTime + periodicity;
458 riTrInsTime = ((periodicity +crntTime )- \
459 cqiCb->cqiOffset + cqiCb->riOffset)\
461 tempIdx = (crntTime + (periodicity -riTrInsTime));
463 if (tempIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
465 tempIdx = tempIdx + periodicity;
467 cqiCb->nRiTrIdx = tempIdx
468 % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
469 if(periodicity >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
471 cqiCb->riDist = rgSCHUtlFindDist((U16)(crntTime + TFU_RECPREQ_DLDELTA),
480 /* Start receiving RI for this SCell for this UE */
481 cmLListAdd2Tail(&ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst,
483 RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_ADD,
484 &ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
486 rgSCHUtlSCellHndlRiCollsn(cqiCb);
489 RGSCHDBGINFONEW(inst,(rgSchPBuf(inst), "SCel RI cfg:"
490 "idx %u period %u Offset %u posInQ(%u) riDist(%u)lst count"
491 "%lu\n", cqiCfg->cqiSetup.riCfgIdx, cqiCb->riPeri,
492 cqiCb->riOffset, cqiCb->nRiTrIdx, cqiCb->riDist,
493 ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst.count));
495 RGSCHDBGINFONEW(inst,(rgSchPBuf(inst), "SCel RI cfg:"
496 "idx %u period %u Offset %u posInQ(%u) riDist(%u)lst count"
497 "%u\n", cqiCfg->cqiSetup.riCfgIdx, cqiCb->riPeri,
498 cqiCb->riOffset, cqiCb->nRiTrIdx, cqiCb->riDist,
499 ueCb->cell->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst.count));
504 RGSCHDBGINFO(inst,(rgSchPBuf(inst),
505 "\n rgSCHSCellActivation(): CrntTime=%d Next RiTrInstTime=%d"
506 "Index Stored at=%d riDis=%d ",
507 crntTime, riTrInsTime, cqiCb->nRiTrIdx, cqiCb->riDist));
512 cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
513 cellSch->apisDl->rgSCHDlSCellActv(sCellInfo->cell, sCellInfo->ue);
521 * @brief Remove CQI from Scell Lst
525 * Function: rgSCHCellClearScellLstOfCQI
526 * Purpose : Remove CQI from Scell Lst
531 * @param[in] RgSchUeCellInfo *sCellInfo
536 PRIVATE Void rgSCHCellClearScellLstOfCQI
538 RgSchUeCellInfo *sCellInfo
541 PRIVATE Void rgSCHCellClearScellLstOfCQI(sCellInfo)
542 RgSchUeCellInfo *sCellInfo;
546 TRC3(rgSCHCellClearScellLstOfCQI);
547 RgSchUePCqiCb *cqiRiCb = NULLP;
549 ueCb = sCellInfo->ue;
550 /* Clear CQI/RI entry for this SCELL */
551 cqiRiCb = &sCellInfo->cqiCb;
552 /* Delete Periodic CQI/PMI Transmission Instance */
553 if (cqiRiCb->nCqiTrIdx != RG_SCH_INVALID_IDX)
555 cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nCqiTrIdx].cqiLst,
556 &cqiRiCb->cqiLstEnt);
557 cqiRiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
559 if (ueCb->nPCqiCb == cqiRiCb)
561 rgSCHUtlSCellHndlCqiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
563 /* Delete Periodic RI Transmission Instance */
565 if (cqiRiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
567 cmLListDelFrm(&ueCb->cell->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst,
569 RG_SCH_RECORD(&cqiRiCb->histElem,RGSCH_ACTION_DEL,
570 &ueCb->cell->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst);
571 cqiRiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
572 if (ueCb->nPRiCb == cqiRiCb)
574 rgSCHUtlSCellHndlRiCollsn(&ueCb->cellInfo[RGSCH_PCELL_INDEX]->cqiCb);
581 #endif/*TFU_UPGRADE*/
584 * @brief Handling of SCell DeActivation
588 * Function: rgSCHSCellDeActivation
589 * Purpose : Perform Deactivation of secondary cell
590 * : Move the state to IN_ACTIVE
591 * : Flush the harqEntity
592 * : Trigger harqEntity flushing to MAC
593 * : Remove PCQI/SRS for this scell
594 * : Stop Deactivation timer if running
596 * Invoked by:Cfg/Commn Scheduler
598 * @param[in] RgSchUeCellInfo *sCellInfo
600 * @return ROK/RFAILED
604 PRIVATE S16 rgSCHSCellDeActivation
606 RgSchUeCellInfo *sCellInfo
609 PRIVATE S16 rgSCHSCellDeActivation(sCellInfo)
610 RgSchUeCellInfo *sCellInfo
614 RgSchCmnCell *cellSch;
615 Inst inst = sCellInfo->cell->instIdx;
617 TRC3(rgSCHSCellDeActivation);
618 /* Stop the timer if running */
620 if(sCellInfo->deactTmr.tmrEvnt != TMR_NONE)
622 rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_DEACT, sCellInfo);
625 if (sCellInfo->actDelayTmr.tmrEvnt != TMR_NONE)
627 rgSCHTmrStopTmr(sCellInfo->cell, RG_SCH_TMR_SCELL_ACT_DELAY, sCellInfo);
630 cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
631 cellSch->apisDl->rgSCHDlUeReset(sCellInfo->cell, sCellInfo->ue);
633 if(sCellInfo->ue->isDrxEnabled)
635 rgSCHDrxUeHqReset(sCellInfo->ue->cell, sCellInfo->ue,
636 sCellInfo->hqEnt, sCellInfo->sCellIdx);
639 /* Flush the harqEntity at scheduler */
640 if(sCellInfo->hqEnt != NULLP)
642 rgSCHDhmHqEntReset(sCellInfo->hqEnt);
644 /* Trigger harq flush req to MAC */
647 rgSCHSCellTrgMacHqEReset(inst,sCellInfo->sCellId,sCellInfo->ue->ueId);
649 sCellInfo->sCellState = RG_SCH_SCELL_READY;
651 rgSCHCellClearScellLstOfCQI(sCellInfo);
655 sCellInfo->ue->tenbStats->stats.persistent.numDeactivation++;
658 cellSch->apisDl->rgSCHDlSCellDeactv(sCellInfo->cell, sCellInfo->ue);
661 printf("SCELL DEATIVATED sCellInfo->ue->ueId =%d, sCellInfo->sCellId =%d\n", sCellInfo->ue->ueId, sCellInfo->sCellId);
662 //MSPD_DBG("SCELL DEATIVATED sCellInfo->ue->ueId =%d, sCellInfo->sCellId =%d\n", sCellInfo->ue->ueId, sCellInfo->sCellId);
669 * @brief Triggering hqEntity reset to mac
673 * Function: rgSCHSCellTrgMacHqEReset
674 * Purpose: Frame the interface for mac to reset
676 * Derive the macInstance corresponding
677 * to the secondary cell going to be deactivated.
678 * Triiger the msg to that macInstance
680 * Invoked by: CommonScheduler
682 * @param[in] U16 sCellId
683 * @param[in] U16 rnti
688 PRIVATE S16 rgSCHSCellTrgMacHqEReset
695 PRIVATE S16 rgSCHSCellTrgMacHqEReset(inst,secCellId,rnti)
702 RgSchCellCb *secCellCb = NULLP;
703 RgInfResetHqEnt hqEntRstInfo;
705 if((secCellCb = (RgSchCellCb *)rgSchUtlGetCellCb(inst, secCellId)) == NULLP)
707 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst), "SCell doesnt exists"));
711 hqEntRstInfo.cellId = secCellId;
712 hqEntRstInfo.crnti = rnti;
714 rgSCHUtlGetPstToLyr(&pst, &rgSchCb[inst], secCellCb->macInst);
716 RgSchMacRstHqEnt(&pst, &hqEntRstInfo);
725 * @brief Handling of harq feeback for SCell act CE txion
729 * Function: rgSCHSCellHndlFdbkInd
730 * Purpose: Handling the harq feedback for SCell ACT ce txion
731 * ACK:: Set the state as active for the Scells for which
733 * HQ FAILURE/DTX/NACK:: Perform retxion. Add to Act CE list
734 * Set the state to TOBE_SCHEDULED
737 * Invoked by: CommonScheduler
739 * @param[in] RgSchCellCb* cell
740 * @param[in] RgSchUeCb* ue
745 PUBLIC Void rgSCHSCellHndlFdbkInd
747 RgSchDlHqProcCb *hqP,
750 Bool maxHqRetxReached
753 PUBLIC Void rgSCHSCellHndlFdbkInd(hqP, tbIdx, fdbk,maxHqRetxReached)
754 RgSchDlHqProcCb *hqP;
757 Bool maxHqRetxReached;
763 RgSchUeCellInfo *sCellInfo;
765 TRC3(rgSCHSCellHndlFdbkInd);
773 hqP->tbInfo[tbIdx].schdSCellActCe.pres = FALSE;
775 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
777 if(ueCb->cellInfo[idx] != NULLP)
779 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
782 printf("\n starting delay timer...\n");
784 rgSCHTmrStartTmr (cell,ueCb->cellInfo[idx] ,RG_SCH_TMR_SCELL_ACT_DELAY,
785 RG_SCH_CMN_SCELL_ACT_DELAY_TMR);
789 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
791 sCellInfo = ueCb->cellInfo[idx];
792 rgSCHSCellDeActivation(sCellInfo);
802 if(TRUE == maxHqRetxReached)
804 hqP->tbInfo[tbIdx].schdSCellActCe.pres = FALSE;
805 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
807 if(ueCb->cellInfo[idx] != NULLP)
809 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTVTN_IN_PROG)
811 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
815 if(ueCb->cellInfo[idx]->sCellState == RG_SCH_SCELL_DEACTVTN_IN_PROG)
817 ueCb->cellInfo[idx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
821 /* Add to actDeactCe lst */
822 rgSCHSCellAddToActDeactLst(cell,ueCb);
835 * @brief Handling of SCell Deactivation Tmr Expiry
839 * Function: rgSCHSCellDeactTmrExpry
840 * Purpose : Deactivating the SCell. a
841 * Clear all the Harq Procs associated with this
843 * Trigger Harq Reset to the respective MAC
844 * Set the state of the cell to Inactive
849 * @param[in] RgSchUeCellInfo *sCellInfo
854 PUBLIC Void rgSCHSCellDeactTmrExpry
856 RgSchUeCellInfo *sCellInfo
859 PUBLIC Void rgSCHSCellDeactTmrExpry(sCellInfo)
860 RgSchUeCellInfo *sCellInfo;
864 TRC3(rgSCHSCellDeactTmrExpry);
865 if (sCellInfo->ue->isScellExplicitDeAct == TRUE)
867 /* Deactivation Timer is not configured (infinity), thus send deactivation CE explicitly */
868 /* No doing Deactivaiton of LAA Cell */
869 if (FALSE == rgSCHLaaSCellEnabled(sCellInfo->cell))
871 rgSCHSCellTrigActDeact(sCellInfo->ue->cell, sCellInfo->ue, sCellInfo->sCellIdx, RGR_SCELL_DEACT);
875 printf (" !!!!!! Avoiding DEACT for UE %d because of LAA Cell !!!!!!!!!!!!! \n",
876 sCellInfo->ue->ueId);
882 /* Deactivation Timer is configured, thus assume that UE has deactivated */
883 rgSCHSCellDeActivation(sCellInfo);
890 * @brief This function handles the action of the SCell
894 * Function: rgSCHSCellTrigActDeact
896 * 1) Prepares SCELL ready for activation OR
897 * 2) Initiates activation of SCELL OR
898 * 3) Initiate deactivation of SCELL OR
900 * Invoked by:Cfg/Commn Scheduler
902 * @param[in] RgSchCellCb *cellCb
903 * @param[in] RgSchUeCb *ueCb
904 * @param[in] U8 sCellIdx
905 * @param[in] U8 action
907 * @return ROK/RFAILED
911 PUBLIC S16 rgSCHSCellTrigActDeact
919 PUBLIC S16 rgSCHSCellTrigActDeact(cell,ueCb,sCellIdx,action)
926 Inst inst = cell->instIdx;
929 TRC3(rgSCHSCellTrigActDeact);
932 (sCellIdx > RGR_MAX_SCELL_PER_UE))
934 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n", \
939 if(ueCb->cellInfo[sCellIdx] == NULLP)
941 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d ueId %d\n", \
942 sCellIdx,ueCb->ueId));
948 case RGR_SCELL_READY:
950 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_INACTIVE)
952 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for preparing SCell Idx %u for UE %u\n", \
953 ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
958 ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_READY;
959 //TODO_SID Activating the cell directly. Ignoring the ActCe procedure.
960 rgSCHSCellActivation(ueCb->cellInfo[sCellIdx]);
961 /* Setting allocCmnUlPdcch flag to FALSE, So that PDCCH allocation will be done
962 from UE Searchspace */
963 ueCb->allocCmnUlPdcch = FALSE;
964 printf("\n***** SCellIdx=%d state Changed to %d State \n",sCellIdx, ueCb->cellInfo[sCellIdx]->sCellState);
965 printf("\n***** SCellInfo Addr=%p state Changed to RG_SCH_SCELL_READY\n",(void*)ueCb->cellInfo[sCellIdx]);
971 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_READY)
973 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for activating SCell Idx %u for UE %u\n", \
974 ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
979 ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_ACTIVATED;
980 if (NULLP == ueCb->sCellActLnk.node)
982 /* Add only if UE is not already present in the activation/deactivation list */
983 rgSCHSCellAddToActDeactLst(cell,ueCb);
988 case RGR_SCELL_DEACT:
990 if(ueCb->cellInfo[sCellIdx]->sCellState != RG_SCH_SCELL_ACTIVE)
992 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid state %u for deactivating SCell Idx %u for UE %u\n", \
993 ueCb->cellInfo[sCellIdx]->sCellState, sCellIdx, ueCb->ueId));
998 ueCb->cellInfo[sCellIdx]->sCellState = RG_SCH_SCELL_TOBE_DEACTIVATED;
999 if (NULLP == ueCb->sCellActLnk.node)
1001 /* Add only if UE is not already present in the activation/deactivation list */
1002 rgSCHSCellAddToActDeactLst(cell,ueCb);
1009 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid action received for SCell Idx %u for UE %u\n", \
1010 sCellIdx, ueCb->ueId));
1020 * @brief SCell Activation of selected cell
1024 * Function: rgSCHSCellSelectForAct
1025 * Purpose : Perform Selection of secondary cell for activation
1027 * Invoked by:Cfg/Commn Scheduler
1029 * @param[in] RgSchCellCb *cellCb
1030 * @param[in] RgSchUeCb *ueCb
1032 * @return ROK/RFAILED
1036 PRIVATE S16 rgSCHSCellSelectForAct
1043 PRIVATE S16 rgSCHSCellSelectForAct(cell, ueCb)
1049 TRC3(rgSCHSCellSelectAndAct);
1051 for((*sCellIdx) = 1; (*sCellIdx) <= RG_SCH_MAX_SCELL; (*sCellIdx)++)
1053 if((ueCb->cellInfo[(*sCellIdx)] != NULLP) &&
1054 (ueCb->cellInfo[(*sCellIdx)]->sCellState == RG_SCH_SCELL_READY))
1063 * @brief SCell Activation of selected cell
1067 * Function: rgSCHSCellSelectAndActDeAct
1068 * Purpose : Perform Selection and Activation/Deactivation of secondary cell
1070 * Invoked by:Cfg/Commn Scheduler
1072 * @param[in] RgSchCellCb *cellCb
1073 * @param[in] RgSchUeCb *ueCb
1074 * @param[in] U8 action
1080 PUBLIC Void rgSCHSCellSelectAndActDeAct
1087 PUBLIC Void rgSCHSCellSelectAndActDeAct(pCell, ueCb, action)
1101 if(((ret = rgSCHSCellSelectForAct(pCell, ueCb, &sCellIdx)) == ROK)
1110 (ROK != (rgSCHSCellTrigActDeact(pCell, ueCb, sCellIdx, action))))
1112 RGSCHDBGERR(pCell->instIdx,(rgSchPBuf(pCell->instIdx), "SCell Actication failed"
1113 "for UE [%d] with SCellIdx [%d]\n", ueCb->ueId, sCellIdx));
1120 * @brief Handling of Scell Deletion
1124 * Function: rgSCHSCellDelUeSCell
1125 * Purpose : Perform Scell Deletion for an UE
1126 * : flush harqEnttiy of the given scell associated
1130 * Invoked by:Cfg module
1132 * @param[in] RgSchCellCb *cellCb
1133 * @param[in] RgSchUeCb *ueCb
1135 * @return ROK/RFAILED
1139 PUBLIC Void rgSCHSCellDelUeSCell
1141 RgSchCellCb *cellCb,
1146 PUBLIC Void rgSCHSCellDelUeSCell(cellCb,ueCb,sCellIdx)
1147 RgSchCellCb *cellCb;
1152 RgUeUlHqCb *ulHqEnt;
1153 Inst inst = cellCb->instIdx;
1154 RgSchUeCellInfo *sCellInfo;
1157 TRC3(rgSCHSCellDelUeSCell);
1158 sCellInfo = ueCb->cellInfo[sCellIdx];
1161 if(sCellInfo == NULLP)
1163 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Serv Cell not added to this Ue Scell Idx %d\
1165 sCellIdx,ueCb->ueId));
1169 rgSCHDbmDelUeCb(sCellInfo->cell, ueCb);
1170 ueUl = RG_SCH_CMN_GET_UL_UE(ueCb, sCellInfo->cell);
1172 if (NULLP != sCellInfo->sCellLnk.node)
1174 cmLListDelFrm(&sCellInfo->cell->sCellUeLst, &sCellInfo->sCellLnk);
1177 /* Clear Scheduler specific list for this UE from the
1178 * corresponding CELL */
1180 /*Updating 1BCS Value*/
1181 ueCb->f1bCsAVal = (ueCb->f1bCsAVal -
1182 rgSCHUtlGetMaxTbSupp(sCellInfo->txMode.txModeEnum));
1185 rgSCHUtlDelUeANFdbkInfo(ueCb,sCellIdx);
1188 rgSCHSCellDeActivation(sCellInfo);
1189 /* Release hqEnt mem */
1190 rgSCHDhmDelHqEnt(cellCb, &sCellInfo->hqEnt);
1192 ulHqEnt = &(ueUl->hqEnt);
1194 cellCb->sc.apis->rgSCHRgrSCellUeDel(sCellInfo, sCellInfo->ue);
1196 rgSCHUhmFreeUe(sCellInfo->cell, ulHqEnt);
1198 rgSCHUtlFreeSBuf(cellCb->instIdx,
1199 (Data**)(&(sCellInfo)), (sizeof(RgSchUeCellInfo)));
1201 ueCb->cellInfo[sCellIdx] = NULLP;
1207 * @brief Handling of UE Deletion
1211 * Function: rgSCHSCellDelUe
1212 * Purpose : Perform UE Deletion
1213 * : Delete all the SCells added for this UE
1214 * : flush harqEnttiy of all scells associated
1218 * Invoked by:Cfg module
1220 * @param[in] RgSchCellCb *cellCb
1221 * @param[in] RgSchUeCb *ueCb
1222 * @return ROK/RFAILED
1226 PUBLIC S16 rgSCHSCellDelUe
1228 RgSchCellCb *cellCb,
1232 PUBLIC S16 rgSCHSCellDelUe(cellCb,ueCb)
1233 RgSchCellCb *cellCb;
1238 TRC3(rgSCHSCellDelUe);
1240 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1242 rgSCHSCellDelUeSCell(cellCb,ueCb,idx);
1251 * @brief Handling of PCqi cfg fro a scell
1255 * Function: rgSCHSCellPCqiCfg
1257 * : Delete all the SCells added for this UE
1258 * : flush harqEnttiy of all scells associated
1261 * - For SCell-specific Periodic CQI related configuration,
1262 * - If Periodic CQI/PMI is configured,
1263 * - Update SCell with the configured values.
1264 * - Update the CQI offset and CQI perodicity information
1267 * - For SCell-specific Periodic RI related configuration,
1268 * - If Periodic RI is configured,
1269 * - Update SCell with the configured values.
1270 * - Update the RI offset and RI perodicity information
1273 * Invoked by:Cfg module
1275 * @param[in] RgSchCellCb *cellCb
1276 * @param[in] RgSchUeCb *ueCb
1277 * @return ROK/RFAILED
1281 PUBLIC S16 rgSCHSCellPCqiCfg
1283 RgSchCellCb *priCellCb,
1284 RgSchCellCb *secCellCb,
1286 RgrUePrdDlCqiCfg *cqiCfg,
1287 CmLteUeCategory ueCat,
1291 PUBLIC S16 rgSCHSCellPCqiCfg(priCellCb,secCellCb,ueCb,cqiCfg,ueCat,sCellIdx)
1292 RgSchCellCb *priCellCb;
1293 RgSchCellCb *secCellCb;
1295 RgrUePrdDlCqiCfg *cqiCfg;
1296 CmLteUeCategory ueCat;
1300 U8 j; /*Bandwidth Parts*/
1303 Inst inst = priCellCb->instIdx;
1305 RgSchUeCellInfo *sCellInfo;
1306 RgSchUePCqiCb *cqiCb = NULLP;
1308 TRC3(rgSCHSCellPCqiCfg);
1310 RGSCHDBGINFO(priCellCb->instIdx, (rgSchPBuf(priCellCb->instIdx),
1311 "rgSCHSCellPCqiCfg cellId =%d, ueId = %d, CfgType =%d\n",
1312 secCellCb->cellId, ueCb->ueId, cqiCfg->type));
1314 if((sCellIdx < 1) ||
1315 (sCellIdx > RGR_MAX_SCELL_PER_UE))
1317 RGSCHDBGERRNEW(inst, (rgSchPBuf(inst),"Invalid Serv Cell Idx %d\n",
1322 sCellInfo = ueCb->cellInfo[sCellIdx];
1324 cqiCb = &ueCb->cellInfo[sCellIdx]->cqiCb;
1325 cqiCb->servCellInfo = sCellInfo;
1327 /* Periodic CQI is setup */
1328 if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
1330 /* 1. Copy the Received CQI Cfg parameters to ueCb */
1331 cmMemcpy((U8 *)&cqiCb->cqiCfg, (U8 *)cqiCfg,
1332 sizeof(RgrUePrdDlCqiCfg));
1334 /* 2. Compute Periodic CQI Periodicity and subframe offset */
1336 rgSCHUtlGetCfgPerOff(RG_SCH_FDD_PCQI_TBL, cqiCfg->cqiSetup.cqiPCfgIdx,
1337 &cqiCb->cqiPeri, &cqiCb->cqiOffset);
1339 rgSCHUtlGetCfgPerOff( RG_SCH_TDD_PCQI_TBL,
1340 cqiCfg->cqiSetup.cqiPCfgIdx,
1341 &cqiCb->cqiPeri, &cqiCb->cqiOffset);
1345 RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx),
1346 "\n rgSCHSCellPCqiCfg(): CQI Peri=%d, CQI Offset=%d",
1347 cqiCb->cqiPeri,cqiCb->cqiOffset));
1349 if(RGR_UE_PCQI_SB_REP == cqiCfg->cqiSetup.cqiRepType)
1351 U8 k; /*SubBand Size (RB) */
1352 RG_SCH_GET_CQI_J_VAL(secCellCb->bwCfg.dlTotalBw, j);
1353 RG_SCH_GET_CQI_K_VAL(secCellCb->bwCfg.dlTotalBw, k);
1354 cqiCb->J = j; /*Number of Bandwidth Parts*/
1355 /*h: reporting instances required for a complete CQI/PMI report */
1356 /*j:Number of bandwidth parts; k: Subband Size*/
1357 cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1;
1358 /* ccpu00140905- L-size is coming as 3 for 100Rbs where it should be 2*/
1359 temp = RGSCH_CEIL(secCellCb->bwCfg.dlTotalBw, (j*k));
1360 cqiCb->label = (temp & (temp-1)) ?
1361 (1+ rgSCHUtlLog32bitNbase2(temp)) : rgSCHUtlLog32bitNbase2(temp);
1365 /* Wideband Cqi Rep Type */
1366 cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_1;
1368 cqiCb->cqiLstEnt.node=(PTR)cqiCb;
1369 cqiCb->isCqiIgnoByCollsn = FALSE;
1372 /* 4. Rank Indicator Cfg handler */
1373 /* 1. Rank Indicator is enabled */
1374 if(cqiCfg->cqiSetup.riEna)
1376 rgSCHUtlGetCfgPerOff(RG_SCH_RI_TBL,
1377 cqiCfg->cqiSetup.riCfgIdx,
1378 &cqiCb->riPeri, &cqiCb->riOffset);
1380 RGSCHDBGINFO(priCellCb->instIdx,(rgSchPBuf(priCellCb->instIdx),
1381 "\n rgSCHSCellPCqiCfg(): RI Peri=%d, RI Offset=%d",
1382 cqiCb->riPeri,cqiCb->riOffset));
1384 if(ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_3
1385 || ueCb->cellInfo[sCellIdx]->txMode.txModeEnum == RGR_UE_TM_4)
1387 if (secCellCb->numTxAntPorts ==2)
1389 cqiCb->riNumBits = 1;
1391 else if(secCellCb->numTxAntPorts ==4)
1393 if(ueCat == CM_LTE_UE_CAT_8)
1395 cqiCb->riNumBits = 3;
1397 else if((ueCat == CM_LTE_UE_CAT_5) ||
1398 (ueCat == CM_LTE_UE_CAT_6) || CM_LTE_UE_CAT_7)
1400 cqiCb->riNumBits = 2;
1404 cqiCb->riNumBits = 1;
1408 cqiCb->riLstEnt.node=(PTR) cqiCb;
1409 cqiCb->isRiIgnoByCollsn = FALSE;
1415 sCellInfo->cqiCb.cqiCfg.type = RGR_SCH_PCQI_REL;
1417 /* Setting the indices to invalid during
1418 scell addition. These indices will be set during
1420 cqiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
1421 cqiCb->riDist = RG_SCH_INVALID_IDX;
1422 cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
1429 * @brief Handling of Ue Reset from common scheduler
1433 * Function: rgSCHSCellDlUeReset
1434 * Purpose: Call scheudler type spcefic UE RESET
1435 * for all the secondary cells
1437 * Invoked by: CommonScheduler
1439 * @param[in] RgSchCellCb* cell
1440 * @param[in] RgSchUeCb* ue
1445 PUBLIC Void rgSCHSCellDlUeReset
1451 PUBLIC Void rgSCHSCellDlUeReset(cell, ue)
1456 RgSchCmnCell *cellSch;
1457 TRC3(rgSCHSCellDlUeReset);
1459 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1461 if(ue->cellInfo[idx] != NULLP)
1463 cellSch = RG_SCH_CMN_GET_CELL(ue->cellInfo[idx]->cell);
1464 cellSch->apisDl->rgSCHDlUeReset(ue->cellInfo[idx]->cell, ue);
1465 rgSCHSCellDeActivation(ue->cellInfo[idx]);
1466 ue->cellInfo[idx]->sCellState = RG_SCH_SCELL_INACTIVE;
1474 * @brief Handling of LC Cfg from common scheduler
1478 * Function: rgSCHSCellDlLcCfg
1479 * Purpose: Call scheudler type spcefic LC config
1480 * for all the secondary cells
1482 * Invoked by: CommonScheduler
1484 * @param[in] RgSchCellCb* cell
1485 * @param[in] RgSchUeCb* ue
1490 PUBLIC Void rgSCHSCellDlLcCfg
1497 PUBLIC Void rgSCHSCellDlLcCfg(cell, ue, svc)
1503 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1504 TRC3(rgSCHSCellDlLcCfg);
1505 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1507 if(ue->cellInfo[idx] != NULLP)
1509 cellSch->apisDl->rgSCHRgrDlLcCfg(ue->cellInfo[idx]->cell, ue, svc,NULLP,NULLP);
1516 * @brief Handling of LC Delete from common scheduler
1520 * Function: rgSCHSCellDlLcDel
1521 * Purpose: Call scheudler type spcefic bo update handler
1522 * for all the secondary cells
1524 * Invoked by: CommonScheduler
1526 * @param[in] RgSchCellCb* cell
1527 * @param[in] RgSchUeCb* ue
1532 PUBLIC Void rgSCHSCellDlLcDel
1539 PUBLIC Void rgSCHSCellDlLcDel(cell, ue, svc)
1545 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1546 TRC3(rgSCHSCellDlLcDel);
1547 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1549 if(ue->cellInfo[idx] != NULLP)
1551 cellSch->apisDl->rgSCHFreeDlLc(ue->cellInfo[idx]->cell, ue, svc);
1558 * @brief Handling of Bo update from common scheduler
1562 * Function: rgSCHSCellDlDedBoUpd
1563 * Purpose: Call scheudler type spcefic bo update handler
1564 * for all the secondary cells
1566 * Invoked by: CommonScheduler
1568 * @param[in] RgSchCellCb* cell
1569 * @param[in] RgSchUeCb* ue
1574 PUBLIC Void rgSCHSCellDlDedBoUpd
1581 PUBLIC Void rgSCHSCellDlDedBoUpd(cell, ue, svc)
1587 RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
1588 TRC3(rgSCHSCellDlDedBoUpd);
1590 /* If this is not invoked by PCell, then
1591 invoke the call to PCell handler
1592 This happens during finalization if LC Bo becomes zero*/
1593 if (ue->cell != cell)
1595 cellSch->apisDl->rgSCHDlDedBoUpd(ue->cell, ue, svc);
1597 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1599 if((ue->cellInfo[idx] != NULLP) &&
1600 (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE) &&
1601 (ue->cellInfo[idx]->cell != cell))
1603 cellSch->apisDl->rgSCHDlDedBoUpd(ue->cellInfo[idx]->cell, ue, svc);
1610 * @brief Compare two CQI CB configs are return the result
1614 * Function: rgSCHUtlSCellCmpCqiCfg
1615 * Purpose : Compare priority levels of cqiCb1 and cqiCb2
1616 * and set the isCqiIgnoByCollsn to TRUE for the
1617 * cqiCb which has lower priority
1618 * Invoked by:scell module
1620 * @param[in] RgSchUePCqiCb *cqiCb1
1621 * @param[in] RgSchUePCqiCb *cqiCb2
1622 * @return U8 cqiCb cell idx which has the higher priority
1626 PRIVATE U8 rgSCHUtlSCellCmpCqiCfg
1628 RgSchUePCqiCb *cqiCb1,
1629 RgSchUePCqiCb *cqiCb2
1632 PRIVATE U8 rgSCHUtlSCellCmpCqiCfg(cqiCb1, cqiCb2)
1633 RgSchUePCqiCb *cqiCb1;
1634 RgSchUePCqiCb *cqiCb2;
1637 RgSchUePCqiCb *retCqiCb;
1638 TRC3(rgSCHUtlSCellCmpCqiCfg);
1639 /* Collision rules are defined in TS 36.213,7.2.2 */
1640 /* RI, WB first PMI > WB CQI > SB CQI */
1641 /* As of now only taking care of RI > WB CQI > SB CQI */
1643 if (cqiCb1->prioLvl > cqiCb2->prioLvl)
1645 cqiCb2->isCqiIgnoByCollsn = TRUE;
1646 cqiCb1->isCqiIgnoByCollsn = FALSE;
1649 else if (cqiCb2->prioLvl > cqiCb1->prioLvl)
1651 cqiCb1->isCqiIgnoByCollsn = TRUE;
1652 cqiCb2->isCqiIgnoByCollsn = FALSE;
1657 if (cqiCb1->servCellInfo->sCellIdx > cqiCb2->servCellInfo->sCellIdx)
1659 cqiCb1->isCqiIgnoByCollsn = TRUE;
1660 cqiCb2->isCqiIgnoByCollsn = FALSE;
1665 cqiCb2->isCqiIgnoByCollsn = TRUE;
1666 cqiCb1->isCqiIgnoByCollsn = FALSE;
1671 RETVALUE(retCqiCb->servCellInfo->sCellIdx);
1675 * @brief Handling of collision of CQI types between serving cells
1679 * Function: rgSCHUtlSCellHndlCqiCollsn
1680 * Purpose : Takes care of collision clauses specified in 36.213 7.2.2 Rel 10
1681 * and selects next nearest cqiCb
1682 * Invoked by:Cfg module
1684 * @param[in] RgSchCellCb *cellCb
1685 * @param[in] RgSchUeCb *ueCb
1686 * @return ROK/RFAILED
1690 PUBLIC S16 rgSCHUtlSCellHndlCqiCollsn
1692 RgSchUePCqiCb *cqiCb
1695 PUBLIC S16 rgSCHUtlSCellHndlCqiCollsn(cqiCb)
1696 RgSchUePCqiCb *cqiCb;
1699 U32 nPCqiServCellIdx;
1703 RgSchCellCb *priCellCb = cqiCb->servCellInfo->ue->cell;
1704 RgSchUeCb *ueCb = cqiCb->servCellInfo->ue;
1708 CmLteTimingInfo timingInfo;
1710 TRC3(rgSCHUtlSCellHndlCqiCollsn);
1713 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1715 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1716 TFU_RECPREQ_DLDELTA);
1719 RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1721 cqiCb->isCqiIgnoByCollsn = FALSE;
1723 pCqiTrIdx = cqiCb->nCqiTrIdx;
1724 nPCqiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1725 /* Handle wrap around case */
1726 if (pCqiTrIdx < crntSfIdx)
1728 pCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1730 minPCqiTrIdx = pCqiTrIdx;
1732 for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1734 /* If a serving cell is configured */
1735 if(ueCb->cellInfo[cellIdx] != NULLP)
1737 /* If the serving cell is in ACTIVE state and
1738 If it is not the same serving cell as cqiCb for which
1739 collision is being checked */
1740 if ((ueCb->cellInfo[cellIdx]->sCellState == RG_SCH_SCELL_ACTIVE)&&
1741 (cellIdx != cqiCb->servCellInfo->sCellIdx))
1743 scellPCqiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nCqiTrIdx;
1745 /* Handle wrap around case */
1746 if (scellPCqiTrIdx < crntSfIdx)
1748 scellPCqiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1751 /* If cqiCb->isCqiIgnoByCollsn is TRUE then a higher prio cqiCb
1752 is already found so need to compare */
1753 if ((FALSE == ueCb->cellInfo[cellIdx]->cqiCb.isCqiIgnoByCollsn) &&
1754 (FALSE == cqiCb->isCqiIgnoByCollsn) &&
1755 (scellPCqiTrIdx == pCqiTrIdx))
1757 /* Handle Collision */
1758 /* set isCqiIgnoByCollsn to TRUE for low prio CQI Rep type */
1759 nPCqiServCellIdx = rgSCHUtlSCellCmpCqiCfg(&ueCb->cellInfo[cellIdx]->cqiCb,cqiCb);
1761 else if (scellPCqiTrIdx < minPCqiTrIdx)
1763 minPCqiTrIdx = scellPCqiTrIdx;
1764 nPCqiServCellIdx = cellIdx;
1768 /* If all of the num of configured scells are checked then break */
1769 if (sCellCnt == ueCb->numSCells)
1777 /* Set the next expected Cqi into nPCqiCb */
1778 idx = ((nPCqiServCellIdx)& (CM_LTE_MAX_CELLS -1));
1779 ueCb->nPCqiCb = &ueCb->cellInfo[idx]->cqiCb;
1786 * @brief Handling of collision of RI types between serving cells
1790 * Function: rgSCHUtlSCellHndlRiCollsn
1791 * Purpose : Takes care of collision clauses specified in 36.213 7.2.2 Rel 10
1792 * and selects next nearest cqiCb
1793 * Invoked by:Cfg module
1795 * @param[in] RgSchCellCb *cellCb
1796 * @param[in] RgSchUeCb *ueCb
1797 * @return ROK/RFAILED
1801 PUBLIC S16 rgSCHUtlSCellHndlRiCollsn
1803 RgSchUePCqiCb *cqiCb
1806 PUBLIC S16 rgSCHUtlSCellHndlRiCollsn(cqiCb)
1807 RgSchUePCqiCb *cqiCb;
1810 U32 nPRiServCellIdx;
1814 RgSchCellCb *priCellCb = cqiCb->servCellInfo->ue->cell;
1815 RgSchUeCb *ueCb = cqiCb->servCellInfo->ue;
1819 CmLteTimingInfo timingInfo;
1820 TRC3(rgSCHUtlSCellHndlRiCollsn);
1823 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo, TFU_DELTA);
1825 RG_SCH_ADD_TO_CRNT_TIME(priCellCb->crntTime, timingInfo,
1826 TFU_RECPREQ_DLDELTA);
1829 RG_SCH_GET_IDX_PCQISRSSR(timingInfo, crntSfIdx);
1831 pRiTrIdx = cqiCb->nRiTrIdx + cqiCb->riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1833 /* Handle wrap around case */
1834 if (pRiTrIdx < crntSfIdx)
1836 pRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1839 cqiCb->isRiIgnoByCollsn = FALSE;
1840 nPRiServCellIdx = cqiCb->servCellInfo->sCellIdx;
1841 minPRiTrIdx = pRiTrIdx;
1843 for (cellIdx =0; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
1845 /* If a serving cell is configured */
1846 if(ueCb->cellInfo[cellIdx] != NULLP)
1848 /* If the serving cell is in ACTIVE state and
1849 If it is not the same serving cell as cqiCb for which
1850 collision is being checked */
1851 if ((ueCb->cellInfo[cellIdx]->sCellState == RG_SCH_SCELL_ACTIVE)&&
1852 (cellIdx != cqiCb->servCellInfo->sCellIdx))
1854 scellPRiTrIdx = ueCb->cellInfo[cellIdx]->cqiCb.nRiTrIdx +
1855 ueCb->cellInfo[cellIdx]->cqiCb.riDist * RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1857 /* Handle wrap around case */
1858 if (scellPRiTrIdx < crntSfIdx)
1860 scellPRiTrIdx += RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1863 /* If cqiCb->isRiIgnoByCollsn is TRUE then a higher prio cqiCb
1864 is already found so need to compare */
1865 if ((FALSE == ueCb->cellInfo[cellIdx]->cqiCb.isRiIgnoByCollsn) &&
1866 (FALSE == cqiCb->isRiIgnoByCollsn) &&
1867 (scellPRiTrIdx == pRiTrIdx))
1869 /* Handle Collision */
1870 /* set isRiIgnoByCollsn to TRUE for low prio CQI Rep type */
1871 if (cqiCb->servCellInfo->sCellIdx < (ueCb->cellInfo[cellIdx]->sCellIdx))
1873 ueCb->cellInfo[cellIdx]->cqiCb.isRiIgnoByCollsn = TRUE;
1877 cqiCb->isRiIgnoByCollsn = TRUE;
1880 else if (scellPRiTrIdx < minPRiTrIdx)
1882 minPRiTrIdx = scellPRiTrIdx;
1883 nPRiServCellIdx = cellIdx;
1887 /* If all of the num of configured scells are checked then break */
1888 if (sCellCnt == ueCb->numSCells)
1896 /* Set the next expected Cqi into nPCqiCb */
1897 ueCb->nPRiCb = &ueCb->cellInfo[nPRiServCellIdx]->cqiCb;
1901 #endif/*TFU_UPGRADE*/
1904 * @brief Checking whethter the scell is active or not
1908 * Function: rgSCHSCellIsActive
1909 * Purpose: Check the Scell is in active state or not
1912 * Invoked by: SpecificScheduler
1914 * @param[in] RgSchCellCb* cell
1915 * @param[in] RgSchUeCb* ue
1920 PUBLIC S16 rgSCHSCellIsActive
1926 PUBLIC S16 rgSCHSCellIsActive(cell, ue)
1931 S16 retVal = RFAILED;
1932 TRC3(rgSCHSCellIsActive);
1934 for(U8 idx = 1; idx <= RG_SCH_MAX_SCELL ; idx++)
1936 if((ue->cellInfo[idx] != NULLP) &&
1937 (ue->cellInfo[idx]->cell->cellId == cell->cellId)&&
1938 (ue->cellInfo[idx]->sCellState == RG_SCH_SCELL_ACTIVE))
1948 * @brief Function to check for Acell Activation Trigered.
1952 * Function : rgSCHIsActvReqd
1953 * This function will check for Secondary cell activation criteria
1954 * If met this will return TRUE else FALSE
1956 * @param[in] RgSchCellCb *cell
1957 * @param[in] RgSchUeCb *ue
1962 PUBLIC Bool rgSCHIsActvReqd
1968 PUBLIC Bool rgSCHIsActvReqd(cell, ue)
1973 TRC2(rgSCHIsActvReqd)
1974 /* Check if remBoCnt in this UE is greater than ZERO for sufficient number of
1975 * Scheduling TTIs. If yes then We should activate a secondary cell to handle
1977 if(ue->remBoCnt == RG_SCH_ACTIVATION_COUNT)
1987 /**********************************************************************
1990 **********************************************************************/