Removed ANSI from multiple folder Part - 1 [JIRA ID - ODUHIGH-249]
[o-du/l2.git] / src / 5gnrmac / rg_com.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Entry point functions
26   
27      File:     rg_com.c 
28   
29 **********************************************************************/
30
31 /** @file rg_com.c
32 @brief This module does processing related to handling of upper interface APIs 
33 invoked by RRC towards MAC.
34 */
35
36 static const char* RLOG_MODULE_NAME="MAC";
37 static int RLOG_FILE_ID=181;
38 static int RLOG_MODULE_ID=4096;
39
40 /* header include files -- defines (.h) */
41 #include "common_def.h"
42 #include "tfu.h"
43 #include "du_app_mac_inf.h"
44 #include "lrg.h"
45 #include "crg.h"
46 #include "rgu.h"
47 #include "rg_sch_inf.h"
48 #include "rg_env.h"
49 #include "rg.h"
50 #include "rg_err.h"
51
52 /* header/extern include files (.x) */
53 #include "tfu.x"
54 #include "lrg.x"
55 #include "crg.x"
56 #include "rgu.x"
57 #include "rg_sch_inf.x"
58 #include "rg_prg.x"       /* PRG interface typedefs*/
59 #include "rg.x"
60 #ifdef LTE_ADV
61 #include "rg_pom_scell.x"
62 #endif
63 /* local defines */
64 static S16 rgCOMHndlCfgReq ARGS((Inst inst,CrgCfg  *cfg, RgErrInfo *errInfo,Bool *isCfmRqrd,CrgCfgTransId transId));
65 static S16 rgCOMHndlRecfgReq ARGS((Inst inst,CrgRecfg *recfg, RgErrInfo *errInfo, \
66          CrgCfgTransId transId,Bool *isCfmRqrd));
67 static S16 rgCOMHndlDelReq ARGS((Inst inst,CrgDel *del, RgErrInfo *errInfo, Bool *isCfmRqrd, CrgCfgTransId transId));
68 static S16 rgCOMHndlResetReq ARGS((Inst inst,CrgRst *reset,RgErrInfo *errInfo));
69 /* local typedefs */
70  
71 /* local externs */
72  
73 /* forward references */
74
75 /**
76  * @brief Handler to handle config request from RRC to MAC.
77  *
78  * @details
79  *
80  *     Function: rgCOMCfgReq
81  *     
82  *     This API handles processing for config request from RRC to MAC. 
83  *     
84  *     Processing Steps:
85  *      - If configuration, process configuration request. Call rgCOMHndlCfgReq.
86  *      - else If re-configuration, process re-configuration request. 
87  *        Call rgCOMHndlRecfgReq.
88  *      - else If reset, process reset request. Call rgCOMHndlResetReq.
89  *      - else If delete, process delete request. Call rgCOMHndlDelReq.
90  *      - If successful, send confirmation to RRC. Call rgUIMCrgCfgCfm.
91  *      - If failed, FAIL.
92  *
93  *  @param[in]  Inst        inst
94  *  @param[in]  CrgCfgTransId transId
95  *  @param[in]  CrgCfgReqInfo *crgCfgReq
96  *  @return  S16
97  *      -# ROK 
98  *      -# RFAILED 
99  **/
100 S16 rgCOMCfgReq
101 (
102 Inst          inst,
103 CrgCfgTransId transId,
104 CrgCfgReqInfo *crgCfgReq
105 )
106 {
107    S16             ret;
108    uint8_t         cfmStatus = CRG_CFG_CFM_OK;
109    RgErrInfo       errInfo;
110    Bool            isCfmRqrd = TRUE;
111
112    /* Process Config/Reconfig/Delete request from RRC */
113    switch (crgCfgReq->action)
114    {
115       case CRG_CONFIG:
116          {
117             ret = rgCOMHndlCfgReq(inst,&crgCfgReq->u.cfgInfo, &errInfo,&isCfmRqrd, transId);
118             break;
119          }
120       case CRG_RECONFIG:
121          {
122             ret = rgCOMHndlRecfgReq(inst,&crgCfgReq->u.recfgInfo, &errInfo, transId, &isCfmRqrd);
123             break;
124          }
125          /* Start: LTEMAC_2.1_DEV_CFG */
126       case CRG_RESET:
127          {
128             ret = rgCOMHndlResetReq(inst,&crgCfgReq->u.rstInfo, &errInfo);
129             break;
130          }
131          /* End: LTEMAC_2.1_DEV_CFG */
132       case CRG_DELETE:
133          {
134             ret = rgCOMHndlDelReq(inst,&crgCfgReq->u.delInfo, &errInfo, &isCfmRqrd, transId);
135             break;
136          }
137       default:
138          {
139             RLOG1(L_ERROR, "Invalid configuration action %d",
140                      crgCfgReq->action);
141
142             ret = RFAILED;
143          }
144    }
145
146    if (ret != ROK)
147    {
148       cfmStatus = CRG_CFG_CFM_NOK;
149    }
150
151    /* When UeSCellCfg is present then confirmation will be sent later once
152       confirm from all SMAC are recved at PMAC. PMAC will send a consolidated
153       confirm to RRC.Handling the failure of PMAC for Ue Scell add*/
154 #ifdef LTE_ADV
155 if(TRUE == isCfmRqrd)
156    {
157 #endif
158       /* Send back confirmation status to RRC */
159       rgUIMCrgCfgCfm(inst,transId, cfmStatus); 
160 #ifdef LTE_ADV
161    }
162 #endif
163    RGDBGINFO(inst,(rgPBuf(inst), "CRG Configuration request processed\n"));
164    return (ret);
165 }  /* rgCOMCfgReq */
166 /**
167  * @brief Handler for processing Cell/Ue/Logical channel configuration request
168  * recieved from RRC.
169  *
170  * @details
171  *
172  *     Function: rgCOMHndlCfgReq
173  *     
174  *     This API handles processing of configuration request from RRC to MAC. 
175  *     
176  *     Processing Steps:
177  *        - Validate configuration request parameters at CFG module. 
178  *          Call rgCFGVldtCrgCellCfg, rgCFGVldtCrgUeCfg, rgCFGVldtCrgLcCfg 
179  *          for Cell, UE and Logical channel configuration respectively.
180  *        - If validated successfully, Call rgCFGCrgCellCfg, rgCFGCrgUeCfg, 
181  *          rgCFGCrgLcCfg for Cell, UE and Logical channel configuration 
182  *          respectively, else FAIL.
183  *
184  *  @param[in]  Inst        inst
185  *  @param[in]  CrgCfg    *cfg
186  *  @param[out] RgErrInfo *errInfo
187  *  @return  S16
188  *      -# ROK 
189  *      -# RFAILED 
190  **/
191 static S16 rgCOMHndlCfgReq
192 (
193 Inst             inst,
194 CrgCfg           *cfg,
195 RgErrInfo        *errInfo,
196 Bool             *isCfmRqrd,
197 CrgCfgTransId    transId
198 )
199 {
200    S16       ret;
201    RgCellCb  *cell = NULLP;
202    RgUeCb    *ue   = NULLP;
203
204    errInfo->errType = RGERR_COM_CFG_REQ;
205
206    /* Validate and process the configuration request */ 
207    switch (cfg->cfgType)
208    {
209       case CRG_CELL_CFG:
210       {
211          ret = rgCFGVldtCrgCellCfg(inst,&cfg->u.cellCfg,errInfo);
212          if (ret != ROK)
213          {
214               RLOG_ARG0(L_ERROR,DBG_CELLID,cfg->u.cellCfg.cellId, "Cell configuration validation FAILED\n");
215               return RFAILED;
216          }
217          ret = rgCFGCrgCellCfg(inst,&cfg->u.cellCfg, errInfo);
218          break;
219       }
220       case CRG_UE_CFG:
221       {
222          {
223             ret = rgCFGVldtCrgUeCfg(inst,&cfg->u.ueCfg, &cell, errInfo);
224             if (ret != ROK)
225             {
226                RLOG_ARG0(L_ERROR,DBG_CRNTI,cfg->u.ueCfg.crnti, "Ue configuration validation FAILED\n");
227                return RFAILED;
228             }
229             ret = rgCFGCrgUeCfg(inst,cell, &cfg->u.ueCfg, errInfo);
230          }
231          break;
232       }
233       case CRG_LCH_CFG:
234       {
235
236          ret = rgCFGVldtCrgLcCfg(inst,&cfg->u.lchCfg, &cell, &ue,errInfo);
237          if (ret != ROK)
238          {
239             
240             RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->u.cellCfg.cellId,
241                          "LC configuration validation FAILED: LC %d\n", cfg->u.lchCfg.lcId);
242             return RFAILED;
243          }
244          ret = rgCFGCrgLcCfg(inst,cell, ue, &cfg->u.lchCfg, errInfo,isCfmRqrd,transId);
245          break;
246       }
247       default:
248       {
249          RLOG1(L_ERROR, "Should never come here: cfgType %d",cfg->cfgType);
250          return RFAILED;
251       }
252    }
253
254    return (ret);
255 }  /* rgCOMHndlCfgReq */
256
257
258 /**
259  * @brief Handler for processing Cell/Ue/Logical channel re-configuration request
260  * recieved from RRC.
261  *
262  * @details
263  *
264  *     Function: rgCOMHndlRecfgReq
265  *     
266  *     This API handles processing of reconfiguration request from RRC to MAC. 
267  *     
268  *     Processing Steps:
269  *      - Validate reconfiguration request parameters at CFG module. Call 
270  *        rgCFGVldtCrgCellRecfg, rgCFGVldtCrgUeRecfg, rgCFGVldtCrgLchRecfg for 
271  *        Cell, UE and logical channel reconfiguration respectively.
272  *      - If validated, Call rgCFGCrgCellRecfg, rgCFGCrgUeRecfg, 
273  *        rgCFGCrgLchRecfg for Cell, UE and Logical channel re-configuration 
274  *        respectively else FAIL.
275  *
276  *  @param[in]  Inst        inst
277  *  @param[in]  CrgRecfg   *recfg
278  *  @param[out] RgErrInfo  *errInfo
279  *  @return  S16
280  *      -# ROK 
281  *      -# RFAILED 
282  **/
283 static S16 rgCOMHndlRecfgReq
284 (
285 Inst             inst,
286 CrgRecfg         *recfg,
287 RgErrInfo        *errInfo,
288 CrgCfgTransId    transId,
289 Bool             *isCfmRqrd
290 )
291 {
292    S16       ret;
293    RgCellCb  *cell = rgCb[inst].cell;
294    RgUeCb    *ue   = NULLP;
295    RgUlLcCb  *ulLc = NULLP;
296
297    errInfo->errType = RGERR_COM_RECFG_REQ;
298    
299    /* Validate and process the re-configuration request */ 
300    switch (recfg->recfgType)
301    {
302       case CRG_CELL_CFG:
303       {
304          ret = rgCFGVldtCrgCellRecfg(inst,&recfg->u.cellRecfg, &cell, errInfo);
305             if (ret != ROK) 
306             {
307                RLOG_ARG0(L_ERROR,DBG_CELLID,recfg->u.cellRecfg.cellId,
308                          "Cell Recfg Validation FAILED");
309                return RFAILED;
310             }
311          ret = rgCFGCrgCellRecfg(inst,cell, &recfg->u.cellRecfg, errInfo);
312          break;
313       }
314       case CRG_UE_CFG:
315       {
316          /*ccpu00126865 - Added as a part of RRC Reestablishment issue with MAC
317           * having a possibility of sending NOK */
318          if (recfg->u.ueRecfg.oldCrnti != recfg->u.ueRecfg.newCrnti)
319          {
320             errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_RECFG;
321             ret = ROK;
322          }    
323          else
324          {
325 #ifdef LTE_ADV
326          /* Check for isSCellCfgPres */
327          if(TRUE == recfg->u.ueRecfg.crgSCellCfg.isSCellCfgPres)
328          {
329             ret = rgFillAndAddSCellCfg(inst, cell, &recfg->u.ueRecfg, transId, isCfmRqrd);
330             if (ret != ROK)
331             {
332                RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Ue SCell configuration FAILED for inst [%d]\n",
333                         recfg->u.ueRecfg.oldCrnti, inst));
334                return RFAILED;
335             }
336
337          }
338          else
339          {
340 #endif /* LTE_ADV */
341             ret = rgCFGVldtCrgUeRecfg(inst,&recfg->u.ueRecfg, &cell, &ue, errInfo);
342             if ( ret != ROK)
343             {
344                RLOG_ARG1(L_ERROR,DBG_CELLID,recfg->u.ueRecfg.cellId,
345                       "Ue Re-configuration validation FAILED OLD CRNTI:%d",
346                       recfg->u.ueRecfg.oldCrnti);
347                return RFAILED;
348             }
349             ret = rgCFGCrgUeRecfg(inst,cell, ue, &recfg->u.ueRecfg, errInfo);
350          }
351 #ifdef LTE_ADV
352          }
353 #endif
354          break;
355       }
356       case CRG_LCH_CFG:
357       {
358          ret = rgCFGVldtCrgLcRecfg(inst,&recfg->u.lchRecfg, &cell, &ue, 
359                &ulLc, errInfo);
360          if (ret != ROK)
361          {
362             RLOG_ARG2(L_ERROR,DBG_CELLID,recfg->u.lchRecfg.cellId,
363                       "LC Re-configuration validation FAILED LCID:%d CRNTI:%d",
364                       recfg->u.lchRecfg.lcId,recfg->u.lchRecfg.crnti);
365             return RFAILED;
366          }
367
368 #ifdef LTE_ADV
369          /*ERAB- multicell fix*/
370          memcpy( &(ue->cfgCfmInfo.transId), &transId,
371                sizeof(CrgCfgTransId));
372 #endif
373          ret = rgCFGCrgLcRecfg(inst,cell, ue, ulLc,
374                &recfg->u.lchRecfg, errInfo,isCfmRqrd);
375
376          break;
377       }
378       default:
379       {
380          RLOG1(L_ERROR, "Should never come here: recfgType %d",
381                   recfg->recfgType);
382          return RFAILED;
383       }
384    }
385
386    return (ret);
387 }  /* rgCOMHndlRecfgReq */
388
389 /*Start: LTEMAC_2.1_DEV_CFG */
390 /**
391  * @brief Handler for processing UE Reset request recieved from RRC.
392  *
393  * @details
394  *
395  *     Function: rgCOMHndlResetReq
396  *     
397  *     This API handles processing of Reset request from RRC to MAC. 
398  *     
399  *     Processing Steps:
400  *      - Validate reset request parameters at CFG module. Call 
401  *        rgCFGVldtCrgUeReset for UE reset.
402  *      - If validated, Call rgCFGCrgUeReset for UE reset, else FAIL.
403  *
404  *  @param[in]  Inst        inst
405  *  @param[in]  CrgRst     *reset
406  *  @param[out] RgErrInfo  *errInfo
407  *  @return  S16
408  *      -# ROK 
409  *      -# RFAILED 
410  **/
411 static S16 rgCOMHndlResetReq
412 (
413 Inst       inst,
414 CrgRst     *reset,
415 RgErrInfo  *errInfo
416 )
417 {
418    /* Fix : ccpu00126865: ignore CRG reset. Let SCH trigger it. */
419    
420    errInfo->errCause = RGERR_NONE;
421    RGDBGINFO(inst,(rgPBuf(inst), "CRG UE Reset processed \n"));
422    return ROK;
423 }  /* rgCOMHndlResetReq */
424 /*End: LTEMAC_2.1_DEV_CFG */
425
426 /**
427  * @brief Handler for processing Cell/UE/Logical channel delete request
428  * recieved from RRC.
429  *
430  * @details
431  *
432  *     Function: rgCOMHndlDelReq
433  *     
434  *     This API handles processing of delete request from RRC to MAC. 
435  *     
436  *     Processing Steps:
437  *        - Fetch corresponding control block and pass it to CFG module.
438  *        - If control block does not exist, FAIL.
439  *
440  *  @param[in]  Inst        inst
441  *  @param[in]  CrgDel    *del
442  *  @param[out] RgErrInfo *errInfo
443     @param[out] Bool      *isCfmRqrd
444  *  @return  S16
445  *      -# ROK 
446  *      -# RFAILED 
447  **/
448 static S16 rgCOMHndlDelReq
449 (
450 Inst        inst,
451 CrgDel      *del,
452 RgErrInfo   *errInfo,
453 Bool        *isCfmRqrd,
454 CrgCfgTransId transId
455 )
456 {
457
458    S16      ret;
459    volatile uint32_t   startTime=0;
460
461    errInfo->errType = RGERR_COM_DEL_REQ;
462    
463    /* Process the delete request */ 
464    switch (del->delType)
465    {
466       case CRG_CELL_CFG:
467       {
468          ret = rgCFGCrgCellDel(inst,del, errInfo);
469          break;
470       }
471       case CRG_UE_CFG:
472       {
473          /*starting Task*/ 
474          SStartTask(&startTime,PID_MAC_UE_DEL);
475
476
477          ret = rgCFGCrgUeDel(inst,del, errInfo);
478          RGDBGINFONEW(inst,(rgPBuf(inst),"[%d] Delete UE Done \n", del->u.ueDel.crnti));
479
480          /*stoping Task*/ 
481          SStopTask(startTime,PID_MAC_UE_DEL);
482
483          break;
484       }
485       case CRG_LCH_CFG:
486       {
487          ret = rgCFGCrgLcDel(inst,del, errInfo,isCfmRqrd, transId);
488          break;
489       }
490       default:
491       {
492          RLOG1(L_ERROR, "Should never come here: delType %d",
493                   del->delType);
494          return RFAILED;
495       }
496    }
497
498    return (ret);
499 }  /* rgCOMHndlDelReq */
500
501 #ifdef LTE_ADV
502 /**
503  * @brief Handler for the SCell configuration request from RRC to MAC.
504  *
505  * @details
506  *
507  *     Function : RgPrgPMacSMacUeSCellCfgReq
508  *
509  *     Processing Steps:
510  *      - Allocate and create UE control block.
511  *      - Update UE control block with the values recieved in the
512  *        configuration.
513  *      - If successful, add the control block to hash list of UEs for the cell
514  *        else Rollback and FAIL.
515  *
516  *  @param[in]  Pst          *pst
517  *  @param[in]  RgPrgUeSCellCfgInfo *ueSCellCb
518  *  @return  S16
519  *      -# ROK
520  *      -# RFAILED
521  **/
522 S16 RgPrgPMacSMacUeSCellCfgReq
523 (
524 Pst         *pst,    
525 RgPrgUeSCellCfgInfo *ueSCellCb
526 )
527 {
528    RgPrgCfgCfmInfo  cfgCfm;
529    Inst             inst = pst->dstInst;
530    RgCellCb         *cell = rgCb[inst].cell;
531    S16              ret;
532    Pst              cfmPst;    
533
534    
535    RGDBGPRM(inst,(rgPBuf(inst),
536             "APPLYING CRG UE SCELL CONFIG: cellId %d ueId %d\n",
537             ueSCellCb->cellId, ueSCellCb->ueId));
538
539    cfgCfm.ueId = ueSCellCb->ueId;
540    cfgCfm.sCellId = ueSCellCb->cellId;
541    cfgCfm.status = PRG_CFG_CFM_OK;
542    cfgCfm.event = EVTPRGUESCELLCFGCFM;
543    rgGetPstToInst(&cfmPst, inst, pst->srcInst);
544
545   ret = rgUtlVltdAddSCellCfg(ueSCellCb, cell, inst);
546   if(ret != ROK)
547   {
548      RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Crg Ue SCell failed:\
549               cellId %d\n", ueSCellCb->ueId, ueSCellCb->cellId));
550      /* Set status as Not OK*/
551      cfgCfm.status = PRG_CFG_CFM_NOK;
552   }
553   else
554   {
555      ret = rgCfgAddUeSCellCfg(inst, ueSCellCb, cell);
556      if(ret != ROK)
557      {
558         RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Crg Ue SCell failed:\
559                  cellId %d\n", ueSCellCb->ueId, ueSCellCb->cellId));
560         /* Set status as Not OK*/
561         cfgCfm.status = PRG_CFG_CFM_NOK;
562      }
563   }
564   
565   RGDBGINFONEW(inst,(rgPBuf(inst), "[%d]Crg Ue SCell Config done:\
566            cellId %d\n", ueSCellCb->ueId, ueSCellCb->cellId));
567
568   /* Send positive confirmation to primary cell*/
569   RgPrgSMacPMacCfg(&cfmPst, &cfgCfm);
570   return ROK;
571 }  /* RgPrgPMacSMacUeSCellCfgReq */
572
573 /**
574  * @brief Hander for config confim from sec MAC to Pri mac for Add Scell Cfg.
575  *
576  * @details
577  *
578  *     Function : RgPrgSMacPMacCfgCfm
579  *
580  *     Processing Steps:
581  *      - Allocate and create UE control block.
582  *      - If cfm event is lch recfg then send the confirmation to RRC for
583  *        that event.
584  *      - If cfm event is Scell addition then send the confirmation to RRC for
585  *        the same.
586  *         - Update UE control block with the values received in the
587  *           configuration.
588  *         - If successful, add the control block to hash list of UEs for the cell
589  *           else Rollback and FAIL.
590  *
591  *  @param[in]  Inst        dstMacInst
592  *  @param[in]  RgUrSCellCb  *ueSCellCb
593  *  @return  S16
594  *      -# ROK
595  *      -# RFAILED
596  **/
597 S16 RgPrgSMacPMacCfgCfm
598 (
599 Pst             *pst,    
600 RgPrgCfgCfmInfo *cfgCfm
601 )
602 {
603    Inst      inst = pst->dstInst;
604    RgCellCb *cell;
605    RgUeCb   *ue;
606
607    RG_IS_INST_VALID(inst);
608
609    RGDBGPRM(pst->dstInst,(rgPBuf(pst->dstInst),
610             "Config Confirm Rcvd from Inst %d ueId %d cellId %d\n",
611             pst->srcInst, cfgCfm->ueId, cfgCfm->cellId));
612
613    cell = rgCb[inst].cell;
614
615    if ((ue = rgDBMGetUeCb(cell, cfgCfm->ueId)) == NULLP)
616    {
617       RGDBGERRNEW(inst,(rgPBuf(inst), 
618                "[%d]Ue does not exist\n", cfgCfm->ueId));
619       return RFAILED;
620    }
621    switch(cfgCfm->event)
622    {
623       /* cfgCount increment for all cases */
624       case EVTPRGUESCELLLCHMODCFM:
625       case EVTPRGUESCELLLCHDELCFM:
626       case EVTPRGUESCELLLCHADDCFM:
627          {
628             ue->cfgCfmInfo.cfgCfgCount++;
629             ue->cfgCfmInfo.mask |= cfgCfm->status;
630             if(ue->cfgCfmInfo.numSCells == ue->cfgCfmInfo.cfgCfgCount)
631             {
632                ue->cfgCfmInfo.cfgCfgCount = 0;
633                /* Send back confirmation status to RRC */
634                rgUIMCrgCfgCfm(inst, ue->cfgCfmInfo.transId, ue->cfgCfmInfo.mask);
635                ue->cfgCfmInfo.mask = 0;
636                RGDBGINFO(inst,(rgPBuf(inst), "CRG Configuration request processed\n"));
637             }
638          }
639          break;
640       case EVTPRGUESCELLCFGCFM:
641          {
642             /*Commit Added SCell info to UeCb as we confirmation received */
643             if(PRG_CFG_CFM_OK == cfgCfm->status)
644             {
645                ue->sCelInfo[pst->srcInst].isSCellAdded = TRUE;
646                ue->sCelInfo[pst->srcInst].macInst = pst->srcInst;
647                ue->sCelInfo[pst->srcInst].sCellId = cfgCfm->sCellId;
648             }
649
650             ue->cfgCfmInfo.cfgCfgCount++;
651             ue->cfgCfmInfo.mask |= cfgCfm->status;
652             if(ue->cfgCfmInfo.numSCells == ue->cfgCfmInfo.cfgCfgCount)
653             {
654                ue->cfgCfmInfo.cfgCfgCount = 0;
655                /* Send back confirmation status to RRC */
656                rgUIMCrgCfgCfm(inst, ue->cfgCfmInfo.transId, ue->cfgCfmInfo.mask);
657                ue->cfgCfmInfo.mask = 0;
658                RGDBGINFO(inst,(rgPBuf(inst), "CRG Configuration request processed\n"));
659             }
660          }
661          break;
662       default:
663          {
664             RGDBGERRNEW(inst,(rgPBuf(inst), "Invalid configuration confirm event %d\n",
665                      cfgCfm->event));
666
667             return RFAILED;
668          }
669
670    }
671    return ROK;
672 }  /* RgPrgSMacPMacCfgCfm */
673
674 /**
675  * @brief Function for handling UE release for SCELL
676  * triggered from Primary Cell
677  *
678  * @details
679  *
680  *     Function : RgPrgPMacSMacUeSCellDelReq
681  *     
682  *        - This Function should be invoked by PCell of UE
683  *        - Remove the UE context from SCELL corresponding to rnti.
684  *           
685  *  @param[in] Pst                 *pst
686  *  @param[in] RgPrgUeSCellDelInfo *ueSCellDelInfo
687  *  @return  ROK is SUCCESS 
688  **/
689 S16 RgPrgPMacSMacUeSCellDelReq
690 (
691 Pst                 *pst,
692 RgPrgUeSCellDelInfo *ueSCellDelInfo
693 )
694 {
695    Inst        inst     = pst->dstInst - RG_INST_START;
696    RgCellCb    *sCell   = rgCb[inst].cell;
697    RgUeCb      *sCellUe = NULLP;
698
699    /* Checking for cell Cb because in case of shutdownReq it is possible that
700     * cell is already deleted for this cell*/
701    if(sCell == NULLP)
702    {
703       return ROK;
704    }
705    /* Retrive the UeCb from sec cell*/
706    if ((sCellUe = rgDBMGetUeCb(sCell, ueSCellDelInfo->ueId)) == NULLP)
707    {
708       RGDBGERRNEW(inst, (rgPBuf(inst), "[%d]UE:does not exist in sCell(%d)\n",
709                ueSCellDelInfo->ueId, sCell->cellId));
710       return RFAILED;
711    }
712    
713    /*PMAC_Reest: ueId and newRnti is different that means its a UeId change
714     *request from PMAC to SMAC during PCell reestablishment
715     */
716   if(ueSCellDelInfo->ueId != ueSCellDelInfo->newRnti)
717   {
718      /* Retrive the UeCb from sec cell*/
719      if ((rgDBMGetUeCb(sCell, ueSCellDelInfo->newRnti)) != NULLP)
720      {
721         RGDBGERRNEW(inst, (rgPBuf(inst), "[%d]UE:UE context already exist in\
722                  sCell(%d)",ueSCellDelInfo->newRnti, sCell->cellId));
723         return RFAILED;
724      }
725
726      rgDBMDelUeCb(sCell, sCellUe);
727
728      sCellUe->ueId = ueSCellDelInfo->newRnti;
729
730      /* Reset harq procs*/
731      rgDHMUeReset(sCell, &sCellUe->dl.hqEnt);
732
733      rgDBMInsUeCb(sCell, sCellUe);
734   }
735   else
736   {
737      rgDBMDelUeCb(sCell, sCellUe);
738      rgCFGFreeUeCb(sCell, sCellUe);
739   }
740
741    return ROK;
742 } /* RgPrgPMacSMacUeSCellDelReq */
743 #endif /*LTE_ADV */
744 /**********************************************************************
745  
746          End of file
747 **********************************************************************/