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