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