2bbecc2d1134edfbc20fab216637fd1fdc7ec62e
[o-du/l2.git] / src / 5gnrsch / rg_sch_cfg.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 functions.
26  
27      File:     rg_sch_cfg.c
28  
29 **********************************************************************/
30
31 /** @file rg_sch_cfg.c
32 @brief This module handles the configuration of SCH by RRC and RRM.
33 */
34
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=186;
37 static int RLOG_MODULE_ID=4096;
38
39 /* header include files -- defines (.h) */
40 #include "common_def.h"
41 #include "lrg.h"
42 #include "rgr.h"
43 #include "rgm.h"
44 #include "tfu.h"
45 #include "rg_env.h"
46 #include "rg_sch_inf.h"
47 #include "rg_sch.h"
48 #include "rg_sch_err.h"
49 #include "rg_sch_cmn.h"
50 #include "rl_interface.h"
51 #include "rl_common.h"
52
53 /* header/extern include files (.x) */
54 #include "tfu.x"           /* TFU types */
55 #include "lrg.x"           /* layer management typedefs for MAC */
56 #include "rgr.x"           /* layer management typedefs for MAC */
57 #include "rgm.x"           /* layer management typedefs for MAC */
58 #include "rg_sch_inf.x"            /* typedefs for MAC */
59 #include "rg_sch.x"            /* typedefs for MAC */
60 /* [ccpu00124018]-MOD- Retrieving CQI value from cell config*/
61 #include "rg_sch_cmn.x"   
62 #include "rg_sch_clist.x"
63
64
65 /* LTE-MAC Scheduler instance control block structures */
66 RgSchCb rgSchCb[RGSCH_MAX_INST];
67
68 #ifdef PHY_ERROR_LOGING
69 RgSchUlAllocCntr rgSchUlAllocCntr;
70 #endif
71
72 #ifdef EMTC_ENABLE
73 Void rgSCHEmtcPOTrigger ARGS ((
74 RgSchCellCb   *cell,
75 RgSchUeCb     *ue
76 ));
77
78 S16 rgSchEmtcUpdSiCfg ARGS ((
79 RgSchCellCb   *cell,
80 RgrCellRecfg  *cellRecfg
81 ));
82
83 S16 rgSCHEmtcCfgVldtDrxReTxCfg ARGS((
84 uint16_t       reTxTmr
85 ));
86
87 S16 rgSCHEmtcCfgVldtDrxUlReTxCfg ARGS((
88 uint16_t       reTxTmr
89 ));
90 #endif
91
92 S16 rgSCHEnbPfsDlCfg ARGS((
93          Inst                instIdx,
94          RgSchErrInfo       *err
95          ));
96 /* local defines */
97 static S16 rgSCHCfgRgrUeRecfgRntiChg ARGS (( RgSchCellCb *cell,
98       RgSchUeCb *ue, RgrUeRecfg *ueRecfg, RgSchErrInfo *errInfo));
99 static S16 rgSCHCfgVldtUePwrCfg ARGS((RgSchCellCb *cell,
100          RgrUeUlPwrCfg *pwrCfg));
101 static S16 rgSCHCfgVldtUeGrpPwrCfg ARGS((RgSchCellCb *cell,
102          RgrUeGrpPwrCfg *grpPwrCfg));
103 #ifdef LTEMAC_SPS
104 static S16 rgSCHCfgVldtUeDlSpsCfg ARGS((RgSchCellCb *cell,
105          RgrUeSpsDlCfg *dlSpsCfg));
106 static S16 rgSCHCfgVldtSpsReCfg ARGS ((RgSchCellCb *cell,
107          RgSchUeCb *ue, RgrUeRecfg *ueRecfg));
108 #endif /*LTEMAC_SPS*/
109 static S16 rgSCHCfgVldtUeCqiModeCfg ARGS((RgSchCellCb *cell,RgrUeDlCqiCfg *ueDlCqiCfg));
110 static S16 rgSCHCfgVldtUeMeasGapAckNakRepCfg ARGS ((RgSchCellCb *cell,
111          RgrUeCfg *ueCfg));
112 static S16 rgSCHCfgVldtUeMeasGapAckNakRepRecfg ARGS ((RgSchCellCb *cell,
113          RgrUeRecfg *ueRecfg));
114 static Void rgSCHCfgFreeDlDedLcCb ARGS((RgSchCellCb *cell, RgSchUeCb *ue,
115          RgSchDlLcCb *dlLc));
116 static Void rgSCHCfgFreeDlCmnLcCb ARGS((RgSchClcDlLcCb *cmnDlLc));
117 static Void rgSCHCfgFreeUeCb ARGS((RgSchCellCb *cell, RgSchUeCb *ue));
118 static Void rgSCHCfgFreeRgrCfgLst ARGS((RgSchCellCb *cell));
119 static Void rgSCHCfgFreeCmnLcLst ARGS((RgSchCellCb *cell));
120 static Void rgSCHCfgFreeUeLst ARGS((RgSchCellCb *cell));
121 #ifdef LTEMAC_SPS
122 static Void rgSCHCfgFreeSpsUeLst ARGS((RgSchCellCb *cell));
123 #endif
124 static S16 rgSCHCfgVldtRgrCmnLcCfg ARGS((Inst inst, RgrCellCfg *cellCfg,
125                          RgSchErrInfo *errInfo));
126 static S16 rgSCHCfgVldtRgrCellPwrCfg ARGS((Inst inst, RgrCellCfg *cellCfg,
127          RgSchErrInfo *errInfo));
128 static S16 rgSCHCfgVldtRgrCellSchCfg ARGS((Inst inst, RgrCellCfg *cellCfg));
129 static S16 rgSCHCfgVldtRgrSchCfg ARGS((Inst inst, RgrSchedEnbCfg *schedEnbCfg));
130 static S16 rgSCHCfgVldtRgrCellRACfg ARGS((Inst inst, RgrCellCfg *cellCfg));
131 static Void rgSCHCfgRgrUePhrMsg3 ARGS(( RgSchCellCb *cell,
132              RgSchRaCb *raCb,RgSchUeCb *ue, RgSchErrInfo *errInfo));
133 static S16 rgSCHCfgRgrCmnLcCfg ARGS((RgSchCellCb *cell, RgrCmnLchCfg *lcCfg,
134                          RgSchErrInfo *errInfo));
135 Void rgSCHSCellFreeBuf ARGS((Inst inst,RgSchUeCb *ue,RgrUeRecfg *ueRecfg,uint8_t idx));    
136 #ifdef RGR_SI_SCH
137 static S16 rgSCHCfgVldtRgrCellSiCfg ARGS(( Inst inst, RgrSiCfg  *siCfg));
138 #endif/*RGR_SI_SCH */
139
140 /* LTE_ADV_FLAG_REMOVED_START */
141 static S16 rgSCHCfgVldtRgrCellLteAdvCfg ARGS(( Inst inst, 
142                                  RgrLteAdvancedCellConfig *lteAdvCfg, uint8_t dlTotalBw));
143 /* LTE_ADV_FLAG_REMOVED_END */
144
145 static S16 rgSCHCfgVldtDrxUeCfg ARGS ((RgSchCellCb *cell,
146                                        RgrUeDrxCfg *ueDrxCfg));
147 static S16 rgSCHCfgVldtDrxOnDurCfg ARGS((uint8_t onDurTmr));
148 static S16 rgSCHCfgVldtDrxInActvCfg ARGS((uint16_t inActvTmr));
149 static S16 rgSCHCfgVldtDrxReTxCfg ARGS((uint8_t reTxTmr));
150 static S16 rgSCHCfgVldtDrxLngCycCfg ARGS((RgrDrxLongCycleOffst lngCycleOffst));
151 static S16 rgSCHCfgVldtDrxLngCyclTmrs ARGS((uint16_t val));
152 static S16 rgSCHCfgVldtDrxShrtCycCfg ARGS((RgrDrxShortDrx shrtCycCfg));
153 static S16 rgSCHCfgVldtRgrCellCsgParamCfg ARGS((Inst inst,
154                           RgrCellCsgParamCfg   *csgParam));
155 #ifdef TFU_UPGRADE
156
157 S16 rgSCHCfgACqiUeCfg ARGS(( RgSchCellCb *cellCb,RgSchUeCb *ue, RgSchUeACqiCb *aCqiCb, 
158                      RgrTxMode ueTxMode,RgrUeAprdDlCqiCfg *aCqiCfg, CmLteUeCategory ueCat ));
159
160 S16 rgSCHCfgAcqiUeReCfg ARGS(( RgSchCellCb *cellCb, RgSchUeCb *ueCb, 
161  RgrUeAprdDlCqiCfg   *acqiCfg, CmLteUeCategory  ueCat ));
162
163 S16 rgSCHUtlGetCfgPerOff ARGS(( RgSchPerTbl tbl, uint16_t  cfgIdx, 
164          uint16_t *peri, uint16_t *offset ));
165
166 S16 rgSCHCfgRiUeCfg ARGS((RgSchCellCb  *cellCb, RgSchUeCb    *ueCb, 
167                    RgrUePrdDlCqiCfg *cqiCfg, CmLteUeCategory ueCat ));
168
169 S16 rgSCHCfgPCqiUeCfg ARGS((RgSchCellCb  *cellCb, RgSchUeCb    *ueCb, 
170                      RgrUePrdDlCqiCfg *cqiCfg,CmLteUeCategory ueCat ));
171
172 S16 rgSCHCfgSrsUeCfg ARGS((RgSchCellCb   *cellCb,RgSchUeCb     *ueCb,
173                      RgrUeUlSrsCfg *srsCfg ));
174
175 S16 rgSCHCfgSrUeCfg ARGS((RgSchCellCb   *cellCb,RgSchUeCb     *ueCb,
176                      RgrUeSrCfg    *srCfg));
177
178 S16 rgSCHCfgPCqiUeReCfg ARGS((RgSchCellCb  *cellCb, RgSchUeCb *ueCb, 
179                      RgrUePrdDlCqiCfg *cqiCfg,CmLteUeCategory ueCat));
180
181 S16 rgSCHCfgSrsUeReCfg ARGS((RgSchCellCb  *cellCb, RgSchUeCb *ueCb, 
182                      RgrUeUlSrsCfg *srsCfg));
183
184 S16 rgSCHCfgSrUeReCfg ARGS((RgSchCellCb  *cellCb, RgSchUeCb *ueCb, 
185                       RgrUeSrCfg   *srCfg));
186
187 S16 rgSCHCfgVldtRgrTxmodePuschMode ARGS((RgSchCellCb  *cellCb,
188          RgrTxMode  txMde, RgrAprdCqiMode puschMode,RgSchErrInfo *errInfo));
189
190 S16 rgSCHCfgVldtRgrUeACqiCfg ARGS(( RgSchCellCb *cellCb,
191          CmLteRnti  crnti, RgrUeAprdDlCqiCfg *acqiCfg, RgrUeTxModeCfg txMode,
192          RgSchErrInfo  *errInfo ));
193
194 S16 rgSCHCfgVldtRgrTxmodePucchMode ARGS((RgSchCellCb  *cellCb,
195          RgrTxMode  txMde, RgrPrdCqiMode pucchMode,RgSchErrInfo *errInfo));
196
197 #ifdef LTEMAC_HDFDD
198 S16 rgSCHCfgVldtRgrUePCqiCfg ARGS(( RgSchCellCb *cellCb,
199          CmLteRnti  crnti, RgrUePrdDlCqiCfg *cqiCfg, Bool hdFdd,
200          RgrUeTxModeCfg txMode, RgSchErrInfo *errInfo));
201 #else
202 S16 rgSCHCfgVldtRgrUePCqiCfg ARGS(( RgSchCellCb *cellCb,
203          CmLteRnti  crnti, RgrUePrdDlCqiCfg *cqiCfg, RgrUeTxModeCfg txMode,
204          RgSchErrInfo *errInfo));         
205 #endif
206 #ifdef LTEMAC_HDFDD
207 S16 rgSCHCfgVldtRgrUeUlSrsCfg  ARGS ((RgSchCellCb *cellCb,
208              CmLteRnti crnti, RgrUeUlSrsCfg *srsCfg, Bool hdFdd, 
209              RgSchErrInfo *errInfo));
210 #else
211 S16 rgSCHCfgVldtRgrUeUlSrsCfg  ARGS ((RgSchCellCb *cellCb,
212          CmLteRnti crnti, RgrUeUlSrsCfg *srsCfg, 
213          RgSchErrInfo *errInfo));
214 #endif
215
216 #ifdef LTEMAC_HDFDD
217 S16 rgSCHCfgVldtRgrUeSrCfg  ARGS((RgSchCellCb *cellCb, CmLteRnti crnti,  
218          RgrUeSrCfg *srCfg, Bool hdFdd, RgSchErrInfo *errInfo));
219 #else
220 S16 rgSCHCfgVldtRgrUeSrCfg  ARGS((RgSchCellCb *cellCb, CmLteRnti crnti,  
221          RgrUeSrCfg *srCfg, RgSchErrInfo *errInfo));
222 #endif
223 static S16 rgSCHCfgVldtCqiSrSrsUeCfg ARGS (( RgSchCellCb       *cellCb,
224                                              RgrUeCfg          *ueCfg,  
225                                              RgSchErrInfo      *errInfo));
226
227 static S16 rgSCHCfgVldtCqiSrSrsUeReCfg ARGS (( RgSchCellCb  *cellCb,
228                                                RgSchUeCb    *ueCb,
229                                                RgrUeRecfg   *ueReCfg,  
230                                                RgSchErrInfo *errInfo ));
231
232 S16 rgSCHCfgPCqiSrsSrUeDel ARGS ((RgSchCellCb *cellCb, 
233                                          RgSchUeCb *ueCb));
234
235 static Void rgSCHCfgUtlFetchAcqiBitSz ARGS (( RgSchUeACqiCb *acqiCb,uint8_t  numTxAnt,
236                      uint8_t* cqiPmiSzR1,uint8_t* cqiPmiSzRn1 ));
237
238 /*  Added the function to be used instead of the 
239  *  MACRO RG_SCH_GET_PERIODICITY_TBL */
240 static const RgSchUePCqiSrsSrCfgIdxTbl*  rgSCHCfgUtlGetPcqiSrsSrRiTbl ARGS ((
241                                            RgSchPerTbl tblType, 
242                                            uint8_t * min, 
243                                            uint8_t * max));
244
245 #endif /* TFU_UPGRADE */ 
246 static Void rgSCHCfgUeTaRecfg ARGS (( RgSchCellCb  *cellCb,
247                                                RgSchUeCb    *ueCb,
248                                                RgrUeRecfg   *ueReCfg,  
249                                                RgSchErrInfo *errInfo ));
250 #ifdef LTE_ADV
251 S16 rgSCHSCellCfgUeCfg ARGS((
252 RgSchCellCb  *cell,
253 RgSchUeCb    *ue,
254 RgrUeRecfg   *ueRecfg,
255 RgSchErrInfo *err
256 ));
257
258 S16 rgSCHSCellCfgUePucchReCfg ARGS((
259 RgSchCellCb  *cell,
260 RgSchUeCb    *ue,
261 RgrUeRecfg   *ueRecfg,
262 RgSchErrInfo *err
263 ));
264 S16 rgSCHCfgVldtRgrUeSCellRecfg ARGS((
265 RgrUeRecfg     *ueRecfg,
266 RgSchCellCb    *cell,
267 RgSchUeCb      *ue,
268 RgSchErrInfo   *errInfo
269 ));
270 static S16 rgSCHSCellCfgUeCfgRollBack ARGS((
271 RgSchCellCb  *cell,
272 RgSchUeCb    *ue,
273 RgrUeRecfg   *ueRecfg
274 ));
275 #endif
276
277 /* ccpu00117452 - MOD - Changed macro name from
278    RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
279 #if ((defined (RGR_CQI_REPT)) && (defined (RGR_V2)))
280 static S16 rgSCHCfgUeCqiReptReCfg ARGS ((
281 RgSchCellCb    *cell,
282 RgSchUeCb      *ue,
283 RgrUeRecfg     *ueRecfg
284 ));
285
286 static S16 rgSCHCfgVldtCqiReptReCfg ARGS ((
287 RgSchCellCb       *cell,
288 RgrUeRecfg     *ueRecfg
289 ));
290 #endif
291 /*LTE_L2_MEAS_PHASE2*/
292 #ifdef LTE_L2_MEAS
293 static S16 rgSchAddToL2Meas ARGS ((RgSchCellCb *cellCb,RgSchDlLcCb *dlLc));
294 #endif
295 #ifdef EMTC_ENABLE
296 S16 rgSCHEmtcCfgVldtDrxOnDurCfg
297 (
298 uint16_t      onDurTmr 
299 );
300 Void rgSCHUtlUpdEmtcY
301 (
302 RgSchUeCb                  *ue
303 );
304 Void rgSCHEmtcHqPAlloc 
305 (
306 RgSchCellCb       *cell,
307 RgSchDlHqEnt      *hqEnt
308 );
309 #endif
310
311 /* local typedefs */
312 const RgSchSrsTxOffst rgSrsTxOffstTbl[RGSCH_MAX_SRS_SFCFG_IDX+1]=
313                                   {{1,{0,0,0,0,0,0,0,0}},
314                                    {1,{0,0,0,0,0,0,0,0}},
315                                    {1,{1,0,0,0,0,0,0,0}},
316                                    {1,{0,0,0,0,0,0,0,0}},
317                                    {1,{1,0,0,0,0,0,0,0}},
318                                    {1,{2,0,0,0,0,0,0,0}},
319                                    {1,{3,0,0,0,0,0,0,0}},
320                                    {2,{0,1,0,0,0,0,0,0}},
321                                    {2,{2,3,0,0,0,0,0,0}},
322                                    {1,{0,0,0,0,0,0,0,0}},
323                                    {1,{1,0,0,0,0,0,0,0}},
324                                    {1,{2,0,0,0,0,0,0,0}},
325                                    {1,{3,0,0,0,0,0,0,0}},
326                                    {7,{0,1,2,3,4,6,8,0}},
327                                    {8,{0,1,2,3,4,5,6,8}},
328                                    {0,{0,0,0,0,0,0,0,0}}};
329  
330 /* local externs */
331
332 #ifdef TFU_UPGRADE
333 /* SRSCfg Table: Ref 36.213, Table: 8.2.1  */
334 const RgSchUePCqiSrsSrCfgIdxTbl  
335 rgSchUeSrsCfgIdxFddTbl[RG_SCH_SRS_ISRS_INDX_MAX_FDD]=
336 {
337  { 0,1,    2,  0 },
338  { 2,6,    5,  2 },
339  { 7,16,   10, 7 },
340  { 17,36,  20, 17},
341  { 37,76,  40, 37},
342  { 77,156, 80, 77},
343  { 157,316,160,157},
344  { 317,636,320,317 }
345 };
346
347 /* Reference : 36.213 Table 8.2-2 */
348 const RgSchUePCqiSrsSrCfgIdxTbl 
349 rgSchUeSrsCfgIdxTddTbl[RG_SCH_SRS_ISRS_INDX_MAX_TDD]=
350 {
351  { 10,14,  5,  10 },
352  { 15,24,  10, 15 },
353  { 25,44,  20, 25 },
354  { 45,84,  40, 45 },
355  { 85,164, 80, 85 },
356  { 165,324,160, 165 },
357  { 325,644,320, 325 }
358  /* RESERVED: Configuration Module should not allow Res values */
359 };
360
361 /*Reference: 36.213 Table:7.2.2-1A */
362 const RgSchUePCqiSrsSrCfgIdxTbl 
363 rgSchUePCqiCfgIdxFddTbl[RG_SCH_CQIPMI_CFGIDX_MAX_FDD]=
364 {
365  { 0,1,   2, 0 },
366  { 2,6,   5, 2 },
367  { 7,16,  10,7 },
368  {17,36,  20,17},
369  {37,76,  40, 37},
370  {77,156, 80, 77},
371  {157,316,160,157},
372  {318,349,32,318}, 
373  {350,413,64, 350},
374  {414,541,128,414 }
375  /* RESERVED: Configuration should not allow Res values */
376 };
377
378 /* Reference: 36.213 Table:7.2.2-1C */
379 const RgSchUePCqiSrsSrCfgIdxTbl 
380 rgSchUeCqiPmiCfgIdxTddTbl[RG_SCH_CQIPMI_CFGIDX_MAX_TDD]=
381 {
382  { 0,0,   1, 0 },
383  { 1,5,   5, 1 },
384  { 6,15,  10,6 },
385  {16,35,  20,16},
386  {36,75,  40,36},
387  {76,155, 80,76},
388  {156,315,160,156}
389  /* RESERVED: Configuration should not allow Res values */
390 };
391
392 /* Note: RI table is same for FDD and TDD */
393 /*Reference: 36.213 Table:7.2.2-1B */
394 const RgSchUePCqiSrsSrCfgIdxTbl 
395 rgSchUeRiCfgIdxTbl[RG_SCH_RI_CFGIDX_MAX]=
396 {
397  { 0,160,    1, 0 },
398  { 161,321,  2, 161 },
399  { 322,482,  4, 322 },
400  { 483,643,  8, 483},
401  { 644,804,  16,644},
402  { 805,965,  32,805 }
403  /* RESERVED: Configuration should not allow Res values */
404 };
405
406 /*Reference: 36.213 Table:7.2.2-2 */
407 const RgSchUeBwSubSzBwParts 
408 rgSchUeBwSubSzBwPartsTbl[RG_SCH_BW_SUBSZ_BWPARTS_MAX]=
409 {
410  {6,7, 0, 0},  /*TODO: 6,7, NA, NA */
411  {8, 10, 4,1},
412  {11, 26, 4,2},
413  {27, 63, 6,3},
414  {64, 110, 8,4}
415 };
416
417
418 /* Reference : 36.213 Table 10.1-5 */
419 /* Note: SR is same table for TDD and FDD */
420 const RgSchUePCqiSrsSrCfgIdxTbl rgSchUeSrCfgIdxTbl[RG_SCH_ISR_INDX_MAX]=
421 {
422  { 0,4,   5, 0 },
423  { 5,14,   10, 5 },
424  { 15,34,  20,15 },
425  { 35,74, 40,35},
426  { 75,154, 80, 75}
427  /* RESERVED: Configuration should not allow Res values */
428 };
429
430 /*Reference:36.213: Derived from Table: 7.2.1-5 for Label L.
431  The Label L is CEIL(log2(BinCoe(N and M)))*/
432 const uint8_t RgSCHUeAcqi2022LBitWidth[6][28] ={
433 {0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5},
434 {0,0,2,3,4,4,5,5,6,6,6,7,7,7,7,7,8,8,8,8,8,8,8,9,9,9,9,9},
435 {0,0,0,2,4,5,6,6,7,7,8,8,9,9,9,10,10,10,10,11,11,11,11,11,12,12,12,12},
436 {0,0,0,0,3,4,6,7,7,8,9,9,10,10,11,11,12,12,12,13,13,13,14,14,14,14,15,15},
437 {0,0,0,0,0,3,5,6,7,8,9,10,11,11,12,13,13,14,14,14,15,15,16,16,16,17,17,17},
438 {0,0,0,0,0,0,3,5,7,8,9,10,11,12,13,13,14,15,15,16,16,17,17,18,18,18,19,19}
439 };
440
441 #endif 
442  
443 extern uint8_t rgSchCmnHarqRtt[];
444 #ifdef EMTC_ENABLE
445 S16 rgSCHEmtcCellAlloc ARGS((RgSchCellCb *cel)); 
446 Void rgSCHEmtcCellFree ARGS((RgSchCellCb *cel)); 
447 Void rgSCHEmtcUeInfoFree ARGS((RgSchCellCb *cell, RgSchUeCb *ue)); 
448 uint8_t rgSchfillPucchSrRepNumCountemtc ARGS((RgSchUeCb *ueCb)); 
449 uint8_t rgSchfillPucchCqiRepNumCountemtc ARGS((RgSchUePCqiCb *cqiCb, RgSchUeCb *ueCb)); 
450 S16 rgEmtcvalidateSiCfg ARGS((RgrSiCfgReqInfo *siCfg,RgSchCellCb  *cell));
451 #endif
452 /* forward references */
453
454
455 /**
456  * @brief Validates the SCH EndoeB configuration request from RRM to SCH.
457  *
458  * @details
459  *
460  *     Function : rgSCHCfgVldtRgrSchedEnbCfg
461  *
462  **     Processing Steps:
463  *      - Retrieve the cell control block.
464  *      - If successful,
465  *        - Validate the range of configured values recieved in
466  *          configuration request.
467  *        - If validated successfully,
468  *          - Return ROK and pointer to the cell.
469  *        - Else 
470  *          - Return RFAILED.
471  *      - Else return RFAILED.
472  *  @param[in]  Inst               inst
473  *  @param[in]  RgrSchedEnbCfg    *schedEnbCfg
474  *  @param[out] RgSchCellCb      **cell
475  *  @param[out] RgSchErrInfo      *errInfo
476  *  @return  S16
477  *      -# ROK
478  *      -# RFAILED
479  **/
480 S16 rgSCHCfgVldtRgrSchedEnbCfg
481 (
482 Inst              inst,
483 RgrSchedEnbCfg   *schedEnbCfg,
484 RgSchErrInfo     *errInfo
485 )
486 {
487    DU_LOG("\nDEBUG  -->  SCH : VALIDATE RGR SCH ENB CONFIG: \n");
488
489    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_ENB_CFG;
490
491    // TODO
492    if ((rgSCHCfgVldtRgrSchCfg(inst, schedEnbCfg)) != ROK)
493    {
494       DU_LOG("\nERROR  -->  SCH : Validation for scheduler related "
495                           "config failed\n");
496       return RFAILED;
497    }
498
499    DU_LOG("\nINFO  -->  SCH : MIMO_DBG:: SCH:: numAntPorts=%d\n",schedEnbCfg->numTxAntPorts);
500    
501    /* Validation for the ENB parameters */
502    if ((schedEnbCfg->numTxAntPorts == 0) || (schedEnbCfg->numTxAntPorts > 4))
503    {
504       DU_LOG("\nERROR  -->  SCH : Invalid number of transmit antenna" 
505             " ports %d\n", schedEnbCfg->numTxAntPorts);
506       return RFAILED;
507    }
508
509    /* Validate csg access mode */
510    if((schedEnbCfg->accsMode < RGR_CELL_ACCS_OPEN) ||
511       (schedEnbCfg->accsMode > RGR_CELL_ACCS_HYBRID))
512    {
513       DU_LOG("\nERROR  -->  SCH : Invalid CSG Access mode\n");
514       return RFAILED;
515    }
516
517    errInfo->errCause = RGSCHERR_NONE;
518    DU_LOG("\nINFO  -->  SCH : RGR SCHED ENB config validation done:");
519
520    return ROK;
521 }  /* rgSCHCfgVldtRgrSchedEnbCfg */
522
523 /**
524  * @brief Validates the cell configuration request from RRM to MAC.
525  *
526  * @details
527  *
528  *     Function : rgSCHCfgVldtRgrCellCfg
529  *
530  *     Processing Steps:
531  *      - Retrieve the cell control block.
532  *      - If successful,
533  *        - Validate the range of configured values recieved in
534  *          configuration request.
535  *        - If validated successfully,
536  *          - Return ROK and pointer to the cell.
537  *        - Else 
538  *          - Return RFAILED.
539  *      - Else return RFAILED.
540  *  @param[in]  Inst         inst
541  *  @param[in]  RgrCellCfg   *cellCfg
542  *  @param[out] RgSchCellCb  **cell
543  *  @param[out] RgSchErrInfo *errInfo
544  *  @return  S16
545  *      -# ROK
546  *      -# RFAILED
547  **/
548 S16 rgSCHCfgVldtRgrCellCfg
549 (
550 Inst         inst,
551 RgrCellCfg   *cellCfg,
552 RgSchCellCb  *cell,
553 RgSchErrInfo *errInfo
554 )
555 {
556    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_CELL_CFG;
557
558    /* check if cell exists already */
559    if ((uint8_t *)cell != NULLP)
560    {
561       DU_LOG("\nERROR  -->  SCH : Cell Id already exists");
562       return RFAILED;
563    }
564    
565    if(cellCfg->macInst >= SCH_INST_START)
566    {
567       DU_LOG("\nERROR  -->  SCH : Invalid MAC Instance %d ",
568                cellCfg->macInst);
569       return RFAILED;
570    }
571    
572    if (cellCfg->macRnti.startRnti < RGSCH_MIN_MAC_RNTI )
573    {
574       DU_LOG("\nERROR  -->  SCH : Invalid start RNTI %d for cell ",
575                cellCfg->macRnti.startRnti);
576       return RFAILED;
577    }
578
579    if ((rgSCHCfgVldtRgrCellSchCfg(inst, cellCfg)) != ROK)
580    {
581       DU_LOG("\nERROR  -->  SCH : Validation for scheduler related "
582                           "config failed");
583       return RFAILED;
584    }
585
586    if ((cellCfg->dlHqCfg.maxDlHqTx < RGSCH_MIN_HQ_TX) ||
587          (cellCfg->dlHqCfg.maxMsg4HqTx < RGSCH_MIN_HQ_TX))
588    {
589       DU_LOG("\nERROR  -->  SCH : Invalid Downlink HARQ configuration:"
590                " maxDlHqTx %d maxMsg4HqTx %d", cellCfg->dlHqCfg.maxDlHqTx,
591                cellCfg->dlHqCfg.maxMsg4HqTx);
592       return RFAILED;
593    }
594    if ((cellCfg->cfiCfg.cfi < RGSCH_MIN_CFI_VAL) ||
595          (cellCfg->cfiCfg.cfi > RGSCH_MAX_CFI_VAL))
596    {
597       DU_LOG("\nERROR  -->  SCH : Invalid CFI configuration %d",
598            cellCfg->cfiCfg.cfi);
599       return RFAILED;
600    }
601    if (((cellCfg->puschSubBand.subbandStart) + 
602         ((cellCfg->puschSubBand.numSubbands -1) * cellCfg->puschSubBand.size))
603          > (cellCfg->bwCfg.ulTotalBw - 1))
604    {
605       DU_LOG("\nERROR  -->  SCH : Invalid PUSCH subband configuration:"
606                " subBandStart %d numSubBands %d subBandSize %d ulTotBw %d",
607                cellCfg->puschSubBand.subbandStart, 
608                cellCfg->puschSubBand.numSubbands, cellCfg->puschSubBand.size,
609                cellCfg->bwCfg.ulTotalBw);
610       return RFAILED;
611    }
612
613    if (((cellCfg->bwCfg.dlTotalBw < RGSCH_MIN_DL_BW) ||
614             (cellCfg->bwCfg.dlTotalBw > RGSCH_MAX_DL_BW)) ||
615          ((cellCfg->bwCfg.ulTotalBw < RGSCH_MIN_UL_BW) || 
616           (cellCfg->bwCfg.ulTotalBw > RGSCH_MAX_UL_BW)))
617    {
618       DU_LOG("\nERROR  -->  SCH : Invalid Bandwidth configuration:"
619             " ul %d dl %d",cellCfg->bwCfg.ulTotalBw,
620             cellCfg->bwCfg.dlTotalBw);
621       return RFAILED;
622    }
623    if (cellCfg->phichCfg.ngEnum > RGR_NG_TWO)
624    {
625       DU_LOG("\nERROR  -->  SCH : Invalid PHICH Ng configuration %d",
626                (uint8_t)cellCfg->phichCfg.ngEnum);
627       return RFAILED;
628    }
629    /* Validation for extended PHICH Duration */
630    if ((cellCfg->phichCfg.isDurExtend == TRUE) && 
631          (cellCfg->bwCfg.dlTotalBw <= 10) && (cellCfg->cfiCfg.cfi < 2))
632    {
633       DU_LOG("\nERROR  -->  SCH : Invalid cfi value for"
634                "Extended PHICH duration cfi:%d dlBw:%d",
635                (uint8_t)cellCfg->cfiCfg.cfi, cellCfg->bwCfg.dlTotalBw);
636       return RFAILED;
637    }
638    if ((cellCfg->phichCfg.isDurExtend == TRUE) &&
639          (cellCfg->bwCfg.dlTotalBw > 10) && (cellCfg->cfiCfg.cfi < 3))
640    {
641       DU_LOG("\nERROR  -->  SCH : Invalid cfi value for"
642                "Extended PHICH duration cfi:%d dlBw:%d",
643                (uint8_t)cellCfg->cfiCfg.cfi, cellCfg->bwCfg.dlTotalBw);
644       return RFAILED;
645    }
646    DU_LOG("\nINFO  -->  SCH : CA_DBG:: PUCCH configuration:"
647          " N2_RB %d N1_PUCCH %d deltaShift %d cyclicShift %d",
648          cellCfg->pucchCfg.resourceSize,
649          cellCfg->pucchCfg.n1PucchAn,
650          cellCfg->pucchCfg.deltaShift,
651          cellCfg->pucchCfg.cyclicShift);
652
653    /* ccpu00138567- Removing validation check for resourceSize as 0.
654     * From the spec, n2RB value 0 is a valid config. */
655    if ((cellCfg->pucchCfg.resourceSize >= cellCfg->bwCfg.ulTotalBw/2) ||
656          (cellCfg->pucchCfg.n1PucchAn == 0) ||
657          (cellCfg->pucchCfg.deltaShift < RGSCH_PUCCH_MINVAL_DS) ||
658          (cellCfg->pucchCfg.deltaShift > RGSCH_PUCCH_MAXVAL_DS) ||
659          (cellCfg->pucchCfg.cyclicShift > RGSCH_PUCCH_MAXVAL_CS))
660    {
661       DU_LOG("\nERROR  -->  SCH : Invalid PUCCH configuration:"
662               " N2_RB %d N1_PUCCH %d deltaShift %d cyclicShift %d",
663                cellCfg->pucchCfg.resourceSize,
664                cellCfg->pucchCfg.n1PucchAn,
665                cellCfg->pucchCfg.deltaShift,
666                cellCfg->pucchCfg.cyclicShift);
667       return RFAILED;
668    }
669    if (cellCfg->srsCfg.isSrsCfgSetup && cellCfg->srsCfg.srsBwEnum > RGR_SRS_BWCFG_7)
670    {
671       DU_LOG("\nERROR  -->  SCH : Invalid SRS configuration: "
672                " srsBw %d", (uint8_t)cellCfg->srsCfg.srsBwEnum);
673       return RFAILED;
674    }
675
676    if ((rgSCHCfgVldtRgrCellRACfg(inst, cellCfg)) != ROK)
677    {
678       DU_LOG("\nERROR  -->  SCH : Validation for Random access related"
679                           "config failed");
680       return RFAILED;
681    }
682
683    if ((rgSCHCfgVldtRgrCellPwrCfg(inst, cellCfg, errInfo)) != ROK)
684    {
685       DU_LOG("\nERROR  -->  SCH : Validation for cell power "
686                           "config failed");
687       return RFAILED;
688    }
689
690    /* Validate the common logical channel configuration */
691    if( (cellCfg->numCmnLcs < RGR_MIN_CMN_LC_PER_CELL)||
692        (cellCfg->numCmnLcs > RGR_MAX_CMN_LC_PER_CELL))
693    {
694       DU_LOG("\nERROR  -->  SCH : Invalid number(%d) of common logical"
695               "channels in cell config", cellCfg->numCmnLcs);
696       return RFAILED;
697    }
698    if ((rgSCHCfgVldtRgrCmnLcCfg(inst, cellCfg, errInfo)) != ROK)
699    {
700       DU_LOG("\nERROR  -->  SCH : Validation for common logical"
701                           "channels failed");
702       return RFAILED;
703    }
704
705    /* Added 0 as a valid value for number of TICKs RRM
706     * 0 implies no ticks i.e. shutting off the feature.*/
707
708 #ifdef RGR_SI_SCH
709    if ((rgSCHCfgVldtRgrCellSiCfg(inst, &(cellCfg->siCfg))) != ROK)
710    {
711       DU_LOG("\nERROR  -->  SCH : Validation for SI"
712                           "configuration failed");
713       return RFAILED;
714    }
715 #endif /*RGR_SI_SCH */
716
717    /*ccpu00116923 - ADD - Srs Present support - Start*/
718 #ifdef TFU_UPGRADE
719 #ifdef LTE_TDD
720    if(cellCfg->srsCfg.isSrsCfgSetup && cellCfg->srsCfg.srsSubFrameCfg > 13)
721 #else
722       if(cellCfg->srsCfg.isSrsCfgSetup && cellCfg->srsCfg.srsSubFrameCfg > 14)
723 #endif
724       {
725          DU_LOG("\nERROR  -->  SCH : Invalid"
726                   "Subframe configuration");
727          return RFAILED;
728       }
729 #endif
730    /*ccpu00116923 - ADD - Srs Present support - End*/
731   
732   if ((cellCfg->bcchTxPwrOffset > 10000) ||
733        (cellCfg->pcchTxPwrOffset > 10000) ||
734        (cellCfg->rarTxPwrOffset > 10000) ||
735        (cellCfg->phichTxPwrOffset > 10000) 
736       )
737    {
738       DU_LOG("\nERROR  -->  SCH : Invalid txPower offset ");
739
740       return RFAILED;
741    }
742
743 /* LTE_ADV_FLAG_REMOVED_START */
744    /* Checking Whether DSFR is enabled without enabling SFR */
745    if(((cellCfg->rgrLteAdvCfg.pres & RGR_DSFR) && 
746        (RGR_ENABLE == cellCfg->rgrLteAdvCfg.dsfrCfg.status)) &&
747       (!((cellCfg->rgrLteAdvCfg.pres & RGR_SFR) &&
748          (RGR_ENABLE == cellCfg->rgrLteAdvCfg.sfrCfg.status))))
749    {
750       DU_LOG("\nERROR  -->  SCH : DSFR is enbaled"
751                "Without enabling SFR");
752       return RFAILED;
753    }
754
755    if ((rgSCHCfgVldtRgrCellLteAdvCfg(inst, &(cellCfg->rgrLteAdvCfg), 
756                                       cellCfg->bwCfg.dlTotalBw)) != ROK)
757    {
758       DU_LOG("\nERROR  -->  SCH : Validation for LTE Adv"
759                "configuration failed");
760       return RFAILED;
761    }
762 #ifdef LTE_ADV
763    if ((rgSCHCfgVldtRgrCellLteLAACfg(inst, cellCfg)) != ROK)
764    {
765       DU_LOG("\nERROR  -->  SCH : Validation for LTE LAA"
766                "configuration failed");
767       return RFAILED;
768    }
769 #endif
770 /* LTE_ADV_FLAG_REMOVED_END */
771    if (cellCfg->msg4pAVal > RGRUE_DLPWRCNTRL_PA_DB3)
772    {
773       DU_LOG("\nERROR  -->  SCH : Invalid"
774                "msg4pAVal %u", cellCfg->msg4pAVal);
775       return RFAILED;
776    }
777   
778    /* Validate RgrCellCsgParamCfg */
779    if(rgSchCb[inst].rgrSchedEnbCfg.accsMode == RGR_CELL_ACCS_HYBRID) 
780    {
781       if((rgSCHCfgVldtRgrCellCsgParamCfg(inst, 
782                   &(cellCfg->csgParamCfg)) != ROK))
783       {
784          DU_LOG("\nERROR  -->  SCH : Validation failed for \n"
785                   "Access CSG parameter failed\n");
786          return RFAILED;
787       }
788    }
789 #ifdef EMTC_ENABLE
790           if (cellCfg->emtcEnable)
791           {
792              if(ROK != rgSCHCfgVldtRgrEmtcCellCfg(cellCfg))
793              {
794                 DU_LOG("\nERROR  -->  SCH : Invalid EMTC cell Configuration %d for cell" ,cellCfg->cellId);
795                          return RFAILED;
796              }
797           }
798 #endif
799    errInfo->errCause = RGSCHERR_NONE;
800    return ROK;
801 }  /* rgSCHCfgVldtRgrCellCfg */
802
803 /**
804  * @brief Validates the scheduler related configuration request from RRM to MAC.
805  *
806  * @details
807  *
808  *     Function : rgSCHCfgVldtRgrSchCfg
809  *
810  *     Processing Steps:
811  *      - Validate the scheduler related configuration request from RRC to MAC at CFG:
812  *        validate the value range for the configured values.
813  *      - If validated successfully,
814  *        - Return ROK .
815  *      - Else 
816  *        - Return RFAILED.
817  *
818  *  @param[in]  Inst         inst
819  *  @param[out] RgSchedCfg  *rgSchedCfg
820  *  @return  S16
821  *      -# ROK
822  *      -# RFAILED
823  **/
824 S16 rgSCHCfgVldtRgrSchCfg
825 (
826 Inst         inst,
827 RgrSchedEnbCfg   *rgSchedCfg
828 )
829 {
830    DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgVldtRgrSchCfg:Validating \
831                scheduler related Configuration");
832    if (rgSchedCfg->ulSchdType > (RGSCH_NUM_SCHEDULERS - 1))
833    {
834       DU_LOG("\nERROR  -->  SCH : rgSCHCfgVldtRgrSchCfg:Invalid \
835                   UL scheduler type %d \n", rgSchedCfg->ulSchdType);
836       return RFAILED;
837    }
838    if (rgSchedCfg->dlSchdType > (RGSCH_NUM_SCHEDULERS - 1))
839    {
840       DU_LOG("\nERROR  -->  SCH : rgSCHCfgVldtRgrSchCfg:Invalid \
841                   DL scheduler type %d \n", rgSchedCfg->dlSchdType);
842       return RFAILED;
843    }
844    return ROK;
845 }
846 /**
847  * @brief Validates the scheduler related configuration request from RRM to MAC.
848  *
849  * @details
850  *
851  *     Function : rgSCHCfgVldtRgrCellSchCfg
852  *
853  *     Processing Steps:
854  *      - Validate the scheduler related configuration request from RRC to MAC at CFG:
855  *        validate the value range for the configured values.
856  *      - If validated successfully,
857  *        - Return ROK and pointer to the cell of UE.
858  *      - Else 
859  *        - Return RFAILED.
860  *
861  *  @param[in]  Inst         inst
862  *  @param[out] RgSchCellCfg  *cellCfg
863  *  @return  S16
864  *      -# ROK
865  *      -# RFAILED
866  **/
867 S16 rgSCHCfgVldtRgrCellSchCfg
868 (
869 Inst         inst,
870 RgrCellCfg   *cellCfg
871 )
872 {
873
874 #if RGSCH_NUM_DLFS_SCHEDULERS
875    if (cellCfg->dlfsSchdType > RGSCH_NUM_DLFS_SCHEDULERS - 1)
876    {
877       DU_LOG("\nERROR  -->  SCH : Invalid dlfs scheduler type %d for cell",
878                 cellCfg->dlfsSchdType);
879       return RFAILED;
880    }
881 #endif
882    return ROK;
883 }
884 /**
885  * @brief Validates the RACH related configuration request from RRM to MAC.
886  *
887  * @details
888  *
889  *     Function : rgSCHCfgVldtRgrCellRACfg
890  *
891  *     Processing Steps:
892  *      - Validate the RA configuration request from RRC to MAC at CFG:
893  *        validate the value range for the configured values.
894  *      - If validated successfully,
895  *        - Return ROK and pointer to the cell of UE.
896  *      - Else 
897  *        - Return RFAILED.
898  *
899  *  @param[in]  Inst         inst
900  *  @param[out] RgSchCellCfg  *cellCfg
901  *  @return  S16
902  *      -# ROK
903  *      -# RFAILED
904  **/
905 S16 rgSCHCfgVldtRgrCellRACfg
906 (
907 Inst         inst,
908 RgrCellCfg   *cellCfg
909 )
910 {
911
912 #ifdef LTE_TDD
913    if ((cellCfg->rachCfg.preambleFormat > RGSCH_MAX_TDD_RA_PREAMBLE_FMT) ||
914 #else
915    if ((cellCfg->rachCfg.preambleFormat > RGSCH_MAX_RA_PREAMBLE_FMT) ||
916 #endif
917          (cellCfg->rachCfg.raWinSize < RGSCH_MIN_RA_WINSIZE)  ||
918          (cellCfg->rachCfg.raWinSize > RGSCH_MAX_RA_WINSIZE) ||
919          (cellCfg->rachCfg.maxMsg3Tx < RGSCH_MIN_HQ_TX) ||
920          (cellCfg->rachCfg.numRaPreamble < RGSCH_MIN_NUM_RA_PREAMBLE) ||
921          (cellCfg->rachCfg.numRaPreamble > RGSCH_MAX_NUM_RA_PREAMBLE) ||
922          (cellCfg->rachCfg.sizeRaPreambleGrpA >
923           cellCfg->rachCfg.numRaPreamble) || 
924          (cellCfg->rachCfg.prachResource > 
925           (cellCfg->bwCfg.ulTotalBw - RGSCH_NUM_RA_RB)))
926    {
927       DU_LOG("\nERROR  -->  SCH : Invalid RACH configuration:"
928                 "preamble Fmt %d raWinSize %d maxMsg3Tx %d",
929                 cellCfg->rachCfg.preambleFormat, cellCfg->rachCfg.raWinSize,
930                 cellCfg->rachCfg.maxMsg3Tx);
931       DU_LOG("\nERROR  -->  SCH : Invalid numRaPreamble %d sizeRaPreambleGrpA %d",
932                 cellCfg->rachCfg.numRaPreamble,
933                 cellCfg->rachCfg.sizeRaPreambleGrpA);
934       return RFAILED;
935    }
936    /* RACHO */
937    /* verify that the ded Preambles cfgd for Pdcch Order
938     * do not collide with that of non-dedicated  and validates against
939     * the configuration index and number of RACH
940     * ded-preambles. For non-zero ded preamble cfg, 
941     * the config index is expected to be != NA.*/
942    if ((cellCfg->macPreambleSet.pres) && 
943        ((cellCfg->macPreambleSet.start < cellCfg->rachCfg.numRaPreamble) ||
944        (cellCfg->macPreambleSet.start >= RGSCH_MAX_NUM_RA_PREAMBLE) ||
945        (cellCfg->macPreambleSet.size < 1) ||
946        (cellCfg->macPreambleSet.size > RGSCH_MAX_NUM_RA_PREAMBLE-
947                                        cellCfg->rachCfg.numRaPreamble) ||
948        (cellCfg->rachCfg.raOccasion.sfnEnum == RGR_SFN_NA)))
949    {
950        DU_LOG("\nERROR  -->  SCH : Invalid RACH Preambleset conf:"
951                 "preambleSet Start %d preambleSet Size %d",
952                 cellCfg->macPreambleSet.start, cellCfg->macPreambleSet.size);
953       return RFAILED;
954    }
955 #ifdef RGR_V1
956    if(cellCfg->rachCfg.contResTmr)
957    {
958       uint8_t idx;
959 #ifdef LTE_TDD
960       idx = cellCfg->ulDlCfgIdx;
961 #else
962       idx = 7; /* FDD */
963 #endif
964       /* maxMsg4TxDelay = (HARQ_RTT * MAX_MSG4_HARQ_RETX)  + 
965          3 TTI (MAX L1+L2 processing delay at the UE) */
966       uint8_t maxMsg4TxDelay = (cellCfg->dlHqCfg.maxMsg4HqTx-1) * 
967          rgSchCmnHarqRtt[idx] + 3; 
968
969
970       if(maxMsg4TxDelay >= cellCfg->rachCfg.contResTmr)
971       {
972          DU_LOG("\nERROR  -->  SCH : Warining !: Contention Resolution timer not greater than the "
973                "guard timer. Conte Res timer %d Guard timer %d",
974                cellCfg->rachCfg.contResTmr, 
975                maxMsg4TxDelay );
976          /* [ccpu00138532]-DEL- removed return fail here as it is ok if the 
977             max Msg4 Tx delay is more than the contension Resolution timer. 
978             In such case, the CRI CE will be scheduled immediately once 
979             msg3 is received */ 
980       }
981    }
982    else
983    {
984       /* ccpu00128575 ADD - If contention resolution timer is configured as 0,
985          Then return fail*/
986       DU_LOG("\nERROR  -->  SCH : Contention Resolution timer is configured as '0'");
987       return RFAILED;
988    }
989 #endif
990
991    return ROK;
992 }
993
994 /**
995  * @brief Validates the UE configuration request from RRM to MAC.
996  *
997  * @details
998  *
999  *     Function : rgSCHCfgVldtRgrUeCfg
1000  *
1001  *     Processing Steps:
1002  *      - Validate the UE configuration request from RRC to MAC at CFG:
1003  *        validate the value range for the configured values.
1004  *      - If validated successfully,
1005  *        - Return ROK and pointer to the cell of UE.
1006  *      - Else 
1007  *        - Return RFAILED.
1008  *
1009  *  @param[in]  Inst         inst
1010  *  @param[in]  RgrUeCfg     *ueCfg
1011  *  @param[out] RgSchCellCb  **cell
1012  *  @param[out] RgSchErrInfo *errInfo
1013  *  @return  S16
1014  *      -# ROK
1015  *      -# RFAILED
1016  **/
1017 S16 rgSCHCfgVldtRgrUeCfg
1018 (
1019 Inst         inst,
1020 RgrUeCfg     *ueCfg,
1021 RgSchCellCb  **cell,
1022 RgSchErrInfo *errInfo
1023 )
1024 {
1025    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_CFG;
1026
1027    if (((*cell) == NULLP) || 
1028        ((*cell)->cellId != ueCfg->cellId))
1029    {
1030       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"Cell does not exist %d", 
1031            ueCfg->cellId);
1032       return RFAILED;
1033    }
1034    /* RACHO: 
1035     * Check configured preamble id not colliding with non dedicated or PDCCH
1036     * order preamble sets. When valid preamble id given check that C-RNTI given
1037     * in configuration is not amongst the C-RNTI'smanaged by scheduler */
1038    if ((rgSCHRamVldtUeCfg(*cell, ueCfg)) != ROK)
1039    {
1040       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Preamble Id configuration"
1041                "failed ",ueCfg->cellId);
1042       return RFAILED;
1043    }
1044    /* Check if Ue already configured */
1045    if (rgSCHDbmGetUeCb(*cell, ueCfg->crnti) != NULLP)
1046    {
1047       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d UEID already exists",
1048              ueCfg->cellId);
1049       return RFAILED;
1050    }
1051    /* Validate Transmission UE modes  */
1052    if ((ueCfg->txMode.pres == TRUE) && ((ueCfg->txMode.txModeEnum < RGR_UE_TM_1)
1053             || (ueCfg->txMode.txModeEnum > RGR_UE_TM_7)))
1054    {
1055       RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid transmission mode for"
1056                " UE is %d", ueCfg->cellId,(uint8_t)ueCfg->txMode.txModeEnum);
1057       return RFAILED;
1058    }
1059   
1060    /* Validate UE Category */
1061    if (ueCfg->ueCatEnum > CM_LTE_UE_CAT_8)
1062    {
1063       RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid category for UE %d",
1064                ueCfg->cellId,(uint8_t)ueCfg->ueCatEnum);
1065       return RFAILED;
1066    }
1067   
1068    /* Validate UE Access Stratum Release */
1069    if (ueCfg->accessStratumRls > RGR_REL_10)
1070    {
1071       RGSCHDBGERRNEW(inst, (rgSchPBuf(inst), "Invalid Access Stratum Release %u for UE\n",
1072                ueCfg->accessStratumRls));
1073       return RFAILED;
1074    }
1075    RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), "Configured Access Stratum Release %u\n", \
1076             ueCfg->accessStratumRls));
1077   
1078    if ((*cell)->numTxAntPorts == 1)
1079    {
1080       if ((ueCfg->txMode.pres == TRUE) && 
1081             (ueCfg->txMode.txModeEnum > RGR_UE_TM_1))
1082       {
1083          RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid transmission mode for"
1084                   " UE (%d) for the configured Cell Antenna Ports",ueCfg->cellId,
1085                   (uint8_t)ueCfg->txMode.txModeEnum);
1086          return RFAILED;
1087       }
1088    }
1089    
1090    if ((rgSCHCfgVldtUeCqiModeCfg(*cell, &ueCfg->ueDlCqiCfg)) != ROK)
1091    {
1092       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti, "CELLID:%d Invalid CQI Mode configuration",
1093                 ueCfg->cellId);
1094       return RFAILED;
1095    }
1096
1097    /* Validate Max Uplink HARQ transmission value */
1098    if (ueCfg->ueUlHqCfg.maxUlHqTx < RGSCH_MIN_HQ_TX)
1099    {
1100       RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid Uplink HARQ config for "
1101             "UE %d",ueCfg->cellId,ueCfg->ueUlHqCfg.maxUlHqTx);
1102       return RFAILED;
1103    }
1104
1105    if (rgSCHCfgVldtUePwrCfg(*cell, &ueCfg->ueUlPwrCfg) != ROK)
1106    {
1107       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid PUSCH Group power"
1108            " configuration",ueCfg->cellId);
1109       return RFAILED;
1110    }
1111  
1112    if (rgSCHCfgVldtUeMeasGapAckNakRepCfg(*cell, ueCfg) != ROK)
1113    {
1114       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid MeasGap/AckNackRep"
1115             " configuration",ueCfg->cellId);
1116       return RFAILED;
1117    }
1118   
1119 #ifdef LTEMAC_SPS
1120    /* Validating SPS RNTI */
1121    if (((ueCfg->ueSpsCfg.spsRnti >=  (*cell)->rntiDb.rntiStart) && 
1122        (ueCfg->ueSpsCfg.spsRnti<=((*cell)->rntiDb.rntiStart+(*cell)->rntiDb.maxRntis)))
1123        ||(ueCfg->ueSpsCfg.spsRnti == RGSCH_SI_RNTI) 
1124        ||(ueCfg->ueSpsCfg.spsRnti == RGSCH_P_RNTI))
1125    {
1126       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid SPS RNTI "
1127                " in DL SPS Config",ueCfg->cellId);
1128       return RFAILED;
1129    }
1130
1131    if (ueCfg->ueSpsCfg.dlSpsCfg.isDlSpsEnabled) 
1132    {
1133       if (rgSCHCfgVldtUeDlSpsCfg(*cell, &ueCfg->ueSpsCfg.dlSpsCfg) != ROK)
1134       {
1135          RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid DL SPS configuration"
1136                   " for the UE",ueCfg->cellId);
1137          return RFAILED;
1138       }
1139    }
1140 #endif 
1141 #ifdef TFU_UPGRADE
1142    /* Validated Periodic CQI/PMI, RI , SRS and SR related UeCfg */
1143    if ( ROK != rgSCHCfgVldtCqiSrSrsUeCfg(*cell, ueCfg, errInfo))
1144    {
1145       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid Periodic CQI/SR/SRS"
1146                "configuration",ueCfg->cellId);
1147       return RFAILED;
1148    }
1149 #endif
1150
1151    /* Validate DRX specific parameters */
1152    if ( ROK != rgSCHCfgVldtDrxUeCfg(*cell, &(ueCfg->ueDrxCfg)))
1153    {
1154       RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid DRX configuration",
1155                 ueCfg->cellId);
1156       return RFAILED;
1157    }
1158
1159 /* ccpu00117452 - MOD - Changed macro name from
1160    RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
1161 #ifdef RGR_CQI_REPT
1162    if (ueCfg->ueCqiReptCfg.numColltdCqiRept > RGR_CQIRPTS_MAXN)
1163    {
1164       RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid numColltdCqiRept,"
1165                "MAX supported %d",RGR_CQIRPTS_MAXN,ueCfg->cellId);
1166       return RFAILED;
1167    }
1168 #endif /* End of RGR_CQI_REPT */
1169
1170 #ifdef EMTC_ENABLE
1171 /*This is to validate the EMTC related configuration if a UE is an EMTC UE*/
1172           if(TRUE == ueCfg->emtcUeCfg.pres)
1173           {
1174              if ( ROK != rgSCHCfgVldtEmtcUeCfg(*cell, &(ueCfg->emtcUeCfg)))
1175              {
1176                          RLOG_ARG2(L_ERROR,DBG_CRNTI,ueCfg->crnti,"CELLID:%d Invalid EMTC UE configurationfor crnti:%d",
1177                                   ueCfg->cellId, ueCfg->crnti);
1178                          return RFAILED;
1179              }
1180           }
1181 #endif
1182    errInfo->errCause = RGSCHERR_NONE;
1183    return ROK;
1184 }  /* rgSCHCfgVldtRgrUeCfg */
1185
1186
1187 /**
1188  * @brief Validates the cell reconfiguration request from RRM to MAC.
1189  *
1190  * @details
1191  *
1192  *     Function : rgSCHCfgVldtRgrCellRecfg
1193  *
1194  *     Processing Steps:
1195  *      - Retrieve the cell control block.
1196  *      - If successful,
1197  *        - Validate the range of reconfigured values recieved in
1198  *          re-configuration request.
1199  *        - If validated successfully,
1200  *          - Return ROK and pointer to the cell.
1201  *        - Else 
1202  *          - Return RFAILED.
1203  *      - Else return RFAILED.
1204  *
1205  *  @param[in]  Inst          inst
1206  *  @param[in]  RgrCellRecfg  *cellRecfg
1207  *  @param[out] RgSchCellCb   **cell
1208  *  @param[out] RgSchErrInfo  *errInfo
1209  *  @return  S16
1210  *      -# ROK
1211  *      -# RFAILED
1212  **/
1213 S16 rgSCHCfgVldtRgrCellRecfg
1214 (
1215 Inst          inst,
1216 RgrCellRecfg  *cellRecfg,
1217 RgSchCellCb   **cell,
1218 RgSchErrInfo  *errInfo
1219 )
1220 {
1221
1222    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_CELL_RECFG;
1223    
1224    /* Fetch cell and validate cell Id with the cell control block*/
1225    if (((*cell) == NULLP) ||
1226        ((*cell)->cellId != cellRecfg->cellId)) 
1227    {
1228       RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Cell control block does not exist");
1229       return RFAILED;
1230    }
1231
1232    /* Validate recieved values */
1233    if ((cellRecfg->recfgTypes & RGR_CELL_DL_HARQ_RECFG) &&
1234          ((cellRecfg->dlHqRecfg.maxDlHqTx < RGSCH_MIN_HQ_TX) ||
1235           (cellRecfg->dlHqRecfg.maxMsg4HqTx < RGSCH_MIN_HQ_TX)))
1236    {
1237       RLOG_ARG2(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid Downlink HARQ configuration:"
1238            " maxDlHqTx %d maxMsg4HqTx %d", cellRecfg->dlHqRecfg.maxDlHqTx,
1239             cellRecfg->dlHqRecfg.maxMsg4HqTx);
1240       return RFAILED;
1241    }
1242    if ((cellRecfg->recfgTypes & RGR_CELL_CFI_RECFG) && 
1243          ((cellRecfg->cfiRecfg.cfi < RGSCH_MIN_CFI_VAL) ||
1244           (cellRecfg->cfiRecfg.cfi > RGSCH_MAX_CFI_VAL)))
1245    {
1246       RLOG_ARG1(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid CFI configuration %d",
1247                cellRecfg->cfiRecfg.cfi);
1248       return RFAILED;
1249    }
1250    if (cellRecfg->recfgTypes & RGR_CELL_PUCCH_RECFG)
1251    {
1252       /* ccpu00138567- Removing validation check for resourceSize as 0.
1253        * From the spec, n2RB value 0 is a valid config. */
1254       if ((cellRecfg->pucchRecfg.n1PucchAn == 0) ||
1255           (cellRecfg->pucchRecfg.resourceSize >= (*cell)->bwCfg.ulTotalBw/2)||
1256           ((cellRecfg->pucchRecfg.deltaShift < RGSCH_PUCCH_MINVAL_DS) || 
1257            (cellRecfg->pucchRecfg.deltaShift > RGSCH_PUCCH_MAXVAL_DS)) ||
1258           (cellRecfg->pucchRecfg.cyclicShift > RGSCH_PUCCH_MAXVAL_CS))
1259       {
1260          RLOG_ARG4(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid PUCCH configuration: "
1261                "N2_RB %d N1_PUCCH %d deltaShift %d cyclicShift %d",
1262                cellRecfg->pucchRecfg.resourceSize,
1263                cellRecfg->pucchRecfg.n1PucchAn,
1264                cellRecfg->pucchRecfg.deltaShift,
1265                cellRecfg->pucchRecfg.cyclicShift);
1266          return RFAILED;
1267       }
1268    }
1269    if (cellRecfg->recfgTypes & RGR_CELL_SRS_RECFG)
1270    {
1271       if (cellRecfg->srsRecfg.isSrsCfgSetup && cellRecfg->srsRecfg.srsBwEnum > RGR_SRS_BWCFG_7)
1272       {
1273          RLOG_ARG1(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid SRS configuration: "
1274                "srsBw %d", (uint8_t)cellRecfg->srsRecfg.srsBwEnum);
1275          return RFAILED;
1276       }
1277
1278       /*ccpu00116923 - ADD - Srs Present support - Start*/
1279 #ifdef TFU_UPGRADE
1280 #ifdef LTE_TDD
1281       if(cellRecfg->srsRecfg.isSrsCfgSetup && cellRecfg->srsRecfg.srsSubFrameCfg > 13)
1282 #else
1283          if(cellRecfg->srsRecfg.isSrsCfgSetup && cellRecfg->srsRecfg.srsSubFrameCfg > 14)
1284 #endif
1285          {
1286             RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid Subframe configuration ");
1287             return RFAILED;
1288          }
1289 #endif
1290       /*ccpu00116923 - ADD - Srs Present support - End*/
1291    }
1292    if (cellRecfg->recfgTypes & RGR_CELL_RACH_RECFG)
1293    {
1294       if ((cellRecfg->rachRecfg.preambleFormat > RGSCH_MAX_RA_PREAMBLE_FMT) ||
1295             ((cellRecfg->rachRecfg.raWinSize < RGSCH_MIN_RA_WINSIZE) ||
1296              (cellRecfg->rachRecfg.raWinSize > RGSCH_MAX_RA_WINSIZE)) ||
1297             (cellRecfg->rachRecfg.maxMsg3Tx < RGSCH_MIN_HQ_TX) ||
1298             ((cellRecfg->rachRecfg.numRaPreamble < RGSCH_MIN_NUM_RA_PREAMBLE)
1299             || (cellRecfg->rachRecfg.numRaPreamble > RGSCH_MAX_NUM_RA_PREAMBLE))
1300             || (cellRecfg->rachRecfg.sizeRaPreambleGrpA >
1301                cellRecfg->rachRecfg.numRaPreamble) ||
1302             (cellRecfg->rachRecfg.prachResource >
1303                (*cell)->bwCfg.ulTotalBw - RGSCH_NUM_RA_RB))
1304       {
1305          RLOG_ARG3(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid RACH configuration:"
1306                " preamble Fmt %d raWinSize %d maxMsg3Tx %d",
1307                cellRecfg->rachRecfg.preambleFormat,
1308                cellRecfg->rachRecfg.raWinSize,
1309                cellRecfg->rachRecfg.maxMsg3Tx);
1310          RLOG_ARG2(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid RACH configuration:"
1311                "numRaPreamble %d sizeRaPreambleGrpA %d",
1312                cellRecfg->rachRecfg.numRaPreamble,
1313                cellRecfg->rachRecfg.sizeRaPreambleGrpA);
1314          return RFAILED;
1315       }
1316    }
1317
1318 #ifdef RGR_SI_SCH
1319    if (cellRecfg->recfgTypes & RGR_CELL_SI_RECFG)
1320    {
1321       if ((rgSCHCfgVldtRgrCellSiCfg(inst, &(cellRecfg->siReCfg))) != ROK)
1322       {
1323          RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Validation for SI"
1324                           "Re-configuration failed");
1325          return RFAILED;
1326       }
1327    }
1328 #endif /*RGR_SI_SCH */
1329
1330 /* LTE_ADV_FLAG_REMOVED_START */
1331    if (cellRecfg->recfgTypes & RGR_CELL_LTEA_FEATURE_RECFG)
1332    {
1333       /* Checkin whether DSFR is enbaled without enabling SFR.
1334        * So we need to check if SFR is enabled along with DSFR
1335        * in the same reconfiguration or it is already enabled earlier*/
1336       if((cellRecfg->rgrLteAdvCfg.pres & RGR_DSFR) && 
1337          (RGR_ENABLE == cellRecfg->rgrLteAdvCfg.dsfrCfg.status)) 
1338       {   
1339          if(!(((cellRecfg->rgrLteAdvCfg.pres & RGR_SFR) &&
1340                (RGR_ENABLE == cellRecfg->rgrLteAdvCfg.sfrCfg.status)) || 
1341                ((*cell)->lteAdvCb.sfrCfg.status == RGR_ENABLE)))
1342          {
1343             RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"DSFR is enbaled"
1344                      "Without enabling SFR");
1345             return RFAILED;
1346          }
1347       }
1348       if ((rgSCHCfgVldtRgrCellLteAdvCfg(inst, &(cellRecfg->rgrLteAdvCfg),
1349                                        (*cell)->bwCfg.dlTotalBw)) != ROK)
1350       {
1351          RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Validation for Lte Adv"
1352                   "Re-configuration failed");
1353          return RFAILED;
1354       }
1355    }
1356 /* LTE_ADV_FLAG_REMOVED_END */
1357
1358    /* Validating minimum resource for non-CSG users */
1359    if (cellRecfg->recfgTypes & RGR_CELL_CSG_PARAM_RECFG)
1360    {
1361      if (cellRecfg->csgParamCfg.minDlResNonCsg > 100)
1362      {
1363          RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid Configuration "
1364                "of minimum DL resources for NON-CSG");
1365          return RFAILED;
1366      }
1367      if (cellRecfg->csgParamCfg.minUlResNonCsg > 100)
1368      {
1369          RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Invalid Configuration "
1370                "of minimum UL resources for NON-CSG");
1371          return RFAILED;
1372      }
1373    }
1374    errInfo->errCause = RGSCHERR_NONE;
1375    return ROK;
1376 }  /* rgSCHCfgVldtRgrCellRecfg */
1377
1378 #ifdef LTE_ADV
1379 /**
1380  * @brief Ue SCell configuration for scheduler. It is invoked during first time
1381  *        Scell configuration. It is not for reconfiguration
1382  *
1383  * @details
1384  *
1385  *     Function : rgSCHSCellCfgUeCfg
1386  *
1387  *     This functions updates UE specific scheduler
1388  *     information upon UE SCell first time Scell configuration
1389  *
1390  *  @param[in]  RgSchCellCb  *cell
1391  *  @param[in]  RgSchUeCb    *ue
1392  *  @param[int] RgrUeRecfg   *ueRecfg
1393  *  @param[out] RgSchErrInfo *err
1394  *  @return  S16
1395  *      -# ROK
1396  *      -# RFAILED
1397  **/
1398 S16 rgSCHSCellCfgUeCfg
1399 (
1400 RgSchCellCb  *cell,
1401 RgSchUeCb    *ue,
1402 RgrUeRecfg   *ueRecfg,
1403 RgSchErrInfo *err
1404 )
1405 {
1406    uint8_t          idx;
1407    Inst             inst = cell->instIdx;
1408    RgSchCellCb      *secCellCb = NULLP;
1409    uint8_t          sCellidx = 0;
1410    RgSchUeCellInfo  *sCellInfo = NULLP;
1411    RgrUeSecCellCfg  *sCellInfoCfg = NULLP;
1412 #ifdef TFU_UPGRADE
1413    RgrUeAprdDlCqiCfg   *aCqiCfg;
1414    RgrUePrdDlCqiCfg    *pCqiCfg;  
1415 #endif
1416
1417    RLOG0(L_INFO, "SCELL recfg received from APP \n");  
1418
1419    RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), 
1420      "--------------------------------------------------------------------\n"
1421      "UE SCell ReConfiguration at SCH: rnti (%u) cell(%u)\n"
1422      "--------------------------------------------------------------------\n",
1423      ue->ueId, cell->cellId));
1424
1425  
1426    for(idx = 0; idx < ueRecfg->ueSCellCfgInfo.numSCells; idx++)
1427    {
1428      /* Allocate the Ue control block */
1429       if (((rgSCHUtlAllocSBuf(inst, (Data **)&sCellInfo,
1430                     sizeof(RgSchUeCellInfo))) != ROK))
1431       {
1432          RGSCHDBGERRNEW(inst, (rgSchPBuf(inst), "[%d]SCellIdx :Memomy allocation "
1433                   "Failed while Adding SCell Information\n", idx));
1434          return RFAILED;
1435       }
1436       
1437
1438       sCellInfoCfg = &ueRecfg->ueSCellCfgInfo.ueSCellDedCfg[idx];
1439
1440
1441       sCellInfo->sCellIdx  = sCellInfoCfg->sCellIdx;
1442       sCellInfo->sCellId   = sCellInfoCfg->sCellId;
1443       
1444       if(PRSNT_NODEF == sCellInfoCfg->sCellDeActTmr.pres)
1445       {
1446          /* Configure implicit release */
1447          ue->sCellDeactTmrVal.val = sCellInfoCfg->sCellDeActTmr.val;
1448          ue->isScellExplicitDeAct = FALSE;
1449          ue->sCellDeactTmrVal.pres = PRSNT_NODEF;
1450       }
1451       else if (rgSchCb[cell->instIdx].genCfg.isSCellActDeactAlgoEnable == TRUE)
1452       {
1453          /* Configure explicit release */
1454          ue->sCellDeactTmrVal.val = RGSCH_SCELL_DEACT_TMR_INFINITY_VAL;
1455          ue->isScellExplicitDeAct = TRUE;
1456          ue->sCellDeactTmrVal.pres = PRSNT_NODEF;
1457       }
1458       else
1459       {
1460          ue->sCellDeactTmrVal.val  = 0;
1461          ue->isScellExplicitDeAct  = FALSE;
1462          ue->sCellDeactTmrVal.pres = NOTPRSNT;
1463       }
1464
1465       sCellInfo->sCellState = RG_SCH_SCELL_INACTIVE;
1466
1467       sCellInfo->ue = ue;
1468       ue->cellInfo[(sCellInfoCfg->sCellIdx)] = sCellInfo;
1469       sCellidx = ((sCellInfo->sCellId -
1470                rgSchCb[cell->instIdx].genCfg.startCellId)&(CM_LTE_MAX_CELLS-1));
1471       ue->cellIdToCellIdxMap[sCellidx] = sCellInfo->sCellIdx;
1472
1473       /* For for time one Scell got added, setting allocCmnUlPdcch flag to TRUE, So that
1474          we will allocate PDCCH from common search space and the csiRequest field in DCI0 will 
1475          be one bit (spec 36.213 sec 7.2.1)*/
1476 #ifdef LTE_ADV
1477       if ( ue->numSCells == 0)
1478       {
1479          ue->allocCmnUlPdcch = TRUE;
1480       }
1481 #endif      
1482       ue->numSCells++;
1483 #ifdef CA_DBG      
1484       DU_LOG("\nDEBUG  -->  SCH : SCell added for ue %d numScells %d\n",ue->ueId,ue->numSCells);
1485 #endif
1486       /* retrieve teh sec cell Cb */
1487       if((secCellCb = (RgSchCellCb *)rgSchUtlGetCellCb(inst, sCellInfo->sCellId)) == NULLP)
1488       {
1489          DU_LOG("\nERROR  -->  SCH : SCell doesnt exists");
1490          rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1491          return RFAILED;
1492       }
1493
1494       if(TRUE == sCellInfoCfg->txMode.pres)
1495       {
1496          sCellInfo->txMode = sCellInfoCfg->txMode;
1497       }
1498       else
1499       {
1500          DU_LOG("\nERROR  -->  SCH : [%d]SCellIdx Tx mode not present ",idx);
1501          sCellInfoCfg->txMode.pres = TRUE;
1502          sCellInfoCfg->txMode.txModeEnum = RGR_UE_TM_1;
1503       
1504          sCellInfo->txMode = sCellInfoCfg->txMode;
1505       }
1506       cmInitTimers (&sCellInfo->actDelayTmr, 1);
1507       cmInitTimers (&sCellInfo->deactTmr, 1);
1508
1509       ue->f1bCsAVal += rgSCHUtlGetMaxTbSupp(sCellInfo->txMode.txModeEnum);
1510
1511 #ifdef TFU_UPGRADE
1512       if(TRUE == sCellInfoCfg->ueSCellDlCqiCfg.aprdCqiCfg.pres)
1513       {
1514          sCellInfo->acqiCb.aCqiCfg.aprdModeEnum = 
1515             sCellInfoCfg->ueSCellDlCqiCfg.aprdCqiCfg.aprdModeEnum;
1516       }
1517
1518       if(TRUE == sCellInfoCfg->uePdschDedCfg.uepACfg.pAPrsnt)
1519       {
1520          sCellInfo->pA.pres = TRUE;
1521          sCellInfo->pA.val = sCellInfoCfg->uePdschDedCfg.uepACfg.pA;
1522       }
1523       else
1524       {
1525          sCellInfo->pA.pres = FALSE;
1526       }
1527
1528       aCqiCfg = &sCellInfoCfg->ueSCellDlCqiCfg.aprdCqiCfg; 
1529       DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgACqiUeCfg cellId =%d,Config Presence =%d for \
1530             Sec Cell Id = %d\n",
1531             cellCb->cellId,  aCqiCfg->pres,sCellInfo->sCellId);
1532
1533       /* if aperiodic cqi is present then only call the below function as it is
1534        * not mandatory*/
1535       if(aCqiCfg->pres)
1536       {
1537          if( ROK != rgSCHCfgACqiUeCfg(secCellCb,ue, &sCellInfo->acqiCb,
1538                   sCellInfo->txMode.txModeEnum, aCqiCfg, ue->ueCatEnum))
1539          {
1540             DU_LOG("\nERROR  -->  SCH : [%d]SCellIdx ACQI Cfg"
1541                      "failed..n\n", idx);
1542             rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1543             return RFAILED;
1544          }
1545       }
1546       /* Configuring PCQI */ 
1547       /* Scell needs to be added to the
1548        * pcqi list only after activation */
1549       pCqiCfg = &sCellInfoCfg->ueSCellDlCqiCfg.prdCqiCfg;
1550
1551       if(ROK != rgSCHSCellPCqiCfg(cell,secCellCb,ue,pCqiCfg,
1552             ue->ueCatEnum,sCellInfoCfg->sCellIdx))
1553       {
1554          DU_LOG("\nERROR  -->  SCH : [%d]SCellIdx PCQI Cfg failed..n\n", idx);
1555          rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1556          return RFAILED;
1557       }
1558 #endif
1559    
1560       /* Configuring ACQI */ 
1561  
1562       /* Stroing the secCell for easy access */
1563       sCellInfo->cell   = secCellCb;
1564
1565
1566 #ifdef LTE_ADV
1567       if (ROK != rgSCHLaaInitDlRbAllocCb(secCellCb, 
1568                &sCellInfo->dlAllocCb))
1569       {
1570          return RFAILED;
1571       }
1572 #endif
1573       /* Initialize Harq entity */
1574
1575       sCellInfo->hqEnt = rgSCHDhmHqEntInit(secCellCb);
1576       if (sCellInfo->hqEnt == NULLP)
1577       {
1578          DU_LOG("\nERROR  -->  SCH : [%d]UEID:Hq Entity Initialization "
1579                   "failed in config\n", ue->ueId);
1580          rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1581          return RFAILED;
1582       }
1583 #ifdef EMTC_ENABLE
1584       rgSCHEmtcHqPAlloc(secCellCb, sCellInfo->hqEnt);
1585 #endif
1586       rgSCHCmnDlInitHqEnt(secCellCb, sCellInfo->hqEnt);
1587
1588       sCellInfo->hqEnt->ue = ue;
1589       /* Init SCell Specific Sched Spfc UE DL CB */
1590       if ((secCellCb->sc.apis->rgSCHRgrSCellUeCfg(secCellCb, ue, sCellInfoCfg, err)) != ROK)
1591       {
1592          DU_LOG("\nERROR  -->  SCH : Spec Sched DL UE CFG FAILED\n");
1593          rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1594          return RFAILED;
1595       }
1596
1597 #ifdef LTE_TDD
1598      if((rgSCHUtlAllocUeANFdbkInfo(ue,sCellInfoCfg->sCellIdx)) != ROK)
1599      {
1600         DU_LOG("\nERROR  -->  SCH : [%d]UEID:Memomy allocation "
1601                  "Failed while UE related Ack Nack Information\n",
1602                  ue->ueId);
1603         rgSCHSCellFreeBuf (inst,ue,ueRecfg,idx);
1604         return RFAILED;
1605      }
1606 #endif /* LTE_TDD */
1607
1608 #ifdef LTE_ADV
1609      sCellInfo->sCellLnk.node = (PTR)sCellInfo;
1610      cmLListAdd2Tail(&secCellCb->sCellUeLst, &sCellInfo->sCellLnk);
1611 #endif
1612
1613       /* Inserting UECB into SCELL DBM */
1614      rgSCHDbmInsUeCb(secCellCb, ue);
1615    }
1616
1617 #ifndef MAC_5GTF_UPDATE
1618    ue->ul.useExtBSRSizes = ueRecfg->ueSCellCfgInfo.useExtBSRSizes;
1619 #else
1620    ue->ul.useExtBSRSizes = TRUE;
1621 #endif
1622
1623    for (idx = 0; idx < RGSCH_ULCTRL_RECP_DIST; idx++)
1624    {
1625       ue->ul.ctrlOnServCellIdx[idx] = 0xFF;
1626    }
1627    /* Trigger SCell addition to primary MAC */
1628    return ROK;
1629
1630 }  /* rgSCHSCellCfgUeCfg */
1631 /*f1b_Sprint */
1632 /**
1633  * @brief UE SCell PUCCH reconfiguration for scheduler
1634  *
1635  * @details
1636  *
1637  *     Function : rgSCHSCellCfgUePucchReCfg
1638  *
1639  *     This functions updates UE specific scheduler
1640  *     information upon UE SCell PUCCH reconfiguration
1641  *
1642  *  @param[in]  RgSchCellCb  *cell
1643  *  @param[in]  RgSchUeCb    *ue
1644  *  @param[int] RgrUeRecfg   *ueRecfg
1645  *  @param[out] RgSchErrInfo *err
1646  *  @return  S16
1647  *      -# ROK
1648  *      -# RFAILED
1649  **/
1650 S16 rgSCHSCellCfgUePucchReCfg
1651 (
1652 RgSchCellCb  *cell,
1653 RgSchUeCb    *ue,
1654 RgrUeRecfg   *ueRecfg,
1655 RgSchErrInfo *err
1656 )
1657 {
1658    Inst         inst = cell->instIdx;
1659    RgrUeSCellAckPucchCfg *sCellPucchRecfg = NULLP;
1660    uint8_t idx;
1661
1662    RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), 
1663      "--------------------------------------------------------------------\n"
1664      "UE SCell PUCCH ReConfiguration at SCH: rnti (%u) cell(%u)\n"
1665      "--------------------------------------------------------------------\n",
1666      ue->ueId, cell->cellId));
1667
1668  
1669    sCellPucchRecfg = &ueRecfg->sCellAckN1ResCfg;
1670    /* Copy the UCI format type suported/configured for UE */
1671    ue->uciFrmtTyp = sCellPucchRecfg->pucchFormatType;
1672    
1673    if (ue->uciFrmtTyp == RG_SCH_UCI_FORMAT1B_CS)
1674    {
1675       ue->n1PucchF1bResCb.cw1N1ResCount = sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb1Count;
1676       ue->n1PucchF1bResCb.cw2N1ResCount = sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb2Count;
1677
1678       for(idx = 0; idx < sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb1Count; idx++)
1679       {
1680          ue->n1PucchF1bResCb.cw1N1Res[idx].n1PucchIdx = sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb1[idx];
1681       }
1682
1683       for(idx = 0; idx < sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb2Count; idx++)
1684       {
1685          ue->n1PucchF1bResCb.cw2N1Res[idx].n1PucchIdx = sCellPucchRecfg->u.format1Bcs.sCellAckN1ResTb2[idx];
1686       }
1687    }
1688 #ifdef LTE_ADV
1689    else if (ue->uciFrmtTyp == RG_SCH_UCI_FORMAT3)
1690    {
1691       ue->n3PucchResCb.antP0N3ResCount = sCellPucchRecfg->u.format3.sCellAckN3ResAntP0Count;
1692       ue->n3PucchResCb.antP1N3ResCount = sCellPucchRecfg->u.format3.sCellAckN3ResAntP1Count;
1693       for (idx = 0;idx < ue->n3PucchResCb.antP0N3ResCount; idx++ )
1694       {
1695          ue->n3PucchResCb.antP0N3Res[idx].n3PucchIdx 
1696                         = sCellPucchRecfg->u.format3.sCellAckN3ResAntP0[idx];
1697          ue->n3PucchResCb.antP0N3Res[idx].n3Lnk.node = NULLP;
1698          ue->n3PucchResCb.antP0N3Res[idx].sCellIdx = RGSCH_INVALID_CELL_IDX;
1699       }
1700       for (idx = 0;idx < ue->n3PucchResCb.antP1N3ResCount; idx++ )
1701       {
1702          ue->n3PucchResCb.antP1N3Res[idx].n3PucchIdx 
1703                         = sCellPucchRecfg->u.format3.sCellAckN3ResAntP1[idx];
1704          ue->n3PucchResCb.antP1N3Res[idx].n3Lnk.node = NULLP;
1705          ue->n3PucchResCb.antP1N3Res[idx].sCellIdx = RGSCH_INVALID_CELL_IDX;
1706       }
1707       ue->simulAckNackCQIFormat3 = ueRecfg->simulAckNackCQIFormat3;
1708    }
1709 #endif
1710    else
1711    {
1712       DU_LOG("\nERROR  -->  SCH : Wrong PUCCH Format:%d configured for CA",ue->uciFrmtTyp);
1713    }
1714
1715    return ROK;
1716
1717 }  /* rgSCHSCellCfgUePucchReCfg */
1718 /**
1719  * @brief Validates the UE SCell Reconfiguration request from APP to SCH.
1720  *
1721  * @details
1722  *
1723  *     Function : rgSCHCfgVldtRgrUeSCellRecfg
1724  *
1725  *     Processing Steps:
1726  *      - Validate Number of SCells
1727  *        - If validated successfully,
1728  *          - Process Number of SCells
1729  *        - Else 
1730  *          - Return RFAILED.
1731  *      - Validate SCellIdx value,
1732  *        - If validated successfully,
1733  *          - Process Number of RgrUeSecCellCfg
1734  *        - Else 
1735  *          - Return RFAILED.
1736  *
1737  *  @param[in]  RgrUeRecfg    *ueRecfg
1738  *  @param[out] RgSchCellCb   *cell
1739  *  @param[out] RgSchUeCb     *ue
1740  *  @param[out] RgSchErrInfo  *errInfo
1741  *  @return  S16
1742  *      -# ROK
1743  *      -# RFAILED
1744  **/
1745 S16 rgSCHCfgVldtRgrUeSCellRecfg
1746 (
1747 RgrUeRecfg     *ueRecfg,
1748 RgSchCellCb    *cell,
1749 RgSchUeCb      *ue,
1750 RgSchErrInfo   *errInfo
1751 )
1752 {
1753    RgrUeSecCellCfg   *ueSCellDedCfg = NULLP;
1754    RgSchCellCb          *sCell = NULLP;
1755    Inst    inst = cell->instIdx;
1756
1757
1758    DU_LOG("\nDEBUG  -->  SCH : VALIDATE RGR UE SCELL RECONFIG: cellId %d "
1759             "oldUeId %d cell %p \n", ueRecfg->cellId, ueRecfg->oldCrnti);
1760    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_SCELL_RECFG;
1761
1762    if((ueRecfg->ueSCellCfgInfo.numSCells > RGR_MAX_SCELL_PER_UE) ||
1763          (ueRecfg->ueSCellCfgInfo.numSCells < 1))
1764    {
1765       DU_LOG("\nERROR  -->  SCH : Invalid number of SCELL "
1766                " in SCELL Recfg\n");
1767       return RFAILED;
1768    }
1769    
1770    for(uint8_t idx = 0; idx < ueRecfg->ueSCellCfgInfo.numSCells; idx++)
1771    {
1772       ueSCellDedCfg = &ueRecfg->ueSCellCfgInfo.ueSCellDedCfg[idx];
1773       if(ROK != rgSchUtlVldtCellId(inst, ueSCellDedCfg->sCellId))
1774       {
1775          DU_LOG("\nERROR  -->  SCH : SCellId is out of range");
1776          return RFAILED;
1777       }
1778       /* Validate existence of sec cell */
1779       sCell = rgSchUtlGetCellCb(inst, ueSCellDedCfg->sCellId);
1780       if(NULLP == sCell )
1781       {
1782          DU_LOG("\nERROR  -->  SCH : SCell doesnt exists");
1783          return RFAILED;
1784       }
1785
1786       /* validate the range of serv cell index */
1787       if((ueSCellDedCfg->sCellIdx < 1) ||
1788             (ueSCellDedCfg->sCellIdx > RGR_MAX_SCELL_PER_UE))
1789       {
1790          DU_LOG("\nERROR  -->  SCH : Invalid Serv Cell Idx %d\n",
1791                   ueSCellDedCfg->sCellIdx);
1792          return RFAILED;
1793       }
1794
1795       /* Is this sec cell alredy confiured */
1796       if(NULLP != ue->cellInfo[ueSCellDedCfg->sCellIdx])
1797       {
1798          DU_LOG("\nERROR  -->  SCH : Secll with id %d already added\n",
1799                   ueSCellDedCfg->sCellIdx);
1800          return RFAILED;
1801       }
1802
1803       /* Validate CQI config  params */
1804       if((rgSCHCfgVldtUeCqiModeCfg(sCell, &ueSCellDedCfg->ueSCellDlCqiCfg)) != ROK)
1805       {
1806          DU_LOG("\nERROR  -->  SCH : Invalid CQI Mode "
1807                   " configuration for Ue %d\n",ue->ueId);
1808          return RFAILED;
1809       }
1810 #ifdef TFU_UPGRADE
1811       /*  1. Validate UE Aperiodic CQI related parameters */
1812       if( ROK != rgSCHCfgVldtRgrUeACqiCfg (sCell, ue->ueId,
1813                &ueSCellDedCfg->ueSCellDlCqiCfg.aprdCqiCfg, ueSCellDedCfg->txMode,
1814                errInfo ))
1815       {
1816          DU_LOG("\nERROR  -->  SCH : rgSCHCfgVldtCqiSrSrsUeCfg: Invalid Aperiodic CQI configuration\n");
1817          return RFAILED;
1818       }
1819
1820 #ifdef LTEMAC_HDFDD
1821       if( ROK != rgSCHCfgVldtRgrUePCqiCfg (sCell, ue->ueId,
1822                &ueSCellDedCfg->ueSCellDlCqiCfg.prdCqiCfg, ueRecfg->isHdFddEnbld, 
1823                ueSCellDedCfg->txMode, errInfo ))
1824 #else
1825       if( ROK != rgSCHCfgVldtRgrUePCqiCfg (sCell, ue->ueId,
1826                &ueSCellDedCfg->ueSCellDlCqiCfg.prdCqiCfg,
1827                ueSCellDedCfg->txMode, 
1828                errInfo )) 
1829 #endif
1830       {
1831          DU_LOG("\nERROR  -->  SCH : rgSCHCfgVldtCqiSrSrsUeCfg: Invalid Periodic CQI configuration\n");
1832          return RFAILED;
1833       }
1834
1835       if((ueSCellDedCfg->txMode.txModeEnum < RGR_UE_TM_1) ||
1836             (ueSCellDedCfg->txMode.txModeEnum > RGR_UE_TM_9))
1837       {
1838          DU_LOG("\nERROR  -->  SCH : SCELL Invalid transmission mode for"
1839                   " UE %d\n", (uint8_t)ueSCellDedCfg->txMode.txModeEnum);
1840          return RFAILED;
1841       }
1842 #endif
1843    }
1844
1845    errInfo->errCause = RGSCHERR_NONE;
1846    DU_LOG("\nDEBUG  -->  SCH : RGR Ue SCell Reconfig validation done: "
1847             "cellId %d oldUeId %d\n", ueRecfg->cellId, ue->ueId);
1848    return ROK;
1849 }  /* rgSCHCfgVldtRgrUeSCellRecfg */
1850
1851 /**
1852  * @brief Ue SCell configuration roll back due to failure during configuration
1853  *        of any scell
1854  *
1855  * @details
1856  *
1857  *     Function : rgSCHSCellCfgUeCfgRollBack
1858  *
1859  *     This functions roll backs the configuration of successfully added Scell
1860  *
1861  *  @param[in]  RgSchCellCb  *cell
1862  *  @param[in]  RgSchUeCb    *ue
1863  *  @param[int] RgrUeRecfg   *ueRecfg
1864  *  @param[out] RgSchErrInfo *err
1865  *  @return  S16
1866  *      -# ROK
1867  *      -# RFAILED
1868  **/
1869 static S16 rgSCHSCellCfgUeCfgRollBack
1870 (
1871 RgSchCellCb  *cell,
1872 RgSchUeCb    *ue,
1873 RgrUeRecfg   *ueRecfg
1874 )
1875 {
1876    Inst                inst = cell->instIdx;
1877    RgrUeSecCellCfg  *sCellInfoCfg = NULLP;
1878    RgSchUeCellInfo     *sCellInfo = NULLP;
1879    RgSchCmnCell        *cellSch   = NULLP;
1880
1881    RGSCHDBGINFONEW(inst, (rgSchPBuf(inst), 
1882      "--------------------------------------------------------------------\n"
1883      "UE SCell config roll back at SCH: rnti (%u) cell(%u)\n"
1884      "--------------------------------------------------------------------\n",
1885      ue->ueId, cell->cellId));
1886   
1887   /* Free all Added scell in this transaction */
1888    for(uint8_t idx = 0; idx < ueRecfg->ueSCellCfgInfo.numSCells; idx++)
1889    {
1890       sCellInfoCfg = &ueRecfg->ueSCellCfgInfo.ueSCellDedCfg[idx];
1891       sCellInfo =  ue->cellInfo[(sCellInfoCfg->sCellIdx)];
1892
1893       /* if sCellInfo is not NULLP that means this Scell is added hence
1894        * delte it*/
1895       if (NULLP != sCellInfo)
1896       {
1897          /* Clear Scheduler specific list for this UE from the 
1898           * corresponding CELL */
1899          cellSch = RG_SCH_CMN_GET_CELL(sCellInfo->cell);
1900          cellSch->apisDl->rgSCHDlUeReset(sCellInfo->cell, sCellInfo->ue);
1901          
1902          /* Delete harq Entity of Scell*/
1903          rgSCHDhmDelHqEnt(cell, &(sCellInfo->hqEnt));
1904          
1905          rgSCHUtlFreeSBuf(inst, (Data**)&(sCellInfo),
1906                sizeof(RgSchUeCellInfo));
1907          
1908          ue->cellInfo[(sCellInfoCfg->sCellIdx)] = NULLP;
1909          ue->numSCells--;
1910 #ifdef LTE_ADV
1911          if (ue->numSCells == 0)
1912          {
1913             ue->allocCmnUlPdcch = TRUE;
1914             /* As there is no SCell left so DCI 0 size at UE specific search space 
1915              * will be recalculated as the CSI is reduced to 1 bit */
1916             rgSCHUtlUpdUeDciSize(cell, ue, FALSE);
1917          }
1918 #endif
1919       }
1920    }
1921    return ROK;
1922 }
1923 #endif /* LTE_ADV */
1924 /**
1925  * @brief Validates the UE reconfiguration request from RRC to MAC.
1926  *
1927  * @details
1928  *
1929  *     Function : rgSCHCfgVldtRgrUeRecfg
1930  *
1931  *     Processing Steps:
1932  *      - Retrieve the UE control block.
1933  *      - If successful,
1934  *        - Validate the range of reconfigured values recieved in
1935  *          re-configuration request.
1936  *        - If validated successfully,
1937  *          - Return ROK and pointer to the cell and ue.
1938  *        - Else 
1939  *          - Return RFAILED.
1940  *      - Else return RFAILED.
1941  *
1942  *  @param[in]  Inst          inst
1943  *  @param[in]  RgrUeRecfg    *ueRecfg
1944  *  @param[out] RgSchCellCb   **cell
1945  *  @param[out] RgSchUeCb     **ue
1946  *  @param[out] RgSchErrInfo  *errInfo
1947  *  @return  S16
1948  *      -# ROK
1949  *      -# RFAILED
1950  **/
1951 S16 rgSCHCfgVldtRgrUeRecfg
1952 (
1953 Inst           inst,
1954 RgrUeRecfg     *ueRecfg,
1955 RgSchCellCb    **cell,
1956 RgSchUeCb      **ue,
1957 RgSchErrInfo   *errInfo
1958 )
1959 {
1960
1961    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_RECFG;
1962    
1963    if (((*cell) == NULLP) ||
1964        ((*cell)->cellId != ueRecfg->cellId))
1965    {
1966       DU_LOG("\nERROR  -->  SCH : Cell does not exist for OLD CRNTI:%d",ueRecfg->oldCrnti);
1967       return RFAILED;
1968    }
1969
1970    /* Fetch the Old Ue */
1971    if ((*ue = rgSCHDbmGetUeCb(*cell, ueRecfg->oldCrnti)) == NULLP)
1972    {
1973       DU_LOG("\nERROR  -->  SCH : OLD CRNTI:%d does not exist", 
1974             ueRecfg->oldCrnti);
1975       return RFAILED;
1976    }
1977
1978 #ifdef LTE_ADV
1979    if(RGR_UE_SCELL_ADD_RECFG & ueRecfg->ueRecfgTypes) 
1980    {
1981       S16 ret = rgSCHCfgVldtRgrUeSCellRecfg(ueRecfg,*cell, *ue, errInfo);
1982       if ( ret != ROK)
1983       {
1984          DU_LOG("\nERROR  -->  SCH : Ue SCell Recfg Validation FAILED\n");
1985          return RFAILED;
1986       }
1987       errInfo->errCause = RGSCHERR_NONE;
1988       return ROK;
1989    }
1990 #endif
1991
1992    if (ueRecfg->oldCrnti != ueRecfg->newCrnti)
1993    {
1994       if (rgSCHDbmGetUeCb(*cell, ueRecfg->newCrnti) != NULLP)
1995       {
1996          DU_LOG("\nERROR  -->  SCH : NEW CRNTI:%d already exists", 
1997               ueRecfg->newCrnti);
1998          return RFAILED;
1999       }
2000    }
2001
2002    if ((ueRecfg->ueRecfgTypes & RGR_UE_CSG_PARAM_RECFG) &&\
2003        ((*ue)->csgMmbrSta == ueRecfg->csgMmbrSta))
2004    {
2005       DU_LOG("\nERROR  -->  SCH : UE ID [%d] invalid CSG Membership reconfig :%d ", 
2006               ueRecfg->newCrnti, (uint8_t)ueRecfg->csgMmbrSta);
2007       return RFAILED;
2008    }
2009    /* Validate values */
2010    if ((ueRecfg->ueRecfgTypes & RGR_UE_TXMODE_RECFG) &&
2011          (ueRecfg->txMode.pres == TRUE) &&
2012          ((ueRecfg->txMode.txModeEnum < RGR_UE_TM_1) ||
2013           (ueRecfg->txMode.txModeEnum > RGR_UE_TM_7)))
2014    {
2015       DU_LOG("\nERROR  -->  SCH : Invalid transmission mode %d"
2016             "for NEW CRNTI:%d", (uint8_t)ueRecfg->txMode.txModeEnum,ueRecfg->newCrnti);
2017       return RFAILED;
2018    }
2019 #ifndef TFU_UPGRADE
2020    if ((ueRecfg->ueRecfgTypes & RGR_UE_PRD_DLCQI_RECFG) &&
2021          (((ueRecfg->prdDlCqiRecfg.k < 1) || (ueRecfg->prdDlCqiRecfg.k > 4)) ||
2022          ((ueRecfg->prdDlCqiRecfg.cqiPmiCfgIdx < 1) || 
2023          (ueRecfg->prdDlCqiRecfg.cqiPmiCfgIdx > 1024))))
2024    {
2025       DU_LOG("\nERROR  -->  SCH : Invalid Periodic CQI INFO"
2026                "OLD CRNTI:%d NEW CRNTI:%d",(uint8_t)ueRecfg->oldCrnti,ueRecfg->newCrnti);
2027       return RFAILED;
2028    }
2029 #endif
2030    if ((ueRecfg->ueRecfgTypes & RGR_UE_ULHARQ_RECFG) &&
2031          (ueRecfg->ueUlHqRecfg.maxUlHqTx < RGSCH_MIN_HQ_TX))
2032    {
2033       DU_LOG("\nERROR  -->  SCH : Invalid Uplink HARQ config %d"
2034           "for NEW CRNTI:%d", ueRecfg->ueUlHqRecfg.maxUlHqTx,ueRecfg->newCrnti);
2035       return RFAILED;
2036    }
2037 #ifndef TFU_UPGRADE
2038    if ((ueRecfg->ueRecfgTypes & RGR_UE_PRD_DLCQI_RECFG) &&
2039          (ueRecfg->prdDlCqiRecfg.prdModeEnum > RGR_PRD_CQI_MOD21))
2040    {
2041       DU_LOG("\nERROR  -->  SCH : Invalid periodic mode config for"
2042           " DL CQI %d NEW CRNTI:%d", (uint8_t)ueRecfg->prdDlCqiRecfg.prdModeEnum,ueRecfg->newCrnti);
2043       return RFAILED;
2044    }
2045 #else
2046    if ((ueRecfg->ueRecfgTypes & RGR_UE_PCQI_RECFG) &&
2047        (ueRecfg->cqiCfg.cqiSetup.prdModeEnum > RGR_PRD_CQI_MOD21))
2048    {
2049      DU_LOG("\nERROR  -->  SCH : Invalid periodic mode config for "
2050             "DL CQI %d for NEW CRNTI:%d",(uint8_t)ueRecfg->cqiCfg.cqiSetup.prdModeEnum,ueRecfg->newCrnti);
2051      return RFAILED;
2052    }
2053 #endif /* TFU_UPGRADE */
2054    /* Validate UE Category */
2055    if (ueRecfg->ueCatEnum > CM_LTE_UE_CAT_8)
2056    {
2057       DU_LOG("\nERROR  -->  SCH : Invalid category %d for NEW CRNTI:%d",
2058                (uint8_t)ueRecfg->ueCatEnum,ueRecfg->newCrnti);
2059       return RFAILED;
2060    }
2061
2062    /* Validate UE Access Stratum Release */
2063    if ((ueRecfg->ueRecfgTypes & RGR_UE_UE_ACCESS_STRATUM_REL_RECFG) && \
2064          (ueRecfg->accessStratumRls > RGR_REL_11))
2065    {
2066       DU_LOG("\nERROR  -->  SCH : Invalid Access Stratum Release %u for UE\n",
2067                ueRecfg->accessStratumRls);
2068       return RFAILED;
2069    }
2070    DU_LOG("\nINFO  -->  SCH : Configured Access Stratum Release %u\n", \
2071             ueRecfg->accessStratumRls);
2072
2073    if ((ueRecfg->ueRecfgTypes & RGR_UE_APRD_DLCQI_RECFG) && 
2074          ((ueRecfg->aprdDlCqiRecfg.pres == TRUE) &&
2075           ((ueRecfg->aprdDlCqiRecfg.aprdModeEnum > RGR_APRD_CQI_MOD31) ||
2076           (*cell)->bwCfg.dlTotalBw <= 7)))
2077    {
2078       DU_LOG("\nERROR  -->  SCH : Invalid aperiodic mode config for"
2079           " DL CQI %d for NEW CRNTI:%d", (uint8_t)ueRecfg->aprdDlCqiRecfg.aprdModeEnum,ueRecfg->newCrnti);
2080       return RFAILED;
2081    }
2082    if ((ueRecfg->ueRecfgTypes & RGR_UE_ULPWR_RECFG) &&
2083          (rgSCHCfgVldtUePwrCfg(*cell, &ueRecfg->ueUlPwrRecfg) != ROK))
2084    {
2085       DU_LOG("\nERROR  -->  SCH : Invalid PUSCH Group power"
2086            " Reconfiguration for NEW CRNTI:%d",ueRecfg->newCrnti);
2087       return RFAILED;
2088    }
2089  
2090    
2091    if ((ueRecfg->ueRecfgTypes & RGR_UE_ACKNACK_MEASGAP_RECFG) &&
2092       (rgSCHCfgVldtUeMeasGapAckNakRepRecfg(*cell, ueRecfg) != ROK))
2093    {
2094       DU_LOG("\nERROR  -->  SCH : Invalid MeasGap/AckNackRep"
2095             " Reconfiguration for NEW CRNTI:%d",ueRecfg->newCrnti);
2096       return RFAILED;
2097    }
2098 #ifdef LTEMAC_SPS
2099    if(rgSCHCfgVldtSpsReCfg(*cell, *ue, ueRecfg)!= ROK)
2100    {
2101       DU_LOG("\nERROR  -->  SCH : Invalid SPS"
2102            " Reconfiguration for NEW CRNTI:%d",ueRecfg->newCrnti);
2103       return RFAILED;
2104    }
2105 #endif
2106 #ifdef TFU_UPGRADE
2107    /* Validated Periodic CQI/PMI, RI , SRS and SR related UeCfg */
2108    if ( ROK != rgSCHCfgVldtCqiSrSrsUeReCfg(*cell, *ue, ueRecfg,  errInfo))
2109    {
2110       DU_LOG("\nERROR  -->  SCH : Invalid ACQI, PCQI/SR/SRS "
2111                "Re-configuration for NEW CRNTI:%d",ueRecfg->newCrnti);
2112       return RFAILED;
2113    }
2114 #endif
2115    if ((ueRecfg->ueRecfgTypes & RGR_UE_DRX_RECFG) &&
2116       (rgSCHCfgVldtDrxUeCfg(*cell, &(ueRecfg->ueDrxRecfg)) != ROK))
2117    {
2118       DU_LOG("\nERROR  -->  SCH : Invalid drxParams"
2119             " Reconfiguration for NEW CRNTI:%d",ueRecfg->newCrnti);
2120       return RFAILED;
2121    }
2122
2123 /* ccpu00117452 - MOD - Changed macro name from
2124    RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
2125 #ifdef RGR_CQI_REPT
2126    /* Validate DL Power Control Config parameters */
2127    if(rgSCHCfgVldtCqiReptReCfg(*cell, ueRecfg)!= ROK)
2128    {
2129       DU_LOG("\nERROR  -->  SCH : Invalid DL Power Control"
2130            " Reconfiguration for NEW CRNTI:%d",ueRecfg->newCrnti);
2131       return RFAILED;
2132    }
2133 #endif /* End of RGR_CQI_REPT */
2134    errInfo->errCause = RGSCHERR_NONE;
2135    return ROK;
2136 }  /* rgSCHCfgVldtRgrUeRecfg */
2137
2138
2139 /**
2140  * @brief Validates the logical channel reconfiguration request from
2141  * RRC to MAC.
2142  *
2143  * @details
2144  *
2145  *     Function : rgSCHCfgVldtRgrLchRecfg
2146  *
2147  *     Processing Steps:
2148  *      - Retrieve the uplink and downlink logical channel control block.
2149  *      - If successful,
2150  *        - Validate the range of reconfigured values recieved in
2151  *          re-configuration request.
2152  *        - If validated successfully,
2153  *          - Return ROK and pointer to the cell, UE and logical channel.
2154  *        - Else 
2155  *          - Return RFAILED.
2156  *      - Else return RFAILED.
2157  *
2158  *  @param[in]  RgrLchRecfg     *lcRecfg
2159  *  @param[out] RgSchCellCb     **cell
2160  *  @param[out] RgSchUeCb       **ue
2161  *  @param[out] RgSchUlLcCb     **ulLc
2162  *  @param[out] RgSchDlLcCb     **dlLc
2163  *  @param[out] RgSchErrInfo       *errInfo
2164  *  @return  S16
2165  *      -# ROK
2166  *      -# RFAILED
2167  **/
2168 S16 rgSCHCfgVldtRgrLchRecfg
2169 (
2170 Inst           inst,
2171 RgrLchRecfg    *lcRecfg,
2172 RgSchCellCb    **cell,
2173 RgSchUeCb      **ue,
2174 RgSchDlLcCb    **dlLc,
2175 RgSchErrInfo   *errInfo
2176 )
2177 {
2178    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_LC_RECFG;
2179
2180    if (((*cell) == NULLP) ||
2181        ((*cell)->cellId != lcRecfg->cellId))
2182    {
2183       DU_LOG("\nERROR  -->  SCH : Cell does not exist " 
2184                 "for CRNTI:%d LCID:%d",lcRecfg->crnti,lcRecfg->lcId);
2185       return RFAILED;
2186    }
2187
2188    /* Fetch the Ue for dedicated channels */
2189    if ((*ue = rgSCHDbmGetUeCb(*cell, lcRecfg->crnti)) == NULLP)
2190    {
2191       DU_LOG("\nERROR  -->  SCH : UEID does not exist"
2192          "dedicated logical channel for CRNTI:%d LCID:%d",lcRecfg->crnti,lcRecfg->lcId);
2193       return RFAILED;
2194    }
2195    
2196    if ((*dlLc = rgSCHDbmGetDlDedLcCb((*ue), lcRecfg->lcId)) == NULLP)
2197    {
2198       DU_LOG("\nERROR  -->  SCH : Dedicated DL LC does not "
2199                "exist for CRNTI:%d LCID:%d",lcRecfg->crnti,lcRecfg->lcId);
2200       return RFAILED;
2201    }
2202
2203    errInfo->errCause = RGSCHERR_NONE;
2204    return ROK;
2205 }  /* rgSCHCfgVldtRgrLchRecfg */
2206
2207 /**
2208  * @brief Validates the UE Reset request from RRM to MAC.
2209  *
2210  * @details
2211  *
2212  *     Function : rgSCHCfgVldtRgrUeReset
2213  *
2214  *     Processing Steps:
2215  *      - Retrieve the CELL control block
2216  *      - If cell does not exist return RFAILED
2217  *      - Retrieve UE Control block
2218  *      - If UE does not exist return RFAILED
2219  *      - Return ROK
2220  *
2221  *  @param[in]  Inst        inst
2222  *  @param[in]  RgrRst      *reset
2223  *  @param[out] RgSchCellCb **cell
2224  *  @param[out] RgSchUeCb      **ue
2225  *  @param[out] RgErrInfo   *errInfo
2226  *  @return  S16
2227  *      -# ROK
2228  *      -# RFAILED
2229  **/
2230 S16 rgSCHCfgVldtRgrUeReset
2231 (
2232 Inst         inst,
2233 RgrRst       *reset,
2234 RgSchCellCb  *cell,
2235 RgSchUeCb    **ue,
2236 RgSchErrInfo *errInfo
2237 )
2238 {
2239
2240    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_RESET;
2241    
2242    if ((cell == NULLP) || (cell->cellId != reset->cellId))
2243    {
2244       DU_LOG("\nERROR  -->  SCH : CELL does not exist for CRNTI:%d",
2245                reset->crnti);
2246       return RFAILED;
2247    }
2248    /* Fetch the Ue  */
2249    if ((*ue = rgSCHDbmGetUeCb(&(*cell), reset->crnti)) == NULLP)
2250    {
2251       DU_LOG("\nERROR  -->  SCH : UE does not exist for CRNTI:%d",
2252                reset->crnti);
2253       return RFAILED;
2254    }
2255
2256    errInfo->errCause = RGSCHERR_NONE;
2257
2258    return ROK;
2259 }  /* rgSCHCfgVldtRgrUeReset */
2260    
2261
2262 /**
2263  * @brief Validates the logical channel reconfiguration request from
2264  * RRC to MAC.
2265  *
2266  * @details
2267  *
2268  *     Function : rgSCHCfgVldtRgrLcgRecfg
2269  *
2270  *     Processing Steps:
2271  *      - Retrieve the uplink and downlink logical channel control block.
2272  *      - If successful,
2273  *        - Validate the range of reconfigured values recieved in
2274  *          re-configuration request.
2275  *        - If validated successfully,
2276  *          - Return ROK and pointer to the cell, UE and logical channel.
2277  *        - Else 
2278  *          - Return RFAILED.
2279  *      - Else return RFAILED.
2280  *
2281  *  @param[in]  RgrLchRecfg     *lcRecfg
2282  *  @param[out] RgSchCellCb     **cell
2283  *  @param[out] RgSchUeCb       **ue
2284  *  @param[out] RgSchErrInfo    *errInfo
2285  *  @return  S16
2286  *      -# ROK
2287  *      -# RFAILED
2288  **/
2289 S16 rgSCHCfgVldtRgrLcgRecfg
2290 (
2291 Inst           inst,
2292 RgrLcgRecfg    *lcgRecfg,
2293 RgSchCellCb    *cell,
2294 RgSchUeCb      **ue,
2295 RgSchErrInfo   *errInfo
2296 )
2297 {
2298    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_LCG_RECFG;
2299
2300    if (((cell) == NULLP) ||
2301        ((cell)->cellId != lcgRecfg->cellId))
2302    {
2303       DU_LOG("\nERROR  -->  SCH : Cell does not exist for" 
2304                 "CRNTI:%d LCGID:%d",lcgRecfg->crnti,lcgRecfg->ulRecfg.lcgId);
2305       return RFAILED;
2306    }
2307
2308    /* Fetch the Ue for dedicated channels */
2309    if ((*ue = rgSCHDbmGetUeCb(&(*cell), lcgRecfg->crnti)) == NULLP)
2310    {
2311       DU_LOG("\nERROR  -->  SCH : UE does not exist for "
2312                 "dedicated logical channel group CRNTI:%d LCGID:%d",
2313                 lcgRecfg->crnti,lcgRecfg->ulRecfg.lcgId);
2314       return RFAILED;
2315    }
2316    if (lcgRecfg->ulRecfg.lcgId > (RGSCH_MAX_LCG_PER_UE - 1))
2317    {
2318       DU_LOG("\nERROR  -->  SCH : Invalid lcgId for uplink logical"
2319                 "channel CRNTI:%d LCGID:%d",
2320                 lcgRecfg->crnti,lcgRecfg->ulRecfg.lcgId);
2321       return RFAILED;
2322    }
2323    
2324    if ((lcgRecfg->ulRecfg.gbr != 0) && (lcgRecfg->ulRecfg.mbr < lcgRecfg->ulRecfg.gbr))
2325    {
2326       DU_LOG("\nERROR  -->  SCH : Dedicated Logical Group %d validation failed"\
2327           " for ue %d for cell %d\n", lcgRecfg->ulRecfg.lcgId,(*ue)->ueId, cell->cellId);
2328       return RFAILED;
2329    }
2330    errInfo->errCause = RGSCHERR_NONE;
2331    return ROK;
2332 }  /* rgSCHCfgVldtRgrLcgRecfg */
2333
2334 /**
2335  *
2336  * @details
2337  *
2338  *     Function : rgSCHDynCfiCfg
2339  *
2340  *  @param[in]  RgSchCellCb   *cell
2341  *              RgrCellCfg    *cellCfg
2342  *  @return  S16
2343  *      -# ROK
2344  *      -# RFAILED
2345  **/
2346 static S16 rgSCHDynCfiCfg
2347 (
2348 RgSchCellCb   *cell,
2349 RgrCellCfg    *cellCfg
2350 )
2351 {
2352    uint8_t        cfi; 
2353 #ifdef LTE_TDD
2354    uint8_t        ulDlCfgIdx = cellCfg->ulDlCfgIdx;
2355    uint8_t        mphIdx;
2356    uint8_t        maxMPhich;
2357    uint16_t       numDlSf;
2358 #endif    
2359
2360    cell->dynCfiCb.isDynCfiEnb = cellCfg->isDynCfiEnb;
2361
2362    /* Initializing Failure Sample Period */
2363    cell->dynCfiCb.failSamplePrd = (RGSCH_CFI_TTI_MON_INTRVL *
2364                      RGSCH_CFI_STEP_UP_TTI_PRCNTG)/100;
2365    /* Initializing Number of Failure Samples */
2366    cell->dynCfiCb.numFailSamples = (RGSCH_CFI_TTI_MON_INTRVL/
2367                                     cell->dynCfiCb.failSamplePrd);
2368    cell->dynCfiCb.maxCfi = RGSCH_MAX_CFI_VAL;
2369    /* Allocating memory for CCE failure average array based on 
2370     * monitoring interval and CCE failure sample period */
2371    if((rgSCHUtlAllocSBuf(cell->instIdx, (Data**)&(cell->dynCfiCb.cceFailSamples),
2372                (cell->dynCfiCb.numFailSamples * sizeof(uint16_t)))) != ROK)
2373    {
2374       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for cell");
2375       return RFAILED;
2376    }
2377
2378    /* Setting the Invalid value 0xFF to pdcchSfIdx, it will be assigned 
2379     * a valid value during CFI swithing is done */
2380    cell->dynCfiCb.pdcchSfIdx = 0xFF;
2381
2382 #ifdef LTE_TDD
2383    /* In case of config index 0, the mphich index can be upto 2 
2384     * in other config index cases, it will always be set as 1*/
2385    if(ulDlCfgIdx == 0)
2386    {
2387       maxMPhich = RG_SCH_MAX_MPHICH;
2388    }
2389    else
2390    {
2391       maxMPhich = RG_SCH_MAX_MPHICH -1;
2392    }    
2393    /* Calculate the number of CCEs in the cell */
2394    for(cfi = 1; cfi < RG_SCH_CMN_MAX_CFI; cfi++)
2395    {   
2396       for(mphIdx = 0; mphIdx < maxMPhich; mphIdx++)
2397       {   
2398          cell->dynCfiCb.cfi2NCceTbl[mphIdx][cfi] = 
2399             rgSCHUtlCalcNCce(cell->bwCfg.dlTotalBw,
2400                cell->phichCfg.ngEnum, cfi, mphIdx,
2401                cell->numTxAntPorts,
2402                cell->isCpDlExtend);
2403       }
2404    }
2405 #else   
2406    /* Calculate the number of CCEs in the cell */
2407    for(cfi = 1; cfi < RG_SCH_CMN_MAX_CFI; cfi++)
2408    {   
2409       /* CFI Index starts from 1 so that there can be a direct mapping from 
2410          actual CFI value to cfi Index. mPhich index will always be set 
2411          as 0 for FDD */
2412       cell->dynCfiCb.cfi2NCceTbl[0][cfi] = 
2413             rgSCHUtlCalcNCce(cell->bwCfg.dlTotalBw, cell->phichCfg.ngEnum,
2414                   cfi, cell->numTxAntPorts, cell->isCpDlExtend);
2415    }
2416
2417    /* Calculate the number of CCEs in the cell */
2418    if(cell->dynCfiCb.isDynCfiEnb == TRUE)
2419    {   
2420       /* In case if Dynamic CFI feature is enabled, default CFI 
2421        * value 1 is used  */
2422       cell->nCce = cell->dynCfiCb.cfi2NCceTbl[0][1];
2423    }   
2424    else
2425    {
2426       cell->nCce = cell->dynCfiCb.cfi2NCceTbl[0][cellCfg->cfiCfg.cfi];
2427    }    
2428 #endif  
2429
2430 #ifdef LTE_TDD   
2431    numDlSf = rgSchTddNumDlSubfrmTbl[ulDlCfgIdx][9] * 
2432                (RGSCH_CFI_TTI_MON_INTRVL/10);
2433    cell->dynCfiCb.cfiStepUpTtiCnt = 
2434                (RGSCH_CFI_STEP_UP_TTI_PRCNTG * numDlSf)/100;
2435    cell->dynCfiCb.cfiStepDownTtiCnt = 
2436                (RGSCH_CFI_STEP_DOWN_TTI_PERCNTG * numDlSf)/100;
2437 #else
2438    cell->dynCfiCb.cfiStepUpTtiCnt = (RGSCH_CFI_STEP_UP_TTI_PRCNTG * 
2439                                      RGSCH_CFI_TTI_MON_INTRVL)/100;
2440    cell->dynCfiCb.cfiStepDownTtiCnt = (RGSCH_CFI_STEP_DOWN_TTI_PERCNTG * 
2441                                      RGSCH_CFI_TTI_MON_INTRVL)/100;
2442 #endif   
2443
2444    return ROK;
2445 }
2446
2447 /**
2448  * @brief Handler for the SCHED Enb configuration request from RRM to MAC.
2449  *
2450  * @details
2451  *
2452  *     Function : rgSCHCfgRgrSchedEnbCfg
2453  *
2454  *     Processing Steps:
2455  *      - Invoke SCH with SCHEDULER control block to update
2456  *        scheduler specific information.
2457  *      - Update rgSch control block with the values recieved in the
2458  *        configuration.
2459  *      - If successful, return ROK else RFAILED.
2460  *      
2461  *  @param[in]  RgSchCb      *instCb
2462  *  @param[in]  SpId         spId
2463  *  @param[in]  RgSchSchedEnbCfg    *schedEnbCfg
2464  *  @param[out] RgSchErrInfo *errInfo
2465  *  @return  S16
2466  *      -# ROK
2467  *      -# RFAILED
2468  **/
2469 S16 rgSCHCfgRgrSchedEnbCfg
2470 (
2471 Inst            inst,
2472 SpId            spId,
2473 RgrSchedEnbCfg *schedEnbCfg,
2474 RgSchErrInfo   *errInfo
2475 )
2476 {
2477
2478    DU_LOG("\nDEBUG  -->  SCH : APPLYING RGR SCH ENB CONFIG: \n");
2479    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_ENB_CFG;
2480
2481    rgSchCb[inst].rgrSchedEnbCfg = *schedEnbCfg;
2482    DU_LOG("\nDEBUG  -->  SCH : dlSchdType %d ulSchdType %d dlTptCoeffi %d"
2483            "dlFairCoeffi %d  ulTptCoeffi %d ulFairCoeffi %d\n",
2484          schedEnbCfg->dlSchdType, schedEnbCfg->ulSchdType, schedEnbCfg->dlSchInfo.dlPfs.tptCoeffi,
2485          schedEnbCfg->dlSchInfo.dlPfs.fairCoeffi, schedEnbCfg->ulSchInfo.ulPfs.tptCoeffi,
2486          schedEnbCfg->ulSchInfo.ulPfs.fairCoeffi);
2487
2488 #ifdef RG_5GTF
2489    rgSchCb[inst].rgSchDynTdd.isDynTddEnbld = schedEnbCfg->isDynTddEnbld;
2490 #endif
2491 # if 0
2492    if(RGR_SCH_TYPE_PFS == schedEnbCfg->dlSchdType)
2493    {
2494      rgSCHEnbPfsDlCfg(inst, errInfo);
2495    }
2496 #endif
2497    errInfo->errCause = RGSCHERR_NONE;
2498    DU_LOG("\nINFO  -->  SCH : RGR SCH gNB done: \n");
2499    return ROK;
2500 }  /* rgSCHCfgRgrSchedEnbCfg */
2501
2502 #ifdef RG_5GTF
2503 /**
2504  * @brief Handler for the cell configuration of 5gtf.
2505  *
2506  * @details
2507  *
2508  *     Function : rgSCH5gtfCellCfg
2509  *      
2510  *  @param[in]  RgSchCellCb   *cell
2511  *  @param[in]  RgSchCellCfg    *cellCfg
2512  *  @return  S16
2513  *      -# ROK
2514  *      -# RFAILED
2515  **/
2516 S16 rgSCH5gtfCellCfg
2517 (
2518 RgSchCellCb   *cell,
2519 RgrCellCfg    *cellCfg
2520 )
2521 {
2522    uint8_t           idx;
2523
2524    for(idx = 0; idx < MAX_5GTF_GROUP; idx++)
2525    {
2526       cell->cell5gtfCb.ueGrp5gConf[idx].beamBitMask = 0;
2527    }
2528
2529    for(idx = 0 ; idx < MAX_5GTF_SUBFRAME_INFO ; ++idx)
2530    {
2531       cell->cell5gtfCb.dynConfig[idx] = cellCfg->Cell5gtfCfg.dynConfig[idx]; 
2532    }
2533    cell->cell5gtfCb.numUes = cellCfg->Cell5gtfCfg.numUes;
2534    cell->cell5gtfCb.uePerGrpPerTti = cellCfg->Cell5gtfCfg.uePerGrp;
2535    cell->cell5gtfCb.ueGrpPerTti = cellCfg->Cell5gtfCfg.ueGrpPerTti;
2536    cell->cell5gtfCb.numCCs = cellCfg->Cell5gtfCfg.numOfCC;
2537    cell->cell5gtfCb.bwPerCC = cellCfg->Cell5gtfCfg.bwPerCC;
2538    DU_LOG("\nINFO  -->  SCH : cell cfg at schd,numUes:%u,uepergrp:%u,uegrppertti:%u,numCC:%u,bwPerc:%u cfi %u\n",
2539          cell->cell5gtfCb.numUes,cell->cell5gtfCb.uePerGrpPerTti,cell->cell5gtfCb.ueGrpPerTti,
2540          cell->cell5gtfCb.numCCs,cell->cell5gtfCb.bwPerCC, cell->cell5gtfCb.cfi);
2541    return ROK;
2542 }
2543 #endif
2544
2545 #ifdef XEON_LMT_ITBS
2546 uint16_t gWrMaxDlItbs;
2547 uint16_t gWrMaxUlItbs;
2548 #endif
2549 /**
2550  * @brief Handler for the cell configuration request from RRM to MAC.
2551  *
2552  * @details
2553  *
2554  *     Function : rgSCHCfgRgrCellCfg
2555  *
2556  *     Processing Steps:
2557  *      - Invoke SCH with cell control block to update
2558  *        scheduler specific information.
2559  *      - Update cell control block with the values recieved in the
2560  *        configuration.
2561  *      - Add to the active list of cells if cell becomes ACTIVE.
2562  *      - If successful, return ROK else RFAILED.
2563  *      
2564  *  @param[in]  RgSchCb      *instCb
2565  *  @param[in]  SpId         spId
2566  *  @param[in]  RgSchCellCfg    *cellCfg
2567  *  @param[out] RgSchErrInfo *errInfo
2568  *  @return  S16
2569  *      -# ROK
2570  *      -# RFAILED
2571  **/
2572 S16 rgSCHCfgRgrCellCfg
2573 (
2574 RgSchCb       *instCb,
2575 SpId          spId,
2576 RgrCellCfg    *cellCfg,
2577 RgSchErrInfo  *errInfo
2578 )
2579 {
2580    S16          ret;
2581    uint8_t           idx;
2582    Pst          pst;
2583    RgInfCellReg cellRegReq;
2584    RgSchCellCb  *cell = NULLP;
2585    Inst         inst = instCb->rgSchInit.inst;
2586    uint32_t          Idx1 = (uint8_t)((cellCfg->cellId - instCb->genCfg.startCellId)&(CM_LTE_MAX_CELLS-1));
2587
2588    errInfo->errCause = RGSCHERR_CFG_RGR_CELL_CFG;
2589    
2590    memset(&pst, 0, sizeof(Pst));
2591     
2592    /* Allocate the scheduler's cell control block */
2593    if((ret = rgSCHUtlAllocSBuf(inst, (Data**)&cell, sizeof(RgSchCellCb))) 
2594          != ROK)
2595    {
2596       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for cell");
2597       return RFAILED;
2598    }
2599 #ifdef EMTC_ENABLE
2600    if(cellCfg->emtcEnable)
2601    {
2602       if((ret = rgSCHEmtcCellAlloc(cell)) 
2603             != ROK)
2604       {
2605          DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for emtc cell");
2606          return RFAILED;
2607       }
2608    }
2609 #endif
2610    if ((uint8_t *)cell == NULLP)
2611    {
2612       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for cell");
2613       return RFAILED;
2614    }
2615    /* Initialize the lists of the cell */
2616    ret = rgSCHDbmInitCell(cell);
2617    if (ret != ROK)
2618    {
2619       DU_LOG("\nERROR  -->  SCH : DBM initialization FAILED for cell");
2620       rgSCHCfgFreeCellCb(cell);
2621       return RFAILED;
2622    }
2623 /* LTE_ADV_FLAG_REMOVED_START */
2624    if(cellCfg->rgrLteAdvCfg.pres & RGR_ABS)
2625    {
2626       cell->lteAdvCb.absCfg =
2627          cellCfg->rgrLteAdvCfg.absCfg;
2628       memset(cell->lteAdvCb.absLoadInfo, 0, sizeof(uint32_t)*RGR_ABS_PATTERN_LEN);
2629       cell->lteAdvCb.absLoadTtiCnt = 0;
2630    }
2631
2632    if(cellCfg->rgrLteAdvCfg.pres & RGR_SFR)
2633    {
2634       cell->lteAdvCb.sfrCfg =
2635          cellCfg->rgrLteAdvCfg.sfrCfg;
2636    }
2637    if(cellCfg->rgrLteAdvCfg.pres & RGR_DSFR)
2638    {
2639       cell->lteAdvCb.dsfrCfg =
2640          cellCfg->rgrLteAdvCfg.dsfrCfg;
2641    }
2642 /* LTE_ADV_FLAG_REMOVED_END */
2643
2644 #ifdef EMTC_ENABLE
2645    cell->emtcEnable = cellCfg->emtcEnable;      
2646 #endif
2647    /* Initialize the cell */
2648    cell->cellId = cellCfg->cellId;
2649    cell->instIdx = inst;
2650    cell->macInst = cellCfg->macInst;
2651    cell->isCpUlExtend = cellCfg->isCpUlExtend;
2652    cell->isCpDlExtend = cellCfg->isCpDlExtend;
2653
2654    cell->numTxAntPorts = rgSchCb[inst].rgrSchedEnbCfg.numTxAntPorts; 
2655    if(cell->numTxAntPorts == 1)
2656    {
2657       cell->numCellRSPerSf = RGSCH_NUM_CELL_RS_ONE_ANT_PORT;
2658    }
2659    else if(cell->numTxAntPorts == 2)
2660    {
2661       cell->numCellRSPerSf = RGSCH_NUM_CELL_RS_TWO_ANT_PORT;
2662    }
2663    else
2664    {
2665       cell->numCellRSPerSf = RGSCH_NUM_CELL_RS_FOUR_ANT_PORT;
2666    }
2667    cell->bwCfg = cellCfg->bwCfg;
2668    cell->pbchRbStart = ((((cell->bwCfg.dlTotalBw * 12)/2) - 36)/12); /* Ref section 6.6 in 36.211 */ 
2669    cell->pbchRbEnd = cell->pbchRbStart + 5;
2670    cell->pucchCfg = cellCfg->pucchCfg;
2671    cell->rachCfg = cellCfg->rachCfg;
2672    cell->siCfg = cellCfg->siCfg;
2673    cell->t300TmrVal = cellCfg->t300TmrVal;
2674 #ifdef RGR_SI_SCH
2675    /*Initialize the SI CB in Cell CB */
2676    memset(&cell->siCb, 0, sizeof(RgSchSiCb));
2677 #endif
2678    /*Fix: Added Guard Pool for RNTI which will contain RNTIs 
2679        *for UEs deleted from Scheduler but not yet from MAC*/
2680    cmLListInit(&cell->rntiDb.rntiGuardPool);
2681
2682    /* Initialize the inWindow to sync with scheduler time when ticks starts */
2683 #ifdef LTEMAC_HDFDD
2684       cell->siCb.inWindow = (cellCfg->siCfg.siWinSize - 
2685             (RG_SCH_CMN_DL_DELTA + RG_SCH_CMN_HARQ_INTERVAL));
2686 #else
2687       cell->siCb.inWindow = (cellCfg->siCfg.siWinSize - 
2688             (RG_SCH_CMN_DL_DELTA));
2689 #endif
2690      
2691       if(cell->siCb.inWindow < 0)
2692       { 
2693          cell->siCb.inWindow = 0;
2694       }
2695    cell->macPreambleSet = cellCfg->macPreambleSet;
2696    cell->phichCfg = cellCfg->phichCfg;
2697
2698    /* Initialize UL and DL CCCH logical channels */
2699    cell->ulCcchId = RGSCH_INVALID_LC_ID;
2700    cell->dlCcchId = RGSCH_INVALID_LC_ID;
2701
2702    /* Update SRS configuration */
2703    cell->srsCfg.isSrsCfgPres = cellCfg->srsCfg.isSrsCfgSetup;
2704    if(cellCfg->srsCfg.isSrsCfgSetup)
2705    {
2706       cell->srsCfg.srsCfgPrdEnum = cellCfg->srsCfg.srsCfgPrdEnum;
2707       cell->srsCfg.srsBwEnum = cellCfg->srsCfg.srsBwEnum;
2708       cell->srsCfg.srsTxOffst =
2709          rgSrsTxOffstTbl[cellCfg->srsCfg.srsSubFrameCfg];
2710       /*ccpu00116923 - ADD - Srs Present support */
2711 #ifdef TFU_UPGRADE
2712       cell->srsCfg.srsSubFrameCfg = cellCfg->srsCfg.srsSubFrameCfg;
2713 #endif
2714    }
2715
2716    /* Configure all the common logical channels for the cell */
2717    for(idx = 0; idx < cellCfg->numCmnLcs; idx++)
2718    {
2719       /* This never returns failure and hence not checked for */
2720       rgSCHCfgRgrCmnLcCfg(cell, &(cellCfg->cmnLcCfg[idx]), errInfo);
2721    }
2722
2723    /* Invoke the MeasGap and ACK NACK Rep handler for cell cfg */
2724
2725    /* Dynamic CFI cell configuration */
2726    ret = rgSCHDynCfiCfg(cell, cellCfg);
2727    if(ret != ROK)
2728    {
2729       DU_LOG("\nERROR  -->  SCH : Rgr cell Config failed at "
2730        "Scheduler for cell");
2731       rgSCHCfgFreeCellCb(cell);
2732       return RFAILED;
2733    }   
2734    /* Updating Auto TM Mode enable/diable flag */
2735    cell->isAutoCfgModeEnb = cellCfg->isAutoCfgModeEnb;
2736    {
2737      if(cell->isAutoCfgModeEnb)
2738      {
2739         DU_LOG("\nINFO  -->  SCH : Auto Mode Cfg enabled durint cell cfg\n");
2740      }
2741    }
2742    /* CPU OvrLoad State Initialization */
2743 #ifdef XEON_LMT_ITBS
2744    cell->thresholds.maxDlItbs = gWrMaxDlItbs;
2745    cell->thresholds.maxUlItbs = gWrMaxUlItbs;
2746    DU_LOG("\nINFO  -->  SCH : LIMIT DL and UL ITBS %d:%d \n",gWrMaxDlItbs,gWrMaxUlItbs);
2747 #else
2748    cell->thresholds.maxDlItbs = RG_SCH_DL_MAX_ITBS;
2749    cell->thresholds.maxUlItbs = RG_SCH_UL_MAX_ITBS;
2750 #endif
2751    cell->measurements.dlTpt = 0;
2752    cell->measurements.ulTpt = 0;
2753    cell->measurements.dlBytesCnt = 0;
2754    cell->measurements.ulBytesCnt = 0;
2755    cell->cpuOvrLdCntrl.cpuOvrLdIns = 0; /* 0 - No command */
2756    cell->cpuOvrLdCntrl.dlNxtIndxDecNumUeTti = 0;
2757    cell->cpuOvrLdCntrl.ulNxtIndxDecNumUeTti = 0;
2758    for ( idx = 0; idx < 10; idx++ )
2759    {
2760       cell->cpuOvrLdCntrl.maxUeNewTxPerTti[idx] = cellCfg->maxDlUeNewTxPerTti;
2761       cell->cpuOvrLdCntrl.maxUeNewRxPerTti[idx] = cellCfg->maxUlUeNewTxPerTti;
2762    }
2763
2764    /* Invoke scheduler to update scheduler specific information */
2765    ret =  rgSCHUtlRgrCellCfg(cell, cellCfg, errInfo);
2766    if (ret != ROK)
2767    {
2768       DU_LOG("\nERROR  -->  SCH : Rgr cell Config failed at "
2769        "Scheduler for cell ");
2770       rgSCHCfgFreeCellCb(cell);
2771       return RFAILED;
2772    }
2773
2774    /* Invoke DHM to update DHM specific information */
2775    rgSCHDhmRgrCellCfg(cell, cellCfg, errInfo);
2776   
2777
2778    /* Initialize RNTI DB */
2779    ret = rgSCHDbmRntiDbInit(cell, cellCfg->macRnti.startRnti,
2780          cellCfg->macRnti.size);
2781    if (ret != ROK)
2782    {
2783       DU_LOG("\nERROR  -->  SCH : Rgr Cell Config failed at"
2784           " RNTI DB init for cell");
2785       rgSCHCfgFreeCellCb(cell);
2786       return RFAILED;
2787    }
2788
2789    /* Update the cell with recieved configuration */
2790    cell->dlHqCfg  =  cellCfg->dlHqCfg;
2791
2792    DU_LOG("\nINFO  -->  SCH : Config DL HQTX = %d\n",cell->dlHqCfg.maxDlHqTx);
2793
2794    cell->crntSfIdx = 0; 
2795    /* Allocate the subframe allocation information */
2796    if((ret = rgSCHUtlGetSfAlloc(cell)) != ROK)
2797    {
2798       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for "
2799                "cell");
2800       rgSCHCfgFreeCellCb(cell);
2801       return RFAILED;
2802    }
2803    /* Update RACH Related information 
2804     * XXX: Below function yet to be written in RAM
2805     * To store the preambles given in  the configuration for PDCCH order in the
2806     * scheduler cell control block. Initialize the PRACH Mask Index allocated
2807     * for these preambles to invalid values */
2808
2809    cell->crntHqIdx = 0; 
2810    /* Allocate the subframe allocation information */
2811    if((ret = rgSCHUtlGetRlsHqAlloc(cell)) != ROK)
2812    {
2813       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for"
2814                "cell");
2815       rgSCHCfgFreeCellCb(cell);
2816       return RFAILED;
2817    }
2818
2819    /* Associate a pair of upper and lower sapCbs with this cell */
2820    instCb->rgrSap[spId].cell = cell;
2821    instCb->tfuSap[spId].cell = cell;
2822    instCb->rgmSap[spId].cell = cell;
2823    cell->tfuSap = &(instCb->tfuSap[spId]);
2824
2825    /* CaDev Start */
2826       instCb->cells[Idx1] = cell;
2827    /* CaDev End */
2828
2829    /* rg001.201: Added for sending TTI tick to RRM */
2830 #if (defined(RGR_RRM_TICK) || defined(RGR_CQI_REPT))
2831    /* Associate the RGR SAP as well utilized while sending TTI
2832     * Ticks to RGR User. */
2833    cell->rgrSap = &(instCb->rgrSap[spId]);
2834 #endif
2835    cell->rgmSap = &(instCb->rgmSap[spId]);
2836 #ifdef RGR_RRM_TICK
2837    /* Store the periodicity configured */
2838    cell->rrmTtiIndPrd = cellCfg->rrmTtiIndPrd;
2839 #endif
2840
2841 #ifdef LTE_L2_MEAS
2842    cmLListInit(&cell->l2mList);
2843 #endif
2844
2845    if (rgSCHDrxCellCfg(cell,cellCfg) != ROK)
2846    {
2847       DU_LOG("\nERROR  -->  SCH : Drx Memory allocation FAILED for"
2848          " cell");
2849       rgSCHCfgFreeCellCb(cell);
2850       return RFAILED;
2851    }
2852    cell->overLoadBackOffEnab = FALSE;/* Disabling RachOverload by default */
2853    /* Updating CSG Parameters */
2854    cell->minDlResNonCsg = cellCfg->csgParamCfg.minDlResNonCsg;
2855    cell->minUlResNonCsg = cellCfg->csgParamCfg.minUlResNonCsg;
2856
2857    /* Register the cell with MAC */ 
2858    rgSCHUtlGetPstToLyr(&pst, instCb, cell->macInst);
2859    cellRegReq.cellId = cell->cellId;
2860    cellRegReq.cellSapId = spId;
2861 #ifdef LTE_TDD
2862    cellRegReq.maxDlHqProcPerUe = rgSchTddDlNumHarqProcTbl[cellCfg->ulDlCfgIdx];
2863 #else
2864    cellRegReq.maxDlHqProcPerUe = RGSCH_MAX_DL_HQ_PROC;
2865 #endif
2866    RgSchMacCellReg(&pst, &cellRegReq);
2867
2868 #ifdef TENB_STATS
2869    cell->tenbStats = TSL2AllocCellStatsBlk(cell->cellId);
2870    cell->tenbStats->cellId = cell->cellId;
2871 #endif
2872
2873    rgSCHUtlCalcDciSizes(cell);
2874
2875 #ifdef LTE_ADV
2876    /* Initilalization of the list of UE for which this cell is secondary cell*/
2877    cmLListInit(&cell->sCellUeLst);
2878 #endif 
2879
2880
2881 #ifdef LTE_ADV
2882    ret = rgSCHLaaSCellCbInit(cell, cellCfg);
2883    if (ret != ROK)
2884    {
2885       DU_LOG("\nERROR  -->  SCH : Rgr Cell Config failed at"
2886           " Initializing the LAA Cell Control Cb");
2887       rgSCHCfgFreeCellCb(cell);
2888       return RFAILED;
2889    }
2890    cell->isPucchFormat3Sptd = cellCfg->isPucchFormat3Sptd;
2891    DU_LOG("\nINFO  -->  SCH : Format 3 is Enabled");
2892    DU_LOG ("\n Format 3 is Enabled for CELL:%d",cell->cellId);
2893 #endif
2894
2895
2896 #ifdef EMTC_ENABLE
2897
2898         if(cell->emtcEnable)
2899         {       
2900           if (rgSCHCfgEmtcCellCfg(cell,&(cellCfg->emtcCellCfg)) != ROK)
2901           {
2902                  DU_LOG("\nERROR  -->  SCH : EMTC Config Failed cell");
2903                  return RFAILED;
2904           }
2905         }
2906 #endif
2907
2908 #ifdef RG_5GTF
2909    ret = rgSCH5gtfCellCfg(cell, cellCfg);
2910    if (ret != ROK)
2911    {
2912       DU_LOG("\nERROR  -->  SCH : 5GTF Rgr Cell Config failed");
2913       rgSCHCfgFreeCellCb(cell);
2914       return RFAILED;
2915    }
2916 #endif
2917    errInfo->errCause = RGSCHERR_NONE;
2918    return ROK;
2919 }  /* rgSCHCfgRgrCellCfg */
2920
2921 /**
2922  * @brief Handler for the UE configuration request from RRC to MAC.
2923  *
2924  * @details
2925  *
2926  *     Function : rgSCHCfgRgrUeCfg
2927  *
2928  *     Processing Steps:
2929  *      - Allocate and create UE control block.
2930  *      - Update UE control block with the values recieved in the
2931  *        configuration.
2932  *      - Invoke RAM, SCH, UHM and DHM with created UE control block, to
2933  *        update random access, scheduler, uplink harq and downlink harq
2934  *        specific information respectively.
2935  *      - If successful, add the control block to hash list of UEs for the cell
2936  *        else Rollback and FAIL.
2937  *
2938  *  @param[in]  RgSchCellCb  *cell
2939  *  @param[in]  RgrUeCfg     *ueCfg
2940  *  @param[out] RgSchErrInfo *errInfo
2941  *  @return  S16
2942  *      -# ROK
2943  *      -# RFAILED
2944  **/
2945 S16 rgSCHCfgRgrUeCfg
2946 (
2947 RgSchCellCb  *cell,
2948 RgrUeCfg     *ueCfg,
2949 RgSchErrInfo *errInfo
2950 )
2951 {
2952    S16          ret;
2953    RgSchRaCb    *raCb=NULLP;
2954    RgSchUeCb    *ue = NULLP;
2955    Inst         inst = cell->instIdx;
2956    uint32_t          lcgCnt;
2957    RgSchDlHqEnt *hqEnt = NULLP;
2958 #ifdef LTE_TDD
2959    uint8_t           ulDlCfgIdx = cell->ulDlCfgIdx;
2960    uint8_t           maxSubframes ;
2961    uint8_t           maxDlSubframes;
2962 #endif
2963    uint32_t          idx = 0;  
2964 #ifdef TFU_UPGRADE
2965    RgSchUePCqiCb *cqiCb = NULLP;
2966 #endif
2967
2968   do {
2969      errInfo->errCause = RGSCHERR_CFG_RGR_UE_CFG;
2970      /* RACHO : Check for raCb only if preamble Id not provded */
2971 #ifndef PRE_DEF_UE_CTX
2972      if (ueCfg->dedPreambleId.pres == NOTPRSNT)
2973      {
2974         if ((raCb = rgSCHDbmGetRaCb(cell, ueCfg->crnti)) == NULLP)
2975         {
2976            DU_LOG("\nERROR  -->  SCH : No RaCb exists for"
2977                     "CRNTI:%d ",ueCfg->crnti);
2978            break;
2979         }
2980      }
2981 #endif
2982
2983      /* Allocate the Ue control block */
2984      if (((rgSCHUtlAllocSBuf(inst, (Data **)&ue, sizeof(RgSchUeCb))) != ROK) ||
2985             ((uint8_t *)ue == NULLP))
2986      {
2987         DU_LOG("\nERROR  -->  SCH : Memory allocation"
2988            " FAILED for CRNTI:%d", ueCfg->crnti);
2989         break;
2990      }
2991
2992      /* Inititialize Ue control block */
2993      ue->ueId = ueCfg->crnti;
2994      ue->cell = cell;
2995      /*ccpu00117778- Initialize Transmission Indices upon UE CB creation */
2996 #ifdef LA
2997    ue->lastRprdAckNackTime.sfn = cell->crntTime.sfn;
2998    ue->lastRprdAckNackTime.subframe = cell->crntTime.slot;
2999    ue->ueIdle = FALSE; 
3000 #endif
3001
3002    /* Allocate the Ue control block */
3003    if (((rgSCHUtlAllocSBuf(inst, (Data **)&(ue->cellInfo[RGSCH_PCELL_INDEX]),
3004                   sizeof(RgSchUeCellInfo))) != ROK))
3005    {
3006 #ifndef ALIGN_64BIT
3007       DU_LOG("\nERROR  -->  SCH : [%lu]SCellIdx :Memomy allocation "
3008                "Failed while Adding SCell Information\n", idx);
3009 #else
3010       DU_LOG("\nERROR  -->  SCH : [%u]SCellIdx :Memomy allocation "
3011                "Failed while Adding SCell Information\n", idx);
3012 #endif
3013       return RFAILED;
3014    }
3015
3016    ue->cellIdToCellIdxMap[RG_SCH_CELLINDEX(cell)] = RGSCH_PCELL_INDEX;
3017    ue->cellInfo[RGSCH_PCELL_INDEX]->cell = cell;
3018    ue->cellInfo[RGSCH_PCELL_INDEX]->ue = ue;
3019 #ifdef LTE_ADV
3020    ue->cellInfo[RGSCH_PCELL_INDEX]->sCellState = RG_SCH_SCELL_ACTIVE;
3021    ue->cellInfo[RGSCH_PCELL_INDEX]->sCellIdx = RGSCH_PCELL_INDEX;
3022    ue->cellInfo[RGSCH_PCELL_INDEX]->sCellId = cell->cellId;
3023
3024    if (ROK != rgSCHLaaInitDlRbAllocCb(cell, 
3025             &ue->cellInfo[RGSCH_PCELL_INDEX]->dlAllocCb))
3026    {
3027       return RFAILED;
3028    }
3029 #endif
3030 #ifdef TFU_UPGRADE
3031      cqiCb = RG_SCH_GET_UE_CELL_CQI_CB(ue,cell);
3032      cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
3033      cqiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
3034      ue->srsCb.nSrsTrIdx = RG_SCH_INVALID_IDX;
3035      ue->srCb.nSrTrIdx = RG_SCH_INVALID_IDX;
3036 #endif
3037    /* LTE_ADV_FLAG_REMOVED_START */
3038    /* While doing UE configuration for SFR at SCH, by default 
3039     * CC UE power is configured as LOW */
3040    ue->lteAdvUeCb.isCCUePHigh = FALSE;
3041    /* LTE_ADV_FLAG_REMOVED_END */
3042
3043      /* Initialize the lists of the UE */
3044      if((rgSCHDbmInitUe(ue)) != ROK)
3045      {
3046         DU_LOG("\nERROR  -->  SCH : DBM initialization "
3047            "failed for CRNTI:%d", ueCfg->crnti);
3048         break;
3049      }
3050 #ifdef EMTC_ENABLE
3051      if(raCb != NULLP)
3052      {
3053         if(TRUE == raCb->isEmtcRaCb)
3054         { 
3055            ue->isEmtcUe = TRUE;
3056            if (rgSCHUtlUpdUeEmtcInfo(cell, ueCfg, ue) != ROK)
3057            {
3058               DU_LOG("\nERROR  -->  SCH : EMTC UE Cfg"
3059                     "failed for CRNTI:%d", ueCfg->crnti);
3060               break;
3061            }
3062         }
3063      } 
3064 #endif
3065
3066      /* Initialize scheduler related information for UE */
3067      if(rgSCHUtlRgrUeCfg(cell, ue, ueCfg, errInfo) != ROK)
3068      {
3069         DU_LOG("\nERROR  -->  SCH : Scheduler handling "
3070                  "failed in config for CRNTI:%d", ueCfg->crnti);
3071         break;
3072      }
3073
3074      ret = rgSCHUhmHqEntInit(cell, ue);
3075      if (ret != ROK)
3076      {
3077         DU_LOG("\nERROR  -->  SCH : UHM HARQ Ent Init "
3078            "Failed for CRNTI:%d", ueCfg->crnti);
3079         break;
3080      }
3081
3082      /* Initialize RAM related information for UE 
3083       * RACHO: if preamble Id is present in ueCfg then raCb will be NULL
3084       * so rgSCHRamRgrUeCfg should take care of creating raCb */
3085    if ((ueCfg->dedPreambleId.pres == NOTPRSNT) && (NULLP != raCb) )
3086      {
3087         if((rgSCHRamRgrUeCfg(cell, ue, raCb, errInfo)) != ROK)
3088         {
3089            DU_LOG("\nERROR  -->  SCH : Random access "
3090               "handling config failed for CRNTI:%d", ueCfg->crnti);
3091            break;
3092         }
3093      }
3094      else /* if HO Ue */
3095      {
3096         RG_SCH_CMN_GET_UE_HQE(ue, cell) = rgSCHDhmHqEntInit(cell);
3097         hqEnt = RG_SCH_CMN_GET_UE_HQE(ue, cell);
3098         if (hqEnt == NULLP)
3099         {
3100            DU_LOG("\nERROR  -->  SCH : Hq Entity Initialization "
3101                     "failed in config for CRNTI:%d", ueCfg->crnti);
3102            break;
3103         }
3104 #ifdef EMTC_ENABLE
3105         rgSCHEmtcHqPAlloc(cell, hqEnt);
3106 #endif
3107         hqEnt->ue = ue;
3108         /* Fix : syed Assign hqEnt to UE only if msg4 is done */
3109
3110         rgSCHCmnDlInitHqEnt(cell, hqEnt);
3111
3112         /* For Hand-In UE Request Aper CQI report
3113          * immediately */
3114         if (ueCfg->ueDlCqiCfg.aprdCqiCfg.pres)
3115         {
3116            /* Set APCQI for Pcell only*/
3117            ue->dl.reqForCqi = RG_SCH_APCQI_SERVING_CC;
3118         }
3119      }
3120      /* CA dev Start */
3121 #ifdef LTE_TDD
3122      maxDlSubframes = rgSchTddNumDlSubfrmTbl[ulDlCfgIdx][RGSCH_NUM_SUB_FRAMES-1];
3123      maxSubframes = 2 * maxDlSubframes;
3124      ue->dl.numHqDlSfInfo = maxSubframes;
3125      rgSCHUtlAllocSBuf(cell->instIdx,
3126            (Data **)&ue->dl.dlSfHqInfo, sizeof(RgSchDlHqInfo) * (ue->dl.numHqDlSfInfo));
3127
3128 #else
3129      ue->dl.numHqDlSfInfo = RGSCH_NUM_DL_slotS;
3130 #endif
3131 #ifndef RG_5GTF 
3132      for (idx =0;idx < ue->dl.numHqDlSfInfo; idx++)
3133      {
3134         cmLListInit(&ue->dl.dlSfHqInfo[idx].hqPLst);
3135         ue->dl.dlSfHqInfo[idx].dlSfUeLnk.node = NULLP;
3136
3137      } 
3138 #else
3139      {
3140         uint8_t cellIdx=0;
3141         for (cellIdx = 0;cellIdx < MAX_5GTF_CELL ; cellIdx++)
3142         {
3143            for (idx =0;idx < ue->dl.numHqDlSfInfo; idx++)
3144            {
3145               cmLListInit(&ue->dl.dlSfHqInfo[cellIdx][idx].hqPLst);
3146               ue->dl.dlSfHqInfo[cellIdx][idx].dlSfUeLnk.node = NULLP;
3147            }
3148         }
3149      }
3150 #endif
3151 #ifdef LTE_ADV
3152      rgSCHLaaInitDlHqInfo(cell, ue);
3153 #endif
3154      /* CA dev End */
3155
3156      /* Initialize lcgIds to Invalid */
3157      for (lcgCnt = 0; lcgCnt < RGSCH_MAX_LCG_PER_UE; lcgCnt++)
3158      {
3159         ue->ul.lcgArr[lcgCnt].lcgId = RGSCH_INVALID_LCG_ID;
3160      }
3161      if(raCb != NULLP)
3162      {
3163         rgSCHCfgRgrUePhrMsg3(cell,raCb,ue,errInfo);
3164         /* Moved this code out of rgSCHCfgRgrUePhrMsg3()
3165          * as it was not the appropriate place to 
3166          * do this. */
3167         if (raCb->raState == RGSCH_RA_MSG4_DONE)
3168         {
3169            DU_LOG("\nERROR  -->  SCH : RNTI:%d RaCb deleted as Msg4 transmission is done",
3170                  raCb->tmpCrnti);
3171            rgSCHRamDelRaCb(cell, raCb, FALSE);
3172         }
3173      }
3174      /* Initialize uplink HARQ related information for UE */
3175      rgSCHUhmRgrUeCfg(cell, ue, ueCfg);
3176      cmInitTimers(&ue->bsrTmr, 1);
3177 #ifdef RGR_V1
3178      /* Added periodic BSR timer */
3179      cmInitTimers(&ue->bsrTmr, 1);
3180
3181      /* Fix - Added proper configuration from U-ARM */
3182      if(ueCfg->ueBsrTmrCfg.isPrdBsrTmrPres == TRUE)
3183      {
3184         ue->ul.bsrTmrCfg.isPrdBsrTmrPres = TRUE;
3185         ue->ul.bsrTmrCfg.prdBsrTmr       = ueCfg->ueBsrTmrCfg.prdBsrTmr;
3186         ue->ul.bsrTmrCfg.retxBsrTmr      = ueCfg->ueBsrTmrCfg.retxBsrTmr;
3187      }
3188     
3189 #endif
3190      /* Initialize downlink HARQ related information for UE */
3191      rgSCHDhmRgrUeCfg(cell, ue, ueCfg, errInfo);
3192
3193      /* Initialize MeasureGap and Acknack Rep Information for UE */
3194      if((rgSCHMeasGapANRepUeCfg(cell, ue, ueCfg)) != ROK)
3195      {
3196         DU_LOG("\nERROR  -->  SCH : Measurement Gap and"
3197                  " AckNack Rep failed in Config for CRNTI:%d", ueCfg->crnti);
3198         break;
3199      }
3200
3201
3202 #ifdef LTE_TDD
3203      if((rgSCHUtlAllocUeANFdbkInfo(ue,RGSCH_PCELL_INDEX)) != ROK)
3204      {
3205         DU_LOG("\nERROR  -->  SCH : Memomy allocation "
3206                  "Failed while UE related Ack Nack Information for CRNTI:%d",
3207                  ueCfg->crnti);
3208         break;
3209      }
3210      ue->dl.ackNackMode = ueCfg->ackNackModeEnum;
3211 #endif /* LTE_TDD */
3212
3213      /* Insert Ue */
3214      rgSCHDbmInsUeCb(cell, ue);
3215
3216 #ifdef TFU_UPGRADE
3217      /*  Int ialize APeriodic CQI/PMI/RI Information for UE */
3218
3219       DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgRgrUeCfg CellID=%d UeId =%d AcqiCfg Pres =%d", cell->cellId, ue->ueId,\
3220       ueCfg->ueDlCqiCfg.aprdCqiCfg.pres);
3221
3222       /*Store Trigger Set Bit String to UE */
3223       
3224       ret = rgSCHCfgACqiUeCfg(cell,ue, (RG_SCH_CMN_GET_ACQICB(ue,cell)),ue->mimoInfo.txMode,
3225            &ueCfg->ueDlCqiCfg.aprdCqiCfg, ue->ueCatEnum);
3226
3227      ue->cqiRiWritIdx = 0;
3228      ue->cqiRiReadIdx = 0;
3229      /*   Initialize Periodic CQI/PMI, RI Information for UE  */
3230      ret = rgSCHCfgPCqiUeCfg(cell, ue, &ueCfg->ueDlCqiCfg.prdCqiCfg, 
3231            ue->ueCatEnum);
3232
3233      /*   Initialize UL SRS Information for UE  */
3234      ret = rgSCHCfgSrsUeCfg(cell, ue, &ueCfg->srsCfg);
3235
3236      /*   Initialize SR Information for UE  */
3237      ret = rgSCHCfgSrUeCfg(cell, ue, &ueCfg->srCfg);
3238 #endif 
3239
3240 #ifdef LTEMAC_HDFDD
3241      if (rgSCHHdFddUeCfg(cell, ue, ueCfg->isHdFddEnbld) != ROK)
3242      {
3243         DU_LOG("\nERROR  -->  SCH : Could not do HD-FDD config for CRNTI:%d",ueCfg->crnti);
3244         break;
3245      }
3246
3247 #endif /* LTEMAC_HDFDD */
3248      /* ccpu00117452 - MOD - Changed macro name from
3249         RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
3250 #ifdef RGR_CQI_REPT
3251      ue->cqiReptCfgInfo.numColltdCqiRept =
3252         ueCfg->ueCqiReptCfg.numColltdCqiRept;
3253 #endif /* End of RGR_CQI_REPT */
3254 #ifdef TFU_UPGRADE
3255      RG_SCH_CMN_GET_PA(ue,cell).pres = FALSE;
3256      if (RG_SCH_UE_CFG_ISPAPRSNT(ueCfg->uePdschDedCfg.uepACfg))
3257      {
3258         RG_SCH_CMN_GET_PA(ue,cell).pres = TRUE;
3259         RG_SCH_CMN_GET_PA(ue,cell).val = ueCfg->uePdschDedCfg.uepACfg.pA;
3260      }
3261 #endif
3262      ue->isDrxEnabled = ueCfg->ueDrxCfg.isDrxEnabled;
3263
3264      if ( ue->isDrxEnabled )
3265      {
3266         if((rgSCHDrxUeCfg(cell,ue,ueCfg)) != ROK )
3267         {
3268            DU_LOG("\nERROR  -->  SCH : DRX configuration failed");
3269            break;
3270         }
3271      }
3272
3273      /* LTE_ADV_FLAG_REMOVED_START */
3274      if ((cell->lteAdvCb.sfrCfg.status == RGR_ENABLE) ||    \
3275         (cell->lteAdvCb.absCfg.status == RGR_ENABLE))
3276      {
3277         ue->lteAdvUeCb.rgrLteAdvUeCfg = ueCfg->ueLteAdvCfg;
3278      }   
3279      /* LTE_ADV_FLAG_REMOVED_END */
3280
3281 #ifdef TENB_STATS
3282      ue->tenbStats = TSL2AllocUeStatsBlk(ue->ueId);
3283      ue->tenbStats->stats.rnti = ue->ueId;
3284 #endif
3285 #ifdef LTE_ADV
3286      /*Update A Value for PCell TBs*/
3287      ue->f1bCsAVal = rgSCHUtlGetMaxTbSupp(ue->mimoInfo.txMode); 
3288      DU_LOG("\nERROR  -->  SCH :  UeCfg A value is %d\n",ue->f1bCsAVal);
3289 #endif
3290      errInfo->errCause = RGSCHERR_NONE;
3291
3292      ue->accessStratumRls = ueCfg->accessStratumRls;
3293      if (ue->numSCells > 0)
3294      {
3295         /* 2 bit CSI */
3296         rgSCHUtlUpdUeDciSize(cell, ue, TRUE);
3297      }
3298      else
3299      {
3300         /* 1 bit CSI Access Stratum Release Change */
3301         rgSCHUtlUpdUeDciSize(cell, ue, FALSE);
3302      }
3303
3304      return ROK;
3305   }while(0);
3306
3307   if (ue)
3308   {
3309      rgSCHCfgFreeUeCb(cell, ue);
3310   }
3311   return RFAILED;
3312 }  /* rgSCHCfgRgrUeCfg */
3313
3314 /**
3315  * @brief Handler for PHR for MSG3.
3316  *
3317  * @details
3318  *
3319  *     Function : rgSCHCfgRgrUePhrMsg3
3320  *
3321  *     Processing Steps:
3322  *       Handle PHR related config for MSG3
3323  *
3324  *  @param[in]  RgSchCellCb  *cell
3325  *  @param[in]  RgrUeCb     *ueCb
3326  *  @param[in]  RgSchRaCb    *raCb
3327  *  @param[out] RgSchErrInfo *errInfo
3328  **/
3329 static Void rgSCHCfgRgrUePhrMsg3
3330 (
3331 RgSchCellCb  *cell,
3332 RgSchRaCb    *raCb,
3333 RgSchUeCb    *ue,
3334 RgSchErrInfo *errInfo
3335 )
3336 {
3337
3338    /* Record msg3 allocation in the UE */
3339    rgSCHUtlRecMsg3Alloc(cell, ue, raCb);
3340
3341    /* If raCb received PHR, update scheduler */
3342    if(raCb->phr.pres == TRUE)
3343    {
3344       ue->macCeRptTime = raCb->msg3AllocTime; 
3345       rgSCHUtlUpdPhr(cell, ue, raCb->phr.val, errInfo);
3346    }
3347
3348    return;
3349 }
3350
3351 /**
3352  *
3353  * @details
3354  *
3355  *     Function : rgSCHDynCfiReCfg
3356  *
3357  *  @param[in]  RgSchCellCb   *cell
3358  *              Bool          isDynCfiEnb 
3359  *  @return  S16
3360  *      -# ROK
3361  *      -# RFAILED
3362  **/
3363 Void rgSCHDynCfiReCfg
3364 (
3365 RgSchCellCb   *cell,
3366 Bool          isDynCfiEnb
3367 )
3368 {            
3369    uint8_t                idx;
3370    RgSchCmnDlCell    *cellSchDl = RG_SCH_CMN_GET_DL_CELL(cell);
3371
3372    if(isDynCfiEnb)
3373    {
3374       cell->dynCfiCb.ttiCnt = 0;
3375       cellSchDl->newCfi = cellSchDl->currCfi;
3376    }   
3377    else
3378    {
3379       /* Resetting the parameters*/
3380       cell->dynCfiCb.cceFailCnt          = 0;
3381       cell->dynCfiCb.cceFailSum          = 0;
3382       cell->dynCfiCb.prevCceFailIdx      = 0;
3383
3384       for(idx = 0; idx < cell->dynCfiCb.numFailSamples; idx++)
3385       {
3386          cell->dynCfiCb.cceFailSamples[idx] = 0;
3387       }   
3388
3389       cell->dynCfiCb.cceUsed             = 0;
3390       cell->dynCfiCb.lowCceCnt           = 0;
3391       cell->dynCfiCb.ttiCnt = 0;
3392    }   
3393 }
3394 /**
3395  * @brief Handler for the cell reconfiguration request from RRM to MAC.
3396  *
3397  * @details
3398  *
3399  *     Function : rgSCHCfgRgrCellRecfg
3400  *
3401  *     Processing Steps:
3402  *      - Invoke SCH with cell control block to update
3403  *        scheduler specific information.
3404  *      - Update cell control block with the values recieved in the
3405  *        configuration.
3406  *      - If successful, return ROK else RFAILED.
3407  *
3408  *  @param[in]  RgSchCellCb   *cell
3409  *  @param[in]  RgrCellRecfg  *cellRecfg
3410  *  @param[out] RgSchErrInfo  *errInfo
3411  *  @return  S16
3412  *      -# ROK
3413  *      -# RFAILED
3414  **/
3415 S16 rgSCHCfgRgrCellRecfg
3416 (
3417 RgSchCellCb   *cell,
3418 RgrCellRecfg  *cellRecfg,
3419 RgSchErrInfo  *errInfo
3420 )
3421 {
3422    S16      ret;
3423    Inst    inst = cell->instIdx;
3424 /* LTE_ADV_FLAG_REMOVED_START */
3425    uint8_t      i = 0;
3426    uint16_t     len; /* dsfr_pal_fixes ** 21-March-2013 ** SKS */
3427 /* LTE_ADV_FLAG_REMOVED_END */
3428    
3429    errInfo->errCause = RGSCHERR_CFG_RGR_CELL_RECFG;
3430    
3431    /* Invoke scheduler to update scheduler specific information */
3432    ret =  rgSCHUtlRgrCellRecfg(cell, cellRecfg, errInfo);
3433    if (ret != ROK)
3434    {
3435      DU_LOG("\nERROR  -->  SCH : RGR Cell re-configuration failed "
3436           "at Scheduler ");
3437       return RFAILED;
3438    }
3439    
3440    /* Invoke DHM to update DHM specific information */
3441    rgSCHDhmRgrCellRecfg(cell, cellRecfg, errInfo);
3442
3443       /* PUCCH Reconfiguration */
3444    if (cellRecfg->recfgTypes & RGR_CELL_PUCCH_RECFG)
3445    {
3446       cell->pucchCfg = cellRecfg->pucchRecfg;
3447    }
3448  
3449    /* SRS Reconfiguration */
3450    if (cellRecfg->recfgTypes & RGR_CELL_SRS_RECFG)
3451    {
3452       cell->srsCfg.isSrsCfgPres = cellRecfg->srsRecfg.isSrsCfgSetup;
3453       if(cellRecfg->srsRecfg.isSrsCfgSetup)
3454       {
3455          cell->srsCfg.srsCfgPrdEnum = cellRecfg->srsRecfg.srsCfgPrdEnum;
3456          cell->srsCfg.srsBwEnum = cellRecfg->srsRecfg.srsBwEnum;
3457          cell->srsCfg.srsTxOffst =
3458             rgSrsTxOffstTbl[cellRecfg->srsRecfg.srsSubFrameCfg];
3459          /*ccpu00116923 - ADD - Srs Present support */
3460 #ifdef TFU_UPGRADE
3461          cell->srsCfg.srsSubFrameCfg = cellRecfg->srsRecfg.srsSubFrameCfg;
3462 #endif
3463       }
3464    }
3465
3466    /* RACH Reconfiguration */
3467    if (cellRecfg->recfgTypes & RGR_CELL_RACH_RECFG)
3468    {
3469       cell->rachCfg = cellRecfg->rachRecfg;
3470    }
3471
3472    /* ccpu00132256:MOD: Moved this assignment from Validation to here.*/
3473    if (cellRecfg->recfgTypes & RGR_CELL_TMRS_RECFG)
3474    {
3475       cell->t300TmrVal = cellRecfg->t300TmrVal;
3476    }
3477 #ifdef RGR_SI_SCH
3478    /* SI Reconfiguration */
3479    if (cellRecfg->recfgTypes & RGR_CELL_SI_RECFG)
3480    {
3481       /*Set the specified SI configuration. */
3482       cell->siCb.newSiCfg = cellRecfg->siReCfg;
3483       /* Set the Bit mask for SI re-configuration */
3484       cell->siCb.siBitMask |= RGSCH_SI_SICFG_UPD; 
3485 #ifdef EMTC_ENABLE
3486       if(cell->emtcEnable)
3487       {
3488       rgSchEmtcUpdSiCfg(cell, cellRecfg);
3489       }
3490 #endif
3491    }
3492 #endif /*RGR_SI_SCH */
3493
3494    /* Overload RACH Control changes */
3495    if (cellRecfg->recfgTypes & RGR_CELL_CNTRL_CMD_RECFG)
3496    {
3497       if (cellRecfg->cntrlCmdCfg.cmdType == RGR_CNTRL_CMD_RACH_OVRLD)
3498       {
3499          cell->overLoadBackOffEnab = cellRecfg->cntrlCmdCfg.cmdDesc.rachOvrLd.backOffEnb;
3500          cell->overLoadBackOffval = cellRecfg->cntrlCmdCfg.cmdDesc.rachOvrLd.backOffVal;
3501       }
3502       else if (cellRecfg->cntrlCmdCfg.cmdType == RGR_CNTRL_CMD_CPU_OVRLD)
3503       {
3504          if( ROK != rgSCHUtlResetCpuOvrLdState(cell, cellRecfg->cntrlCmdCfg.cmdDesc.\
3505                                           cpuOvrLd.instruction))
3506          {
3507             DU_LOG("\nERROR  -->  SCH : Invalid CPU OvrLd Ins %d for cell", 
3508                cellRecfg->cntrlCmdCfg.cmdDesc.cpuOvrLd.instruction);
3509             return RFAILED;
3510          }
3511       }
3512    }
3513
3514 /* LTE_ADV_FLAG_REMOVED_START */
3515    if (cellRecfg->recfgTypes & RGR_CELL_LTEA_FEATURE_RECFG)
3516    {
3517       if(cellRecfg->rgrLteAdvCfg.pres & RGR_ABS)
3518       {
3519          cell->lteAdvCb.absCfg =
3520             cellRecfg->rgrLteAdvCfg.absCfg;         
3521       }
3522       if(cellRecfg->rgrLteAdvCfg.pres & RGR_SFR)
3523       {
3524          memcpy(&cell->lteAdvCb.sfrCfg, &cellRecfg->rgrLteAdvCfg.sfrCfg,
3525                sizeof(RgrSfrConfig));
3526          /* dsfr_pal_fixes ** 21-March-2013 ** SKS */
3527          if (cellRecfg->rgrLteAdvCfg.sfrCfg.status == RGR_ENABLE)
3528          {
3529             for(i = 0; i < RGSCH_NUM_DL_slotS; i++)
3530             {
3531                /*initialise the pools of CC and CE*/
3532                if(rgSchSFRTotalPoolInit(cell, cell->subFrms[i]))
3533                {
3534                   return RFAILED;
3535                }
3536             }
3537          }
3538          else
3539          {
3540             for(i = 0; i < RGSCH_NUM_DL_slotS; i++)
3541             {
3542                /*initialise the pools of CC and CE*/
3543                rgSchSFRTotalPoolFree(&cell->subFrms[i]->sfrTotalPoolInfo, cell);
3544             }
3545
3546             if (cell->lteAdvCb.dsfrCfg.status == RGR_ENABLE)
3547             {
3548                /* releasing rntp info val from each subframe */ 
3549                for(i = 0; i < RGSCH_NUM_DL_slotS; i++)
3550                {
3551                   rgSchDSFRRntpInfoFree(&cell->subFrms[i]->rntpInfo, cell, cell->bwCfg.dlTotalBw);
3552                }
3553
3554                /* releasing RNTP Aggregation Info from CellCb*/
3555                rgSchDSFRRntpInfoFree(&cell->rntpAggrInfo, cell, cell->bwCfg.dlTotalBw); 
3556
3557                cell->lteAdvCb.dsfrCfg.status = RGR_DISABLE;
3558             }
3559          }
3560       }
3561       /* dsfr_pal_fixes ** 21-March-2013 ** SKS ** Start */
3562       if(cellRecfg->rgrLteAdvCfg.pres & RGR_DSFR)
3563       {
3564          cell->lteAdvCb.dsfrCfg =
3565             cellRecfg->rgrLteAdvCfg.dsfrCfg;
3566          if (cell->lteAdvCb.dsfrCfg.status == RGR_ENABLE)
3567          {
3568             for(i = 0; i < RGSCH_NUM_DL_slotS; i++)
3569             {
3570                /*initialise the pools of CC and CE*/
3571                if(rgSchDSFRRntpInfoInit(&cell->subFrms[i]->rntpInfo,cell,cell->bwCfg.dlTotalBw))
3572                {
3573                   return RFAILED;
3574                }
3575             }
3576             /*Calculating the length of RNTP array based on Dl Bandwidth */
3577             len = (uint16_t)((cell->bwCfg.dlTotalBw % 8 == 0) ? (cell->bwCfg.dlTotalBw/8) : (cell->bwCfg.dlTotalBw/8 + 1)); /* KW fix for LTE_ADV */
3578             if(cell->rntpAggrInfo.pres == NOTPRSNT)
3579             {   
3580                if((rgSCHUtlAllocSBuf(inst, (Data**)&(cell->rntpAggrInfo.val),
3581                            (len * sizeof(uint8_t)))) != ROK)
3582                {
3583                   DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for RNTP Alloc");
3584                   return RFAILED;
3585                }
3586                cell->rntpAggrInfo.pres = PRSNT_NODEF;
3587                cell->rntpAggrInfo.len  = len; 
3588             }
3589          }
3590          /* in case if DSFR is disabled, need to free RNTP pattern val*/
3591          else
3592          {
3593             /* releasing rntp info val from each subframe */ 
3594             for(i = 0; i < RGSCH_NUM_DL_slotS; i++)
3595             {
3596                rgSchDSFRRntpInfoFree(&cell->subFrms[i]->rntpInfo, cell, cell->bwCfg.dlTotalBw);
3597             }
3598
3599             /* releasing RNTP Aggregation Info from CellCb*/
3600             rgSchDSFRRntpInfoFree(&cell->rntpAggrInfo, cell, cell->bwCfg.dlTotalBw);
3601          }   
3602       }
3603       /* dsfr_pal_fixes ** 21-March-2013 ** SKS ** End */
3604    }
3605 /* LTE_ADV_FLAG_REMOVED_END */
3606
3607    /* Dynamic CFI cell Reconfiguration */
3608    if(cellRecfg->recfgTypes & RGR_CELL_DYN_CFI_RECFG)
3609    {
3610       if(cell->dynCfiCb.isDynCfiEnb != cellRecfg->isDynCfiEnb)
3611       {
3612          if(cell->dynCfiCb.switchOvrInProgress)  
3613          {
3614             cell->dynCfiCb.dynCfiRecfgPend = TRUE;
3615          }  
3616          else
3617          { 
3618             cell->dynCfiCb.isDynCfiEnb = cellRecfg->isDynCfiEnb;
3619             rgSCHDynCfiReCfg(cell, cellRecfg->isDynCfiEnb); 
3620          }
3621       }   
3622       else
3623       {
3624          /* To hanlde the case where reconfiguration comes for disabling 
3625           * and then enabling before switchover period expires */
3626          cell->dynCfiCb.dynCfiRecfgPend = FALSE;
3627       }   
3628    }   
3629    /* Dynamic config of AUTO chnage flag */
3630    if(cellRecfg->recfgTypes & RGR_CELL_AUTO_CFG_MODE_RECFG)
3631    {
3632       if(cell->isAutoCfgModeEnb != cellRecfg->isAutoCfgModeEnb)
3633       {
3634          cell->isAutoCfgModeEnb = cellRecfg->isAutoCfgModeEnb;
3635       }
3636    }
3637    {
3638      if(cell->isAutoCfgModeEnb)
3639      {
3640         DU_LOG("\nINFO  -->  SCH : Auto Mode Cfg enabled durint cell recfg\n");
3641      }
3642    }
3643
3644    if (cellRecfg->recfgTypes & RGR_CELL_CSG_PARAM_RECFG)
3645    {
3646       cell->minDlResNonCsg = cellRecfg->csgParamCfg.minDlResNonCsg;
3647       cell->minUlResNonCsg = cellRecfg->csgParamCfg.minUlResNonCsg;
3648    }
3649   
3650    errInfo->errCause = RGSCHERR_NONE;
3651    return ROK;
3652 }  /* rgSCHCfgRgrCellRecfg */
3653
3654 /**
3655  * @brief Handler for the UE reconfiguration request from RRC to MAC.
3656  *
3657  * @details
3658  *
3659  *     Function : rgSCHCfgRgrUeRecfgRntiChg
3660  *
3661  *     Processing Steps:
3662  *      - If rnti changes,
3663  *        - Invoke RAM for UE reconfiguration.
3664  *        - Delete old UE from the list.
3665  *        - Update the new rnti and re-insert the UE in the list.
3666  *      - If successful, return ROK else RFAILED.
3667  *
3668  *  @param[in]  RgSchCellCb  *cell
3669  *  @param[in]  RgSchUeCb    *ue
3670  *  @param[in]  RgrUeRecfg   *ueRecfg
3671  *  @param[out] RgSchErrInfo *errInfo
3672  *  @return  S16
3673  *      -# ROK
3674  *      -# RFAILED
3675  **/
3676 static S16 rgSCHCfgRgrUeRecfgRntiChg
3677 (
3678 RgSchCellCb    *cell,
3679 RgSchUeCb      *ue,
3680 RgrUeRecfg     *ueRecfg,
3681 RgSchErrInfo   *errInfo
3682 )
3683 {
3684 #ifdef LTE_ADV
3685    uint8_t          sCellIdx;
3686 #endif
3687    S16          ret;
3688    RgSchRaCb    *raCb;
3689    RgSchRaCb    *oldRaCb;
3690    RgSchDlHqEnt **hqEnt = &(RG_SCH_CMN_GET_UE_HQE(ue, cell));
3691    uint8_t           idx;
3692     
3693    /* Handle CRNTI change in reconfiguration */
3694    if (ueRecfg->oldCrnti != ueRecfg->newCrnti)
3695    {
3696       RgSchRntiLnk   *oldRntiLnk=NULLP;
3697       CmLteRnti      oldRnti = 0;
3698       if ((raCb = rgSCHDbmGetRaCb(cell, ueRecfg->newCrnti)) == NULLP)
3699       {
3700          DU_LOG("\nERROR  -->  SCH : UEID:No RaCb exists while"
3701               "Reconfig for OLD CRNTI:%d NEW CRNTI:%d",ueRecfg->oldCrnti,ueRecfg->newCrnti);
3702          return RFAILED;
3703       }
3704
3705       /* rntiLnk does not exist for a HandIn UE. Hence this check. */
3706       if(ue->rntiLnk)
3707       {
3708          oldRntiLnk = ue->rntiLnk;
3709       }
3710       else
3711       {
3712          /* Fix : syed HO UE does not have a valid ue->rntiLnk */
3713          oldRnti = ue->ueId;
3714       }
3715      
3716       DU_LOG("\nINFO  -->  SCH : UE ID CHNG OLD %d new %d",ueRecfg->oldCrnti, ueRecfg->newCrnti); 
3717
3718       /* Fix : syed Deleting Old DL HqEnt. It would be assigned after
3719        * reest RACH(msg4) is completed. */
3720       rgSCHDhmDelHqEnt(cell, hqEnt);
3721
3722       /* Initialize RAM related information for UE */
3723       ret = rgSCHRamRgrUeCfg(cell, ue, raCb, errInfo);
3724       if (ret != ROK)
3725       {
3726          DU_LOG("\nERROR  -->  SCH : RAM Handling for UE Reconfig failed"
3727               "for OLD CRNTI:%d NEW CRNTI:%d",ueRecfg->oldCrnti,ueRecfg->newCrnti);
3728          return RFAILED;
3729       }
3730       /* Delete Ue from the ue list */
3731       rgSCHDbmDelUeCb(cell, ue);
3732
3733 #ifdef LTE_ADV
3734       if (ue->numSCells)
3735       {
3736          for ( sCellIdx = 1; sCellIdx < CM_LTE_MAX_CELLS; sCellIdx++)
3737          {
3738             if(ue->cellInfo[sCellIdx] != NULLP)
3739             {
3740                rgSCHDbmDelUeCb(ue->cellInfo[sCellIdx]->cell, ue);
3741             }
3742          }
3743       }
3744 #endif
3745
3746       /* Inititialize Ue control block */
3747       ue->ueId = ueRecfg->newCrnti;
3748       DU_LOG("\nDEBUG  -->  SCH : Changing RNTI from %d to %d",
3749             ueRecfg->oldCrnti, 
3750             ueRecfg->newCrnti);
3751 #ifdef EMTC_ENABLE 
3752       if(ue->isEmtcUe)
3753       {
3754          rgSCHUtlUpdEmtcY(ue);
3755       }
3756 #endif
3757       
3758       /* Fix ccpu00122631: PCell_Reest: Updating new Rnti in all the cells
3759        * dlAllocCb 
3760        */
3761       for(idx = 0; idx < CM_LTE_MAX_CELLS; idx++)
3762       {
3763          if(ue->cellInfo[idx])
3764          {
3765             ue->cellInfo[idx]->dlAllocCb.rnti = ueRecfg->newCrnti;
3766          }
3767       }
3768
3769       rgSCHUtlRecMsg3Alloc(cell, ue, raCb);
3770
3771       /* If raCb received PHR, update scheduler */
3772       if(raCb->phr.pres == TRUE)
3773       {
3774          ue->macCeRptTime = raCb->msg3AllocTime; 
3775          rgSCHUtlUpdPhr(cell, ue, raCb->phr.val, errInfo);
3776       }
3777
3778 #ifdef RGR_V2  /* Acc Fix */
3779      if(TRUE == ue->isDrxEnabled)
3780      {
3781          ueRecfg->ueDrxRecfg.isDrxEnabled = TRUE;
3782          ret = rgSCHDrxUeReCfg(cell,ue,ueRecfg);  
3783
3784          if ( ret != ROK )
3785          {
3786              DU_LOG("\nERROR  -->  SCH : UE DRX re-est failed"
3787               "for OLD CRNTI:%d NEW CRNTI:%d",ueRecfg->oldCrnti,ueRecfg->newCrnti);
3788              return RFAILED;
3789          }
3790      }
3791 #endif /* Acc Fix */
3792
3793       /* Re-insert updated Ue */
3794       rgSCHDbmInsUeCb(cell, ue);
3795
3796 #ifdef LTE_ADV
3797       if (ue->numSCells)
3798       {
3799          for ( sCellIdx = 1; sCellIdx < CM_LTE_MAX_CELLS; sCellIdx++)
3800          {
3801             if(ue->cellInfo[sCellIdx] != NULLP)
3802             {
3803                rgSCHDbmInsUeCb(ue->cellInfo[sCellIdx]->cell, ue);
3804             }
3805          }
3806       }
3807 #endif
3808
3809
3810 #ifdef TENB_STATS
3811       ue->tenbStats->stats.rnti = ue->ueId;
3812 #endif
3813
3814       /* Fix : syed If MSG4 is done, since corresponding ueCb
3815        * is ready, the raCb should be cleared immediately.
3816        * Otherwise it would remain in the cell until timed out
3817        * and till then the hq Feedbacks will be assumed to be
3818        * for msg4 */
3819       if (raCb->raState == RGSCH_RA_MSG4_DONE)
3820       {
3821          DU_LOG("\nDEBUG  -->  SCH : RNTI:%d with RaCb deleted as Msg4 transmission is done", 
3822                raCb->tmpCrnti);
3823          rgSCHRamDelRaCb(cell, raCb, FALSE);
3824       }
3825       /* Fix : syed moving the UL CQI initialization to UERESET */
3826
3827       /* Release Older rnti */
3828       if(oldRntiLnk)
3829       {
3830          /* This is the rare case in which back to back reestablishment is 
3831           * happening and previous re-est was not done completely (MSG4 was 
3832           * not done) for an UE, and again re-est is triggered for the same 
3833           * UE. We are deleting the old RA CB for the previous re-est which 
3834           * still exist due to MSG4 not transmitted successfully */
3835          if ((oldRaCb = rgSCHDbmGetRaCb(cell, oldRntiLnk->rnti)) != NULLP)
3836          {
3837             rgSCHRamDelRaCb(cell, oldRaCb, FALSE);
3838          }
3839
3840          rgSCHUtlRlsRnti(cell, oldRntiLnk, TRUE, ueRecfg->newCrnti);
3841       }
3842       else
3843       {
3844          /* Fix : syed HO UE does not have a valid ue->rntiLnk */
3845              /* Just indicate to MAC, no need to release at SCH */
3846          DU_LOG("\nDEBUG  -->  SCH : HO OldRnti:%d RLS and NewRnti:%d CHNG IND TO MAC",
3847                oldRnti, ueRecfg->newCrnti);
3848          rgSCHUtlIndRntiRls2Mac(cell, oldRnti, TRUE, ueRecfg->newCrnti);
3849       }
3850    }
3851    return ROK;
3852 }
3853 /**
3854  * @brief Handler for the UE reconfiguration request from RRC to MAC.
3855  *
3856  * @details
3857  *
3858  *     Function : rgSCHCfgRgrUeRecfg
3859  *
3860  *     Processing Steps:
3861  *      - If rnti changes,
3862  *        - Invoke RAM for UE reconfiguration.
3863  *        - Delete old UE from the list.
3864  *        - Update the new rnti and re-insert the UE in the list.
3865  *      - Update the UE control block with the reconfigured values.
3866  *      - Invoke SCH, UHM and DHM with updated UE control block to 
3867  *        update scheduler, uplink HARQ and downlink HARQ specific
3868  *        parameters.
3869  *      - If successful, return ROK else RFAILED.
3870  *
3871  *  @param[in]  RgSchCellCb  *cell
3872  *  @param[in]  RgSchUeCb    *ue
3873  *  @param[in]  RgrUeRecfg   *ueRecfg
3874  *  @param[out] RgSchErrInfo *errInfo
3875  *  @return  S16
3876  *      -# ROK
3877  *      -# RFAILED
3878  **/
3879 S16 rgSCHCfgRgrUeRecfg
3880 (
3881 RgSchCellCb    *cell,
3882 RgSchUeCb      *ue,
3883 RgrUeRecfg     *ueRecfg,
3884 RgSchErrInfo   *errInfo
3885 )
3886 {
3887    S16          ret;
3888 #ifdef LTE_ADV
3889    Bool dciChange = TRUE;
3890 #endif
3891    
3892    errInfo->errCause = RGSCHERR_CFG_RGR_UE_RECFG;
3893
3894 #ifdef LTE_ADV
3895    if (ue->numSCells > 0)
3896    {
3897       dciChange = FALSE;
3898    }
3899    if ((ueRecfg->ueRecfgTypes & RGR_UE_UE_ACCESS_STRATUM_REL_RECFG) && \
3900          (ue->accessStratumRls != ueRecfg->accessStratumRls))
3901    {
3902       ue->accessStratumRls = ueRecfg->accessStratumRls;
3903       dciChange = TRUE;
3904    }
3905
3906    /* if SCELL_RECFG is present , no other 
3907     * type will be present. Process Scell addition
3908     * and return 
3909     * */
3910    if (ueRecfg->ueRecfgTypes & RGR_UE_SCELL_ADD_RECFG)
3911    {
3912       ret = rgSCHSCellCfgUeCfg(cell, ue, ueRecfg, errInfo);
3913       if( ret != ROK)
3914       {
3915          errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_SCELL_RECFG;
3916          /*FH: SCell config failed for a scell index hence revert all successful
3917           * Scell config and send negative confirmation to APP*/
3918          rgSCHSCellCfgUeCfgRollBack(cell, ue, ueRecfg);
3919          return RFAILED;
3920       }
3921    }
3922    if (dciChange == TRUE)
3923    {
3924       if (ue->numSCells > 0)
3925       {
3926          /* 2 bit CSI */
3927          rgSCHUtlUpdUeDciSize(cell, ue, TRUE);
3928       }
3929       else
3930       {
3931          /* 1 bit CSI Access Stratum Release Change */
3932          rgSCHUtlUpdUeDciSize(cell, ue, FALSE);
3933       }
3934    }
3935    if (ueRecfg->ueRecfgTypes & RGR_UE_SCELL_PUCCH_RECFG)
3936    {
3937       ret = rgSCHSCellCfgUePucchReCfg(cell, ue, ueRecfg, errInfo);
3938       if( ret != ROK)
3939       {
3940          errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_UE_SCELL_PUCCH_RECFG;
3941          return RFAILED;
3942       }
3943    }
3944 #else
3945    if ((ueRecfg->ueRecfgTypes & RGR_UE_UE_ACCESS_STRATUM_REL_RECFG) && \
3946          (ue->accessStratumRls != ueRecfg->accessStratumRls))
3947    {
3948       ue->accessStratumRls = ueRecfg->accessStratumRls;
3949       rgSCHUtlUpdUeDciSize(cell, ue, FALSE);
3950    }
3951 #endif /* LTE_ADV */
3952
3953    if (ueRecfg->ueRecfgTypes)
3954    {
3955       /* Update scheduler related information for UE */
3956       ret = rgSCHUtlRgrUeRecfg(cell, ue, ueRecfg, errInfo);
3957       if (ret != ROK)
3958       {
3959          DU_LOG("\nERROR  -->  SCH : Scheduler handling while reconfig failed"
3960               "for OLD CRNTI:%d NEW CRNTI:%d",ueRecfg->oldCrnti,ueRecfg->newCrnti);
3961          return RFAILED;
3962       }
3963
3964       /* Update uplink HARQ related information for UE */
3965       rgSCHUhmRgrUeRecfg(cell, ue, ueRecfg);
3966
3967       /* Update TA related information for UE */
3968       if (ueRecfg->ueRecfgTypes & RGR_UE_TATMR_RECFG)
3969       {
3970          rgSCHCfgUeTaRecfg(cell, ue, ueRecfg, errInfo);
3971       }
3972
3973       /*Update Measurement Gap and AckNack Details */
3974       /* After merging from 2.2 */
3975       if (ueRecfg->ueRecfgTypes & RGR_UE_ACKNACK_MEASGAP_RECFG)
3976       {
3977          ret = rgSCHMeasGapANRepUeRecfg(cell, ue, ueRecfg);
3978          if (ret != ROK)
3979          {
3980             DU_LOG("\nERROR  -->  SCH : Measurement Gap and"
3981                      "AckNack Rep Recfg failed for OLD CRNTI:%d NEW CRNTI:%d",
3982                       ueRecfg->oldCrnti,ueRecfg->newCrnti);
3983             return RFAILED;
3984          }
3985       }
3986       if (ueRecfg->ueRecfgTypes & RGR_UE_BSRTMR_RECFG)
3987       {
3988          cmInitTimers(&ue->bsrTmr, 1);
3989          ue->ul.bsrTmrCfg = ueRecfg->ueBsrTmrRecfg;
3990          if ((ue->ul.bsrTmrCfg.isPrdBsrTmrPres) && 
3991                (ue->ul.bsrTmrCfg.prdBsrTmr == 0xFFFF))
3992          {
3993             ue->ul.bsrTmrCfg.isPrdBsrTmrPres = FALSE;
3994          }
3995       }
3996    }
3997
3998    if (RFAILED == rgSCHCfgRgrUeRecfgRntiChg (cell, ue, ueRecfg, errInfo))
3999    {
4000        DU_LOG("\nERROR  -->  SCH : RNTI change "
4001                "failed for OLD CRNTI:%d NEW CRNTI:%d",
4002                 ueRecfg->oldCrnti,ueRecfg->newCrnti);
4003        return RFAILED;
4004    }
4005
4006 #ifdef TFU_UPGRADE
4007    /* Re-Initialize Aperiodic CQI Information for UE*/
4008    if ( ueRecfg->ueRecfgTypes & RGR_UE_APRD_DLCQI_RECFG ) 
4009    {
4010       ret = rgSCHCfgAcqiUeReCfg(cell, ue, &ueRecfg->aprdDlCqiRecfg, 
4011             ue->ueCatEnum);
4012    }
4013    /*   Re-Initialize Periodic CQI/PMI, RI Information for UE  */
4014    if ( ueRecfg->ueRecfgTypes & RGR_UE_PCQI_RECFG) 
4015    {
4016       ret = rgSCHCfgPCqiUeReCfg(cell, ue, &ueRecfg->cqiCfg, 
4017             ue->ueCatEnum);
4018    }
4019    /*   Re-Initialize UL SRS Information for UE  */
4020    if ( ueRecfg->ueRecfgTypes & RGR_UE_SRS_RECFG) 
4021    {
4022       ret = rgSCHCfgSrsUeReCfg(cell, ue, &ueRecfg->srsCfg);
4023    }
4024    /*   Re-Initialize SR Information for UE  */
4025    if ( ueRecfg->ueRecfgTypes & RGR_UE_SR_RECFG) 
4026    {
4027       ret = rgSCHCfgSrUeReCfg(cell, ue, &ueRecfg->srCfg);
4028    }
4029 #endif 
4030
4031 #ifdef LTEMAC_HDFDD  
4032    if(ueRecfg->isHdFddEnbld)
4033    {
4034         ret = rgSCHHdFddUeCfg(cell, ue, ueRecfg->isHdFddEnbld);
4035         if (ret != ROK)
4036         {
4037            errInfo->errCause = RGSCHERR_HDFDD_SPSCFGRD;
4038            return (ret);
4039         }
4040    }
4041 #endif /* LTEMAC_HDFDD */
4042 #ifdef RGR_V2
4043   if ( ueRecfg->ueRecfgTypes & RGR_UE_DRX_RECFG)
4044   {
4045      ret = rgSCHDrxUeReCfg(cell,ue,ueRecfg);  
4046
4047      if ( ret != ROK )
4048      {
4049         DU_LOG("\nERROR  -->  SCH : UE DRX reconfig failed"
4050                "failed for OLD CRNTI:%d NEW CRNTI:%d",
4051                 ueRecfg->oldCrnti,ueRecfg->newCrnti);
4052         return RFAILED;
4053      }
4054   }
4055 #endif  
4056 /* ccpu00117452 - MOD - Changed macro name from
4057    RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
4058 #ifdef RGR_CQI_REPT
4059    /* CQI Reporting (N)  Re-configuration */
4060    if(ueRecfg->ueRecfgTypes & RGR_UE_CQIREPT_RECFG)
4061    {
4062       ret = rgSCHCfgUeCqiReptReCfg(cell, ue, ueRecfg);
4063       if(ret != OK)
4064       {
4065          errInfo->errCause = RGSCHERR_CQIREPT;
4066          return (ret);
4067       }
4068    }
4069 #endif /* End of RGR_CQI_REPT */
4070 #ifdef TFU_UPGRADE
4071    /* pA Re-configuration */
4072    if((ueRecfg->ueRecfgTypes & RGR_UE_PA_RECFG) &&
4073          RG_SCH_UE_CFG_ISPAPRSNT(ueRecfg->uePdschDedCfg.uepACfg))
4074    {
4075       RG_SCH_CMN_GET_PA(ue,cell).pres = TRUE;
4076       RG_SCH_CMN_GET_PA(ue,cell).val = ueRecfg->uePdschDedCfg.uepACfg.pA;
4077    }
4078 #endif
4079
4080 /* LTE_ADV_FLAG_REMOVED_START */
4081    if(ueRecfg->ueRecfgTypes & RGR_UE_LTEA_RECFG)
4082    {
4083       if(ueRecfg->ueLteAdvCfg.pres & RGR_ABS)
4084       {
4085          ue->lteAdvUeCb.rgrLteAdvUeCfg.isAbsUe = ueRecfg->ueLteAdvCfg.isAbsUe;
4086       }
4087
4088       if(ueRecfg->ueLteAdvCfg.pres & RGR_SFR)
4089       {
4090          ue->lteAdvUeCb.rgrLteAdvUeCfg.isUeCellEdge = ueRecfg->ueLteAdvCfg.isUeCellEdge;
4091       }
4092    }
4093 /* LTE_ADV_FLAG_REMOVED_END */
4094 #ifdef EMTC_ENABLE
4095    if(ueRecfg->ueRecfgTypes & RGR_UE_EMTC_DPLXMODE_RECFG)
4096    {
4097       rgSCHEmtcHdFddUeCfg (cell, ue,
4098                ueRecfg->emtcUeRecfg.isHdFddEnbld);
4099    }
4100    if(ueRecfg->ueRecfgTypes & RGR_UE_EMTC_PO_TRIGGER)
4101    {
4102       rgSCHEmtcPOTrigger(cell, ue);
4103    }
4104 #endif
4105    errInfo->errCause = RGSCHERR_NONE;
4106
4107    return ROK;
4108 }  /* rgSCHCfgRgrUeRecfg */
4109
4110
4111 /**
4112  * @brief Handler for the logical channel reconfiguration request from
4113  * RRC to MAC.
4114  *
4115  * @details
4116  *
4117  *     Function : rgSCHCfgRgrLchRecfg
4118  *
4119  *     Processing Steps:
4120  *      - Invoke scheduler to update scheduler specific information.
4121  *      - Update the dedicated logical channel Cb with the reconfigured
4122  *        values.
4123  *      - If successful, return ROK else RFAILED.
4124  *
4125  *  @param[in]  RgUlCellCb  *cell
4126  *  @param[in]  RgUlUeCb    *ue
4127  *  @param[in]  RgSchUlLcCb    *ulLc
4128  *  @param[in]  RgSchDlLcCb    *dlLc
4129  *  @param[in]  RgrLchRecfg *lcRecfg
4130  *  @param[out] RgSchErrInfo   *errInfo
4131  *  @return  S16
4132  *      -# ROK
4133  *      -# RFAILED
4134  **/
4135 S16 rgSCHCfgRgrLchRecfg
4136 (
4137 RgSchCellCb    *cell,
4138 RgSchUeCb      *ue,
4139 RgSchDlLcCb    *dlLc,
4140 RgrLchRecfg    *lcRecfg,
4141 RgSchErrInfo   *errInfo
4142 )
4143 {
4144    S16     ret = ROK;
4145
4146    errInfo->errCause = RGSCHERR_CFG_RGR_LC_RECFG;
4147    /* Invoke Scheduler to update the new configuration */
4148    ret = rgSCHUtlRgrLcRecfg(cell, ue, dlLc, lcRecfg, errInfo);
4149    if (ret != ROK)
4150    {
4151       DU_LOG("\nERROR  -->  SCH : Scheduler handling for LC Recfg"
4152               " failed for CRNTI:%d LCID:%d",lcRecfg->crnti,lcRecfg->lcId);
4153       return RFAILED;
4154    }
4155
4156    errInfo->errCause = RGSCHERR_NONE;
4157    return ROK;
4158 }  /* rgSCHCfgRgrLchRecfg */
4159 /**
4160  * @brief Handler for the logical channel reconfiguration request from
4161  * RRC to MAC.
4162  *
4163  * @details
4164  *
4165  *     Function : rgSCHCfgRgrLcgRecfg
4166  *
4167  *     Processing Steps:
4168  *      - Invoke scheduler to update scheduler specific information.
4169  *      - Update the dedicated logical channel Cb with the re-configured
4170  *        values.
4171  *      - If successful, return ROK else RFAILED.
4172  *
4173  *  @param[in]  RgUlCellCb   *cell
4174  *  @param[in]  RgUlUeCb     *ue
4175  *  @param[in]  RgrLcgRecfg  *lcgRecfg
4176  *  @param[out] RgSchErrInfo *errInfo
4177  *  @return  S16
4178  *      -# ROK
4179  *      -# RFAILED
4180  **/
4181 S16 rgSCHCfgRgrLcgRecfg
4182 (
4183 RgSchCellCb    *cell,
4184 RgSchUeCb      *ue,
4185 RgrLcgRecfg    *lcgRecfg,
4186 RgSchErrInfo   *errInfo
4187 )
4188 {
4189    S16     ret = ROK;
4190
4191    errInfo->errCause = RGSCHERR_CFG_RGR_LCG_RECFG;
4192   
4193    /*Added for handling LCG ReConfig if the LCG was deleted */
4194    ue->ul.lcgArr[lcgRecfg->ulRecfg.lcgId].lcgId = lcgRecfg->ulRecfg.lcgId;
4195
4196    /* Invoke Scheduler to update the new configuration */
4197    ret = rgSCHUtlRgrLcgRecfg(cell, ue, lcgRecfg, errInfo);
4198    if (ret != ROK)
4199    {
4200       DU_LOG("\nERROR  -->  SCH : Scheduler handling for LCG Recfg"
4201               " failed for CRNTI:%d LCGID:%d",lcgRecfg->crnti,lcgRecfg->ulRecfg.lcgId);
4202       return RFAILED;
4203    }
4204
4205    errInfo->errCause = RGSCHERR_NONE;
4206    return ROK;
4207 }  /* rgSCHCfgRgrLcgRecfg */
4208
4209 /**
4210  * @brief Handler for the UE Reset request from RRM to MAC.
4211  *
4212  * @details
4213  *
4214  *     Function : rgSCHCfgRgrUeReset
4215  *
4216  *     Processing Steps:
4217  *     - Call Measument Gap Module and Ack/Nack Module for resetting UE.
4218  *     - Call Common Schduler UE rest API which inturn will call scheduler
4219  *     specific UE Reset APis to reset UE.
4220  *
4221  *  @param[in]  RgSchCellCb    *cell
4222  *  @param[in]  RgSchUeCb      *ue
4223  *  @param[in]  RgrRst         *reset
4224  *  @param[out] RgSchErrInfo   *errInfo
4225  *  @return  S16
4226  *      -# ROK
4227  *      -# RFAILED
4228  **/
4229 S16 rgSCHCfgRgrUeReset
4230 (
4231 RgSchCellCb    *cell,
4232 RgSchUeCb      *ue,
4233 RgrRst         *reset,
4234 RgSchErrInfo   *errInfo
4235 )
4236 {
4237    uint32_t     idx;
4238    RgSchRaCb *raCb;
4239
4240    errInfo->errCause = RGSCHERR_CFG_RGR_UE_RESET;
4241   
4242    /* Setting BO of Each Logical Channel of the UE to 0 */
4243    for (idx = 0; idx < RGSCH_MAX_LC_PER_UE; idx++)
4244    {
4245       if(ue->dl.lcCb[idx] != NULLP)
4246          ue->dl.lcCb[idx]->bo = 0;
4247    }
4248
4249    /* Reset the totalBo */
4250    ue->totalBo = 0;
4251    /* Call DRX module to stop all DRX timers */
4252    /* ccpu00129899 */
4253    if(ue->drxCb != NULLP)
4254    {
4255      (Void)rgSCHDrxUeDel(cell,ue);
4256    }
4257
4258    /* ccpu00140894- Stop TXMode transiition timer if it is running*/
4259    if (ue->txModeTransTmr.tmrEvnt != TMR_NONE)
4260    {
4261       rgSCHTmrStopTmr(cell, RG_SCH_TMR_TXMODE_TRNSTN, ue);
4262       ue->txModeTransCmplt =TRUE;
4263    }
4264
4265    /* ccpu00133470- Meas Gap should be released during RRC re-establishment */
4266    rgSCHMeasGapANRepUeDel(cell, ue, FALSE);
4267
4268    /* Call Common scheduler which in turn will call specific scheduler for UE
4269     * Reset*/
4270    rgSCHUtlUeReset(cell, ue);
4271 #ifdef LTE_ADV
4272    /*PCell which is at idx 0 is always active. Adding a line after the loop
4273     *setting RGSCH_PCELL_INDEX to SCELL ACTIVE*/
4274    ue->cellInfo[RGSCH_PCELL_INDEX]->sCellState = RG_SCH_SCELL_ACTIVE;
4275 #endif
4276
4277    /* In case of back to back reestablishments, when this UE's
4278     * previous ReEst is still in progress and has got RESET
4279     * as part of new ReEst */
4280    if((raCb = rgSCHDbmGetRaCb(cell, ue->ueId)) != NULLP)
4281    {
4282       rgSCHRamDelRaCb(cell, raCb, FALSE);
4283    }
4284    /* Fix : syed set UE inactive in DL until UE is reinitialization completed */
4285    ue->dl.dlInactvMask |= RG_HQENT_INACTIVE;
4286    ue->ul.ulInactvMask |= RG_HQENT_INACTIVE;
4287    /* [ccpu00127141] Resetting TA related parameters */
4288    ue->dl.taCb.ta = RGSCH_NO_TA_RQD;
4289    ue->dl.taCb.state = RGSCH_TA_IDLE;
4290    
4291    /*[ccpu00121813]-ADD-Initializing outstanding TA value */
4292    ue->dl.taCb.outStndngTa = FALSE;
4293    ue->dl.taCb.outStndngTaval = RGSCH_NO_TA_RQD;
4294    
4295    if (ue->dl.taCb.cfgTaTmr)
4296    {
4297       rgSCHTmrStartTmr (cell, ue, RG_SCH_TMR_TA, ue->dl.taCb.cfgTaTmr);
4298    }
4299
4300 #ifdef DL_LA
4301    /* Resetting the Tx mode change factor on UE reset */
4302    ue->mimoInfo.txModUpChgFactor = 0;
4303    ue->mimoInfo.txModDownChgFactor = 0;
4304 #endif
4305
4306    errInfo->errCause = RGSCHERR_NONE;
4307    return ROK;
4308 }  /* rgSCHCfgRgrUeReset */
4309
4310 /**
4311  * @brief Handler for the cell delete request from RRM to MAC.
4312  *
4313  * @details
4314  *
4315  *     Function : rgSCHCfgRgrCellDel
4316  *
4317  *     Processing Steps:
4318  *      - Fetch the cell control block.
4319  *      - Remove the cell control block from the hash list of cells.
4320  *      - Free the cell control block.
4321  *      - If successful, return ROK else return RFAILED.
4322  *
4323  *  @param[in]  RgSchCellCb    *cell
4324  *  @param[in]  RgrDel         *cellDelInfo
4325  *  @param[out] RgSchErrInfo   *errInfo
4326  *  @return  S16
4327  *      -# ROK
4328  *      -# RFAILED
4329  **/
4330 S16 rgSCHCfgRgrCellDel
4331 (
4332 RgSchCellCb    *cell,
4333 RgrDel         *cellDelInfo,
4334 RgSchErrInfo   *errInfo
4335 )
4336
4337
4338    errInfo->errCause = RGSCHERR_CFG_RGR_CELL_DEL;
4339
4340    if (cell->cellId != cellDelInfo->u.cellDel.cellId)
4341    {
4342       DU_LOG("\nERROR  -->  SCH : Cell does not exist");
4343       return RFAILED;
4344    }
4345
4346    /* Free the active cell */
4347    rgSCHCfgFreeCellCb(cell);
4348
4349    errInfo->errCause = RGSCHERR_NONE;
4350    return ROK;
4351 }  /* rgSCHCfgRgrCellDel */
4352
4353
4354 /**
4355  * @brief Handler for the UE delete request from RRM to MAC.
4356  *
4357  * @details
4358  *
4359  *     Function : rgSCHCfgRgrUeDel
4360  *
4361  *     Processing Steps:
4362  *      - Fetch the UE control block.
4363  *      - Remove the UE control block from the hash list of UEs for the cell.
4364  *      - Free the UE control block.
4365  *      - If successful, return ROK else return RFAILED.
4366  *
4367  *  @param[in]  RgSchCellCb    *cell
4368  *  @param[in]  RgrDel         *ueDelInfo
4369  *  @param[out] RgSchErrInfo   *errInfo
4370  *  @return  S16
4371  *      -# ROK
4372  *      -# RFAILED
4373  **/
4374 S16 rgSCHCfgRgrUeDel
4375 (
4376 RgSchCellCb         *cell,
4377 RgrDel              *ueDelInfo,
4378 RgSchErrInfo        *errInfo
4379 )
4380 {
4381    RgSchUeCb        *ue;
4382    RgSchRaCb        *raCb;
4383 #ifdef LTE_ADV
4384    Inst    inst = cell->instIdx;
4385    RgSchCellCb      *secCellCb = NULLP;
4386 #endif
4387
4388    errInfo->errCause = RGSCHERR_CFG_RGR_UE_DEL;
4389
4390    if (cell->cellId != ueDelInfo->u.ueDel.cellId)
4391    {
4392       DU_LOG("\nERROR  -->  SCH : Cell does not exist CRNTI:%d",
4393                 ueDelInfo->u.ueDel.crnti);
4394       return RFAILED;
4395    }
4396    if ((ue = rgSCHDbmGetUeCb(cell, ueDelInfo->u.ueDel.crnti)) == NULLP)
4397    {
4398       if((raCb = rgSCHDbmGetRaCb(cell, ueDelInfo->u.ueDel.crnti)) == NULLP)
4399       {
4400          DU_LOG("\nERROR  -->  SCH : RaCb does not exist for CRNTI:%d",ueDelInfo->u.ueDel.crnti);
4401          return RFAILED;
4402       }
4403       else
4404       {
4405          /* This happens in case of Msg4 rejection */
4406          raCb->toDel = TRUE;
4407          return ROK;
4408       }
4409    }
4410    else
4411    {
4412 #ifdef LTE_ADV
4413       if(ueDelInfo->u.ueScellRel.ueDelTypes & RGR_UE_SCELL_DEL_RECFG)
4414       {
4415          for(uint8_t idx = 0; idx < ueDelInfo->u.ueScellRel.ueSCellRelCfgInfo.numSCells; idx++)
4416          {
4417             if(NULLP != (secCellCb = (RgSchCellCb *)rgSchUtlGetCellCb(inst, \
4418                         ueDelInfo->u.ueScellRel.ueSCellRelCfgInfo.ueSCellRelDedCfg[idx].sCellId)))
4419             {
4420                rgSCHUtlSndUeSCellDel2Mac(secCellCb, ue->ueId);
4421                rgSCHSCellDelUeSCell(cell,ue,ueDelInfo->u.ueScellRel.ueSCellRelCfgInfo.ueSCellRelDedCfg[idx].sCellIdx);
4422                ue->numSCells--;
4423                if ( ue->numSCells == 0)
4424                {
4425                   ue->allocCmnUlPdcch = TRUE;
4426                }
4427             }
4428          }
4429          if (ue->numSCells == 0)
4430          {
4431             /* As there is no SCell left so DCI 0 size at UE specific search space 
4432              * will be recalculated as the CSI is reduced to 1 bit */
4433             rgSCHUtlUpdUeDciSize(cell, ue, FALSE);
4434          }
4435       }
4436       else
4437 #endif
4438       {
4439          /* Delete Ue from the UE list of CELL*/
4440          rgSCHDbmDelUeCb(cell, ue);
4441
4442 #ifdef LTE_L2_MEAS
4443          rgSCHDbmDelL2MUe(cell, ue);
4444 #endif
4445
4446          /* Call MeasGap and AckNakRep processing module */
4447          rgSCHMeasGapANRepUeDel(cell, ue, TRUE);
4448
4449          /* ccpu00140894- Stop TXMode transiition timer if it is running*/
4450          if (ue->txModeTransTmr.tmrEvnt != TMR_NONE)
4451          {
4452             rgSCHTmrStopTmr(cell, RG_SCH_TMR_TXMODE_TRNSTN, ue);
4453          }
4454
4455          /* Call DRX module to remove UEs from various
4456           * lists it maintain 
4457           */
4458          /* ccpu00129899 */
4459          if(ue->drxCb != NULLP)
4460          {
4461             (Void)rgSCHDrxUeDel(cell,ue);
4462             /* Free Ue */
4463          }
4464          /*Fix: If RA CB exists, delete it*/
4465          if((raCb = rgSCHDbmGetRaCb(cell, ueDelInfo->u.ueDel.crnti)) != NULLP)
4466          {
4467             /* Fix : syed RNTI was getting released twice, once by racb del 
4468              * and subsequently by ueDel. Let it get released by ueDel alone */       
4469             rgSCHRamDelRaCb(cell, raCb, FALSE);
4470          }
4471 #ifdef EMTC_ENABLE
4472          if(ue->isEmtcUe)
4473          {
4474             rgSCHEmtcUeDel(cell, ue);
4475          }
4476 #endif
4477
4478          rgSCHCfgFreeUeCb(cell, ue);
4479
4480          errInfo->errCause = RGSCHERR_NONE;
4481
4482       }
4483       return ROK;
4484    }
4485 }  /* rgSCHCfgRgrUeDel */
4486
4487
4488 /**
4489  * @brief Handler for the logical channel delete request from
4490  * RRM to MAC.
4491  *
4492  * @details
4493  *
4494  *     Function : rgSCHCfgRgrLcDel
4495  *
4496  *     Processing Steps:
4497  *      - Fetch the logical channel control block.
4498  *      - Free the logical channel control block.
4499  *      - If successful, return ROK else return RFAILED.
4500  *
4501  *  @param[in]  RgrDel      *lcDelInfo
4502  *  @param[out] RgSchErrInfo   *errInfo
4503  *  @return  S16
4504  *      -# ROK
4505  *      -# RFAILED
4506  **/
4507 S16 rgSCHCfgRgrLcDel
4508 (
4509 RgSchCellCb    *cell,
4510 RgrDel         *lcDelInfo,
4511 RgSchErrInfo   *errInfo
4512 )
4513 {
4514    RgSchUeCb    *ue;
4515    RgSchDlLcCb  *dlLc;
4516 #ifdef LTE_L2_MEAS
4517    uint8_t          lcId;
4518    uint8_t          idx;
4519    RgSchUlLcCb  *ulLc; 
4520 #endif
4521
4522    errInfo->errCause = RGSCHERR_CFG_RGR_LC_DEL;
4523
4524    /* Fetch the Active cell */
4525    if (cell->cellId != lcDelInfo->u.lchDel.cellId)
4526    {
4527       DU_LOG("\nERROR  -->  SCH : Cell does not exist %d",
4528                   lcDelInfo->u.lchDel.cellId);
4529       return RFAILED;
4530    }
4531
4532    /* Fetch the Ue */
4533    if ((ue = rgSCHDbmGetUeCb(cell, lcDelInfo->u.lchDel.crnti)) == NULLP)
4534    {
4535       DU_LOG("\nERROR  -->  SCH : UE does not exist for CRNTI:%d LCID:%d",
4536                lcDelInfo->u.lchDel.crnti,lcDelInfo->u.lchDel.lcId);
4537       return RFAILED;
4538    }
4539    if (lcDelInfo->u.lchDel.lcgId > 3)
4540    {
4541       DU_LOG("\nERROR  -->  SCH : [%d]UEID:For LC %d, LCGid %d is invalid",
4542                lcDelInfo->u.lchDel.crnti,lcDelInfo->u.lchDel.lcId,
4543                lcDelInfo->u.lchDel.lcgId);
4544       return RFAILED;
4545    }
4546    if ((dlLc = rgSCHDbmGetDlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
4547          == NULLP)
4548    {
4549       DU_LOG("\nERROR  -->  SCH : LC does not exist for CRNTI:%d LCID:%d",
4550                lcDelInfo->u.lchDel.crnti, lcDelInfo->u.lchDel.lcId);
4551       return RFAILED;
4552    }
4553    rgSCHUtlRgrLcDel(cell, ue, lcDelInfo->u.lchDel.lcId,lcDelInfo->u.lchDel.lcgId); 
4554
4555    /* Reduce any pending bo from this LC(if any) 
4556     * from the UE's total BO */
4557    if(dlLc->bo)
4558    {
4559       if(ue->totalBo >= dlLc->bo)
4560       {
4561          ue->totalBo -= dlLc->bo;
4562       }
4563       else
4564       {
4565         ue->totalBo = 0; /* this scenario should not occur */
4566       }
4567    }
4568    rgSCHDbmDelDlDedLcCb(ue, dlLc);
4569    rgSCHCfgFreeDlDedLcCb(cell, ue, dlLc);
4570
4571 #ifdef LTE_L2_MEAS
4572    lcId = lcDelInfo->u.lchDel.lcId;
4573    if (TRUE == ue->ul.lcCb[lcId -1].isValid)
4574    {
4575       ulLc = &(ue->ul.lcCb[lcId -1]);
4576       ue->ul.lcCb[lcId -1].isValid = FALSE;
4577
4578       if((ulLc->qciCb->ulUeCount) &&
4579             (ue->ulActiveLCs & (1 << (ulLc->qciCb->qci -1))))
4580       {
4581          ulLc->qciCb->ulUeCount--;
4582          ue->ulActiveLCs &= ~(1 << (ulLc->qciCb->qci -1));
4583       }
4584       /* Shifting LCs in LCG Array because of LC deletion */
4585       for (idx = ulLc->lcgArrIdx +1; idx < ulLc->lcg->numLch;
4586                idx++)
4587       {
4588          ulLc->lcg->lcArray[idx -1] =
4589             ulLc->lcg->lcArray[idx];
4590          ulLc->lcg->lcArray[idx -1]->lcgArrIdx = idx -1;
4591       }
4592       ulLc->lcg->numLch--;
4593       ulLc->lcg->lcArray[idx -1] = NULLP;
4594    }
4595 #endif /* LTE_L2_MEAS */
4596
4597
4598    errInfo->errCause = RGSCHERR_NONE;
4599    return ROK;
4600 }  /* rgSCHCfgRgrLcDel */
4601
4602
4603
4604 /**
4605  * @brief Handler for the logical channel delete request from
4606  * RRM to MAC.
4607  *
4608  * @details
4609  *
4610  *     Function : rgSCHCfgRgrLcgDel
4611  *
4612  *     Processing Steps:
4613  *      - Fetch the logical channel control block.
4614  *      - Free the logical channel control block.
4615  *      - If successful, return ROK else return RFAILED.
4616  *
4617  *  @param[in]  RgrDel      *lcDelInfo
4618  *  @param[out] RgSchErrInfo   *errInfo
4619  *  @return  S16
4620  *      -# ROK
4621  *      -# RFAILED
4622  **/
4623 S16 rgSCHCfgRgrLcgDel
4624 (
4625 RgSchCellCb    *cell,
4626 RgrDel         *lcDelInfo,
4627 RgSchErrInfo   *errInfo
4628 )
4629 {
4630    RgSchUeCb    *ue = NULLP;
4631 #ifdef LTE_L2_MEAS
4632    uint8_t           lcCount = 0;
4633 #endif
4634    uint8_t           lcgId = 0;
4635
4636    lcgId = lcDelInfo->u.lcgDel.lcgId;
4637
4638    errInfo->errCause = RGSCHERR_CFG_RGR_LCG_DEL;
4639
4640    /* Fetch the Active cell */
4641    if (cell->cellId != lcDelInfo->u.lcgDel.cellId)
4642    {
4643       DU_LOG("\nERROR  -->  SCH : CELL does not exist for CRNTI:%d LCGID:%d",
4644                lcDelInfo->u.lchDel.crnti,lcDelInfo->u.lchDel.lcId);
4645       return RFAILED;
4646    }
4647
4648    /* Fetch the Ue */
4649    if ((ue = rgSCHDbmGetUeCb(cell, lcDelInfo->u.lcgDel.crnti)) == NULLP)
4650    {
4651       DU_LOG("\nERROR  -->  SCH : UE does not exist for CRNTI:%d LCGID:%d",
4652                lcDelInfo->u.lchDel.crnti,lcDelInfo->u.lchDel.lcId);
4653       return RFAILED;
4654    }
4655
4656    /* set lcgId in UEs lcg cntrl blk to invalid */
4657    rgSCHUtlRgrLcgDel(cell, ue, lcgId);
4658    ue->ul.lcgArr[lcgId].lcgId = RGSCH_INVALID_LCG_ID;
4659
4660 #ifdef LTE_L2_MEAS
4661    /* Since LCs are being deleted, if any of them are contributing
4662       to Active UE count for a QCI, decrease the count */
4663    for (lcCount =0; (lcCount < RGSCH_MAX_LC_PER_UE) && 
4664          (lcCount < ue->ul.lcgArr[lcgId].numLch) ; lcCount++)
4665    {
4666       if (ue->ul.lcgArr[lcgId].lcArray[lcCount])
4667       {
4668          if((ue->ul.lcgArr[lcgId].
4669                   lcArray[lcCount]->qciCb->ulUeCount) &&
4670             (ue->ulActiveLCs &
4671              (1 << ((ue->ul.lcgArr[lcgId].
4672                     lcArray[lcCount])->qciCb->qci -1))))
4673             {
4674                /* L2_COUNTERS */
4675                ue->ul.lcgArr[lcgId].
4676                   lcArray[lcCount]->qciCb->ulUeCount--;
4677                ue->ulActiveLCs &= ~(1 << 
4678                      (ue->ul.lcgArr[lcgId].
4679                       lcArray[lcCount]->qciCb->qci -1));
4680             }
4681       }
4682    }
4683 #endif
4684    
4685    errInfo->errCause = RGSCHERR_NONE;
4686    return ROK;
4687 }  /* rgSCHCfgRgrLcgDel */
4688
4689
4690
4691 /***********************************************************
4692  *
4693  *     Func : rgSCHCfgVldtRgrLcCfg
4694  *
4695  *
4696  *     Desc : Validates dedicated logical channel configuration recieved from RRM.
4697  *
4698  *     Ret  : S16
4699  *            ROK - Success
4700  *            RFAILED - Failed
4701  *
4702  *     Notes:
4703  *
4704  *     File :
4705  *
4706  **********************************************************/
4707 S16 rgSCHCfgVldtRgrLcCfg
4708 (
4709 Inst             inst,
4710 RgrLchCfg     *lcCfg,
4711 RgSchCellCb      **cell,
4712 RgSchUeCb        **ue,
4713 RgSchErrInfo     *errInfo
4714 )
4715 {
4716
4717    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_DED_LC_CFG;
4718
4719    if (((*cell) == NULLP) ||
4720        ((*cell)->cellId != lcCfg->cellId))
4721    {
4722       DU_LOG("\nERROR  -->  SCH : Cell does not existi for "
4723                "CRNTI:%d LCID:%d",lcCfg->crnti, lcCfg->lcId);
4724       return RFAILED;
4725    }
4726
4727    /* Fetch the Ue */
4728    if ((*ue = rgSCHDbmGetUeCb(*cell, lcCfg->crnti)) == NULLP)
4729    {
4730       DU_LOG("\nERROR  -->  SCH : UE does not exist for dedicated"
4731          " logical channel CRNTI:%d LCID:%d", lcCfg->crnti, lcCfg->lcId);
4732       return RFAILED;
4733    }
4734
4735    /* Validate logical channel Id */
4736    if ((lcCfg->lcId < RGSCH_DEDLC_MIN_LCID)
4737             ||(lcCfg->lcId > RGSCH_DEDLC_MAX_LCID))
4738    {
4739       DU_LOG("\nERROR  -->  SCH : Invalid logical channel Id:%d"
4740                "for CRNTI:%d",lcCfg->lcId,lcCfg->crnti);
4741       return RFAILED;
4742    }
4743
4744    if (lcCfg->lcType != CM_LTE_LCH_DTCH && lcCfg->lcType != CM_LTE_LCH_DCCH)
4745    {
4746       DU_LOG("\nERROR  -->  SCH : Invalid logical channel Type %d"
4747                "CRNTI:%d LCID:%d",lcCfg->lcType,lcCfg->crnti, lcCfg->lcId);
4748       return RFAILED;
4749    }
4750
4751    return ROK;
4752 }  /* rgSCHCfgVldtRgrLcCfg */
4753
4754 /***********************************************************
4755  *
4756  *     Func : rgSCHCfgVldtRgrLcgCfg
4757  *
4758  *
4759  *     Desc : Validates dedicated logical channel group configuration recieved from RRM.
4760  *
4761  *     Ret  : S16
4762  *            ROK - Success
4763  *            RFAILED - Failed
4764  *
4765  *     Notes:
4766  *
4767  *     File :
4768  *
4769  **********************************************************/
4770 S16 rgSCHCfgVldtRgrLcgCfg
4771 (
4772 Inst             inst,
4773 RgrLcgCfg        *lcgCfg,
4774 RgSchCellCb      **cell,
4775 RgSchUeCb        **ue,
4776 RgSchErrInfo     *errInfo
4777 )
4778 {
4779
4780    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_DED_LCG_CFG;
4781
4782    if (((*cell) == NULLP) ||
4783        ((*cell)->cellId != lcgCfg->cellId))
4784    {
4785       DU_LOG("\nERROR  -->  SCH : Cell does not exist for"
4786                "CRNTI:%d LCGID:%d",lcgCfg->crnti,lcgCfg->ulInfo.lcgId);
4787       return RFAILED;
4788    }
4789
4790    /* Fetch the Ue */
4791    if ((*ue = rgSCHDbmGetUeCb(*cell, lcgCfg->crnti)) == NULLP)
4792    {
4793       DU_LOG("\nERROR  -->  SCH : UE does not exist for "
4794         "dedicated logical channel CRNTI:%d LCGID:%d", lcgCfg->crnti, lcgCfg->ulInfo.lcgId);
4795       return RFAILED;
4796    }
4797    
4798    if ((lcgCfg->ulInfo.gbr != 0) && (lcgCfg->ulInfo.mbr < lcgCfg->ulInfo.gbr))
4799    {
4800      return RFAILED;
4801    }
4802    
4803    return ROK;
4804 }  /* rgSCHCfgVldtRgrLcgCfg */
4805
4806
4807 /***********************************************************
4808  *
4809  *     Func : rgSCHCfgVldtRgrCellPwrCfg
4810  *
4811  *     Desc : Validates cell power configuration.
4812  *
4813  *     Ret  : S16
4814  *            ROK - Success
4815  *            RFAILED - Failed
4816  *
4817  *     Notes:
4818  *
4819  *     File :
4820  *
4821  **********************************************************/
4822 static S16 rgSCHCfgVldtRgrCellPwrCfg
4823 (
4824 Inst             inst,
4825 RgrCellCfg       *cellCfg,
4826 RgSchErrInfo     *errInfo
4827 )
4828 {
4829    UNUSED(inst);
4830    UNUSED(cellCfg);
4831    UNUSED(errInfo);
4832
4833    /* This function does nothing now, placeholder for
4834     * subsequent power config validations that may be needed */
4835
4836
4837    return ROK;
4838 }  /* rgSCHCfgVldtRgrCellPwrCfg */
4839
4840
4841 /***********************************************************
4842  *
4843  *     Func : rgSCHCfgVldtRgrCmnLcCfg
4844  *
4845  *
4846  *     Desc : Validates common logical channel configuration recieved from RRM.
4847  *
4848  *  @param[in]  Inst         inst
4849  *  @param[in]  RgrCellCfg   *cellCfg
4850  *  @param[out] RgSchErrInfo *errInfo
4851  *     Ret  : S16
4852  *            ROK - Success
4853  *            RFAILED - Failed
4854  *
4855  *     Notes:
4856  *
4857  *     File :
4858  *
4859  **********************************************************/
4860 static S16 rgSCHCfgVldtRgrCmnLcCfg
4861 (
4862 Inst             inst,
4863 RgrCellCfg       *cellCfg,
4864 RgSchErrInfo     *errInfo
4865 )
4866 {
4867    uint8_t            idx;
4868    RgrCmnLchCfg  *lcCfg; 
4869    uint8_t            dirVld  = FALSE;
4870    uint8_t            bitMask = 0x00;
4871    uint8_t            cnt=0;
4872
4873    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_CMN_LC_CFG;
4874    
4875    for (idx = 0; idx < cellCfg->numCmnLcs; idx++)
4876    {
4877       lcCfg = &(cellCfg->cmnLcCfg[idx]);
4878       /* Validate downlink info */
4879       if (lcCfg->dir & RGR_DIR_TX)
4880       {
4881          if (lcCfg->lcType == CM_LTE_LCH_BCCH)
4882          {
4883             if (lcCfg->dlTrchType == CM_LTE_TRCH_DL_SCH)
4884             {
4885                if(cnt == 0)
4886                {
4887                   bitMask |= RGSCH_BCCH_DLSCH_CFG1;
4888                   cnt++;
4889                }
4890                else
4891                {
4892
4893                   if((
4894                      (cellCfg->siCfg.siWinSize == 1)  ||
4895                      (cellCfg->siCfg.siWinSize == 2)  ||
4896                      (cellCfg->siCfg.siWinSize == 5)  ||
4897                      (cellCfg->siCfg.siWinSize == 10) ||
4898                      (cellCfg->siCfg.siWinSize == 15) ||
4899                      (cellCfg->siCfg.siWinSize == 20) ||
4900                      (cellCfg->siCfg.siWinSize == 40)) &&
4901                      (cellCfg->siCfg.retxCnt>0)
4902                     )
4903                   {
4904                      bitMask |= RGSCH_BCCH_DLSCH_CFG2;
4905                   }
4906                   else
4907                   {
4908                      DU_LOG("\nERROR  -->  SCH : Invalid si config for cell");
4909                      return RFAILED;
4910                   }
4911                }
4912             }
4913             else if (lcCfg->dlTrchType == CM_LTE_TRCH_BCH)
4914             {
4915                bitMask |= RGSCH_BCCH_BCH_CFG;
4916             }
4917             else
4918             {
4919                DU_LOG("\nERROR  -->  SCH : Invalid transport channel %d for cell", lcCfg->dlTrchType);
4920                return RFAILED;
4921             }
4922          }
4923          else if (lcCfg->lcType == CM_LTE_LCH_PCCH)
4924          {
4925             bitMask |= RGSCH_PCCH_CFG;
4926          }
4927          else if (lcCfg->lcType == CM_LTE_LCH_CCCH)
4928          {
4929             bitMask |= RGSCH_DL_CCCH_CFG;
4930          }
4931          dirVld = TRUE;
4932       }
4933
4934       /* Validate uplink info */
4935       if (lcCfg->dir & RGR_DIR_RX)
4936       {
4937          /* Uplink CCCH */
4938          if (lcCfg->lcType != CM_LTE_LCH_CCCH)
4939          {
4940             DU_LOG("\nERROR  -->  SCH : Invalid UL common lcType %d for cell", lcCfg->lcType);
4941             return RFAILED;
4942          }
4943          else
4944          {
4945             bitMask |= RGSCH_UL_CCCH_CFG;
4946          }
4947          dirVld = TRUE;
4948       }
4949
4950       /* Invalid direction */
4951       if (!dirVld)
4952       {
4953          DU_LOG("\nERROR  -->  SCH : Invalid Direction %d", lcCfg->dir);
4954          return RFAILED;
4955       }
4956    }
4957    if (bitMask != RGSCH_CELL_ACTIVE_CFG)
4958    {
4959       DU_LOG("\nERROR  -->  SCH : Invalid Common channel config for cell");
4960       return RFAILED;
4961    }
4962
4963    return ROK;
4964 }  /* rgSCHCfgVldtRgrCmnLcCfg */
4965
4966
4967 /***********************************************************
4968  *
4969  *     Func : rgSCHCfgVldtUeCqiModeCfg
4970  *
4971  *
4972  *     Desc : Validates UE CQI modes Configuration recieved from RRC.
4973  *
4974  *     Ret  : S16
4975  *            ROK - Success
4976  *            RFAILED - Failed
4977  *
4978  *     Notes:
4979  *
4980  *     File :
4981  *
4982  **********************************************************/
4983 static S16 rgSCHCfgVldtUeCqiModeCfg
4984 (
4985 RgSchCellCb       *cell,
4986 RgrUeDlCqiCfg     *ueDlCqiCfg
4987 )
4988 {
4989    
4990 #ifndef TFU_UPGRADE
4991    if((ueDlCqiCfg->prdCqiCfg.cqiPmiCfgIdx < 1) || 
4992          (ueDlCqiCfg->prdCqiCfg.cqiPmiCfgIdx > 1024))
4993    {
4994       DU_LOG("\nERROR  -->  SCH : Invalid Periodic CQI Info");
4995       return RFAILED;
4996    }
4997 #endif
4998    /* Validate UE Aperiodic CQI mode */
4999    if ((ueDlCqiCfg->aprdCqiCfg.pres == TRUE) &&
5000        ((ueDlCqiCfg->aprdCqiCfg.aprdModeEnum > RGR_APRD_CQI_MOD31) ||
5001         (cell->bwCfg.dlTotalBw <= 7)))
5002    {
5003       DU_LOG("\nERROR  -->  SCH : Invalid Aperiodic mode config for DL CQI");
5004       return RFAILED;
5005    }
5006 #ifndef TFU_UPGRADE
5007    /* Validate UE Periodic CQI mode */ 
5008    if (ueDlCqiCfg->prdCqiCfg.prdModeEnum > RGR_PRD_CQI_MOD21)
5009    {
5010       DU_LOG("\nERROR  -->  SCH : Invalid periodic mode config for DL CQI");
5011       return RFAILED;
5012    }
5013    /* Validate K value in periodic CQI Config */
5014    if(((ueDlCqiCfg->prdCqiCfg.prdModeEnum == RGR_PRD_CQI_MOD20) ||
5015             (ueDlCqiCfg->prdCqiCfg.prdModeEnum == RGR_PRD_CQI_MOD21)) && 
5016          ((ueDlCqiCfg->prdCqiCfg.k < 1)||
5017             (ueDlCqiCfg->prdCqiCfg.k > 4)))
5018    {
5019       DU_LOG("\nERROR  -->  SCH : Invalid K for Subband CQI reporting");
5020       return RFAILED;
5021    }
5022 #else
5023    if ((ueDlCqiCfg->prdCqiCfg.type == 1) &&
5024        (ueDlCqiCfg->prdCqiCfg.cqiSetup.prdModeEnum > RGR_PRD_CQI_MOD21))
5025    {
5026      DU_LOG("\nERROR  -->  SCH : Invalid periodic mode config for DL CQI");
5027      return RFAILED;
5028    }
5029
5030 #endif
5031    
5032    return ROK;
5033       
5034 }
5035 /***********************************************************
5036  *
5037  *     Func : rgSCHCfgVldtUeMeasGapAckNakRepCfg
5038  *
5039  *
5040  *     Desc : Validates UE Measurement Gap and Ack Nack Repetition Configuration recieved from RRC.
5041  *
5042  *     Ret  : S16
5043  *            ROK - Success
5044  *            RFAILED - Failed
5045  *
5046  *     Notes:
5047  *
5048  *     File :
5049  *
5050  **********************************************************/
5051 static S16 rgSCHCfgVldtUeMeasGapAckNakRepCfg
5052 (
5053 RgSchCellCb       *cell,
5054 RgrUeCfg          *ueCfg
5055 )
5056 {
5057
5058 #ifdef LTE_TDD
5059    if ((ueCfg->ackNackModeEnum == RGR_TDD_ACKNACK_MODE_MULT) &&
5060          (ueCfg->ueAckNackCfg.isAckNackEnabled == TRUE))
5061    {
5062       DU_LOG("\nERROR  -->  SCH : TDD ACK NACK Multiplexing Mode"
5063       "is not allowed when Ack/Nack is Enabled: %d CRNTI:%d",
5064        ueCfg->ueAckNackCfg.ackNackRepFactor,ueCfg->crnti);
5065       return RFAILED;
5066    }
5067 #endif /* LTE_TDD */
5068    /* Validate AckNackRep Factor */
5069    if((ueCfg->ueAckNackCfg.isAckNackEnabled == FALSE) &&
5070          (!ueCfg->ueMesGapCfg.isMesGapEnabled))
5071    {
5072       return ROK;
5073    }
5074
5075    if(ueCfg->ueAckNackCfg.isAckNackEnabled)
5076    {
5077    if ( (ueCfg->ueAckNackCfg.ackNackRepFactor < RGR_ACKNACK_REPFACT_N2)
5078          || (ueCfg->ueAckNackCfg.ackNackRepFactor > RGR_ACKNACK_REPFACT_N6))
5079    {
5080       DU_LOG("\nERROR  -->  SCH : Invalid ACK NACK REP Factor:%d CRNTI:%d",
5081                ueCfg->ueAckNackCfg.ackNackRepFactor,ueCfg->crnti);
5082       return RFAILED;
5083    }
5084    }
5085    if(ueCfg->ueMesGapCfg.isMesGapEnabled)
5086    {
5087    switch(ueCfg->ueMesGapCfg.gapPrd)
5088    {
5089       case RG_MEAS_GAPPRD_40:
5090          if(ueCfg->ueMesGapCfg.gapOffst >= RG_MEAS_GAPPRD_40)
5091          {
5092             DU_LOG("\nERROR  -->  SCH : Invalid GAP Offset:%d CRNTI:%d",
5093                      ueCfg->ueMesGapCfg.gapOffst,ueCfg->crnti);
5094             return RFAILED;
5095          }
5096          break;
5097       case RG_MEAS_GAPPRD_80:
5098          if(ueCfg->ueMesGapCfg.gapOffst >= RG_MEAS_GAPPRD_80)
5099          {
5100             DU_LOG("\nERROR  -->  SCH : Invalid GAP Offset:%d CRNTI:%d",
5101                      ueCfg->ueMesGapCfg.gapOffst,ueCfg->crnti);
5102             return RFAILED;
5103          }
5104          break;
5105          default:
5106          { 
5107             DU_LOG("\nERROR  -->  SCH : Invalid GAP Periodicity Settings:%d"
5108                       "CRNTI:%d", ueCfg->ueMesGapCfg.gapPrd,ueCfg->crnti);
5109             return RFAILED;
5110          }
5111       }
5112    }
5113
5114    return ROK;
5115 }  /* rgSCHCfgVldtUeMeasGapAckNakRepCfg*/
5116
5117
5118 /***********************************************************
5119  *
5120  *     Func : rgSCHCfgVldtUeMeasGapAckNakRepRecfg
5121  *
5122  *
5123  *     Desc : Validates UE Measurement Gap and Ack Nack Repetition Configuration recieved from RRC.
5124  *
5125  *     Ret  : S16
5126  *            ROK - Success
5127  *            RFAILED - Failed
5128  *
5129  *     Notes:
5130  *
5131  *     File :
5132  *
5133  **********************************************************/
5134 static S16 rgSCHCfgVldtUeMeasGapAckNakRepRecfg
5135 (
5136 RgSchCellCb       *cell,
5137 RgrUeRecfg        *ueRecfg
5138 )
5139 {
5140
5141    if((ueRecfg->ueAckNackRecfg.isAckNackEnabled == FALSE) &&
5142           (!ueRecfg->ueMeasGapRecfg.isMesGapEnabled))
5143    {
5144       return ROK;
5145    }
5146
5147    if(ueRecfg->ueAckNackRecfg.isAckNackEnabled )
5148    {
5149    /* Validate AckNackRep Factor */
5150    if ( (ueRecfg->ueAckNackRecfg.ackNackRepFactor < RGR_ACKNACK_REPFACT_N2)
5151          || (ueRecfg->ueAckNackRecfg.ackNackRepFactor > RGR_ACKNACK_REPFACT_N6))
5152    {
5153       DU_LOG("\nERROR  -->  SCH : Invalid ACK NACK REP Factor:%d"
5154                "NEW CRNTI:%d",ueRecfg->ueAckNackRecfg.ackNackRepFactor,ueRecfg->newCrnti);
5155       return RFAILED;
5156    }
5157    }
5158    if(ueRecfg->ueMeasGapRecfg.isMesGapEnabled)
5159    {
5160    switch(ueRecfg->ueMeasGapRecfg.gapPrd)
5161    {
5162       case RG_MEAS_GAPPRD_40:
5163          if(ueRecfg->ueMeasGapRecfg.gapOffst >= RG_MEAS_GAPPRD_40)
5164          {
5165             DU_LOG("\nERROR  -->  SCH : Invalid GAP Offset:%d"
5166                      "NEW CRNTI:%d",ueRecfg->ueMeasGapRecfg.gapOffst,ueRecfg->newCrnti);
5167             return RFAILED;
5168          }
5169          break;
5170       case RG_MEAS_GAPPRD_80:
5171          if(ueRecfg->ueMeasGapRecfg.gapOffst >= RG_MEAS_GAPPRD_80)
5172          {
5173             DU_LOG("\nERROR  -->  SCH : Invalid GAP Offset:%d"
5174                      "NEW CRNTI:%d",ueRecfg->ueMeasGapRecfg.gapOffst,ueRecfg->newCrnti);
5175             return RFAILED;
5176          }
5177          break;
5178          default:
5179          { 
5180             DU_LOG("\nERROR  -->  SCH : Invalid GAP Periodicity Settings:%d"
5181                      "NEW CRNTI:%d",ueRecfg->ueMeasGapRecfg.gapPrd,ueRecfg->newCrnti);
5182             return RFAILED;
5183          }
5184       }
5185    }
5186
5187    return ROK;
5188 }  /* rgSCHCfgVldtUeMeasGapAckNakRepRecfg*/
5189
5190 #ifdef LTEMAC_SPS
5191 /***********************************************************
5192  *
5193  *     Func : rgSCHCfgVldtUeDlSpsCfg
5194  *
5195  *
5196  *     Desc : Validates UE's DL SPS configuration recieved from RRC.
5197  *
5198  *     Ret  : S16
5199  *            ROK - Success
5200  *            RFAILED - Failed
5201  *
5202  *     Notes:
5203  *
5204  *     File :
5205  *
5206  **********************************************************/
5207 static S16 rgSCHCfgVldtUeDlSpsCfg
5208 (
5209 RgSchCellCb       *cell,
5210 RgrUeSpsDlCfg     *dlSpsCfg
5211 )
5212 {
5213
5214    uint8_t                 idx = 0;
5215
5216    /* peridicity validation done in SPS module */
5217    if ((dlSpsCfg->numPucchVal > RG_SCH_MAX_NUM_N1PUCCH_PER_UE) ||
5218          (dlSpsCfg->numPucchVal == 0))
5219    {
5220       DU_LOG("\nERROR  -->  SCH : Invalid number of n1Pucch values"
5221                " in DL SPS Config");
5222       return RFAILED;
5223    }
5224
5225    for (idx = 0; idx < dlSpsCfg->numPucchVal; ++idx)
5226    {
5227       if (dlSpsCfg->n1PucchVal[idx] > RG_SCH_MAX_N1PUCCH_VAL)
5228       {
5229 #ifdef ALIGN_64BIT
5230          DU_LOG("\nERROR  -->  SCH : Invalid N1Pucch value"
5231                   " in DL SPS Config %u", dlSpsCfg->n1PucchVal[idx]);
5232 #else
5233          DU_LOG("\nERROR  -->  SCH : Invalid N1Pucch value"
5234                   " in DL SPS Config %lu", dlSpsCfg->n1PucchVal[idx]);
5235 #endif
5236          return RFAILED;
5237       }
5238    }
5239    /* SPS_TODO: check will change for TDD */
5240    if ((dlSpsCfg->numSpsHqProc == 0) ||
5241          (dlSpsCfg->numSpsHqProc > RGSCH_MAX_DL_HQ_PROC))
5242    {
5243       DU_LOG("\nERROR  -->  SCH : Invalid number of SPS HARQ procs"
5244                " in DL SPS Config");
5245       return RFAILED;
5246    }
5247
5248    return ROK;
5249 }  /* rgSCHCfgVldtDlSpsCfg */
5250 #endif /* LTEMAC_SPS */
5251
5252 /***********************************************************
5253  *
5254  *     Func : rgSCHCfgVldtUePwrCfg
5255  *
5256  *
5257  *     Desc : Validates UE Group power configuration recieved from RRC.
5258  *
5259  *     Ret  : S16
5260  *            ROK - Success
5261  *            RFAILED - Failed
5262  *
5263  *     Notes:
5264  *
5265  *     File :
5266  *
5267  **********************************************************/
5268 static S16 rgSCHCfgVldtUePwrCfg
5269 (
5270 RgSchCellCb       *cell,
5271 RgrUeUlPwrCfg     *pwrCfg
5272 )
5273 {
5274
5275    /* Group power control works only in accumulated mode */
5276    if (!pwrCfg->isAccumulated)
5277    {
5278       /* Fix */
5279       if (pwrCfg->uePuschPwr.pres)
5280       {
5281          DU_LOG("\nERROR  -->  SCH : Accumulation configutation"
5282               " not in sync with group power configuration");
5283          return RFAILED;
5284       }
5285    }
5286
5287    if (rgSCHCfgVldtUeGrpPwrCfg(cell, &pwrCfg->uePuschPwr) != ROK)
5288    {
5289       DU_LOG("\nERROR  -->  SCH : Invalid PUSCH Group power"
5290            " configuration");
5291       return RFAILED;
5292    }
5293    if (rgSCHCfgVldtUeGrpPwrCfg(cell, &pwrCfg->uePucchPwr) != ROK)
5294    {
5295       DU_LOG("\nERROR  -->  SCH : Invalid PUSCH Group power"
5296            " configuration");
5297       return RFAILED;
5298    }
5299
5300    return ROK;
5301 }  /* rgSCHCfgVldtUePwrCfg */
5302
5303 /***********************************************************
5304  *
5305  *     Func : rgSCHCfgVldtUeGrpPwrCfg
5306  *
5307  *
5308  *     Desc : Validates UE Group power configuration recieved from RRC.
5309  *
5310  *     Ret  : S16
5311  *            ROK - Success
5312  *            RFAILED - Failed
5313  *
5314  *     Notes:
5315  *
5316  *     File :
5317  *
5318  **********************************************************/
5319 static S16 rgSCHCfgVldtUeGrpPwrCfg
5320 (
5321 RgSchCellCb       *cell,
5322 RgrUeGrpPwrCfg *grpPwrCfg
5323 )
5324 {
5325
5326    if ((grpPwrCfg->pres) &&
5327        (((grpPwrCfg->tpcRnti > cell->rntiDb.rntiStart) &&
5328         ((grpPwrCfg->tpcRnti <
5329                      (cell->rntiDb.rntiStart + cell->rntiDb.maxRntis))))))
5330    {
5331       DU_LOG("\nERROR  -->  SCH : Invalid Uplink Group power " 
5332              "configuration");
5333       return RFAILED;
5334    }
5335
5336    return ROK;
5337 }  /* rgSCHCfgVldtUeGrpPwrCfg */
5338
5339 #ifdef LTEMAC_SPS
5340 /***********************************************************
5341  *
5342  *     Func : rgSCHCfgVldtSpsReCfg
5343  *
5344  *
5345  *     Desc : Validates UE SPS and other SPS dependent 
5346  *     configuration recieved from RRC.
5347  *
5348  *     Ret  : S16
5349  *            ROK - Success
5350  *            RFAILED - Failed
5351  *
5352  *     Notes:
5353  *
5354  *     File :
5355  *
5356  **********************************************************/
5357 static S16 rgSCHCfgVldtSpsReCfg
5358 (
5359 RgSchCellCb       *cell,
5360 RgSchUeCb         *ue,
5361 RgrUeRecfg        *ueRecfg
5362 )
5363 {
5364
5365    if ((ueRecfg->ueRecfgTypes & RGR_UE_DLSPS_RECFG) &&
5366          (ueRecfg->ueSpsRecfg.dlSpsCfg.isDlSpsEnabled)) 
5367    {
5368       /* Validating SPS RNTI */ 
5369       if (((ueRecfg->ueSpsRecfg.spsRnti >=  cell->rntiDb.rntiStart) && 
5370           (ueRecfg->ueSpsRecfg.spsRnti<=
5371           (cell->rntiDb.rntiStart+cell->rntiDb.maxRntis)))||
5372           (ueRecfg->ueSpsRecfg.spsRnti == RGSCH_SI_RNTI) ||
5373           (ueRecfg->ueSpsRecfg.spsRnti == RGSCH_P_RNTI))
5374       {
5375          DU_LOG("\nERROR  -->  SCH : Invalid SPS RNTI "
5376                   " in DL SPS Recfg OLD CRNTI:%d NEW CCRNTI:%d",
5377                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5378          return RFAILED;
5379       }
5380       if (rgSCHCfgVldtUeDlSpsCfg(cell, &ueRecfg->ueSpsRecfg.dlSpsCfg) != ROK)
5381       {
5382          DU_LOG("\nERROR  -->  SCH : Invalid DL SPS configuration"
5383                   " for the OLD CRNTI:%d NEW CRNTI:%d",
5384                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5385          return RFAILED;
5386       }
5387    }
5388
5389 #if RG_SPS_UNUSED 
5390    if(ueRecfg->ueSpsRecfg.dlSpsCfg.isDlSpsEnabled)
5391    {
5392      if (ueRecfg->ueRecfgTypes & RGR_UE_DRX_RECFG)
5393      {
5394      /* ccpu00117035 - MOD - changed instIdx to inst */
5395      /* ccpu00117035 - MOD - changed ueID to oldCrnti*/
5396        DU_LOG("\nERROR  -->  SCH :  DRX reconfig not supported DL SPS enabled for OLD CRNTI:%d NEW CRNTI:%d", 
5397                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5398        return RFAILED;
5399      }
5400    }
5401 #endif
5402 /* ccpu00117627 - ADD - SPS recfg validation against HDFDD */
5403 #ifdef LTEMAC_HDFDD
5404    if(ueRecfg->ueSpsRecfg.dlSpsCfg.isDlSpsEnabled)
5405    {
5406       if(ue->hdFddEnbld == TRUE)
5407       {
5408          DU_LOG("\nERROR  -->  SCH : DL SPS is not supported for HDFDD enabled for OLD CRNTI:%d NEW CRNTI:%d",
5409                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5410          return RFAILED;
5411       }
5412    }
5413    if(ueRecfg->ueSpsRecfg.ulSpsCfg.isUlSpsEnabled)
5414    {
5415       if(ue->hdFddEnbld == TRUE)
5416       {
5417          DU_LOG("\nERROR  -->  SCH : UL SPS is not supported for HDFDD enabled for OLD CRNTI:%d NEW CRNTI:%d",
5418                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5419          return RFAILED;
5420       }
5421    }
5422 #endif
5423
5424    return ROK;
5425 }  /*rgSCHCfgVldtSpsReCfg*/
5426 #endif
5427
5428 #if ((defined (RGR_CQI_REPT)) && (defined (RGR_V2)))
5429 /***********************************************************
5430  *
5431  *     Func : rgSCHCfgVldtCqiReptReCfg
5432  *
5433  *
5434  *     Desc : Validates UE CQI report for DL Power control
5435  *     configuration recieved from RRC.
5436  *
5437  *     Ret  : S16
5438  *            ROK - Success
5439  *            RFAILED - Failed
5440  *
5441  *     Notes:
5442  *
5443  *     File :
5444  *
5445  **********************************************************/
5446 static S16 rgSCHCfgVldtCqiReptReCfg
5447 (
5448 RgSchCellCb       *cell,
5449 RgrUeRecfg     *ueRecfg
5450 )
5451 {
5452
5453    /* Validate DL Power Control Config parameters */
5454    if (ueRecfg->ueCqiReptCfg.numColltdCqiRept > RGR_CQIRPTS_MAXN)
5455    {
5456       DU_LOG("\nERROR  -->  SCH : Invalide numColltdCqiRept,"
5457                "MAX supported %d for OLD CRNTI:%d NEW CRNTI:%d",RGR_CQIRPTS_MAXN,
5458                   ueRecfg->oldCrnti,ueRecfg->newCrnti);
5459       return RFAILED;
5460    }
5461
5462    return ROK;
5463 }  /*rgSCHCfgVldtCqiReptReCfg*/
5464 #endif
5465
5466 /***********************************************************
5467  *
5468  *     Func : rgSCHCfgRgrLcChfg
5469  *
5470  *
5471  *     Desc : Handles dedicated logical channel configuration 
5472  *     recieved from RRC.
5473  *
5474  *     Ret  : S16
5475  *            ROK - Success
5476  *            RFAILED - Failed
5477  *
5478  *     Notes:
5479  *
5480  *     File :
5481  *
5482  **********************************************************/
5483 S16 rgSCHCfgRgrLchCfg
5484 (
5485 RgSchCellCb      *cell,
5486 RgSchUeCb        *ue,
5487 RgrLchCfg     *lcCfg,
5488 RgSchErrInfo     *errInfo
5489 )
5490 {
5491    S16       ret;
5492    RgSchDlLcCb  *dlLc = NULLP;
5493    Inst    inst = cell->instIdx;
5494 #ifdef LTE_L2_MEAS
5495    RgSchUlLcCb  *ulLc; 
5496 #endif
5497
5498    errInfo->errCause = RGSCHERR_CFG_RGR_DED_LC_CFG;
5499
5500    /* Allocate the downlink logical channel control block */
5501    if((ret = rgSCHUtlAllocSBuf(inst, (Data**)&dlLc, 
5502                sizeof(RgSchDlLcCb))) != ROK)
5503    {
5504       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for "
5505                "Downlink LCId:%d CRNTI:%d", lcCfg->lcId,lcCfg->crnti);
5506       return RFAILED;
5507    }
5508    if ((uint8_t *)dlLc == NULLP)
5509    {
5510       DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED for "
5511                "Downlink LCID:%d CRNTI:%d", lcCfg->lcId,lcCfg->crnti);
5512       return RFAILED;
5513    }
5514    dlLc->lcId   = lcCfg->lcId;
5515 #ifdef LTE_ADV
5516    rgSCHLaaLcCfg(cell, dlLc, lcCfg);
5517 #endif
5518
5519    rgSCHDbmInsDlDedLcCb(ue, dlLc);
5520    
5521    ret = rgSCHUtlRgrLcCfg(cell, ue, dlLc, lcCfg, errInfo);
5522
5523    if (ret != ROK)
5524    {
5525       /* ROLLBACK */
5526       if (dlLc)
5527       {
5528          rgSCHDbmDelDlDedLcCb(ue, dlLc);
5529          rgSCHCfgFreeDlDedLcCb(cell, ue, dlLc);
5530       }
5531
5532       DU_LOG("\nERROR  -->  SCH : Dedicated logical channel "
5533         "configuration failed at SCH:UEID:%d LCID:%d CRNTI:%d",
5534         ue->ueId, lcCfg->lcId,lcCfg->crnti);
5535       return RFAILED;
5536    }
5537 #ifdef LTE_L2_MEAS
5538    RGSCH_ARRAY_BOUND_CHECK(inst, ue->ul.lcCb, (lcCfg->lcId -1));
5539    if ( !lcCfg->lcId || 
5540          (TRUE == ue->ul.lcCb[lcCfg->lcId -1].isValid))
5541    {
5542       /* ROLLBACK */
5543       if (dlLc)
5544       {
5545          rgSCHDbmDelDlDedLcCb(ue, dlLc);
5546          rgSCHCfgFreeDlDedLcCb(cell, ue, dlLc);
5547       }
5548
5549       DU_LOG("\nERROR  -->  SCH : Dedicated logical channel "
5550         "configuration failed at SCH: UL LC CB already existing"
5551         " UEID:%d LCID:%d CRNTI:%d",
5552         ue->ueId, lcCfg->lcId,lcCfg->crnti);
5553       return RFAILED;
5554    }
5555
5556    /* Create UL LC context to maintain LCG to LC mapping and 
5557       LC and QCI mapping, this is for L2 Counters :UL ACTIVE UE 
5558       PER QCI */
5559    ue->ul.lcCb[lcCfg->lcId -1].isValid = TRUE;
5560    ulLc = &(ue->ul.lcCb[lcCfg->lcId -1]);
5561
5562    ulLc->lcId = lcCfg->lcId;
5563    ulLc->qciCb = &(cell->qciArray[lcCfg->dlInfo.dlQos.qci]);
5564    ulLc->qciCb->qci = lcCfg->dlInfo.dlQos.qci;
5565    ue->ul.lcgArr[lcCfg->lcgId].lcArray[ue->ul.lcgArr[lcCfg->lcgId].numLch] = ulLc;
5566    ulLc->lcg = &ue->ul.lcgArr[lcCfg->lcgId];
5567    ulLc->lcgArrIdx = ue->ul.lcgArr[lcCfg->lcgId].numLch;
5568    ue->ul.lcgArr[lcCfg->lcgId].numLch++;
5569
5570    dlLc->qciCb = &(cell->qciArray[lcCfg->dlInfo.dlQos.qci]);
5571    dlLc->qciCb->qci = lcCfg->dlInfo.dlQos.qci;
5572    if(lcCfg->lcType == CM_LTE_LCH_DTCH)
5573    {
5574      rgSchAddToL2Meas(cell,dlLc); /*LTE_L2_MEAS_PHASE2*/
5575    }
5576 #endif /* LTE_L2_MEAS */
5577
5578    return ROK;
5579 }  /* rgSCHCfgRgrLchCfg */
5580
5581 /***********************************************************
5582  *
5583  *     Func : rgSCHCfgRgrLcgCfg
5584  *
5585  *
5586  *     Desc : Handles dedicated logical channel group configuration
5587  *     recieved from RRM.
5588  *
5589  *     Ret  : S16
5590  *            ROK - Success
5591  *            RFAILED - Failed
5592  *
5593  *     Notes:
5594  *
5595  *     File :
5596  *
5597  **********************************************************/
5598 S16 rgSCHCfgRgrLcgCfg
5599 (
5600 RgSchCellCb      *cell,
5601 RgSchUeCb        *ue,
5602 RgrLcgCfg        *lcgCfg,
5603 RgSchErrInfo     *errInfo
5604 )
5605 {
5606    S16          ret = ROK;
5607
5608 #ifdef RG_UNUSED
5609 //#ifdef LTE_L2_MEAS
5610    uint32_t          idx;
5611    RgSchUlLcCb  *ulLc; 
5612 #endif
5613
5614    errInfo->errCause = RGSCHERR_CFG_RGR_DED_LCG_CFG;
5615
5616    ue->ul.lcgArr[lcgCfg->ulInfo.lcgId].lcgId = lcgCfg->ulInfo.lcgId;
5617
5618    ret = rgSCHUtlRgrLcgCfg(cell, ue, lcgCfg, errInfo);
5619    if (ret != ROK)
5620    {
5621       DU_LOG("\nERROR  -->  SCH : Dedicated logical channel "
5622         "configuration failed at SCH: UEID:%d LCGID:%d CRNTI:%d",
5623         ue->ueId, lcgCfg->ulInfo.lcgId,lcgCfg->crnti);
5624       /* Roll back lcgCfg */
5625       ue->ul.lcgArr[lcgCfg->ulInfo.lcgId].lcgId = RGSCH_INVALID_LCG_ID;
5626       rgSCHUtlRgrLcgDel(cell, ue, lcgCfg->ulInfo.lcgId);
5627       return RFAILED;
5628    }
5629 #ifdef RG_UNUSED
5630 //#ifdef LTE_L2_MEAS
5631    /* Copy all info of UL LCH in cfg to ulLcgCb */
5632    for (idx = 0; idx < lcgCfg->ulInfo.numLch; idx++)
5633    {
5634       /* Allocate the uplink logical channel control block */
5635       if((ret = rgSCHUtlAllocSBuf(cell->instIdx, (Data**)&ulLc, 
5636                   sizeof(RgSchUlLcCb))) != ROK)
5637       {
5638          DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED ");
5639          return RFAILED;
5640       }
5641       if ((uint8_t *)ulLc == NULLP)
5642       {
5643          DU_LOG("\nERROR  -->  SCH : Memory allocation FAILED ");
5644          return RFAILED;
5645       }
5646       /* Create UL LC context to maintain LCG to LC mapping and 
5647          LC and QCI mapping, this is for L2 Counters :UL ACTIVE UE 
5648          PER QCI */
5649       ulLc->lcId = lcgCfg->ulInfo.lchUlCfg[idx].lcId;
5650       ulLc->qciCb = &(cell->qciArray[lcgCfg->ulInfo.lchUlCfg[idx].qci]);
5651       ulLc->qciCb->qci = lcgCfg->ulInfo.lchUlCfg[idx].qci;
5652       ue->ul.lcgArr[lcgCfg->ulInfo.lcgId].lcArray[idx] = ulLc;
5653       /* L2_COUNTERS */
5654       ue->ul.lcCb[ulLc->lcId -1] = ulLc;
5655       ulLc->lcg = &ue->ul.lcgArr[lcgCfg->ulInfo.lcgId];
5656       ulLc->lcgArrIdx = idx;
5657    }
5658    ue->ul.lcgArr[lcgCfg->ulInfo.lcgId].numLch = lcgCfg->ulInfo.numLch;
5659 #endif /* LTE_L2_MEAS */
5660
5661    return ROK;
5662 }  /* rgSCHCfgRgrLcgCfg */
5663
5664
5665
5666 /***********************************************************
5667  *
5668  *     Func : rgSCHCfgRgrCmnLcCfg
5669  *
5670  *
5671  *     Desc : Handles dedicated logical channel configuration 
5672  *     recieved from RRC.
5673  *
5674  *     Ret  : S16
5675  *            ROK - Success
5676  *            RFAILED - Failed
5677  *
5678  *     Notes:
5679  *
5680  *     File :
5681  *
5682  **********************************************************/
5683 static S16 rgSCHCfgRgrCmnLcCfg
5684 (
5685 RgSchCellCb           *cell,
5686 RgrCmnLchCfg          *lcCfg,
5687 RgSchErrInfo          *errInfo
5688 )
5689 {
5690    RgSchClcDlLcCb cmnLcCb;
5691
5692    errInfo->errCause = RGSCHERR_CFG_RGR_CMN_LC_CFG;
5693
5694    memset(&cmnLcCb, 0, sizeof(cmnLcCb));
5695
5696    /* Handle configuration for CCCH/BCCH/PCCH */
5697    if (lcCfg->lcType == CM_LTE_LCH_CCCH)
5698    {
5699       /* UL and DL CCCH configuration */
5700       if (lcCfg->dir & RGR_DIR_TX)
5701       {
5702          cell->dlCcchId = lcCfg->lcId;
5703       }
5704
5705       if (lcCfg->dir & RGR_DIR_RX)
5706       {
5707          cell->ulCcchId = lcCfg->lcId;
5708       }
5709    }
5710    else
5711    {
5712       cmnLcCb.lcId = lcCfg->lcId;
5713       rgSCHDbmInitCmnLcBoLst(&cmnLcCb);
5714       if (lcCfg->lcType == CM_LTE_LCH_BCCH)
5715       {
5716          /* BCCH on BCH and DLSCH configuration */
5717          if (lcCfg->dlTrchType == CM_LTE_TRCH_DL_SCH)
5718          {
5719             rgSCHDbmInsBcchOnDlsch(cell, &cmnLcCb);
5720          }
5721          else
5722          {
5723             rgSCHDbmInsBcchOnBch(cell, &cmnLcCb);
5724          }
5725       }
5726       else  /* PCCH configuration */
5727       {
5728          rgSCHDbmInsPcch(cell, &cmnLcCb);
5729       }
5730    }
5731
5732    return ROK;
5733 }  /* rgSCHCfgRgrCmnLcCfg */
5734
5735
5736
5737 /***********************************************************
5738  *
5739  *     Func : rgSCHCfgFreeDlDedLcCb
5740  *
5741  *
5742  *     Desc :
5743  *     - Processing Steps:
5744  *        - Frees downlink dedicated logical channel control block.
5745  *
5746  *     Ret  : Void
5747  *
5748  *     Notes:
5749  *
5750  *     File :
5751  *
5752  **********************************************************/
5753 static Void rgSCHCfgFreeDlDedLcCb
5754 (
5755 RgSchCellCb      *cell,
5756 RgSchUeCb        *ue,
5757 RgSchDlLcCb      *dlLc
5758 )
5759 {
5760    Inst    inst = cell->instIdx;
5761
5762    rgSCHUtlFreeDlLc(cell, ue, dlLc);
5763
5764    /* De-allocate the Cb */
5765    /* ccpu00117052 - MOD - Passing double pointer
5766       for proper NULLP assignment*/
5767    rgSCHUtlFreeSBuf(inst, (Data **)&dlLc, sizeof(*dlLc));
5768
5769
5770   /* Stack Crash problem for TRACE5 changes. Added the return below */
5771   return;
5772
5773 }  /* rgSCHCfgFreeDlDedLcCb */
5774
5775
5776 /***********************************************************
5777  *
5778  *     Func : rgSCHCfgFreeDlCmnLcCb
5779  *
5780  *
5781  *     Desc :
5782  *     - Processing Steps:
5783  *        - Frees downlink common logical channel control block.
5784  *
5785  *     Ret  : Void
5786  *
5787  *     Notes:
5788  *
5789  *     File :
5790  *
5791  **********************************************************/
5792 static Void rgSCHCfgFreeDlCmnLcCb(RgSchClcDlLcCb   *cmnDlLc)
5793 {
5794  
5795    memset(cmnDlLc, 0, sizeof(*cmnDlLc));
5796    cmnDlLc->lcId = RGSCH_INVALID_LC_ID;
5797    return;
5798 }  /* rgSCHCfgFreeDlCmnLcCb */
5799
5800
5801 /***********************************************************
5802  *
5803  *     Func : rgSCHCfgFreeCellCb
5804  *
5805  *
5806  *     Desc :
5807  *     - Processing Steps:
5808  *        - Frees scheduler cell control block.
5809  *
5810  *     Ret  : Void
5811  *
5812  *     Notes:
5813  *
5814  *     File :
5815  *
5816  **********************************************************/
5817 Void rgSCHCfgFreeCellCb(RgSchCellCb      *cell)
5818 {
5819    Inst    inst = cell->instIdx;
5820    CmLList            *node;
5821    Buffer             *pdu;
5822    RgSchWarningSiInfo *warningSi;
5823    RgSchWarningSiPdu  *warningSiPdu;
5824    uint8_t                  idx;
5825  
5826    /* ccpu00132385- SI Warning PDUs which are not processed need to be deleted */
5827    /* Search for used index in WarningSi */
5828    for(idx = 0; idx < RGR_MAX_NUM_WARNING_SI; idx++)
5829    {
5830       if(cell->siCb.warningSi[idx].siId == 0)
5831         continue;
5832       cell->siCb.siCtx.siId = cell->siCb.warningSi[idx].siId;
5833       warningSi = (RgSchWarningSiInfo *) cell->siCb.
5834                   siArray[cell->siCb.siCtx.siId-1].si; 
5835       if(warningSi != NULLP)
5836       {
5837          /* ccpu00136659: CMAS ETWS design change */
5838          while (CM_LLIST_FIRST_NODE(&warningSi->warningSiMsg.segLstCp, node))
5839          {
5840             warningSiPdu = (RgSchWarningSiPdu *)node->node;
5841             pdu = warningSiPdu->pdu;
5842             /* ccpu00136659: CMAS ETWS design change */
5843             cmLListDelFrm(&warningSi->warningSiMsg.segLstCp, node);
5844             RGSCH_FREE_MSG(pdu);
5845          }
5846          cell->siCb.siArray[cell->siCb.siCtx.siId-1].si = NULLP;
5847       }
5848    }
5849    /* Free lists of the cell */
5850    rgSCHCfgFreeUeLst(cell);
5851 #ifdef LTEMAC_SPS
5852    rgSCHCfgFreeSpsUeLst(cell);
5853 #endif /* LTEMAC_SPS */
5854 #ifdef EMTC_ENABLE
5855       if ( TRUE == cell->emtcEnable )
5856       {
5857          rgSCHEmtcCellDel(cell);
5858       }
5859 #endif
5860    rgSCHRamFreeCell(cell);
5861
5862    rgSCHDbmRntiDbDeInit(cell);
5863    /* Deallocate the subframe allocation information */
5864    rgSCHUtlPutSfAlloc(cell);
5865    rgSCHUtlFreeCell(cell);
5866
5867    rgSCHCfgFreeRgrCfgLst(cell);
5868    rgSCHCfgFreeCmnLcLst(cell);
5869
5870    rgSCHUtlPutRlsHqAlloc(cell);
5871
5872 #ifdef LTE_TDD
5873    rgSCHDbmDeInitUeTfuPendLst(cell);
5874 #endif /* LTE_TDD */
5875
5876 #ifdef RGR_SI_SCH
5877    rgSCHUtlPutSiInfo(cell);
5878 #endif/*RGR_SI_SCH*/
5879
5880    (Void)rgSCHDrxCellDel(cell);
5881
5882    rgSCHUtlFreeSBuf(inst, (Data**)&(cell->dynCfiCb.cceFailSamples),
5883                (cell->dynCfiCb.numFailSamples * sizeof(uint16_t)));
5884
5885 #ifdef TENB_STATS
5886    TSL2DeallocCellStatsBlk(cell->cellId); 
5887 #endif
5888
5889 #ifdef LTE_ADV
5890    /* LAA_SCELL: Trigger the De-Init function for the LAA Module */
5891    rgSCHLaaSCellCbDeInit(cell);
5892 #endif
5893
5894 #ifdef EMTC_ENABLE
5895    if(cell->emtcEnable)
5896    {
5897       rgSCHEmtcCellFree(cell);
5898    }
5899 #endif
5900    /* De-allocate the Cell */
5901    /* ccpu00117052 - MOD - Passing double pointer
5902    for proper NULLP assignment*/
5903    rgSCHUtlFreeSBuf(inst, (Data **)&cell, sizeof(*cell));
5904
5905  
5906
5907   /* Stack Crash problem for TRACE5 changes. Added the return below */
5908   return;
5909
5910 }  /* rgSCHCfgFreeCellCb */
5911
5912
5913 /***********************************************************
5914  *
5915  *     Func : rgSCHCfgFreeUeCb
5916  *
5917  *
5918  *     Desc :
5919  *     - Processing Steps:
5920  *        - Frees UE control block.
5921  *
5922  *     Ret  : Void
5923  *
5924  *     Notes:
5925  *
5926  *     File :
5927  *
5928  **********************************************************/
5929 static Void rgSCHCfgFreeUeCb
5930 (
5931 RgSchCellCb    *cell,
5932 RgSchUeCb      *ue
5933 )
5934 {
5935    RgSchCmnUlUe *ueUl = RG_SCH_CMN_GET_UL_UE(ue, cell);
5936    RgUeUlHqCb       *ulHqEnt;
5937    RgSchDlLcCb       *dlLc;
5938    Inst    inst = cell->instIdx;
5939    uint8_t lcCnt; 
5940    uint8_t lcgId; 
5941
5942    /* Free all logical channel info per UE */
5943    while((dlLc = rgSCHDbmGetNextDlDedLcCb(ue, NULLP)) != NULLP)
5944    {
5945       rgSCHDbmDelDlDedLcCb(ue, dlLc);
5946       rgSCHCfgFreeDlDedLcCb(cell, ue, dlLc);
5947    }
5948    for (lcCnt =0; lcCnt<RGSCH_MAX_LC_PER_UE; lcCnt++)
5949    {
5950       if(ue->ul.lcCb[lcCnt].isValid == TRUE) 
5951       {
5952          lcgId = ue->ul.lcCb[lcCnt].lcg->lcgId;
5953          if (lcgId <=3)
5954          {
5955             rgSCHUtlRgrLcDel(cell, ue, ue->ul.lcCb[lcCnt].lcId,lcgId); 
5956             ue->ul.lcCb[lcCnt].isValid = FALSE;
5957          }
5958       }
5959    }
5960
5961    ulHqEnt = &(ueUl->hqEnt);
5962    /* Free Scheduler specific information per UE */
5963    rgSCHUtlFreeUe(cell, ue);
5964
5965    /* Free Uplink HARQ specific information per UE */
5966    rgSCHUhmFreeUe(cell, ulHqEnt);
5967
5968    if ( ue->drxCb != NULLP)
5969    {
5970       /* free drxCb */
5971    /* ccpu00117052 - MOD - Passing double pointer
5972    for proper NULLP assignment*/
5973       rgSCHUtlFreeSBuf(cell->instIdx,
5974             (Data**)(&(ue->drxCb)),
5975             sizeof(RgSchDrxUeCb));
5976    }
5977
5978    ue->drxCb = (RgSchDrxUeCb *)NULLP;
5979    /* Free Downlink HARQ specific information per UE */
5980    rgSCHDhmFreeUe(ue);
5981    /* Release the RNTI */
5982    if (ue->rntiLnk)
5983    {
5984       rgSCHUtlRlsRnti(cell, ue->rntiLnk, FALSE, 0);
5985    }
5986    else
5987    {
5988       /* Fix : syed HO UE does not have a valid ue->rntiLnk */
5989       /* Just indicate to MAC, no need to release at SCH */
5990       rgSCHUtlIndRntiRls2Mac(cell, ue->ueId, FALSE, 0);
5991    }
5992 /* rg009.201. Added changes of TFU_UPGRADE */
5993 #ifdef TFU_UPGRADE
5994     rgSCHCfgPCqiSrsSrUeDel(cell,ue); 
5995 #endif 
5996 #ifdef LTEMAC_HDFDD
5997     rgSCHHdFddUeDel(cell, ue);
5998 #endif
5999 #ifdef TENB_STATS
6000     if (ue->tenbStats)
6001     {
6002        TSL2DeallocUeStatsBlk(ue->ueId, ue->tenbStats); 
6003     }
6004 #endif
6005
6006    /* CA TODO Some handling needed while SCell Delete*/
6007 #ifdef LTE_ADV
6008    /* Delete the UE from the PCell secCellActCeLst*/
6009    rgSCHSCellRmvFrmActLst(cell, ue);
6010    rgSCHSCellDelUe(cell,ue);
6011 #endif
6012    
6013 #ifdef LTE_ADV
6014    rgSCHLaaDeInitDlRbAllocCb(cell, &ue->cellInfo[RGSCH_PCELL_INDEX]->dlAllocCb);
6015 #endif
6016
6017    rgSCHUtlFreeSBuf(inst, (Data **)&ue->cellInfo[0], sizeof(RgSchUeCellInfo));
6018    /* De-allocate the Ue */
6019    /* ccpu00117052 - MOD - Passing double pointer
6020    for proper NULLP assignment*/
6021 #ifdef EMTC_ENABLE
6022    if(ue->isEmtcUe)
6023    {
6024       rgSCHEmtcUeInfoFree(cell, ue);
6025    }
6026 #endif
6027    rgSCHUtlFreeSBuf(inst, (Data **)&ue, sizeof(*ue));
6028
6029   /* Stack Crash problem for TRACE5 changes. Added the return below */
6030   return;
6031
6032 }  /* rgSCHCfgFreeUeCb */
6033
6034 /***********************************************************
6035  *
6036  *     Func : rgSCHCfgFreeRgrCfgLst
6037  *
6038  *
6039  *     Desc :
6040  *     - Processing Steps:
6041  *        - Frees configuration lists in cell control block.
6042  *
6043  *     Ret  : Void
6044  *
6045  *     Notes:
6046  *
6047  *     File :
6048  *
6049  **********************************************************/
6050 static Void rgSCHCfgFreeRgrCfgLst
6051 (
6052 RgSchCellCb      *cell
6053 )
6054 {
6055    RgSchCfgElem  *rgCfgElem;
6056    Inst    inst = cell->instIdx;
6057
6058    /* Free CURRENT RGR cfg list */
6059    while ((rgCfgElem = rgSCHDbmGetNextCrntRgrCfgElem(cell, NULLP)) != NULLP)
6060    {
6061       rgSCHDbmDelCrntRgrCfgElem(cell, rgCfgElem);
6062    /* ccpu00117052 - MOD - Passing double pointer
6063    for proper NULLP assignment*/
6064       rgSCHUtlFreeSBuf(inst, (Data **)&rgCfgElem, sizeof(*rgCfgElem));
6065    }
6066
6067    /* Free PENDING RGR cfg list */
6068    while ((rgCfgElem = rgSCHDbmGetNextPndngRgrCfgElem(cell, NULLP)) != NULLP)
6069    {
6070       rgSCHDbmDelPndngRgrCfgElem(cell, rgCfgElem);
6071    /* ccpu00117052 - MOD - Passing double pointer
6072    for proper NULLP assignment*/
6073       rgSCHUtlFreeSBuf(inst, (Data **)&rgCfgElem, sizeof(*rgCfgElem));
6074    }
6075
6076
6077   /* Stack Crash problem for TRACE5 changes. Added the return below */
6078   return;
6079
6080 }  /* rgSCHCfgFreeRgrCfgLst */
6081
6082
6083 /***********************************************************
6084  *
6085  *     Func : rgSCHCfgFreeCmnLcLst
6086  *
6087  *
6088  *     Desc :
6089  *     - Processing Steps:
6090  *        - Frees common logical channels in cell control block.
6091  *
6092  *     Ret  : Void
6093  *
6094  *     Notes:
6095  *
6096  *     File :
6097  *
6098  **********************************************************/
6099 static Void rgSCHCfgFreeCmnLcLst
6100 (
6101 RgSchCellCb      *cell
6102 )
6103 {
6104    RgSchClcDlLcCb *dlCmnLc;
6105
6106
6107    if ((dlCmnLc = rgSCHDbmGetBcchOnBch(cell)) != NULLP)
6108    {
6109       rgSCHCfgFreeDlCmnLcCb(dlCmnLc);
6110    }
6111    if ((dlCmnLc = rgSCHDbmGetFirstBcchOnDlsch(cell)) != NULLP)
6112    {
6113       rgSCHCfgFreeDlCmnLcCb(dlCmnLc);
6114    }
6115    if ((dlCmnLc = rgSCHDbmGetSecondBcchOnDlsch(cell)) != NULLP)
6116    {
6117       rgSCHCfgFreeDlCmnLcCb(dlCmnLc);
6118    }
6119    if ((dlCmnLc = rgSCHDbmGetPcch(cell)) != NULLP)
6120    {
6121       rgSCHCfgFreeDlCmnLcCb(dlCmnLc);
6122    }
6123
6124
6125   /* Stack Crash problem for TRACE5 changes. Added the return below */
6126   return;
6127
6128 }  /* rgSCHCfgFreeCmnLcLst */
6129
6130
6131 /***********************************************************
6132  *
6133  *     Func : rgSCHCfgFreeUeLst
6134  *
6135  *
6136  *     Desc :
6137  *     - Processing Steps:
6138  *        - Frees UE list in cell control block.
6139  *
6140  *     Ret  : Void
6141  *
6142  *     Notes:
6143  *
6144  *     File :
6145  *
6146  **********************************************************/
6147 static Void rgSCHCfgFreeUeLst
6148 (
6149 RgSchCellCb      *cell
6150 )
6151 {
6152    RgSchUeCb     *ue;
6153 #ifdef LTE_ADV
6154    RgSchUeCellInfo *sCellInfo;       
6155    CmLList         *node;
6156 #endif
6157
6158    /* Free Ues in the list */
6159    while ((ue = rgSCHDbmGetNextUeCb(cell, NULLP)) != NULLP)
6160    {
6161       rgSCHDbmDelUeCb(cell, ue);
6162
6163 #ifdef LTE_ADV
6164       if(ue->cell != cell)
6165       {
6166          continue;
6167       }
6168 #endif
6169       
6170       /* Call MeasGap and AckNakRep processing module */
6171       rgSCHMeasGapANRepUeDel(cell, ue, TRUE);
6172
6173       rgSCHCfgFreeUeCb(cell, ue);
6174    }
6175
6176    /* De-initialize the Ue list */
6177    rgSCHDbmDeInitUeCbLst(cell);
6178
6179
6180 #ifdef LTE_ADV
6181    node = cell->sCellUeLst.first; 
6182    while(node)
6183    {
6184       sCellInfo = (RgSchUeCellInfo *)node->node;
6185       node = node->next;
6186       rgSCHSCellDelUeSCell(sCellInfo->ue->cell, sCellInfo->ue, sCellInfo->sCellIdx);
6187    }   
6188 #endif
6189
6190   /* Stack Crash problem for TRACE5 changes. Added the return below */
6191   return;
6192
6193 }  /* rgSCHCfgFreeUeLst */
6194
6195 #ifdef LTEMAC_SPS
6196 /***********************************************************
6197  *
6198  *     Func : rgSCHCfgFreeSpsUeLst
6199  *
6200  *
6201  *     Desc :
6202  *     - Processing Steps:
6203  *        - Frees Sps UE list in cell control block.
6204  *
6205  *     Ret  : Void
6206  *
6207  *     Notes:
6208  *
6209  *     File :
6210  *
6211  **********************************************************/
6212 static Void rgSCHCfgFreeSpsUeLst(RgSchCellCb *cell)
6213 {
6214    RgSchUeCb     *ue;
6215
6216    /* Free Ues in the list */
6217    while ((ue = rgSCHDbmGetNextSpsUeCb(cell, NULLP)))
6218    {
6219       rgSCHDbmDelSpsUeCb(cell, ue);
6220    }
6221
6222    /* De-initialize the Ue list */
6223    rgSCHDbmDeInitSpsUeCbLst(cell);
6224
6225 }  /* rgSCHCfgFreeSpsUeLst */
6226
6227 #endif /* LTEMAC_SPS */
6228
6229 #ifdef RGR_SI_SCH
6230 /***********************************************************
6231  *
6232  *     Func : rgSCHCfgVldtRgrCellSiCfg
6233  *
6234  *     Desc : Validates SI Configuration for SI
6235  *
6236  *     Ret  : S16
6237  *            ROK - Success
6238  *            RFAILED - Failed
6239  *
6240  *     Notes:
6241  *
6242  *     File :
6243  *
6244  **********************************************************/
6245 static S16 rgSCHCfgVldtRgrCellSiCfg
6246 (
6247 Inst             inst,
6248 RgrSiCfg         *siCfg
6249 )
6250 {
6251    uint8_t   idx; /* idx for iteration */
6252
6253    UNUSED(inst);
6254
6255 #ifndef LTE_TDD
6256    /* Check that retxCnt value should be <= value of siWinSize.
6257    This validation is only applicable for FDD mode. */
6258    if(siCfg->retxCnt > siCfg->siWinSize) 
6259    {
6260       DU_LOG("\nERROR  -->  SCH : retxCnt is greater than siWinSize, validation failed");
6261       return RFAILED;
6262    }
6263 #endif
6264
6265    /* Validate that a valid value for numSi has been specified */
6266    if(siCfg->numSi > RGR_MAX_NUM_SI) 
6267    {
6268       DU_LOG("\nERROR  -->  SCH : Validation for numSi in SI CFG failed");
6269       return RFAILED;
6270    }
6271
6272    /* MinPeriodicity will have the least configured periodicity
6273     * Hence initializing with Max periodicity */
6274    siCfg->minPeriodicity = RGR_SI_PERD_512;
6275
6276    /*Validate the value of periodicity specified for SIs */
6277    for(idx = 0;idx < siCfg->numSi;idx++)
6278    {
6279       siCfg->minPeriodicity =     RGSCH_MIN(siCfg->minPeriodicity, 
6280             siCfg->siPeriodicity[idx]);
6281          /* Set the siPeriodicity as a multiple of 80 subframes */
6282          switch(siCfg->siPeriodicity[idx])
6283          {
6284             case RGR_SI_PERD_8:
6285             case RGR_SI_PERD_16:
6286             case RGR_SI_PERD_32:
6287             case RGR_SI_PERD_64:
6288             case RGR_SI_PERD_128:
6289             case RGR_SI_PERD_256:
6290             case RGR_SI_PERD_512:
6291                continue;
6292
6293          default:
6294             DU_LOG("\nERROR  -->  SCH : Validation for SI Periodicity in SI-CFG failed");
6295             return RFAILED;
6296       }
6297    }
6298
6299    return ROK;
6300 }  /* rgSCHCfgVldtRgrCellSiCfg */
6301
6302 /* LTE_ADV_FLAG_REMOVED_START */
6303 /***********************************************************
6304  *
6305  *     Func : rgSCHCfgVldtRgrCellLtrAdvCfg
6306  *
6307  *     Desc : Validates Lte Adv Configuration
6308  *
6309  *     Ret  : S16
6310  *            ROK - Success
6311  *            RFAILED - Failed
6312  *
6313  *     Notes:
6314  *
6315  *     File :
6316  *
6317  **********************************************************/
6318 static S16 rgSCHCfgVldtRgrCellLteAdvCfg
6319 (
6320 Inst                     inst,
6321 RgrLteAdvancedCellConfig *lteAdvCfg,
6322 uint8_t                       dlTotalBw  
6323 )
6324 {
6325    uint8_t temp[RGR_ABS_PATTERN_LEN];
6326    uint32_t idx;
6327    UNUSED(inst);
6328
6329    if((lteAdvCfg->pres & RGR_SFR) && (RGR_ENABLE == lteAdvCfg->sfrCfg.status))
6330    {
6331       if(lteAdvCfg->sfrCfg.cellEdgeRbRange.startRb > lteAdvCfg->sfrCfg.cellEdgeRbRange.endRb)
6332       {
6333          DU_LOG("\nERROR  -->  SCH : Invalid configuration of cell edge bandwidth for SFR feature");
6334          return RFAILED;
6335       }
6336
6337       if(lteAdvCfg->sfrCfg.cellEdgeRbRange.endRb >= dlTotalBw)
6338       {
6339         DU_LOG("\nERROR  -->  SCH : Invalid configuration of cell edge end RB for SFR feature");
6340          return RFAILED;
6341       }
6342          
6343 #ifdef TFU_UPGRADE      
6344       if(lteAdvCfg->sfrCfg.pwrThreshold.pLow >= lteAdvCfg->sfrCfg.pwrThreshold.pHigh)
6345       {
6346          DU_LOG("\nERROR  -->  SCH : Invalid configuration of power threshold for SFR feature");
6347          return RFAILED;
6348       }
6349 #endif      
6350    }
6351
6352    if((lteAdvCfg->pres & RGR_ABS) && (RGR_ENABLE == lteAdvCfg->absCfg.status))
6353    {
6354       if((RGR_ABS_MUTE != lteAdvCfg->absCfg.absPatternType) && 
6355             (RGR_ABS_TRANSMIT != lteAdvCfg->absCfg.absPatternType)) 
6356       {
6357          DU_LOG("\nERROR  -->  SCH : Invalid configuration of ABS pattern type");
6358          return RFAILED;
6359       }
6360
6361        memcpy(temp, lteAdvCfg->absCfg.absPattern,RGR_ABS_PATTERN_LEN);
6362       
6363        /* Added validation for ABS pattern len */
6364       for(idx = 0; idx < RGR_ABS_PATTERN_LEN; idx++)
6365       {   
6366          if((temp[idx] != 1) && (temp[idx] != 0))
6367         {
6368            DU_LOG("\nERROR  -->  SCH : Invalid configuration of ABS pattern type");
6369            return RFAILED;
6370         }
6371       }
6372    }
6373
6374    return ROK;
6375 }
6376 /* LTE_ADV_FLAG_REMOVED_END */
6377
6378
6379 /***********************************************************
6380  *
6381  *     Func : rgSCHCfgVldtRgrCellCsgParamCfg
6382  *
6383  *     Desc : Validates CSG Parameter Configuration
6384  *
6385  *     Ret  : S16
6386  *            ROK - Success
6387  *            RFAILED - Failed
6388  *
6389  *     Notes:
6390  *
6391  *     File :
6392  *
6393  **********************************************************/
6394 static S16 rgSCHCfgVldtRgrCellCsgParamCfg
6395 (
6396 Inst                     inst,
6397 RgrCellCsgParamCfg       *csgParam
6398 )
6399 {
6400
6401    DU_LOG("\nDEBUG  -->  SCH : Validating CSG Parameters \n");
6402
6403    if(csgParam->minDlResNonCsg > 100)
6404    {
6405       DU_LOG("\nERROR  -->  SCH : Invalid Configuration of minimum DL resources "
6406             "for NON-CSG");
6407       return RFAILED;
6408    }
6409    if(csgParam->minUlResNonCsg > 100)
6410    {
6411       DU_LOG("\nERROR  -->  SCH : Invalid Configuration of minimum UL resources "
6412             "for NON-CSG");
6413       return RFAILED;
6414    }
6415    return ROK;
6416 }
6417
6418 /**
6419  * @brief Validates the SI configuration request from RRM to MAC.
6420  *
6421  * @details
6422  *
6423  *     Function : rgSCHCfgVldtRgrSiCfg
6424  *
6425  *     Processing Steps:
6426  *        - Validate the range of configured values recieved in
6427  *          configuration request.
6428  *        - If validated successfully,
6429  *          - Return ROK
6430  *        - Else 
6431  *          - Return RFAILED.
6432  *      - Else return RFAILED.
6433  *  @param[in]  Inst         inst
6434  *  @param[in]  RgrCellCfg   *siCfg
6435  *  @param[out] RgSchCellCb  *cell
6436  *  @param[out] RgSchErrInfo *errInfo
6437  *  @return  S16
6438  *      -# ROK
6439  *      -# RFAILED
6440  **/
6441 S16 rgSCHCfgVldtRgrSiCfg
6442 (
6443 Inst         inst,
6444 RgrSiCfgReqInfo *siCfg,
6445 RgSchCellCb      *cell,
6446 RgSchErrInfo *errInfo
6447 )
6448 {
6449    MsgLen  msgLen = 0;
6450    uint8_t      numSi;
6451
6452    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_SI_CFG;
6453
6454    /*Validate the cfgType parameter */
6455    switch(siCfg->cfgType)
6456    {
6457       /*ccpu00140789*/
6458       case RGR_SI_STOP:
6459          numSi = (cell->siCb.siBitMask & RGSCH_SI_SICFG_UPD) ?
6460               cell->siCb.newSiCfg.numSi : cell->siCfg.numSi;
6461          if((siCfg->siId < RGSCH_SI_SIID_LOWER_LMT) ||
6462                  (siCfg->siId > numSi))
6463          {
6464             DU_LOG("\nERROR  -->  SCH : Invalid SI Id value"
6465                      " specified");
6466             return RFAILED;
6467          }
6468          errInfo->errCause = RGSCHERR_NONE;
6469          return ROK;
6470       break;
6471       case RGR_SI_CFG_TYPE_MIB:      /* SI CFG Type MIB */
6472       case RGR_SI_CFG_TYPE_SIB1:     /* SI CFG TYPE SIB1 */
6473       case RGR_SI_CFG_TYPE_SIB1_PWS: /* SI CFG TYPE SIB1_PWS */
6474       case RGR_SI_CFG_TYPE_SIB8_CDMA:    /* SI CFG TYPE SIB 8 CDMA */
6475 #ifdef EMTC_ENABLE
6476       case RGR_SI_CFG_EMTC_TYPE_SIB1_BR:
6477       case RGR_SI_CFG_EMTC_TYPE_SIB1_BR_PER:
6478 #endif
6479          break;
6480
6481       case RGR_SI_CFG_TYPE_SI:    /* SI CFG TYPE SI */
6482          /*Check that value of SI should be less than equal 
6483            to configured numSi parameter value */
6484          /* Added siId validation for lower limit */
6485          numSi = (cell->siCb.siBitMask & RGSCH_SI_SICFG_UPD) ? 
6486             cell->siCb.newSiCfg.numSi : cell->siCfg.numSi;
6487          if((siCfg->siId < RGSCH_SI_SIID_LOWER_LMT) || 
6488                (siCfg->siId > numSi))
6489          {
6490             DU_LOG("\nERROR  -->  SCH : Invalid SI Id value"
6491                      " specified");
6492             return RFAILED;
6493          }
6494
6495          if(siCfg->siId > ((cell->siCfg.minPeriodicity * 10)/cell->siCfg.siWinSize))
6496          {
6497             DU_LOG("\nERROR  -->  SCH : SiId can not be scheduled ");
6498             return RFAILED;
6499          }
6500          break;
6501
6502 #ifdef EMTC_ENABLE
6503       case RGR_SI_CFG_EMTC_TYPE_SI:
6504       case RGR_SI_CFG_EMTC_TYPE_SI_PER:
6505          if(ROK != rgEmtcvalidateSiCfg(siCfg,cell))
6506          {
6507             return RFAILED;
6508          } 
6509          break;
6510 #endif
6511       default:
6512          DU_LOG("\nERROR  -->  SCH : Invalid cfgType "
6513                       "parameter value");
6514          return RFAILED;
6515    }
6516
6517    /*Validate the specified pdu */
6518    if(NULLP == siCfg->pdu)
6519    {
6520       DU_LOG("\nERROR  -->  SCH : Invalid NULLP pdu "
6521                    "specified");
6522       return RFAILED;
6523    }
6524
6525    /*Check if PDU is of 0 length*/
6526    SFndLenMsg(siCfg->pdu, &msgLen);
6527    if(0 == msgLen)
6528    {
6529       DU_LOG("\nERROR  -->  SCH : Invalid pdu "
6530                    "specified");
6531       return RFAILED;
6532    }
6533
6534    errInfo->errCause = RGSCHERR_NONE;
6535
6536
6537    return ROK;
6538 }  /* rgSCHCfgVldtRgrSiCfg */
6539 #endif /*RGR_SI_SCH*/
6540
6541 /* LTE_ADV_FLAG_REMOVED_START */
6542 /**
6543  * @brief Validates the RNTP INF request from RRM to MAC.
6544  *
6545  * @details
6546  *
6547  *     Function : rgSCHCfgVldtRgrLoadInf
6548  *
6549  *     Processing Steps:
6550  *        - Validate the range of configured values recieved in
6551  *          LOAD INF request.
6552  *        - If validated successfully,
6553  *          - Return ROK
6554  *        - Else
6555  *          - Return RFAILED.
6556  *      - Else return RFAILED.
6557  *  @param[in]  Inst                inst
6558  *  @param[in]  RgrLoadInfReqInfo   *loadInfReq
6559  *  @param[out] RgSchCellCb         *cell
6560  *  @param[out] RgSchErrInfo        *errInfo
6561  *  @return  S16
6562  *      -# ROK
6563  *      -# RFAILED
6564  **/
6565 S16 rgSCHCfgVldtRgrLoadInf
6566 (
6567 Inst              inst,
6568 RgrLoadInfReqInfo *loadInfReq,
6569 RgSchCellCb       *cell,
6570 RgSchErrInfo      *errInfo
6571 )
6572 {
6573
6574    errInfo->errCause = RGSCHERR_CFG_INVALID_RGR_LOAD_INF;
6575
6576    /* Validate if the CC startRb which we have received from DSFR lies in CE sub-band of the receiving eNB */
6577    if((loadInfReq->rgrCcPHighStartRb >= cell->lteAdvCb.sfrCfg.cellEdgeRbRange.startRb) && 
6578          (loadInfReq->rgrCcPHighStartRb <= cell->lteAdvCb.sfrCfg.cellEdgeRbRange.endRb))
6579    {
6580       DU_LOG("\nERROR  -->  SCH : Invalid rgrCcPHighStartRb received specified");
6581       return RFAILED;
6582    }
6583
6584    /* Validate if the CC endRb which we have received from DSFR lies in CE sub-band of the receiving eNB */
6585    if((loadInfReq->rgrCcPHighEndRb >= cell->lteAdvCb.sfrCfg.cellEdgeRbRange.startRb) && 
6586          (loadInfReq->rgrCcPHighEndRb <= cell->lteAdvCb.sfrCfg.cellEdgeRbRange.endRb))
6587    {
6588       DU_LOG("\nERROR  -->  SCH : Invalid rgrCcPHighEndRb received specified");
6589       return RFAILED;
6590    }
6591
6592    errInfo->errCause = RGSCHERR_NONE;
6593
6594
6595    return ROK;
6596 }  /* rgSCHCfgVldtRgrLoadInf */
6597 /* LTE_ADV_FLAG_REMOVED_END */
6598
6599 #ifdef TFU_UPGRADE
6600
6601 /********************************************************************
6602  *   UE ACQI, PCQI, RI, SRS and SR Re/Configuration  Validation Functions  *
6603  *                                                                   *
6604  *********************************************************************/
6605
6606  /*
6607  * @brief Validates the Tx Mode and PUSCH Mode configuration.
6608  *
6609  * @details
6610  *
6611  *     Function : rgSCHCfgVldtRgrTxmodePuschMode  
6612  *
6613  *     Processing Steps:
6614  *      - Validate whether the configured PUSCH Mode and the
6615  *         Configured Tx Mode are in the right combination
6616  *      - If validated successfully,
6617  *        - Return ROK.
6618  *      - Else 
6619  *        - Return RFAILED.
6620  *
6621  *  @param[in]  RgSchCellCb     *cellCb
6622  *  @param[in]  RgrTxMode     txMde
6623  *  @param[in]  RgrAprdCqiMode puschMode
6624  *  @param[out] RgSchErrInfo *errInfo
6625  *  @return  S16
6626  *      -# ROK
6627  *      -# RFAILED
6628  */
6629 S16 rgSCHCfgVldtRgrTxmodePuschMode 
6630 (
6631 RgSchCellCb     *cellCb,
6632 RgrTxMode       txMde,
6633 RgrAprdCqiMode  puschMode,
6634 RgSchErrInfo    *errInfo
6635 )
6636 {
6637
6638    if (txMde == RGR_UE_TM_1 ||  txMde == RGR_UE_TM_2 ||
6639          txMde == RGR_UE_TM_3 || txMde == RGR_UE_TM_7)
6640    {
6641       if (puschMode == RGR_APRD_CQI_MOD12 ||
6642             puschMode == RGR_APRD_CQI_MOD22  ||
6643             puschMode == RGR_APRD_CQI_MOD31)
6644       {
6645          return RFAILED;
6646       }
6647    }
6648
6649    if (txMde == RGR_UE_TM_4 ||  txMde == RGR_UE_TM_6)
6650    {
6651       if (puschMode == RGR_APRD_CQI_MOD20 ||
6652             puschMode == RGR_APRD_CQI_MOD30)
6653       {
6654          return RFAILED;
6655       }
6656    }
6657
6658    if (txMde == RGR_UE_TM_5 )
6659    {
6660       if (puschMode != RGR_APRD_CQI_MOD31)
6661       {
6662          return RFAILED;
6663       }
6664    }
6665 #ifdef LTE_ADV
6666    /* TOODO:: Tm8 and TM9 validation has to
6667     * be changed as mentioned inthe commented 
6668     * code below*/
6669    /* TM8 and TM9 supports all modes
6670     * Mode 1-2, 2-2, 3-1 if pmi/ri reporting enabled
6671     * 2-0,3-0 of pmi/ri reporitng isdisabled *
6672     * if pmi/ri is enabled 
6673     * Mode 1-2, 2-2, 3-1 if with pmi/ri and csi-rs ports > 1
6674     * 2-0,3-0 of pmi/ri reporitng isdisabled and csi-rs ports == 1*/
6675
6676 #endif
6677    return ROK;
6678 }/*rgSCHCfgVldtRgrTxmodePuschMode ends*/
6679
6680  /*
6681  * @brief Validates the UE ACQI configuration request from RRM to MAC.
6682  *
6683  * @details
6684  *
6685  *     Function : rgSCHCfgVldtRgrUeACqiCfg  
6686  *
6687  *     Processing Steps:
6688  *      - Validate the UE configuration request from RRC to MAC at CFG:
6689  *        validate the ACQI Configuration 
6690  *      - If validated successfully,
6691  *        - Return ROK.
6692  *      - Else 
6693  *        - Return RFAILED.
6694  *
6695  *  @param[in] RgSchCellCb        *cellCb,
6696  *  @param[in] CmLteRnti          crnti,  
6697  *  @param[in] RgrUeAprdDlCqiCfg   *acqiCfg,  
6698  *  @param[in] RgrUeTxModeCfg     txMode,
6699  *  @param[out] RgSchErrInfo       *errInfo
6700
6701  *  @return  S16
6702  *      -# ROK
6703  *      -# RFAILED
6704  */
6705 S16 rgSCHCfgVldtRgrUeACqiCfg 
6706 (
6707 RgSchCellCb        *cellCb,
6708 CmLteRnti          crnti,  
6709 RgrUeAprdDlCqiCfg  *acqiCfg,  
6710 RgrUeTxModeCfg     txMode,
6711 RgSchErrInfo       *errInfo
6712 )
6713 {
6714    RgrTxMode      txMde;
6715    RgrAprdCqiMode puschMode; 
6716
6717    if(acqiCfg->pres)
6718    {
6719       if(txMode.pres == TRUE)
6720       {
6721          txMde = txMode.txModeEnum;
6722          puschMode = acqiCfg->aprdModeEnum;
6723          if ( ROK != rgSCHCfgVldtRgrTxmodePuschMode(cellCb, txMde,
6724                   puschMode, errInfo))
6725          {
6726             DU_LOG("\nERROR  -->  SCH : Invalid Aperiodic CQI configuration CRNTI:%d",crnti);
6727             return RFAILED;
6728          } 
6729       }
6730    }
6731    return ROK;
6732 }
6733
6734  /*
6735  * @brief Validates the Tx Mode and PUCCH Mode configuration.
6736  *
6737  * @details
6738  *
6739  *     Function : rgSCHCfgVldtRgrTxmodePucchMode  
6740  *
6741  *     Processing Steps:
6742  *      - Validate whether the configured PUCCH Mode and the
6743  *         Configured Tx Mode are in the right combination
6744  *      - If validated successfully,
6745  *        - Return ROK.
6746  *      - Else 
6747  *        - Return RFAILED.
6748  *
6749  *  @param[in]  RgSchCellCb     *cellCb
6750  *  @param[in]  RgrTxMode     txMde
6751  *  @param[in]  RgrPrdCqiMode     pucchMode
6752  *  @param[out] RgSchErrInfo *errInfo
6753  *  @return  S16
6754  *      -# ROK
6755  *      -# RFAILED
6756  */
6757 S16 rgSCHCfgVldtRgrTxmodePucchMode 
6758 (
6759 RgSchCellCb     *cellCb,
6760 RgrTxMode       txMde,
6761 RgrPrdCqiMode   pucchMode,
6762 RgSchErrInfo    *errInfo
6763 )
6764 {
6765
6766   if (pucchMode == RGR_PRD_CQI_MOD10 || pucchMode == RGR_PRD_CQI_MOD20 )
6767   {
6768    if (txMde ==RGR_UE_TM_4 || txMde ==RGR_UE_TM_5 || txMde ==RGR_UE_TM_6)
6769    {
6770       return RFAILED;
6771    }
6772   }
6773   else if (pucchMode == RGR_PRD_CQI_MOD11 || pucchMode == RGR_PRD_CQI_MOD21)
6774   {
6775      if (txMde ==RGR_UE_TM_1 || txMde ==RGR_UE_TM_2 || txMde ==RGR_UE_TM_3 \
6776              || txMde ==RGR_UE_TM_7)
6777    {
6778       return RFAILED;
6779    }
6780   }
6781   /* TODO:: Tm8 and TM9 validation needs to be added */
6782    return ROK;
6783 }
6784
6785 /*
6786  * @brief Validates the UE Periodic CQI, PMI, RI, re/configuration request from RRM to MAC.
6787  *
6788  * @details
6789  *
6790  *     Function : rgSCHCfgVldtRgrUePCqiCfg  
6791  *
6792  *     Processing Steps:
6793  *      - Validate the UE configuration request from RRC to MAC at CFG:
6794  *        validate the value range for Periodic CQI, PMI, RI values.
6795  *      - If validated successfully,
6796  *        - Return ROK.
6797  *      - Else 
6798  *        - Return RFAILED.
6799  *
6800  *  @param[in] RgSchCellCb        *cellCb,
6801  *  @param[in] CmLteRnti          crnti,  
6802  *  @param[in] RgrUePrdDlCqiCfg   *cqiCfg,  
6803  *  @param[in] RgrUeTxModeCfg     txMode,
6804  *  @param[out] RgSchErrInfo       *errInfo
6805  *  @return  S16
6806  *      -# ROK
6807  *      -# RFAILED
6808  */
6809 #ifdef LTEMAC_HDFDD
6810 S16 rgSCHCfgVldtRgrUePCqiCfg 
6811 (
6812 RgSchCellCb        *cellCb,
6813 CmLteRnti          crnti,  
6814 RgrUePrdDlCqiCfg   *cqiCfg,
6815 Bool               hdFdd,
6816 RgrUeTxModeCfg     txMode,
6817 RgSchErrInfo       *errInfo
6818 )
6819 #else
6820 S16 rgSCHCfgVldtRgrUePCqiCfg 
6821 (
6822 RgSchCellCb        *cellCb,
6823 CmLteRnti          crnti,  
6824 RgrUePrdDlCqiCfg   *cqiCfg,  
6825 RgrUeTxModeCfg     txMode,
6826 RgSchErrInfo       *errInfo
6827 )
6828 #endif
6829 {
6830    RgrTxMode     txMde; 
6831    RgrPrdCqiMode pucchMode; 
6832
6833    txMde = RGR_UE_TM_1;
6834    pucchMode = RGR_PRD_CQI_MOD20;
6835    if ( RGR_SCH_PCQI_SETUP == cqiCfg->type )
6836    {
6837       /*1. Validate for Tx Mode and PUCCH Mode combination*/
6838       if(txMode.pres == TRUE)
6839       {
6840          txMde = txMode.txModeEnum;
6841          pucchMode = cqiCfg->cqiSetup.prdModeEnum;
6842          if ( ROK != rgSCHCfgVldtRgrTxmodePucchMode(cellCb, txMde,
6843                   pucchMode, errInfo))
6844          {
6845             DU_LOG("\nERROR  -->  SCH : Invalid Tx Mode-PUCCH Mode combination CRNTI:%d",crnti);
6846             return RFAILED;
6847          } 
6848       }
6849
6850       /*2. Validate for PCQI Reporting Type and PUCCH Mode combination*/
6851       if((cqiCfg->cqiSetup.cqiRepType==1) && 
6852               ((pucchMode == RGR_PRD_CQI_MOD20) ||
6853                (pucchMode == RGR_PRD_CQI_MOD21)))
6854       {
6855           DU_LOG("\nERROR  -->  SCH : Invalid Reporting Type-PUCCH Mode combination CRNTI:%d",crnti);
6856             return RFAILED;
6857       }
6858
6859       if((cqiCfg->cqiSetup.cqiRepType==2) && 
6860               ((pucchMode == RGR_PRD_CQI_MOD10) ||
6861                (pucchMode == RGR_PRD_CQI_MOD11)))
6862       {
6863             DU_LOG("\nERROR  -->  SCH : Invalid Reporting Type-PUCCH Mode combination CRNTI:%d",crnti);
6864             return RFAILED;
6865       }
6866
6867       /*3. Validate CQI/PMI and RI Configuration related parameter values */
6868       /*TODO- To be compared with configured n2Pucch Index*/
6869       if (cqiCfg->cqiSetup.cqiPResIdx > RG_SCH_PUCCH_RES_MAX_SUPP ) 
6870       {
6871          DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid CQI-PUCCH resourceIndex=%d Cfg Val=%d CRNTI:%d", 
6872                   RG_SCH_PUCCH_RES_MAX_SUPP, cqiCfg->type,crnti);
6873          return RFAILED;
6874       } 
6875
6876 #ifdef LTEMAC_HDFDD
6877       if(hdFdd)
6878       {
6879          if((cqiCfg->cqiSetup.cqiPCfgIdx > RG_SCH_ICQI_MAX_SUPP)||
6880                (cqiCfg->cqiSetup.cqiPCfgIdx < 7) ||
6881                (cqiCfg->cqiSetup.cqiPCfgIdx == 317))
6882          {
6883             DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg CQI Min Index Sup =%d"
6884                      "Max Index Sup=%d  Cfg Val=%d CRNTI:%d", RG_SCH_ICQI_MIN_SUPP, 
6885                      RG_SCH_ICQI_MAX_SUPP, cqiCfg->type,crnti);
6886             return RFAILED;
6887          }
6888       }
6889       else 
6890       {
6891          if((cqiCfg->cqiSetup.cqiPCfgIdx > RG_SCH_ICQI_MAX_SUPP)||
6892                (cqiCfg->cqiSetup.cqiPCfgIdx == 317))
6893          {
6894             DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg CQI Min Index Sup =%d "
6895                      "Max Index Sup=%d  Cfg Val=%d CRNTI:%d", RG_SCH_ICQI_MIN_SUPP, 
6896                      RG_SCH_ICQI_MAX_SUPP, cqiCfg->type,crnti);
6897             return RFAILED;
6898          }
6899       }
6900 #else
6901       if((cqiCfg->cqiSetup.cqiPCfgIdx > RG_SCH_ICQI_MAX_SUPP)||
6902             (cqiCfg->cqiSetup.cqiPCfgIdx == 317))
6903       {
6904          DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg CQI Min Index Sup =%d"
6905                   "Max Index Sup=%d  Cfg Val=%d CRNTI;%d", RG_SCH_ICQI_MIN_SUPP, 
6906                   RG_SCH_ICQI_MAX_SUPP, cqiCfg->type,crnti);
6907          return RFAILED;
6908       }
6909 #endif
6910
6911       if((cqiCfg->cqiSetup.cqiRepType < RGR_UE_PCQI_WB_REP) ||
6912             (cqiCfg->cqiSetup.cqiRepType > RGR_UE_PCQI_SB_REP))
6913       {
6914          DU_LOG("\nERROR  -->  SCH : Invalid Cfg CQI Report"
6915                   "ModeCfg Val=%d CRNTI:%d", cqiCfg->type,crnti);
6916          return RFAILED;
6917       }
6918
6919       if((cqiCfg->cqiSetup.cqiRepType == RGR_UE_PCQI_SB_REP) && 
6920             ((cqiCfg->cqiSetup.k < RG_SCH_CQI_K_MIN) ||
6921             (cqiCfg->cqiSetup.k > RG_SCH_CQI_K_MAX)))
6922       {
6923          DU_LOG("\nERROR  -->  SCH : Invalid CQI Cfg K Cfg Val=%d CRNTI:%d", cqiCfg->type,crnti);
6924          return RFAILED;
6925       }
6926
6927       if((cqiCfg->cqiSetup.cqiRepType == RGR_UE_PCQI_SB_REP) && 
6928             (cellCb->bwCfg.dlTotalBw <= 7))
6929       {
6930          DU_LOG("\nERROR  -->  SCH : Invalid Periodic CQI mode Cfg for dlTotalBw (%d) for CRNTI:%d", 
6931                   cellCb->bwCfg.dlTotalBw, crnti);
6932          return RFAILED;
6933       }
6934
6935 #ifndef LTE_TDD
6936       if (cqiCfg->cqiSetup.cqiPCfgIdx == RG_SCH_ICQI_RESV_FDD ) 
6937       {  
6938          DU_LOG("\nERROR  -->  SCH : Reserved value Cfg =%d CRNTI:%d", 
6939                   cqiCfg->cqiSetup.cqiPResIdx,crnti);
6940          return RFAILED;
6941       }
6942 #endif
6943
6944       /* 4. Check RI Configuration values */
6945        if(cqiCfg->cqiSetup.riEna == TRUE)
6946       {
6947          if(txMode.pres == TRUE)
6948          {
6949             if((txMde != RGR_UE_TM_3)  
6950             && (txMde != RGR_UE_TM_4) 
6951             && (txMde != RGR_UE_TM_8) 
6952 #ifdef LTE_ADV
6953             && (txMde != RGR_UE_TM_9)
6954 #endif
6955              )
6956             {
6957                DU_LOG("\nERROR  -->  SCH : Invalid Transmission Mode =%d CRNTI:%d",
6958                   txMde,crnti);
6959                return RFAILED;
6960             }
6961          }
6962          
6963          if(cqiCfg->cqiSetup.riCfgIdx > RG_SCH_IRI_MAX_SUPP)
6964          {
6965             DU_LOG("\nERROR  -->  SCH : Invalid Index RI value Cfg =%d CRNTI:%d",
6966                   cqiCfg->cqiSetup.riCfgIdx,crnti);
6967             return RFAILED;
6968          }
6969       }
6970    }
6971
6972   
6973    return ROK;
6974 }
6975
6976 /*
6977  * @brief Validates the UE SRS Re/Configuation request from RRM to MAC.
6978  *
6979  * @details
6980  *
6981  *     Function : rgSCHCfgVldtRgrUeUlSrsCfg 
6982  *
6983  *     Processing Steps:
6984  *      - Validate the UE configuration request from RRC to MAC at CFG:
6985  *        validate the value range for SRS values.
6986  *      - If validated successfully,
6987  *        - Return ROK.
6988  *      - Else 
6989  *        - Return RFAILED.
6990  *
6991  *  @param[in] RgSchCellCb       *cellCb,
6992  *  @param[in] CmLteRnti         crnti,  
6993  *  @param[in] RgrUeUlSrsCfg     *srsCfg,  
6994  *  @param[out] RgSchErrInfo     *errInfo
6995  *  @return  S16
6996  *      -# ROK
6997  *      -# RFAILED
6998  */
6999 #ifdef LTEMAC_HDFDD
7000 S16 rgSCHCfgVldtRgrUeUlSrsCfg 
7001 (
7002  RgSchCellCb       *cellCb,
7003  CmLteRnti         crnti,  
7004  RgrUeUlSrsCfg     *srsCfg,
7005  Bool              hdFdd,
7006  RgSchErrInfo      *errInfo
7007  )
7008 #else
7009 S16 rgSCHCfgVldtRgrUeUlSrsCfg 
7010 (
7011 RgSchCellCb       *cellCb,
7012 CmLteRnti         crnti,  
7013 RgrUeUlSrsCfg     *srsCfg,  
7014 RgSchErrInfo      *errInfo
7015 )
7016 #endif
7017 {
7018    uint16_t    srsPeri=0;
7019    uint16_t    srsOffset=0;
7020    uint8_t     srsSubframe=0;
7021    
7022    if ( RGR_SCH_SRS_SETUP == srsCfg->type )
7023    {
7024
7025       /*ccpu00130768 - ADD - if cell specific SRS is not configured*/
7026       if(cellCb->srsCfg.isSrsCfgPres == FALSE)
7027       {
7028          DU_LOG("\nERROR  -->  SCH : Cell specific SRS is not configured CRNTI:%d",crnti);
7029          return RFAILED;
7030       }
7031
7032       /*  1. Validate SRS Configuration related parameter values  */
7033       /* 1.1 iSRS should be 0-636; Ref: 36.213. Table 8.2-1 */
7034 #ifdef LTEMAC_HDFDD
7035       if(hdFdd)
7036       {
7037          if ( (srsCfg->srsSetup.srsCfgIdx < 7) || 
7038                (srsCfg->srsSetup.srsCfgIdx > RG_SCH_ISRS_MAX_SUPP) )
7039          {
7040             DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg "
7041                      "SRS Min Index Sup =%d   Max Index Sup=%d  Cfg Val=%d CRNTI:%d",
7042                      RG_SCH_ISRS_MIN_SUPP, RG_SCH_ISRS_MAX_SUPP,
7043                      srsCfg->srsSetup.srsCfgIdx,crnti);
7044             return RFAILED;
7045          }
7046       }
7047       else
7048       {
7049          if ( srsCfg->srsSetup.srsCfgIdx > RG_SCH_ISRS_MAX_SUPP )
7050          {
7051             DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg"
7052                      "SRS Min Index Sup =%d   Max Index Sup=%d  Cfg Val=%d CRNTI:%d",
7053                      RG_SCH_ISRS_MIN_SUPP, RG_SCH_ISRS_MAX_SUPP,
7054                      srsCfg->srsSetup.srsCfgIdx,crnti);
7055             return RFAILED;
7056          }
7057
7058       }
7059 #else
7060       if ( srsCfg->srsSetup.srsCfgIdx > RG_SCH_ISRS_MAX_SUPP )
7061       {
7062          DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg" 
7063                   "SRS Min Index Sup =%d   Max Index Sup=%d  Cfg Val=%d CRNTI:%d",
7064                   RG_SCH_ISRS_MIN_SUPP, RG_SCH_ISRS_MAX_SUPP,
7065                   srsCfg->srsSetup.srsCfgIdx,crnti);
7066          return RFAILED;
7067       }
7068 #endif
7069 #ifdef LTE_TDD
7070       /* Compute SRS Offset and Periodicity */
7071       rgSCHUtlGetCfgPerOff( RG_SCH_TDD_SRS_TBL, 
7072             srsCfg->srsSetup.srsCfgIdx,
7073             &srsPeri, &srsOffset);  
7074 #else
7075       rgSCHUtlGetCfgPerOff( RG_SCH_FDD_SRS_TBL, 
7076             srsCfg->srsSetup.srsCfgIdx,
7077             &srsPeri, &srsOffset);     
7078 #endif
7079        srsSubframe = srsOffset%RGSCH_NUM_SUB_FRAMES;
7080 #ifdef LTE_TDD   
7081       if(rgSchTddCellSpSrsSubfrmTbl[cellCb->srsCfg.srsSubFrameCfg][srsSubframe] == FALSE)   {      
7082 #else   
7083       if(rgSchFddCellSpSrsSubfrmTbl[cellCb->srsCfg.srsSubFrameCfg][srsSubframe] == FALSE)   {
7084 #endif
7085          DU_LOG("\nERROR  -->  SCH : UE specific SRS is not occuring in Cell specific SRS subframe"
7086                "srs Cfg Idx =%d CRNTI:%d",
7087                srsCfg->srsSetup.srsCfgIdx,crnti);
7088          return RFAILED;
7089       }
7090
7091
7092       if ( srsCfg->srsSetup.fDomPosi > RG_SCH_SRS_FREQDOM_POS_MAX )
7093       {
7094          DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg" 
7095                   "SRS Min Freq Domain Position =%d"   
7096                   "Max Freq Domain Position =%d  Cfg Val=%d CRNTI:%d",
7097                   RG_SCH_SRS_FREQDOM_POS_MIN, RG_SCH_SRS_FREQDOM_POS_MAX,
7098                   srsCfg->srsSetup.srsCfgIdx,crnti);
7099          return RFAILED;
7100       }
7101
7102       if ( srsCfg->srsSetup.txComb > RG_SCH_SRS_TXCOMB_MAX )
7103       {
7104          DU_LOG("\nERROR  -->  SCH : Not Supported or Invalid Cfg" 
7105                   "SRS Min TX Comb =%d   Max TX Comb =%d  Cfg Val=%d CRNTI:%d",
7106                   RG_SCH_SRS_TXCOMB_MIN, RG_SCH_SRS_TXCOMB_MAX,
7107                   srsCfg->srsSetup.srsCfgIdx,crnti);
7108          return RFAILED;
7109       }
7110    }
7111    return ROK;
7112 }
7113
7114 /*
7115  * @brief Validates the UE SR Re/configuration request from RRM to MAC.
7116  *
7117  * @details
7118  *
7119  *     Function : rgSCHCfgVldtRgrUeSrCfg 
7120  *
7121  *     Processing Steps:
7122  *      - Validate the UE re/configuration request from RRC to MAC at CFG:
7123  *        validate the value range for SR values.
7124  *      - If validated successfully,
7125  *        - Return ROK.
7126  *      - Else 
7127  *        - Return RFAILED.
7128  *
7129  *  @param[in] RgSchCellCb      *cellCb,
7130  *  @param[in] CmLteRnti        crnti,  
7131  *  @param[in] RgrUeSrCfg       *srCfg,  
7132  *  @param[out] RgSchErrInfo    *errInfo
7133  *  @return  S16
7134  *      -# ROK
7135  *      -# RFAILED
7136  */
7137 #ifdef LTEMAC_HDFDD 
7138 S16 rgSCHCfgVldtRgrUeSrCfg 
7139 (
7140  RgSchCellCb      *cellCb,
7141  CmLteRnti        crnti,  
7142  RgrUeSrCfg       *srCfg,
7143  Bool             hdFdd,
7144  RgSchErrInfo     *errInfo
7145  )
7146 #else
7147 S16 rgSCHCfgVldtRgrUeSrCfg 
7148 (
7149  RgSchCellCb      *cellCb,
7150  CmLteRnti        crnti,  
7151  RgrUeSrCfg       *srCfg,  
7152  RgSchErrInfo     *errInfo
7153  )
7154 #endif
7155 {
7156
7157    if ( RGR_SCH_SR_SETUP == srCfg->type )
7158    {
7159       /* 1. Validate SR Configuration related parameter values  */
7160 #ifdef LTEMAC_HDFDD
7161       if(hdFdd)
7162       {
7163          if (( srCfg->srSetup.srResIdx > RG_SCH_SR_RES_IDX   ) ||
7164                ( srCfg->srSetup.srCfgIdx < 5 ) ||
7165                ( srCfg->srSetup.srCfgIdx > RG_SCH_ISR_MAX_SUPP )) 
7166          {
7167              DU_LOG("\nERROR  -->  SCH : Invalid SR Index Cfg =%d"
7168                       "Max Supp=%d,Min Supp=%d CRNTI:%d", srCfg->srSetup.srCfgIdx, 
7169                      RG_SCH_ISR_MAX_SUPP, RG_SCH_ISR_MIN_SUPP,crnti);
7170
7171             return RFAILED;
7172          }
7173       }
7174       else
7175       {
7176          if (( srCfg->srSetup.srResIdx > RG_SCH_SR_RES_IDX   ) ||
7177                ( srCfg->srSetup.srCfgIdx > RG_SCH_ISR_MAX_SUPP )) 
7178          {
7179             DU_LOG("\nERROR  -->  SCH : Invalid SR Index Cfg =%d" 
7180                       "Max Supp=%d,Min Supp=%d CRNTI:%d", srCfg->srSetup.srCfgIdx, 
7181                      RG_SCH_ISR_MAX_SUPP, RG_SCH_ISR_MIN_SUPP,crnti);
7182
7183             return RFAILED;
7184          }
7185       }
7186 #else
7187       if (( srCfg->srSetup.srResIdx > RG_SCH_SR_RES_IDX   ) ||
7188             ( srCfg->srSetup.srCfgIdx > RG_SCH_ISR_MAX_SUPP )) 
7189       {
7190          DU_LOG("\nERROR  -->  SCH : Invalid SR Index Cfg =%d"
7191                   "Max Supp=%d,Min Supp=%d CRNTI:%d", srCfg->srSetup.srCfgIdx, 
7192                   RG_SCH_ISR_MAX_SUPP, RG_SCH_ISR_MIN_SUPP,crnti);
7193
7194          return RFAILED;
7195       }
7196 #endif
7197    } 
7198    return ROK;
7199 }
7200
7201
7202 /*
7203  * @brief Validates the UE Aperiodic & Periodic  CQI, PMI, RI, SRS and SR Configuration 
7204  *             request from RRM to MAC.
7205  *
7206  * @details
7207  *
7208  *     Function :rgSCHCfgVldtCqiSrSrsUeCfg 
7209  *
7210  *     Processing Steps:
7211  *      - Validate the UE configuration request from RRC to MAC at CFG:
7212  *        validate the value range for Aperiodic & Periodic CQI, PMI, RI , SRS and SR values.
7213  *      - If validated successfully,
7214  *        - Return ROK.
7215  *      - Else 
7216  *        - Return RFAILED.
7217  *
7218  *  @param[in]  RgSchCellCb  *cellCb
7219  *  @param[in]  RgrUeCfg     *ueCfg
7220  *  @param[out] RgSchErrInfo *errInfo
7221  *  @return  S16
7222  *      -# ROK
7223  *      -# RFAILED
7224  */
7225 static S16 rgSCHCfgVldtCqiSrSrsUeCfg 
7226 (
7227 RgSchCellCb       *cellCb,  
7228 RgrUeCfg          *ueCfg,  
7229 RgSchErrInfo      *errInfo
7230 )
7231 {
7232
7233    /*  1. Validate UE Aperiodic CQI related parameters */
7234    if ( ROK != rgSCHCfgVldtRgrUeACqiCfg (cellCb, ueCfg->crnti,
7235             &ueCfg->ueDlCqiCfg.aprdCqiCfg, ueCfg->txMode, errInfo ))
7236    {
7237       DU_LOG("\nERROR  -->  SCH : Invalid Aperiodic CQI configuration CRNTI:%d",ueCfg->crnti);
7238       return RFAILED;
7239    }
7240
7241    /*  1. Validate UE Periodic CQI/PMI, SRS and SR related parameters */
7242 #ifdef LTEMAC_HDFDD
7243    if ( ROK != rgSCHCfgVldtRgrUePCqiCfg (cellCb, ueCfg->crnti,
7244             &ueCfg->ueDlCqiCfg.prdCqiCfg, ueCfg->isHdFddEnbld, 
7245             ueCfg->txMode, errInfo ))
7246 #else
7247       if ( ROK != rgSCHCfgVldtRgrUePCqiCfg (cellCb, ueCfg->crnti,
7248              &ueCfg->ueDlCqiCfg.prdCqiCfg, ueCfg->txMode, errInfo ))
7249 #endif
7250       {
7251          DU_LOG("\nERROR  -->  SCH : Invalid Periodic CQI configuration CRNTI:%d",ueCfg->crnti);
7252          return RFAILED;
7253       }
7254
7255    /*  2. Validate SRS Configuration related parameter values  */
7256 #ifdef LTEMAC_HDFDD
7257    if ( ROK != rgSCHCfgVldtRgrUeUlSrsCfg(cellCb, ueCfg->crnti, &ueCfg->srsCfg,
7258             ueCfg->isHdFddEnbld, errInfo ))
7259 #else
7260       if ( ROK != rgSCHCfgVldtRgrUeUlSrsCfg(cellCb, ueCfg->crnti, 
7261                   &ueCfg->srsCfg, errInfo ))
7262 #endif
7263       {
7264          DU_LOG("\nERROR  -->  SCH : Invalid SRS  configuration CRNTI:%d",ueCfg->crnti);
7265          return RFAILED;
7266       } 
7267
7268    /*  3. Validate SR Configuration related parameter values  */
7269 #ifdef LTEMAC_HDFDD
7270    if ( ROK != rgSCHCfgVldtRgrUeSrCfg (cellCb, ueCfg->crnti, &ueCfg->srCfg,
7271             ueCfg->isHdFddEnbld, errInfo))
7272 #else
7273       if ( ROK != rgSCHCfgVldtRgrUeSrCfg (cellCb, ueCfg->crnti, 
7274                   &ueCfg->srCfg, errInfo))
7275 #endif
7276       {
7277          DU_LOG("\nERROR  -->  SCH : Invalid SR  configuration CRNTI:%d",ueCfg->crnti);
7278          return RFAILED;
7279       }
7280
7281    return ROK;
7282
7283 }
7284
7285
7286
7287 /*****************************************************************
7288  *   UE PCQI, RI, SRS and SR Re Configuration  Validation Functions  *
7289  *                                                                *
7290  ******************************************************************/
7291 /*
7292  * @brief Validates the UE Periodic CQI, PMI, RI, SRS and SR 
7293  * Re-configuration request from RRM to MAC.
7294  *
7295  * @details
7296  *
7297  *     Function : rgSCHCfgVldtCqiSrSrsUeReCfg 
7298  *
7299  *     Processing Steps:
7300  *      - Validate the UE Re configuration request from RRC to MAC at CFG:
7301  *        validate the value range for Periodic CQI, PMI, RI, SRS and SR values.
7302  *      - If validated successfully,
7303  *        - Return ROK.
7304  *      - Else 
7305  *        - Return RFAILED.
7306  *
7307  *  @param[in]   RgSchCellCb *cellCb
7308  *  @param[in]   RgSchUeCb   *ueCb
7309  *  @param[in]  RgrUeCfg     *ueCfg
7310  *  @param[out] RgSchErrInfo *errInfo
7311  *  @return  S16
7312  *      -# ROK
7313  *      -# RFAILED
7314  */
7315 static S16 rgSCHCfgVldtCqiSrSrsUeReCfg 
7316 (
7317 RgSchCellCb          *cellCb,
7318 RgSchUeCb            *ueCb,
7319 RgrUeRecfg           *ueReCfg,  
7320 RgSchErrInfo         *errInfo
7321 )
7322 {
7323    RgrUeTxModeCfg     txMode;
7324
7325    txMode.pres = TRUE;
7326    txMode.tmTrnstnState = RGR_TXMODE_RECFG_CMPLT;
7327    if ((ueReCfg->ueRecfgTypes & RGR_UE_TXMODE_RECFG) &&
7328        (ueReCfg->txMode.pres == TRUE)) 
7329    {
7330       txMode.txModeEnum = ueReCfg->txMode.txModeEnum;
7331    }
7332    else
7333    {
7334       txMode.txModeEnum = ueCb->mimoInfo.txMode;
7335    }
7336
7337    /*    1. Validate UE CQI/PMI, SRS and SR related parameters */
7338
7339    if ( ueReCfg->ueRecfgTypes & RGR_UE_APRD_DLCQI_RECFG ) 
7340    { 
7341       if ( ROK != rgSCHCfgVldtRgrUeACqiCfg (cellCb, ueReCfg->oldCrnti,     
7342                &ueReCfg->aprdDlCqiRecfg, txMode, errInfo ))
7343       {
7344          DU_LOG("\nERROR  -->  SCH : Invalid Aperiodic CQI configuration OLD CRNTI:%d",ueReCfg->oldCrnti);
7345          return RFAILED;
7346       }
7347    }
7348
7349
7350    /*    2. Validate UE CQI/PMI, SRS and SR related parameters */
7351
7352    if ( ueReCfg->ueRecfgTypes & RGR_UE_PCQI_RECFG ) 
7353    { 
7354 #ifdef LTEMAC_HDFDD   
7355       if ( ROK != rgSCHCfgVldtRgrUePCqiCfg (cellCb, ueReCfg->oldCrnti,     
7356                &ueReCfg->cqiCfg, ueReCfg->isHdFddEnbld, txMode, errInfo ))
7357 #else
7358          if ( ROK != rgSCHCfgVldtRgrUePCqiCfg (cellCb, ueReCfg->oldCrnti,     
7359                   &ueReCfg->cqiCfg, txMode, errInfo ))
7360 #endif
7361
7362          {
7363             DU_LOG("\nERROR  -->  SCH : Invalid Periodic CQI configuration OLD CRNTI:%d",ueReCfg->oldCrnti);
7364             return RFAILED;
7365          }
7366    }
7367
7368    if(ueReCfg->ueRecfgTypes & RGR_UE_SRS_RECFG )
7369    {
7370 #ifdef LTEMAC_HDFDD
7371       if ( ROK != rgSCHCfgVldtRgrUeUlSrsCfg(cellCb, ueReCfg->oldCrnti,
7372                &ueReCfg->srsCfg, ueReCfg->isHdFddEnbld, errInfo ))
7373 #else
7374          if ( ROK != rgSCHCfgVldtRgrUeUlSrsCfg(cellCb, ueReCfg->oldCrnti,
7375                   &ueReCfg->srsCfg, errInfo ))
7376 #endif
7377          {
7378             DU_LOG("\nERROR  -->  SCH : Invalid SRS  configuration OLD CRNTI:%d",ueReCfg->oldCrnti);
7379             return RFAILED;
7380          } 
7381
7382    }
7383
7384    if ( ueReCfg->ueRecfgTypes & RGR_UE_SR_RECFG )
7385    {
7386 #ifdef LTEMAC_HDFDD
7387       if ( ROK != rgSCHCfgVldtRgrUeSrCfg (cellCb, ueReCfg->oldCrnti, 
7388             &ueReCfg->srCfg, ueReCfg->isHdFddEnbld, errInfo))
7389 #else
7390          if ( ROK != rgSCHCfgVldtRgrUeSrCfg (cellCb, ueReCfg->oldCrnti, 
7391             &ueReCfg->srCfg, errInfo))
7392 #endif
7393          {
7394             DU_LOG("\nERROR  -->  SCH : Invalid SR configuration OLD CRNTI:%d",ueReCfg->oldCrnti);
7395             return RFAILED;
7396          }
7397    }
7398
7399    return ROK;
7400 }
7401
7402
7403 /*****************************************************************
7404  *   UE ACQI, PCQI, RI, SRS SR Configuration Functions      *
7405  *                                                                *
7406  ******************************************************************/
7407    /**
7408     * @brief Handles Aperiodic CQI , PMI, RI  configuration for a UE.
7409     *
7410     * @details
7411     *
7412     *     Function : rgSCHCfgACqiUeCfg 
7413     *
7414     *     Invoking Module Processing:
7415     *      - This shall be invoked by SCH_GOM at UE configuration. It 
7416     *      shall do the validations for the spec-defined values.
7417     *        
7418     *     Processing Steps:
7419     *     
7420     *     - Return ROK
7421     *
7422     *  @param[in]  RgSchCellCb  *cell
7423     *  @param[in]  RgrTxMode    txMode
7424     *  @param[in]  RgrUeAprdDlCqiCfg *aCqiCfg
7425     *  @param[in]  CmLteUeCategory        ueCat
7426     *  @return  S16
7427     *      -# ROK
7428     *
7429     **/
7430 S16 rgSCHCfgACqiUeCfg
7431 (
7432 RgSchCellCb        *cellCb, 
7433 RgSchUeCb          *ue, 
7434 RgSchUeACqiCb      *acqiCb,
7435 RgrTxMode           ueTxMode,
7436 RgrUeAprdDlCqiCfg  *aCqiCfg,
7437 CmLteUeCategory     ueCat
7438 )
7439 {
7440    uint8_t     M;  /*Num of Subbands -- Applicable only for Mode 2-0 and 2-2*/
7441    uint8_t     k;  /*SubBand Size (RB)  -- 
7442               Holds different values depending on Mode*/
7443    uint8_t     cqiPmiSzR1;   /*CQIPMI Size for Rank =1*/
7444    uint8_t     cqiPmiSzRn1; /*CQIPMI Size for Rank > 1*/
7445
7446    cqiPmiSzR1 = 0;
7447    cqiPmiSzRn1 = 0;
7448    
7449    acqiCb->aCqiCfg.pres = aCqiCfg->pres;
7450    acqiCb->aCqiCfg.aprdModeEnum = aCqiCfg->aprdModeEnum;
7451
7452    if(aCqiCfg->pres)
7453    {
7454 #ifdef LTE_ADV
7455       /*Store Trigger Set Bit String to UE */
7456       RgSchUeCellInfo *pCellInfo = RG_SCH_CMN_GET_PCELL_INFO(ue);
7457       pCellInfo->acqiCb.aCqiCfg.triggerSet1 = aCqiCfg->triggerSet1;
7458       pCellInfo->acqiCb.aCqiCfg.triggerSet2 = aCqiCfg->triggerSet2;
7459 #endif
7460
7461
7462       switch(aCqiCfg->aprdModeEnum)
7463       {
7464          case RGR_APRD_CQI_MOD12:
7465          case RGR_APRD_CQI_MOD30:
7466          case RGR_APRD_CQI_MOD31:
7467             RG_SCH_GET_CQI_K_VAL(cellCb->bwCfg.dlTotalBw, k);
7468             acqiCb->N = RGSCH_CEIL(cellCb->bwCfg.dlTotalBw, k);
7469             acqiCb->k = k;
7470             break;
7471
7472          case RGR_APRD_CQI_MOD20:
7473          case RGR_APRD_CQI_MOD22:
7474             RG_SCH_GET_SBCQI_M_K_VAL(cellCb->bwCfg.dlTotalBw, M, k);
7475             acqiCb->N = RGSCH_CEIL(cellCb->bwCfg.dlTotalBw, k);
7476             acqiCb->k = k;
7477             acqiCb->M = M;
7478             acqiCb->L = RgSCHUeAcqi2022LBitWidth[M-1][acqiCb->N-1];
7479             break;
7480
7481          default:
7482             break; 
7483       }
7484       if((ueTxMode == RGR_UE_TM_3) || 
7485          (ueTxMode == RGR_UE_TM_4))
7486       {
7487          if(cellCb->numTxAntPorts ==2)
7488          {
7489             acqiCb->riNumBits = 1;
7490          }
7491          else if(cellCb->numTxAntPorts ==4)
7492          {
7493             if(ueCat == CM_LTE_UE_CAT_8)
7494             {
7495                acqiCb->riNumBits = 3;
7496             }
7497             else if(ueCat >= CM_LTE_UE_CAT_5)  
7498             {
7499                acqiCb->riNumBits = 2;
7500             }
7501             else
7502             {
7503                acqiCb->riNumBits = 1;
7504             }
7505          }
7506       }
7507       rgSCHCfgUtlFetchAcqiBitSz(acqiCb, cellCb->numTxAntPorts, 
7508             &cqiPmiSzR1, &cqiPmiSzRn1);
7509       acqiCb->cqiPmiSzR1  = cqiPmiSzR1;
7510       acqiCb->cqiPmiSzRn1 = cqiPmiSzRn1;
7511    }
7512    acqiCb->cqiReqField = TRUE;
7513 #ifdef LTE_ADV
7514    rgSchCmnSetCqiReqField(RG_SCH_CMN_GET_SCELL_INFO(ue, cellCb),ue,&acqiCb->cqiReqField);
7515 #endif
7516    
7517    return ROK;
7518 }
7519
7520 /**
7521  * @brief Handles Periodic CQI , PMI, RI  configuration for a UE.
7522  *
7523  * @details
7524  *
7525  *     Function : rgSCHCfgPCqiUeCfg 
7526  *
7527  *     Invoking Module Processing:
7528  *      - This shall be invoked by SCH_GOM at UE configuration. It shall do the
7529  *      validations for the spec-defined values.
7530  *        
7531  *     Processing Steps:
7532  *     - For UE-specific Periodic CQI  related configuration, 
7533  *      - If Periodic CQI/PMI is configured,
7534  *        - Update UE with the configured values.
7535  - Compute and Update next occurance of CQI/PMI or RI Tranmission instance.
7536  - Update the CQI offset and CQI perodicity information
7537  - Add Ue to cell's list  
7538  *        
7539  *
7540  *     - For UE-specific Periodic RI  related configuration, 
7541  *      - If Periodic RI is configured,
7542  *        - Update UE with the configured values.
7543  - Compute and Update next occurance of RI Tranmission instance.
7544  - Update the  RI offset and RI perodicity information
7545  *      
7546  *
7547  *     - Return ROK
7548  *
7549  *  @param[in]  RgSchCellCb  *cell
7550  *  @param[in]  RgSchUeCb    *ue
7551  *  @param[in]  RgrUePrdDlCqiCfg *cqiCfg
7552  *  @param[in]  CmLteUeCategory   ueCat
7553  *  @return  S16
7554  *      -# ROK
7555  *
7556  **/
7557 S16 rgSCHCfgPCqiUeCfg
7558 (
7559 RgSchCellCb         *cellCb, 
7560 RgSchUeCb           *ueCb, 
7561 RgrUePrdDlCqiCfg    *cqiCfg,
7562 CmLteUeCategory     ueCat
7563 )
7564 {  
7565    CmLteTimingInfo timingInfo;
7566    uint16_t    crntTime;           
7567    uint16_t    cqiTrInstTime; 
7568    uint8_t     j;  /*Bandwidth Parts*/
7569    uint8_t     temp; 
7570    uint8_t     loop;
7571    RgSchUePCqiCb *cqiCb = NULLP;
7572
7573    crntTime = (cellCb->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)+
7574                   (cellCb->crntTime.slot);
7575    cqiCb = RG_SCH_GET_UE_CELL_CQI_CB(ueCb,cellCb);
7576    cqiCb->servCellInfo = ueCb->cellInfo[0];
7577    /* Periodic CQI is setup  */
7578    if (cqiCfg->type == RGR_SCH_PCQI_SETUP)
7579    {   
7580       for(loop = 0; loop < MAX_CQI_RI_RPT_BUFF;loop++)
7581       {
7582          ueCb->rawCqiBitW[loop].type = TFU_RECP_REQ_INVLD; /* setting invalid  type*/
7583       }
7584       /*  1. Copy the Received CQI Cfg parameters to ueCb  */
7585       memcpy(&cqiCb->cqiCfg, cqiCfg, 
7586             sizeof(RgrUePrdDlCqiCfg));
7587
7588       /*  2. Compute Periodic CQI Periodicity and subframe offset   */
7589 #ifndef LTE_TDD           
7590       rgSCHUtlGetCfgPerOff(RG_SCH_FDD_PCQI_TBL, cqiCfg->cqiSetup.cqiPCfgIdx,
7591             &cqiCb->cqiPeri, &cqiCb->cqiOffset);      
7592 #else
7593       rgSCHUtlGetCfgPerOff( RG_SCH_TDD_PCQI_TBL, 
7594             cqiCfg->cqiSetup.cqiPCfgIdx,
7595             &cqiCb->cqiPeri, &cqiCb->cqiOffset);    
7596 #endif
7597       DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgPCqiUeCfg(): UEID:%d CQI Peri=%d, CQI Offset=%d",
7598             ueCb->ueId,
7599             cqiCb->cqiPeri,
7600             cqiCb->cqiOffset);
7601
7602
7603       cqiTrInstTime = ((cqiCb->cqiPeri+crntTime) - cqiCb->cqiOffset)
7604          %cqiCb->cqiPeri;
7605       cqiCb->nCqiTrIdx = (crntTime + 
7606             (cqiCb->cqiPeri - cqiTrInstTime));
7607       /* Introduced timing delta for reception req
7608        * in FDD*/
7609       if(cqiCb->nCqiTrIdx  <= (crntTime + TFU_RECPREQ_DLDELTA))
7610       {
7611          cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx + cqiCb->cqiPeri;
7612       }
7613
7614       /* To handle the SFN wrap around case */
7615       cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx % (RGSCH_MAX_SFN * RGSCH_NUM_SUB_FRAMES_5G);
7616
7617       timingInfo.sfn =  cqiCb->nCqiTrIdx/RGSCH_NUM_SUB_FRAMES_5G;
7618       timingInfo.slot =  cqiCb->nCqiTrIdx % RGSCH_NUM_SUB_FRAMES_5G;
7619
7620       cqiCb->nCqiTrIdx = cqiCb->nCqiTrIdx
7621            %RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
7622
7623 #ifdef EMTC_ENABLE
7624           /*CQI Repetition configuration*/
7625       if(ueCb->isEmtcUe)
7626       {
7627           rgSchfillPucchCqiRepNumCountemtc(cqiCb, ueCb);
7628       }
7629 #endif
7630
7631       if(RGR_UE_PCQI_SB_REP == cqiCfg->cqiSetup.cqiRepType)
7632       {
7633          uint8_t     k;  /*SubBand Size (RB) */
7634          RG_SCH_GET_CQI_J_VAL(cellCb->bwCfg.dlTotalBw, j);
7635          RG_SCH_GET_CQI_K_VAL(cellCb->bwCfg.dlTotalBw, k);
7636          cqiCb->J = j; /*Number of Bandwidth Parts*/
7637          /*h: reporting instances required for a complete CQI/PMI report */
7638          /*j:Number of bandwidth parts; k: Subband Size*/
7639          cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1; 
7640          /* ccpu00140905- L-size is coming as 3 for 100Rbs where it should be 2*/
7641          temp = RGSCH_CEIL(cellCb->bwCfg.dlTotalBw, (j*k));
7642          cqiCb->label = (temp & (temp-1)) ?
7643             (1+ rgSCHUtlLog32bitNbase2(temp)) : rgSCHUtlLog32bitNbase2(temp);
7644
7645          rgSCHTomUtlPcqiSbCalcBpIdx(timingInfo,ueCb, cqiCb); 
7646       }
7647 #ifdef LTE_ADV
7648       else
7649       {
7650          cqiCb->prioLvl = RG_SCH_CQI_PRIO_LVL_1;
7651       }
7652 #endif
7653
7654       /*    Place the UE in cellCb->tIUeLstCp  */
7655       cqiCb->cqiLstEnt.node=(PTR) cqiCb;
7656 #ifdef LTE_ADV
7657       cqiCb->isCqiIgnoByCollsn = FALSE;
7658       cqiCb->isRiIgnoByCollsn = FALSE;
7659 #endif
7660
7661
7662       cmLListAdd2Tail(&cellCb->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
7663             &cqiCb->cqiLstEnt);  
7664
7665
7666       /* 4. Rank Indicator Cfg handler */
7667       rgSCHCfgRiUeCfg(cellCb, ueCb, cqiCfg, ueCat);
7668    }
7669    else
7670    { 
7671       cqiCb->cqiCfg.type =  RGR_SCH_PCQI_REL;
7672       if(cqiCb->nCqiTrIdx != RG_SCH_INVALID_IDX)
7673       {
7674          cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,\
7675                &cqiCb->cqiLstEnt);
7676       } 
7677       if(cqiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
7678       {
7679          cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst, \
7680                &cqiCb->riLstEnt);
7681           RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_DEL,
7682             &cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
7683       }
7684       cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
7685       cqiCb->nRiTrIdx   = RG_SCH_INVALID_IDX;
7686       cqiCb->riDist   = RG_SCH_INVALID_IDX; 
7687    } 
7688    ueCb->nPCqiCb = cqiCb;
7689    ueCb->nPRiCb = cqiCb;
7690    return ROK;
7691 }
7692
7693 /**
7694  * @brief Handles Periodic  RI  configuration for a UE.
7695  *
7696  * @details
7697  *
7698  *     Function : rgSCHCfgRiUeCfg 
7699  *
7700  *     Invoking Module Processing:
7701  *      - This shall be invoked by SCH_GOM at UE configuration. It shall do the
7702  *      validations for the spec-defined values.
7703  *        
7704  *     Processing Steps:
7705  *     - For UE-specific Periodic RI  related configuration, 
7706  *      - If Periodic RI is configured,
7707  *        - Update UE with the configured values.
7708  - Compute and Update next occurance of RI Tranmission instance.
7709  - Update the  RI offset and RI perodicity information
7710  *
7711  *     - Return ROK
7712  *
7713  *  @param[in]  RgSchCellCb  *cell
7714  *  @param[in]  RgSchUeCb    *ue
7715  *  @param[in]  RgrUePrdDlCqiCfg *cqiCfg
7716  *  @param[in]  CmLteUeCategory   ueCat
7717  *  @return  S16
7718  *      -# ROK
7719  *
7720  **/
7721 S16 rgSCHCfgRiUeCfg
7722 (
7723 RgSchCellCb        *cellCb, 
7724 RgSchUeCb          *ueCb, 
7725 RgrUePrdDlCqiCfg   *cqiCfg,
7726 CmLteUeCategory    ueCat
7727 )
7728 {
7729    uint16_t     crntTime;  
7730    uint16_t     riTrInsTime;  
7731    uint8_t      j; /*Bandwidth parts. Valid for Modes 2-0, 2-1*/         
7732    uint16_t     periodicity; 
7733    uint16_t    tempIdx; 
7734    RgSchUePCqiCb *cqiCb = NULLP;
7735
7736    crntTime = (cellCb->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)
7737       +(cellCb->crntTime.slot);
7738    cqiCb = RG_SCH_GET_UE_CELL_CQI_CB(ueCb,cellCb);
7739    /* 1. Rank Indicator is enabled  */
7740    if(cqiCfg->cqiSetup.riEna)
7741    {
7742
7743       rgSCHUtlGetCfgPerOff(RG_SCH_RI_TBL, 
7744             cqiCfg->cqiSetup.riCfgIdx,
7745             &cqiCb->riPeri, &cqiCb->riOffset);
7746
7747       DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgRiUeCfg(): RI Peri=%d, RI Offset=%d UEID:%d", 
7748             cqiCb->riPeri, cqiCb->riOffset,ueCb->ueId);
7749
7750       cqiCb->perRiVal = 1;
7751       cqiCb->invalidateCqi = FALSE;
7752
7753       if(RGR_UE_PCQI_WB_REP == cqiCfg->cqiSetup.cqiRepType)
7754       {
7755          /* 
7756             1. wideband RI reporting is configured 
7757             (Mode 1-0 or 1-1)
7758             (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )Mod(NCqiperiod
7759           *MriPeriod)=0  
7760           */ 
7761          periodicity = cqiCb->cqiPeri * cqiCb->riPeri; 
7762       }
7763       else
7764       {
7765          /*
7766          *  Where Widesband and Subband RI reporting is configured
7767          *   (Mode 2-0 or 2-1 )
7768          *   (10*sfn+floor(subframe)-Noffsetcqi-NoffsetRI )
7769          *   Mod(H. NCqiperiod *MriPeriod )=0 
7770          *   where H= J * K +1;  J=Number of bandwidth parts(BW/subsize). 
7771          *   K is RGR interf input 
7772          */
7773
7774          RG_SCH_GET_CQI_J_VAL(cellCb->bwCfg.dlTotalBw, j);
7775          cqiCb->h = (cqiCb->cqiCfg.cqiSetup.k *j )+1;  
7776          periodicity = cqiCb->h * cqiCb->cqiPeri * 
7777                                   cqiCb->riPeri; 
7778       }
7779
7780       /* In case of SFN wraparound, the SB CQI reporting cycle breaks
7781        * and RI->WB CQI->SBCQI.. should resume. RI is repositioned 
7782        * accordingly. WBCQI handling is naturally accomplished */
7783       if (periodicity >= RGSCH_MAX_SUBFRM_5G)
7784       {
7785          periodicity = cqiCb->cqiOffset - cqiCb->riOffset + 
7786                        RGSCH_MAX_SUBFRM_5G - (crntTime);
7787          tempIdx = crntTime + periodicity;
7788          DU_LOG("\nINFO  -->  SCH : CHECK_SID - periodicity %d tempIdx %d\n", periodicity, tempIdx);
7789       }
7790       else
7791       {
7792          if ((crntTime + TFU_RECPREQ_DLDELTA + periodicity) > 
7793                             (RGSCH_MAX_SUBFRM_5G - 1))
7794          {
7795             riTrInsTime = (periodicity - cqiCb->cqiOffset + cqiCb->riOffset) % periodicity; 
7796             tempIdx = RGSCH_MAX_SUBFRM_5G + (periodicity - riTrInsTime);
7797          }
7798          else
7799          {
7800             riTrInsTime = ((periodicity +crntTime )- \
7801                cqiCb->cqiOffset + cqiCb->riOffset)\
7802                        % periodicity;
7803             tempIdx = (crntTime + (periodicity -riTrInsTime));
7804          }
7805       }
7806       if (tempIdx <= (crntTime + TFU_RECPREQ_DLDELTA))
7807       {
7808          tempIdx = tempIdx + periodicity; 
7809       }
7810       cqiCb->nRiTrIdx = tempIdx 
7811          % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
7812       if(periodicity >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
7813       {  
7814          cqiCb->riDist = rgSCHUtlFindDist((uint16_t)(crntTime + TFU_RECPREQ_DLDELTA),
7815                 (uint16_t) tempIdx);
7816       }
7817       else
7818       {
7819          cqiCb->riDist =0; 
7820       }
7821       if(ueCb->mimoInfo.txMode == RGR_UE_TM_3 
7822             || ueCb->mimoInfo.txMode == RGR_UE_TM_4)
7823       {
7824          if (cellCb->numTxAntPorts ==2)
7825          {
7826             cqiCb->riNumBits = 1;
7827          }
7828          else if(cellCb->numTxAntPorts ==4)
7829          {
7830             if(ueCat == CM_LTE_UE_CAT_8)
7831             {
7832                cqiCb->riNumBits = 3;
7833             }
7834             else if(ueCat >= CM_LTE_UE_CAT_5)  
7835             {
7836                cqiCb->riNumBits = 2;
7837             }
7838             else
7839             {
7840                cqiCb->riNumBits = 1;
7841             }
7842          }
7843       }
7844       /*    Place the UE in cellCb->tIUeLstCp  */
7845       cqiCb->riLstEnt.node=(PTR) cqiCb;
7846
7847       cmLListAdd2Tail(&cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst,
7848             &cqiCb->riLstEnt);  
7849       RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_ADD,
7850          &cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
7851      
7852
7853    }
7854    else
7855    {
7856       cqiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
7857       cqiCb->riDist   = RG_SCH_INVALID_IDX; 
7858    }
7859
7860    return ROK;
7861
7862 }
7863
7864 /* @brief Handles SRS configuration for a UE.
7865  *
7866  * @details
7867  *
7868  *     Function : rgSCHCfgSrsUeCfg 
7869  *
7870  *     Invoking Module Processing:
7871  *      - This shall be invoked by SCH_GOM at UE configuration. It shall do the
7872  *      validations for the spec-defined values.
7873  *        
7874  *     Processing Steps:
7875  *     - For UE-specific SRS  related configuration, 
7876  *      - If SRS is configured,
7877  *        - Update UE with the configured values.
7878  - Compute and Update next occurance of SRS Tranmission instance.
7879  - Update the  SRS offset and SRS perodicity information
7880  - Add Ue to cell's srs list
7881  *      - else
7882  *        - next occurance transmission instance of SRS  = RG_SCH_INVALID_IDX
7883  *
7884  *     - Return ROK
7885  *
7886  *  @param[in]  RgSchCellCb  *cell
7887  *  @param[in]  RgSchUeCb    *ue
7888  *  @param[in]  RgrUeUlSrsCfg   *srsCfg
7889  *
7890  *  @return  S16
7891  *      -# ROK
7892  *      -# RFAILED
7893  */
7894 S16 rgSCHCfgSrsUeCfg
7895 (
7896 RgSchCellCb     *cellCb,
7897 RgSchUeCb       *ueCb,
7898 RgrUeUlSrsCfg   *srsCfg 
7899 )
7900 {
7901    uint16_t      srsTrInsTime;
7902    uint16_t      crntTime;  
7903    uint16_t      tempIdx;
7904
7905    crntTime = (cellCb->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)
7906       +(cellCb->crntTime.slot);
7907
7908    if(RGR_SCH_SRS_SETUP == srsCfg->type) 
7909    {
7910       /*  1. Copy the Received Cfg parameters to local cb  */
7911       memcpy(&ueCb->srsCb.srsCfg, srsCfg, sizeof(RgrUeUlSrsCfg));
7912
7913 #ifndef LTE_TDD
7914       /* 2.  Compute SRS Offset and Periodicity */
7915       rgSCHUtlGetCfgPerOff( RG_SCH_FDD_SRS_TBL, 
7916             srsCfg->srsSetup.srsCfgIdx,
7917             &ueCb->srsCb.peri, &ueCb->srsCb.offset);      
7918 #else
7919       rgSCHUtlGetCfgPerOff( RG_SCH_TDD_SRS_TBL, 
7920             srsCfg->srsSetup.srsCfgIdx,
7921             &ueCb->srsCb.peri, &ueCb->srsCb.offset);      
7922 #endif       
7923
7924       DU_LOG("\nDEBUG  -->  SCH : rgSCHCfgSrsUeCfg(): SRS Peri=%d, SRS Offset=%d UEID:%d", 
7925             ueCb->srsCb.peri,ueCb->srsCb.offset,ueCb->ueId);
7926
7927       /*  3. Compute next Tranmission index for SRS */ 
7928       /*     Referenence: 36.213 Section:8.2
7929              i. SRS transmission instances for TDD with  period > 2 and for FDD are 
7930              ((10*sfn +Ksrs-suframeoffset))/mod(periodicity))  
7931              FDD: Ksrs is 0...9
7932              TDD: Ksrs Table 8.2-3: 
7933              ii.The SRS transmission instances for TDD (periodicity == 2)
7934              (Ksrs-Toffset)mod(5)==0.  Note: This is not supported now  
7935       */ 
7936
7937       srsTrInsTime = ((ueCb->srsCb.peri+crntTime) - ueCb->srsCb.offset)
7938          %ueCb->srsCb.peri;
7939      tempIdx = (crntTime + (ueCb->srsCb.peri - srsTrInsTime));
7940 #ifdef LTE_TDD
7941       if (tempIdx  <=  (crntTime + TFU_DELTA))
7942 #else
7943       if (tempIdx  <=  (crntTime + TFU_RECPREQ_DLDELTA))
7944 #endif
7945       {
7946          tempIdx = tempIdx + ueCb->srsCb.peri;
7947       }
7948       ueCb->srsCb.nSrsTrIdx =(uint16_t) (tempIdx 
7949          % RG_SCH_PCQI_SRS_SR_TRINS_SIZE);
7950       if(ueCb->srsCb.peri >= RG_SCH_PCQI_SRS_SR_TRINS_SIZE)
7951       {
7952 #ifdef LTE_TDD
7953          ueCb->srsCb.srsDist = rgSCHUtlFindDist((uint8_t)(crntTime+TFU_DELTA), 
7954                                                     (uint16_t)tempIdx); 
7955 #else
7956          ueCb->srsCb.srsDist = rgSCHUtlFindDist((uint8_t)(crntTime + TFU_RECPREQ_DLDELTA), 
7957                                                     (uint16_t)tempIdx); 
7958 #endif
7959       }
7960       else
7961       {
7962          ueCb->srsCb.srsDist = 0; 
7963       }
7964
7965       /*UE Tx Antenna Selection - START*/
7966       if(ueCb->ul.ulTxAntSel.pres == TRUE )
7967       {
7968           /*for both partial and full sounding bandwidth, 
7969            and when frequency hopping is disabled */
7970          ueCb->srsCb.selectedAnt = (crntTime/ueCb->srsCb.peri)%2; 
7971       }
7972       else
7973       {
7974          /* TS 36.213 specifies that if Tx Antenna Selection is 
7975             disabled/not supported then its Port 0*/
7976          ueCb->srsCb.selectedAnt=0; 
7977       }
7978       ueCb->validTxAnt = ueCb->srsCb.selectedAnt; 
7979       /*UE Tx Antenna Selection - ENDS*/
7980
7981       ueCb->srsCb.srsLstEnt.node=(PTR)ueCb;
7982       cmLListAdd2Tail(&cellCb->pCqiSrsSrLst[ueCb->srsCb.nSrsTrIdx].srsLst,
7983             &ueCb->srsCb.srsLstEnt);  
7984
7985
7986    }
7987    else
7988    {
7989       /*  SRS Release / Not configured */
7990       ueCb->srsCb.srsCfg.type = RGR_SCH_SRS_REL;
7991       if(ueCb->srsCb.nSrsTrIdx != RG_SCH_INVALID_IDX)
7992       {
7993          cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srsCb.nSrsTrIdx].srsLst,
7994                &ueCb->srsCb.srsLstEnt);
7995       }
7996       ueCb->srsCb.nSrsTrIdx = RG_SCH_INVALID_IDX; 
7997       ueCb->srsCb.srsLstEnt.node =(PTR) NULLP;
7998    }
7999
8000    return ROK;
8001 }
8002
8003
8004 /* * @brief Handles SR configuration for a UE.
8005  *
8006  * @details
8007  *
8008  *     Function : rgSCHCfgSrUeCfg 
8009  *
8010  *     Invoking Module Processing:
8011  *      - This shall be invoked by SCH_GOM at UE configuration. It shall do the
8012  *      validations for the spec-defined values.
8013  *        
8014  *      - If SR is configured,
8015  *        - Update UE with the configured values.
8016  - Compute and Update next occurance of SR Tranmission instance.
8017  - Update the  SR offset and SR perodicity information
8018  - Add Ue to cell->tIUeLstCp[n]  
8019  *      - else
8020  *        - next occurance transmission instance of SR = RG_INVALID_SR_ID
8021  *
8022  *
8023  *     - Return ROK
8024  *
8025  *  @param[in]  RgSchCellCb  *cell
8026  *  @param[in]  RgSchUeCb    *ue
8027  *  @param[in]  RgrUeSrCfg       *srCfg
8028  *
8029  *  @return  S16
8030  *      -# ROK
8031  *      -# RFAILED
8032  */
8033 S16 rgSCHCfgSrUeCfg
8034 (
8035 RgSchCellCb      *cellCb,
8036 RgSchUeCb        *ueCb,
8037 RgrUeSrCfg       *srCfg
8038 )
8039 {
8040    uint16_t     srTrInsTime;
8041    uint16_t     crntTime;
8042
8043
8044    crntTime = (cellCb->crntTime.sfn * RGSCH_NUM_SUB_FRAMES_5G)
8045       +(cellCb->crntTime.slot);
8046    if(srCfg->type == RGR_SCH_SR_SETUP) 
8047    {
8048       /*  1. Copy the Received Cfg parameters to local cb  */
8049       memcpy(&ueCb->srCb.srCfg, srCfg, sizeof(RgrUeSrCfg));
8050
8051
8052       /*  2. Compute SR periodicity and offset */
8053       rgSCHUtlGetCfgPerOff( RG_SCH_SR_TBL, 
8054             srCfg->srSetup.srCfgIdx,
8055             &ueCb->srCb.peri, &ueCb->srCb.offset);
8056     
8057       DU_LOG("\nDEBUG  -->  SCH : SR Config: idx(%u), period (%u) offset (%u) UEID:%d",
8058             srCfg->srSetup.srCfgIdx,
8059             ueCb->srCb.peri, 
8060             ueCb->srCb.offset,
8061             ueCb->ueId);
8062 #ifdef EMTC_ENABLE
8063       if(ueCb->isEmtcUe)
8064       {
8065          rgSchfillPucchSrRepNumCountemtc(ueCb);
8066       }
8067 #endif
8068       /*   3. Compute Next Transmission Instance */
8069
8070       srTrInsTime = ((ueCb->srCb.peri+crntTime) - ueCb->srCb.offset)
8071          %ueCb->srCb.peri;
8072       ueCb->srCb.nSrTrIdx = (crntTime + (ueCb->srCb.peri- srTrInsTime)); 
8073 #ifdef LTE_TDD
8074       if (ueCb->srCb.nSrTrIdx  <= (crntTime + TFU_DELTA))
8075 #else
8076       if (ueCb->srCb.nSrTrIdx  <= (crntTime + TFU_RECPREQ_DLDELTA))
8077 #endif
8078       {
8079          ueCb->srCb.nSrTrIdx = ueCb->srCb.nSrTrIdx +  ueCb->srCb.peri;
8080       }
8081       ueCb->srCb.nSrTrIdx = ueCb->srCb.nSrTrIdx 
8082          % RG_SCH_PCQI_SRS_SR_TRINS_SIZE;
8083       ueCb->srCb.srLstEnt.node= (PTR) ueCb;
8084
8085       /* 4. Place UE in Cell SR Tranmisison Instance List  */
8086       cmLListAdd2Tail(&cellCb->pCqiSrsSrLst[ueCb->srCb.nSrTrIdx].srLst,
8087             &ueCb->srCb.srLstEnt);  
8088    }
8089    else
8090    {
8091       ueCb->srCb.srCfg.type =  RGR_SCH_SR_REL;
8092
8093       if(ueCb->srCb.nSrTrIdx != RG_SCH_INVALID_IDX)
8094       {
8095          cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srCb.nSrTrIdx].srLst,
8096                &ueCb->srCb.srLstEnt);
8097       }
8098       ueCb->srCb.nSrTrIdx = RG_SCH_INVALID_IDX; 
8099       ueCb->srCb.srLstEnt.node = (PTR)NULLP;
8100    }
8101
8102    return ROK;
8103 }
8104
8105
8106 /*****************************************************************
8107  *    UE PCQI, RI, SRS and SR       Re Configuration Functions    *
8108  *                                                                *
8109  ******************************************************************/
8110
8111
8112 /* * @brief Handles Periodic CQI, PMI, RI  Re-configuration for a UE.
8113  *
8114  * @details
8115  *
8116  *     Function : rgSCHCfgPCqiUeReCfg 
8117  *
8118  *     Invoking Module Processing:
8119  *      - This shall be invoked by SCH_GOM at UE Re configuration. It shall do the
8120  *      validations for the spec-defined values.
8121  *        
8122  *     Processing Steps:
8123  *     - For UE-specific Periodic CQI  related configuration, 
8124  *      - If Periodic CQI/PMI is re configured(first time enabled),
8125  *          - Update UE with the configured values.
8126  *         - Compute and Update next occurance of CQI/PMI or RI Tranmission 
8127  *         instance.
8128  *         - Update the CQI offset and CQI perodicity information
8129  *         - Add Ue to cell's list 
8130  *      - If Periodic CQI/PMI is re configured(modify),
8131  *         - Update UE with the configured values.
8132  *         - Del Ue from cell->tIUeLstCp list 
8133  *          - Compute and Update next occurance of CQI/PMI or RI Tranmission
8134  *          instance.
8135  *         - Update the CQI offset and CQI perodicity information
8136  *         - Add Ue to cell's list
8137  *      - If Periodic CQI/PMI is re configured(disabled),
8138  *        - Update UE with the configured values.
8139  *         - Del Ue from cell's list  
8140  *         - Update next occurance of CQI/PMI or RI Tranmission instance.
8141  *        - next occurance of CQI/PMI = RG_INVALID_CQIPMI_ID
8142  *
8143  *     - For UE-specific Periodic RI  related configuration, 
8144  *      - If Periodic RI is configured(first time enabled),
8145  *        - Update UE with the configured values.
8146  *          - Compute and Update next occurance of RI Tranmission instance.
8147  *         - Update the  RI offset and RI perodicity information
8148  *      - If Periodic RI is configured(modify),
8149  *        - Update UE with the configured values.
8150  *         - Compute and Update next occurance of RI Tranmission instance.
8151  *         - Update the  RI offset and RI perodicity information
8152  *      - else
8153  *        - next occurance of RI  = RG_INVALID_CQIPMI_ID
8154  *
8155  *     - Return ROK
8156  *
8157  *  @param[in]  RgSchCellCb  *cell
8158  *  @param[in]  RgSchUeCb    *ue
8159  *  @param[in]  RgrUeCfg     *ueCfg
8160  *
8161  *  @return  S16
8162  *      -# ROK
8163  *
8164  */
8165 S16 rgSCHCfgPCqiUeReCfg
8166 (
8167 RgSchCellCb        *cellCb, 
8168 RgSchUeCb          *ueCb, 
8169 RgrUePrdDlCqiCfg   *cqiCfg,
8170 CmLteUeCategory      ueCat
8171 )
8172 {
8173
8174    RgSchUePCqiCb *cqiCb = NULLP;
8175
8176    cqiCb = RG_SCH_GET_UE_CELL_CQI_CB(ueCb,cellCb);
8177    /* Fix: ccpu00124008 Fix for incorrect check causing missed CQI reception instance */
8178    if((cqiCfg->type == RGR_SCH_PCQI_SETUP) &&
8179          (cqiCb->cqiCfg.type != RGR_SCH_PCQI_SETUP))
8180    {
8181       /* 1. cqi is in Release (Disable) state,  Recfg is allowing Setup (Enable)
8182       */
8183       rgSCHCfgPCqiUeCfg(cellCb, ueCb, cqiCfg, ueCat);
8184
8185    }
8186    else if((cqiCfg->type == RGR_SCH_PCQI_SETUP) &&
8187          (cqiCb->cqiCfg.type == RGR_SCH_PCQI_SETUP ))
8188    {
8189
8190       /*
8191          2. Present is SETUP(Enable) state,  Recfg is modifying SETUP(Enable)
8192
8193          2.1 Delete UE from the cqiList 
8194          2.2 Set next occurance Transmission instace to "INVALID"
8195          2.3 Compute Next occurance Transmission instace 
8196          2.4 Placed ue in Transmission instance list.
8197          */    
8198       if(cqiCb->nCqiTrIdx != RG_SCH_INVALID_IDX )
8199          cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiCb->nCqiTrIdx].cqiLst,
8200                &cqiCb->cqiLstEnt); 
8201
8202       if(cqiCb->nRiTrIdx != RG_SCH_INVALID_IDX )
8203       {
8204          cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst,
8205                &cqiCb->riLstEnt); 
8206          RG_SCH_RECORD(&cqiCb->histElem,RGSCH_ACTION_DEL,
8207             &cellCb->pCqiSrsSrLst[cqiCb->nRiTrIdx].riLst);
8208       }
8209
8210
8211       cqiCb->cqiLstEnt.next = NULLP;
8212       cqiCb->cqiLstEnt.prev  = NULLP;
8213       cqiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
8214       cqiCb->nRiTrIdx  = RG_SCH_INVALID_IDX;
8215       cqiCb->riDist    = RG_SCH_INVALID_IDX;
8216
8217       rgSCHCfgPCqiUeCfg(cellCb, ueCb, cqiCfg, ueCat);
8218    }
8219    else
8220    {
8221       /* Present is SETUP(Enable) state,  Recfg is Release(Disable)  */
8222       rgSCHCfgPCqiUeCfg(cellCb, ueCb, cqiCfg, ueCat);
8223    }
8224
8225    /* ccpu00140578:: */
8226    cqiCb->riRecpPrcsd = FALSE;
8227    return ROK;
8228 }
8229
8230
8231 /* * @brief Handles SRS  Re-configuration for a UE.
8232  *
8233  * @details
8234  *
8235  *     Function : rgSCHCfgSrsUeReCfg 
8236  *
8237  *     Invoking Module Processing:
8238  *      - This shall be invoked by SCH_GOM at UE Re configuration. It shall do the
8239  *      validations for the spec-defined values.
8240  *        
8241  *     Processing Steps:
8242  *     - For UE-specific SRS  related re configuration, 
8243  *      - If SRS is configured modified(First time Enabled),
8244  *        - Update UE with the configured values.
8245  *         - Compute and Update next occurance of SRS Tranmission instance.
8246  *        - Update the  SRS offset and SRS perodicity information
8247  *        - Add Ue to cell's list  
8248  *      - If SRS is configured modified(Changed offset or index ),
8249  *      - Delete UE from cell->tIUeLstCp[n] if present  
8250  *      - Update UE with the configured values.
8251  *      - Compute and Update next occurance of SRS Tranmission instance.
8252  *      - Update the  SRS offset and SRS perodicity information
8253  *      - Add Ue to cell's list  
8254  *      - If SRS is configured modified(disabled),
8255  *      - Delete UE from cell->tIUeLstCp[n] if present  
8256  *        - Update next occurance of SRS Tranmission instance to "INVALID".
8257  *        - Update the  SRS offset and SRS perodicity information "INVALID"
8258  *      - else
8259  *        - ROK 
8260  *
8261  *     - Return ROK
8262  *
8263  *  @param[in]  RgSchCellCb  *cell
8264  *  @param[in]  RgSchUeCb    *ue
8265  *  @param[in]  RgrUeUlSrsCfg    *srsCfg
8266  *
8267  *  @return  S16
8268  *      -# ROK
8269  *      -# RFAILED
8270  */
8271 S16 rgSCHCfgSrsUeReCfg
8272 (
8273 RgSchCellCb        *cellCb, 
8274 RgSchUeCb          *ueCb, 
8275 RgrUeUlSrsCfg      *srsCfg
8276 )
8277 {
8278
8279
8280    if(( RGR_SCH_SRS_SETUP == srsCfg->type) ||
8281          ( RGR_SCH_SRS_SETUP != ueCb->srsCb.srsCfg.type ))
8282    {
8283       /*     1. Present is Release(Disable) state,  Recfg is allowing
8284        *     SETUP(Enable)  */
8285       rgSCHCfgSrsUeCfg(cellCb, ueCb, srsCfg);
8286    } 
8287    else if (( RGR_SCH_SRS_SETUP == srsCfg->type ) &&
8288          ( RGR_SCH_SRS_SETUP  == ueCb->srsCb.srsCfg.type))
8289    {
8290
8291       /*     2. Present is SETUP(Eanble) state,  Recfg is modifying SETUP(Enable) 
8292
8293              2.1 Delete UE from the cqiList 
8294              2.2 Set next occurance Transmission instance to "INVALID"
8295              2.3 Compute Next occurance Transmission instance 
8296              2.4 Placed ue in Transmission instance list.
8297              */ 
8298       if (ueCb->srsCb.nSrsTrIdx != RG_SCH_INVALID_IDX)
8299       {
8300          cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srsCb.nSrsTrIdx].srsLst,
8301                &ueCb->srsCb.srsLstEnt);
8302          ueCb->srsCb.nSrsTrIdx = RG_SCH_INVALID_IDX;
8303       }
8304
8305       rgSCHCfgSrsUeCfg(cellCb, ueCb, srsCfg);
8306    }
8307    else
8308    {
8309       /* 3. Present is SETUP(Enable) state,  Recfg is Release(Disable)*/ 
8310       rgSCHCfgSrsUeCfg(cellCb, ueCb, srsCfg);
8311    }
8312    /* ccpu00140578:: */
8313    ueCb->srsCb.srsRecpPrcsd = FALSE;
8314
8315    return ROK;
8316 }
8317
8318 /* @brief Handles  SR Re-configuration for a UE.
8319  *
8320  * @details
8321  *
8322  *     Function : rgSCHCfgSrUeReCfg 
8323  *
8324  *     Invoking Module Processing:
8325  *      - This shall be invoked by SCH_GOM at UE Re configuration. 
8326  *      It shall do the validations for the spec-defined values.
8327  *        
8328  *     Processing Steps:
8329  *     - For UE-specific SR  related re configuration, 
8330  *      - If SR is configured modified(First time Enabled),
8331  *        - Update UE with the configured values.
8332  *          - Compute and Update next occurance of SR Tranmission instance.
8333  *         - Update the  SR offset and SR perodicity information
8334  *         - Add Ue to cell->tIUeLstCp[n]  
8335  *      - If SR is configured modified(Changed offset or index ),
8336  *      - Delete UE from cell->tIUeLstCp[n] if present  
8337  *       - Update UE with the configured values.
8338  *       - Compute and Update next occurance of SR Tranmission instance.
8339  *       - Update the  SR offset and SR perodicity information
8340  *       - Add Ue to cell->tIUeLstCp[n]  
8341  *      - If SR is configured modified(disabled),
8342  *      - Delete UE from cell->tIUeLstCp[n] if present  
8343  *         - Update next occurance of SR Tranmission instance to "INVALID".
8344  *         - Update the  SR offset and SR perodicity information "INVALID"
8345  *      - else
8346  *        - ROK 
8347  *
8348  *
8349  *
8350  *     - Return ROK
8351  *
8352  *  @param[in]  RgSchCellCb  *cell
8353  *  @param[in]  RgSchUeCb    *ue
8354  *  @param[in]  RgrUeCfg     *ueCfg
8355  *
8356  *  @return  S16
8357  *      -# ROK
8358  *      -# RFAILED
8359  */
8360 S16 rgSCHCfgSrUeReCfg
8361 (
8362 RgSchCellCb    *cellCb, 
8363 RgSchUeCb      *ueCb, 
8364 RgrUeSrCfg     *srCfg
8365 )
8366 {
8367
8368    /* Fix : syed Incorrect check for SR RECFG */
8369    if((srCfg->type == RGR_SCH_SR_SETUP) &&
8370          (ueCb->srCb.srCfg.type != RGR_SCH_SR_SETUP))
8371    {
8372       /*
8373          1. Present is Release(Disable) state,  Recfg is allowing SETUP(Enable) 
8374          */
8375       rgSCHCfgSrUeCfg(cellCb, ueCb, srCfg);
8376    } 
8377    else if((srCfg->type == RGR_SCH_SR_SETUP) &&
8378          (ueCb->srCb.srCfg.type == RGR_SCH_SR_SETUP))
8379    {
8380
8381       /*   2. Present is SETUP(Eanble) state,  Recfg is modifying SETUP(Enable) 
8382
8383            2.1 Delete UE from the cqiList 
8384            2.2 Compute Next occurance Transmission instace 
8385            */      
8386       if(ueCb->srCb.nSrTrIdx != RG_SCH_INVALID_IDX )
8387       {
8388          cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srCb.nSrTrIdx].srLst, 
8389                &ueCb->srCb.srLstEnt);
8390          ueCb->srCb.nSrTrIdx = RG_SCH_INVALID_IDX;
8391       }
8392       rgSCHCfgSrUeCfg(cellCb, ueCb, srCfg);
8393
8394    }
8395    else
8396    {
8397       /* 3. Present is SETUP(Enable) state,  Recfg is Release(Disable) */
8398       rgSCHCfgSrUeCfg(cellCb, ueCb, srCfg);
8399    }
8400
8401    return ROK;
8402 }
8403
8404 /* @brief Handles  ACQI Re-configuration for a UE.
8405  *
8406  * @details
8407  *
8408  *     Function : rgSCHCfgAcqiUeReCfg 
8409  *
8410  *     Invoking Module Processing:
8411  *      - This shall be invoked by SCH_GOM at UE Re configuration. 
8412  *      It shall do the validations for the spec-defined values.
8413  *        
8414  *     Processing Steps:
8415  *     - For UE-specific ACQI  related re configuration, 
8416  *          - Check if the ACQI Mode has been changed from the
8417  *             existing Configuration.
8418  *     - If the configuration has been changed,
8419  *          - Call Aperiodic Config function to change the config
8420  *      - else
8421  *        - ROK 
8422  *
8423  *
8424  *     - Return ROK
8425  *
8426  *  @param[in]  RgSchCellCb  *cell
8427  *  @param[in]  RgSchUeCb    *ue
8428  *  @param[in]  RgrUeAprdDlCqiCfg   *acqiCfg
8429  *
8430  *  @return  S16
8431  *      -# ROK
8432  *      -# RFAILED
8433  */
8434 S16 rgSCHCfgAcqiUeReCfg
8435 (
8436 RgSchCellCb    *cellCb, 
8437 RgSchUeCb      *ueCb, 
8438 RgrUeAprdDlCqiCfg   *acqiCfg,
8439 CmLteUeCategory   ueCat
8440 )
8441 {
8442
8443    return (rgSCHCfgACqiUeCfg(cellCb,ueCb,(RG_SCH_CMN_GET_ACQICB(ueCb,cellCb))
8444                                     ,ueCb->mimoInfo.txMode, acqiCfg, ueCat));
8445
8446 }
8447
8448 /*****************************************************************
8449  *   UE PCQI, RI, SRS and SR Configuration  Delete                *
8450  *                                                                *
8451  *****************************************************************/
8452
8453 /* @brief Free Periodic CQI/PMI/RI, SRS and SR transmission instance 
8454  * related data structures of this UE from CellCb 
8455  *
8456  * @details
8457  *
8458  *     Function : rgSCHCfgPCqiSrsSrUeDel
8459  *
8460  *     Invoking Module Processing:
8461  *      - This shall be invoked by SCH_GOM at Ue deletion.
8462  *
8463  *     Processing Steps:
8464  *      - For SRS Transmission Instance
8465  *       - if (srsTxInst!= RG_INVALID)
8466  *        - Remove from the cellCb->tIUeLstCp[srsTxInst*3+2]
8467  *       - else
8468  *        - Nothing to do
8469  *      - For SR Transmission Instance
8470  *       - if (srTxInst!= RG_INVALID)
8471  *        - Remove from the cellCb->tIUeLstCp[srTxInst*3+1]
8472  *       - else
8473  *        - Nothing to do
8474  *      - For Periodic CQI/PMI RI  Transmission Instance
8475  *       - if (pCqiTxInst!= RG_INVALID)
8476  *        - Remove from the cellCb->tIUeLstCp[srTxInst*3+0]
8477  *       - else
8478  *        - Nothing to do
8479  *      - Return ROK
8480  *  @param[in]  RgSchCellCb  *cell
8481  *  @param[in]  RgSchUeCb    *ue
8482  *
8483  *  @return  S16
8484  *      -# ROK
8485  */
8486 S16 rgSCHCfgPCqiSrsSrUeDel 
8487 (
8488 RgSchCellCb      *cellCb,
8489 RgSchUeCb        *ueCb
8490 )
8491 {
8492 #ifdef LTE_ADV
8493    uint32_t cellIdx;
8494    uint32_t sCellCnt = 0;
8495 #endif
8496    RgSchUePCqiCb *cqiRiCb = NULLP;
8497
8498    cqiRiCb = RG_SCH_GET_UE_CELL_CQI_CB(ueCb,cellCb);
8499
8500
8501
8502    /* Delete SRS Transmission Instance  */
8503    if (ueCb->srsCb.nSrsTrIdx != RG_SCH_INVALID_IDX)
8504    {
8505       cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srsCb.nSrsTrIdx].srsLst,
8506             &ueCb->srsCb.srsLstEnt); 
8507       ueCb->srsCb.nSrsTrIdx = RG_SCH_INVALID_IDX;
8508    }
8509
8510    /* Delete SR Transmission Instance  */
8511    if (ueCb->srCb.nSrTrIdx != RG_SCH_INVALID_IDX)
8512    {
8513       cmLListDelFrm(&cellCb->pCqiSrsSrLst[ueCb->srCb.nSrTrIdx].srLst,
8514             &ueCb->srCb.srLstEnt); 
8515       ueCb->srCb.nSrTrIdx = RG_SCH_INVALID_IDX;
8516    }
8517
8518    /* Delete Periodic CQI/PMI  Transmission Instance  */
8519    if (cqiRiCb->nCqiTrIdx != RG_SCH_INVALID_IDX)
8520    {
8521       cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiRiCb->nCqiTrIdx].cqiLst, 
8522             &cqiRiCb->cqiLstEnt); 
8523       cqiRiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
8524
8525       /* Delete Periodic  RI  Transmission Instance  */
8526
8527       if (cqiRiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
8528       {
8529          cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst, 
8530                &cqiRiCb->riLstEnt); 
8531          RG_SCH_RECORD(&cqiRiCb->histElem,RGSCH_ACTION_DEL,
8532             &cellCb->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst);
8533          cqiRiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
8534       }
8535    }
8536
8537 #ifdef LTE_ADV
8538    for (cellIdx =1; cellIdx <= RG_SCH_MAX_SCELL; cellIdx++)
8539    {
8540       /* If a serving cell is configured */
8541       if(ueCb->cellInfo[cellIdx] != NULLP)
8542       {
8543          /* If the serving cell is in ACTIVE state and 
8544             If it is not the same serving cell as cqiRiCb for which 
8545             collision is being checked */
8546          cqiRiCb = &ueCb->cellInfo[cellIdx]->cqiCb;
8547          /* Delete Periodic CQI/PMI  Transmission Instance  */
8548          if (cqiRiCb->nCqiTrIdx != RG_SCH_INVALID_IDX)
8549          {
8550             cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiRiCb->nCqiTrIdx].cqiLst, 
8551                   &cqiRiCb->cqiLstEnt); 
8552             cqiRiCb->nCqiTrIdx = RG_SCH_INVALID_IDX;
8553
8554             /* Delete Periodic  RI  Transmission Instance  */
8555
8556             if (cqiRiCb->nRiTrIdx != RG_SCH_INVALID_IDX)
8557             {
8558                cmLListDelFrm(&cellCb->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst, 
8559                      &cqiRiCb->riLstEnt); 
8560                RG_SCH_RECORD(&cqiRiCb->histElem,RGSCH_ACTION_DEL,
8561                   &cellCb->pCqiSrsSrLst[cqiRiCb->nRiTrIdx].riLst);
8562                cqiRiCb->nRiTrIdx = RG_SCH_INVALID_IDX;
8563             }
8564          }
8565          sCellCnt++;
8566          /* If all of the num of configured scells are checked then break */
8567          if (sCellCnt == ueCb->numSCells)
8568          {
8569             break;
8570          }   
8571       }
8572    }
8573 #endif
8574
8575    return ROK;
8576 }
8577
8578
8579 /* @brief Search the cfgIdx in given table and retrive periodicity & offset
8580  * @details
8581  *
8582  *     Function : rgSCHUtlGetCfgPerOff 
8583  *
8584  *     Invoking Module Processing:
8585  *      - This shall be invoked by Cfg Module 
8586  *
8587  *     Processing Steps:
8588  *          binary search for given entry in table
8589  *          find the periodicty, offset for a given config index from the table
8590  *      - Return ROK
8591  *  @param[in]  RgSchPerTbl tbl
8592  *  @param[in]  uint16_t      cfgIdx
8593  *  @param[out] uint16_t     *peri 
8594  *  @param[out] uint16_t     *offset 
8595  *
8596  *  @return  S16
8597  *      -# ROK
8598  *
8599  */
8600 S16 rgSCHUtlGetCfgPerOff
8601 (
8602 RgSchPerTbl   tbl,
8603 uint16_t      cfgIdx, 
8604 uint16_t      *peri, 
8605 uint16_t      *offset
8606 )
8607 {
8608    uint8_t     mid;
8609    uint8_t     min = 0;
8610    uint8_t     max = 0;
8611    const RgSchUePCqiSrsSrCfgIdxTbl* table;
8612   
8613    /* Added the function instead of the MACRO to get the 
8614     * periodicity table */
8615    table = rgSCHCfgUtlGetPcqiSrsSrRiTbl ( tbl,&min,&max );
8616    do{
8617       mid = (min+max)/2;
8618       if (( cfgIdx >= table[mid].min) &&
8619             ( cfgIdx <= table[mid].max))
8620       {
8621          *peri = table[mid].peri;
8622          *offset = cfgIdx - table[mid].offset;
8623          break;
8624       } 
8625
8626       if ( cfgIdx > table[mid].min)
8627       {
8628          min = mid+1;
8629       }
8630       else
8631       {
8632          max = mid-1;
8633       }
8634
8635    }while( min <= max );
8636
8637    return ROK;
8638
8639
8640
8641 /***********************************************************
8642  *
8643  *     Func : rgSCHCfgUtlFetchAcqiBitSz
8644  *
8645  *
8646  *     Desc : Fetch the CQI/PMI bits for a UE based on the mode and store them 
8647  *                for decoding. 
8648  *
8649  *     Ret  : Void
8650  *            ROK - void
8651  *
8652  *     Notes:
8653  *
8654  *     File :
8655  *
8656  **********************************************************/
8657 static Void rgSCHCfgUtlFetchAcqiBitSz
8658 (
8659 RgSchUeACqiCb  *acqiCb,
8660 uint8_t        numTxAnt,
8661 uint8_t*       cqiPmiSzR1,
8662 uint8_t*       cqiPmiSzRn1
8663 )
8664 {
8665
8666    uint32_t    confRepMode;
8667
8668    confRepMode = acqiCb->aCqiCfg.aprdModeEnum;
8669    switch(confRepMode)
8670    {
8671       case RGR_APRD_CQI_MOD12:
8672          {
8673             if(numTxAnt == 2)
8674             {
8675                *cqiPmiSzR1 = 4 + 2*acqiCb->N;
8676                *cqiPmiSzRn1 = 8+ acqiCb->N;
8677             }
8678             else if(numTxAnt == 4)
8679             {
8680                *cqiPmiSzR1 = 4 + 4*acqiCb->N;
8681                *cqiPmiSzRn1 = 8 + 4*acqiCb->N;
8682             }
8683          }
8684          break;
8685
8686       case RGR_APRD_CQI_MOD20:
8687          {
8688             *cqiPmiSzR1 = 6 + acqiCb->L;
8689             *cqiPmiSzRn1 = 6  + acqiCb->L;
8690          }
8691          break;
8692
8693       case RGR_APRD_CQI_MOD22:
8694          {
8695             if(numTxAnt == 2)
8696             {
8697                *cqiPmiSzR1 = 10 + acqiCb->L;
8698                *cqiPmiSzRn1 = 14 + acqiCb->L;
8699             }
8700             else if(numTxAnt == 4)
8701             {
8702                *cqiPmiSzR1 = 14 + acqiCb->L;
8703                *cqiPmiSzRn1 = 20 + acqiCb->L;
8704             }
8705          }
8706          break;
8707
8708       case RGR_APRD_CQI_MOD30:
8709          {
8710             *cqiPmiSzR1 = 4 + 2*acqiCb->N;
8711             *cqiPmiSzRn1 = 4 + 2*acqiCb->N;
8712          }
8713          break;
8714
8715       case RGR_APRD_CQI_MOD31:
8716          {
8717             if(numTxAnt == 2)
8718             {
8719                *cqiPmiSzR1 = 6 + 2*acqiCb->N;
8720                *cqiPmiSzRn1 = 9 + 4*acqiCb->N;
8721             }
8722             else if(numTxAnt == 4)
8723             {
8724                *cqiPmiSzR1 = 8 + 2*acqiCb->N;
8725                *cqiPmiSzRn1 = 12 + 4*acqiCb->N;
8726             }
8727          }
8728          break;
8729       default:
8730          break;
8731    }
8732    return;
8733 }
8734 /* Added the function rgSCHCfgUtlGetPcqiCrsSrRiTbl to be used
8735  * instead of the MACRO RG_SCH_GET_PERIODICITY_TBL */
8736 /***********************************************************
8737  *
8738  *     Func : rgSCHCfgUtlGetPcqiCrsSrRiTbl
8739  *
8740  *
8741  *     Desc :  Get the Srs Cqi Crs Ri Table 
8742  *
8743  *     Ret  : Void
8744  *            ROK - void
8745  *
8746  *     Notes:
8747  *
8748  *     File :
8749  *
8750  **********************************************************/
8751
8752 static const RgSchUePCqiSrsSrCfgIdxTbl *  rgSCHCfgUtlGetPcqiSrsSrRiTbl
8753 (
8754 RgSchPerTbl tblType, 
8755 uint8_t* min, 
8756 uint8_t* max
8757 )
8758 {
8759     const RgSchUePCqiSrsSrCfgIdxTbl * table;
8760     
8761     switch (tblType)
8762     {
8763
8764         case RG_SCH_FDD_PCQI_TBL:
8765         {
8766             table = rgSchUePCqiCfgIdxFddTbl;
8767             * min = 0;
8768             * max=RG_SCH_CQIPMI_CFGIDX_MAX_FDD;
8769             break;
8770         }
8771         case RG_SCH_TDD_PCQI_TBL:
8772         {
8773             table = rgSchUeCqiPmiCfgIdxTddTbl;
8774             * min = 0;
8775             * max=RG_SCH_CQIPMI_CFGIDX_MAX_TDD;
8776             break;
8777         }
8778         case RG_SCH_RI_TBL:
8779         {
8780             table = rgSchUeRiCfgIdxTbl;
8781             * min = 0;
8782             * max=RG_SCH_RI_CFGIDX_MAX;
8783             break;
8784         }
8785         case RG_SCH_FDD_SRS_TBL:
8786         {
8787             table = rgSchUeSrsCfgIdxFddTbl;
8788             * min = 0;
8789             * max=RG_SCH_SRS_ISRS_INDX_MAX_FDD;
8790             break;
8791         }
8792         case RG_SCH_TDD_SRS_TBL:
8793         {
8794             table = rgSchUeSrsCfgIdxTddTbl;
8795             * min = 0;
8796             * max=RG_SCH_SRS_ISRS_INDX_MAX_TDD;
8797             break;
8798         }
8799         case RG_SCH_SR_TBL:
8800         {
8801             table = rgSchUeSrCfgIdxTbl;
8802             * min = 0;
8803             * max=RG_SCH_ISR_INDX_MAX;
8804             break;
8805         }
8806         default:
8807         {
8808             table = (const RgSchUePCqiSrsSrCfgIdxTbl *) 0;
8809             * min = 0;
8810             * max = 0;
8811             break;
8812         }
8813
8814     }
8815     return  ( table );
8816 }
8817 /* #endif */
8818 #endif /* TFU_UPGRADE */
8819
8820 /***********************************************************
8821  *
8822  *     Func : rgSCHCfgVldtDrxUeCfg
8823  *
8824  *
8825  *     Desc : Validates UE DRX Timers Configuration recieved from RRC.
8826  *
8827  *     Ret  : S16
8828  *            ROK - Success
8829  *            RFAILED - Failed
8830  *
8831  *     Notes:
8832  *
8833  *     File :
8834  *
8835  **********************************************************/
8836 static S16 rgSCHCfgVldtDrxUeCfg
8837 (
8838 RgSchCellCb       *cell,
8839 RgrUeDrxCfg       *ueDrxCfg
8840 )
8841 {
8842
8843    if (ueDrxCfg->isDrxEnabled == FALSE)
8844    {
8845       return ROK;
8846    }
8847
8848 #ifdef LTEMAC_R9
8849    if ( ueDrxCfg->cqiMask.pres )
8850    {
8851       if ( ueDrxCfg->cqiMask.val != RGR_DRX_SETUP )
8852       {
8853 #ifdef ALIGN_64BIT
8854          DU_LOG("\nERROR  -->  SCH : Invalid cqiMask configuration (%d)",
8855                   ueDrxCfg->cqiMask.val);
8856 #else
8857          DU_LOG("\nERROR  -->  SCH : Invalid cqiMask configuration(%ld)",
8858                   ueDrxCfg->cqiMask.val);
8859 #endif
8860          return RFAILED;
8861       }
8862    }
8863 #endif /*LTEMAC_R9*/
8864 #ifdef EMTC_ENABLE
8865    if(ueDrxCfg->isEmtcUe)
8866    {
8867       if(ueDrxCfg->drxOnDurTmrR13Pres)
8868       {
8869          if ( rgSCHEmtcCfgVldtDrxOnDurCfg(ueDrxCfg->drxOnDurTmr) != ROK )
8870          {
8871             DU_LOG("\nERROR  -->  SCH : Invalid onDurTimer configuration(%d)",
8872                ueDrxCfg->drxOnDurTmr);
8873             return RFAILED;
8874          }
8875        }
8876          else
8877          {
8878             if (rgSCHCfgVldtDrxOnDurCfg(ueDrxCfg->drxOnDurTmr) != ROK )
8879             {
8880                DU_LOG("\nERROR  -->  SCH : Invalid onDurTimer configuration(%d) for EMTC",
8881                ueDrxCfg->drxOnDurTmr);
8882                return RFAILED;
8883             }
8884
8885          }
8886     }
8887    else
8888 #endif
8889    {
8890       if ( rgSCHCfgVldtDrxOnDurCfg(ueDrxCfg->drxOnDurTmr) != ROK )
8891       {
8892          DU_LOG("\nERROR  -->  SCH : Invalid onDurTimer configuration(%d) for EMTC",
8893                ueDrxCfg->drxOnDurTmr);
8894          return RFAILED;
8895       }
8896    }
8897
8898    if ( rgSCHCfgVldtDrxInActvCfg(ueDrxCfg->drxInactvTmr) != ROK )
8899    {
8900       DU_LOG("\nERROR  -->  SCH : Invalid Inactivity configuration(%d)",
8901                ueDrxCfg->drxInactvTmr);
8902       return RFAILED;
8903    }
8904 #ifdef EMTC_ENABLE
8905    if(ueDrxCfg->isEmtcUe)
8906    {
8907       if(ueDrxCfg->drxRetxTmrR13Pres)
8908       {
8909          if ( rgSCHEmtcCfgVldtDrxReTxCfg(ueDrxCfg->drxRetxTmr) != ROK )
8910          {
8911             DU_LOG("\nERROR  -->  SCH : Invalid DrxReTX configuration(%d) for EMTC",
8912                ueDrxCfg->drxRetxTmr);
8913             return RFAILED;
8914          }
8915       }
8916          else
8917          {
8918             if (rgSCHCfgVldtDrxReTxCfg(ueDrxCfg->drxRetxTmr) != ROK )
8919             {
8920                DU_LOG("\nERROR  -->  SCH : Invalid DrxReTX configuration(%d)",
8921                ueDrxCfg->drxRetxTmr);
8922                return RFAILED;
8923             }
8924
8925          }
8926     }
8927    else
8928 #endif
8929    {
8930       if ( rgSCHCfgVldtDrxReTxCfg(ueDrxCfg->drxRetxTmr) != ROK )
8931       {
8932          DU_LOG("\nERROR  -->  SCH : Invalid DrxReTX configuration(%d)",
8933                ueDrxCfg->drxRetxTmr);
8934          return RFAILED;
8935       }
8936    }
8937 #ifdef EMTC_ENABLE
8938    if(ueDrxCfg->isEmtcUe)
8939    {
8940       if ( rgSCHEmtcCfgVldtDrxUlReTxCfg(ueDrxCfg->emtcDrxUlRetxTmr) != ROK )
8941       {
8942          DU_LOG("\nERROR  -->  SCH : Invalid DrxReTX configuration(%d) for EMTC",
8943                ueDrxCfg->drxRetxTmr);
8944          return RFAILED;
8945       }
8946
8947    }
8948 #endif
8949
8950    if ( rgSCHCfgVldtDrxLngCycCfg(ueDrxCfg->drxLongCycleOffst) != ROK )
8951    {
8952       DU_LOG("\nERROR  -->  SCH : Invalid LongCycle configuration");
8953       return RFAILED;
8954    }
8955
8956    if ( ueDrxCfg->drxLongCycleOffst.longDrxCycle < ueDrxCfg->drxOnDurTmr ) 
8957    {
8958       DU_LOG("\nERROR  -->  SCH : Invalid combination of Long DRX Cycle " 
8959               " and onDuration timer values");
8960       return RFAILED;
8961    }
8962
8963 #ifdef LTE_TDD
8964    if( rgSCHCfgVldtTddDrxCycCfg(cell, ueDrxCfg->drxLongCycleOffst.longDrxCycle, 
8965        ueDrxCfg->drxOnDurTmr, ueDrxCfg->drxLongCycleOffst.drxStartOffst) != ROK)
8966    {
8967       DU_LOG("\nERROR  -->  SCH : Invalid combination of Long DRX Cycle " 
8968               " and onDuration timer values");
8969       return RFAILED;
8970    }
8971 #endif
8972   
8973    if( TRUE == ueDrxCfg->drxShortDrx.pres )
8974    { 
8975       if ( ueDrxCfg->drxShortDrx.shortDrxCycle < ueDrxCfg->drxOnDurTmr )
8976       {
8977          DU_LOG("\nERROR  -->  SCH : Invalid combination of short DRX "
8978                  "Cycle and onDuration timer values");
8979          return RFAILED;
8980       }
8981
8982       if ( (ueDrxCfg->drxLongCycleOffst.longDrxCycle %
8983                ueDrxCfg->drxShortDrx.shortDrxCycle) != 0)
8984       {
8985          DU_LOG("\nERROR  -->  SCH : Long DRX cycle is not multiple of "
8986                  "short DRX cycle");
8987          return RFAILED;
8988       }
8989
8990       if ( rgSCHCfgVldtDrxShrtCycCfg(ueDrxCfg->drxShortDrx) != ROK )
8991       {
8992          DU_LOG("\nERROR  -->  SCH : Invalid Short Cycle configuration");
8993          return RFAILED;
8994       }
8995
8996 #ifdef LTE_TDD
8997       if( rgSCHCfgVldtTddDrxCycCfg(cell, ueDrxCfg->drxShortDrx.shortDrxCycle, 
8998              ueDrxCfg->drxOnDurTmr, 
8999              ueDrxCfg->drxLongCycleOffst.drxStartOffst % 
9000              ueDrxCfg->drxShortDrx.shortDrxCycle) != ROK)
9001       { 
9002          DU_LOG("\nERROR  -->  SCH : Invalid combination of Long DRX Cycle " 
9003                  " and onDuration timer values");
9004          return RFAILED;
9005       }
9006 #endif
9007    }
9008    
9009    return ROK;
9010 }/*rgSCHCfgVldtDrxUeCfg*/
9011       
9012 /***********************************************************
9013  *
9014  *     Func : rgSCHCfgVldtDrxOnDurCfg
9015  *
9016  *
9017  *     Desc : Validates UE DRX On Duration configuration 
9018  *            recieved from RRC.
9019  *
9020  *     Ret  : S16
9021  *            ROK - Success
9022  *            RFAILED - Failed
9023  *
9024  *     Notes:
9025  *
9026  *     File :
9027  *
9028  **********************************************************/
9029 static S16 rgSCHCfgVldtDrxOnDurCfg
9030 (
9031 uint8_t      onDurTmr 
9032 )
9033 {
9034
9035    switch ( onDurTmr )
9036    {
9037       case RGR_DRX_PRD_1PSF:
9038       case RGR_DRX_PRD_2PSF:
9039       case RGR_DRX_PRD_3PSF:
9040       case RGR_DRX_PRD_4PSF:
9041       case RGR_DRX_PRD_5PSF:
9042       case RGR_DRX_PRD_6PSF:
9043       case RGR_DRX_PRD_8PSF:
9044       case RGR_DRX_PRD_10PSF:
9045       case RGR_DRX_PRD_20PSF:
9046       case RGR_DRX_PRD_30PSF:
9047       case RGR_DRX_PRD_40PSF:
9048       case RGR_DRX_PRD_50PSF:
9049       case RGR_DRX_PRD_60PSF:
9050       case RGR_DRX_PRD_80PSF:
9051       case RGR_DRX_PRD_100PSF:
9052       case RGR_DRX_PRD_200PSF:
9053          break;
9054
9055       default:
9056          {
9057             return RFAILED;
9058          }
9059    }/*switch(onDurTmr)*/
9060
9061    return ROK;
9062 }/*rgSCHCfgVldtOnDurCfg*/
9063
9064 /***********************************************************
9065  *
9066  *     Func : rgSCHCfgVldtDrxInActvCfg
9067  *
9068  *
9069  *     Desc : Validates UE DRX InActivity configuration 
9070  *            recieved from RRC.
9071  *
9072  *     Ret  : S16
9073  *            ROK - Success
9074  *            RFAILED - Failed
9075  *
9076  *     Notes:
9077  *
9078  *     File :
9079  *
9080  **********************************************************/
9081 static S16 rgSCHCfgVldtDrxInActvCfg(uint16_t inActvTmr)
9082 {
9083    switch ( inActvTmr )
9084    {
9085       case RGR_DRX_PRD_1PSF:
9086       case RGR_DRX_PRD_2PSF:
9087       case RGR_DRX_PRD_3PSF:
9088       case RGR_DRX_PRD_4PSF:
9089       case RGR_DRX_PRD_5PSF:
9090       case RGR_DRX_PRD_6PSF:
9091       case RGR_DRX_PRD_8PSF:
9092       case RGR_DRX_PRD_10PSF:
9093       case RGR_DRX_PRD_20PSF:
9094       case RGR_DRX_PRD_30PSF:
9095       case RGR_DRX_PRD_40PSF:
9096       case RGR_DRX_PRD_50PSF:
9097       case RGR_DRX_PRD_60PSF:
9098       case RGR_DRX_PRD_80PSF:
9099       case RGR_DRX_PRD_100PSF:
9100       case RGR_DRX_PRD_200PSF:
9101       case RGR_DRX_PRD_300PSF:
9102       case RGR_DRX_PRD_500PSF:
9103       case RGR_DRX_PRD_750PSF:
9104       case RGR_DRX_PRD_1280PSF:
9105       case RGR_DRX_PRD_1920PSF:
9106       case RGR_DRX_PRD_2560PSF:
9107          break;
9108
9109       default:
9110          {
9111             return RFAILED;
9112          }
9113    }/*switch(InactvTmr)*/
9114
9115    return ROK;
9116 }/*rgSCHCfgVldtDrxInActvCfg*/
9117
9118 /***********************************************************
9119  *
9120  *     Func : rgSCHCfgVldtDrxReTxCfg
9121  *
9122  *
9123  *     Desc : Validates DRX ReTx timer  configuration 
9124  *            recieved from RRC.
9125  *
9126  *     Ret  : S16
9127  *            ROK - Success
9128  *            RFAILED - Failed
9129  *
9130  *     Notes:
9131  *
9132  *     File :
9133  *
9134  **********************************************************/
9135 static S16 rgSCHCfgVldtDrxReTxCfg(uint8_t reTxTmr)
9136 {
9137    switch ( reTxTmr )
9138    {
9139       case RGR_DRX_PRD_1PSF:
9140       case RGR_DRX_PRD_2PSF:
9141       case RGR_DRX_PRD_4PSF:
9142       case RGR_DRX_PRD_6PSF:
9143       case RGR_DRX_PRD_8PSF:
9144       case RGR_DRX_PRD_16PSF:
9145       case RGR_DRX_PRD_24PSF:
9146       case RGR_DRX_PRD_33PSF:
9147          break;
9148
9149       default:
9150          {
9151             return RFAILED;
9152          }
9153    }/*switch(drxRetxTmr)*/
9154
9155    return ROK;
9156 }/*rgSCHCfgVldtDrxReTxCfg*/
9157
9158 /***********************************************************
9159  *
9160  *     Func : rgSCHCfgVldtDrxShrtCycCfg
9161  *
9162  *
9163  *     Desc : Validates DRX Short Cycle timer  configuration 
9164  *            recieved from RRC.
9165  *
9166  *     Ret  : S16
9167  *            ROK - Success
9168  *
9169  *            RFAILED - Failed
9170  *
9171  *     Notes:
9172  *
9173  *     File :
9174  *
9175  **********************************************************/
9176 static S16 rgSCHCfgVldtDrxLngCycCfg(RgrDrxLongCycleOffst lngCycleOffst)
9177 {
9178    if ( rgSCHCfgVldtDrxLngCyclTmrs(lngCycleOffst.longDrxCycle) != ROK )
9179    {
9180       return RFAILED;
9181    }
9182
9183    if ( lngCycleOffst.drxStartOffst >= lngCycleOffst.longDrxCycle ) 
9184    {
9185       return RFAILED;  
9186    }
9187
9188    return ROK;
9189 }/*rgSCHCfgVldtDrxLngCycCfg*/
9190
9191 /***********************************************************
9192  *
9193  *     Func : rgSCHCfgVldtDrxLngCyclTmrs
9194  *
9195  *
9196  *     Desc : Validates DRX Long Cycle timer values 
9197  *            recieved from RRC.
9198  *
9199  *     Ret  : S16
9200  *            ROK - Success
9201  *
9202  *            RFAILED - Failed
9203  *
9204  *     Notes:
9205  *
9206  *     File :
9207  *
9208  **********************************************************/
9209 static S16 rgSCHCfgVldtDrxLngCyclTmrs(uint16_t val)
9210 {
9211
9212    switch ( val )
9213    {
9214       case RGR_DRX_PRD_10SF:
9215       case RGR_DRX_PRD_20SF:
9216       case RGR_DRX_PRD_32SF:
9217       case RGR_DRX_PRD_40SF:
9218       case RGR_DRX_PRD_64SF:
9219       case RGR_DRX_PRD_80SF:
9220       case RGR_DRX_PRD_128SF:
9221       case RGR_DRX_PRD_160SF:
9222       case RGR_DRX_PRD_256SF:
9223       case RGR_DRX_PRD_320SF:
9224       case RGR_DRX_PRD_512SF:
9225       case RGR_DRX_PRD_640SF:
9226       case RGR_DRX_PRD_1024SF:
9227       case RGR_DRX_PRD_1280SF:
9228       case RGR_DRX_PRD_2048SF:
9229       case RGR_DRX_PRD_2560SF:
9230          break;
9231
9232       default:
9233          {
9234             return RFAILED;
9235          }
9236    }/*switch(longDrxCycle)*/
9237
9238    return ROK;
9239 }/*rgSCHCfgVldtDrxLngCyclTmrs*/
9240
9241 /***********************************************************
9242  *
9243  *     Func : rgSCHCfgVldtDrxShrtCycCfg
9244  *
9245  *
9246  *     Desc : Validates DRX Short Cycle timer  configuration 
9247  *            recieved from RRC.
9248  *
9249  *     Ret  : S16
9250  *            ROK - Success
9251  *
9252  *            RFAILED - Failed
9253  *
9254  *     Notes:
9255  *
9256  *     File :
9257  *
9258  **********************************************************/
9259 static S16 rgSCHCfgVldtDrxShrtCycCfg(RgrDrxShortDrx shrtCycCfg )
9260 {
9261    switch(shrtCycCfg.shortDrxCycle)
9262    {
9263       case RGR_DRX_PRD_2SF:
9264       case RGR_DRX_PRD_5SF:
9265       case RGR_DRX_PRD_8SF:
9266       case RGR_DRX_PRD_10SF:
9267       case RGR_DRX_PRD_16SF:
9268       case RGR_DRX_PRD_20SF:
9269       case RGR_DRX_PRD_32SF:
9270       case RGR_DRX_PRD_40SF:
9271       case RGR_DRX_PRD_64SF:
9272       case RGR_DRX_PRD_80SF:
9273       case RGR_DRX_PRD_128SF:
9274       case RGR_DRX_PRD_160SF:
9275       case RGR_DRX_PRD_256SF:
9276       case RGR_DRX_PRD_320SF:
9277       case RGR_DRX_PRD_640SF:
9278          break;
9279
9280       default:
9281          {
9282             return RFAILED;
9283          }
9284
9285    }/*switch(shortDrxCycle)*/
9286
9287    if ( (shrtCycCfg.drxShortCycleTmr < RGR_DRX_SHRTCYCLE_MIN) ||
9288          (shrtCycCfg.drxShortCycleTmr > RGR_DRX_SHRTCYCLE_MAX)
9289       )
9290    {
9291       return RFAILED;
9292    }
9293
9294    return ROK;
9295 }
9296
9297 /**
9298  * @brief Handler for TA related UE Reconfiguration.
9299  *
9300  * @details
9301  *
9302  *     Function : rgSCHCfgUeTaRecfg
9303  *     
9304  *     This function shall fetch the TA timer related information into the
9305  *     respective ueCb from the UE configuration as provided by the 
9306  *     upper layers. 
9307  *           
9308  *  @param[in]  RgSchCellCb   *cell 
9309  *  @param[in]  RgSchUeCb     *ueCb 
9310  *  @param[in]  RgrUeCfg      *ueCfg 
9311  *  @param[out] RgSchErrInfo  *errInfo 
9312  *  @return     S16
9313  *      -# ROK 
9314  *      -# RFAILED 
9315  **/
9316 static Void rgSCHCfgUeTaRecfg
9317 (
9318 RgSchCellCb       *cell,
9319 RgSchUeCb         *ueCb,
9320 RgrUeRecfg        *ueCfg,
9321 RgSchErrInfo      *err
9322 )
9323 {
9324    UNUSED(err);
9325
9326    /* Update the TA related information */
9327    
9328    if (ueCfg->ueTaTmrRecfg.pres)
9329    {
9330       /* Configuring taTmr with 30 deficit, to enable eNodeB sending
9331        * TA command before the expiry of TA at UE. Also considering for 
9332        * possible retx for this TA command */
9333       /* [ccpu00121813]-ADD-Added chk if tatmr val > 30 */
9334       if(ueCfg->ueTaTmrRecfg.taTmr > 30)
9335       {
9336          ueCb->dl.taCb.cfgTaTmr = ueCfg->ueTaTmrRecfg.taTmr - 30;
9337       }
9338        /* If TA Timer is running. Stop it and then start it*/
9339       if (ueCb->taTmr.tmrEvnt != TMR_NONE)
9340       {
9341          rgSCHTmrStopTmr(cell, ueCb->taTmr.tmrEvnt, ueCb);
9342          rgSCHTmrStartTmr(cell, ueCb, RG_SCH_TMR_TA, ueCb->dl.taCb.cfgTaTmr);
9343       }
9344       else
9345       {
9346          rgSCHTmrStartTmr(cell, ueCb, RG_SCH_TMR_TA, ueCb->dl.taCb.cfgTaTmr);
9347       }
9348    }
9349    return;
9350 }  /* rgSCHCfgUeTaRecfg */
9351
9352 /* ccpu00117452 - MOD - Changed macro name from
9353    RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */
9354 #if ((defined (RGR_CQI_REPT)) && (defined (RGR_V2)))
9355 /***********************************************************
9356  *
9357  *     Func : rgSCHCfgUeCqiReptReCfg
9358  *
9359  *
9360  *     Desc : Reconfiguration of PUSH N CQI Reporting 
9361  *
9362  *     Ret  : RFAILED in case of failure
9363  *            ROK if success
9364  *
9365  *     Notes:
9366  *
9367  *     File :
9368  *
9369  **********************************************************/
9370 static S16 rgSCHCfgUeCqiReptReCfg
9371 (
9372 RgSchCellCb    *cell,
9373 RgSchUeCb      *ue,
9374 RgrUeRecfg     *ueRecfg
9375 )
9376 {
9377    S16 retVal;
9378
9379    /* Check has it been disabled */
9380    if(ueRecfg->ueCqiReptCfg.numColltdCqiRept)
9381    {
9382     /* Check if we need to send CQI reports collagted so far and send if so */
9383       if(ue->schCqiInfo.cqiCount >=
9384               ueRecfg->ueCqiReptCfg.numColltdCqiRept)
9385       {
9386          RgrStaIndInfo *staInfo;
9387       /* if yes, Send StaInd to RRM */
9388          retVal = rgSCHUtlAllocSBuf (cell->instIdx,(Data**)&staInfo,
9389                   sizeof(RgrStaIndInfo));
9390          if(retVal != ROK)
9391          {
9392             DU_LOG("\nERROR  -->  SCH : Could not allocate memory for sending StaInd OLD CRNTI:%d",ueRecfg->oldCrnti);
9393             return (retVal);
9394          }
9395
9396       /* Fill StaInd for sending collated N CQI rpeort                        */
9397          rgSCHUtlFillSndStaInd(cell, ue, staInfo,
9398                ueRecfg->ueCqiReptCfg.numColltdCqiRept);
9399       }
9400    }
9401    else
9402    {
9403       ue->schCqiInfo.cqiCount = 0;
9404    }
9405
9406    ue->cqiReptCfgInfo.numColltdCqiRept =
9407       ueRecfg->ueCqiReptCfg.numColltdCqiRept;
9408    return ROK;
9409 } /* End of rgSCHCfgUeCqiReptReCfg */
9410 #endif /* End of RGR_CQI_REPT */
9411 /*This function Added Ue in ongoing L2 Meas*/
9412 /*LTE_L2_MEAS_PHASE2*/
9413 #ifdef LTE_L2_MEAS
9414 static S16 rgSchAddToL2Meas(RgSchCellCb *cellCb,RgSchDlLcCb *dlLc)
9415 {
9416    CmLList             *lnk;
9417    uint16_t       idx;
9418    RgSchL2MeasCb       *measCb = NULLP;
9419    lnk = cellCb->l2mList.first;
9420
9421    while(lnk != NULLP)
9422    {
9423       /* Get the MeasCb : RgSchL2MeasCb */
9424       measCb = (RgSchL2MeasCb *)lnk->node;
9425       if (measCb->measReq.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_DL)
9426       {
9427          for(idx = 0;idx < measCb->measReq.avgPrbQciDl.numQci;idx++)
9428          {
9429             if(measCb->measReq.avgPrbQciDl.qci[idx] == dlLc->qciCb->qci)
9430             {
9431                break; /*exit from for loop*/
9432             } 
9433          }      
9434          if(idx  == measCb->measReq.avgPrbQciDl.numQci)
9435          {
9436             measCb->measReq.avgPrbQciDl.qci[measCb->measReq.avgPrbQciDl.numQci++] = dlLc->qciCb->qci;
9437          }              
9438       }
9439       lnk = lnk->next;
9440    }/*End of while loop*/
9441
9442    return ROK;
9443 }
9444 #endif
9445 #ifdef LTE_ADV
9446 /**
9447  * @brief UE SCell Buffer Free 
9448  *
9449  * @details
9450  *
9451  *     Function : rgSCHSCellFreeBuf
9452  *
9453  *     This functions will free allocated memory 
9454  *     for UE secondart cellCB
9455  *     
9456  *
9457  *  @param[in]  Inst         inst 
9458  *  @param[in]  RgSchUeCb    *ue
9459  *  @param[int] RgrUeRecfg   *ueRecfg
9460  *  @param[out] uint8_t           idx 
9461  *  @return  VOID
9462  **/
9463 Void rgSCHSCellFreeBuf
9464 (
9465 Inst         inst,         
9466 RgSchUeCb    *ue,
9467 RgrUeRecfg   *ueRecfg,
9468 uint8_t      idx
9469 )
9470 {
9471    RgSchUeCellInfo *sCellInfo = NULLP;
9472    RgrUeSecCellCfg *sCellInfoRecfg = NULLP;
9473    
9474
9475    for(uint8_t i = 0; i <= idx; i++)
9476    {
9477       sCellInfoRecfg = &ueRecfg->ueSCellCfgInfo.ueSCellDedCfg[i]; 
9478       sCellInfo = ue->cellInfo[(sCellInfoRecfg->sCellIdx)];
9479       
9480       if (NULLP != sCellInfo)
9481       {
9482          rgSCHUtlFreeSBuf(inst, (Data**)&(sCellInfo),
9483                sizeof(RgSchUeCellInfo));
9484          ue->cellInfo[(sCellInfoRecfg->sCellIdx)] = NULLP;
9485
9486       } 
9487    }
9488    return;
9489 }
9490 #endif
9491 /**********************************************************************
9492  
9493          End of file
9494 **********************************************************************/