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