[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[o-du/l2.git] / src / 5gnrsch / rg_sch_tom.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Entry point fucntions
26   
27      File:     rg_sch_tom.c 
28   
29 **********************************************************************/
30
31 /** @file rg_sch_tom.c 
32 @brief This module does processing related to handling of lower interface APIs 
33 invoked by PHY towards scheduler.
34 */
35
36 /* header include files -- defines (.h) */
37 #include "common_def.h"
38 #include "tfu.h"           /* RGU defines */
39 #include "lrg.h"           /* layer management defines for LTE-MAC */
40 #include "rgr.h"           /* layer management defines for LTE-MAC */
41 #include "rgm.h"           /* layer management defines for LTE-MAC */
42 #include "rg_env.h"        /* defines and macros for MAC */
43 #include "rg_sch_err.h"    /* defines and macros for MAC */
44 #include "rg_sch_inf.h"    /* defines and macros for MAC */
45 #include "rg_sch.h"        /* defines and macros for MAC */
46 #include "rg_sch_cmn.h"    /* typedefs for MAC */
47
48
49 /* header/extern include files (.x) */
50 #include "tfu.x"           /* RGU types */
51 #include "lrg.x"           /* layer management typedefs for MAC */
52 #include "rgr.x"           /* layer management typedefs for MAC */
53 #include "rgm.x"           /* layer management typedefs for MAC */
54 #include "rg_sch_inf.x"    /* typedefs for Scheduler */
55 #include "rg_sch.x"        /* typedefs for MAC */
56 #include "rg_sch_cmn.x"    /* typedefs for MAC */
57 #ifdef EMTC_ENABLE
58 #include "rg_sch_emtc_ext.x"
59 #endif 
60 uint8_t rgSCHCmnCalcPcqiBitSz(RgSchUeCb    *ueCb,uint8_t numTxAnt);
61 S16 rgSCHDhm5gtfHqFdbkInd(RgSchUeCb *ue,RgSchCellCb *cell,CmLteTimingInfo timingInfo,TfuHqFdbk fdbk,RgSchErrInfo *err);
62 /* local defines */
63 #ifdef EMTC_ENABLE
64 Bool rgSCHEmtcChkEmtcUe ARGS(
65 (
66 RgSchCellCb  *cell,
67 uint16_t          rapId
68 ));
69 Void rgSchTomTtiEmtcSched ARGS(
70 (
71 RgSchCellCb        *cell
72 ));
73
74 S16 rgSCHEmtcRamVldtProcRaReq
75 (
76 uint8_t              raRntiCnt,
77 uint8_t              raReqCnt,
78 RgSchCellCb     *cell, 
79 TfuRaReqIndInfo *raReqInd,
80 RgSchUeCb       *ue,
81 Bool            *isEmtcUe,  
82 RgSchErrInfo    *err
83 );
84 Void rgSCHEmtcUpdCqiInfo
85 (
86 RgSchUeCb       *ue,
87 RgSchUePCqiCb   *cqiCb,
88 uint16_t             *cqiIdx
89 );
90 Void rgSCHEmtcUpdSRInfo
91 (
92 RgSchUeCb       *ue,
93 uint16_t             *srIdx
94 );
95 Void rgSCHCmnEmtcHdlCrcFailInd
96 (
97 RgSchCellCb       *cell,
98 RgSchRaCb         *raCb
99 );
100 S16 rgSCHEmtcTomUtlProcAtCrc
101 (
102 RgSchCellCb       *cell,
103 CmLteTimingInfo   crntHiDci0Frm,
104 TfuCntrlReqInfo   *cntrlInfo,
105 RgSchErrInfo      *err
106 );
107 Void rgSCHEmtcInitUeRecpReqLst
108 (
109 TfuRecpReqInfo  *recpReqInfo
110 );
111 Void rgSCHEmtcFillPucchRecpInfo
112 (
113 RgSchCellCb       *cell,
114 RgSchDlHqProcCb   *hqCb,
115 uint16_t               *hqRes
116 );
117 Bool rgSCHEmtcAddRecpInfoToLst
118 (
119 RgSchDlHqProcCb   *hqCb,
120 TfuRecpReqInfo    *recpReqInfo,
121 TfuUeRecpReqInfo  *pucchRecpInfo,
122 Bool              isEmtcUe
123 );
124 Void rgSCHEmtcWillUeRptCqi
125 (
126 RgSchUeCb         *ue, 
127 Bool              *willUeRprtCqi  
128 );
129 Void rgSchEmtcTomTtiCnsldtSfAlloc
130 (
131 RgSchCellCb        *cell
132 );
133
134 S16 rgSchEmtcTomTtiL1DlAndUlCfg
135 (
136 RgSchCellCb        *cell,
137 RgTfuCntrlReqInfo  *cntrlInfo
138 );
139
140 S16 rgSCHTomEmtcUtlFillDatRecpReq
141 (
142 TfuRecpReqInfo       *recpReqInfo,
143 RgSchCellCb          *cell,
144 uint16_t                  validIdx,
145 RgSchErrInfo         *err
146 );
147
148 S16 rgSCHEmtcTomUtlFillHqFdbkRecpReq
149 (
150 TfuRecpReqInfo          *recpReqInfo,
151 RgSchCellCb             *cell,
152 uint16_t                  validIdx,
153 RgSchErrInfo            *err
154 );
155
156 S16 rgSCHEmtcDhmRlsDlsfHqProc
157 (
158 RgSchCellCb          *cell,
159 CmLteTimingInfo      timingInfo
160 );
161
162 Void rgSCHEmtcCmnUlSch
163 (
164 RgSchCellCb  *cell
165 );
166
167 #ifdef RG_ULSCHED_AT_CRC
168 S16 rgSCHEmtcTomUtlProcDlSfAtCrc
169 (
170 RgSchEmtcDlSf        *ulSf,
171 CmLteTimingInfo      crntUlFrm,
172 RgSchCellCb          *cell,
173 TfuCntrlReqInfo      *cntrlInfo,
174 RgSchErrInfo         *err
175 );
176
177 RgSchEmtcDlSf* rgSCHEmtcUtlSubFrmGet
178 (
179 RgSchCellCb            *cell,
180 CmLteTimingInfo        frm
181 );
182 #endif
183
184 uint32_t gDlMpdcchBlank;
185 uint32_t gUlMpdcchBlank;
186 S16 rgSCHUtlIotResPrcTti
187 (
188 RgSchCellCb *cell
189 );
190
191 #endif
192
193 RgSchUeCb* rgSCHCmnGetHoUe
194 (
195 RgSchCellCb           *cell,
196 uint16_t                   rapId
197 );
198 RgSchUeCb* rgSCHCmnGetPoUe
199 (
200 RgSchCellCb           *cell,
201 uint16_t                   rapId,
202 CmLteTimingInfo       timingInfo
203 );
204 S16 rgSCHTomUtlFillDatAperRecpReq ARGS(
205 (
206 RgSchCellCb       *cell,
207 uint8_t                cqiReq,
208 RgSchUlAlloc      *alloc,
209 TfuUeRecpReqInfo  *datRecpInfo,
210 CmLteTimingInfo   *timeInfo,
211 Bool              hqPres,
212 uint16_t                validIdx
213 ));
214
215 S16 rgSCHTomUtlFillDatPriRecpReq ARGS(
216 (
217 RgSchCellCb       *cell,
218 RgSchUlAlloc      *alloc,
219 TfuUeRecpReqInfo  *datRecpInfo,
220 CmLteTimingInfo   *timeInfo,
221 Bool              hqPres,
222 uint16_t               validIdx
223 ));
224
225 S16 rgSCHTomUtlFillDatPCqiRecpReq ARGS(
226 (
227 RgSchCellCb       *cell,
228 RgSchUlAlloc      *alloc,
229 TfuUeRecpReqInfo  *datRecpInfo,
230 CmLteTimingInfo   *timeInfo,
231 Bool              hqPres, 
232 uint16_t                validIdx
233 ));
234
235 S16 rgSCHTomUtlFillDatSrsRecpReq ARGS(
236 (
237 RgSchCellCb       *cell,
238 RgSchUlAlloc      *alloc,
239 TfuUeRecpReqInfo  *datRecpInfo,
240 CmLteTimingInfo   *timeInfo,
241 Bool              hqPres
242 ));
243
244 void schFillCrntTime( SlotTimingInfo slotInd,Inst schInst);
245
246 #ifdef CA_DBG
247 uint32_t delayedApiCnt;
248 uint32_t gPCellTb1AckCount=0,gPCellTb2AckCount=0,gPCellTb1NackCount=0,gPCellTb2NackCount=0;
249 uint32_t gSCellSchedCount=0,gPrimarySchedCount=0;
250 uint32_t gSCellTb1AckCount=0,gSCellTb2AckCount=0,gSCellTb1NackCount=0,gSCellTb2NackCount=0;
251 uint32_t gPCellTb1DtxCount = 0, gPCellTb2DtxCount = 0, gSCellTb1DtxCount = 0, gSCellTb2DtxCount = 0;
252 uint32_t gHqFdbkCount = 0;
253
254  
255
256 uint32_t gCqiRecpCount = 0;
257 uint32_t gCqiRecpPuschCount = 0;
258 uint32_t gCqiRcvdCount = 0;
259 Bool gF1bCsPres = FALSE;
260 uint32_t  gRiReqCount = 0;
261 uint32_t gCqiReqCount = 0;
262 uint32_t gF1bCsCount = 0;
263 uint32_t gACqiRcvdCount = 0;
264 uint32_t gCqiReptToAppCount = 0;
265 uint32_t gRawACqiCount= 0;
266 uint32_t gCqiDropCount,gPucchDropCount;
267 uint32_t gCqiPucchLowSnrDropCount,gCqiPucchConfMaskDropCount,gCqiPuschConfMaskDropCount;
268 uint32_t gDci0Count = 0;
269 uint32_t gUlCrcFailCount = 0;
270 uint32_t gUlCrcPassCount = 0;
271 uint32_t gPuschCqiDropCount = 0;
272 uint32_t gCaDbgCaFrmt = 0;
273 uint32_t gCaDbgNonCaFrmt = 0;
274 uint32_t gPcellZeroBoOcc=0,gScellZeroBoOcc=0, dbgDelayedDatReqInMac=0,gDropDatReqCnt=0, gIccPktRcvrMemDropCnt=0;
275 #endif
276
277 #ifdef EMTC_ENABLE
278 uint32_t gUlCrcFailCounter = 0;
279 uint32_t gUlCrcPassCounter = 0;
280 #endif
281
282 #ifdef RG_5GTF
283 uint32_t gUl5gtfPdcchSend;
284 #endif
285
286 #ifdef UNUSED_FUNC
287 #ifdef TFU_UPGRADE
288 static S16 rgSCHTomUtlFillCqiSrsWithSr ARGS
289 ((
290 RgSchCellCb       *cell,
291 RgSchUeCb         *ue,
292 TfuRecpReqInfo    *recpReqInfo,
293 TfuUeRecpReqInfo  *pucchRecpInfo,
294 uint16_t               validIdx
295 ));
296 static Bool rgSCHTomUtlFillDatHarqRecpReq ARGS
297 ((
298 RgSchCellCb       *cell,
299 RgSchUlAlloc      *alloc,
300 TfuUeRecpReqInfo  *datRecpInfo,
301 TfuRecpReqInfo    *recpReqInfo
302 ));
303 static S16 rgSCHTomUtlFillSrRecpReq ARGS((
304 TfuRecpReqInfo   *recpReq,
305 RgSchCellCb      *cell,
306 uint16_t              validIdx,
307 RgSchErrInfo     *err));
308 static S16 rgSCHTomUtlFillRiRecpReq ARGS((
309 TfuRecpReqInfo   *recpReq,
310 RgSchCellCb      *cell,
311 uint16_t              validIdx,
312 RgSchErrInfo     *err));
313 static S16 rgSCHTomUtlFillPcqiRecpReq ARGS((
314 TfuRecpReqInfo   *recpReq,
315 RgSchCellCb      *cell,
316 uint16_t              validIdx,
317 RgSchErrInfo     *err));
318 static S16 rgSCHTomUtlFillSrsRecpReq ARGS((
319 TfuRecpReqInfo   *recpReq,
320 RgSchCellCb      *cell,
321 uint16_t              validIdx,
322 RgSchErrInfo     *err));
323 static S16 rgSCHTomUtlGenIndices ARGS((
324 uint32_t      label,
325 uint8_t        posM,
326 uint8_t        valN,
327 uint8_t        valK,
328 TfuSubbandInfo*    sbInfo));
329 #endif
330 static S16 rgSCHTomUtlFillCqiRiRecpReq ARGS(
331 (
332 TfuRecpReqInfo       *recpReqInfo,
333 RgSchCellCb          *cell,
334 uint16_t                  validIdx, 
335 RgSchErrInfo         *err
336 ));
337 static Void rgSchTomFillCellTtiInfo ARGS
338 ((
339 TfuTtiIndInfo      *ttiInd,
340 Inst               schInst,
341 uint8_t                 *nCell,
342 RgSchCellCb        *cells[]
343 ));
344 #endif
345
346 /* local typedefs */
347 uint32_t rgBwAlloInfo[RGSCH_NUM_SUB_FRAMES]; /* Num of Rbs Allocated in each SF */ 
348 uint32_t rgBwAlcnt[RGSCH_NUM_SUB_FRAMES];   /*Num of times Allocation done in each Subframe */
349
350 /* local externs */
351 /* rg006.201: [ccpu000111706, ccpu00112394]: Separated UL and DL TTI
352  * processing */
353 #ifdef LTE_L2_MEAS
354    uint64_t     glblTtiCnt = 0;
355 #endif
356 uint32_t ri1Cnt ;
357 uint32_t ri2Cnt ;  
358 uint32_t gDlNumUePerTti[20] = {0};
359 uint32_t gUlNumUePerTti[20] = {0};
360 static S16 rgSCHTomUtlProcDlSf ARGS((
361          RgSchDlSf        *dlSf,
362          RgSchDlSf        *ulSf,
363          RgSchCellCb      *cell,
364          RgTfuCntrlReqInfo *cntrlInfo,
365          RgSchErrInfo     *err));
366 #ifdef RG_ULSCHED_AT_CRC
367 static S16 rgSCHTomUtlProcDlSfAtCrc ARGS((
368          RgSchDlSf        *ulSf,
369          CmLteTimingInfo  crntUlFrm,
370          RgSchCellCb      *cell,
371          TfuCntrlReqInfo  *cntrlInfo,
372          RgSchErrInfo     *err));
373 #endif /* RG_ULSCHED_AT_CRC */
374 #ifdef LTE_TDD
375 #ifdef TFU_UPGRADE
376 static S16 rgSCHTomUtlPrcUlTddSpclSf ARGS((
377          RgSchCellCb        *cell,
378          RgSchErrInfo       *err));
379 #endif /* TFU_UPGRADE */
380 #endif
381 static S16 rgSCHTomUtlFillPhich ARGS((
382          RgSchCellCb     *cell,
383          TfuCntrlReqInfo  *cntrlInfo,
384          RgSchDlSf        *dlSf,
385          RgSchErrInfo     *err));
386
387 static S16 rgSCHTomUtlFillDlPdcch ARGS((
388          RgSchCellCb      *cell,
389          TfuCntrlReqInfo  *cntrlInfo,
390          RgSchDlSf        *dlSf,
391          RgSchErrInfo     *err));
392 static S16 rgSCHTomUtlFillUlPdcch ARGS((
393          RgSchCellCb       *cell,
394          TfuCntrlReqInfo  *cntrlInfo,
395          RgSchDlSf        *ulSf,
396          RgSchErrInfo     *err));
397
398 static S16 rgSCHTomUtlProcTA ARGS((
399          RgSchCellCb      *cell));
400 #ifdef TFU_UPGRADE
401 static S16 rgSCHTomUtlFillHqFdbkRecpReq ARGS((
402          TfuRecpReqInfo   *recpReq,
403          RgSchCellCb      *cell,
404          uint16_t              validIdx,
405         RgSchErrInfo     *err));
406 #else
407 static S16 rgSCHTomUtlFillHqFdbkRecpReq ARGS((
408          TfuRecpReqInfo   *recpReq,
409          RgSchCellCb      *cell,
410          RgSchErrInfo     *err));
411 #endif
412 #ifdef TFU_UPGRADE
413
414 S16 rgSCHTomFillOnlySrsRecpReq ARGS
415 ((
416 RgSchCellCb       *cell,
417 RgSchUlAlloc      *alloc,
418 TfuUeRecpReqInfo  *datRecpInfo
419 ));
420 static S16 rgSCHTomUtlFillCqiSrSrsWithHq ARGS
421 ((
422 RgSchCellCb         *cell,
423 TfuRecpReqInfo      *recpReqInfo,
424 RgSchUeCb           *ue,
425 TfuUeRecpReqInfo    *pucchRecpInfo,
426 uint16_t                  validIdx,
427 Bool                 isDatPresOnSecCell
428 ));
429
430 S16 rgSCHTomUtlFillRiBitWidthInfo ARGS
431 ((
432 RgSchUeCb          *ueCb
433 ));
434
435 uint8_t rgSCHTomUtlFetchPcqiBitSz ARGS
436 ((
437 RgSchUeCb          *ueCb, 
438 uint8_t                 numTxAnt,
439 uint8_t                 *ri
440 ));
441
442 uint8_t rgSCHTomUtlFetchPcqiBitSzPucchMode21 ARGS
443 ((
444 RgSchUeCb          *ueCb, 
445 TfuCqiPucchMode21   *mode21Info,
446 uint8_t                 numTxAnt,
447 uint8_t                 *ri
448 ));
449
450 S16 rgSCHTomUtlMoveNxtOccasion ARGS
451 ((
452 RgSchCellCb        *cell,
453 RgSchUeCb          *ueCb,
454 uint16_t                validIdx
455 ));
456
457 static S16 rgSCHTomUtlMovePcqiNxtOccasion ARGS
458 ((
459 RgSchCellCb     *cell,
460 RgSchUeCb       *ue,
461 RgSchUePCqiCb   *cqiCb
462 ));
463
464 static S16 rgSCHTomUtlMovePriNxtOccasion ARGS
465 ((
466 RgSchCellCb     *cell,
467 RgSchUeCb       *ue,
468 RgSchUePCqiCb   *riCb
469 ));
470
471 static S16 rgSCHTomUtlMoveSrNxtOccasion ARGS
472 ((
473 RgSchCellCb     *cell,
474 RgSchUeCb       *ue
475 ));
476
477 static S16 rgSCHTomUtlMoveSrsNxtOccasion ARGS
478 ((
479 RgSchCellCb     *cell,
480 RgSchUeCb       *ue
481 ));
482 static S16 rgSCHTomUtlWillUeRprtCqiRi ARGS((
483          RgSchUeCb        *ue,
484          Bool             *willueRprtCqiRii));
485 #endif 
486 #ifdef TFU_UPGRADE
487 static S16 rgSCHTomUtlFillDatRecpReq ARGS((
488          TfuRecpReqInfo   *recpReq,
489          RgSchCellCb      *cell,
490          uint16_t              validIdx,
491          RgSchErrInfo     *err));
492 #else
493 static S16 rgSCHTomUtlFillDatRecpReq ARGS((
494          TfuRecpReqInfo   *recpReq,
495          RgSchCellCb      *cell,
496          RgSchErrInfo     *err));
497 #endif
498
499 #ifdef LTE_TDD
500 #ifdef TFU_UPGRADE
501 static S16 rgSCHTomUtlFillSfRepHqFdbk ARGS((
502       TfuRecpReqInfo *recpReqInfo,
503       RgSchCellCb    *cell,
504       RgSchErrInfo   *err,
505       RgSchDlSf      *dlSf,
506       uint8_t             noFdbks,
507       CmMemListCp    *memCp,
508       uint8_t             elemIdx,
509       RgSchDlSf      *nxtDlsf,
510       uint16_t              validIdx
511      ));
512 #else
513 static S16 rgSCHTomUtlFillSfRepHqFdbk ARGS((
514       TfuRecpReqInfo *recpReqInfo,
515       RgSchCellCb    *cell,
516       RgSchErrInfo   *err,
517       RgSchDlSf      *dlSf,
518       uint8_t             noFdbks,
519       CmMemListCp    *memCp,
520       uint8_t             elemIdx,
521       RgSchDlSf      *nxtDlsf
522      ));
523 #endif
524 #ifdef TFU_UPGRADE
525 static S16 rgSCHTomUtlFillSfHqFdbk ARGS((
526       TfuRecpReqInfo *recpReqInfo,
527       RgSchCellCb    *cell,
528       RgSchErrInfo   *err,
529       RgSchDlSf      *dlSf,
530       uint8_t             noFdbks,
531       CmMemListCp    *memCp,
532       uint8_t             elemIdx,
533       RgSchDlSf      *nxtDlsf,
534       uint16_t              validIdx
535      ));
536 #else
537 static S16 rgSCHTomUtlFillSfHqFdbk ARGS((
538       TfuRecpReqInfo *recpReqInfo,
539       RgSchCellCb    *cell,
540       RgSchErrInfo   *err,
541       RgSchDlSf      *dlSf,
542       uint8_t             noFdbks,
543       CmMemListCp    *memCp,
544       uint8_t             elemIdx,
545       RgSchDlSf      *nxtDlsf
546      ));
547 #endif
548
549 static S16 rgSCHTomUtlFillSfHqFdbkForOneUe ARGS((
550       RgSchDlHqProcCb         *hqCb,
551       TfuRecpReqInfo          *recpReqInfo,
552       RgSchCellCb             *cellCb,
553       RgSchErrInfo            *err,
554       RgSchDlSf               *dlSf,
555       uint8_t                      noFdbks,
556       CmMemListCp             *memCp,
557       uint8_t                      elemIdx,
558       RgSchDlSf               *nxtDlsf,
559       CmLteRnti               rnti,
560       RgrTddAckNackMode       ackNackMode,
561       RgSchUePucchRecpInfo    **pucchInfoRef,
562       RgSchPdcch              *pdcch,
563       TknUInt16                  n1PucchTkn,
564       Bool                    *allocRef,
565       uint8_t                      hqSz
566       ));
567 #endif
568 #ifdef LTEMAC_SPS
569 Void rgSCHCmnDlSpsSch (RgSchCellCb *cell);
570 #ifndef LTE_TDD
571 #ifdef UNUSED_FUNC
572 #ifdef TFU_UPGRADE
573 static S16 rgSCHTomCnsdrRelPdcch ARGS
574 ((
575 RgSchCellCb    *cell,
576 RgSchDlSf      *dlSf,
577 TfuRecpReqInfo *recpReqInfo,
578 uint16_t       validIdx,
579 RgSchErrInfo   *err
580 ));
581 #else
582 static S16 rgSCHTomCnsdrRelPdcch ARGS
583 ((
584  RgSchCellCb    *cell,
585  RgSchDlSf      *dlSf,
586  TfuRecpReqInfo *recpReqInfo,
587  RgSchErrInfo    *err
588  ));
589 #endif
590 #endif
591 #endif
592 #endif
593
594 static Void rgSchTomTtiMiscFunctions ARGS
595 ((
596 RgSchCellCb  *cell
597 ));
598
599 static Void rgSchTomTtiUlAndDlCmnChSch ARGS
600 ((
601 RgSchCellCb  *cell
602 ));
603
604 static Void rgSchTomTtiDlSch ARGS
605 ((
606 RgSchCellCb  *cell
607 ));
608
609 static Void rgSchTomTtiCnsldtSfAlloc ARGS
610 ((
611 RgSchCellCb  *cell
612 ));
613
614 static Void rgSchTomTtiL1DlAndUlCfg ARGS
615 ((
616 RgSchCellCb  *cell,
617 RgTfuCntrlReqInfo  *cntrlInfo
618 ));
619
620 #ifdef RGR_RRM_TICK   
621 static Void rgSCHTomUtlSendSfnTick ARGS
622 ((
623 RgSchCellCb  *cell
624 ));
625 #endif
626 #ifdef LTE_TDD
627 static Void rgSchTomUtlTddRlsSfAndHarq ARGS
628 ((
629 RgSchCellCb        *cell
630 ));
631 static Void rgSCHTomUtlProcTddUlSf ARGS
632 ((
633 RgSchCellCb        *cell
634 ));
635 #ifdef LTE_ADV
636 static Void rgSCHTomUtlGethqRes ARGS
637 ((
638 uint8_t                      noFdbks,
639 RgSchDlSf               *dlSf,
640 RgSchPdcch              *pdcch,
641 RgSchCellCb             *cellCb,
642 uint16_t                     *hqRes
643 ));
644 static Void rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM1 ARGS
645 ((
646 RgSchDlHqProcCb     *hqCb,
647 TfuUePucchRecpReq   *hqRecpReq,
648 uint8_t                  noFdbks,
649 RgSchDlSf           *dlSf,
650 RgSchPdcch          *pdcch,
651 RgSchCellCb         *cellCb
652 ));
653 static Void rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM234 ARGS
654 ((
655 RgSchDlHqProcCb         *hqCb,
656 TfuUePucchRecpReq       *hqRecpReq,
657 uint8_t                      noFdbks,
658 RgSchDlSf               *dlSf,
659 RgSchPdcch              *pdcch,
660 RgSchCellCb             *cellCb,
661 uint8_t                      elemIdx
662 ));
663 #endif/*LTE_ADV*/
664 #endif/*LTE_TDD*/
665
666 uint32_t rgDlCqiRptCnt[16], rgTotDlCqiRpt;
667
668 #ifdef RG_5GTF
669 uint32_t rgSch5gtfCqi2Mcs[15] = 
670     {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
671 #endif
672 /* forward references */
673 #ifdef TFU_UPGRADE
674 /*HARQ Feedback interpretation in accordance with Femto Forum.
675 Note: There is no value as '0' in Femto Forum Spec but in order to retain
676 the existing usage in MAC (and its Acceptance), its being considered*/
677 //const static uint8_t rgSchTomHqFbkMap[8] = {0,1,0,0,4,4,4,4};
678 /*added #defines instead of magic numbers*/
679 /*const static uint32_t rgSCHTomBinCoe[RG_SCH_MAX_NUM_UE_SEL_SUBBANDS][RG_SCH_MAX_TOT_NUM_SUBBANDS]={
680 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28},
681 {0,1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210,231,253,276,300,325,351,378},
682 {0,0,1,4,10,20,35,56,84,120,165,220,286,364,455,560,680,816,969,1140,1330,1540,1771,2024,2300,2600,2925,3276},
683 {0,0,0,1,5,15,35,70,126,210,330,495,715,1001,1365,1820,2380,3060,3876,4845,5985,7315,8855,10626,12650,14950,17550,20475},
684 {0,0,0,0,1,6,21,56,126,252,462,792,1287,2002,3003,4368,6188,8568,11628,15504,20349,26334,33649,42504,53130,65780,80730,98280},
685 {0,0,0,0,0,1,7,28,84,210,462,924,1716,3003,5005,8008,12376,18564,27132,38760,54264,74613,100947,134596,177100,230230,296010,376740}
686 };
687 */
688
689 /*ccpu00116923 - ADD - SRS present support*/
690 /*Tables Derived from 3GPP TS 36.211 Section 5.5.3.3 */
691 /* Table 5.5.3.3-1 */
692 #ifndef LTE_TDD
693 const RgSchFddCellSpSrsSubfrmTbl rgSchFddCellSpSrsSubfrmTbl = {
694    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE},
695    {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE},
696    {FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE},
697    {TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE},
698    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
699    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE},
700    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE},
701    {TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE},
702    {FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE},
703    {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
704    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
705    {FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
706    {FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
707    {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE},
708    {TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE},
709    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}
710 };
711 #else
712 /* Table 5.5.3.3-2 */
713 const RgSchTddCellSpSrsSubfrmTbl rgSchTddCellSpSrsSubfrmTbl = {
714    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
715    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE},
716    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE},
717    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE},
718    {FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE},
719    {FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE},
720    {FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE},
721    {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE},
722    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
723    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE},
724    {FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE},
725    {FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE},
726    {FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE},
727    {FALSE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE},
728    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
729    {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE}
730 };
731 #endif
732 S8 rgSchCmnAper20n22DiffCqi[4] = {1, 2, 3, 4};
733 S8 rgSchCmnAper30n31DiffCqi[4] = {0, 1, 2, -1};
734 #endif 
735
736 /**
737  * @brief get Ue for dedicated preamble rach
738  *
739  * @details
740  *
741  *     Function: rgSCHGetDedPrmUe 
742  *
743  *     Invoked by: rgSCHTomRaReqInd 
744  *
745  *  @param[in] RgSchCellCb     *cell
746  *  @param[in] TfuRaReqIndInfo *raReqInd
747  *  @return  S16
748  *      -# ROK 
749  *      -# RFAILED 
750  **/
751 S16 rgSCHGetDedPrmUe 
752 (
753 RgSchCellCb     *cell,
754 uint16_t        rapId,
755 CmLteTimingInfo timingInfo,
756 RgSchUeCb       **ue
757 )
758 {
759    RgSchCmnCell          *cellSch = (RgSchCmnCell *)(cell->sc.sch);
760
761    DU_LOG("\nINFO  -->  SCH : rapId[%d] cellSch->rachCfg.dedPrmStart[%d] cellSch->rachCfg.numDedPrm[%d]\n",\
762    rapId,cellSch->rachCfg.dedPrmStart,cellSch->rachCfg.numDedPrm);
763    /* Finding UE in handOver List */
764    if ((rapId < cellSch->rachCfg.dedPrmStart) ||
765          (rapId > cellSch->rachCfg.dedPrmStart +
766           cellSch->rachCfg.numDedPrm - 1))
767    {
768       /* This ded Preamble corresponds to handover */
769       *ue = rgSCHCmnGetHoUe(cell, rapId);
770       DU_LOG("\nDEBUG  -->  SCH : ded Preamble corresponds to handover\n");
771    }
772    else/* Finding UE from PDCCH Order Mappings */
773    {
774       /* Get the UE which has transmitted this RaReq */
775       *ue = rgSCHCmnGetPoUe(cell, rapId, timingInfo);
776       DU_LOG("\nDEBUG  -->  SCH :  UE from PDCCH Order Mapping\n");
777    }
778    return ROK;
779 }
780 /**
781  * @brief Handler for processing Random Access request indication 
782  * recieved from PHY.
783  *
784  * @details
785  *
786  *     Function: rgSCHTomRaReqInd
787  *
788  *     Handler for processing Random Access request indication recieved from
789  *     PHY.
790  *
791  *     Invoked by: RgLiTfuRaReqInd of LIM
792  *
793  *     Processing Steps: 
794  *      - Validate the information received: cellId value and raRnti values
795  *      - Process the request: Call rgSCHRamProcRaReq (cell, raRnti, raReqInd)
796  *           
797  *  @param[in] RgSchCellCb     *cell
798  *  @param[in] TfuRaReqIndInfo *raReqInd
799  *  @return  S16
800  *      -# ROK 
801  *      -# RFAILED 
802  **/
803 S16 rgSCHTomRaReqInd
804 (
805 RgSchCellCb     *cell,
806 TfuRaReqIndInfo *raReqInd
807 )
808 {
809    S16           ret;
810    uint8_t       raRntiCnt;
811    uint8_t       raReqCnt;
812    RgSchErrInfo  err;
813    Bool          isEmtcUe = FALSE;
814    uint16_t      rapId;
815    RgSchUeCb     *ue = NULLP;
816
817    if(cell->cellId != raReqInd->cellId)
818    {
819       err.errType    = RGSCHERR_TOM_RAREQIND;
820       err.errCause   = RGSCHERR_TOM_INV_CELL_ID;
821       DU_LOG("\nERROR  -->  SCH : rgSCHTomRaReqInd(): No cell found with raReq cellId = (%d) errorType (%d)"
822          " errorCause(%d)",raReqInd->cellId, err.errType, err.errCause);
823       return RFAILED;
824    } 
825    
826    for (raRntiCnt = 0; raRntiCnt < raReqInd->nmbOfRaRnti; raRntiCnt++)
827    {
828       for (raReqCnt = 0; raReqCnt < raReqInd->rachInfoArr->numRaReqInfo; raReqCnt++)
829       {
830          rapId = raReqInd->rachInfoArr[raRntiCnt].raReqInfoArr[raReqCnt].rapId;
831
832          if(RGSCH_IS_DEDPRM(cell, rapId))
833          {
834             rgSCHGetDedPrmUe(cell, rapId, raReqInd->timingInfo, &ue);
835             if(NULLP == ue)
836             {
837                /* Since rapId is within dedicated range and No ue context
838                 * is found means it is a spurious rach. So ignore it.*/
839                continue;
840             }
841          }
842
843          if(FALSE == isEmtcUe)
844          {
845 #if (ERRCLASS & ERRCLS_DEBUG)
846             if(raReqInd->rachInfoArr[raRntiCnt].raRnti > RGSCH_MAX_RA_RNTI)
847             {
848                DU_LOG("\nERROR  -->  SCH : rgSCHTomRaReqInd(): raRnti  is out of range\n");
849                continue;
850             }
851 #endif
852             ret = rgSCHRamProcRaReq(raReqCnt, cell, raReqInd->rachInfoArr[raRntiCnt].raRnti, 
853                   (TfuRachInfo *)&raReqInd->rachInfoArr[raRntiCnt],
854                   raReqInd->timingInfo, ue, &err);
855             if(ret == RFAILED)
856             {
857                err.errType = RGSCHERR_TOM_RAREQIND;
858                DU_LOG("\nERROR  -->  SCH : RARNTI:%d rgSCHTomRaReqInd(): RAM processing failed errType(%d) "
859                      "errCause(%d)", raReqInd->rachInfoArr[raRntiCnt].raRnti, 
860                      err.errType, err.errCause);
861                continue;
862             }
863          }
864       }
865    }
866    return ROK;
867 }  /* rgSCHTomRaReqInd */
868
869
870 /**
871  * @brief Handler for processing uplink CQI indication recieved from PHY.
872  *
873  * @details
874  *
875  *     Function: rgSCHTomUlCqiInd
876  *
877  *     Handler for processing uplink CQI indication recieved from PHY.
878  *
879  *     Invoked by: RgLiTfuUlCqiInd 
880  *
881  *     Processing Steps:
882  *     - Gets UE
883  *     - Invoke scheduler to push reported CQI info rgSCHUtlUlCqiInd 
884  *           
885  *  @param[in] RgSchCellCb     *cell
886  *  @param[in] TfuUlCqiIndInfo *ulCqiInd
887  *  @return  S16
888  *      -# ROK 
889  *      -# RFAILED 
890  **/
891 S16 rgSCHTomUlCqiInd
892
893 RgSchCellCb     *cell,
894 TfuUlCqiIndInfo *ulCqiInd
895 )
896 {
897    RgSchUeCb    *ue;
898    CmLList      *node;
899    TfuUlCqiRpt  *ulCqiInfo;
900
901    node =  ulCqiInd->ulCqiRpt.first;
902    if(cell->cellId != ulCqiInd->cellId)
903    {
904       DU_LOG("\nERROR  -->  SCH : rgSCHTomUlCqiInd() Unable to get the ulCqiInd cell with id(%d)", 
905          ulCqiInd->cellId);
906       return RFAILED;
907    }
908
909    for (;node; node=node->next)
910    {
911       ulCqiInfo = (TfuUlCqiRpt *)node->node;
912 #if (ERRCLASS & ERRCLS_DEBUG)
913       if(ulCqiInfo->numSubband == 0)
914       {
915          DU_LOG("\nERROR  -->  SCH : Num Subband is"
916             "out of range RNTI:%d",ulCqiInfo->rnti);
917          continue;
918       }
919 #endif
920       if((ue = rgSCHDbmGetUeCb(cell, ulCqiInfo->rnti)) == NULLP)
921       {
922 #ifdef LTEMAC_SPS
923          if((ue = rgSCHDbmGetSpsUeCb(cell, ulCqiInfo->rnti)) == NULLP)
924 #endif
925          {
926             DU_LOG("\nERROR  -->  SCH : Unable to get the ue for RNTI:%d", ulCqiInfo->rnti);
927             continue;
928          }
929       }
930       /* wideband cqi is directly reported now. and also isTxPort0 */
931       rgSCHUtlUlCqiInd(cell, ue, ulCqiInfo);
932    }
933        return ROK;
934 }  /* rgSCHTomUlCqiInd */
935
936 /**
937  * @brief Handler for processing PUCCH power adjustment indication
938  *
939  * @details
940  *
941  *     Function: rgSCHTomPucchDeltaPwrInd
942  *
943  *     Handler for processing PUCCH power adjustment indication
944  *     received from PHY.
945  *
946  *     Invoked by: RgLiTfuPucchDeltaPwrInd 
947  *
948  *     Processing Steps:
949  *     - Gets UE
950  *     - Invoke scheduler to push reported CQI info rgSCHUtlPucchDeltaPwrInd 
951  *           
952  *  @param[in] RgSchCellCb             *cell
953  *  @param[in] TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
954  *  @return  S16
955  *      -# ROK 
956  *      -# RFAILED 
957  **/
958 S16 rgSCHTomPucchDeltaPwrInd
959
960 RgSchCellCb             *cell,
961 TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
962 )
963 {
964    RgSchUeCb       *ue;
965    CmLList         *node;
966    TfuPucchDeltaPwr  *ueElem;
967
968    if(cell->cellId != pucchDeltaPwr->cellId)
969    {
970       DU_LOG("\nERROR  -->  SCH : rgSCHTomPucchDeltaPwrInd() Unable to get the pucchDeltaPwr cell with id(%d)", 
971          pucchDeltaPwr->cellId);
972       return RFAILED;
973    }
974
975    node =  pucchDeltaPwr->pucchDeltaPwrLst.first;
976    for (;node; node=node->next)
977    {
978       ueElem = (TfuPucchDeltaPwr *)node->node;
979       if((ue = rgSCHDbmGetUeCb(cell, ueElem->rnti)) == NULLP)
980       {
981 #ifdef LTEMAC_SPS 
982          if((ue = rgSCHDbmGetSpsUeCb(cell, ueElem->rnti)) == NULLP)
983 #endif
984          {
985             DU_LOG("\nERROR  -->  SCH : RNTI:%d "
986                      "rgSCHTomPucchDeltaPwrInd() Unable to get the ue ", 
987                      ueElem->rnti);
988             continue;
989          }
990       }
991       rgSCHUtlPucchDeltaPwrInd(cell, ue, ueElem->pucchDeltaPwr);
992    }
993    return ROK;
994 }  /* rgSCHTomPucchDeltaPwrInd */
995
996 /**
997  * @brief Handler for processing harq ACK/NACK indication recieved from PHY.
998  *
999  * @details
1000  *
1001  *     Function: rgSCHTomHarqAckInd
1002  *
1003  *     Handler for processing harq ACK/NACK indication recieved from PHY.
1004  *
1005  *     Invoked by: RgLiTfuHqInd
1006  *
1007  *     Processing Steps:
1008  *     For each HqAckInfo received
1009  *     - Get UE
1010  *     - If UE doesnt exist look for a RaCb and invoke rgSCHRamMsg4FdbkInd
1011  *     - Invoke HARQ module to pass HARQ-ACK info rgSCHDhmHqFdbkInd
1012  *           
1013  *  @param[in]  TfuHqIndInfo *harqAckInd
1014  *  @return  S16
1015  *      -# ROK 
1016  *      -# RFAILED 
1017  **/
1018 S16 rgSCHTomHarqAckInd
1019 (
1020 RgSchCellCb     *cell,
1021 TfuHqIndInfo    *harqAckInd
1022 )
1023 {
1024    RgSchErrInfo    err;
1025    RgSchUeCb       *ue;
1026    RgSchRaCb       *raCb;
1027    CmLList         *node;
1028    TfuHqInfo       *hqInfo;
1029    Pst             pst;
1030   // uint8_t              tbCnt;
1031
1032    RgInfRlsHqInfo  *rlsHqBufs = &(cell->rlsHqArr[cell->crntHqIdx]);
1033    uint32_t            cellIdx;
1034    RgSchCellCb     *iterCellP; 
1035    
1036    if(cell->cellId != harqAckInd->cellId)
1037    {
1038       DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() Unable to get"
1039          " the cell for cellId (%d)", harqAckInd->cellId);
1040       err.errType = RGSCHERR_TOM_HARQACKIND;
1041       err.errCause = RGSCHERR_TOM_INV_CELL_ID;
1042       return RFAILED;
1043         }
1044 #ifdef RG_5GTF   
1045    node =  harqAckInd->hqIndLst.first;
1046    for (;node; node=node->next)
1047    {
1048       hqInfo = (TfuHqInfo *)node->node;
1049       {
1050          rlsHqBufs = &(cell->rlsHqArr[cell->crntHqIdx]);
1051          TfuHqFdbk fdbk = hqInfo->isAck[0];
1052          raCb = rgSCHDbmGetRaCb (cell, hqInfo->rnti);
1053          ue = rgSCHDbmGetUeCb (cell, hqInfo->rnti);
1054          if (ue != NULLP && raCb == NULLP)
1055          {  
1056             if ((rgSCHDhm5gtfHqFdbkInd (ue, cell, harqAckInd->timingInfo, fdbk, &err)) != ROK)
1057             {
1058                err.errType = RGSCHERR_TOM_HARQACKIND;
1059                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() "
1060                      "HARQ feedback processing failed errType(%d)errCause(%d)n",
1061                      err.errType, err.errCause); 
1062                continue;
1063             }
1064          }
1065       }
1066       
1067    }
1068
1069    if ((rgSCHDhmRlsDlsfHqProc (cell, harqAckInd->timingInfo)) != ROK)
1070    {
1071       DU_LOG("\nERROR  -->  SCH : Unable to Release Downlink "
1072             "subframe for cellId (%d) ", cell->cellId);
1073       err.errType = RGSCHERR_TOM_HARQACKIND;
1074    }
1075
1076    for (cellIdx = 0; cellIdx < CM_LTE_MAX_CELLS; cellIdx++)
1077    {
1078       if (NULLP != rgSchCb[cell->instIdx].cells[cellIdx])
1079       {
1080          iterCellP = rgSchCb[cell->instIdx].cells[cellIdx];
1081
1082          rlsHqBufs = &(iterCellP->rlsHqArr[iterCellP->crntHqIdx]);
1083          if(rlsHqBufs->numUes)
1084          {
1085             rgSCHUtlGetPstToLyr(&pst, &rgSchCb[cell->instIdx], iterCellP->macInst);
1086             RgSchMacRlsHq (&pst, rlsHqBufs);
1087          }
1088          rlsHqBufs->numUes = 0;
1089       }
1090    }
1091 #else 
1092    rlsHqBufs->numUes = 0;
1093    node =  harqAckInd->hqIndLst.first;
1094    for (;node; node=node->next)
1095    {
1096       hqInfo = (TfuHqInfo *)node->node;
1097          for(tbCnt=0; tbCnt<TFU_MAX_HARQ_FDBKS; tbCnt++)
1098          {
1099             hqInfo->isAck[tbCnt]=(TfuHqFdbk)rgSchTomHqFbkMap[hqInfo->isAck[tbCnt]];
1100          }
1101       raCb = rgSCHDbmGetRaCb (cell, hqInfo->rnti);
1102       ue = rgSCHDbmGetUeCb (cell, hqInfo->rnti);
1103       if (ue == NULLP && raCb != NULLP)
1104       {
1105 #ifdef RG_UNUSED
1106          rgSCHRamMsg4FdbkInd (raCb);
1107 #endif
1108          if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1109                      cell, harqAckInd->timingInfo, hqInfo, rlsHqBufs, &err)) != ROK)
1110          {
1111             err.errType = RGSCHERR_TOM_HARQACKIND;
1112             DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1113                " feedback processing failed errType(%d) errCause(%d)", 
1114                err.errType, err.errCause); 
1115             continue;
1116          }
1117          continue;
1118       }
1119       else if (ue != NULLP && raCb == NULLP)
1120       {
1121          /* Get the Downlink HARQ entity from ue */
1122          if ((rgSCHDhmHqFdbkInd (ue, RGSCH_HQ_FDB_IND_CB_TYPE_HQ_ENT, 
1123                      cell, harqAckInd->timingInfo, hqInfo, rlsHqBufs, &err)) != ROK)
1124          {
1125             err.errType = RGSCHERR_TOM_HARQACKIND;
1126             DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() "
1127                "HARQ feedback processing failed errType(%d)errCause(%d)n",
1128                err.errType, err.errCause);
1129             continue;
1130          }
1131       }
1132       else if (ue != NULLP && raCb != NULLP)
1133       {
1134          if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1135                      cell, harqAckInd->timingInfo, hqInfo, rlsHqBufs, &err)) != ROK)
1136          {
1137             err.errType = RGSCHERR_TOM_HARQACKIND;
1138             DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1139                " feedback processing failed errType(%d) errCause(%d).", 
1140                err.errType, err.errCause); 
1141             continue;
1142          }
1143       }
1144       else
1145       {
1146             DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the "
1147                      "UE CB or RA CB ", hqInfo->rnti);
1148             err.errType = RGSCHERR_TOM_HARQACKIND;
1149             continue;
1150       }
1151    }
1152
1153    /* Check with TDD call DHM*/
1154    if ((rgSCHDhmRlsDlsfHqProc (cell, harqAckInd->timingInfo)) != ROK)
1155    {
1156       DU_LOG("\nERROR  -->  SCH : Unable to Release Downlink "
1157          "subframe for cellId (%d) ", harqAckInd->cellId);
1158       err.errType = RGSCHERR_TOM_HARQACKIND;
1159    }
1160
1161    for (cellIdx = 0; cellIdx < CM_LTE_MAX_CELLS; cellIdx++)
1162    {
1163       if (NULLP != rgSchCb[cell->instIdx].cells[cellIdx])
1164       {
1165          iterCellP = rgSchCb[cell->instIdx].cells[cellIdx];
1166
1167          rlsHqBufs = &(iterCellP->rlsHqArr[iterCellP->crntHqIdx]);
1168          if(rlsHqBufs->numUes)
1169          {
1170             rgSCHUtlGetPstToLyr(&pst, &rgSchCb[cell->instIdx], iterCellP->macInst);
1171             RgSchMacRlsHq (&pst, rlsHqBufs);
1172          }
1173          rlsHqBufs->numUes = 0;
1174       }
1175    }
1176 #endif 
1177    return ROK;
1178 }  /* rgSCHTomHarqAckInd */
1179
1180
1181 /**
1182  * @brief Handler for processing Scheduling Request indication 
1183  * recieved from PHY for a list of UEs.
1184  *
1185  * @details
1186  *
1187  *     Function: rgSCHTomSrInd
1188  *
1189  *     Handler for processing Scheduling Request indication recieved from PHY
1190  *     for UEs.
1191  *
1192  *     Invoked by: RgLiTfuSrInd
1193  *
1194  *     Processing Steps:
1195  *     - Get UE
1196  *     - Invoke scheduler to indicate SR rgSCHUtlSrRcvd 
1197  *           
1198  *  @param[in]  TfuSrIndInfo *srInd
1199  *  @return  S16
1200  *      -# ROK 
1201  *      -# RFAILED 
1202  **/
1203 S16 rgSCHTomSrInd
1204 (
1205 RgSchCellCb     *cell,
1206 TfuSrIndInfo    *srInd
1207 )
1208 {
1209    S16          ret = RFAILED;
1210    RgSchErrInfo err;
1211    RgSchUeCb    *ue;
1212    CmLList      *node;
1213    TfuSrInfo    *srInfo;
1214
1215    if(cell->cellId != srInd->cellId)
1216    {
1217       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for srcInd cellId"
1218          ":%d ", srInd->cellId);
1219       err.errType = RGSCHERR_TOM_SRIND;
1220       err.errCause = RGSCHERR_TOM_INV_CELL_ID;
1221       return RFAILED;
1222         }
1223
1224
1225    node =  srInd->srLst.first;
1226    for (;node; node=node->next)
1227    {
1228       rgNumSrRecvd++;
1229           
1230       srInfo = (TfuSrInfo *)node->node;
1231       ue = rgSCHDbmGetUeCb (cell, srInfo->rnti);
1232       if (ue == NULLP)
1233       {
1234          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the UE CB",
1235             srInfo->rnti);
1236          continue;
1237       }
1238       rgSCHUtlHdlUlTransInd(cell, ue, srInd->timingInfo);
1239       /*Need to activate UE as SR received*/
1240       if (ue->isDrxEnabled)
1241       {
1242          rgSCHDrxSrInd(cell, ue);
1243       }
1244       ret = rgSCHUtlSrRcvd (cell, ue, srInd->timingInfo, &err);
1245       if (ret != ROK)
1246       {
1247          err.errType = RGSCHERR_TOM_SRIND;
1248          DU_LOG("\nERROR  -->  SCH : Scheduler processing failed "
1249              "errType(%d) errCause(%d) RNTI:%d", err.errType, err.errCause,srInfo->rnti);
1250          continue;
1251       }
1252    }
1253    return ROK;
1254 }  /* end of rgSCHTomSrInd */
1255
1256 /**
1257  * @brief Handler for processing downlink CQI indication recieved from 
1258  * PHY for a UE.
1259  *
1260  * @details
1261  *
1262  *     Function:  rgSCHTomDoaInd  
1263  *
1264  *     Handler for processing DOA recieved from PHY
1265  *     for a set of UEs.
1266  *
1267  *     Invoked by: RgLiTfuDoaInd
1268  *
1269  *     Processing Steps:
1270  *     - Get UE
1271  *     - Invoke scheduler to indicate DOA rgSCHUtlDoaInd
1272  *           
1273  *  @param[in]  TfuDoaIndInfo *doaInd
1274  *  @return  S16
1275  *      -# ROK 
1276  *      -# RFAILED 
1277  **/
1278 S16 rgSCHTomDoaInd
1279 (
1280 RgSchCellCb     *cell,
1281 TfuDoaIndInfo   *doaInd
1282 )
1283 {
1284    RgSchUeCb    *ue;
1285    CmLList      *node;
1286    TfuDoaRpt    *doaInfo;
1287
1288    if(cell->cellId != doaInd->cellId)
1289    {
1290       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for doaInd cellId"
1291          ":%d", doaInd->cellId);
1292       return RFAILED;
1293         }
1294
1295
1296    node =  doaInd->doaRpt.first;
1297    for (;node; node=node->next)
1298    {
1299       doaInfo = (TfuDoaRpt *)node->node;
1300       ue = rgSCHDbmGetUeCb (cell, doaInfo->rnti);
1301       if (ue == NULLP)
1302       {
1303          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the UE CB",
1304             doaInfo->rnti);
1305          continue;
1306       }
1307       rgSCHUtlDoaInd(cell, ue, doaInfo);
1308    }
1309    return ROK;
1310 }  /* rgSCHTomDoaInd */
1311 /**
1312  * @brief Handler for processing downlink CQI indication recieved from 
1313  * PHY for a UE.
1314  *
1315  * @details
1316  *
1317  *     Function: rgSCHTomDlCqiInd
1318  *
1319  *     Handler for processing downlink CQI indication recieved from PHY
1320  *     for a set of UEs.
1321  *
1322  *     Invoked by: RgLiTfuDlCqiInd
1323  *
1324  *     Processing Steps:
1325  *     - Get UE
1326  *     - Invoke scheduler to indicate DL CQI rgSCHUtlDlCqiInd
1327  *           
1328  *  @param[in]  TfuDlCqiIndInfo *dlCqiInd
1329  *  @return  S16
1330  *      -# ROK 
1331  *      -# RFAILED 
1332  **/
1333 S16 rgSCHTomDlCqiInd
1334 (
1335 RgSchCellCb     *cell,
1336 TfuDlCqiIndInfo *dlCqiInd
1337 )
1338 {
1339    RgSchUeCb    *ue;
1340    CmLList      *node;
1341    TfuDlCqiRpt  *dlCqiInfo;
1342
1343    if(cell->cellId != dlCqiInd->cellId)
1344    {
1345       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for cellId"
1346          ":%d", dlCqiInd->cellId);
1347       return RFAILED;
1348         }
1349
1350
1351    node =  dlCqiInd->dlCqiRptsLst.first;
1352    for (;node; node=node->next)
1353    {
1354       dlCqiInfo = (TfuDlCqiRpt *)node->node;
1355       ue = rgSCHDbmGetUeCb (cell, dlCqiInfo->rnti);
1356       if (ue == NULLP)
1357       {
1358          DU_LOG("\nERROR  -->  SCH : RNTI:%dUnable to get the UE CB",
1359             dlCqiInfo->rnti);
1360          continue;
1361       }
1362       rgSCHUtlDlCqiInd(cell, ue, dlCqiInfo, dlCqiInd->timingInfo);
1363       rgSCHUtlHdlUlTransInd(cell, ue, dlCqiInd->timingInfo);
1364    }
1365    return ROK;
1366 }  /* rgSCHTomDlCqiInd */
1367
1368 /**
1369  * @brief Handler for moving PCQI instance for the next periodic occasion
1370  *
1371  * @details
1372  *
1373  *     Function: rgSCHTomUtlMovePcqiNxtOccasion
1374  *
1375  *     Handler for moving PCQI instance for the next periodic occasion
1376  *
1377  *     Invoked by: rgSCHTomUtlFill*
1378  *
1379  *     Processing Steps:
1380  *     - For a UE move its occurence instance to next occasion 
1381  *        depending on its periodicity 
1382  *     - Remove it from the current list and insert it to the list 
1383  *        having the index matching with the derived number. 
1384  *           
1385  *  @param[in]  RgSchCellCb     *cell,
1386  *               [in]        RgSchUeCb      *ue
1387  *  @return  S16
1388  *      -# ROK 
1389  *      -# RFAILED 
1390  **/
1391 static S16 rgSCHTomUtlMovePcqiNxtOccasion
1392 (
1393 RgSchCellCb     *cell,
1394 RgSchUeCb      *ue,
1395 RgSchUePCqiCb   *cqiCb
1396 )
1397 {
1398    uint16_t   cqiIdx = 0;
1399
1400    CmLteTimingInfo timingInfo;
1401
1402    if(cqiCb->cqiCfg.cqiSetup.cqiRepType == RGR_UE_PCQI_SB_REP)
1403    {
1404 #ifdef xLTE_TDD
1405       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, timingInfo, TFU_DELTA);
1406 #else
1407       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, timingInfo,
1408             TFU_RECPREQ_DLDELTA);
1409 #endif
1410       RG_SCH_ADD_TO_CRNT_TIME(timingInfo,timingInfo,cqiCb->cqiPeri);
1411       rgSCHTomUtlPcqiSbCalcBpIdx(timingInfo,ue,cqiCb); 
1412    }
1413    /* Compute Next Transmission Instance */ 
1414    cqiIdx = cqiCb->cqiPeri + cqiCb->nCqiTrIdx;
1415    cqiIdx = cqiIdx%RG_SCH_PCQI_SRS_SR_TRINS_SIZE;  
1416    /* Delete from current List and move to new list */ 
1417    if (NULLP == cmLListDelFrm(&cell->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
1418             &cqiCb->cqiLstEnt))
1419    {
1420       DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to remove node",
1421          ue->ueId);
1422    }
1423    cqiCb->nCqiTrIdx = cqiIdx;
1424    cmLListAdd2Tail(&(cell->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst), 
1425          &(cqiCb->cqiLstEnt));
1426 #ifdef LTE_ADV
1427    rgSCHUtlSCellHndlCqiCollsn(cqiCb);
1428 #endif
1429
1430    return ROK;
1431 }  /* rgSCHTomUtlMovePcqiNxtOccasion */
1432
1433 /**
1434  * @brief Handler for moving RI instance for the next periodic occasion
1435  *
1436  * @details
1437  *
1438  *     Function: rgSCHTomUtlMovePriNxtOccasion
1439  *
1440  *     Handler for moving PCQI instance for the next periodic occasion
1441  *
1442  *     Invoked by: rgSCHTomUtlFill*
1443  *
1444  *     Processing Steps:
1445  *     - For a UE move its occurence instance to next occasion 
1446  *        depending on its periodicity 
1447  *     - Remove it from the current list and insert it to the list 
1448  *        having the index matching with the derived number. 
1449  *           
1450  *  @param[in]  RgSchCellCb     *cell,
1451  *               [in]        RgSchUeCb      *ue
1452  *  @return  S16
1453  *      -# ROK 
1454  *      -# RFAILED 
1455  **/
1456 static S16 rgSCHTomUtlMovePriNxtOccasion
1457 (
1458 RgSchCellCb    *cell,
1459 RgSchUeCb      *ue, 
1460 RgSchUePCqiCb  *riCb
1461 )
1462 {
1463    uint16_t   riIdx;
1464    uint16_t   riDist=0;
1465    uint16_t   effPeriodicity;
1466    uint16_t   riTrInsTime;  
1467    uint16_t   crntTime;
1468    uint16_t   tempIdx; 
1469
1470    crntTime = (cell->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)
1471       +(cell->crntTime.slot);
1472 #ifdef XEON_SPECIFIC_CHANGES
1473    RGSCHCPYTIMEINFO(cell->crntTime, ue->riRecpTime);
1474 #endif
1475    /* Compute Next Transmission Instance */ 
1476    if (riCb->cqiCfg.cqiSetup.cqiRepType == RGR_UE_PCQI_WB_REP)
1477    {
1478       effPeriodicity = riCb->cqiPeri * riCb->riPeri;
1479       tempIdx = effPeriodicity + riCb->nRiTrIdx;
1480    }
1481    else 
1482    {
1483       effPeriodicity = (riCb->h * riCb->cqiPeri * riCb->riPeri);
1484       /* In case of SFN wraparound, the SB CQI reporting cycle breaks
1485        * and RI->WB CQI->SBCQI.. should resume. RI is repositioned 
1486        * accordingly. WBCQI handling is naturally accomplished */
1487       if ((crntTime + TFU_RECPREQ_DLDELTA + effPeriodicity) > 
1488           (RGSCH_MAX_SUBFRM_5G - 1))
1489       {
1490          riTrInsTime = (effPeriodicity - riCb->cqiOffset + riCb->riOffset) % effPeriodicity; 
1491          tempIdx = RGSCH_MAX_SUBFRM_5G + (effPeriodicity - riTrInsTime);
1492          /*  In case of SFN wraparound, riDist should be distance from crntTime
1493           *  + TFU_RECPREQ_DLDELTA to tempIdx. Updating effPeriodicity 
1494           *  to make riDist calculation consistent for both SFN wraparound 
1495           *  case and normal case */
1496          effPeriodicity = tempIdx - TFU_RECPREQ_DLDELTA - crntTime;
1497       }
1498       else
1499       {
1500          tempIdx = effPeriodicity + riCb->nRiTrIdx;
1501       }
1502    }
1503    riIdx = tempIdx % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
1504    if (effPeriodicity >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
1505    {
1506       riDist = rgSCHUtlFindDist((uint16_t)(crntTime + TFU_RECPREQ_DLDELTA), 
1507       (uint16_t)(crntTime + TFU_RECPREQ_DLDELTA + effPeriodicity));  
1508    }
1509    else
1510    {
1511       riDist = 0; 
1512    }
1513
1514    /* ccpu00138306- If Periodicity is equal to Queue Size or multiple of it 
1515     * then the next occasion idx will be same as current Idx, Hence need not 
1516     * to delete and add 
1517     */
1518    if((effPeriodicity%RG_SCH_PCQI_SRS_SR_TRINS_SIZE) != 0)
1519    {
1520       /* Delete from current List and move to new list */ 
1521       if (NULLP == cmLListDelFrm(&cell->pCqiSrsSrLst[riCb->nRiTrIdx].riLst,
1522             &riCb->riLstEnt))
1523       {
1524          DU_LOG("\nERROR  -->  SCH : [%d]UEID:Unable to remove node",
1525             ue->ueId);
1526       }
1527       RG_SCH_RECORD(&riCb->histElem,RGSCH_ACTION_DEL, &cell->pCqiSrsSrLst[riCb->nRiTrIdx].riLst);
1528       cmLListAdd2Tail(&cell->pCqiSrsSrLst[riIdx].riLst, 
1529             &riCb->riLstEnt);
1530       RG_SCH_RECORD(&riCb->histElem,RGSCH_ACTION_ADD, &cell->pCqiSrsSrLst[riIdx].riLst);
1531    }
1532    else
1533    {
1534       if(riDist > 0) 
1535       {   
1536          riDist--;
1537       }
1538    }
1539    riCb->nRiTrIdx = riIdx;
1540    riCb->riDist = riDist;
1541
1542 #ifdef LTE_ADV
1543    rgSCHUtlSCellHndlRiCollsn(riCb);
1544 #endif
1545    return ROK;
1546 }  /* rgSCHTomUtlMovePriNxtOccasion */
1547
1548 /**
1549  * @brief Handler for moving SR instance for the next periodic occasion
1550  *
1551  * @details
1552  *
1553  *     Function: rgSCHTomUtlMoveSrNxtOccasion
1554  *
1555  *     Handler for moving SR instance for the next periodic occasion
1556  *
1557  *     Invoked by: rgSCHTomUtlFill*
1558  *
1559  *     Processing Steps:
1560  *     - For a UE move its occurence instance to next occasion 
1561  *        depending on its periodicity 
1562  *     - Remove it from the current list and insert it to the list 
1563  *        having the index matching with the derived number. 
1564  *           
1565  *  @param[in]  RgSchCellCb     *cell,
1566  *               [in]        RgSchUeCb      *ue
1567  *  @return  S16
1568  *      -# ROK 
1569  *      -# RFAILED 
1570  **/
1571 static S16 rgSCHTomUtlMoveSrNxtOccasion
1572 (
1573 RgSchCellCb     *cell,
1574 RgSchUeCb      *ue
1575 )
1576 {
1577    uint16_t   srIdx = 0;
1578
1579    /* Compute Next Transmission Instance */ 
1580    srIdx = ue->srCb.peri + ue->srCb.nSrTrIdx;
1581    srIdx = srIdx%RG_SCH_PCQI_SRS_SR_TRINS_SIZE;  
1582    /* Delete from current List and move to new list */ 
1583    if (NULLP == cmLListDelFrm(&cell->pCqiSrsSrLst[ue->srCb.nSrTrIdx].srLst,
1584             &ue->srCb.srLstEnt))
1585    {
1586       DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to remove node",
1587          ue->ueId);
1588    }
1589    ue->srCb.nSrTrIdx = srIdx;
1590    cmLListAdd2Tail(&cell->pCqiSrsSrLst[ue->srCb.nSrTrIdx].srLst, 
1591          &ue->srCb.srLstEnt);
1592
1593    return ROK;
1594 }  /* rgSCHTomUtlMoveSrNxtOccasion */
1595
1596 /**
1597  * @brief Handler for moving SRS instance for the next periodic occasion
1598  *
1599  * @details
1600  *
1601  *     Function: rgSCHTomUtlMoveSrsNxtOccasion
1602  *
1603  *     Handler for moving SRS instance for the next periodic occasion
1604  *
1605  *     Invoked by: rgSCHTomUtlFill*
1606  *
1607  *     Processing Steps:
1608  *     - For a UE move its occurence instance to next occasion 
1609  *        depending on its periodicity 
1610  *     - Remove it from the current list and insert it to the list 
1611  *        having the index matching with the derived number. 
1612  *           
1613  *  @param[in]  RgSchCellCb     *cell,
1614  *               [in]        RgSchUeCb      *ue
1615  *  @return  S16
1616  *      -# ROK 
1617  *      -# RFAILED 
1618  **/
1619 static S16 rgSCHTomUtlMoveSrsNxtOccasion
1620 (
1621 RgSchCellCb     *cell,
1622 RgSchUeCb      *ue
1623 )
1624 {
1625    uint16_t   srsIdx;
1626    uint16_t   srsDist;
1627    uint16_t   tempIdx;
1628    uint16_t   crntTime; 
1629
1630
1631    crntTime = (cell->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)
1632       +(cell->crntTime.slot);
1633
1634    /* Compute Next Transmission Instance */ 
1635    tempIdx = ue->srsCb.peri + ue->srsCb.nSrsTrIdx;
1636    srsIdx = tempIdx %RG_SCH_PCQI_SRS_SR_TRINS_SIZE;  
1637    if (ue->srsCb.peri > RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
1638    {
1639       srsDist = rgSCHUtlFindDist((uint16_t)(crntTime + TFU_RECPREQ_DLDELTA), 
1640       (uint16_t)(crntTime + TFU_RECPREQ_DLDELTA + ue->srsCb.peri));  
1641    }
1642    else
1643    {
1644       srsDist =0; 
1645    }
1646
1647    /* ccpu00138306- If Periodicity is equal to Queue Size or multiple of it 
1648     * then the next occasion idx will be same as current Idx, Hence need not 
1649     * to delete and add 
1650     */
1651    if((ue->srsCb.peri%RG_SCH_PCQI_SRS_SR_TRINS_SIZE) != 0)
1652    {
1653       /* Delete from current List and move to new list */ 
1654       if (NULLP == cmLListDelFrm(&cell->pCqiSrsSrLst[ue->srsCb.nSrsTrIdx].srsLst,
1655             &ue->srsCb.srsLstEnt))
1656       {
1657          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to remove node",
1658             ue->ueId);
1659       }
1660       cmLListAdd2Tail(&cell->pCqiSrsSrLst[srsIdx].srsLst,
1661             &ue->srsCb.srsLstEnt);
1662    }
1663    else
1664    {
1665       if(srsDist > 0)
1666       {
1667          srsDist--; 
1668       }   
1669    }   
1670    ue->srsCb.nSrsTrIdx = srsIdx;
1671    ue->srsCb.srsDist = srsDist; 
1672    return ROK;
1673 }  /* rgSCHTomUtlMoveSrsNxtOccasion */
1674
1675
1676 /**
1677  * @brief Handler for processing RAW CQI indication recieved from 
1678  * PHY for a UE.
1679  *
1680  * @details
1681  *
1682  *     Function: rgSCHTomRawCqiInd
1683  *
1684  *     Handler for processing RAW CQI indication recieved from PHY
1685  *     for a set of UEs.
1686  *
1687  *     Invoked by: RgLiTfuRawCqiInd
1688  *
1689  *     Processing Steps:
1690  *     - Get UE
1691  *     - Invoke scheduler to indicate Raw CQI rgSCHUtlRawCqiInd
1692  *           
1693  *  @param[in]  TfuRawCqiIndInfo *rawCqiInd
1694  *  @return  S16
1695  *      -# ROK 
1696  *      -# RFAILED 
1697  **/
1698 S16 rgSCHTomRawCqiInd
1699 (
1700 RgSchCellCb     *cell,
1701 TfuRawCqiIndInfo *rawCqiInd
1702 )
1703 {
1704    RgSchUeCb    *ue;
1705    CmLList      *node;
1706    TfuRawCqiRpt* rawCqiInfo;
1707
1708    RgSchErrInfo err;
1709    uint32_t     cellIdx;
1710    RgInfRlsHqInfo  *rlsHqBufs = &(cell->rlsHqArr[cell->crntHqIdx]);
1711    RgSchCellCb     *iterCellP;
1712 #if DL_LA
1713    RgSchCmnDlUe    *ueDl;
1714 #endif
1715    uint8_t      cqi;
1716    uint8_t      ri;
1717    uint8_t      hqAck;
1718    Pst          pst;
1719    RgSchRaCb    *raCb;
1720    TfuHqInfo    hqInfo;
1721
1722    if(cell->cellId != rawCqiInd->cellId)
1723    {
1724       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for cellId"
1725             ":%d", rawCqiInd->cellId);
1726       return RFAILED;
1727         }
1728
1729
1730    node =  rawCqiInd->rawCqiRpt.first;
1731    for (;node; node=node->next)
1732    {
1733       rawCqiInfo = (TfuRawCqiRpt *)node->node;
1734       ue = rgSCHDbmGetUeCb (cell, rawCqiInfo->crnti);
1735       raCb = rgSCHDbmGetRaCb (cell, rawCqiInfo->crnti);
1736       /*
1737       if (ue == NULLP)
1738       {
1739          DU_LOG("\nERROR  -->  SCH : CRNTI:%d Unable to get the UECB",
1740                rawCqiInfo->crnti);
1741          continue;
1742       }
1743       */
1744 #ifdef RG_5GTF
1745       /*
1746       if (rawCqiInfo->numBits >= 5)
1747          DU_LOG("\nINFO  -->  SCH : cellId [%d] crnti [%d] numBits [%d]  uciPayload [0x%08x] sfn/sf [%d:%d]\n", 
1748                 cell->cellId, rawCqiInfo->crnti, rawCqiInfo->numBits, rawCqiInfo->uciPayload, 
1749                 rawCqiInd->timingInfo.sfn, rawCqiInd->timingInfo.slot);
1750       */
1751       if (rawCqiInfo->numBits == 1)
1752       {
1753          rlsHqBufs = &(cell->rlsHqArr[cell->crntHqIdx]);
1754          uint8_t fdbk = TFU_HQFDB_NACK;
1755          /* Process HARQ FdbkInd */
1756          hqAck = (rawCqiInfo->uciPayload >> 31) & 0x1;
1757          if (hqAck)
1758          {
1759             fdbk = TFU_HQFDB_ACK;
1760             hqInfo.isAck[0] = fdbk;
1761          }
1762          if (ue != NULLP && raCb == NULLP)
1763          {  
1764             if ((rgSCHDhm5gtfHqFdbkInd (ue, cell, rawCqiInd->timingInfo, fdbk, &err)) != ROK)
1765             {
1766                err.errType = RGSCHERR_TOM_HARQACKIND;
1767                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() "
1768                      "HARQ feedback processing failed errType(%d)errCause(%d)n",
1769                      err.errType, err.errCause); 
1770                continue;
1771             }
1772          }
1773          else if (ue == NULLP && raCb != NULLP)
1774          {
1775             if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1776                         cell, rawCqiInd->timingInfo, &hqInfo, rlsHqBufs, &err)) != ROK)
1777             {
1778                err.errType = RGSCHERR_TOM_HARQACKIND;
1779                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1780                      " feedback processing failed errType(%d) errCause(%d)", 
1781                      err.errType, err.errCause); 
1782                continue;
1783             }
1784             continue;
1785          }
1786          else if (ue != NULLP && raCb != NULLP)
1787          {
1788             if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1789                         cell, rawCqiInd->timingInfo, &hqInfo, rlsHqBufs, &err)) != ROK)
1790             {
1791                err.errType = RGSCHERR_TOM_HARQACKIND;
1792                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1793                      " feedback processing failed errType(%d) errCause(%d).", 
1794                      err.errType, err.errCause); 
1795                continue;
1796             }
1797          }
1798          else
1799          {
1800             DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the "
1801                   "UE CB or RA CB ", rawCqiInfo->crnti);
1802             err.errType = RGSCHERR_TOM_HARQACKIND;
1803             continue;
1804          }
1805          /*
1806          DU_LOG("rawCqiInfo->numBits [%d]  uciPayload [0x%08x] sfn/sf [%d:%d]\n", rawCqiInfo->numBits,
1807                 rawCqiInfo->uciPayload, rawCqiInd->timingInfo.sfn, rawCqiInd->timingInfo.slot);
1808          */
1809       }
1810       else if (rawCqiInfo->numBits == 5)
1811       {
1812          /* Process CQI-RI Ind*/
1813          ri = (rawCqiInfo->uciPayload >> 27) & 0x1;
1814          cqi = (rawCqiInfo->uciPayload >> 28) & 0xF;
1815          if(ue) {
1816          if (cqi == 0)
1817          {
1818            DU_LOG("\nERROR  -->  SCH : UE[%d] CQI[%d] Invalid\n", ue->ueId, cqi);
1819             cqi = 15;
1820          }
1821          ue->ue5gtfCb.mcs = rgSch5gtfCqi2Mcs[cqi - 1];
1822          ue->ue5gtfCb.rank = ri + 1;
1823 #ifdef DL_LA
1824          if (rawCqiInfo->numBits > 1)
1825          {
1826                ueDl =  RG_SCH_CMN_GET_DL_UE(ue,cell);
1827                ueDl->mimoInfo.cwInfo[0].cqi = cqi;
1828                ueDl->cqiFlag = TRUE;
1829                rgSCHCmnDlSetUeAllocLmtLa(cell, ue);
1830             // rgSCHCheckAndSetTxScheme(cell, ue);
1831          }
1832 #endif
1833          }
1834          /*
1835          DU_LOG("\nERROR  -->  SCH : UE[%d] CQI[%d] MCS[%d] RI[%d]\n", ue->ueId, cqi, ue->ue5gtfCb.mcs, ri);
1836          */
1837       }
1838       else if (rawCqiInfo->numBits == 6)
1839       {
1840          rlsHqBufs = &(cell->rlsHqArr[cell->crntHqIdx]);
1841          TfuHqFdbk fdbk = TFU_HQFDB_NACK;
1842          /* Process both HARQ and CQI-RI Ind*/
1843          ri = (rawCqiInfo->uciPayload >> 26) & 0x1;
1844          cqi = (rawCqiInfo->uciPayload >> 27) & 0xF;
1845          hqAck = (rawCqiInfo->uciPayload >> 31) & 0x1;
1846          if (cqi == 0)
1847          {
1848             DU_LOG("\nERROR  -->  SCH : UE[%d] CQI[%d] Invalid\n", ue->ueId, cqi);
1849             cqi = 13;
1850          }
1851          ue->ue5gtfCb.mcs = rgSch5gtfCqi2Mcs[cqi - 1];
1852          ue->ue5gtfCb.rank = ri + 1;
1853 #ifdef DL_LA
1854          if (rawCqiInfo->numBits > 1)
1855          {
1856                ueDl =  RG_SCH_CMN_GET_DL_UE(ue,cell);
1857                ueDl->mimoInfo.cwInfo[0].cqi = cqi;
1858                ueDl->cqiFlag = TRUE;
1859                rgSCHCmnDlSetUeAllocLmtLa(cell, ue);
1860             // rgSCHCheckAndSetTxScheme(cell, ue);
1861          }
1862 #endif
1863          if (hqAck)
1864          {
1865             fdbk = TFU_HQFDB_ACK;
1866             hqInfo.isAck[0] = fdbk;
1867          }
1868          if (ue != NULLP && raCb == NULLP)
1869          {  
1870              if ((rgSCHDhm5gtfHqFdbkInd (ue, cell, rawCqiInd->timingInfo, fdbk, &err)) != ROK)
1871              {
1872                  err.errType = RGSCHERR_TOM_HARQACKIND;
1873                  DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() "
1874                          "HARQ feedback processing failed errType(%d)errCause(%d)n",
1875                          err.errType, err.errCause); 
1876                  continue;
1877              }
1878          }
1879          else if (ue == NULLP && raCb != NULLP)
1880          {
1881             if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1882                         cell, rawCqiInd->timingInfo, &hqInfo, rlsHqBufs, &err)) != ROK)
1883             {
1884                err.errType = RGSCHERR_TOM_HARQACKIND;
1885                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1886                      " feedback processing failed errType(%d) errCause(%d)", 
1887                      err.errType, err.errCause); 
1888                continue;
1889             }
1890             continue;
1891          }
1892          else if (ue != NULLP && raCb != NULLP)
1893          {
1894             if ((rgSCHDhmHqFdbkInd (raCb, RGSCH_HQ_FDB_IND_CB_TYPE_RA_CB, 
1895                         cell, rawCqiInd->timingInfo, &hqInfo, rlsHqBufs, &err)) != ROK)
1896             {
1897                err.errType = RGSCHERR_TOM_HARQACKIND;
1898                DU_LOG("\nERROR  -->  SCH : rgSCHTomHarqAckInd() HARQ"
1899                      " feedback processing failed errType(%d) errCause(%d).", 
1900                      err.errType, err.errCause); 
1901                continue;
1902             }
1903          }
1904          else
1905          {
1906             DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the "
1907                   "UE CB or RA CB ", rawCqiInfo->crnti);
1908             err.errType = RGSCHERR_TOM_HARQACKIND;
1909             continue;
1910          }
1911
1912          /*
1913          DU_LOG("\nERROR  -->  SCH : UE[%u] CQI[%u] MCS[%u] RI[%u] HQ[%u]\n", ue->ueId, cqi, ue->ue5gtfCb.mcs, ri, hqAck);
1914          */
1915       }
1916    }
1917
1918    if ((rgSCHDhmRlsDlsfHqProc (cell, rawCqiInd->timingInfo)) != ROK)
1919    {
1920       DU_LOG("\nERROR  -->  SCH : Unable to Release Downlink "
1921             "subframe for cellId (%d) ", cell->cellId);
1922       err.errType = RGSCHERR_TOM_HARQACKIND;
1923    }
1924
1925    for (cellIdx = 0; cellIdx < CM_LTE_MAX_CELLS; cellIdx++)
1926    {
1927       if (NULLP != rgSchCb[cell->instIdx].cells[cellIdx])
1928       {
1929          iterCellP = rgSchCb[cell->instIdx].cells[cellIdx];
1930
1931          rlsHqBufs = &(iterCellP->rlsHqArr[iterCellP->crntHqIdx]);
1932          if(rlsHqBufs->numUes)
1933          {
1934             rgSCHUtlGetPstToLyr(&pst, &rgSchCb[cell->instIdx], iterCellP->macInst);
1935             RgSchMacRlsHq (&pst, rlsHqBufs);
1936          }
1937          rlsHqBufs->numUes = 0;
1938       }
1939    }
1940    return ROK;
1941 }  /* rgSCHTomRawCqiInd */
1942
1943 /**
1944  * @brief Handler for processing SRS indication recieved from 
1945  * PHY for a UE.
1946  *
1947  * @details
1948  *
1949  *     Function: rgSCHTomSrsInd
1950  *
1951  *     Handler for SRS indication recieved from PHY
1952  *     for a set of UEs.
1953  *
1954  *     Invoked by: RgLiTfuSrsInd
1955  *
1956  *     Processing Steps:
1957  *     - Get UE
1958  *     - Invoke scheduler to indicate UL SRS  rgSCHUtlSrsInd
1959  *           
1960  *  @param[in]  TfuSrsIndInfo *srsInd
1961  *  @return  S16
1962  *      -# ROK 
1963  *      -# RFAILED 
1964  **/
1965 S16 rgSCHTomSrsInd
1966 (
1967 RgSchCellCb     *cell,
1968 TfuSrsIndInfo *srsInd
1969 )
1970 {
1971    RgSchUeCb    *ue;
1972    CmLList      *node;
1973    TfuSrsRpt* srsInfo;
1974
1975    if(cell->cellId != srsInd->cellId)
1976    {
1977       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for cellId"
1978          ":%d", srsInd->cellId);
1979       return RFAILED;
1980         }
1981
1982    node =  srsInd->srsRpt.first;
1983    for (;node; node=node->next)
1984    {
1985       srsInfo = (TfuSrsRpt *)node->node;
1986       ue = rgSCHDbmGetUeCb (cell, srsInfo->ueId);
1987       if (ue == NULLP)
1988       {
1989          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the "
1990             "UE CB", srsInfo->ueId);
1991          continue;
1992       }
1993       rgSCHUtlSrsInd(cell, ue, srsInfo, srsInd->timingInfo);
1994       rgSCHUtlHdlUlTransInd(cell, ue, srsInd->timingInfo);
1995    }
1996    return ROK;
1997 }  /* rgSCHTomSrsInd */
1998
1999 /*
2000 *
2001 *       Fun:   rgSCHTomUtlGenIndices
2002 *
2003 *       Desc:  This function reconstructs the Subband Indices for
2004 *       of M selected Subbands conveyed by the UE for APeriodic Modes
2005 *       2-0 and 2-2. It decodes the Label which uniquely encodes M out
2006 *       of N subbands.
2007 *                   
2008 *
2009 *       Ret:   ROK
2010 *
2011 *       Notes: None
2012 *
2013 *       File:  rg_sch_utl.c
2014 *
2015 */
2016 #ifdef UNUSED_FUNC
2017 static S16 rgSCHTomUtlGenIndices
2018 (
2019 uint32_t      label,
2020 uint8_t        posM,
2021 uint8_t        valN,
2022 uint8_t        valK,
2023 TfuSubbandInfo* sbInfo
2024 )
2025 {
2026    uint8_t idx, kval, xval, xmin;
2027    uint32_t binCoe;
2028    xmin =1;
2029    for(kval=0; kval<posM;kval++)
2030    {
2031       xval = xmin;
2032       RGSCH_ARRAY_BOUND_CHECK_WITH_POS_IDX(0, rgSCHTomBinCoe, (posM-kval-1));
2033       RGSCH_ARRAY_BOUND_CHECK_WITH_POS_IDX(0, rgSCHTomBinCoe[posM-kval-1], (valN-xval-1));
2034       binCoe = rgSCHTomBinCoe[posM-kval-1][valN-xval-1];
2035       while(binCoe>label)
2036       {
2037          xval = xval+1;
2038          RGSCH_ARRAY_BOUND_CHECK_WITH_POS_IDX(0, rgSCHTomBinCoe[posM-kval-1], (valN-xval-1));
2039          binCoe = rgSCHTomBinCoe[posM-kval-1][valN-xval-1];
2040       }
2041       idx = xval;
2042       sbInfo[kval].numRb = valK;
2043       sbInfo[kval].rbStart = idx*valK;
2044       xmin = idx+1;
2045       label = label-binCoe;
2046    }
2047    return ROK;
2048 } /* end of rgSCHTomUtlGenIndices*/
2049 #endif
2050 #endif 
2051 /**
2052  * @brief Handler for processing decode failure indication recieved from 
2053  * PHY for a UE.
2054  *
2055  * @details
2056  *
2057  *     Function: rgSCHTomCrcInd
2058  *
2059  *     Handler for processing decode failure indication recieved from 
2060  *     PHY for a set of UEs.
2061  *
2062  *     Invoked by: RgLiTfuCrcInd of rg_sch.x 
2063  *
2064  *     Processing Steps:
2065  *     - Validate the information received and retrieve cell and ue.
2066  *     - Process Decode failure Indication: Call rgSCHUhmProcHqFailure().
2067  *           
2068  *  @param[in]  TfuCrcIndInfo *crcInd
2069  *  @return  S16
2070  *      -# ROK 
2071  *      -# RFAILED 
2072  **/
2073 S16 rgSCHTomCrcInd
2074 (
2075 RgSchCellCb       *cell,
2076 TfuCrcIndInfo *crcInd
2077 )
2078 {
2079    RgSchUeCb      *ue = NULLP;
2080    RgSchRaCb      *raCb = NULLP;
2081    CmLList        *node;
2082    TfuCrcInfo     *crcInfo;
2083 #ifdef RG_ULSCHED_AT_CRC
2084    RgSchErrInfo    err;
2085    RgSchDlSf       *ulSf;
2086    CmLteTimingInfo crntHiDci0Frm;
2087    //RgSchCmnUlCell  *cellUl; 
2088    Inst             inst = cell->instIdx;
2089    TfuCntrlReqInfo  *cntrlInfo;
2090    uint32_t               ret;
2091 #ifdef LTE_TDD
2092    uint8_t              Mval;
2093    uint8_t              idx;
2094 #endif
2095 #endif
2096 #ifdef LTE_TDD
2097    RgSchUlHqProcCb   *hqProc;
2098 #endif
2099
2100 #ifdef LTE_L2_MEAS
2101    RgSchUlHqProcCb   *ulHqProc;
2102 #endif   
2103
2104    if(cell->cellId != crcInd->cellId)
2105    {
2106       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for cellId"
2107          ":%d", crcInd->cellId);
2108       return RFAILED;
2109         }
2110 #ifdef RG_ULSCHED_AT_CRC
2111 #ifndef LTE_ADV
2112    {
2113       static CmLteTimingInfo lastCrc = {2000,0};
2114       CmLteTimingInfo crntCrc = cell->crntTime;
2115       if (RGSCH_TIMEINFO_SAME(lastCrc, crntCrc))
2116       {
2117          /*Removed the WA to drop 2nd CRC*/
2118          DU_LOG("\nINFO  -->  SCH : Recieved CRC "
2119             "twice per TTI @(%u,%u)", cell->crntTime.sfn,
2120             cell->crntTime.slot);
2121       }
2122       lastCrc = crntCrc;
2123    }
2124 #endif
2125 #endif
2126    node =  crcInd->crcLst.first;
2127    for (;node; node=node->next)
2128    {
2129       crcInfo = (TfuCrcInfo*)node->node;
2130       ue = rgSCHDbmGetUeCb (cell, crcInfo->rnti);
2131       if (ue == NULLP)
2132       {
2133 #ifdef LTEMAC_SPS
2134          /* Fetch from SPS List */
2135          ue = rgSCHDbmGetSpsUeCb(cell, crcInfo->rnti);
2136          if (ue == NULLP)         
2137 #endif 
2138          {
2139             raCb = rgSCHDbmGetRaCb (cell, crcInfo->rnti);
2140             if (raCb == NULLP)
2141             {
2142                continue;
2143             }
2144          }
2145       }
2146       /* Added Ul TB count for Uplink data scheduled*/
2147 #ifdef LTE_L2_MEAS
2148       if(raCb)
2149       {
2150          ulHqProc = &(raCb->msg3HqProc);
2151          if(ulHqProc->remTx == (cell->rachCfg.maxMsg3Tx -1))
2152          {
2153             cell->dlUlTbCnt.tbTransUlTotalCnt++;
2154          }   
2155       }  
2156       else
2157       {
2158          rgSCHUtlUlHqProcForUe(cell, crcInd->timingInfo, ue, &ulHqProc); 
2159          if(ulHqProc->remTx == ((RgUeUlHqCb*)ulHqProc->hqEnt)->maxHqRetx) 
2160          {
2161             cell->dlUlTbCnt.tbTransUlTotalCnt++;
2162          }   
2163       }   
2164 #endif
2165
2166       if (crcInfo->isFailure == FALSE)
2167       {
2168          if(raCb)
2169          {
2170             rgSCHRamMsg3DatInd(raCb);
2171 #ifdef LTE_TDD
2172             /*ccpu00128820 - MOD - Msg3 alloc double delete issue*/
2173             hqProc = &(raCb->msg3HqProc);
2174             RGSCH_UPD_PHICH(cell->ulDlCfgIdx, crcInd->timingInfo.slot,
2175                     hqProc);
2176 #endif
2177             raCb = NULLP;
2178          }
2179          else
2180          {
2181 #ifdef EMTC_ENABLE
2182             gUlCrcPassCounter++;
2183 #endif
2184 #ifdef CA_DBG
2185             gUlCrcPassCount++;
2186 #endif
2187             RGSCHCPYTIMEINFO(crcInd->timingInfo, ue->datIndTime);
2188 #ifndef MAC_SCH_STATS
2189             rgSCHUhmProcDatInd(cell, ue, crcInd->timingInfo);
2190
2191 #else 
2192             /** Stats update over here 
2193             */
2194             {
2195                RgSchCmnUe     *cmnUe = RG_SCH_CMN_GET_UE(ue,cell);
2196
2197                rgSCHUhmProcDatInd(cell, ue, crcInd->timingInfo, cmnUe->ul.crntUlCqi[0]);
2198             }
2199 #endif /* MAC_SCH_STATS */
2200
2201             rgSCHUtlHdlUlTransInd(cell, ue, crcInd->timingInfo);
2202 #ifdef LTEMAC_SPS
2203             rgSCHUtlHdlCrcInd(cell, ue, crcInd->timingInfo);
2204 #endif
2205          }
2206       }
2207       else
2208       {
2209          if(raCb)
2210          {
2211             /* SR_RACH_STATS : MSG3 Nack / DTX*/
2212             if (crcInfo->isDtx == TRUE)
2213             {
2214                rgNumMsg3DtxRcvd++;
2215             }
2216             else
2217             {
2218                rgNumMsg3CrcFailed++;
2219             }
2220             rgSCHRamMsg3FailureInd(raCb);
2221 #ifdef EMTC_ENABLE
2222             rgSCHCmnEmtcHdlCrcFailInd(cell, raCb);
2223 #endif
2224             /* Added Ul TB count for CRC Failure of MSG3 */
2225 #ifdef LTE_L2_MEAS            
2226             ulHqProc = &(raCb->msg3HqProc);
2227             if(ulHqProc->remTx == (cell->rachCfg.maxMsg3Tx -1))
2228             {
2229                cell->dlUlTbCnt.tbTransUlFaulty++;
2230             }
2231 #endif
2232             raCb = NULLP;
2233          }
2234          else
2235          {
2236 #ifdef EMTC_ENABLE
2237             gUlCrcFailCounter++; 
2238 #endif 
2239 #ifdef CA_DBG
2240             gUlCrcFailCount++;
2241 #endif
2242 #ifndef MAC_SCH_STATS
2243             rgSCHUhmProcHqFailure (cell, ue, crcInd->timingInfo, crcInfo->rv);
2244 #else
2245             {
2246                RgSchCmnUe     *cmnUe = RG_SCH_CMN_GET_UE(ue,cell);
2247
2248                rgSCHUhmProcHqFailure (cell, ue, crcInd->timingInfo, crcInfo->rv, cmnUe->ul.crntUlCqi[0]);
2249             }
2250 #endif /* MAC_SCH_STATS */
2251             rgSCHUtlHdlUlTransInd(cell, ue, crcInd->timingInfo);
2252 #ifdef LTEMAC_SPS
2253             rgSCHUtlHdlCrcFailInd(cell, ue, crcInd->timingInfo);
2254 #endif
2255             /* Added Ul TB count for CRC Failure of Uplink data */
2256 #ifdef LTE_L2_MEAS            
2257             rgSCHUtlUlHqProcForUe(cell, crcInd->timingInfo, ue, &ulHqProc); 
2258             if(ulHqProc->remTx == ((RgUeUlHqCb*)ulHqProc->hqEnt)->maxHqRetx) 
2259             {
2260                cell->dlUlTbCnt.tbTransUlFaulty++;
2261             }   
2262 #endif   
2263          }
2264       }
2265    }
2266
2267 /* ccpu00132653-ADD Added Sched_At_Crc Changes for TDD and optimized here 
2268    the codebase across TDD and FDD*/
2269 #ifdef RG_ULSCHED_AT_CRC
2270    /* Changes to do uplink scheduling at CRC Indication */
2271    //cellUl = RG_SCH_CMN_GET_UL_CELL(cell);
2272    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, crntHiDci0Frm, TFU_ULCNTRL_DLDELTA);
2273
2274
2275    rgSCHCmnRlsUlSf(cell,0);
2276
2277
2278       /* Allocating memory for CntrlReq as it required for both EMTC and
2279        * Normal UEs */   
2280       if ((ret = rgSCHUtlAllocEventMem(inst, (Ptr *)&cntrlInfo, 
2281                   sizeof(TfuCntrlReqInfo))) != ROK)
2282       {
2283          DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuCntrlReqInfo "
2284                "for cell");
2285          return ret;
2286       }
2287       rgSCHCmnUlSch(cell);
2288 #ifdef LTE_L2_MEAS
2289       rgSCHL2Meas(cell,TRUE);
2290 #endif
2291       /* Also, sending UL DCI and PHICH for just scheduled subframe */
2292       ulSf = rgSCHUtlSubFrmGet (cell, crntHiDci0Frm);
2293
2294       if ((rgSCHTomUtlProcDlSfAtCrc (ulSf, crntHiDci0Frm, cell, cntrlInfo, &err)) != ROK)
2295       {
2296          DU_LOG("\nERROR  -->  SCH : rgSCHTomCrcInd() Unable to process"
2297                   " downlink subframe for cellId %d", crcInd->cellId);
2298          err.errType = RGSCHERR_TOM_TTIIND;
2299          return RFAILED;
2300                 }
2301 #endif /* RG_ULSCHED_AT_CRC */
2302    return ROK;
2303 }  /* rgSCHTomCrcInd */
2304
2305 /**
2306  * @brief Handler for processing timing Advance indication recieved from 
2307  * PHY for a UE.
2308  *
2309  * @details
2310  *
2311  *     Function: rgSCHTomTimingAdvInd
2312  *
2313  *     Handler for processing timing advance indication recieved from PHY
2314  *     for a set of UEs.
2315  *
2316  *     Invoked by: RgLiTfuTimingAdvInd
2317  *
2318  *     Processing Steps:
2319  *     - Get UE.
2320  *     - Call DHM to update value of Timing Advance rgSCHDhmUpdTa.
2321  *           
2322  *  @param[in] TfuTimingAdvIndInfo *timingAdvInd
2323  *  @return  S16
2324  *      -# ROK 
2325  *      -# RFAILED 
2326  **/
2327 S16 rgSCHTomTimingAdvInd
2328 (
2329 RgSchCellCb         *cell,
2330 TfuTimingAdvIndInfo *timingAdvInd
2331 )
2332 {
2333    RgSchUeCb        *ue;
2334    CmLList          *node;
2335    TfuTimingAdvInfo *timingAdvInfo;
2336
2337    if(cell->cellId != timingAdvInd->cellId)
2338    {
2339       DU_LOG("\nERROR  -->  SCH : Unable to get the cell for cellId"
2340          "=(%d)", timingAdvInd->cellId);
2341       return RFAILED;
2342         }
2343
2344
2345    node =  timingAdvInd->timingAdvLst.first;
2346    for (;node; node=node->next)
2347    {
2348       timingAdvInfo = (TfuTimingAdvInfo *)node->node;
2349       ue = rgSCHDbmGetUeCb (cell, timingAdvInfo->rnti);
2350       if (ue == NULLP)
2351       {
2352          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to get the UE CB",
2353             timingAdvInfo->rnti);
2354          continue;
2355       }
2356       rgSCHDhmUpdTa (cell, ue, timingAdvInfo->timingAdv);
2357    }
2358    return ROK;
2359 }  /* rgSCHTomTimingAdvInd */
2360
2361 /**
2362  * @brief Handler for processing TTI indication recieved from 
2363  * PHY for 'n' cells.
2364  *
2365  * @details
2366  *
2367  *     Function: rgSCHTomTtiInd
2368  *
2369  *     Handler for processing slot indication recieved from MAC
2370  *     for a cell. This is split into the below Steps. 
2371  *     
2372  *     1: Complete the Uplink and Common Channel Scheduling for each Cell
2373  *     2: Complete the UE specific Scheduling for each Cell / across Cells.
2374  *     3: Consolidate the subframe allocations and send to each MAC instance
2375  *     4: Fill the Tfu structures for DL and UL Config requests  
2376  *     5: Handle the RGR Config messages per Cell
2377  *
2378  *  @param[in] SlotTimingInfo    *slotInd
2379  *  @param[in] Inst           schInst
2380  *  @return  Void
2381  **/
2382 Void rgSCHTomTtiInd
2383 (
2384 SlotTimingInfo        *slotInd,
2385 Inst               schInst
2386 )
2387 {
2388    RgInfSfAlloc      *subfrmAlloc;
2389    RgTfuCntrlReqInfo *cntrlInfo = NULLP;
2390    S16               ret = ROK;
2391    uint8_t           i;
2392    uint8_t           nCell = 0;
2393    RgSchCellCb       *cell[CM_LTE_MAX_CELLS];
2394    RgSchCellCb       *cellLst[CM_LTE_MAX_CELLS];
2395    
2396 #ifdef LTE_L2_MEAS
2397    glblTtiCnt++;
2398 #endif
2399
2400    //rgSchTomFillCellTtiInfo(slotInd, schInst, &nCell, &cell[0]);
2401
2402    schFillCrntTime(*slotInd,schInst);
2403    for (i = 0; i < nCell; i++)
2404    {
2405       /* Perform UL and DL Common Channel scheduling */
2406       rgSchTomTtiUlAndDlCmnChSch (cell[i]);
2407    }
2408
2409    /* Perform scheduling in Order of
2410     * 1. SPS
2411     * 2. CEs
2412     * 3. Retx */
2413    for (i = 0; i < nCell; i++)
2414    {
2415       
2416       if (cell[i]->isDlDataAllwd && (cell[i]->stopDlSch == FALSE))
2417       {
2418          RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell[i]);
2419          /* Perform DL Retx scheduling */
2420          cellSch->apisDl->rgSCHDlRetxSched(cell[i], &cellSch->allocInfo);      
2421       }
2422    }
2423
2424    rgSchCmnPreDlSch(cell, nCell, cellLst);
2425    for (i = 0; i < nCell; i++)
2426    {
2427       /* Perform DL scheduling */
2428       rgSchTomTtiDlSch (cellLst[i]);
2429    }
2430    rgSchCmnPstDlSch(cell[0]);
2431
2432    for (i = 0; i < nCell; i++)
2433    {
2434 #ifdef LTE_TDD
2435 #ifndef RG_ULSCHED_AT_CRC      
2436       /* Perform UL scheduling for TDD */
2437       rgSCHCmnUlSch (cell[i]);
2438 #endif      
2439 #endif
2440    }
2441    /* Init SF Alloc info per Cell */
2442    for (i = 0; i < nCell; i++)
2443    {
2444       subfrmAlloc = &(cell[i]->sfAllocArr[cell[i]->crntSfIdx]);
2445       rgSCHUtlResetSfAlloc(subfrmAlloc,FALSE,TRUE);
2446    }
2447    for (i = 0; i < nCell; i++)
2448    {
2449       if (cell[i]->isDlDataAllwd && (cell[i]->stopSiSch == FALSE))
2450       {
2451          subfrmAlloc = &(cell[i]->sfAllocArr[cell[i]->crntSfIdx]);
2452          /*
2453           * TFU_DLDATA_DLDELTA is used in this calculation because the subfrmAlloc
2454           * timingInfo which is being calculated here will be used by MAC
2455           */
2456          RG_SCH_ADD_TO_CRNT_TIME(cell[i]->crntTime, subfrmAlloc->timingInfo,
2457                                  RG_DL_DELTA - TFU_DLDATA_DLDELTA);
2458          /* Consolidate the Allocations and send response to MAC instances */
2459          rgSchTomTtiCnsldtSfAlloc (cell[i]);
2460       }
2461    }
2462
2463    for (i = 0; i < nCell; i++)
2464    {
2465       if (cell[i]->isDlDataAllwd && (cell[i]->stopSiSch == FALSE))
2466       {
2467          /* Send the consolidated Alloc Info to MAC instances */
2468          rgSCHCmnSndCnsldtInfo (cell[i]);
2469       }
2470    }
2471
2472    for (i = 0; i < nCell; i++)
2473    {
2474       /* Fill control data from scheduler to PHY */   
2475       if ((ret = rgSCHUtlAllocEventMem((cell[i]->instIdx), (Ptr *)&cntrlInfo, 
2476                   sizeof(RgTfuCntrlReqInfo))) != ROK)
2477       {     
2478          DU_LOG("\nERROR   -->  SCH : Unable to Allocate TfuCntrlReqInfo"
2479                " for cell");
2480          return;
2481       }
2482
2483 #ifdef EMTC_ENABLE
2484       /* Fill the TFU structures and send to CL */
2485          if(TRUE == cell[i]->emtcEnable)
2486          {
2487             ret = rgSchEmtcTomTtiL1DlAndUlCfg  (cell[i], cntrlInfo);
2488          }
2489 #endif
2490       if((ROK == ret)
2491          && (NULLP != cntrlInfo))
2492       {
2493       /* Fill the TFU structures and send to CL */
2494          rgSchTomTtiL1DlAndUlCfg  (cell[i], cntrlInfo);
2495       }
2496    }
2497 #ifdef RGR_RRM_TICK   
2498    rgSCHTomUtlSendSfnTick(cell[0]);
2499 #endif
2500
2501    for (i = 0; i < nCell; i++)
2502    {
2503       /* Invoke non critical functions like measurements, etc */
2504       rgSchTomTtiMiscFunctions (cell[i]);
2505    }
2506
2507 #ifdef CA_DBG
2508    {
2509       uint32_t dbgUeIdChngAndDatReqInClCnt = 0;
2510       static uint32_t gTtiCount = 0;
2511       gTtiCount++;
2512
2513       if(gTtiCount == 3000)
2514       {
2515 #ifdef XEON_SPECIFIC_CHANGES
2516          DU_LOG("\nINFO   -->  SCH : SChed:: (P/S)::(%u/%u) \n",
2517                gPrimarySchedCount,gSCellSchedCount);
2518
2519          DU_LOG("\nINFO   -->  SCH :  HQFDBK :: %u\n",gHqFdbkCount);
2520          
2521          long int total;
2522          long int total2 ;
2523
2524          total = gPCellTb1AckCount + gPCellTb1NackCount + gPCellTb1DtxCount;
2525          total2 = gPCellTb2AckCount + gPCellTb2NackCount + gPCellTb2DtxCount;
2526          
2527          DU_LOG("\nINFO   -->  SCH :  PCell:: TB1:: (A/N/D)::(%u/%u/%u)  TB2:: (A/N/D)::(%u/%u/%u)\n",
2528                gPCellTb1AckCount,gPCellTb1NackCount,gPCellTb1DtxCount,
2529                gPCellTb2AckCount,gPCellTb2NackCount,gPCellTb2DtxCount);
2530          if ((total != 0 ) && total2 != 0)
2531          {
2532             DU_LOG("\nINFO   -->  SCH :  PCell:: TB1:: (AP/NP/DP)::(%.2f/%.2f/%.2f)   TB2:: (AP/NP/DP)::(%.2f/%.2f/%.2f)\n",
2533                   (float)gPCellTb1AckCount/total * 100,(float)gPCellTb1NackCount/total * 100,(float)gPCellTb1DtxCount/total * 100,
2534                   (float)gPCellTb2AckCount/total2 *100 ,(float)gPCellTb2NackCount/total2 *100 ,(float)gPCellTb2DtxCount/total2 *2);
2535          }
2536
2537          total = gSCellTb1AckCount + gSCellTb1NackCount + gSCellTb1DtxCount;
2538          total2 = gSCellTb2AckCount + gSCellTb2NackCount + gSCellTb2DtxCount;
2539
2540
2541          DU_LOG("\nINFO   -->  SCH : SCell:: TB1:: (A/N/D)::(%u/%u/%u)  TB2:: (A/N/D)::(%u/%u/%u)\n",
2542                gSCellTb1AckCount,gSCellTb1NackCount,gSCellTb1DtxCount,
2543                gSCellTb2AckCount,gSCellTb2NackCount,gSCellTb2DtxCount);
2544          if ((total != 0 ) && total2 != 0)
2545          {
2546             DU_LOG("\nINFO   -->  SCH : SCell:: TB1:: (AP/NP/DP)::(%.2f/%.2f/%.2f)   TB2:: (AP/NP/DP)::(%.2f/%.2f/%.2f)\n",
2547                   (float)gSCellTb1AckCount/total * 100,(float)gSCellTb1NackCount/total * 100,(float)gSCellTb1DtxCount/total * 100,
2548                   (float)gSCellTb2AckCount/total2 *100 ,(float)gSCellTb2NackCount/total2 *100 ,(float)gSCellTb2DtxCount/total2 *2);
2549          }
2550
2551
2552          DU_LOG("\nINFO   -->  SCH : CQI:: Recp(Pucch/Pusch):Rcvd(pcqi/rawacqireport/apcqi/AppReprt)::(%u/%u):(%u/%u/%u/%u)\n",
2553                gCqiRecpCount,gCqiRecpPuschCount,gCqiRcvdCount,gRawACqiCount,
2554                gACqiRcvdCount,gCqiReptToAppCount);
2555               
2556          DU_LOG("\nINFO   -->  SCH : (F1BCS Count/Cqi/Ri/CqiDrop/PucchDrop/PuschCqiDrop)::(%u/%u/%u/%u/%u/%u)\n",
2557                gF1bCsCount,gCqiReqCount,gRiReqCount,gCqiDropCount,gPucchDropCount,gPuschCqiDropCount); 
2558
2559          DU_LOG("\nINFO   -->  SCH : UL::(DCI0/CrcPass/CrcFail)::(%u/%u/%u)\n"
2560                "gPcellZeroBoOcc:%u\t gScellZeroBoOcc:%u dbgUeIdChngAndDatReqInClCnt: %u\n"
2561                "DelayedDatReqInMac: %u DelayedDatReqInCl : %u gIccPktRcvrMemDropCnt :%u\n",
2562                gDci0Count,
2563                gUlCrcPassCount,
2564                gUlCrcFailCount,
2565                gPcellZeroBoOcc,
2566                gScellZeroBoOcc,
2567                dbgUeIdChngAndDatReqInClCnt,
2568                dbgDelayedDatReqInMac,
2569               gDropDatReqCnt, gIccPktRcvrMemDropCnt);
2570 #else
2571          DU_LOG("\nINFO   -->  SCH : SChed:: (P/S)::(%ld/%ld) \n",
2572                gPrimarySchedCount,gSCellSchedCount);
2573
2574          DU_LOG("\nINFO   -->  SCH :  HQFDBK :: %ld\n",gHqFdbkCount);
2575
2576          
2577          DU_LOG("\nINFO   -->  SCH :  PCell:: TB1:: (A/N/D)::(%ld/%ld/%ld)  TB2:: (A/N/D)::(%ld/%ld/%ld)\n",
2578                gPCellTb1AckCount,gPCellTb1NackCount,gPCellTb1DtxCount,
2579                gPCellTb2AckCount,gPCellTb2NackCount,gPCellTb2DtxCount);
2580
2581          DU_LOG("\nINFO   -->  SCH : SCell:: TB1:: (A/N/D)::(%ld/%ld/%ld)  TB2:: (A/N/D)::(%ld/%ld/%ld)\n",
2582                gSCellTb1AckCount,gSCellTb1NackCount,gSCellTb1DtxCount,
2583                gSCellTb2AckCount,gSCellTb2NackCount,gSCellTb2DtxCount);
2584
2585          DU_LOG("\nINFO   -->  SCH : CQI:: Recp(Pucch/Pusch):Rcvd(pcqi/rawacqireport/apcqi/AppReprt)::\
2586          (%ld/%ld):(%ld/%ld/%ld/%ld)\n",
2587                gCqiRecpCount,gCqiRecpPuschCount,gCqiRcvdCount,gRawACqiCount,
2588                gACqiRcvdCount,gCqiReptToAppCount);
2589          DU_LOG("\nINFO   -->  SCH : CQI:: PucchCqiSnrDropCnt/PucchCqiConfBitMaskDropCnt/PuschCqiConfMaskDropCount\
2590          :: (%ld/%ld/%ld) \n",gCqiPucchLowSnrDropCount,gCqiPucchConfMaskDropCount,gCqiPuschConfMaskDropCount);
2591               
2592          DU_LOG("\nINFO   -->  SCH : (F1BCS Count/Cqi/Ri/CqiDrop/PucchDrop/PuschCqiDrop)::(%ld/%ld/%ld/%ld/%ld/%ld)\n",
2593                gF1bCsCount,gCqiReqCount,gRiReqCount,gCqiDropCount,gPucchDropCount,gPuschCqiDropCount); 
2594
2595          DU_LOG("\nINFO   -->  SCH : UL::(DCI0/CrcPass/CrcFail)::(%ld/%ld/%ld)\n"
2596                "gPcellZeroBoOcc:%ld\t gScellZeroBoOcc:%ld dbgUeIdChngAndDatReqInClCnt: %ld\n"
2597                "DelayedDatReqInMac: %ld DelayedDatReqInCl : %ld gIccPktRcvrMemDropCnt :%ld\n",
2598                gDci0Count,
2599                gUlCrcPassCount,
2600                gUlCrcFailCount,
2601                gPcellZeroBoOcc,
2602                gScellZeroBoOcc,
2603                dbgUeIdChngAndDatReqInClCnt,
2604                dbgDelayedDatReqInMac,
2605               gDropDatReqCnt, gIccPktRcvrMemDropCnt);
2606          //DU_LOG("\nINFO   -->  SCH : delayedApiCnt:%ld",delayedApiCnt);
2607 #endif
2608
2609         /*LAA STATS*/               
2610         rgSCHLaaPrintStats();
2611
2612          gCaDbgNonCaFrmt = gIccPktRcvrMemDropCnt = 0;
2613
2614          gCaDbgCaFrmt = 0;
2615          
2616          gF1bCsCount = 0;
2617          gCqiReqCount = 0;
2618          gACqiRcvdCount = 0;
2619          gRawACqiCount= 0;
2620          gRiReqCount = 0;
2621          gCqiDropCount = 0;
2622          gPucchDropCount= 0;
2623
2624          gCqiPucchLowSnrDropCount     = 0;
2625          gCqiPucchConfMaskDropCount   = 0;
2626          gCqiPuschConfMaskDropCount   = 0;
2627          gPuschCqiDropCount = 0;
2628
2629          gDci0Count = 0;
2630          gUlCrcPassCount = 0;
2631          gUlCrcFailCount = 0;
2632          
2633          gCqiRecpCount = 0;
2634          gCqiRecpPuschCount = 0;
2635          gCqiRcvdCount = 0;
2636          
2637          gCqiReptToAppCount = 0;
2638       
2639          gTtiCount = 0;
2640
2641          gHqFdbkCount       = 0;
2642          gPrimarySchedCount = 0;
2643          gSCellSchedCount   = 0;
2644          gSCellTb1AckCount  = 0;
2645          gSCellTb2AckCount  = 0;
2646          gSCellTb2AckCount  = 0;
2647          gSCellTb2NackCount = 0;
2648          gPCellTb1AckCount  = 0;
2649          gPCellTb1NackCount  = 0;
2650          gPCellTb2AckCount  = 0;
2651          gPCellTb2NackCount  = 0;
2652          gSCellTb1NackCount=0;
2653
2654          gPCellTb1DtxCount  = 0;
2655          gPCellTb2DtxCount  = 0;
2656          gSCellTb1DtxCount  = 0;
2657          gSCellTb2DtxCount  = 0;
2658          gPcellZeroBoOcc    = 0;
2659          gScellZeroBoOcc    = 0;
2660
2661       }
2662    
2663    }
2664
2665 #endif
2666    return;
2667 }  /* rgSCHTomTtiInd */
2668
2669 /** @brief This function does the TTI processin for the uplink subframe,
2670  * already populated by the scheduler.
2671  *
2672  * @details
2673  *
2674  *     Function: rgSCHTomUtlProcUlSf
2675  *
2676  *         Processing steps:
2677  *         - Loop through the Uplink allocations present in the uplink subframe.
2678  *         - For each allocation Fill a data reception request to be sent to PHY
2679  *         - Also fills the harq reception requests for the expected HQ feedbacks.
2680  *
2681  *
2682  * @param  [in]  RgSchCellCb   *cell
2683  * @param  [out] RgSchErrInfo  *err
2684  * @return  S16
2685  *      -# ROK 
2686  *      -# RFAILED 
2687  */
2688
2689 static S16 rgSCHTomUtlProcUlSf 
2690 (
2691 RgSchCellCb        *cell,
2692 RgSchErrInfo       *err
2693 )
2694 {
2695    S16             ret;
2696    TfuRecpReqInfo  *recpReqInfo;
2697 #ifdef TFU_UPGRADE
2698    uint16_t             validIdx = 0; /* Index computed from recreq's timing info*/
2699 #endif 
2700    Inst            inst = cell->instIdx;
2701
2702    if ((ret = rgSCHUtlAllocEventMem(inst, (Ptr *)&recpReqInfo, 
2703                             sizeof(TfuRecpReqInfo))) != ROK)
2704    {
2705       DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuRecpReqInfo "
2706          "for cell");
2707       err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
2708       return ret;
2709    }    
2710    recpReqInfo->cellId = cell->cellId;
2711    cmLListInit(&recpReqInfo->ueRecpReqLst);
2712
2713    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, recpReqInfo->timingInfo,
2714                       TFU_RECPREQ_DLDELTA);
2715
2716    /* Filling data Reception requests */
2717    ret = rgSCHTomUtlFillDatRecpReq(recpReqInfo, cell, 
2718          validIdx,
2719          err);
2720    if (ret != ROK)
2721    {
2722       DU_LOG("\nERROR  -->  SCH : Unable to fill Data recption "
2723          "requests for cell");
2724       RGSCH_FREE_MEM(recpReqInfo);
2725       return ret;
2726    } 
2727    /* Filling HARQ Reception requests */
2728    ret = rgSCHTomUtlFillHqFdbkRecpReq (recpReqInfo, cell, validIdx,err);
2729    if (ret != ROK)
2730    {
2731       DU_LOG("\nERROR  -->  SCH : Unable to fill Harq Feedback "
2732          "reception requests for cell");
2733       RGSCH_FREE_MEM(recpReqInfo);
2734       return ret;
2735    }
2736    /* sending the RecpReq to Phy */
2737    //if (rgSCHUtlTfuRecpReq(inst, cell->tfuSap->sapCfg.suId, recpReqInfo) != ROK)
2738    {
2739       DU_LOG("\nERROR  -->  SCH : Unable to send Cntrl info for cell");
2740    }
2741    return ROK;
2742 } /* end of rgSCHTomUtlProcUlSf */ 
2743
2744 #ifdef LTE_TDD
2745 #ifdef TFU_UPGRADE
2746 /** @brief This function does the TTI processin for the uplink subframe,
2747  * already populated by the scheduler.
2748  *
2749  * @details
2750  *
2751  *     Function: rgSCHTomUtlPrcUlTddSpclSf
2752  *
2753  *         Processing steps:
2754  *         - Fill the SRS Info for the Special Subframe in Reception Req.
2755  *         - Send the Reception Req to TFU 
2756  *
2757  *
2758  * @param  [in]  RgSchCellCb   *cell
2759  * @param  [out] RgSchErrInfo  *err
2760  * @return  S16
2761  *      -# ROK 
2762  *      -# RFAILED 
2763  */
2764 static S16 rgSCHTomUtlPrcUlTddSpclSf 
2765 (
2766 RgSchCellCb  *cell,
2767 RgSchErrInfo *err
2768 )
2769 {
2770    S16             ret;
2771    TfuRecpReqInfo  *recpReqInfo;
2772    uint16_t        validIdx; /* Index computed from recreq's timing info*/
2773    Inst            inst = cell->instIdx;
2774
2775    if ((ret = rgSCHUtlAllocEventMem(inst, (Ptr *)&recpReqInfo, 
2776                             sizeof(TfuRecpReqInfo))) != ROK)
2777    {
2778       DU_LOG("\nERROR  -->  SCH : rgSCHTomUtlPrcUlTddSpclSf() Unable to "
2779                "Allocate TfuRecpReqInfo for cell");
2780       err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
2781       return ret;
2782    }    
2783    recpReqInfo->cellId = cell->cellId;
2784    cmLListInit(&recpReqInfo->ueRecpReqLst);
2785
2786    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, recpReqInfo->timingInfo, TFU_RECPREQ_DLDELTA);
2787
2788    RG_SCH_GET_IDX_PCQISRSSR(recpReqInfo->timingInfo, validIdx);
2789
2790    /*ccpu00130768  */ 
2791    if(cell->srsCfg.isSrsCfgPres && 
2792       rgSchTddCellSpSrsSubfrmTbl[cell->srsCfg.srsSubFrameCfg][recpReqInfo->timingInfo.slot])
2793    {
2794       recpReqInfo->srsPres = TRUE;
2795    }
2796    else
2797    {
2798       recpReqInfo->srsPres = FALSE;
2799    }  
2800
2801    /* Filling SRS Reception requests */
2802    ret = rgSCHTomUtlFillSrsRecpReq (recpReqInfo, cell, validIdx, err);
2803    if (ret != ROK)
2804    {
2805       DU_LOG("\nERROR  -->  SCH : rgSCHTomUtlPrcUlTddSpclSf() Unable to fill"
2806             " SRS recption requests for cell");
2807       RGSCH_FREE_MEM(recpReqInfo);
2808       return ret;
2809    }
2810    /* sending the RecpReq to Phy */
2811    //if (rgSCHUtlTfuRecpReq(inst, cell->tfuSap->sapCfg.suId, recpReqInfo) != ROK)
2812    {
2813       DU_LOG("\nERROR  -->  SCH : rgSCHTomUtlPrcUlTddSpclSf() Unable to send "
2814                                "Cntrl info for cell");
2815    }
2816    return ROK;
2817 } /* end of rgSCHTomUtlPrcUlTddSpclSf */ 
2818 #endif
2819 #endif
2820 /** @brief This function does all the processing related to a single downlink
2821  * subframe.
2822  *
2823  * @details 
2824  *
2825  *     Function: rgSCHTomUtlProcDlSf
2826  *
2827  *         Processing steps:
2828  *         - collate control data for all UEs and send to PHY 
2829  *         - collate data buffers for all UEs and send to PHY 
2830  *
2831  * @param  [in] RgSchDlSf     *dlSf
2832  * @param  [in] RgSchDlSf     *ulSf
2833  * @param  [in] RgSchCellCb   *cell
2834  * @param  [out] RgSchErrInfo *err
2835  * @return S16
2836  */
2837 static S16 rgSCHTomUtlProcDlSf
2838 (
2839 RgSchDlSf            *dlSf,
2840 RgSchDlSf            *ulSf,
2841 RgSchCellCb          *cell,
2842 RgTfuCntrlReqInfo    *cntrlInfo,
2843 RgSchErrInfo         *err
2844 )
2845 {
2846    S16     ret;
2847    uint8_t sfTyp = 1; /* Dl Subframe */
2848
2849       cmLListInit(&cntrlInfo->phichLst);
2850       cmLListInit(&cntrlInfo->dlPdcchLst);
2851       cmLListInit(&cntrlInfo->ulPdcchLst);
2852       
2853 #ifdef TFU_ALLOC_EVENT_NO_INIT
2854       cntrlInfo->ulTiming.sfn = cntrlInfo->ulTiming.subframe = 0;
2855 #endif
2856       cntrlInfo->dlTiming = cell->dlDciTime;
2857       cntrlInfo->cellId   = cell->cellId;
2858       cntrlInfo->ulTiming = cell->hiDci0Time;
2859       if((0 == (cntrlInfo->dlTiming.sfn % 30)) && (0 == cntrlInfo->dlTiming.slot))
2860       {
2861          //DU_LOG("\nERROR  -->  SCH : 5GTF_CHECK rgSCHTomUtlProcDlSf Cntrl dl (%d : %d) ul (%d : %d)\n", \
2862          cntrlInfo->dlTiming.sfn, cntrlInfo->dlTiming.subframe, cntrlInfo->ulTiming.sfn, cntrlInfo->ulTiming.subframe);
2863       }
2864       /* Fill PCFICH info */
2865       /* Fix for DCFI FLE issue: when DL delta is 1 and UL delta is 0 and CFI
2866        *change happens in that SF then UL PDCCH allocation happens with old CFI
2867        *but CFI in control Req goes updated one since it was stored in the CELL
2868        */
2869       cntrlInfo->cfi = dlSf->pdcchInfo.currCfi;
2870 #ifndef RG_ULSCHED_AT_CRC
2871       uint8_t                Mval  = 1;
2872 #ifdef LTE_TDD
2873       Mval = rgSchTddPhichMValTbl[cell->ulDlCfgIdx]
2874                                  [cell->hiDci0Time.subframe];
2875       if(dlSf->sfType == RG_SCH_SPL_SF_DATA)
2876       {
2877          RGSCH_GET_SPS_SF_CFI(cell->bwCfg.dlTotalBw, cntrlInfo->cfi);
2878       }
2879 #endif
2880       if(Mval)
2881       {
2882          /* Fill PHICH info */
2883          if ((ret = rgSCHTomUtlFillPhich (cell, cntrlInfo, ulSf, err)) != ROK)
2884          {
2885             DU_LOG("\nERROR  -->  SCH : Unable to send PHICH info "
2886                      "for cellId (%d)\n", cell->cellId);
2887             RGSCH_FREE_MEM(cntrlInfo);
2888             return ret;
2889          }
2890          if ((ret = rgSCHTomUtlFillUlPdcch (cell, cntrlInfo, ulSf, err)) != 
2891                         ROK)
2892          {
2893             DU_LOG("\nERROR  -->  SCH : Unable to send PDCCH info "
2894                      "for cellId (%d)\n", cell->cellId);
2895             RGSCH_FREE_MEM(cntrlInfo);
2896             return ret;
2897          }
2898       }
2899 #ifdef EMTC_ENABLE
2900       if(0 == cntrlInfo->ulMpdcchLst.count)
2901       {
2902          gUlMpdcchBlank++;
2903       }
2904 #endif
2905 #endif
2906 #ifdef LTE_TDD
2907       sfTyp = rgSchTddUlDlSubfrmTbl[cell->ulDlCfgIdx]
2908                                    [cell->dlDciTime.subframe]; 
2909 #endif      
2910       if (sfTyp != 2) /* Uplink subframe */   
2911       {
2912          /* Fill PDCCH info */
2913          if ((ret = rgSCHTomUtlFillDlPdcch(cell,cntrlInfo, dlSf, err)) != ROK)
2914          {
2915             DU_LOG("\nERROR  -->  SCH : Unable to send PDCCH info "
2916                      "for cellId (%d)\n", cell->cellId);
2917             RGSCH_FREE_MEM(cntrlInfo);
2918             return ret;
2919          }
2920          rgBwAlloInfo[dlSf->sfNum] += dlSf->bwAssigned;
2921          rgBwAlcnt[dlSf->sfNum] ++;
2922
2923       }
2924 #ifdef LTEMAC_SPS /* SPS_NEW_CHGS */
2925       cntrlInfo->isSPSOcc = dlSf->isSPSOcc;
2926 #endif
2927       cntrlInfo->numDlActvUes += dlSf->numDlActvUes;  /* 4UE_TTI_DELTA */
2928       dlSf->numDlActvUes      = 0;
2929 #ifdef EMTC_ENABLE
2930 if(0 == cntrlInfo->dlMpdcchLst.count)
2931 {
2932    gDlMpdcchBlank++;
2933 }
2934 #endif
2935       /* Now always sending down a cntrl req */
2936       /* sending the cntrl data to Phy */
2937       //if (rgSCHUtlTfuCntrlReq(inst, cell->tfuSap->sapCfg.suId, cntrlInfo) 
2938             //!= ROK)
2939       {
2940          DU_LOG("\nERROR  -->  SCH : Unable to send Cntrl info for cell");
2941       }
2942    return ROK;
2943
2944
2945
2946
2947 /** @brief This function handles sending of the PHICH information for the
2948  * downlink subframe to be sent in the next TTI.
2949  *
2950  * @details
2951  *
2952  *     Function: 
2953  *
2954  *         Processing steps:
2955  *         - Loop through the PHICH information present in the downlink
2956  *         subframe and fill the information in cntrlInfo.
2957  *
2958  * @param  [out] TfuCntrlReqInfo *cntrlInfo 
2959  * @param  [in]  RgSchDlSf   *dlSf
2960  * @param  [out] RgSchErrInfo *err
2961  * @return  S16
2962  *      -# ROK 
2963  *      -# RFAILED 
2964  */
2965 static S16 rgSCHTomUtlFillPhich
2966 (
2967 RgSchCellCb     *cell,
2968 TfuCntrlReqInfo    *cntrlInfo,
2969 RgSchDlSf          *dlSf,
2970 RgSchErrInfo       *err
2971 )
2972 {
2973    S16             ret;
2974    CmLList         *node;
2975    RgSchPhich      *phich;
2976    TfuPhichInfo    *harqAck;
2977 #ifdef TFU_UPGRADE
2978    RgSchCmnDlCell   *cellDl = RG_SCH_CMN_GET_DL_CELL(cell);
2979 #endif
2980
2981    ret = ROK;
2982    /* Traversing the list of Phichs */
2983    node =  dlSf->phichInfo.phichs.first;
2984    while (node)
2985    {
2986       phich = (RgSchPhich*)node->node;
2987       if ((ret = rgSCHUtlGetEventMem((Ptr *)&harqAck, sizeof(TfuPhichInfo), 
2988                                 &(cntrlInfo->memCp))) != ROK)
2989       {
2990          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
2991          return ret;
2992       }
2993 #ifdef TFU_ALLOC_EVENT_NO_INIT
2994       harqAck->txPower = 0;
2995 #endif
2996       /* fill in the tfu structure from the information present in the
2997        * phich node */
2998       harqAck->rbStart     = phich->rbStart;
2999       harqAck->nDmrs       = phich->nDmrs;
3000       harqAck->isAck       = phich->hqFeedBack;
3001       harqAck->isForMsg3   = phich->isForMsg3;  /*SR_RACH_STATS : PHICH ACK/NACK for MSG3 */
3002 #ifdef LTE_TDD
3003       /* Changes for passing iPhich at TFU interface*/
3004       harqAck->iPhich      = phich->iPhich;
3005 #endif
3006   /* ccpu00138898 - Added Tx pwr offset for PHICH Tx*/
3007 #ifdef TFU_UPGRADE
3008       harqAck->txPower       = cellDl->phichTxPwrOffset;
3009 #endif
3010       cmLListAdd2Tail(&cntrlInfo->phichLst, &(harqAck->lnk));
3011       harqAck->lnk.node = (PTR)harqAck;
3012       node = node->next;
3013    } /* end of while */
3014    return ret;
3015 } /* end of */ 
3016
3017
3018 #ifdef LTE_ADV
3019 /** @brief This function is a utility function to restart 
3020  * deactivation timer.
3021  *
3022  * @details
3023  *
3024  *     Function: rgSCHTmrRestartScellDeactTmr 
3025  *
3026  *         Processing steps:
3027  *         - Starts timer at scheduler
3028  *         
3029  *   @param[in]  RgSchCellCb    *cell
3030  *   @param[in]  CmLteRnti       rnti
3031  *   @return  Void
3032  */
3033 static Void rgSCHTmrRestartScellDeactTmr
3034 (
3035 RgSchCellCb     *cell,
3036 RgSchUeCb       *ueCb
3037 )
3038 {
3039    RgSchUeCellInfo   *sCellInfo = NULLP;
3040    
3041    if(NULLP != ueCb)
3042    {
3043       if(RG_SCH_IS_CELL_SEC(ueCb, cell))
3044       {
3045          sCellInfo = ueCb->cellInfo[(ueCb->cellIdToCellIdxMap[RG_SCH_CELLINDEX(cell)])];
3046
3047          if(sCellInfo->deactTmr.tmrEvnt != TMR_NONE)
3048          {
3049             rgSCHTmrStopTmr(cell, RG_SCH_TMR_SCELL_DEACT, sCellInfo);
3050          }
3051          if(PRSNT_NODEF == ueCb->sCellDeactTmrVal.pres)
3052          {
3053             /*
3054             rgSCHTmrStartTmr(cell,sCellInfo,RG_SCH_TMR_SCELL_DEACT,
3055                   ueCb->sCellDeactTmrVal.val);
3056             */
3057          }
3058       }
3059    }
3060 }/*end of rgSCHTmrRestartScellDeactTmr*/
3061 #endif
3062
3063 /** @brief This function will send all the PDCCH's for the given downlink
3064  * subframe.
3065  *
3066  * @details
3067  *
3068  *     Function: 
3069  *
3070  *         Processing steps:
3071  *         - Loop through all the scheduled HARQ processes and fill
3072  *           the PDCCH information in cntrlInfo.
3073  *
3074  * @param  [out] TfuCntrlReqInfo *cntrlInfo 
3075  * @param  [in]  RgSchDlSf   *dlSf
3076  * @param  [out] RgSchErrInfo *err
3077  *  @return  S16
3078  *      -# ROK 
3079  *      -# RFAILED 
3080  */
3081 uint32_t numdlSpsRelSentToTf;
3082 static S16 rgSCHTomUtlFillDlPdcch
3083 (
3084 RgSchCellCb     *cell,
3085 TfuCntrlReqInfo *cntrlInfo,
3086 RgSchDlSf       *dlSf,
3087 RgSchErrInfo    *err
3088 )
3089 {
3090    S16          ret;
3091    CmLList      *node;
3092    RgSchPdcch   *pdcch;
3093    TfuPdcchInfo *tfuPdcch;
3094    uint8_t isDcivld = FALSE;
3095    uint8_t            numUePerTti = 0;
3096
3097    ret = ROK;
3098    /* Traversing the scheduled Harq processes */
3099    node =  dlSf->pdcchInfo.pdcchs.first;
3100    while (node)
3101    {
3102       pdcch = (RgSchPdcch*)node->node;
3103        switch(pdcch->dci.dciFormat)
3104        {
3105           case TFU_DCI_FORMAT_3:
3106              isDcivld = (pdcch->dci.u.format3Info.isPucch) ? TRUE : FALSE;
3107              break;
3108
3109           case TFU_DCI_FORMAT_3A:
3110              isDcivld = (pdcch->dci.u.format3AInfo.isPucch) ? TRUE : FALSE;
3111              break;
3112
3113           default:
3114              isDcivld = TRUE;
3115              break;
3116        }
3117       if(!isDcivld) 
3118       {
3119          node = node->next;
3120          continue;
3121       }    
3122
3123       /*ccpu00117179 - ADD - Build only non DCI format-0 messages */
3124       if((pdcch->dci.dciFormat == TFU_DCI_FORMAT_0) ||
3125                         (pdcch->dci.dciFormat == TFU_DCI_FORMAT_A1) ||
3126                         (pdcch->dci.dciFormat == TFU_DCI_FORMAT_A2))
3127       {
3128          node = node->next;
3129          continue;
3130       }
3131
3132
3133 #ifdef RGSCH_SPS_STATS
3134       if((pdcch->dci.dciFormat == TFU_DCI_FORMAT_1A) &&
3135          (pdcch->dci.u.format1aInfo.t.pdschInfo.allocInfo.mcs == 0x1F) &&
3136          (pdcch->dci.u.format1aInfo.t.pdschInfo.allocInfo.alloc.type == TFU_ALLOC_TYPE_RIV) &&
3137          (pdcch->dci.u.format1aInfo.t.pdschInfo.allocInfo.alloc.u.riv == 0xFFFFFFFF))
3138       {
3139          numdlSpsRelSentToTf++;
3140       }
3141 #endif
3142
3143       if ((ret = rgSCHUtlGetEventMem((Ptr *)&tfuPdcch, sizeof(TfuPdcchInfo),
3144                                 &(cntrlInfo->memCp))) != ROK)
3145       {
3146          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
3147          return ret;
3148       }
3149 #ifdef LTEMAC_SPS
3150       tfuPdcch->crnti       = pdcch->crnti;
3151       tfuPdcch->isSpsRnti   = pdcch->isSpsRnti;
3152 #endif
3153       tfuPdcch->rnti       = pdcch->rnti;
3154       
3155 #ifdef LTE_ADV
3156       rgSCHTmrRestartScellDeactTmr(cell,pdcch->ue);
3157 #endif
3158       tfuPdcch->dciNumOfBits = pdcch->dciNumOfBits;
3159
3160       tfuPdcch->nCce       = pdcch->nCce;
3161       tfuPdcch->aggrLvl    = pdcch->aggrLvl;
3162       tfuPdcch->dci        = pdcch->dci;
3163 #ifdef RG_5GTF
3164       //TODO_SID: Need to check these values during INT
3165       tfuPdcch->sectorId = 0;
3166       tfuPdcch->sccIdx = 0;
3167                 tfuPdcch->grpId = 
3168 #endif
3169       /* SR_RACH_STATS : Reset isTBMsg4 */
3170       pdcch->dci.u.format1aInfo.t.pdschInfo.isTBMsg4 = FALSE;        
3171       /* To be enhanced later for 2.1 */
3172       cmLListAdd2Tail(&cntrlInfo->dlPdcchLst, &(tfuPdcch->lnk));
3173       tfuPdcch->lnk.node = (PTR)tfuPdcch;
3174       node = node->next;
3175       if((pdcch->rnti > 60) && (pdcch->rnti < 5000))
3176       {
3177 #if defined (TENB_STATS) && defined (RG_5GTF)
3178          cell->tenbStats->sch.dl5gtfPdcchSend++;
3179 #endif
3180          numUePerTti++;
3181       }
3182    } /* end of while */
3183
3184    if((numUePerTti) && (numUePerTti < RG_MAX_NUM_UE_PER_TTI ))
3185    {
3186       cell->dlNumUeSchedPerTti[numUePerTti-1]++;
3187       {
3188          gDlNumUePerTti[numUePerTti-1]++;
3189       }
3190    }
3191    return ret;
3192 } /* end of rgSCHTomUtlFillDlPdcch*/ 
3193
3194 #ifdef RGSCH_SPS_STATS
3195 uint32_t rgSchSpsRelSentToTf;
3196 uint32_t rgSchSpsRelPdcchAllocd; 
3197 #endif
3198 /** @brief This function will send all the UL PDCCH's for the given
3199  * subframe.
3200  *
3201  * @details
3202  *
3203  *     Function: 
3204  *
3205  *         Processing steps:
3206  *         - Loop through all the scheduled HARQ processes and fill
3207  *           the PDCCH information in cntrlInfo.
3208  *
3209  * @param  [out] TfuCntrlReqInfo *cntrlInfo 
3210  * @param  [in]  RgSchDlSf   *dlSf
3211  * @param  [out] RgSchErrInfo *err
3212  *  @return  S16
3213  *      -# ROK 
3214  *      -# RFAILED 
3215  */
3216 static S16 rgSCHTomUtlFillUlPdcch
3217 (
3218 RgSchCellCb       *cell,
3219 TfuCntrlReqInfo *cntrlInfo,
3220 RgSchDlSf       *dlSf,
3221 RgSchErrInfo    *err
3222 )
3223 {
3224    S16          ret;
3225    CmLList      *node;
3226    RgSchPdcch   *pdcch;
3227    TfuPdcchInfo *tfuPdcch;
3228    uint8_t isDcivld = FALSE;
3229
3230    ret = ROK;
3231    /* Traversing the scheduled Harq processes */
3232    node =  dlSf->pdcchInfo.pdcchs.first;
3233    while (node)
3234    {
3235       pdcch = (RgSchPdcch*)node->node;
3236       node = node->next;
3237       /*ccpu00116712- Function should pick only UL allocation related control
3238        * info- start */
3239        switch(pdcch->dci.dciFormat)
3240        {
3241           case TFU_DCI_FORMAT_A1:
3242              isDcivld = TRUE;
3243              break;
3244
3245                          case TFU_DCI_FORMAT_A2:
3246              isDcivld = TRUE;
3247              break;
3248
3249           case TFU_DCI_FORMAT_3:
3250              isDcivld = (pdcch->dci.u.format3Info.isPucch) ? FALSE : TRUE;
3251              break;
3252
3253           case TFU_DCI_FORMAT_3A:
3254              isDcivld = (pdcch->dci.u.format3AInfo.isPucch) ? FALSE : TRUE;
3255              break;
3256
3257           default:
3258              isDcivld = FALSE;
3259              break;
3260        }
3261       if(!isDcivld) 
3262       {    
3263          continue;
3264       } 
3265 #ifdef CA_DBG
3266       gDci0Count++;
3267 #endif
3268
3269       /*ccpu00116712- Function should pick only UL allocation related control
3270        * info- end */
3271       if ((ret = rgSCHUtlGetEventMem((Ptr *)&tfuPdcch, sizeof(TfuPdcchInfo),
3272                   &(cntrlInfo->memCp))) != ROK)
3273       {
3274          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
3275          return ret;
3276       }
3277       tfuPdcch->rnti       = pdcch->rnti;
3278 #ifdef LTE_ADV
3279       rgSCHTmrRestartScellDeactTmr(cell,pdcch->ue);
3280 #endif
3281       tfuPdcch->dciNumOfBits = pdcch->dciNumOfBits;
3282
3283       tfuPdcch->nCce       = pdcch->nCce;
3284       tfuPdcch->aggrLvl    = pdcch->aggrLvl;
3285       tfuPdcch->dci        = pdcch->dci;
3286 #ifdef RG_5GTF
3287       //TODO_SID: Need to check these values during INT
3288       tfuPdcch->sectorId = 0;
3289       tfuPdcch->sccIdx = 0;
3290                 tfuPdcch->grpId = 
3291 #endif
3292       /* To be enhanced later for 2.1 */
3293       gUl5gtfPdcchSend++;
3294 #if defined (TENB_STATS) && defined (RG_5GTF)
3295       cell->tenbStats->sch.ul5gtfPdcchSend++;
3296 #endif
3297       cmLListAdd2Tail(&cntrlInfo->ulPdcchLst, &(tfuPdcch->lnk));
3298       tfuPdcch->lnk.node = (PTR)tfuPdcch;
3299    } /* end of while */
3300
3301 #ifdef RGSCH_SPS_STATS
3302    if (rgSchSpsRelSentToTf != rgSchSpsRelPdcchAllocd)
3303    {
3304      //   abort();
3305    }
3306 #endif
3307    return ret;
3308 } /* end of rgSCHTomUtlFillUlPdcch*/ 
3309
3310 /** @brief This function does the processing for Timing adjustment.
3311  *
3312  * @details
3313  *
3314  *     Function: 
3315  *
3316  *         Processing steps:
3317  *         - Loop through the ue present ueTimeLst, decrement the remaining
3318  *         frames left. 
3319  *
3320  *
3321  * @param  [in] RgSchCellCb   *cell
3322  *  @return  S16
3323  *      -# ROK 
3324  *      -# RFAILED 
3325  */
3326 static S16 rgSCHTomUtlProcTA(RgSchCellCb    *cell)
3327 {
3328    CmLList     *node;
3329    RgSchUeCb   *ue;
3330
3331    node =  cell->taUeLst.first;
3332    while (node)
3333    {
3334       ue = (RgSchUeCb *)node->node;
3335       node = node->next;
3336       if (ue->dl.taCb.numRemSf == 0)
3337       {
3338          ue->dl.taCb.state = RGSCH_TA_IDLE;
3339          /* If Outstanding Ta is present, schedule it */
3340          if(ue->dl.taCb.outStndngTa == TRUE)
3341          {
3342             rgSCHUtlReTxTa(cell, ue);
3343          }
3344          else
3345          {
3346             /* We need to reset state and also value of TA, 
3347              * then we start the timer */
3348             ue->dl.taCb.ta = RGSCH_NO_TA_RQD;
3349             /* Start the timer only if TA is cfgd as FINITE value */
3350             if (ue->dl.taCb.cfgTaTmr)
3351             {
3352                rgSCHTmrStartTmr (cell, ue, RG_SCH_TMR_TA, ue->dl.taCb.cfgTaTmr);
3353             }
3354          }
3355          /* need to delete from the link list */
3356          cmLListDelFrm(&(cell->taUeLst), &(ue->taLnk));
3357          ue->taLnk.node = NULLP;
3358       }
3359       else
3360       {
3361          ue->dl.taCb.numRemSf--;
3362       }
3363    } /* end of taUeLst */
3364    return ROK;
3365 } /* end of rgSCHTomUtlProcTA */ 
3366
3367 /** @brief This function handles filling of Hq reception request to
3368  *   Per Hq Proc.
3369  *
3370  * @details
3371  *
3372  *     Function: 
3373  *
3374  *         Processing steps:
3375  *
3376  *  @return  S16
3377  *      -# ROK 
3378  *      -# RFAILED 
3379  */
3380 #ifdef TFU_UPGRADE
3381 S16 rgSCHTomUtlFillHqFdbkInfo
3382 (
3383 TfuRecpReqInfo          *recpReqInfo,
3384 RgSchCellCb             *cell,
3385 uint16_t                validIdx,
3386 RgSchDlHqProcCb         *hqCb,
3387 RgSchDlSf               *nxtDlsf,
3388 TfuUeRecpReqInfo        *pucchRecpInfo,
3389 RgSchDlHqProcCb         *prvHqCb,
3390 RgSchErrInfo            *err
3391 )
3392 #else
3393 S16 rgSCHTomUtlFillHqFdbkInfo
3394 (
3395 TfuRecpReqInfo          *recpReqInfo,
3396 RgSchCellCb             *cell,
3397 RgSchDlHqProcCb         *hqCb,
3398 RgSchDlSf               *nxtDlsf,
3399 TfuUeRecpReqInfo        *pucchRecpInfo,
3400 RgSchDlHqProcCb         *prvHqCb,
3401 RgSchErrInfo            *err
3402 )
3403 #endif 
3404
3405    S16                  ret;
3406    RgSchDlHqTbCb        *tbCb;
3407    uint32_t             idx;
3408    Bool                 isAddToLst = FALSE;
3409
3410    for (idx = 0 ;idx < 2; idx++)
3411    {
3412       if (HQ_TB_WAITING == hqCb->tbInfo[idx].state)
3413       {
3414          tbCb = &hqCb->tbInfo[idx];
3415
3416          /* FOR ACK NAK REP */
3417          if ((hqCb->hqE->ue != NULLP) &&
3418                (hqCb->hqE->ue->measGapCb.isMeasuring == TRUE))
3419          {
3420             if ((tbCb->fbkRecpRepCntr) && 
3421                   (--tbCb->fbkRecpRepCntr))
3422             {
3423                /* Add to next subfarme */
3424                /* Add this hqCb to the next dlSf's ackNakRepQ */
3425                cmLListAdd2Tail (&(nxtDlsf->ackNakRepQ), 
3426                      &(tbCb->anRepLnk[tbCb->fbkRecpRepCntr]));
3427                tbCb->anRepLnk[tbCb->fbkRecpRepCntr].node = (PTR)tbCb;
3428                tbCb->crntSubfrm[tbCb->fbkRecpRepCntr] = nxtDlsf;
3429             }
3430 #ifdef TFU_UPGRADE
3431             rgSCHTomUtlMoveNxtOccasion(cell, hqCb->hqE->ue, validIdx);
3432 #endif 
3433             continue;
3434          }
3435 #ifdef TFU_UPGRADE
3436          if (hqCb->tbCnt) 
3437          {
3438             hqCb->tbCnt--;
3439             /* Go to the next node */
3440             continue;
3441          }
3442 #endif
3443
3444
3445          //if (hqCb != prvHqCb) 
3446          {
3447             ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
3448                   sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
3449             if (ret != ROK)
3450             {
3451                DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for cell");
3452                err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
3453                return ret;
3454             }
3455             pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
3456             if ((hqCb->hqE->ue != NULLP) /*&& 
3457                                            ((tbCb->lchSchdData[0].lcId != 0) || (tbCb->taSnt ==
3458                                            TRUE))*/
3459                )
3460             {
3461                pucchRecpInfo->rnti = hqCb->hqE->ue->ueId;
3462             }
3463             else
3464             {
3465                if (hqCb->hqE->raCb)
3466                {
3467                   pucchRecpInfo->rnti    =  hqCb->hqE->raCb->tmpCrnti;
3468                }
3469             }
3470 #ifndef TFU_UPGRADE
3471 #ifndef TFU_TDD         
3472 #ifdef LTEMAC_SPS
3473             if (!hqCb->spsN1PucchRes.pres)
3474 #endif
3475             {
3476                pucchRecpInfo->t.pucchRecpReq.hqType = 
3477                   TFU_HQ_RECP_REQ_NORMAL;
3478                pucchRecpInfo->t.pucchRecpReq.t.nCce = 
3479                   hqCb->pdcch->nCce;
3480             }
3481 #ifdef LTEMAC_SPS
3482             else
3483             {
3484                pucchRecpInfo->t.pucchRecpReq.hqType = 
3485                   TFU_HQ_RECP_REQ_N1PUCCH;
3486                pucchRecpInfo->t.pucchRecpReq.t.n1Pucch =
3487                   hqCb->spsN1PucchRes.val;
3488             }
3489 #endif
3490 #endif
3491             /* Handling of other types */
3492             pucchRecpInfo->t.pucchRecpReq.type = TFU_UCI_HARQ;
3493 #else   /* TFU_UPGRADE */
3494             pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ;
3495             if ((hqCb->tbInfo[0].state == HQ_TB_WAITING) && 
3496                   (hqCb->tbInfo[1].state == HQ_TB_WAITING))
3497             {
3498                pucchRecpInfo->t.pucchRecpReq.hqInfo.hqSz = 2; /* MIMO */
3499             }
3500             else
3501             {
3502                pucchRecpInfo->t.pucchRecpReq.hqInfo.hqSz = 1; /* NON-MIMO */ 
3503             }
3504             {
3505 #ifdef LTEMAC_SPS
3506                /* PucchRecpReq needs to be filled up for n1Pucch resource for SPS
3507                 * ocassions */
3508                if (hqCb->spsN1PucchRes.pres)
3509                {
3510                   pucchRecpInfo->t.pucchRecpReq.hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
3511                }
3512                else
3513 #endif /* LTEMAC_SPS */
3514                {
3515                   pucchRecpInfo->t.pucchRecpReq.hqInfo.hqRes[0] = (hqCb->pdcch->nCce +
3516                         cell->pucchCfg.n1PucchAn);
3517                }
3518 #ifdef EMTC_ENABLE
3519                rgSCHEmtcFillPucchRecpInfo(cell, hqCb, &(pucchRecpInfo->t.pucchRecpReq.hqInfo.hqRes[0]));
3520 #endif
3521             }
3522 #endif/*TFU_UPGRADE*/
3523
3524 #ifdef TFU_UPGRADE
3525             rgSCHTomUtlFillCqiSrSrsWithHq(cell,recpReqInfo, hqCb->hqE->ue, 
3526                   pucchRecpInfo, validIdx,FALSE);    
3527 #endif 
3528 #ifdef EMTC_ENABLE
3529             /* Passing last parameter as FALSE in this case as it will be verified from hqCb*/
3530             isAddToLst = rgSCHEmtcAddRecpInfoToLst(hqCb,recpReqInfo, pucchRecpInfo,FALSE);
3531 #endif
3532             if(!isAddToLst)
3533             {
3534                cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
3535             }
3536             pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
3537          }
3538
3539          if ((tbCb->fbkRecpRepCntr) && 
3540                (--tbCb->fbkRecpRepCntr))
3541          {
3542             /* Add to next subfarme */
3543             /* Add this hqCb to the next dlSf's ackNakRepQ */
3544             cmLListAdd2Tail (&(nxtDlsf->ackNakRepQ), 
3545                   &(tbCb->anRepLnk[tbCb->fbkRecpRepCntr]));
3546             tbCb->anRepLnk[tbCb->fbkRecpRepCntr].node = (PTR)tbCb;
3547             tbCb->crntSubfrm[tbCb->fbkRecpRepCntr] = nxtDlsf;
3548          }
3549          break;
3550       }
3551    }
3552    return ROK;
3553 }/* end of rgSCHTomUtlFillHqFdbkInfo */
3554
3555 #ifdef RG_5GTF 
3556 /** @brief This function handles filling of Hq reception request to
3557  *   Per Hq Proc.
3558  *
3559  * @details
3560  *
3561  *     Function:rgSCHTomUtlFillHqFdbkFor5gtf 
3562  *
3563  *         Processing steps:
3564  *
3565  * @param  [out] TfuRecpReqInfo   *recpReqInfo
3566  * @param  [in]  RgSchCellCb      *cell
3567  * @param  [in]  uint16_t              validIdx,
3568  * @param  [in]  RgSchDlHqInfo    *dlSfHqInfo,
3569  * @param  [in]  RgSchDlSf        *dlSf,
3570  * @param  [in]  TfuUeRecpReqInfo *pucchRecpInfo,
3571  * @param  [out] RgSchErrInfo     *err
3572  *
3573  *  @return  S16
3574  *      -# ROK 
3575  *      -# RFAILED 
3576  */
3577 static S16 rgSCHTomUtlFillHqFdbkFor5gtf
3578 (
3579 TfuRecpReqInfo          *recpReqInfo,
3580 RgSchCellCb             *cell,
3581 uint16_t                validIdx,
3582 RgSchDlHqInfo           *dlSfHqInfo,
3583 RgSchDlSf               *dlSf,
3584 TfuUeRecpReqInfo        *pucchRecpInfo,
3585 RgSchErrInfo            *err
3586 )
3587
3588    S16                  ret;
3589    RgSchUeCb            *ue;
3590    TfuUePucchRecpReq    *pucchReqInfo = NULLP;
3591
3592    ue = (RgSchUeCb*)dlSfHqInfo->dlSfUeLnk.node;
3593    
3594    if (ue == NULLP)
3595    {
3596       return RFAILED;
3597         }
3598    ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
3599          sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
3600    if (ret != ROK)
3601    {
3602       DU_LOG("\nERROR  -->  SCH : Unable to Allocate "
3603                "TfuUeRecpReqInfo for cellId=%d \n", cell->cellId);
3604       err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
3605       return ret;
3606    }
3607    pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
3608    pucchRecpInfo->rnti = ue->ueId; /* Even for Rel pdcch also setting CRNTI
3609                                       * instead of SPS-CRNTI */
3610
3611    pucchReqInfo = &(pucchRecpInfo->t.pucchRecpReq);
3612
3613    pucchReqInfo->uciInfo = TFU_XPUCCH_UCI_INFO;
3614
3615    /* 5gtf TODO : Hardcoded nPUCCHIdx */
3616    pucchReqInfo->uciPduInfo.pucchIndex = 0;
3617
3618    pucchReqInfo->uciPduInfo.numBits = 1;
3619          
3620    /* 5gtf TODO : CQI Periodicity Hardcoded to (n,0)*/
3621    if (RGSCH_TIMEINFO_SAME (recpReqInfo->timingInfo, ue->ue5gtfCb.nxtCqiRiOccn)) 
3622    {
3623       pucchReqInfo->uciPduInfo.numBits += 5;
3624       RG_SCH_ADD_TO_CRNT_TIME(recpReqInfo->timingInfo, ue->ue5gtfCb.nxtCqiRiOccn,
3625                               ue->ue5gtfCb.cqiRiPer);
3626    }
3627    
3628    cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
3629    pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
3630    return ROK;
3631 }/* end of rgSCHTomUtlFillHqFdbkForFrmt1B */
3632 #endif
3633
3634 #ifdef LTE_ADV
3635 /** @brief This function handles filling of Hq reception request to
3636  *   Per Hq Proc.
3637  *
3638  * @details
3639  *
3640  *     Function:rgSCHTomUtlFillHqFdbkForFrmt1B 
3641  *
3642  *         Processing steps:
3643  *         Allocates the N1Pucch Resources based on teh A Value
3644  *
3645  * @param  [out] TfuRecpReqInfo   *recpReqInfo
3646  * @param  [in]  RgSchCellCb      *cell
3647  * @param  [in]  uint16_t              validIdx,
3648  * @param  [in]  RgSchDlHqInfo    *dlSfHqInfo,
3649  * @param  [in]  RgSchDlSf        *dlSf,
3650  * @param  [in]  TfuUeRecpReqInfo *pucchRecpInfo,
3651  * @param  [out] RgSchErrInfo     *err
3652  *
3653  *  @return  S16
3654  *      -# ROK 
3655  *      -# RFAILED 
3656  */
3657 #ifdef TFU_UPGRADE
3658 static S16 rgSCHTomUtlFillHqFdbkForFrmt1B
3659 (
3660 TfuRecpReqInfo          *recpReqInfo,
3661 RgSchCellCb             *cell,
3662 uint16_t                     validIdx,
3663 RgSchDlHqInfo           *dlSfHqInfo,
3664 RgSchDlSf               *dlSf,
3665 TfuUeRecpReqInfo        *pucchRecpInfo,
3666 RgSchErrInfo            *err
3667 )
3668 #else
3669 static S16 rgSCHTomUtlFillHqFdbkForFrmt1B
3670 (
3671 TfuRecpReqInfo          *recpReqInfo,
3672 RgSchCellCb             *cell,
3673 RgSchDlHqInfo           *dlSfHqInfo,
3674 RgSchDlSf               *dlSf,
3675 TfuUeRecpReqInfo        *pucchRecpInfo,
3676 RgSchErrInfo            *err
3677 )
3678 #endif 
3679
3680 #ifdef DEBUGP
3681    Inst                 inst = cell->instIdx;
3682 #endif
3683    S16                  ret;
3684    CmLList              *hqPNode;
3685    RgSchDlHqProcCb      *hqCb = NULLP;
3686    RgSchUeCb            *ue;
3687    TfuUePucchRecpReq    *pucchReqInfo = NULLP;
3688    Bool                 isDatPresOnSecCell = FALSE;
3689    uint8_t              primCellTbCount = 0;
3690
3691    hqPNode = dlSfHqInfo->hqPLst.first;
3692    ue = (RgSchUeCb*)dlSfHqInfo->dlSfUeLnk.node;
3693    
3694    if (ue == NULLP)
3695    {
3696       return RFAILED;
3697         }
3698    ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
3699          sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
3700    if (ret != ROK)
3701    {
3702       DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for cellId=%d \n", cell->cellId);
3703       err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
3704       return ret;
3705    }
3706    pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
3707    pucchRecpInfo->rnti = ue->ueId; /* Even for Rel pdcch also setting CRNTI
3708                                       * instead of SPS-CRNTI */
3709
3710    pucchReqInfo = &(pucchRecpInfo->t.pucchRecpReq);
3711
3712 #ifndef TFU_UPGRADE
3713    pucchReqInfo->hqType = TFU_HQ_RECP_REQ_NORMAL;
3714    /* Handling of other types */
3715    pucchReqInfo->type = TFU_UCI_HARQ;
3716 #else   /* TFU_UPGRADE */
3717    pucchReqInfo->uciInfo = TFU_PUCCH_HARQ;
3718    /* Fill hqFdbkMode by using uciFrmtTyp from dlSfHqInfo */
3719    pucchReqInfo->hqInfo.hqFdbkMode = rgSchUtlGetFdbkMode(dlSfHqInfo->uciFrmtTyp);
3720    /* Fill HqSz by using totalTbCnt based on the TM mode and
3721     * the number of serv cells configured*/
3722
3723    pucchReqInfo->hqInfo.hqSz = ue->f1bCsAVal;
3724    pucchReqInfo->hqInfo.pucchResCnt = ue->f1bCsAVal;
3725
3726   memset(pucchReqInfo->hqInfo.hqRes,0xff,sizeof(uint16_t)*TFU_MAX_HQ_RES);
3727 #ifdef LTEMAC_SPS
3728    /* Two Resources needs to be configured if the 
3729     * serving cell is in mimo mode else single
3730     * resource */
3731    if ((dlSf->relPdcch != NULLP) && 
3732          (RGSCH_TIMEINFO_SAME(recpReqInfo->timingInfo, ue->relPdcchFbkTiming)))
3733    {/* Pcell is having sps rel pdcch present */
3734       if(rgSCHUtlGetMaxTbSupp(ue->mimoInfo.txMode) > 1)
3735       {/* prim cell is in mimo mode, use 0 and 1 */
3736          pucchReqInfo->hqInfo.hqRes[0] = (dlSf->relPdcch->nCce +
3737                                           cell->pucchCfg.n1PucchAn);
3738          pucchReqInfo->hqInfo.hqRes[1] = pucchReqInfo->hqInfo.hqRes[0] + 1; 
3739                                         
3740              
3741       }else
3742       {
3743          pucchReqInfo->hqInfo.hqRes[2] = (dlSf->relPdcch->nCce +
3744                                           cell->pucchCfg.n1PucchAn);
3745       }
3746       /* Release the pdcch  so that it will not further processed */
3747       rgSCHUtlPdcchPut(ue->cell,&dlSf->pdcchInfo, dlSf->relPdcch);
3748       dlSf->relPdcch = NULLP;/* only one UE will be scheduled for release pdcch order in one tti */
3749    }
3750 #endif/*LTEMAC_SPS*/
3751 #endif/*TFU_UPGRADE*/
3752    while(hqPNode)
3753    {
3754       hqCb = (RgSchDlHqProcCb *)hqPNode->node;
3755       hqPNode = hqPNode->next;
3756       /* In case of CSI + 1BCS , CSI will be 
3757        * dropped if scheduling is present on
3758        * seconday cell.36.213 10.1.1
3759        * */
3760       if(RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell))
3761       {
3762          isDatPresOnSecCell = TRUE;
3763       }else
3764       {
3765          if ((hqCb->tbInfo[0].state == HQ_TB_WAITING) && 
3766              (hqCb->tbInfo[1].state == HQ_TB_WAITING))
3767          {
3768             primCellTbCount = 2;
3769          }else
3770          {
3771             primCellTbCount = 1;
3772          }
3773       }
3774 #ifndef TFU_UPGRADE
3775       pucchReqInfo->t.nCce = hqCb->pdcch->nCce;
3776 #else
3777       {
3778          switch(ue->f1bCsAVal)
3779          {/* A Value */
3780             case RG_SCH_A_VAL_2:
3781                /* harq(0) is primary harq(1) is secondary) */
3782                if(RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell))
3783                {
3784                    pucchReqInfo->hqInfo.hqRes[1] = ue->n1PucchF1bResCb.\
3785                                                    cw1N1Res[hqCb->tpc].n1PucchIdx;
3786                }
3787                else/* primary cell */
3788                {
3789 #ifdef LTEMAC_SPS
3790                   /* Need to consider only sps occasions */
3791                   if (hqCb->spsN1PucchRes.pres)
3792                   {
3793                      pucchReqInfo->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
3794                   }
3795                   else
3796 #endif /* LTEMAC_SPS */
3797                   {
3798
3799                      pucchReqInfo->hqInfo.hqRes[0] = (hqCb->pdcch->nCce +
3800                            cell->pucchCfg.n1PucchAn);
3801                   }
3802                }
3803                break;
3804             case RG_SCH_A_VAL_3:
3805                /* Serving cell in mimo mode should be
3806                 * in 0 and 1 and the serving cell in siso
3807                 * mode should be in 2 indices */
3808                if(RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell))
3809                {
3810                    uint8_t cellIdx = ue->cellIdToCellIdxMap[RG_SCH_CELLINDEX(hqCb->hqE->cell)];
3811                    if(rgSCHUtlGetMaxTbSupp(ue->cellInfo[cellIdx]->txMode.txModeEnum) > 1)
3812                    {/* Sec cell is in mimo mode, use 0 and 1 */
3813                       pucchReqInfo->hqInfo.hqRes[0] = 
3814                          ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
3815
3816                       pucchReqInfo->hqInfo.hqRes[1] = 
3817                             ue->n1PucchF1bResCb.cw2N1Res[hqCb->tpc].n1PucchIdx;
3818                    }
3819                    else
3820                    {/* Sec cell is in siso mode, use 2 */
3821                       pucchReqInfo->hqInfo.hqRes[2] = 
3822                          ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
3823                    }   
3824                }
3825                else
3826                {/* primary cell hq */
3827                   if(rgSCHUtlGetMaxTbSupp(ue->mimoInfo.txMode) > 1)
3828                   {/* prim cell is in mimo mode, use 0 and 1 */
3829 #ifdef LTEMAC_SPS
3830                      if (hqCb->spsN1PucchRes.pres)
3831                      {/* SPS occasions */
3832                         pucchReqInfo->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
3833                         pucchReqInfo->hqInfo.hqRes[1] = hqCb->spsN1PucchRes.val + 1;
3834                      }
3835                      else
3836 #endif /* LTEMAC_SPS */
3837                      {
3838                         pucchReqInfo->hqInfo.hqRes[0] = (hqCb->pdcch->nCce +
3839                               cell->pucchCfg.n1PucchAn);
3840                         pucchReqInfo->hqInfo.hqRes[1] = (hqCb->pdcch->nCce +
3841                                  cell->pucchCfg.n1PucchAn + 1);
3842                      }
3843                   }
3844                   else
3845                   {/* prim cell is in siso mode use 2 */
3846 #ifdef LTEMAC_SPS
3847                      /* Need to consider only sps occasions */
3848                      if (hqCb->spsN1PucchRes.pres)
3849                      {
3850                         pucchReqInfo->hqInfo.hqRes[2] = hqCb->spsN1PucchRes.val;
3851                      }
3852                      else
3853 #endif /* LTEMAC_SPS */
3854                      {
3855
3856                         pucchReqInfo->hqInfo.hqRes[2] = (hqCb->pdcch->nCce +
3857                               cell->pucchCfg.n1PucchAn);
3858
3859                      }
3860                   }
3861                }
3862                break;
3863             case RG_SCH_A_VAL_4:
3864                {
3865                   if(RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell))
3866                   {/*  2 and 3 for sec cell */
3867                      pucchReqInfo->hqInfo.hqRes[2] = 
3868                         ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
3869                      pucchReqInfo->hqInfo.hqRes[3] = 
3870                         ue->n1PucchF1bResCb.cw2N1Res[hqCb->tpc].n1PucchIdx;
3871                   }
3872                   else/* primary cell */
3873                   {/* 0 and 1 are for primary cell */
3874 #ifdef LTEMAC_SPS
3875                      /* Need to consider only sps occasions */
3876                      if (hqCb->spsN1PucchRes.pres)
3877                      {
3878                         pucchReqInfo->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
3879                         pucchReqInfo->hqInfo.hqRes[1] = hqCb->spsN1PucchRes.val + 1;
3880                      }
3881                      else
3882 #endif /* LTEMAC_SPS */
3883                      {
3884
3885                         pucchReqInfo->hqInfo.hqRes[0] = (hqCb->pdcch->nCce +
3886                               cell->pucchCfg.n1PucchAn);
3887                         pucchReqInfo->hqInfo.hqRes[1] = (hqCb->pdcch->nCce +
3888                               cell->pucchCfg.n1PucchAn + 1);
3889                      }
3890                   }
3891                }
3892
3893                break;
3894             default:
3895                /* TOD:: Add error print */
3896                break;
3897          }
3898       }
3899 #endif/*TFU_UPGRADE*/
3900    }
3901 #ifdef TFU_UPGRADE
3902
3903 #ifdef CA_DBG
3904    {
3905       gF1bCsCount++;
3906       gF1bCsPres = TRUE;
3907    }
3908
3909 #endif
3910    rgSCHTomUtlFillCqiSrSrsWithHq(cell,recpReqInfo, ue, 
3911          pucchRecpInfo, validIdx,isDatPresOnSecCell);    
3912
3913    /* Channel selection wil not be used in case of
3914     * CQI + HARQ. if the data was present only on 
3915     * primary cell */
3916    if((isDatPresOnSecCell == FALSE) &&
3917       (dlSfHqInfo->uciFrmtTyp == RG_SCH_UCI_FORMAT1B_CS))
3918    {/* Data is present only on primary cell */
3919     
3920       switch(pucchReqInfo->uciInfo)
3921       {
3922          case TFU_PUCCH_HARQ_SRS:
3923          case TFU_PUCCH_HARQ_CQI:
3924          case TFU_PUCCH_HARQ_SR_SRS:
3925          case TFU_PUCCH_HARQ_SR_CQI:
3926             {
3927                dlSfHqInfo->uciFrmtTyp          = RG_SCH_UCI_FORMAT1A_1B;
3928                pucchReqInfo->hqInfo.hqSz       = primCellTbCount;
3929                pucchReqInfo->hqInfo.hqFdbkMode = rgSchUtlGetFdbkMode(dlSfHqInfo->uciFrmtTyp);
3930             }
3931             break;
3932          default:
3933             {
3934                break;
3935             }
3936       }
3937    }
3938 #endif/*TFU_UPGRADE*/
3939    cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
3940    pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
3941    return ROK;
3942 }/* end of rgSCHTomUtlFillHqFdbkForFrmt1B */
3943 /** @brief This function handles filling of Hq reception request to
3944  *   Per Hq Proc.
3945  *
3946  * @details
3947  *
3948  *     Function:rgSCHTomUtlFillHqFdbkForFrmt3 
3949  *
3950  *         Processing steps:
3951  *         Allocates the N1Pucch Resources based on teh A Value
3952  *
3953  * @param  [out] TfuRecpReqInfo   *recpReqInfo
3954  * @param  [in]  RgSchCellCb      *cell
3955  * @param  [in]  uint16_t              validIdx,
3956  * @param  [in]  RgSchDlHqInfo    *dlSfHqInfo,
3957  * @param  [in]  RgSchDlSf        *dlSf,
3958  * @param  [in]  TfuUeRecpReqInfo *pucchRecpInfo,
3959  * @param  [out] RgSchErrInfo     *err
3960  *
3961  *  @return  S16
3962  *      -# ROK 
3963  *      -# RFAILED 
3964  */
3965 #ifdef TFU_UPGRADE
3966 static S16 rgSCHTomUtlFillHqFdbkForFrmt3
3967 (
3968 TfuRecpReqInfo          *recpReqInfo,
3969 RgSchCellCb             *cell,
3970 uint16_t                     validIdx,
3971 RgSchDlHqInfo           *dlSfHqInfo,
3972 RgSchDlSf               *dlSf,
3973 TfuUeRecpReqInfo        *pucchRecpInfo,
3974 RgSchErrInfo            *err
3975 )
3976 #else
3977 static S16 rgSCHTomUtlFillHqFdbkForFrmt3
3978 (
3979 TfuRecpReqInfo          *recpReqInfo,
3980 RgSchCellCb             *cell,
3981 RgSchDlHqInfo           *dlSfHqInfo,
3982 RgSchDlSf               *dlSf,
3983 TfuUeRecpReqInfo        *pucchRecpInfo,
3984 RgSchErrInfo            *err
3985 )
3986 #endif 
3987
3988 #ifdef DEBUGP
3989    Inst                 inst = cell->instIdx;
3990 #endif
3991    S16                  ret;
3992    //CmLList              *hqPNode;
3993    RgSchUeCb            *ue;
3994    TfuUePucchRecpReq    *pucchReqInfo = NULLP;
3995
3996    //hqPNode = dlSfHqInfo->hqPLst.first;
3997    ue = (RgSchUeCb*)dlSfHqInfo->dlSfUeLnk.node;
3998    
3999    if (ue == NULLP)
4000    {
4001       return RFAILED;
4002         }
4003    ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4004          sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
4005    if (ret != ROK)
4006    {
4007       DU_LOG("\nERROR  -->  SCH : Unable to Allocate "
4008                "TfuUeRecpReqInfo for cellId=%d \n", cell->cellId);
4009       err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4010       return ret;
4011    }
4012    pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
4013    pucchRecpInfo->rnti = ue->ueId; /* Even for Rel pdcch also setting CRNTI
4014                                       * instead of SPS-CRNTI */
4015
4016    pucchReqInfo = &(pucchRecpInfo->t.pucchRecpReq);
4017
4018 #ifndef TFU_UPGRADE
4019    pucchReqInfo->hqType = TFU_HQ_RECP_REQ_NORMAL;
4020    /* Handling of other types */
4021    pucchReqInfo->type = TFU_UCI_HARQ;
4022 #else   /* TFU_UPGRADE */
4023    pucchReqInfo->uciInfo = TFU_PUCCH_HARQ;
4024    /* Fill hqFdbkMode by using uciFrmtTyp from dlSfHqInfo */
4025    pucchReqInfo->hqInfo.hqFdbkMode = rgSchUtlGetFdbkMode(dlSfHqInfo->uciFrmtTyp);
4026    /* Fill HqSz by using totalTbCnt based on the TM mode and
4027     * the number of serv cells configured*/
4028
4029    pucchReqInfo->hqInfo.hqSz = ue->f1bCsAVal;
4030    pucchReqInfo->hqInfo.pucchResCnt = 1;
4031
4032   memset(pucchReqInfo->hqInfo.hqRes,0xff,sizeof(uint16_t)*TFU_MAX_HQ_RES);
4033 #endif/*TFU_UPGRADE*/
4034    pucchReqInfo->hqInfo.hqRes[0] = dlSfHqInfo->n3ScellPucch.n3PucchIdx; 
4035 #ifdef TFU_UPGRADE
4036    rgSCHTomUtlFillCqiSrSrsWithHq(cell,recpReqInfo, ue, 
4037          pucchRecpInfo, validIdx,TRUE);    
4038 #endif/*TFU_UPGRADE*/
4039    cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4040    pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4041    return ROK;
4042 }/* end of rgSCHTomUtlFillHqFdbkForFrmt3 */
4043
4044 #endif/*LTE_ADV*/
4045
4046 /** @brief This function handles filling of HARQ feedback recption request to
4047  * PHY.
4048  *
4049  * @details
4050  *
4051  *     Function: 
4052  *
4053  *         Processing steps:
4054  *
4055  * @param  [out] TfuRecpReqInfo *recpReqInfo
4056  * @param  [in]  RgSchCellCb   *cell
4057  * @param  [out] RgSchErrInfo *err
4058  *  @return  S16
4059  *      -# ROK 
4060  *      -# RFAILED 
4061  */
4062 #ifdef TFU_UPGRADE
4063 static S16 rgSCHTomUtlFillHqFdbkRecpReq
4064 (
4065 TfuRecpReqInfo    *recpReqInfo,
4066 RgSchCellCb       *cell,
4067 uint16_t          validIdx,
4068 RgSchErrInfo      *err
4069 )
4070 #else
4071 static S16 rgSCHTomUtlFillHqFdbkRecpReq
4072 (
4073 TfuRecpReqInfo    *recpReqInfo,
4074 RgSchCellCb       *cell,
4075 RgSchErrInfo      *err
4076 )
4077 #endif 
4078 {
4079    CmLList              *node;
4080    RgSchDlHqProcCb      *hqCb;
4081    CmLteTimingInfo      futTime;
4082    RgSchDlSf            *dlSf;
4083    RgSchDlSf            *nxtDlsf;
4084    TfuUeRecpReqInfo     *pucchRecpInfo = NULLP;
4085    RgSchUeCb            *ue;
4086    RgSchDlHqProcCb      *prvHqCb=NULLP;
4087
4088 #ifdef CA_DBG
4089    {
4090       gF1bCsPres = FALSE;
4091    }
4092 #endif
4093    /* ccpu00133109: Removed RGSCHSUBFRMCRNTTIME as it is not giving proper output 
4094     * if diff is more than 10. Instead using RGSCHDECRFRMCRNTTIME() as it is 
4095     * serving the purpose */
4096    RGSCHDECRFRMCRNTTIME(cell->crntTime, futTime, (RG_SCH_CMN_HARQ_INTERVAL - 
4097        TFU_RECPREQ_DLDELTA));
4098    dlSf = rgSCHUtlSubFrmGet (cell, futTime);
4099    /* Get the next dlsf as well */
4100    RG_SCH_ADD_TO_CRNT_TIME(futTime, futTime, 1)
4101    nxtDlsf = rgSCHUtlSubFrmGet (cell, futTime);
4102
4103    prvHqCb = NULLP;
4104
4105    if (dlSf->ueLst.count != 0)
4106    {
4107       node =  dlSf->ueLst.first;
4108       while (node)
4109       {
4110          ue = (RgSchUeCb *)(node->node);
4111          node = node->next;
4112
4113          if(ue->dl.dlSfHqInfo[cell->cellId][dlSf->dlIdx].isPuschHarqRecpPres == TRUE)
4114          {/* This UE is already considered for PUSCH
4115              Ignore for PUCCH */
4116             continue;
4117          }
4118          rgSCHTomUtlFillHqFdbkFor5gtf(recpReqInfo, cell, validIdx, 
4119                &ue->dl.dlSfHqInfo[cell->cellId][dlSf->dlIdx], dlSf, pucchRecpInfo, err);
4120       } /* end of while */
4121    } /* If hq is expected */
4122
4123    if (dlSf->msg4HqPLst.count != 0)
4124    {
4125       prvHqCb = NULLP;
4126       node =  dlSf->msg4HqPLst.first;
4127       while (node)
4128       {
4129          hqCb = (RgSchDlHqProcCb*)(node->node);
4130          node = node->next;
4131          //TODO_SID: need to check validIdx 
4132          rgSCHTomUtlFillHqFdbkInfo (recpReqInfo, cell, validIdx, hqCb, nxtDlsf, pucchRecpInfo, prvHqCb, err);
4133          prvHqCb = hqCb; 
4134       } /* end of while */
4135    }
4136
4137    /* Check with TDD Code */
4138    /* FOR ACK NACK REP */
4139    return ROK;
4140 } /* end of rgSCHTomUtlFillHqFdbkRecpReq */ 
4141 #ifdef TFU_UPGRADE 
4142 /** @brief This function handles filling of SR reception request to
4143  * PHY.
4144  *
4145  * @details
4146  *
4147  *     Function: 
4148  *
4149  *         Processing steps:
4150  *
4151  * @param  [out] TfuRecpReqInfo *recpReqInfo
4152  * @param  [in]  RgSchCellCb   *cell
4153  * @param  [out] RgSchErrInfo *err
4154  *  @return  S16
4155  *      -# ROK 
4156  *      -# RFAILED 
4157  */
4158 #ifdef UNUSED_FUNC
4159 static S16 rgSCHTomUtlFillSrRecpReq
4160 (
4161 TfuRecpReqInfo          *recpReqInfo,
4162 RgSchCellCb             *cell,
4163 uint16_t                  validIdx,
4164 RgSchErrInfo            *err
4165 )
4166 {
4167    CmLList              *node;
4168    TfuUeRecpReqInfo     *pucchRecpInfo;
4169    S16                  ret;
4170
4171    RgSchUeCb            *ue;
4172    Bool                 isAddToLst;
4173 #ifdef LTEMAC_SPS
4174    RgSchCmnUlUeSpsInfo   *ulSpsUe = NULL;
4175 #endif
4176
4177
4178    isAddToLst = FALSE;
4179
4180    node = cell->pCqiSrsSrLst[validIdx].srLst.first;
4181    while(node)
4182    {
4183       ue = (RgSchUeCb *)(node->node);
4184       /* Fix: ccpu00124011: Fix for missing reception request for UE with same offset */
4185       node = node->next;
4186       if(ue == NULLP)
4187       {
4188          continue;
4189       }
4190       if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4191                   sizeof(TfuUeRecpReqInfo),&(recpReqInfo->memCp))) != ROK)
4192       {
4193          DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for cell RNTI:%d",ue->ueId);
4194          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4195          return ret;
4196       }
4197 #ifdef TFU_ALLOC_EVENT_NO_INIT
4198      memset(&pucchRecpInfo->t.pucchRecpReq, 0, sizeof(TfuUePucchRecpReq));
4199       pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
4200 #endif      
4201       /*Fill SR params*/
4202
4203
4204 #ifdef LTEMAC_SPS
4205       /* Should we check for Rel8 and above???
4206        * Dont send SR recp req if logicalChannelSR-Mask enabled and UL SPS is
4207        * active*/
4208       ulSpsUe =  RG_SCH_CMN_GET_UL_SPS_UE(ue, cell);
4209       /* Avoiding check for ulSpsEnabled as isUlSpsActv FALSE if sps is not enabled*/
4210       if((ue->ul.ulSpsCfg.isLcSRMaskEnab) &&
4211          (ulSpsUe->isUlSpsActv))
4212       {
4213          rgSCHTomUtlMoveSrNxtOccasion(cell, ue);
4214          continue;
4215       }
4216 #endif
4217
4218       pucchRecpInfo->rnti =  ue->ueId; 
4219       pucchRecpInfo->t.pucchRecpReq.srInfo.n1PucchIdx = 
4220       ue->srCb.srCfg.srSetup.srResIdx;
4221       pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SR;
4222       rgSCHTomUtlMoveSrNxtOccasion(cell, ue);
4223       rgSCHTomUtlFillCqiSrsWithSr(cell, ue, recpReqInfo,  
4224                   pucchRecpInfo, validIdx);
4225 #ifdef EMTC_ENABLE
4226       isAddToLst = rgSCHEmtcAddRecpInfoToLst(NULLP,recpReqInfo, pucchRecpInfo,ue->isEmtcUe);
4227 #endif
4228       if(!isAddToLst)
4229       {
4230          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4231       }
4232       pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4233    }
4234    return ROK;
4235 }/* end of rgSCHTomUtlFillSrRecpReq */
4236 #endif
4237 #endif
4238 /** @brief This function tells will the UE has a periodic CQI/PMI/RI 
4239  *  reporting
4240  *
4241  * @details
4242  *
4243  *     Function: 
4244  *
4245  *         Processing steps:
4246  *
4247  *  @param  [in]   RgSchUeCb        *ue 
4248  *  @param  [out]  Bool             *willueRprtCqiRi  
4249  *  @return  S16
4250  *      -# ROK 
4251  *      -# RFAILED 
4252  */
4253
4254 static S16 rgSCHTomUtlWillUeRprtCqiRi
4255 (
4256 RgSchUeCb        *ue,
4257 Bool             *willueRprtCqiRi
4258 )
4259 {
4260    /* Intialising Reporting probability as TRUE */ 
4261    *willueRprtCqiRi = TRUE; 
4262
4263    /* Checking the cases in which UE will not report CQIPMI/RI */
4264    if(ue->isDrxEnabled && ue->drxCb)
4265    {
4266 #ifdef LTEMAC_R9
4267       if(ue->drxCb->cqiMask.pres && ue->drxCb->cqiMask.val == RGR_DRX_SETUP)
4268       {/*cqiMask is setup by upper layers */                                
4269          if((ue->drxCb->drxUlInactvMask & RG_SCH_DRX_ONDUR_BITMASK) ==
4270                RG_SCH_DRX_ONDUR_BITMASK)
4271          {/*onDuration NOT running, do not expect cqi/pmi/ri*/
4272             *willueRprtCqiRi = FALSE;
4273          }
4274          return ROK;
4275                 }
4276 #endif /*end of LTEMAC_R9*/
4277       /* ccpu00134258: Fix for CQI DRX issue*/
4278       if(ue->drxCb->onDurTmrLen > 2)
4279       {
4280          if ( !RG_SCH_DRX_UL_IS_UE_ACTIVE(ue->drxCb) ) 
4281          {/*UE is not active, do not expect cqi/pmi/ri*/                                  
4282             *willueRprtCqiRi = FALSE; 
4283          }
4284       }
4285    }/*ue->isDrxEnabled*/
4286    return ROK; 
4287 } /*End of rgSCHTomUtlWillUeRprtCqiRi*/
4288
4289 /** @brief This function handles filling of RI reception request to
4290  * PHY.
4291  *
4292  * @details
4293  *
4294  *     Function: 
4295  *
4296  *         Processing steps:
4297  *
4298  * @param  [out] TfuRecpReqInfo *recpReqInfo
4299  * @param  [in]  RgSchCellCb   *cell
4300  * @param  [in]  uint16_t           validIdx
4301  * @param  [out] RgSchErrInfo *err
4302  *  @return  S16
4303  *      -# ROK 
4304  *      -# RFAILED 
4305  */
4306 #ifdef UNUSED_FUNC
4307 static S16 rgSCHTomUtlFillRiRecpReq
4308 (
4309 TfuRecpReqInfo       *recpReqInfo,
4310 RgSchCellCb          *cell,
4311 uint16_t             validIdx,
4312 RgSchErrInfo         *err
4313 )
4314 {
4315    CmLList              *node;
4316    TfuUeRecpReqInfo     *pucchRecpInfo;
4317    S16                  ret;
4318    RgSchUeCb            *ue;
4319    Bool                  willUeRprtCqi; /* Flag set due to CQI Mask
4320                                        and UE inactive state (DRX) */
4321    RgSchUePCqiCb *riCb = NULLP;
4322
4323    node = cell->pCqiSrsSrLst[validIdx].riLst.first;
4324    while(node)
4325    {
4326       riCb = (RgSchUePCqiCb *)(node->node);
4327       ue = riCb->servCellInfo->ue;
4328       /* Fix: ccpu00124011: Fix for missing reception request for UE with same offset */
4329       node = node->next;
4330       if(riCb->riRecpPrcsd)
4331       {
4332          /*ccpu00140578:: RI Proecssing is already done for this TTI
4333           * as part of PUSCH reception process or HARQ 
4334           * Reception processing. Hence skipping this UE
4335           * */
4336          riCb->riRecpPrcsd = FALSE;
4337          continue;
4338       }
4339       if(riCb->riDist ==0)
4340       {
4341          rgSCHTomUtlWillUeRprtCqiRi(ue, &willUeRprtCqi);
4342 #ifdef XEON_SPECIFIC_CHANGES
4343          if(RGSCH_TIMEINFO_SAME(cell->crntTime, ue->riRecpTime))
4344          {
4345             continue;
4346          }
4347 #endif
4348 #ifdef LTE_ADV
4349          if((TRUE == riCb->isRiIgnoByCollsn) 
4350                || (willUeRprtCqi == FALSE))
4351 #else
4352          if(willUeRprtCqi == FALSE)
4353 #endif
4354          {    
4355             rgSCHTomUtlMovePriNxtOccasion(cell, ue, riCb);
4356             continue;
4357          }  
4358          if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4359                      sizeof(TfuUeRecpReqInfo),&(recpReqInfo->memCp))) != ROK)
4360          {
4361             DU_LOG("\nERROR  -->  SCH : Unable to Allocate "
4362                "TfuUeRecpReqInfo for cell RNTI:%d",ue->ueId);
4363             err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4364             return ret;
4365          }
4366 #ifdef TFU_ALLOC_EVENT_NO_INIT
4367          memset(&pucchRecpInfo->t.pucchRecpReq, 0, sizeof(TfuUePucchRecpReq));
4368          pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
4369 #endif
4370          /*Fill RI params*/
4371          pucchRecpInfo->rnti =  ue->ueId; 
4372          pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx = 
4373             riCb->cqiCfg.cqiSetup.cqiPResIdx; 
4374          pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz = riCb->riNumBits; 
4375          pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_CQI;
4376          ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
4377 #ifdef LTE_ADV
4378          ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
4379             riCb->servCellInfo->sCellIdx;
4380 #endif
4381          rgSCHTomUtlFillRiBitWidthInfo(ue);
4382          rgSCHTomUtlMovePriNxtOccasion(cell, ue, riCb);
4383          if (ue->nPCqiCb->nCqiTrIdx == validIdx)
4384          {
4385             rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, ue->nPCqiCb); 
4386          }
4387          if((ue->srsCb.nSrsTrIdx == validIdx) && (ue->srsCb.srsDist ==0))
4388          {
4389             rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);
4390          }
4391          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4392          pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4393       }
4394       else
4395       {
4396          riCb->riDist--; 
4397       }     
4398    }
4399    return ROK;
4400 }/* end of rgSCHTomUtlFillRiRecpReq */
4401 #endif
4402 #ifdef RG_5GTF
4403 /** @brief This function handles filling of 5GTF CQI-RI reception request to
4404  * PHY.
4405  *
4406  * @details
4407  *
4408  *     Function: 
4409  *
4410  *         Processing steps:
4411  *
4412  * @param  [out] TfuRecpReqInfo *recpReqInfo
4413  * @param  [in]  RgSchCellCb   *cell
4414  * @param  [in]  uint16_t           validIdx
4415  * @param  [out] RgSchErrInfo *err
4416  *  @return  S16
4417  *      -# ROK 
4418  *      -# RFAILED 
4419  */
4420
4421 #ifdef UNUSED_FUNC
4422 static S16 rgSCHTomUtlFillCqiRiRecpReq
4423 (
4424 TfuRecpReqInfo       *recpReqInfo,
4425 RgSchCellCb          *cell,
4426 uint16_t             validIdx, 
4427 RgSchErrInfo         *err
4428 )
4429 {
4430    TfuUeRecpReqInfo  *pucchRecpInfo;
4431    RgSchUeCb         *ue = NULLP;
4432    uint16_t          ret;
4433
4434    while ((ue = rgSCHDbmGetNextUeCb(cell, ue)) != NULLP)
4435    {
4436       if (RGSCH_TIMEINFO_SAME (recpReqInfo->timingInfo, ue->ue5gtfCb.nxtCqiRiOccn)) 
4437       {
4438          if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4439                      sizeof(TfuUeRecpReqInfo),&(recpReqInfo->memCp))) != ROK)
4440          {
4441             DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for cell RNTI:%d ", ue->ueId);
4442             err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4443             return ret;
4444          }
4445 #ifdef TFU_ALLOC_EVENT_NO_INIT
4446          memset(&pucchRecpInfo->t.pucchRecpReq, 0, sizeof(TfuUePucchRecpReq));
4447          pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;     
4448 #endif
4449          pucchRecpInfo->rnti =  ue->ueId; 
4450          pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_XPUCCH_UCI_INFO;
4451          pucchRecpInfo->t.pucchRecpReq.uciPduInfo.pucchIndex = 0;
4452          pucchRecpInfo->t.pucchRecpReq.uciPduInfo.numBits = 5;
4453
4454          RG_SCH_ADD_TO_CRNT_TIME(recpReqInfo->timingInfo, ue->ue5gtfCb.nxtCqiRiOccn,
4455                                  ue->ue5gtfCb.cqiRiPer);
4456          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4457          pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4458       }
4459    }
4460    return ROK;
4461 }/* end of rgSCHTomUtlFillCqiRiRecpReq */
4462 #endif
4463 #endif
4464 /** @brief This function handles filling of PCQI reception request to
4465  * PHY.
4466  *
4467  * @details
4468  *
4469  *     Function: 
4470  *
4471  *         Processing steps:
4472  *
4473  * @param  [out] TfuRecpReqInfo *recpReqInfo
4474  * @param  [in]  RgSchCellCb   *cell
4475  * @param  [in]  uint16_t           validIdx
4476  * @param  [out] RgSchErrInfo *err
4477  *  @return  S16
4478  *      -# ROK 
4479  *      -# RFAILED 
4480  */
4481 #ifdef UNUSED_FUNC
4482 static S16 rgSCHTomUtlFillPcqiRecpReq
4483 (
4484 TfuRecpReqInfo       *recpReqInfo,
4485 RgSchCellCb          *cell,
4486 uint16_t             validIdx, 
4487 RgSchErrInfo         *err
4488 )
4489 {
4490    CmLList              *node;
4491    TfuUeRecpReqInfo     *pucchRecpInfo;
4492    S16                  ret;
4493    RgSchUeCb            *ue;
4494    uint8_t              ri; /*RI value*/
4495    Bool                 willUeRprtCqi;   /* Flag set due to CQI Mask   and UE Inactive state (DRX)*/
4496    uint8_t              cqiPmiSz; 
4497    RgSchUePCqiCb        *cqiCb = NULLP;
4498    Bool                 isAddToLst = FALSE;
4499
4500    node = cell->pCqiSrsSrLst[validIdx].cqiLst.first;
4501    while(node)
4502    {
4503       cqiCb = (RgSchUePCqiCb*)(node->node);
4504       ue = cqiCb->servCellInfo->ue;
4505       /* Fix: ccpu00124011: Fix for missing reception request for UE with same offset */
4506       node = node->next;
4507       rgSCHTomUtlWillUeRprtCqiRi(ue, &willUeRprtCqi);
4508 #ifdef LTE_ADV
4509       if ((cqiCb->isCqiIgnoByCollsn == TRUE) ||
4510             (willUeRprtCqi == FALSE))
4511 #else
4512       if(willUeRprtCqi == FALSE)
4513 #endif
4514       {
4515          rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb);  
4516          continue;
4517       }
4518
4519       ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
4520 #ifdef LTE_ADV
4521       ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
4522          cqiCb->servCellInfo->sCellIdx;
4523 #endif
4524       cqiPmiSz = rgSCHTomUtlFetchPcqiBitSz(ue, cell->numTxAntPorts, &ri); 
4525       if(!cqiPmiSz)
4526       {
4527          DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to Fill CqiPmi size", ue->ueId);
4528          continue;
4529       }
4530
4531       if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4532                   sizeof(TfuUeRecpReqInfo),&(recpReqInfo->memCp))) != ROK)
4533       {
4534          DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for cell RNTI:%d ", ue->ueId);
4535          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4536          return ret;
4537       }
4538 #ifdef TFU_ALLOC_EVENT_NO_INIT
4539       memset(&pucchRecpInfo->t.pucchRecpReq, 0, sizeof(TfuUePucchRecpReq));
4540       pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;     
4541 #endif
4542       
4543       /*Fill PCQI params*/
4544       pucchRecpInfo->rnti =  ue->ueId; 
4545       pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx = 
4546          cqiCb->cqiCfg.cqiSetup.cqiPResIdx; 
4547       pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz = cqiPmiSz; 
4548       pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_CQI;
4549       rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb);  
4550       if((ue->srsCb.nSrsTrIdx == validIdx) && (ue->srsCb.srsDist ==0))
4551       {
4552          rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);
4553       }
4554 #ifdef EMTC_ENABLE
4555       isAddToLst = rgSCHEmtcAddRecpInfoToLst(NULLP,recpReqInfo, pucchRecpInfo,ue->isEmtcUe);
4556 #endif
4557       if(!isAddToLst)
4558       {
4559          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4560       }
4561       pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4562    }
4563    return ROK;
4564 }/* end of rgSCHTomUtlFillPcqiRecpReq */
4565 /** @brief This function handles filling of SRS reception request to
4566  * PHY.
4567  *
4568  * @details
4569  *
4570  *     Function: 
4571  *
4572  *         Processing steps:
4573  *
4574  * @param  [out] TfuRecpReqInfo *recpReqInfo
4575  * @param  [in]  RgSchCellCb   *cell
4576  * @param  [in]  uint16_t           validIdx
4577  * @param  [out] RgSchErrInfo *err
4578  *  @return  S16
4579  *      -# ROK 
4580  *      -# RFAILED 
4581  */
4582 static S16 rgSCHTomUtlFillSrsRecpReq
4583 (
4584 TfuRecpReqInfo       *recpReqInfo,
4585 RgSchCellCb          *cell,
4586 uint16_t             validIdx,
4587 RgSchErrInfo         *err
4588 )
4589 {
4590    CmLList              *node;
4591    TfuUeRecpReqInfo     *pucchRecpInfo;
4592    S16                  ret;
4593    RgSchUeCb            *ue;
4594
4595    node = cell->pCqiSrsSrLst[validIdx].srsLst.first;
4596    while(node)
4597    {
4598       ue = (RgSchUeCb *)(node->node);
4599       /* Fix: ccpu00124011: Fix for missing reception request for UE with same offset */
4600       node = node->next;
4601       if(ue->srsCb.srsRecpPrcsd)
4602       {
4603          /* ccpu00140578::SRS Proecssing is already done for this TTI
4604           * as part of PUSCH or HARQ reception process and
4605           * hence skipping this UE */
4606          ue->srsCb.srsRecpPrcsd = FALSE;
4607          continue;
4608       }
4609
4610       if(ue->srsCb.srsDist ==0)
4611       {
4612          /* We need to add the recp request to be sent on the pucchANRep value. */
4613          if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
4614                      sizeof(TfuUeRecpReqInfo),&(recpReqInfo->memCp))) != ROK)
4615          {
4616             DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for RNTI:%d ",ue->ueId);
4617             err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4618             return ret;
4619          }
4620
4621 #ifdef TFU_ALLOC_EVENT_NO_INIT
4622          pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
4623 #endif
4624          
4625          /*Fill SRS params*/
4626          pucchRecpInfo->rnti = ue->ueId;
4627          pucchRecpInfo->t.pucchRecpReq.srsInfo.srsBw = 
4628             (TfuUlSrsBwInfo)ue->srsCb.srsCfg.srsSetup.srsBw;
4629          pucchRecpInfo->t.pucchRecpReq.srsInfo.nRrc = 
4630             ue->srsCb.srsCfg.srsSetup.fDomPosi;
4631          pucchRecpInfo->t.pucchRecpReq.srsInfo.srsHopBw = 
4632             (TfuUlSrsHoBwInfo)ue->srsCb.srsCfg.srsSetup.srsHopBw;
4633          pucchRecpInfo->t.pucchRecpReq.srsInfo.transComb = 
4634             ue->srsCb.srsCfg.srsSetup.txComb;
4635          pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCfgIdx = 
4636             ue->srsCb.srsCfg.srsSetup.srsCfgIdx;
4637          pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCyclicShft = 
4638             (TfuUlSrsCycShiftInfo)ue->srsCb.srsCfg.srsSetup.cycShift;
4639          
4640          pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SRS;
4641          rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);
4642          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
4643          pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
4644       }
4645       else
4646       {
4647          ue->srsCb.srsDist--; 
4648       }
4649    }
4650    return ROK;
4651 }/* end of rgSCHTomUtlFillSrsRecpReq */
4652 #endif 
4653 #ifndef TFU_UPGRADE
4654 /** @brief This function handles filling of data reception requests for
4655  *  PUSCH and MSG3.
4656  *
4657  * @details
4658  *
4659  *     Function: 
4660  *
4661  *         Processing steps:
4662  *
4663  * @param  [out] TfuRecpReqInfo *recpReqInfo
4664  * @param  [in]  RgSchCellCb   *cell
4665  * @param  [out] RgSchErrInfo *err
4666  *  @return  S16
4667  *      -# ROK 
4668  *      -# RFAILED 
4669  */
4670 static S16 rgSCHTomUtlFillDatRecpReq
4671 (
4672 TfuRecpReqInfo       *recpReqInfo,
4673 RgSchCellCb          *cell,
4674 RgSchErrInfo         *err
4675 )
4676 {
4677    S16               ret;
4678    RgSchUlAlloc      *alloc;
4679    TfuUeRecpReqInfo  *datRecpInfo;
4680
4681
4682    /* processing steps are 
4683     * - Run through the UL allocations going out in this subframe.
4684     * - Run through the UL receptions expected the next subframe.
4685     */
4686    alloc = rgSCHUtlFirstRcptnReq (cell);
4687    while(alloc)
4688    {
4689       /* FOR ACK NACK REP */
4690       if (NULLP != alloc->ue)
4691       {
4692          /* If measuring or ackNakRep we shall not send dat RecpReq */
4693          if ((alloc->ue->measGapCb.isMeasuring == TRUE) ||
4694                (alloc->ue->ackNakRepCb.isAckNakRep == TRUE))
4695          {
4696             alloc = rgSCHUtlNextRcptnReq (cell, alloc);
4697             continue;
4698          }
4699
4700       }
4701       if ((ret = rgSCHUtlGetEventMem((Ptr *)&datRecpInfo,
4702                                 sizeof(TfuUeRecpReqInfo), 
4703                                 &(recpReqInfo->memCp))) != ROK)
4704       {
4705          DU_LOG("\nERROR  -->  SCH : Unable to Allocate TfuUeRecpReqInfo for RNTI:%d ", alloc->ue->ueId);
4706          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4707          return ret;
4708       }
4709       if (!alloc->forMsg3)
4710       {
4711          datRecpInfo->type = TFU_RECP_REQ_PUSCH;
4712          rgSCHUtlAllocRcptInfo (alloc, 
4713             &datRecpInfo->rnti,
4714             &datRecpInfo->t.puschRecpReq.mcs,
4715             &datRecpInfo->t.puschRecpReq.rbStart,
4716             &datRecpInfo->t.puschRecpReq.numRb,
4717             &datRecpInfo->t.puschRecpReq.rv,
4718             &datRecpInfo->t.puschRecpReq.size,
4719             &datRecpInfo->t.puschRecpReq.modType,
4720             &datRecpInfo->t.puschRecpReq.isRtx,
4721             &datRecpInfo->t.puschRecpReq.nDmrs,
4722             &datRecpInfo->t.puschRecpReq.ndi,
4723             &datRecpInfo->t.puschRecpReq.harqProcId
4724             );
4725       }
4726       else
4727       {
4728          datRecpInfo->type = TFU_RECP_REQ_MSG3;
4729          rgSCHUtlAllocRcptInfo (alloc, 
4730             &datRecpInfo->rnti,
4731             &datRecpInfo->t.msg3RecpReq.mcs,
4732             &datRecpInfo->t.msg3RecpReq.rbStart,
4733             &datRecpInfo->t.msg3RecpReq.numRb,
4734                         /*ccpu00128993 - MOD - fix for msg3 softcombining bug*/
4735             &datRecpInfo->t.msg3RecpReq.rv,
4736             &datRecpInfo->t.msg3RecpReq.size,
4737             &datRecpInfo->t.msg3RecpReq.modType,
4738             &datRecpInfo->t.msg3RecpReq.isRtx,
4739             &datRecpInfo->t.msg3RecpReq.nDmrs,
4740             &datRecpInfo->t.msg3RecpReq.ndi,
4741             &datRecpInfo->t.msg3RecpReq.harqProcId
4742             );
4743          
4744       }
4745       /* Other fields of datRecpInfo shall be filled 
4746        * here for new features */
4747       cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(datRecpInfo->lnk));
4748       datRecpInfo->lnk.node = (PTR)datRecpInfo;
4749       
4750       alloc = rgSCHUtlNextRcptnReq (cell, alloc);
4751    } /* end of while */
4752    return ROK;
4753 } /* end of rgSCHTomUtlFillDatRecpReq */
4754
4755 #else
4756 /** @brief This function handles filling of data reception requests for
4757  *  PUSCH and MSG3.
4758  *
4759  * @details
4760  *
4761  *     Function: 
4762  *
4763  *         Processing steps:
4764  *
4765  * @param  [out] TfuRecpReqInfo *recpReqInfo
4766  * @param  [in]  RgSchCellCb   *cell
4767  * @param  [in]  uint16_t           validIdx
4768  * @param  [out] RgSchErrInfo *err
4769  *  @return  S16
4770  *      -# ROK 
4771  *      -# RFAILED 
4772  */
4773 static S16 rgSCHTomUtlFillDatRecpReq
4774 (
4775 TfuRecpReqInfo       *recpReqInfo,
4776 RgSchCellCb          *cell,
4777 uint16_t             validIdx,
4778 RgSchErrInfo         *err
4779 )
4780 {
4781    CmLteTimingInfo   dci0Time;
4782    uint8_t           idx;
4783    S16               ret;
4784    RgSchUlAlloc      *alloc;
4785    TfuUeRecpReqInfo  *datRecpInfo;
4786
4787    Bool              isAperiodic = FALSE; /*Set when Aperiodic CQI is expected */
4788    uint8_t           numUePerTti = 0;
4789
4790    if((0 == (recpReqInfo->timingInfo.sfn % 30)) && (0 == recpReqInfo->timingInfo.slot))
4791    {
4792       //DU_LOG("\nERROR  -->  SCH : 5GTF_CHECK rgSCHTomUtlFillDatRecpReq (%d : %d)\n",\
4793       recpReqInfo->timingInfo.sfn, recpReqInfo->timingInfo.slot);
4794    }
4795    /* processing steps are 
4796     * - Run through the UL allocations going out in this subframe.
4797     * - Run through the UL receptions expected the next subframe.
4798     */
4799
4800    alloc = rgSCHUtlFirstRcptnReq (cell);
4801    while(alloc)
4802    {
4803       isAperiodic = FALSE;
4804       ret = rgSCHUtlGetEventMem((Ptr *)&datRecpInfo,
4805             sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
4806       if(ret != ROK)            
4807       {
4808          DU_LOG("\nERROR  -->  SCH : Unable to Allocate "
4809             "TfuUeRecpReqInfo for RNTI:%d ", alloc->rnti);
4810          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
4811          return ret;
4812       }
4813 #ifdef TFU_ALLOC_EVENT_NO_INIT
4814       datRecpInfo->t.puschRecpReq.initialNSrs.pres = FALSE;
4815       datRecpInfo->t.puschRecpReq.initialNumRbs.pres = FALSE;
4816 #endif
4817       datRecpInfo->type = TFU_RECP_REQ_PUSCH;
4818       /* Check if this if for MSG3 - no scope for feedback along with it. */
4819       if ((FALSE == alloc->forMsg3))
4820       {
4821          /*  Check if any DL HARQ processes has a feedback coming at the time of
4822           *  this reception request. 
4823           */
4824 /* ACC-TDD */             
4825          if(alloc->ue)
4826          {
4827             RGSCHDECRFRMCRNTTIME(cell->crntTime,dci0Time,(RGSCH_ULCTRL_RECP_DIST));
4828             
4829             idx = (dci0Time.sfn * RGSCH_NUM_SUB_FRAMES_5G + dci0Time.slot)%
4830                      RGSCH_ULCTRL_RECP_DIST; 
4831             UNUSED(idx);
4832             datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA;
4833             datRecpInfo->rnti = alloc->rnti;
4834             rgSCHUtlAllocRcptInfo (cell,alloc, &recpReqInfo->timingInfo,
4835                                    &datRecpInfo->t.puschRecpReq.ulSchInfo);
4836          }
4837       }
4838       else /*Enters for Msg3 == TRUE condition*/
4839       {
4840          /* ccpu00130884 - ADD - HO case when Msg3 alloc and Cqi/Ri/SRS opportunity 
4841           * occur at same time */
4842          if(NULLP != alloc->ue)
4843          {
4844                          
4845             /* Only DATA is expected */
4846             datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA;
4847             datRecpInfo->rnti = alloc->rnti;
4848             rgSCHUtlAllocRcptInfo (cell,alloc, &recpReqInfo->timingInfo,
4849                &datRecpInfo->t.puschRecpReq.ulSchInfo);
4850          }
4851       }
4852       if(alloc->ue)
4853       {
4854          if(datRecpInfo->t.puschRecpReq.rcpInfo != TFU_PUSCH_DATA &&
4855                datRecpInfo->t.puschRecpReq.rcpInfo != TFU_PUSCH_DATA_SRS &&
4856                isAperiodic == FALSE)
4857          {
4858             datRecpInfo->t.puschRecpReq.initialNumRbs.pres = TRUE;
4859             datRecpInfo->t.puschRecpReq.initialNumRbs.val = alloc->ue->initNumRbs;
4860          }
4861          else
4862          {
4863             datRecpInfo->t.puschRecpReq.initialNumRbs.pres = FALSE;
4864          }
4865       }
4866       cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(datRecpInfo->lnk));
4867       datRecpInfo->lnk.node = (PTR)datRecpInfo;
4868       alloc = rgSCHUtlNextRcptnReq (cell, alloc);
4869       numUePerTti++;
4870    } /* end of while */
4871
4872    if(numUePerTti && (numUePerTti < RG_MAX_NUM_UE_PER_TTI))
4873    {
4874       cell->ulNumUeSchedPerTti[numUePerTti-1]++;
4875       gUlNumUePerTti[numUePerTti - 1]++;
4876    }
4877    return ROK;
4878 } /* end of rgSCHTomUtlFillDatRecpReq */
4879 #endif
4880 /* rg009.201. Added changes of TFU_UPGRADE */
4881 #ifdef TFU_UPGRADE
4882 /***********************************************************
4883  *
4884  *     Func : rgSCHTomUtlFillRiBitWidthInfo
4885  *
4886  *
4887  *     Desc : Fills the RI BitWidth and stores it for decoding.
4888  *
4889  *     Ret  : S16
4890  *            ROK - Success
4891  *
4892  *     Notes:
4893  *
4894  *     File :
4895  *
4896  **********************************************************/
4897 S16 rgSCHTomUtlFillRiBitWidthInfo
4898 (
4899 RgSchUeCb     *ueCb
4900 )
4901 {
4902    RgSchUePCqiCb *riCb = ueCb->nPRiCb;
4903    
4904    if (ueCb->mimoInfo.txMode != RGR_UE_TM_3 &&
4905              ueCb->mimoInfo.txMode != RGR_UE_TM_4)
4906    {
4907       return RFAILED;
4908         }
4909
4910    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].type = TFU_RECP_REQ_PUCCH;
4911    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.mode= 
4912       (TfuDlCqiPucchMode)riCb->cqiCfg.cqiSetup.prdModeEnum;
4913    switch(ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.mode)
4914    {
4915       case TFU_PUCCH_CQI_MODE10:
4916          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode10Info.type = TFU_RPT_RI;
4917          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode10Info.u.ri = 
4918             riCb->riNumBits;
4919          break;
4920       case TFU_PUCCH_CQI_MODE11:
4921          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode11Info.type = TFU_RPT_RI;
4922          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode11Info.u.ri = 
4923             riCb->riNumBits;
4924          break;
4925       case TFU_PUCCH_CQI_MODE20:
4926          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode20Info.type = TFU_RPT_RI;
4927          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode20Info.u.ri = 
4928             riCb->riNumBits;
4929          break;
4930       case TFU_PUCCH_CQI_MODE21:
4931          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode21Info.type = TFU_RPT_RI;
4932          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode21Info.u.ri = 
4933             riCb->riNumBits;
4934          break;
4935       default:
4936          break;
4937    }
4938    
4939    RG_SCH_INCR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
4940    return ROK;
4941 }
4942
4943 /***********************************************************
4944  *
4945  *     Func : rgSCHTomUtlFetchPcqiBitSz
4946  *
4947  *
4948  *     Desc : Fetch the CQI/PMI bits for a UE based on the mode, periodicity.
4949  *
4950  *     Ret  : uint8_t
4951  *            ROK - Success
4952  *
4953  *     Notes:
4954  *
4955  *     File :
4956  *
4957  **********************************************************/
4958 uint8_t rgSCHTomUtlFetchPcqiBitSz
4959 (
4960 RgSchUeCb  *ueCb, 
4961 uint8_t    numTxAnt,
4962 uint8_t    *ri
4963 )
4964 {
4965    uint8_t confRepMode;
4966    uint8_t pcqiSz;
4967    TfuCqiPucchMode10   *mode10Info;    
4968    TfuCqiPucchMode11   *mode11Info;    
4969    TfuCqiPucchMode20   *mode20Info;   
4970    TfuCqiPucchMode21   *mode21Info;    
4971    RgSchUePCqiCb *cqiCb = ueCb->nPCqiCb;
4972
4973
4974    confRepMode = cqiCb->cqiCfg.cqiSetup.prdModeEnum;
4975    if((ueCb->mimoInfo.txMode != RGR_UE_TM_3) && 
4976          (ueCb->mimoInfo.txMode != RGR_UE_TM_4))
4977    {
4978       *ri =1;
4979    }
4980    else
4981    {
4982       *ri = cqiCb->perRiVal;
4983    }
4984    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].type = TFU_RECP_REQ_PUCCH;
4985    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.mode= 
4986        (TfuDlCqiPucchMode)confRepMode;
4987    switch(confRepMode)
4988    {
4989       case RGR_PRD_CQI_MOD10:
4990          {
4991             mode10Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode10Info;
4992             pcqiSz = 4;
4993             mode10Info->type = TFU_RPT_CQI;
4994             mode10Info->u.cqi = 4;
4995          }
4996          break;
4997
4998       case RGR_PRD_CQI_MOD11:
4999          {
5000             mode11Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode11Info;
5001             mode11Info->type = TFU_RPT_CQI;
5002             if(numTxAnt == 2)
5003             {
5004                if (*ri ==1)
5005                {
5006                   pcqiSz = 6;
5007                   mode11Info->u.cqi.cqi = 4;
5008                   mode11Info->u.cqi.wideDiffCqi.pres = FALSE;
5009                   mode11Info->u.cqi.pmi = 2;
5010                }
5011                else
5012                {
5013                   pcqiSz = 8;
5014                   mode11Info->u.cqi.cqi = 4;
5015                   mode11Info->u.cqi.wideDiffCqi.pres = TRUE;
5016                   mode11Info->u.cqi.wideDiffCqi.val = 3;
5017                   mode11Info->u.cqi.pmi = 1;
5018                }
5019             }
5020             else if(numTxAnt == 4)
5021             {
5022                if (*ri ==1)
5023                {
5024                   pcqiSz = 8;
5025                   mode11Info->u.cqi.cqi = 4;
5026                   mode11Info->u.cqi.wideDiffCqi.pres = FALSE;
5027                   mode11Info->u.cqi.pmi = 4;
5028                }
5029                else
5030                {
5031                   pcqiSz = 11;
5032                   mode11Info->u.cqi.cqi = 4;
5033                   mode11Info->u.cqi.wideDiffCqi.pres = TRUE;
5034                   mode11Info->u.cqi.wideDiffCqi.val = 3;
5035                   mode11Info->u.cqi.pmi = 4;
5036                }
5037             }
5038             else
5039             {
5040                /* This is number of antenna case 1.
5041                 * This is not applicable for Mode 1-1. 
5042                 * So setting it to invalid value */
5043                pcqiSz = 0;
5044             }
5045          }
5046          break;
5047
5048       case RGR_PRD_CQI_MOD20:
5049          {
5050             mode20Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode20Info;
5051             mode20Info->type = TFU_RPT_CQI;
5052             if(cqiCb->isWb)
5053             {
5054                pcqiSz = 4;
5055                mode20Info->u.cqi.isWideband = TRUE;
5056                mode20Info->u.cqi.u.wideCqi = 4;
5057             }
5058             else
5059             {
5060                pcqiSz = 4 + cqiCb->label;
5061                mode20Info->u.cqi.isWideband = FALSE;
5062                mode20Info->u.cqi.u.subCqi.cqi = 4;
5063                mode20Info->u.cqi.u.subCqi.l = cqiCb->label;
5064             }
5065          }
5066          break;
5067
5068       case RGR_PRD_CQI_MOD21:
5069          {
5070             mode21Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pucch.pucchRawCqiInfo.u.mode21Info;
5071             mode21Info->type = TFU_RPT_CQI;
5072             //pcqiSz = rgSCHTomUtlFetchPcqiBitSzPucchMode21(ueCb, 
5073               //                   mode21Info, numTxAnt, ri);
5074          }
5075          break;
5076       default:
5077           pcqiSz = 0;
5078           break;
5079    }
5080    
5081    RG_SCH_INCR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
5082    return pcqiSz;
5083 }
5084
5085
5086 /***********************************************************
5087  *
5088  *     Func : rgSCHTomUtlPcqiSbCalcBpIdx
5089  *
5090  *
5091  *     Desc : Determines the BP index from the timing info
5092  *
5093  *     Ret  : S16
5094  *            ROK - Success
5095  *
5096  *     Notes:
5097  *
5098  *     File :
5099  *
5100  **********************************************************/
5101 S16 rgSCHTomUtlPcqiSbCalcBpIdx
5102 (
5103 CmLteTimingInfo   crntTimInfo,
5104 RgSchUeCb         *ueCb,
5105 RgSchUePCqiCb     *cqiCb
5106 )
5107 {
5108    uint16_t tti = (crntTimInfo.sfn * RGSCH_NUM_SUB_FRAMES_5G + crntTimInfo.slot);
5109    uint16_t  prdNum = tti/cqiCb->cqiPeri;
5110
5111    if((prdNum % cqiCb->h) == 0)
5112    {
5113       cqiCb->isWb = TRUE;
5114 #ifdef LTE_ADV
5115       cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_1;
5116 #endif
5117    }
5118    else
5119    {
5120       cqiCb->isWb = FALSE;
5121       cqiCb->bpIdx = ((prdNum % cqiCb->h) - 1) % cqiCb->J;  
5122 #ifdef LTE_ADV
5123       cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_0;
5124 #endif
5125    }
5126    return ROK;
5127 }
5128
5129
5130 /**
5131  * @brief Function which moves PCQI, RI, SR and SRS to next periodicity
5132  *           Occasions as that needs to be done in case of Ack/Nack repetition
5133  *           reception request occasions or during Measurement Gap occasions.
5134  *
5135  * @details
5136  *
5137  *     Function: rgSCHTomUtlMoveNxtOccasion
5138  *
5139  *       Function which moves PCQI, RI, SR and SRS to next perodicity
5140  *      Occasions as that needs to be done in case of Ack/Nack repetition
5141  *      reception request occasions or during Measurement Gap occasions.
5142  *
5143  *     Invoked by: rgSCHTomUtlFillDatRecpReq of rg_sch_tom.c 
5144  *
5145  *     Processing Steps:
5146  *     - Check whether the current Tx Instance matches with the rec req time
5147  *     - If true, then move them to their next Tx Instance
5148  *           
5149  *  @param[in]   RgSchCellCb    *cell,
5150  *               RgSchUeCb      *ue,
5151  *               uint16_t            validIdx
5152  *  @return  S16
5153  *      -# ROK 
5154  *      -# RFAILED 
5155  **/
5156 S16 rgSCHTomUtlMoveNxtOccasion
5157 (
5158 RgSchCellCb  *cell,
5159 RgSchUeCb    *ue,
5160 uint16_t     validIdx
5161 )
5162 {
5163    RgSchUePCqiCb *cqiCb = ue->nPCqiCb;
5164    RgSchUePCqiCb *riCb = ue->nPRiCb;
5165  
5166    /* ccpu00140578::Skip the UE if already RI recpetion 
5167     * is processed in the same subframe */
5168    if ((riCb->nRiTrIdx == validIdx) &&
5169       (riCb->riRecpPrcsd == FALSE))
5170    {
5171       if(riCb->riDist ==0)
5172       {
5173          rgSCHTomUtlMovePriNxtOccasion(cell, ue, riCb); 
5174       }
5175       else
5176       {
5177          riCb->riDist--; 
5178       }
5179       /* ccpu00140578:: As this UE is considered for this TTI
5180        * Same UE should not get processed for RI reception 
5181        * or for updating th RI distance.*/
5182       if(riCb->nRiTrIdx == validIdx)
5183       {
5184          riCb->riRecpPrcsd = TRUE;
5185       }
5186    }
5187    if (cqiCb->nCqiTrIdx == validIdx)
5188    {
5189       rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb); 
5190    }
5191
5192       /* ccpu00140578::Skip the UE if SRS recpetion 
5193        * is already processed in the same subframe */
5194    if ((ue->srsCb.nSrsTrIdx == validIdx) &&
5195        (ue->srsCb.srsRecpPrcsd == FALSE))  
5196    {
5197       if(ue->srsCb.srsDist ==0)
5198       {
5199          rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);  
5200       }
5201       else
5202       {
5203          ue->srsCb.srsDist--; 
5204       }
5205       /* ccpu00140578:: As this UE is considered for this TTI
5206        * Same UE should not get processed for SRS reception 
5207        * or for updating th SRS distance.*/
5208       if(ue->srsCb.nSrsTrIdx == validIdx)
5209       {
5210          ue->srsCb.srsRecpPrcsd = TRUE;
5211       }
5212    }
5213    if (ue->srCb.nSrTrIdx == validIdx)
5214    {
5215       rgSCHTomUtlMoveSrNxtOccasion(cell, ue); 
5216    }
5217    return ROK;
5218 }  /* rgSCHTomUtlMoveNxtOccasion */
5219
5220
5221 /***********************************************************
5222  *
5223  *     Func : rgSCHTomPrepareAcqiRecp
5224  *
5225  *
5226  *     Desc : Fetch the CQI/PMI bits for a UE based on the mode and store them 
5227  *            for decoding. Fill RECP request and prepare the scartchpad
5228  *            to aid decoding of Aperiodic CQI. 
5229  *
5230  *     Ret  : Void
5231  *            ROK - void
5232  *
5233  *     Notes:
5234  *
5235  *     File :
5236  *
5237  **********************************************************/
5238 Void rgSCHTomPrepareAcqiRecp
5239 (
5240 RgSchUeCb       *ueCb, 
5241 RgSchCellCb     *cell,
5242 TfuUePuschCqiRecpInfo *cqiRecpReqInfo,
5243 uint8_t         ccIdx
5244 )
5245 {
5246    uint8_t confRepMode;
5247    RgSchCqiRawPuschMode12   *mode12Info;   
5248    RgSchCqiRawPuschMode20   *mode20Info;    
5249    RgSchCqiRawPuschMode22   *mode22Info;    
5250    RgSchCqiRawPuschMode30   *mode30Info;   
5251    RgSchCqiRawPuschMode31   *mode31Info;    
5252    uint8_t numTxAnt   = cell->numTxAntPorts;
5253    uint8_t sCellIdx   = ueCb->cellIdToCellIdxMap[RG_SCH_CELLINDEX(cell)];
5254    uint8_t numOfCells = 0;
5255    RgSchUeACqiCb *acqiCb  = &ueCb->cellInfo[sCellIdx]->acqiCb;
5256
5257    /* Fill TFU Recp */
5258    cqiRecpReqInfo->reportType = TFU_APERIODIC_CQI_TYPE; /* Aperiodic */
5259    if (ueCb->mimoInfo.txMode == RGR_UE_TM_3 ||
5260          ueCb->mimoInfo.txMode == RGR_UE_TM_4)
5261    {
5262       cqiRecpReqInfo->riSz[ccIdx].pres = TRUE;
5263       cqiRecpReqInfo->riSz[ccIdx].val  = acqiCb->riNumBits; 
5264    }
5265    /* This flag will be rmeoved after making changes in BRDCM CL
5266     * Sachin is doing the change 
5267     * */
5268 #if (defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
5269    //LTE_ADV_ACQI_SUPP
5270    cqiRecpReqInfo->cqiPmiSzR1[ccIdx]  = acqiCb->cqiPmiSzR1;
5271    cqiRecpReqInfo->cqiPmiSzRn1[ccIdx] = acqiCb->cqiPmiSzRn1;
5272 #else
5273    if(ueCb->nPCqiCb->perRiVal == 1)
5274    {
5275       cqiRecpReqInfo->cqiPmiSzR1[ccIdx]  = acqiCb->cqiPmiSzR1;
5276    }
5277    else
5278    {
5279       cqiRecpReqInfo->cqiPmiSzRn1[ccIdx] = acqiCb->cqiPmiSzRn1;
5280    }
5281 #endif
5282    /* Fill scratchpad to aid decoding of aper CQI upon
5283     * reception */
5284    confRepMode = acqiCb->aCqiCfg.aprdModeEnum;
5285    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].type = TFU_RECP_REQ_PUSCH;
5286
5287    numOfCells = ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.numOfCells;
5288
5289    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.cqiBitWidth[numOfCells].\
5290       puschRawCqiInfo.mode = (TfuDlCqiPuschMode)confRepMode;
5291
5292    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.cqiBitWidth[numOfCells].\
5293       puschRawCqiInfo.ri.pres = cqiRecpReqInfo->riSz[ccIdx].pres;
5294
5295    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.cqiBitWidth[numOfCells].\
5296       puschRawCqiInfo.ri.val = cqiRecpReqInfo->riSz[ccIdx].val;
5297
5298    /* Setting the sCellIdx */
5299    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.cqiBitWidth[numOfCells].\
5300       sCellIdx = sCellIdx;
5301
5302    switch(confRepMode)
5303    {
5304       case RGR_APRD_CQI_MOD12:
5305          {
5306             mode12Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.\
5307                          cqiBitWidth[numOfCells].puschRawCqiInfo.u.mode12Info;
5308             mode12Info->wideBCqiCw0 = 4;
5309             mode12Info->r1WideBCqiCw1 = 0;
5310             mode12Info->rg1WideBCqiCw1 = 4;
5311             if(numTxAnt == 2)
5312             {
5313                mode12Info->r1TotalPmiBitLen = 2*acqiCb->N;
5314                mode12Info->rg1TotalPmiBitLen = acqiCb->N;
5315             }
5316             else if(numTxAnt == 4)
5317             {
5318                mode12Info->r1TotalPmiBitLen = 4*acqiCb->N;
5319                mode12Info->rg1TotalPmiBitLen = 4*acqiCb->N;
5320             }
5321          }
5322          break;
5323
5324       case RGR_APRD_CQI_MOD20:
5325          {
5326             mode20Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.\
5327                          cqiBitWidth[numOfCells].puschRawCqiInfo.u.mode20Info;
5328             mode20Info->wideBCqiCw = 4;
5329             mode20Info->subBandDiffCqi = 2;
5330             mode20Info->posOfM = acqiCb->L;
5331          }
5332          break;
5333
5334       case RGR_APRD_CQI_MOD22:
5335          {
5336             mode22Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.\
5337                          cqiBitWidth[numOfCells].puschRawCqiInfo.u.mode22Info;
5338             mode22Info->wideBCqiCw0 = 4;
5339             mode22Info->sBDiffCqiCw0 = 2;
5340             mode22Info->r1WideBCqiCw1 = 0;
5341             mode22Info->r1SbDiffCqiCw1 = 0;
5342             mode22Info->rg1WideBCqiCw1 = 4;
5343             mode22Info->rg1SbDiffCqiCw1 = 2;
5344             mode22Info->posOfM = acqiCb->L;
5345             if(numTxAnt == 2)
5346             {
5347                mode22Info->r1PmiBitLen = 4;
5348                mode22Info->rg1PmiBitLen = 2;
5349             }
5350             else if(numTxAnt == 4)
5351             {
5352                mode22Info->r1PmiBitLen = 8;
5353                mode22Info->rg1PmiBitLen = 8;
5354             }
5355          }
5356          break;
5357
5358       case RGR_APRD_CQI_MOD30:
5359          {
5360             mode30Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.\
5361                          cqiBitWidth[numOfCells].puschRawCqiInfo.u.mode30Info;
5362             mode30Info->wideBCqiCw = 4;
5363             mode30Info->totLenSbDiffCqi = 2*acqiCb->N;
5364          }
5365          break;
5366
5367       case RGR_APRD_CQI_MOD31:
5368          {
5369             mode31Info = &ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.\
5370                          cqiBitWidth[numOfCells].puschRawCqiInfo.u.mode31Info;
5371             mode31Info->wideBCqiCw0 = 4;
5372             mode31Info->totLenSbDiffCqiCw0 = 2*acqiCb->N;
5373             mode31Info->r1WideBCqiCw1 = 0;
5374             mode31Info->r1TotLenSbDiffCqiCw1 =0;
5375             mode31Info->rg1WideBCqiCw1 = 4;
5376             mode31Info->rg1TotLenSbDiffCqiCw1 = 2*acqiCb->N;
5377             if(numTxAnt == 2)
5378             {
5379                mode31Info->r1PmiBitLen = 2;
5380                mode31Info->rg1PmiBitLen = 1;
5381             }
5382             else if(numTxAnt == 4)
5383             {
5384                mode31Info->r1PmiBitLen = 4;
5385                mode31Info->rg1PmiBitLen = 4;
5386             }
5387          }
5388          break;
5389       default:
5390          break;
5391    }
5392    return;
5393 }
5394
5395 /**
5396  * @brief Function which handles the filling of Aperiodic CQI/RI reception
5397  * request values 
5398  *
5399  * @details
5400  *
5401  *     Function: rgSCHTomUtlFillDatAperRecpReq
5402  *
5403  *    Function which handles the filling of Aperiodic CQI/RI reception
5404  *    request values
5405  *
5406  *     Invoked by: rgSCHTomUtlFillDatRecpReq of rg_sch_tom.c 
5407  *
5408  *     Processing Steps:
5409  *     - Fill the reception request for the data arriving on the ULSCH
5410  *     - Fill the reception request information for the Aperiodic CQI/PMI/RI
5411  *           
5412  *  @param[in]  RgSchCellCb       *cell,
5413  *              RgSchUlAlloc      *alloc,
5414  *              TfuUeRecpReqInfo  *datRecpInfo,
5415  *              CmLteTimingInfo   *timeInfo,
5416  *              Bool              hqPres
5417  *  @return  S16
5418  *      -# ROK 
5419  *      -# RFAILED 
5420  **/
5421 S16 rgSCHTomUtlFillDatAperRecpReq
5422 (
5423 RgSchCellCb       *cell,
5424 uint8_t           cqiReq,
5425 RgSchUlAlloc      *alloc,
5426 TfuUeRecpReqInfo  *datRecpInfo,
5427 CmLteTimingInfo   *timeInfo,
5428 Bool              hqPres,
5429 uint16_t          validIdx
5430 )
5431 {
5432    TfuUePuschCqiRecpInfo  *cqiRecpReqInfo;
5433    RgSchUeCb    *ueCb = alloc->ue;
5434 #ifdef LTE_ADV
5435    uint8_t      triggerSet = 0;
5436    uint8_t      sIdx = 0;
5437 #endif
5438
5439    /*Fill RI Reception Params*/
5440    cqiRecpReqInfo = &datRecpInfo->t.puschRecpReq.cqiRiInfo;   
5441    cqiRecpReqInfo->riBetaOff = alloc->ue->ul.betaRiOffst;
5442    cqiRecpReqInfo->cqiBetaOff = alloc->ue->ul.betaCqiOffst;
5443
5444    
5445    cqiRecpReqInfo->cCNum = 0;
5446    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.numOfCells = 0;
5447
5448 #ifdef LTE_ADV
5449    rgSCHTomUtlGetTrigSet(cell, ueCb, cqiReq, &triggerSet);
5450    for (sIdx = 0; sIdx < CM_LTE_MAX_CELLS; sIdx++)
5451    {
5452       /* The Aperiodic request for SCell index sIdx */
5453       if ((triggerSet >> (7 - sIdx)) & 0x01)
5454       {
5455          /* The Aperiodic request for SCell index sIdx */
5456          rgSCHTomPrepareAcqiRecp(ueCb, ueCb->cellInfo[sIdx]->cell, cqiRecpReqInfo, cqiRecpReqInfo->cCNum);
5457          cqiRecpReqInfo->cCNum++;
5458          ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.numOfCells++;
5459       }
5460    }
5461 #else
5462    rgSCHTomPrepareAcqiRecp(ueCb, ueCb->cellInfo[0]->cell, cqiRecpReqInfo, cqiRecpReqInfo->cCNum);
5463    ueCb->rawCqiBitW[ueCb->cqiRiWritIdx].u.pusch.numOfCells++;
5464 #endif
5465
5466    RG_SCH_INCR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
5467
5468    if((alloc->ue->srsCb.nSrsTrIdx == validIdx) && (alloc->ue->srsCb.srsDist ==0))
5469    {
5470          rgSCHTomFillOnlySrsRecpReq(cell,alloc, datRecpInfo); 
5471          datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_SRS; 
5472          
5473    }
5474    if(hqPres && 
5475    (datRecpInfo->t.puschRecpReq.rcpInfo == TFU_PUSCH_DATA_CQI_SRS))
5476    {
5477       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ_SRS;
5478    }
5479    else if (hqPres)
5480    {
5481       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ;
5482    }
5483    else if(datRecpInfo->t.puschRecpReq.rcpInfo != TFU_PUSCH_DATA_CQI_SRS)
5484    {
5485       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI;
5486    }
5487    datRecpInfo->rnti = alloc->rnti;
5488    rgSCHUtlAllocRcptInfo (cell, alloc, timeInfo,
5489             &datRecpInfo->t.puschRecpReq.ulSchInfo);
5490    return ROK;
5491 }  /* rgSCHTomUtlFillDatAperRecpReq */
5492
5493
5494
5495 /**
5496  * @brief Function which handles the filling of Periodic RI reception
5497  * request values which arrives along with UL Data on ULSCH
5498  *
5499  * @details
5500  *
5501  *     Function: rgSCHTomUtlFillDatPriRecpReq
5502  *
5503       *    Function which handles the filling of Periodic RI reception
5504  *    request values which arrives along with UL Data on ULSCH
5505  *
5506  *     Invoked by: rgSCHTomUtlFillDatRecpReq of rg_sch_tom.c 
5507  *
5508  *     Processing Steps:
5509  *     - Fill the reception request for the data arriving on the ULSCH
5510  *     - Fill the reception request information for the Periodic RI
5511  *           
5512  *  @param[in]  RgSchCellCb       *cell,
5513  *              RgSchUlAlloc      *alloc,
5514  *              TfuUeRecpReqInfo  *datRecpInfo,
5515  *              CmLteTimingInfo   *timeInfo,
5516  *              Bool              hqPres
5517  *  @return  S16
5518  *      -# ROK 
5519  *      -# RFAILED 
5520  **/
5521 S16 rgSCHTomUtlFillDatPriRecpReq
5522 (
5523 RgSchCellCb       *cell,
5524 RgSchUlAlloc      *alloc,
5525 TfuUeRecpReqInfo  *datRecpInfo,
5526 CmLteTimingInfo   *timeInfo,
5527 Bool              hqPres,
5528 uint16_t          validIdx
5529 )
5530 {
5531    TfuUePuschCqiRecpInfo  *cqiRecpReqInfo;
5532
5533    /*Fill RI Reception Params*/
5534    cqiRecpReqInfo = &datRecpInfo->t.puschRecpReq.cqiRiInfo;   
5535 #ifdef TFU_ALLOC_EVENT_NO_INIT
5536    cqiRecpReqInfo->cqiBetaOff = 0;
5537    /* Fill only the first RI index since Periodic can come 
5538     * only for 1 CC */
5539    cqiRecpReqInfo->cqiPmiSzR1[0] = 0;
5540    cqiRecpReqInfo->cqiPmiSzRn1[0] = 0;
5541 #endif
5542    cqiRecpReqInfo->reportType = TFU_PERIODIC_CQI_TYPE; /* periodic */
5543    cqiRecpReqInfo->riBetaOff = alloc->ue->ul.betaRiOffst;
5544
5545    /* Fill only the first RI index since Periodic can come 
5546     * only for 1 CC */
5547    cqiRecpReqInfo->cCNum = 1;
5548    cqiRecpReqInfo->riSz[0].pres = TRUE;
5549    cqiRecpReqInfo->riSz[0].val = alloc->ue->nPRiCb->riNumBits;
5550     /*Other params*/
5551    rgSCHTomUtlFillRiBitWidthInfo(alloc->ue);
5552     if((alloc->ue->srsCb.nSrsTrIdx == validIdx) && (alloc->ue->srsCb.srsDist ==0))
5553    {
5554          rgSCHTomFillOnlySrsRecpReq(cell,alloc, datRecpInfo);
5555          datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_SRS; 
5556
5557    }
5558    if(hqPres && 
5559    (datRecpInfo->t.puschRecpReq.rcpInfo == TFU_PUSCH_DATA_CQI_SRS))
5560    {
5561       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ_SRS;
5562    }
5563    else if (hqPres)
5564    {
5565       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ;
5566    }
5567    else if(datRecpInfo->t.puschRecpReq.rcpInfo != TFU_PUSCH_DATA_CQI_SRS)
5568    {
5569       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI;
5570    }
5571    datRecpInfo->rnti = alloc->rnti;
5572    rgSCHUtlAllocRcptInfo (cell, alloc, timeInfo,
5573          &datRecpInfo->t.puschRecpReq.ulSchInfo);
5574    return ROK;
5575 }  /* rgSCHTomUtlFillDatPriRecpReq */
5576
5577
5578 /**
5579  * @brief Function which handles the filling of Periodic CQI/PMI reception
5580  * request values which arrives along with UL Data on ULSCH
5581  *
5582  * @details
5583  *
5584  *     Function: rgSCHTomUtlFillDatPCqiRecpReq
5585  *
5586  *    Function which handles the filling of Periodic CQI/PMI reception
5587  *    request values which arrives along with UL Data on ULSCH
5588  *
5589  *     Invoked by: rgSCHTomUtlFillDatRecpReq of rg_sch_tom.c 
5590  *
5591  *     Processing Steps:
5592  *     - Fill the reception request for the data arriving on the ULSCH
5593  *     - Fill the reception request information for the Periodic CQI/PMI
5594  *           
5595  *  @param[in]  RgSchCellCb       *cell,
5596  *              RgSchUlAlloc      *alloc,
5597  *              TfuUeRecpReqInfo  *datRecpInfo,
5598  *              CmLteTimingInfo         *timeInfo,
5599  *              Bool hqPres
5600  *  @return  S16
5601  *      -# ROK 
5602  *      -# RFAILED 
5603  **/
5604
5605 S16 rgSCHTomUtlFillDatPCqiRecpReq
5606 (
5607 RgSchCellCb       *cell,
5608 RgSchUlAlloc      *alloc,
5609 TfuUeRecpReqInfo  *datRecpInfo,
5610 CmLteTimingInfo   *timeInfo,
5611 Bool              hqPres, 
5612 uint16_t          validIdx
5613 )
5614 {
5615    TfuUePuschCqiRecpInfo  *cqiRecpReqInfo;
5616    uint8_t     cqiPmiSz; /*Raw CQI/PMI Size*/
5617    uint8_t     ri;
5618
5619    /*Fill CQI Reception Params*/
5620    cqiRecpReqInfo = &datRecpInfo->t.puschRecpReq.cqiRiInfo;
5621 #ifdef TFU_ALLOC_EVENT_NO_INIT
5622    cqiRecpReqInfo->riBetaOff = 0;
5623 #endif
5624    cqiRecpReqInfo->cqiBetaOff = alloc->ue->ul.betaCqiOffst;
5625    cqiPmiSz = rgSCHTomUtlFetchPcqiBitSz(alloc->ue, cell->numTxAntPorts, &ri);
5626    if(0 == cqiPmiSz)
5627    {
5628       DU_LOG("\nERROR  -->  SCH : Unable to Fill "
5629          "CqiPmi size RNTI:%d",alloc->rnti);
5630       return RFAILED;
5631    }
5632
5633    /* Fill only the first RI index since Periodic can come 
5634     * only for 1 CC */
5635    cqiRecpReqInfo->cCNum = 1;
5636    cqiRecpReqInfo->reportType = TFU_PERIODIC_CQI_TYPE; /* Periodic */
5637    /* This flags will be removed once Sachin does changes 
5638     * in BRDCM CL */
5639 #if (defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
5640       cqiRecpReqInfo->cqiPmiSzR1[0] = cqiPmiSz;
5641       cqiRecpReqInfo->cqiPmiSzRn1[0] = cqiPmiSz;
5642 #else
5643    if (ri ==1)
5644    {
5645       cqiRecpReqInfo->cqiPmiSzR1[0] = cqiPmiSz;
5646       cqiRecpReqInfo->cqiPmiSzRn1[0] = 0;
5647    }
5648    else
5649    {
5650       cqiRecpReqInfo->cqiPmiSzRn1[0] = cqiPmiSz;
5651       cqiRecpReqInfo->cqiPmiSzR1[0] = 0;
5652    }
5653 #endif
5654    cqiRecpReqInfo->riSz[0].pres = FALSE; 
5655
5656    if((alloc->ue->srsCb.nSrsTrIdx == validIdx) && (alloc->ue->srsCb.srsDist ==0))
5657    {
5658          rgSCHTomFillOnlySrsRecpReq(cell,alloc, datRecpInfo); 
5659          datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_SRS; 
5660    }
5661    if(hqPres && 
5662    (datRecpInfo->t.puschRecpReq.rcpInfo == TFU_PUSCH_DATA_CQI_SRS))
5663    {
5664       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ_SRS;
5665    }
5666    else if (hqPres)
5667    {
5668       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI_HARQ;
5669    }
5670    else if(datRecpInfo->t.puschRecpReq.rcpInfo != TFU_PUSCH_DATA_CQI_SRS)
5671    {
5672       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_CQI;
5673    }
5674    datRecpInfo->rnti = alloc->rnti;
5675    rgSCHUtlAllocRcptInfo (cell, alloc, timeInfo,
5676             &datRecpInfo->t.puschRecpReq.ulSchInfo);
5677    return ROK;
5678 }  /* rgSCHTomUtlFillDatPCqiRecpReq */
5679
5680 /**
5681  * @brief Function which handles the filling of SRS reception
5682  * request values which arrives along with UL Data on ULSCH
5683  *
5684  * @details
5685  *
5686  *     Function: rgSCHTomUtlFillDatSrsRecpReq
5687  *
5688  *    Function which handles the filling of SRS reception
5689  *    request values which arrives along with UL Data on ULSCH
5690  *
5691  *     Invoked by: rgSCHTomUtlFillDatRecpReq of rg_sch_tom.c 
5692  *
5693  *     Processing Steps:
5694  *     - Fill the reception request for the data arriving on the ULSCH
5695  *     - Fill the reception request information for the SRS
5696  *           
5697  *  @param[in]  RgSchCellCb       *cell,
5698  *              RgSchUlAlloc      *alloc,
5699  *              TfuUeRecpReqInfo  *datRecpInfo,
5700  *              CmLteTimingInfo   *timeInfo,
5701  *              Bool              hqPres
5702  *  @return  S16
5703  *      -# ROK 
5704  *      -# RFAILED 
5705  **/
5706 S16 rgSCHTomUtlFillDatSrsRecpReq
5707 (
5708 RgSchCellCb       *cell,
5709 RgSchUlAlloc      *alloc,
5710 TfuUeRecpReqInfo  *datRecpInfo,
5711 CmLteTimingInfo   *timeInfo,
5712 Bool              hqPres
5713 )
5714 {
5715    datRecpInfo->rnti = alloc->rnti;
5716    rgSCHTomFillOnlySrsRecpReq(cell,alloc, datRecpInfo); 
5717    if(hqPres)
5718    {
5719       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_HARQ_SRS;
5720    }
5721    else
5722    {
5723       datRecpInfo->t.puschRecpReq.rcpInfo = TFU_PUSCH_DATA_SRS;
5724    }
5725    datRecpInfo->rnti = alloc->rnti;
5726    rgSCHUtlAllocRcptInfo (cell, alloc, timeInfo, 
5727             &datRecpInfo->t.puschRecpReq.ulSchInfo);
5728    return ROK;
5729 }  /* rgSCHTomUtlFillDatSrsRecpReq */
5730
5731 /**
5732  * @brief Function which handles the filling of only SRS reception
5733  * request values on ULSCH
5734  *
5735  * @details
5736  *
5737  *     Function: rgSCHTomFillOnlySrsRecpReq
5738  *
5739  *    Function which handles the filling of SRS reception
5740  *    request values which arrives along with UL Data on ULSCH
5741  *
5742  *     Invoked by: rgSCHTomUtlFillDatSrsRecpReq of rg_sch_tom.c 
5743  *
5744  *     Processing Steps:
5745  *     - Fill the reception request for the data arriving on the ULSCH
5746  *     - Fill the reception request information for the SRS
5747  *           
5748  *  @param[in]  RgSchCellCb       *cell,
5749  *              RgSchUlAlloc      *alloc,
5750  *              TfuUeRecpReqInfo  *datRecpInfo,
5751  *  @return  S16
5752  *      -# ROK 
5753  *      -# RFAILED 
5754  **/
5755 S16 rgSCHTomFillOnlySrsRecpReq
5756 (
5757 RgSchCellCb       *cell,
5758 RgSchUlAlloc      *alloc,
5759 TfuUeRecpReqInfo  *datRecpInfo
5760 )
5761 {
5762    TfuUePuschSrsRecpInfo  *srsRecpReqInfo;
5763
5764    srsRecpReqInfo = &datRecpInfo->t.puschRecpReq.srsInfo;
5765    srsRecpReqInfo->srsBw = (TfuUlSrsBwInfo)alloc->ue->srsCb.srsCfg.srsSetup.srsBw;
5766    srsRecpReqInfo->nRrc = alloc->ue->srsCb.srsCfg.srsSetup.fDomPosi;
5767    srsRecpReqInfo->srsHopBw = (TfuUlSrsHoBwInfo)alloc->ue->srsCb.srsCfg.srsSetup.srsHopBw;
5768    srsRecpReqInfo->transComb = alloc->ue->srsCb.srsCfg.srsSetup.txComb;
5769    srsRecpReqInfo->srsCfgIdx = alloc->ue->srsCb.srsCfg.srsSetup.srsCfgIdx;
5770    srsRecpReqInfo->srsCyclicShft = (TfuUlSrsCycShiftInfo)alloc->ue->srsCb.srsCfg.srsSetup.cycShift;
5771
5772    /* ccpu00117050 - ADD - nSrs setting 
5773     * Refer Section 5.2.2.6 of TS 36.212 V8.5.0*/
5774    datRecpInfo->t.puschRecpReq.ulSchInfo.nSrs = 1;
5775
5776    return ROK;
5777 }  /* rgSCHTomFillOnlySrsRecpReq */
5778
5779 /**
5780  * @brief Function which handles the filling of PCQI/RI, SRS and SR
5781  *             Reception Request Information along
5782  *             with the HARQ reception Request
5783  *
5784  * @details
5785  *
5786  *     Function: rgSCHTomUtlFillCqiSrSrsWithHq
5787  *
5788  *              Function which handles the filling of PCQI/RI, SRS ans SR
5789  *             Reception Request Information along
5790  *             with the HARQ reception Request
5791  *
5792  *
5793  *     Invoked by: rgSCHTomUtlFillHqFdbkRecpReq & 
5794  *          rgSCHTomUtlFillSfHqFdbk of rg_sch_tom.c 
5795  *
5796  *     Processing Steps:
5797  *     - Fill the reception request for the Control Info arriving on the PUCCH
5798  *     - Fill the reception request information for the SR, RI, CQI, SRS
5799  *           
5800  *  @param[in]   RgSchCellCb       *cell,
5801  *               TfuRecpReqInfo    *recpReqInfo,
5802  *               RgSchDlHqProcCb   *hqCb,
5803  *  @param[out]  TfuUeRecpReqInfo  *pucchRecpInfo
5804  *  @param[in]   uint16_t               validIdx
5805  *  @return  S16
5806  *      -# ROK 
5807  *      -# RFAILED 
5808  **/
5809 static S16 rgSCHTomUtlFillCqiSrSrsWithHq
5810 (
5811 RgSchCellCb       *cell,
5812 TfuRecpReqInfo    *recpReqInfo,
5813 RgSchUeCb         *ue,
5814 TfuUeRecpReqInfo  *pucchRecpInfo,
5815 uint16_t          validIdx,
5816 Bool               isDatPresOnSecCell
5817 )
5818 {
5819    RgSchUePCqiCb   *cqiCb;
5820    RgSchUePCqiCb   *riCb;
5821    uint8_t         ri; /*To fetch RI value*/
5822    Bool            willUeRprtCqi;   /* Flag set due to CQI Mask and UE Inactive state (DRX)*/
5823    Bool            willUeRprtSr = TRUE;   
5824    TfuAckNackMode  hqFdbkMode;
5825    uint8_t         numCqiBit;
5826    uint8_t         totalPucchBits;
5827    Bool            dropCqi = FALSE;
5828 #ifdef LTEMAC_SPS
5829    RgSchCmnUlUeSpsInfo   *ulSpsUe = NULL;
5830 #endif
5831 #ifdef EMTC_ENABLE
5832    RgSchEmtcUeInfo *emtcUe = NULLP;
5833 #endif
5834
5835    if(ue)
5836    {
5837       /*Changes for PUCCH Format3 */
5838       hqFdbkMode = pucchRecpInfo->t.pucchRecpReq.hqInfo.hqFdbkMode; 
5839       numCqiBit = rgSCHCmnCalcPcqiBitSz (ue,cell->numTxAntPorts);
5840       totalPucchBits = pucchRecpInfo->t.pucchRecpReq.hqInfo.hqSz + numCqiBit; 
5841
5842 #ifdef EMTC_ENABLE
5843       emtcUe = RG_GET_EMTC_UE_CB(ue);
5844 #endif
5845       rgSCHTomUtlWillUeRprtCqiRi(ue, &willUeRprtCqi);
5846 #ifdef EMTC_ENABLE         /*VINU*/
5847       if (ue->isEmtcUe)
5848       {
5849          if((emtcUe->pucchRepNumFr1 > 1) || (emtcUe->pucchRepNumFr2 > 1))
5850          {
5851             willUeRprtCqi = FALSE;
5852             willUeRprtSr = FALSE;
5853          }
5854       } 
5855 #endif
5856       if(ue->srCb.nSrTrIdx == validIdx)
5857       {
5858
5859 #ifdef LTEMAC_SPS
5860         /* Should we check for Rel8 and above???
5861          * Dont send SR recp req if logicalChannelSR-Mask enabled and UL SPS is
5862          * active*/
5863         ulSpsUe =  RG_SCH_CMN_GET_UL_SPS_UE(ue, cell);
5864         /* Avoiding check for ulSpsEnabled as isUlSpsActv FALSE if sps is not enabled*/
5865         if(!((ue->ul.ulSpsCfg.isLcSRMaskEnab) &&
5866            (ulSpsUe->isUlSpsActv)))
5867         {
5868 #endif
5869
5870            if(willUeRprtSr)     
5871            {
5872          /*Fill SR params*/
5873          pucchRecpInfo->t.pucchRecpReq.srInfo.n1PucchIdx = 
5874          ue->srCb.srCfg.srSetup.srResIdx; 
5875          pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR;
5876          /* FORMAT3: If SR is present it will be appended after HARQ */
5877          totalPucchBits = totalPucchBits + 1;
5878            }
5879
5880 #ifdef LTEMAC_SPS
5881         }
5882 #endif
5883
5884          rgSCHTomUtlMoveSrNxtOccasion(cell, ue);
5885       }
5886       /* LTE_ADV:: UE will drop CSI during CSI+1BCS if data is present
5887        * on sec cell(isDatPresOnSecCell)*/
5888 #ifdef LTE_TDD
5889       if (hqFdbkMode == TFU_ACK_NACK_CHANNEL_SELECTION) 
5890 #else
5891       if (hqFdbkMode == TFU_UCI_FORMAT_1B_CS) 
5892 #endif
5893       {
5894          if (isDatPresOnSecCell == TRUE)
5895          {
5896             dropCqi = TRUE;
5897          }
5898       }
5899 #ifdef LTE_ADV
5900 #ifndef LTE_TDD
5901       /* Format 3 Changes : If Hq + SR + CQI bits < 22 and simultaneousAckNackAndCQI-Format3
5902          is enabled then CQI will be multiplexed with HQ otherwise CQI will be dropped 
5903          Spec 36.213 Sec 10.1.1 */
5904       else if (hqFdbkMode == TFU_UCI_FORMAT_3)
5905       {
5906          if ((isDatPresOnSecCell == TRUE) && 
5907                ((!ue->simulAckNackCQIFormat3) || (totalPucchBits > 22)))
5908          {
5909             dropCqi = TRUE;
5910          }
5911       }
5912 #endif
5913 #endif
5914       riCb = ue->nPRiCb;
5915       cqiCb = ue->nPCqiCb;
5916       if(riCb->nRiTrIdx == validIdx)
5917       {
5918          /*ccpu00140578:: Skip the UE if the RI is already processed
5919           * for PUSCH */
5920          if(riCb->riRecpPrcsd == FALSE)
5921          {
5922             if(riCb->riDist == 0)
5923             {
5924                if((riCb->cqiCfg.cqiSetup.sANCQI == TRUE) && (willUeRprtCqi == TRUE)&&
5925                      (isDatPresOnSecCell == FALSE))
5926                {
5927                   /*Fill RI params*/
5928                   pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx =
5929                      riCb->cqiCfg.cqiSetup.cqiPResIdx; 
5930                   pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz = 
5931                      riCb->riNumBits; 
5932                   if(pucchRecpInfo->t.pucchRecpReq.uciInfo == TFU_PUCCH_HARQ_SR)
5933                   {
5934                      pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR_CQI;
5935                   }
5936                   else
5937                   {
5938                      pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_CQI;
5939                   }
5940                   ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
5941 #ifdef LTE_ADV
5942                   ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
5943                      ue->nPRiCb->servCellInfo->sCellIdx;
5944 #endif
5945                   rgSCHTomUtlFillRiBitWidthInfo(ue);
5946                   if (ue->nPCqiCb->nCqiTrIdx == validIdx)
5947                   {
5948                      rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, ue->nPCqiCb); 
5949                   } 
5950 #ifdef CA_DBG
5951                   {
5952                      if(gF1bCsPres)
5953                      {
5954                         gRiReqCount++;
5955                      } 
5956                   }
5957
5958 #endif
5959
5960
5961
5962                }
5963                rgSCHTomUtlMovePriNxtOccasion(cell, ue, riCb);
5964             }
5965             else
5966             {
5967                riCb->riDist--;
5968             }
5969             /* Skip the UE for RI processing on PUCCH
5970              * in the same subframe as it already processed */
5971             if(riCb->nRiTrIdx == validIdx)
5972             {
5973                /* As the new idx is same is current idx
5974                 * then PUCCH reception processing will consider
5975                 * RI also in the same subframe. To block this
5976                 * below flag is used*/
5977                riCb->riRecpPrcsd = TRUE;
5978             }
5979          }
5980       }
5981       else if(cqiCb->nCqiTrIdx == validIdx)
5982       {
5983          if((cqiCb->cqiCfg.cqiSetup.sANCQI == TRUE) && (willUeRprtCqi == TRUE)&&
5984             (isDatPresOnSecCell == FALSE))
5985          {
5986             /*Fill CQI Params*/
5987             pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx =
5988                cqiCb->cqiCfg.cqiSetup.cqiPResIdx; 
5989
5990             ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
5991 #ifdef LTE_ADV
5992             ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
5993                cqiCb->servCellInfo->sCellIdx;
5994 #endif
5995             pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz =
5996                rgSCHTomUtlFetchPcqiBitSz(ue, cell->numTxAntPorts, &ri); 
5997             if(0 == pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz)
5998             {
5999                DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to Fill CqiPmi size", ue->ueId);
6000                return RFAILED;
6001             }
6002             if(pucchRecpInfo->t.pucchRecpReq.uciInfo == TFU_PUCCH_HARQ_SR)
6003             {
6004                pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR_CQI;
6005             }
6006             else
6007             {
6008                pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_CQI;
6009             }
6010          }
6011 #ifdef CA_DBG
6012                {
6013                   if(gF1bCsPres)
6014                   {
6015                      gCqiReqCount++;
6016                   } 
6017                }
6018
6019 #endif
6020
6021          rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb);           
6022       }
6023       if(ue->srsCb.nSrsTrIdx == validIdx)
6024       {
6025          /* ccpu00140578::Skip the UE for SRS reception processing
6026           * if already done as part of PUSCH recpetion 
6027           * process*/
6028          if(ue->srsCb.srsRecpPrcsd == FALSE)
6029          {
6030             if(ue->srsCb.srsDist ==0 )
6031             {
6032                if((pucchRecpInfo->t.pucchRecpReq.uciInfo != TFU_PUCCH_HARQ_CQI) 
6033                      && (ue->srsCb.srsCfg.srsSetup.sANSrs)
6034                      && (isDatPresOnSecCell == FALSE))
6035                {
6036                   /*Fill SRS params*/
6037                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsBw = 
6038                      (TfuUlSrsBwInfo)ue->srsCb.srsCfg.srsSetup.srsBw;
6039                   pucchRecpInfo->t.pucchRecpReq.srsInfo.nRrc = 
6040                      ue->srsCb.srsCfg.srsSetup.fDomPosi;
6041                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsHopBw = 
6042                      (TfuUlSrsHoBwInfo)ue->srsCb.srsCfg.srsSetup.srsHopBw;
6043                   pucchRecpInfo->t.pucchRecpReq.srsInfo.transComb = 
6044                      ue->srsCb.srsCfg.srsSetup.txComb;
6045                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCfgIdx = 
6046                      ue->srsCb.srsCfg.srsSetup.srsCfgIdx;
6047                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCyclicShft = 
6048                      (TfuUlSrsCycShiftInfo)ue->srsCb.srsCfg.srsSetup.cycShift;
6049                   /* ccpu00116923 - ADD - New Reception Request types for CQI and SRS with SR */
6050                   switch(pucchRecpInfo->t.pucchRecpReq.uciInfo)
6051                   {
6052                      case TFU_PUCCH_HARQ_SR:
6053                         pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR_SRS;
6054                         break;
6055                      case TFU_PUCCH_HARQ_SR_CQI:
6056                         pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR_CQI_SRS;
6057                         break;
6058                      default:
6059                         pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SRS;
6060                         break;
6061                   }
6062                }
6063                rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);
6064             }
6065             else
6066             {
6067                ue->srsCb.srsDist--; 
6068             }
6069             /* Skip the UE for SRS processing on PUCCH
6070              * in the same subframe as it already processed */
6071             if(ue->srsCb.nSrsTrIdx == validIdx)
6072             {
6073                /* As the new idx is same is current idx
6074                 * then PUCCH reception processing will consider
6075                 * SRS also in the same subframe. To block this
6076                 * below flag is used*/
6077                ue->srsCb.srsRecpPrcsd = TRUE;
6078             }
6079
6080          }
6081       }
6082    }            
6083    UNUSED(dropCqi);
6084    return ROK;
6085 }  /* rgSCHTomUtlFillCqiSrSrsWithHq */
6086
6087 /**
6088  * @brief  Function which handles the filling of PCQI/RI, SRS 
6089  *             Reception Request Information along with SR reception 
6090  *              Request 
6091  *
6092  * @details
6093  *
6094  *     Function: rgSCHTomUtlFillCqiSrsWithSr
6095  *
6096  *              Function which handles the filling of PCQI/RI, SRS 
6097  *             Reception Request Information along
6098  *             with the SR reception Request
6099  *
6100  *
6101  *     Invoked by: rgSCHTomUtlFillSrRecpReq of rg_sch_tom.c 
6102  *
6103  *     Processing Steps:
6104  *     - Fill the reception request for CQI/RI, SRS if they occur
6105  *       in the same instance as of SR. 
6106  *           
6107  *  @param[in]   RgSchCellCb       *cell,
6108  *               RgSchUeCb         *ue
6109  *               TfuRecpReqInfo    *recpReqInfo,
6110  *  @param[out]  TfuUeRecpReqInfo  *pucchRecpInfo
6111  *  @param[in]   uint16_t               validIdx
6112  *  @return  S16
6113  *      -# ROK 
6114  *      -# RFAILED 
6115  **/
6116 #ifdef UNUSED_FUNC
6117 static S16 rgSCHTomUtlFillCqiSrsWithSr
6118 (
6119 RgSchCellCb       *cell,
6120 RgSchUeCb         *ue, 
6121 TfuRecpReqInfo    *recpReqInfo,
6122 TfuUeRecpReqInfo  *pucchRecpInfo,
6123 uint16_t          validIdx
6124 )
6125 {
6126    RgSchUePCqiCb  *cqiCb;
6127    RgSchUePCqiCb  *riCb;
6128    uint8_t        ri; /*To fetch RI value*/
6129    Bool           willUeRprtCqi;   /* Flag set due to CQI Mask and 
6130                                       UE Inactive state (DRX)*/
6131    riCb = ue->nPRiCb;
6132    cqiCb = ue->nPCqiCb;
6133    rgSCHTomUtlWillUeRprtCqiRi(ue, &willUeRprtCqi);
6134 #ifdef EMTC_ENABLE
6135    rgSCHEmtcWillUeRptCqi(ue, &willUeRprtCqi);
6136 #endif
6137    if(riCb->nRiTrIdx == validIdx)
6138    {
6139       /*ccpu00140578:: Skip the UE if the RI is already processed
6140        * for PUSCH */
6141       if(riCb->riRecpPrcsd == FALSE)
6142       {
6143          if(riCb->riDist == 0)
6144          {
6145             if(willUeRprtCqi == TRUE)
6146             {
6147                /*Fill RI params*/
6148                pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx =
6149                   riCb->cqiCfg.cqiSetup.cqiPResIdx; 
6150                pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz = 
6151                   riCb->riNumBits; 
6152
6153                pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SR_CQI;
6154                ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
6155 #ifdef LTE_ADV
6156                ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
6157                   ue->nPRiCb->servCellInfo->sCellIdx;
6158 #endif
6159                rgSCHTomUtlFillRiBitWidthInfo(ue);
6160                /* TODO:: syed Shouldn't this be done outside this if condition */
6161                if (cqiCb->nCqiTrIdx == validIdx)
6162                {
6163                   rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb); 
6164                }       
6165             }
6166             rgSCHTomUtlMovePriNxtOccasion(cell, ue, riCb);
6167          }
6168          else
6169          {
6170             riCb->riDist--;
6171          }
6172          if(riCb->nRiTrIdx == validIdx)
6173          {/* Need to skip this UE during PUCCH RI recpetion process
6174              in the current subframe */
6175             riCb->riRecpPrcsd = TRUE;
6176          }
6177       }
6178    }
6179    else if(cqiCb->nCqiTrIdx == validIdx)
6180    {
6181       if(willUeRprtCqi == TRUE)
6182       {
6183          /*Fill CQI Params*/
6184          pucchRecpInfo->t.pucchRecpReq.cqiInfo.n2PucchIdx =
6185             cqiCb->cqiCfg.cqiSetup.cqiPResIdx; 
6186
6187             ue->rawCqiBitW[ue->cqiRiWritIdx].recvTime = recpReqInfo->timingInfo;
6188
6189 #ifdef LTE_ADV
6190             ue->rawCqiBitW[ue->cqiRiWritIdx].u.pucch.sCellIdx =
6191                cqiCb->servCellInfo->sCellIdx;
6192 #endif
6193             pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz =
6194                rgSCHTomUtlFetchPcqiBitSz(ue, cell->numTxAntPorts, &ri); 
6195             if(0 == pucchRecpInfo->t.pucchRecpReq.cqiInfo.cqiPmiSz)
6196             {
6197                DU_LOG("\nERROR  -->  SCH : RNTI:%d Unable to Fill CqiPmi size", ue->ueId);
6198                return RFAILED;
6199             }
6200
6201             pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SR_CQI;
6202          }
6203          rgSCHTomUtlMovePcqiNxtOccasion(cell, ue, cqiCb);  
6204       }
6205       if(ue->srsCb.nSrsTrIdx == validIdx)
6206       {
6207          /* ccpu00140578:: Cnsider the SRS processing 
6208           * only if not done in the same TTI 
6209           * as part of PUSCH or HARQ reception process*/
6210          if(ue->srsCb.srsRecpPrcsd == FALSE)
6211          {
6212             if(ue->srsCb.srsDist ==0 )
6213             {
6214                if(ue->srsCb.srsCfg.srsSetup.sANSrs) 
6215                {
6216                   /*Fill SRS params*/
6217                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsBw = 
6218                      (TfuUlSrsBwInfo)ue->srsCb.srsCfg.srsSetup.srsBw;
6219                   pucchRecpInfo->t.pucchRecpReq.srsInfo.nRrc = 
6220                      ue->srsCb.srsCfg.srsSetup.fDomPosi;
6221                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsHopBw = 
6222                      (TfuUlSrsHoBwInfo)ue->srsCb.srsCfg.srsSetup.srsHopBw;
6223                   pucchRecpInfo->t.pucchRecpReq.srsInfo.transComb = 
6224                      ue->srsCb.srsCfg.srsSetup.txComb;
6225                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCfgIdx = 
6226                      ue->srsCb.srsCfg.srsSetup.srsCfgIdx;
6227                   pucchRecpInfo->t.pucchRecpReq.srsInfo.srsCyclicShft = 
6228                      (TfuUlSrsCycShiftInfo)ue->srsCb.srsCfg.srsSetup.cycShift;
6229                   /* ccpu00116923 - ADD - New Reception Request types for CQI and
6230                    * SRS with SR */
6231                   if(pucchRecpInfo->t.pucchRecpReq.uciInfo == TFU_PUCCH_SR_CQI)
6232                   {
6233                      pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SR_CQI_SRS;
6234                   }
6235                   else
6236                   {
6237                      pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_SR_SRS;
6238                   }
6239
6240                }
6241                rgSCHTomUtlMoveSrsNxtOccasion(cell, ue);
6242             }
6243             else
6244             {
6245                ue->srsCb.srsDist--; 
6246             }
6247             /* Skip the UE for SRS processing on PUCCH
6248              * in the same subframe as it already processed */
6249             if(ue->srsCb.nSrsTrIdx == validIdx)
6250             {
6251                /* As the new idx is same is current idx
6252                 * then PUCCH reception processing will consider
6253                 * SRS also in the same subframe. To block this
6254                 * below flag is used*/
6255                ue->srsCb.srsRecpPrcsd = TRUE;
6256             }
6257
6258          }
6259       }
6260    return ROK;
6261 }  /* rgSCHTomUtlFillCqiSrsWithSr */
6262
6263 #endif 
6264 #endif
6265
6266 #ifdef LTE_TDD
6267 /** @brief This function handles filling of HARQ feedback repetition
6268  * recption request for each subframe
6269  *
6270  * @details
6271  *
6272  *     Function: rgSCHTomUtlFillSfRepHqFdbk 
6273  *
6274  *         Processing steps:
6275  *
6276  * @param  [out] TfuRecpReqInfo  *recpReqInfo
6277  * @param  [in]  RgSchCellCb     *cell
6278  * @param  [out] RgSchErrInfo    *err
6279  * @param  [in]  RgSchDlSf       *dlSf
6280  * @param  [in]  uint8_t              noFdbks
6281  * @param  [in]  CmMemListCp     *memCp
6282  * @param  [in]  uint8_t              elemIdx
6283  * @param  [in]  RgSchDlSf       *nxtDlsf
6284  *  @return  S16
6285  *      -# ROK 
6286  *      -# RFAILED 
6287  */
6288 #ifdef TFU_UPGRADE
6289 static S16 rgSCHTomUtlFillSfRepHqFdbk
6290 (
6291 TfuRecpReqInfo *recpReqInfo,
6292 RgSchCellCb    *cellCb,
6293 RgSchErrInfo   *err,
6294 RgSchDlSf      *dlSf,
6295 uint8_t        noFdbks,
6296 CmMemListCp    *memCp,
6297 uint8_t        elemIdx,
6298 RgSchDlSf      *nxtDlsf,
6299 uint16_t       validIdx
6300 )
6301 #else
6302 static S16 rgSCHTomUtlFillSfRepHqFdbk
6303 (
6304 TfuRecpReqInfo  *recpReqInfo,
6305 RgSchCellCb     *cellCb,
6306 RgSchErrInfo    *err,
6307 RgSchDlSf       *dlSf,
6308 uint8_t         noFdbks,
6309 CmMemListCp     *memCp,
6310 uint8_t         elemIdx,
6311 RgSchDlSf       *nxtDlsf
6312 )
6313 #endif 
6314 {
6315    RgSchDlHqProcCb         *hqCb;
6316    CmLList                 *node;
6317    S16                     ret;
6318    RgSchUeCb               *ueCb;
6319    TfuUeRecpReqInfo        *pucchRecpInfo;
6320 #ifdef TFU_UPGRADE
6321    TfuUePucchHqRecpInfo    *hqRecpReq;  
6322 #endif
6323    RgSchDlHqTbCb           *tbCb;
6324    RgSchDlHqProcCb         *prvHqCb = NULLP;
6325
6326    node =  dlSf->ackNakRepQ.first;
6327    while (node)
6328    {
6329       tbCb = (RgSchDlHqTbCb *)(node->node);
6330       hqCb = tbCb->hqP;
6331       ueCb = hqCb->hqE->ue;
6332
6333       if (--tbCb->fbkRecpRepCntr)
6334       {            
6335          /* Add to next subfarme */
6336          /* Add this hqCb to the next dlSf's ackNakRepQ */
6337          cmLListAdd2Tail (&(nxtDlsf->ackNakRepQ), 
6338                &(tbCb->anRepLnk[tbCb->fbkRecpRepCntr]));
6339          tbCb->anRepLnk[tbCb->fbkRecpRepCntr].node = (PTR)tbCb;
6340          tbCb->crntSubfrm[tbCb->fbkRecpRepCntr] = nxtDlsf;
6341       }
6342
6343 #ifdef TFU_UPGRADE
6344       if (hqCb->tbCnt) 
6345       {
6346          hqCb->tbCnt--;
6347          /* Go to the next node */
6348          node = node->next;
6349          continue;
6350       }
6351 #endif
6352       if ((hqCb->hqE->ue != NULLP) &&
6353             (hqCb->hqE->ue->measGapCb.isMeasuring != TRUE)
6354             && (hqCb != prvHqCb)
6355          )
6356       {
6357          /* We need to add the recp request to be sent on the pucchANRep
6358           * value.
6359           */
6360          ret = rgSCHUtlGetEventMem((Ptr *)&pucchRecpInfo,
6361                      sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp));
6362          if (ret != ROK)            
6363          {
6364             DU_LOG("\nERROR  -->  SCH : Unable to"
6365                "Allocate TfuUeRecpReqInfo for RNTI:%d ", ueCb->ueId);
6366             err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
6367             return ret;
6368          }
6369          pucchRecpInfo->rnti    =  ueCb->ueId;
6370 #ifndef TFU_UPGRADE
6371          pucchRecpInfo->t.pucchRecpReq.type = TFU_UCI_HARQ;
6372 #else
6373          pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
6374 #endif
6375
6376          /* FOR repetition Feedback shall come on n1PucchAnRep Configured per
6377           * UE.
6378           */
6379 #ifndef TFU_UPGRADE
6380          pucchRecpInfo->t.pucchRecpReq.hqType = TFU_HQ_RECP_REQ_N1PUCCH;
6381          pucchRecpInfo->t.pucchRecpReq.t.n1Pucch = ueCb->ackNakRepCb.pucchRes;
6382 #else
6383          pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ;
6384          hqRecpReq = &(pucchRecpInfo->t.pucchRecpReq.hqInfo);
6385          /* ACK NACK rep works only in bundling mode . */
6386          hqRecpReq->hqFdbkMode = (TfuAckNackMode)RGR_TDD_ACKNACK_MODE_BUNDL;
6387          if ((hqCb->hqPSfLnk.node != NULLP) && 
6388                (hqCb->hqPSfLnk.node != NULLP))
6389          {
6390
6391             hqRecpReq->hqSz = 2;
6392          }
6393          else
6394          {
6395             hqRecpReq->hqSz = 1;
6396          }
6397          hqRecpReq->pucchResCnt = 1; 
6398          hqRecpReq->hqRes[0] = ueCb->ackNakRepCb.pucchRes; 
6399 #endif
6400          cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, &(pucchRecpInfo->lnk));
6401          pucchRecpInfo->lnk.node = (PTR)pucchRecpInfo;
6402       }
6403       /* In a given dlSf, if there is 2 TBs context 
6404        * stored for a given harq, then they are added
6405        * adjacent to each other in the subframe. To avoid
6406        * adding duplicate recpnInfo for each TB, store this
6407        * hqCb in prvHqCb. If nextHqCb is same as prvHqCb then
6408        * do not add reception req info.*/
6409       prvHqCb = hqCb;
6410 #ifdef TFU_UPGRADE
6411       RGSCH_NULL_CHECK(cellCb->instIdx, hqCb->hqE->ue);
6412       rgSCHTomUtlMoveNxtOccasion(cellCb, hqCb->hqE->ue, validIdx);
6413 #endif 
6414       /* Go to the next node */
6415       node = node->next;
6416    }
6417    return ROK;
6418 }
6419
6420 /** @brief This function handles filling of HARQ feedback recption request
6421  * for each subframe 
6422  *
6423  * @details 
6424  *
6425  *     Function: rgSCHTomUtlFillSfHqFdbkInfo
6426  *
6427  *         Processing steps:
6428  *
6429  * @param  [out] TfuRecpReqInfo  *recpReqInfo
6430  * @param  [in]  RgSchCellCb     *cell
6431  * @param  [out] RgSchErrInfo    *err
6432  * @param  [in]  RgSchDlSf       *dlSf
6433  * @param  [in]  uint8_t              noFdbks
6434  * @param  [in]  CmMemListCp     *memCp
6435  * @param  [in]  uint8_t              elemIdx
6436  * @param  [in]  RgSchDlSf       *nxtDlsf
6437 *  @param  [in]  uint16_t             validIdx; 
6438  *  @return  S16
6439  *      -# ROK 
6440  *      -# RFAILED 
6441  */
6442 #ifdef TFU_UPGRADE
6443 static S16 rgSCHTomUtlFillSfHqFdbkInfo
6444 (
6445 TfuRecpReqInfo       *recpReqInfo,
6446 RgSchCellCb          *cellCb,
6447 RgSchErrInfo         *err,
6448 RgSchDlSf            *dlSf,
6449 uint8_t              noFdbks,
6450 CmMemListCp          *memCp,
6451 uint8_t              elemIdx,
6452 RgSchDlSf            *nxtDlsf,
6453 uint16_t             validIdx,
6454 RgSchDlHqProcCb      *hqCb,
6455 RgSchUePucchRecpInfo *pucchInfo,
6456 Bool                 alloc,
6457 RgSchDlHqProcCb      *prvHqCb
6458 )
6459 #else
6460 static S16 rgSCHTomUtlFillSfHqFdbkInfo
6461 (
6462 TfuRecpReqInfo       *recpReqInfo,
6463 RgSchCellCb          *cellCb,
6464 RgSchErrInfo         *err,
6465 RgSchDlSf            *dlSf,
6466 uint8_t              noFdbks,
6467 CmMemListCp          *memCp,
6468 uint8_t              elemIdx,
6469 RgSchDlSf            *nxtDlsf,
6470 RgSchDlHqProcCb      *hqCb,
6471 RgSchUePucchRecpInfo *pucchInfo,
6472 Bool                 alloc,
6473 RgSchDlHqProcCb      *prvHqCb
6474 )
6475 #endif
6476 {
6477    S16                     ret;
6478    RgSchUeCb               *ueCb = hqCb->hqE->ue;
6479 #ifndef TFU_UPGRADE
6480    CmLteTimingInfo         futTime;
6481    RgSchTddANInfo          *anInfo;
6482 #else
6483 #endif
6484    RgrTddAckNackMode       ackNackMode;
6485    RgSchDlHqTbCb           *tbCb;
6486    CmLteRnti               rnti;
6487    uint8_t                      hqSz = 0;
6488    uint32_t                     idx = 0;
6489
6490 #ifndef TFU_UPGRADE
6491    RG_SCH_ADD_TO_CRNT_TIME(cellCb->crntTime, futTime, TFU_RECPREQ_DLDELTA);
6492 #endif
6493
6494
6495    for (idx = 0 ;idx < 2; idx++)
6496    {
6497       if (HQ_TB_WAITING == hqCb->tbInfo[idx].state)
6498       {
6499
6500          tbCb = &hqCb->tbInfo[idx];
6501          if (ueCb)
6502          {
6503             rnti = ueCb->ueId;
6504             ackNackMode = ueCb->dl.ackNackMode;
6505 #ifndef TFU_UPGRADE
6506             if(ackNackMode == RGR_TDD_ACKNACK_MODE_BUNDL)
6507             {
6508                anInfo = rgSCHUtlGetUeANFdbkInfo(ueCb, &futTime);
6509                /* Only the last scheduled TB for the UE is for HARQ
6510                 * ACK/NACK reception in Bundling case */
6511                if((anInfo == NULLP) || 
6512                      (anInfo->latestMIdx != dlSf->dlFdbkInfo.m))
6513                {
6514                                            return ROK; 
6515                                         }
6516             }
6517             else
6518             {
6519                /* Get the TFU reception request pointer, if present */
6520                cmHashListFind(&cellCb->ueTfuPendLst, (uint8_t*) &ueCb->ueId,
6521                      sizeof(ueCb->ueId), 0, (PTR *) &pucchInfo);
6522             }
6523 #else
6524             /* For upgrade we shall use the existing logic of pending list. */
6525             cmHashListFind(&cellCb->ueTfuPendLst, (uint8_t*) &ueCb->ueId,
6526                   sizeof(ueCb->ueId), 0, (PTR *) &pucchInfo);
6527 #endif
6528          }
6529          else if(hqCb->hqE->raCb != NULLP)
6530          {
6531             /* For RACH it is set to Bundling */
6532             ackNackMode = RGR_TDD_ACKNACK_MODE_BUNDL;
6533             rnti = hqCb->hqE->raCb->tmpCrnti;
6534          }
6535          else
6536          {
6537                            return ROK;
6538          }
6539
6540          /* Do not proceed if PUSCH
6541             reception req is already filled*/
6542 #ifdef TFU_UPGRADE
6543          if (hqCb->tbCnt) 
6544          {
6545             hqCb->tbCnt--;
6546             /* Go to the next node */
6547             continue;
6548          }
6549 #endif
6550          if(((ueCb == NULLP) || (ueCb->measGapCb.isMeasuring != TRUE))
6551                &&(hqCb != prvHqCb)
6552            )
6553          {
6554             TknUInt16       n1PucchTkn = {FALSE, 0};
6555             RgSchPdcch   *pdcch;
6556             uint8_t            tbIndx;
6557             pdcch = tbCb->hqP->pdcch;
6558 #ifdef LTEMAC_SPS
6559             n1PucchTkn = hqCb->spsN1PucchRes;
6560 #endif
6561             for (tbIndx = 0; tbIndx < TFU_MAX_TB; tbIndx++)
6562             {
6563                if (hqCb->tbInfo[tbIndx].state == HQ_TB_WAITING && 
6564                      (RGSCH_TIMEINFO_SAME(hqCb->tbInfo[tbIndx].fdbkTime,
6565                                           recpReqInfo->timingInfo)))
6566                {
6567                   hqSz++;
6568                   hqCb->tbInfo[tbIndx].pucchFdbkIdx = hqCb->ulDai;
6569                }
6570             }
6571             ret = rgSCHTomUtlFillSfHqFdbkForOneUe(hqCb,recpReqInfo, cellCb, err, dlSf, noFdbks,
6572                   memCp, elemIdx, nxtDlsf, rnti, ackNackMode, &pucchInfo, pdcch,
6573                   n1PucchTkn, &alloc, hqSz);
6574             if (ret != ROK)
6575             {
6576                return ret;
6577             }
6578             /* TODO:: In case of F1BCS and CSI in same subframe
6579              * UE shall drop the CSI if there was at least one 
6580              * PDSCH transmission in any of the DL subframe
6581              * mapping to this UL subframe
6582              * */
6583 #ifdef TFU_UPGRADE
6584             rgSCHTomUtlFillCqiSrSrsWithHq(cellCb,recpReqInfo, hqCb->hqE->ue, 
6585                   pucchInfo->pucchRecpInfo, validIdx,FALSE);  
6586 #ifdef LTE_ADV
6587             if((hqCb->hqE->ue) &&
6588                (hqCb->hqE->ue->uciFrmtTyp == RG_SCH_UCI_FORMAT1B_CS))
6589             {
6590
6591                if(RG_SCH_IS_CELL_SEC(hqCb->hqE->ue,hqCb->hqE->cell))
6592                {
6593                   switch(pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo)
6594                   {
6595                      case TFU_PUCCH_HARQ_SR_CQI:
6596                         pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR;
6597                         RG_SCH_DECR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
6598                         break;
6599                      case TFU_PUCCH_HARQ_CQI:
6600                         pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ;
6601                         RG_SCH_DECR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
6602                         break;
6603                      case TFU_PUCCH_HARQ_SR_CQI_SRS:
6604                         pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR_SRS;
6605                         RG_SCH_DECR_CQIRI_INDEX(ueCb->cqiRiWritIdx);
6606                         break;
6607                      case TFU_PUCCH_HARQ_SR_SRS:
6608                         pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ_SR;
6609                         break;
6610                      case TFU_PUCCH_HARQ_SRS:
6611                         pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo = TFU_PUCCH_HARQ;
6612                         break;
6613                      default:
6614                         break;
6615                   }
6616                }
6617             }
6618 #endif
6619
6620 #endif 
6621
6622             /* TODO antz - pushing the following code (under TFU_UPGRADE)
6623              * into the above function (...ForOneUe) did not work (caused
6624              * two additional TCs to fail). Don't know why. If this
6625              * is done later, make sure that the code branch
6626              * for relPdcch (later in this func) is also modified appropriately.
6627              */
6628             /* Now add to the recp request or pending list */
6629             //if((elemIdx != (noFdbks - 1)))
6630             {
6631                cmHashListInsert(&cellCb->ueTfuPendLst, (PTR) pucchInfo,
6632                      (uint8_t *)&rnti ,(uint16_t) sizeof(CmLteRnti));
6633                alloc = FALSE;
6634             }
6635
6636          } /* If measuring */
6637          /* Go to the next node */
6638          if ((tbCb->fbkRecpRepCntr) && (--tbCb->fbkRecpRepCntr))
6639          {
6640             /* Add to next subfarme */
6641             /* Add this hqCb to the next dlSf's ackNakRepQ */
6642             cmLListAdd2Tail (&(nxtDlsf->ackNakRepQ), 
6643                   &(tbCb->anRepLnk[tbCb->fbkRecpRepCntr]));
6644             tbCb->anRepLnk[tbCb->fbkRecpRepCntr].node = (PTR)tbCb;
6645             tbCb->crntSubfrm[tbCb->fbkRecpRepCntr] = nxtDlsf;
6646          }
6647          /* In a given dlSf, if there is 2 TBs context 
6648           * stored for a given harq, then they are added
6649           * adjacent to each other in the subframe. To avoid
6650           * adding duplicate recpnInfo for each TB, store this
6651           * hqCb in prvHqCb. If nextHqCb is same as prvHqCb then
6652           * do not add reception req info.*/
6653          prvHqCb = hqCb;
6654       }
6655    }
6656    return ROK;
6657 }
6658
6659 #ifdef LTE_ADV
6660 /** @brief This function calculates the pucch resource idx 
6661  *         that is to be filled in harq reception request
6662  *
6663  * @details 
6664  *
6665  *     Function: rgSCHTomUtlGethqRes
6666  *
6667  *         Processing steps:
6668  *          -Calculate the pucch resource idx 
6669  *           Harq Reception Request for Format 1B with
6670  *           Channel Selection
6671  *
6672  * @param  [in] uint8_t                      noFdbks
6673  * @param  [in] RgSchDlSf               *dlSf
6674  * @param  [in] RgSchPdcch              *pdcch
6675  * @param  [in] RgSchCellCb             *cellCb
6676  * @param  [out]uint16_t                     *hqRes
6677  * @return void
6678  */
6679 static Void rgSCHTomUtlGethqRes
6680 (
6681 uint8_t       noFdbks,
6682 RgSchDlSf     *dlSf,
6683 RgSchPdcch    *pdcch,
6684 RgSchCellCb   *cellCb,
6685 uint16_t      *hqRes
6686 )
6687 {
6688    uint8_t    M;
6689    uint8_t    P;
6690    uint8_t    m;
6691    uint8_t    nP;
6692    uint8_t    nPlusOne;
6693    uint8_t    nCce;
6694    
6695    M = noFdbks;
6696    m = dlSf->dlFdbkInfo.m;
6697    nCce = pdcch->nCce;
6698    P = rgSCHCmnGetPValFrmCCE(cellCb, nCce);
6699    nP = cellCb->rgSchTddNpValTbl[P];
6700    nPlusOne = cellCb->rgSchTddNpValTbl[P + 1];
6701    *hqRes = (M - m - 1)* nP + (m * nPlusOne) + pdcch->nCce + 
6702       cellCb->pucchCfg.n1PucchAn;
6703
6704    return;
6705 }
6706
6707 /** @brief This function fills the harq reception request for
6708  *         TDD in case of Fomat 1B with CS for M=1
6709  *
6710  * @details 
6711  *
6712  *     Function: rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM1
6713  *
6714  *         Processing steps:
6715  *          -Fill Harq Reception Request for Format 1B with
6716  *           Channel Selection
6717  *
6718  * @param  [in] RgSchDlHqProcCb         *hqCb
6719  * @param  [in] TfuUePucchRecpReq       *hqRecpReq
6720  * @param  [in] uint8_t                      noFdbks
6721  * @param  [in] RgSchDlSf               *dlSf
6722  * @param  [in] RgSchPdcch              *pdcch
6723  * @param  [in] RgSchCellCb             *cellCb
6724  * @return void
6725  */
6726 static Void rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM1
6727 (
6728 RgSchDlHqProcCb     *hqCb,
6729 TfuUePucchRecpReq   *hqRecpReq,
6730 uint8_t             noFdbks,
6731 RgSchDlSf           *dlSf,
6732 RgSchPdcch          *pdcch,
6733 RgSchCellCb         *cellCb
6734 )
6735 {
6736    RgSchUeCb *ue = NULLP;
6737    Bool      isCellSec = FALSE;
6738    uint16_t  hqRes;
6739
6740    /*ccpu00147920: UeCb is NULL for SPS activation*/
6741    if(pdcch && pdcch->ue)
6742    {/* SPS Release pdcch or dynamic data */
6743       ue = pdcch->ue;
6744    }else
6745    {/* SPS occasion */
6746 #ifdef ERRCLS_KW
6747       if(hqCb == NULLP)
6748       {
6749          /* This is not supposed to happen
6750           * Error case. hqCB has to be ter
6751           * when pdcch is present . Adding 
6752           * if check bcs of kwork*/
6753          return;
6754       }
6755 #endif
6756       ue = hqCb->hqE->ue;
6757    }
6758
6759    if((hqCb != NULLP) && 
6760       (RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell)))
6761    {
6762       isCellSec = TRUE;
6763    }
6764
6765    switch(ue->f1bCsAVal)
6766    {
6767       case RG_SCH_A_VAL_2:
6768          /* harq(0) is primary harq(1) is secondary) */
6769          if(isCellSec)
6770          {
6771             hqRecpReq->hqInfo.hqRes[1] = ue->n1PucchF1bResCb.
6772                cw1N1Res[hqCb->tpc].n1PucchIdx;
6773          }
6774          else/* primary cell */
6775          {
6776 #ifdef LTEMAC_SPS
6777             /* hqCb will be null in case of sps rel pdcch */
6778             if ((hqCb) && hqCb->spsN1PucchRes.pres)
6779             {/* SPS occasion or dyn sched*/
6780                hqRecpReq->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
6781             }
6782             else
6783 #endif /* LTEMAC_SPS */
6784             {/* dyn data or sps release */
6785 #ifdef ERRCLS_KW
6786                if(pdcch == NULLP)
6787                {
6788                   /* This is not supposed to happen
6789                    * Error case. hqCB has to be ter
6790                    * when pdcch is present . Adding 
6791                    * if check bcs of kwork*/
6792                   return;
6793                }
6794 #endif
6795  
6796                rgSCHTomUtlGethqRes(noFdbks,dlSf,pdcch,cellCb,&hqRes);
6797                hqRecpReq->hqInfo.hqRes[0] = hqRes;
6798             }
6799          }
6800          break;
6801       case RG_SCH_A_VAL_3:
6802          {
6803             /* Serving cell in mimo mode should be
6804              * in 0 and 1 and the serving cell in siso
6805              * mode should be in 2 indices */
6806             if(isCellSec)
6807             {
6808                uint8_t servCellIdx = rgSchUtlGetServCellIdx(hqCb->hqE->cell->instIdx,
6809                      hqCb->hqE->cell->cellId,
6810                      hqCb->hqE->ue);
6811
6812                if(rgSCHUtlGetMaxTbSupp(ue->cellInfo[servCellIdx]->txMode.txModeEnum) > 1)
6813                {/* Sec cell is in mimo mode, use 0 and 1 */
6814                   hqRecpReq->hqInfo.hqRes[0] = 
6815                      ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
6816                   hqRecpReq->hqInfo.hqRes[1] = 
6817                         ue->n1PucchF1bResCb.cw2N1Res[hqCb->tpc].n1PucchIdx;
6818                }
6819                else
6820                {/* Sec cell is in siso mode, use 2 */
6821                   hqRecpReq->hqInfo.hqRes[2] = 
6822                      ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
6823                }   
6824             }
6825             else
6826             {/* primary cell hq */
6827
6828                if(rgSCHUtlGetMaxTbSupp(ue->mimoInfo.txMode) > 1)
6829                {/* prim cell is in mimo mode, use 0 and 1 */
6830 #ifdef LTEMAC_SPS
6831                   if (hqCb && hqCb->spsN1PucchRes.pres)
6832                   {/* Not sps release */
6833                      hqRecpReq->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
6834                   }
6835                   else
6836 #endif /* LTEMAC_SPS */
6837                   {/* sps rel or dyn */
6838 #ifdef ERRCLS_KW
6839                      if(pdcch == NULLP)
6840                      {
6841                         /* This is not supposed to happen
6842                          * Error case. hqCB has to be ter
6843                          * when pdcch is present . Adding 
6844                          * if check bcs of kwork*/
6845                         return;
6846                      }
6847 #endif
6848
6849                      rgSCHTomUtlGethqRes(noFdbks,dlSf,pdcch,cellCb,&hqRes);
6850                      hqRecpReq->hqInfo.hqRes[0] = hqRes;
6851                      hqRecpReq->hqInfo.hqRes[1] = hqRes + 1;
6852                   }
6853                }
6854                else
6855                {/* prim cell is in siso mode use 2 */
6856 #ifdef LTEMAC_SPS
6857                   /* Consider sps occasions */
6858                   if (hqCb && hqCb->spsN1PucchRes.pres)
6859                   {/* Not sps release */
6860                      hqRecpReq->hqInfo.hqRes[2] = hqCb->spsN1PucchRes.val;
6861                   }
6862                   else
6863 #endif /* LTEMAC_SPS */
6864                   {
6865 #ifdef ERRCLS_KW
6866                      if(pdcch == NULLP)
6867                      {
6868                         /* This is not supposed to happen
6869                          * Error case. hqCB has to be ter
6870                          * when pdcch is present . Adding 
6871                          * if check bcs of kwork*/
6872                         return;
6873                      }
6874 #endif
6875
6876                      rgSCHTomUtlGethqRes(noFdbks,dlSf,pdcch,cellCb,&hqRes);
6877                      hqRecpReq->hqInfo.hqRes[2] = hqRes;
6878                   }
6879                }
6880             }
6881          }
6882          break;
6883       case RG_SCH_A_VAL_4:
6884          {/* Both the serv cells are in mimo mode */
6885             if(isCellSec)
6886             {/* 2 and 3 for sec cell */
6887                hqRecpReq->hqInfo.hqRes[2] = 
6888                   ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
6889                hqRecpReq->hqInfo.hqRes[3] = 
6890                      ue->n1PucchF1bResCb.cw2N1Res[hqCb->tpc].n1PucchIdx;
6891             }
6892             else/* primary cell */
6893             {/* 0 and 1 are for primary cell */
6894 #ifdef LTEMAC_SPS
6895                if (hqCb && hqCb->spsN1PucchRes.pres)
6896                {/* Not sps release */
6897                   hqRecpReq->hqInfo.hqRes[0] = hqCb->spsN1PucchRes.val;
6898                }
6899                else
6900 #endif /* LTEMAC_SPS */
6901                {
6902 #ifdef ERRCLS_KW
6903                   if(pdcch == NULLP)
6904                   {
6905                      /* This is not supposed to happen
6906                       * Error case. hqCB has to be ter
6907                       * when pdcch is present . Adding 
6908                       * if check bcs of kwork*/
6909                      return;
6910                   }
6911 #endif
6912
6913                   rgSCHTomUtlGethqRes(noFdbks,dlSf,pdcch,cellCb,&hqRes);
6914                   hqRecpReq->hqInfo.hqRes[0] = hqRes;
6915                   hqRecpReq->hqInfo.hqRes[1] = hqRes + 1;
6916                }
6917             }
6918          }
6919          break;
6920       default:
6921          break;
6922    }
6923    return;
6924 }
6925
6926 /** @brief This function fills the harq reception request for
6927  *         TDD in case of Fomat 1B with CS for M>=2
6928  *
6929  * @details 
6930  *
6931  *     Function: rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM234
6932  *
6933  *         Processing steps:
6934  *          -Fill Harq Reception Request for Format 1B with
6935  *           Channel Selection
6936  *
6937  * @param  [in] RgSchDlHqProcCb         *hqCb
6938  * @param  [in] TfuUePucchRecpReq       *hqRecpReq
6939  * @param  [in] uint8_t                      noFdbks
6940  * @param  [in] RgSchDlSf               *dlSf
6941  * @param  [in] RgSchPdcch              *pdcch
6942  * @param  [in] RgSchCellCb             *cellCb
6943  * @param  [in] uint8_t                      elemIdx
6944  * @return void
6945  */
6946 static Void rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM234
6947 (
6948 RgSchDlHqProcCb    *hqCb,
6949 TfuUePucchRecpReq  *hqRecpReq,
6950 uint8_t            noFdbks,
6951 RgSchDlSf          *dlSf,
6952 RgSchPdcch         *pdcch,
6953 RgSchCellCb        *cellCb,
6954 uint8_t            elemIdx
6955 )
6956 {
6957    RgSchUeCb  *ue;
6958    Bool       isCellSec = FALSE;
6959    uint16_t   hqRes = 0;
6960    uint8_t    servCellIdx;
6961
6962    if(pdcch)
6963    {/* SPS Release pdcch or dynamic data */
6964       ue = pdcch->ue;
6965    }else
6966    {/* SPS occasion */
6967 #ifdef ERRCLS_KW
6968       if(hqCb == NULLP)
6969       {
6970          /* This is not supposed to happen
6971           * Error case. hqCB has to be ter
6972           * when pdcch is present . Adding 
6973           * if check bcs of kwork*/
6974          return;
6975       }
6976 #endif
6977       ue = hqCb->hqE->ue;
6978    }
6979
6980    if((hqCb != NULLP) && (ue != NULLP) &&  
6981       (RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell)))
6982    {
6983       isCellSec = TRUE;
6984    }   
6985
6986    if(isCellSec)
6987    {/* Sec Cell indices are 2 and 3*/
6988       servCellIdx = rgSchUtlGetServCellIdx(hqCb->hqE->cell->instIdx,
6989                                            hqCb->hqE->cell->cellId,
6990                                            hqCb->hqE->ue);
6991
6992       hqRecpReq->hqInfo.hqRes[2] = 
6993          ue->n1PucchF1bResCb.cw1N1Res[hqCb->tpc].n1PucchIdx;
6994
6995       if(rgSCHUtlGetMaxTbSupp(ue->cellInfo[servCellIdx]->txMode.txModeEnum) > 1)
6996       {
6997          hqRecpReq->hqInfo.hqRes[3] = 
6998             ue->n1PucchF1bResCb.cw2N1Res[hqCb->tpc].n1PucchIdx;
6999       }
7000    }
7001    else
7002    {/* Primary cell indices are 0 and 1 */
7003       /* SPS occasions
7004        * M > 2 if SPS occasion is present in any of the 
7005        * DL subframe in the bundle, the n1Pucch(0) is
7006        * the SPS resource and n1Pucch(1) is the resource
7007        * derived from pdcch with DAI = 1
7008        * If No SPS Occasion
7009        * Then n1Pucch(0) is from pdcch with DAI =1
7010        * and n1Pucch(1) is from pdcch with DAI = 2
7011        * */
7012
7013       if(hqCb != NULLP)
7014       {/* this is not sps release pdcch */
7015          if(hqCb->spsN1PucchRes.pres == TRUE)
7016          {/* SPS occasion*/
7017             hqRes = hqCb->spsN1PucchRes.val;
7018          }
7019       }
7020
7021       if(pdcch)
7022       {/*Dynamic scheduling or SPS Release
7023          Derive from pdcch */
7024          if(pdcch->dlDai < 3)
7025          {/* No need to calcualte from DAI > 2 */
7026             rgSCHTomUtlGethqRes(noFdbks,dlSf,pdcch,cellCb,&hqRes);
7027          }
7028       }
7029
7030       if(2 == noFdbks)
7031       {/* M == 2 case */
7032          hqRecpReq->hqInfo.hqRes[elemIdx] = hqRes; 
7033       }
7034       else
7035       {/* Pdcch with DAI = 1 and 2 needs to be used
7036           for resource calculation*/
7037          if(hqCb && hqCb->spsN1PucchRes.pres == TRUE)
7038          {/* dyn or sps occasion */
7039             /* Shift the hqRes[0] if it was filled
7040              * if there was a pdcch with DAI 1 before to this 
7041              * subframe*/
7042             if(hqCb->ulDai > 1)
7043             {/* SPS occasion happened in the middle 
7044                 of the bundle */
7045                /* shifting the non SPS resource to n1Pucch(1) */
7046                hqRecpReq->hqInfo.hqRes[1] = hqRecpReq->hqInfo.hqRes[0]; 
7047             }
7048
7049             hqRecpReq->hqInfo.hqRes[0] = hqRes; 
7050          }
7051 #ifdef ERRCLS_KW
7052          else if(pdcch && pdcch->dlDai < 3)
7053 #else
7054          else if(pdcch->dlDai < 3)
7055 #endif
7056          {/* sps rel or dyn sched */
7057             /* hqCb wil not be present for sps release pdcch */
7058             if(hqCb && (pdcch->dlDai != hqCb->ulDai))
7059             {/* there was a SPS occasion before to this */
7060                if(pdcch->dlDai == 1)
7061                {
7062                   hqRecpReq->hqInfo.hqRes[1] = hqRes; 
7063                }/* ignore the DAI 2 in this case */
7064             }else
7065             {/* There was no SPS occasion before to this */
7066 #ifdef ERRCLS_KW
7067                if(pdcch->dlDai)
7068 #endif
7069                {/* Added check to ignore kwork warning */
7070                   hqRecpReq->hqInfo.hqRes[(pdcch->dlDai)-1] = hqRes; 
7071                }
7072             }
7073          }
7074       }
7075    }
7076    return;
7077 }
7078
7079 /** @brief This function fills the harq reception request for
7080  *         TDD in case of Fomat 1B with CS
7081  *
7082  * @details 
7083  *
7084  *     Function: rgSCHTomUtlFillSfHqFdbkForFrmt1BCS
7085  *
7086  *         Processing steps:
7087  *          -Fill Harq Reception Request for Format 1B with
7088  *           Channel Selection
7089  *
7090  * @param  [in] RgSchDlSf     *ulSf
7091  * @param  [in] RgSchCellCb   *cell
7092  * @param  [out]TfuUePucchRecpReq *hqRecpReq
7093  * @return S16
7094  */
7095 static S16 rgSCHTomUtlFillSfHqFdbkForFrmt1BCS
7096 (
7097 RgSchDlHqProcCb    *hqCb,
7098 TfuUePucchRecpReq  *hqRecpReq,
7099 uint8_t            noFdbks,
7100 RgSchDlSf          *dlSf,
7101 RgSchPdcch         *pdcch,
7102 uint8_t            elemIdx,
7103 RgSchCellCb        *cellCb
7104 )
7105 {
7106    /* Update teh fdbk mode if something different is present
7107     * in L1 API file for F1BS *//* 1 --> F1BCS */
7108    hqRecpReq->hqInfo.hqFdbkMode = TFU_ACK_NACK_CHANNEL_SELECTION;
7109
7110    switch(noFdbks)
7111    {/* M Value */
7112       case RG_SCH_M_VAL_1:
7113          {
7114
7115             rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM1(hqCb,hqRecpReq,
7116                   noFdbks,dlSf,pdcch,cellCb);
7117             break;
7118          }
7119       case RG_SCH_M_VAL_2:
7120       case RG_SCH_M_VAL_3:
7121       case RG_SCH_M_VAL_4:
7122          {
7123             /* Spatial bundling will be applied */
7124             rgSCHTomUtlFillSfHqFdbkForFrmt1BCSForM234(hqCb,hqRecpReq,
7125                   noFdbks,dlSf,pdcch,cellCb,elemIdx);
7126             break;
7127          }
7128       default:
7129          break;
7130    }
7131    return ROK;
7132 }
7133 #endif
7134
7135 /***********************************************************
7136  *
7137  *     Func : rgSCHTomUtlFillSfHqFdbkForOneUe
7138  *
7139  *     Desc : Fill HARQ feedback info for one UE/entry
7140  *
7141  *     Ret  : ROK/RFAILED
7142  *
7143  *     Notes:
7144  *
7145  *     File :
7146  *
7147  **********************************************************/
7148 static S16 rgSCHTomUtlFillSfHqFdbkForOneUe
7149
7150 RgSchDlHqProcCb         *hqCb,
7151 TfuRecpReqInfo          *recpReqInfo,
7152 RgSchCellCb             *cellCb,
7153 RgSchErrInfo            *err,
7154 RgSchDlSf               *dlSf,
7155 uint8_t                 noFdbks,
7156 CmMemListCp             *memCp,
7157 uint8_t                 elemIdx,
7158 RgSchDlSf               *nxtDlsf,
7159 CmLteRnti               rnti,
7160 RgrTddAckNackMode       ackNackMode,
7161 RgSchUePucchRecpInfo    **pucchInfoRef,
7162 RgSchPdcch              *pdcch,
7163 TknUInt16               n1PucchTkn,
7164 Bool                    *allocRef,
7165 uint8_t                 hqSz  
7166 )
7167 {
7168    RgSchUePucchRecpInfo    *pucchInfo = *pucchInfoRef;
7169    Bool                    alloc = FALSE;
7170    S16                     ret;
7171    TfuUePucchRecpReq       *hqRecpReq;
7172 #ifdef TFU_UPGRADE
7173    uint8_t                 M;
7174    uint8_t                 P;
7175    uint8_t                 m;
7176    uint8_t                 nP;
7177    uint8_t                 nPlusOne;
7178    uint16_t                pucchRes;
7179    uint8_t                 resIdx;
7180    uint8_t                 nCce;
7181    uint8_t                 prevHqSize;
7182 #else
7183    uint8_t                 multCnt;
7184 #endif
7185 #ifdef LTEMAC_SPS
7186    Bool                    isFirstFdbk = FALSE;
7187 #endif
7188    if(pucchInfo == NULLP)
7189    {
7190       if ((ret = rgSCHUtlGetEventMem((Ptr *)&pucchInfo,
7191                   sizeof(RgSchUePucchRecpInfo), memCp)) != ROK)
7192       {
7193          DU_LOG("\nERROR  -->  SCH : Unable to "
7194             "Allocate TfuUeRecpReqInfo for cell RNTI:%d",rnti);
7195          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
7196          return ret;
7197       }
7198       alloc = TRUE;
7199 #ifdef TFU_ALLOC_EVENT_NO_INIT
7200       pucchInfo->hashLstEnt.hashVal = 0;
7201       pucchInfo->hashLstEnt.keyLen = 0;
7202       pucchInfo->hashLstEnt.key = 0;
7203       pucchInfo->hashLstEnt.list.prev = pucchInfo->hashLstEnt.list.next = 0;
7204 #endif
7205       if ((ret = rgSCHUtlGetEventMem((Ptr *)&(pucchInfo->pucchRecpInfo),
7206                   sizeof(TfuUeRecpReqInfo), &(recpReqInfo->memCp))) != ROK)
7207       {
7208          DU_LOG("\nERROR  -->  SCH : Unable to "
7209             "Allocate TfuUeRecpReqInfo for cell RNTI:%d",rnti);
7210          err->errCause = RGSCHERR_TOM_MEM_EXHAUST;
7211          return ret;
7212       }
7213       memset(pucchInfo->pucchRecpInfo->t.pucchRecpReq.hqInfo.hqRes,0xff,sizeof(uint16_t)*TFU_MAX_HQ_RES);
7214 #ifdef TFU_ALLOC_EVENT_NO_INIT
7215       memset(&pucchInfo->pucchRecpInfo->t.pucchRecpReq, 0, sizeof(TfuUePucchRecpReq));
7216 #endif
7217       pucchInfo->pucchRecpInfo->type = TFU_RECP_REQ_PUCCH;
7218       pucchInfo->pucchRecpInfo->rnti = rnti;
7219 #ifdef TFU_UPGRADE
7220       pucchInfo->pucchRecpInfo->t.pucchRecpReq.uciInfo=TFU_PUCCH_HARQ;
7221 #endif
7222 #ifdef LTEMAC_SPS
7223       isFirstFdbk = TRUE;
7224 #endif
7225    }
7226    /* Fill m, M, P */
7227    /* Calculation of resources same for both bundling and muxing for M = 1
7228     * */
7229 #ifdef LTE_ADV
7230     RgSchUeCb     *ue = rgSCHDbmGetUeCb (cellCb, rnti);
7231     if((ue) && (1 == ue->numSCells))
7232     {
7233        if(ue->uciFrmtTyp == RG_SCH_UCI_FORMAT1B_CS)
7234        {
7235           hqRecpReq = &(pucchInfo->pucchRecpInfo->t.pucchRecpReq);
7236           rgSCHTomUtlFillSfHqFdbkForFrmt1BCS(hqCb,hqRecpReq,
7237                 noFdbks,dlSf,pdcch,elemIdx,cellCb);
7238
7239           if(noFdbks == 1)
7240           {/* M = 1 case . size is same as A Value*/
7241                hqRecpReq->hqInfo.hqSz = ue->f1bCsAVal;
7242                hqRecpReq->hqInfo.pucchResCnt = hqRecpReq->hqInfo.hqSz;
7243           }else
7244           {/* M > 1 case */
7245             hqRecpReq->hqInfo.hqSz = (noFdbks * 2); /* M for 2 cells */
7246             hqRecpReq->hqInfo.pucchResCnt = 4;
7247           }
7248           hqRecpReq->hqInfo.a = ue->f1bCsAVal;
7249           /* handling for SPS occasions*/
7250           if(elemIdx == 0)
7251           {
7252              /* set the datPresinFirstSUbframe to TRUE if this 
7253               * is for pcell txion*/
7254 #ifdef ERRCLS_KW
7255              RgSchTddANInfo      *anInfo = NULLP;
7256 #endif
7257              /* if this txion is on pcell
7258               * sps occaion, dyn sched or sps release pdcch
7259               * set the sched present in first 
7260               * dl subframe of the bundle to TRUE. This 
7261               * is required for mapping the feedbak when SPS occasion
7262               * is present in any of the DL subframe in the bundle in 
7263               * case of M > 2*/
7264
7265               /* SPS will happen only on pcell */
7266              if((hqCb == NULLP) || (!RG_SCH_IS_CELL_SEC(ue,hqCb->hqE->cell)))
7267              {
7268 #ifdef ERRCLS_KW
7269                  anInfo = rgSCHUtlGetUeANFdbkInfo(ue,
7270                       &recpReqInfo->timingInfo,RGSCH_PCELL_INDEX);
7271                 if(anInfo == NULL)
7272                 {/* ANInfo must be there. adding block
7273                     because of kworks*/
7274                    DU_LOG("\nERROR  -->  SCH : ANInfo should not be NULL for cellId=%d \n", cellCb->cellId);
7275                    return RFAILED;
7276                 }
7277 #endif
7278              }
7279          }
7280        }else
7281        {/* This needs to be revisited while
7282            adding support for PUCCH format 3 */
7283           DU_LOG("\nERROR  -->  SCH : Invalid Pucch format configured..");
7284           return RFAILED;
7285        }
7286     }
7287     else
7288 #endif
7289     {
7290        if((ackNackMode == RGR_TDD_ACKNACK_MODE_BUNDL) || 
7291              ((noFdbks == 1) && (ackNackMode == RGR_TDD_ACKNACK_MODE_MULT)))
7292        {
7293           hqRecpReq = &(pucchInfo->pucchRecpInfo->t.pucchRecpReq);
7294 #ifdef TFU_UPGRADE
7295           prevHqSize =  hqRecpReq->hqInfo.hqSz;
7296 #endif
7297 #ifndef TFU_UPGRADE
7298           /* Only one index for bundling case */
7299           hqRecpReq->M = noFdbks;
7300           hqRecpReq->hqType =
7301              TFU_HQ_RECP_REQ_NORMAL;
7302           hqRecpReq->multCnt = 1;
7303           hqRecpReq->t.nCce[0] = 
7304              pdcch->nCce;
7305           hqRecpReq->m[0] = 
7306              dlSf->dlFdbkInfo.m;
7307           hqRecpReq->p[0] =
7308              rgSCHCmnGetPValFrmCCE(cellCb, pdcch->nCce);
7309
7310           hqRecpReq->type = TFU_UCI_HARQ;
7311
7312 #else /* TFU_UPGRADE */
7313
7314 #ifdef LTEMAC_SPS
7315           if ((TRUE == isFirstFdbk) && (TRUE == n1PucchTkn.pres))
7316           {
7317              hqRecpReq->hqInfo.hqFdbkMode = (TfuAckNackMode)ackNackMode;
7318              hqRecpReq->hqInfo.pucchResCnt=1;
7319              hqRecpReq->hqInfo.hqRes[0] = n1PucchTkn.val;
7320              hqRecpReq->hqInfo.hqSz = hqSz;
7321           }
7322           /* ccpu00139413 */
7323           else if (FALSE == n1PucchTkn.pres)
7324 #endif
7325           {
7326              hqRecpReq->hqInfo.hqFdbkMode = (TfuAckNackMode)ackNackMode;
7327              M = noFdbks;
7328              P = rgSCHCmnGetPValFrmCCE(cellCb, pdcch->nCce);
7329              nP = cellCb->rgSchTddNpValTbl[P];
7330              nPlusOne = cellCb->rgSchTddNpValTbl[P + 1];
7331              m = dlSf->dlFdbkInfo.m;
7332              /* In case of no UE */
7333              pucchRes = (M - m - 1)* nP + (m * nPlusOne) + pdcch->nCce + 
7334                 cellCb->pucchCfg.n1PucchAn;
7335              /*ccpu00130164:MOD-Changed to maitain value of
7336                hqRecpReq->hqInfo.pucchResCnt=1 in case of bundling*/
7337              /*ccpu00132284 -MOD- hqRes need to be updated after pucchReCnt set to 1
7338               * and resource should be update at index-0*/
7339              hqRecpReq->hqInfo.pucchResCnt=1;
7340              hqRecpReq->hqInfo.hqRes[hqRecpReq->hqInfo.pucchResCnt-1] = pucchRes;
7341
7342              if((ackNackMode == RGR_TDD_ACKNACK_MODE_BUNDL) && (hqSz > prevHqSize))
7343                 hqRecpReq->hqInfo.hqSz = hqSz;
7344              else if (ackNackMode == RGR_TDD_ACKNACK_MODE_MULT)
7345                 hqRecpReq->hqInfo.hqSz = hqSz;
7346              else
7347                 hqRecpReq->hqInfo.hqSz = prevHqSize;
7348           }
7349 #endif /* TFU_UPGRADE */
7350 #ifndef TFU_UPGRADE
7351           cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, 
7352                 &(pucchInfo->pucchRecpInfo->lnk));
7353           pucchInfo->pucchRecpInfo->lnk.node = 
7354              (PTR)pucchInfo->pucchRecpInfo;
7355 #endif
7356        }
7357        else /* Multiplexing */
7358        {
7359 #ifndef TFU_UPGRADE
7360           pucchInfo->pucchRecpInfo->t.pucchRecpReq.M = noFdbks;
7361 #ifdef LTEMAC_SPS
7362           if (n1PucchTkn.pres == TRUE)
7363           {
7364              pucchInfo->pucchRecpInfo->t.pucchRecpReq.hqType =
7365                 TFU_HQ_RECP_REQ_N1PUCCH;
7366              pucchInfo->pucchRecpInfo->t.pucchRecpReq.t.n1Pucch = n1PucchTkn.val;
7367           }
7368           else
7369 #endif
7370           {
7371              pucchInfo->pucchRecpInfo->t.pucchRecpReq.hqType =
7372                 TFU_HQ_RECP_REQ_NORMAL;
7373              multCnt = pucchInfo->pucchRecpInfo->t.pucchRecpReq.multCnt;
7374              pucchInfo->pucchRecpInfo->t.pucchRecpReq.t.nCce[multCnt] = 
7375                 pdcch->nCce;
7376              pucchInfo->pucchRecpInfo->t.pucchRecpReq.m[multCnt] =
7377                 dlSf->dlFdbkInfo.m;
7378              pucchInfo->pucchRecpInfo->t.pucchRecpReq.p[multCnt] =
7379                 rgSCHCmnGetPValFrmCCE(cellCb, pdcch->nCce);
7380
7381              pucchInfo->pucchRecpInfo->t.pucchRecpReq.multCnt++;
7382           }
7383 #else /* TFU_UPGRADE */
7384
7385           hqRecpReq = &(pucchInfo->pucchRecpInfo->t.pucchRecpReq);
7386           hqRecpReq->hqInfo.hqFdbkMode = (TfuAckNackMode)RGR_TDD_ACKNACK_MODE_MULT;
7387           hqRecpReq->hqInfo.hqSz = noFdbks;
7388
7389           resIdx = hqRecpReq->hqInfo.pucchResCnt;
7390           hqRecpReq->hqInfo.pucchResCnt++;
7391
7392 #ifdef LTEMAC_SPS
7393           if (n1PucchTkn.pres == TRUE)
7394           {
7395              hqRecpReq->hqInfo.hqRes[resIdx] = n1PucchTkn.val;
7396           }
7397           else
7398 #endif
7399           {
7400              M = noFdbks;
7401              m = dlSf->dlFdbkInfo.m;
7402              nCce = pdcch->nCce;
7403              P = rgSCHCmnGetPValFrmCCE(cellCb, nCce);
7404              nP = cellCb->rgSchTddNpValTbl[P];
7405              nPlusOne = cellCb->rgSchTddNpValTbl[P + 1];
7406              hqRecpReq->hqInfo.hqRes[resIdx] = (M - m - 1)* nP + 
7407                 (m * nPlusOne) + pdcch->nCce + 
7408                 cellCb->pucchCfg.n1PucchAn;
7409           }
7410 #endif /* TFU_UPGRADE */
7411           /* If all the DL subframes are scanned, then
7412            * send TFU request*/
7413 #ifndef TFU_UPGRADE
7414           if((elemIdx != noFdbks) && alloc)
7415           {
7416              cmHashListInsert(&cellCb->ueTfuPendLst, (PTR) pucchInfo,
7417                    (uint8_t *)&rnti, (uint16_t) sizeof(rnti));
7418              alloc = FALSE;
7419           }
7420           else
7421           {
7422              pucchInfo->pucchRecpInfo->t.pucchRecpReq.type = TFU_UCI_HARQ;
7423              cmLListAdd2Tail(&recpReqInfo->ueRecpReqLst, 
7424                    &(pucchInfo->pucchRecpInfo->lnk));
7425              pucchInfo->pucchRecpInfo->lnk.node = 
7426                 (PTR)pucchInfo->pucchRecpInfo;
7427              /* Delete the entry after addition to the list */
7428              cmHashListDelete(&cellCb->ueTfuPendLst, (PTR) pucchInfo);
7429           }
7430 #endif
7431        }
7432     }
7433
7434    *pucchInfoRef = pucchInfo;
7435    *allocRef     = alloc;
7436    return ROK;
7437 }
7438 #endif
7439
7440 #ifdef RG_ULSCHED_AT_CRC
7441 /** @brief This function does all the processing related to a single downlink
7442  * subframe.
7443  *
7444  * @details 
7445  *
7446  *     Function: rgSCHTomUtlProcDlSfAtCrc
7447  *
7448  *         Processing steps:
7449  *         - collate control data for all UEs and send to PHY 
7450  *         - collate data buffers for all UEs and send to PHY 
7451  *
7452  * @param  [in] RgSchDlSf     *ulSf
7453  * @param  [in] RgSchCellCb   *cell
7454  * @param  [in] TfuCntrlReqInfo *cntrlInfo
7455  * @param  [out] RgSchErrInfo *err
7456  * @return S16
7457  */
7458 static S16 rgSCHTomUtlProcDlSfAtCrc
7459 (
7460 RgSchDlSf            *ulSf,
7461 CmLteTimingInfo      crntUlFrm,
7462 RgSchCellCb          *cell,
7463 TfuCntrlReqInfo      *cntrlInfo,
7464 RgSchErrInfo         *err
7465 )
7466 {
7467    Inst              inst = cell->instIdx;
7468    S16               ret;
7469
7470    cntrlInfo->numDlActvUes = 0;
7471    cmLListInit(&cntrlInfo->phichLst);
7472    cmLListInit(&cntrlInfo->dlPdcchLst);
7473    cmLListInit(&cntrlInfo->ulPdcchLst);
7474 #ifdef TFU_ALLOC_EVENT_NO_INIT
7475    cntrlInfo->dlTiming.sfn = cntrlInfo->dlTiming.subframe = 0;
7476    cntrlInfo->cfi = 0;
7477 #endif
7478
7479    cntrlInfo->ulTiming = crntUlFrm;
7480    RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cntrlInfo->ulTiming, TFU_ULCNTRL_DLDELTA);
7481
7482    cntrlInfo->cellId = cell->cellId;
7483    /* Fill PHICH info */
7484    if ((ret = rgSCHTomUtlFillPhich (cell, cntrlInfo, ulSf, err)) != ROK)
7485    {
7486       DU_LOG("\nERROR  -->  SCH : Unable to send PHICH info for cell");
7487       RGSCH_FREE_MEM(cntrlInfo);
7488       return ret;
7489    }
7490
7491    /* Fill UL Pdcch */
7492    if ((ret = rgSCHTomUtlFillUlPdcch (cell, cntrlInfo, ulSf, err)) != ROK)
7493    {
7494       DU_LOG("\nERROR  -->  SCH : Unable to send PDCCH info for cell");
7495       RGSCH_FREE_MEM(cntrlInfo);
7496       return ret;
7497    }
7498    
7499 #ifdef EMTC_ENABLE
7500    if(0 == cntrlInfo->ulMpdcchLst.count)
7501    {
7502       gUlMpdcchBlank++;
7503    }
7504 #endif
7505
7506 #ifdef EMTC_ENABLE
7507    if ((cntrlInfo->ulPdcchLst.count || cntrlInfo->phichLst.count) || RG_SCH_EMTC_GET_PDCCHLST_CNT(cntrlInfo))
7508 #else
7509    if (cntrlInfo->ulPdcchLst.count || cntrlInfo->phichLst.count)
7510 #endif
7511    {
7512       //if (rgSCHUtlTfuCntrlReq(inst, cell->tfuSap->sapCfg.suId, cntrlInfo) != ROK)
7513       {
7514          DU_LOG("\nERROR  -->  SCH : Unable to send Cntrl info for cell");
7515       }
7516    }
7517    else
7518    {
7519       RGSCH_FREE_MEM(cntrlInfo);
7520    }
7521    return ROK;
7522 } /* end of */ 
7523 #endif /* #ifdef RG_ULSCHED_AT_CRC*/
7524
7525 #ifdef RGR_RRM_TICK
7526 /** @brief This function sends the SFN Tick to L3  
7527  * subframe.
7528  *
7529  * @details 
7530  *
7531  *     Function: rgSCHTomUtlSendSfnTick
7532  *
7533  * @param  [in] RgSchCellCb   *cell
7534  */
7535 static Void rgSCHTomUtlSendSfnTick
7536 (
7537 RgSchCellCb          *cell
7538 )
7539 {
7540    RgrTtiIndInfo     *rgrTtiInd;
7541    
7542    /* TTI to be sent to RRM only once per system frame */
7543    /* Added support for period = 0 to disable tick to RRM */
7544    if ((cell->rrmTtiIndPrd != 0) && 
7545          ((cell->crntTime.sfn % cell->rrmTtiIndPrd) == 0) && 
7546          (cell->crntTime.slot == 0))
7547    {
7548       /* Allocate a TTI indication structure and send to RRM over RGR interface */
7549       if (rgSCHUtlAllocSBuf (cell->instIdx,
7550                (Data**)&rgrTtiInd, sizeof(RgrTtiIndInfo)) != ROK)
7551       {
7552          DU_LOG("\nERROR  -->  SCH : Mem alloc failed for RGR TTI ind, cellId (%d))\n", 
7553                   cell->cellId);
7554          return;
7555       }
7556       rgrTtiInd->cellId = cell->cellId;
7557       //rgrTtiInd->hSfn = cell->crntTime.hSfn;
7558       rgrTtiInd->sfn    = cell->crntTime.sfn;
7559
7560       if (rgSCHUtlRgrTtiInd (cell, rgrTtiInd) != ROK)
7561       {
7562          DU_LOG("\nERROR  -->  SCH : Failed to send RGR TTI ind, cellId (%d))\n", 
7563                   cell->cellId);
7564          rgSCHUtlFreeSBuf(cell->instIdx, (Data**)&rgrTtiInd,
7565                sizeof(RgrTtiIndInfo));
7566          return;
7567       }
7568    }
7569    return;
7570 }
7571 #endif
7572
7573 #ifdef RG_5GTF
7574
7575 /* @brief Mark Dyn TDD CrntSfIdx.
7576  *
7577  * @details
7578  *
7579  *     Function: rgSCHDynTDDMrkCrntSfIdx 
7580  *     Purpose:  update the dyn tdd sunframe index
7581  *  @param[in]  Inst   schInst
7582  *  @return    None
7583  */
7584 #ifdef UNUSED_FUNC
7585 static Void rgSCHDynTDDMrkCrntSfIdx(Inst   schInst)
7586 {
7587    RgSchDynTddCb  *rgSchDynTddInfo = &(rgSchCb[schInst].rgSchDynTdd);
7588
7589
7590         RG_SCH_DYN_TDD_MARKTYPE(rgSchDynTddInfo, rgSchDynTddInfo->crntDTddSfIdx, 
7591                               RG_SCH_DYNTDD_NOTDEF);
7592         rgSchDynTddInfo->crntDTddSfIdx = (rgSchDynTddInfo->crntDTddSfIdx + 1) %
7593                                    RG_SCH_DYNTDD_MAX_SFINFO;
7594
7595    //DU_LOG("\nERROR  -->  SCH : Initializing Index %d \n", rgSchDynTddInfo->crntDTddSfIdx);
7596
7597    return;
7598 }
7599 #endif
7600 #endif
7601 /** @brief This function fills the TTI timinig info for each cell  
7602  *
7603  * @details 
7604  *
7605  *     Function: rgSchTomFillCellTtiInfo
7606  *
7607  * @param  [in]  TfuTtiIndInfo  *ttiInd
7608  * @param  [in]  Inst           schInst
7609  * @param  [out] uint8_t             *nCell
7610  * @param  [out] RgSchCellCb    *cell[]
7611  *
7612  * Returns: Void  
7613  *  
7614  */
7615 #ifdef UNUSED_FUNC
7616 static Void rgSchTomFillCellTtiInfo
7617 (
7618 TfuTtiIndInfo      *ttiInd,
7619 Inst               schInst,
7620 uint8_t            *nCell,
7621 RgSchCellCb        *cells[]
7622 )
7623 {
7624    uint8_t         i = 0;
7625    uint8_t         strtCellId;
7626    TfuTtiCellInfo  *cellInfo;
7627    RgSchCellCb     *cell; 
7628    uint32_t        Idx1;
7629  
7630    CmLteTimingInfo frm;
7631      
7632    if (CM_LTE_MAX_CELLS < ttiInd->numCells)
7633    {
7634       return;
7635    }
7636         
7637 #ifdef RG_5GTF
7638    rgSCHDynTDDMrkCrntSfIdx(schInst);
7639 #endif
7640
7641    for (i = 0; i < ttiInd->numCells; i++)
7642    {
7643       cellInfo   = &ttiInd->cells[i];
7644       strtCellId = rgSchCb[schInst].genCfg.startCellId;
7645       Idx1 = (uint8_t)((cellInfo->cellId - strtCellId)&(CM_LTE_MAX_CELLS-1));
7646       cell = rgSchCb[schInst].cells[Idx1];
7647       /* Validate the cell */
7648       if (cell == NULLP) 
7649       {
7650          /* Use SCH inst 0 print buff */
7651         DU_LOG("\nERROR  -->  SCH : RgLiTfuTtiInd()No cell exists for cellId %d\n", 
7652                   cellInfo->cellId));
7653          continue;
7654       }
7655       *nCell = *nCell + 1;
7656       cells[i] = (RgSchCellCb *)cell;
7657
7658       /* 4UE_TTI_DELTA */
7659       if(cell->schTickDelta != cellInfo->schTickDelta)
7660       {
7661          DU_LOG("\nERROR  -->  SCH : Delta changed for cellId=%d: curr delta=%d new delta=%d\n"
7662          "dlblankSf=%d ulblankSf=%d dummyTti=%d \n",
7663          cell->cellId, cell->schTickDelta, cellInfo->schTickDelta, cellInfo->dlBlankSf,cellInfo->ulBlankSf,
7664          cellInfo->isDummyTti);
7665       }
7666       RGSCH_UPDATE_DELTA(schInst, cellInfo->schTickDelta);
7667       cell->schTickDelta = cellInfo->schTickDelta;
7668       /* 4UE_TTI_DELTA */
7669
7670       cell->stopSiSch    = cellInfo->dlBlankSf;
7671       cell->stopDlSch    = cellInfo->dlBlankSf;
7672       cell->stopUlSch    = cellInfo->ulBlankSf;
7673       if (cellInfo->isDummyTti)
7674       {
7675          cell->stopDlSch = TRUE;
7676       }
7677       if((0 == (cellInfo->timingInfo.sfn % 30)) && (0 == cellInfo->timingInfo.slot))
7678       {
7679          //DU_LOG("5GTF_CHECK rgSCHTOMTtiInd (%d : %d)\n", cellInfo->timingInfo.sfn, cellInfo->timingInfo.slot);
7680       }
7681 #ifndef EMTC_ENABLE 
7682       RGSCHCPYTIMEINFO(cellInfo->timingInfo, cell->crntTime);
7683       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->hiDci0Time, 
7684                               TFU_ULCNTRL_DLDELTA);
7685       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->dlDciTime, 
7686                               TFU_DLCNTRL_DLDELTA);
7687       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->rcpReqTime, 
7688                               TFU_RECPREQ_DLDELTA);
7689       RGSCHDECRFRMCRNTTIME(cell->crntTime, cell->hqRlsTime, 
7690                               TFU_HQFBKIND_ULDELTA); 
7691       RGSCHDECRFRMCRNTTIME(cell->crntTime, cell->dlSfRlsTime, 
7692                               RGSCH_RLS_SF_IDX);
7693 #else
7694       RGSCHCPYTIMEINFO_EMTC(cellInfo->timingInfo, cell->crntTime);
7695       RG_SCH_ADD_TO_CRNT_TIME_EMTC(cell->crntTime, cell->hiDci0Time, 
7696                               TFU_ULCNTRL_DLDELTA);
7697       RG_SCH_ADD_TO_CRNT_TIME_EMTC(cell->crntTime, cell->dlDciTime, 
7698                               TFU_DLCNTRL_DLDELTA);
7699       RG_SCH_ADD_TO_CRNT_TIME_EMTC(cell->crntTime, cell->rcpReqTime, 
7700                               TFU_RECPREQ_DLDELTA);
7701       RGSCHDECRFRMCRNTTIME_EMTC(cell->crntTime, cell->hqRlsTime, 
7702                               TFU_HQFBKIND_ULDELTA); 
7703       RGSCHDECRFRMCRNTTIME_EMTC(cell->crntTime, cell->dlSfRlsTime, 
7704                               RGSCH_RLS_SF_IDX);
7705 #endif
7706       rgSCHCmnUpdVars(cell);
7707       cell->isDlDataAllwd = TRUE;
7708 /* Get DownLink SubFrame */
7709       RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
7710       frm   = cell->crntTime;
7711 #ifndef EMTC_ENABLE 
7712       RGSCH_INCR_SUB_FRAME(frm, RG_SCH_CMN_DL_DELTA);
7713 #else
7714       RGSCH_INCR_SUB_FRAME_EMTC(frm, RG_SCH_CMN_DL_DELTA);
7715 #endif
7716       cellSch->dl.time = frm; 
7717
7718 #ifdef RG_PFS_STATS
7719       cell->totalTime++;
7720 #endif
7721 #ifdef LTE_TDD
7722       uint8_t idx = (cell->crntTime.slot + RG_SCH_CMN_DL_DELTA) %
7723          RGSCH_NUM_SUB_FRAMES_5G;       
7724       
7725       cell->isDlDataAllwd = RG_SCH_CMN_CHK_DL_DATA_ALLOWED(cell, idx);
7726       
7727       /*ccpu00130639 -ADD - used in UL HARQ proc id calculation*/
7728       if((cell->crntTime.sfn == 0) && (cell->crntTime.slot == 0))
7729       {
7730          /* sfn Cycle used for Tdd UL Harq Proc Determination. 
7731             This sfn Cycle will have values from 0 to numUl Harq-1. */
7732          cell->tddHqSfnCycle = (cell->tddHqSfnCycle + 1 ) %
7733             (rgSchTddUlNumHarqProcTbl[cell->ulDlCfgIdx]);
7734       }
7735 #endif      
7736 #ifdef EMTC_ENABLE
7737       if(cell->emtcEnable)
7738       {
7739          rgSCHUtlEmtcResPrcTti(cell);
7740       }
7741 #endif
7742    } 
7743 }
7744 #endif
7745 void schFillCrntTime(
7746    SlotTimingInfo slotInd,
7747    Inst        schInst)
7748 {
7749    uint8_t cellCount = 0;
7750    for(cellCount = 0; cellCount < CM_LTE_MAX_CELLS; cellCount++)
7751    {
7752       RgSchCellCb    *cell;
7753       cell = rgSchCb[schInst].cells[cellCount];
7754
7755       RGSCHCPYTIMEINFO(slotInd, cell->crntTime);
7756
7757       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->hiDci0Time, 
7758                            TFU_ULCNTRL_DLDELTA);
7759       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->dlDciTime, 
7760                            TFU_DLCNTRL_DLDELTA);
7761       RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, cell->rcpReqTime, 
7762                            TFU_RECPREQ_DLDELTA);
7763       RGSCHDECRFRMCRNTTIME(cell->crntTime, cell->hqRlsTime, 
7764                            TFU_HQFBKIND_ULDELTA); 
7765       RGSCHDECRFRMCRNTTIME(cell->crntTime, cell->dlSfRlsTime, 
7766                            RGSCH_RLS_SF_IDX);
7767
7768       RGSCH_INCR_SUB_FRAME(cell->crntTime, RG_SCH_CMN_DL_DELTA);
7769
7770       RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
7771       cellSch->dl.time = cell->crntTime; 
7772    }
7773 }
7774
7775 /** @brief This function prepares the TTI for scheduling and 
7776  *         invokes the Common channel scheduler. Uplink scheduler
7777  *         is invoked first if UL Scheduling at CRC is not enabled   
7778  *
7779  * @details 
7780  *
7781  *     Function: rgSchTomTtiUlAndDlCmnChSch
7782  *
7783  * @param  [out] RgSchCellCb    *cell
7784  *
7785  * Returns: Void  
7786  *  
7787  */
7788 static Void rgSchTomTtiUlAndDlCmnChSch
7789 (
7790 RgSchCellCb        *cell
7791 )
7792 {
7793
7794    cell->rlsHqArr[cell->crntHqIdx].numUes = 0;
7795    cell->crntHqIdx++;
7796    cell->crntHqIdx  = cell->crntHqIdx % RGSCH_NUM_SUB_FRAMES;
7797
7798    cmPrcTmr(&cell->tqCp, cell->tq, (PFV)rgSCHTmrProcTmr);
7799    rgSCHMeasGapANRepTtiHndl (cell);
7800    /* We need to fill the PHICH for the UL Data, first we need to get the UL
7801     * SF from Scheduler, next we fill the dlSf that goes out this TTI. 
7802     * This must be performed prior to any other processing of the TTI
7803     * so that we do not wrap around and generate feedback prior to 
7804     * reception of UL data.
7805     */
7806 #ifndef RG_ULSCHED_AT_CRC
7807    {
7808       uint8_t   Mval = 1;
7809       uint8_t   idx; /* Index into Uplink Sf array */ 
7810 #ifdef LTE_TDD      
7811       Mval = rgSchTddPhichMValTbl[cell->ulDlCfgIdx]
7812                                  [cell->hiDci0Time.subframe];
7813 #endif      
7814       if(Mval)
7815       {
7816          for(idx=0; idx < Mval; idx++)
7817          {
7818             rgSCHCmnRlsUlSf(cell, idx);
7819          }
7820       }           
7821    }
7822 #endif
7823
7824    /* DTX processing for those Harq's which did not get feedback from L1 */
7825    rgSCHDhmRlsDlsfHqProc (cell, cell->hqRlsTime);
7826    /* Re-Init the Downlink subframe */
7827    rgSCHUtlDlRlsSubFrm(cell, cell->dlSfRlsTime);
7828    /* Added handling to retransmit
7829     * release PDCCH in case of DTX
7830     */
7831
7832    /*Check for DRX every TTI*/
7833    rgSCHDrxTtiInd(cell);
7834
7835    /* For TDD, UL scheduling should happen after DL scheduling */
7836 #ifndef LTE_TDD   
7837 #ifndef RG_ULSCHED_AT_CRC
7838    /* Perform UL scheduling */ 
7839    rgSCHCmnUlSch(cell);
7840 #endif
7841 #endif   
7842    /* Perform DL scheduling  for Common channels */
7843    rgSCHCmnDlCommonChSch(cell);
7844       
7845    return;
7846 }
7847
7848 /** @brief This function invokes the Non critical procedures like measurements,
7849  *         and RGR configurations.    
7850  *
7851  * @details 
7852  *
7853  *     Function: rgSchTomTtiMiscFunctions
7854  *
7855  * @param  [in] RgSchCellCb    *cell
7856  *
7857  * Returns: Void  
7858  *  
7859  */
7860 static Void rgSchTomTtiMiscFunctions
7861 (
7862 RgSchCellCb *cell
7863 )
7864 {
7865    uint8_t   suId = cell->tfuSap->sapCfg.suId;
7866     
7867    /* Invoke RAM Tti Handler  */
7868    rgSCHRamTtiHndlr(cell);
7869
7870    /* Handle RGR configurations */
7871    rgSCHGomTtiHndlr(cell, suId);
7872 #ifdef LTE_L2_MEAS
7873    if((RGM_PRB_REPORT_START == cell->prbUsage.prbRprtEnabld) 
7874       && (!(cell->prbUsage.rprtPeriod) || ((glblTtiCnt % cell->prbUsage.rprtPeriod) == 0)))
7875    {
7876       rgSCHUtlUpdAvgPrbUsage(cell);
7877    }
7878    rgSCHL2Meas(cell,FALSE);
7879 #endif 
7880    
7881    /* LTE_ADV_FLAG_REMOVED_START */
7882    /* Report ABS Load information to application periodically */
7883    if((RGR_ENABLE == cell->lteAdvCb.absCfg.status) &&
7884                     (cell->lteAdvCb.absCfg.absLoadPeriodicity))
7885    {
7886       RgrLoadInfIndInfo *rgrLoadInf;
7887       uint8_t                 idx;
7888
7889       cell->lteAdvCb.absLoadTtiCnt++;
7890       if(cell->lteAdvCb.absLoadTtiCnt >= cell->lteAdvCb.absCfg.absLoadPeriodicity)
7891       {
7892          /* ccpu00134492 */
7893          if(rgSCHUtlAllocSBuf (cell->instIdx,(Data**)&rgrLoadInf,
7894                sizeof(RgrLoadInfIndInfo)) != ROK)
7895          {
7896             DU_LOG("\nERROR  -->  SCH : Could not "\
7897                      "allocate memory for sending LoadInfo\n");
7898             return;
7899          }
7900          cell->lteAdvCb.absLoadTtiCnt = 0;
7901          rgrLoadInf->cellId = cell->cellId;
7902          rgrLoadInf->bw     = cell->bwCfg.dlTotalBw;
7903          rgrLoadInf->type   = RGR_ABS;
7904          for(idx= 0; idx<RGR_ABS_PATTERN_LEN; idx++)
7905          {
7906             rgrLoadInf->u.absLoadInfo[idx] = cell->lteAdvCb.absLoadInfo[idx];
7907             cell->lteAdvCb.absLoadInfo[idx] = 0;
7908          }
7909          rgSCHUtlRgrLoadInfInd(cell, rgrLoadInf);
7910       }
7911    }
7912
7913 #ifdef LTE_TDD   
7914    if(cell->isDlDataAllwd)
7915    {   
7916       /* Calling function to update CFI parameters*/
7917       rgSchCmnUpdCfiDb(cell, RG_SCH_CMN_DL_DELTA);   
7918    }
7919    else
7920    {
7921       /* Incrementing the ttiCnt in case of UL subframe */
7922       if(!cell->dynCfiCb.switchOvrInProgress)
7923       {   
7924          cell->dynCfiCb.ttiCnt++;
7925       }
7926    }   
7927 #else
7928    rgSchCmnUpdCfiDb(cell, RG_SCH_CMN_DL_DELTA);   
7929 #endif   
7930
7931    /* LTE_ADV_FLAG_REMOVED_END */
7932    return;
7933 }
7934
7935
7936 /** @brief This function invokes the Downlink scheduler
7937  *
7938  * @details
7939  *
7940  *     Function: rgSchTomTtiDlSch
7941  *
7942  * @param  [in] RgSchCellCb    *cell
7943  *
7944  * Returns: Void
7945  *
7946  */
7947 static Void rgSchTomTtiDlSch
7948 (
7949 RgSchCellCb *cell
7950 )
7951 {
7952
7953    if (cell->isDlDataAllwd && (cell->stopDlSch == FALSE))
7954    {
7955       rgSCHCmnDlSch(cell);
7956    }
7957
7958    return;
7959 }
7960
7961 /** @brief This function invokes Consolidates the allocations
7962  *         send the Subframe allocation info to MAC
7963  *
7964  * @details
7965  *
7966  *     Function: rgSchTomTtiCnsldtSfAlloc
7967  *
7968  * @param  [in] RgSchCellCb    *cell
7969  *
7970  * Returns: Void
7971  *
7972  */
7973 static Void rgSchTomTtiCnsldtSfAlloc
7974 (
7975 RgSchCellCb  *cell
7976 )
7977 {
7978    RgSchDlSf *dlSf;
7979    RgSchCmnCell *cellSch = RG_SCH_CMN_GET_CELL(cell);
7980    
7981    dlSf = rgSCHUtlSubFrmGet(cell, cellSch->dl.time);
7982    
7983    /* Prepare Subframe allocation info and send to MAC */
7984    rgSCHCmnCnsldtSfAlloc(cell); 
7985    
7986    /* Call ACK NACK module to add to dlsf Queue */
7987    rgSCHAckNakRepAddToQ(cell, dlSf);
7988       
7989    rgSCHTomUtlProcTA(cell);
7990   
7991    return;
7992 }
7993
7994 /** @brief This function prepares the DL and UL Config requests
7995  *         and sends to CL 
7996  *
7997  * @details
7998  *
7999  *     Function: rgSchTomTtiL1DlAndUlCfg
8000  *
8001  * @param  [in] RgSchCellCb    *cell
8002  *
8003  * Returns: Void
8004  *
8005  */
8006 static Void rgSchTomTtiL1DlAndUlCfg
8007 (
8008 RgSchCellCb        *cell,
8009 RgTfuCntrlReqInfo  *cntrlInfo
8010 )
8011 {
8012    RgSchDlSf *dlSf = rgSCHUtlSubFrmGet (cell, cell->dlDciTime);
8013    RgSchDlSf *ulSf = rgSCHUtlSubFrmGet (cell, cell->hiDci0Time);
8014    RgSchErrInfo    err;
8015
8016    rgSCHTomUtlProcDlSf (dlSf, ulSf, cell, cntrlInfo, &err);
8017    /* Mark this frame as sent */
8018    dlSf->txDone = TRUE;
8019
8020    rgBwAlloInfo[dlSf->sfNum] += dlSf->bwAssigned;
8021    rgBwAlcnt[dlSf->sfNum] ++;
8022
8023
8024 #ifdef LTE_TDD 
8025    rgSCHTomUtlProcTddUlSf(cell);
8026 #else
8027    rgSCHTomUtlProcUlSf (cell, &err);
8028 #endif   
8029    
8030    return;
8031 }
8032 #ifdef LTE_TDD
8033 /** @brief This function prepares does the Downlink subframe re-init and 
8034  *         Harq DTX processing 
8035  *
8036  * @details
8037  *
8038  *     Function: rgSchTomUtlTddRlsSfAndHarq
8039  *
8040  * @param  [in] RgSchCellCb    *cell
8041  *
8042  * Returns: Void
8043  *
8044  */
8045 static Void rgSchTomUtlTddRlsSfAndHarq
8046 (
8047 RgSchCellCb  *cell
8048 )
8049 {
8050
8051    /* ccpu00132341-MOD- rgSchTddRlsDlSubfrmTbl is dependent on DELTA(=2).
8052     * Instead rgSchTddDlAscSetIdxKTbl can be used as the K set gives proper
8053     * UL subframes*/
8054    /* ccpu00133109: Removed RGSCHSUBFRMCRNTTIME as it is not giving proper 
8055     * output if diff is more than 10. Instead using RGSCHDECRFRMCRNTTIME() 
8056     * as it is serving the purpose */
8057    if(rgSchTddDlAscSetIdxKTbl[cell->ulDlCfgIdx][cell->hqRlsTime.subframe].
8058       numFdbkSubfrms)   
8059    {
8060       /* ccpu00132341-MOD- Providing the UL SF timing for avoiding 
8061        * calculation inside the function */
8062       rgSCHDhmTddRlsSubFrm(cell, cell->hqRlsTime);
8063       rgSCHDhmRlsDlsfHqProc(cell, cell->hqRlsTime);
8064    }
8065    return;
8066 }
8067
8068 /** @brief This function processes the UL subframe and fills TFU reception
8069  *         request
8070  *
8071  * @details
8072  *
8073  *     Function: rgSCHTomUtlProcTddUlSf
8074  *
8075  * @param  [in] RgSchCellCb    *cell
8076  *
8077  * Returns: Void
8078  *
8079  */
8080 static Void rgSCHTomUtlProcTddUlSf(RgSchCellCb  *cell)
8081 {
8082    RgSchErrInfo    err;
8083    
8084    if(rgSchTddUlDlSubfrmTbl[cell->ulDlCfgIdx]
8085          [cell->rcpReqTime.subframe] == RG_SCH_TDD_UL_SUBFRAME)
8086    {
8087       if (rgSCHTomUtlProcUlSf (cell, &err) != ROK)
8088       {
8089          /* fill in err type and call sta ind */
8090          DU_LOG("\nERROR  -->  SCH : Unable to process Uplink subframe for cellId (%d))\n", cell->cellId);
8091       }
8092    }
8093    /* TDD Fix , to allow Special SF  SRS CFg  */
8094    else if(rgSchTddUlDlSubfrmTbl[cell->ulDlCfgIdx]
8095          [cell->rcpReqTime.subframe] == RG_SCH_TDD_SPL_SUBFRAME)
8096    {
8097       if (rgSCHTomUtlPrcUlTddSpclSf(cell, &err) != ROK)
8098       {
8099          /* fill in err type and call sta ind */
8100          DU_LOG("\nERROR  -->  SCH : Unable to process Sipceial subframe for cellId (%d))\n", cell->cellId);
8101       }
8102    }
8103
8104    return;
8105 }
8106 #endif
8107
8108
8109 /**********************************************************************
8110
8111      End of file
8112 **********************************************************************/