[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-483] Memeory related fix in FDD and TDD mode
[o-du/l2.git] / src / 5gnrmac / rg_pom_scell.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_pom_scell.c 
28   
29 **********************************************************************/
30
31 /** @file rg_pom_scell.c
32 @brief This module does processing related to handling of SCell related function.
33 */
34
35 /* header include files -- defines (.h) */
36 #include "common_def.h"
37 #include "lrg.h"
38 #include "crg.h"
39 #include "rgu.h"
40 #include "tfu.h"
41 #include "rg_sch_inf.h"
42 #include "rg_prg.h"       /* PRG interface includes*/
43 #include "rg_env.h"
44 #include "rg.h"
45 #include "rg_err.h"
46
47 /* header/extern include files (.x) */
48 #include "lrg.x"
49 #include "crg.x"
50 #include "rgu.x"
51 #include "tfu.x"
52 #include "rg_sch_inf.x"
53 #include "rg_prg.x"       /* PRG interface typedefs*/
54 #include "du_app_mac_inf.h"
55 #include "rg.x"
56 #ifdef LTE_ADV
57 #include "rg_pom_scell.x"
58 static S16 rgPomVldtSCellDedLchCfg ARGS((
59             Inst                       inst,
60             RgPrgUeSCellLchAddInfo     *lcCfg,
61             RgCellCb                   **cell,
62             RgUeCb                     **ue
63           ));
64 static S16 rgPomUeSCellDedLcCfg ARGS((RgCellCb                   *cell,
65                                        RgUeCb                     *ue,
66                                        RgPrgUeSCellLchAddInfo     *lcCfg
67                                      ));
68 /**
69  * @brief Handler for the Lch reconfiguration request from PMAC to SMAC.
70  *
71  * @details
72  *
73  *     Function : RgPrgPMacSMacUeSCellLchModReq
74  *
75  *     Processing Steps:
76  *      - calls the function for validating cell, uecb and lch sent by PMAC
77  *      - Updates the lch recfg into ueCb.
78  *      - If successful, add the control block to hash list of UEs for the cell
79  *        else Rollback and FAIL.
80  *
81  *  @param[in]  Pst                    *pst
82  *  @param[in]  RgPrgUeSCellLchModInfo *lchCfgCb
83  *  @return  S16
84  *      -# ROK
85  *      -# RFAILED
86  **/
87 S16 RgPrgPMacSMacUeSCellLchModReq
88 (
89 Pst                      *pst,    
90 RgPrgUeSCellLchModInfo   *lchCfgCb
91 )
92 {
93    RgPrgCfgCfmInfo  cfgCfm;
94    Inst             inst = pst->dstInst;
95    RgCellCb         *cell;
96    S16              ret;
97    Pst              cfmPst;    
98    RgUeCb           *ue;
99    RgUlLcCb         *ulLc;
100
101    RGDBGPRM(inst,(rgPBuf(inst),
102             "APPLYING CRG UE SCELL CONFIG: cellId %d ueId %d lcId %d lcgId %d\n",
103          lchCfgCb->cellId, lchCfgCb->crnti,lchCfgCb->lcId,lchCfgCb->ulLchRecfg.lcgId));
104
105    cfgCfm.ueId = lchCfgCb->crnti;
106    cfgCfm.sCellId = lchCfgCb->cellId;
107    cfgCfm.status = PRG_CFG_CFM_OK;
108    cfgCfm.event = EVTPRGUESCELLLCHMODCFM; 
109    rgGetPstToInst(&cfmPst, inst, pst->srcInst);
110
111    ret = rgPomVltdModLch(inst,lchCfgCb, &cell, &ue,&ulLc);
112   if(ret != ROK)
113   {
114      RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMAC SCell Lc Cfg failed:\
115               cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
116      /* Set status as Not OK*/
117      cfgCfm.status = PRG_CFG_CFM_NOK;
118   }
119   else
120   {
121      ret = rgPomUeSCellLcMod(inst, ue, ulLc, lchCfgCb);
122      if(ret != ROK)
123      {
124         RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMac SCell lc cfg failed:\
125                  cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
126         /* Set status as Not OK*/
127         cfgCfm.status = PRG_CFG_CFM_NOK;
128      }
129   }
130   
131   RGDBGINFONEW(inst,(rgPBuf(inst), "[%d] Scell Lch Config done:\
132            cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
133
134   /* Send positive confirmation to primary cell*/
135   RgPrgSMacPMacCfg(&cfmPst, &cfgCfm);
136   return ROK;
137 }  /* RgPrgPMacSMacUeSCellLchModReq */
138
139
140 /**
141  * @brief A wrapper class to send the LCH Del req from PMAC to SMAC
142  *
143  * @details
144  *
145  *     Function : rgPomSndUeSCellLchDelToSmac 
146  *
147  *     Processing Steps:
148  *      - Retrieve the cell control block.
149  *      - If successful,
150  *        - Validate the range of values received in
151  *          delete request.
152  *        - Checks if the Ue has any scell added.
153  *        - If validated successfully,
154  *          - if SCells have been added ,then 
155  *            send the lchDel structure to update the same values to SMAC.
156  *        - Return ROK.
157  *      - Else return RFAILED.
158  *
159  *  @param[in]  Inst          inst
160  *  @param[in]  CrgDel        *lcDel
161  *  @param[in]  Bool          *isCfmRqrd
162  *  @return  S16
163  *      -# ROK
164  *      -# RFAILED
165  **/
166 S16 rgPomSndUeSCellLchDelToSmac
167 (
168 Inst            inst,
169 CrgDel          *lcDel,
170 Bool            *isCfmRqrd
171 )
172 {
173    uint8_t                    idx = 0;
174    Inst                       dstMacInst;
175    Pst                        dstInstPst;
176    RgPrgUeSCellLchDelInfo     delLcCb;
177    RgCellCb                   *cell;
178    RgUeCb                     *ue;
179
180   /* Fetch the Active cell */
181    if(((cell = rgCb[inst].cell) == NULLP) ||
182        (cell->cellId != lcDel->u.lchDel.cellId))
183    {
184       RGDBGERRNEW(inst,(rgPBuf(inst), 
185                        "[%d]Active Cell does not exist %d\n",
186                                   lcDel->u.lchDel.crnti, lcDel->u.lchDel.cellId));
187       return RFAILED;
188    }
189
190    RGDBGPRM(inst,(rgPBuf(inst), 
191             "Filling SCell LCh Config : cellId %d ueId %d\n",
192             cell->cellId, cell->ueId));
193
194    if ((ue = rgDBMGetUeCb(cell, lcDel->u.lchDel.crnti)) == NULLP)
195    {
196       RGDBGERRNEW(inst,(rgPBuf(inst), 
197                "[%d]Ue does not exist\n", lcDel->u.lchDel.crnti));
198       return RFAILED;
199    }
200    for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
201    {
202       if(TRUE == ue->sCelInfo[idx].isSCellAdded)
203       {
204          dstMacInst = ue->sCelInfo[idx].macInst - RG_INST_START;
205          delLcCb.cellId = ue->sCelInfo[idx].sCellId;
206          delLcCb.crnti = lcDel->u.lchDel.crnti;
207          delLcCb.lcId = lcDel->u.lchDel.lcId;
208          delLcCb.dir = lcDel->u.lchDel.dir;
209
210       /* Get post structure of the cell to whom delLcCb needs to be sent
211        * And then send the lch recfg based on Mac instances */
212          rgGetPstToInst(&dstInstPst, inst, dstMacInst);
213          RgPrgPMacSMacUeScellLchDel(&dstInstPst, &delLcCb);
214          *isCfmRqrd = FALSE;
215       }
216    }
217    return ROK;
218 }
219
220
221 /**
222  * @brief A wrapper class to send the LCH reconfig req from PMAC to SMAC
223  *
224  * @details
225  *
226  *     Function : rgPomSndUeSCellLchModToSmac 
227  *
228  *     Processing Steps:
229  *      - Retrieve the cell control block.
230  *      - If successful,
231  *        - Validate the range of re-configured values recieved in
232  *          re-configuration request.
233  *        - Checks if the Ue has any scell added.
234  *        - If validated successfully,
235  *          - if SCells have been added ,then 
236  *            send the lchRecfg structure to update the same values to SMAC.
237  *        - Return ROK.
238  *      - Else return RFAILED.
239  *
240  *  @param[in]  Inst          inst
241  *  @param[in]  RgCellCb      *cell
242     @param[in]  RgUeCb        *ue,
243     @param[in]  CrgLchRecfg   *lchRecfg,
244     @param[in]  Bool          *isCfmRqrd
245  *  @return  S16
246  *      -# ROK
247  *      -# RFAILED
248  **/
249 S16 rgPomSndUeSCellLchModToSmac
250 (
251 Inst           inst,
252 RgCellCb       *cell,
253 RgUeCb         *ue,
254 CrgLchRecfg    *lchRecfg,
255 Bool           *isCfmRqrd
256 )
257 {
258    uint8_t                   idx = 0;
259    Inst                      dstMacInst;
260    RgPrgUeSCellLchModInfo    lchCfgCb; 
261    Pst                       dstInstPst;
262
263    for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
264    {
265       if(TRUE == ue->sCelInfo[idx].isSCellAdded)
266       {
267          dstMacInst = ue->sCelInfo[idx].macInst - RG_INST_START;
268          lchCfgCb.cellId = ue->sCelInfo[idx].sCellId;
269          lchCfgCb.crnti = lchRecfg->crnti;
270          lchCfgCb.lcId = lchRecfg->lcId;
271          lchCfgCb.ulLchRecfg.lcgId = lchRecfg->ulRecfg.lcgId;
272
273       /* Get post structure of the cell to whom lchCfgCb needs to be sent
274        * And then send the lch recfg based on Mac instances */
275          rgGetPstToInst(&dstInstPst, inst, dstMacInst);
276          RgPrgPMacSMacUeScellLchMod(&dstInstPst, &lchCfgCb);
277          *isCfmRqrd = FALSE;
278       }
279    }
280    return ROK;
281 }
282
283 /**
284  * @brief A wrapper class to send the LCH config req from PMAC to SMAC
285  *
286  * @details
287  *
288  *     Function : rgPomSndUeSCellLchAddToSmac
289  *
290  *     Processing Steps:
291  *        - Checks if the Ue has any scell added.
292  *          - if SCells have been added ,then 
293  *            send the lchCfgCb structure to update the same values to SMAC.
294  *        - Return ROK.
295  *      - Else return RFAILED.
296  *
297  *  @param[in]  Inst          insg
298  *
299  *  @param[in]  RgCellCb      *cell
300  *  @paran[in]  RgUeCb        *ue
301  *  @paran[in]  CrgLchCfg     *lchCfg
302  *  @paran[in]   Bool         *isCfmRqrd
303  *  @return  S16
304  *      -# ROK
305  *      -# RFAILED
306  **/
307 S16 rgPomSndUeSCellLchAddToSmac
308 (
309 Inst           inst,
310 RgCellCb       *cell,
311 RgUeCb         *ue,
312 CrgLchCfg      *lchCfg,
313 Bool           *isCfmRqrd
314 )
315 {
316    uint8_t                   idx = 0;
317    Inst                      dstMacInst;
318    RgPrgUeSCellLchAddInfo    lchCfgCb; 
319    Pst                       dstInstPst;
320
321    for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
322    {
323       if(TRUE == ue->sCelInfo[idx].isSCellAdded)
324       {
325          dstMacInst = ue->sCelInfo[idx].macInst - RG_INST_START;
326          lchCfgCb.cellId = ue->sCelInfo[idx].sCellId;
327          lchCfgCb.crnti =  lchCfg->crnti;
328          lchCfgCb.lcId = lchCfg->lcId;
329          lchCfgCb.lcType = lchCfg->lcType;
330          lchCfgCb.dir = lchCfg->dir;
331          lchCfgCb.dlInfo.dlTrchType = lchCfg->dlInfo.dlTrchType;
332          lchCfgCb.ulInfo.ulTrchType = lchCfg->ulInfo.ulTrchType;
333          lchCfgCb.ulInfo.lcgId = lchCfg->ulInfo.lcgId;
334 #ifdef LTE_L2_MEAS
335          lchCfgCb.qci = lchCfg->qci;
336 #endif /* LTE_L2_MEAS */
337
338       /* Get post structure of the cell to whom lchCfgCb needs to be sent
339        * And then send the lch recfg based on Mac instances */
340          rgGetPstToInst(&dstInstPst, inst, dstMacInst);
341          RgPrgPMacSMacUeScellLchAdd(&dstInstPst, &lchCfgCb);
342          *isCfmRqrd = FALSE;
343       }
344    }
345    return ROK;
346 } /* rgPomSndUeSCellLchAddToSmac */
347
348 /**
349  * @brief Handler for the Lch delete request from PMAC to SMAC.
350  *
351  * @details
352  *
353  *     Function : RgPrgPMacSMacUeSCellLchDelReq
354  *
355  *     Processing Steps:
356  *      - calls the function for validating cell, uecb and Lch sent by PMAC
357  *      - If successful, delete the logical channel 
358  *        else Rollback and FAIL.
359  *
360  *  @param[in]  Pst                    *pst
361  *  @param[in]  RgPrgUeSCellLchDelInfo *lchCfgCb
362  *  @return  S16
363  *      -# ROK
364  *      -# RFAILED
365  **/
366 S16 RgPrgPMacSMacUeSCellLchDelReq
367 (
368 Pst                       *pst,    
369 RgPrgUeSCellLchDelInfo    *delLcCb
370 )
371 {
372    RgPrgCfgCfmInfo  cfgCfm;
373    Inst             inst = pst->dstInst;
374    RgCellCb         *cell;
375    S16              ret;
376    Pst              cfmPst;    
377    RgUeCb           *ue;
378    RgUlLcCb         *ulLc;
379    RgDlLcCb         *dlLc;
380
381    RGDBGPRM(inst,(rgPBuf(inst),
382             "APPLYING CRG UE SCELL CONFIG: cellId %d ueId %d\n",
383          lchCfgCb->cellId, lchCfgCb->crnti));
384
385    cfgCfm.ueId = delLcCb->crnti;
386    cfgCfm.sCellId = delLcCb->cellId;
387    cfgCfm.status = PRG_CFG_CFM_OK;
388    cfgCfm.event = EVTPRGUESCELLLCHDELCFM; 
389    rgGetPstToInst(&cfmPst, inst, pst->srcInst);
390
391    ret = rgPomVltdDelLch(inst,delLcCb, &cell, &ue,&ulLc,&dlLc);
392   if(ret != ROK)
393   {
394      RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMAC SCell Lc Cfg failed:\
395               cellId %d\n", delLcCb->crnti, delLcCb->cellId));
396      /* Set status as Not OK*/
397      cfgCfm.status = PRG_CFG_CFM_NOK;
398   }
399   else
400   {
401      ret = rgPomUeSCellLcDel(inst, delLcCb, ue, ulLc,dlLc);
402      if(ret != ROK)
403      {
404         RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMac SCell lc cfg failed:\
405                  cellId %d\n", delLcCb->crnti, delLcCb->cellId));
406         /* Set status as Not OK*/
407         cfgCfm.status = PRG_CFG_CFM_NOK;
408      }
409   }
410   
411   RGDBGINFONEW(inst,(rgPBuf(inst), "[%d] Scell Lch Config done:\
412            cellId %d\n", delLcCb->crnti, delLcCb->cellId));
413
414   /* Send positive confirmation to primary cell*/
415   RgPrgSMacPMacCfg(&cfmPst, &cfgCfm);
416   return ROK;
417 }  /* RgPrgPMacSMacUeSCellLchDelReq */
418
419
420 /**
421  * @brief Handler for the Lch configuration request from PMAC to SMAC.
422  *
423  * @details
424  *
425  *     Function : RgPrgPMacSMacUeSCellLchAddReq
426  *
427  *     Processing Steps:
428  *      - calls the function for validating cell, uecb and Lch sent by PMAC
429  *      - Updates the lch recfg into ueCb.
430  *      - If successful, add the control block to hash list of UEs for the cell
431  *        else Rollback and FAIL.
432  *
433  *  @param[in]  Pst                 *pst
434  *  @param[in]  RgPrgLchRecfgInfo   *lchCfgCb
435  *  @return  S16
436  *      -# ROK
437  *      -# RFAILED
438  **/
439 S16 RgPrgPMacSMacUeSCellLchAddReq
440 (
441 Pst                      *pst,    
442 RgPrgUeSCellLchAddInfo   *lchCfgCb
443 )
444 {
445    RgPrgCfgCfmInfo   cfgCfm;
446    Inst              inst = pst->dstInst;
447    RgCellCb          *cell;
448    S16               ret;
449    Pst               cfmPst;    
450    RgUeCb            *ue;
451
452    RGDBGPRM(inst,(rgPBuf(inst),
453             "APPLYING UE SCELL CONFIG AT SMAC : cellId %d ueId %d\n",
454          lchCfgCb->cellId, lchCfgCb->crnti));
455
456    cfgCfm.ueId = lchCfgCb->crnti;
457    cfgCfm.sCellId = lchCfgCb->cellId;
458    cfgCfm.status = PRG_CFG_CFM_OK;
459    cfgCfm.event = EVTPRGUESCELLLCHADDCFM; 
460    rgGetPstToInst(&cfmPst, inst, pst->srcInst);
461
462    ret = rgPomVldtAddLch(inst,lchCfgCb, &cell, &ue);
463   if(ret != ROK)
464   {
465      RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMAC SCell Lc Cfg failed:\
466               cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
467      /* Set status as Not OK*/
468      cfgCfm.status = PRG_CFG_CFM_NOK;
469   }
470   else
471   {
472      ret = rgPomUeSCellLcAdd(inst, cell, ue, lchCfgCb);
473      if(ret != ROK)
474      {
475         RGDBGERRNEW(inst,(rgPBuf(inst), "[%d] SMac SCell lc cfg failed:\
476                  cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
477         /* Set status as Not OK*/
478         cfgCfm.status = PRG_CFG_CFM_NOK;
479      }
480   }
481   
482   RGDBGINFONEW(inst,(rgPBuf(inst), "[%d] Scell Lch Config done:\
483            cellId %d\n", lchCfgCb->crnti, lchCfgCb->cellId));
484
485   /* Send positive confirmation to primary cell*/
486   RgPrgSMacPMacCfg(&cfmPst, &cfgCfm);
487   return ROK;
488 }  /* RgPrgPMacSMacUeSCellLchAddReq */
489 /**
490  * @brief Validates the logical channel configuration request from PMAC to SMAC.
491  *
492  * @details
493  *
494  *     Function : rPommVldtAddLch
495  *
496  *     Processing Steps:
497  *      - Validate the logical channel configuration request from PMAC to
498  *        SMAC : validate if configured values are within the range.
499  *      - If validated successfully,
500  *        - Return ROK and pointer to cell and UE for dedicated logical channels.
501  *      - Else 
502  *        - Return RFAILED.
503  *
504  *  @param[in]  Inst                     inst
505  *  @param[in]  RgPrgUeSCellLchAddInfo   *lcCfg
506  *  @param[out] RgCellCb                 **cell
507  *  @param[out] RgUeCb                   **ue
508  *  @return  S16
509  *      -# ROK
510  *      -# RFAILED
511  **/
512 S16 rgPomVldtAddLch
513 (
514 Inst                    inst, 
515 RgPrgUeSCellLchAddInfo  *lcCfg,
516 RgCellCb                **cell,
517 RgUeCb                  **ue
518 )
519 {
520
521    RGDBGPRM(inst,(rgPBuf(inst), "VALIDATE SMAC LC CONFIG: cellId %d ueId %d lcId %d\
522             cell %p ue %p\n", lcCfg->cellId, lcCfg->crnti, lcCfg->lcId,
523             (void*)*cell, (void*)*ue));
524
525    if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
526    {
527       /* Dedicated logical channels */
528       if ((rgPomVldtSCellDedLchCfg(inst,lcCfg, cell, ue)) != ROK)
529       {
530          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UEID Validation for dedicated LC failed\n",
531                   lcCfg->crnti));
532          return RFAILED;
533       }
534    }
535    else
536    {
537       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UEID Invalid logical channel type %d\n",\
538                lcCfg->crnti, lcCfg->lcType));
539       return RFAILED;
540    }
541 #ifdef LTE_L2_MEAS
542    if ( lcCfg->qci <  RG_QCI_MIN ||
543         lcCfg->qci >  RG_QCI_MAX
544       )
545    {
546       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UEID Invalid qci %x\n",
547                lcCfg->crnti, lcCfg->qci));
548       return RFAILED;
549    }
550    /*validate qci */
551 #endif /*LTE_L2_MEAS */
552
553    RGDBGINFONEW(inst,(rgPBuf(inst),"[%d]UEID CRG LCconfig validation done:cellId:%d lcId:%d\n",
554             lcCfg->crnti, lcCfg->cellId, lcCfg->lcId));
555    return ROK;
556 }
557 /**
558  * @brief Handler for the logical channel configuration request from
559  * PMAC to SMAC.
560  *
561  * @details
562  *
563  *     Function : rgPomUeSCellLcAdd
564  *
565  *     Processing Steps:
566  *      - Update the dedicated logical channel Cb with the configured values.
567  *      - If successful, return ROK else RFAILED.
568  *
569  *  @param[in]  Inst        inst
570  *  @param[in]  RgCellCb    *cell
571  *  @param[in]  RgUeCb      *ue
572  *  @param[in]  CrgLchCfg   *lcCfg
573  *  @param[out] RgErrInfo   *errInfo
574  *  @return  S16
575  *      -# ROK
576  *      -# RFAILED
577  **/
578 S16 rgPomUeSCellLcAdd
579 (
580 Inst                     inst,
581 RgCellCb                 *cell,
582 RgUeCb                   *ue,
583 RgPrgUeSCellLchAddInfo   *lcCfg
584 )
585 {
586
587    RGDBGPRM(inst,(rgPBuf(inst), "APPLYING CRG LC CONFIG: cellId %d ueId %d\
588             lcId %d dir %d cell %p ue %p\n", lcCfg->cellId, lcCfg->crnti,
589             lcCfg->lcId, lcCfg->dir, (void*)cell, (void*)ue));
590    
591       if ((rgPomUeSCellDedLcCfg(cell, ue, lcCfg)) != ROK)
592       {
593          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Dedicated logical channel configuration"
594                   "failed in SCell%d\n", lcCfg->crnti, lcCfg->lcId));
595          return RFAILED;
596       }
597
598    RGDBGINFONEW(inst,(rgPBuf(inst), "[%d]SCell LC config done: cellId %d lcId %d\n",
599           lcCfg->crnti, lcCfg->cellId, lcCfg->lcId));
600    return ROK;
601 }  /* rgPomUeSCellLcAdd */
602
603 /***********************************************************
604  *
605  *     Func : rgPomVldtSCellDedLchCfg
606  *
607  *
608  *     Desc : Validates dedicated logical channel configuration received from PMAC.
609  *
610  *     @param[in] Inst                     inst
611  *     @param[in] RgPrgUeScellLchAddInfo   *lcCfg 
612  *     @param[in] RgCellCb                 **cell
613  *     @param[in] RgUeCb                   **ue
614  *
615  *     Ret  : S16
616  *            ROK - Success
617  *            RFAILED - Failed
618  *
619  *     Notes:
620  *
621  *     File :
622  *
623  **********************************************************/
624 static S16 rgPomVldtSCellDedLchCfg
625 (
626 Inst                       inst, 
627 RgPrgUeSCellLchAddInfo     *lcCfg,
628 RgCellCb                   **cell,
629 RgUeCb                     **ue
630 )
631 {
632    RGDBGPRM(inst,(rgPBuf(inst), "VALIDATING CRG DEDICATED LC CONFIG \n"));
633
634
635    /* Fetch the Active cell */
636    if (((*cell = rgCb[inst].cell) == NULLP)
637       || ((*cell)->cellId != lcCfg->cellId))
638    {
639       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Active Cell does not exist: Cell %d\n",
640                lcCfg->crnti, lcCfg->cellId));
641       return RFAILED;
642    }
643
644    /* Fetch the Ue */
645    if ((*ue = rgDBMGetUeCb(*cell, lcCfg->crnti)) == NULLP)
646    {
647       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE  does not exist for dedicated logical"
648                "channel %d\n", lcCfg->crnti, lcCfg->lcId));
649       return RFAILED;
650    }
651
652    /* Validate logical channel Id */
653    /*if ((lcCfg->lcId < RG_DEDLC_MIN_LCID)
654             ||(lcCfg->lcId > RG_DEDLC_MAX_LCID))
655    {
656       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Invalid logical channel Id %d\n",
657                 lcCfg->crnti, lcCfg->lcId));
658       return RFAILED;
659    }*/
660    /* Validate downlink info */
661    if (lcCfg->dir & PRG_DIR_TX)
662    {
663       if (rgDBMGetDlDedLcCb((*ue), lcCfg->lcId) != NULLP)
664       {
665          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE: Dedicated DL LC %d already configured\n",
666                    lcCfg->crnti, lcCfg->lcId));
667          return RFAILED;
668       }
669 /*      dirVld = TRUE;*/
670    }
671
672    /* Validate uplink info */
673    if (lcCfg->dir & PRG_DIR_RX)
674    {
675       if (lcCfg->ulInfo.lcgId > (RG_MAX_LCG_PER_UE - 1))
676       {
677          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE: Invalid lcgId for uplink logical"
678                   "channel %d\n", lcCfg->crnti, lcCfg->ulInfo.lcgId));
679          return RFAILED;
680       }
681       if (rgDBMGetUlDedLcCb((*ue), lcCfg->lcId) != NULLP)
682       {
683          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE: Dedicated UL LC %d already configured\n",
684                    lcCfg->crnti, lcCfg->lcId));
685          return RFAILED;
686       }
687 /*      dirVld = TRUE;*/
688    }
689 /*
690    if (!dirVld)
691    {
692       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Invalid Direction %d \n",
693                lcCfg->crnti, lcCfg->dir));
694       return RFAILED;
695    }
696 */
697    RGDBGINFONEW(inst,(rgPBuf(inst), "[%d]Dedicated logical channel %d validated"
698             "for cell %d\n", lcCfg->crnti, lcCfg->lcId, lcCfg->cellId));
699    return ROK;
700 }  /* rgPomVldtSCellDedLchCfg */
701 /***********************************************************
702  *
703  *     Func : rgPomUeSCellDedLcCfg
704  *
705  *
706  *     Desc : Validates dedicated logical channel configuration received from PMAC.
707  *
708  *     @param[in] RgCellCb                 *cell
709  *     @param[in] RgUeCb                   *ue 
710  *     @param[in] RgPrgUeSCellLchAddInfo   *lcCfg
711  *
712  *     Ret  : S16
713  *            ROK - Success
714  *            RFAILED - Failed
715  *
716  *     Notes:
717  *
718  *     File :
719  *
720  **********************************************************/
721 static S16 rgPomUeSCellDedLcCfg
722 (
723 RgCellCb                   *cell,
724 RgUeCb                     *ue,
725 RgPrgUeSCellLchAddInfo     *lcCfg
726 )
727 {
728    //Inst     inst = cell->macInst - RG_INST_START;
729    //RGDBGPRM(inst,(rgPBuf(inst), "APPLYING DEDICATED LC CONFIG\n"));
730
731    /* Uplink/Bi-directional logical channel */
732    if (lcCfg->dir & PRG_DIR_RX)
733    {
734 #ifdef LTE_L2_MEAS
735       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId, lcCfg->qci);
736       cell->qciArray[lcCfg->qci].qci = lcCfg->qci;
737       if(lcCfg->lcType == CM_LTE_LCH_DTCH)
738       {
739         rgAddToL2MeasPerQci(cell,lcCfg->qci);/*LTE_L2_MEAS_PHASE2*/ 
740       }
741 #else
742       rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId);
743 #endif
744    }
745
746    /* Downlink/Bi-directional logical channel */
747    if (lcCfg->dir & PRG_DIR_TX)
748    {
749       rgDBMInsDlDedLcCb(ue, lcCfg->lcId);
750    }
751    RGDBGINFO(inst,(rgPBuf(inst), "Dedicated LC config done\n"));
752    return ROK;
753
754   }  /* rgPomUeSCellDedLcCfg */
755 /**
756  * @brief Function to validate SCellLchReCfg.
757  *
758  * @details
759  *
760  *     Function : rgPomVltdModLch
761  *     
762  *           
763  *  @param[in] inst        instance number to fetch rgCb instance
764  *  @param[in] lchCfg Cb   lchCfg CB for validation
765  *  @param[out] cell        cell control block
766  *  @param[out] RgCellCb     **cell
767  *  @param[out] RgUeCb       **ue
768  *  @param[out] RgUlLcCb     **ulLc
769  *  @return  S16
770  *      -# ROK 
771  **/
772 S16 rgPomVltdModLch
773 (
774 Inst                     inst,
775 RgPrgUeSCellLchModInfo   *lchCfgCb,
776 RgCellCb                 **cell,
777 RgUeCb                   **ue,
778 RgUlLcCb                 **ulLc
779 )
780 {
781    RGDBGPRM(inst,(rgPBuf(inst), "VALIDATE SMAC LC RECONFIG: cellId %d ueId %d \
782             lcId %d cell %p ue %p ulLc %p\n",lchCfgCb->cellId,
783             lchCfgCb->crnti,lchCfgCb->lcId, (void*)*cell, (void*)*ue,
784             (void*)*ulLc));
785    /* Fetch the cell */
786    if ((((*cell = rgCb[inst].cell)) == NULLP)
787          || ((*cell)->cellId != lchCfgCb->cellId))
788    {
789       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Active Cell does not exist %d\n",lchCfgCb->crnti, lchCfgCb->cellId));
790       return RFAILED;
791    }
792    /* Fetch the Ue for dedicated channels */
793    if ((*ue = rgDBMGetUeCb(*cell, lchCfgCb->crnti)) == NULLP)
794    {
795       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Ue does not exist for dedicated logical channel\n",
796                lchCfgCb->crnti));
797       return RFAILED;
798    }
799    if ((*ulLc = rgDBMGetUlDedLcCb((*ue), lchCfgCb->lcId)) == NULLP)
800    {
801       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Dedicated UL LC does not exist %d\n",
802                lchCfgCb->crnti, lchCfgCb->lcId));
803       return RFAILED;
804    }
805   /* if (lchCfgCb->ulLchRecfg.lcgId > (RG_MAX_LCG_PER_UE - 1))
806    {
807       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Invalid lcgId for uplink logical channel: lcg %d"
808                "lc %d\n",lchCfgCb->crnti, lchCfgCb->ulLchRecfg.lcgId, lchCfgCb->lcId));
809       return RFAILED;
810    }*/
811    return ROK;
812 } /*rgPomVltdModLch*/
813 /**
814  * @brief Handler for the logical channel re-configuration request from
815  * PMAC to SMAC.
816  *
817  * @details
818  *
819  *     Function : rgPomUeSCellLcMod
820  *
821  *     Processing Steps:
822  *      - Update the dedicated logical channel Cb with the re-configured
823  *        values.
824  *      - If successful, return ROK else RFAILED.
825  *
826  *  @param[in]  Inst              inst
827  *  @param[in]  RgUlUeCb          *ue
828  *  @param[in]  RgUlLcCb          *ulLc
829  *  @param[in]  RgPrgLchRecfgInfo *lchCfgCb
830  *  @return  S16
831  *      -# ROK
832  *      -# RFAILED
833  **/
834 S16 rgPomUeSCellLcMod
835 (
836 Inst                    inst,
837 RgUeCb                  *ue,
838 RgUlLcCb                *ulLc,
839 RgPrgUeSCellLchModInfo  *lchCfgCb
840 )
841 {
842    RGDBGPRM(inst,(rgPBuf(inst), "APPLYING SMAC LC RECONFIG: cellId %d ueId %d\
843             lcId %d  \n",
844             lchCfgCb->cellId, lchCfgCb->crnti, lchCfgCb->lcId));
845
846    if (ulLc->lcgId != lchCfgCb->ulLchRecfg.lcgId)
847    {
848       rgDBMUpdUlDedLcCb(ue, ulLc, lchCfgCb->ulLchRecfg.lcgId);
849    }
850
851    RGDBGINFO(inst,(rgPBuf(inst), "LC %d of Ue %d of cell %d Reconfigured\n", 
852             lchCfgCb->lcId, ue->ueId, cell->cellId));
853    return ROK;
854 }  /* rgPomUeSCellLcMod */
855 /**
856  * @brief Function to validate SCellLchDel.
857  *
858  * @details
859  *
860  *     Function : rgPomVltdDelLch
861  *     
862  *           
863  *  @param[in] inst        instance number to fetch rgCb instance
864  *  @param[in] lchCfg Cb   lchCfg CB for validation
865  *  @param[out] cell        cell control block
866  *  @param[out] RgCellCb     **cell
867  *  @param[out] RgUeCb       **ue
868  *  @param[out] RgUlLcCb     **ulLc
869  *  @return  S16
870  *      -# ROK 
871  **/
872 S16 rgPomVltdDelLch
873 (
874 Inst                      inst,
875 RgPrgUeSCellLchDelInfo    *delLcCb,
876 RgCellCb                  **cell,
877 RgUeCb                    **ue,
878 RgUlLcCb                  **ulLc,
879 RgDlLcCb                  **dlLc
880 )
881 {
882    RGDBGPRM(inst,(rgPBuf(inst), "VALIDATE SMAC LC RECONFIG: cellId %d ueId %d \
883             lcId %d cell %p ue %p ulLc %p\n",delLcCb->cellId,
884             delLcCb->crnti,delLcCb->lcId, (void*)*cell, (void*)*ue,
885             (void*)*ulLc));
886    /* Fetch the cell */
887    if ((((*cell = rgCb[inst].cell)) == NULLP)
888          || ((*cell)->cellId != delLcCb->cellId))
889    {
890       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Active Cell does not exist %d\n",delLcCb->crnti, delLcCb->cellId));
891       return RFAILED;
892    }
893    /* Fetch the Ue for dedicated channels */
894    if ((*ue = rgDBMGetUeCb(*cell, delLcCb->crnti)) == NULLP)
895    {
896       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Ue does not exist for dedicated logical channel\n",
897                delLcCb->crnti));
898       return RFAILED;
899    }
900    if ((*ulLc = rgDBMGetUlDedLcCb((*ue), delLcCb->lcId)) == NULLP)
901    {
902       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Dedicated UL LC does not exist %d\n",
903                delLcCb->crnti, delLcCb->lcId));
904       return RFAILED;
905    }
906    if ((*dlLc = rgDBMGetDlDedLcCb((*ue), delLcCb->lcId)) == NULLP)
907    {
908          RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]DL LC %d does not exist\n",
909                delLcCb->crnti, delLcCb->lcId));
910          return RFAILED;
911    }
912    return ROK;
913 } /*rgPomVltdDelLch*/
914 /**
915  * @brief Handler for the logical channel delete request from
916  * PMAC to SMAC.
917  *
918  * @details
919  *
920  *     Function : rgPomUeSCellLcDel
921  *
922  *     Processing Steps:
923  *      - Fetch the logical channel control block.
924  *      - Free the logical channel control block.
925  *      - If successful, return ROK else return RFAILED.
926  *
927  *  @param[in]  Inst                      inst
928  *  @param[in]  RgPrgUeSCellLchDelInfo    *delLcCb
929  *  @param[in]  RgUeCb                    *ue
930  *  @param[in]  RgUlLcCb                  *ulLc
931  *  @return  S16
932  *      -# ROK
933  *      -# RFAILED
934  **/
935 S16 rgPomUeSCellLcDel
936 (
937 Inst                      inst,
938 RgPrgUeSCellLchDelInfo    *delLcCb,
939 RgUeCb                    *ue,
940 RgUlLcCb                  *ulLc,
941 RgDlLcCb                  *dlLc
942 )
943 {
944
945    RGDBGPRM(inst,(rgPBuf(inst), "APPLYING CRG LC DELETE: cellId %d ueId %d\
946             lcId %d dir %d\n", delLcCb->cellId,
947             delLcCb->crnti, delLcCb->lcId,
948             delLcCb->dir));
949
950
951    /* Validate downlink info */
952    if (delLcCb->dir & PRG_DIR_TX)
953    {
954       rgDBMDelDlDedLcCb(ue, dlLc);
955 /*      dirVld = TRUE;*/
956    }
957
958    /* Validate uplink info */
959    if (delLcCb->dir & PRG_DIR_RX)
960    {
961       rgDBMDelUlDedLcCb(ue, ulLc);
962 /*      dirVld = TRUE;*/
963    }
964
965    /*if (!dirVld)
966    {
967       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Invalid direction %d for LC Delete\n",
968             delLcCb->crnti, delLcCb->dir));
969       return RFAILED;
970    }*/
971    RGDBGINFONEW(inst,(rgPBuf(inst), "[%d]UE's Logical channel %d deleted from cell %d\n",
972          delLcCb->crnti, delLcCb->lcId,
973          delLcCb->cellId));
974    return ROK;
975 }  /* rgPomUeSCellLcDel */
976 #endif /*LTE_ADV */
977 /**********************************************************************
978  
979          End of file
980 **********************************************************************/