Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_dl_utl.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 *******************************************************************************/
18
19 /**********************************************************************
20
21      Name:     LTE-PDCP Layer
22   
23      Type:     C file
24   
25      Desc:     Source code for PDCP Utility Module
26
27                This file contains following functions:
28
29                   --PjLibObdCmpCfm
30                   --PjLibObdIntProtCfm
31                   --PjLibObdCipherCfm
32                   --PjLibObdDecipherCfm
33                   --PjLibObdIntVerCfm
34                   --PjLibObdDecmpCfm
35                   -- pjUtlCmpReq
36                   -- pjUtlCipherReq
37                   -- pjUtlIntProtReq
38   
39      File:     pj_dl_utl.c
40
41 **********************************************************************/
42  static const char* RLOG_MODULE_NAME="PDCP";
43 static int RLOG_MODULE_ID=1024;
44 static int RLOG_FILE_ID=218;
45
46 /** @file pj_dl_utl.c 
47 @brief PDCP Utility Module 
48 */
49
50 /* header (.h) include files */
51 #include "envopt.h"        /* environment options */
52 #include "envdep.h"        /* environment dependent */
53 #include "envind.h"        /* environment independent */
54
55 #include "gen.h"           /* general */
56 #include "ssi.h"           /* system services */
57 #include "cm5.h"           /* common timer defines */
58 #include "cm_tkns.h"       /* common tokens defines */
59 #include "cm_mblk.h"       /* common memory allocation library defines */
60 #include "cm_llist.h"      /* common link list  defines  */
61 #include "cm_hash.h"       /* common hash list  defines */
62 #include "cm_lte.h"        /* common LTE defines */
63 #include "cpj.h"                /* CPJ defines */
64 #include "pju.h"                /* PJU defines */
65 #include "lpj.h"                /* LPJ defines */
66
67 #include "pj_env.h"        /* RLC environment options */
68 #include "pj.h"            /* RLC defines */
69 #include "pj_dl.h"
70 #include "pj_err.h"        /* Error defines */
71 #include "pj_udx.h"
72 #include "pj_ptsec.h"
73
74 /* extern (.x) include files */
75 #include "gen.x"           /* general */
76 #include "ssi.x"           /* system services */
77
78 #include "cm5.x"           /* common timer library */
79 #include "cm_tkns.x"       /* common tokens */
80 #include "cm_mblk.x"       /* common memory allocation */
81 #include "cm_llist.x"      /* common link list */
82 #include "cm_hash.x"       /* common hash list */
83 #include "cm_lte.x"        /* common LTE includes */
84 #include "cm_lib.x"        /* common memory allocation library */
85 #include "cpj.x"                /* CPJ */
86 #include "pju.x"                /* PJU */
87 #include "lpj.x"                /* LPJ */
88 #include "pj.x"
89 #include "pj_udx.h"
90 #include "pj_udx.x"
91 #include "pj_dl.x"
92 #include "pj_lib.x"          /* LIB */
93
94
95 EXTERN CmLListCp pjMsCiphQ;
96 EXTERN CmLListCp pjMsDeCiphQ;
97 #ifndef XEON_SPECIFIC_CHANGES
98 EXTERN U32 dbgPdcpMemCount,pdcpdrop, dbgSpaccThreshHoldDropCnt;
99 EXTERN U32 dbgPdcpQSizeThreshHoldDropCnt;
100 U32 spaccDropCount = 0;
101 EXTERN U32 pjMsDlSpaccQCnt;
102 EXTERN U32 pjMsUlSpaccQCnt;
103 #endif
104 #ifdef __cplusplus
105 EXTERN "C" {
106 #endif /* __cplusplus */
107
108 #ifdef INTEL_SW_SEC 
109 EXTERN S16 PjLibObdSwCipherReq(PjLibTrans  *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu);
110
111 EXTERN S16 pjSendToSwCipherFB ARGS((PjLibTrans *libTrans, FlatBuffer *mBuf,
112                                            PjCb *gCb, Buffer **opSdu));
113 #endif
114
115 PUBLIC S16 pjUtlReEstDl 
116 (
117 PjCb        *gCb,
118 PjDlUeCb       *ueCb           /* UE Control Block */ 
119 );
120
121 PRIVATE S16 pjUtlDlHdlSecInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, 
122               U16 txIdx,PjAsyncCfm *asyncCfm, UdxSecCfgCfmInfo *secCfgCfm,UdxReEstCfmInfo *reEstCfm));
123 PRIVATE S16 pjUtlDlHdlCmpInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, 
124               U16 txIdx,PjAsyncCfm *asyncCfm, UdxCfgCfmInfo *cfgCfm));
125
126 /**
127  *
128  * @brief 
129  *
130  *        Handler to apply the new security algorithms and 
131  *        reset the compression unit.
132  *
133  * @b Description:
134  *
135  *        This function 
136  *        1. Creates new contexts for Control Plane Ciphering and Integrity.
137  *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
138  *
139  *  @param[in] ueCb   UE Control Block
140  *
141  *  @return  S16
142  *      -# ROK 
143  *      -# RFAILED
144  *
145  */
146 #ifdef ANSI
147 PUBLIC S16 pjUtlDlUpdUpSecKeys
148 (
149 PjCb       *gCb,
150 PjDlUeCb   *ueCb           /* UE Control Block */ 
151 )
152 #else
153 PUBLIC S16 pjUtlDlUpdUpSecKeys(gCb,ueCb)
154 PjCb         *gCb;
155 PjDlUeCb     *ueCb;           /* UE Control Block */ 
156 #endif
157 {
158    Void     *tmpUpCxt;
159
160    TRC2(pjUtlDlUpdUpSecKeys);
161
162    RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))",
163          ueCb->key.ueId, ueCb->key.cellId);
164
165    if(ueCb->secInfo.secAct == TRUE)
166    {
167       /* Initialisation is done first followed by closure since we
168        * do not want the same ctxId to be returned for the new init.
169        * In ASYNC case, we drop packets if they are returned from a
170        * different ctxId. */
171
172 #ifdef INTEL_QAT_DP
173       tmpUpCxt  = ueCb->secInfo.upCiphSessCxtId;
174 #else
175       tmpUpCxt  = ueCb->secInfo.upCxtId;    
176 #endif
177
178       pjUtlDlUpInit(gCb,ueCb);
179       pjUtlDlCipherClose(gCb,tmpUpCxt);
180    }
181
182    RETVALUE(ROK);
183 } /* pjUtlDlUpdUpSecKeys */
184
185 /**
186  *
187  * @brief 
188  *
189  *        Handler to apply the new security algorithms and 
190  *        reset the compression unit.
191  *
192  * @b Description:
193  *
194  *        This function 
195  *        1. Creates new contexts for Control Plane Ciphering and Integrity.
196  *        2. Closes the old contexts for Control Plane Ciphering and Integrity.
197  *
198  *  @param[in] ueCb   UE Control Block
199  *
200  *  @return  S16
201  *      -# ROK 
202  *      -# RFAILED
203  *
204  */
205 #ifdef ANSI
206 PUBLIC S16 pjUtlDlUpdCpSecKeys
207 (
208 PjCb       *gCb,
209 PjDlUeCb   *ueCb           /* UE Control Block */ 
210 )
211 #else
212 PUBLIC S16 pjUtlDlUpdCpSecKeys(gCb,ueCb)
213 PjCb         *gCb;
214 PjDlUeCb     *ueCb;           /* UE Control Block */ 
215 #endif
216 {
217    Void     *tmpIntCxt;
218    Void     *tmpCpCxt;
219
220    TRC2(pjUtlDlUpdCpSecKeys);
221
222    RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))",
223          ueCb->key.ueId, ueCb->key.cellId);
224
225    if(ueCb->secInfo.secAct == TRUE)
226    {
227       /* Initialisation is done first followed by closure since we
228        * do not want the same ctxId to be returned for the new init.
229        * In ASYNC case, we drop packets if they are returned from a
230        * different ctxId. */
231
232 #ifdef INTEL_QAT_DP
233       tmpIntCxt = ueCb->secInfo.cpIntSessCxtId;
234       tmpCpCxt  = ueCb->secInfo.cpCiphSessCxtId;
235 #else
236       tmpIntCxt = ueCb->secInfo.intCxtId;  
237       tmpCpCxt  = ueCb->secInfo.cpCxtId;    
238 #endif
239
240       pjUtlDlCpInit(gCb,ueCb);
241       pjUtlDlIntInit(gCb,ueCb);
242
243       pjUtlDlIntClose(gCb,tmpIntCxt);
244       pjUtlDlCipherClose(gCb,tmpCpCxt);
245
246    }
247
248    RETVALUE(ROK);
249
250 } /* pjUtlDlUpdCpSecKeys */
251
252 /********************************************************************
253  *    Utility Handler for Sending to Offboarding unit               *
254  *******************************************************************/
255 \f
256 /**
257  *
258  * @brief 
259  *
260  *        Handler for opening the context with the compression unit (either 
261  *        synchronous or asynchronous) for RB within an UE.
262  *
263  * @b Description:
264  *
265  *        This function opens the context with the compression unit per RB per
266  *        UE, by sending ROHC configuration elements using synchronous / asynchronous 
267  *        function calls with relevant input parameters.
268  *
269  *
270  *  @param[in]  pjRbCb   PDCP RbCb
271  *
272  *  @return  S16
273  *      -# ROK 
274  *
275  */
276 #ifdef ANSI
277 PUBLIC S16 pjUtlDlCmpInit
278 (
279 PjCb       *gCb,
280 PjDlRbCb   *pjRbCb                  /* PDCP RbCb */
281 )
282 #else
283 PUBLIC S16 pjUtlDlCmpInit(pjRbCb)
284 PjCb       *gCb;
285 PjDlRbCb   *pjRbCb;                 /* PDCP RbCb */
286 #endif
287 {
288    TRC3(pjUtlDlCmpInit)
289
290    RLOG2(L_DEBUG, "pjUtlDlCmpInit(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
291 #ifdef PJ_CMP_ASYNC
292
293    pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1));
294    pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK;
295    pjRbCb->cmpCxt.cfgTxId  =  pjRbCb->ueCb->libInfo.nxtAvlbTxId;
296
297    PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst, 
298                                     pjRbCb->cmpCxt, pjRbCb->rohc);
299 #else
300    pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId));
301 #endif  /* PJ_CMP_ASYNC */
302
303    RETVALUE(ROK);
304
305 } /* end of pjUtlCmpInit */
306 \f
307
308
309 /**
310  *
311  * @brief 
312  *
313  *        Handler for opening the context with the Integration unit (either 
314  *        synchronous or asynchronous) for all SRBs of an UE.
315  *
316  * @b Description:
317  *
318  *        This function opens the context with the security algo unit per UE
319  *        for Integration protection/verification by sending the configured
320  *        Integrity Info using synchronous / asynchronous function calls with 
321  *        relevant input parameters.
322  *
323  *  @param[in]  pjRbCb     Pointer to RB control Block
324  *
325  *
326  *  @return  S16
327  *      -# ROK 
328  *
329  */
330 #ifdef ANSI
331 PUBLIC S16 pjUtlDlIntInit
332 (
333 PjCb     *gCb,
334 PjDlUeCb   *ueCb                   /* UE CB Ptr */
335 )
336 #else
337 PUBLIC S16 pjUtlDlIntInit(*gCb, *ueCb)
338 PjCb     *gCb;
339 PjDlUeCb   *ueCb;                   /* UE CB Ptr */
340 #endif
341 {
342
343    S16 ret=ROK;
344    Void *ctxId = NULLP;   
345 #ifdef PJ_SEC_ASYNC
346    U8  txIdx;
347    U32 *libInitBitMask = NULLP;
348 #endif
349    
350    TRC3(pjUtlDlIntInit)
351
352    RLOG2(L_DEBUG, "pjUtlDlIntInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
353
354 #ifdef PJ_SEC_ASYNC
355
356    if(ueCb->libInfo.state == PJ_STATE_REEST)
357    {
358       for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
359       {
360          if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
361                (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
362          {
363             libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
364             break;
365          }
366       }
367    }
368    else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
369    {
370       libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
371    }
372
373    if(libInitBitMask)
374    {
375       (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK;
376    }
377
378    ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst, 
379                            ueCb->secInfo.secCxt, ueCb->secInfo.intInfo);
380 #else
381 #ifdef INTEL_QAT_DP
382 #ifdef QAT_TWO_INSTANCE
383    pjLibIntInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.intInfo,&ctxId);
384 #else
385    pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId);
386 #endif
387    ueCb->secInfo.cpIntSessCxtId  =  ctxId;
388 #else
389    pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId));
390    ueCb->secInfo.intCxtId    =  ctxId;
391 #endif /* INTEL_QAT_DP */
392 #endif /* PJ_SEC_ASYNC */
393
394    RETVALUE(ret);
395
396 } /* end of pjUtlIntInit */
397 \f
398 /**
399  *
400  * @brief 
401  *
402  *        Handler for opening the context with the Ciphering unit (either 
403  *        synchronous or asynchronous) for SRBs of an UE.
404  *
405  * @b Description:
406  *
407  *        This function opens the context with the security algo unit per UE
408  *        for ciphering / deciphering by key by sending the configured
409  *        Ciphering Info with control plane key using synchronous / asynchronous 
410  *        function calls with relevant input parameters.
411  *
412  *  @param[in]  pjRbCb     Pointer to RB control Block
413  *
414  *  @return  S16
415  *      -# ROK 
416  *
417  */
418 #ifdef ANSI
419 PUBLIC S16 pjUtlDlCpInit
420 (
421 PjCb     *gCb,
422 PjDlUeCb   *ueCb                    /* UE CB Ptr */
423 )
424 #else
425 PUBLIC S16 pjUtlDlCpInit(*gCb, *ueCb)
426 PjCb     *gCb;
427 PjDlUeCb   *ueCb;                   /* UE CB Ptr */
428 #endif
429 {
430    Void *ctxId = NULLP;
431 #ifdef PJ_SEC_ASYNC
432    U8  txIdx;
433    U32 *libInitBitMask = NULLP;
434 #endif
435    S16   ret = ROK;
436
437    TRC3(pjUtlDlCpInit)
438
439    RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
440
441 #ifdef PJ_SEC_ASYNC
442
443    if(ueCb->libInfo.state == PJ_STATE_REEST)
444    {
445       for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
446       {
447          if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
448                (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
449          {
450             libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
451             break;
452          }
453       }
454    }
455    else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
456    {
457       libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
458    }
459
460    if(libInitBitMask)
461    {
462       (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK;
463    }
464    ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
465          ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey);
466 #else
467 #ifdef INTEL_QAT_DP
468 #ifdef QAT_TWO_INSTANCE
469    ret = pjLibCpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
470          ueCb->secInfo.cipherInfo.cpKey, &ctxId);
471 #else
472   ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
473                   ueCb->secInfo.cipherInfo.cpKey, &ctxId); 
474 #endif
475    ueCb->secInfo.cpCiphSessCxtId= ctxId;
476 #else
477    ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType,
478                   ueCb->secInfo.cipherInfo.cpKey, &ctxId);    /*KW_FIX*/
479    ueCb->secInfo.cpCxtId = ctxId;
480 #endif /* INTEL_QAT_DP */
481 #endif /* PJ_SEC_ASYNC */
482
483    RETVALUE(ret);
484
485 } /* end of pjUtlCpInit */
486
487 /**
488  *
489  * @brief 
490  *
491  *        Handler for opening the context with the Ciphering unit (either 
492  *        synchronous or asynchronous) for DRBs of an UE.
493  *
494  * @b Description:
495  *
496  *        This function opens the context with the security algo unit per UE
497  *        for ciphering / deciphering by sending the configured
498  *        Ciphering Info with user plane key using synchronous / asynchronous 
499  *        function calls with relevant input parameters.
500  *
501  *  @param[in]  pjRbCb     Pointer to RB control Block
502  *
503  *  @return  S16
504  *      -# ROK 
505  *
506  */
507 #ifdef ANSI
508 PUBLIC S16 pjUtlDlUpInit
509 (
510 PjCb     *gCb,
511 PjDlUeCb   *ueCb                    /* UE CB Ptr */
512 )
513 #else
514 PUBLIC S16 pjUtlDlUpInit(*gCb,*ueCb) 
515 PjCb     *gCb;
516 PjDlUeCb   *ueCb;                   /* UE CB Ptr */
517 #endif
518 {
519
520    Void  *ctxId = NULLP;
521 #ifdef PJ_SEC_ASYNC
522    U8  txIdx;
523    U32 *libInitBitMask = NULLP;
524 #endif
525    S16 ret = ROK;
526
527    TRC3(pjUtlDlUpInit)
528
529    RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
530
531 #ifdef PJ_SEC_ASYNC
532
533    if(ueCb->libInfo.state == PJ_STATE_REEST)
534    {
535       for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
536       {
537          if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
538                (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM))
539          {
540             libInitBitMask =  &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask;
541             break;
542          }
543       }
544    }
545    else if(ueCb->libInfo.state == PJ_STATE_NORMAL)
546    {
547       libInitBitMask =  &ueCb->libInfo.tLibInitBitMask;
548    }
549
550    if(libInitBitMask)
551       (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK;
552
553    ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, 
554          ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey);
555 #else
556 #ifdef INTEL_QAT_DP
557 #ifdef QAT_TWO_INSTANCE
558    pjLibUpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
559                               ueCb->secInfo.cipherInfo.upKey, &ctxId);
560 #else
561    pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType,
562                               ueCb->secInfo.cipherInfo.upKey, &ctxId);
563 #endif
564    ueCb->secInfo.upCiphSessCxtId= ctxId;
565 #else
566    pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, 
567                               ueCb->secInfo.cipherInfo.upKey, &ctxId);   /*KW_FIX*/
568    ueCb->secInfo.upCxtId = ctxId;
569 #endif /* INTEL_QAT_DP */
570 #endif /* PJ_SEC_ASYNC */
571    RETVALUE(ret);
572 } /* end of pjUtlUpInit */
573
574
575
576 /**
577  *
578  * @brief 
579  *
580  *        Handler for redirecing ciphering request to either synchronous
581  *        or asynchronous module.
582  *
583  * @b Description:
584  *
585  *        This function sends ciphering protection request as either synchronous or
586  *        asynchronous function calls with relevant input parameters.
587  *
588  *  @param[in]   pjRbCb           PDCP RbCb 
589  *  @param[in]   secInp           Input parameters for deciphering 
590  *  @param[in]   mBuf             Data to be deciphered 
591  *  @param[in]   opSdu            Deciphered SDU 
592  *
593  *  @return  S16
594  *      -# ROK 
595  *
596  */
597 //#ifdef TENB_AS_SECURITY
598 #ifdef ANSI
599 PUBLIC S16 pjUtlCipherReq
600 (
601 PjCb     *gCb,
602 PjDlRbCb   *pjRbCb,              /* PDCP RbCb */
603 U32      count,                  /* Input parameters for deciphering */ 
604 Buffer   *mBuf,                  /* Data to be deciphered */
605 Buffer   **opSdu                 /* Deciphered SDU */
606 )
607 #else
608 PUBLIC S16 pjUtlCipherReq(gCb, pjRbCb, count, mBuf, opSdu)
609 PjCb     *gCb,
610 PjDlRbCb   *pjRbCb;               /* PDCP RbCb */
611 U32      count;                   /* Input parameters for deciphering */ 
612 Buffer   *mBuf;                   /* Data to be deciphered */
613 Buffer   **opSdu;                 /* Deciphered SDU */
614 #endif
615 {
616    S16 ret = ROK;
617    PjDlUeCb *dlUeCb;
618    PjLibTrans libTrans; /* Transaction Id for deciphering */
619
620 #if PJ_SEC_ASYNC
621    Void   *cxtId;    /* Context Identifier */
622 #endif
623
624    TRC3(pjUtlCipherReq)
625
626    dlUeCb = pjRbCb->ueCb;
627    libTrans.pdcpInstance = gCb->init.inst;
628    libTrans.count = count;
629
630    libTrans.rbId = pjRbCb->rbId - 1;
631    libTrans.dir = PJ_SEC_DIR_DL;
632    libTrans.rbType = pjRbCb->rbType;
633    libTrans.snLen = pjRbCb->snLen;
634    libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType;
635    libTrans.ueCb = (PTR)dlUeCb;
636    libTrans.ueId = dlUeCb->key.ueId;
637    libTrans.cellId = dlUeCb->key.cellId;
638    if(PJ_SRB == pjRbCb->rbType)
639    {
640       libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey;
641 #ifdef INTEL_QAT_DP
642       libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId;
643 #ifdef QAT_TWO_INSTANCE
644       libTrans.instHndl = gCb->u.dlCb->instHndl;
645 #else
646       libTrans.instHndl = gCb->instHndl;
647 #endif
648 #endif
649    }
650    else
651    {
652       libTrans.key = dlUeCb->secInfo.cipherInfo.upKey;
653 #ifdef INTEL_QAT_DP
654       libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId;
655 #ifdef QAT_TWO_INSTANCE
656       libTrans.instHndl = gCb->u.dlCb->instHndl;
657 #else
658       libTrans.instHndl = gCb->instHndl;
659 #endif
660 #endif
661    }
662
663 #ifdef PJ_SEC_ASYNC
664    /* Start the timer if it is not started already */
665    if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
666    {
667       pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
668    }
669
670    if (pjRbCb->rbType == PJ_SRB)
671    {
672       cxtId = pjRbCb->ueCb->secInfo.cpCxtId;
673    }
674    else
675    {
676       cxtId = pjRbCb->ueCb->secInfo.upCxtId;
677    } 
678
679    ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
680                                              secInp, libTrans, mBuf);
681
682 #else
683 #ifdef INTEL_SW_SEC
684    ret = PjLibObdSwCipherReq(&libTrans, mBuf, gCb,opSdu);
685 #else
686    ret = PjLibObdCipherReq(&libTrans, mBuf, opSdu);
687 #endif /* INTEL_SW_SEC */
688 #endif
689
690    RETVALUE(ret);
691
692 }
693
694
695 #ifdef FLAT_BUFFER_OPT
696 /**
697  *
698  * @brief 
699  *
700  *        Handler for redirecing ciphering request to either synchronous
701  *        or asynchronous module.
702  *
703  * @b Description:
704  *
705  *        This function sends ciphering protection request as either synchronous or
706  *        asynchronous function calls with relevant input parameters.
707  *
708  *  @param[in]   pjRbCb           PDCP RbCb 
709  *  @param[in]   secInp           Input parameters for deciphering 
710  *  @param[in]   mBuf             Flat Buffer to be deciphered 
711  *  @param[in]   opSdu            Deciphered SDU 
712  *
713  *  @return  S16
714  *      -# ROK 
715  *
716  */
717
718 #ifdef ANSI
719 PUBLIC S16 pjUtlCipherReqFB
720 (
721 PjCb       *gCb,
722 PjDlRbCb   *pjRbCb,                /* PDCP RbCb */
723 U32        count,                  /* Input parameters for deciphering */ 
724 FlatBuffer *mBuf,                  /* Data to be deciphered */
725 Buffer     **opSdu                 /* Deciphered SDU */
726 )
727 #else
728 PUBLIC S16 pjUtlCipherReqFB(gCb, pjRbCb, count, mBuf, opSdu)
729 PjCb       *gCb,
730 PjDlRbCb   *pjRbCb;                /* PDCP RbCb */
731 U32        count;                  /* Input parameters for deciphering */ 
732 FlatBuffer *mBuf;                  /* Data to be deciphered */
733 Buffer     **opSdu;                /* Deciphered SDU */
734 #endif
735 {
736    S16 ret = ROK;
737 #ifdef PJ_SEC_ASYNC
738    Void   *cxtId;    /* Context Identifier */
739 #endif
740    PjDlUeCb *dlUeCb;
741    PjLibTrans libTrans;
742
743    TRC3(pjUtlCipherReqFB)
744
745 #ifdef PJ_SEC_ASYNC
746    cxtId = pjRbCb->ueCb->secInfo.upCxtId;
747 #endif
748
749    dlUeCb = pjRbCb->ueCb;
750    libTrans.pdcpInstance = gCb->init.inst;
751    libTrans.count = count;
752
753    libTrans.rbId = pjRbCb->rbId - 1;
754    libTrans.dir = PJ_SEC_DIR_DL;
755    libTrans.rbType = pjRbCb->rbType;
756    libTrans.snLen = pjRbCb->snLen;
757    libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType;
758    libTrans.ueCb = (PTR)dlUeCb;
759    libTrans.ueId = dlUeCb->key.ueId;
760    libTrans.cellId = dlUeCb->key.cellId;
761    if(PJ_SRB == pjRbCb->rbType)
762    {
763       libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey;
764 #ifdef INTEL_QAT_DP
765       libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId;
766 #ifdef QAT_TWO_INSTANCE
767       libTrans.instHndl = gCb->u.dlCb->instHndl;
768 #else
769       libTrans.instHndl = gCb->instHndl;
770 #endif
771 #endif
772    }
773    else
774    {
775       libTrans.key = dlUeCb->secInfo.cipherInfo.upKey;
776 #ifdef INTEL_QAT_DP
777           libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId;
778 #ifdef QAT_TWO_INSTANCE
779       libTrans.instHndl = gCb->u.dlCb->instHndl;
780 #else
781           libTrans.instHndl = gCb->instHndl;
782 #endif
783 #endif
784    }
785
786 #ifdef PJ_SEC_ASYNC
787    /* Start the timer if it is not started already */
788    if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
789    {
790       pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
791    }
792
793    ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
794                                              secInp, libTrans, mBuf);  
795
796 #else
797 #ifndef INTEL_SW_SEC
798       ret = PjLibObdCipherReqFB(&libTrans, mBuf, opSdu);
799 #else
800       ret = pjSendToSwCipherFB(&libTrans, mBuf,gCb,opSdu);
801 #endif
802 #endif
803
804    RETVALUE(ret);
805
806 }
807 #endif
808
809
810 /**
811  *
812  * @brief 
813  *
814  *        Handler for redirecing Integration request to either synchronous
815  *        or asynchronous module.
816  *
817  * @b Description:
818  *
819  *        This function sends Intergrity protection request as either synchronous or
820  *        asynchronous function calls with relevant input parameters.
821  *
822  *  @param[in]   pjRbCb       PDCP RbCb 
823  *  @param[in]   secInp       Input parameters for integrity 
824  *  @param[in]   mBuf         SDU to be compressed 
825  *  @param[out]  macI         Message authentication code for the SDU 
826  *
827  *  @return  S16
828  *      -# ROK 
829  *
830  */
831 #ifdef ANSI
832 PUBLIC S16 pjUtlIntProtReq
833 (
834 PjCb     *gCb,
835 PjDlRbCb   *pjRbCb,             /* PDCP RbCb */
836 PjSecInp secInp,              /* Input parameters for integrity */ 
837 Buffer   **mBuf               /* SDU to be compressed */
838 )
839 #else
840 PUBLIC S16 pjUtlIntProtReq(gCb, pjRbCb, secInp, mBuf)
841 PjCb     *gCb;
842 PjDlRbCb   *pjRbCb;             /* PDCP RbCb */
843 PjSecInp secInp;              /* Input parameters for integrity */ 
844 Buffer   **mBuf;               /* SDU to be compressed */
845 #endif
846 {
847    S16 ret = ROK;
848    PjDlUeCb *dlUeCb;
849    PjLibTrans libTrans;
850 #if PJ_SEC_ASYNC
851    Void   *cxtId;    /* Context Identifier */
852 #endif
853
854    TRC3(pjUtlIntProtReq)
855
856 #if PJ_SEC_ASYNC
857    cxtId = pjRbCb->ueCb->secInfo.intCxtId;
858 #endif
859
860    dlUeCb = pjRbCb->ueCb;
861    libTrans.pdcpInstance = gCb->init.inst;
862    libTrans.count = secInp.count;
863    libTrans.rbId = pjRbCb->rbId - 1;
864    libTrans.dir = secInp.dir;
865    libTrans.rbType = pjRbCb->rbType;
866    /*pSecInfo.snLen = pjRbCb->snLen;*/
867    libTrans.intAlgoType = dlUeCb->secInfo.intInfo.algoType;
868    libTrans.ueCb = (PTR)dlUeCb;
869    libTrans.ueId = dlUeCb->key.ueId;
870    libTrans.cellId = dlUeCb->key.cellId;
871    libTrans.key = &(dlUeCb->secInfo.intInfo.intKey[0]);
872    PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId);
873    
874 #ifdef INTEL_QAT_DP
875    libTrans.sessCxtId = dlUeCb->secInfo.cpIntSessCxtId;
876 #ifdef QAT_TWO_INSTNACES
877    libTrans.instHndl = gCb->u.dlCb->instHndl;
878 #else
879    libTrans.instHndl = gCb->instHndl;
880 #endif
881 #endif
882
883 #ifdef PJ_SEC_ASYNC
884    /* Start the timer if it is not started already */
885    if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
886    {
887       pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
888    }
889
890    ret = PjLibObdIntProtReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, 
891                                  secInp, libTrans, mBuf);  
892
893 #else
894 #ifdef INTEL_SW_INTEG
895    ret = PjLibObdIntProtReq(gCb, &libTrans, mBuf);
896 #else
897    ret = PjLibObdIntProtReq(&libTrans, mBuf);
898 #endif /* INTEL_SW_INTEG */
899 #endif
900
901    RETVALUE(ret);
902
903 } /* end of pjUtlIntProtReq */
904
905 //#endif
906
907
908 /**
909  *
910  * @brief 
911  *
912  *        Handler for closing the DL context with the Ciphering unit (either 
913  *        synchronous or asynchronous) for SRBs of an UE.
914  *
915  * @b Description:
916  *
917  *        This function closes an existing DL context with the security algo unit per UE
918  *        for ciphering / deciphering with control plane key using synchronous / asynchronous 
919  *        function calls with relevant input parameters.
920  *
921  *
922  *  @param[in] cpCxtId          Context Id for Ciphering to be closed 
923  *
924  *  @return  S16
925  *      -# ROK 
926  *
927  */
928 #ifdef ANSI 
929 PUBLIC S16 pjUtlDlCipherClose
930 (
931 PjCb     *gCb,
932 Void     *cpCxtId                  /* Context Id for Ciphering to be closed */
933 )
934 #else
935 PUBLIC S16 pjUtlDlCipherClose(gCb, cpCxtId)
936 PjCb     *gCb;
937 Void     *cpCxtId;                 /* Context Id for Ciphering to be closed */
938 #endif
939 {
940 #ifdef INTEL_QAT_DP
941    S16 ret;
942 #endif
943    TRC3(pjUtlDlCipherClose)
944
945    RLOG0(L_DEBUG, "pjUtlDlCipherClose");
946
947 #ifndef PJ_SEC_ASYNC
948 #ifdef INTEL_QAT_DP
949 #ifdef QAT_TWO_INSTANCE
950    ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId);
951 #else
952    ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
953 #endif
954 #else
955    PjLibObdCipherCloseReq(cpCxtId);
956 #endif
957 #else
958 #ifdef INTEL_QAT_DP
959 #ifdef QAT_TWO_INSTANCE
960    ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId);
961 #else
962    ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId);
963 #endif
964 #else
965    PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId);
966 #endif
967 #endif
968
969 #ifdef INTEL_QAT_DP
970    RETVALUE(ret);
971 #else
972    RETVALUE(ROK);
973 #endif
974
975 } /* end of pjUtlCipherClose */
976
977
978 /**
979  *
980  * @brief 
981  *
982  *        Handler for closing the DL context with the Integration unit (either 
983  *        synchronous or asynchronous) for all RBs of an UE.
984  *
985  * @b Description:
986  *
987  *        This function closes an existing DL context with the security algo unit per UE
988  *        for Integration protection/verification using synchronous / asynchronous function 
989  *        calls with relevant input parameters.
990  *
991  *
992  *  @param[in] intCxtId        Integration CxtId to be closed 
993  *
994  *  @return  S16
995  *      -# ROK 
996  *
997  */
998 #ifdef ANSI 
999 PUBLIC S16 pjUtlDlIntClose
1000 (
1001 PjCb     *gCb,
1002 Void      *intCxtId                 /* Integration CxtId to be closed */
1003 )
1004 #else
1005 PUBLIC S16 pjUtlDlIntClose(gCb, intCxtId)
1006 PjCb     *gCb;
1007 Void      *intCxtId;                /* Integration CxtId to be closed */
1008 #endif
1009 {
1010 #ifdef INTEL_QAT_DP
1011    S16 ret = ROK;
1012 #endif
1013    TRC3(pjUtlDlIntClose)
1014
1015    RLOG0(L_DEBUG, "pjUtlDlIntClose");
1016
1017 #ifdef PJ_SEC_ASYNC
1018    PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId);
1019 #else   
1020 #ifdef INTEL_QAT_DP
1021 #ifdef QAT_TWO_INSTANCE
1022    ret = PjLibObdIntCloseReq(gCb->u.dlCb->instHndl,intCxtId);
1023 #else
1024    ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId);
1025 #endif
1026 #else
1027    PjLibObdIntCloseReq(intCxtId);
1028 #endif /* INTEL_QAT_DP */
1029 #endif /* PJ_SEC_ASYNC */
1030
1031 #ifdef INTEL_QAT_DP
1032    RETVALUE(ret);
1033 #else
1034    RETVALUE(ROK);
1035 #endif
1036
1037 } /* end of pjUtlIntClose */
1038
1039
1040 /**
1041  *
1042  * @brief 
1043  *
1044  *        Handler for resetting the context with the compression unit (either 
1045  *        synchronous or asynchronous) for RB within an UE.
1046  *
1047  * @b Description:
1048  *
1049  *        This function resets the context with the compression unit per RB per
1050  *        UE by using synchronous / asynchronous function calls.
1051  *
1052  *
1053  *  @param[in] cmpCxtId     Context to be reset for compression 
1054  *
1055  *  @return  S16
1056  *      -# ROK 
1057  *
1058  */
1059 #ifdef ANSI
1060 PUBLIC S16 pjUtlDlCmpReset
1061 (
1062 PjCb        *gCb,
1063 PjDlRbCb      *pjRbCb                 /* Context to be reset for compression */
1064 )
1065 #else
1066 PUBLIC S16 pjUtlDlCmpReset(pjRbCb) 
1067 PjCb        *gCb;
1068 PjDlRbCb      *pjRbCb;                 /* Context to be reset for compression */
1069 #endif
1070 {
1071    TRC3(pjUtlDlCmpReset)  
1072
1073    RLOG2(L_DEBUG, "pjUtlCmpReset(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
1074
1075 #ifdef PJ_CMP_ASYNC
1076    PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId);
1077 #else
1078    pjLibCmpResetReq(pjRbCb->cmpCxtId);
1079 #endif
1080
1081    RETVALUE(ROK);
1082
1083 } /* end of pjUtlCmpReset */
1084
1085
1086 /**
1087  *
1088  * @brief 
1089  *        Handle re-establishment on SRB1. 
1090  *
1091  * @b Description:
1092  *        This function 
1093  *        1. Marks the state of the RBs as PJ_STATE_REEST.
1094  *        2. Calculates the number of RBs undergoing reestablishment.
1095  *
1096  *  @param[in] gCb     PDCP Instance control block
1097  *  @param[in] pjRbCb  Downlink Rb control block 
1098  *
1099  *  @return  S16
1100  *      -# ROK 
1101  *      -# RFAILED
1102  *
1103  */
1104 #ifdef ANSI
1105 PUBLIC S16 pjUtlDlReEstSrb1
1106 (
1107 PjCb       *gCb,
1108 PjDlRbCb   *pjRbCb                    /* PDCP Control Block Pointer */
1109 )
1110 #else
1111 PUBLIC S16 pjUtlDlReEstSrb1(gCb, pjRbCb)
1112 PjCb       *gCb;
1113 PjDlRbCb   *pjRbCb;                   /* PDCP Control Block Pointer */
1114 #endif
1115 {
1116    PjDlUeCb   *ueCb;
1117
1118    TRC2(pjUtlDlReEstSrb1)
1119
1120    RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType);
1121
1122    ueCb = pjRbCb->ueCb;
1123
1124    ueCb->libInfo.state  =  PJ_STATE_REEST;
1125
1126    /* SRB Reconfiguration we can update the control Plane keys and
1127       the Integrity Keys in the OBD module */
1128
1129    pjUtlDlUpdCpSecKeys(gCb,ueCb);
1130
1131    /* Perform downlink reestablishment of SRB1 */
1132    pjDlmReEstSrb(gCb,pjRbCb);
1133
1134    /*  If Only SRB1 configured then we can update userplane 
1135        keys also */
1136    if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0))
1137    {
1138       pjUtlDlUpdUpSecKeys(gCb,ueCb);
1139    }
1140
1141    RETVALUE(ROK);
1142 } /* pjUtlReEstSrb1 */
1143
1144 \f
1145 /**
1146  *
1147  * @brief 
1148  *
1149  *        Handler to start reestablishment processing
1150  *
1151  * @b Description:
1152  *
1153  *        This function 
1154  *        1. Marks the state of the RBs as PJ_STATE_REEST_HO.
1155  *        2. Calculates the number of RBs undergoing reestablishment.
1156  *
1157  *  @param[in] ueCb    Number of RBs undergoing reestablishment
1158  *
1159  *  @return  S16
1160  *      -# ROK 
1161  *      -# RFAILED
1162  *
1163  */
1164 #ifdef ANSI
1165 PUBLIC S16 pjUtlDlReEstHO
1166 (
1167 PjCb              *gCb,
1168 PjDlUeCb          *ueCb           /* Number of RBs undergoing reestablishment*/ 
1169 )
1170 #else
1171 PUBLIC S16 pjUtlDlReEstHO(gCb,ueCb)    
1172 PjCb              *gCb;
1173 PjDlUeCb          *ueCb;           /* Number of RBs undergoing reestablishment*/ 
1174 #endif
1175 {
1176    U8             rbCnt;
1177    PjDlRbCb     **rbCbLst;
1178    PjDlRbCb     * pjRbCb;
1179
1180    TRC2 (pjUtlDlReEstHO); 
1181
1182 #ifdef ALIGN_64BIT
1183    RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
1184 #else
1185    RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
1186 #endif
1187
1188    /* Initialisations */
1189    ueCb->libInfo.numReEstDrb = 0;
1190    ueCb->libInfo.state = PJ_STATE_REEST_HO;
1191
1192    /* Perform initialisations on the HO Info structure */
1193    PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));
1194 #if (ERRCLASS & ERRCLS_ADD_RES)
1195    if (ueCb->hoInfo == NULLP)
1196    {
1197       RLOG0(L_FATAL, "Memory Allocation failed.");
1198       RETVALUE(RFAILED);
1199    }
1200 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1201
1202    PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo, sizeof(PjDlHoCfmInfo) *  PJ_MAX_DRB_PER_UE );
1203 #if (ERRCLASS & ERRCLS_ADD_RES)
1204    if (ueCb->hoInfo->hoCfmInfo == NULLP )
1205    {
1206       /*ccpu00136858 */      
1207       PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region,
1208                   gCb->u.dlCb->udxDlSap[0].pst.pool, 
1209                            ueCb->hoInfo, sizeof(PjDlHoInfo));
1210       RLOG0(L_FATAL, "Memory Allocation failed.");
1211       RETVALUE(RFAILED);
1212    }
1213 #endif /* ERRCLASS & ERRCLS_ADD_RES */
1214
1215    /* Initialise the reestablishment states for the RBs */
1216    rbCbLst      = ueCb->drbCb;
1217    for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++)
1218    {
1219       /* Check of rbCb available */
1220       if( (pjRbCb = rbCbLst[rbCnt]) == NULLP)
1221       {
1222          continue;
1223       }
1224
1225       /* Fetch the rbCb and intialise the states */
1226       pjRbCb->state  =  PJ_STATE_REEST_HO;
1227       
1228       if(pjRbCb->mode == PJ_DRB_AM)
1229       {
1230          pjDlmReEstHoDrbAm(gCb, pjRbCb);
1231       }
1232
1233    }/* for(rbCnt .. */ 
1234
1235    RETVALUE(ROK);
1236 } /* pjUtlReEstHO */
1237
1238
1239 /**
1240  *
1241  * @brief 
1242  *
1243  *        Called after the new security algorithms have been applied
1244  *        and header compression/decompression reset. It starts
1245  *        reestablishment procedures for downlink DRBs.
1246  *
1247  * @b Description:
1248  *
1249  *        This function 
1250  *        1. Creates new contexts for Ciphering and Integrity.
1251  *        2. Closes the old contexts for Ciphering and Integrity.
1252  *        3. Resets the ROHC unit.
1253  *
1254  *  @param[in] ueCb   UE Control Block
1255  *
1256  *  @return  S16
1257  *      -# ROK 
1258  *      -# RFAILED
1259  *
1260  */
1261 #ifdef ANSI
1262 PUBLIC S16 pjUtlReEstDl
1263 (
1264 PjCb       *gCb,
1265 PjDlUeCb   *ueCb           /* UE Control Block */ 
1266 )
1267 #else
1268 PUBLIC S16 pjUtlReEstDl(gCb, ueCb)
1269 PjCb       *gCb;
1270 PjDlUeCb   *ueCb;           /* UE Control Block */ 
1271 #endif
1272 {
1273    TRC2(pjUtlReEstDl);
1274
1275    RLOG2(L_DEBUG, "pjUtlReEstDl(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
1276
1277
1278    /* Send Cfms and update the state  only 
1279       when there is some cfgreq cfm is present for other RBs*/
1280    if(ueCb->libInfo.state == PJ_STATE_REEST)
1281    {
1282       pjUtlDlSndReEstCfgCfm(gCb, ueCb);
1283    }
1284    else if(ueCb->libInfo.state == PJ_STATE_REEST_HO)
1285    {
1286       pjUtlDlSndSduStaCfm(gCb, ueCb);
1287    }
1288    ueCb->libInfo.state = PJ_STATE_NORMAL;
1289
1290    RETVALUE(ROK);
1291
1292 } /* pjUtlReEstDl */
1293
1294
1295
1296 \f
1297 /**
1298  *
1299  * @brief 
1300  *
1301  *        Function to sent the REESTABLISHMENT COMPPLETE 
1302  *        to the RRC.
1303  *
1304  * @b Description:
1305  *
1306  *        This function 
1307  *        1. Sends a ReEstablishment Confirm for normal reestablishment.
1308  *        2. Sends a SDU status confirm for handover reestablishment.
1309  *
1310  *  @param[in] ueCb   UE Control Block
1311  *
1312  *  @return  S16
1313  *      -# ROK 
1314  *      -# RFAILED
1315  *
1316  */
1317 #ifdef ANSI
1318 PUBLIC S16 pjUtlDlSndReEstCfgCfm
1319 (
1320 PjCb         *gCb,
1321 PjDlUeCb       *ueCb           /* UE Control Block */ 
1322 )
1323 #else
1324 PUBLIC S16 pjUtlDlSndReEstCfgCfm(ueCb)
1325 PjCb         *gCb;
1326 PjDlUeCb       *ueCb;           /* UE Control Block */ 
1327 #endif
1328 {
1329    U8             rbCnt;
1330    PjDlRbCb        *tRbCb;
1331    CpjCfgCfmInfo *cfgCfmInfo;
1332    U8             txIdx;
1333    PjAsyncCfm    *asyncCfm    = NULLP;
1334    PjUdxDlSapCb *udxSap;
1335    S16          ret = ROK;
1336
1337    TRC2(pjUtlDlSndReEstCfgCfm);
1338
1339    RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
1340
1341    ueCb->libInfo.state  =  PJ_STATE_NORMAL;
1342
1343    /* Pick up the confirm info */
1344    for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++)
1345    {
1346       if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) &&
1347          (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1348       {
1349          asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
1350          break;
1351       }
1352    }
1353
1354    /* its a reestablishment with only srb1 configured */
1355    if(asyncCfm == NULLP)
1356    {
1357       RETVALUE(ROK);
1358    }
1359
1360    for(rbCnt = 0; rbCnt < PJ_MAX_SRB_PER_UE; rbCnt ++)
1361    {
1362       if( ((tRbCb = ueCb->srbCb[rbCnt]) == NULLP)    ||
1363           (tRbCb->state ==  PJ_STATE_NORMAL))
1364       {
1365          continue;
1366       }
1367
1368       /* Fetch the rbCb and intialise the states */
1369       tRbCb->state  =  PJ_STATE_NORMAL;
1370    } 
1371    
1372    /* Memory leak fix ccpu00135359 */
1373    udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
1374    PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfmInfo,
1375       sizeof (CpjCfgCfmInfo), ret);
1376    if(ret != ROK)
1377    {
1378       RLOG0(L_FATAL, "Memory Allocation failed.");
1379       RETVALUE(RFAILED);
1380    }
1381
1382    PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm);
1383    PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1384
1385    PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
1386                   gCb->u.dlCb->udxDlSap[0].suId, 
1387                    (UdxCfgCfmInfo *)cfgCfmInfo);         
1388
1389    RETVALUE(ROK);
1390 } /* pjUtlSndReEstCfgCfm */
1391
1392
1393 /**
1394  *
1395  * @brief Handler to store the confirms while we wait for the init
1396  *        confirms from the off-board.
1397  *       
1398  *
1399  * @b Description
1400  *        This function is invoked during security config request,
1401  *        reestablishment request and config request if the libraries
1402  *        are off-boarded. This stores the entries in a confirm list
1403  *        while waiting for the confirm from the offboard.
1404  *
1405  *  @return  S16
1406  *      -# ROK 
1407  *      -# RFAILED 
1408  *
1409 */
1410
1411 #ifdef ANSI
1412 PUBLIC S16 pjUtlDlSaveCfmInfo
1413 (
1414 PjCb        *gCb,
1415 PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
1416 U8          cfmType,         /* Confirm type */
1417 Bool        startTmr,        /* Start Timer */
1418 U8          entity,          /* Confirm type */
1419 PTR         cfmPtr,          /* Pointer to the structure for confirm */
1420 PTR         cfgPtr           /* Pointer to the structure for request */
1421 )
1422 #else
1423 PUBLIC S16 pjUtlDlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr)
1424 PjCb        *gCb;
1425 PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
1426 U8          cfmType;         /* Confirm type */
1427 Bool        startTmr;        /* Start Timer */
1428 U8          entity;          /* Confirm type */
1429 PTR         cfmPtr;          /* Pointer to the structure for confirm */
1430 PTR         cfgPtr;          /* Pointer to the structure for request */
1431 #endif
1432 {
1433    S16               ret;        /* Return value            */
1434    CpjSecCfgCfmInfo  *secCfm;    /* Security confirm        */
1435    CpjReEstCfmInfo   *reEstCfm;  /* Reestablishment confirm */
1436    CpjCfgCfmInfo     *cfgCfm;    /* Config confirm          */
1437    U16               txId;       /* Transaction Id          */
1438    PjAsyncCfm        *tAsyncCfm; /* Pointer to the async Cfm*/
1439    CpjCfgReqInfo     *cfgReq;    /* Pointer to the config request */
1440    U8                cfmIdx;     /* index for loopoing */
1441
1442
1443    TRC3(pjUtlDlSaveCfmInfo) 
1444
1445    RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
1446          "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))",
1447          ueCb->key.cellId, cfmType, startTmr, entity);
1448
1449    /* Initialisations */
1450    ret      = ROK;
1451    secCfm   = NULLP;
1452    reEstCfm = NULLP;
1453    cfgCfm   = NULLP;
1454    cfgReq   = NULLP;
1455    txId     = ueCb->libInfo.nxtAvlbTxId;
1456
1457    if(txId == PJ_MAX_ASYNC_CFM)
1458    {
1459       /* The entire list is full, have to return negative confirms */
1460       RETVALUE(RFAILED);
1461    }
1462
1463    /* is entry already present */
1464    if(ueCb->libInfo.asyncCfm[txId] != NULLP)
1465    {
1466       RETVALUE(RFAILED);
1467    }
1468
1469    /* Allocate the structure */
1470    PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId],  sizeof(PjAsyncCfm));
1471    if(ueCb->libInfo.asyncCfm[txId]== NULLP)
1472    {
1473       RLOG0(L_FATAL, "Memory Allocation failed.");
1474       RETVALUE(RFAILED);
1475    }
1476
1477    /* Initialise the structure */
1478    tAsyncCfm   =   ueCb->libInfo.asyncCfm[txId];
1479    tAsyncCfm->libInitBitMask   =   ueCb->libInfo.tLibInitBitMask;
1480    tAsyncCfm->cmpInitBitMask   =   ueCb->libInfo.tCmpInitBitMask;
1481    tAsyncCfm->entity           =   entity;
1482    tAsyncCfm->startTmr         =   startTmr;
1483
1484    ueCb->libInfo.tLibInitBitMask =  0; 
1485    ueCb->libInfo.tCmpInitBitMask =  0; 
1486    
1487    /* Assign the values */
1488    if(cfmType  ==   PJ_SEC_ASYNC_CFM)
1489    {
1490       secCfm   =  (CpjSecCfgCfmInfo *)cfmPtr;
1491       tAsyncCfm->cfmType =  cfmType;
1492       tAsyncCfm->ueId    = secCfm->ueId;
1493       tAsyncCfm->cellId  = secCfm->cellId;
1494       tAsyncCfm->transId = secCfm->transId;
1495    }
1496    else if(cfmType  ==   PJ_REEST_ASYNC_CFM)
1497    {
1498       reEstCfm   =  (CpjReEstCfmInfo *)cfmPtr;
1499       tAsyncCfm->cfmType =  cfmType;
1500       tAsyncCfm->ueId    = reEstCfm->ueId;
1501       tAsyncCfm->cellId  = reEstCfm->cellId;
1502       tAsyncCfm->transId = reEstCfm->transId;
1503    }
1504    else if((cfmType  & PJ_CFG_ASYNC_CFM)  ||
1505            (cfmType  & PJ_CFG_REEST_ASYNC_CFM)||
1506            (cfmType  & PJ_CFG_UEDEL_ASYNC_CFM))
1507    {
1508       if(entity   == ENTPJ)
1509       {
1510          cfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
1511          cfgReq   =  (CpjCfgReqInfo *)cfgPtr;
1512
1513          tAsyncCfm->cfmType = cfmType;
1514          tAsyncCfm->ueId    = cfgCfm->ueId;
1515          tAsyncCfm->cellId  = cfgCfm->cellId;
1516          tAsyncCfm->transId = cfgCfm->transId;
1517          tAsyncCfm->numEnt  = cfgReq->numEnt;
1518
1519          for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ )
1520          {
1521             tAsyncCfm->cfmEnt[cfmIdx].status  = cfgCfm->cfmEnt[cfmIdx].status;
1522             tAsyncCfm->cfmEnt[cfmIdx].reason  = cfgCfm->cfmEnt[cfmIdx].reason;
1523             tAsyncCfm->cfmEnt[cfmIdx].rbId    = cfgCfm->cfmEnt[cfmIdx].rbId;
1524             tAsyncCfm->cfmEnt[cfmIdx].rbType  = cfgCfm->cfmEnt[cfmIdx].rbType;
1525             tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType;
1526          }
1527       }
1528       else if(entity == ENTPJ)
1529       {
1530          CpjCfgCfmInfo  *pjCfgCfm;       /* Configuraiton Confirm */
1531
1532          pjCfgCfm   =  (CpjCfgCfmInfo *)cfmPtr;
1533
1534          tAsyncCfm->cfmType = cfmType;
1535          tAsyncCfm->transId = pjCfgCfm->transId;
1536          tAsyncCfm->ueId    = pjCfgCfm->ueId;
1537          tAsyncCfm->cellId  = pjCfgCfm->cellId;
1538          tAsyncCfm->numEnt  = pjCfgCfm->numEnt;
1539
1540          for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ )
1541          {
1542             tAsyncCfm->cfmEnt[cfmIdx].status  = 
1543                                  pjCfgCfm->cfmEnt[cfmIdx].status;
1544             tAsyncCfm->cfmEnt[cfmIdx].reason  = 
1545                                  pjCfgCfm->cfmEnt[cfmIdx].reason;
1546             tAsyncCfm->cfmEnt[cfmIdx].rbId    = 
1547                                  pjCfgCfm->cfmEnt[cfmIdx].rbId;
1548             tAsyncCfm->cfmEnt[cfmIdx].rbType  = 
1549                                  pjCfgCfm->cfmEnt[cfmIdx].rbType;
1550          }
1551       }
1552    }
1553
1554    /* Start timer */
1555    /* Timer should not be started when SEC is SYNC for ReEst Req
1556     * and for the subsequent config req for REEST. The config req
1557     * after reest req can still start the timer in the case comp being
1558     * async and sec being sync if it also adds a RB and a compInit has
1559     * to be sent . 
1560     * */
1561
1562    if(tAsyncCfm->startTmr  == TRUE)
1563    {
1564       if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE)
1565       {
1566          pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
1567          ueCb->libInfo.crntTmrTxId  =  ueCb->libInfo.nxtAvlbTxId;
1568       }
1569    }
1570
1571    /* update nxtAvlbTxId to the next empty slot */
1572    for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++)
1573    {
1574       ueCb->libInfo.nxtAvlbTxId = 
1575         (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM);  /*KW_FIX*/
1576
1577       if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP)
1578       {
1579          break;
1580       }
1581    }
1582
1583    /* Cant find an empty slot ? */
1584    if(cfmIdx == PJ_MAX_ASYNC_CFM)
1585    {
1586       ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM;
1587    }
1588
1589    RETVALUE(ret);
1590 }/* pjUtlSaveCfmInfo */
1591 \f
1592 /**
1593  *
1594  * @brief Handler to store update the bitmaks and send confirms if necessary.
1595  *       
1596  *
1597  * @b Description
1598  *        This function is invoked when receiving a InitCfm from Offboard.
1599  *        It updates the bit masks and checks if it is necesary to send a 
1600  *        confirm.
1601  *
1602  *  @return  S16
1603  *      -# ROK 
1604  *      -# RFAILED 
1605  *
1606 */
1607
1608 #ifdef ANSI
1609 PUBLIC S16 pjUtlDlHdlObdInitCfm
1610 (
1611 PjCb        *gCb,
1612 PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
1613 U16         txIdx,           /* Transaction Index for UeCb */
1614 U8          cfmType,         /* Confirm type */
1615 U8          maskVal          /* mask value */
1616 )
1617 #else
1618 PUBLIC S16 pjUtlDlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal)
1619 PjCb        *gCb;
1620 PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
1621 U16         txIdx;           /* Transaction Index for UeCb */
1622 U8          cfmType;         /* Confirm type */
1623 U8          maskVal;         /* mask value */
1624 #endif
1625 {
1626    UdxSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
1627    UdxReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
1628    PjAsyncCfm       *asyncCfm;
1629    UdxCfgCfmInfo    *cfgCfm;
1630    U8               idx;
1631    S16              ret;
1632
1633    TRC3(pjUtlDlHdlObdInitCfm)
1634
1635    RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, 
1636          "pjUtlHdlDlObdInitCfm cellId(%d), txIdx(%d), cfmType(%d), maskVal(%d))",
1637           ueCb->key.cellId, txIdx, cfmType, maskVal);
1638
1639    /* Initialisations */
1640    secCfgCfm   =  NULLP;
1641    reEstCfm    =  NULLP;
1642    cfgCfm      =  NULLP;
1643    asyncCfm    =  NULLP;
1644    ret         =  ROK;
1645
1646    if((txIdx  == PJ_MAX_ASYNC_CFM) ||
1647       (ueCb->libInfo.asyncCfm[txIdx] == NULLP))
1648    {
1649       RETVALUE(RFAILED);
1650    }
1651
1652    asyncCfm =  ueCb->libInfo.asyncCfm[txIdx];
1653
1654    if(cfmType & PJ_SEC_INIT_CFM)
1655    {
1656       /* Update bit mask and check if all confirms have been received */
1657       asyncCfm->libInitBitMask ^= (maskVal);
1658       ret = pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm);
1659    }
1660    else if(cfmType  & PJ_CMP_INIT_CFM)
1661    {
1662       /* Check if all confirms have been received */
1663       asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1));
1664
1665       /* Update the status and reason for the received CmpInitCfm */
1666       for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
1667       {
1668          if ( asyncCfm->cfmEnt[idx].rbId == maskVal)
1669          {
1670             asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK;
1671             asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE;
1672             break;
1673          }
1674       }
1675
1676       /* Check if we can send confirm */
1677       if(asyncCfm->cmpInitBitMask == 0)
1678       {
1679          ret = pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm);
1680       }
1681    }
1682    RETVALUE(ret);
1683 }/* pjUtlHdlDlObdInitCfm */
1684 \f
1685 /**
1686  *
1687  * @brief Handler for init off-board timer expiry.
1688  *
1689  *
1690  * @b Description
1691  *        This function is called when the off-board timer expires for
1692  *        a Init Req of a channel (either for ciphering/integrity/compression).
1693  *        This function sends a confirm with failure for SecCfgReq if the
1694  *        state of the RB is normal. It sends a confirm with failure
1695  *        for config request(only for RBs with Re-establishment Req, a failure 
1696  *        is stored in the confirm) if the state of the RB is re-establishment.
1697  *
1698  *  @param[in] ueCb    UE control block.
1699  *
1700  *
1701  *  @return  S16
1702  *      -# ROK
1703  */
1704
1705 #ifdef ANSI
1706 PUBLIC S16 pjUtlDlHdlInitObdTmrExp
1707 (
1708 PjCb     *gCb,
1709 PjDlUeCb *ueCb
1710 )
1711 #else
1712 PUBLIC S16 pjUtlDlHdlInitObdTmrExp(ueCb)
1713 PjCb     *gCb;
1714 PjDlUeCb *ueCb;
1715 #endif
1716 {
1717    S16               ret;           /* Return Value */
1718    UdxSecCfgCfmInfo  *secCfgCfm;    /* Security Cfg Confirm Info */
1719    UdxCfgCfmInfo     *cfgCfm;       /* Config Confirm Info */
1720    UdxReEstCfmInfo   *reEstCfm;     /* Reest config confirm */
1721    UdxCfgCfmInfo     *pjCfgCfm;
1722    PjLibInfo         *libInfo;      /* Off-board Info */
1723    PjAsyncCfm        *asyncCfm;     /* Async Cfm Info */
1724    PjUdxDlSapCb      *udxSap;
1725    U16               txIdx;         /* Tx Idx */
1726    U16               idx;           /* Index for looping */
1727    U16               cfgIdx;
1728
1729    TRC3(pjUtlDlHdlInitObdTmrExp)
1730
1731    RLOG2(L_DEBUG, "pjUtlDlHdlInitObdTmrExp(ueCb(%d,%d))",
1732          ueCb->key.ueId, ueCb->key.cellId);
1733
1734    ret       = ROK;
1735    udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
1736    secCfgCfm = NULLP;
1737    libInfo   = &ueCb->libInfo;
1738    txIdx     = libInfo->crntTmrTxId;
1739
1740    /* Restart the timer */
1741    PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
1742
1743    /* Shouldnt happen, nevertheless, check */
1744    if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP)
1745    {
1746       RETVALUE(ROK);
1747    }
1748
1749    asyncCfm =  libInfo->asyncCfm[txIdx];
1750
1751    /* Security confirm */
1752    if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM)
1753    {
1754       PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm,
1755           sizeof (UdxSecCfgCfmInfo), ret);
1756       if(ret != ROK)
1757       {
1758          RLOG0(L_FATAL, "Memory Allocation failed.");
1759          RETVALUE(RFAILED);
1760       }
1761       PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
1762       secCfgCfm->status = CPJ_CFG_CFM_NOK;
1763       secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT;
1764
1765       PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1766
1767       PjDlUdxSecCfgCfm((&udxSap->pst), udxSap->suId, secCfgCfm);
1768    }
1769
1770    /* Configuration confirms */
1771    else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) ||
1772             (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1773    {
1774       PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
1775
1776       PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1777
1778       PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), 
1779                          gCb->u.dlCb->udxDlSap[0].suId, 
1780                         cfgCfm);
1781    }
1782    else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM)
1783    {
1784       /* Send ReEstCfm */
1785       /* Memory leak fix ccpu00135359 */
1786       PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm,
1787           sizeof (UdxReEstCfmInfo), ret);
1788       if(ret != ROK)
1789       {
1790          RLOG0(L_FATAL, "Memory Allocation failed.");
1791          RETVALUE(RFAILED);
1792       }
1793       PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK);
1794
1795       PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1796
1797       PjDlUdxReEstCfm(&udxSap->pst, 
1798                        udxSap->suId, reEstCfm);
1799
1800       /* Send the config confirm also if any exists */
1801       cfgIdx   = (U16)( txIdx + 1); /*KW_FIX*/
1802
1803       for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++)
1804       {
1805          cfgIdx %=   PJ_MAX_ASYNC_CFM;
1806          if((libInfo->asyncCfm[cfgIdx] != NULLP) &&
1807             (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM))
1808          {
1809             break;
1810          }
1811       }
1812
1813       /* This scenario occurs when only SRB1 is configured */
1814       if(idx == PJ_MAX_ASYNC_CFM)
1815       {
1816          RETVALUE(ROK);
1817       }
1818
1819       PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx);
1820       asyncCfm =  libInfo->asyncCfm[cfgIdx];
1821
1822       PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm);
1823
1824       PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
1825
1826       PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
1827                   gCb->u.dlCb->udxDlSap[0].suId, cfgCfm);         
1828    }
1829    else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM)
1830    {
1831       /* Delete ueCb entry from ueLstCp */
1832       pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR);
1833       ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb);
1834       if (ret != ROK)
1835       {
1836
1837 #ifdef DEBUGP
1838          RLOG_ARG0(L_ERROR, DBG_UEID,ueCb->key.ueId, 
1839                "Hash List Delete Failed for DL ueCb");
1840 #endif
1841       }
1842
1843       if ( asyncCfm->entity == ENTPJ )
1844       {
1845          PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm,
1846              sizeof (UdxCfgCfmInfo), ret);
1847          if(ret != ROK)
1848          {
1849             RLOG0(L_FATAL, "Memory Allocation failed.");
1850             RETVALUE(RFAILED);
1851          }
1852
1853          for ( idx = 0; idx < asyncCfm->numEnt; idx++)
1854          {
1855             cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
1856             cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
1857             cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
1858             cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
1859          }
1860          cfgCfm->ueId    = asyncCfm->ueId;
1861          cfgCfm->cellId  = asyncCfm->cellId;
1862          cfgCfm->transId = asyncCfm->transId;
1863          cfgCfm->numEnt  = asyncCfm->numEnt;
1864
1865          /* delete all confirms present there */
1866          for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
1867          {
1868             if(libInfo->asyncCfm[idx] != NULLP)
1869             {
1870                PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
1871                ueCb->libInfo.asyncCfm[idx] = NULLP; 
1872             }
1873          }
1874
1875          PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb));
1876          PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm);
1877       }
1878       else if ( asyncCfm->entity == ENTPJ )
1879       {
1880          /* Memory leak fix ccpu00135359 */
1881          PJ_ALLOC_BUF_SHRABL(udxSap->pst,pjCfgCfm,
1882              sizeof (UdxCfgCfmInfo), ret);
1883          if(ret != ROK)
1884          {
1885             RLOG0(L_FATAL, "Memory Allocation failed.");
1886             RETVALUE(RFAILED);
1887          }
1888          for ( idx = 0; idx < asyncCfm->numEnt; idx++)
1889          {
1890             pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;
1891             pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;
1892             pjCfgCfm->cfmEnt[idx].rbId          = asyncCfm->cfmEnt[idx].rbId;
1893             pjCfgCfm->cfmEnt[idx].rbType        = asyncCfm->cfmEnt[idx].rbType;
1894          }
1895          pjCfgCfm->ueId    = asyncCfm->ueId;
1896          pjCfgCfm->cellId  = asyncCfm->cellId;
1897          pjCfgCfm->transId = asyncCfm->transId;
1898          pjCfgCfm->numEnt  = asyncCfm->numEnt;
1899
1900          /* delete all confirms present there */
1901          for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++)
1902          {
1903             if(libInfo->asyncCfm[idx] != NULLP)
1904             {
1905                PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); 
1906                ueCb->libInfo.asyncCfm[idx] = NULLP; 
1907             }
1908          }
1909
1910          PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb));
1911          PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, pjCfgCfm);
1912       }
1913    }
1914
1915    RETVALUE(ret);
1916 } /* pjHdlUeDelWaitTmrExp */
1917
1918 \f
1919 /**
1920  *
1921  * @brief 
1922  *
1923  *        Function to sent the REESTABLISHMENT COMPPLETE 
1924  *        to the RRC.
1925  *
1926  * @b Description:
1927  *
1928  *        This function 
1929  *        1. Sends a ReEstablishment Confirm for normal reestablishment.
1930  *        2. Sends a SDU status confirm for handover reestablishment.
1931  *
1932  *  @param[in] ueCb   UE Control Block
1933  *
1934  *  @return  S16
1935  *      -# ROK 
1936  *      -# RFAILED
1937  *
1938  */
1939 #ifdef ANSI
1940 PUBLIC S16 pjUtlDlSndSduStaCfm
1941 (
1942 PjCb         *gCb,
1943 PjDlUeCb       *ueCb           /* UE Control Block */ 
1944 )
1945 #else
1946 PUBLIC S16 pjUtlDlSndSduStaCfm(gCb, ueCb) 
1947 PjCb         *gCb;
1948 PjDlUeCb       *ueCb;           /* UE Control Block */ 
1949 #endif
1950 {
1951    UdxSduStaCfmInfo  *cfmInfo; 
1952    PjUdxDlSapCb     *udxSap;
1953    S16              ret = ROK;
1954
1955    TRC2(pjUtlDlSndSduStaCfm); 
1956
1957    RLOG2(L_DEBUG, "pjUtlSndSduStaCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId);
1958
1959    /* Perform processing for filling up cfm structures */
1960    /* Memory leak fix ccpu00135359 */
1961    udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
1962    PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo,
1963       sizeof (UdxSduStaCfmInfo), ret);
1964    if( ret != ROK)
1965    {
1966       RLOG0(L_FATAL, "Memory Allocation failed.");
1967       RETVALUE(RFAILED);
1968    }
1969    PJ_FILL_DL_SDU_CFM_INFO(gCb,cfmInfo, ueCb);
1970
1971    PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
1972                      gCb->u.dlCb->udxDlSap[0].suId, 
1973                      cfmInfo); 
1974
1975    RETVALUE(ROK);
1976
1977 } /* pjUtlSndSduStaCfm */
1978
1979 /**
1980  *
1981  * @brief Handler to clean up all the PDCP Control Blocks.
1982  *       
1983  *
1984  * @b Description
1985  *        This function is invoked by LMM to shutdown the
1986  *        layer. This cleans up recBuf and txBuf of all the
1987  *        PDCP RBs in all the UEs.
1988  *
1989  *  @return  S16
1990  *      -# ROK 
1991  *      -# RFAILED 
1992  *
1993 */
1994
1995 #ifdef ANSI
1996 PUBLIC S16 pjUtlDlShutdown
1997 (
1998 PjCb  *gCb
1999 )
2000 #else
2001 PUBLIC S16 pjUtlDlShutdown()
2002 PjCb   *gCb;
2003 #endif
2004 {
2005    S16         ret;              /* Return Value */
2006    PjDlUeCb      *ueCb;            /* UE Control Block */
2007    PjDlUeCb      *prevUeCb;        /* Previos UE Control Block */
2008    PjDlRbCb        *rbCb;            /* RB Control Block */
2009    PjDlRbCb        **rbCbLst;        /* RB Control Block List */
2010    PjSec       secInfo;          /* Security info of UE */
2011    U8          idx;              /* Index for RBs */
2012 #ifdef LTE_L2_MEAS_COMMENT
2013    PjL2MeasEvtCb  *measEvtCb = NULLP;
2014 #endif
2015    TRC3(pjUtlDlShutdown) 
2016
2017    RLOG0(L_DEBUG, "pjUtlShutdown()");
2018
2019    ret      = ROK;
2020    ueCb     = NULLP;
2021    prevUeCb = NULLP;
2022    rbCb     = NULLP;
2023    rbCbLst  = NULLP;
2024    idx      = 0;
2025
2026    /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
2027    while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK)
2028    {
2029       if ( ueCb != NULLP )
2030       {
2031 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
2032          if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR)
2033          {
2034             pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR);
2035          }
2036 #endif
2037          rbCbLst = ueCb->srbCb;
2038          for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++)
2039          {
2040              rbCb = rbCbLst[idx];
2041              if (rbCb != NULLP)
2042              {
2043                /* Free the Buffers of RbCb */
2044                pjUtlDlFreeRb(gCb,rbCb);
2045              }
2046          }
2047          rbCbLst = ueCb->drbCb;
2048          for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
2049          {
2050              rbCb = rbCbLst[idx];
2051              if (rbCb != NULLP)
2052              {
2053                 pjUtlDlFreeRb(gCb,rbCb);
2054              }
2055          }
2056          /* Close all the context info for offboarding */
2057          secInfo = ueCb->secInfo;
2058 #ifdef INTEL_QAT_DP
2059          pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
2060          pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
2061          pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
2062 #else    
2063          pjUtlDlCipherClose(gCb,secInfo.cpCxtId);
2064          pjUtlDlCipherClose(gCb,secInfo.upCxtId);
2065          pjUtlDlIntClose(gCb,secInfo.intCxtId);
2066 #endif
2067
2068          /* Delete hoInfo if present */
2069          if (ueCb->hoInfo != NULLP)
2070          {
2071             PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo,
2072                            (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
2073             PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo));                 
2074          }
2075       }
2076       prevUeCb = ueCb;
2077    }
2078 #ifdef LTE_L2_MEAS_COMMENT
2079    for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++)
2080    {
2081       if(gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] != NULLP)
2082       {
2083          measEvtCb = gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx];
2084          pjStopTmr((PTR)measEvtCb, PJ_EVT_L2_TMR);
2085          gCb->u.dlCb->pjL2Cb.pjNumMeas--;
2086          PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb));
2087          gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] = NULLP;
2088       }
2089    }
2090 #endif
2091    ret = pjDbmDlDeInit(gCb);
2092 #if (ERRCLASS & ERRCLS_DEBUG)
2093    if (ret != ROK)
2094    {
2095       RLOG0(L_FATAL, "PDCP DL DeInitialization Failed.");
2096    }
2097 #endif /* ERRCLASS & ERRCLS_DEBUG */
2098
2099
2100    /* commented this to use in deregister timer and kwusap */
2101    /* gCb->init.cfgDone &= ~PJ_LMM_GENCFG_DONE; */
2102    RETVALUE(ret);
2103 }
2104
2105 /**
2106  * 
2107  * @brief 
2108  *
2109  *        Handler to free a PDCP Control Block.
2110  *
2111  * @b Description:
2112  * 
2113  *        This function frees the txBuf and rxBuf in a PDCP control block.
2114  *        and closes the compression channel opened. It stops the timers 
2115  *        of this control block if they are running.
2116  *
2117  *  @param[in]  pst        Post structure 
2118  *  @param[in]  secCxt     Context for Integrity protection/verification 
2119  *  @param[in]  ctxId      Integrity Context Id
2120  *
2121  *
2122  *  @return  S16
2123  *      -# ROK 
2124  *
2125  */
2126
2127 #ifdef ANSI
2128 PUBLIC Void pjUtlDlFreeRb
2129 (
2130 PjCb     *gCb,
2131 PjDlRbCb *pjRbCb
2132 )
2133 #else
2134 PUBLIC Void pjUtlDlFreeRb(pjRbCb)
2135 PjCb     *gCb;
2136 PjDlRbCb *pjRbCb;
2137 #endif
2138 {
2139    TRC3(pjUtlDlFreeRb)
2140    RLOG0(L_DEBUG, "pjUtlFreeRb()");
2141
2142
2143 #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC))
2144    if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR)
2145    {
2146        pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
2147    }
2148 #endif
2149    
2150    pjUtlCmpClose(gCb,pjRbCb->cmpCxtId);
2151    /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/
2152    RETVOID;
2153 }
2154
2155 /* pj005.201 added function to send data forward indication message */
2156 /**
2157  * 
2158  * @brief 
2159  *
2160  *        Handler to send Data Fwd Indication
2161  *
2162  * @b Description:
2163  *      This function sends Data Fwd Indication message to PDCP user 
2164  *
2165  *  @param[in]  pjRbCb     PDCP RbCb
2166  *  @param[in]  datFwdInd  Data forward indication
2167  *
2168  *
2169  *  @return  S16
2170  *      -# ROK 
2171  *
2172  */
2173
2174 #ifdef ANSI
2175 PUBLIC S16 pjUtlDlSndDatFwdInd
2176 (
2177 PjCb             *gCb,
2178 PjDlRbCb           *pjRbCb,
2179 PjuDatFwdIndInfo *datFwdInd
2180 )
2181 #else
2182 PUBLIC S16 pjUtlDlSndDatFwdInd(pjRbCb, datFwdInd) 
2183 PjCb             *gCb;
2184 PjDlRbCb           *pjRbCb;
2185 PjuDatFwdIndInfo *datFwdInd;
2186 #endif
2187 {
2188    CmLtePdcpId  *pdcpId;
2189    PjPjuSapCb   *pjuSap;
2190
2191    TRC3(pjUtlDlSndDatFwdInd) 
2192    
2193    RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()");
2194
2195    pjuSap   = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]);
2196    CmLtePdcpId pdcpIdTmp;
2197    pdcpId = &pdcpIdTmp;
2198
2199    if(pdcpId != NULLP)
2200    {
2201       pdcpId->ueId   =  pjRbCb->ueCb->key.ueId;
2202       pdcpId->cellId =  pjRbCb->ueCb->key.cellId;
2203       pdcpId->rbId   =  pjRbCb->rbId;
2204       pdcpId->rbType =  pjRbCb->rbType;
2205       
2206       gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus;
2207       /* If trace flag is enabled send the trace indication */
2208       if(gCb->init.trc == TRUE)
2209       {                       
2210          /* Populate the trace params */
2211          pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP);
2212       }
2213       PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd);
2214    }
2215
2216   RETVALUE(ROK);
2217
2218 }/* end of pjUtlSndDatFwdInd */
2219
2220 /* pj005.201 added support for L2 Measurement */
2221 #ifdef LTE_L2_MEAS
2222 /**
2223  *
2224  * @brief Function to initialise measurement
2225  *
2226  * @b Description
2227  *
2228  * @param[in]  gCb     PDCP Instance Control Block
2229  *
2230  *  @return  Void
2231  *
2232  */
2233 S16 pjUtlL2MeasDlInit(PjCb *gCb)
2234 {
2235    U16   cntr;
2236
2237    gCb->u.dlCb->pjL2Cb.pjNumMeas=0;
2238    for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++)
2239    {
2240       cmMemset((U8 *)&(gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb));
2241    }
2242    gCb->u.dlCb->pjL2Cb.pjL2EvtCb[0].measCb.measType = LPJ_L2MEAS_DL_DISC;
2243
2244    RETVALUE(ROK);
2245 }
2246 \f
2247 /**
2248  *
2249  * @brief Handler for sending L2 Measurement report 
2250  *
2251  * @b Description
2252  *
2253  *  @param[in] gCb          PDCP Instance Control Block. 
2254  *  @param[in] measEvtCb    Measurement Event Control Block.
2255  *
2256  *
2257  *  @return  S16
2258  *      -# ROK
2259  */
2260
2261 #ifdef ANSI
2262 PUBLIC S16 pjUtlSndDlL2MeasCfm
2263 (
2264 PjCb            *gCb,
2265 PjL2MeasEvtCb   *measEvtCb
2266 )
2267 #else
2268 PUBLIC S16 pjUtlSndDlL2MeasCfm(measEvtCb)
2269 PjCb            *gCb;
2270 PjL2MeasEvtCb   *measEvtCb;
2271 #endif
2272 {
2273    PjL2MeasCb     *measCb;
2274    PjL2MeasCfmEvt measCfmEvt;
2275    U8             qciIdx;
2276
2277    TRC3(pjUtlSndDlL2MeasCfm)
2278
2279    measCb = &measEvtCb->measCb;
2280    cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt));
2281    
2282    measCfmEvt.measType = measCb->measType;
2283    measCfmEvt.status.status = LCM_PRIM_OK;
2284    measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
2285    for(qciIdx = 0; qciIdx < (LPJ_MAX_QCI-1); qciIdx++)
2286    {
2287       measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx];
2288       if(measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci > 0)
2289       {
2290          if((measCb->measType & LPJ_L2MEAS_DL_DISC) &&
2291                (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0))
2292          {
2293             /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */
2294             measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = 
2295                measCb->measData[measCb->qci[qciIdx]].dlDisc.val  * (1000000) /
2296                measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts;
2297             /* Reset the counters */
2298             measCb->measData[measCb->qci[qciIdx]].dlDisc.val = 0; 
2299             measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts =0;
2300          }
2301          measCfmEvt.numQciCfm++;
2302       }
2303    }
2304
2305    /* Send Measurement confirmation to layer manager */
2306    PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst,&measCfmEvt);
2307
2308    RETVALUE(ROK);
2309 }
2310 \f
2311
2312 /**
2313  * @brief  Validates the measurement request parameters. 
2314  *
2315  * @details
2316  *
2317  *     Function :pjUtlValidateL2Meas 
2318  *
2319  *  @param[in]  PjL2MeasReqEvt measReqEvt
2320  *  @param[out] PjL2MeasCfmEvt measCfmEvt
2321  **/
2322 /**
2323  *
2324  * @brief Handler for resetting the DL measurement counters 
2325  *
2326  *     Function :pjUtlResetDlL2MeasCntr 
2327  *
2328  * @b Description
2329  *
2330  * @param[in] measCb    Measurement Control Block.
2331  *
2332  *
2333  * @return  Void
2334  */
2335 #ifdef ANSI
2336
2337 PUBLIC Void pjUtlResetDlL2MeasCntr
2338 (
2339 PjCb         *gCb,
2340 PjL2MeasCb   *measCb,
2341 U8           measType
2342 )
2343 #else
2344 PUBLIC Void pjUtlResetDlL2MeasCntr(gCb, measCb, measType)
2345 PjCb         *gCb;
2346 PjL2MeasCb   *measCb;
2347 U8           measType;
2348 #endif
2349 {
2350    /* for now the only meas should be DL discard in this case */
2351    if (measCb->measType & LPJ_L2MEAS_DL_DISC)
2352    {
2353       U32 i;
2354       for(i = 0; i < (LPJ_MAX_QCI - 1); i++)
2355       {
2356          U8 qciVal = measCb->qci[i];
2357
2358          measCb->measData[qciVal].dlDisc.val = 0;
2359          measCb->measData[qciVal].dlDisc.numPkts  = 0;
2360          gCb->u.dlCb->pjL2Cb.measOn[qciVal] &= ~LPJ_L2MEAS_DL_DISC;
2361       }
2362
2363       measCb->numQci = 0;
2364    }
2365 }
2366
2367 /**
2368  *
2369  * @brief Handler for storing address of MeasData in rbCb at right index
2370  *
2371  *
2372  * @b Description
2373  *        This function is called when LM sends measReq message to RLC.
2374  *
2375  *  @param[in] 
2376  *  @param[out] 
2377  *  @param[in] 
2378  *
2379  *
2380  *  @return  S16
2381  *      -# ROK
2382  */
2383 #ifdef ANSI
2384 PUBLIC Void pjUtlPlcMeasDatInDlL2Sts
2385 (
2386 PjL2Cntr       *measData, 
2387 PjL2MeasRbCb   *rbL2Cb,
2388 U8             measType
2389 )
2390 #else
2391 PUBLIC Void pjUtlPlcMeasDatInDlL2Sts(measData, rbL2Cb, measType)
2392 PjL2Cntr       *measData; 
2393 PjL2MeasRbCb   *rbL2Cb;
2394 U8             measType;
2395 #endif
2396 {
2397    TRC3(pjUtlPlcMeasDatInDlL2Sts)
2398    
2399    /* We should check the number of measType in the request. This can be done 
2400     * by looking at each bit in the measType. Also store the measData in the 
2401     * correct index of l2Sts in RbCb.
2402     * */
2403
2404     if(measType & LPJ_L2MEAS_DL_DISC)
2405     {
2406          rbL2Cb->l2Sts[PJ_L2MEAS_DL_DISC] = measData;
2407     }
2408
2409 }/* End of pjUtlPlcMeasDatInDlL2Sts */
2410 #endif /* LTE_L2_MEAS */
2411
2412 void dumpPDCPDlRbInformation(PjDlRbCb* dlRbCb, U16 ueId)
2413 {
2414    PjDlCb* dlCb = &dlRbCb->dlCb;
2415    RLOG_ARG1(L_INFO,DBG_UEID,ueId, "PDCP DL RB numEntries = %lu",
2416                     dlCb->txBuf.numEntries);
2417 #ifndef ALIGN_64BIT
2418    RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %lu",
2419                   ueId, dlCb->txBuf.numEntries);
2420 #else
2421    RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %u",
2422                   ueId, dlCb->txBuf.numEntries);
2423 #endif
2424 }
2425
2426 void DumpPDCPDlDebugInformation(void)
2427 {
2428 #ifndef RGL_SPECIFIC_CHANGES
2429 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
2430    void *iccHdl = NULLP;
2431    U32 poolZeroFreeCnt;
2432    U32 poolOneFreeCnt;
2433    U32 poolTwoFreeCnt;
2434    U32 poolThreeFreeCnt;
2435 #endif   
2436
2437    PjCb* dlInst = pjCb[1]; /* TODO: check whether DL is 0 or 1 */
2438    PjDlgCb* dlgCb = dlInst->u.dlCb;
2439
2440    PjDlUeCb *ueCb = NULLP; 
2441    RLOG0(L_INFO,"PDCP DL Information");
2442    RLOG0(L_INFO,"===================");
2443    RTLIN_DUMP_DEBUG("PDCP DL Information\n");
2444    RTLIN_DUMP_DEBUG("===================\n");
2445    /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
2446    while (ROK == cmHashListGetNext(&dlgCb->ueLstCp, 
2447                                    (PTR) ueCb, 
2448                                    (PTR *)&ueCb))
2449    {
2450       U32 i;
2451       for(i = 0; i < PJ_MAX_SRB_PER_UE; i++)
2452       {
2453          PjDlRbCb* rbCb = ueCb->srbCb[i];
2454          if(rbCb != NULLP)
2455          {
2456             dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId);
2457          }
2458       }
2459       for(i = 0; i < PJ_MAX_DRB_PER_UE; i++)
2460       {
2461          PjDlRbCb* rbCb = ueCb->drbCb[i];
2462          if(rbCb != NULLP)
2463          {
2464             dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId);
2465          }
2466       }
2467    }/* end while */
2468    /*printing ICC memory statistics*/
2469 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
2470    iccHdl = ssGetIccHdl(dlInst->init.region);
2471    if(NULLP != iccHdl)
2472    {
2473       poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE);
2474       poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE);
2475       poolTwoFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE);
2476       poolThreeFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE);
2477       RLOG1(L_ALWAYS,"ICC pool zero free count = %lu", poolZeroFreeCnt);
2478       RLOG1(L_ALWAYS,"ICC pool one free count = %lu", poolOneFreeCnt);
2479       RLOG1(L_ALWAYS,"ICC pool two free count = %lu", poolTwoFreeCnt);
2480       RLOG1(L_ALWAYS,"ICC pool three free count = %lu", poolThreeFreeCnt);
2481       RTLIN_DUMP_DEBUG("ICC pool zero free count = %lu\n", poolZeroFreeCnt);
2482       RTLIN_DUMP_DEBUG("ICC pool one free count = %lu\n", poolOneFreeCnt);
2483       RTLIN_DUMP_DEBUG("ICC pool two free count = %lu\n", poolTwoFreeCnt);
2484       RTLIN_DUMP_DEBUG("ICC pool three free count = %lu\n", poolThreeFreeCnt);
2485    }
2486       /*ccpu00136858 */      
2487    RLOG1(L_ALWAYS,"SPACC cipher Q num of entry = %lu ", pjMsCiphQ.count);
2488    RLOG1(L_ALWAYS,"SPACC decipher Q num of entry = %lu ", pjMsDeCiphQ.count);
2489    RTLIN_DUMP_DEBUG("SPACC cipher Q num of entry = %lu \n", pjMsCiphQ.count);
2490    RTLIN_DUMP_DEBUG("SPACC decipher Q num of entry = %lu \n", pjMsDeCiphQ.count);
2491 #endif
2492 #endif
2493 }
2494
2495 PUBLIC Void pjUtlEmptyDlPktList(PjCb *gCb, PjDlRbCb *pjRbCb)
2496 {
2497    PjDlPkt *ulPkt;
2498    CmLListCp *ulPktLst = &pjRbCb->dlCb.dlPktQ;
2499    while(ulPktLst->first)
2500    {
2501       ulPkt = (PjDlPkt *)(ulPktLst->first->node);
2502       cmLListDelFrm(ulPktLst, ulPktLst->first);
2503       PJ_FREE_BUF(ulPkt->pdu);
2504 #ifdef FLAT_BUFFER_OPT
2505       PJ_FREE_FLAT_BUF(gCb, &(ulPkt->fb))
2506 #endif
2507       PJ_FREE(gCb, ulPkt, sizeof(PjDlPkt));
2508    }
2509    RETVOID;
2510 }
2511
2512 void ResetPDCPStats(void)
2513 {
2514    cmMemset((U8*)&gPdcpStats, 0, sizeof(PDCPStats));
2515 }
2516
2517 #ifndef ALIGN_64BIT
2518 void PrintPDCPStats(void)
2519 {
2520 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
2521    /* UDAY */
2522 #ifdef XEON_SPECIFIC_CHANGES
2523    RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld),"
2524             "Decipher = (%ld)",
2525            gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count);
2526 #else
2527    RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld),"
2528             "Decipher = (%ld)",
2529            gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt);
2530 #endif
2531 #ifdef XEON_SPECIFIC_CHANGES
2532    if((gPdcpStats.numPdcpSdusDiscarded > 0) || (pjMsCiphQ.count > 0) || (pjMsDeCiphQ.count > 0) )
2533    {   
2534       RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%d),"
2535             "SDUs Queued for SPAcc Cipher = (%d), Decipher = (%d)  \n",
2536              gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count); /* UDAY */
2537    }    
2538 #else
2539    RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%ld),"
2540          "SDUs Queued for SPAcc Cipher = (%ld), Decipher = (%ld) Rb Overload DROP = (%ld) dbgPdcpQSizeThreshHoldDropCnt is (%ld) MmThredHldDrp (%ld) spaccQDropCnt (%ld) dlSpaccPktDrop %ld\n",
2541            gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt,dbgPdcpMemCount,dbgPdcpQSizeThreshHoldDropCnt,pdcpdrop, dbgSpaccThreshHoldDropCnt,spaccDropCount); /* UDAY */
2542    dbgPdcpMemCount =0;
2543    dbgPdcpQSizeThreshHoldDropCnt=0;
2544    pdcpdrop = 0;
2545
2546    spaccDropCount = 0;
2547    //pdcpDropMemTh=0;
2548 #endif
2549 #endif
2550 }
2551 #else
2552 void PrintPDCPStats(void)
2553 {
2554    printf ("\n============================== PDCP STATS ===========================\n");
2555    RTLIN_DUMP_DEBUG("SDUs Dropped = (%u) No of Reodering Tmr Exp (%u)",
2556          gPdcpStats.numPdcpSdusDiscarded, gPdcpStats.numPdcpCellReorderTmrExp);
2557 }
2558 #endif
2559
2560 #ifdef ANSI
2561 PRIVATE S16 pjUtlDlHdlSecInitCfm
2562 (
2563 PjCb        *gCb,              /* Pointer to PJ DL Control Block */
2564 PjDlUeCb      *ueCb,           /* Pointer to UeCb */ 
2565 U16         txIdx,             /* Transaction Index for UeCb */
2566 PjAsyncCfm       *asyncCfm,
2567 UdxSecCfgCfmInfo *secCfgCfm,   /* Security config confirm */
2568 UdxReEstCfmInfo  *reEstCfm     /* Reest config confirm */
2569 )
2570 #else
2571 PRIVATE S16 pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,secCfgCfm,reEstCfm)
2572 (                              
2573 PjCb        *gCb;              /* Pointer to PJ DL Control Block */
2574 PjDlUeCb      *ueCb;           /* Pointer to UeCb */ 
2575 U16         txIdx;             /* Transaction Index for UeCb */
2576 PjAsyncCfm       *asyncCfm;
2577 UdxSecCfgCfmInfo *secCfgCfm;   /* Security config confirm */
2578 UdxReEstCfmInfo  *reEstCfm;    /* Reest config confirm */
2579 )
2580 #endif   
2581 {
2582    PjUdxDlSapCb    *udxSap;
2583    S16             ret = ROK;
2584    
2585    TRC3(pjUtlDlHdlSecInitCfm)
2586
2587    if(asyncCfm->libInitBitMask == 0)
2588    {
2589       PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
2590       if(ueCb->libInfo.state == PJ_STATE_NORMAL)
2591       {
2592          /* Send security config confirm */
2593          /* Memory leak fix ccpu00135359 */
2594          udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
2595          PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm,
2596                   sizeof (UdxSecCfgCfmInfo), ret);
2597          if(ret != ROK)
2598          {
2599             RLOG0(L_FATAL, "Memory Allocation failed.");
2600             RETVALUE(RFAILED);
2601          }
2602          PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm);
2603
2604          PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2605
2606          PjDlUdxSecCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
2607                gCb->u.dlCb->udxDlSap[0].suId, 
2608                (UdxSecCfgCfmInfo *) secCfgCfm);
2609       }
2610       else if(ueCb->libInfo.state == PJ_STATE_REEST)
2611       {
2612          /* Send ReEstCfm */
2613          /* Memory leak fix ccpu00135359 */
2614          udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
2615          PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm,
2616                   sizeof (UdxReEstCfmInfo), ret);
2617          if(ret != ROK)
2618          {
2619             RLOG0(L_FATAL, "Memory Allocation failed.");
2620             RETVALUE(RFAILED);
2621          }
2622          PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK);
2623
2624          /* Some house keeping work */
2625          PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2626
2627          PjDlUdxReEstCfm(&gCb->u.dlCb->udxDlSap[0].pst, 
2628                gCb->u.dlCb->udxDlSap[0].suId, reEstCfm);
2629
2630          pjUtlReEstDl(gCb, ueCb);
2631       }
2632    }
2633    RETVALUE(ROK);
2634 }
2635
2636
2637 #ifdef ANSI
2638 PRIVATE S16 pjUtlDlHdlCmpInitCfm
2639 (
2640 PjCb           *gCb,            /* Pointer to PJ DL Control Block */
2641 PjDlUeCb       *ueCb,           /* Pointer to UeCb */ 
2642 U16            txIdx,           /* Transaction Index for UeCb */
2643 PjAsyncCfm     *asyncCfm,       /* Async Confirm */
2644 UdxCfgCfmInfo  *cfgCfm         /* UDX Config Confirm */
2645 )
2646 #else
2647 PRIVATE S16 pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm)
2648 (                              
2649 PjCb           *gCb;            /* Pointer to PJ DL Control Block */
2650 PjDlUeCb       *ueCb;           /* Pointer to UeCb */ 
2651 U16            txIdx;           /* Transaction Index for UeCb */
2652 PjAsyncCfm     *asyncCfm;       /* Async Confirm */
2653 UdxCfgCfmInfo  *cfgCfm;         /* UDX Config Confirm */
2654 )
2655 #endif   
2656 {
2657    PjUdxDlSapCb    *udxSap;
2658    U32             idx;
2659    S16             ret = ROK;
2660    TRC3(pjUtlDlHdlCmpInitCfm)
2661
2662       asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK);
2663
2664    if((asyncCfm->libInitBitMask == 0) &&
2665          !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM))
2666    {
2667
2668       /* Send config confirm */
2669       /* Memory leak fix ccpu00135359 */
2670       udxSap    = &(gCb->u.dlCb->udxDlSap[0]);
2671       PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm,
2672                sizeof (UdxCfgCfmInfo), ret);
2673       if(ret != ROK)
2674       {
2675          RLOG0(L_FATAL, "Memory Allocation failed.");
2676          RETVALUE(RFAILED);
2677       }
2678       cfgCfm->transId = asyncCfm->transId;
2679       cfgCfm->ueId    = asyncCfm->ueId;
2680       cfgCfm->cellId  = asyncCfm->cellId;
2681       cfgCfm->numEnt  = asyncCfm->numEnt; 
2682       for ( idx = 0; idx < asyncCfm->numEnt; idx++ )
2683       {
2684          cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status;  
2685          cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason;  
2686          cfgCfm->cfmEnt[idx].rbId   = asyncCfm->cfmEnt[idx].rbId;
2687          cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType;
2688       }
2689
2690       /* Some house keeping work */
2691       PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx);
2692       PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx);
2693
2694       /* Send confirmtion to the User */
2695       PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), 
2696             gCb->u.dlCb->udxDlSap[0].suId, 
2697             (UdxCfgCfmInfo *)cfgCfm);
2698    }
2699    
2700    RETVALUE(ROK); 
2701 }
2702
2703
2704
2705 #ifdef __cplusplus
2706 }
2707 #endif /* __cplusplus */
2708 /********************************************************************30**
2709          End of file
2710 **********************************************************************/