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