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