UL data path changes at Phy stub, RLC UL UM and DU APP [Issue-ID: ODUHIGH-262]
[o-du/l2.git] / src / 5gnrrlc / kw_cfg_dl.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**
20
21         Name:    LTE RLC - Configuration Manager file
22
23         Type:    C source file
24
25         Desc:    It contains the following configuraiton primtives
26                  for different actions
27                     -- rlcCfgValdtEntCfg
28                     -- rlcCfgFillRbCb
29                     -- rlcCfgRbInit
30                     -- rlcCfgAddRb
31                     -- rlcCfgReCfgRb
32                     -- rlcCfgDelRb
33                     -- rlcCfgReEstRb
34                     -- rlcCfgDelUe
35
36         File:    kw_cfg_dl.c
37
38 *********************************************************************21*/
39 static const char* RLOG_MODULE_NAME="CFG";
40 static int RLOG_MODULE_ID=2048;
41 static int RLOG_FILE_ID=191;
42
43 /** @file kw_cfg_dl.c
44 @brief RLC Downlink Configuration Module
45 **/
46
47 \f
48 /* header (.h) include files */
49 #include "common_def.h"
50 #include "lkw.h"           /* LKW defines */
51 #include "ckw.h"           /* CKW defines */
52 #include "kwu.h"           /* KWU defines */
53 #include "rgu.h"           /* RGU defines */
54 #include "kw_err.h"        /* RLC error options */
55 #include "kw_env.h"        /* RLC environment options */
56 #include "kw.h"            /* RLC defines */
57 #include "kw_udx.h"
58 #include "kw_dl.h"
59
60 /* extern (.x) include files */
61 #include "lkw.x"           /* LKW */
62 #include "ckw.x"           /* CKW */
63 #include "kwu.x"           /* KWU */
64 #include "rgu.x"           /* RGU */
65
66 #include "kw.x"
67 #include "kw_udx.x"
68 #include "kw_dl.x"
69
70 #define RLC_MODULE RLC_DBGMASK_CFG
71 /*Added for adding new Ue in onging L2 Meas*/
72 #ifdef LTE_L2_MEAS
73 /**
74  *
75  * @brief Handle modification of UE ID for L2 Meas data structs
76  *       
77  *
78  *  @param[in] ueId     ue ID
79  *
80  *  @return  S16
81  *      -# ROK 
82  *      -# RFAILED 
83  *
84 */
85 static S16 rlcHdlMeasDlUeIdChg(RlcCb *gCb, uint8_t cellId,uint8_t oldUeId, uint8_t newUeId)
86 {
87    RlcL2MeasEvtCb *measEvtCb = NULLP;
88    RlcL2MeasCb    *measCb    = NULLP;
89    uint16_t       cntr;
90    uint16_t       ueIdx = 0;     
91
92    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
93    {
94       measEvtCb = &(gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
95       measCb = &(measEvtCb->measCb);
96
97
98       if(measCb->measType & LKW_L2MEAS_DL_IP ) 
99       {
100
101          for(ueIdx = 0; ueIdx < measCb->val.ipThMeas.numUes; ueIdx++)
102          {
103             if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == oldUeId)
104             {
105                measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId = newUeId;
106                break;
107             }
108          }
109       }
110    }
111    return ROK;
112 }
113
114 /**
115  *
116  * @brief Handler to delete an UE's L2 Meas ctxt
117  *       
118 *
119  *  @param[in] ueId     ue ID
120  *
121  *  @return  S16
122  *      -# ROK 
123  *      -# RFAILED 
124  *
125 */
126 static S16 rlcDelFrmDlL2Meas(RlcCb *gCb, uint8_t cellId,uint8_t ueId)
127 {
128    RlcL2MeasEvtCb *measEvtCb = NULLP;
129    RlcL2MeasCb    *measCb    = NULLP;
130    uint16_t       cntr;
131    uint16_t       ueIdx = 0;     
132
133
134    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
135    {
136       measEvtCb = &gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr];
137       measCb = &(measEvtCb->measCb);
138
139
140       if(measCb->measType & LKW_L2MEAS_DL_IP )
141       {
142
143          for(ueIdx = 0; ((ueIdx < measCb->val.ipThMeas.numUes) &&
144                        (ueIdx < gCb->genCfg.maxUe)); ueIdx++)
145          {
146             if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == ueId)
147             {
148                measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid = FALSE;
149                if (measCb->val.ipThMeas.numUes-1 == ueIdx)
150                {
151                   measCb->val.ipThMeas.numUes--;
152                }
153                break;
154             }
155          }
156       }
157    }
158
159    return ROK;
160 }
161
162
163 static S16 rlcAddToDlL2Meas(RlcCb *gCb, RlcDlRbCb *rlcRbCb,uint8_t cellId,uint8_t ueId)
164 {
165    RlcL2MeasEvtCb *measEvtCb = NULLP;
166    RlcL2MeasCb    *measCb    = NULLP;
167    uint16_t       cntr;
168    uint16_t       cntr1;
169    uint16_t       ueIdx = 0;
170    uint16_t       qciIdx = 0;
171    uint16_t       *numQci;
172    #ifndef XEON_SPECIFIC_CHANGES 
173    uint8_t        freeIdx = gCb->genCfg.maxUe;
174    #else
175    uint16_t       freeIdx = LKW_MAX_UE;
176    #endif
177
178
179    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
180    {
181       measEvtCb = &gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr];
182       measCb = &(measEvtCb->measCb);
183
184       freeIdx = gCb->genCfg.maxUe;
185
186       if(measCb->measType & 
187           (LKW_L2MEAS_ACT_UE | LKW_L2MEAS_UU_LOSS | LKW_L2MEAS_DL_DELAY))
188       {
189          for(cntr1 =0;((cntr1 < measCb->val.nonIpThMeas.numQci) &&
190                        (cntr1 < LKW_MAX_QCI));cntr1++)
191          {
192             if(measCb->val.nonIpThMeas.qci[cntr1] != rlcRbCb->qci)
193             {
194                measCb->val.nonIpThMeas.qci[cntr1]  = rlcRbCb->qci;
195                gCb->u.dlCb->rlcL2Cb.measOn[rlcRbCb->qci] |=measCb->measType;
196                break;
197             }
198          }
199       }
200
201       if(((rlcRbCb->rbL2Cb.measOn & measCb->measType) == LKW_L2MEAS_NONE))
202       {
203          if (measCb->measType & LKW_L2MEAS_ACT_UE)
204          {
205             if((rlcRbCb->mode == RLC_MODE_UM) &&
206                   (rlcRbCb->dir & RLC_DIR_DL ))
207             {
208                if (rlcRbCb->m.umDl.sduQ.count)
209                {
210                   if (rlcRbCb->ueCb->numActRb[rlcRbCb->qci] == 0)
211                   {
212                      rlcRbCb->ueCb->numActRb[rlcRbCb->qci]++;
213                      gCb->u.dlCb->rlcL2Cb.numActUe[rlcRbCb->qci]++;
214                   }
215                }
216             }
217             else if (rlcRbCb->mode == RLC_MODE_AM)
218             {
219                if ((rlcRbCb->m.amDl.cntrlBo) ||
220                      (rlcRbCb->m.amDl.retxBo)  ||
221                      (rlcRbCb->m.amDl.bo))
222                {
223                   if (rlcRbCb->ueCb->numActRb[rlcRbCb->qci] == 0)
224                   {
225                      rlcRbCb->ueCb->numActRb[rlcRbCb->qci]++;
226                      gCb->u.dlCb->rlcL2Cb.numActUe[rlcRbCb->qci]++;
227                   }
228                }
229             }
230          }
231       }
232       if((measCb->measType & LKW_L2MEAS_DL_IP))
233       {
234
235          for(ueIdx = 0; ((ueIdx < measCb->val.ipThMeas.numUes) &&
236                          (ueIdx < gCb->genCfg.maxUe)); ueIdx++)
237          {
238             if ((freeIdx == gCb->genCfg.maxUe) && 
239                   (measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid == FALSE))
240             {
241                freeIdx = ueIdx;
242                continue;
243             }
244             if((measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId) == ueId)
245             {
246                break;
247             }
248          }
249
250          if (ueIdx ==  measCb->val.ipThMeas.numUes)
251          {
252             if (gCb->genCfg.maxUe == measCb->val.ipThMeas.numUes)
253             {
254                return RFAILED;  
255             }
256             if (gCb->genCfg.maxUe == freeIdx)
257             {               
258                measCb->val.ipThMeas.numUes++;
259             }
260             else
261             {
262                ueIdx = freeIdx;
263             }
264             measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid = TRUE;
265             memset(&measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[0],0x00,(sizeof(RlcL2Cntr) *LKW_MAX_QCI));
266             measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci = 0;
267          }
268          measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId = ueId;
269          measCb->val.ipThMeas.ueInfoLst[ueIdx].cellId = cellId;
270          numQci = &(measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci);
271
272          for (qciIdx =0; ((qciIdx <  *numQci) &&
273                            (qciIdx < LKW_MAX_QCI)) ; qciIdx++)
274          {
275             if (measCb->val.ipThMeas.ueInfoLst[ueIdx].qci[qciIdx] == rlcRbCb->qci)
276             {
277                break;
278             }
279          }
280
281          /* Fix Klock Warning */
282          if ((qciIdx == *numQci) && (qciIdx < LKW_MAX_QCI))
283          {
284             measCb->val.ipThMeas.ueInfoLst[ueIdx].qci[qciIdx] = rlcRbCb->qci;
285             (*numQci)++;
286          }
287
288          rlcUtlPlcMeasDatInL2Sts(&measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[rlcRbCb->qci],
289                &rlcRbCb->rbL2Cb, measCb->measType);
290       }
291       else if (measCb->measType & 
292          (LKW_L2MEAS_DL_DISC | LKW_L2MEAS_DL_DELAY | LKW_L2MEAS_UU_LOSS))
293       {
294          rlcUtlPlcMeasDatInL2Sts(&measCb->val.nonIpThMeas.measData[rlcRbCb->qci],
295                &rlcRbCb->rbL2Cb, measCb->measType);
296          measCb->val.nonIpThMeas.qci[rlcRbCb->qci] = rlcRbCb->qci;
297          measCb->val.nonIpThMeas.measData[rlcRbCb->qci].totDrbsPerQci++;
298       }
299       rlcRbCb->rbL2Cb.measOn |= measCb->measType;      
300    }
301    return ROK;
302 }/*rlcAddToDlL2Meas*/ 
303 #endif /*LTE_L2_MEAS*/
304 \f
305 /** 
306  * @brief
307  *     This primitive fills the RbCb 
308  *
309  * @param [in]    gCb      -  RLC Instance Control Block
310  * @param [out]   rbCb     -  RB Control Block
311  * @param [out]   ueCb     -  UE Control Block
312  * @param [in]    entCfg   -  RLC Entity configuration
313  *
314  * @return  S16
315  *    -#ROK
316  *    -#RFAILED
317  */
318 static S16 rlcCfgFillDlRbCb(RlcCb *gCb,RlcDlRbCb *rbCb,RlcDlUeCb *ueCb,RlcEntCfgInfo *entCfg)
319 {
320
321    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
322          "rlcCfgFillRbCb(ueId(%d),cellId(%d) rbType(%d))",
323                 rbCb->rlcId.ueId,
324                 rbCb->rlcId.cellId, 
325                 entCfg->rbType);
326
327    /* Initialize according to entMode */
328    switch (entCfg->entMode)
329    {
330       case RLC_MODE_TM:
331       {
332          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
333          rbCb->lch.lChType = entCfg->lCh[0].type;
334          rbCb->dir = entCfg->dir;
335          break;
336       }
337
338       case RLC_MODE_UM:
339       {
340          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
341          rbCb->lch.lChType = entCfg->lCh[0].type;
342          rbCb->dir = entCfg->dir;
343
344          /* Spec 38.322 Section 7.1 
345           * All UM state variables can take values from 0 to 63 for 6 bit SN or 
346           * from 0 to 4095 for 12 bit SN. All arithmetic operations on UM state 
347           * variables are affected by the UM modulus 
348           * (i.e. final value = [value from arithmetic operation] modulo 64
349           * for 6 bit SN and 4096 for 12 bit SN)
350           */
351          rbCb->m.umDl.snLen = entCfg->m.umInfo.dl.snLen;
352          if (entCfg->m.umInfo.dl.snLen == RLC_UM_CFG_6BIT_SN_LEN)
353             rbCb->m.umDl.modBitMask = 0x3f;
354          else
355             rbCb->m.umDl.modBitMask = 0xfff;
356
357          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
358
359          break;
360       }
361       case RLC_MODE_AM:
362       {
363          /* Down Link Information 
364           * indx = 0 as Down Link   */
365          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
366          rbCb->lch.lChType = entCfg->lCh[0].type;
367          rbCb->dir = RLC_DIR_BOTH;
368          rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
369          rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
370          rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
371          rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
372          rbCb->m.amDl.snLen = entCfg->m.amInfo.dl.snLen;
373          
374          if(RLC_AM_CFG_12BIT_SN_LEN == rbCb->m.amDl.snLen)
375          {
376             rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_12BITS) - 1; /* 5GNR */
377          }
378          else 
379          {
380             rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_18BITS) - 1; /* 5GNR */
381          }
382
383          cmInitTimers(&(rbCb->m.amDl.pollRetxTmr), 1);
384       
385         
386          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
387        
388 #ifndef LTE_TDD 
389              uint32_t hashIndex;
390               RLC_ALLOC(gCb,
391                     rbCb->m.amDl.txBufLst,
392                     (RLC_TX_BUF_BIN_SIZE * sizeof(CmLListCp)));
393               for(hashIndex = 0; hashIndex < RLC_TX_BUF_BIN_SIZE; hashIndex++)
394               {
395                   cmLListInit(&(rbCb->m.amDl.txBufLst[hashIndex]));
396               }
397 #endif
398          break;
399       }
400       default:
401       {
402          RLOG_ARG2(L_ERROR,DBG_RBID,entCfg->rbId, 
403                   "Invalid RB Mode ueId(%d),cellId(%d)",
404                   rbCb->rlcId.ueId,
405                   rbCb->rlcId.cellId);
406          return RFAILED;
407       }
408    }
409    rbCb->mode = entCfg->entMode;
410    rbCb->discTmrInt = entCfg->discardTmr;
411
412    return ROK;
413
414
415 \f
416 /** 
417  * @brief This primitive Initializes the RB Cb
418  *
419  * @param [in]    gCb      -  RLC Instance Control Block
420  * @param [out]   rbCb     -  RB Control Block
421  * @param [in]    ptr      -  Void pointer
422  * @param [in]    entCfg   -  Entity Configuration
423  *
424  * @return  S16
425  *    -#ROK
426  *    -#RFAILED
427  */
428 static S16 rlcCfgUpdateDlRb
429 (
430 RlcCb           *gCb,
431 RlcDlRbCb       *rbCb,
432 void            *ptr,
433 RlcEntCfgInfo   *entCfg
434 )
435 {
436    
437    if (rbCb->mode != entCfg->entMode)
438    {
439       RLOG_ARG4(L_ERROR,DBG_RBID,rbCb->rlcId.rbId,
440             "RB Mode Mismatch : exp [%d] rcv [%d] UEID:%d CELLID:%d", 
441             rbCb->mode, 
442             entCfg->entMode,
443             rbCb->rlcId.ueId,
444             rbCb->rlcId.cellId);
445       return (CKW_CFG_REAS_RB_MODE_MIS);
446    }
447
448    switch (rbCb->mode)
449    {
450       case RLC_MODE_TM:
451       {
452          RlcDlCellCb *cellCb = (RlcDlCellCb *)ptr;
453
454          rbCb->dir = entCfg->dir;
455          rbCb->lch.lChId = entCfg->lCh[0].lChId;
456          rbCb->lch.lChType = entCfg->lCh[0].type;
457
458          cellCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
459          break;
460       }
461
462       case RLC_MODE_UM:
463       {
464          RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
465
466          if (entCfg->lCh[0].type == CM_LTE_LCH_DCCH)
467          {
468             return (CKW_CFG_REAS_LCHTYPE_MIS);
469          }
470          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
471          ueCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rbCb;
472
473          rbCb->lch.lChId = entCfg->lCh[0].lChId;
474          rbCb->lch.lChType = entCfg->lCh[0].type;
475          rbCb->dir = entCfg->dir;
476          break;
477       }
478
479       case RLC_MODE_AM:
480       {
481          RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
482
483          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
484          ueCb->lCh[entCfg->lCh[1].lChId - 1].dlRbCb = rbCb;
485          
486          /* Down Link */
487          rbCb->lch.lChId = entCfg->lCh[1].lChId;
488          rbCb->lch.lChType = entCfg->lCh[1].type;
489          rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
490          rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
491          rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
492          rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
493          
494          break;
495       }
496    }
497
498 /* AGHOSH */
499    rbCb->discTmrInt = entCfg->discardTmr;
500 /* AGHOSH */
501    return (CKW_CFG_REAS_NONE);
502
503
504 \f
505 /** 
506  * @brief 
507  *    This primitive adds new RB in Ue/Cell Cb.
508  *
509  * @details
510  *    This function does following steps -
511  *    - If UE ID is 0 then
512  *    - Check for CELL CB is present
513  *    - If yes, Check for RB ID
514  *       - If RB ID is present Status Indication with reason
515  *       - Else, Create New RB CB in CELL CB
516  *    - If no Create New CELL CB and RB CB
517  *    - Else,
518  *       - Check for UE CB is present
519  *       - If yes Check for RB ID
520  *          - If RB ID is present Status Indication with reason
521  *          - Else, Create New RB CB in UE CB
522  *          - If no Create New UE CB and RB CB
523  *    - Fill entity confirmation
524  *
525  * @param [in]    gCb      -  RLC Instance Control Block
526  * @param [in]    ueId     -  UE Identifier
527  * @param [in]    cellId   -  CELL Identifier
528  * @param [in]    entCfg   -  Entity Configuration to be done.
529  * @param [out]   entCfm   -  Entity Confirmation.
530  *
531  * @return  S16
532  *    -# ROK
533  *    -# RFAILED
534  */
535 S16 rlcCfgAddDlRb
536 (
537 RlcCb               *gCb,
538 CmLteRnti          ueId,
539 CmLteCellId        cellId,
540 RlcEntCfgInfo      *entCfg,
541 RlcEntCfgCfmInfo   *entCfm
542 )
543 {
544    RlcDlUeCb     *ueCb = NULLP;   /* UE Control Block */
545    RlcDlCellCb   *cellCb;         /* Cell Control Block */
546    RlcDlRbCb     *rlcRbCb;         /* KW RB Control Block */
547    uint8_t       reason;          /* Rb Identifier */
548
549    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId, 
550          "rlcCfgAddRb(cellId(%d),UEID:%d cfgType(%d))",
551                 cellId, 
552                 ueId,
553                 entCfg->cfgType);
554
555    if (cellId == 0)
556    {
557       /* Fill entCfm structure */
558       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
559                           CKW_CFG_REAS_CELL_UNKWN);
560       RLOG_ARG1(L_ERROR,DBG_RBID,entCfg->rbId,
561                "Add DLRb,CellId is 0 for UEID:%d",
562                ueId);
563       return RFAILED;
564    }
565    if ((entCfg->rguSapId >= gCb->genCfg.maxRguSaps) || (entCfg->rguSapId < 0))
566    {
567          RLCDBGP_ERROR(gCb, "rlcCfgAddDlRb(ueId(%u), cellId(%u), Invalid rguSapId (%d)\n",
568                ueId, cellId, entCfg->rguSapId);
569          return RFAILED; 
570    }
571
572
573    /* Process Adding new RB */
574    if (ueId == 0)
575    {
576       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
577       {
578          /* Fill entCfm structure */
579          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
580                              CKW_CFG_CFM_NOK,
581                              CKW_CFG_REAS_RB_UNKWN);
582          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId,
583                   "Invalid RbId ,Max is [%d] CELLID:%d UEID:%d",
584                   RLC_MAX_RB_PER_CELL,
585                   cellId,
586                   ueId);
587          return RFAILED;
588       }
589
590       if (((entCfg->lCh[0].type == CM_LTE_LCH_BCCH) || 
591            (entCfg->lCh[0].type == CM_LTE_LCH_PCCH) ||
592            (entCfg->lCh[0].type == CM_LTE_LCH_CCCH)) &&
593           (entCfg->entMode == RLC_MODE_TM))
594       {
595          /* Cell CB present */
596          rlcDbmFetchDlCellCb(gCb, cellId, &cellCb);
597          if(cellCb)
598          {
599             /* Get rbCb from cellCb->rbCb List */
600             if (( cellCb->rbCb[entCfg->rbId] != NULLP))
601             {
602                /* Fill entCfm structure */
603                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
604                                    CKW_CFG_CFM_NOK,
605                                    CKW_CFG_REAS_RB_PRSNT);
606                RLOG_ARG2(L_WARNING, DBG_CELLID,cellId, 
607                         "RbId [%d] already exists UEID:%d",
608                         entCfg->rbId,
609                         ueId);
610                return RFAILED;
611             }
612          }
613          else  /* Cell CB UNKNOWN */
614          {
615             /* Create CELL CB */
616             if ( ROK != rlcDbmCreateDlCellCb(gCb,cellId, &cellCb))
617             {
618                /* Fill entCfm structure */
619                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
620                                    CKW_CFG_CFM_NOK,
621                                    CKW_CFG_REAS_CELL_CREAT_FAIL);
622                RLOG_ARG2(L_ERROR,DBG_CELLID,cellId,
623                         "cellCb Creation failed RBID:%d UEID:%d",
624                         entCfg->rbId,
625                         ueId);
626                return RFAILED;
627             }
628          }
629
630          /* Validate LChId */
631          if(entCfg->lCh[0].lChId <= 0)
632          {
633             RLOG_ARG3(L_ERROR,DBG_LCID,entCfg->lCh[0].lChId ,
634                      "Invalid LcId CELLID:%d UEID:%d RBID:%d",
635                      cellId,
636                      ueId,
637                      entCfg->rbId);
638             /* Fill entCfm structure */                               
639             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
640                   CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);           
641             return RFAILED;                                        
642          }                                                            
643
644          /* Create RB CB */
645          RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
646          if (!rlcRbCb)
647          {
648             RLOG_ARG2(L_FATAL,DBG_UEID,ueId,
649                      "Memory allocation failed for rbId:%d CELLID:%d",
650                      entCfg->rbId,
651                      ueId);
652             /* Fill entCfm structure */                           
653             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
654                                 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_CREAT_FAIL); 
655             return RFAILED; 
656          }
657          rlcRbCb->rlcId.rbId = entCfg->rbId;
658          cellCb->rbCb[entCfg->rbId] = rlcRbCb;
659          RLC_LMM_RB_STS_INC(gCb);
660          cellCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rlcRbCb;
661       }
662       else
663       {
664          reason= (entCfg->entMode != RLC_MODE_TM)? CKW_CFG_REAS_RB_MODE_MIS:
665                                                       CKW_CFG_REAS_LCHTYPE_MIS;
666          /* Fill entCfm structure */
667          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
668                              CKW_CFG_CFM_NOK, reason);
669          return RFAILED;
670       }
671    }
672    else
673    {
674       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
675       {
676          /* Fill entCfm structure */
677          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
678                CKW_CFG_REAS_RB_UNKWN);
679          RLOG_ARG2(L_ERROR,DBG_RBID, entCfg->rbId,
680                   "Invalid RbId for RbType[%d] UEID:%d", 
681                   entCfg->rbType,
682                   ueId);
683          return RFAILED;
684       }
685       if ((((entCfg->lCh[0].type == CM_LTE_LCH_DCCH) && 
686             (entCfg->entMode != RLC_MODE_UM) && 
687             (CM_LTE_SRB == entCfg->rbType)) ||
688            ((entCfg->lCh[0].type == CM_LTE_LCH_DTCH) && 
689             (CM_LTE_DRB == entCfg->rbType))) &&
690           (entCfg->entMode != RLC_MODE_TM))
691       {
692          /* UE CB present */
693          if ( rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb) == ROK)
694          {
695             /* Get rbCb from ueCb->rbCb list */
696             RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
697
698             if(( rlcRbCb != NULLP))
699             {
700                /* Fill entCfm structure */
701                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
702                      CKW_CFG_REAS_RB_PRSNT);
703                RLOG_ARG2(L_WARNING, DBG_UEID, ueId,
704                         "CellId[%u]:rbId [%d] already exists",
705                         cellId,
706                         entCfg->rbId);
707                return RFAILED;
708             }
709          }
710          else  /* UE CB UNKNOWN */
711          {
712             /* Create UE CB */
713             if ( rlcDbmCreateDlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
714             {
715                /* Fill entCfm structure */
716                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
717                      CKW_CFG_REAS_UE_CREAT_FAIL);
718                RLOG_ARG2(L_WARNING, DBG_CELLID,cellId,
719                         "UeId [%u]:ueCb Creation Failed RBID:%d",
720                         ueId,
721                         entCfg->rbId);
722                return RFAILED;
723             }
724          }
725
726          /* Validate LChId for UM and AM modes */
727          if ((entCfg->lCh[0].lChId <= 0) ||
728              ((entCfg->entMode == RLC_MODE_AM)&&
729                (entCfg->lCh[1].lChId <= 0)))
730          {
731             /* Fill entCfm structure */                               
732             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
733                   CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);           
734             return RFAILED;                                        
735          }                                                            
736
737          /* Create RB CB */
738          RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
739          if (rlcRbCb == NULL)
740          {
741             /* Fill entCfm structure */                           
742             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,CKW_CFG_CFM_NOK,
743                                     CKW_CFG_REAS_RB_CREAT_FAIL); 
744             RLOG_ARG2(L_FATAL,DBG_UEID,ueId,
745                      "Memory allocation failed RBID:%d CELLID:%d",
746                      entCfg->rbId,
747                      cellId);
748             return RFAILED; 
749          }
750
751          /* copy the RB Cb into UECb */
752          rlcRbCb->rlcId.rbId = entCfg->rbId;
753          if(entCfg->rbType == CM_LTE_SRB)
754             ueCb->srbCb[entCfg->rbId] = rlcRbCb;
755          else
756             ueCb->drbCb[entCfg->rbId] = rlcRbCb;
757          
758          RLC_LMM_RB_STS_INC(gCb);
759
760       }
761       else
762       {
763          if (entCfg->entMode == RLC_MODE_TM)
764          {
765             reason = CKW_CFG_REAS_RB_MODE_MIS;
766          }
767          else
768          {
769             reason = CKW_CFG_REAS_LCHTYPE_MIS;
770          }
771
772          /* Fill entCfm structure */
773          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK, reason);
774          return RFAILED;
775       }
776    }
777
778
779    rlcRbCb->rlcId.cellId = cellId;
780    rlcRbCb->rlcId.ueId   = ueId;
781    rlcRbCb->rlcId.rbType = entCfg->rbType;
782    rlcRbCb->inst         = gCb->init.inst;
783 #ifdef TENB_MULT_CELL_SUPPRT
784    rlcRbCb->rguSapId     = entCfg->rguSapId;
785 #endif
786
787
788    /* Fill RB CB */
789    if (rlcCfgFillDlRbCb(gCb,rlcRbCb, ueCb, entCfg) != ROK)
790    {
791       /* Fill entCfm structure */
792       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
793                CKW_CFG_REAS_RB_CREAT_FAIL);
794
795       /* Delete RB CB created */
796       RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));
797       RLOG_ARG2(L_ERROR,DBG_RBID, entCfg->rbId,
798                "Filling of RbCb failed UEID:%d CELLID:%d",
799                ueId,
800                cellId);
801       return RFAILED;
802    }
803    rlcRbCb->qci = entCfg->qci;
804 #ifdef LTE_L2_MEAS
805    rlcRbCb->ueCb =  ueCb;
806    if (entCfg->lCh[0].type == CM_LTE_LCH_DTCH)
807    {
808       /* ccpu00129778 */
809       rlcAddToDlL2Meas(gCb, rlcRbCb,cellId,ueId); 
810    }
811 #endif /* LTE_L2_MEAS */
812
813    /* Fill entCfm structure */
814    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
815
816    return ROK;
817
818
819 \f
820 /** 
821  * @brief
822  *    This primitive reconfigures the existing RB in Ue/Cell Cb.
823  *
824  * @details
825  *    This primitive executes following steps in reconfiguration of existing
826  *    RB -
827  *    - If UE ID is 0 then
828  *       - Check for CELL CB is present
829  *       - If yes, Check for RB ID
830  *          - If RB ID is present Reconfigure the RB CB
831  *          - Else, Status Indication with Reason
832  *       - Else, Status Indication with Reason
833  *    - Else,
834  *       - Check for UE CB is present
835  *       - If yes, Check for RB ID
836  *          - If RB ID is prenset Reconfigure the CELL CB
837  *          - Else, Status Indication with Reason
838  *       - Else, Status Indication with Reason
839  *    - Fill entity confirmation
840  *
841  * @param [in]    gCb      -  RLC Instance Control Block
842  * @param [in]    ueId     -  UE Identifier
843  * @param [in]    cellId   -  CELL Identifier
844  * @param [in]    entCfg   -  Entity Configuration to be done.
845  * @param [out]   entCfm   -  Entity Confirmation
846  *
847  * @return  S16
848  *    -#ROK
849  *    -#RFAILED
850  */
851 S16 rlcCfgReCfgDlRb
852 (
853 RlcCb               *gCb,
854 CmLteRnti          ueId,
855 CmLteCellId        cellId,
856 RlcEntCfgInfo      *entCfg,
857 RlcEntCfgCfmInfo   *entCfm
858 )
859 {
860    RlcDlRbCb     *rbCb;     /* RB Control Block */
861    RlcDlRbCb     tRbCb;     /* KW RB Control Block */
862    RlcDlCellCb   *cellCb;   /* Cell Control Block */
863    RlcDlUeCb     *ueCb;     /* Ue Control Block */
864    uint8_t       ret;
865
866    RLOG_ARG3(L_DEBUG,DBG_UEID,ueId,
867              "rlcCfgReCfgRb(cellId(%d), cfgType(%d)) RBID:%d",
868             cellId, entCfg->cfgType,entCfg->rbId);
869
870
871    /* Check for UeCb or CellCb */
872    if (ueId == 0)
873    { 
874       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
875       {
876          /* Fill entCfm structure */
877          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
878                              CKW_CFG_REAS_RB_UNKWN);
879          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId,
880                   "Invalid RbId , Max is [%d] UEID:%d CELLID:%d",
881                   RLC_MAX_RB_PER_CELL,
882                   ueId,
883                   cellId);
884          return RFAILED;
885       }
886       /* Get cellCb */
887       rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
888       if(!cellCb)
889       {
890          /* Fill entCfm structure */
891          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
892                              CKW_CFG_REAS_CELL_UNKWN);
893          RLOG_ARG3(L_ERROR,DBG_CELLID,cellId,
894                   "CellCb not found ueId:%d RBID:%d CELLID:%d",
895                   ueId,
896                   entCfg->rbId,
897                   cellId);
898          return RFAILED;
899       }
900
901       /* Get rbCb */
902       RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rbCb);
903
904       if (!rbCb)
905       {
906          /* Fill entCfm structure */
907          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
908                CKW_CFG_REAS_RB_UNKWN);
909          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
910                   "CELLID:%d RBID:%d not found",
911                   cellId,
912                   entCfg->rbId);
913          return RFAILED;
914       }
915
916       /* Take backup of rbCb before updating.
917        * Because in failure case restore original rbCb
918        */
919       memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
920
921       /* Update rbCb */
922       ret = rlcCfgUpdateDlRb(gCb,rbCb, cellCb,entCfg);
923       if (ret != ROK)
924       {
925          /* Fill entCfm structure */
926          RLC_CFG_FILL_CFG_CFM(entCfm, 
927                              entCfg->rbId, 
928                              entCfg->rbType, 
929                              CKW_CFG_CFM_NOK,
930                              ret);
931
932          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
933                   "CELLID:%u RBID:%d updation failed",
934                   cellId,
935                   entCfg->rbId);
936          memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
937
938          return (ret);
939       }
940    }
941    else
942    {
943       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
944       {
945          /* Fill entCfm structure */
946          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
947                CKW_CFG_REAS_RB_UNKWN);
948          RLOG_ARG3(L_ERROR,DBG_UEID,ueId,
949                   "CELLID:%d Invalid RBID:%d for RbType[%d]",
950                   cellId,
951                   entCfg->rbId,
952                   entCfg->rbType);
953          return RFAILED;
954       }
955       /* Get ueCb */
956       ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
957       if (ret != ROK)
958       {
959          /* Fill entCfm structure */
960          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
961                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
962          RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
963                   "UEID:%d UeCb not found RBID:%d",
964                   ueId,
965                   entCfg->rbId);
966          return (ret);
967       }
968
969       /* Get rbCb */
970       RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
971
972       if ( rbCb == NULLP)
973       {
974          /* Fill entCfm structure */
975          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
976                CKW_CFG_REAS_RB_UNKWN);
977          RLOG_ARG2(L_ERROR, DBG_UEID,ueId, 
978                   "CELLID:%d RBID:%d not found",
979                   cellId,
980                   entCfg->rbId);
981          return (ret);
982       }
983
984       /* Take backup of rbCb before updating.
985        * Because in failure case restore original rbCb
986        */
987       memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
988
989       /* Update rbCb */
990       ret = rlcCfgUpdateDlRb(gCb,rbCb,ueCb, entCfg);
991       if (ret != CKW_CFG_REAS_NONE)
992       {
993          /* Fill entCfm structure */
994          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
995                ret);
996          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
997                   "CELLID:%d RBID:%d updation failed",
998                   cellId,
999                   entCfg->rbId);
1000          memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
1001
1002          return (ret);
1003       }
1004    }
1005
1006    /* Fill entCfm structure */
1007    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1008
1009    return ROK;
1010
1011
1012 \f
1013 /** 
1014  * @brief This primitive deletes the existing RB in Ue/Cell Cb.
1015  *
1016  * @details
1017  *    - If UE ID is 0 then
1018  *      - Check for CELL CB is present
1019  *       - If yes, Check for RB ID
1020  *      - If RB ID is prenset Delete the RB CB
1021  *       - If there is no RB CB exist in CELL CB then Delete CELL CB.
1022  *      - Else, Status Indication with Reason
1023  *      - Else, Status Indication with Reason
1024  *    - Else,
1025  *      - Check for UE CB is present
1026  *      - If yes, Check for RB ID
1027  *        - If RB ID is prenset Delete the RB CB
1028  *          - If there is no RB CB exist in UE CB then Delete UE CB.
1029  *        - Else, Status Indication with Reason
1030  *      - Else, Status Indication with Reason
1031  *    - Fill entity confirmation
1032  *
1033  * @param [in]    gCb      -  RLC Instance Control Block
1034  * @param [in]    ueId     -  UE Identifier
1035  * @param [in]    cellId   -  CELL Identifier
1036  * @param [in]    entCfg   -  Entity Configuration to be done.
1037  * @param [out]   entCfm   -  Entity Confirmation
1038  *
1039  * @return  S16
1040  *    -#ROK
1041  *    -#RFAILED
1042  */
1043 S16 rlcCfgDelDlRb
1044 (
1045 RlcCb               *gCb,
1046 CmLteRnti          ueId,
1047 CmLteCellId        cellId,
1048 RlcEntCfgInfo      *entCfg,
1049 RlcEntCfgCfmInfo   *entCfm
1050 )
1051 {
1052    S16          ret;       /* Return Value */
1053    RlcDlUeCb     *ueCb;     /* UE Control Block */
1054    RlcDlCellCb   *cellCb;   /* UE Control Block */
1055    RlcDlRbCb     *rlcRbCb;   /* KW RB Control Block */
1056
1057    RLOG_ARG3(L_DEBUG,DBG_UEID,ueId, 
1058             "rlcCfgDelRb(RBID(%d), cellId(%d), cfgType(%d))",
1059             entCfg->rbId, 
1060             cellId, 
1061             entCfg->cfgType);
1062
1063    ret = ROK;
1064
1065    /* Get cellCb and delete rbCb from it */
1066    if (ueId == 0)
1067    {
1068       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
1069       {
1070          /* Fill entCfm structure */
1071          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1072                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1073          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId ,
1074                   "Invalid RbId, Max is [%d] UEID:%d CELLID:%d",
1075                   RLC_MAX_RB_PER_CELL,
1076                   ueId,
1077                   cellId);
1078          return RFAILED;
1079       }
1080       /* Get cellCb */
1081       rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1082       if (!cellCb)
1083       {
1084          /* Fill entCfm structure */
1085          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1086                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1087          RLOG_ARG2(L_ERROR,DBG_CELLID,cellId,
1088                   "CellCb not found UEID:%d RBID:%d",
1089                   ueId,
1090                   entCfg->rbId);
1091          return (ret);
1092       }
1093
1094       /* Get rbCb */
1095       RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rlcRbCb);
1096
1097       if ( rlcRbCb == NULLP)
1098       {
1099          /* Fill entCfm structure */
1100          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1101                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1102          RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1103                   "CellId[%u]:RbId[%d] not found",
1104                   cellId,
1105                   entCfg->rbId);
1106          return (ret);
1107       }
1108
1109       /* Assign NULLP to rbCb in rbCbLst */
1110       cellCb->rbCb[entCfg->rbId] = NULLP;
1111
1112       /* Assign NULLP to dlRbCb/ulRbCb.
1113        * Delete Hashlist allocated for it if any */
1114       cellCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1115       RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));   /*Vartika: Mem leak fix */  
1116    }
1117     /* Get ueCb and delete rbCb from it */
1118    else
1119    {
1120       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
1121       {
1122          /* Fill entCfm structure */
1123          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1124                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1125          RLOG_ARG3(L_ERROR,DBG_RBID, entCfg->rbId,
1126                   "Invalid RbId for RbType[%d] UEID:%d CELLID:%d", 
1127                   entCfg->rbType,
1128                   ueId,
1129                   cellId);
1130          return RFAILED;
1131       }
1132
1133       /* Get ueCb */
1134       ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1135       if (ret != ROK)
1136       {
1137          /* Fill entCfm structure */
1138          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1139                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1140          RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
1141                   "UeId [%d]: UeCb not found RBID:%d",
1142                   ueId,
1143                   entCfg->rbId);
1144          return (ret);
1145       }
1146
1147       /* Get rbCb */
1148       RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
1149
1150       if ( rlcRbCb == NULLP)
1151       {
1152          /* Fill entCfm structure */
1153          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1154                CKW_CFG_REAS_RB_UNKWN);
1155          RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1156                   "CellId[%u]:RbId[%d] not found",
1157                   cellId,
1158                   entCfg->rbId);
1159          return (ret);
1160       }
1161
1162       ueCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1163
1164 #ifdef LTE_L2_MEAS
1165       RLC_UPD_L2_DECR_NONIP_PER_QCI_RB_COUNT(gCb, rlcRbCb);
1166 #endif
1167       /* Free the Buffers of RbCb */
1168       if( RLC_MODE_UM == rlcRbCb->mode)
1169       {
1170          rlcUmmFreeDlRbCb(gCb,rlcRbCb);
1171          /* Delete RbCb  */
1172          RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));     
1173       }
1174       else if( RLC_MODE_AM == rlcRbCb->mode)
1175       {
1176          rlcAmmFreeDlRbCb(gCb,rlcRbCb);
1177       }
1178
1179       /* Assign NULLP to rbCb in rbCbLst */
1180       if ( entCfg->rbType == CM_LTE_SRB )
1181       {
1182          ueCb->srbCb[entCfg->rbId] = NULLP;
1183       }
1184       else
1185       {
1186          ueCb->drbCb[entCfg->rbId] = NULLP;
1187       }
1188    }
1189
1190    RLC_LMM_RB_STS_DEC(gCb);
1191
1192    /* Fill entCfm structure */
1193    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, 
1194                        CKW_CFG_REAS_NONE);
1195
1196    return (ret);
1197
1198
1199 \f
1200 /** 
1201  * @brief This primitive re-establish the existing RB in Ue/Cell Cb.
1202  *
1203  * @details
1204  *    - If UE ID is 0 then
1205  *      - Check for CELL CB is present
1206  *      - If yes, Check for RB ID
1207  *        - If RB ID is prenset initialize the parameters of the RB CB
1208  *        - Else, Status Indication with Reason
1209  *      - Else, Status Indication with Reason
1210  *    - Else,
1211  *      - Check for UE CB is present
1212  *      - If yes, Check for RB ID
1213  *        - If RB ID is prenset initialize the parameters of the RB CB
1214  *        - Else, Status Indication with Reason
1215  *      - Else, Status Indication with Reason
1216  *    - Fill entity confirmation
1217  *
1218  * @param [in]    gCb      -  RLC Instance Control Block
1219  * @param [in]    ueId     -  UE Identifier
1220  * @param [in]    cellId   -  CELL Identifier
1221  * @param [in]    entCfg   -  Entity Configuration to be done.
1222  * @param [out]   entCfm   -  Entity Confirmation
1223  *
1224  * @return  S16
1225  *    -# ROK
1226  *    -# RFAILED
1227  */
1228 S16 rlcCfgReEstDlRb
1229 (
1230 RlcCb              *gCb,
1231 CmLteRnti          ueId,
1232 CmLteCellId        cellId,
1233 Bool               sndReEstInd,
1234 RlcEntCfgInfo      *entCfg,
1235 RlcEntCfgCfmInfo   *entCfm
1236 )
1237 {
1238    RlcDlRbCb     *rbCb;   /* RB Control Block */
1239    CmLteRlcId   rlcId;   /* RLC Identifier */
1240
1241    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
1242             "rlcCfgReEstDlRb(ueId(%d), cellId(%d), cfgType(%d))",
1243             ueId, 
1244             cellId, 
1245             entCfg->cfgType);
1246
1247    /* Get rlcId */
1248    rlcId.ueId = ueId;
1249    rlcId.cellId = cellId;
1250    rlcId.rbId = entCfg->rbId;
1251    rlcId.rbType = entCfg->rbType;
1252
1253    rlcDbmFetchDlRbCbByRbId(gCb,&rlcId, &rbCb);
1254    if (rbCb == NULLP)
1255    {
1256       /* Fill entCfm structure */
1257       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, rlcId.rbType, CKW_CFG_CFM_NOK,
1258             CKW_CFG_REAS_RB_UNKWN);
1259       RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1260                "CellId[%u]:RbId[%d] not found",
1261                cellId,
1262                entCfg->rbId);
1263       return RFAILED;
1264    }
1265
1266    rbCb->rlcId.ueId = ueId;
1267
1268    switch (rbCb->mode)
1269    {
1270       case RLC_MODE_TM:
1271          {
1272             rlcDlTmmReEstablish(gCb,rbCb);
1273             break;
1274          }
1275
1276       case RLC_MODE_UM:
1277          {
1278             rlcDlUmmReEstablish(gCb,rlcId,sndReEstInd,rbCb);
1279             break;
1280          }
1281
1282       case RLC_MODE_AM:
1283          {           
1284             rlcAmmDlReEstablish(gCb, rlcId, rbCb);
1285             break;
1286          }
1287    }
1288
1289    /* Fill entCfm structure */
1290    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1291       CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1292
1293    return ROK;
1294
1295
1296 \f
1297 /** 
1298  * @brief This primitive deletes the RBs in Ue Cb.
1299  *
1300  * @details
1301  *    - If UE ID is 0 then
1302  *      - Status Indication with Reason
1303  *    - Else,
1304  *      - Check for UE CB is present
1305  *      - If yes, Delete all RB CB in UE CB and Delete UE CB also.
1306  *      - Else, Status Indication with Reason
1307  *    - Fill entity confirmation
1308  *
1309  * @param [in]    gCb      -  RLC Instance Control Block
1310  * @param [in]    ueId     -  UE Identifier
1311  * @param [in]    cellId   -  CELL Identifier
1312  * @param [in]    entCfg   -  Entity Configuration to be done.
1313  * @param [out]   entCfm   -  Entity Confirmation
1314  *
1315  * @return  S16
1316  *    -#ROK
1317  *    -#RFAILED
1318  */
1319 S16 rlcCfgDelDlUe
1320 (
1321 RlcCb              *gCb,
1322 CmLteRnti          ueId,
1323 CmLteCellId        cellId,
1324 RlcEntCfgInfo      *entCfg,
1325 RlcEntCfgCfmInfo   *entCfm
1326 )
1327 {
1328    S16        ret;     /* Return Value */
1329    RlcDlUeCb   *ueCb;   /* UE Control Block */
1330
1331    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
1332              "rlcCfgDelUe(ueId(%d), cellId(%d), cfgType(%d))",
1333             ueId, 
1334             cellId, 
1335             entCfg->cfgType);
1336
1337    ret = ROK;
1338
1339    /* Check for ueId is present or not */
1340    if ( ueId == 0 )
1341    {
1342       /* Fill entCfm structure */
1343       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1344           CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1345       RLOG_ARG2(L_ERROR,DBG_RBID,entCfg->rbId,
1346                "ueId(%d), cellId(%d)",
1347                ueId, 
1348                cellId);
1349       return RFAILED;
1350    }
1351
1352    /* Fetch Ue Cb */
1353    ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1354    if (ret != ROK)
1355    {
1356       /* Fill entCfm structure */
1357       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1358          CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1359       RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
1360                "UEID:%d UeCb not found RBID:%d",
1361                ueId,
1362                entCfg->rbId);
1363       return RFAILED;
1364    }
1365
1366 #ifdef LTE_L2_MEAS
1367    rlcDelFrmDlL2Meas(gCb,cellId,ueId);
1368    rlcDbmDelAllDlL2MeasTbFrmUe(gCb,ueCb);
1369 #endif
1370    /* Delete Ue Cb */
1371    rlcDbmDelDlUeCb(gCb,ueCb, FALSE);
1372
1373    /* Fill entCfm structure */
1374    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1375       CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1376
1377    return ROK;
1378
1379
1380
1381 /**
1382  * @brief This primitive deletes the RBs in Ue Cb.
1383  *
1384  * @details
1385  *    - If CELL ID is 0 then
1386  *      - Status Indication with Reason
1387  *    - Else,
1388  *      - Check for CELL CB is present
1389  *      - If yes, Delete all RB CB in CELL CB and Delete CELL CB also.
1390  *      - Else, Status Indication with Reason
1391  *    - Fill entity confirmation
1392  *
1393  * @param [in]    cellId   -  CELL Identifier
1394  * @param [in]    entCfg   -  Entity Configuration to be done.
1395  * @param [out]   entCfm   -  Entity Confirmation
1396  *
1397  * @return S16
1398  *    -#ROK
1399  *    -#RFAILED
1400  */
1401 S16 rlcCfgDelDlCell
1402 (
1403 RlcCb               *gCb,
1404 CmLteCellId        cellId,
1405 RlcEntCfgInfo      *entCfg,
1406 RlcEntCfgCfmInfo   *entCfm
1407 )
1408 {
1409    RlcDlCellCb   *cellCb;   /* UE Control Block */
1410    uint8_t       rbId;      /* RB Identifier */
1411
1412    RLOG_ARG2(L_DEBUG,DBG_RBID,entCfg->rbId,
1413          "rlcCfgDelCell( cellId(%d), cfgType(%d)",
1414          cellId, 
1415          entCfg->cfgType);
1416
1417    cellCb = NULLP;
1418    rbId = entCfg->rbId;
1419
1420    /* Check for ueId is present or not */
1421    if ( cellId == 0 )
1422    {
1423       /* Fill entCfm structure */
1424       RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1425             CKW_CFG_REAS_CELL_UNKWN);
1426       RLOG_ARG1(L_DEBUG,DBG_RBID,entCfg->rbId,
1427                "cellId is 0 (%d) ",
1428                cellId);
1429       return RFAILED;
1430    }
1431
1432    /* Fetch Ue Cb */
1433    rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1434    if (!cellCb)
1435    {
1436       /* Fill entCfm structure */
1437       RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1438             CKW_CFG_REAS_CELL_UNKWN);
1439       RLOG_ARG1(L_ERROR, DBG_CELLID,cellId,
1440                "CellCb not found for RBID:%d",
1441                entCfg->rbId);
1442       return RFAILED;
1443    }
1444
1445    /* Delete Ue Cb */
1446    rlcDbmDelDlCellCb(gCb,cellCb);
1447
1448    /* Fill entCfm structure */
1449   /* kw005.201 added support for L2 Measurement */         
1450    RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_OK,
1451                        CKW_CFG_REAS_NONE);
1452
1453    return ROK;
1454
1455
1456 /**
1457  * @brief This primitive changes the ueId of Ue Cb.
1458  *
1459  * @details
1460  *    - If oldUeId and newUeId are
1461  *      - Confirm the Status with Reason
1462  *    - If UeId not present
1463  *      - Confirm the Status with Reason
1464  *    - Create New UeCb
1465  *    - Copy rbCbs from old UeCb to new UeCb
1466  *    - Delete old UeCb
1467  *    - Fill entity confirmation
1468  *
1469  * @param [in]    ueInfo      -  Old UE Information
1470  * @param [in]    newUeInfo   -  New UE Information
1471  * @param [out]   status      -  Status
1472  *
1473  * @return  S16
1474  *    -# ROK
1475  *    -# RFAILED
1476  */
1477 S16 rlcCfgDlUeIdChng
1478 (
1479 RlcCb        *gCb,
1480 CkwUeInfo   *ueInfo,
1481 CkwUeInfo   *newUeInfo,
1482 CmStatus    *status
1483 )
1484 {
1485    RlcDlUeCb *ueCb;
1486 /*kw004.201 Adding of Missing Trace in LTE RLC PDCP*/
1487
1488    if ( (ueInfo->ueId == newUeInfo->ueId) && 
1489         (ueInfo->cellId == newUeInfo->cellId))
1490    {
1491       status->reason = CKW_CFG_REAS_SAME_UEID;
1492       status->status = CKW_CFG_CFM_NOK; 
1493       RLOG_ARG2(L_ERROR,DBG_CELLID,ueInfo->cellId,
1494             "Old UeId[%d] same as new UeId[%d]",
1495             ueInfo->ueId,
1496             newUeInfo->ueId);
1497       return RFAILED;
1498    } 
1499    
1500    if(ROK == rlcDbmFetchDlUeCb(gCb,newUeInfo->ueId, newUeInfo->cellId, &ueCb))
1501    {
1502       RLOG_ARG1(L_ERROR, DBG_CELLID, newUeInfo->cellId, 
1503             "NewUeId[%d]:ueCb already exists",
1504             newUeInfo->ueId);
1505       status->reason = CKW_CFG_REAS_UE_EXISTS;
1506       status->status = CKW_CFG_CFM_NOK;
1507       return RFAILED;
1508    }
1509   
1510    if(ROK != rlcDbmFetchDlUeCb(gCb,ueInfo->ueId, ueInfo->cellId, &ueCb))
1511    {
1512
1513       RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,
1514             "UeId [%d]: UeCb not found",
1515             ueInfo->ueId);
1516       status->reason = CKW_CFG_REAS_UE_UNKWN;
1517       status->status = CKW_CFG_CFM_NOK;
1518       return RFAILED;
1519    }
1520   
1521 #ifdef LTE_L2_MEAS
1522    rlcHdlMeasDlUeIdChg(gCb, ueInfo->cellId, ueInfo->ueId, newUeInfo->ueId);
1523 #endif   
1524    if(ROK != cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb))
1525    {
1526       RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,
1527             "UeId[%u] HashList Deletion Failed",
1528             ueInfo->ueId);
1529       status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1530       status->status = CKW_CFG_CFM_NOK;
1531       return RFAILED;
1532    }
1533    
1534    /* update the hash key with new values */ 
1535    ueCb->ueId = newUeInfo->ueId;
1536    ueCb->cellId = newUeInfo->cellId;
1537
1538    if(ROK != cmHashListInsert(&(gCb->u.dlCb->ueLstCp), 
1539                               (PTR)ueCb, (uint8_t *)&(ueCb->ueId),
1540                               (uint16_t) sizeof(CmLteRnti)))
1541
1542    {
1543       RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,
1544             "UeId[%u] HashList Insertion Failed",
1545             newUeInfo->ueId);
1546       status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1547       status->status = CKW_CFG_CFM_NOK;
1548       return RFAILED;
1549    }  
1550   
1551    return ROK;
1552
1553
1554 /********************************************************************30**
1555
1556          End of file
1557 **********************************************************************/