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