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