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