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