Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_cfg_ul.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 PDCP - Configuration Manager file
22
23         Type:    C source file
24
25         Desc:    It contains the following configuraiton primtives
26                     -- pjCfgAddRb 
27                     -- pjCfgReCfgRb 
28                     -- pjCfgDelRb 
29                     -- pjCfgReEstRb 
30                     -- pjCfgDelUe 
31                     -- pjCfgPrcSecCfg 
32                     -- pjCfgUeIdChng 
33                     -- pjCfgPrcCount 
34                     -- pjCfgPrcSduSta 
35
36         File:     pj_cfg_ul.c
37
38 *********************************************************************21*/
39 static const char* RLOG_MODULE_NAME="PDCP";
40 static int RLOG_MODULE_ID=1024;
41 static int RLOG_FILE_ID=213;
42
43 /** @file gp_pj_cfg.c
44 @brief LTE PDCP Configuration Module
45 **/
46
47 \f
48 /* header (.h) include files */
49 #include "envopt.h"             /* environment options */
50 #include "envdep.h"             /* environment dependent */
51 #include "envind.h"             /* environment independent */
52
53 #include "gen.h"                /* general */
54 #include "ssi.h"                /* system services interface */
55 #include "cm5.h"                /* Timer Functions */
56 #include "cm_lte.h"             /* common LTE header file */
57 #include "cm_hash.h"            /* common hash module  file */
58 #include "cm_llist.h"           /* common list header file */
59 #include "cpj.h"                /* RRC layer */
60 #include "pju.h"                /* PDCP service user */
61 #include "lpj.h"                /* RRC layer */
62 #include "pj_env.h"             /* RLC environment options */
63 #include "pj.h"                 /* RLC layer */
64 #include  "pj_ul.h"
65 #include "pj_err.h"
66
67
68
69 /* header/extern include files (.x) */
70
71 #include "gen.x"                /* general */
72 #include "ssi.x"                /* system services interface */
73 #include "cm_lib.x"             /* common library */
74 #include "cm5.x"                /* Timer Functions */
75 #include "cm_hash.x"            /* common hash module */
76 #include "cm_lte.x"             /* common LTE file */
77 #include "cm_llist.x"           /* common list header file */
78 #include "cpj.x"                /* RRC layer */
79 #include "pju.x"                /* PDCP service user */
80 #include "lpj.x"                /* LM Interface */
81 #include "pj.x"                 /* RLC layer */
82 #include "pj_udx.h"
83 #include "pj_udx.x"
84 #include "pj_ul.x"
85
86 /* Proto types declarations for local functions */
87  
88 PRIVATE S16 pjCfgFillPjUlRbCb ARGS ((
89 PjCb            *gCb,
90 PjUlRbCb        *rbCb,
91 PjUlUeCb        *ueCb,
92 U8              isHo,
93 CpjCfgEnt       *cfgEnt,
94 CpjCfmEnt       *cfmEnt
95 ));
96
97 PRIVATE S16 pjCfgUpdUlCompInfo  ARGS ((
98 PjCb                   *gCb,
99 PjUlRbCb               *rbCb,
100 PjUlUeCb               *ueCb,
101 CpjHdrCompCfg        *rohcCfg
102 ));
103
104 #ifdef LTE_L2_MEAS
105 PRIVATE S16 pjAddToUlL2Meas ARGS ((
106 PjCb *gCb, 
107 PjUlRbCb *kwRbCb,
108 U8 cellId,
109 U16 ueId
110 ));
111 #endif
112
113 /* Store the Profile ID into array index */
114 /* RRC is not sending the profile id directly. It will give
115    the for all the profiles with True/False. PDCP will derive the profile
116    based on this profile Id list */
117
118 PRIVATE U16  rohcProfId[CPJ_MAX_ROHC_PROF_LIST]=    { 0x0001, 0x0002, 0x0003, 0x0004,
119                                               0x0006, 0x0101, 0x0102, 0x0103, 
120                                               0x0104};
121 /** @addtogroup cfgdata */
122 /*@{*/
123 /** 
124 * @brief
125
126 *   Hanlder to process the configuration recieved from the upper layer and update the pdcp
127 *   data base.
128 *
129 * @b Description: 
130 *     1. This function create a new  PDCP RB Cb. @n
131 *     2. Newly created PDCP RB Cb will be placed in Data base with the  configuration
132 *     informtion received.  @n
133 *     3. Return Success or Failure to the caller with reason and status
134 *     information. @n
135  
136  * @param [in]    ueId     -  UE Identifier
137  * @param [in]    cellId   -  CELL Identifier
138  * @param [in]    entCfg   -  Entity Configuration to be done.
139  * @param [out]   entCfm   -  Entity Confirmation.
140  * 
141  * @return  ROK
142  */
143 #ifdef ANSI
144 PUBLIC S16 pjCfgAddUlRb
145 (
146 PjCb              *gCb,
147 CmLteRnti         ueId,
148 CmLteCellId       cellId,
149 U8                isHo,
150 CpjCfgEnt         *entCfg,
151 PjUlUeCb          **ueCb,
152 CpjCfmEnt         *entCfm
153 )
154 #else
155 PUBLIC S16 pjCfgAddUlRb (gCb, ueId, cellId,isHo, entCfg, entCfm)
156 PjCb              *gCb;
157 CmLteRnti         ueId;
158 CmLteCellId       cellId;
159 U8                isHo;
160 CpjCfgEnt         *entCfg;
161 PjUlUeCb          **ueCb;
162 CpjCfmEnt         *entCfm;
163 #endif
164 {
165    S16              ret;
166    PjUlRbCb         *rbCb;  /* Rb Cb Pointer */
167
168    TRC3(pjCfgAddUlRb);  
169
170    /* Initialization */
171    ret  = ROK;
172    rbCb = NULLP;
173
174    RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)",
175                      cellId, ueId);
176
177    if( NULLP == *ueCb)
178    { 
179       /* Ue Cb is not present, Create Ue Cb */   
180       if ( pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb) != ROK)
181       {
182          /* Ue Cb allocation failed  */   
183          PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
184                CPJ_CFG_REAS_UE_CREAT_FAIL);
185
186          RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "Creating UE Cb Failed -- cellId(%d)",
187                      cellId);
188          RETVALUE(ret);
189       } 
190    }
191
192    (*ueCb)->inst = gCb->init.inst;
193    /* Rb Id is allowed range or not */   
194    PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret);
195    if ( ROK != ret)
196    { 
197       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
198          CPJ_CFG_REAS_INVALID_RBID);
199
200       RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Invalid RB ID-- cellId(%d),RB Id(%d)",
201                      cellId, entCfg->rbId);
202       RETVALUE(ret);
203    }
204
205
206    /* Find Rb Cb already exist or not */   
207    PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb);
208
209    if (NULLP != rbCb)
210    {
211       RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists",
212             cellId,entCfg->rbId);
213       /* Rb Cb already exist for pdpcp */   
214       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
215             CPJ_CFG_REAS_SAME_RBID);
216       RETVALUE(RFAILED);
217    }
218    else if (NULLP == rbCb)
219    {
220       /* Create Rb Cb and place in Ue Cb */   
221       rbCb =   pjDbmCreateUlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP); 
222       if(NULLP == rbCb)
223       {
224          RLOG_ARG2(L_ERROR, DBG_UEID, ueId,"CellId [%u]:Creation of rbCb with id [%d] failed", 
225                cellId, entCfg->rbId);
226          /* Create Rb Cb Failed*/   
227          PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
228                CPJ_CFG_REAS_ENT_CREAT_FAIL);
229          RETVALUE(RFAILED);
230       } 
231    }
232
233    /* Copy the Recived information into RbCb */ 
234    ret = pjCfgFillPjUlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm);
235
236    /* Fill the Cfm status and Reason */
237    PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
238          CPJ_CFG_REAS_NONE);
239
240    RETVALUE(ret);
241 } /* pjCfgAddRb */
242
243 /**
244 * @brief 
245 *
246 *   Hanlder to update the PJRB with the received infromation during
247 *   configuration or re configuration. 
248 *
249 * @b Description: 
250 *     1. update the data base with the  new configuration informtion received.  @n
251 *     2. update the data base with the  new re-configuration informtion received.  @n
252 *     3. If required Initiliaze the tx/rx Buffers and Timers. @n
253 *     4. Return Success or Failure to the caller with reason and status
254 *     information. @n
255 *
256  * @param [out]   rbCb     -  RB Control Block
257  * @param [out]   entCfm   -  PDCP Entiry Confirmation 
258  * @param [in]    ueCb     -  UE Control Block
259  * @param [in]    entCfg   -  PDCP Entity Configuration
260  *
261  * @return  ROK
262  */
263 #ifdef ANSI
264 PRIVATE S16 pjCfgFillPjUlRbCb
265 (
266 PjCb            *gCb,
267 PjUlRbCb        *pjRbCb,
268 PjUlUeCb        *ueCb,
269 U8               isHo,
270 CpjCfgEnt       *cfgEnt,
271 CpjCfmEnt       *cfmEnt
272 )
273 #else
274 PRIVATE S16 pjCfgFillPjUlRbCb(gCb, pjRbCb, ueCb, isHo, cfgEnt, cfmEnt)
275 PjCb            *gCb;
276 PjUlRbCb        *pjRbCb;
277 PjUlUeCb        *ueCb;
278 U8               isHo;
279 CpjCfgEnt       *cfgEnt;
280 CpjCfmEnt       *cfmEnt;
281 #endif
282 {
283    S16            ret;
284    U8             *bitMap;  /* Bitmap status report buffer      */
285    U16            bMapLen; /* Bit Map length */
286    /* kw005.201 added support for L2 measurement */
287    
288    TRC3(pjCfgFillPjUlRbCb);
289
290    /* Initialization */
291    ret     = ROK;
292    bMapLen = 0;
293
294    RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId,"Received Fill RB Req For "
295                  "cellId(%d), rbId(%d), cfgType(%d)",
296                  ueCb->key.cellId, cfgEnt->rbId, cfgEnt->cfgType);
297
298    switch (cfgEnt->cfgType)
299    {
300       /* Cfg Type received as ADD RB */
301       case CPJ_CFG_ADD:
302          {
303             pjRbCb->state  =   PJ_STATE_NORMAL;
304             pjRbCb->rbId   =   cfgEnt->rbId;
305             pjRbCb->rbType =   cfgEnt->rbType;
306             pjRbCb->mode   =   cfgEnt->m.addCfg.rlcInfo.mode;
307             pjRbCb->dir    =   cfgEnt->m.addCfg.rlcInfo.dir;
308             pjRbCb->ueCb   =   ueCb;
309
310             if(PJ_SRB == pjRbCb->rbType)
311             {
312                /* SN length is fixed for SRB */
313                pjRbCb->snLen  = PJ_SRB_SN_LEN;
314                ueCb->numSrbs++;
315             }
316             else
317             {
318                if (CM_LTE_MODE_UM == pjRbCb->mode)
319                {   /* SN length can be 7 bit or 12 bit in UM mode */
320                   pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize;
321 #ifdef NR_PDCP_DRB_SN_18_BIT
322                   pjRbCb->snLen  =   PJ_18_BIT_SN;
323 #else
324                   pjRbCb->snLen  =   PJ_12_BIT_SN;
325 #endif
326                }
327                else
328                {
329                   /* SN length can be 12/15 bit for AM mode */
330                   pjRbCb->snLen  =   cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize;
331 #ifdef NR_PDCP_DRB_SN_18_BIT
332                   pjRbCb->snLen  =   PJ_18_BIT_SN;
333 #else
334                   pjRbCb->snLen  =   PJ_12_BIT_SN;
335 #endif
336                   if (isHo)
337                   {
338                      pjRbCb->state = PJ_STATE_HO;
339                   }
340                }
341                ueCb->numDrbs++;
342             }
343             /* Initialize all off board  timers */
344 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
345             cmInitTimers(&pjRbCb->ulCb.obdTmr,PJ_RB_MAX_TIMERS); 
346 #endif                  
347
348             RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
349                   "RB Add Req Received with - Dir(%d),mode(%d)",
350                          pjRbCb->dir, pjRbCb->mode);
351
352             pjRbCb->ulCb.discReqd   = cfgEnt->m.addCfg.discReqd;
353             pjRbCb->ulCb.staRepReqd = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.statusRepReqd;
354
355             /*Initialization for Rx Buf */
356             gCb->pjGenCfg.nmbUlBins = PJ_MAX_HASH_BINS;
357             pjDbmBufInit(gCb, &pjRbCb->ulCb.recBuf,gCb->pjGenCfg.nmbUlBins);
358             cmLListInit(&pjRbCb->ulCb.ulPktLst);
359             //pjRbCb->ulCb.lastSubCnt = 0xffffffff;
360             
361
362             /* Update the Compressor Informatio in Rb Cb */
363             if(cfgEnt->rbType == CM_LTE_DRB)
364             {
365                ret=pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb,&cfgEnt->m.addCfg.hdrCompCfg);
366 /* kw005.201 added support for L2 measurement */
367 #ifdef LTE_L2_MEAS
368                pjRbCb->qci =  cfgEnt->m.addCfg.qci;
369                pjAddToUlL2Meas(gCb,pjRbCb,
370                                ueCb->key.cellId,ueCb->key.ueId); 
371 #endif
372             }
373             /* TODO: once APP and RRC changes are done, we can enable the below line */
374             //pjRbCb->reOrdrTmrVal = cfgEnt->m.addCfg.reOrdrTmrVal;
375             pjRbCb->reOrdrTmrVal = 8000; 
376             cmInitTimers(&(pjRbCb->ulCb.tReordTmr), 1); 
377             break;
378          }
379
380          /* Cfg Type received as Modify RB */
381       case CPJ_CFG_MODIFY:
382          {
383             /* Store the received Information */
384             if(CPJ_RECFG_DISRQD & cfgEnt->m.modCfg.bitFlag)
385                pjRbCb->ulCb.discReqd   = cfgEnt->m.modCfg.discReqd;
386             
387             if(CPJ_RECFG_REORDTMR & cfgEnt->m.modCfg.bitFlag)
388             {
389             
390                /* TODO: once APP and RRC changes are done, we can enable the below line */
391                //pjRbCb->reOrdrTmrVal = cfgEnt->m.modCfg.reOrdrTmrVal;
392                pjRbCb->reOrdrTmrVal = 8000;
393                Bool tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
394                if(tmrRunning)
395                {
396                   /*  update RX_REORD to RX_NEXT; */
397                   pjRbCb->ulCb.rxReord = pjRbCb->ulCb.rxNext;
398
399                   /*  stop and restart t-Reordering. */
400                   pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
401                   pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR);
402                }
403             }
404             
405             /* Header Compression profile has been modified */
406             if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed)
407             {
408                /* Close All the channels */
409                pjUtlUlCmpReset(gCb, pjRbCb); 
410                pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg);
411             }
412
413             /* In case of Hand off scenario: At Target eNode-B, 
414                Handoff information will send in re-cfg req */
415
416             if(TRUE  & cfgEnt->m.modCfg.hoInfo.isHoPres)
417             {
418                /* Store the HO information  and call for Status Report
419                 * Generation also */
420               
421                /* Down Up Lin Information present */
422                if(CPJ_HO_UL & cfgEnt->m.modCfg.hoInfo.isHoPres)
423                {
424                   RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
425                         "Received PDCP Update from Application for dir(%d), mode(%d)",
426                                pjRbCb->dir, pjRbCb->mode);
427
428                   pjRbCb->ulCb.rxDeliv = cfgEnt->m.modCfg.hoInfo.ulCount;
429                   pjRbCb->ulCb.rxNext = cfgEnt->m.modCfg.hoInfo.ulCount;
430                   if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen)
431                   {
432                      pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen;
433                   }
434                   /* Store the Count in ulCb, this is needed while sending PDCP Status Report */
435                   bMapLen = cfgEnt->m.modCfg.hoInfo.numBits;
436                   bitMap = cfgEnt->m.modCfg.hoInfo.ulBitMap;
437
438                   /* Build and send the Status Report to RLC */
439                   /* Send the FMS & bitmap retrieved now from App */
440                   RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId,
441                           "Sending PDCP Status Report to UE ");
442
443                   pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.rxDeliv, bitMap, bMapLen);
444
445                   pjUlmProcessUlPktQ(gCb, pjRbCb);
446
447                   pjRbCb->state = PJ_STATE_NORMAL;
448
449                   if(bMapLen != 0)
450                   {
451                      PJ_FREE(gCb, bitMap, (bMapLen / 8) * sizeof(U8));
452                   }
453                } 
454             }
455
456             break;
457          }
458
459          /* Un Expected cfg type */
460       default:
461          {
462             RLOG1(L_ERROR, "Invalid cfgType [%d]", cfgEnt->cfgType);
463          }
464    }
465    RETVALUE(ret);
466 } /* pjCfgFillPjRbCb */
467
468
469 \f
470 /**
471 * @brief 
472 *
473 *   Hanlder to process the re-configuration for existing PJRB from the upper
474 *   layer.
475 *
476 * @b Description: 
477 *     1. This function fetch the PJRB from pdcp data base. @n
478 *     2. update the data base with the  new configuration informtion received.  @n
479 *     3. Return Success or Failure to the caller with reason and status
480 *     information. @n
481 *
482 * @param [in]    ueId     -  UE Identifier
483 * @param [in]    cellId   -  CELL Identifier
484 * @param [in]    entCfg   -  Entity Configuration to be done.
485 * @param [out]   entCfm   -  Entity Confirmation.
486
487 * @return  ROK
488 *
489 */
490 #ifdef ANSI
491 PUBLIC S16 pjCfgReCfgUlRb
492 (
493 PjCb              *gCb,
494 PjUlUeCb          *ueCb,
495 CpjCfgEnt         *entCfg,
496 CpjCfmEnt         *entCfm
497 )
498 #else
499 PUBLIC S16 pjCfgReCfgUlRb (gCb, ueCb, entCfg, entCfm)
500 PjCb              *gCb;
501 PjUlUeCb          *ueCb;
502 CpjCfgEnt         *entCfg;
503 CpjCfmEnt         *entCfm;
504 #endif
505 {
506    S16       ret;
507    PjUlRbCb     *rbCb;    /* Rb Cb */
508
509    TRC3(pjCfgReCfgUlRb);
510
511    /* Initialization */
512    ret  = ROK;
513    rbCb = NULLP;
514
515    RLOG2(L_DEBUG, "Re-Cfg UL RB Req Received for -- cellId(%d),ueId(%d)",
516                      ueCb->key.cellId,ueCb->key.ueId);
517
518    /* Fetch Rb Cb */
519    PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
520
521    /* Rb Cb is not present or Rb Cb is not configured for PDCP */
522    if( NULLP == rbCb)
523    { 
524       RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
525             ueCb->key.cellId, entCfg->rbId);
526       /* Fill entCfm structure */
527       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
528             CPJ_CFG_REAS_PDCPID_UNKWN);
529
530       RETVALUE(RFAILED);
531    }
532
533    /* Copy the received infromation in to Rb Cb */
534    ret = pjCfgFillPjUlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm);
535
536    /* Fill the Cfm status and Reason */
537    PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
538          CPJ_CFG_REAS_NONE);
539
540
541    RETVALUE(ret);
542 } /* pjCfgReCfgRb */
543
544 \f
545 /**
546 * @brief
547 *  This function deletes the existing RB(PDCP and RLC) from  Ue Cb.
548 *
549 * @b Description:
550 *    1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n
551 *    2. Delete the existing RB Cb(PDCP and RLC)  from Ue Cb. @n
552 *
553 * @param [in]    ueId     -  UE Identifier
554 * @param [in]    cellId   -  CELL Identifier
555 * @param [in]    entCfg   -  Entity Configuration to be done.
556 * @param [out]   entCfm   -  Entity Confirmation.
557
558 * @return  ROK
559 *
560 */
561 #ifdef ANSI
562 PUBLIC S16 pjCfgDelUlRb
563 (
564 PjCb              *gCb,
565 PjUlUeCb          *ueCb,
566 CpjCfgEnt         *entCfg,
567 CpjCfmEnt         *entCfm
568 )
569 #else
570 PUBLIC S16 pjCfgDelUlRb (gCb, ueId, cellId, entCfg, entCfm)
571 PjCb              *gCb;
572 PjUlUeCb          *ueCb;
573 CpjCfgEnt         *entCfg;
574 CpjCfmEnt         *entCfm;
575 #endif
576 {
577    S16      ret;
578    PjUlRbCb *rbCb = NULLP; 
579
580    TRC3(pjCfgDelUlRb);
581
582    /* Initialization */
583    ret = ROK;
584
585    RLOG2(L_DEBUG, "Del UL RB Req Received for -- cellId(%d),ueId(%d)",
586                      ueCb->key.cellId, ueCb->key.ueId);
587
588    /* Fetch RB Cb */
589    PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
590
591    /* RB Cb is not present   or not configured for PDCP */
592    if (NULLP == rbCb) 
593    { 
594       RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
595             ueCb->key.cellId, entCfg->rbId);
596       /* Fill entCfm structure with invalid pdcp Id */
597       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
598             CPJ_CFG_REAS_INVALID_PDCPID);
599
600       RETVALUE(RFAILED);
601    }
602    /* Delete PDCP Related infromation from RB CB */
603    ret= pjCfgDelPjUlRbCb(gCb, ueCb, rbCb); 
604
605    if(ROK != ret)
606    {
607       /* Fill entCfm structure with invalid pdcp Id */
608       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
609             CPJ_CFG_REAS_INVALID_PDCPID);
610
611       RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not deleted",
612             ueCb->key.cellId, entCfg->rbId);
613       RETVALUE(ret);
614    }
615    /* Fill the Cfm status and Reason */
616    PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
617          CPJ_CFG_REAS_NONE);
618
619
620    RETVALUE(ret);
621 } /* pjCfgDelRb */
622
623
624
625 \f
626 /**
627 *  @brief
628 *
629 *   This primitive is used to re-establish Uplink SRB2 and/or DRB'S during RRC connection
630 *   re-configuration procedure.
631 *  
632 *  @b Description:
633 *  1. This function will trigger re-establishment for SRB2 and/or DRB's
634 *
635 * @param [in]    gCB      -  Pdcp Instance Control block
636 * @param [in]    ueId     -  UE Identifier
637 * @param [in]    cellId   -  CELL Identifier
638 * @param [in]    entCfg   -  Entity Configuration to be done.
639 * @param [out]   entCfm   -  Entity Configuration cfm.
640
641 * @return  ROK
642 *
643 */
644 #ifdef ANSI
645 PUBLIC S16 pjCfgReEstUlRb
646 (
647 PjCb              *gCb,
648 PjUlUeCb          *ueCb, 
649 CpjCfgEnt         *entCfg,
650 CpjCfmEnt         *entCfm,
651 UdxCfmEnt         *entDlCfgCfm 
652 )
653 #else
654 PUBLIC S16 pjCfgReEstUlRb (gCb, *ueCb, entCfg, entCfm, entDlCfgCfm)
655 PjCb          *gCb;
656 PjUlUeCb      *ueCb;
657 CpjCfgEnt     *entCfg;
658 CpjCfmEnt     *entCfm;
659 UdxCfmEnt     *entDlCfgCfm; 
660 #endif
661 {
662    PjUlRbCb *rbCb = NULLP;
663
664    TRC3(pjCfgReEstUlRb); 
665
666    RLOG2(L_DEBUG, "Config ReEst Req Received for UL RB -- cellId(%d),ueId(%d)",
667                      ueCb->key.cellId, ueCb->key.ueId);
668
669    /* Fetch Rb Cb */
670    PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb);
671
672    /* Rb Cb is not present or Rb Cb is not configured for PDCP */
673    if( NULLP == rbCb )
674    {
675       RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not found",
676             ueCb->key.cellId, entCfg->rbId);
677       /*This RB might be configured at PDCP-DL not at PDCP-UL (Rlc-UM RB with DL direction)*/
678       PJ_MEM_CPY(entCfm, entDlCfgCfm, sizeof(CpjCfmEnt)); /* KW_FIX */
679
680       RETVALUE(RFAILED);
681    }
682    /* A Cfm with failure is sent if the re-establishment comes when RBs are not in
683       re-est state */
684    if (ueCb->libInfo.state != PJ_STATE_REEST )
685    {
686       /* Fill entCfm structure with invalid PDCP Id*/
687       PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\
688             CPJ_CFG_REAS_INVALID_STATE);
689       RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:W/o REEST ,RbId[%d] not reestblshd",
690             ueCb->key.cellId, entCfg->rbId);
691       RETVALUE(RFAILED);
692    }
693
694    if(rbCb->rbType == PJ_SRB)
695    {
696       pjUlmReEstSrb(gCb,rbCb);
697    }
698    else
699    {
700       ueCb->libInfo.numReEstDrb++;
701       rbCb->state = PJ_STATE_REEST;
702      
703 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
704        rbCb->ulCb.obdCnt   = 0;
705        rbCb->ulCb.transCmp = FALSE;
706        if(rbCb->mode == PJ_DRB_AM)
707        {
708           rbCb->ulCb.firstReEstCnt   =   rbCb->ulCb.rxDeliv;
709        }
710 #endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */    
711    }/* if(rbType == .... */
712  
713    if (entDlCfgCfm->status != CPJ_CFG_CFM_OK)
714    {
715       PJ_MEM_CPY(entCfm, entDlCfgCfm, 
716                        sizeof(CpjCfmEnt)); /* KW_FIX */
717    }
718
719    RETVALUE(ROK);
720 } /* pjCfgReEstRb */
721
722
723 \f
724 /**
725 * @brief
726 * This primitive Delete Ue Cb from PDCP/RLC data base.
727 *
728 * @b Description:
729 *  1. This primitive Delete the Ue Cb from PDCP/RLC Data base.
730 *
731 * @param [in]    ueId     -  UE Identifier
732 * @param [in]    cellId   -  CELL Identifier
733 * @param [in]    entCfg   -  Entity Configuration to be done.
734 * @param [out]   entCfm   -  Entity Confirmation.
735
736 * @return  ROK
737 *
738 */
739 #ifdef ANSI
740 PUBLIC S16 pjCfgDelUlUe
741 (
742 PjCb              *gCb,
743 PjUlUeCb          *ueCb,
744 CpjCfgEnt         *entCfg,
745 CpjCfmEnt         *entCfm
746 )
747 #else
748 PUBLIC S16 pjCfgDelUlUe (gCb, ueId, cellId, entCfg, entCfm)
749 PjCb              *gCb;
750 PjUlUeCb          *ueCb,
751 CpjCfgEnt         *entCfg;
752 CpjCfmEnt         *entCfm;
753 #endif
754 {
755    S16     ret;
756
757    TRC3(pjCfgDelUlUe);
758
759    /* Initialization */
760    ret    = ROK;
761
762    RLOG2(L_DEBUG, "pjCfgDelUe- Received for -- cellId(%d),ueId(%d)",
763                      ueCb->key.cellId, ueCb->key.ueId);
764
765
766    /* Delete Ue Cb */
767    ret=pjDbmDelUlUeCb(gCb, ueCb, FALSE);
768
769    /* Fill the Cfm */
770    PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\
771          CPJ_CFG_REAS_NONE);
772
773
774    RETVALUE(ret);
775 } /* pjCfgDelUe */
776
777 \f
778 /**
779 * @brief
780 * This primitive configure the security information of an Ue Cb.
781 *
782 * @b Description:
783 *  1. This primitive  configure the security information of an Ue Cb.
784 *  2. Initilize  the  Integrity/Ciphering Channels if required.
785 *
786 * @param [in]    secCfg   -  Entity Configuration to be done.
787 * @param [out]   secCfm   -  Entity Configuration Cfm done.
788
789 * @return  ROK
790 *
791 */
792 #ifdef ANSI
793 PUBLIC S16 pjCfgPrcSecUlCfg
794 (
795 PjCb             *gCb,
796 CpjSecCfgReqInfo *secCfg,
797 CpjSecCfgCfmInfo *cfgCfm
798 )
799 #else
800 PUBLIC S16 pjCfgPrcSecUlCfg (gCb,secCfg, cfgCfm)
801 PjCb              *gCb;
802 CpjSecCfgReqInfo  *secCfg;
803 CpjSecCfgCfmInfo  *cfgCfm;
804 #endif
805 {
806    S16     ret;
807    PjUlUeCb *ueCb;
808
809    TRC3(pjCfgPrcSecUlCfg);
810
811    /* Initialization */
812    ret  = ROK;
813    ueCb = NULLP;
814
815    RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)",
816                      secCfg->cellId, secCfg->ueId);
817
818    /* Fetch Ue Cb */
819    ret = pjDbmFetchUlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb);
820
821    /* Ue Cb is not present */
822    if( ROK != ret || NULLP == ueCb)
823    { 
824       RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found",
825             secCfg->ueId);
826       /* Fill entCfm structure */
827       PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
828             CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN);
829       RETVALUE(ret);
830    }
831
832    ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct;
833
834    /* Store Integrity Information */
835    ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType;
836    cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN);
837
838    /* Store Ciphering Informaiton */
839    ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType; 
840
841    cmMemcpy(ueCb->secInfo.cipherInfo.cpKey,
842          &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN);
843
844    cmMemcpy(ueCb->secInfo.cipherInfo.upKey,
845          &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN);
846
847    /* Security Activation Done */
848    ueCb->secInfo.secAct = TRUE;
849
850    if(TRUE == secCfg->secCfg.isHo)
851    {
852       ueCb->secInfo.firstMsg   =  FALSE;
853    }
854    else
855    {
856       ueCb->secInfo.firstMsg   =  TRUE;
857    }
858
859    ueCb->secInfo.secCxt.cellId = secCfg->cellId;
860    ueCb->secInfo.secCxt.ueId   = secCfg->ueId;
861    ueCb->secInfo.secCxt.dir    = PJ_SEC_DIR_UL;
862
863 #ifndef ALIGN_64BIT
864    RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
865          "Security Paramters stored in UE CB are -- cellId(%d),"
866           " Integrity Algo(%ld), cipherAlgoType(%ld) ",
867            secCfg->cellId, ueCb->secInfo.intInfo.algoType,
868            ueCb->secInfo.cipherInfo.algoType);
869 #else
870    RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, 
871          "Security Paramters stored in UE CB are -- cellId(%d),"
872           " Integrity Algo(%d), cipherAlgoType(%d) ",
873            secCfg->cellId, ueCb->secInfo.intInfo.algoType,
874            ueCb->secInfo.cipherInfo.algoType);
875 #endif
876    /* Open the Security Channels */
877
878    if(ueCb->secInfo.secAct)
879    {
880
881 #ifdef PJ_SEC_ASYNC
882       ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId;
883 #endif 
884
885       ret = pjUtlUlIntInit(gCb,ueCb);
886
887       /* Integrity Init failed */
888       if(ROK != ret)
889       {
890          PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
891                CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED);
892
893          RETVALUE(ret);
894
895       }
896       ret = pjUtlUlCpInit(gCb,ueCb);
897       /* Ciphering Control Plane Init failed */
898       if(ROK != ret)
899       {
900          PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
901                CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED);
902
903          RETVALUE(ret);
904
905       }
906       ret = pjUtlUlUpInit(gCb,ueCb);
907
908       /* Ciphering User Plane Init failed */
909       if(ROK != ret)
910       {
911          PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
912                CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED);
913
914          RETVALUE(ret);
915       }
916    }
917
918    /* Fill Cfg Cfm with Status OK */
919    PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\
920          CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE);
921
922    RETVALUE(ROK);
923 } /* pjCfgPrcSecCfg */
924
925 \f
926 /**
927 * @brief
928 * This primitive changes the ueId of existing Ue Cb.
929
930 * @b Description:
931 *
932 *    1. This function delete the UeCb from hashList. @n
933 *    2. Update the Ue Cb with the new Keys. @n
934 *    3. Insert the UeCb in hash list with new Key.  @n
935 *
936 * @param [in]    ueInfo      -  Old UE Information
937 * @param [in]    newUeInfo   -  New UE Information
938 * @param [out]   status      -  Status
939
940 * @return  ROK
941 *
942 */
943 #ifdef ANSI
944 PUBLIC S16 pjCfgUlUeIdChng
945 (
946 PjCb      *gCb,
947 CpjUeInfo *ueInfo,
948 CpjUeInfo *newUeInfo,
949 CmStatus  *status
950 )
951 #else
952 PUBLIC S16 pjCfgUlUeIdChng (gCb, ueInfo, newUeInfo, status)
953 PjCb      *gCb;
954 CpjUeInfo *ueInfo;
955 CpjUeInfo *newUeInfo;
956 CmStatus  *status;
957 #endif
958 {
959    PjUlUeCb *ueCb;
960    S16    ret;
961
962    TRC3(pjCfgUlUeIdChng)
963
964    ueCb = NULLP;
965    ret= ROK;
966
967    RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)",
968                      ueInfo->cellId, ueInfo->ueId);
969
970    if ( (ueInfo->ueId == newUeInfo->ueId) && 
971         (ueInfo->cellId == newUeInfo->cellId))
972    {
973       status->reason = CPJ_CFG_REAS_SAME_UEID;
974       status->status = CPJ_CFG_CFM_NOK; 
975
976 #ifdef DEBUGP
977       RLOG_ARG3(L_ERROR,DBG_UEID,ueInfo->ueId, "Changing UE Id -- Failed :"
978            "old and New UeId are Same - cellId(%d),newCellId(%d), newUeId(%d)",
979                 ueInfo->cellId, newUeInfo->cellId, newUeInfo->ueId);
980 #endif
981       RETVALUE(RFAILED);
982    } 
983    
984    ret = pjDbmFetchUlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb);
985    if (ret == ROK)
986    {
987
988 #ifdef DEBUGP
989       RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId,
990             "Changing Ue ID Failed :New UeId already Exists -- cellId(%d)",
991                      newUeInfo->cellId );
992 #endif
993       status->reason = CPJ_CFG_REAS_SAME_UEID;
994       status->status = CPJ_CFG_CFM_NOK;
995       RETVALUE(RFAILED);
996    }
997   
998    ret = pjDbmFetchUlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb);
999    if (ret != ROK)
1000    {
1001       RLOG_ARG1(L_ERROR, DBG_CELLID, ueInfo->cellId,"UeId[%u] not found",ueInfo->ueId);
1002       status->reason = CPJ_CFG_REAS_UE_UNKWN;
1003       status->status = CPJ_CFG_CFM_NOK;
1004       RETVALUE(RFAILED);
1005    }
1006   
1007    ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
1008    if (ret != ROK)
1009    {
1010
1011 #ifdef DEBUGP
1012       RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId, "cmHashListDelete Failed -- cellId(%d)",
1013                      ueInfo->cellId);
1014 #endif
1015       status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
1016       status->status = CPJ_CFG_CFM_NOK;
1017       RETVALUE(RFAILED);
1018    }
1019    
1020    /* update the hash key with new values */ 
1021    ueCb->key.ueId = newUeInfo->ueId;
1022    ueCb->key.cellId = newUeInfo->cellId;
1023
1024     ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)ueCb, 
1025           (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey));
1026
1027   if (ret != ROK)
1028    {
1029 #ifdef DEBUGP
1030       RLOG_ARG2(L_ERROR,DBG_UEID,ueInfo->ueId, 
1031             "cmHashListInsert Failed -- cellId(%d),New ueId(%d)",
1032                      newUeInfo->cellId, newUeInfo->ueId);
1033 #endif
1034       status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL;
1035       status->status = CPJ_CFG_CFM_NOK;
1036    }  
1037   
1038    RETVALUE(ret);
1039 } /* pjCfgUeIdChng */
1040
1041 \f
1042 /**
1043 * @brief
1044 * This primitive reports the Count informatin of all RBs of an Ue Cb.
1045 *
1046 * @b Description:
1047 * 1. This function reports the count information of all the RBs of an UE. 
1048 *
1049 * @param [in]    ueId     -  UE Identifier
1050 * @param [in]    cellId   -  CELL Identifier
1051 * @param [out]   countCfm -  Count Information
1052
1053 * @return  ROK
1054 *
1055 */
1056 #ifdef ANSI
1057 PUBLIC S16 pjCfgPrcUlCount
1058 (
1059 PjCb            *gCb,
1060 CpjCountReqInfo *countReq,
1061 CpjCountCfmInfo       *countCfm,
1062 UdxCountCfmInfo *cntCfm
1063 )
1064 #else
1065 PUBLIC S16 pjCfgPrcUlCount (gCb, countReq, countCfm)
1066 PjCb            *gCb;
1067 CpjCountReqInfo *countReq;
1068 CpjCountCfmInfo       *countCfm;
1069 UdxCountCfmInfo *cntCfm;
1070 #endif
1071 {
1072    S16     ret;
1073    PjUlUeCb  *ueCb;
1074    PjUlRbCb    *rbCb;
1075    U8      numdlRb;
1076    U8      idx;
1077    U8      idx1;
1078
1079    TRC3(pjCfgPrcUlCount); 
1080
1081    /* Initialization */
1082    ueCb   = NULLP;
1083    rbCb   = NULLP;
1084    ret    = ROK;
1085    idx  = 0;
1086    idx1  = 0;
1087    numdlRb = cntCfm->numRb;
1088
1089    RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)",
1090                      countReq->cellId, countReq->ueId);
1091
1092    /* Fetch  ue Cb */
1093    ret = pjDbmFetchUlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb);
1094    countCfm->ueId = countReq->ueId;
1095    countCfm->cellId = countReq->cellId;
1096    countCfm->transId = countReq->transId;
1097
1098    /* Ue Cb is not present */
1099    if( ROK != ret || NULLP == ueCb)
1100    { 
1101       RLOG_ARG1(L_ERROR, DBG_CELLID, countReq->cellId,"UeId[%u] not found",countReq->ueId);
1102       /* Fill entCfm structure */
1103       countCfm->numRb  = cntCfm->numRb;
1104       countCfm->status = CPJ_CFG_CFM_NOK;
1105       countCfm->reason = CPJ_CFG_REAS_UE_UNKWN;
1106       RETVALUE(ret);
1107    }
1108
1109    /* Loop through all DRBs  */
1110    for(idx=0; idx < PJ_MAX_DRB_PER_UE; idx++)     /* KW_FIX */
1111    {
1112       rbCb = ueCb->drbCb[idx];
1113       /* RB is present and configured for PDCP Layer */
1114       if(NULLP != rbCb)
1115       {
1116          for(idx1=0; idx1 < numdlRb; idx1++)
1117          {
1118             if(rbCb->rbId == countCfm->countInfo[idx1].rbId)
1119             {
1120                countCfm->countInfo[idx1].ulCount=  rbCb->ulCb.rxNext; 
1121                break;
1122             }   
1123             else
1124             {    
1125                countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; 
1126                countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; 
1127                countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; 
1128                countCfm->countInfo[countCfm->numRb].dlCount= 0; 
1129                countCfm->numRb++;  
1130             }
1131          } 
1132          if(numdlRb == 0)
1133          {  
1134             countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; 
1135             countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; 
1136             countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; 
1137             countCfm->countInfo[countCfm->numRb].dlCount= 0; 
1138             countCfm->numRb++;  
1139
1140          }
1141
1142       }
1143
1144    }
1145
1146    /* Fill CountCfm with status and reason */
1147    if(countCfm->numRb)
1148    {
1149       countCfm->status =CPJ_CFG_CFM_OK;
1150       countCfm->reason =CPJ_CFG_REAS_NONE;
1151    }
1152    else
1153    {
1154       countCfm->status =CPJ_CFG_CFM_NOK;
1155       countCfm->reason =CPJ_CFG_REAS_NO_DRBS;
1156
1157    }
1158
1159    RETVALUE(ret);
1160 } /* pjCfgPrcCount */
1161
1162 /**
1163 * @brief
1164 * This primitive reports SDU status information of all RBs of an Ue Cb.
1165 *
1166 * @b Description:
1167 *  1. This primitive Trigger the Handoff Request procedure 
1168 *
1169 * @param [in]    ueId      -  UE Identifier
1170 * @param [in]    cellId    -  CELL Identifier
1171 * @param [out]   sduStaCfm -  SDU Status Information
1172
1173 * @return  ROK
1174 *
1175 */
1176 #ifdef ANSI
1177 PUBLIC S16 pjCfgPrcUlSduSta
1178 (
1179 PjCb                 *gCb,
1180 CpjSduStaReqInfo     *staReq,
1181 UdxSduStaCfmInfo     *staCfm
1182 )
1183 #else
1184 PUBLIC S16 pjCfgPrcUlSduSta (gCb, staReq, staCfm)
1185 PjCb                 *gCb;
1186 CpjSduStaReqInfo     *staReq;
1187 UdxSduStaCfmInfo     *staCfm;
1188 #endif
1189 {
1190    S16                ret;
1191    PjUlUeCb          *ueCb;
1192    CpjSduStaCfmInfo  *cfmInfo;
1193
1194    TRC3(pjCfgPrcUlSduSta);
1195
1196    /* Initialization */
1197    ret  = ROK;
1198    ueCb = NULLP;
1199
1200    RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)",
1201                      staReq->cellId, staReq->ueId);
1202
1203
1204    /* Fetch Ue Cb */
1205    ret = pjDbmFetchUlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb);
1206
1207    /* UeCb is not present */
1208    if( ROK != ret || NULLP == ueCb)
1209    { 
1210       RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId);
1211       /* Memory leak fix ccpu00135359 */
1212       PjCpjSapCb        *cpjSap;
1213       cpjSap = &gCb->u.ulCb->cpjSap;
1214       if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, 
1215          sizeof (CpjSduStaCfmInfo)) != ROK)
1216       {
1217          RLOG0(L_FATAL,"Memory allocation failed");
1218          RETVALUE(RFAILED);
1219       }
1220
1221       cfmInfo->ueId = staReq->ueId;
1222       cfmInfo->cellId = staReq->cellId;
1223       cfmInfo->transId = staReq->transId;
1224       cfmInfo->status = CPJ_CFG_CFM_NOK; 
1225       cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN;
1226
1227       /* Caller should return cfm with failure */
1228       RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "UE Cb is not found -- cellId(%d)",
1229                      staReq->cellId);
1230
1231       /* Send Failure SduStaCfm */
1232       PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst, 
1233                         gCb->u.ulCb->cpjSap.suId, cfmInfo);
1234
1235       
1236       RETVALUE(RFAILED);
1237    }
1238
1239    /* Call Ho Start handler for this UE */
1240    pjUtlUlReEstHO(gCb, ueCb);
1241
1242    ueCb->hoInfo->transId = staReq->transId;
1243    ueCb->hoInfo->staCfm = staCfm;
1244
1245    if (ueCb->libInfo.numReEstCmp > 0)
1246    {
1247       if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb)
1248       {
1249          /* Error Case */
1250          ueCb->libInfo.numReEstDrb = 0;
1251          ueCb->libInfo.numReEstCmp = 0;
1252       } 
1253       else
1254       {
1255          ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp;
1256          ueCb->libInfo.numReEstCmp = 0;
1257       }
1258    }
1259
1260    if (ueCb->libInfo.numReEstDrb == 0)
1261    {
1262       pjUtlUlSndSduStaCfm(gCb,ueCb);
1263    }
1264
1265    RETVALUE(ROK);
1266 } /* pjCfgPrcSduSta */
1267
1268    
1269 \f
1270 /**
1271  * @brief
1272  * This primitive to update the ROHC Comp details in PJRB  Cb.
1273  *
1274  * @b Description:
1275  *  1. This primitive to update  the ROHC comp detils in PJRB Cb.
1276  *
1277  * @param [in]    pjRbCb    -  RB Control Block  
1278  * @param [in]    ueCb      -  Ue Control Block 
1279  * @param [in]    hdrCompCfg-  Comp Cfg Information 
1280  * 
1281  * @return  ROK
1282  *
1283  */
1284 #ifdef ANSI
1285 PRIVATE S16 pjCfgUpdUlCompInfo 
1286 (
1287 PjCb                   *gCb,
1288 PjUlRbCb               *rbCb,
1289 PjUlUeCb               *ueCb,
1290 CpjHdrCompCfg        *rohcCfg
1291 )
1292 #else
1293 PRIVATE S16 pjCfgUpdUlCompInfo(gCb, rbCb, ueCb, rohcCfg)
1294 PjCb                   *gCb; 
1295 PjUlRbCb               *rbCb;
1296 PjUlUeCb               *ueCb;
1297 CpjHdrCompCfg        *rohcCfg;
1298 #endif
1299 {
1300    U16   profId;
1301    U8    idx;
1302    S16   ret;
1303
1304    TRC3(pjCfgUpdUlCompInfo);
1305
1306    /* Initialization */   
1307    ret    = ROK;
1308    profId = 0;
1309    idx  = 0; 
1310
1311    RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)",
1312                      rbCb->rbId, ueCb->key.ueId);
1313
1314    /* Header Compresion information present */
1315    if(rohcCfg->hdrCompUsed)
1316    {
1317       /* Header Compression is enabled */ 
1318       rbCb->rohc.hdrCmpUsed = TRUE;
1319
1320       /* User Can Configure multipel profiles. Maximum profile ID should be used */  
1321       for(; idx<CPJ_MAX_ROHC_PROF_LIST; idx++)
1322       {
1323          if((rohcCfg->rohcInfo.profLst[idx] )&&
1324                (profId < rohcProfId[idx]))
1325             profId = rohcProfId[idx];
1326       } 
1327    }
1328    else
1329    {
1330       /* Header Compression is disabled */
1331       rbCb->rohc.hdrCmpUsed = FALSE;
1332       profId = 0x0000;
1333    }
1334
1335    /* Store the profile Id and MaxCid */
1336
1337    rbCb->rohc.profId = profId;
1338    rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid;
1339
1340    /* Store the ue Details in Compressor Context */
1341    rbCb->cmpCxt.ueId   = ueCb->key.ueId;
1342    rbCb->cmpCxt.cellId = ueCb->key.cellId;
1343    rbCb->cmpCxt.rbId   = rbCb->rbId;
1344    rbCb->cmpCxt.rbType = rbCb->rbType;
1345
1346    RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected   -- profId(%d),maxCid(%d)",
1347                      rbCb->rohc.profId, rbCb->rohc.maxCid);
1348
1349
1350    /* Compress Init */
1351    if(rbCb->rohc.hdrCmpUsed)
1352    {
1353       ret=pjUtlUlCmpInit(gCb, rbCb); 
1354    }
1355
1356    RETVALUE(ret);
1357 } /* pjCfgUpdCompInfo */
1358
1359 \f
1360 /**
1361  * @brief
1362  * This primitive to delete RB from Ue Cb.
1363  *
1364  * @b Description:
1365  * 1. To delete the PJRB Cb from  UeCb.
1366  *
1367  * @param [in]    ueCb      -  Ue Control Block 
1368  * @param [in]    rbCb      -  Rb Control Block  
1369  * 
1370  * @return  ROK
1371  *
1372  */
1373 #ifdef ANSI
1374 PUBLIC S16  pjCfgDelPjUlRbCb 
1375 (
1376 PjCb                 *gCb,
1377 PjUlUeCb             *ueCb,
1378 PjUlRbCb             *rbCb
1379 )
1380 #else
1381 PUBLIC S16 pjCfgDelPjUlRbCb(gCb,ueCb,rbCb)
1382 PjCb                  *gCb;
1383 PjUlUeCb              *ueCb;
1384 PjUlRbCb              *rbCb;
1385 #endif
1386 {   
1387    S16  ret;
1388 /* kw005.201 added support for L2 measurement */
1389 #ifdef LTE_L2_MEAS_COMMENT
1390    U8   evtIdx;
1391    U8   qciIdx;
1392 #endif
1393    TRC3(pjCfgDelPjUlRbCb);
1394
1395    /* Initialization */
1396    ret = ROK;
1397
1398    RLOG0(L_DEBUG,"pjCfgDelPjRBCb- Recieved -- rbId() CfgState() ");
1399
1400    /* RbCb is present and Configured for PDCP */
1401    if(NULLP != rbCb) 
1402    {
1403       RLOG1(L_DEBUG, "pjCfgDelPjRBCb- Received for -- rbId (%d)",
1404                rbCb->rbId);
1405
1406 #ifdef LTE_L2_MEAS
1407       /* This should be done for every counter added for UL */
1408       if((rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS] != NULLP) &&
1409           (rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci > 0))
1410       {
1411          rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci--;
1412       }
1413 #endif
1414       Bool tmrRunning = pjChkTmr(gCb,(PTR)rbCb,PJ_EVT_UL_REORD_TMR);
1415       if(tmrRunning)
1416       {
1417           pjStopTmr(gCb,(PTR)rbCb, PJ_EVT_UL_REORD_TMR);
1418       }
1419
1420
1421       rbCb->ueCb   = NULLP;
1422
1423 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
1424       /* Stop off board timers */  
1425
1426       if(PJ_DIR_UL & rbCb->dir)
1427           if(rbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
1428           {
1429                 pjStopTmr(gCb, (PTR)&rbCb, PJ_EVT_UL_OBD_TMR); 
1430           }
1431 #endif
1432      
1433       /* Deinit Rx Buffers */
1434       pjDbmRxDeInit(gCb,&rbCb->ulCb.recBuf);
1435       pjUtlEmptyUlPktList(gCb, rbCb);
1436
1437       /* Close the Comp channels */  
1438       if (PJ_SRB == rbCb->rbType)
1439       {
1440          ueCb->numSrbs--;
1441       }
1442       else if (PJ_DRB == rbCb->rbType)
1443       {
1444          ueCb->numDrbs--;
1445          if (rbCb->rohc.hdrCmpUsed)
1446          {
1447             pjUtlCmpClose(gCb,rbCb->cmpCxtId);
1448          }
1449       }
1450             /* Free the rbCb */
1451       pjDbmDelUlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP, ueCb);
1452
1453    } 
1454    RETVALUE(ret);
1455 } /* pjCfgDelPjRBCb */
1456
1457 \f
1458 /**
1459  * @brief
1460  * Handler to process the re-establishment Request for SRB1 during
1461  * RRC Re-Establishment request.
1462  *
1463  * @b Description:
1464  * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment 
1465  * 2. New Security Algo will applied 
1466  *
1467  * @param [in]    reEstReq   -  Entity Configuration to be done.
1468  * @param [out]   reEstCfm   -  Entity Configuration cfm.
1469  * 
1470  * @return  ROK
1471  *
1472  */
1473 #ifdef ANSI
1474 PUBLIC S16 pjCfgUlReEstReq
1475 (
1476 PjCb              *gCb,
1477 CpjReEstReqInfo   *reEstReq,
1478 CpjReEstCfmInfo   *reEstCfm
1479 )
1480 #else
1481 PUBLIC S16 pjCfgUlReEstReq (gCb, reEstReq, reEstCfm)
1482 PjCb              *gCb;
1483 CpjReEstReqInfo   *reEstReq;
1484 CpjReEstCfmInfo   *reEstCfm;
1485 #endif
1486 {
1487    S16     ret;
1488    PjUlUeCb  *ueCb;
1489    PjUlRbCb    *rbCb;
1490    CmLteRlcId rlcId;
1491
1492    TRC3(pjCfgUlReEstReq);
1493  
1494    /* Initialization */
1495    ret = ROK;
1496    rlcId.ueId   =  reEstReq->pdcpId.ueId;
1497    rlcId.cellId   =  reEstReq->pdcpId.cellId;
1498    rlcId.rbId   =  reEstReq->pdcpId.rbId;
1499    rlcId.rbType   =  reEstReq->pdcpId.rbType;
1500
1501    RLOG2(L_DEBUG, "pjCfgReEstReq- Received for -- cellId(%d),ueId(%d)",
1502                      rlcId.cellId, rlcId.ueId);
1503
1504    ret = pjDbmFetchUlRbCb(gCb, rlcId,&rbCb);
1505    
1506    
1507    /* Ue Cb is not present */
1508    if( ROK != ret || NULLP == rbCb)
1509    {
1510       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
1511             rlcId.cellId, rlcId.rbId);
1512       /* Fill entCfm structure */
1513       PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, rlcId.ueId,rlcId.cellId,
1514             reEstReq->transId, LCM_PRIM_NOK);
1515       RETVALUE(ret);
1516    }
1517   
1518    ueCb = rbCb->ueCb;
1519
1520    /* Copy Security Information */ 
1521    cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN);
1522    cmMemcpy(&ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN);
1523    cmMemcpy(&ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN);
1524
1525    /* Mark Security Action Done */
1526    ueCb->secInfo.secAct = TRUE;
1527
1528    reEstCfm->transId = reEstReq->transId;
1529    reEstCfm->ueId    = reEstReq->pdcpId.ueId;
1530    reEstCfm->cellId  = reEstReq->pdcpId.cellId;
1531
1532    /* Save the information */
1533 #ifdef PJ_SEC_ASYNC
1534    pjUtlUlSaveCfmInfo(gCb,rbCb->ueCb, PJ_REEST_ASYNC_CFM, FALSE, ENTPJ, 
1535                                           (PTR)reEstCfm, NULLP);
1536    PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo));
1537 #endif /* PJ_SEC_ASYNC */
1538
1539    /* Call ReEst for SRB1 */
1540    pjUtlUlReEstSrb1(gCb,rbCb);
1541
1542    RETVALUE(ROK);
1543 } /* pjCfgReEstReq */
1544
1545 #ifdef LTE_L2_MEAS
1546 /**
1547  * @brief
1548  * Handler to add measCb to rbCb.
1549  *
1550  * @b Description:
1551  * Handler to add measCb to rbCb.
1552  *
1553  * 
1554  * @return  ROK
1555  *
1556  */
1557 PRIVATE S16 pjAddToUlL2Meas(PjCb *tPjCb, PjUlRbCb *pjRbCb,U8 cellId, U16 ueId)
1558 {
1559    U32 cntr;
1560
1561    RLOG1(L_DEBUG, "L2_MEAS_ADD Adding UE ueid %d ", ueId);
1562
1563    for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
1564    {
1565       PjL2MeasCb *measCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr].measCb;
1566
1567       if (measCb->measType & LPJ_L2MEAS_UL_LOSS)
1568       {
1569          pjUtlPlcMeasDatInUlL2Sts(&measCb->measData[pjRbCb->qci],
1570                &pjRbCb->rbL2Cb, measCb->measType);
1571          measCb->qci[pjRbCb->qci] = pjRbCb->qci;
1572          measCb->measData[pjRbCb->qci].totDrbsPerQci++;
1573          measCb->numQci++;
1574       }
1575    }
1576    RETVALUE(ROK);
1577 }/*pjAddToDlL2Meas*/ 
1578 #endif
1579
1580 /*@}*/
1581 \f
1582 /********************************************************************30**
1583
1584          End of file
1585 **********************************************************************/