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