Merge "Part -5 Separation of log [JIRA-ID ODUHIGH-275]"
[o-du/l2.git] / src / 5gnrmac / rg_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 fucntions
26  
27      File:     rg_cfg.c
28  
29 **********************************************************************/
30
31 /** @file rg_cfg.c
32 @brief This module handles the configuration of MAC by RRC and RRM.
33 */
34
35
36 /* header include files -- defines (.h) */
37 #include "common_def.h"
38 #include "lrg.h"           /* Layer manager interface includes*/
39 #include "crg.h"           /* CRG interface includes*/
40 #include "rgu.h"           /* RGU interface includes*/
41 #include "tfu.h"           /* TFU interface includes */
42 #include "rg_sch_inf.h"    /* SCH interface includes */
43 #include "rg_prg.h"       /* PRG (MAC-MAC) interface includes*/
44 #include "rg_env.h"       /* MAC environmental includes*/
45 #include "rg.h"           /* MAC includes*/
46 #include "rg_err.h"       /* MAC error includes*/
47
48 /* header/extern include files (.x) */
49 #include "rgu.x"           /* RGU types */
50 #include "tfu.x"           /* RGU types */
51 #include "lrg.x"           /* layer management typedefs for MAC */
52 #include "crg.x"           /* CRG interface includes */
53 #include "rg_sch_inf.x"    /* SCH interface typedefs */
54 #include "rg_prg.x"        /* PRG (MAC-MAC) Interface typedefs */
55 #include "du_app_mac_inf.h"
56 #include "rg.x"            /* typedefs for MAC */
57 #ifdef LTE_ADV
58 #include "rg_pom_scell.x"
59 #endif
60 /* LTE-MAC Control Block Structure */
61 RgCb rgCb[RG_MAX_INST];
62
63 /* local defines */
64 static S16 rgCFGVldtCrgDedLcCfg ARGS((Inst inst,CrgLchCfg *lcCfg, RgCellCb **cell,
65          RgUeCb **ue, RgErrInfo *errInfo));
66 static S16 rgCFGVldtCrgCmnLcCfg ARGS((Inst inst,CrgLchCfg *lcCfg, RgCellCb **cell,
67          RgErrInfo *errInfo));
68 static S16 rgCFGCrgDedLcCfg ARGS((RgCellCb *cell, RgUeCb *ue,
69          CrgLchCfg *lcCfg, RgErrInfo *errInfo));
70 static S16 rgCFGCrgCmnLcCfg ARGS((Inst inst,RgCellCb *cell, CrgLchCfg *lcCfg,
71          RgErrInfo *errInfo));
72
73 static Void rgCFGFreeCmnLcLst ARGS((RgCellCb *cell));
74 static Void rgCFGFreeUeLst ARGS((RgCellCb *cell));
75 /* Added support for SPS*/
76 #ifdef LTEMAC_SPS
77 static Void rgCFGFreeSpsUeLst ARGS((RgCellCb *cell));
78 #endif /* LTEMAC_SPS */
79
80
81 /* local typedefs */
82  
83 /* local externs */
84  
85 /* forward references */
86
87
88
89
90 /**
91  * @brief Validates the cell configuration request from RRC to MAC.
92  *
93  * @details
94  *
95  *     Function : rgCFGVldtCrgCellCfg
96  *
97  *     Processing Steps:
98  *      - Validate the cell configuration request from RRC to MAC at CFG:
99  *        validate the value range for the configured values.
100  *      - If validated successfully,
101  *        - Return ROK.
102  *      - Else 
103  *        - Return RFAILED.
104  *
105  *  @param[in]  Inst        inst
106  *  @param[in]  CrgCellCfg  *cellCfg
107  *  @param[out] RgErrInfo   *errInfo
108  *  @return  S16
109  *      -# ROK
110  *      -# RFAILED
111  **/
112 S16 rgCFGVldtCrgCellCfg
113 (
114 Inst        inst,
115 CrgCellCfg  *cellCfg,
116 RgErrInfo   *errInfo
117 )
118 {
119    errInfo->errCause = RGERR_CFG_INVALID_CRG_CELL_CFG;
120    if ((rgCb[inst].cell != NULLP)
121          || rgCb[inst].inactiveCell != NULLP)
122    {
123       DU_LOG("\nERROR  -->  MAC : Cell already exists");
124       return RFAILED;
125    }
126    if ((cellCfg->bwCfg.dlTotalBw < RG_MIN_DL_BW
127             || cellCfg->bwCfg.dlTotalBw > RG_MAX_DL_BW)
128          || (cellCfg->bwCfg.ulTotalBw < RG_MIN_UL_BW
129             || cellCfg->bwCfg.ulTotalBw > RG_MAX_UL_BW))
130    {
131       DU_LOG("\nERROR  -->  MAC : Invalid Bandwidth configuration: ul %d dl %d",
132             cellCfg->bwCfg.ulTotalBw, cellCfg->bwCfg.dlTotalBw);
133       return RFAILED;
134    }
135    if (cellCfg->rachCfg.maxMsg3Tx < RG_MIN_HQ_TX)
136    {
137       DU_LOG("\nERROR  -->  MAC : Invalid RACH configuration: maxMsg3Tx %d",cellCfg->rachCfg.maxMsg3Tx);
138       return RFAILED;
139    }
140 #ifdef TENB_MULT_CELL_SUPPRT
141    if((cellCfg->rguDlSapId > rgCb[inst].numRguSaps) ||
142       (cellCfg->rguUlSapId > rgCb[inst].numRguSaps))
143    {
144       DU_LOG("\nERROR  -->  MAC : Invald Sap Id: DL %d UL %d for CellId %d failed\n",
145                cellCfg->rguDlSapId,
146                cellCfg->rguUlSapId,
147                cellCfg->cellId);
148       return RFAILED;
149    }
150 #endif
151    errInfo->errCause = RGERR_NONE;
152    return ROK;
153 }  /* rgCFGVldtCrgCellCfg */
154
155
156 /**
157  * @brief Validates the UE configuration request from RRC to MAC.
158  *
159  * @details
160  *
161  *     Function : rgCFGVldtCrgUeCfg
162  *
163  *     Processing Steps:
164  *      - Validate the UE configuration request from RRC to MAC at CFG:
165  *        validate the value range for the configured values.
166  *      - If validated successfully,
167  *        - Return ROK and pointer to the cell of UE.
168  *      - Else 
169  *        - Return RFAILED.
170  *
171  *  @param[in]  Inst        inst
172  *  @param[in]  CrgUeCfg  *ueCfg
173  *  @param[out] RgCellCb  **cell
174  *  @param[out] RgErrInfo *errInfo
175  *  @return  S16
176  *      -# ROK
177  *      -# RFAILED
178  **/
179 S16 rgCFGVldtCrgUeCfg
180 (
181 Inst      inst,
182 CrgUeCfg  *ueCfg,
183 RgCellCb  **cell,
184 RgErrInfo *errInfo
185 )
186 {
187    errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_CFG;
188    if ((ueCfg->txMode.pres == PRSNT_NODEF) && 
189        (ueCfg->txMode.tm == CRG_UE_TM_5))
190    {
191       DU_LOG("\nERROR  -->  MAC : Transmission Mode=%d not supported",
192             ueCfg->txMode.tm);
193       return RFAILED;
194    }
195    
196    /* Fetch the Active cell */
197    if(((*cell = rgCb[inst].cell) == NULLP) ||
198        ((*cell)->cellId != ueCfg->cellId))
199    {
200       DU_LOG("\nERROR  -->  MAC : Active Cell does not exist for cellId%d",
201             ueCfg->cellId);
202       return RFAILED;
203    }
204    /* Check if UE already configured */
205    if (rgDBMGetUeCb(*cell, ueCfg->crnti) != NULLP)
206    {
207       DU_LOG("\nERROR  -->  MAC : UE already exists");
208       return RFAILED;
209    }
210
211    if (ueCfg->ueUlHqCfg.maxUlHqTx < RG_MIN_HQ_TX)
212    {
213       DU_LOG("\nERROR  -->  MAC : Invalid Uplink HARQ config %d ",
214             ueCfg->ueUlHqCfg.maxUlHqTx);
215       return RFAILED;
216    }
217 #ifdef TENB_MULT_CELL_SUPPRT
218    if((ueCfg->rguDlSapId > rgCb[inst].numRguSaps) ||
219       (ueCfg->rguUlSapId > rgCb[inst].numRguSaps))
220    {
221       DU_LOG("\nERROR  -->  MAC : Invald Sap Id: DL %d UL %d for ueId %d failed\n",
222                ueCfg->rguDlSapId,
223                ueCfg->rguUlSapId,
224                ueCfg->crnti);
225       return RFAILED;
226    }
227 #endif
228
229    errInfo->errCause = RGERR_NONE;
230    return ROK;
231 }  /* rgCFGVldtCrgUeCfg */
232
233
234 /**
235  * @brief Validates the logical channel configuration request from RRC to MAC.
236  *
237  * @details
238  *
239  *     Function : rgCFGVldtCrgLcCfg
240  *
241  *     Processing Steps:
242  *      - Validate the logical channel configuration request from RRC to
243  *        MAC at CFG: validate if configured values are within the range.
244  *      - If validated successfully,
245  *        - Return ROK and pointer to the cell for common channels. Return
246  *          pointer to cell and UE for dedicated logical channels.
247  *      - Else 
248  *        - Return RFAILED.
249  *
250  *  @param[in]  CrgLchCfg  *lcCfg
251  *  @param[in]  Inst        inst
252  *  @param[out] RgCellCb   **cell
253  *  @param[out] RgUeCb     **ue
254  *  @param[out] RgErrInfo  *errInfo
255  *  @return  S16
256  *      -# ROK
257  *      -# RFAILED
258  **/
259 S16 rgCFGVldtCrgLcCfg
260 (
261 Inst       inst, 
262 CrgLchCfg  *lcCfg,
263 RgCellCb   **cell,
264 RgUeCb     **ue,
265 RgErrInfo  *errInfo
266 )
267 {
268
269    if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
270    {
271       /* Dedicated logical channels */
272       if ((rgCFGVldtCrgDedLcCfg(inst,lcCfg, cell, ue, errInfo)) != ROK)
273       {
274          DU_LOG("\nERROR  -->  MAC : Validation for dedicated LC failed");
275          return RFAILED;
276       }
277    }
278    else if (lcCfg->lcType == CM_LTE_LCH_BCCH
279          || lcCfg->lcType == CM_LTE_LCH_PCCH
280          || lcCfg->lcType == CM_LTE_LCH_CCCH)
281    {
282       if ((rgCFGVldtCrgCmnLcCfg(inst,lcCfg, cell, errInfo)) != ROK)
283       {
284          DU_LOG("\nERROR  -->  MAC : Validation for common logical channels failed");
285          return RFAILED;
286       }
287    }
288    else
289    {
290       DU_LOG("\nERROR  -->  MAC : Invalid logical channel type %d",
291                 lcCfg->lcType);
292       return RFAILED;
293    }
294 #ifdef LTE_L2_MEAS
295    if ( lcCfg->qci <  RG_QCI_MIN ||
296         lcCfg->qci >  RG_QCI_MAX
297       )
298    {
299       DU_LOG("\nERROR  -->  MAC : Invalid qci %x",lcCfg->qci);
300       return RFAILED;
301    }
302    /*validate qci */
303 #endif /*LTE_L2_MEAS */
304
305    errInfo->errCause = RGERR_NONE;
306    return ROK;
307 }  /* rgCFGVldtCrgLcCfg */
308
309
310 /**
311  * @brief Validates the cell re-configuration request from RRC to MAC.
312  *
313  * @details
314  *
315  *     Function : rgCFGVldtCrgCellRecfg
316  *
317  *     Processing Steps:
318  *      - Retrieve the cell control block.
319  *      - If successful,
320  *        - Validate the range of re-configured values recieved in
321  *          re-configuration request.
322  *        - If validated successfully,
323  *          - Return ROK and pointer to the cell.
324  *        - Else 
325  *          - Return RFAILED.
326  *      - Else return RFAILED.
327  *
328  *  @param[in]  Inst        inst
329  *  @param[in]  CrgCellRecfg  *cellRecfg
330  *  @param[out] RgCellCb      **cell
331  *  @param[out] RgErrInfo     *errInfo
332  *  @return  S16
333  *      -# ROK
334  *      -# RFAILED
335  **/
336 S16 rgCFGVldtCrgCellRecfg
337 (
338 Inst          inst,
339 CrgCellRecfg  *cellRecfg,
340 RgCellCb      **cell,
341 RgErrInfo     *errInfo
342 )
343 {
344    errInfo->errCause = RGERR_CFG_INVALID_CRG_CELL_RECFG;
345    
346    if (((*cell = rgCb[inst].cell) == NULLP)
347          && ((*cell = rgCb[inst].inactiveCell) == NULLP))
348    {
349       DU_LOG("\nERROR  -->  MAC : Cell does not exist");
350       return RFAILED;
351    }
352
353    if((*cell)->cellId != cellRecfg->cellId)
354    {
355       DU_LOG("\nERROR  -->  MAC : Cell does not exist %d\n",cellRecfg->cellId);
356       return RFAILED;
357    }
358    if (cellRecfg->rachRecfg.maxMsg3Tx < RG_MIN_HQ_TX)
359    {
360       DU_LOG("\nERROR  -->  MAC : Invalid RACH configuration: maxMsg3Tx %d",cellRecfg->rachRecfg.maxMsg3Tx);
361       return RFAILED;
362    }
363    errInfo->errCause = RGERR_NONE;
364    return ROK;
365 }  /* rgCFGVldtCrgCellRecfg */
366
367
368 /**
369  * @brief Validates the UE re-configuration request from RRC to MAC.
370  *
371  * @details
372  *
373  *     Function : rgCFGVldtCrgUeRecfg
374  *
375  *     Processing Steps:
376  *      - Retrieve the UE control block.
377  *      - If successful,
378  *        - Validate the range of re-configured values recieved in
379  *          re-configuration request.
380  *        - If validated successfully,
381  *          - Return ROK and pointer to the cell and ue.
382  *        - Else 
383  *          - Return RFAILED.
384  *      - Else return RFAILED.
385  *
386  *  @param[in]  Inst        inst
387  *  @param[in]  CrgUeRecfg *ueRecfg
388  *  @param[out] RgCellCb   **cell
389  *  @param[out] RgUeCb     **ue
390  *  @param[out] RgErrInfo *errInfo
391  *  @return  S16
392  *      -# ROK
393  *      -# RFAILED
394  **/
395 S16 rgCFGVldtCrgUeRecfg
396 (
397 Inst        inst,
398 CrgUeRecfg  *ueRecfg,
399 RgCellCb    **cell,
400 RgUeCb      **ue,
401 RgErrInfo   *errInfo
402 )
403 {
404    errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_RECFG;
405    
406    if ((ueRecfg->txMode.pres == PRSNT_NODEF) && 
407        (ueRecfg->txMode.tm == CRG_UE_TM_5))
408    {
409       DU_LOG("\nERROR  -->  MAC : Transmission Mode=%d not supported",
410                 ueRecfg->txMode.tm);
411       return RFAILED;
412    }
413
414     /* Fetch the Active cell */
415    if (((*cell = rgCb[inst].cell) == NULLP) 
416         || ((*cell)->cellId != ueRecfg->cellId))
417    {
418       DU_LOG("\nERROR  -->  MAC : Active Cell does not exist\n");
419       return RFAILED;
420    }
421  
422    /* Fix : syed UE ID change at MAC will now be controlled
423     * by SCH. */
424    if ((*ue = rgDBMGetUeCb(*cell, ueRecfg->oldCrnti)) == NULLP)
425    {
426       DU_LOG("\nERROR  -->  MAC : [%d]Old UE does not exist", ueRecfg->oldCrnti);
427       return RFAILED;
428    }
429    if (ueRecfg->ueUlHqRecfg.maxUlHqTx < RG_MIN_HQ_TX)
430    {
431       DU_LOG("\nERROR  -->  MAC : Invalid Uplink HARQ config for UE %d",
432             ueRecfg->ueUlHqRecfg.maxUlHqTx);
433       return RFAILED;
434    }
435    errInfo->errCause = RGERR_NONE;
436    return ROK;
437 }  /* rgCFGVldtCrgUeRecfg */
438
439
440 /**
441  * @brief Validates the logical channel re-configuration request from
442  * RRC to MAC.
443  *
444  * @details
445  *
446  *     Function : rgCFGVldtCrgLcRecfg
447  *
448  *     Processing Steps:
449  *      - Retrieve the uplink and downlink logical channel control block.
450  *      - If successful,
451  *        - Validate the range of re-configured values recieved in
452  *          re-configuration request.
453  *        - If validated successfully,
454  *          - Return ROK and pointer to the cell, UE and logical channel.
455  *        - Else 
456  *          - Return RFAILED.
457  *      - Else return RFAILED.
458  *
459  *  @param[in]  Inst        inst
460  *  @param[in]  CrgLchRecfg  *lcRecfg
461  *  @param[out] RgCellCb     **cell
462  *  @param[out] RgUeCb       **ue
463  *  @param[out] RgUlLcCb     **ulLc
464  *  @param[out] RgDlLcCb     **dlLc
465  *  @param[out] RgErrInfo    *errInfo
466  *  @return  S16
467  *      -# ROK
468  *      -# RFAILED
469  **/
470 S16 rgCFGVldtCrgLcRecfg
471 (
472 Inst        inst,
473 CrgLchRecfg *lcRecfg,
474 RgCellCb    **cell,
475 RgUeCb      **ue,
476 RgUlLcCb    **ulLc,
477 RgErrInfo   *errInfo
478 )
479 {
480    errInfo->errCause = RGERR_CFG_INVALID_CRG_LC_RECFG;
481
482    /* Fetch the cell */
483    if ((((*cell = rgCb[inst].cell)) == NULLP)
484       || ((*cell)->cellId != lcRecfg->cellId))
485    {
486       DU_LOG("\nERROR  -->  MAC : Active Cell %u does not exist for UE %u", lcRecfg->cellId, lcRecfg->crnti);
487       return RFAILED;
488    }
489    /* Fetch the Ue for dedicated channels */
490    if ((*ue = rgDBMGetUeCb(*cell, lcRecfg->crnti)) == NULLP)
491    {
492       DU_LOG("\nERROR  -->  MAC : UE does not exist for dedicated logical channel");
493       return RFAILED;
494    }
495
496    if ((*ulLc = rgDBMGetUlDedLcCb((*ue), lcRecfg->lcId)) == NULLP)
497    {
498       DU_LOG("\nERROR  -->  MAC : Dedicated UL LC does not exist %d",lcRecfg->lcId);
499       return RFAILED;
500    }
501
502    if (lcRecfg->ulRecfg.lcgId > (RG_MAX_LCG_PER_UE - 1))
503    {
504       DU_LOG("\nERROR  -->  MAC : Invalid lcgId for uplink logical channel lcg %d lc %d",
505                 lcRecfg->ulRecfg.lcgId, lcRecfg->lcId);
506       return RFAILED;
507    }
508
509    errInfo->errCause = RGERR_NONE;
510    return ROK;
511 }  /* rgCFGVldtCrgLcRecfg */
512
513 /* Start: LTEMAC_2.1_DEV_CFG */
514 /**
515  * @brief Validates the UE Reset request from RRC to MAC.
516  *
517  * @details
518  *
519  *     Function : rgCFGVldtCrgUeReset
520  *
521  *     Processing Steps:
522  *      - Retrieve the CELL control block.
523  *      - If Failue,
524  *          - Return RFAILED.
525  *      - Retrieve the UE control block.
526  *      - If Failue,
527  *          - Return RFAILED.
528  *
529  *  @param[in]  Inst        inst
530  *  @param[in]  CrgRst     *reset,
531  *  @param[out] RgCellCb   **cell
532  *  @param[out] RgUeCb     **ue
533  *  @param[out] RgErrInfo *errInfo
534  *  @return  S16
535  *      -# ROK
536  *      -# RFAILED
537  **/
538 S16 rgCFGVldtCrgUeReset
539 (
540 Inst        inst,
541 CrgRst      *reset,
542 RgCellCb    **cell,
543 RgUeCb      **ue,
544 RgErrInfo   *errInfo
545 )
546 {
547    errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_RESET;
548    
549    /* Fetch the Active cell */
550    if (((*cell = rgCb[inst].cell) == NULLP)
551       || ((*cell)->cellId != reset->cellId))
552    {
553       DU_LOG("\nERROR  -->  MAC : Active Cell does not exist %d",reset->cellId);
554       return RFAILED;
555    }
556
557    /* Fetch the Ue */
558    if ((*ue = rgDBMGetUeCb(*cell, reset->crnti)) == NULLP)
559    {
560       DU_LOG("\nERROR  -->  MAC : UE does not exist");
561       return RFAILED;
562    }
563
564    errInfo->errCause = RGERR_NONE;
565    return ROK;
566 }  /* rgCFGVldtCrgUeReset*/
567 /* End: LTEMAC_2.1_DEV_CFG */
568
569
570
571 /**
572  * @brief Handler for the cell configuration request from RRC to MAC.
573  *
574  * @details
575  *
576  *     Function : rgCFGCrgCellCfg
577  *
578  *     Processing Steps:
579  *      - Allocate and create cell control block.
580  *      - Update cell control block with the values recieved in the
581  *        configuration.
582  *      - Add the control block to hash list of cells.
583  *      - Update the statistics.
584  *      - If successful, return ROK else return RFAILED.
585  *
586  *  @param[in]  Inst        inst
587  *  @param[in]  CrgCellCfg  *cellCfg
588  *  @param[out] RgErrInfo   *errInfo
589  *  @return  S16
590  *      -# ROK
591  *      -# RFAILED
592  **/
593 S16 rgCFGCrgCellCfg
594 (
595 Inst        inst,
596 CrgCellCfg  *cellCfg,
597 RgErrInfo   *errInfo
598 )
599 {
600    S16        ret;
601    RgCellCb   *cell = NULLP;
602    uint8_t    idx;
603    SuId       rguUlSapId = 0;
604    SuId       rguDlSapId = 0;
605    /* RLC SAP to allocate flowCntrlInd buffer*/
606    Pst        *pst ;
607
608    errInfo->errCause = RGERR_CFG_CRG_CELL_CFG;
609    
610    /* Allocate the cell control block */
611    if((ret = rgAllocSBuf(inst,(Data**)&cell, sizeof(RgCellCb))) != ROK)
612    {
613       DU_LOG("\nERROR  -->  MAC : Memory allocation FAILED for cell");
614       return RFAILED;
615    }
616    if (cell == NULLP)
617    {
618       DU_LOG("\nERROR  -->  MAC : Memory allocation FAILED for cell");
619       return RFAILED;
620    }
621
622    /* Initialize the cell */
623    cell->cellId  = cellCfg->cellId;
624    cell->rachCfg = cellCfg->rachCfg;
625    cell->bwCfg   = cellCfg->bwCfg;
626 #ifdef EMTC_ENABLE
627    if(cellCfg->emtcEnable)
628     {  
629      cell->emtcEnable = cellCfg->emtcEnable;
630     }
631 #endif
632    /* Initialize UL and DL CCCH logical channels */
633    cell->ulCcchId = RG_INVALID_LC_ID;
634    cell->dlCcchId = RG_INVALID_LC_ID;
635
636    
637    /* Initialize the lists of the cell */
638    ret = rgDBMInitCell(cell);
639    if (ret != ROK)
640    {
641       DU_LOG("\nERROR  -->  MAC : DBM initialization for cell failed");
642       rgCFGFreeInactvCellCb(cell);
643       return RFAILED;
644    }
645
646 #ifdef LTE_ADV
647    if (RFAILED == RgLaaCellCbInit(cell))
648    {
649       rgCFGFreeInactvCellCb(cell);
650       return RFAILED;
651    }
652 #endif
653
654    for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
655    {
656       cell->subFrms[idx].txDone = TRUE;
657    }
658   
659    cell->macInst           = inst + RG_INST_START; 
660    /* Insert cell in the incative cell list */
661    rgCb[inst].inactiveCell = cell;
662    rgCb[inst].cell         = NULLP;
663 #ifdef TENB_MULT_CELL_SUPPRT
664    rguDlSapId              = cellCfg->rguDlSapId;
665    rguUlSapId              = cellCfg->rguUlSapId;
666 #else
667    if(rgCb[inst].numRguSaps > 1)
668    {
669       rguDlSapId              = 1;
670    }
671 #endif
672    cell->rguDlSap          = &(rgCb[inst].rguSap[rguDlSapId]);
673    cell->rguUlSap          = &(rgCb[inst].rguSap[rguUlSapId]);
674
675
676 #ifdef LTE_L2_MEAS
677    cmLListInit(&cell->l2mList);
678    for(idx = 0; idx < RG_NUM_UL_SUB_FRAMES; idx++)
679    {
680       memset(&cell->ulSf[idx], 0, sizeof(RgUlSf));
681    }
682
683    cell->ttiCycle = (uint32_t)RG_TTI_CYCLE_INVLD;   
684 #endif
685    /* Update Statistics */
686    rgUpdtCellCnt(inst,RG_CFG_ADD);
687    errInfo->errCause = RGERR_NONE;
688   
689    pst = &rgCb[inst].rguSap[rguDlSapId].sapCfg.sapPst;
690    /* Allocate a buffer for flowCntrlInd.*/
691    SGetSBuf(pst->region, pst->pool, (Data **)&cell->flowCntrlInd, 
692               sizeof(RguFlowCntrlInd));
693    return ROK;
694 }  /* rgCFGCrgCellCfg */
695
696 #ifdef LTE_ADV
697 /**
698  * @brief Add SCell Cfg recvd from primary MAC instance.
699  *
700  * @details
701  *
702  *     Function : rgCfgAddUeSCellCfg
703  *
704  *     Processing Steps:
705  *      - Allocate and create UE control block.
706  *      - Update UE control block with the values recieved in the
707  *        configuration.
708  *      - If successful, add the control block to hash list of UEs for the cell
709  *        else Rollback and FAIL.
710  *
711  *  @param[in]  Inst                 dstMacInst
712  *  @param[in]  RgPrgUeSCellCfgInfo  *ueSCellCb
713  *  @param[in]  RgCellCb              cell
714
715  *  @return  S16
716  *      -# ROK
717  *      -# RFAILED
718  **/
719 S16 rgCfgAddUeSCellCfg
720 (
721 Inst        dstMacInst,    
722 RgPrgUeSCellCfgInfo *ueSCellCb,
723 RgCellCb    *cell
724 )
725 {
726    RgUeCb     *ueCb = NULLP;
727    SuId       rguUlSapId = 0;
728    SuId       rguDlSapId = 0;
729    uint8_t    idx;
730    RgErrInfo  errInfo;
731
732 #ifdef LTE_ADV
733    rguDlSapId              = ueSCellCb->rguDlSapId;
734    rguUlSapId              = ueSCellCb->rguUlSapId;
735 #endif
736 #ifndef TENB_MULT_CELL_SUPPRT
737    if(rgCb[dstMacInst].numRguSaps > 1)
738    {
739       rguDlSapId              = 1;
740    }
741 #endif
742
743    if ((ueCb = rgDBMGetUeCb(cell, ueSCellCb->ueId)) != NULLP)
744    {
745       DU_LOG("\nERROR  -->  MAC : [%d]UE already exist in scell %d during scell addition\n", 
746                ueSCellCb->ueId,
747                cell->cellId);
748       return RFAILED;
749    }
750
751    /* Create UeCb */
752    if((ueCb = rgRAMCreateUeCb(cell, ueSCellCb->ueId,
753                FALSE, &errInfo)) == NULLP)
754    {
755       DU_LOG("\nERROR  -->  MAC : [%d]UeCb creation failed\n", ueSCellCb->ueId);
756       return RFAILED;
757    }
758
759    if(rgDHMHqEntInit(dstMacInst, &ueCb->dl.hqEnt, 
760             (rgCb[dstMacInst].cell)->maxDlHqProcPerUe) != ROK)
761    {
762       DU_LOG("\nERROR  -->  MAC : [%d]UeCb Harq Entity Initialization failed\n", ueSCellCb->ueId);
763       return RFAILED;
764    }
765    rgDBMInsUeCb(cell, ueCb);
766
767
768    ueCb->rguDlSap          = &(rgCb[dstMacInst].rguSap[rguDlSapId]);
769    ueCb->rguUlSap          = &(rgCb[dstMacInst].rguSap[rguUlSapId]);
770
771    /* Update satistics */
772    rgUpdtUeCnt(dstMacInst, RG_CFG_ADD);
773    /*Commit Added SCell info to UeCb */
774    /*
775    ueCb->sCelAddInfo[idx].isSCellAdded = TRUE;
776    ueCb->sCelAddInfo[idx].macInst = dstMacInst;
777    ueCb->sCelAddInfo[idx].sCellId = ueSCellCb->cellId;
778    */
779
780    ueCb->txMode = ueSCellCb->txMode;
781    ueCb->ul.hqEnt.maxHqRetx = ueSCellCb->maxUlHqRetx;
782
783    for (idx =0; idx <RG_MAX_LC_PER_UE; idx++)
784    {
785       ueCb->ul.lcCb[idx] = ueSCellCb->ulLcInfo[idx];
786       ueCb->dl.lcCb[idx] = ueSCellCb->dlLcInfo[idx];
787    }
788
789    for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
790    {
791       ueCb->ul.lcgArr[idx].lcgId = ueSCellCb->lcgInfo[idx].lcgId;
792       ueCb->ul.lcgArr[idx].lcCount = ueSCellCb->lcgInfo[idx].lcCount;
793       ueCb->ul.lcgArr[idx].isGbr = ueSCellCb->lcgInfo[idx].isGbr;
794    }
795    return ROK;
796 }/* rgCfgAddUeSCellCfg */
797
798 /**
799  * @brief SCell Config Filling for added cell from RRC to MAC.
800  *
801  * @details
802  *
803  *     Function : rgFillAndAddSCellCfg 
804  *
805  *     Processing Steps:
806  *      - Update UE control block with the values recieved in the
807  *        configuration.
808  *      - Update UE control block with the values present in the
809  *        CellCb
810  *      - If successful, add the control block to hash list of UEs for the cell
811  *        else Rollback and FAIL.
812  *
813  *  @param[in]  Inst          inst
814  *  @param[in]  RgCellCb      *cell
815  *  @param[in]  CrgUeCfg      *ueCfg
816  *  @param[in]  CrgCfgTransId transId
817  *  @return  S16
818  *      -# ROK
819  *      -# RFAILED
820  **/
821 S16 rgFillAndAddSCellCfg
822 (
823 Inst            inst,
824 RgCellCb        *cell,
825 CrgUeRecfg      *ueRecfg,
826 CrgCfgTransId   transId,
827 Bool            *isCfmRqrd
828 )
829 {
830    RgUeCb     *ue = NULLP;
831    uint8_t     idx = 0;
832    Inst        dstMacInst;
833    RgPrgUeSCellCfgInfo ueSCellCb;
834    Pst          dstInstPst;
835
836   /* Fetch the Active cell */
837    if(((cell = rgCb[inst].cell) == NULLP) ||
838        (cell->cellId != ueRecfg->cellId))
839    {
840       DU_LOG("\nERROR  -->  MAC : [%d]Active Cell does not exist %d\n",
841                                   ueRecfg->oldCrnti, ueRecfg->cellId);
842       return RFAILED;
843    }
844
845    DU_LOG("\nINFO  -->  MAC : Filling SCell Config : cellId %d ueId %d\n",
846             cell->cellId, cell->ueId);
847
848    if ((ue = rgDBMGetUeCb(cell, ueRecfg->oldCrnti)) == NULLP)
849    {
850       DU_LOG("\nERROR  -->  MAC : [%d]UE does not exist\n", ueRecfg->oldCrnti);
851       return RFAILED;
852    }
853
854    /* Initialize cfgCfmInfo in the ueCb. This is used while processing SCellAdd
855     *confirmation*/
856    ue->cfgCfmInfo.numSCells = ueRecfg->crgSCellCfg.numSCells;
857    ue->cfgCfmInfo.cfgCfgCount = 0;
858    ue->cfgCfmInfo.mask = 0x0;
859
860    memcpy(&(ue->cfgCfmInfo.transId), &transId,
861          sizeof(CrgCfgTransId));
862    ueSCellCb.ueId = ueRecfg->oldCrnti;
863    ueSCellCb.txMode = ue->txMode;
864    ueSCellCb.maxUlHqRetx = ue->ul.hqEnt.maxHqRetx;
865    memcpy(ueSCellCb.ulLcInfo, ue->ul.lcCb, sizeof(ue->ul.lcCb));
866    memcpy(ueSCellCb.dlLcInfo, ue->dl.lcCb, sizeof(ue->dl.lcCb));
867    for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
868    {
869       ueSCellCb.lcgInfo[idx].lcgId = ue->ul.lcgArr[idx].lcgId;
870       ueSCellCb.lcgInfo[idx].lcCount = ue->ul.lcgArr[idx].lcCount;
871       ueSCellCb.lcgInfo[idx].isGbr = ue->ul.lcgArr[idx].isGbr;
872    }
873
874    for(idx = 0; 
875          idx < ueRecfg->crgSCellCfg.numSCells; idx++)
876    {
877       dstMacInst = ueRecfg->crgSCellCfg.ueSCellCfg[idx].macInst - RG_INST_START;
878       ueSCellCb.cellId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].sCellId;
879       ueSCellCb.rguDlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguDlSapId;
880       ueSCellCb.rguUlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguUlSapId;
881
882       /* Get post structure of the cell to whom ueSCellCb needs to be sent
883        * And then send the sCell Add based on Mac instances */
884       rgGetPstToInst(&dstInstPst, inst, dstMacInst);
885       RgPrgPMacSMacUeSCellCfg(&dstInstPst, &ueSCellCb);
886
887       /*Commit Added SCell info to UeCb is moved to config confirm*/
888    } /*end of for loop */
889    *isCfmRqrd = FALSE;
890
891    return ROK;
892 }  /* rgFillAndAddSCellCfg */
893 #endif /* LTE_ADV */
894
895 /**
896  * @brief Handler for the UE configuration request from RRC to MAC.
897  *
898  * @details
899  *
900  *     Function : rgCFGCrgUeCfg
901  *
902  *     Processing Steps:
903  *      - Allocate and create UE control block.
904  *      - Update UE control block with the values recieved in the
905  *        configuration.
906  *      - Invoke RAM, SCH, UHM and DHM with created UE control block, to
907  *        update random access, scheduler, uplink harq and downlink harq
908  *        specific information respectively.
909  *      - If successful, add the control block to hash list of UEs for the cell
910  *        else Rollback and FAIL.
911  *
912  *  @param[in]  Inst        inst
913  *  @param[in]  RgCellCb  *cell
914  *  @param[in]  CrgUeCfg  *ueCfg
915  *  @param[out] RgErrInfo *errInfo
916  *  @return  S16
917  *      -# ROK
918  *      -# RFAILED
919  **/
920 S16 rgCFGCrgUeCfg
921 (
922 Inst      inst,
923 RgCellCb  *cell,
924 CrgUeCfg  *ueCfg,
925 RgErrInfo *errInfo
926 )
927 {
928    RgUeCb    *ue = NULLP;
929    Bool      handover = FALSE;
930    SuId       rguUlSapId = 0;
931    SuId       rguDlSapId = 0;
932
933    errInfo->errCause = RGERR_CFG_CRG_UE_CFG;
934
935 /* Start: LTEMAC_2.1_DEV_CFG */
936    if ((ue = rgDBMGetUeCbFromRachLst(cell, ueCfg->crnti)) == NULLP)
937    {
938       /* Create UeCb and Insert in Rach List */
939       if((ue=rgRAMCreateUeCb(cell, ueCfg->crnti, FALSE, errInfo)) == NULLP)
940       {
941          DU_LOG("\nERROR  -->  MAC : UeCb creation failed");
942          return RFAILED;
943       }
944       if(rgDHMHqEntInit(inst,&ue->dl.hqEnt, cell->maxDlHqProcPerUe) != ROK)
945       {
946          DU_LOG("\nERROR  -->  MAC : UeCb Harq Entity Initialization failed");
947          return RFAILED;
948       }
949       handover = TRUE;
950    }
951 /* End: LTEMAC_2.1_DEV_CFG */
952
953    if(handover == FALSE)
954    {
955       /* Remove from the rachLst */
956       rgDBMDelUeCbFromRachLst(cell, ue);
957    }
958
959
960    /* Initialize uplink HARQ related information for UE */
961    rgUHMCrgUeCfg(cell, ue, ueCfg);
962
963    rgDBMInsUeCb(cell, ue);
964
965 #ifdef TENB_MULT_CELL_SUPPRT
966    rguDlSapId              = ueCfg->rguDlSapId;
967    rguUlSapId              = ueCfg->rguUlSapId;
968 #else
969    if(rgCb[inst].numRguSaps > 1)
970    {
971       rguDlSapId              = 1;
972    }
973 #endif
974
975    ue->rguDlSap          = &(rgCb[inst].rguSap[rguDlSapId]);
976    ue->rguUlSap          = &(rgCb[inst].rguSap[rguUlSapId]);
977
978
979    /* Update satistics */
980    rgUpdtUeCnt(inst,RG_CFG_ADD);
981    errInfo->errCause = RGERR_NONE;
982    return ROK;
983 }  /* rgCFGCrgUeCfg */
984
985
986 /**
987  * @brief Handler for the logical channel configuration request from
988  * RRC to MAC.
989  *
990  * @details
991  *
992  *     Function : rgCFGCrgLcCfg
993  *
994  *     Processing Steps:
995  *      - Check if the configuration is for dedicated or common logical channel.
996  *      - For Dedicated logical channels:
997  *        - Update the dedicated logical channel Cb with the configured values.
998  *        - Invoke SCH will cell, UE and logical channel Cb to update scheduler
999  *          specific information.
1000  *      - For Common logical channels:
1001  *        - Update the common logical channel Cb with the configured values.
1002  *        - Move cell to active list of cells if cell becomes ACTIVE.
1003  *      - If successful, return ROK else RFAILED.
1004  *
1005  *  @param[in]  Inst        inst
1006  *  @param[in]  RgCellCb    *cell
1007  *  @param[in]  RgUeCb      *ue
1008  *  @param[in]  CrgLchCfg   *lcCfg
1009  *  @param[out] RgErrInfo   *errInfo
1010  *  @param[in]  Bool        *isCfmRqrd
1011  *  @return  S16
1012  *      -# ROK
1013  *      -# RFAILED
1014  **/
1015 S16 rgCFGCrgLcCfg
1016 (
1017 Inst            inst,
1018 RgCellCb        *cell,
1019 RgUeCb          *ue,
1020 CrgLchCfg       *lcCfg,
1021 RgErrInfo       *errInfo,
1022 Bool            *isCfmRqrd,
1023 CrgCfgTransId   transId
1024 )
1025 {
1026
1027    /* Handle Config for dedicated/common logical channels */
1028    if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
1029    {
1030
1031       if ((rgCFGCrgDedLcCfg(cell, ue, lcCfg, errInfo)) != ROK)
1032       {
1033          DU_LOG("\nERROR  -->  MAC : Dedicated logical channel configuration failed %d",lcCfg->lcId);
1034          return RFAILED;
1035       }
1036 #ifdef LTE_ADV
1037       /*ERAB Multl Cell fix*/
1038        memcpy(&(ue->cfgCfmInfo.transId), &transId,
1039             sizeof(CrgCfgTransId));
1040        rgPomSndUeSCellLchAddToSmac(inst, cell, ue, lcCfg,isCfmRqrd);
1041 #endif
1042    }
1043    else
1044    {
1045       if ((rgCFGCrgCmnLcCfg(inst,cell, lcCfg, errInfo)) != ROK)
1046       {
1047          DU_LOG("\nERROR  -->  MAC : Common logical channel configuration"
1048                   "failed %d\n", lcCfg->lcId);
1049          return RFAILED;
1050       }
1051    }
1052
1053    errInfo->errCause = RGERR_NONE;
1054    DU_LOG("\nINFO   -->  MAC : CRG LC config done for UE lcId %d\n", lcCfg->lcId);
1055    return ROK;
1056 }  /* rgCFGCrgLcCfg */
1057
1058
1059 /**
1060  * @brief Handler for the cell re-configuration request from RRC to MAC.
1061  *
1062  * @details
1063  *
1064  *     Function : rgCFGCrgCellRecfg
1065  *
1066  *     Processing Steps:
1067  *      - Invoke SCH with updated Cell Cb to update scheduler specific
1068  *        parameters.
1069  *      - Update the cell Cb with the reconfigured values.
1070  *      - If successful, return ROK else RFAILED.
1071  *
1072  *  @param[in]  Inst        inst
1073  *  @param[in]  RgCellCb      *cell
1074  *  @param[in]  CrgCellRecfg  *cellRecfg
1075  *  @param[out] RgErrInfo     *errInfo
1076  *  @return  S16
1077  *      -# ROK
1078  *      -# RFAILED
1079  **/
1080 S16 rgCFGCrgCellRecfg
1081 (
1082 Inst          inst,
1083 RgCellCb      *cell,
1084 CrgCellRecfg  *cellRecfg,
1085 RgErrInfo     *errInfo
1086 )
1087 {
1088    /* Store the given rachCfg */
1089    cell->rachCfg = cellRecfg->rachRecfg;
1090
1091    errInfo->errCause = RGERR_NONE;
1092    return ROK;
1093 }  /* rgCFGCrgCellRecfg */
1094
1095
1096 /**
1097  * @brief Handler for the UE re-configuration request from RRC to MAC.
1098  *
1099  * @details
1100  *
1101  *     Function : rgCFGCrgUeRecfg
1102  *
1103  *     Processing Steps:
1104  *      - If rnti changes,
1105  *        - Invoke RAM for UE reconfiguration.
1106  *        - Delete old UE from the list.
1107  *        - Update the new rnti and re-insert the UE in the list.
1108  *      - Update the UE control block with the reconfigured values.
1109  *      - Invoke SCH, UHM and DHM with updated UE control block to 
1110  *        update scheduler, uplink HARQ and downlink HARQ specific
1111  *        parameters.
1112  *      - If successful, return ROK else RFAILED.
1113  *
1114  *  @param[in]  Inst        inst
1115  *  @param[in]  RgCellCb    *cell
1116  *  @param[in]  RgUeCb      *ue
1117  *  @param[in]  CrgUeRecfg  *ueRecfg
1118  *  @param[out] RgErrInfo   *errInfo
1119  *  @return  S16
1120  *      -# ROK
1121  *      -# RFAILED
1122  **/
1123 S16 rgCFGCrgUeRecfg
1124 (
1125 Inst        inst,
1126 RgCellCb    *cell,
1127 RgUeCb      *ue,
1128 CrgUeRecfg  *ueRecfg,
1129 RgErrInfo   *errInfo
1130 )
1131 {
1132    errInfo->errCause = RGERR_CFG_CRG_UE_RECFG;
1133
1134    /* Fix : syed UE ID change at MAC will now be controlled
1135     * by SCH. */
1136
1137    /* Update uplink HARQ related information for UE */
1138    rgUHMCrgUeRecfg(cell, ue, ueRecfg);
1139
1140    errInfo->errCause = RGERR_NONE;
1141    return ROK;
1142 }  /* rgCFGCrgUeRecfg */
1143
1144
1145 /**
1146  * @brief Handler for the logical channel re-configuration request from
1147  * RRC to MAC.
1148  *
1149  * @details
1150  *
1151  *     Function : rgCFGCrgLcRecfg
1152  *
1153  *     Processing Steps:
1154  *      - Invoke scheduler to update scheduler specific information.
1155  *      - Update the dedicated logical channel Cb with the re-configured
1156  *        values.
1157  *      - If successful, return ROK else RFAILED.
1158  *
1159  *  @param[in]  Inst        inst
1160  *  @param[in]  RgUlCellCb  *cell
1161  *  @param[in]  RgUlUeCb    *ue
1162  *  @param[in]  RgUlLcCb    *ulLc
1163  *  @param[in]  RgDlLcCb    *dlLc
1164  *  @param[in]  CrgLchRecfg *lcRecfg
1165  *  @param[out] RgErrInfo   *errInfo
1166  *  @return  S16
1167  *      -# ROK
1168  *      -# RFAILED
1169  **/
1170 S16 rgCFGCrgLcRecfg
1171 (
1172 Inst        inst,
1173 RgCellCb    *cell,
1174 RgUeCb      *ue,
1175 RgUlLcCb    *ulLc,
1176 CrgLchRecfg *lcRecfg,
1177 RgErrInfo   *errInfo,
1178 Bool        *isCfmRqrd
1179 )
1180 {
1181
1182    if (ulLc->lcgId != lcRecfg->ulRecfg.lcgId)
1183    {
1184       rgDBMUpdUlDedLcCb(ue, ulLc, lcRecfg->ulRecfg.lcgId);
1185 #ifdef LTE_ADV
1186       rgPomSndUeSCellLchModToSmac(inst, cell, ue,  lcRecfg,isCfmRqrd);
1187 #endif
1188    }
1189
1190    errInfo->errCause = RGERR_NONE;
1191    return ROK;
1192 }  /* rgCFGCrgLcRecfg */
1193
1194 /* Start: LTEMAC_2.1_DEV_CFG */
1195 /**
1196  * @brief Handler for the logical channel re-configuration request from
1197  * RRC to MAC.
1198  *
1199  * @details
1200  *
1201  *     Function : rgCFGCrgUeReset
1202  *
1203  *     Processing Steps:
1204  *
1205  *  @param[in]  RgUlCellCb  *cell
1206  *  @param[in]  RgUlUeCb    *ue
1207  *  @param[in]  CrgRst     *reset
1208  *  @param[out] RgErrInfo   *errInfo
1209  *  @return  S16
1210  *      -# ROK
1211  *      -# RFAILED
1212  **/
1213 S16 rgCFGCrgUeReset
1214 (
1215 RgCellCb    *cell,
1216 RgUeCb      *ue,
1217 CrgRst      *reset,
1218 RgErrInfo   *errInfo
1219 )
1220 {
1221
1222    DU_LOG("\nDEBUG  -->  MAC : UE of cell %d Reset\n", cell->cellId);
1223    rgDHMUeReset(cell, &ue->dl.hqEnt);
1224
1225    errInfo->errCause = RGERR_NONE;
1226
1227    return ROK;
1228 }  /* rgCFGCrgUeReset */
1229 /* End: LTEMAC_2.1_DEV_CFG */
1230
1231 /**
1232  * @brief Handler for the cell delete request from RRC to MAC.
1233  *
1234  * @details
1235  *
1236  *     Function : rgCFGCrgCellDel
1237  *
1238  *     Processing Steps:
1239  *      - Fetch the cell control block.
1240  *      - Remove the cell control block from the hash list of cells.
1241  *      - Free the cell control block.
1242  *      - If successful, return ROK else return RFAILED.
1243  *
1244  *  @param[in]  Inst        inst
1245  *  @param[in]  CrgDel      *cellDelInfo
1246  *  @param[out] RgErrInfo   *errInfo
1247  *  @return  S16
1248  *      -# ROK
1249  *      -# RFAILED
1250  **/
1251 S16 rgCFGCrgCellDel
1252 (
1253 Inst        inst,
1254 CrgDel      *cellDelInfo,
1255 RgErrInfo   *errInfo
1256 )
1257 {
1258    RgCellCb *cell;
1259    uint8_t  idx;
1260
1261
1262    errInfo->errCause = RGERR_CFG_CRG_CELL_DEL;
1263    if (((cell = rgCb[inst].cell) == NULLP)
1264        ||(cell->cellId != cellDelInfo->u.cellDel.cellId))  
1265    {
1266       if(((cell = rgCb[inst].inactiveCell) == NULLP)
1267           ||(cell->cellId != cellDelInfo->u.cellDel.cellId))  
1268       {
1269
1270          
1271          DU_LOG("\nERROR  -->  MAC : Cell does not exist");
1272          return RFAILED;
1273       }
1274
1275       /* Delete cell from inactive list */
1276       rgCb[inst].inactiveCell = NULLP ;
1277
1278       /* Free the inactive cell */
1279       rgCFGFreeInactvCellCb(cell);
1280
1281       errInfo->errCause = RGERR_NONE;
1282       return ROK;
1283    }
1284
1285    /* Delete from the cell list */
1286    //rgDBMDelCellCb(cell);
1287    for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1288    {
1289       rgTOMRlsSf(inst,&cell->subFrms[idx]);
1290    }
1291
1292    /* Free the active cell */
1293    rgCFGFreeCellCb(cell);
1294
1295    rgCb[inst].cell = NULLP;
1296
1297    errInfo->errCause    = RGERR_NONE;
1298    DU_LOG("\nINFO  -->  MAC : Cell %d deleted\n", cellDelInfo->u.cellDel.cellId);
1299    return ROK;
1300 }  /* rgCFGCrgCellDel */
1301
1302
1303 /**
1304  * @brief Handler for the UE delete request from RRC to MAC.
1305  *
1306  * @details
1307  *
1308  *     Function : rgCFGCrgUeDel
1309  *
1310  *     Processing Steps:
1311  *      - Fetch the UE control block.
1312  *      - Remove the UE control block from the hash list of UEs for the cell.
1313  *      - Free the UE control block.
1314  *      - If successful, return ROK else return RFAILED.
1315  *
1316  *  @param[in]  Inst        inst
1317  *  @param[in]  CrgDel      *ueDelInfo
1318  *  @param[out] RgErrInfo   *errInfo
1319  *  @return  S16
1320  *      -# ROK
1321  *      -# RFAILED
1322  **/
1323 S16 rgCFGCrgUeDel
1324 (
1325 Inst        inst,
1326 CrgDel      *ueDelInfo,
1327 RgErrInfo   *errInfo
1328 )
1329 {
1330
1331    errInfo->errCause = RGERR_CFG_CRG_UE_DEL;
1332
1333    DU_LOG("\nDEBUG  -->  MAC : UE %d Deletion Req at MAC\n", \
1334             ueDelInfo->u.ueDel.crnti);
1335    if ((rgCb[inst].cell == NULLP)
1336        || (rgCb[inst].cell->cellId != ueDelInfo->u.ueDel.cellId))
1337    {
1338       DU_LOG("\nERROR  -->  MAC : Cell does not exist %d",
1339                 ueDelInfo->u.ueDel.cellId);
1340       return RFAILED;
1341    }
1342
1343    errInfo->errCause = RGERR_NONE;
1344    /* Fix: syed Context Deletion is relied upon SCH indication */
1345    return ROK;
1346 }  /* rgCFGCrgUeDel */
1347
1348
1349 /**
1350  * @brief Handler for the logical channel delete request from
1351  * RRC to MAC.
1352  *
1353  * @details
1354  *
1355  *     Function : rgCFGCrgLcDel
1356  *
1357  *     Processing Steps:
1358  *      - Fetch the logical channel control block.
1359  *      - Free the logical channel control block.
1360  *      - If successful, return ROK else return RFAILED.
1361  *
1362  *  @param[in]  Inst        inst
1363  *  @param[in]  CrgDel      *lcDelInfo
1364  *  @param[out] RgErrInfo   *errInfo
1365  *  @return  S16
1366  *      -# ROK
1367  *      -# RFAILED
1368  **/
1369 S16 rgCFGCrgLcDel
1370 (
1371 Inst        inst,
1372 CrgDel      *lcDelInfo,
1373 RgErrInfo   *errInfo,
1374 Bool        *isCfmRqrd,
1375 CrgCfgTransId transId
1376 )
1377 {
1378    Bool      dirVld = FALSE;
1379    RgCellCb  *cell;
1380    RgUeCb    *ue;
1381    RgUlLcCb  *ulLc;
1382    RgDlLcCb  *dlLc;
1383
1384    errInfo->errCause = RGERR_CFG_CRG_LC_DEL;
1385
1386    /* Fetch the Active cell */
1387    if (((cell = rgCb[inst].cell) == NULLP) ||
1388        (rgCb[inst].cell->cellId != lcDelInfo->u.lchDel.cellId))
1389    {
1390       DU_LOG("\nERROR  -->  MAC : Cell does not exist %d",
1391                 lcDelInfo->u.lchDel.cellId);
1392       return RFAILED;
1393    }
1394
1395    /* Fetch the Ue */
1396    if ((ue = rgDBMGetUeCb(cell, lcDelInfo->u.lchDel.crnti)) == NULLP)
1397    {
1398       DU_LOG("\nERROR  -->  MAC : UE does not exist for dedicated logical channel");
1399       return RFAILED;
1400    }
1401
1402    /* Validate downlink info */
1403    if (lcDelInfo->u.lchDel.dir & CRG_DIR_TX)
1404    {
1405       if ((dlLc = rgDBMGetDlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1406             == NULLP)
1407       {
1408          DU_LOG("\nERROR  -->  MAC : DL LC %d does not exist",
1409                    lcDelInfo->u.lchDel.lcId);
1410          return RFAILED;
1411       }
1412       rgDBMDelDlDedLcCb(ue, dlLc);
1413       dirVld = TRUE;
1414    }
1415
1416    /* Validate uplink info */
1417    if (lcDelInfo->u.lchDel.dir & CRG_DIR_RX)
1418    {
1419       if ((ulLc = rgDBMGetUlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1420             == NULLP)
1421       {
1422          DU_LOG("\nERROR  -->  MAC : UL LC %d does not exist",
1423                    lcDelInfo->u.lchDel.lcId);
1424          return RFAILED;
1425       }
1426       rgDBMDelUlDedLcCb(ue, ulLc);
1427       dirVld = TRUE;
1428    }
1429
1430    if (!dirVld)
1431    {
1432       DU_LOG("\nERROR  -->  MAC : Invalid direction %d for LC Delete",
1433             lcDelInfo->u.lchDel.dir);
1434       return RFAILED;
1435    }
1436 #ifdef LTE_ADV
1437    /*ERAB - multicell fix*/
1438    memcpy( &(ue->cfgCfmInfo.transId), &transId,
1439          sizeof(CrgCfgTransId));
1440    rgPomSndUeSCellLchDelToSmac(inst, lcDelInfo, isCfmRqrd);
1441 #endif
1442    errInfo->errCause = RGERR_NONE;
1443    return ROK;
1444 }  /* rgCFGCrgLcDel */
1445
1446 /***********************************************************
1447  *
1448  *     Func : rgCFGVldtCrgDedLcCfg
1449  *
1450  *
1451  *     Desc : Validates dedicated logical channel configuration recieved from RRC.
1452  *
1453  *     Ret  : S16
1454  *            ROK - Success
1455  *            RFAILED - Failed
1456  *
1457  *     Notes:
1458  *
1459  *     File :
1460  *
1461  **********************************************************/
1462 static S16 rgCFGVldtCrgDedLcCfg
1463 (
1464 Inst          inst, 
1465 CrgLchCfg     *lcCfg,
1466 RgCellCb      **cell,
1467 RgUeCb        **ue,
1468 RgErrInfo     *errInfo
1469 )
1470 {
1471    uint8_t         dirVld   = FALSE;
1472
1473    errInfo->errCause = RGERR_CFG_INVALID_CRG_DED_LC_CFG;
1474
1475    /* Fetch the Active cell */
1476    if (((*cell = rgCb[inst].cell) == NULLP)
1477       || ((*cell)->cellId != lcCfg->cellId))
1478    {
1479       DU_LOG("\nERROR  -->  MAC : Active Cell does not exist: Cell %d",
1480                 lcCfg->cellId);
1481       return RFAILED;
1482    }
1483
1484    /* Fetch the Ue */
1485    if ((*ue = rgDBMGetUeCb(*cell, lcCfg->crnti)) == NULLP)
1486    {
1487       DU_LOG("\nERROR  -->  MAC : UE  does not exist for dedicated logical channel %d",
1488                 lcCfg->lcId);
1489       return RFAILED;
1490    }
1491
1492    /* Validate logical channel Id */
1493    if ((lcCfg->lcId < RG_DEDLC_MIN_LCID)
1494             ||(lcCfg->lcId > RG_DEDLC_MAX_LCID))
1495    {
1496       DU_LOG("\nERROR  -->  MAC : Invalid logical channel Id %d",
1497                 lcCfg->lcId);
1498       return RFAILED;
1499    }
1500
1501    /* Validate downlink info */
1502    if (lcCfg->dir & CRG_DIR_TX)
1503    {
1504       if (rgDBMGetDlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1505       {
1506          DU_LOG("\nERROR  -->  MAC : UE Dedicated DL LC %d already configured",
1507                     lcCfg->lcId);
1508          return RFAILED;
1509       }
1510       dirVld = TRUE;
1511    }
1512
1513    /* Validate uplink info */
1514    if (lcCfg->dir & CRG_DIR_RX)
1515    {
1516       if (lcCfg->ulInfo.lcgId > (RG_MAX_LCG_PER_UE - 1))
1517       {
1518          DU_LOG("\nERROR  -->  MAC : UE Invalid lcgId for uplink logical channel %d",
1519                    lcCfg->ulInfo.lcgId);
1520          return RFAILED;
1521       }
1522       if (rgDBMGetUlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1523       {
1524          DU_LOG("\nERROR  -->  MAC : UE Dedicated UL LC %d already configured",
1525                    lcCfg->lcId);
1526          return RFAILED;
1527       }
1528       dirVld = TRUE;
1529    }
1530
1531    if (!dirVld)
1532    {
1533       DU_LOG("\nERROR  -->  MAC : Invalid Direction %d",
1534                lcCfg->dir);
1535       return RFAILED;
1536    }
1537
1538    return ROK;
1539 }  /* rgCFGVldtCrgDedLcCfg */
1540
1541
1542 /***********************************************************
1543  *
1544  *     Func : rgCFGVldtCrgCmnLcCfg
1545  *
1546  *
1547  *     Desc : Validates common logical channel configuration recieved from RRC.
1548  *
1549  *     Ret  : S16
1550  *            ROK - Success
1551  *            RFAILED - Failed
1552  *
1553  *     Notes:
1554  *
1555  *     File :
1556  *
1557  **********************************************************/
1558 static S16 rgCFGVldtCrgCmnLcCfg
1559 (
1560 Inst          inst,
1561 CrgLchCfg     *lcCfg,
1562 RgCellCb      **cell,
1563 RgErrInfo     *errInfo
1564 )
1565 {
1566    uint8_t dirVld  = FALSE;
1567
1568    errInfo->errCause = RGERR_CFG_INVALID_CRG_CMN_LC_CFG;
1569
1570    /* Ensure cell is not in the active list */
1571    if (((*cell = rgCb[inst].cell) != NULLP)
1572       && ((*cell)->cellId != lcCfg->cellId))
1573    {
1574       DU_LOG("\nERROR  -->  MAC : Active Cell exists for common channels");
1575       return RFAILED;
1576    }
1577
1578    /* Fetch the inactive cell for common logical channels */
1579    if (((*cell = rgCb[inst].inactiveCell) == NULLP)
1580         || ((*cell)->cellId != lcCfg->cellId))
1581    {
1582       
1583       DU_LOG("\nERROR  -->  MAC : Inactive Cell does not exist for common channels");
1584       return RFAILED;
1585    }
1586    /* Validate downlink info */
1587    if (lcCfg->dir & CRG_DIR_TX)
1588    {
1589       if (lcCfg->lcType == CM_LTE_LCH_BCCH)
1590       {
1591          if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
1592          {
1593             if (rgDBMGetBcchOnDlsch(*cell,lcCfg->lcId) != NULLP)
1594             {
1595                DU_LOG("\nERROR  -->  MAC : BCCH on DLSCH already configured for cell");
1596                return RFAILED;
1597             }
1598          }
1599          else if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_BCH)
1600          {
1601             if (rgDBMGetBcchOnBch(*cell) != NULLP)
1602             {
1603                DU_LOG("\nERROR  -->  MAC : BCCH on BCH already configured for cell ");
1604                return RFAILED;
1605             }
1606          }
1607          else
1608          {
1609             DU_LOG("\nERROR  -->  MAC : Invalid transport channel %d for cell",
1610                   lcCfg->dlInfo.dlTrchType);
1611             return RFAILED;
1612          }
1613       }
1614       else if (lcCfg->lcType == CM_LTE_LCH_PCCH)
1615       {
1616          if (rgDBMGetPcch(*cell) != NULLP)
1617          {
1618             DU_LOG("\nERROR  -->  MAC : PCCH already configured for cell");
1619             return RFAILED;
1620          }
1621       }
1622       else if (RG_DLCCCH_ISCFGD(*cell))
1623       {
1624          DU_LOG("\nERROR  -->  MAC : DL CCCH already configured for cell ");
1625          return RFAILED;
1626       }
1627       dirVld = TRUE;
1628    }
1629
1630    /* Validate uplink info */
1631    if (lcCfg->dir & CRG_DIR_RX)
1632    {
1633       /* Uplink CCCH */
1634       if (lcCfg->lcType != CM_LTE_LCH_CCCH)
1635       {
1636          DU_LOG("\nERROR  -->  MAC : Invalid UL common lcType %d for cell ",
1637                   lcCfg->lcType);
1638          return RFAILED;
1639       }
1640       if (RG_ULCCCH_ISCFGD(*cell))
1641       {
1642          DU_LOG("\nERROR  -->  MAC : UL CCCH already configured for cell ");
1643          return RFAILED;
1644       }
1645       dirVld = TRUE;
1646    }
1647
1648    /* Invalid direction */
1649    if (!dirVld)
1650    {
1651       DU_LOG("\nERROR  -->  MAC : Invalid Direction %d", lcCfg->dir);
1652       return RFAILED;
1653    }
1654
1655    return ROK;
1656 }  /* rgCFGVldtCrgCmnLcCfg */
1657
1658 /***********************************************************
1659  *
1660  *     Func : rgCFGCrgDedLcCfg
1661  *
1662  *
1663  *     Desc : Handles dedicated logical channel configuration 
1664  *     recieved from RRC.
1665  *
1666  *     Ret  : S16
1667  *            ROK - Success
1668  *            RFAILED - Failed
1669  *
1670  *     Notes:
1671  *
1672  *     File :
1673  *
1674  **********************************************************/
1675 static S16 rgCFGCrgDedLcCfg
1676 (
1677 RgCellCb      *cell,
1678 RgUeCb        *ue,
1679 CrgLchCfg     *lcCfg,
1680 RgErrInfo     *errInfo
1681 )
1682 {
1683    //Inst     inst = cell->macInst - RG_INST_START;
1684    errInfo->errCause = RGERR_CFG_CRG_DED_LC_CFG;
1685
1686    /* Uplink/Bi-directional logical channel */
1687    if (lcCfg->dir & CRG_DIR_RX)
1688    {
1689 #ifdef LTE_L2_MEAS
1690       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId, lcCfg->qci);
1691       cell->qciArray[lcCfg->qci].qci = lcCfg->qci;
1692       if(lcCfg->lcType == CM_LTE_LCH_DTCH)
1693       {
1694         rgAddToL2MeasPerQci(cell,lcCfg->qci);/*LTE_L2_MEAS_PHASE2*/ 
1695       }
1696 #else
1697       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId);
1698 #endif
1699    }
1700
1701    /* Downlink/Bi-directional logical channel */
1702    if (lcCfg->dir & CRG_DIR_TX)
1703    {
1704       rgDBMInsDlDedLcCb(ue, lcCfg->lcId);
1705    }
1706    return ROK;
1707 }  /* rgCFGCrgDedLcCfg */
1708
1709
1710 /***********************************************************
1711  *
1712  *     Func : rgCFGCrgCmnLcCfg
1713  *
1714  *
1715  *     Desc : Handles dedicated logical channel configuration 
1716  *     recieved from RRC.
1717  *
1718  *     Ret  : S16
1719  *            ROK - Success
1720  *            RFAILED - Failed
1721  *
1722  *     Notes:
1723  *
1724  *     File :
1725  *
1726  **********************************************************/
1727 static S16 rgCFGCrgCmnLcCfg
1728 (
1729 Inst          inst,
1730 RgCellCb      *cell,
1731 CrgLchCfg     *lcCfg,
1732 RgErrInfo     *errInfo
1733 )
1734 {
1735    errInfo->errCause = RGERR_CFG_CRG_CMN_LC_CFG;
1736
1737    /* Handle configuration for CCCH/BCCH/PCCH */
1738    if (lcCfg->lcType == CM_LTE_LCH_CCCH)
1739    {
1740       /* UL and DL CCCH configuration */
1741       if (lcCfg->dir & CRG_DIR_TX)
1742       {
1743          cell->dlCcchId = lcCfg->lcId;
1744          cell->cellActvState |= RG_DL_CCCH_CFG_DONE;
1745       }
1746
1747       if (lcCfg->dir & CRG_DIR_RX)
1748       {
1749          cell->ulCcchId = lcCfg->lcId;
1750          cell->cellActvState |= RG_UL_CCCH_CFG_DONE;
1751       }
1752    }
1753    else
1754    {
1755       if (lcCfg->lcType == CM_LTE_LCH_BCCH)
1756       {
1757          /* BCCH on BCH and DLSCH configuration */
1758          if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
1759          {
1760             rgDBMInsBcchOnDlsch(cell, lcCfg->lcId);
1761             
1762             if(cell->cellActvState & RG_BCCH_DLSCH_CFG1_DONE)
1763             {
1764                cell->cellActvState |= RG_BCCH_DLSCH_CFG2_DONE;
1765             }
1766             else
1767             {
1768                cell->cellActvState |= RG_BCCH_DLSCH_CFG1_DONE;
1769             }
1770          }
1771          else
1772          {
1773             rgDBMInsBcchOnBch(cell, lcCfg->lcId);
1774             cell->cellActvState |= RG_BCCH_BCH_CFG_DONE;
1775          }
1776       }
1777       else  /* PCCH configuration */
1778       {
1779          rgDBMInsPcch(cell, lcCfg->lcId);
1780          cell->cellActvState |= RG_PCCH_CFG_DONE;
1781       }
1782    }
1783
1784    /* Add to active cell list if cell is active */
1785    if (cell->cellActvState == RG_CELL_ACTIVE)
1786    {
1787       rgCb[inst].cell = cell;
1788       rgCb[inst].inactiveCell = NULLP;
1789       DU_LOG("\nDEBUG  -->  MAC : Cell  added to active list after common LC %d\
1790                config\n", lcCfg->lcId);
1791    }
1792
1793    return ROK;
1794 }  /* rgCFGCrgCmnLcCfg */
1795 #ifdef LTE_L2_MEAS
1796 /***********************************************************
1797  *
1798  *     Func : rgCFGFreeUeUlAlloc 
1799  *
1800  *
1801  *     Desc :
1802  *     - Processing Steps:
1803  *        - Frees cell control block.
1804  *
1805  *     Ret  : Void
1806  *
1807  *     Notes:
1808  *
1809  *     File :
1810  *
1811  **********************************************************/
1812 static Void rgCFGFreeUeUlAlloc(RgCellCb *cell)
1813 {
1814    uint8_t    sfIdx;
1815    Inst inst = cell->macInst - RG_INST_START;
1816    
1817    for(sfIdx = 0; sfIdx < RG_NUM_UL_SUB_FRAMES; sfIdx++)
1818    {
1819       if(cell->ulSf[sfIdx].ueUlAllocInfo != NULLP)
1820       {
1821          /*ccpu00117052 - MOD- Passing double pointer for proper
1822           *                    NULLP assignment */
1823          rgFreeSBuf(inst,(Data **)&(cell->ulSf[sfIdx].ueUlAllocInfo), 
1824                (cell->ulSf[sfIdx].numUe * sizeof(RgUeUlAlloc)));
1825       }
1826    }
1827 }/* rgCFGFreeUeUlAlloc */
1828 #endif
1829 /***********************************************************
1830  *
1831  *     Func : rgCFGFreeCellCb
1832  *
1833  *
1834  *     Desc :
1835  *     - Processing Steps:
1836  *        - Frees cell control block.
1837  *
1838  *     Ret  : Void
1839  *
1840  *     Notes:
1841  *
1842  *     File :
1843  *
1844  **********************************************************/
1845 Void rgCFGFreeCellCb(RgCellCb  *cell)
1846 {
1847    Inst inst = cell->macInst - RG_INST_START;
1848
1849 #ifdef LTE_ADV
1850    RgLaaCellCbDeInit(cell);
1851 #endif
1852    /* Free lists of the cell */
1853 #ifdef LTEMAC_SPS
1854    rgCFGFreeSpsUeLst(cell);
1855 #endif /* LTEMAC_SPS */
1856    rgCFGFreeUeLst(cell);
1857    rgRAMFreeCell(cell);
1858    rgCFGFreeCmnLcLst(cell);
1859 #ifdef LTE_L2_MEAS
1860    rgCFGFreeUeUlAlloc(cell);
1861 #endif
1862    /* ccpu00117052 - MOD - Passing double pointer for proper NULLP 
1863                            assignment */
1864    /* Update satistics */
1865    rgUpdtCellCnt(inst,RG_CFG_DEL);
1866    rgDHMFreeAllTbBufs(inst);
1867
1868    rgFreeSBuf(inst,(Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
1869
1870    /* De-allocate the Cell */
1871    rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
1872  
1873
1874    DU_LOG("\nINFO  -->  MAC : Cell freed\n");
1875
1876   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1877   return; 
1878 }  /* rgCFGFreeCellCb */
1879
1880
1881 /***********************************************************
1882  *
1883  *     Func : rgCFGFreeInactvCellCb
1884  *
1885  *
1886  *     Desc :
1887  *     - Processing Steps:
1888  *        - Frees inactive cell control block.
1889  *
1890  *     Ret  : Void
1891  *
1892  *     Notes:
1893  *
1894  *     File :
1895  *
1896  **********************************************************/
1897 Void rgCFGFreeInactvCellCb(RgCellCb *cell)
1898 {
1899    Inst      inst = cell->macInst - RG_INST_START;
1900    /* De-initialize the Ue list */
1901    rgDBMDeInitUeCbLst(cell);
1902 #ifdef LTEMAC_SPS
1903    rgDBMDeInitSpsUeCbLst(cell);
1904 #endif
1905
1906    rgCFGFreeCmnLcLst(cell);
1907
1908    rgFreeSBuf(inst, (Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
1909    /*ccpu00117052 - MOD- Passing double pointer for proper
1910                         NULLP assignment */
1911    /* De-allocate the Cell */
1912    rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
1913
1914    /* Update satistics */
1915    rgUpdtCellCnt(inst,RG_CFG_DEL);
1916
1917
1918   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1919   return; 
1920 }  /* rgCFGFreeInactvCellCb */
1921
1922
1923 /***********************************************************
1924  *
1925  *     Func : rgCFGFreeUeCb
1926  *
1927  *
1928  *     Desc :
1929  *     - Processing Steps:
1930  *        - Frees UE control block.
1931  *
1932  *     Ret  : Void
1933  *
1934  *     Notes:
1935  *
1936  *     File :
1937  *
1938  **********************************************************/
1939 Void rgCFGFreeUeCb(RgCellCb *cell,RgUeCb *ue)
1940 {
1941    Inst inst = cell->macInst - RG_INST_START;
1942
1943    rgDHMFreeUe(inst,&ue->dl.hqEnt);
1944
1945    /* ccpu00117052 - MOD - Passing double pointer for proper NULLP
1946                           assignment */
1947    /* De-allocate the Ue */
1948    rgFreeSBuf(inst,(Data **)&ue, sizeof(*ue));
1949
1950    /* Update Statistics */
1951    rgUpdtUeCnt(inst,RG_CFG_DEL);
1952
1953
1954   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1955   return; 
1956 }  /* rgCFGFreeUeCb */
1957
1958 /***********************************************************
1959  *
1960  *     Func : rgCFGFreeCmnLcLst
1961  *
1962  *
1963  *     Desc :
1964  *     - Processing Steps:
1965  *        - Frees common logical channels in cell control block.
1966  *
1967  *     Ret  : Void
1968  *
1969  *     Notes:
1970  *
1971  *     File :
1972  *
1973  **********************************************************/
1974 static Void rgCFGFreeCmnLcLst(RgCellCb *cell)
1975 {
1976    rgDBMFreeCmnLcLst(cell);
1977
1978
1979   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1980   return; 
1981 }  /* rgCFGFreeCmnLcLst */
1982
1983
1984 /***********************************************************
1985  *
1986  *     Func : rgCFGFreeUeLst
1987  *
1988  *
1989  *     Desc :
1990  *     - Processing Steps:
1991  *        - Frees UE list in cell control block.
1992  *
1993  *     Ret  : Void
1994  *
1995  *     Notes:
1996  *
1997  *     File :
1998  *
1999  **********************************************************/
2000 static Void rgCFGFreeUeLst(RgCellCb *cell)
2001 {
2002    RgUeCb     *ue;
2003
2004    /* Free Ues in the list */
2005    while ((ue = rgDBMGetNextUeCb(cell, NULLP)) != NULLP)
2006    {
2007 #ifdef LTE_ADV
2008       rgDelUeFrmAllSCell(cell,ue);
2009 #endif
2010       rgDBMDelUeCb(cell, ue);
2011       rgCFGFreeUeCb(cell, ue);
2012    }
2013
2014    /* De-initialize the Ue list */
2015    rgDBMDeInitUeCbLst(cell);
2016
2017
2018   /* Stack Crash Problem for TRACE5 Changes. Added return below */
2019   return; 
2020 }  /* rgCFGFreeUeLst */
2021
2022 #ifdef LTEMAC_SPS
2023 /***********************************************************
2024  *
2025  *     Func : rgCFGFreeSpsUeLst
2026  *
2027  *
2028  *     Desc :
2029  *     - Processing Steps:
2030  *        - Frees Sps UE list in cell control block.
2031  *
2032  *     Ret  : Void
2033  *
2034  *     Notes:
2035  *
2036  *     File :
2037  *
2038  **********************************************************/
2039 static Void rgCFGFreeSpsUeLst(RgCellCb *cell)
2040 {
2041    RgUeCb     *ue;
2042
2043    /* Free Ues in the list */
2044    while ((ue = rgDBMGetNextSpsUeCb(cell, NULLP)))
2045    {
2046       rgDBMDelSpsUeCb(cell, ue);
2047    }
2048
2049    /* De-initialize the Ue list */
2050    rgDBMDeInitSpsUeCbLst(cell);
2051
2052 }  /* rgCFGFreeSpsUeLst */
2053
2054 #endif /* LTEMAC_SPS */
2055
2056 /**
2057  * @brief Function for registering cell- scheduler instance mapping
2058  *
2059  * @details
2060  *
2061  *     Function : RgSchMacCellRegReq
2062  *     
2063  *     This function shall be invoked whenever scheduler is done with the
2064  *     cell configuration successfully.
2065  *     This shall create a mapping of the cell, scheduler instance that
2066  *     is serving the cell and the unique identifier of the cell on the 
2067  *     scheduler at MAC. This mapping shall be used for further 
2068  *     communication to the scheduler instance for this cell.
2069  *     
2070  *           
2071  *  @param[in] Pst*                pst,
2072  *  @param[in] CmLteCellId         cellId,
2073  *  @param[in] RaRespReqInfo       raRespReq
2074  *  @return  S16
2075  *      -# ROK 
2076  **/
2077 S16 RgSchMacCellRegReq(Pst*  pst,RgInfCellReg* regReq)
2078 {
2079    Inst      inst;
2080    RgCellCb *cell = NULLP;
2081
2082    RG_IS_INST_VALID(pst->dstInst);
2083    inst = pst->dstInst - RG_INST_START;
2084    cell = rgCb[inst].cell;
2085
2086    if(NULLP == regReq)
2087    {
2088       return RFAILED;
2089    }
2090       
2091    if((cell  == NULLP) || (cell->cellId != regReq->cellId))
2092    {
2093       return RFAILED;
2094    }
2095    if(regReq->maxDlHqProcPerUe > RG_MAX_DL_HARQ_NUM) 
2096    {
2097       return RFAILED;
2098    }
2099    /* Initialize */
2100    cell->schInstMap.cellSapId = regReq->cellSapId;
2101    cell->schInstMap.schInst   = pst->srcInst;
2102    cell->maxDlHqProcPerUe = regReq->maxDlHqProcPerUe;
2103
2104    return ROK;
2105
2106 } /* end of RgSchMacCellRegReq */
2107
2108 /*Added Ue for Onging L2 Meas*/
2109 #ifdef LTE_L2_MEAS
2110 /*LTE_L2_MEAS_PHASE2*/
2111 S16 rgAddToL2MeasPerQci(RgCellCb  *cell,uint8_t qci)
2112 {
2113    S16        ret = ROK;        
2114    CmLList    *lnk;
2115    RgL2MeasCb *measCb;
2116    uint16_t   idx;
2117
2118    lnk = cell->l2mList.first;
2119    while(lnk != NULLP )
2120    {
2121       measCb = (RgL2MeasCb *)lnk->node;
2122       if(measCb->measReq.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
2123       {
2124          for(idx = 0;idx< measCb->measReq.t.prbReq.numQci;idx++)
2125          {
2126             if(measCb->measReq.t.prbReq.qci[idx] == qci)
2127             {
2128                break; /*exit from for loop*/
2129             } 
2130          }      
2131          if(idx == measCb->measReq.t.prbReq.numQci)
2132          {
2133             cell->qciArray[qci].mask = TRUE; 
2134             measCb->measReq.t.prbReq.qci[measCb->measReq.t.prbReq.numQci++] = qci;
2135          }              
2136       }           
2137       lnk = lnk->next;
2138    }  /* End of While*/
2139
2140
2141
2142    return (ret);
2143 }
2144
2145
2146 #endif
2147
2148 /**********************************************************************
2149  
2150          End of file
2151 **********************************************************************/