[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[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 #include "mac_utils.h" 
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    /* Commented below to resolve compilation warning */
607    //Pst        *pst ;
608
609    errInfo->errCause = RGERR_CFG_CRG_CELL_CFG;
610    
611    /* Allocate the cell control block */
612    if((ret = rgAllocSBuf(inst,(Data**)&cell, sizeof(RgCellCb))) != ROK)
613    {
614       DU_LOG("\nERROR  -->  MAC : Memory allocation FAILED for cell");
615       return RFAILED;
616    }
617    if (cell == NULLP)
618    {
619       DU_LOG("\nERROR  -->  MAC : Memory allocation FAILED for cell");
620       return RFAILED;
621    }
622
623    /* Initialize the cell */
624    cell->cellId  = cellCfg->cellId;
625    cell->rachCfg = cellCfg->rachCfg;
626    cell->bwCfg   = cellCfg->bwCfg;
627 #ifdef EMTC_ENABLE
628    if(cellCfg->emtcEnable)
629     {  
630      cell->emtcEnable = cellCfg->emtcEnable;
631     }
632 #endif
633    /* Initialize UL and DL CCCH logical channels */
634    cell->ulCcchId = RG_INVALID_LC_ID;
635    cell->dlCcchId = RG_INVALID_LC_ID;
636
637    
638    /* Initialize the lists of the cell */
639    ret = rgDBMInitCell(cell);
640    if (ret != ROK)
641    {
642       DU_LOG("\nERROR  -->  MAC : DBM initialization for cell failed");
643       rgCFGFreeInactvCellCb(cell);
644       return RFAILED;
645    }
646
647 #ifdef LTE_ADV
648    if (RFAILED == RgLaaCellCbInit(cell))
649    {
650       rgCFGFreeInactvCellCb(cell);
651       return RFAILED;
652    }
653 #endif
654
655    for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
656    {
657       cell->subFrms[idx].txDone = TRUE;
658    }
659   
660    cell->macInst           = inst + RG_INST_START; 
661    /* Insert cell in the incative cell list */
662    rgCb[inst].inactiveCell = cell;
663    rgCb[inst].cell         = NULLP;
664 #ifdef TENB_MULT_CELL_SUPPRT
665    rguDlSapId              = cellCfg->rguDlSapId;
666    rguUlSapId              = cellCfg->rguUlSapId;
667 #else
668    if(rgCb[inst].numRguSaps > 1)
669    {
670       rguDlSapId              = 1;
671    }
672 #endif
673    cell->rguDlSap          = &(rgCb[inst].rguSap[rguDlSapId]);
674    cell->rguUlSap          = &(rgCb[inst].rguSap[rguUlSapId]);
675
676
677 #ifdef LTE_L2_MEAS
678    cmLListInit(&cell->l2mList);
679    for(idx = 0; idx < RG_NUM_UL_SUB_FRAMES; idx++)
680    {
681       memset(&cell->ulSf[idx], 0, sizeof(RgUlSf));
682    }
683
684    cell->ttiCycle = (uint32_t)RG_TTI_CYCLE_INVLD;   
685 #endif
686    /* Update Statistics */
687    rgUpdtCellCnt(inst,RG_CFG_ADD);
688    errInfo->errCause = RGERR_NONE;
689   
690    /* Commented below to resolve compilation warning */
691    //pst = &rgCb[inst].rguSap[rguDlSapId].sapCfg.sapPst;
692    /* Allocate a buffer for flowCntrlInd.*/
693    MAC_ALLOC(cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
694    if(cell->flowCntrlInd == NULLP)
695    {
696       DU_LOG("ERROR  --> MAC : rgCFGCrgCellCfg(): Memory allocation failed");
697       return RFAILED;
698    }
699    return ROK;
700 }  /* rgCFGCrgCellCfg */
701
702 #ifdef LTE_ADV
703 /**
704  * @brief Add SCell Cfg recvd from primary MAC instance.
705  *
706  * @details
707  *
708  *     Function : rgCfgAddUeSCellCfg
709  *
710  *     Processing Steps:
711  *      - Allocate and create UE control block.
712  *      - Update UE control block with the values recieved in the
713  *        configuration.
714  *      - If successful, add the control block to hash list of UEs for the cell
715  *        else Rollback and FAIL.
716  *
717  *  @param[in]  Inst                 dstMacInst
718  *  @param[in]  RgPrgUeSCellCfgInfo  *ueSCellCb
719  *  @param[in]  RgCellCb              cell
720
721  *  @return  S16
722  *      -# ROK
723  *      -# RFAILED
724  **/
725 S16 rgCfgAddUeSCellCfg
726 (
727 Inst        dstMacInst,    
728 RgPrgUeSCellCfgInfo *ueSCellCb,
729 RgCellCb    *cell
730 )
731 {
732    RgUeCb     *ueCb = NULLP;
733    SuId       rguUlSapId = 0;
734    SuId       rguDlSapId = 0;
735    uint8_t    idx;
736    RgErrInfo  errInfo;
737
738 #ifdef LTE_ADV
739    rguDlSapId              = ueSCellCb->rguDlSapId;
740    rguUlSapId              = ueSCellCb->rguUlSapId;
741 #endif
742 #ifndef TENB_MULT_CELL_SUPPRT
743    if(rgCb[dstMacInst].numRguSaps > 1)
744    {
745       rguDlSapId              = 1;
746    }
747 #endif
748
749    if ((ueCb = rgDBMGetUeCb(cell, ueSCellCb->ueId)) != NULLP)
750    {
751       DU_LOG("\nERROR  -->  MAC : [%d]UE already exist in scell %d during scell addition\n", 
752                ueSCellCb->ueId,
753                cell->cellId);
754       return RFAILED;
755    }
756
757    /* Create UeCb */
758    if((ueCb = rgRAMCreateUeCb(cell, ueSCellCb->ueId,
759                FALSE, &errInfo)) == NULLP)
760    {
761       DU_LOG("\nERROR  -->  MAC : [%d]UeCb creation failed\n", ueSCellCb->ueId);
762       return RFAILED;
763    }
764
765    if(rgDHMHqEntInit(dstMacInst, &ueCb->dl.hqEnt, 
766             (rgCb[dstMacInst].cell)->maxDlHqProcPerUe) != ROK)
767    {
768       DU_LOG("\nERROR  -->  MAC : [%d]UeCb Harq Entity Initialization failed\n", ueSCellCb->ueId);
769       return RFAILED;
770    }
771    rgDBMInsUeCb(cell, ueCb);
772
773
774    ueCb->rguDlSap          = &(rgCb[dstMacInst].rguSap[rguDlSapId]);
775    ueCb->rguUlSap          = &(rgCb[dstMacInst].rguSap[rguUlSapId]);
776
777    /* Update satistics */
778    rgUpdtUeCnt(dstMacInst, RG_CFG_ADD);
779    /*Commit Added SCell info to UeCb */
780    /*
781    ueCb->sCelAddInfo[idx].isSCellAdded = TRUE;
782    ueCb->sCelAddInfo[idx].macInst = dstMacInst;
783    ueCb->sCelAddInfo[idx].sCellId = ueSCellCb->cellId;
784    */
785
786    ueCb->txMode = ueSCellCb->txMode;
787    ueCb->ul.hqEnt.maxHqRetx = ueSCellCb->maxUlHqRetx;
788
789    for (idx =0; idx <RG_MAX_LC_PER_UE; idx++)
790    {
791       ueCb->ul.lcCb[idx] = ueSCellCb->ulLcInfo[idx];
792       ueCb->dl.lcCb[idx] = ueSCellCb->dlLcInfo[idx];
793    }
794
795    for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
796    {
797       ueCb->ul.lcgArr[idx].lcgId = ueSCellCb->lcgInfo[idx].lcgId;
798       ueCb->ul.lcgArr[idx].lcCount = ueSCellCb->lcgInfo[idx].lcCount;
799       ueCb->ul.lcgArr[idx].isGbr = ueSCellCb->lcgInfo[idx].isGbr;
800    }
801    return ROK;
802 }/* rgCfgAddUeSCellCfg */
803
804 /**
805  * @brief SCell Config Filling for added cell from RRC to MAC.
806  *
807  * @details
808  *
809  *     Function : rgFillAndAddSCellCfg 
810  *
811  *     Processing Steps:
812  *      - Update UE control block with the values recieved in the
813  *        configuration.
814  *      - Update UE control block with the values present in the
815  *        CellCb
816  *      - If successful, add the control block to hash list of UEs for the cell
817  *        else Rollback and FAIL.
818  *
819  *  @param[in]  Inst          inst
820  *  @param[in]  RgCellCb      *cell
821  *  @param[in]  CrgUeCfg      *ueCfg
822  *  @param[in]  CrgCfgTransId transId
823  *  @return  S16
824  *      -# ROK
825  *      -# RFAILED
826  **/
827 S16 rgFillAndAddSCellCfg
828 (
829 Inst            inst,
830 RgCellCb        *cell,
831 CrgUeRecfg      *ueRecfg,
832 CrgCfgTransId   transId,
833 Bool            *isCfmRqrd
834 )
835 {
836    RgUeCb     *ue = NULLP;
837    uint8_t     idx = 0;
838    Inst        dstMacInst;
839    RgPrgUeSCellCfgInfo ueSCellCb;
840    Pst          dstInstPst;
841
842   /* Fetch the Active cell */
843    if(((cell = rgCb[inst].cell) == NULLP) ||
844        (cell->cellId != ueRecfg->cellId))
845    {
846       DU_LOG("\nERROR  -->  MAC : [%d]Active Cell does not exist %d\n",
847                                   ueRecfg->oldCrnti, ueRecfg->cellId);
848       return RFAILED;
849    }
850
851    DU_LOG("\nINFO  -->  MAC : Filling SCell Config : cellId %d ueId %d\n",
852             cell->cellId, cell->ueId);
853
854    if ((ue = rgDBMGetUeCb(cell, ueRecfg->oldCrnti)) == NULLP)
855    {
856       DU_LOG("\nERROR  -->  MAC : [%d]UE does not exist\n", ueRecfg->oldCrnti);
857       return RFAILED;
858    }
859
860    /* Initialize cfgCfmInfo in the ueCb. This is used while processing SCellAdd
861     *confirmation*/
862    ue->cfgCfmInfo.numSCells = ueRecfg->crgSCellCfg.numSCells;
863    ue->cfgCfmInfo.cfgCfgCount = 0;
864    ue->cfgCfmInfo.mask = 0x0;
865
866    memcpy(&(ue->cfgCfmInfo.transId), &transId,
867          sizeof(CrgCfgTransId));
868    ueSCellCb.ueId = ueRecfg->oldCrnti;
869    ueSCellCb.txMode = ue->txMode;
870    ueSCellCb.maxUlHqRetx = ue->ul.hqEnt.maxHqRetx;
871    memcpy(ueSCellCb.ulLcInfo, ue->ul.lcCb, sizeof(ue->ul.lcCb));
872    memcpy(ueSCellCb.dlLcInfo, ue->dl.lcCb, sizeof(ue->dl.lcCb));
873    for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
874    {
875       ueSCellCb.lcgInfo[idx].lcgId = ue->ul.lcgArr[idx].lcgId;
876       ueSCellCb.lcgInfo[idx].lcCount = ue->ul.lcgArr[idx].lcCount;
877       ueSCellCb.lcgInfo[idx].isGbr = ue->ul.lcgArr[idx].isGbr;
878    }
879
880    for(idx = 0; 
881          idx < ueRecfg->crgSCellCfg.numSCells; idx++)
882    {
883       dstMacInst = ueRecfg->crgSCellCfg.ueSCellCfg[idx].macInst - RG_INST_START;
884       ueSCellCb.cellId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].sCellId;
885       ueSCellCb.rguDlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguDlSapId;
886       ueSCellCb.rguUlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguUlSapId;
887
888       /* Get post structure of the cell to whom ueSCellCb needs to be sent
889        * And then send the sCell Add based on Mac instances */
890       rgGetPstToInst(&dstInstPst, inst, dstMacInst);
891       RgPrgPMacSMacUeSCellCfg(&dstInstPst, &ueSCellCb);
892
893       /*Commit Added SCell info to UeCb is moved to config confirm*/
894    } /*end of for loop */
895    *isCfmRqrd = FALSE;
896
897    return ROK;
898 }  /* rgFillAndAddSCellCfg */
899 #endif /* LTE_ADV */
900
901 /**
902  * @brief Handler for the UE configuration request from RRC to MAC.
903  *
904  * @details
905  *
906  *     Function : rgCFGCrgUeCfg
907  *
908  *     Processing Steps:
909  *      - Allocate and create UE control block.
910  *      - Update UE control block with the values recieved in the
911  *        configuration.
912  *      - Invoke RAM, SCH, UHM and DHM with created UE control block, to
913  *        update random access, scheduler, uplink harq and downlink harq
914  *        specific information respectively.
915  *      - If successful, add the control block to hash list of UEs for the cell
916  *        else Rollback and FAIL.
917  *
918  *  @param[in]  Inst        inst
919  *  @param[in]  RgCellCb  *cell
920  *  @param[in]  CrgUeCfg  *ueCfg
921  *  @param[out] RgErrInfo *errInfo
922  *  @return  S16
923  *      -# ROK
924  *      -# RFAILED
925  **/
926 S16 rgCFGCrgUeCfg
927 (
928 Inst      inst,
929 RgCellCb  *cell,
930 CrgUeCfg  *ueCfg,
931 RgErrInfo *errInfo
932 )
933 {
934    RgUeCb    *ue = NULLP;
935    Bool      handover = FALSE;
936    SuId       rguUlSapId = 0;
937    SuId       rguDlSapId = 0;
938
939    errInfo->errCause = RGERR_CFG_CRG_UE_CFG;
940
941 /* Start: LTEMAC_2.1_DEV_CFG */
942    if ((ue = rgDBMGetUeCbFromRachLst(cell, ueCfg->crnti)) == NULLP)
943    {
944       /* Create UeCb and Insert in Rach List */
945       if((ue=rgRAMCreateUeCb(cell, ueCfg->crnti, FALSE, errInfo)) == NULLP)
946       {
947          DU_LOG("\nERROR  -->  MAC : UeCb creation failed");
948          return RFAILED;
949       }
950       if(rgDHMHqEntInit(inst,&ue->dl.hqEnt, cell->maxDlHqProcPerUe) != ROK)
951       {
952          DU_LOG("\nERROR  -->  MAC : UeCb Harq Entity Initialization failed");
953          return RFAILED;
954       }
955       handover = TRUE;
956    }
957 /* End: LTEMAC_2.1_DEV_CFG */
958
959    if(handover == FALSE)
960    {
961       /* Remove from the rachLst */
962       rgDBMDelUeCbFromRachLst(cell, ue);
963    }
964
965
966    /* Initialize uplink HARQ related information for UE */
967    rgUHMCrgUeCfg(cell, ue, ueCfg);
968
969    rgDBMInsUeCb(cell, ue);
970
971 #ifdef TENB_MULT_CELL_SUPPRT
972    rguDlSapId              = ueCfg->rguDlSapId;
973    rguUlSapId              = ueCfg->rguUlSapId;
974 #else
975    if(rgCb[inst].numRguSaps > 1)
976    {
977       rguDlSapId              = 1;
978    }
979 #endif
980
981    ue->rguDlSap          = &(rgCb[inst].rguSap[rguDlSapId]);
982    ue->rguUlSap          = &(rgCb[inst].rguSap[rguUlSapId]);
983
984
985    /* Update satistics */
986    rgUpdtUeCnt(inst,RG_CFG_ADD);
987    errInfo->errCause = RGERR_NONE;
988    return ROK;
989 }  /* rgCFGCrgUeCfg */
990
991
992 /**
993  * @brief Handler for the logical channel configuration request from
994  * RRC to MAC.
995  *
996  * @details
997  *
998  *     Function : rgCFGCrgLcCfg
999  *
1000  *     Processing Steps:
1001  *      - Check if the configuration is for dedicated or common logical channel.
1002  *      - For Dedicated logical channels:
1003  *        - Update the dedicated logical channel Cb with the configured values.
1004  *        - Invoke SCH will cell, UE and logical channel Cb to update scheduler
1005  *          specific information.
1006  *      - For Common logical channels:
1007  *        - Update the common logical channel Cb with the configured values.
1008  *        - Move cell to active list of cells if cell becomes ACTIVE.
1009  *      - If successful, return ROK else RFAILED.
1010  *
1011  *  @param[in]  Inst        inst
1012  *  @param[in]  RgCellCb    *cell
1013  *  @param[in]  RgUeCb      *ue
1014  *  @param[in]  CrgLchCfg   *lcCfg
1015  *  @param[out] RgErrInfo   *errInfo
1016  *  @param[in]  Bool        *isCfmRqrd
1017  *  @return  S16
1018  *      -# ROK
1019  *      -# RFAILED
1020  **/
1021 S16 rgCFGCrgLcCfg
1022 (
1023 Inst            inst,
1024 RgCellCb        *cell,
1025 RgUeCb          *ue,
1026 CrgLchCfg       *lcCfg,
1027 RgErrInfo       *errInfo,
1028 Bool            *isCfmRqrd,
1029 CrgCfgTransId   transId
1030 )
1031 {
1032
1033    /* Handle Config for dedicated/common logical channels */
1034    if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
1035    {
1036
1037       if ((rgCFGCrgDedLcCfg(cell, ue, lcCfg, errInfo)) != ROK)
1038       {
1039          DU_LOG("\nERROR  -->  MAC : Dedicated logical channel configuration failed %d",lcCfg->lcId);
1040          return RFAILED;
1041       }
1042 #ifdef LTE_ADV
1043       /*ERAB Multl Cell fix*/
1044        memcpy(&(ue->cfgCfmInfo.transId), &transId,
1045             sizeof(CrgCfgTransId));
1046        rgPomSndUeSCellLchAddToSmac(inst, cell, ue, lcCfg,isCfmRqrd);
1047 #endif
1048    }
1049    else
1050    {
1051       if ((rgCFGCrgCmnLcCfg(inst,cell, lcCfg, errInfo)) != ROK)
1052       {
1053          DU_LOG("\nERROR  -->  MAC : Common logical channel configuration"
1054                   "failed %d\n", lcCfg->lcId);
1055          return RFAILED;
1056       }
1057    }
1058
1059    errInfo->errCause = RGERR_NONE;
1060    DU_LOG("\nINFO   -->  MAC : CRG LC config done for UE lcId %d\n", lcCfg->lcId);
1061    return ROK;
1062 }  /* rgCFGCrgLcCfg */
1063
1064
1065 /**
1066  * @brief Handler for the cell re-configuration request from RRC to MAC.
1067  *
1068  * @details
1069  *
1070  *     Function : rgCFGCrgCellRecfg
1071  *
1072  *     Processing Steps:
1073  *      - Invoke SCH with updated Cell Cb to update scheduler specific
1074  *        parameters.
1075  *      - Update the cell Cb with the reconfigured values.
1076  *      - If successful, return ROK else RFAILED.
1077  *
1078  *  @param[in]  Inst        inst
1079  *  @param[in]  RgCellCb      *cell
1080  *  @param[in]  CrgCellRecfg  *cellRecfg
1081  *  @param[out] RgErrInfo     *errInfo
1082  *  @return  S16
1083  *      -# ROK
1084  *      -# RFAILED
1085  **/
1086 S16 rgCFGCrgCellRecfg
1087 (
1088 Inst          inst,
1089 RgCellCb      *cell,
1090 CrgCellRecfg  *cellRecfg,
1091 RgErrInfo     *errInfo
1092 )
1093 {
1094    /* Store the given rachCfg */
1095    cell->rachCfg = cellRecfg->rachRecfg;
1096
1097    errInfo->errCause = RGERR_NONE;
1098    return ROK;
1099 }  /* rgCFGCrgCellRecfg */
1100
1101
1102 /**
1103  * @brief Handler for the UE re-configuration request from RRC to MAC.
1104  *
1105  * @details
1106  *
1107  *     Function : rgCFGCrgUeRecfg
1108  *
1109  *     Processing Steps:
1110  *      - If rnti changes,
1111  *        - Invoke RAM for UE reconfiguration.
1112  *        - Delete old UE from the list.
1113  *        - Update the new rnti and re-insert the UE in the list.
1114  *      - Update the UE control block with the reconfigured values.
1115  *      - Invoke SCH, UHM and DHM with updated UE control block to 
1116  *        update scheduler, uplink HARQ and downlink HARQ specific
1117  *        parameters.
1118  *      - If successful, return ROK else RFAILED.
1119  *
1120  *  @param[in]  Inst        inst
1121  *  @param[in]  RgCellCb    *cell
1122  *  @param[in]  RgUeCb      *ue
1123  *  @param[in]  CrgUeRecfg  *ueRecfg
1124  *  @param[out] RgErrInfo   *errInfo
1125  *  @return  S16
1126  *      -# ROK
1127  *      -# RFAILED
1128  **/
1129 S16 rgCFGCrgUeRecfg
1130 (
1131 Inst        inst,
1132 RgCellCb    *cell,
1133 RgUeCb      *ue,
1134 CrgUeRecfg  *ueRecfg,
1135 RgErrInfo   *errInfo
1136 )
1137 {
1138    errInfo->errCause = RGERR_CFG_CRG_UE_RECFG;
1139
1140    /* Fix : syed UE ID change at MAC will now be controlled
1141     * by SCH. */
1142
1143    /* Update uplink HARQ related information for UE */
1144    rgUHMCrgUeRecfg(cell, ue, ueRecfg);
1145
1146    errInfo->errCause = RGERR_NONE;
1147    return ROK;
1148 }  /* rgCFGCrgUeRecfg */
1149
1150
1151 /**
1152  * @brief Handler for the logical channel re-configuration request from
1153  * RRC to MAC.
1154  *
1155  * @details
1156  *
1157  *     Function : rgCFGCrgLcRecfg
1158  *
1159  *     Processing Steps:
1160  *      - Invoke scheduler to update scheduler specific information.
1161  *      - Update the dedicated logical channel Cb with the re-configured
1162  *        values.
1163  *      - If successful, return ROK else RFAILED.
1164  *
1165  *  @param[in]  Inst        inst
1166  *  @param[in]  RgUlCellCb  *cell
1167  *  @param[in]  RgUlUeCb    *ue
1168  *  @param[in]  RgUlLcCb    *ulLc
1169  *  @param[in]  RgDlLcCb    *dlLc
1170  *  @param[in]  CrgLchRecfg *lcRecfg
1171  *  @param[out] RgErrInfo   *errInfo
1172  *  @return  S16
1173  *      -# ROK
1174  *      -# RFAILED
1175  **/
1176 S16 rgCFGCrgLcRecfg
1177 (
1178 Inst        inst,
1179 RgCellCb    *cell,
1180 RgUeCb      *ue,
1181 RgUlLcCb    *ulLc,
1182 CrgLchRecfg *lcRecfg,
1183 RgErrInfo   *errInfo,
1184 Bool        *isCfmRqrd
1185 )
1186 {
1187
1188    if (ulLc->lcgId != lcRecfg->ulRecfg.lcgId)
1189    {
1190       rgDBMUpdUlDedLcCb(ue, ulLc, lcRecfg->ulRecfg.lcgId);
1191 #ifdef LTE_ADV
1192       rgPomSndUeSCellLchModToSmac(inst, cell, ue,  lcRecfg,isCfmRqrd);
1193 #endif
1194    }
1195
1196    errInfo->errCause = RGERR_NONE;
1197    return ROK;
1198 }  /* rgCFGCrgLcRecfg */
1199
1200 /* Start: LTEMAC_2.1_DEV_CFG */
1201 /**
1202  * @brief Handler for the logical channel re-configuration request from
1203  * RRC to MAC.
1204  *
1205  * @details
1206  *
1207  *     Function : rgCFGCrgUeReset
1208  *
1209  *     Processing Steps:
1210  *
1211  *  @param[in]  RgUlCellCb  *cell
1212  *  @param[in]  RgUlUeCb    *ue
1213  *  @param[in]  CrgRst     *reset
1214  *  @param[out] RgErrInfo   *errInfo
1215  *  @return  S16
1216  *      -# ROK
1217  *      -# RFAILED
1218  **/
1219 S16 rgCFGCrgUeReset
1220 (
1221 RgCellCb    *cell,
1222 RgUeCb      *ue,
1223 CrgRst      *reset,
1224 RgErrInfo   *errInfo
1225 )
1226 {
1227
1228    DU_LOG("\nDEBUG  -->  MAC : UE of cell %d Reset\n", cell->cellId);
1229    rgDHMUeReset(cell, &ue->dl.hqEnt);
1230
1231    errInfo->errCause = RGERR_NONE;
1232
1233    return ROK;
1234 }  /* rgCFGCrgUeReset */
1235 /* End: LTEMAC_2.1_DEV_CFG */
1236
1237 /**
1238  * @brief Handler for the cell delete request from RRC to MAC.
1239  *
1240  * @details
1241  *
1242  *     Function : rgCFGCrgCellDel
1243  *
1244  *     Processing Steps:
1245  *      - Fetch the cell control block.
1246  *      - Remove the cell control block from the hash list of cells.
1247  *      - Free the cell control block.
1248  *      - If successful, return ROK else return RFAILED.
1249  *
1250  *  @param[in]  Inst        inst
1251  *  @param[in]  CrgDel      *cellDelInfo
1252  *  @param[out] RgErrInfo   *errInfo
1253  *  @return  S16
1254  *      -# ROK
1255  *      -# RFAILED
1256  **/
1257 S16 rgCFGCrgCellDel
1258 (
1259 Inst        inst,
1260 CrgDel      *cellDelInfo,
1261 RgErrInfo   *errInfo
1262 )
1263 {
1264    RgCellCb *cell;
1265    uint8_t  idx;
1266
1267
1268    errInfo->errCause = RGERR_CFG_CRG_CELL_DEL;
1269    if (((cell = rgCb[inst].cell) == NULLP)
1270        ||(cell->cellId != cellDelInfo->u.cellDel.cellId))  
1271    {
1272       if(((cell = rgCb[inst].inactiveCell) == NULLP)
1273           ||(cell->cellId != cellDelInfo->u.cellDel.cellId))  
1274       {
1275
1276          
1277          DU_LOG("\nERROR  -->  MAC : Cell does not exist");
1278          return RFAILED;
1279       }
1280
1281       /* Delete cell from inactive list */
1282       rgCb[inst].inactiveCell = NULLP ;
1283
1284       /* Free the inactive cell */
1285       rgCFGFreeInactvCellCb(cell);
1286
1287       errInfo->errCause = RGERR_NONE;
1288       return ROK;
1289    }
1290
1291    /* Delete from the cell list */
1292    //rgDBMDelCellCb(cell);
1293    for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1294    {
1295       rgTOMRlsSf(inst,&cell->subFrms[idx]);
1296    }
1297
1298    /* Free the active cell */
1299    rgCFGFreeCellCb(cell);
1300
1301    rgCb[inst].cell = NULLP;
1302
1303    errInfo->errCause    = RGERR_NONE;
1304    DU_LOG("\nINFO  -->  MAC : Cell %d deleted\n", cellDelInfo->u.cellDel.cellId);
1305    return ROK;
1306 }  /* rgCFGCrgCellDel */
1307
1308
1309 /**
1310  * @brief Handler for the UE delete request from RRC to MAC.
1311  *
1312  * @details
1313  *
1314  *     Function : rgCFGCrgUeDel
1315  *
1316  *     Processing Steps:
1317  *      - Fetch the UE control block.
1318  *      - Remove the UE control block from the hash list of UEs for the cell.
1319  *      - Free the UE control block.
1320  *      - If successful, return ROK else return RFAILED.
1321  *
1322  *  @param[in]  Inst        inst
1323  *  @param[in]  CrgDel      *ueDelInfo
1324  *  @param[out] RgErrInfo   *errInfo
1325  *  @return  S16
1326  *      -# ROK
1327  *      -# RFAILED
1328  **/
1329 S16 rgCFGCrgUeDel
1330 (
1331 Inst        inst,
1332 CrgDel      *ueDelInfo,
1333 RgErrInfo   *errInfo
1334 )
1335 {
1336
1337    errInfo->errCause = RGERR_CFG_CRG_UE_DEL;
1338
1339    DU_LOG("\nDEBUG  -->  MAC : UE %d Deletion Req at MAC\n", \
1340             ueDelInfo->u.ueDel.crnti);
1341    if ((rgCb[inst].cell == NULLP)
1342        || (rgCb[inst].cell->cellId != ueDelInfo->u.ueDel.cellId))
1343    {
1344       DU_LOG("\nERROR  -->  MAC : Cell does not exist %d",
1345                 ueDelInfo->u.ueDel.cellId);
1346       return RFAILED;
1347    }
1348
1349    errInfo->errCause = RGERR_NONE;
1350    /* Fix: syed Context Deletion is relied upon SCH indication */
1351    return ROK;
1352 }  /* rgCFGCrgUeDel */
1353
1354
1355 /**
1356  * @brief Handler for the logical channel delete request from
1357  * RRC to MAC.
1358  *
1359  * @details
1360  *
1361  *     Function : rgCFGCrgLcDel
1362  *
1363  *     Processing Steps:
1364  *      - Fetch the logical channel control block.
1365  *      - Free the logical channel control block.
1366  *      - If successful, return ROK else return RFAILED.
1367  *
1368  *  @param[in]  Inst        inst
1369  *  @param[in]  CrgDel      *lcDelInfo
1370  *  @param[out] RgErrInfo   *errInfo
1371  *  @return  S16
1372  *      -# ROK
1373  *      -# RFAILED
1374  **/
1375 S16 rgCFGCrgLcDel
1376 (
1377 Inst        inst,
1378 CrgDel      *lcDelInfo,
1379 RgErrInfo   *errInfo,
1380 Bool        *isCfmRqrd,
1381 CrgCfgTransId transId
1382 )
1383 {
1384    Bool      dirVld = FALSE;
1385    RgCellCb  *cell;
1386    RgUeCb    *ue;
1387    RgUlLcCb  *ulLc;
1388    RgDlLcCb  *dlLc;
1389
1390    errInfo->errCause = RGERR_CFG_CRG_LC_DEL;
1391
1392    /* Fetch the Active cell */
1393    if (((cell = rgCb[inst].cell) == NULLP) ||
1394        (rgCb[inst].cell->cellId != lcDelInfo->u.lchDel.cellId))
1395    {
1396       DU_LOG("\nERROR  -->  MAC : Cell does not exist %d",
1397                 lcDelInfo->u.lchDel.cellId);
1398       return RFAILED;
1399    }
1400
1401    /* Fetch the Ue */
1402    if ((ue = rgDBMGetUeCb(cell, lcDelInfo->u.lchDel.crnti)) == NULLP)
1403    {
1404       DU_LOG("\nERROR  -->  MAC : UE does not exist for dedicated logical channel");
1405       return RFAILED;
1406    }
1407
1408    /* Validate downlink info */
1409    if (lcDelInfo->u.lchDel.dir & CRG_DIR_TX)
1410    {
1411       if ((dlLc = rgDBMGetDlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1412             == NULLP)
1413       {
1414          DU_LOG("\nERROR  -->  MAC : DL LC %d does not exist",
1415                    lcDelInfo->u.lchDel.lcId);
1416          return RFAILED;
1417       }
1418       rgDBMDelDlDedLcCb(ue, dlLc);
1419       dirVld = TRUE;
1420    }
1421
1422    /* Validate uplink info */
1423    if (lcDelInfo->u.lchDel.dir & CRG_DIR_RX)
1424    {
1425       if ((ulLc = rgDBMGetUlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1426             == NULLP)
1427       {
1428          DU_LOG("\nERROR  -->  MAC : UL LC %d does not exist",
1429                    lcDelInfo->u.lchDel.lcId);
1430          return RFAILED;
1431       }
1432       rgDBMDelUlDedLcCb(ue, ulLc);
1433       dirVld = TRUE;
1434    }
1435
1436    if (!dirVld)
1437    {
1438       DU_LOG("\nERROR  -->  MAC : Invalid direction %d for LC Delete",
1439             lcDelInfo->u.lchDel.dir);
1440       return RFAILED;
1441    }
1442 #ifdef LTE_ADV
1443    /*ERAB - multicell fix*/
1444    memcpy( &(ue->cfgCfmInfo.transId), &transId,
1445          sizeof(CrgCfgTransId));
1446    rgPomSndUeSCellLchDelToSmac(inst, lcDelInfo, isCfmRqrd);
1447 #endif
1448    errInfo->errCause = RGERR_NONE;
1449    return ROK;
1450 }  /* rgCFGCrgLcDel */
1451
1452 /***********************************************************
1453  *
1454  *     Func : rgCFGVldtCrgDedLcCfg
1455  *
1456  *
1457  *     Desc : Validates dedicated logical channel configuration recieved from RRC.
1458  *
1459  *     Ret  : S16
1460  *            ROK - Success
1461  *            RFAILED - Failed
1462  *
1463  *     Notes:
1464  *
1465  *     File :
1466  *
1467  **********************************************************/
1468 static S16 rgCFGVldtCrgDedLcCfg
1469 (
1470 Inst          inst, 
1471 CrgLchCfg     *lcCfg,
1472 RgCellCb      **cell,
1473 RgUeCb        **ue,
1474 RgErrInfo     *errInfo
1475 )
1476 {
1477    uint8_t         dirVld   = FALSE;
1478
1479    errInfo->errCause = RGERR_CFG_INVALID_CRG_DED_LC_CFG;
1480
1481    /* Fetch the Active cell */
1482    if (((*cell = rgCb[inst].cell) == NULLP)
1483       || ((*cell)->cellId != lcCfg->cellId))
1484    {
1485       DU_LOG("\nERROR  -->  MAC : Active Cell does not exist: Cell %d",
1486                 lcCfg->cellId);
1487       return RFAILED;
1488    }
1489
1490    /* Fetch the Ue */
1491    if ((*ue = rgDBMGetUeCb(*cell, lcCfg->crnti)) == NULLP)
1492    {
1493       DU_LOG("\nERROR  -->  MAC : UE  does not exist for dedicated logical channel %d",
1494                 lcCfg->lcId);
1495       return RFAILED;
1496    }
1497
1498    /* Validate logical channel Id */
1499    if ((lcCfg->lcId < RG_DEDLC_MIN_LCID)
1500             ||(lcCfg->lcId > RG_DEDLC_MAX_LCID))
1501    {
1502       DU_LOG("\nERROR  -->  MAC : Invalid logical channel Id %d",
1503                 lcCfg->lcId);
1504       return RFAILED;
1505    }
1506
1507    /* Validate downlink info */
1508    if (lcCfg->dir & CRG_DIR_TX)
1509    {
1510       if (rgDBMGetDlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1511       {
1512          DU_LOG("\nERROR  -->  MAC : UE Dedicated DL LC %d already configured",
1513                     lcCfg->lcId);
1514          return RFAILED;
1515       }
1516       dirVld = TRUE;
1517    }
1518
1519    /* Validate uplink info */
1520    if (lcCfg->dir & CRG_DIR_RX)
1521    {
1522       if (lcCfg->ulInfo.lcgId > (RG_MAX_LCG_PER_UE - 1))
1523       {
1524          DU_LOG("\nERROR  -->  MAC : UE Invalid lcgId for uplink logical channel %d",
1525                    lcCfg->ulInfo.lcgId);
1526          return RFAILED;
1527       }
1528       if (rgDBMGetUlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1529       {
1530          DU_LOG("\nERROR  -->  MAC : UE Dedicated UL LC %d already configured",
1531                    lcCfg->lcId);
1532          return RFAILED;
1533       }
1534       dirVld = TRUE;
1535    }
1536
1537    if (!dirVld)
1538    {
1539       DU_LOG("\nERROR  -->  MAC : Invalid Direction %d",
1540                lcCfg->dir);
1541       return RFAILED;
1542    }
1543
1544    return ROK;
1545 }  /* rgCFGVldtCrgDedLcCfg */
1546
1547
1548 /***********************************************************
1549  *
1550  *     Func : rgCFGVldtCrgCmnLcCfg
1551  *
1552  *
1553  *     Desc : Validates common logical channel configuration recieved from RRC.
1554  *
1555  *     Ret  : S16
1556  *            ROK - Success
1557  *            RFAILED - Failed
1558  *
1559  *     Notes:
1560  *
1561  *     File :
1562  *
1563  **********************************************************/
1564 static S16 rgCFGVldtCrgCmnLcCfg
1565 (
1566 Inst          inst,
1567 CrgLchCfg     *lcCfg,
1568 RgCellCb      **cell,
1569 RgErrInfo     *errInfo
1570 )
1571 {
1572    uint8_t dirVld  = FALSE;
1573
1574    errInfo->errCause = RGERR_CFG_INVALID_CRG_CMN_LC_CFG;
1575
1576    /* Ensure cell is not in the active list */
1577    if (((*cell = rgCb[inst].cell) != NULLP)
1578       && ((*cell)->cellId != lcCfg->cellId))
1579    {
1580       DU_LOG("\nERROR  -->  MAC : Active Cell exists for common channels");
1581       return RFAILED;
1582    }
1583
1584    /* Fetch the inactive cell for common logical channels */
1585    if (((*cell = rgCb[inst].inactiveCell) == NULLP)
1586         || ((*cell)->cellId != lcCfg->cellId))
1587    {
1588       
1589       DU_LOG("\nERROR  -->  MAC : Inactive Cell does not exist for common channels");
1590       return RFAILED;
1591    }
1592    /* Validate downlink info */
1593    if (lcCfg->dir & CRG_DIR_TX)
1594    {
1595       if (lcCfg->lcType == CM_LTE_LCH_BCCH)
1596       {
1597          if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
1598          {
1599             if (rgDBMGetBcchOnDlsch(*cell,lcCfg->lcId) != NULLP)
1600             {
1601                DU_LOG("\nERROR  -->  MAC : BCCH on DLSCH already configured for cell");
1602                return RFAILED;
1603             }
1604          }
1605          else if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_BCH)
1606          {
1607             if (rgDBMGetBcchOnBch(*cell) != NULLP)
1608             {
1609                DU_LOG("\nERROR  -->  MAC : BCCH on BCH already configured for cell ");
1610                return RFAILED;
1611             }
1612          }
1613          else
1614          {
1615             DU_LOG("\nERROR  -->  MAC : Invalid transport channel %d for cell",
1616                   lcCfg->dlInfo.dlTrchType);
1617             return RFAILED;
1618          }
1619       }
1620       else if (lcCfg->lcType == CM_LTE_LCH_PCCH)
1621       {
1622          if (rgDBMGetPcch(*cell) != NULLP)
1623          {
1624             DU_LOG("\nERROR  -->  MAC : PCCH already configured for cell");
1625             return RFAILED;
1626          }
1627       }
1628       else if (RG_DLCCCH_ISCFGD(*cell))
1629       {
1630          DU_LOG("\nERROR  -->  MAC : DL CCCH already configured for cell ");
1631          return RFAILED;
1632       }
1633       dirVld = TRUE;
1634    }
1635
1636    /* Validate uplink info */
1637    if (lcCfg->dir & CRG_DIR_RX)
1638    {
1639       /* Uplink CCCH */
1640       if (lcCfg->lcType != CM_LTE_LCH_CCCH)
1641       {
1642          DU_LOG("\nERROR  -->  MAC : Invalid UL common lcType %d for cell ",
1643                   lcCfg->lcType);
1644          return RFAILED;
1645       }
1646       if (RG_ULCCCH_ISCFGD(*cell))
1647       {
1648          DU_LOG("\nERROR  -->  MAC : UL CCCH already configured for cell ");
1649          return RFAILED;
1650       }
1651       dirVld = TRUE;
1652    }
1653
1654    /* Invalid direction */
1655    if (!dirVld)
1656    {
1657       DU_LOG("\nERROR  -->  MAC : Invalid Direction %d", lcCfg->dir);
1658       return RFAILED;
1659    }
1660
1661    return ROK;
1662 }  /* rgCFGVldtCrgCmnLcCfg */
1663
1664 /***********************************************************
1665  *
1666  *     Func : rgCFGCrgDedLcCfg
1667  *
1668  *
1669  *     Desc : Handles dedicated logical channel configuration 
1670  *     recieved from RRC.
1671  *
1672  *     Ret  : S16
1673  *            ROK - Success
1674  *            RFAILED - Failed
1675  *
1676  *     Notes:
1677  *
1678  *     File :
1679  *
1680  **********************************************************/
1681 static S16 rgCFGCrgDedLcCfg
1682 (
1683 RgCellCb      *cell,
1684 RgUeCb        *ue,
1685 CrgLchCfg     *lcCfg,
1686 RgErrInfo     *errInfo
1687 )
1688 {
1689    //Inst     inst = cell->macInst - RG_INST_START;
1690    errInfo->errCause = RGERR_CFG_CRG_DED_LC_CFG;
1691
1692    /* Uplink/Bi-directional logical channel */
1693    if (lcCfg->dir & CRG_DIR_RX)
1694    {
1695 #ifdef LTE_L2_MEAS
1696       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId, lcCfg->qci);
1697       cell->qciArray[lcCfg->qci].qci = lcCfg->qci;
1698       if(lcCfg->lcType == CM_LTE_LCH_DTCH)
1699       {
1700         rgAddToL2MeasPerQci(cell,lcCfg->qci);/*LTE_L2_MEAS_PHASE2*/ 
1701       }
1702 #else
1703       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId);
1704 #endif
1705    }
1706
1707    /* Downlink/Bi-directional logical channel */
1708    if (lcCfg->dir & CRG_DIR_TX)
1709    {
1710       rgDBMInsDlDedLcCb(ue, lcCfg->lcId);
1711    }
1712    return ROK;
1713 }  /* rgCFGCrgDedLcCfg */
1714
1715
1716 /***********************************************************
1717  *
1718  *     Func : rgCFGCrgCmnLcCfg
1719  *
1720  *
1721  *     Desc : Handles dedicated logical channel configuration 
1722  *     recieved from RRC.
1723  *
1724  *     Ret  : S16
1725  *            ROK - Success
1726  *            RFAILED - Failed
1727  *
1728  *     Notes:
1729  *
1730  *     File :
1731  *
1732  **********************************************************/
1733 static S16 rgCFGCrgCmnLcCfg
1734 (
1735 Inst          inst,
1736 RgCellCb      *cell,
1737 CrgLchCfg     *lcCfg,
1738 RgErrInfo     *errInfo
1739 )
1740 {
1741    errInfo->errCause = RGERR_CFG_CRG_CMN_LC_CFG;
1742
1743    /* Handle configuration for CCCH/BCCH/PCCH */
1744    if (lcCfg->lcType == CM_LTE_LCH_CCCH)
1745    {
1746       /* UL and DL CCCH configuration */
1747       if (lcCfg->dir & CRG_DIR_TX)
1748       {
1749          cell->dlCcchId = lcCfg->lcId;
1750          cell->cellActvState |= RG_DL_CCCH_CFG_DONE;
1751       }
1752
1753       if (lcCfg->dir & CRG_DIR_RX)
1754       {
1755          cell->ulCcchId = lcCfg->lcId;
1756          cell->cellActvState |= RG_UL_CCCH_CFG_DONE;
1757       }
1758    }
1759    else
1760    {
1761       if (lcCfg->lcType == CM_LTE_LCH_BCCH)
1762       {
1763          /* BCCH on BCH and DLSCH configuration */
1764          if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
1765          {
1766             rgDBMInsBcchOnDlsch(cell, lcCfg->lcId);
1767             
1768             if(cell->cellActvState & RG_BCCH_DLSCH_CFG1_DONE)
1769             {
1770                cell->cellActvState |= RG_BCCH_DLSCH_CFG2_DONE;
1771             }
1772             else
1773             {
1774                cell->cellActvState |= RG_BCCH_DLSCH_CFG1_DONE;
1775             }
1776          }
1777          else
1778          {
1779             rgDBMInsBcchOnBch(cell, lcCfg->lcId);
1780             cell->cellActvState |= RG_BCCH_BCH_CFG_DONE;
1781          }
1782       }
1783       else  /* PCCH configuration */
1784       {
1785          rgDBMInsPcch(cell, lcCfg->lcId);
1786          cell->cellActvState |= RG_PCCH_CFG_DONE;
1787       }
1788    }
1789
1790    /* Add to active cell list if cell is active */
1791    if (cell->cellActvState == RG_CELL_ACTIVE)
1792    {
1793       rgCb[inst].cell = cell;
1794       rgCb[inst].inactiveCell = NULLP;
1795       DU_LOG("\nDEBUG  -->  MAC : Cell  added to active list after common LC %d\
1796                config\n", lcCfg->lcId);
1797    }
1798
1799    return ROK;
1800 }  /* rgCFGCrgCmnLcCfg */
1801 #ifdef LTE_L2_MEAS
1802 /***********************************************************
1803  *
1804  *     Func : rgCFGFreeUeUlAlloc 
1805  *
1806  *
1807  *     Desc :
1808  *     - Processing Steps:
1809  *        - Frees cell control block.
1810  *
1811  *     Ret  : Void
1812  *
1813  *     Notes:
1814  *
1815  *     File :
1816  *
1817  **********************************************************/
1818 static Void rgCFGFreeUeUlAlloc(RgCellCb *cell)
1819 {
1820    uint8_t    sfIdx;
1821    Inst inst = cell->macInst - RG_INST_START;
1822    
1823    for(sfIdx = 0; sfIdx < RG_NUM_UL_SUB_FRAMES; sfIdx++)
1824    {
1825       if(cell->ulSf[sfIdx].ueUlAllocInfo != NULLP)
1826       {
1827          /*ccpu00117052 - MOD- Passing double pointer for proper
1828           *                    NULLP assignment */
1829          rgFreeSBuf(inst,(Data **)&(cell->ulSf[sfIdx].ueUlAllocInfo), 
1830                (cell->ulSf[sfIdx].numUe * sizeof(RgUeUlAlloc)));
1831       }
1832    }
1833 }/* rgCFGFreeUeUlAlloc */
1834 #endif
1835 /***********************************************************
1836  *
1837  *     Func : rgCFGFreeCellCb
1838  *
1839  *
1840  *     Desc :
1841  *     - Processing Steps:
1842  *        - Frees cell control block.
1843  *
1844  *     Ret  : Void
1845  *
1846  *     Notes:
1847  *
1848  *     File :
1849  *
1850  **********************************************************/
1851 Void rgCFGFreeCellCb(RgCellCb  *cell)
1852 {
1853    Inst inst = cell->macInst - RG_INST_START;
1854
1855 #ifdef LTE_ADV
1856    RgLaaCellCbDeInit(cell);
1857 #endif
1858    /* Free lists of the cell */
1859 #ifdef LTEMAC_SPS
1860    rgCFGFreeSpsUeLst(cell);
1861 #endif /* LTEMAC_SPS */
1862    rgCFGFreeUeLst(cell);
1863    rgRAMFreeCell(cell);
1864    rgCFGFreeCmnLcLst(cell);
1865 #ifdef LTE_L2_MEAS
1866    rgCFGFreeUeUlAlloc(cell);
1867 #endif
1868    /* ccpu00117052 - MOD - Passing double pointer for proper NULLP 
1869                            assignment */
1870    /* Update satistics */
1871    rgUpdtCellCnt(inst,RG_CFG_DEL);
1872    rgDHMFreeAllTbBufs(inst);
1873
1874    rgFreeSBuf(inst,(Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
1875
1876    /* De-allocate the Cell */
1877    rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
1878  
1879
1880    DU_LOG("\nINFO  -->  MAC : Cell freed\n");
1881
1882   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1883   return; 
1884 }  /* rgCFGFreeCellCb */
1885
1886
1887 /***********************************************************
1888  *
1889  *     Func : rgCFGFreeInactvCellCb
1890  *
1891  *
1892  *     Desc :
1893  *     - Processing Steps:
1894  *        - Frees inactive cell control block.
1895  *
1896  *     Ret  : Void
1897  *
1898  *     Notes:
1899  *
1900  *     File :
1901  *
1902  **********************************************************/
1903 Void rgCFGFreeInactvCellCb(RgCellCb *cell)
1904 {
1905    Inst      inst = cell->macInst - RG_INST_START;
1906    /* De-initialize the Ue list */
1907    rgDBMDeInitUeCbLst(cell);
1908 #ifdef LTEMAC_SPS
1909    rgDBMDeInitSpsUeCbLst(cell);
1910 #endif
1911
1912    rgCFGFreeCmnLcLst(cell);
1913
1914    rgFreeSBuf(inst, (Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
1915    /*ccpu00117052 - MOD- Passing double pointer for proper
1916                         NULLP assignment */
1917    /* De-allocate the Cell */
1918    rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
1919
1920    /* Update satistics */
1921    rgUpdtCellCnt(inst,RG_CFG_DEL);
1922
1923
1924   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1925   return; 
1926 }  /* rgCFGFreeInactvCellCb */
1927
1928
1929 /***********************************************************
1930  *
1931  *     Func : rgCFGFreeUeCb
1932  *
1933  *
1934  *     Desc :
1935  *     - Processing Steps:
1936  *        - Frees UE control block.
1937  *
1938  *     Ret  : Void
1939  *
1940  *     Notes:
1941  *
1942  *     File :
1943  *
1944  **********************************************************/
1945 Void rgCFGFreeUeCb(RgCellCb *cell,RgUeCb *ue)
1946 {
1947    Inst inst = cell->macInst - RG_INST_START;
1948
1949    rgDHMFreeUe(inst,&ue->dl.hqEnt);
1950
1951    /* ccpu00117052 - MOD - Passing double pointer for proper NULLP
1952                           assignment */
1953    /* De-allocate the Ue */
1954    rgFreeSBuf(inst,(Data **)&ue, sizeof(*ue));
1955
1956    /* Update Statistics */
1957    rgUpdtUeCnt(inst,RG_CFG_DEL);
1958
1959
1960   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1961   return; 
1962 }  /* rgCFGFreeUeCb */
1963
1964 /***********************************************************
1965  *
1966  *     Func : rgCFGFreeCmnLcLst
1967  *
1968  *
1969  *     Desc :
1970  *     - Processing Steps:
1971  *        - Frees common logical channels in cell control block.
1972  *
1973  *     Ret  : Void
1974  *
1975  *     Notes:
1976  *
1977  *     File :
1978  *
1979  **********************************************************/
1980 static Void rgCFGFreeCmnLcLst(RgCellCb *cell)
1981 {
1982    rgDBMFreeCmnLcLst(cell);
1983
1984
1985   /* Stack Crash Problem for TRACE5 Changes. Added return below */
1986   return; 
1987 }  /* rgCFGFreeCmnLcLst */
1988
1989
1990 /***********************************************************
1991  *
1992  *     Func : rgCFGFreeUeLst
1993  *
1994  *
1995  *     Desc :
1996  *     - Processing Steps:
1997  *        - Frees UE list in cell control block.
1998  *
1999  *     Ret  : Void
2000  *
2001  *     Notes:
2002  *
2003  *     File :
2004  *
2005  **********************************************************/
2006 static Void rgCFGFreeUeLst(RgCellCb *cell)
2007 {
2008    RgUeCb     *ue;
2009
2010    /* Free Ues in the list */
2011    while ((ue = rgDBMGetNextUeCb(cell, NULLP)) != NULLP)
2012    {
2013 #ifdef LTE_ADV
2014       rgDelUeFrmAllSCell(cell,ue);
2015 #endif
2016       rgDBMDelUeCb(cell, ue);
2017       rgCFGFreeUeCb(cell, ue);
2018    }
2019
2020    /* De-initialize the Ue list */
2021    rgDBMDeInitUeCbLst(cell);
2022
2023
2024   /* Stack Crash Problem for TRACE5 Changes. Added return below */
2025   return; 
2026 }  /* rgCFGFreeUeLst */
2027
2028 #ifdef LTEMAC_SPS
2029 /***********************************************************
2030  *
2031  *     Func : rgCFGFreeSpsUeLst
2032  *
2033  *
2034  *     Desc :
2035  *     - Processing Steps:
2036  *        - Frees Sps UE list in cell control block.
2037  *
2038  *     Ret  : Void
2039  *
2040  *     Notes:
2041  *
2042  *     File :
2043  *
2044  **********************************************************/
2045 static Void rgCFGFreeSpsUeLst(RgCellCb *cell)
2046 {
2047    RgUeCb     *ue;
2048
2049    /* Free Ues in the list */
2050    while ((ue = rgDBMGetNextSpsUeCb(cell, NULLP)))
2051    {
2052       rgDBMDelSpsUeCb(cell, ue);
2053    }
2054
2055    /* De-initialize the Ue list */
2056    rgDBMDeInitSpsUeCbLst(cell);
2057
2058 }  /* rgCFGFreeSpsUeLst */
2059
2060 #endif /* LTEMAC_SPS */
2061
2062 /**
2063  * @brief Function for registering cell- scheduler instance mapping
2064  *
2065  * @details
2066  *
2067  *     Function : RgSchMacCellRegReq
2068  *     
2069  *     This function shall be invoked whenever scheduler is done with the
2070  *     cell configuration successfully.
2071  *     This shall create a mapping of the cell, scheduler instance that
2072  *     is serving the cell and the unique identifier of the cell on the 
2073  *     scheduler at MAC. This mapping shall be used for further 
2074  *     communication to the scheduler instance for this cell.
2075  *     
2076  *           
2077  *  @param[in] Pst*                pst,
2078  *  @param[in] CmLteCellId         cellId,
2079  *  @param[in] RaRespReqInfo       raRespReq
2080  *  @return  S16
2081  *      -# ROK 
2082  **/
2083 S16 RgSchMacCellRegReq(Pst*  pst,RgInfCellReg* regReq)
2084 {
2085    Inst      inst;
2086    RgCellCb *cell = NULLP;
2087
2088    RG_IS_INST_VALID(pst->dstInst);
2089    inst = pst->dstInst - RG_INST_START;
2090    cell = rgCb[inst].cell;
2091
2092    if(NULLP == regReq)
2093    {
2094       return RFAILED;
2095    }
2096       
2097    if((cell  == NULLP) || (cell->cellId != regReq->cellId))
2098    {
2099       return RFAILED;
2100    }
2101    if(regReq->maxDlHqProcPerUe > RG_MAX_DL_HARQ_NUM) 
2102    {
2103       return RFAILED;
2104    }
2105    /* Initialize */
2106    cell->schInstMap.cellSapId = regReq->cellSapId;
2107    cell->schInstMap.schInst   = pst->srcInst;
2108    cell->maxDlHqProcPerUe = regReq->maxDlHqProcPerUe;
2109
2110    return ROK;
2111
2112 } /* end of RgSchMacCellRegReq */
2113
2114 /*Added Ue for Onging L2 Meas*/
2115 #ifdef LTE_L2_MEAS
2116 /*LTE_L2_MEAS_PHASE2*/
2117 S16 rgAddToL2MeasPerQci(RgCellCb  *cell,uint8_t qci)
2118 {
2119    S16        ret = ROK;        
2120    CmLList    *lnk;
2121    RgL2MeasCb *measCb;
2122    uint16_t   idx;
2123
2124    lnk = cell->l2mList.first;
2125    while(lnk != NULLP )
2126    {
2127       measCb = (RgL2MeasCb *)lnk->node;
2128       if(measCb->measReq.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
2129       {
2130          for(idx = 0;idx< measCb->measReq.t.prbReq.numQci;idx++)
2131          {
2132             if(measCb->measReq.t.prbReq.qci[idx] == qci)
2133             {
2134                break; /*exit from for loop*/
2135             } 
2136          }      
2137          if(idx == measCb->measReq.t.prbReq.numQci)
2138          {
2139             cell->qciArray[qci].mask = TRUE; 
2140             measCb->measReq.t.prbReq.qci[measCb->measReq.t.prbReq.numQci++] = qci;
2141          }              
2142       }           
2143       lnk = lnk->next;
2144    }  /* End of While*/
2145
2146
2147
2148    return (ret);
2149 }
2150
2151
2152 #endif
2153
2154 /**********************************************************************
2155  
2156          End of file
2157 **********************************************************************/