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