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