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