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