U8, U16, U32 data type changes
[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 PRIVATE 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 PRIVATE 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 PRIVATE 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 == CM_LTE_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 == CM_LTE_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 #ifdef ANSI
319 PRIVATE S16 rlcCfgFillDlRbCb
320 (
321 RlcCb            *gCb,
322 RlcDlRbCb        *rbCb,
323 RlcDlUeCb        *ueCb,
324 RlcEntCfgInfo   *entCfg
325 )
326 #else
327 PRIVATE S16 rlcCfgFillDlRbCb(gCb,rbCb,entCfg)
328 RlcCb            *gCb;
329 RlcDlRbCb        *rbCb;
330 RlcDlUeCb        *ueCb;
331 RlcEntCfgInfo   *entCfg;
332 #endif
333 {
334
335    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
336          "rlcCfgFillRbCb(ueId(%d),cellId(%d) rbType(%d))",
337                 rbCb->rlcId.ueId,
338                 rbCb->rlcId.cellId, 
339                 entCfg->rbType);
340
341    /* Initialize according to entMode */
342    switch (entCfg->entMode)
343    {
344       case CM_LTE_MODE_TM:
345       {
346          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
347          rbCb->lch.lChType = entCfg->lCh[0].type;
348          rbCb->dir = entCfg->dir;
349          break;
350       }
351
352       case CM_LTE_MODE_UM:
353       {
354          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
355          rbCb->lch.lChType = entCfg->lCh[0].type;
356          rbCb->dir = entCfg->dir;
357          rbCb->m.umDl.snLen = entCfg->m.umInfo.dl.snLen;
358          if (entCfg->m.umInfo.dl.snLen == RLC_UM_CFG_5BIT_SN_LEN)
359             rbCb->m.umDl.modBitMask = 0x1f;
360          else
361             rbCb->m.umDl.modBitMask = 0x3ff;
362
363          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
364
365          break;
366       }
367       case CM_LTE_MODE_AM:
368       {
369          /* Down Link Information 
370           * indx = 0 as Down Link   */
371          rbCb->lch.lChId  = entCfg->lCh[0].lChId;
372          rbCb->lch.lChType = entCfg->lCh[0].type;
373          rbCb->dir = RLC_DIR_BOTH;
374          rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
375          rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
376          rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
377          rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
378          rbCb->m.amDl.snLen = entCfg->m.amInfo.dl.snLen;
379          
380          if(RLC_AM_CFG_12BIT_SN_LEN == rbCb->m.amDl.snLen)
381          {
382             rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_12BITS) - 1; /* 5GNR */
383          }
384          else 
385          {
386             rbCb->m.amDl.snModMask = (1 << RLC_SN_LEN_18BITS) - 1; /* 5GNR */
387          }
388
389          cmInitTimers(&(rbCb->m.amDl.pollRetxTmr), 1);
390       
391         
392          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
393        
394 #ifndef LTE_TDD 
395              uint32_t hashIndex;
396               RLC_ALLOC(gCb,
397                     rbCb->m.amDl.txBufLst,
398                     (RLC_TX_BUF_BIN_SIZE * sizeof(CmLListCp)));
399               for(hashIndex = 0; hashIndex < RLC_TX_BUF_BIN_SIZE; hashIndex++)
400               {
401                   cmLListInit(&(rbCb->m.amDl.txBufLst[hashIndex]));
402               }
403 #endif
404          break;
405       }
406       default:
407       {
408          RLOG_ARG2(L_ERROR,DBG_RBID,entCfg->rbId, 
409                   "Invalid RB Mode ueId(%d),cellId(%d)",
410                   rbCb->rlcId.ueId,
411                   rbCb->rlcId.cellId);
412          return RFAILED;
413       }
414    }
415    rbCb->mode = entCfg->entMode;
416    rbCb->discTmrInt = entCfg->discardTmr;
417
418    return ROK;
419
420
421 \f
422 /** 
423  * @brief This primitive Initializes the RB Cb
424  *
425  * @param [in]    gCb      -  RLC Instance Control Block
426  * @param [out]   rbCb     -  RB Control Block
427  * @param [in]    ptr      -  Void pointer
428  * @param [in]    entCfg   -  Entity Configuration
429  *
430  * @return  S16
431  *    -#ROK
432  *    -#RFAILED
433  */
434 #ifdef ANSI
435 PRIVATE S16 rlcCfgUpdateDlRb
436 (
437 RlcCb            *gCb,
438 RlcDlRbCb        *rbCb,
439 void            *ptr,
440 RlcEntCfgInfo   *entCfg
441 )
442 #else
443 PRIVATE S16 rlcCfgUpdateDlRb(gCb,rbCb, ptr, entCfg)
444 RlcCb            *gCb;
445 RlcDlRbCb        *rbCb;
446 void            *ptr;
447 RlcEntCfgInfo   *entCfg;
448 #endif
449 {
450    
451    if (rbCb->mode != entCfg->entMode)
452    {
453       RLOG_ARG4(L_ERROR,DBG_RBID,rbCb->rlcId.rbId,
454             "RB Mode Mismatch : exp [%d] rcv [%d] UEID:%d CELLID:%d", 
455             rbCb->mode, 
456             entCfg->entMode,
457             rbCb->rlcId.ueId,
458             rbCb->rlcId.cellId);
459       return (CKW_CFG_REAS_RB_MODE_MIS);
460    }
461
462    switch (rbCb->mode)
463    {
464       case CM_LTE_MODE_TM:
465       {
466          RlcDlCellCb *cellCb = (RlcDlCellCb *)ptr;
467
468          rbCb->dir = entCfg->dir;
469          rbCb->lch.lChId = entCfg->lCh[0].lChId;
470          rbCb->lch.lChType = entCfg->lCh[0].type;
471
472          cellCb->lCh[rbCb->lch.lChId - 1].dlRbCb = rbCb;
473          break;
474       }
475
476       case CM_LTE_MODE_UM:
477       {
478          RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
479
480          if (entCfg->lCh[0].type == CM_LTE_LCH_DCCH)
481          {
482             return (CKW_CFG_REAS_LCHTYPE_MIS);
483          }
484          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
485          ueCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rbCb;
486
487          rbCb->lch.lChId = entCfg->lCh[0].lChId;
488          rbCb->lch.lChType = entCfg->lCh[0].type;
489          rbCb->dir = entCfg->dir;
490          break;
491       }
492
493       case CM_LTE_MODE_AM:
494       {
495          RlcDlUeCb *ueCb = (RlcDlUeCb *)ptr;
496
497          ueCb->lCh[rbCb->lch.lChId - 1].dlRbCb = NULLP;
498          ueCb->lCh[entCfg->lCh[1].lChId - 1].dlRbCb = rbCb;
499          
500          /* Down Link */
501          rbCb->lch.lChId = entCfg->lCh[1].lChId;
502          rbCb->lch.lChType = entCfg->lCh[1].type;
503          rbCb->m.amDl.pollRetxTmrInt = entCfg->m.amInfo.dl.pollRetxTmr;
504          rbCb->m.amDl.pollPdu = entCfg->m.amInfo.dl.pollPdu;
505          rbCb->m.amDl.pollByte = entCfg->m.amInfo.dl.pollByte;
506          rbCb->m.amDl.maxRetx = entCfg->m.amInfo.dl.maxRetx;
507          
508          break;
509       }
510    }
511
512 /* AGHOSH */
513    rbCb->discTmrInt = entCfg->discardTmr;
514 /* AGHOSH */
515    return (CKW_CFG_REAS_NONE);
516
517
518 \f
519 /** 
520  * @brief 
521  *    This primitive adds new RB in Ue/Cell Cb.
522  *
523  * @details
524  *    This function does following steps -
525  *    - If UE ID is 0 then
526  *    - Check for CELL CB is present
527  *    - If yes, Check for RB ID
528  *       - If RB ID is present Status Indication with reason
529  *       - Else, Create New RB CB in CELL CB
530  *    - If no Create New CELL CB and RB CB
531  *    - Else,
532  *       - Check for UE CB is present
533  *       - If yes Check for RB ID
534  *          - If RB ID is present Status Indication with reason
535  *          - Else, Create New RB CB in UE CB
536  *          - If no Create New UE CB and RB CB
537  *    - Fill entity confirmation
538  *
539  * @param [in]    gCb      -  RLC Instance Control Block
540  * @param [in]    ueId     -  UE Identifier
541  * @param [in]    cellId   -  CELL Identifier
542  * @param [in]    entCfg   -  Entity Configuration to be done.
543  * @param [out]   entCfm   -  Entity Confirmation.
544  *
545  * @return  S16
546  *    -# ROK
547  *    -# RFAILED
548  */
549 #ifdef ANSI
550 S16 rlcCfgAddDlRb
551 (
552 RlcCb               *gCb,
553 CmLteRnti          ueId,
554 CmLteCellId        cellId,
555 RlcEntCfgInfo      *entCfg,
556 RlcEntCfgCfmInfo   *entCfm
557 )
558 #else
559 S16 rlcCfgAddDlRb(gCb,ueId, cellId, entCfg, entCfm)
560 RlcCb               *gCb;
561 CmLteRnti          ueId;
562 CmLteCellId        cellId;
563 RlcEntCfgInfo      *entCfg;
564 RlcEntCfgCfmInfo   *entCfm;
565 #endif
566 {
567    RlcDlUeCb     *ueCb = NULLP;   /* UE Control Block */
568    RlcDlCellCb   *cellCb;         /* Cell Control Block */
569    RlcDlRbCb     *rlcRbCb;         /* KW RB Control Block */
570    uint8_t       reason;          /* Rb Identifier */
571
572    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId, 
573          "rlcCfgAddRb(cellId(%d),UEID:%d cfgType(%d))",
574                 cellId, 
575                 ueId,
576                 entCfg->cfgType);
577
578    if (cellId == 0)
579    {
580       /* Fill entCfm structure */
581       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
582                           CKW_CFG_REAS_CELL_UNKWN);
583       RLOG_ARG1(L_ERROR,DBG_RBID,entCfg->rbId,
584                "Add DLRb,CellId is 0 for UEID:%d",
585                ueId);
586       return RFAILED;
587    }
588    if ((entCfg->rguSapId >= gCb->genCfg.maxRguSaps) || (entCfg->rguSapId < 0))
589    {
590          RLCDBGP_ERROR(gCb, "rlcCfgAddDlRb(ueId(%u), cellId(%u), Invalid rguSapId (%d)\n",
591                ueId, cellId, entCfg->rguSapId);
592          return RFAILED; 
593    }
594
595
596    /* Process Adding new RB */
597    if (ueId == 0)
598    {
599       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
600       {
601          /* Fill entCfm structure */
602          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
603                              CKW_CFG_CFM_NOK,
604                              CKW_CFG_REAS_RB_UNKWN);
605          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId,
606                   "Invalid RbId ,Max is [%d] CELLID:%d UEID:%d",
607                   RLC_MAX_RB_PER_CELL,
608                   cellId,
609                   ueId);
610          return RFAILED;
611       }
612
613       if (((entCfg->lCh[0].type == CM_LTE_LCH_BCCH) || 
614            (entCfg->lCh[0].type == CM_LTE_LCH_PCCH) ||
615            (entCfg->lCh[0].type == CM_LTE_LCH_CCCH)) &&
616           (entCfg->entMode == CM_LTE_MODE_TM))
617       {
618          /* Cell CB present */
619          rlcDbmFetchDlCellCb(gCb, cellId, &cellCb);
620          if(cellCb)
621          {
622             /* Get rbCb from cellCb->rbCb List */
623             if (( cellCb->rbCb[entCfg->rbId] != NULLP))
624             {
625                /* Fill entCfm structure */
626                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
627                                    CKW_CFG_CFM_NOK,
628                                    CKW_CFG_REAS_RB_PRSNT);
629                RLOG_ARG2(L_WARNING, DBG_CELLID,cellId, 
630                         "RbId [%d] already exists UEID:%d",
631                         entCfg->rbId,
632                         ueId);
633                return RFAILED;
634             }
635          }
636          else  /* Cell CB UNKNOWN */
637          {
638             /* Create CELL CB */
639             if ( ROK != rlcDbmCreateDlCellCb(gCb,cellId, &cellCb))
640             {
641                /* Fill entCfm structure */
642                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
643                                    CKW_CFG_CFM_NOK,
644                                    CKW_CFG_REAS_CELL_CREAT_FAIL);
645                RLOG_ARG2(L_ERROR,DBG_CELLID,cellId,
646                         "cellCb Creation failed RBID:%d UEID:%d",
647                         entCfg->rbId,
648                         ueId);
649                return RFAILED;
650             }
651          }
652
653          /* Validate LChId */
654          if(entCfg->lCh[0].lChId <= 0)
655          {
656             RLOG_ARG3(L_ERROR,DBG_LCID,entCfg->lCh[0].lChId ,
657                      "Invalid LcId CELLID:%d UEID:%d RBID:%d",
658                      cellId,
659                      ueId,
660                      entCfg->rbId);
661             /* Fill entCfm structure */                               
662             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
663                   CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);           
664             return RFAILED;                                        
665          }                                                            
666
667          /* Create RB CB */
668          RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
669          if (!rlcRbCb)
670          {
671             RLOG_ARG2(L_FATAL,DBG_UEID,ueId,
672                      "Memory allocation failed for rbId:%d CELLID:%d",
673                      entCfg->rbId,
674                      ueId);
675             /* Fill entCfm structure */                           
676             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
677                                 CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_CREAT_FAIL); 
678             return RFAILED; 
679          }
680          rlcRbCb->rlcId.rbId = entCfg->rbId;
681          cellCb->rbCb[entCfg->rbId] = rlcRbCb;
682          RLC_LMM_RB_STS_INC(gCb);
683          cellCb->lCh[entCfg->lCh[0].lChId - 1].dlRbCb = rlcRbCb;
684       }
685       else
686       {
687          reason= (entCfg->entMode != CM_LTE_MODE_TM)? CKW_CFG_REAS_RB_MODE_MIS:
688                                                       CKW_CFG_REAS_LCHTYPE_MIS;
689          /* Fill entCfm structure */
690          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
691                              CKW_CFG_CFM_NOK, reason);
692          return RFAILED;
693       }
694    }
695    else
696    {
697       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
698       {
699          /* Fill entCfm structure */
700          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
701                CKW_CFG_REAS_RB_UNKWN);
702          RLOG_ARG2(L_ERROR,DBG_RBID, entCfg->rbId,
703                   "Invalid RbId for RbType[%d] UEID:%d", 
704                   entCfg->rbType,
705                   ueId);
706          return RFAILED;
707       }
708       if ((((entCfg->lCh[0].type == CM_LTE_LCH_DCCH) && 
709             (entCfg->entMode != CM_LTE_MODE_UM) && 
710             (CM_LTE_SRB == entCfg->rbType)) ||
711            ((entCfg->lCh[0].type == CM_LTE_LCH_DTCH) && 
712             (CM_LTE_DRB == entCfg->rbType))) &&
713           (entCfg->entMode != CM_LTE_MODE_TM))
714       {
715          /* UE CB present */
716          if ( rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb) == ROK)
717          {
718             /* Get rbCb from ueCb->rbCb list */
719             RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
720
721             if(( rlcRbCb != NULLP))
722             {
723                /* Fill entCfm structure */
724                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
725                      CKW_CFG_REAS_RB_PRSNT);
726                RLOG_ARG2(L_WARNING, DBG_UEID, ueId,
727                         "CellId[%u]:rbId [%d] already exists",
728                         cellId,
729                         entCfg->rbId);
730                return RFAILED;
731             }
732          }
733          else  /* UE CB UNKNOWN */
734          {
735             /* Create UE CB */
736             if ( rlcDbmCreateDlUeCb(gCb,ueId, cellId, &ueCb) != ROK)
737             {
738                /* Fill entCfm structure */
739                RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
740                      CKW_CFG_REAS_UE_CREAT_FAIL);
741                RLOG_ARG2(L_WARNING, DBG_CELLID,cellId,
742                         "UeId [%u]:ueCb Creation Failed RBID:%d",
743                         ueId,
744                         entCfg->rbId);
745                return RFAILED;
746             }
747          }
748
749          /* Validate LChId for UM and AM modes */
750          if ((entCfg->lCh[0].lChId <= 0) ||
751              ((entCfg->entMode == CM_LTE_MODE_AM)&&
752                (entCfg->lCh[1].lChId <= 0)))
753          {
754             /* Fill entCfm structure */                               
755             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
756                   CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_LCHID);           
757             return RFAILED;                                        
758          }                                                            
759
760          /* Create RB CB */
761          RLC_ALLOC(gCb,rlcRbCb, sizeof (RlcDlRbCb));
762          if (rlcRbCb == NULL)
763          {
764             /* Fill entCfm structure */                           
765             RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,CKW_CFG_CFM_NOK,
766                                     CKW_CFG_REAS_RB_CREAT_FAIL); 
767             RLOG_ARG2(L_FATAL,DBG_UEID,ueId,
768                      "Memory allocation failed RBID:%d CELLID:%d",
769                      entCfg->rbId,
770                      cellId);
771             return RFAILED; 
772          }
773
774          /* copy the RB Cb into UECb */
775          rlcRbCb->rlcId.rbId = entCfg->rbId;
776          if(entCfg->rbType == CM_LTE_SRB)
777             ueCb->srbCb[entCfg->rbId] = rlcRbCb;
778          else
779             ueCb->drbCb[entCfg->rbId] = rlcRbCb;
780          
781          RLC_LMM_RB_STS_INC(gCb);
782
783       }
784       else
785       {
786          if (entCfg->entMode == CM_LTE_MODE_TM)
787          {
788             reason = CKW_CFG_REAS_RB_MODE_MIS;
789          }
790          else
791          {
792             reason = CKW_CFG_REAS_LCHTYPE_MIS;
793          }
794
795          /* Fill entCfm structure */
796          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK, reason);
797          return RFAILED;
798       }
799    }
800
801
802    rlcRbCb->rlcId.cellId = cellId;
803    rlcRbCb->rlcId.ueId   = ueId;
804    rlcRbCb->rlcId.rbType = entCfg->rbType;
805    rlcRbCb->inst         = gCb->init.inst;
806 #ifdef TENB_MULT_CELL_SUPPRT
807    rlcRbCb->rguSapId     = entCfg->rguSapId;
808 #endif
809
810
811    /* Fill RB CB */
812    if (rlcCfgFillDlRbCb(gCb,rlcRbCb, ueCb, entCfg) != ROK)
813    {
814       /* Fill entCfm structure */
815       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
816                CKW_CFG_REAS_RB_CREAT_FAIL);
817
818       /* Delete RB CB created */
819       RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));
820       RLOG_ARG2(L_ERROR,DBG_RBID, entCfg->rbId,
821                "Filling of RbCb failed UEID:%d CELLID:%d",
822                ueId,
823                cellId);
824       return RFAILED;
825    }
826    rlcRbCb->qci = entCfg->qci;
827 #ifdef LTE_L2_MEAS
828    rlcRbCb->ueCb =  ueCb;
829    if (entCfg->lCh[0].type == CM_LTE_LCH_DTCH)
830    {
831       /* ccpu00129778 */
832       rlcAddToDlL2Meas(gCb, rlcRbCb,cellId,ueId); 
833    }
834 #endif /* LTE_L2_MEAS */
835
836    /* Fill entCfm structure */
837    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
838
839    return ROK;
840
841
842 \f
843 /** 
844  * @brief
845  *    This primitive reconfigures the existing RB in Ue/Cell Cb.
846  *
847  * @details
848  *    This primitive executes following steps in reconfiguration of existing
849  *    RB -
850  *    - If UE ID is 0 then
851  *       - Check for CELL CB is present
852  *       - If yes, Check for RB ID
853  *          - If RB ID is present Reconfigure the RB CB
854  *          - Else, Status Indication with Reason
855  *       - Else, Status Indication with Reason
856  *    - Else,
857  *       - Check for UE CB is present
858  *       - If yes, Check for RB ID
859  *          - If RB ID is prenset Reconfigure the CELL CB
860  *          - Else, Status Indication with Reason
861  *       - Else, Status Indication with Reason
862  *    - Fill entity confirmation
863  *
864  * @param [in]    gCb      -  RLC Instance Control Block
865  * @param [in]    ueId     -  UE Identifier
866  * @param [in]    cellId   -  CELL Identifier
867  * @param [in]    entCfg   -  Entity Configuration to be done.
868  * @param [out]   entCfm   -  Entity Confirmation
869  *
870  * @return  S16
871  *    -#ROK
872  *    -#RFAILED
873  */
874 #ifdef ANSI
875 S16 rlcCfgReCfgDlRb
876 (
877 RlcCb               *gCb,
878 CmLteRnti          ueId,
879 CmLteCellId        cellId,
880 RlcEntCfgInfo      *entCfg,
881 RlcEntCfgCfmInfo   *entCfm
882 )
883 #else
884 S16 rlcCfgReCfgDlRb(gCb,ueId, cellId, entCfg, entCfm)
885 RlcCb               *gCb;
886 CmLteRnti          ueId;
887 CmLteCellId        cellId;
888 RlcEntCfgInfo      *entCfg;
889 RlcEntCfgCfmInfo   *entCfm;
890 #endif
891 {
892    RlcDlRbCb     *rbCb;     /* RB Control Block */
893    RlcDlRbCb     tRbCb;     /* KW RB Control Block */
894    RlcDlCellCb   *cellCb;   /* Cell Control Block */
895    RlcDlUeCb     *ueCb;     /* Ue Control Block */
896    uint8_t       ret;
897
898    RLOG_ARG3(L_DEBUG,DBG_UEID,ueId,
899              "rlcCfgReCfgRb(cellId(%d), cfgType(%d)) RBID:%d",
900             cellId, entCfg->cfgType,entCfg->rbId);
901
902
903    /* Check for UeCb or CellCb */
904    if (ueId == 0)
905    { 
906       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
907       {
908          /* Fill entCfm structure */
909          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
910                              CKW_CFG_REAS_RB_UNKWN);
911          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId,
912                   "Invalid RbId , Max is [%d] UEID:%d CELLID:%d",
913                   RLC_MAX_RB_PER_CELL,
914                   ueId,
915                   cellId);
916          return RFAILED;
917       }
918       /* Get cellCb */
919       rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
920       if(!cellCb)
921       {
922          /* Fill entCfm structure */
923          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
924                              CKW_CFG_REAS_CELL_UNKWN);
925          RLOG_ARG3(L_ERROR,DBG_CELLID,cellId,
926                   "CellCb not found ueId:%d RBID:%d CELLID:%d",
927                   ueId,
928                   entCfg->rbId,
929                   cellId);
930          return RFAILED;
931       }
932
933       /* Get rbCb */
934       RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rbCb);
935
936       if (!rbCb)
937       {
938          /* Fill entCfm structure */
939          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
940                CKW_CFG_REAS_RB_UNKWN);
941          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
942                   "CELLID:%d RBID:%d not found",
943                   cellId,
944                   entCfg->rbId);
945          return RFAILED;
946       }
947
948       /* Take backup of rbCb before updating.
949        * Because in failure case restore original rbCb
950        */
951       memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
952
953       /* Update rbCb */
954       ret = rlcCfgUpdateDlRb(gCb,rbCb, cellCb,entCfg);
955       if (ret != ROK)
956       {
957          /* Fill entCfm structure */
958          RLC_CFG_FILL_CFG_CFM(entCfm, 
959                              entCfg->rbId, 
960                              entCfg->rbType, 
961                              CKW_CFG_CFM_NOK,
962                              ret);
963
964          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
965                   "CELLID:%u RBID:%d updation failed",
966                   cellId,
967                   entCfg->rbId);
968          memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
969
970          return (ret);
971       }
972    }
973    else
974    {
975       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
976       {
977          /* Fill entCfm structure */
978          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
979                CKW_CFG_REAS_RB_UNKWN);
980          RLOG_ARG3(L_ERROR,DBG_UEID,ueId,
981                   "CELLID:%d Invalid RBID:%d for RbType[%d]",
982                   cellId,
983                   entCfg->rbId,
984                   entCfg->rbType);
985          return RFAILED;
986       }
987       /* Get ueCb */
988       ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
989       if (ret != ROK)
990       {
991          /* Fill entCfm structure */
992          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
993                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
994          RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
995                   "UEID:%d UeCb not found RBID:%d",
996                   ueId,
997                   entCfg->rbId);
998          return (ret);
999       }
1000
1001       /* Get rbCb */
1002       RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
1003
1004       if ( rbCb == NULLP)
1005       {
1006          /* Fill entCfm structure */
1007          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1008                CKW_CFG_REAS_RB_UNKWN);
1009          RLOG_ARG2(L_ERROR, DBG_UEID,ueId, 
1010                   "CELLID:%d RBID:%d not found",
1011                   cellId,
1012                   entCfg->rbId);
1013          return (ret);
1014       }
1015
1016       /* Take backup of rbCb before updating.
1017        * Because in failure case restore original rbCb
1018        */
1019       memcpy(&tRbCb, rbCb, sizeof(RlcDlRbCb));
1020
1021       /* Update rbCb */
1022       ret = rlcCfgUpdateDlRb(gCb,rbCb,ueCb, entCfg);
1023       if (ret != CKW_CFG_REAS_NONE)
1024       {
1025          /* Fill entCfm structure */
1026          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1027                ret);
1028          RLOG_ARG2(L_ERROR,DBG_UEID,ueId,
1029                   "CELLID:%d RBID:%d updation failed",
1030                   cellId,
1031                   entCfg->rbId);
1032          memcpy(rbCb, &tRbCb, sizeof(RlcDlRbCb));
1033
1034          return (ret);
1035       }
1036    }
1037
1038    /* Fill entCfm structure */
1039    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1040
1041    return ROK;
1042
1043
1044 \f
1045 /** 
1046  * @brief This primitive deletes the existing RB in Ue/Cell Cb.
1047  *
1048  * @details
1049  *    - If UE ID is 0 then
1050  *      - Check for CELL CB is present
1051  *       - If yes, Check for RB ID
1052  *      - If RB ID is prenset Delete the RB CB
1053  *       - If there is no RB CB exist in CELL CB then Delete CELL CB.
1054  *      - Else, Status Indication with Reason
1055  *      - Else, Status Indication with Reason
1056  *    - Else,
1057  *      - Check for UE CB is present
1058  *      - If yes, Check for RB ID
1059  *        - If RB ID is prenset Delete the RB CB
1060  *          - If there is no RB CB exist in UE CB then Delete UE CB.
1061  *        - Else, Status Indication with Reason
1062  *      - Else, Status Indication with Reason
1063  *    - Fill entity confirmation
1064  *
1065  * @param [in]    gCb      -  RLC Instance Control Block
1066  * @param [in]    ueId     -  UE Identifier
1067  * @param [in]    cellId   -  CELL Identifier
1068  * @param [in]    entCfg   -  Entity Configuration to be done.
1069  * @param [out]   entCfm   -  Entity Confirmation
1070  *
1071  * @return  S16
1072  *    -#ROK
1073  *    -#RFAILED
1074  */
1075 #ifdef ANSI
1076 S16 rlcCfgDelDlRb
1077 (
1078 RlcCb               *gCb,
1079 CmLteRnti          ueId,
1080 CmLteCellId        cellId,
1081 RlcEntCfgInfo      *entCfg,
1082 RlcEntCfgCfmInfo   *entCfm
1083 )
1084 #else
1085 S16 rlcCfgDelRb(gCb,ueId, cellId, entCfg, entCfm)
1086 RlcCb               *gCb;
1087 CmLteRnti          ueId;
1088 CmLteCellId        cellId;
1089 RlcEntCfgInfo      *entCfg;
1090 RlcEntCfgCfmInfo   *entCfm;
1091 #endif
1092 {
1093    S16          ret;       /* Return Value */
1094    RlcDlUeCb     *ueCb;     /* UE Control Block */
1095    RlcDlCellCb   *cellCb;   /* UE Control Block */
1096    RlcDlRbCb     *rlcRbCb;   /* KW RB Control Block */
1097
1098    RLOG_ARG3(L_DEBUG,DBG_UEID,ueId, 
1099             "rlcCfgDelRb(RBID(%d), cellId(%d), cfgType(%d))",
1100             entCfg->rbId, 
1101             cellId, 
1102             entCfg->cfgType);
1103
1104    ret = ROK;
1105
1106    /* Get cellCb and delete rbCb from it */
1107    if (ueId == 0)
1108    {
1109       if(entCfg->rbId >= RLC_MAX_RB_PER_CELL)
1110       {
1111          /* Fill entCfm structure */
1112          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1113                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1114          RLOG_ARG3(L_ERROR,DBG_RBID,entCfg->rbId ,
1115                   "Invalid RbId, Max is [%d] UEID:%d CELLID:%d",
1116                   RLC_MAX_RB_PER_CELL,
1117                   ueId,
1118                   cellId);
1119          return RFAILED;
1120       }
1121       /* Get cellCb */
1122       rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1123       if (!cellCb)
1124       {
1125          /* Fill entCfm structure */
1126          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1127                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1128          RLOG_ARG2(L_ERROR,DBG_CELLID,cellId,
1129                   "CellCb not found UEID:%d RBID:%d",
1130                   ueId,
1131                   entCfg->rbId);
1132          return (ret);
1133       }
1134
1135       /* Get rbCb */
1136       RLC_DBM_GET_CELL_RBCB(entCfg->rbId, cellCb->rbCb, rlcRbCb);
1137
1138       if ( rlcRbCb == NULLP)
1139       {
1140          /* Fill entCfm structure */
1141          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1142                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1143          RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1144                   "CellId[%u]:RbId[%d] not found",
1145                   cellId,
1146                   entCfg->rbId);
1147          return (ret);
1148       }
1149
1150       /* Assign NULLP to rbCb in rbCbLst */
1151       cellCb->rbCb[entCfg->rbId] = NULLP;
1152
1153       /* Assign NULLP to dlRbCb/ulRbCb.
1154        * Delete Hashlist allocated for it if any */
1155       cellCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1156       RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));   /*Vartika: Mem leak fix */  
1157    }
1158     /* Get ueCb and delete rbCb from it */
1159    else
1160    {
1161       if (!(RLC_VALIDATE_UE_RBID(entCfg->rbType, entCfg->rbId)))
1162       {
1163          /* Fill entCfm structure */
1164          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1165                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_RB_UNKWN);
1166          RLOG_ARG3(L_ERROR,DBG_RBID, entCfg->rbId,
1167                   "Invalid RbId for RbType[%d] UEID:%d CELLID:%d", 
1168                   entCfg->rbType,
1169                   ueId,
1170                   cellId);
1171          return RFAILED;
1172       }
1173
1174       /* Get ueCb */
1175       ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1176       if (ret != ROK)
1177       {
1178          /* Fill entCfm structure */
1179          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, 
1180                              CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1181          RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
1182                   "UeId [%d]: UeCb not found RBID:%d",
1183                   ueId,
1184                   entCfg->rbId);
1185          return (ret);
1186       }
1187
1188       /* Get rbCb */
1189       RLC_DBM_GET_RBCB_FROM_UECB(entCfg->rbId, entCfg->rbType, ueCb, rlcRbCb);
1190
1191       if ( rlcRbCb == NULLP)
1192       {
1193          /* Fill entCfm structure */
1194          RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1195                CKW_CFG_REAS_RB_UNKWN);
1196          RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1197                   "CellId[%u]:RbId[%d] not found",
1198                   cellId,
1199                   entCfg->rbId);
1200          return (ret);
1201       }
1202
1203       ueCb->lCh[rlcRbCb->lch.lChId - 1].dlRbCb = NULLP;
1204
1205 #ifdef LTE_L2_MEAS
1206       RLC_UPD_L2_DECR_NONIP_PER_QCI_RB_COUNT(gCb, rlcRbCb);
1207 #endif
1208       /* Free the Buffers of RbCb */
1209       if( CM_LTE_MODE_UM == rlcRbCb->mode)
1210       {
1211          rlcUmmFreeDlRbCb(gCb,rlcRbCb);
1212          /* Delete RbCb  */
1213          RLC_FREE(gCb,rlcRbCb, sizeof(RlcDlRbCb));     
1214       }
1215       else if( CM_LTE_MODE_AM == rlcRbCb->mode)
1216       {
1217          rlcAmmFreeDlRbCb(gCb,rlcRbCb);
1218       }
1219
1220       /* Assign NULLP to rbCb in rbCbLst */
1221       if ( entCfg->rbType == CM_LTE_SRB )
1222       {
1223          ueCb->srbCb[entCfg->rbId] = NULLP;
1224       }
1225       else
1226       {
1227          ueCb->drbCb[entCfg->rbId] = NULLP;
1228       }
1229    }
1230
1231    RLC_LMM_RB_STS_DEC(gCb);
1232
1233    /* Fill entCfm structure */
1234    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CKW_CFG_CFM_OK, 
1235                        CKW_CFG_REAS_NONE);
1236
1237    return (ret);
1238
1239
1240 \f
1241 /** 
1242  * @brief This primitive re-establish the existing RB in Ue/Cell Cb.
1243  *
1244  * @details
1245  *    - If UE ID is 0 then
1246  *      - Check for CELL CB is present
1247  *      - If yes, Check for RB ID
1248  *        - If RB ID is prenset initialize the parameters of the RB CB
1249  *        - Else, Status Indication with Reason
1250  *      - Else, Status Indication with Reason
1251  *    - Else,
1252  *      - Check for UE CB is present
1253  *      - If yes, Check for RB ID
1254  *        - If RB ID is prenset initialize the parameters of the RB CB
1255  *        - Else, Status Indication with Reason
1256  *      - Else, Status Indication with Reason
1257  *    - Fill entity confirmation
1258  *
1259  * @param [in]    gCb      -  RLC Instance Control Block
1260  * @param [in]    ueId     -  UE Identifier
1261  * @param [in]    cellId   -  CELL Identifier
1262  * @param [in]    entCfg   -  Entity Configuration to be done.
1263  * @param [out]   entCfm   -  Entity Confirmation
1264  *
1265  * @return  S16
1266  *    -# ROK
1267  *    -# RFAILED
1268  */
1269 #ifdef ANSI
1270 S16 rlcCfgReEstDlRb
1271 (
1272 RlcCb               *gCb,
1273 CmLteRnti          ueId,
1274 CmLteCellId        cellId,
1275 Bool               sndReEstInd,
1276 RlcEntCfgInfo      *entCfg,
1277 RlcEntCfgCfmInfo   *entCfm
1278 )
1279 #else
1280 S16 rlcCfgReEstDlRb(gCb,ueId, cellId,sndReEstInd,entCfg, entCfm)
1281 RlcCb               *gCb;
1282 CmLteRnti          ueId;
1283 CmLteCellId        cellId;
1284 Bool               sndReEstInd;
1285 RlcEntCfgInfo      *entCfg;
1286 RlcEntCfgCfmInfo   *entCfm;
1287 #endif
1288 {
1289    RlcDlRbCb     *rbCb;   /* RB Control Block */
1290    CmLteRlcId   rlcId;   /* RLC Identifier */
1291
1292    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
1293             "rlcCfgReEstDlRb(ueId(%d), cellId(%d), cfgType(%d))",
1294             ueId, 
1295             cellId, 
1296             entCfg->cfgType);
1297
1298    /* Get rlcId */
1299    rlcId.ueId = ueId;
1300    rlcId.cellId = cellId;
1301    rlcId.rbId = entCfg->rbId;
1302    rlcId.rbType = entCfg->rbType;
1303
1304    rlcDbmFetchDlRbCbByRbId(gCb,&rlcId, &rbCb);
1305    if (rbCb == NULLP)
1306    {
1307       /* Fill entCfm structure */
1308       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, rlcId.rbType, CKW_CFG_CFM_NOK,
1309             CKW_CFG_REAS_RB_UNKWN);
1310       RLOG_ARG2(L_ERROR, DBG_UEID,ueId,
1311                "CellId[%u]:RbId[%d] not found",
1312                cellId,
1313                entCfg->rbId);
1314       return RFAILED;
1315    }
1316
1317    rbCb->rlcId.ueId = ueId;
1318
1319    switch (rbCb->mode)
1320    {
1321       case CM_LTE_MODE_TM:
1322          {
1323             rlcDlTmmReEstablish(gCb,rbCb);
1324             break;
1325          }
1326
1327       case CM_LTE_MODE_UM:
1328          {
1329             rlcDlUmmReEstablish(gCb,rlcId,sndReEstInd,rbCb);
1330             break;
1331          }
1332
1333       case CM_LTE_MODE_AM:
1334          {           
1335             rlcAmmDlReEstablish(gCb, rlcId, rbCb);
1336             break;
1337          }
1338    }
1339
1340    /* Fill entCfm structure */
1341    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1342       CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1343
1344    return ROK;
1345
1346
1347 \f
1348 /** 
1349  * @brief This primitive deletes the RBs in Ue Cb.
1350  *
1351  * @details
1352  *    - If UE ID is 0 then
1353  *      - Status Indication with Reason
1354  *    - Else,
1355  *      - Check for UE CB is present
1356  *      - If yes, Delete all RB CB in UE CB and Delete UE CB also.
1357  *      - Else, Status Indication with Reason
1358  *    - Fill entity confirmation
1359  *
1360  * @param [in]    gCb      -  RLC Instance Control Block
1361  * @param [in]    ueId     -  UE Identifier
1362  * @param [in]    cellId   -  CELL Identifier
1363  * @param [in]    entCfg   -  Entity Configuration to be done.
1364  * @param [out]   entCfm   -  Entity Confirmation
1365  *
1366  * @return  S16
1367  *    -#ROK
1368  *    -#RFAILED
1369  */
1370 #ifdef ANSI
1371 S16 rlcCfgDelDlUe
1372 (
1373 RlcCb               *gCb,
1374 CmLteRnti          ueId,
1375 CmLteCellId        cellId,
1376 RlcEntCfgInfo      *entCfg,
1377 RlcEntCfgCfmInfo   *entCfm
1378 )
1379 #else
1380 S16 rlcCfgDelDlUe(ueId, cellId, entCfg, entCfm)
1381 RlcCb               *gCb;
1382 CmLteRnti          ueId;
1383 CmLteCellId        cellId;
1384 RlcEntCfgInfo      *entCfg;
1385 RlcEntCfgCfmInfo   *entCfm;
1386 #endif
1387 {
1388    S16        ret;     /* Return Value */
1389    RlcDlUeCb   *ueCb;   /* UE Control Block */
1390
1391    RLOG_ARG3(L_DEBUG,DBG_RBID,entCfg->rbId,
1392              "rlcCfgDelUe(ueId(%d), cellId(%d), cfgType(%d))",
1393             ueId, 
1394             cellId, 
1395             entCfg->cfgType);
1396
1397    ret = ROK;
1398
1399    /* Check for ueId is present or not */
1400    if ( ueId == 0 )
1401    {
1402       /* Fill entCfm structure */
1403       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1404           CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1405       RLOG_ARG2(L_ERROR,DBG_RBID,entCfg->rbId,
1406                "ueId(%d), cellId(%d)",
1407                ueId, 
1408                cellId);
1409       return RFAILED;
1410    }
1411
1412    /* Fetch Ue Cb */
1413    ret = rlcDbmFetchDlUeCb(gCb,ueId, cellId, &ueCb);
1414    if (ret != ROK)
1415    {
1416       /* Fill entCfm structure */
1417       RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1418          CKW_CFG_CFM_NOK, CKW_CFG_REAS_UE_UNKWN);
1419       RLOG_ARG2(L_ERROR,DBG_CELLID, cellId,
1420                "UEID:%d UeCb not found RBID:%d",
1421                ueId,
1422                entCfg->rbId);
1423       return RFAILED;
1424    }
1425
1426 #ifdef LTE_L2_MEAS
1427    rlcDelFrmDlL2Meas(gCb,cellId,ueId);
1428    rlcDbmDelAllDlL2MeasTbFrmUe(gCb,ueCb);
1429 #endif
1430    /* Delete Ue Cb */
1431    rlcDbmDelDlUeCb(gCb,ueCb, FALSE);
1432
1433    /* Fill entCfm structure */
1434    RLC_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType,
1435       CKW_CFG_CFM_OK, CKW_CFG_REAS_NONE);
1436
1437    return ROK;
1438
1439
1440
1441 /**
1442  * @brief This primitive deletes the RBs in Ue Cb.
1443  *
1444  * @details
1445  *    - If CELL ID is 0 then
1446  *      - Status Indication with Reason
1447  *    - Else,
1448  *      - Check for CELL CB is present
1449  *      - If yes, Delete all RB CB in CELL CB and Delete CELL CB also.
1450  *      - Else, Status Indication with Reason
1451  *    - Fill entity confirmation
1452  *
1453  * @param [in]    cellId   -  CELL Identifier
1454  * @param [in]    entCfg   -  Entity Configuration to be done.
1455  * @param [out]   entCfm   -  Entity Confirmation
1456  *
1457  * @return S16
1458  *    -#ROK
1459  *    -#RFAILED
1460  */
1461 #ifdef ANSI
1462 S16 rlcCfgDelDlCell
1463 (
1464 RlcCb               *gCb,
1465 CmLteCellId        cellId,
1466 RlcEntCfgInfo      *entCfg,
1467 RlcEntCfgCfmInfo   *entCfm
1468 )
1469 #else
1470 S16 rlcCfgDelCell(gCb,cellId, entCfg, entCfm)
1471 RlcCb               *gCb;
1472 CmLteCellId        cellId;
1473 RlcEntCfgInfo      *entCfg;
1474 RlcEntCfgCfmInfo   *entCfm;
1475 #endif
1476 {
1477    RlcDlCellCb   *cellCb;   /* UE Control Block */
1478    uint8_t       rbId;      /* RB Identifier */
1479
1480    RLOG_ARG2(L_DEBUG,DBG_RBID,entCfg->rbId,
1481          "rlcCfgDelCell( cellId(%d), cfgType(%d)",
1482          cellId, 
1483          entCfg->cfgType);
1484
1485    cellCb = NULLP;
1486    rbId = entCfg->rbId;
1487
1488    /* Check for ueId is present or not */
1489    if ( cellId == 0 )
1490    {
1491       /* Fill entCfm structure */
1492       RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1493             CKW_CFG_REAS_CELL_UNKWN);
1494       RLOG_ARG1(L_DEBUG,DBG_RBID,entCfg->rbId,
1495                "cellId is 0 (%d) ",
1496                cellId);
1497       return RFAILED;
1498    }
1499
1500    /* Fetch Ue Cb */
1501    rlcDbmFetchDlCellCb(gCb,cellId, &cellCb);
1502    if (!cellCb)
1503    {
1504       /* Fill entCfm structure */
1505       RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_NOK,
1506             CKW_CFG_REAS_CELL_UNKWN);
1507       RLOG_ARG1(L_ERROR, DBG_CELLID,cellId,
1508                "CellCb not found for RBID:%d",
1509                entCfg->rbId);
1510       return RFAILED;
1511    }
1512
1513    /* Delete Ue Cb */
1514    rlcDbmDelDlCellCb(gCb,cellCb);
1515
1516    /* Fill entCfm structure */
1517   /* kw005.201 added support for L2 Measurement */         
1518    RLC_CFG_FILL_CFG_CFM(entCfm, rbId, entCfg->rbType, CKW_CFG_CFM_OK,
1519                        CKW_CFG_REAS_NONE);
1520
1521    return ROK;
1522
1523
1524 /**
1525  * @brief This primitive changes the ueId of Ue Cb.
1526  *
1527  * @details
1528  *    - If oldUeId and newUeId are
1529  *      - Confirm the Status with Reason
1530  *    - If UeId not present
1531  *      - Confirm the Status with Reason
1532  *    - Create New UeCb
1533  *    - Copy rbCbs from old UeCb to new UeCb
1534  *    - Delete old UeCb
1535  *    - Fill entity confirmation
1536  *
1537  * @param [in]    ueInfo      -  Old UE Information
1538  * @param [in]    newUeInfo   -  New UE Information
1539  * @param [out]   status      -  Status
1540  *
1541  * @return  S16
1542  *    -# ROK
1543  *    -# RFAILED
1544  */
1545 #ifdef ANSI
1546 S16 rlcCfgDlUeIdChng
1547 (
1548 RlcCb        *gCb,
1549 CkwUeInfo   *ueInfo,
1550 CkwUeInfo   *newUeInfo,
1551 CmStatus    *status
1552 )
1553 #else
1554 S16 rlcCfgDlUeIdChng(gCb,ueInfo,newUeInfo,status)
1555 RlcCb        *gCb;
1556 CkwUeInfo   *ueInfo;
1557 CkwUeInfo   *newUeInfo;
1558 CmStatus    *status;
1559 #endif
1560 {
1561    RlcDlUeCb *ueCb;
1562 /*kw004.201 Adding of Missing Trace in LTE RLC PDCP*/
1563
1564    if ( (ueInfo->ueId == newUeInfo->ueId) && 
1565         (ueInfo->cellId == newUeInfo->cellId))
1566    {
1567       status->reason = CKW_CFG_REAS_SAME_UEID;
1568       status->status = CKW_CFG_CFM_NOK; 
1569       RLOG_ARG2(L_ERROR,DBG_CELLID,ueInfo->cellId,
1570             "Old UeId[%d] same as new UeId[%d]",
1571             ueInfo->ueId,
1572             newUeInfo->ueId);
1573       return RFAILED;
1574    } 
1575    
1576    if(ROK == rlcDbmFetchDlUeCb(gCb,newUeInfo->ueId, newUeInfo->cellId, &ueCb))
1577    {
1578       RLOG_ARG1(L_ERROR, DBG_CELLID, newUeInfo->cellId, 
1579             "NewUeId[%d]:ueCb already exists",
1580             newUeInfo->ueId);
1581       status->reason = CKW_CFG_REAS_UE_EXISTS;
1582       status->status = CKW_CFG_CFM_NOK;
1583       return RFAILED;
1584    }
1585   
1586    if(ROK != rlcDbmFetchDlUeCb(gCb,ueInfo->ueId, ueInfo->cellId, &ueCb))
1587    {
1588
1589       RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,
1590             "UeId [%d]: UeCb not found",
1591             ueInfo->ueId);
1592       status->reason = CKW_CFG_REAS_UE_UNKWN;
1593       status->status = CKW_CFG_CFM_NOK;
1594       return RFAILED;
1595    }
1596   
1597 #ifdef LTE_L2_MEAS
1598    rlcHdlMeasDlUeIdChg(gCb, ueInfo->cellId, ueInfo->ueId, newUeInfo->ueId);
1599 #endif   
1600    if(ROK != cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb))
1601    {
1602       RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,
1603             "UeId[%u] HashList Deletion Failed",
1604             ueInfo->ueId);
1605       status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1606       status->status = CKW_CFG_CFM_NOK;
1607       return RFAILED;
1608    }
1609    
1610    /* update the hash key with new values */ 
1611    ueCb->ueId = newUeInfo->ueId;
1612    ueCb->cellId = newUeInfo->cellId;
1613
1614    if(ROK != cmHashListInsert(&(gCb->u.dlCb->ueLstCp), 
1615                               (PTR)ueCb, (uint8_t *)&(ueCb->ueId),
1616                               (uint16_t) sizeof(CmLteRnti)))
1617
1618    {
1619       RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,
1620             "UeId[%u] HashList Insertion Failed",
1621             newUeInfo->ueId);
1622       status->reason = CKW_CFG_REAS_UE_CREAT_FAIL;
1623       status->status = CKW_CFG_CFM_NOK;
1624       return RFAILED;
1625    }  
1626   
1627    return ROK;
1628
1629
1630 /********************************************************************30**
1631
1632          End of file
1633 **********************************************************************/