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