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