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