Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_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                   -- pjUtlIntProtReq
37   
38      File:     pj_utl.c
39
40 **********************************************************************/
41 static const char* RLOG_MODULE_NAME="PDCP";
42 static int RLOG_MODULE_ID=1024;
43 static int RLOG_FILE_ID=231;
44 /** @file pj_utl.c
45 @brief PDCP Utility Module 
46 */
47
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 */
55 #include "cm5.h"           /* common timer defines */
56 #include "cm_tkns.h"       /* common tokens defines */
57 #include "cm_mblk.h"       /* common memory allocation library defines */
58 #include "cm_llist.h"      /* common link list  defines  */
59 #include "cm_hash.h"       /* common hash list  defines */
60 #include "cm_lte.h"        /* common LTE defines */
61 #include "cpj.h"                /* CPJ defines */
62 #include "pju.h"                /* PJU defines */
63 #include "lpj.h"                /* LPJ defines */
64
65 #include "pj_env.h"        /* RLC environment options */
66 #include "pj.h"            /* RLC defines */
67 #include "pj_ul.h"
68 #include "pj_dl.h"
69 #include "pj_err.h"        /* Error defines */
70
71 /* extern (.x) include files */
72 #include "gen.x"           /* general */
73 #include "ssi.x"           /* system services */
74
75 #include "cm5.x"           /* common timer library */
76 #include "cm_tkns.x"       /* common tokens */
77 #include "cm_mblk.x"       /* common memory allocation */
78 #include "cm_llist.x"      /* common link list */
79 #include "cm_hash.x"       /* common hash list */
80 #include "cm_lte.x"        /* common LTE includes */
81 #include "cm_lib.x"        /* common memory allocation library */
82 #include "cpj.x"                /* CPJ */
83 #include "pju.x"                /* PJU */
84 #include "lpj.x"                /* LPJ */
85 #include "pj.x"
86 #include "pj_udx.h"          /* LIB */
87 #include "pj_udx.x"          /* LIB */
88 #include "pj_ul.x"
89 #include "pj_dl.x"
90
91 #include "pj_lib.x"          /* LIB */
92
93 #ifdef __cplusplus
94 EXTERN "C" {
95 #endif /* __cplusplus */
96
97 /** @addtogroup dldata */
98 /*@{*/
99 \f
100 #ifdef PJ_CMP_ASYNC
101 /********************************************************************
102  *    Input Handler from Offboarding unit                           *
103  *******************************************************************/
104 /**
105  *
106  * @brief 
107  *
108  *        Asynchronous handler to received that Init Confirm for 
109  *        compression for the  offboarding unit.
110  *
111  * @b Description:
112  *
113  *        This function gets the context Id passed as the parameter and stores it
114  *        in the RbCb.
115  *
116  *  @param[in]  pst      Post structure 
117  *  @param[in]  cmpCxt   Context for ROHC
118  *  @param[in]  ctxId    Context Id
119  *
120  *  @return  S16
121  *      -# ROK 
122  *
123  */
124 #ifdef ANSI
125 PUBLIC S16 PjLibObdCmpInitCfm
126 (
127 Pst      *pst,                    /* post structure */
128 PjCmpCxt cmpCxt,                  /* Context for ROHC */
129 PTR      ctxId                    /* Compression Context ID */
130 )
131 #else
132 PUBLIC S16 PjLibObdCmpInitCfm(pst, cmpCxt, ctxId)
133 Pst      *pst;                    /* post structure */
134 PjCmpCxt cmpCxt;                  /* Context for ROHC */
135 PTR      ctxId;                   /* Compression Context ID */
136 #endif
137 {                                 
138    PjCb     *tPjCb;
139
140    TRC3(PjLibObdCmpInitCfm);
141    
142    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
143    {
144       RETVALUE (RFAILED);
145    }
146
147    tPjCb = PJ_GET_PJCB(pst->dstInst);
148
149    RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, cmpCxt(%d,%d,%d,%d)"
150            cmpCxt.ueId, cmpCxt.rbId, cmpCxt.rbType, cmpCxt.cfgTxId);
151    RLOG1(L_DEBUG ," ctxId(%ld))",ctxId);
152
153    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
154    {
155       RETVALUE(RFAILED);
156    }
157
158    if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
159    {
160       PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
161       PjUlRbCb   *pjRbCb = NULLP;       /* PDCP RB control block */
162
163       pjDbmFetchUlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb);
164       if(ueCb  == NULLP)
165       {
166          RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"UL UeId[%u] not found",
167             cmpCxt.ueId);
168          RETVALUE(RFAILED);
169       }
170       
171       pjDbmFetchPjUlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb); 
172       if(pjRbCb  == NULLP)
173       {
174          RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId,"CellId[%u]: UL RbId[%d] not found",
175             cmpCxt.cellId, cmpCxt.rbId);
176          RETVALUE(RFAILED);
177       }
178
179       pjRbCb->cmpCxtId  =  ctxId;
180
181       /* Check if all confirms have been received */
182       pjUtlUlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM,  cmpCxt.rbId);
183    }
184    else
185    {
186       PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
187       PjDlRbCb   *pjRbCb = NULLP;       /* PDCP RB control block */
188
189       pjDbmFetchDlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb);
190       if(ueCb  == NULLP)
191       {
192          RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"DL UeId[%u] not found",
193                 cmpCxt.ueId);
194          RETVALUE(RFAILED);
195       }
196
197       pjDbmFetchPjDlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb);
198       if(pjRbCb  == NULLP)
199       {
200          RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId, "CellId[%u]: DL RbId[%d] not found",
201                 cmpCxt.cellId, cmpCxt.rbId);
202          RETVALUE(RFAILED);
203       }
204
205       pjRbCb->cmpCxtId  =  ctxId;
206
207       /* Check if all confirms have been received */
208       pjUtlDlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM,  cmpCxt.rbId);
209    }
210
211
212    RETVALUE(ROK);
213
214 } /* end of PjLibObdCmpInitCfm */
215 #endif /* PJ_SEC_ASYNC */
216
217 #ifdef PJ_SEC_ASYNC
218 /**
219  *
220  * @brief 
221  *
222  *        Asynchronous handler to received that Init Confirm for 
223  *        Integrity for the  offboarding unit.
224  *
225  * @b Description:
226  *
227  *        This function gets the context Id passed as the parameter and stores it
228  *        in the UeCb.
229  *
230  *  @param[in]  pst        Post structure 
231  *  @param[in]  secCxt     Context for Integrity protection/verification 
232  *  @param[in]  ctxId      Integrity Context Id
233  *
234  *
235  *  @return  S16
236  *      -# ROK 
237  *
238  */
239 #ifdef ANSI
240 PUBLIC S16 PjLibObdIntInitCfm
241 (
242 Pst      *pst,                    /* post structure */
243 PjSecCxt secCxt,                  /* Secutiry Context */
244 PTR      ctxId                    /* Integrity Context ID */
245 )
246 #else
247 PUBLIC S16 PjLibObdIntInitCfm(pst, secCxt, ctxId)
248 Pst      *pst;                    /* post structure */
249 PjSecCxt secCxt;                  /* Secutriy Context */
250 PTR      ctxId;                   /* Integrity Context ID */
251 #endif
252 {                                 
253    PjCb     *tPjCb;
254
255    TRC3(PjLibObdIntInitCfm)
256
257    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
258    {
259       RETVALUE (RFAILED);
260    }
261
262    tPjCb = PJ_GET_PJCB(pst->dstInst);
263
264
265    RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
266            secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
267
268    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
269    {
270       RETVALUE(RFAILED);
271    }
272
273    if (tPjCb->pjGenCfg.mode  == LPJ_MODE_PDCP_UL)
274    {
275       PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
276  
277       /* Fetch UeCb */
278       pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
279       if(ueCb  == NULLP)
280       {
281          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
282             secCxt.ueId);
283          RETVALUE(RFAILED);
284       }
285
286       /* Update context Id */
287       ueCb->secInfo.intCxtId = ctxId;
288
289       pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
290                                              PJ_LIB_INT_BIT_MASK);
291    }
292    else
293    {
294       PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
295  
296       /* Fetch UeCb */
297       pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
298       if(ueCb  == NULLP)
299       {
300          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
301             secCxt.ueId);
302          RETVALUE(RFAILED);
303       }
304
305       /* Update context Id */
306       ueCb->secInfo.intCxtId = ctxId;
307
308       pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
309                                              PJ_LIB_INT_BIT_MASK);
310    }
311
312    RETVALUE(ROK);
313
314 } /* end of PjLibObdIntInitCfm */
315 \f
316 /**
317  *
318  * @brief 
319  *
320  *        Asynchronous handler to received that Init Confirm for 
321  *        Ciphering Cp Key  for the  offboarding unit.
322  *
323  * @b Description:
324  *
325  *        This function gets the context Id passed as the parameter and stores it
326  *        in the UeCb.
327  *
328  *  @param[in]  pst        Post structure 
329  *  @param[in]  secCxt     Context for Ciphering 
330  *  @param[in]  ctxId      Ciphering CP Context Id
331  *
332  *  @return  S16
333  *      -# ROK 
334  *
335  */
336 #ifdef ANSI
337 PUBLIC S16 PjLibObdCpInitCfm
338 (
339 Pst      *pst,                    /* post structure */
340 PjSecCxt secCxt,                  /* Secutiry Context */
341 PTR      ctxId                    /* Ciphering Context ID */
342 )
343 #else
344 PUBLIC S16 PjLibObdCpInitCfm(pst, secCxt, ctxId)
345 Pst      *pst;                    /* post structure */
346 PjSecCxt secCxt;                  /* Secutriy Context */
347 PTR      ctxId;                   /* Ciphering Context ID */
348 #endif
349 {
350    PjCb     *tPjCb;
351
352    TRC3(PjLibObdCpInitCfm);
353
354    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
355    {
356       RETVALUE (RFAILED);
357    }
358
359    tPjCb = PJ_GET_PJCB(pst->dstInst);
360
361
362    RLOG4(L_DEBUG, "PjLibObdCpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
363            secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
364
365    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
366    {
367       RETVALUE(RFAILED);
368    }
369
370    if (tPjCb->pjGenCfg.mode  == LPJ_MODE_PDCP_UL)
371    {
372       PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
373  
374       pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
375       if(ueCb  == NULLP)
376       {
377          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
378             secCxt.ueId);
379          RETVALUE(RFAILED);
380       }
381
382       ueCb->secInfo.cpCxtId =  ctxId;
383
384       /* Update bit mask and check if all confirms have been received */
385       pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
386                            (U8)PJ_LIB_CP_CIP_BIT_MASK);
387    }
388    else
389    {
390       PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
391  
392       pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
393       if(ueCb  == NULLP)
394       {
395          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
396             secCxt.ueId);
397          RETVALUE(RFAILED);
398       }
399
400       ueCb->secInfo.cpCxtId =  ctxId;
401
402       /* Update bit mask and check if all confirms have been received */
403       pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
404                            (U8)PJ_LIB_CP_CIP_BIT_MASK);
405    }
406
407    RETVALUE(ROK);
408 } /* end of PjLibObdCpInitCfm */
409
410 /**
411  *
412  * @brief 
413  *
414  *        Asynchronous handler to received that Init Confirm for 
415  *        Ciphering Up Key  for the  offboarding unit.
416  *
417  * @b Description:
418  *
419  *        This function gets the context Id passed as the parameter and stores it
420  *        in the UeCb.
421  *
422  *  @param[in]  pst        Post structure 
423  *  @param[in]  secCxt     Context for Ciphering 
424  *  @param[in]  ctxId      Ciphering UP Context Id
425  *
426  *  @return  S16
427  *      -# ROK 
428  *
429  */
430 #ifdef ANSI
431 PUBLIC S16 PjLibObdUpInitCfm
432 (
433 Pst      *pst,                    /* post structure */
434 PjSecCxt secCxt,                  /* Secutiry Context */
435 PTR      ctxId                    /* Ciphering Context ID */
436 )
437 #else
438 PUBLIC S16 PjLibObdUpInitCfm(pst, secCxt, ctxId)
439 Pst      *pst;                    /* post structure */
440 PjSecCxt secCxt;                  /* Secutriy Context */
441 PTR      ctxId;                   /* Ciphering Context ID */
442 #endif
443 {
444    PjCb     *tPjCb;
445
446    TRC3(PjLibObdUpInitCfm);
447
448    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
449    {
450       RETVALUE (RFAILED);
451    }
452
453    tPjCb = PJ_GET_PJCB(pst->dstInst);
454
455    RLOG4(L_DEBUG, "PjLibObdUpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))",
456            secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId);
457
458    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
459    {
460       RETVALUE(RFAILED);
461    }
462
463    if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)
464    {
465       PjUlUeCb   *ueCb = NULLP;         /* UeCb control block */
466
467       pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
468       if(ueCb  == NULLP)
469       {
470          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found",
471             secCxt.ueId);
472          RETVALUE(RFAILED);
473       }
474
475       ueCb->secInfo.upCxtId =  ctxId;
476
477       /* Update bit mask and check if all confirms have been received */
478       pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
479                         (U8)PJ_LIB_UP_CIP_BIT_MASK);
480    }
481    else
482    {
483       PjDlUeCb   *ueCb = NULLP;         /* UeCb control block */
484
485       pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb);
486       if(ueCb  == NULLP)
487       {
488          RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found",
489             secCxt.ueId);
490          RETVALUE(RFAILED);
491       }
492
493       ueCb->secInfo.upCxtId =  ctxId;
494
495       /* Update bit mask and check if all confirms have been received */
496       pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM,  
497                         (U8)PJ_LIB_UP_CIP_BIT_MASK);
498    }
499
500    RETVALUE(ROK);
501
502 } /* end of PjLibObdUpInitCfm */
503
504 #endif /* PJ_SEC_ASYNC */
505
506 #ifdef PJ_CMP_ASYNC
507 /**
508  *
509  * @brief 
510  *
511  *        Asynchronous handler to receive the compressed SDU from off-board
512  *        entity.
513  *
514  * @b Description:
515  *
516  *        This function receives an output from compression unit and 
517  *        sends the same for ciphering with relevant input paramenters.
518  *
519  *  @param[in]   pst          Post structure 
520  *  @param[in]   cmpCxtId     Context Id for compression 
521  *  @param[in]   libTrans     Transaction Id 
522  *  @param[in]   opSdu        compressed SDU 
523  *
524  *  @return  S16
525  *      -# ROK 
526  *      -# RFAILED
527  *
528  */
529 #ifdef ANSI
530 PUBLIC S16 PjLibObdCmpCfm
531 (
532 Pst        *pst,        /* post structure             */
533 PTR         cmpCxtId,   /* Context Id for compression */
534 PjLibTrans  libTrans,   /* Transaction Id             */
535 Buffer     *opSdu       /* compressed SDU             */
536 )
537 #else
538 PUBLIC S16 PjLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu)
539 Pst        *pst;        /* post structure             */
540 PTR         cmpCxtId;   /* Context Id for compression */
541 PjLibTrans  libTrans;   /* Transaction Id             */
542 Buffer     *opSdu;      /* compressed SDU             */
543 #endif
544 {
545    PjCb        *tPjCb;
546    PjDlRbCb    *pjRbCb;
547    PjTxEnt     *txEnt;
548    S16         ret;
549    U32         macI;          /* MAC-I value to be padded to the PDU */
550    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
551    CmLteRbId rbId;
552
553    TRC3(PjLibObdCmpCfm)
554
555    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
556    {
557       RETVALUE (RFAILED);
558    }
559
560    tPjCb = PJ_GET_PJCB(pst->dstInst);
561
562 #ifdef ALIGN_64BIT
563    RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))",
564            cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
565 #else
566    RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))",
567            cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
568 #endif
569
570    /* If PDCP Layer is not configured and recieved message from Off-board, then
571     * clean the resources recieved and return RFAILED.
572     * Else proceed with processing.*/
573    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
574    {
575       PJ_FREE_BUF(opSdu);
576       RETVALUE(RFAILED);
577    }
578
579    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
580    rbId =  libTrans.rbId + 1;
581    pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
582    if ( pjRbCb == NULLP )
583    {
584       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
585             libTrans.cellId, rbId);
586       PJ_FREE_BUF(opSdu);
587       RETVALUE(RFAILED);
588    }
589    
590    if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
591    {
592       PJ_FREE_BUF(opSdu);
593       RETVALUE(ret);
594    }
595
596    txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), libTrans.count);
597    if ( txEnt == NULLP )
598    {
599       RLOG1(L_ERROR, "txEnt not found for Cnt [%lu]", libTrans.count);
600       PJ_FREE_BUF(opSdu);
601       RETVALUE(RFAILED);
602    }
603    if ( opSdu == NULLP )
604    {
605       RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"Compression Failed , Count [%lu]",  libTrans.count);
606       PJ_UPD_DL_VAR(tPjCb, pjRbCb, txEnt->count);
607       txEnt->sdu = NULLP;
608       if ( pjRbCb->dlCb.cfmReqd)
609       {
610          PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_COMP_FAILED);
611       }
612       else
613       {
614           pjDbmDelTxEnt( tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count);
615       }
616       tPjCb->pjGenSts.numCmpFails++;
617       RETVALUE(RFAILED);
618    }
619
620    txEnt->pdu    = opSdu;
621    if(pjRbCb->ueCb->secInfo.intProtEnbForDrb)
622    {
623       macI   = 0;
624       PJ_PACK_MACI(txEnt->sdu, macI);
625    }
626    if ( pjRbCb->ueCb->secInfo.secAct )
627    {
628       ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt);
629       if ( ret != ROK )
630       {
631          RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"CipherReq Failed , Count [%lu]",  libTrans.count);
632          RETVALUE(RFAILED);
633       }
634 #ifdef PJ_SEC_ASYNC
635       RETVALUE(ret);
636 #endif
637    }
638    ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
639    
640    RETVALUE(ret);
641 } /* end of PjLibObdCmpCfm */
642
643 /**
644  *
645  * @brief 
646  *
647  *        Asynchronous handler to receive the decompressed SDU from off-board
648  *        entity.
649  *
650  * @b Description:
651  *
652  *        This function receives an output from decompression unit and 
653  *        sends the SDU to upper layer in sequence. 
654  *
655  *  @param[in] pst         post structure
656  *  @param[in] cmpCxtId    Context Id for decompression
657  *  @param[in] libTrans    Transaction Id
658  *  @param[in] opSdu       decompressed SDU
659  *  @param[in] fbPkt       Feedback Pkt
660  *
661  *  @return  S16
662  *      -# ROK 
663  *      -# RFAILED
664  *
665  */
666 #ifdef ANSI
667 PUBLIC S16 PjLibObdDecmpCfm
668 (
669 Pst         *pst,                 /* post structure */
670 PTR         cmpCxtId,             /* Context Id for decompression */
671 PjLibTrans  libTrans,             /* Transaction Id */
672 Buffer      *opSdu,               /* decompressed SDU */
673 Buffer      *fbPkt                /* Feedback pkt */
674 )
675 #else
676 PUBLIC S16 PjLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt)
677 Pst         *pst;                 /* post structure */
678 PTR         cmpCxtId;             /* Context Id for decompression */
679 PjLibTrans  libTrans;             /* Transaction Id */
680 Buffer      *opSdu;               /* decompressed SDU */
681 Buffer      *fbPkt;               /* feedback Pkt */
682 #endif
683 {
684    PjCb       *tPjCb;
685    PjUlRbCb   *pjRbCb;
686    PjUlCb     *ulCb;
687    PjRxEnt    *rxEnt;
688
689    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
690    CmLteRbId rbId;
691
692    TRC2(PjLibObdDecmpCfm);
693    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
694    {
695       RETVALUE (RFAILED);
696    }
697
698    tPjCb = PJ_GET_PJCB(pst->dstInst);
699
700 #ifdef ALIGN_64BIT
701    RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))",
702         cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
703 #else
704    RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))",
705        cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
706 #endif
707
708    /* If PDCP Layer is not configured and recieved message from Off-board, then
709     * clean the resources recieved and return RFAILED.
710     * Else proceed with processing.*/
711    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
712    {
713       PJ_FREE_BUF(opSdu);
714       PJ_FREE_BUF(fbPkt);
715       RETVALUE(RFAILED);
716    }
717
718    /* 1. Initialisations */
719    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
720    rbId =  libTrans.rbId + 1;
721    pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
722    if(pjRbCb == NULLP)
723    {
724       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
725             libTrans.cellId, rbId);
726       RETVALUE(RFAILED);
727    }
728    ulCb  =  &pjRbCb->ulCb;
729
730    /* 2. Send the feedback packet */
731    if(fbPkt != NULLP)
732    {
733       pjUtlUlSndUlRohcFdbk(tPjCb,pjRbCb,fbPkt);
734    }
735
736    
737    /* 3. Get the rxEnt */
738    rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count );
739    if((rxEnt == NULLP) || (rxEnt->state != PJ_SENT_TO_DCOMP))
740    {
741       /* We  have got a duplicate . 
742        * It is NULLP if the original has been sent up,
743        * Or, the original is in another state 
744        * (if both are in the same state, we accept the 
745        * first output) */
746       PJ_FREE_BUF(opSdu);
747       RETVALUE(ROK);
748    }
749
750    /* 4. check decompression status */
751    if(opSdu == NULLP)
752    {
753       RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP");
754       PJ_FREE_BUF(opSdu);
755       PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
756       PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails);
757       pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count);
758       pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
759       RETVALUE(RFAILED);
760    }
761
762    /* 5. check for discardable entries */
763    if(rxEnt->discFlag == TRUE)
764    {
765       pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
766       PJ_FREE_BUF(opSdu);
767       RETVALUE(ROK);
768    }
769
770    /* 6. Post decomp updations */
771    rxEnt->state   =  PJ_RDY_TO_SUBMIT;
772    PJ_FREE_BUF(rxEnt->mBuf);
773    rxEnt->mBuf  =  opSdu;
774
775    /* 7. Call the function to deliver the pdu*/
776    PJ_DEC_OBD_COUNT(tPjCb,pjRbCb, rxEnt->count);
777    PJ_ULM_DELIVER_DRB(tPjCb,pjRbCb, rxEnt);
778
779    RETVALUE(ROK);
780 } /* end of PjLibObdDecmpCfm */
781
782 #endif /* PJ_CMP_ASYNC */
783 \f
784 #ifdef PJ_SEC_ASYNC 
785 /**
786  *
787  * @brief 
788  *
789  *        Asynchronous handler to receive the MAC-I from off-board
790  *        entity.
791  *
792  * @b Description:
793  *
794  *        This function receives an output, MAC-I from Integration unit and 
795  *        sends the data for ciphering with relevant input paramenters.
796  *
797  *  @param[in]   pst         Post structure 
798  *  @param[in]   cxtId       Context Id for Integrity protection
799  *  @param[in]   libTrans    Transaction Id 
800  *  @param[in]   macI        Message authentication code 
801  *
802  *  @return  S16
803  *      -# ROK 
804  *      -# RFAILED
805  *
806  */
807 #ifdef ANSI
808 PUBLIC S16 PjLibObdIntProtCfm
809 (
810 Pst      *pst,                    /* post structure */
811 PTR      cxtId,                   /* Context Id for Integrity protection*/
812 PjLibTrans libTrans,              /* Transaction Id */
813 U32      macI                     /* Message authentication code */
814 )
815 #else
816 PUBLIC S16 PjLibObdIntProtCfm(pst, cxtId, libTrans, macI)
817 Pst      *pst;                    /* post structure */
818 PTR      cxtId;                   /* Context Id for Integrity protection */
819 PjLibTrans libTrans;              /* Transaction Id */
820 U32      macI;                    /* Message authentication code */
821 #endif
822 {
823    PjCb    *tPjCb;
824    U8         hdr;
825    PjDlRbCb   *pjRbCb;
826    Buffer   *ciphSdu;
827    S16      ret;
828    U32      count;
829    PjTxEnt  *txEnt;
830    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
831    CmLteRbId rbId;
832   
833    TRC3(PjLibObdIntProtCfm)
834    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
835    {
836       RETVALUE (RFAILED);
837    }
838
839    tPjCb = PJ_GET_PJCB(pst->dstInst);
840
841 #ifdef ALIGN_64BIT
842    RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
843            cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
844 #else
845    RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
846            cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
847 #endif
848
849
850    /* If PDCP Layer is not configured and recieved message from Off-board, then
851     * clean the resources recieved and return RFAILED.
852     * Else proceed with processing.*/
853    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
854    {
855       RETVALUE(RFAILED);
856    }
857    
858    count    = libTrans.count;
859    ret      = ROK;
860    txEnt    = NULLP;
861    ciphSdu  = NULLP;
862    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
863    rbId =  libTrans.rbId + 1;
864    pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
865    if ( pjRbCb == NULLP )
866    {
867       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
868             libTrans.cellId, rbId);
869       RETVALUE(RFAILED);
870    }
871    if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
872    {
873       RETVALUE(ret);
874    }
875
876    txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count);
877    if ( txEnt == NULLP)
878    {
879       RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]",
880             count);
881       RETVALUE(RFAILED);
882    }
883
884
885    PJ_PACK_MACI(txEnt->sdu, macI);
886    
887    ret = SRemPreMsg(&hdr, txEnt->sdu);
888    if ( ret != ROK )
889    {
890       RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"SRemPreMsg failed , Count [%lu]",
891             count);
892       PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count);
893       PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED);
894       pjDbmDelTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count);
895       RETVALUE(RFAILED);
896    }
897     
898    txEnt->pdu = txEnt->sdu;
899
900    if (pjRbCb->firstDlMsg == TRUE && pjRbCb->firstSn == txEnt->sn)
901    {
902       pjRbCb->firstDlMsg = FALSE; 
903       txEnt->sdu = NULLP;
904       ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
905    }
906    else
907    {
908       ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt);
909       if ( ret != ROK )
910       {    
911          RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"CipherReq failed, Count[%lu]",
912                 libTrans.count);
913       } 
914    }
915    
916    RETVALUE(ret);
917
918 } /* end of PjLibObdIntProtCfm */
919
920 /**
921  *
922  * @brief 
923  *
924  *        Asynchronous handler to receive the ciphered SDU from off-board
925  *        entity.
926  *
927  * @b Description:
928  *
929  *        This function receives an output from ciphering unit and 
930  *        sends the PDU to lower layer in sequence.
931  *
932  *  @param[in]   pst              Post structure
933  *  @param[in]   cxtId            Context Id for Ciphering 
934  *  @param[in]   libTrans         Transaction Id 
935  *  @param[in]   opSdu            ciphered SDU 
936  *
937  *  @return  S16
938  *      -# ROK 
939  *      -# RFAILED
940  *
941  */
942 #ifdef ANSI
943 PUBLIC S16 PjLibObdCipherCfm
944 (
945 Pst      *pst,                    /* post structure */
946 PTR      cxtId,                   /* Context Id for Ciphering */
947 PjLibTrans libTrans,              /* Transaction Id */
948 Buffer   *opSdu                   /* ciphered SDU */
949 )
950 #else
951 PUBLIC S16 PjLibObdCipherCfm(pst, cxtId, libTrans, opSdu)
952 Pst      *pst;                    /* post structure */
953 PTR      cxtId;                   /* Context Id for Integrity protection */
954 PjLibTrans libTrans;              /* Transaction Id */
955 Buffer   *opSdu;                  /* ciphered SDU */
956 #endif
957 {
958    PjCb     *tPjCb;
959    PjDlRbCb   *pjRbCb;
960    S16      ret;
961    PjTxEnt  *txEnt;
962    U32      count;
963    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
964    CmLteRbId rbId;
965
966    TRC3(PjLibObdCipherCfm)
967    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
968    {
969       RETVALUE (RFAILED);
970    }
971
972    tPjCb = PJ_GET_PJCB(pst->dstInst);
973
974 #ifdef ALIGN_64BIT
975    RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
976            cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
977 #else
978    RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
979            cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
980 #endif
981
982    count  = libTrans.count;
983    ret    = ROK;
984
985    /* If PDCP Layer is not configured and recieved message from Off-board, then
986     * clean the resources recieved and return RFAILED.
987     * Else proceed with processing.*/
988    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
989    {
990       PJ_FREE_BUF(opSdu);
991       RETVALUE(RFAILED);
992    }
993
994    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
995    rbId =  libTrans.rbId + 1;
996    pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb);
997    if ( pjRbCb == NULLP )
998    {
999       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found",
1000             libTrans.cellId, rbId);
1001       PJ_FREE_BUF(opSdu);
1002       RETVALUE(RFAILED);
1003    }
1004    if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO)
1005    {
1006       PJ_FREE_BUF(opSdu);
1007       RETVALUE(ret);
1008    }
1009    txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count);
1010    if ( txEnt == NULLP )
1011    {
1012       /* Log an error and return */
1013       RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]",
1014             count);
1015       PJ_FREE_BUF(opSdu);
1016       RETVALUE(RFAILED);
1017    }
1018    if ( opSdu == NULLP )
1019    {
1020       RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP");
1021       PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count);
1022       if (!pjRbCb->rohc.hdrCmpUsed)
1023       {
1024          txEnt->sdu = NULLP;
1025       }
1026       if ( pjRbCb->dlCb.cfmReqd)
1027       {
1028          PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_CIPHER_FAILED);
1029       }
1030       else
1031       {
1032          pjDbmDelTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt->count);
1033       }
1034       tPjCb->pjGenSts.numCiphFails++;
1035       RETVALUE(RFAILED);
1036    }
1037
1038    if ( pjRbCb->rohc.hdrCmpUsed )
1039    {
1040       PJ_FREE_BUF(txEnt->pdu);
1041    }
1042    txEnt->pdu = opSdu;
1043    ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt);
1044
1045    RETVALUE(ret);
1046
1047 } /* end of PjLibObdCipherCfm */
1048 /*@}*/
1049
1050 /**
1051  *
1052  * @brief 
1053  *
1054  *        Asynchronous handler to receive the deciphered SDU from off-board
1055  *        entity.
1056  *
1057  * @b Description:
1058  *
1059  *        This function receives an output from deciphering unit and 
1060  *        sends the same for Integrity verification or decompression
1061  *        based on the rbType.
1062  * 
1063  *  @param[in]  pst            Post structure 
1064  *  @param[in]  cxtId          Context Id for Integrity protection
1065  *  @param[in]  libTrans       Transaction Id 
1066  *  @param[in]  opPdu          Deciphered SDU 
1067  *
1068  *  @return  S16
1069  *      -# ROK 
1070  *      -# RFAILED
1071  *
1072  */
1073 #ifdef ANSI
1074 PUBLIC S16 PjLibObdDecipherCfm
1075 (
1076 Pst         *pst,                 /* post structure */
1077 PTR         cxtId,                /* Context Id for Integrity protection*/
1078 PjLibTrans  libTrans,             /* Transaction Id */
1079 Buffer      *opPdu                /* deciphered SDU */
1080 )
1081 #else
1082 PUBLIC S16 PjLibObdDecipherCfm(pst, cxtId, libTrans, opPdu)
1083 Pst         *pst;                 /* post structure */
1084 PTR         cxtId;                /* Context Id for Integrity protection*/
1085 PjLibTrans  libTrans;             /* Transaction Id */
1086 Buffer      *opPdu;               /* deciphered SDU */
1087 #endif
1088 {
1089    PjCb       *tPjCb;
1090    PjUlCb     *ulCb;
1091    PjRxEnt    *rxEnt;
1092    PjUlRbCb     *pjRbCb;
1093    Buffer     *outPdu = NULLP;
1094    S16         ret   =  ROK;
1095    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1096    CmLteRbId rbId;
1097
1098    TRC2(PjLibObdDecipherCfm);
1099
1100    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
1101    {
1102       RETVALUE (RFAILED);
1103    }
1104
1105    tPjCb = PJ_GET_PJCB(pst->dstInst);
1106
1107 #ifdef ALIGN_64BIT
1108    RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))",
1109        cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
1110 #else
1111    RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))",
1112        cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
1113 #endif
1114
1115    /* If PDCP Layer is not configured and recieved message from Off-board, then
1116     * clean the resources recieved and return RFAILED.
1117     * Else proceed with processing.*/
1118    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
1119    {
1120       PJ_FREE_BUF(opPdu);
1121       RETVALUE(RFAILED);
1122    }
1123
1124    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1125    rbId =  libTrans.rbId + 1;
1126    /* 1. Initialisations */
1127     pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); 
1128    if(pjRbCb == NULLP)
1129    {
1130       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
1131             libTrans.cellId, rbId);
1132       PJ_FREE_BUF(opPdu);
1133       PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails);
1134       RETVALUE(RFAILED);
1135    }
1136
1137    ulCb  =  &pjRbCb->ulCb;
1138
1139    /* Validating rxEnt will be done later in code */
1140    rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count);
1141
1142     /* 2. check decipher status */
1143    if( opPdu == NULLP)
1144    {
1145       RLOG_ARG0(L_ERROR, DBG_RBID, rbId,"opPdu is NULL");
1146       PJ_FREE_BUF(opPdu);
1147       PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails);
1148       if ( rxEnt != NULLP )
1149       {
1150          PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
1151          pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count);
1152          pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
1153       }
1154       RETVALUE(RFAILED);
1155    }
1156
1157
1158    /* 3. Check if it is SRB */
1159    if(pjRbCb->rbType == PJ_SRB)
1160    {
1161       /* 3.1 For reestablishment scenarios, discard */
1162       if(pjRbCb->state != PJ_STATE_NORMAL )
1163       {
1164          /* Discard the mBuf */
1165          PJ_FREE_BUF(opPdu);
1166          RETVALUE(ROK);
1167       }
1168       
1169       /* 3.2 Validate the rxEnt */
1170       if(rxEnt == NULLP)
1171       {
1172          RLOG_ARG0(L_ERROR, DBG_RBID,rbId,"rxEnt not found");
1173          PJ_FREE_BUF(opPdu);
1174          PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails);
1175          RETVALUE(RFAILED);
1176       }
1177          
1178       /* 3.3 Post deciphering updations */
1179       rxEnt->state   =  PJ_RDY_TO_INTVER;
1180       PJ_FREE_BUF(rxEnt->mBuf);
1181       rxEnt->mBuf  =  opPdu;
1182
1183       /* 3.4 Send for IntVer. This will be ASYNC  */
1184       ret = pjUlmHdlIntVer(tPjCb,pjRbCb, rxEnt);
1185
1186       RETVALUE(ret);
1187    }
1188    else  /*  DRB */
1189    {
1190
1191       /* 4. Special case, 
1192        * Duplicate entries, can be sent out of order */
1193       if((rxEnt  == NULLP)||
1194          (rxEnt->discFlag == TRUE) ||
1195          (rxEnt->state != PJ_SENT_TO_DCIPHER))
1196       {
1197          /* 4.1 is decompression applicable */
1198          if(pjRbCb->rohc.hdrCmpUsed == TRUE)
1199          {
1200
1201             /* 4.1.1 Calling decompression hook */
1202             if(pjUtlDeCmpReq(tPjCb,pjRbCb, libTrans.count, opPdu, &outPdu) != ROK)
1203             {
1204                RETVALUE(RFAILED);
1205             }
1206
1207 #ifdef PJ_CMP_ASYNC
1208             PJ_FREE_BUF(opPdu);
1209             RETVALUE(ROK);
1210 #endif /* PJ_CMP_ASYNC */
1211          }
1212
1213          /* 4.1.2 discard output and exit */
1214          PJ_FREE_BUF(opPdu);
1215          PJ_FREE_BUF(outPdu);
1216          if((rxEnt != NULLP) &&
1217             (rxEnt->discFlag == TRUE))
1218          {
1219             pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count);
1220          }
1221
1222          RETVALUE(ROK);
1223       }
1224       
1225
1226       /* 5. Post deciphering updations */
1227       rxEnt->state   =  PJ_RDY_TO_SUBMIT;
1228       PJ_FREE_BUF(rxEnt->mBuf);
1229       rxEnt->mBuf  =  opPdu;
1230
1231       /* 6. Submit it for decompression */
1232       pjUlmSubmitForDecmp(tPjCb,pjRbCb, rxEnt);
1233
1234    }/* if(pjRbCb->rbType == PJ_DRB) */
1235
1236    RETVALUE(ROK);
1237
1238 } /* end of PjLibObdDecipherCfm */
1239
1240 /**
1241  *
1242  * @brief 
1243  *
1244  *        Asynchronous handler to receive the status for Integrity verification 
1245  *        from off-board entity.
1246  *
1247  * @b Description:
1248  *
1249  *        This function receives status, success or failure for Integrity
1250  *        verification and sends the data for deciphering with relevant input paramenters.
1251  *
1252  *  @param[in] pst        post structure 
1253  *  @param[in] cxtId      Context Id for Integrity protection
1254  *  @param[in] libTrans   Transaction Id 
1255  *  @param[in] status     Integrity verification status 
1256  *
1257  *  @return  S16
1258  *      -# ROK 
1259  *      -# RFAILED
1260  *
1261  */
1262 #ifdef ANSI
1263 PUBLIC S16 PjLibObdIntVerCfm
1264 (
1265 Pst      *pst,                    /* post structure */
1266 PTR      cxtId,                   /* Context Id for Integrity protection*/
1267 PjLibTrans libTrans,              /* Transaction Id */
1268 Status   status                   /* Integrity verification status */
1269 )
1270 #else
1271 PUBLIC S16 PjLibObdIntVerCfm(pst, cxtId, libTrans, status)
1272 Pst      *pst;                    /* post structure */
1273 PTR      cxtId;                   /* Context Id for Integrity protection */
1274 PjLibTrans libTrans;              /* Transaction Id */
1275 Status   status;                  /* Integrity verification status */
1276 #endif
1277 {
1278    PjCb     *tPjCb;
1279    PjUlRbCb   *pjRbCb;
1280    PjUlCb   *ulCb;
1281    PjRxEnt  *rxEnt;
1282    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1283    CmLteRbId rbId;
1284
1285    TRC2(PjLibObdIntVerCfm)
1286
1287    if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES)
1288    {
1289       RETVALUE (RFAILED);
1290    }
1291
1292    tPjCb = PJ_GET_PJCB(pst->dstInst);
1293
1294 #ifdef ALIGN_64BIT
1295    RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%d))",
1296           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count);
1297 #else
1298    RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%ld))",
1299           cxtId, libTrans.rbId, libTrans.rbType, libTrans.count, status);
1300 #endif
1301    RLOG1(L_DEBUG," status(%d)",status);
1302
1303    /* If PDCP Layer is not configured and recieved message from Off-board, then
1304     * clean the resources recieved and return RFAILED.
1305     * Else proceed with processing.*/
1306    if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE))
1307    {
1308       RETVALUE(RFAILED);
1309    }
1310
1311    /* Initialisations */
1312    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1313    rbId =  libTrans.rbId + 1;
1314    pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); 
1315    if(pjRbCb == NULLP)
1316    {
1317       RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found",
1318             libTrans.cellId, rbId);
1319       PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails);
1320       RETVALUE(RFAILED);
1321    }
1322    ulCb  =  &pjRbCb->ulCb;
1323
1324    /* For reestablishment cases, exit */
1325    if(pjRbCb->state != PJ_STATE_NORMAL)
1326    {
1327       RETVALUE(ROK);
1328    }
1329
1330    /* Get the rxEnt */
1331    rxEnt =  pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count);
1332    if(rxEnt == NULLP)
1333    {
1334       RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "rxEnt not found for Count [%lu]", libTrans.count);
1335       PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails);
1336       PJ_PERFORM_ERR_UPDATES(tPjCb, pjRbCb, libTrans.count);
1337       RETVALUE(RFAILED);
1338    }
1339
1340    /* Validate status */
1341    if(status != ROK)
1342    {
1343       RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "Integrity Verification Failed , Count [%lu]"
1344             , rxEnt->count);
1345       PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt);
1346       PJ_STS_INC_GEN_CNT(tPjCb,numIntgVrfFails);
1347       PJ_PERFORM_ERR_UPDATES(tPjCb,pjRbCb, rxEnt->count);
1348 /*      pjDbmDelRxEnt(&ulCb->recBuf, rxEnt->count); */
1349       RETVALUE(RFAILED);
1350    }
1351
1352    /* Check if next in line for delivery */
1353    rxEnt->state   =  PJ_RDY_TO_SUBMIT;
1354    if(rxEnt->count != ulCb->nxtSubCnt)
1355    {
1356       RETVALUE(ROK);
1357    }
1358
1359    /* Send for delivery */
1360    pjUlmDeliverSrb(tPjCb,pjRbCb, rxEnt);
1361
1362    RETVALUE(ROK);
1363
1364 } /* end of PjLibObdIntVerCfm */
1365 #endif /* PJ_SEC_ASYNC */
1366
1367
1368 /**
1369  *
1370  * @brief 
1371  *
1372  *        Handler for redirecing compression request to either synchronous
1373  *        or asynchronous module.
1374  *
1375  * @b Description:
1376  *
1377  *        This function sends compression request as either synchronous or
1378  *        asynchronous function calls with relevant input parameters.
1379  *
1380  *  @param[in]   pjRbCb         PDCP RbCb 
1381  *  @param[in]   mBuf           SDU to be compressed 
1382  *  @param[in]   opSdu          Compressed SDU 
1383  *  @param[in]   count          COUNT - transaction Id 
1384  *
1385  *  @return  S16
1386  *      -# ROK 
1387  *
1388  */
1389 #ifdef ANSI
1390 PUBLIC S16 pjUtlCmpReq
1391 (
1392 PjCb       *gCb,
1393 PjDlRbCb   *pjRbCb,                 /* PDCP RbCb */
1394 Buffer   *mBuf,                   /* SDU to be compressed */
1395 Buffer   **opSdu,                 /* Compressed SDU */
1396 U32      count                    /* COUNT - transaction Id */
1397 )
1398 #else
1399 PUBLIC S16 pjUtlCmpReq(gCb,pjRbCb, mBuf, opSdu, count)
1400 PjCb       *gCb;
1401 PjDlRbCb   *pjRbCb;                 /* PDCP RbCb */
1402 Buffer   *mBuf;                   /* SDU to be compressed */
1403 Buffer   **opSdu;                 /* Compressed SDU */
1404 U32      count;                   /* COUNT - transaction Id */
1405 #endif
1406 {
1407 #ifdef PJ_CMP_ASYNC
1408    PjLibTrans libTrans; /* Transaction Id for compression */
1409 #endif
1410    S16        ret;
1411
1412    ret = ROK;
1413
1414    TRC3(pjUtlCmpReq)
1415
1416 #ifdef ALIGN_64BIT
1417    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
1418           (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%d))\n",\
1419                     pjRbCb->rbId, pjRbCb->rbType, count));
1420 #else
1421    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
1422           (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%ld))\n",\
1423                     pjRbCb->rbId, pjRbCb->rbType, count));
1424 #endif
1425
1426
1427 #ifdef PJ_CMP_ASYNC
1428    /* Assign transId and cxtId */
1429    libTrans.count  = count;
1430    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1431    libTrans.rbId   = pjRbCb->rbId - 1;
1432    libTrans.rbType = pjRbCb->rbType;
1433    libTrans.ueCb   = (PTR)pjRbCb->ueCb;
1434
1435    /* Start the timer if it is not started already */
1436    if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE)
1437    {
1438       pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR);
1439    }
1440
1441    /* Send to the library */
1442    ret = PjLibObdCmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, 
1443                                                       libTrans, mBuf);  
1444 #else
1445    ret = pjLibCmpReq(pjRbCb->cmpCxtId, mBuf, opSdu);
1446 #endif
1447
1448    RETVALUE(ret);
1449
1450 } /* end of pjUtlCmpReq */
1451
1452
1453
1454 /**
1455  *
1456  * @brief 
1457  *
1458  *        Handler for redirecing decompression request to either synchronous
1459  *        or asynchronous module.
1460  *
1461  * @b Description:
1462  *
1463  *        This function sends decompression protection request as either synchronous or
1464  *        asynchronous function calls with relevant input parameters.
1465  *
1466  *  @param[in]   pjRbCb         PDCP RbCb 
1467  *  @param[in]   mBuf           SDU to be compressed 
1468  *  @param[in]   opSdu          Compressed SDU 
1469  *  @param[in]   count          COUNT - transaction Id 
1470  *
1471  *  @return  S16
1472  *      -# ROK 
1473  *
1474  */
1475 #ifdef ANSI
1476 PUBLIC S16 pjUtlDeCmpReq
1477 (
1478 PjCb       *gCb,
1479 PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
1480 U32      count,                   /* COUNT - transaction Id */
1481 Buffer   *mBuf,                   /* SDU to be compressed */
1482 Buffer   **opSdu                  /* Compressed SDU */
1483 )
1484 #else
1485 PUBLIC S16 pjUtlDeCmpReq(pjRbCb, count, mBuf, opSdu)
1486 PjCb    *gCb;
1487 PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
1488 U32      count;                   /* COUNT - transaction Id */
1489 Buffer   *mBuf;                   /* SDU to be compressed */
1490 Buffer   **opSdu;                 /* Compressed SDU */
1491 #endif
1492 {
1493    S16 ret = ROK;
1494 #ifdef PJ_CMP_ASYNC
1495    PjLibTrans libTrans; /* Transaction Id for compression */
1496 #else
1497    Buffer *feedback  = NULLP;
1498 #endif /* PJ_CMP_ASYNC */
1499
1500    TRC3(pjUtlDeCmpReq)
1501
1502 #ifdef ALIGN_64BIT
1503    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
1504           (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%d))\n",\
1505                     pjRbCb->rbId, pjRbCb->rbType, count));
1506 #else
1507    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), 
1508           (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%ld))\n",\
1509                     pjRbCb->rbId, pjRbCb->rbType, count));
1510 #endif
1511 #ifdef PJ_CMP_ASYNC
1512    /* Assign transId and cxtId */
1513    libTrans.count  = count;
1514    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1515    libTrans.rbId   = pjRbCb->rbId - 1;
1516    libTrans.rbType = pjRbCb->rbType;
1517    libTrans.ueCb   = (PTR)pjRbCb->ueCb;
1518
1519    /* Start the timer if it is not started already */
1520    if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE)
1521    {
1522       pjRbCb->ulCb.obdPdu   =  count;
1523       pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR);
1524    }
1525
1526    ret = PjLibObdDecmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), 
1527                                       pjRbCb->cmpCxtId, libTrans, mBuf);  
1528 #else
1529    ret = pjLibDecmpReq(pjRbCb->cmpCxtId, mBuf, &feedback, opSdu);
1530
1531    if(feedback != NULLP)
1532    {
1533       pjUtlUlSndUlRohcFdbk(gCb,pjRbCb,feedback);
1534    }
1535 #endif
1536
1537    RETVALUE(ret);
1538
1539 } /* end of pjUtlDeCmpReq */
1540
1541
1542 /**
1543  *
1544  * @brief 
1545  *
1546  *        Handler for redirecing compression request to either synchronous
1547  *        or asynchronous module.
1548  *
1549  * @b Description:
1550  *
1551  *        This function sends compression request as either synchronous or
1552  *        asynchronous function calls with relevant input parameters.
1553  *
1554  *  @param[in]   pjRbCb           PDCP RbCb
1555  *  @param[in]   feedback         ROHC Feedback
1556  *
1557  *  @return  S16
1558  *      -# ROK 
1559  *
1560  */
1561 #ifdef ANSI
1562 PUBLIC S16 pjUtlSndFeedback
1563 (
1564 PjCb     *gCb,
1565 PjUlRbCb   *pjRbCb,                 /* PDCP RbCb */
1566 Buffer   *feedback                /* ROHC Feedback */
1567 )
1568 #else
1569 PUBLIC S16 pjUtlSndFeedback(pjRbCb, feedback)
1570 PjCb     *gCb;
1571 PjUlRbCb   *pjRbCb;                 /* PDCP RbCb */
1572 Buffer   *feedback;               /* Feedback */
1573 #endif
1574 {
1575 #ifdef PJ_CMP_ASYNC
1576    PjLibTrans libTrans; /* Transaction Id for compression */
1577 #endif /* PJ_SEC_ASYNC */
1578
1579    TRC3(pjUtlSndFeedback)
1580
1581    RLOG2(L_DEBUG, "pjUtlCmpReq(pjRbCb(%d,%d))",
1582                     pjRbCb->rbId, pjRbCb->rbType);
1583
1584 #ifdef PJ_CMP_ASYNC
1585    /* Assign transId and cxtId */
1586    libTrans.count  = pjRbCb->ulCb.rxDeliv - 1;
1587    /* pj005.201 ccpu00114955 corrected the RB ID calculation */
1588    libTrans.rbId   = pjRbCb->rbId - 1;
1589    libTrans.rbType = pjRbCb->rbType;
1590    libTrans.ueCb   = (PTR)pjRbCb->ueCb;
1591
1592    PjLibObdCmpFbReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, libTrans,
1593          feedback);
1594 #else
1595    pjLibCmpFbReq(pjRbCb->cmpCxtId, feedback);
1596 #endif
1597
1598    RETVALUE(ROK);
1599
1600 } /* end of pjUtlSndFeedback */
1601
1602 /**
1603  *
1604  * @brief 
1605  *
1606  *        Handler for closing the context with the compression unit (either 
1607  *        synchronous or asynchronous) for RB within an UE.
1608  *
1609  * @b Description:
1610  *
1611  *        This function closes an existing context with the compression unit per RB per
1612  *        UE, either using synchronous / asynchronous function calls with relevant input parameters.
1613  *
1614  *
1615  *  @param[in] cmpCxtId         ROHC Context to be closed
1616  *
1617  *  @return  S16
1618  *      -# ROK 
1619  *
1620  */
1621 #ifdef ANSI
1622 PUBLIC S16 pjUtlCmpClose
1623 (
1624 PjCb     *gCb,
1625 PTR      cmpCxtId                 /* ROHC Context to be closed */
1626 )
1627 #else
1628 PUBLIC S16 pjUtlCmpClose(cmpCxtId)
1629 PjCb     *gCb;
1630 PTR      cmpCxtId;                /* ROHC Context to be closed */
1631 #endif
1632 {
1633    TRC3(pjUtlCmpClose)
1634
1635    RLOG1(L_DEBUG, "pjUtlCmpClose(cmpCxtId(%ld))", cmpCxtId);
1636
1637 #ifndef PJ_CMP_ASYNC
1638    pjLibCmpCloseReq(cmpCxtId);
1639 #else
1640    PjLibObdCmpCloseReq(&gCb->pjGenCfg.obdPst.cmpPst, cmpCxtId);
1641 #endif
1642
1643    RETVALUE(ROK);
1644
1645 } /* end of pjUtlCmpClose */
1646
1647
1648
1649 /* pj005.201 added support for L2 Measurement */
1650 #ifdef LTE_L2_MEAS_COMMENT
1651 \f
1652 /**
1653  *
1654  * @brief Handler for L2 Measurement timer expiry.
1655  *
1656  *
1657  * @b Description
1658  *        This function is called when the l2 measurement timer expires. 
1659  *        This function sends a consolidates the mesaurements taken during
1660  *        this time and sends the confirm .
1661  *
1662  *  @param[in] measEvtCb    Measurement Event Control Block.
1663  *
1664  *
1665  *  @return  S16
1666  *      -# ROK
1667  */
1668
1669 #ifdef ANSI
1670 PUBLIC S16 pjUtlHdlL2TmrExp
1671 (
1672 PjL2MeasEvtCb *measEvtCb
1673 )
1674 #else
1675 PUBLIC S16 pjUtlHdlL2TmrExp(measEvtCb)
1676 PjL2MeasEvtCb *measEvtCb;
1677 #endif
1678 {
1679    CmLList        *node;
1680    U32            idx;
1681    PjL2MeasCb     *measCb;
1682    PjL2MeasCfmEvt measCfmEvt;
1683    PjRbCb         *pjRbCb;
1684    PjTxEnt        *txEnt      = NULLP;
1685    U8             qciIdx;
1686
1687    TRC3(pjUtlHdlL2TmrExp)
1688
1689    RLOG1,"pjUtlHdlL2TmrExp(transId(%ld))", measEvtCb->transId);
1690
1691    measCb = &measEvtCb->measCb;
1692    while((node = cmLListFirst(&measCb->rbList)))
1693    {
1694       node = cmLListDelFrm(&measCb->rbList, node);
1695       pjRbCb = (PjRbCb *) node->node;
1696
1697       /* Cleanup any pending buffers which were not acked */
1698       if(measCb->measType & LPJ_L2MEAS_DL_DELAY)
1699       {
1700          for(idx = pjRbCb->rbL2Cb.startCount; idx < pjRbCb->dlCb.count; idx++)
1701          {
1702             if((txEnt = pjDbmGetTxEnt( &(pjRbCb->dlCb.txBuf), idx)) == NULLP)
1703             {
1704                continue;
1705             }
1706             if(txEnt->state != PJ_PDU_SUBMITTED)
1707             {
1708                break;
1709             }
1710             pjDbmDelTxEnt( &(pjRbCb->dlCb.txBuf), idx);
1711          }
1712          pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]   =  NULLP;
1713       }
1714       if(measCb->measType & PJ_L2MEAS_ACT_UE)
1715       {
1716          pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_ACT_UE]   =  NULLP;
1717       }
1718       if(measCb->measType & PJ_L2MEAS_DL_DISC )
1719       {
1720          pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]   =  NULLP;
1721       }
1722       if(measCb->measType & PJ_L2MEAS_UL_LOSS)
1723       {
1724          pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]   =  NULLP;
1725       }
1726     }/* End of while loop */
1727    /* Initialize measCfmEvt */
1728    cmMemset((U8 *) &measCfmEvt, 0, sizeof(PjL2MeasCfmEvt));
1729
1730    measCfmEvt.transId = measEvtCb->transId;
1731    measCfmEvt.numQciCfm = 0;
1732    /* Fill the measCfmEvt structure */
1733    for(qciIdx = 0; qciIdx < measCb->numQci; qciIdx++)
1734    {
1735       pjCb.pjL2Cb.measOn[measCb->qci[qciIdx]] &= ~measCb->measType;
1736       measCfmEvt.measType = measCb->measType;
1737       measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx];
1738       measCfmEvt.status.status = LCM_PRIM_OK;
1739       measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
1740       if((measCb->measType &  LPJ_L2MEAS_DL_DELAY) &&
1741          (measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts > 0))
1742       {
1743          /* Packed delay is in ms */
1744          measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDelay = 
1745          (measCb->measData[measCb->qci[qciIdx]].dlDelay.val / 
1746          measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts);
1747       }
1748       if((measCb->measType & LPJ_L2MEAS_DL_DISC) &&
1749          (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0))
1750       {
1751          /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */
1752          measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = 
1753          measCb->measData[measCb->qci[qciIdx]].dlDisc.val  * (1000000) /
1754          measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts;
1755       }
1756       if((measCb->measType &  LPJ_L2MEAS_UL_LOSS) &&
1757          (measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts > 0))
1758       {
1759          /* ul Loss  = num of Pkts lost * 10^6 / total no of pkts. */
1760          measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss  =
1761          measCb->measData[measCb->qci[qciIdx]].ulLoss.val  * (1000000) /
1762          measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts;
1763       }
1764       measCfmEvt.numQciCfm++;
1765    }
1766
1767    pjCb.pjL2Cb.pjMeasEvtCb[measEvtCb->cbIdx] = NULLP;
1768    PJ_FREE(measEvtCb, sizeof(PjL2MeasEvtCb));
1769    pjCb.pjL2Cb.pjNumMeas--;
1770
1771    /* Send Measurement confirmation to layer manager */
1772    PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst,&measCfmEvt);
1773
1774    RETVALUE(ROK);
1775 } /* pjUtlHdlL2TmrExp */
1776 \f
1777 /**
1778  *
1779  * @brief Handler for Sending Negative confirm .
1780  *
1781  *
1782  * @b Description
1783  *        This function is called when the l2 measurement cannot be started
1784  *        This function sends  negative confirm for all the requests
1785  *
1786  *  @param[in] measReqEvt    Measurement Req Structure
1787  *
1788  *
1789  *  @return  S16
1790  *      -# ROK
1791  */
1792
1793 #ifdef ANSI
1794 PUBLIC S16 pjUtlSndL2MeasNCfm
1795 (
1796 PjL2MeasReqEvt  *measReqEvt,
1797 PjL2MeasCfmEvt  *measCfmEvt
1798 )
1799 #else
1800 PUBLIC S16 pjUtlSndL2MeasNCfm(measReqEvt, measCfmEvt)
1801 PjL2MeasReqEvt  *measReqEvt;
1802 PjL2MeasCfmEvt  *measCfmEvt;
1803 #endif
1804 {
1805
1806    TRC3(pjUtlSndL2MeasNCfm)
1807
1808    RLOG1,"pjUtlSndL2MeasNCfm(transId(%ld))", measReqEvt->transId);
1809
1810    PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst, measCfmEvt);
1811
1812    RETVALUE(ROK);
1813 } /* pjUtlSndL2MeasNCfm */
1814 #endif
1815
1816 #ifdef FLAT_BUFFER_OPT
1817 /**
1818  *
1819  * @brief 
1820  *
1821  *       Handler to move the 'FlatBuffer' into 'Buffer' 
1822  *
1823  * @b Description: 
1824  *
1825  *            
1826  *  @param[in] gCb         Global PDCP control block. 
1827  *  @param[in] FlatBuffer  'FlatBuffer' ptr to be converted. 
1828  *  @param[in_out] Buffer  Output mBuf. 
1829  *
1830  *  @return  S16
1831  *      -# ROK 
1832  *      -# RFAILED
1833  *
1834  */
1835
1836 #ifdef ANSI
1837 PUBLIC S16 pjUtlConvFbToBuf
1838 (
1839 PjCb       *gCb,
1840 FlatBuffer *fb,
1841 Buffer     **mBuf
1842 )
1843 #else
1844 PUBLIC S16 pjUtlConvFbToBuf(gCb, fb, mBuf)
1845 PjCb       *gCb;
1846 FlatBuffer *fb;
1847 Buffer     **mBuf;
1848 #endif
1849 {
1850    S16 ret;
1851
1852    TRC3(pjUtlConvFbToBuf);
1853 #ifdef T2K_MEM_LEAK_DBG
1854    ret = SAttachPtrToBufNew(gCb->init.region,
1855          gCb->init.pool,
1856          fb->ptr,
1857          fb->len,
1858          mBuf,
1859          __FILE__,
1860          __LINE__);
1861 #else
1862    ret = SAttachPtrToBuf(gCb->init.region,
1863          gCb->init.pool,
1864          fb->ptr,
1865          fb->len,
1866          mBuf);
1867
1868 #endif
1869    if(ret != ROK)
1870    {
1871       RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!");
1872    }
1873
1874    RETVALUE(ret);
1875 }
1876
1877
1878 /**
1879  *
1880  * @brief 
1881  *
1882  *       Handler to copy a 'FlatBuffer' to 'Buffer' 
1883  *
1884  * @b Description: 
1885  *
1886  *            
1887  *  @param[in] gCb         Global PDCP control block. 
1888  *  @param[in] FlatBuffer  'FlatBuffer' to be converted. 
1889  *  @param[in_out] Buffer  Output mBuf. 
1890  *
1891  *  @return  S16
1892  *      -# ROK 
1893  *      -# RFAILED
1894  *
1895  */
1896
1897 #ifdef ANSI
1898 PUBLIC S16 pjUtlCopyFbToBuf
1899 (
1900 PjCb       *gCb,
1901 FlatBuffer *fb,
1902 Buffer     **mBuf
1903 )
1904 #else
1905 PUBLIC S16 pjUtlCopyFbToBuf(gCb, fb, mBuf)
1906 PjCb       *gCb;
1907 FlatBuffer *fb;
1908 Buffer     **mBuf;
1909 #endif
1910 {
1911    U8 *opPdu;
1912    S16 ret;
1913
1914    TRC3(pjUtlCopyFbToBuf);
1915 #ifdef INTEL_WLS
1916       SGetSBufWls(gCb->init.region, gCb->init.pool,
1917                   (Data **)&(opPdu), fb->len + 128);
1918    
1919       //cmMemcpy(opPdu + 2, fb->ptr, fb->len);
1920       cmMemcpy(opPdu + 128, fb->ptr, fb->len);
1921
1922       ret = SAttachWlsPtrToMBuf(gCb->init.region,
1923                                 gCb->init.pool,
1924                                 opPdu,
1925                                 opPdu + 128,
1926                                 fb->len,
1927                                 fb->len + 128,
1928                                 mBuf);
1929 #else
1930
1931    if((SGetStaticBuffer(gCb->init.region,
1932                gCb->init.pool,
1933                (Data
1934                 **)&(opPdu),
1935                fb->len,
1936                SS_SHARABLE_MEMORY)
1937             != ROK))
1938    {
1939       RLOG0(L_ERROR,"SGetStaticBuffer failed !!!!!");
1940       RETVALUE(RFAILED);
1941    }
1942
1943    cmMemcpy(opPdu, fb->ptr, fb->len);
1944    /*RLOG1(L_ERROR,"Data forwarding: PDCP SN %d is converted to mBuf",
1945     * txEnt->sn); */
1946 #ifdef T2K_MEM_LEAK_DBG
1947    ret = SAttachPtrToBufNew(gCb->init.region,
1948          gCb->init.pool,
1949          opPdu,
1950          fb->len,
1951          mBuf,
1952          __FILE__,
1953          __LINE__);
1954 #else
1955    ret = SAttachPtrToBuf(gCb->init.region,
1956          gCb->init.pool,
1957          opPdu,
1958          fb->len,
1959          mBuf);
1960 #endif 
1961
1962 #endif
1963    if(ret != ROK)
1964    {
1965       RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!");
1966    }
1967
1968    RETVALUE(ret);
1969 }
1970 #endif
1971
1972 #ifdef __cplusplus
1973 }
1974 #endif /* __cplusplus */
1975 /********************************************************************30**
1976          End of file
1977 **********************************************************************/