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