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